diff --git a/Doc/dxwnd_manual.odt b/Doc/dxwnd_manual.odt deleted file mode 100644 index 1826b5a..0000000 Binary files a/Doc/dxwnd_manual.odt and /dev/null differ diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 1a367a5..eedd809 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:93bd98c222d5a3a27ae412c7dff1b5cdca3ad7980ea19e86e4e543b6f34e685b -size 484352 +oid sha256:3bb7913ecbd4bf5117c4858a94e0f9e1d5606d8dc8165258118f0a2b4e05c6ef +size 485888 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index d42901e..8fd0f19 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32bbbe4a6676b22413cb11cfcb1c8a6cbe831221bea1c1cc83fb25963b86fb9c +oid sha256:d25ed7d43c0672c5ce69054896578802218de233bbc82f22b392c3406e56915f size 540160 diff --git a/build/exports/Age of Empires Expansion Trial.dxw b/build/exports/Age of Empires Expansion Trial.dxw new file mode 100644 index 0000000..8277d20 --- /dev/null +++ b/build/exports/Age of Empires Expansion Trial.dxw @@ -0,0 +1,26 @@ +[target] +title0=Age of Empires Expansion Trial +path0=D:\Games\Age of Empires Expansion Trial\empiresx.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=4194308 +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 diff --git a/build/exports/Age of Wonders II.dxw b/build/exports/Age of Wonders II.dxw new file mode 100644 index 0000000..86614a3 --- /dev/null +++ b/build/exports/Age of Wonders II.dxw @@ -0,0 +1,27 @@ +[target] +title0=Age of Wonders II +path0=D:\Games\Age of Wonders II\AoW2.exe +launchpath0= +module0= +opengllib0= +ver0=7 +coord0=0 +flag0=142606624 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +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 diff --git a/build/exports/Blair Witch Volume One - Rustin Parr.dxw b/build/exports/Blair Witch Volume One - Rustin Parr.dxw new file mode 100644 index 0000000..c48948e --- /dev/null +++ b/build/exports/Blair Witch Volume One - Rustin Parr.dxw @@ -0,0 +1,27 @@ +[target] +title0=Blair Witch Volume One - Rustin Parr +path0=D:\Games\Blair Witch Volume One - Rustin Parr\NOCTURNE.EXE +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=134217732 +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 diff --git a/build/exports/Conflict Zone.dxw b/build/exports/Conflict Zone.dxw new file mode 100644 index 0000000..98bb0ff --- /dev/null +++ b/build/exports/Conflict Zone.dxw @@ -0,0 +1,27 @@ +[target] +title0=Conflict Zone +path0=D:\Games\Conflict Zone\Conflict zone.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217760 +flagg0=1207959552 +flagh0=20 +flagi0=4194308 +tflag0=64 +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 diff --git a/build/exports/Disciples II - Dark Prophecy.dxw b/build/exports/Disciples II - Dark Prophecy.dxw new file mode 100644 index 0000000..fcd01c1 --- /dev/null +++ b/build/exports/Disciples II - Dark Prophecy.dxw @@ -0,0 +1,27 @@ +[target] +title0=Disciples II - Dark Prophecy +path0=D:\Games\Disciples II - Dark Prophecy\Discipl2.exe +launchpath0= +module0= +opengllib0= +ver0=1 +coord0=0 +flag0=134234144 +flagg0=1207959552 +flagh0=16 +flagi0=138412036 +tflag0=6147 +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 diff --git a/build/exports/KA52 Team Alligator.dxw b/build/exports/KA52 Team Alligator.dxw new file mode 100644 index 0000000..2539a64 --- /dev/null +++ b/build/exports/KA52 Team Alligator.dxw @@ -0,0 +1,27 @@ +[target] +title0=KA52 Team Alligator +path0=D:\Games\Team Alligator\Team2.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=687865888 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +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 diff --git a/build/exports/Myth III - The Wolf Age.dxw b/build/exports/Myth III - The Wolf Age.dxw new file mode 100644 index 0000000..dcd15fb --- /dev/null +++ b/build/exports/Myth III - The Wolf Age.dxw @@ -0,0 +1,27 @@ +[target] +title0=Myth III - The Wolf Age +path0=D:\Games\Myth III - The Wolf Age\Myth3.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1744830464 +flagh0=20 +flagi0=205520900 +tflag0=6147 +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 diff --git a/build/exports/Re-Volt.dxw b/build/exports/Re-Volt.dxw new file mode 100644 index 0000000..1b642a6 --- /dev/null +++ b/build/exports/Re-Volt.dxw @@ -0,0 +1,26 @@ +[target] +title0=Re-Volt +path0=D:\Games\Re-Volt\REVOLT.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217760 +flagg0=1208025088 +flagh0=20 +flagi0=12 +tflag0=64 +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 diff --git a/build/exports/Rune.dxw b/build/exports/Rune.dxw new file mode 100644 index 0000000..5300f0e --- /dev/null +++ b/build/exports/Rune.dxw @@ -0,0 +1,26 @@ +[target] +title0=Rune +path0=D:\Games\Rune\System\Rune.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=402669601 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=6211 +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 diff --git a/build/exports/Shogo Mobile Armor Division.dxw b/build/exports/Shogo Mobile Armor Division.dxw new file mode 100644 index 0000000..faac6b6 --- /dev/null +++ b/build/exports/Shogo Mobile Armor Division.dxw @@ -0,0 +1,27 @@ +[target] +title0=Shogo Mobile Armor Division +path0=D:\Games\Shogo\Client.exe +launchpath0=D:\Games\Shogo\Shogo.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=151011328 +flagg0=1207959552 +flagh0=20 +flagi0=4194308 +tflag0=64 +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 diff --git a/build/exports/Slave Zero.dxw b/build/exports/Slave Zero.dxw new file mode 100644 index 0000000..8c16fac --- /dev/null +++ b/build/exports/Slave Zero.dxw @@ -0,0 +1,27 @@ +[target] +title0=Slave Zero +path0=D:\Games\Slave Zero\SlaveZero.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671105120 +flagg0=1207959552 +flagh0=20 +flagi0=2097156 +tflag0=6210 +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 diff --git a/build/exports/Unreal.dxw b/build/exports/Unreal.dxw new file mode 100644 index 0000000..f255a01 --- /dev/null +++ b/build/exports/Unreal.dxw @@ -0,0 +1,27 @@ +[target] +title0=Unreal +path0=D:\Games\Unreal\System\Unreal.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +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=4 +winver0=0 +maxres0=-1 diff --git a/build/exports/Warpath.dxw b/build/exports/Warpath.dxw new file mode 100644 index 0000000..a013acb --- /dev/null +++ b/build/exports/Warpath.dxw @@ -0,0 +1,26 @@ +[target] +title0=Warpath +path0=D:\Games\Warpath\System\Warpath.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=4 +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 diff --git a/build/exports/Warrior Kings.dxw b/build/exports/Warrior Kings.dxw new file mode 100644 index 0000000..9054252 --- /dev/null +++ b/build/exports/Warrior Kings.dxw @@ -0,0 +1,26 @@ +[target] +title0=Warrior Kings +path0=D:\Games\Warrior Kings\warrior_kings.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671236130 +flagg0=1207959569 +flagh0=65556 +flagi0=4 +tflag0=64 +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 diff --git a/build/exports/World Racing (Demo) MX.dxw b/build/exports/World Racing (Demo) MX.dxw new file mode 100644 index 0000000..674cde0 --- /dev/null +++ b/build/exports/World Racing (Demo) MX.dxw @@ -0,0 +1,26 @@ +[target] +title0=World Racing (Demo) MX +path0=D:\Games\World Racing Demo\mbwr_pc_MX.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234146 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=64 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=2 +winver0=0 +maxres0=-1 diff --git a/build/exports/World Racing (Demo).dxw b/build/exports/World Racing (Demo).dxw new file mode 100644 index 0000000..ff101ce --- /dev/null +++ b/build/exports/World Racing (Demo).dxw @@ -0,0 +1,26 @@ +[target] +title0=World Racing (Demo) +path0=D:\Games\World Racing Demo\mbwr_pc.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234146 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=64 +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 diff --git a/build/exports/XIII.dxw b/build/exports/XIII.dxw new file mode 100644 index 0000000..f48765e --- /dev/null +++ b/build/exports/XIII.dxw @@ -0,0 +1,27 @@ +[target] +title0=XIII +path0=D:\Games\Ubisoft\XIII\system\XIII.exe +launchpath0= +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671105540 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +tflag0=6146 +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 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 6524dbc..f878460 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -511,4 +511,14 @@ fix: some log messages fix: handling of GetProcAddress D3D9 api fix: handling of EMULATEBUFFER option - fixes "Star Trek Birth of the Federation" fix: expanded hot patching scope - now can handle QueryPerformanceCounter and fix time stretching on obfuscated version of "Wind Fantasy SP" -added logging in D3DDevice9::GetAdapterIdentifier \ No newline at end of file +added logging in D3DDevice9::GetAdapterIdentifier + +v2.02.78 +fix: hooked D3D8/9Device::BeginStateBlock +ddraw API hot swappable +log: helper for ChangeDisplaySettings() flags +fix: hot patch handling of loaded modules +log: fixed some messages with no line ending for GetObjectType() +d3d begin of code reorganization and cleaning +ole32, user32 API hot patched +handling of DWL_DLGPROC message \ No newline at end of file diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 47ff132..7de1e2f 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -265,10 +265,10 @@ static void SetPixFmt(LPDDSURFACEDESC2); static void GetPixFmt(LPDDSURFACEDESC2); static HookEntry_Type ddHooks[]={ - {HOOK_IAT_CANDIDATE, "DirectDrawCreate", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreate, (FARPROC)extDirectDrawCreate}, - {HOOK_IAT_CANDIDATE, "DirectDrawCreateEx", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreateEx, (FARPROC)extDirectDrawCreateEx}, - {HOOK_IAT_CANDIDATE, "DirectDrawEnumerateA", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerate, (FARPROC)extDirectDrawEnumerate}, - {HOOK_IAT_CANDIDATE, "DirectDrawEnumerateExA", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerateEx, (FARPROC)extDirectDrawEnumerateEx}, + {HOOK_HOT_CANDIDATE, "DirectDrawCreate", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreate, (FARPROC)extDirectDrawCreate}, + {HOOK_HOT_CANDIDATE, "DirectDrawCreateEx", (FARPROC)NULL, (FARPROC *)&pDirectDrawCreateEx, (FARPROC)extDirectDrawCreateEx}, + {HOOK_HOT_CANDIDATE, "DirectDrawEnumerateA", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerate, (FARPROC)extDirectDrawEnumerate}, + {HOOK_HOT_CANDIDATE, "DirectDrawEnumerateExA", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerateEx, (FARPROC)extDirectDrawEnumerateEx}, //{HOOK_IAT_CANDIDATE, "DirectDrawEnumerateW", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerateW, (FARPROC)extDirectDrawCreate}, //{HOOK_IAT_CANDIDATE, "DirectDrawEnumerateExW", (FARPROC)NULL, (FARPROC *)&pDirectDrawEnumerateExW, (FARPROC)extDirectDrawCreate}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator @@ -642,92 +642,110 @@ void FixPixelFormat(int ColorDepth, DDPIXELFORMAT *pf) } } +static void ddSetCompatibility() +{ + typedef HRESULT (WINAPI *SetAppCompatData_Type)(DWORD, DWORD); + SetAppCompatData_Type pSetAppCompatData; + HRESULT res; + HINSTANCE hinst; + + hinst=LoadLibrary("ddraw.dll"); + pSetAppCompatData=(SetAppCompatData_Type)(*pGetProcAddress)(hinst, "SetAppCompatData"); + if(pSetAppCompatData) { + res=(*pSetAppCompatData)(2, 0); + OutTraceDW("HookDirectDraw: SetAppCompatData(2,0) ret=%x(%s)\n", res, ExplainDDError(res)); + } + FreeLibrary(hinst); +} + int HookDirectDraw(HMODULE module, int version) { - HINSTANCE hinst; - void *tmp; - const GUID dd7 = {0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b}; + if(dxw.dwFlags2 & SETCOMPATIBILITY) ddSetCompatibility(); - if(dxw.dwFlags2 & SETCOMPATIBILITY){ - typedef HRESULT (WINAPI *SetAppCompatData_Type)(DWORD, DWORD); - SetAppCompatData_Type pSetAppCompatData; - HRESULT res; - hinst=LoadLibrary("ddraw.dll"); - pSetAppCompatData=(SetAppCompatData_Type)(*pGetProcAddress)(hinst, "SetAppCompatData"); - if(pSetAppCompatData) { - res=(*pSetAppCompatData)(2, 0); - OutTraceDW("HookDirectDraw: SetAppCompatData(2,0) ret=%x(%s)\n", res, ExplainDDError(res)); - } - FreeLibrary(hinst); - } +#if 0 + //void *tmp; + //const GUID dd7 = {0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b}; OutTraceB("HookDirectDraw version=%d\n", version); //GHO switch(version){ case 0: // automatic - tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreate", extDirectDrawCreate); - if(tmp) pDirectDrawCreate = (DirectDrawCreate_Type)tmp; - tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreateEx", extDirectDrawCreateEx); - if(tmp) pDirectDrawCreateEx = (DirectDrawCreateEx_Type)tmp; - tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateA", extDirectDrawEnumerate); - if(tmp) pDirectDrawEnumerate = (DirectDrawEnumerate_Type)tmp; - tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx); - if(tmp) pDirectDrawEnumerateEx = (DirectDrawEnumerateEx_Type)tmp; + HookLibrary(module, ddHooks, "ddraw.dll"); + //tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreate", extDirectDrawCreate); + //if(tmp) pDirectDrawCreate = (DirectDrawCreate_Type)tmp; + //tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreateEx", extDirectDrawCreateEx); + //if(tmp) pDirectDrawCreateEx = (DirectDrawCreateEx_Type)tmp; + //tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateA", extDirectDrawEnumerate); + //if(tmp) pDirectDrawEnumerate = (DirectDrawEnumerate_Type)tmp; + //tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx); + //if(tmp) pDirectDrawEnumerateEx = (DirectDrawEnumerateEx_Type)tmp; break; case 1: case 2: case 3: case 5: case 6: - hinst = LoadLibrary("ddraw.dll"); - pDirectDrawEnumerate = - (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA"); - pDirectDrawCreate = - (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate"); - if(pDirectDrawCreate){ - LPDIRECTDRAW lpdd; - BOOL res; - HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); - HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate); - res=extDirectDrawCreate(0, &lpdd, 0); - if (res){ - OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res)); - } - lpdd->Release(); - } - break; + HookLibrary(module, ddHooks, "ddraw.dll"); + //hinst = LoadLibrary("ddraw.dll"); + //pDirectDrawEnumerate = + // (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA"); + //pDirectDrawCreate = + // (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate"); + //if(dxw.dwFlags4 & HOTPATCH){ + // extern void *HotPatch(void *, const char *, void *); + // pDirectDrawEnumerate = (DirectDrawEnumerate_Type)HotPatch(pDirectDrawEnumerate, "DirectDrawEnumerate", extDirectDrawEnumerate); + // pDirectDrawCreate = (DirectDrawCreate_Type)HotPatch(pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); + //} + //else { + // if(pDirectDrawCreate){ + // LPDIRECTDRAW lpdd; + // BOOL res; + // HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); + // HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate); + // res=extDirectDrawCreate(0, &lpdd, 0); + // if (res){ + // OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res)); + // } + // lpdd->Release(); + // } + //} + //break; case 7: - hinst = LoadLibrary("ddraw.dll"); - pDirectDrawEnumerate = - (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA"); - pDirectDrawEnumerateEx = - (DirectDrawEnumerateEx_Type)GetProcAddress(hinst, "DirectDrawEnumerateExA"); - pDirectDrawCreate = - (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate"); - if(pDirectDrawCreate){ - LPDIRECTDRAW lpdd; - BOOL res; - HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); - HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate); - HookAPI(module, "ddraw.dll", pDirectDrawEnumerateEx, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx); - res=extDirectDrawCreate(0, &lpdd, 0); - if (res) OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res)); - lpdd->Release(); - } - pDirectDrawCreateEx = - (DirectDrawCreateEx_Type)GetProcAddress(hinst, "DirectDrawCreateEx"); - if(pDirectDrawCreateEx){ - LPDIRECTDRAW lpdd; - BOOL res; - HookAPI(module, "ddraw.dll", pDirectDrawCreateEx, "DirectDrawCreateEx", extDirectDrawCreateEx); - res=extDirectDrawCreateEx(0, &lpdd, dd7, 0); - if (res) OutTraceE("DirectDrawCreateEx: ERROR res=%x(%s)\n", res, ExplainDDError(res)); - lpdd->Release(); - } + HookLibrary(module, ddHooks, "ddraw.dll"); + //hinst = LoadLibrary("ddraw.dll"); + //pDirectDrawEnumerate = + // (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA"); + //pDirectDrawEnumerateEx = + // (DirectDrawEnumerateEx_Type)GetProcAddress(hinst, "DirectDrawEnumerateExA"); + //pDirectDrawCreate = + // (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate"); + //if(pDirectDrawCreate){ + // LPDIRECTDRAW lpdd; + // BOOL res; + // HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); + // HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate); + // HookAPI(module, "ddraw.dll", pDirectDrawEnumerateEx, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx); + // res=extDirectDrawCreate(0, &lpdd, 0); + // if (res) OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res)); + // lpdd->Release(); + //} + //pDirectDrawCreateEx = + // (DirectDrawCreateEx_Type)GetProcAddress(hinst, "DirectDrawCreateEx"); + //if(pDirectDrawCreateEx){ + // LPDIRECTDRAW lpdd; + // BOOL res; + // HookAPI(module, "ddraw.dll", pDirectDrawCreateEx, "DirectDrawCreateEx", extDirectDrawCreateEx); + // res=extDirectDrawCreateEx(0, &lpdd, dd7, 0); + // if (res) OutTraceE("DirectDrawCreateEx: ERROR res=%x(%s)\n", res, ExplainDDError(res)); + // lpdd->Release(); + //} break; } if(pDirectDrawCreate || pDirectDrawCreateEx) return 1; +#else + HookLibrary(module, ddHooks, "ddraw.dll"); +#endif return 0; } diff --git a/dll/dxhelper.cpp b/dll/dxhelper.cpp index 300b1ce..34ac2fc 100644 --- a/dll/dxhelper.cpp +++ b/dll/dxhelper.cpp @@ -1694,3 +1694,25 @@ char *ExplainWfPFlags(DWORD c) else strcpy(eb,"CWP_ALL"); return(eb); } + +char *ExplainChangeDisplaySettingsFlags(DWORD c) +{ + static char eb[128]; + unsigned int l; + strcpy(eb,"CDS_"); + if(c & CDS_UPDATEREGISTRY) strcat(eb, "UPDATEREGISTRY+"); + if(c & CDS_TEST) strcat(eb, "TEST+"); + if(c & CDS_FULLSCREEN) strcat(eb, "FULLSCREEN+"); + if(c & CDS_GLOBAL) strcat(eb, "GLOBAL+"); + if(c & CDS_SET_PRIMARY) strcat(eb, "SET_PRIMARY+"); + if(c & CDS_VIDEOPARAMETERS) strcat(eb, "VIDEOPARAMETERS+"); + if(c & CDS_ENABLE_UNSAFE_MODES) strcat(eb, "ENABLE_UNSAFE_MODES+"); + if(c & CDS_DISABLE_UNSAFE_MODES) strcat(eb, "DISABLE_UNSAFE_MODES+"); + if(c & CDS_RESET) strcat(eb, "RESET+"); + if(c & CDS_NORESET) strcat(eb, "NORESET+"); + l=strlen(eb); + if (l>strlen("CDS_")) eb[l-1]=0; // delete last '+' if any + else strcpy(eb,"NULL"); + return(eb); +} + diff --git a/dll/dxhelper.h b/dll/dxhelper.h index 75917ea..e9098e1 100644 --- a/dll/dxhelper.h +++ b/dll/dxhelper.h @@ -49,3 +49,4 @@ extern char *ExplainRasterCaps(DWORD); extern char *ExplainD3DRenderState(DWORD); extern char *ExplainRenderstateValue(DWORD); extern char *ExplainWfPFlags(DWORD); +extern char *ExplainChangeDisplaySettingsFlags(DWORD); diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index 4e24f68..826c521 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -1543,8 +1543,31 @@ LPCSTR ProcToString(LPCSTR proc) FARPROC RemapLibrary(LPCSTR proc, HMODULE hModule, HookEntry_Type *Hooks) { + void *remapped_addr; for(; Hooks->APIName; Hooks++){ if (!strcmp(proc,Hooks->APIName)){ + if((((dxw.dwFlags4 & HOTPATCH) && (Hooks->HookStatus == HOOK_HOT_CANDIDATE)) || // hot patch candidate still to process - or + ((dxw.dwFlags4 & HOTPATCHALWAYS) && (Hooks->HookStatus != HOOK_HOT_LINKED)))){ // force hot patch and not already hooked + + if(!Hooks->OriginalAddress) { + Hooks->OriginalAddress=(*pGetProcAddress)(hModule, Hooks->APIName); + if(!Hooks->OriginalAddress) continue; + } + + remapped_addr = HotPatch(Hooks->OriginalAddress, Hooks->APIName, Hooks->HookerAddress); + if(remapped_addr == (void *)1) { // should never go here ... + Hooks->HookStatus = HOOK_HOT_LINKED; + continue; // already hooked + } + if(remapped_addr) { + Hooks->HookStatus = HOOK_HOT_LINKED; + if(Hooks->StoreAddress) *(Hooks->StoreAddress) = (FARPROC)remapped_addr; + } + } + if(Hooks->HookStatus == HOOK_HOT_LINKED) { + OutTraceDW("GetProcAddress: hot patched proc=%s addr=%x\n", ProcToString(proc), Hooks->HookerAddress); + return Hooks->HookerAddress; + } if (Hooks->StoreAddress) *(Hooks->StoreAddress)=(*pGetProcAddress)(hModule, proc); OutTraceDW("GetProcAddress: hooking proc=%s addr=%x->%x\n", ProcToString(proc), (Hooks->StoreAddress) ? *(Hooks->StoreAddress) : 0, Hooks->HookerAddress); @@ -1556,6 +1579,8 @@ FARPROC RemapLibrary(LPCSTR proc, HMODULE hModule, HookEntry_Type *Hooks) void HookLibrary(HMODULE hModule, HookEntry_Type *Hooks, char *DLLName) { + HMODULE hDLL = NULL; + //OutTrace("HookLibrary: hModule=%x dll=%s\n", hModule, DLLName); for(; Hooks->APIName; Hooks++){ //tmp = HookAPI(hModule, DLLName, Hooks->HookStatus, Hooks->OriginalAddress, Hooks->APIName, Hooks->HookerAddress); //if(tmp && Hooks->StoreAddress) *(Hooks->StoreAddress) = (FARPROC)tmp; @@ -1577,8 +1602,26 @@ void HookLibrary(HMODULE hModule, HookEntry_Type *Hooks, char *DLLName) if((((dxw.dwFlags4 & HOTPATCH) && (Hooks->HookStatus == HOOK_HOT_CANDIDATE)) || // hot patch candidate still to process - or ((dxw.dwFlags4 & HOTPATCHALWAYS) && (Hooks->HookStatus != HOOK_HOT_LINKED))) // force hot patch and not already hooked && - (Hooks->OriginalAddress && Hooks->StoreAddress)){ // API address and save ptr available - // Hot Patch + Hooks->StoreAddress){ // and save ptr available +#if 1 + // Hot Patch - beware! This way yo're likely to hook unneeded libraries. + if(!Hooks->OriginalAddress) { + if(!hDLL) { + hDLL = (*pLoadLibraryA)(DLLName); + if(!hDLL) { + OutTrace("HookLibrary: LoadLibrary failed on DLL=%s err=%x\n", DLLName, GetLastError()); + continue; + } + } + Hooks->OriginalAddress=(*pGetProcAddress)(hDLL, Hooks->APIName); + if(!Hooks->OriginalAddress) { + OutTrace("HookLibrary: GetProcAddress failed on API=%s err=%x\n", Hooks->APIName, GetLastError()); + continue; + } + } +#else + if(!Hooks->OriginalAddress) continue; +#endif remapped_addr = HotPatch(Hooks->OriginalAddress, Hooks->APIName, Hooks->HookerAddress); if(remapped_addr == (void *)1) { // should never go here ... Hooks->HookStatus = HOOK_HOT_LINKED; diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index 814a851..ed006fe 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include "dxwnd.h" #include "dxwcore.hpp" -#define VERSION "2.02.77" +#define VERSION "2.02.78" #define DDTHREADLOCK 1 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index e3e6f98..5099f4b 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 1117be6..2b99b2a 100644 --- a/dll/gdi32.cpp +++ b/dll/gdi32.cpp @@ -1804,9 +1804,9 @@ DWORD WINAPI extGetObjectType(HGDIOBJ h) { DWORD res; res=(*pGetObjectType)(h); - OutTraceDW("GetObjectType: h=%x type=%x", h, res); + OutTraceDW("GetObjectType: h=%x type=%x\n", h, res); if(h==dxw.VirtualHDC) { - OutTraceDW("GetObjectType: REMAP h=%x type=%x->%x", h, res, OBJ_DC); + OutTraceDW("GetObjectType: REMAP h=%x type=%x->%x\n", h, res, OBJ_DC); res=OBJ_DC; } return res; diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index 756913b..4964b65 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -11,38 +11,140 @@ #include "syslibs.h" #define HOOKD3D10ANDLATER 1 +#define TRACEALLMETHODS 1 typedef HRESULT (WINAPI *QueryInterface_Type)(void *, REFIID riid, void** ppvObj); +// D3D8/9 API + typedef void* (WINAPI *Direct3DCreate8_Type)(UINT); typedef void* (WINAPI *Direct3DCreate9_Type)(UINT); typedef HRESULT (WINAPI *Direct3DCreate9Ex_Type)(UINT, IDirect3D9Ex **); typedef HRESULT (WINAPI *CheckFullScreen_Type)(void); typedef BOOL (WINAPI * DisableD3DSpy_Type)(void); +void* WINAPI extDirect3DCreate8(UINT); +void* WINAPI extDirect3DCreate9(UINT); +HRESULT WINAPI extDirect3DCreate9Ex(UINT, IDirect3D9Ex **); +HRESULT WINAPI extCheckFullScreen(void); +HRESULT WINAPI voidDirect3DShaderValidatorCreate9(void); +void WINAPI voidDebugSetLevel(void); +void WINAPI voidDebugSetMute(void); +BOOL WINAPI voidDisableD3DSpy(void); + +// IDirect3D8/9 methods + +typedef HRESULT (WINAPI *RegisterSoftwareDevice_Type)(void *, void*); typedef UINT (WINAPI *GetAdapterCount_Type)(void *); typedef HRESULT (WINAPI *GetAdapterIdentifier_Type)(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); -typedef HRESULT (WINAPI *CreateDevice_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, void **); -typedef HRESULT (WINAPI *CreateDeviceEx_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, D3DDISPLAYMODEEX *, void **); +typedef UINT (WINAPI *GetAdapterModeCount_Type)(void *, UINT, D3DFORMAT); typedef HRESULT (WINAPI *EnumAdapterModes8_Type)(void *, UINT, UINT, D3DDISPLAYMODE *); typedef HRESULT (WINAPI *EnumAdapterModes9_Type)(void *, UINT, D3DFORMAT ,UINT, D3DDISPLAYMODE *); typedef HRESULT (WINAPI *GetAdapterDisplayMode_Type)(void *, UINT, D3DDISPLAYMODE *); -typedef HRESULT (WINAPI *GetDisplayMode8_Type)(void *, D3DDISPLAYMODE *); -typedef HRESULT (WINAPI *GetDisplayMode9_Type)(void *, UINT, D3DDISPLAYMODE *); -typedef HRESULT (WINAPI *Present_Type)(void *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *); -typedef HRESULT (WINAPI *SetRenderState_Type)(void *, D3DRENDERSTATETYPE, DWORD); -typedef HRESULT (WINAPI *GetRenderState_Type)(void *, D3DRENDERSTATETYPE, DWORD ); -typedef HRESULT (WINAPI *CreateAdditionalSwapChain_Type)(void *, D3DPRESENT_PARAMETERS *, IDirect3DSwapChain9 **); +typedef HRESULT (WINAPI *CheckDeviceType_Type)(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT, BOOL); +typedef HRESULT (WINAPI *CheckDeviceFormat_Type)(void *, UINT, D3DDEVTYPE, D3DFORMAT, DWORD, D3DRESOURCETYPE, D3DFORMAT); +typedef HRESULT (WINAPI *CheckDeviceMultiSampleType_Type)(void *, UINT, D3DDEVTYPE, D3DFORMAT, BOOL, D3DMULTISAMPLE_TYPE, DWORD *); +typedef HRESULT (WINAPI *CheckDepthStencilMatch_Type)(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT, D3DFORMAT); +typedef HRESULT (WINAPI *CheckDeviceFormatConversion_Type)(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT); +typedef HRESULT (WINAPI *D3DGetDeviceCaps_Type)(void *, UINT, D3DDEVTYPE, D3DCAPS9 *); +typedef HMONITOR (WINAPI *GetAdapterMonitor_Type)(void *, UINT); +typedef HRESULT (WINAPI *CreateDevice_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, void **); +typedef HRESULT (WINAPI *CreateDeviceEx_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, D3DDISPLAYMODEEX *, void **); + +HRESULT WINAPI extRegisterSoftwareDevice(void *, void*); +UINT WINAPI extGetAdapterCount8(void *); +UINT WINAPI extGetAdapterCount9(void *); +HRESULT WINAPI extGetAdapterIdentifier8(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); +HRESULT WINAPI extGetAdapterIdentifier9(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); +UINT WINAPI extGetAdapterModeCount(void *, UINT, D3DFORMAT); +HRESULT WINAPI extCheckDeviceType(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT, BOOL); +HRESULT WINAPI extCheckDeviceFormat(void *, UINT, D3DDEVTYPE, D3DFORMAT, DWORD, D3DRESOURCETYPE, D3DFORMAT); +HRESULT WINAPI extCheckDeviceMultiSampleType(void *, UINT, D3DDEVTYPE, D3DFORMAT, BOOL, D3DMULTISAMPLE_TYPE, DWORD *); +HRESULT WINAPI extCheckDepthStencilMatch(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT, D3DFORMAT); +HRESULT WINAPI extCheckDeviceFormatConversion(void *, UINT, D3DDEVTYPE, D3DFORMAT, D3DFORMAT); +HRESULT WINAPI extD3DGetDeviceCaps(void *, UINT, D3DDEVTYPE, D3DCAPS9 *); +HMONITOR WINAPI extGetAdapterMonitor(void *, UINT); +HRESULT WINAPI extCreateDevice(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, void **); +HRESULT WINAPI extCreateDeviceEx(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, D3DDISPLAYMODEEX *, void **); + +RegisterSoftwareDevice_Type pRegisterSoftwareDevice = 0; +GetAdapterCount_Type pGetAdapterCount8 = 0; +GetAdapterCount_Type pGetAdapterCount9 = 0; +GetAdapterIdentifier_Type pGetAdapterIdentifier8 = 0; +GetAdapterIdentifier_Type pGetAdapterIdentifier9 = 0; +GetAdapterModeCount_Type pGetAdapterModeCount = 0; +CheckDeviceType_Type pCheckDeviceType = 0; +CheckDeviceFormat_Type pCheckDeviceFormat = 0; +CheckDeviceMultiSampleType_Type pCheckDeviceMultiSampleType = 0; +CheckDepthStencilMatch_Type pCheckDepthStencilMatch = 0; +CheckDeviceFormatConversion_Type pCheckDeviceFormatConversion = 0; +D3DGetDeviceCaps_Type pD3DGetDeviceCaps = 0; +GetAdapterMonitor_Type pGetAdapterMonitor = 0; +CreateDevice_Type pCreateDevice8 = 0; +CreateDevice_Type pCreateDevice9 = 0; +CreateDeviceEx_Type pCreateDeviceEx = 0; + +// IDirect3DDevice8/9 methods + +typedef HRESULT (WINAPI *TestCooperativeLevel_Type)(void *); typedef HRESULT (WINAPI *GetDirect3D8_Type)(void *, void **); typedef HRESULT (WINAPI *GetDirect3D9_Type)(void *, void **); -typedef HRESULT (WINAPI *GetViewport_Type)(void *, D3DVIEWPORT9 *); -typedef HRESULT (WINAPI *SetViewport_Type)(void *, D3DVIEWPORT9 *); -typedef void (WINAPI *SetGammaRamp_Type)(void *, UINT, DWORD, D3DGAMMARAMP *); -typedef void (WINAPI *GetGammaRamp_Type)(void *, UINT, D3DGAMMARAMP *); +typedef HRESULT (WINAPI *GetDisplayMode8_Type)(void *, D3DDISPLAYMODE *); +typedef HRESULT (WINAPI *GetDisplayMode9_Type)(void *, UINT, D3DDISPLAYMODE *); typedef void (WINAPI *SetCursorPosition9_Type)(void *, int, int, DWORD); typedef void (WINAPI *SetCursorPosition8_Type)(void *, int, int, DWORD); typedef BOOL (WINAPI *ShowCursor8_Type)(void *, BOOL); typedef BOOL (WINAPI *ShowCursor9_Type)(void *, BOOL); +typedef HRESULT (WINAPI *CreateAdditionalSwapChain_Type)(void *, D3DPRESENT_PARAMETERS *, IDirect3DSwapChain9 **); +typedef HRESULT (WINAPI *GetSwapChain_Type)(void *, UINT, IDirect3DSwapChain9**); +typedef UINT (WINAPI *GetNumberOfSwapChains_Type)(void *); +typedef HRESULT (WINAPI *BeginStateBlock_Type)(void *); +typedef HRESULT (WINAPI *EndStateBlock8_Type)(void *, DWORD *); +typedef HRESULT (WINAPI *EndStateBlock9_Type)(void *, IDirect3DStateBlock9**); + +HRESULT WINAPI extTestCooperativeLevel(void *); +HRESULT WINAPI extGetDirect3D8(void *, void **); +HRESULT WINAPI extGetDirect3D9(void *, void **); +HRESULT WINAPI extGetDisplayMode8(void *, D3DDISPLAYMODE *); +HRESULT WINAPI extGetDisplayMode9(void *, UINT, D3DDISPLAYMODE *); +void WINAPI extSetCursorPosition9(void *, int, int, DWORD); +void WINAPI extSetCursorPosition8(void *, int, int, DWORD); +BOOL WINAPI extShowCursor8(void *, BOOL); +BOOL WINAPI extShowCursor9(void *, BOOL); +HRESULT WINAPI extCreateAdditionalSwapChain(void *, D3DPRESENT_PARAMETERS *, IDirect3DSwapChain9 **); +HRESULT WINAPI extGetSwapChain(void *, UINT, IDirect3DSwapChain9**); +UINT WINAPI extGetNumberOfSwapChains(void *); +HRESULT WINAPI extBeginStateBlock8(void *); +HRESULT WINAPI extBeginStateBlock9(void *); +HRESULT WINAPI extEndStateBlock8(void *, DWORD *); +HRESULT WINAPI extEndStateBlock9(void *, IDirect3DStateBlock9**); + +TestCooperativeLevel_Type pTestCooperativeLevel = 0; +GetDirect3D8_Type pGetDirect3D8 = 0; +GetDirect3D9_Type pGetDirect3D9 = 0; +GetDisplayMode8_Type pGetDisplayMode8 = 0; +GetDisplayMode9_Type pGetDisplayMode9 = 0; +SetCursorPosition9_Type pSetCursorPosition9 = 0; +SetCursorPosition8_Type pSetCursorPosition8 = 0; +ShowCursor8_Type pShowCursor8 = 0; +ShowCursor9_Type pShowCursor9 = 0; +CreateAdditionalSwapChain_Type pCreateAdditionalSwapChain = 0; +GetSwapChain_Type pGetSwapChain = 0; +GetNumberOfSwapChains_Type pGetNumberOfSwapChains = 0; +BeginStateBlock_Type pBeginStateBlock8 = 0; +BeginStateBlock_Type pBeginStateBlock9 = 0; +EndStateBlock8_Type pEndStateBlock8 = 0; +EndStateBlock9_Type pEndStateBlock9 = 0; + +// to sort ... + +typedef HRESULT (WINAPI *Present_Type)(void *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *); +typedef HRESULT (WINAPI *SetRenderState_Type)(void *, D3DRENDERSTATETYPE, DWORD); +typedef HRESULT (WINAPI *GetRenderState_Type)(void *, D3DRENDERSTATETYPE, DWORD ); +typedef HRESULT (WINAPI *GetViewport_Type)(void *, D3DVIEWPORT9 *); +typedef HRESULT (WINAPI *SetViewport_Type)(void *, D3DVIEWPORT9 *); +typedef void (WINAPI *SetGammaRamp_Type)(void *, UINT, DWORD, D3DGAMMARAMP *); +typedef void (WINAPI *GetGammaRamp_Type)(void *, UINT, D3DGAMMARAMP *); typedef HRESULT (WINAPI *SetTexture8_Type)(void *, DWORD, void *); typedef HRESULT (WINAPI *SetTexture9_Type)(void *, DWORD, void *); @@ -66,39 +168,20 @@ HRESULT WINAPI extQueryInterfaceD3D8(void *, REFIID, void** ); HRESULT WINAPI extQueryInterfaceDev8(void *, REFIID, void** ); HRESULT WINAPI extQueryInterfaceD3D9(void *, REFIID, void** ); HRESULT WINAPI extQueryInterfaceDev9(void *, REFIID, void** ); -HRESULT WINAPI extGetDirect3D8(void *, void **); -HRESULT WINAPI extGetDirect3D9(void *, void **); -void* WINAPI extDirect3DCreate8(UINT); -void* WINAPI extDirect3DCreate9(UINT); -HRESULT WINAPI extDirect3DCreate9Ex(UINT, IDirect3D9Ex **); -HRESULT WINAPI extCheckFullScreen(void); -UINT WINAPI extGetAdapterCount8(void *); -UINT WINAPI extGetAdapterCount9(void *); -HRESULT WINAPI extGetAdapterIdentifier8(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); -HRESULT WINAPI extGetAdapterIdentifier9(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); -HRESULT WINAPI extCreateDevice(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, void **); -HRESULT WINAPI extCreateDeviceEx(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, D3DDISPLAYMODEEX *, void **); HRESULT WINAPI extEnumAdapterModes8(void *, UINT, UINT , D3DDISPLAYMODE *); HRESULT WINAPI extEnumAdapterModes9(void *, UINT, D3DFORMAT, UINT , D3DDISPLAYMODE *); HRESULT WINAPI extGetAdapterDisplayMode8(void *, UINT, D3DDISPLAYMODE *); HRESULT WINAPI extGetAdapterDisplayMode9(void *, UINT, D3DDISPLAYMODE *); -HRESULT WINAPI extGetDisplayMode8(void *, D3DDISPLAYMODE *); -HRESULT WINAPI extGetDisplayMode9(void *, UINT, D3DDISPLAYMODE *); HRESULT WINAPI extPresent(void *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *); HRESULT WINAPI extSetRenderState(void *, D3DRENDERSTATETYPE, DWORD); HRESULT WINAPI extGetRenderState(void *, D3DRENDERSTATETYPE, DWORD); -HRESULT WINAPI extCreateAdditionalSwapChain(void *, D3DPRESENT_PARAMETERS *, IDirect3DSwapChain9 **); HRESULT WINAPI extGetViewport(void *, D3DVIEWPORT9 *); HRESULT WINAPI extSetViewport(void *, D3DVIEWPORT9 *); HRESULT WINAPI extReset(void *, D3DPRESENT_PARAMETERS *); void WINAPI extSetGammaRamp(void *, UINT, DWORD, D3DGAMMARAMP *); void WINAPI extGetGammaRamp(void *, UINT, D3DGAMMARAMP *); -void WINAPI extSetCursorPosition9(void *, int, int, DWORD); -void WINAPI extSetCursorPosition8(void *, int, int, DWORD); -BOOL WINAPI extShowCursor8(void *, BOOL); -BOOL WINAPI extShowCursor9(void *, BOOL); ULONG WINAPI extAddRef9(void *); ULONG WINAPI extRelease9(void *); BOOL WINAPI voidDisableD3DSpy(void); @@ -112,7 +195,6 @@ ULONG WINAPI extEndScene9(void *); ULONG WINAPI extSetTexture8(void *, DWORD, void *); ULONG WINAPI extSetTexture9(void *, DWORD, void *); - HRESULT WINAPI extD3D10CreateDevice(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, ID3D10Device **); HRESULT WINAPI extD3D10CreateDeviceAndSwapChain(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, DXGI_SWAP_CHAIN_DESC *, IDXGISwapChain **, ID3D10Device **); HRESULT WINAPI extD3D10CreateDevice1(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, D3D10_FEATURE_LEVEL1, UINT, ID3D10Device **); @@ -128,38 +210,22 @@ QueryInterface_Type pQueryInterfaceDev8 = 0; QueryInterface_Type pQueryInterfaceD3D9 = 0; QueryInterface_Type pQueryInterfaceDev9 = 0; -GetDirect3D8_Type pGetDirect3D8 = 0; -GetDirect3D9_Type pGetDirect3D9 = 0; Direct3DCreate8_Type pDirect3DCreate8 = 0; Direct3DCreate9_Type pDirect3DCreate9 = 0; Direct3DCreate9Ex_Type pDirect3DCreate9Ex = 0; CheckFullScreen_Type pCheckFullScreen = 0; -GetAdapterCount_Type pGetAdapterCount8 = 0; -GetAdapterCount_Type pGetAdapterCount9 = 0; -GetAdapterIdentifier_Type pGetAdapterIdentifier8 = 0; -GetAdapterIdentifier_Type pGetAdapterIdentifier9 = 0; -CreateDevice_Type pCreateDevice8 = 0; -CreateDevice_Type pCreateDevice9 = 0; -CreateDeviceEx_Type pCreateDeviceEx = 0; EnumAdapterModes8_Type pEnumAdapterModes8 = 0; EnumAdapterModes9_Type pEnumAdapterModes9 = 0; GetAdapterDisplayMode_Type pGetAdapterDisplayMode8 = 0; GetAdapterDisplayMode_Type pGetAdapterDisplayMode9 = 0; -GetDisplayMode8_Type pGetDisplayMode8 = 0; -GetDisplayMode9_Type pGetDisplayMode9 = 0; Present_Type pPresent = 0; SetRenderState_Type pSetRenderState = 0; GetRenderState_Type pGetRenderState = 0; -CreateAdditionalSwapChain_Type pCreateAdditionalSwapChain = 0; GetViewport_Type pGetViewport = 0; SetViewport_Type pSetViewport = 0; SetGammaRamp_Type pSetGammaRamp = 0; GetGammaRamp_Type pGetGammaRamp = 0; -SetCursorPosition9_Type pSetCursorPosition9 = 0; -SetCursorPosition8_Type pSetCursorPosition8 = 0; -ShowCursor8_Type pShowCursor8 = 0; -ShowCursor9_Type pShowCursor9 = 0; CreateRenderTarget8_Type pCreateRenderTarget8 = 0; BeginScene_Type pBeginScene8 = 0; @@ -183,276 +249,106 @@ Release_Type pRelease9 = 0; DWORD dwD3DVersion; +static HookEntry_Type d3d8Hooks[]={ + {HOOK_HOT_CANDIDATE, "Direct3DCreate8", (FARPROC)NULL, (FARPROC *)&pDirect3DCreate8, (FARPROC)extDirect3DCreate8}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + + +static HookEntry_Type d3d9Hooks[]={ + {HOOK_HOT_CANDIDATE, "Direct3DCreate9", (FARPROC)NULL, (FARPROC *)&pDirect3DCreate9, (FARPROC)extDirect3DCreate9}, + {HOOK_HOT_CANDIDATE, "Direct3DCreate9Ex", (FARPROC)NULL, (FARPROC *)&pDirect3DCreate9Ex, (FARPROC)extDirect3DCreate9Ex}, + {HOOK_HOT_CANDIDATE, "CheckFullScreen", (FARPROC)NULL, (FARPROC *)&pCheckFullScreen, (FARPROC)extCheckFullScreen}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + +static HookEntry_Type d3d9Extra[]={ + {HOOK_HOT_CANDIDATE, "Direct3DShaderValidatorCreate9", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)voidDirect3DShaderValidatorCreate9}, + {HOOK_HOT_CANDIDATE, "DebugSetLevel", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)voidDebugSetLevel}, + {HOOK_HOT_CANDIDATE, "DebugSetMute", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)voidDebugSetMute}, + {HOOK_HOT_CANDIDATE, "DisableD3DSpy", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)voidDisableD3DSpy}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + +static HookEntry_Type d3d10Hooks[]={ + {HOOK_HOT_CANDIDATE, "D3D10CreateDevice", (FARPROC)NULL, (FARPROC *)&pD3D10CreateDevice, (FARPROC)extD3D10CreateDevice}, + {HOOK_HOT_CANDIDATE, "D3D10CreateDeviceAndSwapChain", (FARPROC)NULL, (FARPROC *)&pD3D10CreateDeviceAndSwapChain, (FARPROC)extD3D10CreateDeviceAndSwapChain}, + {HOOK_HOT_CANDIDATE, "CheckFullScreen", (FARPROC)NULL, (FARPROC *)&pCheckFullScreen, (FARPROC)extCheckFullScreen}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + +static HookEntry_Type d3d10_1Hooks[]={ + {HOOK_HOT_CANDIDATE, "D3D11CreateDevice", (FARPROC)NULL, (FARPROC *)&pD3D11CreateDevice, (FARPROC)extD3D11CreateDevice}, + {HOOK_HOT_CANDIDATE, "D3D11CreateDeviceAndSwapChain", (FARPROC)NULL, (FARPROC *)&pD3D11CreateDeviceAndSwapChain, (FARPROC)extD3D11CreateDeviceAndSwapChain}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + +static HookEntry_Type d3d11Hooks[]={ + {HOOK_HOT_CANDIDATE, "D3D10CreateDevice1", (FARPROC)NULL, (FARPROC *)&pD3D10CreateDevice1, (FARPROC)extD3D10CreateDevice1}, + {HOOK_HOT_CANDIDATE, "D3D10CreateDeviceAndSwapChain1", (FARPROC)NULL, (FARPROC *)&pD3D10CreateDeviceAndSwapChain1, (FARPROC)extD3D10CreateDeviceAndSwapChain1}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator +}; + FARPROC Remap_d3d8_ProcAddress(LPCSTR proc, HMODULE hModule) { - if (!strcmp(proc,"Direct3DCreate8") && !pDirect3DCreate8){ - pDirect3DCreate8=(Direct3DCreate8_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pDirect3DCreate8); - return (FARPROC)extDirect3DCreate8; - } - // NULL -> keep the original call address + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, d3d8Hooks)) return addr; return NULL; } -HRESULT WINAPI voidDirect3DShaderValidatorCreate9(void) -{ - OutTraceDW("Direct3DShaderValidatorCreate9: SUPPRESSED\n"); - return 0; -} - -void WINAPI voidDebugSetLevel(void) -{ - OutTraceDW("DebugSetLevel: SUPPRESSED\n"); -} - -void WINAPI voidDebugSetMute(void) -{ - OutTraceDW("DebugSetMute: SUPPRESSED\n"); -} - -BOOL WINAPI voidDisableD3DSpy(void) -{ - OutTraceDW("DisableD3DSpy: SUPPRESSED\n"); - return FALSE; -} - FARPROC Remap_d3d9_ProcAddress(LPCSTR proc, HMODULE hModule) { - if (!strcmp(proc,"Direct3DCreate9")){ - if(!pDirect3DCreate9) pDirect3DCreate9=(Direct3DCreate9_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pDirect3DCreate9); - return (FARPROC)extDirect3DCreate9; - } - if (!strcmp(proc,"Direct3DCreate9Ex")){ - if(!pDirect3DCreate9Ex) pDirect3DCreate9Ex=(Direct3DCreate9Ex_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pDirect3DCreate9Ex); - return (FARPROC)extDirect3DCreate9Ex; - } - if (!strcmp(proc,"CheckFullScreen")){ - if(!pCheckFullScreen) pCheckFullScreen=(CheckFullScreen_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pCheckFullScreen); - return (FARPROC)extCheckFullScreen; - } - - if (!(dxw.dwFlags3 & SUPPRESSD3DEXT)) return NULL; - - if (!strcmp(proc,"Direct3DShaderValidatorCreate9")){ - OutTraceDW("GetProcAddress: suppressing Direct3DShaderValidatorCreate9\n"); - return (FARPROC)voidDirect3DShaderValidatorCreate9; - } - if (!strcmp(proc,"DebugSetLevel")){ - OutTraceDW("GetProcAddress: suppressing DebugSetLevel\n"); - return (FARPROC)voidDebugSetLevel; - } - if (!strcmp(proc,"DebugSetMute")){ - OutTraceDW("GetProcAddress: suppressing DebugSetMute\n"); - return (FARPROC)voidDebugSetMute; - } - if (!strcmp(proc,"DisableD3DSpy")){ - OutTraceDW("GetProcAddress: suppressing DisableD3DSpy\n"); - return (FARPROC)voidDisableD3DSpy; - } + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, d3d9Hooks)) return addr; + if (dxw.dwFlags3 & SUPPRESSD3DEXT) if (addr=RemapLibrary(proc, hModule, d3d9Extra)) return addr; return NULL; } FARPROC Remap_d3d10_ProcAddress(LPCSTR proc, HMODULE hModule) { - if (!strcmp(proc,"D3D10CreateDevice") && !pD3D10CreateDevice){ - pD3D10CreateDevice=(D3D10CreateDevice_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D10CreateDevice); - return (FARPROC)extD3D10CreateDevice; - } - if (!strcmp(proc,"D3D10CreateDeviceAndSwapChain") && !pD3D10CreateDeviceAndSwapChain){ - pD3D10CreateDeviceAndSwapChain=(D3D10CreateDeviceAndSwapChain_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D10CreateDeviceAndSwapChain); - return (FARPROC)extD3D10CreateDeviceAndSwapChain; - } - // NULL -> keep the original call address + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, d3d10Hooks)) return addr; return NULL; } -FARPROC Remap_d3d10_1_ProcAddress(LPCSTR proc, HMODULE hModule) +FARPROC Remap_d3d10_1_ProcAddress(LPCSTR proc, HMODULE hModule) { - if (!strcmp(proc,"D3D10CreateDevice1") && !pD3D10CreateDevice1){ - pD3D10CreateDevice1=(D3D10CreateDevice1_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D10CreateDevice1); - return (FARPROC)extD3D10CreateDevice1; - } - if (!strcmp(proc,"D3D10CreateDeviceAndSwapChain1") && !pD3D10CreateDeviceAndSwapChain1){ - pD3D10CreateDeviceAndSwapChain1=(D3D10CreateDeviceAndSwapChain1_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D10CreateDeviceAndSwapChain1); - return (FARPROC)extD3D10CreateDeviceAndSwapChain1; - } - // NULL -> keep the original call address + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, d3d10_1Hooks)) return addr; return NULL; } FARPROC Remap_d3d11_ProcAddress(LPCSTR proc, HMODULE hModule) { - if (!strcmp(proc,"D3D11CreateDevice") && !pD3D11CreateDevice){ - pD3D11CreateDevice=(D3D11CreateDevice_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D11CreateDevice); - return (FARPROC)extD3D11CreateDevice; - } - if (!strcmp(proc,"D3D11CreateDeviceAndSwapChain") && !pD3D11CreateDeviceAndSwapChain){ - pD3D11CreateDeviceAndSwapChain=(D3D11CreateDeviceAndSwapChain_Type)(*pGetProcAddress)(hModule, proc); - OutTraceDW("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pD3D11CreateDeviceAndSwapChain); - return (FARPROC)extD3D11CreateDeviceAndSwapChain; - } - // NULL -> keep the original call address + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, d3d11Hooks)) return addr; return NULL; } int HookDirect3D(HMODULE module, int version){ - HINSTANCE hinst; - void *tmp; - LPDIRECT3D9 lpd3d; - ID3D10Device *lpd3d10; - ID3D11Device *lpd3d11; - HRESULT res; - switch(version){ case 0: - // D3D8 - tmp = HookAPI(module, "d3d8.dll", NULL, "Direct3DCreate8", extDirect3DCreate8); - if(tmp) pDirect3DCreate8 = (Direct3DCreate8_Type)tmp; - // D3D9 - tmp = HookAPI(module, "d3d9.dll", NULL, "Direct3DCreate9", extDirect3DCreate9); - if(tmp) pDirect3DCreate9 = (Direct3DCreate9_Type)tmp; - tmp = HookAPI(module, "d3d9.dll", NULL, "Direct3DCreate9Ex", extDirect3DCreate9Ex); - if(tmp) pDirect3DCreate9Ex = (Direct3DCreate9Ex_Type)tmp; - tmp = HookAPI(module, "d3d9.dll", NULL, "CheckFullScreen", extCheckFullScreen); - if(tmp) pCheckFullScreen = (CheckFullScreen_Type)tmp; + HookLibrary(module, d3d8Hooks, "d3d8.dll"); + HookLibrary(module, d3d9Hooks, "d3d9.dll"); #ifdef HOOKD3D10ANDLATER - // D3D10 - tmp = HookAPI(module, "d3d10.dll", NULL, "D3D10CreateDevice", extD3D10CreateDevice); - if(tmp) pD3D10CreateDevice = (D3D10CreateDevice_Type)tmp; - tmp = HookAPI(module, "d3d10.dll", NULL, "D3D10CreateDeviceAndSwapChain", extD3D10CreateDeviceAndSwapChain); - if(tmp) pD3D10CreateDeviceAndSwapChain = (D3D10CreateDeviceAndSwapChain_Type)tmp; - // D3D10.1 - tmp = HookAPI(module, "d3d10_1.dll", NULL, "D3D10CreateDevice1", extD3D10CreateDevice1); - if(tmp) pD3D10CreateDevice1 = (D3D10CreateDevice1_Type)tmp; - tmp = HookAPI(module, "d3d10_1.dll", NULL, "D3D10CreateDeviceAndSwapChain1", extD3D10CreateDeviceAndSwapChain); - if(tmp) pD3D10CreateDeviceAndSwapChain1 = (D3D10CreateDeviceAndSwapChain1_Type)tmp; - // D3D11 - tmp = HookAPI(module, "d3d11.dll", NULL, "D3D11CreateDevice", extD3D11CreateDevice); - if(tmp) pD3D11CreateDevice = (D3D11CreateDevice_Type)tmp; - tmp = HookAPI(module, "d3d11.dll", NULL, "D3D11CreateDeviceAndSwapChain", extD3D11CreateDeviceAndSwapChain); - if(tmp) pD3D11CreateDeviceAndSwapChain = (D3D11CreateDeviceAndSwapChain_Type)tmp; + HookLibrary(module, d3d10Hooks, "d3d10.dll"); + HookLibrary(module, d3d10_1Hooks, "d3d10_1.dll"); + HookLibrary(module, d3d11Hooks, "d3d11.dll"); #endif break; case 8: - hinst = LoadLibrary("d3d8.dll"); - pDirect3DCreate8 = - (Direct3DCreate8_Type)GetProcAddress(hinst, "Direct3DCreate8"); - if(pDirect3DCreate8){ - lpd3d = (LPDIRECT3D9)extDirect3DCreate8(220); - if(lpd3d) lpd3d->Release(); - } + HookLibrary(module, d3d8Hooks, "d3d8.dll"); break; case 9: - hinst = (*pLoadLibraryA)("d3d9.dll"); - pDirect3DCreate9 = - (Direct3DCreate9_Type)(*pGetProcAddress)(hinst, "Direct3DCreate9"); - pDirect3DCreate9Ex = - (Direct3DCreate9Ex_Type)(*pGetProcAddress)(hinst, "Direct3DCreate9Ex"); - pCheckFullScreen = - (CheckFullScreen_Type)(*pGetProcAddress)(hinst, "CheckFullScreen"); - if(pDirect3DCreate9){ - lpd3d = (LPDIRECT3D9)extDirect3DCreate9(31); - if(lpd3d) lpd3d->Release(); - } + HookLibrary(module, d3d9Hooks, "d3d9.dll"); break; #ifdef HOOKD3D10ANDLATER case 10: - hinst = (*pLoadLibraryA)("d3d10.dll"); - pD3D10CreateDevice = - (D3D10CreateDevice_Type)(*pGetProcAddress)(hinst, "D3D10CreateDevice"); - if(pD3D10CreateDevice){ - res = extD3D10CreateDevice( - NULL, - D3D10_DRIVER_TYPE_HARDWARE, - NULL, - 0, - D3D10_SDK_VERSION, - &lpd3d10); - if(res==DD_OK) lpd3d10->Release(); - } - hinst = (*pLoadLibraryA)("d3d10_1.dll"); - pD3D10CreateDevice1 = - (D3D10CreateDevice1_Type)(*pGetProcAddress)(hinst, "D3D10CreateDevice1"); - break; - if(pD3D10CreateDevice1){ - res = extD3D10CreateDevice1( - NULL, - D3D10_DRIVER_TYPE_HARDWARE, - NULL, - 0, - D3D10_FEATURE_LEVEL_10_1, - D3D10_SDK_VERSION, - &lpd3d10); - if(res==DD_OK) lpd3d10->Release(); - } - pD3D10CreateDeviceAndSwapChain = - (D3D10CreateDeviceAndSwapChain_Type)(*pGetProcAddress)(hinst, "D3D10CreateDeviceAndSwapChain"); - if(pD3D10CreateDeviceAndSwapChain){ - DXGI_SWAP_CHAIN_DESC swapChainDesc; - IDXGISwapChain *pSwapChain; - ZeroMemory(&swapChainDesc, sizeof(swapChainDesc)); - - //set buffer dimensions and format - swapChainDesc.BufferCount = 2; - swapChainDesc.BufferDesc.Width = dxw.GetScreenWidth(); - swapChainDesc.BufferDesc.Height = dxw.GetScreenHeight(); - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;; - - //set refresh rate - swapChainDesc.BufferDesc.RefreshRate.Numerator = 60; - swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; - - //sampling settings - swapChainDesc.SampleDesc.Quality = 0; - swapChainDesc.SampleDesc.Count = 1; - - //output window handle - swapChainDesc.OutputWindow = dxw.GethWnd(); - swapChainDesc.Windowed = true; - res = extD3D10CreateDeviceAndSwapChain( - NULL, - D3D10_DRIVER_TYPE_HARDWARE, - NULL, - 0, - D3D10_SDK_VERSION, - &swapChainDesc, - &pSwapChain, - &lpd3d10); - if(res==DD_OK) lpd3d10->Release(); - } + HookLibrary(module, d3d10Hooks, "d3d10.dll"); + HookLibrary(module, d3d10_1Hooks, "d3d10_1.dll"); break; case 11: - hinst = (*pLoadLibraryA)("d3d11.dll"); - pD3D11CreateDevice = - (D3D11CreateDevice_Type)(*pGetProcAddress)(hinst, "D3D11CreateDevice"); - if(pD3D11CreateDevice){ - D3D_FEATURE_LEVEL FeatureLevel; - ID3D11DeviceContext *pImmediateContext; - res = extD3D11CreateDevice( - NULL, - D3D_DRIVER_TYPE_HARDWARE, - NULL, - 0, // flags - NULL, // FeatureLevels - 0, - D3D11_SDK_VERSION, - &lpd3d11, - &FeatureLevel, - &pImmediateContext); - if(res==DD_OK) lpd3d11->Release(); - } - pD3D11CreateDeviceAndSwapChain = - (D3D11CreateDeviceAndSwapChain_Type)(*pGetProcAddress)(hinst, "D3D11CreateDeviceAndSwapChain"); - break; + HookLibrary(module, d3d11Hooks, "d3d11.dll"); #endif } if(pDirect3DCreate8 || pDirect3DCreate9) return 1; @@ -461,7 +357,7 @@ int HookDirect3D(HMODULE module, int version){ void HookD3DDevice8(void** ppD3Ddev8) { - OutTraceDW("Device hook for IID_IDirect3DDevice8 interface\n"); + OutTraceD3D("Device hook for IID_IDirect3DDevice8 interface\n"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 0), extQueryInterfaceDev8, (void **)&pQueryInterfaceDev8, "QueryInterface(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 24), extGetDirect3D8, (void **)&pGetDirect3D8, "GetDirect3D(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 32), extGetDisplayMode8, (void **)&pGetDisplayMode8, "GetDisplayMode(D8)"); @@ -485,6 +381,8 @@ void HookD3DDevice8(void** ppD3Ddev8) if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_ZFUNC, D3DCMP_ALWAYS); //if(1) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_SPECULARENABLE, TRUE); } + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 208), extBeginStateBlock8, (void **)&pBeginStateBlock8, "BeginStateBlock(D8)"); + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 212), extEndStateBlock8, (void **)&pEndStateBlock8, "EndStateBlock(D8)"); if (dxw.dwFlags4 & NOTEXTURES) SetHook((void *)(**(DWORD **)ppD3Ddev8 + 244), extSetTexture8, (void **)&pSetTexture8, "SetTexture(D8)"); //if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; //SetHook((void *)(**(DWORD **)ppD3Ddev8 + 4), extAddRef8, (void **)&pAddRef8, "AddRef(D8)"); @@ -493,13 +391,15 @@ void HookD3DDevice8(void** ppD3Ddev8) void HookD3DDevice9(void** ppD3Ddev9) { - OutTraceDW("Device hook for IID_IDirect3DDevice9 interface\n"); + OutTraceD3D("Device hook for IID_IDirect3DDevice9 interface\n"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 0), extQueryInterfaceDev9, (void **)&pQueryInterfaceDev9, "QueryInterface(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 24), extGetDirect3D9, (void **)&pGetDirect3D9, "GetDirect3D(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 32), extGetDisplayMode9, (void **)&pGetDisplayMode9, "GetDisplayMode(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 44), extSetCursorPosition9, (void **)&pSetCursorPosition9, "SetCursorPosition(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 48), extShowCursor9, (void **)&pShowCursor9, "ShowCursor(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 52), extCreateAdditionalSwapChain, (void **)&pCreateAdditionalSwapChain, "CreateAdditionalSwapChain(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 56), extGetSwapChain, (void **)&pGetSwapChain, "GetSwapChain(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 60), extGetNumberOfSwapChains, (void **)&pGetNumberOfSwapChains, "extGetNumberOfSwapChains(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 64), extReset, (void **)&pReset, "Reset(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 68), extPresent, (void **)&pPresent, "Present(D9)"); if(dxw.dwFlags2 & DISABLEGAMMARAMP){ @@ -518,10 +418,17 @@ void HookD3DDevice9(void** ppD3Ddev9) if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_ZFUNC, D3DCMP_ALWAYS); //if(1) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_SPECULARENABLE, TRUE); } - if (dxw.dwFlags4 & NOTEXTURES) SetHook((void *)(**(DWORD **)ppD3Ddev9 + 260), extSetTexture9, (void **)&pSetTexture9, "SetTexture(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 240), extBeginStateBlock9, (void **)&pBeginStateBlock9, "BeginStateBlock(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 244), extEndStateBlock9, (void **)&pEndStateBlock9, "EndStateBlock(D9)"); + if (dxw.dwFlags4 & NOTEXTURES) { + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 260), extSetTexture9, (void **)&pSetTexture9, "SetTexture(D9)"); + } if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; SetHook((void *)(**(DWORD **)ppD3Ddev9 + 4), extAddRef9, (void **)&pAddRef9, "AddRef(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 8), extRelease9, (void **)&pRelease9, "Release(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 12), extTestCooperativeLevel, (void **)&pTestCooperativeLevel, "TestCooperativeLevel(D9)"); + + } void HookDirect3D8(void *lpd3d) @@ -560,6 +467,16 @@ void HookDirect3D9(void *lpd3d, BOOL ex) SetHook((void *)(*(DWORD *)lpd3d + 32), extGetAdapterDisplayMode9, (void **)&pGetAdapterDisplayMode9, "GetAdapterDisplayMode(D9)"); SetHook((void *)(*(DWORD *)lpd3d + 64), extCreateDevice, (void **)&pCreateDevice9, "CreateDevice(D9)"); if(ex) SetHook((void *)(*(DWORD *)lpd3d + 80), extCreateDeviceEx, (void **)&pCreateDeviceEx, "CreateDeviceEx(D9)"); + if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; + SetHook((void *)(*(DWORD *)lpd3d + 12), extRegisterSoftwareDevice, (void **)&pRegisterSoftwareDevice, "RegisterSoftwareDevice(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 24), extGetAdapterModeCount, (void **)&pGetAdapterModeCount, "GetAdapterModeCount(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 36), extCheckDeviceType, (void **)&pCheckDeviceType, "CheckDeviceType(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 40), extCheckDeviceFormat, (void **)&pCheckDeviceFormat, "CheckDeviceFormat(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 44), extCheckDeviceMultiSampleType, (void **)&pCheckDeviceMultiSampleType, "CheckDeviceMultiSampleType(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 48), extCheckDepthStencilMatch, (void **)&pCheckDepthStencilMatch, "CheckDepthStencilMatch(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 52), extCheckDeviceFormatConversion, (void **)&pCheckDeviceFormatConversion, "CheckDeviceFormatConversion(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 56), extD3DGetDeviceCaps, (void **)&pD3DGetDeviceCaps, "GetDeviceCaps(D9)"); + SetHook((void *)(*(DWORD *)lpd3d + 60), extGetAdapterMonitor, (void **)&pGetAdapterMonitor, "GetAdapterMonitor(D9)"); } void* WINAPI extDirect3DCreate9(UINT sdkversion) @@ -604,7 +521,7 @@ UINT WINAPI extGetAdapterCount8(void *lpd3d) res=(*pGetAdapterCount8)(lpd3d); OutTraceD3D("GetAdapterCount(8): count=%d\n", res); if(dxw.dwFlags2 & HIDEMULTIMONITOR) { - OutTraceDW("GetAdapterCount: HIDEMULTIMONITOR count=1\n"); + OutTraceD3D("GetAdapterCount: HIDEMULTIMONITOR count=1\n"); res=1; } return res; @@ -616,7 +533,7 @@ UINT WINAPI extGetAdapterCount9(void *lpd3d) res=(*pGetAdapterCount9)(lpd3d); OutTraceD3D("GetAdapterCount(9): count=%d\n", res); if(dxw.dwFlags2 & HIDEMULTIMONITOR) { - OutTraceDW("GetAdapterCount: HIDEMULTIMONITOR count=1\n"); + OutTraceD3D("GetAdapterCount: HIDEMULTIMONITOR count=1\n"); res=1; } return res; @@ -661,12 +578,12 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) HRESULT res; DWORD param[64], *tmp; D3DDISPLAYMODE mode; - int Windowed; + DWORD Windowed; void *pD3D; memcpy(param, pPresParam, (dwD3DVersion == 9)?56:52); - if(IsTraceDW){ + if(IsTraceD3D){ tmp = param; OutTrace("D3D%d::Reset\n", dwD3DVersion); OutTrace(" BackBufferWidth = %i\n", *(tmp ++)); @@ -677,7 +594,7 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++)); OutTrace(" SwapEffect = 0x%x\n", *(tmp ++)); OutTrace(" hDeviceWindow = 0x%x\n", *(tmp ++)); - OutTrace(" Windowed = %i\n", (Windowed=*(tmp ++))); + OutTrace(" Windowed = %i\n", *(tmp ++)); OutTrace(" EnableAutoDepthStencil = %i\n", *(tmp ++)); OutTrace(" AutoDepthStencilFormat = %i\n", *(tmp ++)); OutTrace(" Flags = 0x%x\n", *(tmp ++)); @@ -685,24 +602,25 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) OutTrace(" PresentationInterval = 0x%x\n", *(tmp ++)); } + Windowed = (dwD3DVersion == 8) ? param[7] : param[8]; if(dxw.Windowize){ if(Windowed) { // do not attempt to reset when returning to windowed mode: it is useless (you are windowed already) // and the code below (GetDirect3D, ...) doesn't work. - OutTraceDW("SKIPPED!\n"); + OutTraceD3D("SKIPPED!\n"); return DD_OK; } if (dwD3DVersion == 9){ res=(*pGetDirect3D9)(pd3dd, &pD3D); if(res) { - OutTraceDW("GetDirect3D FAILED! %x\n", res); + OutTraceD3D("GetDirect3D FAILED! %x\n", res); return(DD_OK); } - OutTraceDW("GetDirect3D pd3d=%x\n", pD3D); + OutTraceD3D("GetDirect3D pd3d=%x\n", pD3D); res=(*pGetAdapterDisplayMode9)(pD3D, 0, &mode); if(res) { - OutTraceDW("GetAdapterDisplayMode FAILED! %x\n", res); + OutTraceD3D("GetAdapterDisplayMode FAILED! %x\n", res); return(DD_OK); } param[2] = mode.Format; @@ -716,13 +634,13 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) else{ res=(*pGetDirect3D8)(pd3dd, &pD3D); if(res) { - OutTraceDW("GetDirect3D FAILED! %x\n", res); + OutTraceD3D("GetDirect3D FAILED! %x\n", res); return(DD_OK); } - OutTraceDW("GetDirect3D pd3d=%x\n", pD3D); + OutTraceD3D("GetDirect3D pd3d=%x\n", pD3D); res=(*pGetAdapterDisplayMode8)(pD3D, 0, &mode); if(res) { - OutTraceDW("GetAdapterDisplayMode FAILED! %x\n", res); + OutTraceD3D("GetAdapterDisplayMode FAILED! %x\n", res); return(DD_OK); } param[2] = mode.Format; @@ -738,18 +656,18 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) if(!(dxw.dwFlags4 & NOD3DRESET)){ res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); if(res == D3DERR_INVALIDCALL){ - OutTraceDW("FAILED! D3DERR_INVALIDCALL\n", res); + OutTraceD3D("FAILED! D3DERR_INVALIDCALL\n", res); return D3DERR_INVALIDCALL; } if(res){ - OutTraceDW("FAILED! %x\n", res); + OutTraceD3D("FAILED! %x\n", res); return res; } - OutTraceDW("SUCCESS!\n"); + OutTraceD3D("SUCCESS!\n"); (dwD3DVersion == 8) ? HookD3DDevice8(&pd3dd) : HookD3DDevice9(&pd3dd); } else{ - OutTraceDW("SKIPPED!\n"); + OutTraceD3D("SKIPPED!\n"); res=D3D_OK; } @@ -790,7 +708,7 @@ HRESULT WINAPI extGetDisplayMode8(void *lpd3d, D3DDISPLAYMODE *pMode) pMode->Width = dxw.GetScreenWidth(); pMode->Height = dxw.GetScreenHeight(); } - OutTraceDW("GetDisplayMode(8): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); + OutTraceD3D("GetDisplayMode(8): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); return res; } @@ -808,7 +726,7 @@ HRESULT WINAPI extGetDisplayMode9(void *lpd3d, UINT iSwapChain, D3DDISPLAYMODE * pMode->Width = dxw.GetScreenWidth(); pMode->Height = dxw.GetScreenHeight(); } - OutTraceDW("GetDisplayMode(9): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); + OutTraceD3D("GetDisplayMode(9): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); return res; } @@ -844,7 +762,7 @@ HRESULT WINAPI extGetAdapterDisplayMode8(void *lpd3d, UINT Adapter, D3DDISPLAYMO pMode->Width = dxw.GetScreenWidth(); pMode->Height = dxw.GetScreenHeight(); } - OutTraceDW("GetAdapterDisplayMode(8): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); + OutTraceD3D("GetAdapterDisplayMode(8): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); return res; } @@ -862,7 +780,7 @@ HRESULT WINAPI extGetAdapterDisplayMode9(void *lpd3d, UINT Adapter, D3DDISPLAYMO pMode->Width = dxw.GetScreenWidth(); pMode->Height = dxw.GetScreenHeight(); } - OutTraceDW("GetAdapterDisplayMode(9): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); + OutTraceD3D("GetAdapterDisplayMode(9): fixed size=(%dx%d)\n", pMode->Width, pMode->Height); return res; } @@ -884,7 +802,7 @@ void FixD3DWindowFrame(HWND hfocuswindow) workarea.left, workarea.top, workarea.right-workarea.left, workarea.bottom-workarea.top, dxw.GethWnd(), NULL, NULL, NULL); if (hfocuswindow) - OutTraceDW("CreateDevice: updated hfocuswindow=%x pos=(%d,%d) size=(%d,%d)\n", + OutTraceD3D("CreateDevice: updated hfocuswindow=%x pos=(%d,%d) size=(%d,%d)\n", hfocuswindow, workarea.left, workarea.top, workarea.right-workarea.left, workarea.bottom-workarea.top); else OutTraceE("CreateDevice: CreateWindowEx ERROR err=%d\n", GetLastError()); @@ -898,7 +816,6 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, HRESULT res; DWORD param[64], *tmp; D3DDISPLAYMODE mode; - int Windowed; OutTraceD3D("CreateDevice: D3DVersion=%d lpd3d=%x adapter=%x hFocusWnd=%x behavior=%x, size=(%d,%d)\n", dwD3DVersion, lpd3d, adapter, hfocuswindow, behaviorflags, ppresentparam->BackBufferWidth, ppresentparam->BackBufferHeight); @@ -909,7 +826,7 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, if(dxw.Windowize) FixD3DWindowFrame(hfocuswindow); - if(IsTraceDW){ + if(IsTraceD3D){ tmp = param; OutTrace("D3D%d::CreateDevice\n", dwD3DVersion); OutTrace(" Adapter = %i\n", adapter); @@ -924,7 +841,7 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++)); OutTrace(" SwapEffect = 0x%x\n", *(tmp ++)); OutTrace(" hDeviceWindow = 0x%x\n", *(tmp ++)); - OutTrace(" Windowed = %i\n", (Windowed=*(tmp ++))); + OutTrace(" Windowed = %i\n", *(tmp ++)); OutTrace(" EnableAutoDepthStencil = %i\n", *(tmp ++)); OutTrace(" AutoDepthStencilFormat = %i\n", *(tmp ++)); OutTrace(" Flags = 0x%x\n", *(tmp ++)); @@ -937,9 +854,9 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, else (*pGetAdapterDisplayMode8)(lpd3d, 0, &mode); param[2] = mode.Format; - OutTraceDW(" Current Format = 0x%x\n", mode.Format); - OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); - OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); + OutTraceD3D(" Current Format = 0x%x\n", mode.Format); + OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); if(dwD3DVersion == 9){ if(dxw.Windowize){ @@ -965,10 +882,10 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, } if(res){ - OutTraceDW("FAILED! %x\n", res); + OutTraceD3D("FAILED! %x\n", res); return res; } - OutTraceDW("SUCCESS! device=%x\n", *ppd3dd); + OutTraceD3D("SUCCESS! device=%x\n", *ppd3dd); if(dwD3DVersion == 8){ HookD3DDevice8(ppd3dd); @@ -992,7 +909,6 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp HRESULT res; DWORD param[64], *tmp; D3DDISPLAYMODE mode; - int Windowed; OutTraceD3D("CreateDeviceEx: D3DVersion=%d lpd3d=%x adapter=%x hFocusWnd=%x behavior=%x, size=(%d,%d)\n", dwD3DVersion, lpd3d, adapter, hfocuswindow, behaviorflags, ppresentparam->BackBufferWidth, ppresentparam->BackBufferHeight); @@ -1004,7 +920,7 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp if(dxw.Windowize) FixD3DWindowFrame(hfocuswindow); tmp = param; - if(IsTraceDW){ + if(IsTraceD3D){ OutTrace("D3D%d::CreateDeviceEx\n", dwD3DVersion); OutTrace(" Adapter = %i\n", adapter); OutTrace(" DeviceType = %i\n", devicetype); @@ -1018,7 +934,7 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp OutTrace(" MultiSampleQuality = %i\n", *(tmp ++)); OutTrace(" SwapEffect = 0x%x\n", *(tmp ++)); OutTrace(" hDeviceWindow = 0x%x\n", *(tmp ++)); - OutTrace(" Windowed = %i\n", (Windowed=*(tmp ++))); + OutTrace(" Windowed = %i\n", *(tmp ++)); OutTrace(" EnableAutoDepthStencil = %i\n", *(tmp ++)); OutTrace(" AutoDepthStencilFormat = %i\n", *(tmp ++)); OutTrace(" Flags = 0x%x\n", *(tmp ++)); @@ -1029,9 +945,9 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp //((LPDIRECT3D9)lpd3d)->GetAdapterDisplayMode(0, &mode); (*pGetAdapterDisplayMode9)(lpd3d, 0, &mode); param[2] = mode.Format; - OutTraceDW(" Current Format = 0x%x\n", mode.Format); - OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); - OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); + OutTraceD3D(" Current Format = 0x%x\n", mode.Format); + OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); if(dxw.Windowize){ //param[7] = 0; //hDeviceWindow @@ -1044,10 +960,10 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd); if(res){ - OutTraceDW("FAILED! %x\n", res); + OutTraceD3D("FAILED! %x\n", res); return res; } - OutTraceDW("SUCCESS!\n"); + OutTraceD3D("SUCCESS!\n"); HookD3DDevice9(ppd3dd); @@ -1108,26 +1024,25 @@ HRESULT WINAPI extSetViewport(void *pd3dd, D3DVIEWPORT9 *pViewport) pViewport->Y = (pViewport->Y * (int)client.bottom) / (int)dxw.GetScreenHeight(); pViewport->Width = (pViewport->Width * (int)client.right) / (int)dxw.GetScreenWidth(); pViewport->Height = (pViewport->Height * (int)client.bottom) / (int)dxw.GetScreenHeight(); - OutTraceDW("SetViewport: remapped pos=(%d,%d) size=(%d,%d)\n", + OutTraceD3D("SetViewport: remapped pos=(%d,%d) size=(%d,%d)\n", pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height); return (*pSetViewport)(pd3dd, pViewport); } -HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3d, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain9 **ppSwapChain) +HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3dd, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DSwapChain9 **ppSwapChain) { HRESULT res; DWORD param[64], *tmp; D3DDISPLAYMODE mode; - int Windowed; - OutTraceD3D("CreateAdditionalSwapChain: d3d=%x\n", lpd3d); + OutTraceD3D("CreateAdditionalSwapChain: d3d=%x\n", lpd3dd); memcpy(param, pPresentationParameters, (dwD3DVersion == 9)?56:52); dxw.SetScreenSize(param[0], param[1]); if(dxw.Windowize) FixD3DWindowFrame(dxw.GethWnd()); tmp = param; - if(IsTraceDW){ + if(IsTraceD3D){ OutTrace("D3D%d::CreateAdditionalSwapChain\n", dwD3DVersion); OutTrace(" BackBufferWidth = %i\n", *(tmp ++)); OutTrace(" BackBufferHeight = %i\n", *(tmp ++)); @@ -1137,7 +1052,7 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3d, D3DPRESENT_PARAMETERS * if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++)); OutTrace(" SwapEffect = 0x%x\n", *(tmp ++)); OutTrace(" hDeviceWindow = 0x%x\n", *(tmp ++)); - OutTrace(" Windowed = %i\n", (Windowed=*(tmp ++))); + OutTrace(" Windowed = %i\n", *(tmp ++)); OutTrace(" EnableAutoDepthStencil = %i\n", *(tmp ++)); OutTrace(" AutoDepthStencilFormat = %i\n", *(tmp ++)); OutTrace(" Flags = 0x%x\n", *(tmp ++)); @@ -1146,13 +1061,13 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3d, D3DPRESENT_PARAMETERS * } if (dwD3DVersion == 9) - (*pGetAdapterDisplayMode9)(lpd3d, 0, &mode); + (*pGetAdapterDisplayMode9)(lpd3dd, 0, &mode); else - (*pGetAdapterDisplayMode8)(lpd3d, 0, &mode); + (*pGetAdapterDisplayMode8)(lpd3dd, 0, &mode); param[2] = mode.Format; - OutTraceDW(" Current Format = 0x%x\n", mode.Format); - OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); - OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); + OutTraceD3D(" Current Format = 0x%x\n", mode.Format); + OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); if(dxw.Windowize){ if(dwD3DVersion == 9){ @@ -1170,8 +1085,9 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3d, D3DPRESENT_PARAMETERS * param[12] = D3DPRESENT_INTERVAL_DEFAULT; //PresentationInterval } } - res=(*pCreateAdditionalSwapChain)(lpd3d, (D3DPRESENT_PARAMETERS *)param, ppSwapChain); + res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain); if(res) OutTraceE("CreateAdditionalSwapChain ERROR: res=%x\n", res); + (dwD3DVersion == 9) ? HookD3DDevice9(&lpd3dd) : HookD3DDevice8(&lpd3dd); return res; } @@ -1435,12 +1351,12 @@ HRESULT WINAPI extCheckFullScreen(void) { HRESULT res; if(dxw.Windowize){ - OutTraceDW("CheckFullScreen: return OK\n"); + OutTraceD3D("CheckFullScreen: return OK\n"); res=0; } else{ res=(*pCheckFullScreen)(); - OutTraceDW("CheckFullScreen: return %x\n", res); + OutTraceD3D("CheckFullScreen: return %x\n", res); } return res; } @@ -1505,7 +1421,7 @@ ULONG WINAPI extCreateRenderTarget8(void *lpdd3dd, UINT Width, UINT Height, D3DF ULONG WINAPI extBeginScene8(void *lpdd3dd) { ULONG res; - OutTraceD3D("Device::BeginScene(8): d3dd=%x\n", lpdd3dd); + OutTraceB("Device::BeginScene(8): d3dd=%x\n", lpdd3dd); res=(*pBeginScene8)(lpdd3dd); if (res) OutTraceE("Device::BeginScene(8) ERROR: err=%x\n", res); return res; @@ -1514,7 +1430,7 @@ ULONG WINAPI extBeginScene8(void *lpdd3dd) ULONG WINAPI extBeginScene9(void *lpdd3dd) { ULONG res; - OutTraceD3D("Device::BeginScene(9): d3dd=%x\n", lpdd3dd); + OutTraceB("Device::BeginScene(9): d3dd=%x\n", lpdd3dd); res=(*pBeginScene9)(lpdd3dd); if (res) OutTraceE("Device::BeginScene(9) ERROR: err=%x\n", res); return res; @@ -1523,6 +1439,7 @@ ULONG WINAPI extBeginScene9(void *lpdd3dd) ULONG WINAPI extEndScene8(void *lpdd3dd) { ULONG res; + OutTraceB("Device::EndScene(8): d3dd=%x\n", lpdd3dd); res=(*pEndScene8)(lpdd3dd); if (res) OutTraceE("Device::EndScene(8) ERROR: err=%x\n", res); return res; @@ -1531,6 +1448,7 @@ ULONG WINAPI extEndScene8(void *lpdd3dd) ULONG WINAPI extEndScene9(void *lpdd3dd) { ULONG res; + OutTraceB("Device::EndScene(9): d3dd=%x\n", lpdd3dd); res=(*pEndScene9)(lpdd3dd); if (res) OutTraceE("Device::EndScene(9) ERROR: err=%x\n", res); return res; @@ -1577,3 +1495,140 @@ BOOL WINAPI extShowCursor9(void *lpd3dd, BOOL bShow) OutTraceD3D("Device::ShowCursor(9): d3dd=%x show=%x->%x res=%x\n", lpd3dd, bShow, bNew, res); return res; } + +void WINAPI voidDebugSetLevel(void) +{ + OutTraceD3D("DebugSetLevel: SUPPRESSED\n"); +} + +void WINAPI voidDebugSetMute(void) +{ + OutTraceD3D("DebugSetMute: SUPPRESSED\n"); +} + +BOOL WINAPI voidDisableD3DSpy(void) +{ + OutTraceD3D("DisableD3DSpy: SUPPRESSED\n"); + return FALSE; +} + +HRESULT WINAPI voidDirect3DShaderValidatorCreate9(void) +{ + OutTraceD3D("Direct3DShaderValidatorCreate9: SUPPRESSED\n"); + return 0; +} + +HRESULT WINAPI extRegisterSoftwareDevice(void *lpd3d, void *pInitializeFunction) +{ + OutTrace("RegisterSoftwareDevice: d3d=%x\n", lpd3d); + return (*pRegisterSoftwareDevice)(lpd3d, pInitializeFunction); +} + +UINT WINAPI extGetAdapterModeCount(void *lpd3d, UINT Adapter, D3DFORMAT Format) +{ + OutTrace("GetAdapterModeCount: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pGetAdapterModeCount)(lpd3d, Adapter, Format); +} + +HRESULT WINAPI extCheckDeviceType(void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) +{ + OutTrace("CheckDeviceType: d3d=%x adapter=%d windowed=%x\n", lpd3d, Adapter, bWindowed); + return (*pCheckDeviceType)(lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); +} + +HRESULT WINAPI extCheckDeviceFormat(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) +{ + OutTrace("CheckDeviceFormat: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pCheckDeviceFormat)(lpd3d, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); +} + +HRESULT WINAPI extCheckDeviceMultiSampleType(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels) +{ + OutTrace("CheckDeviceMultiSampleType: d3d=%x adapter=%d windowed=%x\n", lpd3d, Adapter, Windowed); + return (*pCheckDeviceMultiSampleType)(lpd3d, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); +} + +HRESULT WINAPI extCheckDepthStencilMatch(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) +{ + OutTrace("CheckDepthStencilMatch: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pCheckDepthStencilMatch)(lpd3d, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); +} + +HRESULT WINAPI extCheckDeviceFormatConversion(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) +{ + OutTrace("CheckDeviceFormatConversion: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pCheckDeviceFormatConversion)(lpd3d, Adapter, DeviceType, SourceFormat, TargetFormat); +} + +HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) +{ + OutTrace("GetDeviceCaps: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pD3DGetDeviceCaps)(lpd3d, Adapter, DeviceType, pCaps); +} + +HMONITOR WINAPI extGetAdapterMonitor(void *lpd3d, UINT Adapter) +{ + OutTrace("GetAdapterMonitor: d3d=%x adapter=%d\n", lpd3d, Adapter); + return (*pGetAdapterMonitor)(lpd3d, Adapter); +} + +HRESULT WINAPI extTestCooperativeLevel(void *lpd3dd) +{ + HRESULT res; + res = (*pTestCooperativeLevel)(lpd3dd); + OutTrace("TestCooperativeLevel: d3dd=%x res=%x\n", lpd3dd, res); + return res; +} + +HRESULT WINAPI extGetSwapChain(void *lpd3dd, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) +{ + HRESULT res; + OutTrace("GetSwapChain: d3dd=%x SwapChain=%d\n", lpd3dd, iSwapChain); + res = (*pGetSwapChain)(lpd3dd, iSwapChain, pSwapChain); + return res; +} + +UINT WINAPI extGetNumberOfSwapChains(void *lpd3dd) +{ + UINT res; + res = (*pGetNumberOfSwapChains)(lpd3dd); + OutTrace("GetNumberOfSwapChains: d3dd=%x res=%d\n", lpd3dd, res); + return res; +} + +HRESULT WINAPI extBeginStateBlock8(void *lpd3dd) +{ + HRESULT res; + OutTrace("BeginStateBlock(8): d3dd=%x\n", lpd3dd); + res = (*pBeginStateBlock8)(lpd3dd); + HookD3DDevice8(&lpd3dd); + return res; +} + +HRESULT WINAPI extBeginStateBlock9(void *lpd3dd) +{ + // v2.02.78: D3DDevice9::BeginStateBlock refreshes the COM D3DDevice9 method pointers, so that + // you need to hook the device object again. This operation fixes the switch to fullscreen mode + // in "Freedom Force vs. the Third Reich". + HRESULT res; + OutTrace("BeginStateBlock(9): d3dd=%x\n", lpd3dd); + res = (*pBeginStateBlock9)(lpd3dd); + HookD3DDevice9(&lpd3dd); + return res; +} + +HRESULT WINAPI extEndStateBlock8(void *lpd3dd, DWORD *pToken) +{ + HRESULT res; + OutTrace("EndStateBlock(8): d3dd=%x\n", lpd3dd); + res = (*pEndStateBlock8)(lpd3dd, pToken); + return res; +} + +HRESULT WINAPI extEndStateBlock9(void *lpd3dd, IDirect3DStateBlock9** ppSB) +{ + HRESULT res; + OutTrace("EndStateBlock(9): d3dd=%x\n", lpd3dd); + res = (*pEndStateBlock9)(lpd3dd, ppSB); + return res; +} \ No newline at end of file diff --git a/dll/ole32.cpp b/dll/ole32.cpp index 624795a..484e3b5 100644 --- a/dll/ole32.cpp +++ b/dll/ole32.cpp @@ -8,9 +8,9 @@ extern void HookModule(HMODULE, int); static HookEntry_Type Hooks[]={ - {HOOK_IAT_CANDIDATE, "CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance}, - {HOOK_IAT_CANDIDATE, "CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx}, - {HOOK_IAT_CANDIDATE, "CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize}, + {HOOK_HOT_CANDIDATE, "CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance}, + {HOOK_HOT_CANDIDATE, "CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx}, + {HOOK_HOT_CANDIDATE, "CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; diff --git a/dll/user32.cpp b/dll/user32.cpp index 1feaf7c..1fcf12f 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -125,10 +125,10 @@ static HookEntry_Type MouseHooks[]={ }; static HookEntry_Type WinHooks[]={ - {HOOK_IAT_CANDIDATE, "ShowWindow", (FARPROC)ShowWindow, (FARPROC *)&pShowWindow, (FARPROC)extShowWindow}, - {HOOK_IAT_CANDIDATE, "SetWindowPos", (FARPROC)SetWindowPos, (FARPROC *)&pSetWindowPos, (FARPROC)extSetWindowPos}, - {HOOK_IAT_CANDIDATE, "DeferWindowPos", (FARPROC)DeferWindowPos, (FARPROC *)&pGDIDeferWindowPos, (FARPROC)extDeferWindowPos}, - {HOOK_IAT_CANDIDATE, "CallWindowProcA", (FARPROC)CallWindowProcA, (FARPROC *)&pCallWindowProc, (FARPROC)extCallWindowProc}, + {HOOK_HOT_CANDIDATE, "ShowWindow", (FARPROC)ShowWindow, (FARPROC *)&pShowWindow, (FARPROC)extShowWindow}, + {HOOK_HOT_CANDIDATE, "SetWindowPos", (FARPROC)SetWindowPos, (FARPROC *)&pSetWindowPos, (FARPROC)extSetWindowPos}, + {HOOK_HOT_CANDIDATE, "DeferWindowPos", (FARPROC)DeferWindowPos, (FARPROC *)&pGDIDeferWindowPos, (FARPROC)extDeferWindowPos}, + {HOOK_HOT_CANDIDATE, "CallWindowProcA", (FARPROC)CallWindowProcA, (FARPROC *)&pCallWindowProc, (FARPROC)extCallWindowProc}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -277,7 +277,7 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, BOOL WideChar, void *lpDevMode, dxw.SetFullScreen(TRUE); } } - + if ((dwflags==0 || dwflags==CDS_FULLSCREEN) && lpDevMode){ if (dxw.dwFlags1 & EMULATESURFACE || !(dmFields & DM_BITSPERPEL)){ OutTraceDW("%s: BYPASS res=DISP_CHANGE_SUCCESSFUL\n", fname); @@ -286,7 +286,7 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, BOOL WideChar, void *lpDevMode, else{ DEVMODEA NewMode; if(dwflags==CDS_FULLSCREEN) dwflags=0; // no FULLSCREEN - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &NewMode); + (*pEnumDisplaySettings)(NULL, ENUM_CURRENT_SETTINGS, &NewMode); OutTraceDW("ChangeDisplaySettings: CURRENT wxh=(%dx%d) BitsPerPel=%d -> %d\n", NewMode.dmPelsWidth, NewMode.dmPelsHeight, NewMode.dmBitsPerPel, dmBitsPerPel); NewMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; @@ -298,7 +298,7 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, BOOL WideChar, void *lpDevMode, } else{ if(WideChar) - return (*pChangeDisplaySettingsW)((LPDEVMODEW)lpDevMode, dwflags); + return (*pChangeDisplaySettingsExW)(NULL, (LPDEVMODEW)lpDevMode, NULL, dwflags, NULL); else return (*pChangeDisplaySettingsExA)(NULL, (LPDEVMODEA)lpDevMode, NULL, dwflags, NULL); } @@ -539,7 +539,7 @@ LONG WINAPI extGetWindowLong(HWND hwnd, int nIndex, GetWindowLong_Type pGetWindo OutTraceDW("GetWindowLong: hwnd=%x, Index=%x(%s) res=%x\n", hwnd, nIndex, ExplainSetWindowIndex(nIndex), res); - if(nIndex==GWL_WNDPROC){ + if((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)){ WNDPROC wp; wp=WhndGetWindowProc(hwnd); OutTraceDW("GetWindowLong: remapping WindowProc res=%x -> %x\n", res, (LONG)wp); @@ -606,7 +606,7 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon } } - if ((nIndex==GWL_WNDPROC) && dxw.IsFullScreen()){ // v2.02.51 - see A10 Cuba.... + if (((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)) && dxw.IsFullScreen()){ // v2.02.51 - see A10 Cuba.... //if (nIndex==GWL_WNDPROC){ WNDPROC lres; WNDPROC OldProc; @@ -617,7 +617,7 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon } // end of GPL fix - OldProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC); + OldProc = (WNDPROC)(*pGetWindowLongA)(hwnd, nIndex); // v2.02.70 fix if((OldProc==extWindowProc) || (OldProc==extChildWindowProc)|| @@ -626,7 +626,7 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon WhndStackPush(hwnd, (WNDPROC)dwNewLong); res=(LONG)OldProc; SetLastError(0); - lres=(WNDPROC)(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extWindowProc); + lres=(WNDPROC)(*pSetWindowLongA)(hwnd, nIndex, (LONG)extWindowProc); if(!lres && GetLastError())OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__); } else { @@ -1165,6 +1165,24 @@ static HWND WINAPI extCreateWindowCommon( if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError()); WhndStackPush(hwnd, pWindowProc); } + if ((dwStyle & WS_DLGFRAME) && (dxw.dwFlags1 & HOOKCHILDWIN)){ + // child window inherit the father's windproc, so if it's redirected to + // a hooker (either extWindowProc or extChildWindowProc) you have to retrieve + // the correct value (WhndGetWindowProc) before saving it (WhndStackPush). + long res; + pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, DWL_DLGPROC); + if((pWindowProc == extWindowProc) || + (pWindowProc == extChildWindowProc) || + (pWindowProc == extDialogWindowProc)){ // avoid recursions + HWND Father; + Father=GetParent(hwnd); + pWindowProc=WhndGetWindowProc(Father); + } + OutTraceDW("Hooking CHILD hwnd=%x father WindowProc %x->%x\n", hwnd, pWindowProc, extChildWindowProc); + res=(*pSetWindowLongA)(hwnd, DWL_DLGPROC, (LONG)extDialogWindowProc); + if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError()); + WhndStackPush(hwnd, pWindowProc); + } OutTraceDW("%s: ret=%x\n", ApiName, hwnd); return hwnd; } @@ -1333,6 +1351,24 @@ static HWND WINAPI extCreateWindowCommon( if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError()); WhndStackPush(hwnd, pWindowProc); } + if ((dwStyle & WS_DLGFRAME) && (dxw.dwFlags1 & HOOKCHILDWIN)){ + // child window inherit the father's windproc, so if it's redirected to + // a hooker (either extWindowProc or extChildWindowProc) you have to retrieve + // the correct value (WhndGetWindowProc) before saving it (WhndStackPush). + long res; + pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, DWL_DLGPROC); + if((pWindowProc == extWindowProc) || + (pWindowProc == extChildWindowProc) || + (pWindowProc == extDialogWindowProc)){ // avoid recursions + HWND Father; + Father=GetParent(hwnd); + pWindowProc=WhndGetWindowProc(Father); + } + OutTraceDW("Hooking CHILD hwnd=%x father WindowProc %x->%x\n", hwnd, pWindowProc, extChildWindowProc); + res=(*pSetWindowLongA)(hwnd, DWL_DLGPROC, (LONG)extDialogWindowProc); + if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError()); + WhndStackPush(hwnd, pWindowProc); + } OutTraceDW("%s: ret=%x\n", ApiName, hwnd); return hwnd; @@ -1649,7 +1685,7 @@ LONG WINAPI extEnumDisplaySettings(LPCTSTR lpszDeviceName, DWORD iModeNum, DEVMO LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *lpDevMode, DWORD dwflags) { if(IsTraceDDRAW){ - OutTrace("ChangeDisplaySettingsA: lpDevMode=%x flags=%x", lpDevMode, dwflags); + OutTrace("ChangeDisplaySettingsA: lpDevMode=%x flags=%x(%s)", lpDevMode, dwflags, ExplainChangeDisplaySettingsFlags(dwflags)); if (lpDevMode) OutTrace(" DeviceName=%s fields=%x(%s) size=(%d x %d) bpp=%d", lpDevMode->dmDeviceName, lpDevMode->dmFields, ExplainDevModeFields(lpDevMode->dmFields), lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, lpDevMode->dmBitsPerPel); @@ -1665,7 +1701,7 @@ LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *lpDevMode, DWORD dwflags) LONG WINAPI extChangeDisplaySettingsW(DEVMODEW *lpDevMode, DWORD dwflags) { if(IsTraceDDRAW){ - OutTrace("ChangeDisplaySettingsW: lpDevMode=%x flags=%x", lpDevMode, dwflags); + OutTrace("ChangeDisplaySettingsW: lpDevMode=%x flags=%x(%s)", lpDevMode, dwflags, ExplainChangeDisplaySettingsFlags(dwflags)); if (lpDevMode) OutTrace(" DeviceName=%ls fields=%x(%s) size=(%d x %d) bpp=%d", lpDevMode->dmDeviceName, lpDevMode->dmFields, ExplainDevModeFields(lpDevMode->dmFields), lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, lpDevMode->dmBitsPerPel); @@ -1681,7 +1717,7 @@ LONG WINAPI extChangeDisplaySettingsW(DEVMODEW *lpDevMode, DWORD dwflags) LONG WINAPI extChangeDisplaySettingsExA(LPCTSTR lpszDeviceName, DEVMODEA *lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam) { if(IsTraceDDRAW){ - OutTrace("ChangeDisplaySettingsExA: DeviceName=%s lpDevMode=%x flags=%x", lpszDeviceName, lpDevMode, dwflags); + OutTrace("ChangeDisplaySettingsExA: DeviceName=%s lpDevMode=%x flags=%x(%s)", lpszDeviceName, lpDevMode, dwflags, ExplainChangeDisplaySettingsFlags(dwflags)); if (lpDevMode) OutTrace(" DeviceName=%s fields=%x(%s) size=(%d x %d) bpp=%d", lpDevMode->dmDeviceName, lpDevMode->dmFields, ExplainDevModeFields(lpDevMode->dmFields), lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, lpDevMode->dmBitsPerPel); @@ -1697,7 +1733,7 @@ LONG WINAPI extChangeDisplaySettingsExA(LPCTSTR lpszDeviceName, DEVMODEA *lpDevM LONG WINAPI extChangeDisplaySettingsExW(LPCTSTR lpszDeviceName, DEVMODEW *lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam) { if(IsTraceDDRAW){ - OutTrace("ChangeDisplaySettingsExW: DeviceName=%ls lpDevMode=%x flags=%x", lpszDeviceName, lpDevMode, dwflags); + OutTrace("ChangeDisplaySettingsExW: DeviceName=%ls lpDevMode=%x flags=%x(%s)", lpszDeviceName, lpDevMode, dwflags, ExplainChangeDisplaySettingsFlags(dwflags)); if (lpDevMode) OutTrace(" DeviceName=%ls fields=%x(%s) size=(%d x %d) bpp=%d", lpDevMode->dmDeviceName, lpDevMode->dmFields, ExplainDevModeFields(lpDevMode->dmFields), lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, lpDevMode->dmBitsPerPel); diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index c2feeaa..2bf8032 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