1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_03_69_src

Former-commit-id: 4f4cf2e5e767eebd57c07acb242cb4f7d131fa8f
This commit is contained in:
gho tik 2016-05-14 12:45:59 -04:00 committed by Refael ACkermann
parent 82aec03bcd
commit 8425298274
33 changed files with 280 additions and 563 deletions

View File

@ -223,7 +223,7 @@
#define BLOCKPRIORITYCLASS 0x00000020 // blocks attempts to change the process priority class
#define CPUSLOWDOWN 0x00000040 // reduces CPU time dedicated to non time critical threads
#define CPUMAXUSAGE 0x00000080 // reduces CPU time to non time critical threads that consume more than the given ratio
#define NOWINERRORS 0x00000100 // suppress some possible window errors returning OK also in case of failure
// eighth flags DWORD dxw.dwFlags8:
// logging Tflags DWORD:

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c7dbfc11581e871c2b2611baad8c24e7e904c1264771fbddf1ae438805b6817
size 651776
oid sha256:c7943551fe966c9338314466a778a5b8116dbf776047162959a1403ad895a167
size 652800

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a0ffb89088ea50da7077abb29aa298d730841a13f2a8b0e9882b088e0a8290c6
oid sha256:1dfdcf69403a93563f73c0f77084c8c054b570c2c2681aa1323aa5d7d0c70ae0
size 568320

View File

@ -1,6 +1,6 @@
[target]
title0=Microsoft Golf '98 trial (win)
path0=D:\Games\MSGolf98\MSGOLF98\GAME.EXE
title0=Microsoft Golf 1998 Edition
path0=D:\Games\Microsoft Golf 1998 Edition\game.exe
launchpath0=
module0=
opengllib0=
@ -13,10 +13,11 @@ flagg0=-671088640
flagh0=1302
flagi0=1212547076
flagj0=4224
flagk0=67436544
flagl0=4
flagk0=327680
flagl0=260
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=0
@ -27,3 +28,4 @@ winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7
slowratio0=1

View File

@ -0,0 +1,31 @@
[target]
title0=Microsoft Golf 1999 Edition
path0=D:\Games\Microsoft Golf 1999 Edition\game.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98\Version 1.0 Demo]\n"AppPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"InstallType"="1"\n"InstallPath"="D:\\Games\\MSGolf98\\MSGOLF98\\"\n"CDPath"="D:\\Games\\MSGolf98\\MSGOLF98"\n"Launched"="1"\n"PID"=""\n"Path"="D:\\Games\\MSGolf98\\MSGOLF98"\n"VersionType"="TrialVersion"\n"InstalledGroup"="1"\n"LangID"=dword:00000009\n
ver0=0
coord0=0
flag0=136314914
flagg0=-671088640
flagh0=1302
flagi0=1212547076
flagj0=4224
flagk0=327680
flagl0=260
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=0
sizy0=0
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7
slowratio0=1

View File

@ -1,29 +0,0 @@
[target]
title0=Miscrosoft Golf '98 Trial
path0=D:\Games\msgolf\Golf '98 Trial\game.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98]\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Golf '98\Version 1.0 Demo]\n"AppPath"="D:\\Games\\msgolf\\Golf '98 Trial"\n"InstallType"="1"\n"InstalledPath"="D:\\Games\\msgolf\\Golf '98 Trial"\n"CDPath"="D:\\Games\\msgolf\\Golf '98 Trial\\"\n"ITF File Path"="D:\\Games\\msgolf\\Golf '98 Trial\\golf.itf"\n"Launched"="1"\n"PID"=""\n"Path"="D:\\Games\\msgolf\\Golf '98 Trial"\n"VersionType"="TrialVersion"\n"InstalledGroup"="1"\n"LangID"=dword:00000009\n\n\n[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft Games]\n[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft Games\Golf '98]\n[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft Games\Golf '98\Version 1.0 Demo]\n"AppPath"="D:\\Games\\msgolf\\Golf '98 Trial"\n"InstallType"="1"\n"InstalledPath"="D:\\Games\\msgolf\\Golf '98 Trial"\n"CDPath"="D:\\Games\\msgolf\\Golf '98 Trial\\"\n"ITF File Path"="D:\\Games\\msgolf\\Golf '98 Trial\\golf.itf"\n"Launched"="1"\n"PID"=""\n"Path"="D:\\Games\\msgolf\\Golf '98 Trial"\n"VersionType"="TrialVersion"\n"InstalledGroup"="1"\n"LangID"=dword:00000009
ver0=0
coord0=0
flag0=2101474
flagg0=1476395016
flagh0=1044
flagi0=1210187780
flagj0=128
flagk0=327680
flagl0=4
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=880
sizy0=660
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=0

