diff --git a/build/dxwnd.dll b/build/dxwnd.dll
index 763a8a5..d6660b5 100644
--- a/build/dxwnd.dll
+++ b/build/dxwnd.dll
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:8f543c951f150e29ae64f702c21bceeaa46d3bda294913e9b03346aa6aa276ea
+oid sha256:c4a337db3a9c5cbb7c06069a437f34c28285dcf2548181622789c594c8750bc1
size 781312
diff --git a/build/dxwnd.exe b/build/dxwnd.exe
index 470de73..7abf7ae 100644
--- a/build/dxwnd.exe
+++ b/build/dxwnd.exe
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:864a303e49a88b3bee7353573304b29f4b64852f8fae83b8ac33502099c46a08
+oid sha256:fb594ca522bdf3bc9956b3e2f18c8582c85728c30a77f6c0879e971bc3417ff2
size 673280
diff --git a/build/exports/Wizardry Chronicles V0984b - English.exe.dxw b/build/exports/Wizardry Chronicles V0984b - English.exe.dxw
new file mode 100644
index 0000000..9018488
--- /dev/null
+++ b/build/exports/Wizardry Chronicles V0984b - English.exe.dxw
@@ -0,0 +1,36 @@
+[target]
+title0=Wizardry Chronicles V0984b - English.exe
+path0=D:\Games\Wizardry Chronicle\Wizardry Chronicles V0984b - English.exe
+startfolder0=
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+monitorid0=-1
+coord0=0
+flag0=673185826
+flagg0=1207959552
+flagh0=20
+flagi0=205520900
+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=0
+swapeffect0=0
+maxddinterface0=7
+slowratio0=2
+scanline0=0
+initresw0=800
+initresh0=600
diff --git a/build/exports/Wizardry Chronicles.dxw b/build/exports/Wizardry Chronicles.dxw
new file mode 100644
index 0000000..fa9d3c3
--- /dev/null
+++ b/build/exports/Wizardry Chronicles.dxw
@@ -0,0 +1,36 @@
+[target]
+title0=Wizardry Chronicles
+path0=D:\Games\Wizardry Chronicle\Wiz.exe
+startfolder0=
+launchpath0=
+module0=
+opengllib0=
+notes0=
+registry0=
+ver0=0
+monitorid0=-1
+coord0=0
+flag0=673185826
+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=0
+swapeffect0=0
+maxddinterface0=7
+slowratio0=2
+scanline0=0
+initresw0=800
+initresh0=600
diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt
index f8a7cad..86cc913 100644
--- a/build/readme-relnotes.txt
+++ b/build/readme-relnotes.txt
@@ -1455,10 +1455,13 @@ add: GDI32 debug highlighting of blitted rects on screen
add: hooks for GDI32 GetTextExtentPointA and GetTextExtentPoint32A: needed for proper string rendering on "Warhammer: Shadow of the Horned Rat"
add: hook for GDI32 GdiAlphaBlend, very rare call that appeared in "RHEM" during savegame load.
-v2.04.06
+v2.04.06/fx3
GUI:
add: Expert mode
DLL:
fix: corrected condition to print two virtual registry log messages
fix: improved logic to recover surfaces with DDSCAPS_TEXTURE capability - ref. "Dominant Species"
-fix: fixed cursor clipping state and toggle key to make it work in all conditions
\ No newline at end of file
+fix: fixed cursor clipping state and toggle key to make it work in all conditions
+fix: D3D objects hooking with QueryInterface method. Fixes "Wizardry Chronicle"
+fix: add hook for GDI32 GdiGradientFill and GdiTransparentBlt, present in "RHEM"
+fix: log messages for CloseHandle wrapper
\ No newline at end of file
diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp
index 95c04fe..c0dcbc1 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.04.06.fx2"
+#define VERSION "2.04.06.fx3"
#define DDTHREADLOCK 1
diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo
index 459a95f..71657df 100644
Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ
diff --git a/dll/hd3d7.cpp b/dll/hd3d7.cpp
index fd30ed1..05051a1 100644
--- a/dll/hd3d7.cpp
+++ b/dll/hd3d7.cpp
@@ -702,51 +702,91 @@ void HookTexture(LPVOID *lpTexture, int version)
}
}
-HRESULT WINAPI extQueryInterfaceD3(int d3dversion, QueryInterfaceD3_Type pQueryInterfaceD3, void *lpd3d, REFIID riid, LPVOID *ppvObj)
+HRESULT WINAPI extQueryInterfaceD3(int d3dversion, QueryInterfaceD3_Type pQueryInterfaceD3, void *lpd3d, REFIID riid, LPVOID *obp)
{
HRESULT res;
+ unsigned int dwLocalDDVersion;
+ unsigned int dwLocalD3DVersion;
- OutTraceD3D("QueryInterface(D3D%d): d3d=%x REFIID=%x obj=%x\n", d3dversion, lpd3d, riid.Data1, ppvObj);
- res=(*pQueryInterfaceD3)(lpd3d, riid, ppvObj);
- if(res){
- OutTraceE("QueryInterface(D3D) ERROR: err=%x(%s)\n", res, ExplainDDError(res));
+ res = (*pQueryInterfaceD3)(lpd3d, riid, obp);
+ OutTraceDDRAW("QueryInterface(D3D%d): lpdd=%x REFIID=%x(%s) obp=%x ret=%x at %d\n",
+ d3dversion, lpd3d, riid.Data1, ExplainGUID((GUID *)&riid), *obp, res, __LINE__);
+
+ if(res) {
+ OutTraceE("QueryInterface(D3D) ERROR: res=%x(%s)\n", res, ExplainDDError(res));
return res;
}
- switch(d3dversion){
- case 1:
- SetHook((void *)(**(DWORD **)ppvObj + 12), extInitialize, (void **)&pInitialize, "Initialize");
- SetHook((void *)(**(DWORD **)ppvObj + 16), extEnumDevices1, (void **)&pEnumDevices1, "EnumDevices");
- SetHook((void *)(**(DWORD **)ppvObj + 20), extCreateLight1, (void **)&pCreateLight1, "CreateLight(1)");
-#ifdef TRACEMATERIAL
- SetHook((void *)(**(DWORD **)ppvObj + 24), extCreateMaterial1, (void **)&pCreateMaterial1, "CreateMaterial(1)");
-#endif
- SetHook((void *)(**(DWORD **)ppvObj + 28), extCreateViewport1, (void **)&pCreateViewport1, "CreateViewport(1)");
- SetHook((void *)(**(DWORD **)ppvObj + 32), extFindDevice1, (void **)&pFindDevice1, "FindDevice(1)");
+
+ dwLocalDDVersion=0;
+ dwLocalD3DVersion=0;
+ switch(riid.Data1){
+ case 0x6C14DB80: //DirectDraw1
+ dwLocalDDVersion = 1;
break;
- case 2:
- SetHook((void *)(**(DWORD **)ppvObj + 12), extEnumDevices2, (void **)&pEnumDevices2, "EnumDevices(2)");
- SetHook((void *)(**(DWORD **)ppvObj + 16), extCreateLight2, (void **)&pCreateLight2, "CreateLight(2)");
-#ifdef TRACEMATERIAL
- SetHook((void *)(**(DWORD **)ppvObj + 20), extCreateMaterial2, (void **)&pCreateMaterial2, "CreateMaterial(2)");
-#endif
- SetHook((void *)(**(DWORD **)ppvObj + 24), extCreateViewport2, (void **)&pCreateViewport2, "CreateViewport(2)");
- SetHook((void *)(**(DWORD **)ppvObj + 28), extFindDevice2, (void **)&pFindDevice2, "FindDevice(2)");
+ case 0xB3A6F3E0: //DirectDraw2
+ dwLocalDDVersion = 2;
break;
- case 3:
- SetHook((void *)(**(DWORD **)ppvObj + 12), extEnumDevices3, (void **)&pEnumDevices3, "EnumDevices(3)");
- SetHook((void *)(**(DWORD **)ppvObj + 16), extCreateLight3, (void **)&pCreateLight3, "CreateLight(3)");
-#ifdef TRACEMATERIAL
- SetHook((void *)(**(DWORD **)ppvObj + 20), extCreateMaterial3, (void **)&pCreateMaterial3, "CreateMaterial(3)");
-#endif
- SetHook((void *)(**(DWORD **)ppvObj + 24), extCreateViewport3, (void **)&pCreateViewport3, "CreateViewport(3)");
- SetHook((void *)(**(DWORD **)ppvObj + 28), extFindDevice3, (void **)&pFindDevice3, "FindDevice(3)");
+ case 0x618f8ad4: //DirectDraw3
+ dwLocalDDVersion = 3;
break;
- case 7:
- SetHook((void *)(**(DWORD **)ppvObj + 12), extEnumDevices7, (void **)&pEnumDevices7, "EnumDevices(7)");
- SetHook((void *)(**(DWORD **)ppvObj + 32), extCreateDevice7, (void **)&pCreateDevice7, "CreateDevice(D3D7)");
+ case 0x9c59509a: //DirectDraw4
+ dwLocalDDVersion = 4;
+ break;
+ case 0x15e65ec0: //DirectDraw7
+ dwLocalDDVersion = 7;
+ break;
+ case 0x3BBA0080: //Direct3D
+ dwLocalD3DVersion = 1;
+ break;
+ case 0x6aae1ec1: //Direct3D2
+ dwLocalD3DVersion = 2;
+ break;
+ case 0xbb223240: //Direct3D3
+ dwLocalD3DVersion = 3;
+ break;
+ case 0xf5049e77: //Direct3D7
+ dwLocalD3DVersion = 7;
break;
}
- return res;
+ if (! *obp){
+ OutTraceDDRAW("QueryInterface(D): Interface for DX version %d not found\n", dwLocalDDVersion);
+ return(0);
+ }
+ if(dwLocalDDVersion) OutTraceDW("QueryInterface(D): Got interface for DX version %d\n", dwLocalDDVersion);
+ if(dwLocalD3DVersion) OutTraceDW("QueryInterface(D): Got interface for D3D version %d\n", dwLocalD3DVersion);
+
+ if (dwLocalDDVersion > dxw.dwMaxDDVersion) {
+ *obp = NULL;
+ OutTraceDW("QueryInterface(D): lpdd=%x REFIID=%x obp=(NULL) ret=%x at %d\n",
+ lpd3d, riid.Data1, res, __LINE__);
+ return(0);
+ }
+
+ switch (dwLocalDDVersion){
+ case 1: // you never know ....
+ case 2:
+ case 3:
+ case 4:
+ case 7:
+ dxw.dwDDVersion=dwLocalDDVersion;
+ extern void HookDDSession(LPDIRECTDRAW *, int);
+ HookDDSession((LPDIRECTDRAW *)obp, dxw.dwDDVersion);
+ break;
+ }
+
+ switch (dwLocalD3DVersion){
+ case 1:
+ case 2:
+ case 3:
+ case 7:
+ HookDirect3DSession((LPDIRECTDRAW *)obp, dwLocalD3DVersion);
+ break;
+ }
+
+ OutTraceDDRAW("QueryInterface(D3D): lpdd=%x REFIID=%x obp=%x DDVersion=%d ret=0\n",
+ lpd3d, riid.Data1, *obp, dxw.dwDDVersion);
+
+ return D3D_OK;
}
HRESULT WINAPI extQueryInterfaceD31(void *lpd3d, REFIID riid, LPVOID *ppvObj)
@@ -924,7 +964,7 @@ HRESULT WINAPI extEnumDevices(int d3dversion, EnumDevices_Type pEnumDevices, voi
HRESULT res;
CallbackArg Arg;
- OutTraceD3D("EnumDevices(D#D%d): d3d=%x arg=%x\n", d3dversion, lpd3d, arg);
+ OutTraceD3D("EnumDevices(D3D%d): d3d=%x arg=%x\n", d3dversion, lpd3d, arg);
Arg.cb= &cb;
Arg.arg=arg;
res=(*pEnumDevices)(lpd3d, (LPD3DENUMDEVICESCALLBACK)extDeviceProxy, (LPVOID)&Arg);
diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp
index ded25e8..a0b7e96 100644
--- a/dll/kernel32.cpp
+++ b/dll/kernel32.cpp
@@ -954,8 +954,15 @@ HANDLE WINAPI extCreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwS
BOOL WINAPI extCloseHandle(HANDLE hObject)
{
BOOL ret;
- OutTrace("CloseHandle: hFile=%x\n", hObject);
- if (hObject && (hObject != (HANDLE)-1)) __try {ret=CloseHandle(hObject);} __except(EXCEPTION_EXECUTE_HANDLER){};
+ if (hObject && (hObject != (HANDLE)-1)) {
+ OutTraceB("CloseHandle: hFile=%x\n", hObject);
+ __try {ret=CloseHandle(hObject);
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER){};
+ }
+ else{
+ OutTraceDW("CloseHandle: BYPASS hFile=%x\n", hObject);
+ }
return ret;
}
diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps
index ac4a258..ae3a3aa 100644
Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ
diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc
index 6508883..4d09648 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 bd88006..aef3c02 100644
Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ
diff --git a/host/dxwndhost.vs2008.vcproj.DESKTOP-Q3RE27J.user.user b/host/dxwndhost.vs2008.vcproj.DESKTOP-Q3RE27J.user.user
deleted file mode 100644
index 723bba8..0000000
--- a/host/dxwndhost.vs2008.vcproj.DESKTOP-Q3RE27J.user.user
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-