diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 23dac4c..5c3db29 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f437c5d0f51575ce6fd0d3ffcc160d7c5f84f86db47b3af6847427a28466cde4 -size 577024 +oid sha256:2e7c1adfbd594089e1c8eb7040b06037ae1f239498a09399e82ef4e52023c080 +size 576512 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index e67795d..74d412c 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4637fee61c70d8ffa927a88878191e4174bac16129dd30242892a5ad07dcbc6b +oid sha256:a512e18dc9a004e3cb5f8f08eca94a0b06c8e5d935689eac885ba75f5636cde1 size 538624 diff --git a/build/exports/Axis & Allies Iron Blitz Edition.dxw b/build/exports/Axis & Allies Iron Blitz Edition.dxw new file mode 100644 index 0000000..17fa320 --- /dev/null +++ b/build/exports/Axis & Allies Iron Blitz Edition.dxw @@ -0,0 +1,29 @@ +[target] +title0=Axis & Allies Iron Blitz Edition +path0=D:\Games\Axis & Allies Iron Blitz Edition\Axis & Allies\AxisAllies.exe +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=-2013265822 +flagg0=1207959552 +flagh0=20 +flagi0=138412037 +flagj0=128 +tflag0=6402 +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/Crusaders of Might and Magic (GOG).dxw b/build/exports/Crusaders of Might and Magic (GOG).dxw new file mode 100644 index 0000000..6038dc4 --- /dev/null +++ b/build/exports/Crusaders of Might and Magic (GOG).dxw @@ -0,0 +1,29 @@ +[target] +title0=Crusaders of Might and Magic (GOG) +path0=D:\Games\Crusaders of Might and Magic (GOG)\crusaders.exe +launchpath0= +module0=gfx_d3d gfx_sw +opengllib0= +notes0=the ddraw.dll hooker in the game folder must be deleted or renamed \nto allow DxWnd to play the game. +ver0=0 +coord0=0 +flag0=-1467989966 +flagg0=1744830472 +flagh0=20 +flagi0=138412036 +flagj0=4224 +tflag0=-2147477229 +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/Crusaders of Might and Magic Demo.dxw b/build/exports/Crusaders of Might and Magic Demo.dxw new file mode 100644 index 0000000..4016a48 --- /dev/null +++ b/build/exports/Crusaders of Might and Magic Demo.dxw @@ -0,0 +1,29 @@ +[target] +title0=Crusaders of Might and Magic Demo +path0=D:\Games\Crusaders of Might and Magic Demo\crusaders demo.exe +launchpath0= +module0=gfx_d3d gfx_sw +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=-1467989966 +flagg0=1207959560 +flagh0=20 +flagi0=138412036 +flagj0=4224 +tflag0=6418 +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/Darkened Skye.dxw b/build/exports/Darkened Skye.dxw index a67b3be..ac9f547 100644 --- a/build/exports/Darkened Skye.dxw +++ b/build/exports/Darkened Skye.dxw @@ -5,7 +5,7 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=679493666 +flag0=679493664 flagg0=1207959552 flagh0=65556 flagi0=69206020 @@ -25,5 +25,3 @@ initts0=0 winver0=0 maxres0=-1 launchpath0= -notes0= -flagj0=128 diff --git a/build/exports/Dune 2000.dxw b/build/exports/Dune 2000.dxw index 83abcdc..a90698b 100644 --- a/build/exports/Dune 2000.dxw +++ b/build/exports/Dune 2000.dxw @@ -6,11 +6,11 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=671105312 +flag0=671105058 flagg0=1207959568 flagh0=20 flagi0=4194308 -tflag0=64 +tflag0=0 initx0=0 inity0=0 minx0=0 @@ -25,3 +25,5 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +notes0= +flagj0=128 diff --git a/build/exports/Evolva.dxw b/build/exports/Evolva.dxw index 1aa687b..c715fc8 100644 --- a/build/exports/Evolva.dxw +++ b/build/exports/Evolva.dxw @@ -5,10 +5,10 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=134217760 +flag0=134217762 flagg0=1207959552 flagh0=20 -flagi0=4 +flagi0=4194308 tflag0=6146 initx0=0 inity0=0 @@ -24,3 +24,6 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +flagj0=128 diff --git a/build/exports/Forsaken (HW).dxw b/build/exports/Forsaken (HW).dxw index 025c461..f5ba94d 100644 --- a/build/exports/Forsaken (HW).dxw +++ b/build/exports/Forsaken (HW).dxw @@ -8,7 +8,7 @@ coord0=0 flag0=411058208 flagg0=1207959808 flagh0=20 -flagi0=4 +flagi0=2097156 tflag0=0 initx0=0 inity0=0 @@ -24,3 +24,6 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +flagj0=8388736 diff --git a/build/exports/Galapagos.dxw b/build/exports/Galapagos.dxw new file mode 100644 index 0000000..be8b55b --- /dev/null +++ b/build/exports/Galapagos.dxw @@ -0,0 +1,29 @@ +[target] +title0=Galapagos +path0=D:\Games\Galapagos\GALA.EXE +launchpath0= +module0= +opengllib0= +notes0= +ver0=7 +coord0=0 +flag0=746602528 +flagg0=1207959552 +flagh0=16 +flagi0=138412036 +flagj0=142610600 +tflag0=6402 +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/Horde 2 the Citadel.dxw b/build/exports/Horde 2 the Citadel.dxw index 08c8dff..a889d01 100644 --- a/build/exports/Horde 2 the Citadel.dxw +++ b/build/exports/Horde 2 the Citadel.dxw @@ -6,10 +6,10 @@ opengllib0= ver0=0 coord0=0 flag0=134217766 -flagg0=134217728 +flagg0=1207959552 flagh0=20 -flagi0=4 -tflag0=64 +flagi0=4194308 +tflag0=0 initx0=0 inity0=0 minx0=0 @@ -24,3 +24,6 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +flagj0=128 diff --git a/build/exports/Horde.dxw b/build/exports/Horde.dxw index 881986a..ce5f1c9 100644 --- a/build/exports/Horde.dxw +++ b/build/exports/Horde.dxw @@ -6,10 +6,10 @@ opengllib0= ver0=0 coord0=0 flag0=134217766 -flagg0=134217728 +flagg0=1207959552 flagh0=20 -flagi0=4 -tflag0=64 +flagi0=4194308 +tflag0=0 initx0=0 inity0=0 minx0=0 @@ -24,3 +24,6 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +flagj0=128 diff --git a/build/exports/The Mummy.dxw b/build/exports/The Mummy.dxw new file mode 100644 index 0000000..67f7cb4 --- /dev/null +++ b/build/exports/The Mummy.dxw @@ -0,0 +1,29 @@ +[target] +title0=The Mummy +path0=D:\Games\The Mummy\MummyPC.exe +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=134217762 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +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/Ultimate Soccer Manager 98.dxw b/build/exports/Ultimate Soccer Manager 98.dxw new file mode 100644 index 0000000..512c1af --- /dev/null +++ b/build/exports/Ultimate Soccer Manager 98.dxw @@ -0,0 +1,29 @@ +[target] +title0=Ultimate Soccer Manager 98 +path0=D:\Games\USM98\USM98.EXE +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=134217760 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=266368 +tflag0=-2147477245 +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/dxwnd.ini b/build/exports/dxwnd.ini index 1036463..823f159 100644 --- a/build/exports/dxwnd.ini +++ b/build/exports/dxwnd.ini @@ -1,5 +1,5 @@ [window] -posx=1439 -posy=619 +posx=1496 +posy=246 sizx=320 sizy=200 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 013e4df..7f73f80 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -776,4 +776,12 @@ v2.03.16 fix: MapWindowPoints hook - added coordinate scaling (fixes "NBA Live 99" components size and position) fix: using "Suppress D3D8/9 reset" sets the backbuffer area as large as the whole desktop to avoid clipping add: added "Unlock Z-order" flag to avoid window to stay locked on top of z-order (useful for "NBA Live 99") -add: added "EA Sprots hack" flag to suppress some interfering hooks set by EA games internally (useful for "NBA Live 99") \ No newline at end of file +add: added "EA Sprots hack" flag to suppress some interfering hooks set by EA games internally (useful for "NBA Live 99") + +v2.03.18: +fix: eliminated direct output to primary surface, causing more troubles than goods ("Divine Divinity" flickering...) +fix: handled CoCreateInstance calling CoCreateInstanceEx in hot patch mode. +fix: eliminated InvalidateRect calls in ddrow Unlock hooker: this is not the right way to fix "Deadlock II", sorry. +fix: DirectDrawEnumerateEx log +fix: cursor is hidden in fullscreen mode only +fix: CoCreateInstance & CoCreateInstanceEx wrappers. Now "Crusaders of Might & Magic" is playable in window diff --git a/dll/ddblit.cpp b/dll/ddblit.cpp index dd776c8..ec66120 100644 --- a/dll/ddblit.cpp +++ b/dll/ddblit.cpp @@ -64,15 +64,16 @@ static HRESULT sBltNoPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest // Wrong guess!!! The cause was not compression, but simply a pixelformat mismatch. Better // configure things properly and avoid this branch. switch(res){ - case DDERR_UNSUPPORTED: - if (dxw.dwFlags1 & EMULATESURFACE){ - RECT targetrect; - if (IsDebug) BlitTrace("UNSUPP", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__); - targetrect=*lpdestrect; - dxw.MapWindowRect(&targetrect); - res=(*pBlt)(lpDDSEmu_Prim, &targetrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx); - } - break; + // commented out: it was the cause of the "Divine Divinity" flickering. + // commented in?: it seems useful in "Axis and Allies".... + //case DDERR_UNSUPPORTED: + // if (dxw.dwFlags1 & EMULATESURFACE){ + // RECT targetrect; + // if (IsDebug) BlitTrace("UNSUPP", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__); + // targetrect = dxw.MapWindowRect(lpdestrect); + // res=(*pBlt)(lpDDSEmu_Prim, &targetrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx); + // } + // break; case DDERR_SURFACEBUSY: (*pUnlockMethod(lpdds))(lpdds, NULL); if (lpddssrc) (*pUnlockMethod(lpddssrc))(lpddssrc, NULL); @@ -261,8 +262,7 @@ static HRESULT sBltToPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest RECT targetrect; dxw.ShowOverlay(lpddssrc); if (IsDebug) BlitTrace("UNSUPP", &emurect, &destrect, __LINE__); - targetrect=destrect; - dxw.MapWindowRect(&targetrect); // v2.03.15 + targetrect=dxw.MapWindowRect(&destrect); // v2.03.18 res=(*pBlt)(lpDDSEmu_Prim, &targetrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx); if (res) BlitError(res, lpsrcrect, &destrect, __LINE__); } diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index e9a04b9..927cec0 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -1760,9 +1760,10 @@ HRESULT WINAPI extInitialize(LPDIRECTDRAW lpdd, GUID FAR *lpguid) res=(*pInitialize)(lpdd, lpPrivGuid); + if(res == DDERR_ALREADYINITIALIZED) res=DD_OK; // v2.03.18: this error could be caused by the CoCreateInstance implementation if(dxw.dwFlags3 & COLORFIX) (((DDRAWI_DIRECTDRAW_INT *)lpdd))->lpLcl->dwAppHackFlags |= 0x800; - if(res) OutTraceE("Initialize ERROR: res=%x(%s)\n", res, ExplainDDError(res)); + return res; } @@ -3716,18 +3717,12 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC } res=(*pUnlock)(lpdds, lprect); + if (IsPrim && res==DD_OK) { + if(dxversion == 1) lprect=NULL; + res=sBlt("Unlock", lpdds, lprect, lpdds, lprect, NULL, 0, FALSE); + } if(res==DDERR_NOTLOCKED) res=DD_OK; // ignore not locked error if (res) OutTraceE("Unlock ERROR res=%x(%s) at %d\n",res, ExplainDDError(res), __LINE__); - if (IsPrim && res==DD_OK) { - if(dxversion == 1){ - res=sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE); - (*pInvalidateRect)(dxw.GethWnd(), NULL, FALSE); // to fix "Deadlock II" mouse trails.... - } - else { - res=sBlt("Unlock", lpdds, lprect, lpdds, lprect, NULL, 0, FALSE); - (*pInvalidateRect)(dxw.GethWnd(), lprect, FALSE); - } - } if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; @@ -4712,7 +4707,7 @@ HRESULT WINAPI extReleaseP(LPDIRECTDRAWPALETTE lpddPalette) return ref; } -BOOL WINAPI DDEnumerateCallbackFilter(GUID *lpGuid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext) +BOOL FAR PASCAL DDEnumerateCallbackFilter(GUID FAR *lpGuid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext) { BOOL res; typedef struct {LPDDENUMCALLBACK lpCallback; LPVOID lpContext;} Context_Type; @@ -4725,7 +4720,7 @@ BOOL WINAPI DDEnumerateCallbackFilter(GUID *lpGuid, LPSTR lpDriverDescription, L return res; } -BOOL WINAPI DDEnumerateCallbackExFilter(GUID *lpGuid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) +BOOL FAR PASCAL DDEnumerateCallbackExFilter(GUID FAR *lpGuid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) { BOOL res; typedef struct {LPDDENUMCALLBACKEX lpCallback; LPVOID lpContext;} Context_Type; @@ -4759,15 +4754,16 @@ HRESULT WINAPI extDirectDrawEnumerateEx(LPDDENUMCALLBACKEX lpCallback, LPVOID lp { HRESULT ret; OutTraceDDRAW("DirectDrawEnumerateEx: lpCallback=%x lpContext=%x Flags=%x(%s)\n", - lpCallback, lpContext, dxw.dwFlags1, ExplainDDEnumerateFlags(dwFlags)); + lpCallback, lpContext, dwFlags, ExplainDDEnumerateFlags(dwFlags)); if((dxw.dwFlags2 & HIDEMULTIMONITOR) || (dxw.dwTFlags & OUTDEBUG)){ struct {LPDDENUMCALLBACKEX lpCallback; LPVOID lpContext;} myContext; myContext.lpCallback=lpCallback; myContext.lpContext=lpContext; ret=(*pDirectDrawEnumerateEx)(DDEnumerateCallbackExFilter, (LPVOID)&myContext, dwFlags); } - else + else{ ret=(*pDirectDrawEnumerateEx)(lpCallback, lpContext, dwFlags); + } if(ret) OutTraceE("DirectDrawEnumerateEx: ERROR res=%x(%s)\n", ret, ExplainDDError(ret)); if(dxw.dwFlags1 & SUPPRESSDXERRORS) ret=0; return ret; diff --git a/dll/dxhelper.cpp b/dll/dxhelper.cpp index 99d2230..c97a6f0 100644 --- a/dll/dxhelper.cpp +++ b/dll/dxhelper.cpp @@ -936,6 +936,7 @@ char *ExplainSetWindowIndex(DWORD c) case GWL_STYLE: eb="GWL_STYLE"; break; case GWL_USERDATA: eb="GWL_USERDATA"; break; case GWL_WNDPROC: eb="GWL_WNDPROC"; break; + case GWL_HWNDPARENT: eb="GWL_HWNDPARENT"; break; case DWL_DLGPROC: eb="DWL_DLGPROC"; break; case DWL_MSGRESULT: eb="DWL_MSGRESULT"; break; case DWL_USER: eb="DWL_USER"; break; diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index aa95c59..06afaf3 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -598,7 +598,6 @@ void HookWindowProc(HWND hwnd) void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height) { - HRESULT res=0; LONG style; @@ -629,7 +628,7 @@ void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height) // fixing cursor view and clipping region - if (dxw.dwFlags1 & HIDEHWCURSOR) while ((*pShowCursor)(0) >= 0); + if ((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()) while ((*pShowCursor)(0) >= 0); if (dxw.dwFlags2 & SHOWHWCURSOR) while((*pShowCursor)(1) < 0); if (dxw.dwFlags1 & CLIPCURSOR) { OutTraceDW("AdjustWindowFrame: setting clip region\n"); @@ -937,7 +936,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp dxw.dwFlags1 |= LOCKWINPOS; dx_UpdatePositionLock(hwnd); } - if(dxw.dwFlags1 & HIDEHWCURSOR) while((*pShowCursor)(0) >= 0); + if((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()) while((*pShowCursor)(0) >= 0); if(dxw.dwFlags2 & SHOWHWCURSOR) while((*pShowCursor)(1) < 0); if(dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion); if(dxw.dwFlags2 & REFRESHONRESIZE) dxw.ScreenRefresh(); @@ -974,7 +973,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp if(dxw.Windowize){ prev.x = LOWORD(lparam); prev.y = HIWORD(lparam); - if (dxw.dwFlags1 & HIDEHWCURSOR) { + if ((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()){ (*pGetClientRect)(hwnd, &rect); if(prev.x >= 0 && prev.x < rect.right && prev.y >= 0 && prev.y < rect.bottom) while((*pShowCursor)(0) >= 0); @@ -1681,7 +1680,6 @@ void HookInit(TARGETMAP *target, HWND hwnd) if(dxw.dwFlags5 & GDIMODE) dxw.dwFlags1 |= EMULATESURFACE; if(dxw.dwFlags5 & STRESSRESOURCES) dxw.dwFlags5 |= LIMITRESOURCES; - if(hwnd){ // v2.02.32: skip this when in code injection mode. // v2.1.75: is it correct to set hWnd here? //dxw.SethWnd(hwnd); diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index 29c7a1e..7958352 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -997,7 +997,7 @@ void dxwCore::ScreenRefresh(void) if (lpDDSPrim) extBlt(lpDDSPrim, NULL, lpDDSPrim, NULL, 0, NULL); // v2.02.44 - used for what? Commenting out seems to fix the palette update glitches - // and make the "Palette updates don't blit"option useless.... + // and make the "Palette updates don't blit" option useless.... //(*pInvalidateRect)(hWnd, NULL, FALSE); } diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index de6e7ab..7b88850 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -27,7 +27,7 @@ along with this program. If not, see . #include "TlHelp32.h" -#define VERSION "2.03.16" +#define VERSION "2.03.18" #define DDTHREADLOCK 1 //#define LOCKTHREADS diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index cf841b6..65f237b 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index c794fc1..940f747 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -17,6 +17,16 @@ typedef BOOL (WINAPI *CreateProcessA_Type)(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTE BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); CreateProcessA_Type pCreateProcessA = NULL; +#ifdef NOFREELIBRARY +typedef BOOL (WINAPI *FreeLibrary_Type)(HMODULE); +FreeLibrary_Type pFreeLibrary = NULL; +BOOL WINAPI extFreeLibrary(HMODULE hModule) +{ + OutTrace("FreeLibrary: hModule=%x SUPPRESS\n", hModule); + return TRUE; +} +#endif + // v2.02.96: the GetSystemInfo API is NOT hot patchable on Win7. This can cause problems because it can't be hooked by simply // enabling hot patch. A solution is making all LoadLibrary* calls hot patchable, so that when loading the module, the call // can be hooked by the IAT lookup. This fixes a problem after movie playing in Wind Fantasy SP. @@ -33,6 +43,9 @@ static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "GetLogicalDrives", (FARPROC)NULL, (FARPROC *)&pGetLogicalDrives, (FARPROC)extGetLogicalDrives}, {HOOK_IAT_CANDIDATE, "GetTempFileNameA", (FARPROC)GetTempFileNameA, (FARPROC *)&pGetTempFileName, (FARPROC)extGetTempFileName}, {HOOK_IAT_CANDIDATE, "CreateProcessA", (FARPROC)NULL, (FARPROC *)&pCreateProcessA, (FARPROC)extCreateProcessA}, +#ifdef NOFREELIBRARY + {HOOK_HOT_CANDIDATE, "FreeLibrary", (FARPROC)FreeLibrary, (FARPROC *)&pFreeLibrary, (FARPROC)extFreeLibrary}, +#endif {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -533,7 +546,6 @@ FARPROC WINAPI extGetProcAddress(HMODULE hModule, LPCSTR proc) } // to do: the else condition: the program COULD load addresses by ordinal value ... done ?? - // to do: CoCreateInstanceEx if((DWORD)proc & 0xFFFF0000){ FARPROC remap; switch(idx){ diff --git a/dll/ole32.cpp b/dll/ole32.cpp index 484e3b5..fd0d8fd 100644 --- a/dll/ole32.cpp +++ b/dll/ole32.cpp @@ -7,10 +7,13 @@ extern void HookModule(HMODULE, int); +static BOOL bRecursedHook = FALSE; + static HookEntry_Type Hooks[]={ {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_HOT_CANDIDATE, "CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize}, + //{HOOK_HOT_CANDIDATE, "CoUninitialize", NULL, (FARPROC *)&pCoUninitialize, (FARPROC)extCoUninitialize}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -29,7 +32,7 @@ FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule) return NULL; } -// so far, there are 4 additional libraries that could be loaded by meand of a CoCreateInstance call.... +// so far, there are 4 additional libraries that could be loaded by means of a CoCreateInstance call.... #define ADDITIONAL_MODULE_COUNT 4 struct { @@ -61,58 +64,94 @@ static void HookAdditionalModules() // ------------------------------------------------------------------------------------- // Ole32 CoCreateInstance handling: you can create DirectDraw objects through it! -// utilized so far in a single game: Axiz & Allies +// utilized so far in a single game: "Axis & Allies" +// another one: "Crusaders of Might and Magic" .... // ------------------------------------------------------------------------------------- +extern void HookDDSession(LPDIRECTDRAW *, int); +#if 0 +typedef HRESULT (WINAPI *Initialize_Type)(LPDIRECTDRAW, GUID FAR *); +extern Initialize_Type pInitialize; +HRESULT WINAPI extInitialize1(LPDIRECTDRAW lpdd, GUID FAR *lpguid) { OutTrace("1\n"); HookDDSession(&lpdd, 1); return DD_OK; } +HRESULT WINAPI extInitialize2(LPDIRECTDRAW lpdd, GUID FAR *lpguid) { OutTrace("2\n"); HookDDSession(&lpdd, 2); return DD_OK; } +HRESULT WINAPI extInitialize4(LPDIRECTDRAW lpdd, GUID FAR *lpguid) { OutTrace("4\n"); HookDDSession(&lpdd, 4); return DD_OK; } +HRESULT WINAPI extInitialize7(LPDIRECTDRAW lpdd, GUID FAR *lpguid) { OutTrace("7\n"); HookDDSession(&lpdd, 7); return DD_OK; } + +void HookDDSessionInitialize(LPDIRECTDRAW *lplpdd, int dxversion, Initialize_Type extInitialize) +{ + OutTraceDW("Hooking directdraw Init dd=%x dxversion=%d pInit=%x\n", + *lplpdd, dxversion, extInitialize); + SetHook((void *)(**(DWORD **)lplpdd + 72), extInitialize, (void **)&pInitialize, "Initialize(D)"); +} +#endif + HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv) { HRESULT res; OutTraceDW("CoCreateInstance: rclsid=%x UnkOuter=%x ClsContext=%x refiid=%x(%s)\n", - rclsid, pUnkOuter, dwClsContext, riid.Data1, ExplainGUID((GUID *)&riid)); + rclsid.Data1, pUnkOuter, dwClsContext, riid.Data1, ExplainGUID((GUID *)&riid)); + bRecursedHook = TRUE; res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv); - if(res) + bRecursedHook = FALSE; + if(res) { OutTraceE("CoCreateInstance: ERROR res=%x\n", res); - else - OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv); + return res; + } + + OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv); - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ - LPDIRECTDRAW lpOldDDraw; + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ // v2.03.18: fixed OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n"); + HookDDSession((LPDIRECTDRAW *)ppv, 1); switch (*(DWORD *)&riid){ +#if 0 case 0x6C14DB80: - OutTraceDW("DirectDrawCreate: IID_DirectDraw RIID\n"); - res=extDirectDrawCreate(NULL, (LPDIRECTDRAW *)&ppv, 0); - if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); + HookDDSessionInitialize((LPDIRECTDRAW *)ppv, 1, extInitialize1); break; + case 0xB3A6F3E0: + HookDDSessionInitialize((LPDIRECTDRAW *)ppv, 2, extInitialize2); break; + case 0x9C59509A: + HookDDSessionInitialize((LPDIRECTDRAW *)ppv, 4, extInitialize4); break; + case 0x15E65EC0: + HookDDSessionInitialize((LPDIRECTDRAW *)ppv, 7, extInitialize7); break; +#else + LPDIRECTDRAW lpOldDDraw; + case 0x6C14DB80: + OutTraceDW("CoCreateInstance: IID_DirectDraw RIID\n"); + HookDDSession((LPDIRECTDRAW *)ppv, 1); break; case 0xB3A6F3E0: - OutTraceDW("DirectDrawCreate: IID_DirectDraw2 RIID\n"); + OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID\n"); res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); - res=lpOldDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)&ppv); + res=lpOldDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)ppv); if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); lpOldDDraw->Release(); break; - case 0x9c59509a: - OutTraceDW("DirectDrawCreate: IID_DirectDraw4 RIID\n"); + case 0x9C59509A: + OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID\n"); res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); - res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&ppv); + res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)ppv); if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); lpOldDDraw->Release(); - case 0x15e65ec0: + break; + case 0x15E65EC0: OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID\n"); - res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)&ppv, IID_IDirectDraw7, 0); + res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)ppv, IID_IDirectDraw7, 0); if(res)OutTraceDW("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res)); break; - case 0xe436ebb3: + case 0xE436EBB3: break; +#endif } } - else - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + else { + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + } HookAdditionalModules(); + OutTraceDW("CoCreateInstance: res=%x ppv=%x->%x\n", res, *ppv, *(DWORD *)*ppv); return res; } @@ -122,13 +161,14 @@ HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID rclsid, IUnknown *punkOute DWORD i; OutTraceDW("CoCreateInstanceEx: rclsid=%x UnkOuter=%x ClsContext=%x Count=%d\n", - rclsid, punkOuter, dwClsCtx, dwCount); + rclsid.Data1, punkOuter, dwClsCtx, dwCount); res=(*pCoCreateInstanceEx)(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults); if(res) { OutTraceE("CoCreateInstanceEx: ERROR res=%x\n", res); return res; } + if(bRecursedHook) return res; for(i=0; iQueryInterface(IID_IDirectDraw2, (LPVOID *)&ppv); - if(res)OutTraceDW("QueryInterfaceEx: res=%x(%s)\n", res, ExplainDDError(res)); - lpOldDDraw->Release(); - break; - case 0x9c59509a: - OutTraceDW("DirectDrawCreateEx: IID_DirectDraw4 RIID\n"); - res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); - if(res)OutTraceDW("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res)); - res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&ppv); - if(res)OutTraceDW("QueryInterfaceEx: res=%x(%s)\n", res, ExplainDDError(res)); - lpOldDDraw->Release(); - case 0x15e65ec0: - OutTraceDW("CoCreateInstanceEx: IID_DirectDraw7 RIID\n"); - res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)&ppv, IID_IDirectDraw7, 0); - if(res)OutTraceDW("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res)); - break; - case 0xe436ebb3: - break; + LPDIRECTDRAW lpOldDDraw; + case 0x6C14DB80: + OutTraceDW("CoCreateInstance: IID_DirectDraw RIID\n"); + HookDDSession((LPDIRECTDRAW *)ppv, 1); + break; + case 0xB3A6F3E0: + OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID\n"); + res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); + if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); + res=lpOldDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)ppv); + if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); + lpOldDDraw->Release(); + break; + case 0x9C59509A: + OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID\n"); + res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); + if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); + res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)ppv); + if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); + lpOldDDraw->Release(); + break; + case 0x15E65EC0: + OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID\n"); + res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)ppv, IID_IDirectDraw7, 0); + if(res)OutTraceDW("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res)); + break; + case 0xE436EBB3: + break; } } - else - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + else { + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + } } HookAdditionalModules(); + OutTraceDW("CoCreateInstanceEx: res=%x\n", res); return res; } @@ -197,3 +240,9 @@ HRESULT WINAPI extCoInitialize(LPVOID pvReserved) res=(*pCoInitialize)(pvReserved); return res; } + +void WINAPI extCoUninitialize(void) +{ + OutTraceDW("CoUninitialize\n"); + (*pCoUninitialize)(); +} \ No newline at end of file diff --git a/dll/syslibs.h b/dll/syslibs.h index 2710520..8b35f8e 100644 --- a/dll/syslibs.h +++ b/dll/syslibs.h @@ -136,6 +136,7 @@ typedef BOOL (WINAPI *GetExitCodeProcess_Type)(HANDLE, LPDWORD); typedef HRESULT (STDAPICALLTYPE *CoCreateInstance_Type)(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*); typedef HRESULT (STDAPICALLTYPE *CoCreateInstanceEx_Type)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, DWORD, MULTI_QI *); typedef HRESULT (STDAPICALLTYPE *CoInitialize_Type)(LPVOID); +typedef void (STDAPICALLTYPE *CoUninitialize_Type)(void); // user32.dll: typedef HDC (WINAPI *BeginPaint_Type)(HWND, LPPAINTSTRUCT); @@ -350,6 +351,7 @@ DXWEXTERN GetExitCodeProcess_Type pGetExitCodeProcess DXWINITIALIZED; DXWEXTERN CoCreateInstance_Type pCoCreateInstance DXWINITIALIZED; DXWEXTERN CoCreateInstanceEx_Type pCoCreateInstanceEx DXWINITIALIZED; DXWEXTERN CoInitialize_Type pCoInitialize DXWINITIALIZED; +DXWEXTERN CoUninitialize_Type pCoUninitialize DXWINITIALIZED; // user32.dll: DXWEXTERN BeginPaint_Type pBeginPaint DXWINITIALIZED; @@ -565,6 +567,7 @@ extern BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *); extern HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*); extern HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, DWORD, MULTI_QI *); extern HRESULT STDAPICALLTYPE extCoInitialize(LPVOID); +extern void STDAPICALLTYPE extCoUninitialize(void); // user32.dll: extern HDC WINAPI extBeginPaint(HWND, LPPAINTSTRUCT); diff --git a/dll/user32.cpp b/dll/user32.cpp index 861f45e..bc35be4 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -36,6 +36,12 @@ HHOOK WINAPI extSetWindowsHookEx(int, HOOKPROC, HINSTANCE, DWORD); typedef BOOL (WINAPI *PostMessageA_Type)(HWND, UINT, WPARAM, LPARAM); PostMessageA_Type pPostMessageA = NULL; BOOL WINAPI extPostMessageA(HWND, UINT, WPARAM, LPARAM); +typedef HRESULT (WINAPI *MessageBoxTimeoutA_Type)(HWND, LPCSTR, LPCSTR, UINT, WORD, DWORD); +MessageBoxTimeoutA_Type pMessageBoxTimeoutA = NULL; +HRESULT WINAPI extMessageBoxTimeoutA(HWND, LPCSTR, LPCSTR, UINT, WORD, DWORD); +typedef HRESULT (WINAPI *MessageBoxTimeoutW_Type)(HWND, LPCWSTR, LPCWSTR, UINT, WORD, DWORD); +MessageBoxTimeoutW_Type pMessageBoxTimeoutW = NULL; +HRESULT WINAPI extMessageBoxTimeoutW(HWND, LPCWSTR, LPCWSTR, UINT, WORD, DWORD); #ifdef TRACEPALETTE typedef UINT (WINAPI *GetDIBColorTable_Type)(HDC, UINT, UINT, RGBQUAD *); @@ -99,6 +105,9 @@ static HookEntry_Type Hooks[]={ {HOOK_HOT_CANDIDATE, "WindowFromPoint", (FARPROC)WindowFromPoint, (FARPROC *)&pWindowFromPoint, (FARPROC)extWindowFromPoint}, {HOOK_HOT_CANDIDATE, "SetWindowsHookExA", (FARPROC)SetWindowsHookExA, (FARPROC *)&pSetWindowsHookEx, (FARPROC)extSetWindowsHookEx}, + //{HOOK_HOT_CANDIDATE, "MessageBoxTimeoutA", (FARPROC)NULL, (FARPROC *)&pMessageBoxTimeoutA, (FARPROC)extMessageBoxTimeoutA}, + //{HOOK_HOT_CANDIDATE, "MessageBoxTimeoutW", (FARPROC)NULL, (FARPROC *)&pMessageBoxTimeoutW, (FARPROC)extMessageBoxTimeoutW}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -1113,6 +1122,7 @@ int WINAPI extMapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT ret=(*pMapWindowPoints)(hWndFrom, hWndTo, lpPoints, cPoints); // v2.03.16: now must scale every point (fixes "NBA Live 99") + // v2.03.18: in some cases it should not! "New Your Race"... for(pi=0; pi