diff --git a/build/dxwnd.dll b/build/dxwnd.dll
index 8538e43..1220791 100644
--- a/build/dxwnd.dll
+++ b/build/dxwnd.dll
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:3a374cec9f980973164610e2661704aa5658ea7e19901b5e61aa72207c7624b3
+oid sha256:e285a1e111688d9564456ef3cba3955cbf10fd56e711280c3da2c5028c4b734e
size 660480
diff --git a/build/dxwnd.exe b/build/dxwnd.exe
index 90384f5..c993d91 100644
--- a/build/dxwnd.exe
+++ b/build/dxwnd.exe
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:d041afd6e18a75dc3b7316a913318827696603e87d9f8e6a06da4da57ccdbf53
-size 643072
+oid sha256:45173c58df52cbfe63834fb949adf1dc91809a0fce0acdad63069e1c7a20d71a
+size 642560
diff --git a/build/dxwnd.ini b/build/dxwnd.ini
deleted file mode 100644
index 999b7b8..0000000
--- a/build/dxwnd.ini
+++ /dev/null
@@ -1,41 +0,0 @@
-[target]
-title0=Mechwarrior 3 (high res)
-path0=D:\Games\Mechwarrior 3 - RIP\Mech3.exe
-launchpath0=
-module0=
-opengllib0=
-notes0=
-registry0=\n[HKEY_LOCAL_MACHINE\Software]\n[HKEY_LOCAL_MACHINE\Software\MicroProse]\n[HKEY_LOCAL_MACHINE\Software\MicroProse\MechWarrior 3 EP1]\n[HKEY_LOCAL_MACHINE\Software\MicroProse\MechWarrior 3 EP1\1.0]\n"Program"="..\\"\n"Version"="1.0"\n"InstallOptions"=dword:00050707\n\n[HKEY_LOCAL_MACHINE\Software\Microsoft]\n[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay]\n[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay\Applications]\n[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay\Applications\MechWarrior 3 EP1]\n"Guid"="{FA96C421-18DD-11D3-95AF-0060089877F0}"\n"File"="Mech3.exe"\n"CommandLine"="\n"Path"=".\\"\n"CurrentDirectory"=".\\"\n\n[HKEY_CURRENT_USER\Software]\n[HKEY_CURRENT_USER\Software\MicroProse]\n[HKEY_CURRENT_USER\Software\MicroProse\MechWarrior 3]\n[HKEY_CURRENT_USER\Software\MicroProse\MechWarrior 3\1.0]\n"InGameVMode"=dword:0000000a
-ver0=0
-coord0=0
-flag0=136331398
-flagg0=1207959552
-flagh0=9236
-flagi0=1277165574
-flagj0=4224
-flagk0=65600
-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
-slowratio0=1
-title1=Mechwarrior 3 (high res)
-module1=
-opengllib1=
-dflag1=0
-[window]
-posx=915
-posy=519
-sizx=320
-sizy=200
-exportpath=D:\DxWnd\exports.ok\
diff --git a/build/exports/Dethkarz.dxw b/build/exports/Dethkarz.dxw
new file mode 100644
index 0000000..1c2b3bb
--- /dev/null
+++ b/build/exports/Dethkarz.dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Dethkarz
+path0=D:\Games\Dethkarz\Dethkarz.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=On Win7, FORCECLIPPER is requested\nOn Win10, FORCECLIPPER is not necessary and may cause program crash:\neither unckeck FORCECLIPPER or check HANDLEEXCEPTIONS seems to fix the problem
+registry0=
+ver0=0
+coord0=0
+flag0=679477282
+flagg0=1207959552
+flagh0=8212
+flagi0=138416132
+flagj0=1073741952
+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=3
+swapeffect0=0
+maxddinterface0=7
+slowratio0=2
diff --git a/build/exports/End of Twilight.dxw b/build/exports/End of Twilight.dxw
new file mode 100644
index 0000000..62704aa
--- /dev/null
+++ b/build/exports/End of Twilight.dxw
@@ -0,0 +1,31 @@
+[target]
+title0=End of Twilight
+path0=D:\Games\End of Twilight\bin\mol.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=136314914
+flagg0=1744830464
+flagh0=20
+flagi0=138412036
+flagj0=4224
+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
+slowratio0=2
diff --git a/build/exports/GP 500.dxw b/build/exports/GP 500.dxw
new file mode 100644
index 0000000..c72a1b9
--- /dev/null
+++ b/build/exports/GP 500.dxw
@@ -0,0 +1,31 @@
+[target]
+title0=GP 500
+path0=D:\Games\gp500\gp500_win2k.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=681590834
+flagg0=1744830464
+flagh0=20
+flagi0=138412036
+flagj0=4224
+flagk0=-2147418110
+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
+slowratio0=2
diff --git a/build/exports/Hot Chix 'n' Gear Stix (demo).dxw b/build/exports/Hot Chix 'n' Gear Stix (demo).dxw
new file mode 100644
index 0000000..2e8e92a
--- /dev/null
+++ b/build/exports/Hot Chix 'n' Gear Stix (demo).dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Hot Chix 'n' Gear Stix (demo)
+path0=D:\Games\Hot Chix 'n' Gear Stix\HotChix.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=136314914
+flagg0=1749024768
+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
+slowratio0=2
diff --git a/build/exports/MoonBase Commander (640x480).dxw b/build/exports/MoonBase Commander (640x480).dxw
new file mode 100644
index 0000000..d5379ac
--- /dev/null
+++ b/build/exports/MoonBase Commander (640x480).dxw
@@ -0,0 +1,31 @@
+[target]
+title0=MoonBase Commander
+path0=D:\Games\MoonBase Commander\Moonbase.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=-2011168734
+flagg0=1744830464
+flagh0=20
+flagi0=138416132
+flagj0=4224
+flagk0=65536
+flagl0=0
+flagm0=0
+tflag0=0
+dflag0=0
+posx0=50
+posy0=50
+sizx0=640
+sizy0=480
+maxfps0=0
+initts0=0
+winver0=0
+maxres0=3
+swapeffect0=0
+maxddinterface0=7
+slowratio0=2
diff --git a/build/exports/SuperChix'76 (demo).dxw b/build/exports/SuperChix'76 (demo).dxw
new file mode 100644
index 0000000..cf365fc
--- /dev/null
+++ b/build/exports/SuperChix'76 (demo).dxw
@@ -0,0 +1,31 @@
+[target]
+title0=SuperChix'76 (demo)
+path0=*\HotChix2.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=203423778
+flagg0=1207959552
+flagh0=532
+flagi0=138412036
+flagj0=134221952
+flagk0=65536
+flagl0=8
+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
+slowratio0=4
diff --git a/build/exports/Tone Rebellion Leviathan.dxw b/build/exports/Tone Rebellion Leviathan.dxw
new file mode 100644
index 0000000..9b819cd
--- /dev/null
+++ b/build/exports/Tone Rebellion Leviathan.dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Tone Rebellion Leviathan
+path0=D:\Games\Tone Rebellion\FLOAT.EXE
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=-2011168734
+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
+slowratio0=2
diff --git a/build/exports/Totò Sapore e il magico sapore della pizza.dxw b/build/exports/Totò Sapore e il magico sapore della pizza.dxw
new file mode 100644
index 0000000..c0a42dc
--- /dev/null
+++ b/build/exports/Totò Sapore e il magico sapore della pizza.dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Totò Sapore e il magico sapore della pizza
+path0=D:\Program Files (x86)\Totò Sapore\Artematica.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=136314914
+flagg0=1207959552
+flagh0=20
+flagi0=134217732
+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
+slowratio0=2
diff --git a/build/exports/Warlords Battlecry 3 (GOG).dxw b/build/exports/Warlords Battlecry 3 (GOG).dxw
new file mode 100644
index 0000000..e9c53d2
--- /dev/null
+++ b/build/exports/Warlords Battlecry 3 (GOG).dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Warlords Battlecry 3 (GOG)
+path0=D:\Games\Warlords Battlecry 3 (GOG)\Battlecry III.exe
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=136314914
+flagg0=1207959552
+flagh0=20
+flagi0=134217732
+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
+slowratio0=2
diff --git a/build/exports/Yu No (english patch).dxw b/build/exports/Yu No (english patch).dxw
new file mode 100644
index 0000000..246637a
--- /dev/null
+++ b/build/exports/Yu No (english patch).dxw
@@ -0,0 +1,31 @@
+[target]
+title0=Yu No (english patch)
+path0=D:\Games\Yu no\Classics\YUNO\AI5ENG.EXE
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+coord0=0
+flag0=681574432
+flagg0=1207959552
+flagh0=20
+flagi0=138412036
+flagj0=8392832
+flagk0=67436544
+flagl0=4
+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
+slowratio0=2
diff --git a/build/exports/dxwnd.reg b/build/exports/dxwnd.reg
new file mode 100644
index 0000000..0bf1cd1
--- /dev/null
+++ b/build/exports/dxwnd.reg
@@ -0,0 +1,19 @@
+
+[HKEY_LOCAL_MACHINE\Software]
+[HKEY_LOCAL_MACHINE\Software\MicroProse]
+[HKEY_LOCAL_MACHINE\Software\MicroProse\MechWarrior 3 EP1]
+[HKEY_LOCAL_MACHINE\Software\MicroProse\MechWarrior 3 EP1\1.0]
+"Program"="..\\"
+"Version"="1.0"
+"InstallOptions"=dword:00050707
+
+[HKEY_LOCAL_MACHINE\Software\Microsoft]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay\Applications]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectPlay\Applications\MechWarrior 3 EP1]
+"Guid"="{FA96C421-18DD-11D3-95AF-0060089877F0}"
+"File"="Mech3.exe"
+"CommandLine"="
+"Path"=".\\"
+"CurrentDirectory"=".\\"
+
diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt
index 77974b2..f595b46 100644
--- a/build/readme-relnotes.txt
+++ b/build/readme-relnotes.txt
@@ -1158,4 +1158,14 @@ fix: DC leakage caused by CreateCompatibleDC. Fix "Mechwarrior 3" repeated play
add: GUI drag & drop of game executables
fix: RegQueryValueEx bad retcode when Data ptr is NULL
fix: recovered support for Windows XP
-fix: fake registry did not read last registry line! Fixed.
\ No newline at end of file
+fix: fake registry did not read last registry line! Fixed.
+
+v2.03.76
+fix: DC handle leakage in several places, this also fixed GDI "emulated devie context" mode.
+fix: FillRect wrapper, fixed coordinate remapping with wrong values. Fixes "Imperialism" menu and detailed view.
+fix: suppressed "reuse emulated DC" flag: it was no longer referenced in the code.
+fix: workaround for occasional DDERR_INVALIDPARAMS error in service GetDisplayMode to detect current video mode.
+fix: code cleanup: eliminated CREATEDESKTOP handling, experimental and no longer supported
+fix: vdxcore::IsToRemap now detects the NULL dc handle as remappable DC
+fix: some logging imperfections
+fix: palette log message crashing the program
\ No newline at end of file
diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp
index 98909f8..5c7c093 100644
--- a/dll/ddraw.cpp
+++ b/dll/ddraw.cpp
@@ -2052,6 +2052,16 @@ HRESULT WINAPI extSetDisplayMode(int dxversion, LPDIRECTDRAW lpdd,
case 7: ddsd.dwSize=sizeof(LPDDSURFACEDESC2); res=(*pGetDisplayMode7)(lpdd, &ddsd); break;
}
+ if(res){
+ OutTraceE("SetDisplayMode: GetDisplayMode err=%x(%s)\n", res, ExplainDDError(res));
+ // fix for Win10 platform returning DDERR_INVALIDPARAMS
+ RECT desktop;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ (*pGetClientRect)((*pGetDesktopWindow)(), &desktop);
+ ddsd.dwWidth = desktop.right;
+ ddsd.dwHeight = desktop.bottom;
+ }
+
OutTraceB("SetDisplayMode: detected screen size=(%dx%d)\n", ddsd.dwWidth, ddsd.dwHeight);
if(dxw.Windowize){
@@ -2074,7 +2084,7 @@ HRESULT WINAPI extSetDisplayMode(int dxversion, LPDIRECTDRAW lpdd,
case 4: res=(*pSetDisplayMode4)(lpdd, dwwidth, dwheight, dwbpp, ddsd.dwRefreshRate, 0); break;
case 7: res=(*pSetDisplayMode7)(lpdd, dwwidth, dwheight, dwbpp, ddsd.dwRefreshRate, 0); break;
}
- if(res) OutTraceE("SetDisplayMode: error=%x\n", res);
+ if(res) OutTraceE("SetDisplayMode: error=%x(%s)\n", res, ExplainDDError(res));
SetVSyncDelays(dxversion, lpdd);
// set a default palette ???
diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp
index 4a8d6e9..032d69e 100644
--- a/dll/dxhook.cpp
+++ b/dll/dxhook.cpp
@@ -121,7 +121,7 @@ static char *Flag6Names[32]={
"FIXPITCH", "POWER2WIDTH", "HIDETASKBAR", "ACTIVATEAPP",
"NOSYSMEMPRIMARY", "NOSYSMEMBACKBUF", "CONFIRMONCLOSE", "TERMINATEONCLOSE",
"FLIPEMULATION", "SETZBUFFERBITDEPTHS", "SHAREDDC", "WOW32REGISTRY",
- "STRETCHMOVIES", "BYPASSMCI", "FIXPIXELZOOM", "REUSEEMULATEDDC",
+ "STRETCHMOVIES", "BYPASSMCI", "FIXPIXELZOOM", "---REUSEEMULATEDDC---",
"CREATEDESKTOP", "NOWINDOWHOOKS", "SYNCPALETTE", "VIRTUALJOYSTICK",
"UNACQUIRE", "HOOKGOGLIBS", "BYPASSGOGLIBS", "EMULATERELMOUSE",
};
@@ -1359,21 +1359,11 @@ void HookInit(TARGETMAP *target, HWND hwnd)
if(dxw.dwFlags4 & ENABLEHOTKEYS) dxw.MapKeysInit();
}
- if(dxw.dwFlags6 & CREATEDESKTOP){
- RECT TargetPos;
- TargetPos.left = target->posx;
- TargetPos.right = target->posx+target->sizx;
- TargetPos.top = target->posy;
- TargetPos.bottom = target->posy+target->sizy;
- if (!hDesktopWindow) hDesktopWindow=CreateVirtualDesktop(&TargetPos);
- }
-
if(IsTraceDW){
char sInfo[1024];
OSVERSIONINFO osinfo;
strcpy(sInfo, "");
- if(hwnd) sprintf(sInfo, " hWnd=%x(hdc=%x) dxw.hParentWnd=%x(hdc=%x) desktop=%x(hdc=%x)",
- hwnd, GetDC(hwnd), dxw.hParentWnd, GetDC(dxw.hParentWnd), GetDesktopWindow(), GetDC(GetDesktopWindow()));
+ if(hwnd) sprintf(sInfo, " hWnd=%x ParentWnd=%x desktop=%x", hwnd, dxw.hParentWnd, GetDesktopWindow());
OutTrace("HookInit: path=\"%s\" module=\"%s\" dxversion=%s pos=(%d,%d) size=(%d,%d)%s\n",
target->path, target->module, dxversions[dxw.dwTargetDDVersion],
target->posx, target->posy, target->sizx, target->sizy, sInfo);
@@ -1438,14 +1428,6 @@ void HookInit(TARGETMAP *target, HWND hwnd)
}
}
- if(dxw.dwFlags6 & CREATEDESKTOP){
- if (hDesktopWindow){
- OutTraceDW("HookInit: set new parent=%x to main win=%x\n", hDesktopWindow, dxw.hChildWnd);
- SetParent(dxw.hChildWnd, hDesktopWindow);
- dxw.hParentWnd = hDesktopWindow;
- }
- }
-
#ifdef CHECKFORCOMPATIBILITYFLAGS
CheckCompatibilityFlags(); // v2.02.83 Check for change of OS release
#endif
diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp
index 6b0281c..932d251 100644
--- a/dll/dxwcore.cpp
+++ b/dll/dxwcore.cpp
@@ -78,6 +78,7 @@ BOOL dxwCore::IsFullScreen()
BOOL dxwCore::IsToRemap(HDC hdc)
{
+ if(!hdc) return TRUE;
return (Windowize && FullScreen && (OBJ_DC == (*pGetObjectType)(hdc)));
}
@@ -483,12 +484,11 @@ void dxwCore::SethWnd(HWND hwnd)
hWnd=hwnd;
hWndFPS=hwnd;
- RealHDC=(*pGDIGetDC)(hwnd);
if(hwnd){
(*pGetWindowRect)(hwnd, &WinRect);
- OutTraceDW("SethWnd: setting main win=%x hdc=%x pos=(%d,%d)-(%d,%d)\n",
- hwnd, RealHDC, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom);
+ OutTraceDW("SethWnd: setting main win=%x pos=(%d,%d)-(%d,%d)\n",
+ hwnd, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom);
}
else{
OutTraceDW("SethWnd: clearing main win\n");
@@ -1454,13 +1454,13 @@ void dxwCore::ShowBanner(HWND hwnd)
POINT PrevViewPort;
int StretchMode;
- hClientDC=(*pGDIGetDC)(hwnd);
- (*pGetClientRect)(hwnd, &client);
- (*pGDIBitBlt)(hClientDC, 0, 0, client.right, client.bottom, NULL, 0, 0, BLACKNESS);
-
if(JustOnce || (dwFlags2 & NOBANNER)) return;
JustOnce=TRUE;
+ hClientDC=(*pGDIGetDC)(hwnd);
+ (*pGetClientRect)(hwnd, &client);
+ (*pGDIBitBlt)(hClientDC, 0, 0, client.right, client.bottom, NULL, 0, 0, BLACKNESS);
+
g_hbmBall = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BANNER));
HDC hdcMem = CreateCompatibleDC(hClientDC);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hbmBall);
@@ -1493,6 +1493,7 @@ void dxwCore::ShowBanner(HWND hwnd)
(*pSetViewportOrgEx)(hClientDC, PrevViewPort.x, PrevViewPort.y, NULL);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
+ (*pGDIReleaseDC)(hwnd, hClientDC);
Sleep(200);
}
@@ -1597,7 +1598,8 @@ HDC dxwCore::AcquireEmulatedDC(HWND hwnd)
HDC wdc;
RECT WinRect;
- if(!(wdc=(*pGDIGetDC)(hwnd))){
+ if(RealHDC) (*pGDIReleaseDC)(WindowFromDC(RealHDC), RealHDC); // fixed DC leakage
+ if(!(wdc=(*pGDIGetDC)(hwnd))){ // potential DC leakage
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
return NULL;
}
@@ -1659,14 +1661,16 @@ BOOL dxwCore::ReleaseEmulatedDC(HWND hwnd)
WinRect.left, WinRect.top, WinRect.right, WinRect.bottom,
VirtualPicRect.left, VirtualPicRect.top, VirtualPicRect.right, VirtualPicRect.bottom);
- if(!(wdc=(*pGDIGetDC)(hwnd)))
+ if(!(wdc=(*pGDIGetDC)(hwnd))) // potential DC leakage
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
- SetStretchBltMode(wdc, HALFTONE);
+ SetStretchBltMode(VirtualHDC, HALFTONE);
if(!(*pGDIStretchBlt)(wdc, 0, 0, WinRect.right, WinRect.bottom, VirtualHDC, 0, 0, VirtualPicRect.right, VirtualPicRect.bottom, SRCCOPY))
OutTraceE("StretchBlt: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
//(*pInvalidateRect)(hwnd, NULL, 0);
+ (*pGDIReleaseDC)(hwnd, wdc); // fixed DC leakage
(*pGDIReleaseDC)(hwnd, VirtualHDC);
+ VirtualHDC=NULL; // no longer valid
return TRUE;
}
diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp
index 0e8435e..e6cda92 100644
--- a/dll/dxwnd.cpp
+++ b/dll/dxwnd.cpp
@@ -27,7 +27,7 @@ along with this program. If not, see .
#include "TlHelp32.h"
-#define VERSION "2.03.75.fix1"
+#define VERSION "2.03.76"
#define DDTHREADLOCK 1
//#define LOCKTHREADS
diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo
index e5024e0..00dad54 100644
Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ
diff --git a/dll/gdi32.cpp b/dll/gdi32.cpp
index 7867f9a..96e9359 100644
--- a/dll/gdi32.cpp
+++ b/dll/gdi32.cpp
@@ -798,7 +798,7 @@ UINT WINAPI extGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries,
ret = nEntries;
OutTraceDW("GetSystemPaletteEntries: FIXED ret=%d\n", ret);
}
- if(IsDebug) dxw.DumpPalette(nEntries, &lppe[iStartIndex]);
+ if(IsDebug) dxw.DumpPalette(nEntries, lppe);
return ret;
}
@@ -819,7 +819,7 @@ UINT WINAPI extGetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT nEntries,
res = nEntries;
OutTraceDW("GDI.GetPaletteEntries: faking missing entries=%d\n", res);
}
- if(IsDebug && res) dxw.DumpPalette(res, &lppe[iStartIndex]);
+ if(IsDebug && res) dxw.DumpPalette(res, lppe);
//mySetPalette(0, nEntries, lppe);
return res;
}
@@ -928,19 +928,15 @@ HDC WINAPI extGDICreateCompatibleDC(HDC hdc)
OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc);
if(hdc==0){
- hdc=(*pGDIGetDC)(dxw.GethWnd());
+ hdc=(*pGDIGetDC)(dxw.GethWnd()); // potential DC leakage
bSwitchedToMainWin = TRUE;
- if(dxw.dwFlags6 & CREATEDESKTOP){
- extern HWND hDesktopWindow;
- hdc=(*pGDIGetDC)(hDesktopWindow);
- }
OutTraceDW("GDI.CreateCompatibleDC: duplicating win HDC hWnd=%x\n", dxw.GethWnd());
}
// eliminated error message for errorcode 0.
SetLastError(0);
RetHdc=(*pGDICreateCompatibleDC)(hdc);
- if(bSwitchedToMainWin) (*pGDIReleaseDC)(dxw.GethWnd(),hdc);
+ if(bSwitchedToMainWin) (*pGDIReleaseDC)(dxw.GethWnd(),hdc); // fixed DC leakage
LastError=GetLastError();
if(LastError == 0){
OutTraceDW("GDI.CreateCompatibleDC: returning HDC=%x\n", RetHdc);
@@ -2644,6 +2640,8 @@ int WINAPI extAddFontResourceW(LPCWSTR lpszFontFile)
BOOL WINAPI extGDISetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
{
BOOL res;
+ BOOL bRemappedDC = FALSE;
+
OutTraceDW("SetPixelFormat: hdc=%x PixelFormat=%d Flags=%x PixelType=%x(%s) ColorBits=%d RGBdepth=(%d,%d,%d) RGBshift=(%d,%d,%d)\n",
hdc, iPixelFormat,
ppfd->dwFlags, ppfd->iPixelType, ppfd->iPixelType?"PFD_TYPE_COLORINDEX":"PFD_TYPE_RGBA", ppfd->cColorBits,
@@ -2658,10 +2656,12 @@ BOOL WINAPI extGDISetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDES
//}
if(dxw.IsDesktop(WindowFromDC(hdc))){
HDC oldhdc = hdc;
- hdc=(*pGDIGetDC)(dxw.GethWnd());
+ hdc=(*pGDIGetDC)(dxw.GethWnd()); // potential DC leakage
+ bRemappedDC = TRUE;
OutTraceDW("SetPixelFormat: remapped desktop hdc=%x->%x hWnd=%x\n", oldhdc, hdc, dxw.GethWnd());
}
res=(*pGDISetPixelFormat)(hdc, iPixelFormat, ppfd);
+ if(bRemappedDC) (*pGDIReleaseDC)(dxw.GethWnd(), hdc); // fixed DC leakage
dxw.ActualPixelFormat.dwRGBBitCount = ppfd->cColorBits;
if(!res) OutTraceE("SetPixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
return res;
@@ -2670,15 +2670,18 @@ BOOL WINAPI extGDISetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDES
int WINAPI extGDIGetPixelFormat(HDC hdc)
{
int res;
+ BOOL bRemappedDC = FALSE;
OutTraceDW("GetPixelFormat: hdc=%x\n", hdc);
if(dxw.IsDesktop(WindowFromDC(hdc))){
HDC oldhdc = hdc;
- hdc=(*pGDIGetDC)(dxw.GethWnd());
+ hdc=(*pGDIGetDC)(dxw.GethWnd()); // potential DC leakage
+ bRemappedDC = TRUE;
OutTraceDW("GetPixelFormat: remapped desktop hdc=%x->%x hWnd=%x\n", oldhdc, hdc, dxw.GethWnd());
}
res=(*pGDIGetPixelFormat)(hdc);
if(!res) OutTraceE("GetPixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
else OutTraceDW("GetPixelFormat: res=%d\n", res);
+ if(bRemappedDC)(*pGDIReleaseDC)(dxw.GethWnd(), hdc); // fixed DC leakage
return res;
}
diff --git a/dll/user32.cpp b/dll/user32.cpp
index 2e34e3d..7837e07 100644
--- a/dll/user32.cpp
+++ b/dll/user32.cpp
@@ -1301,11 +1301,6 @@ HWND WINAPI extGetDesktopWindow(void)
OutTraceDW("GetDesktopWindow: FullScreen=%x\n", dxw.IsFullScreen());
if (dxw.IsFullScreen()){
- if(dxw.dwFlags6 & CREATEDESKTOP){
- extern HWND hDesktopWindow;
- OutTraceDW("GetDesktopWindow: returning desktop emulated hwnd=%x\n", hDesktopWindow);
- return hDesktopWindow;
- }
OutTraceDW("GetDesktopWindow: returning main window hwnd=%x\n", dxw.GethWnd());
return dxw.GethWnd();
}
@@ -1515,14 +1510,6 @@ static HWND WINAPI extCreateWindowCommon(
dwStyle &= ~WS_MAXIMIZE;
}
- if(dxw.dwFlags6 & CREATEDESKTOP){
- extern HWND hDesktopWindow;
- if (dxw.IsRealDesktop(hWndParent)){
- OutTraceE("%s: new parent win %x->%x\n", ApiName, hWndParent, hDesktopWindow);
- hWndParent=hDesktopWindow;
- }
- }
-
// v2.1.92: fixes size & position for auxiliary big window, often used
// for intro movies etc. : needed for ......
// evidently, this was supposed to be a fullscreen window....
@@ -1890,12 +1877,18 @@ static int HandleRect(char *ApiName, void *pFun, HDC hdc, const RECT *lprc, HBRU
RECT client;
HWND hwnd;
hwnd=WindowFromDC(hdc);
- (*pGetClientRect)(hwnd, &client);
- if(rc.left < 0) rc.left=0;
- if(rc.top < 0) rc.top=0;
- if(rc.right > client.right) rc.right=client.right;
- if(rc.bottom > client.bottom) rc.bottom=client.bottom;
- OutTraceDW("%s: remapped hdc from hwnd=%x to rect=(%d,%d)-(%d,%d)\n", ApiName, hwnd, rc.left, rc.top, rc.right, rc.bottom);
+ // v2.03.76 fix: sometimes WindowFromDC returns NULL with unpredictable results
+ // if NULL, try to bount within the main window rect
+ if(!hwnd) hwnd=dxw.GethWnd();
+ // if still NULL, avoid doing changes
+ if(hwnd){
+ (*pGetClientRect)(hwnd, &client);
+ if(rc.left < client.left) rc.left=client.left;
+ if(rc.top < client.top) rc.top=client.top;
+ if(rc.right > client.right) rc.right=client.right;
+ if(rc.bottom > client.bottom) rc.bottom=client.bottom;
+ OutTraceDW("%s: remapped hdc from hwnd=%x to rect=(%d,%d)-(%d,%d)\n", ApiName, hwnd, rc.left, rc.top, rc.right, rc.bottom);
+ }
}
res=(*(FillRect_Type)pFun)(hdc, &rc, hbr);
@@ -1909,7 +1902,7 @@ int WINAPI extFillRect(HDC hdc, const RECT *lprc, HBRUSH hbr)
int WINAPI extFrameRect(HDC hdc, const RECT *lprc, HBRUSH hbr)
{
- return HandleRect("FramelRect", (void *)pFrameRect, hdc, lprc, hbr);
+ return HandleRect("FrameRect", (void *)pFrameRect, hdc, lprc, hbr);
}
BOOL WINAPI extInvertRect(HDC hdc, const RECT *lprc)
@@ -2331,7 +2324,7 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
{
BOOL ret;
- OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x lpPaint.rcpaint=(%d,%d)-(%d-%d)\n",
+ OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x lpPaint.rcpaint=(%d,%d)-(%d,%d)\n",
hwnd, lpPaint, lpPaint->hdc, lpPaint->rcPaint.left, lpPaint->rcPaint.top, lpPaint->rcPaint.right, lpPaint->rcPaint.bottom);
// if not fullscreen or not desktop win, just proxy the call
diff --git a/host/TabSysLibs.cpp b/host/TabSysLibs.cpp
index f46defc..827ee71 100644
--- a/host/TabSysLibs.cpp
+++ b/host/TabSysLibs.cpp
@@ -32,9 +32,7 @@ void CTabSysLibs::DoDataExchange(CDataExchange* pDX)
DDX_Radio(pDX, IDC_GDINONE, cTarget->m_DCEmulationMode);
DDX_Check(pDX, IDC_FIXTEXTOUT, cTarget->m_FixTextOut);
DDX_Check(pDX, IDC_NOFILLRECT, cTarget->m_NoFillRect);
- DDX_Check(pDX, IDC_REUSEEMULATEDDC, cTarget->m_ReuseEmulatedDC);
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);
diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp
index 7dbe784..d1763f0 100644
--- a/host/TargetDlg.cpp
+++ b/host/TargetDlg.cpp
@@ -219,9 +219,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_NoDDRAWFlip = FALSE;
m_NoGDIBlt = FALSE;
m_NoFillRect = FALSE;
- m_ReuseEmulatedDC = FALSE; // ??
m_FixClipperArea = FALSE; // ??
- m_CreateDesktop = FALSE;
m_SyncPalette = FALSE;
m_NoWinErrors = FALSE;
m_AnalyticMode = FALSE;
diff --git a/host/TargetDlg.h b/host/TargetDlg.h
index bbed84e..e135273 100644
--- a/host/TargetDlg.h
+++ b/host/TargetDlg.h
@@ -178,9 +178,7 @@ public:
BOOL m_NoDDRAWFlip;
BOOL m_NoGDIBlt;
BOOL m_NoFillRect;
- BOOL m_ReuseEmulatedDC;
BOOL m_FixClipperArea;
- BOOL m_CreateDesktop;
BOOL m_SyncPalette;
BOOL m_NoWinErrors;
BOOL m_AnalyticMode;
diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps
index e25e84b..961baf3 100644
Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ
diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc
index f41a4d9..3019b22 100644
Binary files a/host/dxwndhost.rc and b/host/dxwndhost.rc differ
diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo
index d8defb2..a08136f 100644
Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ
diff --git a/host/dxwndhost.vs2008.vcproj b/host/dxwndhost.vs2008.vcproj
index 929cf57..2b33f7f 100644
--- a/host/dxwndhost.vs2008.vcproj
+++ b/host/dxwndhost.vs2008.vcproj
@@ -722,22 +722,22 @@
>
-
-
+
+
diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp
index db1d033..c2e7f94 100644
--- a/host/dxwndhostView.cpp
+++ b/host/dxwndhostView.cpp
@@ -461,9 +461,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_NoDDRAWFlip) t->flags3 |= NODDRAWFLIP;
if(dlg->m_NoGDIBlt) t->flags3 |= NOGDIBLT;
if(dlg->m_NoFillRect) t->flags4 |= NOFILLRECT;
- if(dlg->m_ReuseEmulatedDC) t->flags6 |= REUSEEMULATEDDC;
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;
@@ -733,9 +731,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_NoDDRAWFlip = t->flags3 & NODDRAWFLIP ? 1 : 0;
dlg->m_NoGDIBlt = t->flags3 & NOGDIBLT ? 1 : 0;
dlg->m_NoFillRect = t->flags4 & NOFILLRECT ? 1 : 0;
- dlg->m_ReuseEmulatedDC = t->flags6 & REUSEEMULATEDDC ? 1 : 0;
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;
@@ -1309,7 +1305,7 @@ void CDxwndhostView::OnExport()
}
}
-void CDxwndhostView::OnImport(CString sFilePath)
+BOOL CDxwndhostView::OnImport(CString sFilePath)
{
LV_ITEM listitem;
int i;
@@ -1317,7 +1313,7 @@ void CDxwndhostView::OnImport(CString sFilePath)
;
if (i==MAXTARGETS) {
MessageBoxLang(DXW_STRING_MAXENTRIES, DXW_STRING_WARNING, MB_OK | MB_ICONEXCLAMATION);
- return;
+ return FALSE;
}
CListCtrl& listctrl = GetListCtrl();
if(LoadConfigItem(&TargetMaps[i], &PrivateMaps[i], 0, (char *)sFilePath.GetString())){
@@ -1328,6 +1324,10 @@ void CDxwndhostView::OnImport(CString sFilePath)
listitem.pszText = PrivateMaps[i].title;
listctrl.InsertItem(&listitem);
}
+ Resize();
+ SetTarget(TargetMaps);
+ this->isUpdated=TRUE;
+ return TRUE;
}
void CDxwndhostView::OnImport()
@@ -1382,10 +1382,13 @@ void CDxwndhostView::OnImport()
if(GetPrivateProfileInt("window", "updatepaths", 1, gInitPath))
WritePrivateProfileString("window", "exportpath", folder, gInitPath);
p += lstrlen((LPSTR)p) + 1;
- while(*p && (iisUpdated=TRUE;
@@ -2817,7 +2821,14 @@ void CDxwndhostView::OnDropFiles(HDROP dropInfo)
p = (char *)sFile.GetString();
p += (strlen(p)-4);
if(!_strnicmp(p, ".dxw", 4)){
- this->OnImport(sFile);
+ for(UINT i=1; i<=nFilesDropped; i++){
+ if(!this->OnImport(sFile)) break;
+ nBuffer = DragQueryFile(dropInfo, i, NULL, 0);
+ DragQueryFile(dropInfo, i, sFile.GetBuffer(nBuffer+1), nBuffer+1);
+ p = (char *)sFile.GetString();
+ p += (strlen(p)-4);
+ if(_strnicmp(p, ".dxw", 4)) break;
+ }
}
else {
this->OnAdd(sFile.GetBuffer());
diff --git a/host/dxwndhostView.h b/host/dxwndhostView.h
index e1654cb..c89fc5d 100644
--- a/host/dxwndhostView.h
+++ b/host/dxwndhostView.h
@@ -68,7 +68,7 @@ protected:
afx_msg void OnModify();
afx_msg void OnExport();
afx_msg void OnImport();
- afx_msg void OnImport(CString);
+ BOOL OnImport(CString);
afx_msg void OnDelete();
afx_msg void OnExplore();
afx_msg void OnKill();
diff --git a/host/resource b/host/resource
index 2c6819e..3f0efa7 100644
Binary files a/host/resource and b/host/resource differ