View File

@ -1110,4 +1110,10 @@ fix: GUI placement coordinates are not saved when terminating in minimized or ma
v2.03.68
add: options to limit the cpu usage of program threads, either inconditionally ("CPU slow down") or only for CPU consuming threads ("CPU max usage").
fix: some logging details
fix: some logging details
v2.03.69
fix: fixed "CPU max usage" option
fix: WindowFromPoint & WindowFromPointEx hooks
fix: recovered partilly working implementation of "shared dc" mode
add: "Suppress Win errors" option, needed to skip a blocking error and make "Migrosoft Golf '98" starting

View File

@ -31,7 +31,6 @@ DWORD WINAPI CpuLimit(LPVOID lpThreadParameter)
OutTrace("starting CPULimit dwOwnerPID=%x Ratio=1:%d\n", dwOwnerPID, iSlowDownRatio);
if(!dwOwnerPID) return FALSE;
if(iSlowDownRatio < 1) return FALSE;
//while(TRUE)
return LimitCpuUsage(dwOwnerPID, dwOwnerThread, iSlowDownRatio);
}
@ -63,12 +62,13 @@ BOOL SlowCpuSpeed(DWORD dwOwnerPID, DWORD dwOwnerThread, int iSlowDownRatio)
// and stop each low-priority thread
iThreadIndex = 0;
do {
if((te32.th32OwnerProcessID == dwOwnerPID) && (te32.th32ThreadID != dwOwnerThread)){
if (te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL) {
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
SuspendThread(hThread);
SuspThreads[iThreadIndex++] = hThread;
}
if( (te32.th32OwnerProcessID == dwOwnerPID) &&
(te32.th32ThreadID != dwOwnerThread) &&
(te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL)) {
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
SuspendThread(hThread);
SuspThreads[iThreadIndex++] = hThread;
}
} while(Thread32Next(hThreadSnap, &te32) && (iThreadIndex<MAX_THREAD_ARRAY));
iNumThreads = iThreadIndex;
@ -92,149 +92,195 @@ BOOL SlowCpuSpeed(DWORD dwOwnerPID, DWORD dwOwnerThread, int iSlowDownRatio)
typedef struct{
DWORD tid;
HANDLE hThread;
//ULARGE_INTEGER LastUsed;
DWORD LastUsed;
FILETIME LastUsed;
signed long DeltaUsed;
BOOL Suspended;
} ThreadDesc_Type;
#define DELTA_TIME 2
static FILETIME FTFTSUM(FILETIME a, FILETIME b)
{
FILETIME s;
s.dwHighDateTime = a.dwHighDateTime + b.dwHighDateTime;
__try{ s.dwLowDateTime = a.dwLowDateTime + b.dwLowDateTime;}
__except (EXCEPTION_EXECUTE_HANDLER){ s.dwHighDateTime += 1; }; // add reminder on overflow
return s;
}
static FILETIME FTDWSUM(FILETIME a, DWORD b)
{
FILETIME s;
s.dwHighDateTime = a.dwHighDateTime;
__try{ s.dwLowDateTime = a.dwLowDateTime + b;}
__except (EXCEPTION_EXECUTE_HANDLER){ s.dwHighDateTime += 1; }; // add reminder on overflow
return s;
}
static DWORD DWDIFF(FILETIME a, FILETIME b)
{
// we suppose that the difference can't be greater to 2^sizeof(DWORD), so
// dwHighDateTime values are either identical or 1 greater
DWORD d;
if(a.dwHighDateTime == a.dwHighDateTime)
d = a.dwLowDateTime - b.dwLowDateTime;
else
d = b.dwLowDateTime - a.dwLowDateTime;
return d;
}
//#define DEBUGTRACE 1
static BOOL RefreshThreadList(int *iNumThreads, ThreadDesc_Type ProcessThreads[], DWORD dwOwnerPID, DWORD dwOwnerThread)
{
THREADENTRY32 te32;
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
int iThreadIndex;
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
OutTrace("LimitCpuUsage: refreshing thread list\n");
te32.dwSize = sizeof(THREADENTRY32);
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if(hThreadSnap == INVALID_HANDLE_VALUE) {
OutTrace("LimitCpuUsage: CreateToolhelp32Snapshot ERROR err=%d\n", GetLastError());
return FALSE;
}
// Retrieve information about the first thread, and exit if unsuccessful
if(!Thread32First(hThreadSnap, &te32)){
OutTrace("LimitCpuUsage: Thread32First ERROR err=%d\n", GetLastError()); // Show cause of failure
CloseHandle(hThreadSnap); // Must clean up the snapshot object!
return FALSE;
}
// Now walk the thread list of the system threads,
// and take a snapshot of each target low-priority thread
do {
if( (te32.th32OwnerProcessID == dwOwnerPID) &&
(te32.th32ThreadID != dwOwnerThread) &&
(te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL)) {
// find threads already listed
BOOL IsListed = FALSE;
iThreadIndex = *iNumThreads;
for(int j=0; j<(*iNumThreads); j++){
if(ProcessThreads[j].tid == 0) iThreadIndex=j; // find a list hole, if existing
if(te32.th32ThreadID == ProcessThreads[j].tid){
IsListed = TRUE;
break;
}
}
// if not in the list, add
if(!IsListed){
HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION|THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
if(!GetThreadTimes(hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) continue;
ProcessThreads[iThreadIndex].LastUsed = FTFTSUM(UserTime, KernelTime);
ProcessThreads[iThreadIndex].hThread =hThread;
ProcessThreads[iThreadIndex].tid = te32.th32ThreadID;
ProcessThreads[iThreadIndex].Suspended = FALSE;
#ifdef DEBUGTRACE
OutTrace("Tid[%d]:%x init time=%d\n", iThreadIndex, te32.th32ThreadID, ProcessThreads[iThreadIndex].LastUsed);
#endif
iThreadIndex++;
if(iThreadIndex> *iNumThreads) *iNumThreads = iThreadIndex;
}
}
} while(Thread32Next(hThreadSnap, &te32) && (*iNumThreads<MAX_THREAD_ARRAY-1));
#ifdef DEBUGTRACE
OutTrace("Got %d threads\n", *iNumThreads);
#endif
// Don't forget to clean up the snapshot object.
CloseHandle(hThreadSnap);
return TRUE;
}
BOOL LimitCpuUsage(DWORD dwOwnerPID, DWORD dwOwnerThread, int iSlowDownRatio)
{
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
THREADENTRY32 te32;
ThreadDesc_Type ProcessThreads[MAX_THREAD_ARRAY];
int iThreadIndex, iNumThreads;
int cycle;
int iResumeCount;
DWORD iTimeLimit = 100000;
DWORD iTimeSlot = 100000 / iSlowDownRatio;
FILETIME CreationTime, ExitTime, KernelTime, UserTime;
//ULARGE_INTEGER iKernelTime, iUserTime;
DWORD iKernelTime, iUserTime;
DWORD iTimeLimit = (100000 * DELTA_TIME);
DWORD iTimeSlot = (100000 * DELTA_TIME) /iSlowDownRatio;
OutTrace("LimitCpuUsage: TimeLimit=%ld TimeSlot=%ld\n", iTimeLimit, iTimeSlot);
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32);
for(int i=0; i<MAX_THREAD_ARRAY; i++) {
ProcessThreads[i].LastUsed = 0;
ProcessThreads[i].DeltaUsed = 0;
ProcessThreads[i].Suspended = FALSE;
ProcessThreads[i].hThread = NULL;
ProcessThreads[i].tid = 0;
}
iNumThreads = 0;
for(cycle=0; TRUE; cycle++){
if(cycle == 0){
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if(hThreadSnap == INVALID_HANDLE_VALUE) {
OutTrace("LimitCpuUsage: CreateToolhelp32Snapshot ERROR err=%d\n", GetLastError());
return FALSE;
}
// Retrieve information about the first thread, and exit if unsuccessful
if(!Thread32First(hThreadSnap, &te32)){
OutTrace("LimitCpuUsage: Thread32First ERROR err=%d\n", GetLastError()); // Show cause of failure
CloseHandle(hThreadSnap); // Must clean up the snapshot object!
return FALSE;
}
iThreadIndex = iNumThreads;
// Now walk the thread list of the system threads,
// and take a snapshot of each target low-priority thread
do {
if( (te32.th32OwnerProcessID == dwOwnerPID) &&
(te32.th32ThreadID != dwOwnerThread) &&
(te32.tpBasePri < THREAD_PRIORITY_TIME_CRITICAL)) {
// find threads already listed
BOOL IsListed = FALSE;
for(int j=0; j<iNumThreads; j++){
if(te32.th32ThreadID == ProcessThreads[j].tid){
IsListed = TRUE;
break;
}
}
// if not in the list, add
if(!IsListed){
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION, FALSE, te32.th32ThreadID);
if(!GetThreadTimes(hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) continue;
iUserTime = UserTime.dwLowDateTime;
iKernelTime = KernelTime.dwLowDateTime;
ProcessThreads[iThreadIndex].hThread = hThread;
ProcessThreads[iThreadIndex].LastUsed = iUserTime + iKernelTime;
//OutTrace("Tid[%d]=%x init time=%d\n", iThreadIndex, hThread, ProcessThreads[iThreadIndex].LastUsed);
iThreadIndex++;
}
}
} while(Thread32Next(hThreadSnap, &te32) && (iThreadIndex<MAX_THREAD_ARRAY));
iNumThreads = iThreadIndex;
//OutTrace("Got %d threads\n", iNumThreads);
}
// Don't forget to clean up the snapshot object.
CloseHandle(hThreadSnap);
if(cycle == 0) if(!RefreshThreadList(&iNumThreads, ProcessThreads, dwOwnerPID, dwOwnerThread)) break;
if(cycle > 100) cycle=0; // every 100 cyces forces a thread list refresh
Sleep(DELTA_TIME);
for(iThreadIndex=0; iThreadIndex<iNumThreads; iThreadIndex++) {
ThreadDesc_Type *t = &ProcessThreads[iThreadIndex];
if (t->DeltaUsed > (signed long)iTimeLimit) {
#ifdef DEBUGTRACE
OutTrace("Tid[%d]:%x delta=%d stopped at %d\n", iThreadIndex, t->tid, t->DeltaUsed, __LINE__);
#endif
if ((iResumeCount=SuspendThread(t->hThread))== -1) {
t->tid = NULL;
CloseHandle(t->hThread);
continue;
}
t->Suspended = TRUE;
t->DeltaUsed -= iTimeSlot;
}
}
Sleep(iSlowDownRatio);
for(iThreadIndex=0; iThreadIndex<iNumThreads; iThreadIndex++) {
ThreadDesc_Type *t = &ProcessThreads[iThreadIndex];
if (t->hThread == NULL) continue; // skip terminated ones
if(!GetThreadTimes(t->hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) {
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
if (t->tid == NULL) continue; // skip terminated ones
if (t->Suspended) {
t->DeltaUsed -= iTimeSlot;
//OutTrace("Tid[%d]=%x suspended delta=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if(t->DeltaUsed < 0) {
if (ResumeThread(t->hThread)== -1){
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
t->Suspended = FALSE;
#ifdef DEBUGTRACE
OutTrace("Tid[%d]=%x delta=%d started at %d\n", iThreadIndex, t->tid, t->DeltaUsed, __LINE__);
#endif
if ((iResumeCount=ResumeThread(t->hThread))== -1) {
t->tid = NULL;
CloseHandle(t->hThread);
continue;
}
t->Suspended = FALSE;
t->DeltaUsed -= iTimeSlot;
}
else {
iUserTime = UserTime.dwLowDateTime;
iKernelTime = KernelTime.dwLowDateTime;
t->DeltaUsed = t->DeltaUsed + (iUserTime + iKernelTime) - t->LastUsed;
t->LastUsed = iUserTime + iKernelTime;
//OutTrace("Tid[%d]=%x active delta=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if (t->DeltaUsed > (signed long)iTimeLimit) {
//OutTrace("Tid[%d]=%x stopped last=%ld\n", iThreadIndex, t->hThread, t->DeltaUsed);
if (SuspendThread(t->hThread)== -1) {
//OutTrace("Tid[%d]=%x died at %d\n", iThreadIndex, t->hThread, __LINE__);
//CloseHandle(t->hThread);
t->hThread = NULL;
continue;
}
t->Suspended = TRUE;
t->DeltaUsed -= iTimeSlot;
}
if(!GetThreadTimes(t->hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) {
t->tid = NULL;
CloseHandle(t->hThread);
continue;
}
FILETIME tmp = t->LastUsed;
t->LastUsed = FTFTSUM(UserTime, KernelTime);
t->DeltaUsed = t->DeltaUsed + DWDIFF(t->LastUsed, tmp);
#ifdef DEBUGTRACE
OutTrace("Tid[%d]:%x delta=%d measured at %d\n", iThreadIndex, t->tid, t->DeltaUsed, __LINE__);
#endif
}
}
}
// should never go here ....
OutTrace("end of cycle\n");
for(int i=0; i<MAX_THREAD_ARRAY; i++) {
HANDLE hThread = ProcessThreads[i].hThread;
if(hThread){
if(ProcessThreads[i].Suspended) ResumeThread(hThread);
CloseHandle(hThread);
}
Sleep(1);
}
// should never go here, but in case, awake all suspended threads
for(iThreadIndex=0; iThreadIndex<iNumThreads; iThreadIndex++) {
ThreadDesc_Type *t = &ProcessThreads[iThreadIndex];
if (t->tid && t->Suspended) {
ResumeThread(t->hThread);
}
}
return TRUE;
}

View File

@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "TlHelp32.h"
#define VERSION "2.03.68"
#define VERSION "2.03.69"
#define DDTHREADLOCK 1
//#define LOCKTHREADS

Binary file not shown.

View File

@ -21,7 +21,6 @@
extern HandleDDThreadLock_Type pReleaseDDThreadLock;
extern GetDC_Type pGetDCMethod();
extern ReleaseDC_Type pReleaseDCMethod();
//void setClippingRegion(HDC, HDC, HWND, bool, const POINT&);
/*---------------------------------------------------------------------------------+
| |
@ -192,8 +191,8 @@ HDC dxwSDC::GetPrimaryDC(HDC hdc)
origin.y -= mainwin.y;
OutTraceB("dxwSDC::GetPrimaryDC: origin=(%d,%d)\n", origin.x, origin.y);
copyDcAttributes(VirtualHDC, hdc, origin);
setClippingRegion(VirtualHDC, hdc, dxw.GethWnd(), FALSE, origin); // no good
copyDcAttributes(VirtualHDC, hdc, origin);
setClippingRegion(VirtualHDC, hdc, origin);
return VirtualHDC;
}
@ -369,60 +368,77 @@ void dxwSDC::copyDcAttributes(HDC destDC, HDC origDc, POINT origin)
typedef struct
{
HDC compatDc;
POINT origin;
HWND rootWnd;
} ExcludeClipRectsData_Type;
static BOOL CALLBACK excludeClipRectForOverlappingWindow(HWND hwnd, LPARAM lParam)
static BOOL CALLBACK excludeClipRectsForOverlappingWindows(HWND hwnd, LPARAM lParam)
{
ExcludeClipRectsData_Type *excludeClipRectsData = (ExcludeClipRectsData_Type *)lParam;
if (hwnd == excludeClipRectsData->rootWnd) return FALSE;
if (!IsWindowVisible(hwnd)) return TRUE;
RECT windowRect = {};
GetWindowRect(hwnd, &windowRect);
HRGN windowRgn = (*pCreateRectRgnIndirect)(&windowRect);
ExtSelectClipRgn(excludeClipRectsData->compatDc, windowRgn, RGN_DIFF);
DeleteObject(windowRgn);
OutTraceB("dxwSDC::excludeClipRect: hwnd=%x rect=(%d,%d)-(%d,%d)\n", hwnd, windowRect.left, windowRect.top, windowRect.right, windowRect.bottom);
if (!IsWindowVisible(hwnd)) return TRUE; // go ahead
if (hwnd == excludeClipRectsData->rootWnd) return FALSE; // stop
if(dxw.IsDesktop(hwnd)) return FALSE;
RECT rect = {};
(*pGetClientRect)(hwnd, &rect);
OffsetRect(&rect, -excludeClipRectsData->origin.x, -excludeClipRectsData->origin.y);
ExcludeClipRect(excludeClipRectsData->compatDc, rect.left, rect.top, rect.right, rect.bottom);
OutTraceB("dxwSDC::excludeClipRects: hwnd=%x rect=(%d,%d)-(%d,%d)\n", hwnd, rect.left, rect.top, rect.right, rect.bottom);
return TRUE;
}
static void excludeClipRectsForOverlappingWindows(HWND hwnd, BOOL isMenuWindow, HDC compatDc)
void dxwSDC::setClippingRegion(HDC compatDc, HDC origDc, POINT origin)
{
ExcludeClipRectsData_Type excludeClipRectsData = { compatDc, GetAncestor(hwnd, GA_ROOT) };
if (!isMenuWindow){
EnumWindows(&excludeClipRectForOverlappingWindow, (LPARAM)(&excludeClipRectsData));
OutTraceB("dxwSDC::setClippingRegion: compdc=%x origdc=%x origin=(%d,%d)\n", compatDc, origDc, origin.x, origin.y);
HRGN clipRgn = CreateRectRgn(0, 0, 0, 0);
const bool isEmptyClipRgn = (1 != GetRandomRgn(origDc, clipRgn, SYSRGN));
OutTraceB("dxwSDC::setClippingRegion: isEmptyClipRgn=%x\n", isEmptyClipRgn);
// scale clip region
POINT upleft={0, 0};
//(*pClientToScreen)(dxw.GethWnd(), &upleft);
(*pClientToScreen)(CurrenthWnd, &upleft);
if(IsDebug){
OutTraceB("dxwSDC::setClippingRegion: upleft=(%d,%d)\n", upleft.x, upleft.y);
}
HWND menuWindow = FindWindow((LPCSTR)(0x8000), NULL);
while (menuWindow && menuWindow != hwnd){
excludeClipRectForOverlappingWindow(menuWindow, (LPARAM)(&excludeClipRectsData));
menuWindow = FindWindowEx(NULL, menuWindow, (LPCSTR)(0x8000), NULL);
OffsetRgn(clipRgn, -upleft.x, -upleft.y);
if(IsDebug){
RECT RgnBox;
GetRgnBox(clipRgn, &RgnBox);
OutTraceB("dxwSDC::setClippingRegion: RgnBox=(%d,%d)-(%d,%d) size=(%dx%d)\n",
RgnBox.left, RgnBox.top, RgnBox.right, RgnBox.bottom, RgnBox.right-RgnBox.left, RgnBox.bottom-RgnBox.top);
}
}
void dxwSDC::setClippingRegion(HDC compatDc, HDC origDc, HWND hwnd, bool isMenuWindow, const POINT& origin)
{
HRGN clipRgn = (*pCreateRectRgn)(0, 0, 0, 0);
if (1 == GetClipRgn(origDc, clipRgn)){
OffsetRgn(clipRgn, origin.x, origin.y);
SelectClipRgn(compatDc, clipRgn);
}
if ((hwnd) && (dxw.dwFlags7 & FIXCLIPPERAREA)){
if (isMenuWindow || 1 != GetRandomRgn(origDc, clipRgn, SYSRGN)){
RECT rect = {};
(*pGetWindowRect)(hwnd, &rect);
(*pSetRectRgn)(clipRgn, rect.left, rect.top, rect.right, rect.bottom);
}
excludeClipRectsForOverlappingWindows(hwnd, isMenuWindow, compatDc);
ExtSelectClipRgn(compatDc, clipRgn, RGN_AND);
}
// end of scaling
SelectClipRgn(compatDc, isEmptyClipRgn ? NULL : clipRgn);
DeleteObject(clipRgn);
SetMetaRgn(compatDc);
HRGN origClipRgn = (*pCreateRectRgn)(0, 0, 0, 0);
if (1 == GetClipRgn(origDc, origClipRgn))
{
OutTraceB("dxwSDC::setClippingRegion: GetClipRgn==1\n");
OffsetRgn(origClipRgn, origin.x, origin.y);
ExtSelectClipRgn(compatDc, origClipRgn, RGN_AND);
if(IsDebug){
RECT RgnBox;
GetRgnBox(origClipRgn, &RgnBox); // for logging only
OutTraceB("dxwSDC::setClippingRegion: OrigRgnBox=(%d,%d)-(%d,%d)\n", RgnBox.left, RgnBox.top, RgnBox.right, RgnBox.bottom);
}
}
DeleteObject(origClipRgn);
if(dxw.dwFlags7 & FIXCLIPPERAREA){
// to finish .....
// on Win10 this part seems unnecessary and giving troubles .....
if (!isEmptyClipRgn){
OutTraceB("dxwSDC::setClippingRegion: isEmptyClipRgn FALSE\n");
HWND hwnd = WindowFromDC(origDc);
if (hwnd && (!dxw.IsDesktop(hwnd))){
ExcludeClipRectsData_Type excludeClipRectsData = { compatDc, origin, dxw.GethWnd() };
//ExcludeClipRectsData_Type excludeClipRectsData = { compatDc, origin, GetAncestor(hwnd, GA_ROOT) };
OutTraceB("dxwSDC::setClippingRegion: compatdc=%x origin=(%d,%d) ancestor=%x\n",
compatDc, origin.x, origin.y, dxw.GethWnd());
EnumWindows(&excludeClipRectsForOverlappingWindows,(LPARAM)(&excludeClipRectsData));
}
}
}
}

View File

@ -26,7 +26,7 @@ public: // methods
private:
void copyDcAttributes(HDC, HDC, POINT);
void setClippingRegion(HDC, HDC, HWND, bool, const POINT &);
void setClippingRegion(HDC, HDC, POINT);
HDC PrimaryDC;
HDC VirtualHDC;

View File

@ -2636,6 +2636,7 @@ BOOL WINAPI extDestroyWindow(HWND hWnd)
// v2.02.43: "Empire Earth" builds test surfaces that must be destroyed!
// v2.03.20: "Prince of Persia 3D" destroys the main window that must be preserved!
BOOL res;
OutTraceB("DestroyWindow: hwnd=%x\n", hWnd);
if (hWnd == dxw.GethWnd()) {
if(dxw.dwFlags6 & NODESTROYWINDOW) {
@ -2651,6 +2652,8 @@ BOOL WINAPI extDestroyWindow(HWND hWnd)
}
res=(*pDestroyWindow)(hWnd);
if(!res)OutTraceE("DestroyWindow: ERROR err=%d\n", GetLastError());
if(dxw.dwFlags7 & NOWINERRORS) return TRUE; // v2.03.69: suppress unessential errors
return res;
}
@ -3132,14 +3135,12 @@ BOOL WINAPI extGetCursorInfo(PCURSORINFO pci)
return ret;
}
// --- to be hooked ....
HWND WINAPI extWindowFromPoint(POINT Point)
{
HWND ret;
OutTraceDW("WindowFromPoint: point=(%d,%d)\n", Point.x, Point.y);
if(dxw.IsFullScreen()){
dxw.UnmapWindow(&Point);
dxw.MapWindow(&Point); // v2.03.69 fix
OutTraceDW("WindowFromPoint: FIXED point=(%d,%d)\n", Point.x, Point.y);
}
ret = (*pWindowFromPoint)(Point);
@ -3152,7 +3153,7 @@ HWND WINAPI extChildWindowFromPoint(HWND hWndParent, POINT Point)
HWND ret;
OutTraceDW("ChildWindowFromPoint: hWndParent=%x point=(%d,%d)\n", hWndParent, Point.x, Point.y);
if(dxw.IsDesktop(hWndParent) && dxw.IsFullScreen() && dxw.Windowize){
dxw.UnmapClient(&Point);
dxw.MapClient(&Point);
OutTraceDW("ChildWindowFromPoint: FIXED point=(%d,%d)\n", Point.x, Point.y);
}
ret = (*pChildWindowFromPoint)(hWndParent, Point);

View File

@ -1,29 +0,0 @@
[target]
title0=Betrayal in Antara
path0=D:\Games\Betrayal in Antara\ANTARAR.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,29 +0,0 @@
[target]
title0=Blood 2 the Chosen
path0=D:\Games\Blood2\CLIENT.EXE
launchpath0=D:\Games\Blood2\BLOOD2.EXE
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136315042
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=1200
sizy0=900
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,29 +0,0 @@
[target]
title0=Bugs Bunny Lost In Time
path0=D:\Games\Bugs.Bunny.Lost.In.Time\bin\bugs.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=7
coord0=0
flag0=681574434
flagg0=1209139200
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=98304
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,29 +0,0 @@
[target]
title0=Gooka The Mystery of Janatris
path0=D:\Games\Gooka The Mystery of Janatris\Gooka\gooka2.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136315394
flagg0=1207959552
flagh0=20
flagi0=138412038
flagj0=4224
flagk0=268500992
flagl0=8
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,30 +0,0 @@
[target]
title0=NHL 2002
path0=D:\Games\NHL 2002\nhl2002.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=7
coord0=0
flag0=681574499
flagg0=1476395008
flagh0=528
flagi0=136314884
flagj0=1073746048
flagk0=327680
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,35 +0,0 @@
[target]
title0=No Respect (1.1)
path0=D:\Games\No Respect\nr11.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=327680
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
flagl0=0
flagm0=0
maxddinterface0=7

View File

@ -1,32 +0,0 @@
[target]
title0=No Respect
path0=D:\Games\No Respect\NR.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=327680
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0

View File

@ -1,29 +0,0 @@
[target]
title0=Phantasmagoria 2
path0=D:\Games\Phantasmagoria 2\SIERRAW.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,29 +0,0 @@
[target]
title0=Silver
path0=D:\Games\Silver\silver.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314998
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=268500992
flagl0=0
flagm0=0
tflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,30 +0,0 @@
[target]
title0=The Hobbit(TM) Demo
path0=D:\Games\The Hobbit(TM) Demo\MeridianDemo.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=8
coord0=0
flag0=136315426
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,30 +0,0 @@
[target]
title0=Urban Chaos
path0=D:\Games\Urban Chaos\fallen.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -1,30 +0,0 @@
[target]
title0=Weird War
path0=D:\Games\Weird War\WeirdWar.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=4224
flagk0=65536
flagl0=0
flagm0=0
tflag0=0
dflag0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1
swapeffect0=0
maxddinterface0=7

View File

@ -36,6 +36,7 @@ void CTabSysLibs::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_FIXCLIPPERAREA, cTarget->m_FixClipperArea);
DDX_Check(pDX, IDC_CREATEDESKTOP, cTarget->m_CreateDesktop);
DDX_Check(pDX, IDC_SYNCPALETTE, cTarget->m_SyncPalette);
DDX_Check(pDX, IDC_NOWINERRORS, cTarget->m_NoWinErrors);
// OpenGL
DDX_Check(pDX, IDC_HOOKOPENGL, cTarget->m_HookOpenGL); // duplicated

View File

@ -224,6 +224,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_FixClipperArea = FALSE; // ??
m_CreateDesktop = FALSE;
m_SyncPalette = FALSE;
m_NoWinErrors = FALSE;
m_AnalyticMode = FALSE;
m_NoPaletteUpdate = FALSE;
m_WireFrame = FALSE;

View File

@ -179,6 +179,7 @@ public:
BOOL m_FixClipperArea;
BOOL m_CreateDesktop;
BOOL m_SyncPalette;
BOOL m_NoWinErrors;
BOOL m_AnalyticMode;
BOOL m_NoPaletteUpdate;
BOOL m_LimitResources;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -446,6 +446,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_FixClipperArea) t->flags7 |= FIXCLIPPERAREA;
if(dlg->m_CreateDesktop) t->flags6 |= CREATEDESKTOP;
if(dlg->m_SyncPalette) t->flags6 |= SYNCPALETTE;
if(dlg->m_NoWinErrors) t->flags7 |= NOWINERRORS;
if(dlg->m_AnalyticMode) t->flags3 |= ANALYTICMODE;
if(dlg->m_ReplacePrivOps) t->flags5 |= REPLACEPRIVOPS;
t->posx = dlg->m_PosX;
@ -706,6 +707,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_FixClipperArea = t->flags7 & FIXCLIPPERAREA ? 1 : 0;
dlg->m_CreateDesktop = t->flags6 & CREATEDESKTOP ? 1 : 0;
dlg->m_SyncPalette = t->flags6 & SYNCPALETTE ? 1 : 0;
dlg->m_NoWinErrors = t->flags7 & NOWINERRORS ? 1 : 0;
dlg->m_AnalyticMode = t->flags3 & ANALYTICMODE ? 1 : 0;
dlg->m_ReplacePrivOps = t->flags5 & REPLACEPRIVOPS ? 1 : 0;
dlg->m_PosX = t->posx;

Binary file not shown.