diff --git a/Include/dxwnd.h b/Include/dxwnd.h index 9cc4aca..5b35bf2 100644 --- a/Include/dxwnd.h +++ b/Include/dxwnd.h @@ -142,6 +142,7 @@ #define HOTPATCH 0x04000000 // Use hot patching technique to handle obfuscated IAT #define ENABLEHOTKEYS 0x08000000 // Enables hot keys #define HOTPATCHALWAYS 0x10000000 // Force hot patching to every call +#define NOD3DRESET 0x20000000 // Disables D3D8/9 D3DDevice::Reset method // logging Tflags DWORD: #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general diff --git a/build/dxwnd.dll b/build/dxwnd.dll index c94aabe..ef61201 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b7f9b28cc1d19e29759f70cf2f5187a21319a31a0d8bd24d36c3314161d958c -size 483328 +oid sha256:0abd5d664eea54b2046da9cf7c3b556569a5bbd8c65eb87e1b088dff67641ef1 +size 483840 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index e470991..b44d478 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d705eb95e5834c95b4be2e8639c08df2c027df4edec2b0e3f2247e9f05da5d67 -size 539136 +oid sha256:11f3d90b87b33ec400bd96219a0786300f2dbd21935e72a2b859317f887696e0 +size 540160 diff --git a/build/dxwnd.ini b/build/dxwnd.ini index b74c8f2..2f9754f 100644 --- a/build/dxwnd.ini +++ b/build/dxwnd.ini @@ -3,9 +3,3 @@ timetoggle=0x72 altf4=0x73 timeslow=0x74 timefast=0x75 - -[window] -posx=50 -posy=50 -sizx=320 -sizy=200 diff --git a/build/exports/Rollcage (3DFX).dxw b/build/exports/Rollcage (3DFX).dxw new file mode 100644 index 0000000..1376e5e --- /dev/null +++ b/build/exports/Rollcage (3DFX).dxw @@ -0,0 +1,27 @@ +[target] +title0=Rollcage (3DFX) +path0=D:\Games\Rollcage\Glide\ROLLCAGE.EXE +launchpath0=D:\Games\Rollcage\RollCage.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=150994976 +flagg0=1207959552 +flagh0=20 +flagi0=136314884 +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/Rollcage (D3D).dxw b/build/exports/Rollcage (D3D).dxw new file mode 100644 index 0000000..bb50259 --- /dev/null +++ b/build/exports/Rollcage (D3D).dxw @@ -0,0 +1,27 @@ +[target] +title0=Rollcage (D3D) +path0=D:\Games\Rollcage\Direct3D\Rollcage.exe +launchpath0=D:\Games\Rollcage\RollCage.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=150994976 +flagg0=134217728 +flagh0=20 +flagi0=136314884 +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/Rollcage 2 (D3D).dxw b/build/exports/Rollcage 2 (D3D).dxw new file mode 100644 index 0000000..62cb48f --- /dev/null +++ b/build/exports/Rollcage 2 (D3D).dxw @@ -0,0 +1,27 @@ +[target] +title0=Rollcage 2 (D3D) +path0=D:\Games\Rollcage 2\BIN\Rollcage D3D.exe +launchpath0=D:\Games\Rollcage 2\Rollcage.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217760 +flagg0=134217728 +flagh0=20 +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/readme-relnotes.txt b/build/readme-relnotes.txt index 91e0e53..a107f21 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -493,3 +493,10 @@ fix: eliminated dialogs with timer warning messages (to be investigated...) fix: moved "no banner" flag to main tab again fix: potential string violation, possible cause for flash crash? +v2.02.75 +Hooked D3DDevice::ShowCursor method to apply force show/hide cursor (preliminary...) +fix: dynamic allocation for WndProc stack to eliminate predefined limit of 256 entries. Star Wars Rebellion uses more than 256. +added: "Suppress D3D8/9 Reset" flag +fix: improved show FPS and Time Stretch overlay so that the two overlays won't overlap each other +fix: bug in ddraw "Locked surface" mode preventing output on screen +fix: fixed bug in critical common portion of the code that was crashing even unhooked programs (namely, Flash Player, ...) diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 1015ead..1f3e0f9 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -1524,7 +1524,8 @@ HRESULT WINAPI extDirectDrawCreate(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplpdd, I //OutTrace("DirectDrawCreate: drivercaps=%x(%s) emulcaps=%x(%s)\n", DriverCaps.ddsCaps, "???", EmulCaps.ddsCaps, "???"); } - return 0; + lpPrimaryDD=*lplpdd; + return DD_OK; } HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *lpguid, @@ -1586,9 +1587,19 @@ HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *lpguid, OutTraceDDRAW("DirectDrawCreateEx: lpdd=%x guid=%s DDVersion=%d\n", *lplpdd, mode, dxw.dwDDVersion); HookDDSession(lplpdd, dxw.dwDDVersion); - lpPrimaryDD=*lplpdd; - return 0; + if(IsDebug && (dxw.dwTFlags & OUTPROXYTRACE)){ + DDCAPS DriverCaps, EmulCaps; + memset(&DriverCaps, 0, sizeof(DriverCaps)); + DriverCaps.dwSize=sizeof(DriverCaps); + memset(&EmulCaps, 0, sizeof(EmulCaps)); + EmulCaps.dwSize=sizeof(EmulCaps); + (LPDIRECTDRAW)(*lplpdd)->GetCaps(&DriverCaps, &EmulCaps); + //OutTrace("DirectDrawCreate: drivercaps=%x(%s) emulcaps=%x(%s)\n", DriverCaps.ddsCaps, "???", EmulCaps.ddsCaps, "???"); + } + + lpPrimaryDD=*lplpdd; + return DD_OK; } HRESULT WINAPI extInitialize(LPDIRECTDRAW lpdd, GUID FAR *lpguid) @@ -3766,9 +3777,10 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC } res=(*pUnlock)(lpdds, lprect); + 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) sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE); - if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=0; + if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; return res; } @@ -3807,23 +3819,24 @@ HRESULT WINAPI extUnlockDir(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSUR } if(dxw.dwFlags1 & LOCKEDSURFACE){ - (*pGetGDISurface)(lpPrimaryDD, &lpDDSPrim); - if(lpdds==lpDDSPrim){ - RECT client; - POINT upleft={0,0}; - (*pGetClientRect)(dxw.GethWnd(), &client); - (*pClientToScreen)(dxw.GethWnd(), &upleft); - if (!lprect) lprect=&client; - OffsetRect(lprect, upleft.x, upleft.y); - res=(*pUnlock)((LPDIRECTDRAWSURFACE)lpDDSBuffer, lprect); - (*pBlt)(lpdds, lprect, (LPDIRECTDRAWSURFACE)lpDDSBuffer, NULL, DDBLT_WAIT, 0); - if(lpDDSBuffer) (*pReleaseS)((LPDIRECTDRAWSURFACE)lpDDSBuffer); - lpDDSBuffer = NULL; - } + (*pGetGDISurface)(lpPrimaryDD, &lpDDSPrim); + if(lpdds==lpDDSPrim && lpDDSBuffer){ + RECT client; + POINT upleft={0,0}; + (*pGetClientRect)(dxw.GethWnd(), &client); + (*pClientToScreen)(dxw.GethWnd(), &upleft); + if (!lprect) lprect=&client; + OffsetRect(lprect, upleft.x, upleft.y); + res=(*pUnlock)((LPDIRECTDRAWSURFACE)lpDDSBuffer, lprect); + (*pBlt)(lpdds, lprect, (LPDIRECTDRAWSURFACE)lpDDSBuffer, NULL, DDBLT_WAIT, 0); + (*pReleaseS)((LPDIRECTDRAWSURFACE)lpDDSBuffer); + lpDDSBuffer = NULL; + } (*pReleaseS)(lpDDSPrim); // to leave a correct refcount } res=(*pUnlock)(lpdds, lprect); + 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) sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE); if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index fa756bd..c7b7d6c 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -29,6 +29,7 @@ static LARGE_INTEGER TimeShifter64Coarse(LARGE_INTEGER, int); dxwCore::dxwCore() { // initialization stuff .... + extern void WhndStackInit(); FullScreen=FALSE; SethWnd(NULL); SetScreenSize(); @@ -43,6 +44,7 @@ dxwCore::dxwCore() ResetEmulatedDC(); MustShowOverlay=FALSE; TimerEvent.dwTimerType = TIMER_TYPE_NONE; + WhndStackInit(); } dxwCore::~dxwCore() @@ -1130,6 +1132,10 @@ void dxwCore::ShowOverlay(HDC hdc) // lpdds->ReleaseDC(hdc); //} +// nasty global to ensure that the corner is picked semi-random, but never overlapped +// between FPS and TimeStretch (and, as a side effect, never twice the same!) +static int LastCorner; + void dxwCore::ShowFPS(HDC xdc) { char sBuf[81]; @@ -1142,6 +1148,8 @@ void dxwCore::ShowFPS(HDC xdc) RECT rect; dwTimer = (*pGetTickCount)(); corner = dwTimer % 4; + if(corner==LastCorner) corner = (corner+1) % 4; + LastCorner = corner; color=0xFF0000; // blue (*pGetClientRect)(hWnd, &rect); switch (corner) { @@ -1194,6 +1202,8 @@ void dxwCore::ShowTimeStretching(HDC xdc) dwTimer = (*pGetTickCount)(); LastTimeShift=TimeShift; corner = dwTimer % 4; + if(corner==LastCorner) corner = (corner+1) % 4; + LastCorner = corner; color=0x0000FF; // red (*pGetClientRect)(hWnd, &rect); switch (corner) { @@ -1651,58 +1661,37 @@ BOOL dxwCore::CheckScreenResolution(unsigned int w, unsigned int h) return TRUE; } -#ifdef COMPATIBLEMODE -void dxwCore::MapKeysInit(){} - -UINT dxwCore::MapKeysConfig(UINT message, LPARAM lparam, WPARAM wparam) -{ - int vkey; - char *caption; - if(message!=WM_SYSKEYDOWN) return DXVK_NONE; - switch(wparam){ - case VK_F12: vkey=DXVK_CLIPTOGGLE; caption="CLIPCURSORTOGGLE"; break; - case VK_F11: vkey=DXVK_REFRESH; caption="REFRESH"; break; - case VK_F10: vkey=DXVK_LOGTOGGLE; caption="LOGTOGGLE"; break; - case VK_F9: vkey=DXVK_PLOCKTOGGLE; caption="POSITIONLOCKTOGGLE"; break; - case VK_F7: vkey=DXVK_FPSTOGGLE; caption="FPSTOGGLE"; break; - case VK_F6: vkey=DXVK_TIMEFAST; caption="TIMESTRETCHFAST"; break; - case VK_F5: vkey=DXVK_TIMESLOW; caption="TIMESTRETCHSLOW"; break; - case VK_F4: vkey=DXVK_ALTF4; caption="ALTF4"; break; - default: vkey=DXVK_NONE; break; - } - if(vkey) OutTraceDW("MapKeysConfig: ret=%x(%s)\n", vkey); - return vkey; -} -#else UINT VKeyConfig[DXVK_SIZE]; -void dxwCore::MapKeysInit() +static char *VKeyLabels[DXVK_SIZE]={ + "none", + "cliptoggle", + "refresh", + "logtoggle", + "plocktoggle", + "fpstoggle", + "timefast", + "timeslow", + "timetoggle", + "altf4" +}; +void dxwCore::MapKeysInit() { char InitPath[MAX_PATH]; char *p; DWORD dwAttrib; - + int KeyIdx; dwAttrib = GetFileAttributes("dxwnd.dll"); if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) return; GetModuleFileName(GetModuleHandle("dxwnd"), InitPath, MAX_PATH); p=&InitPath[strlen(InitPath)-strlen("dxwnd.dll")]; strcpy(p, "dxwnd.ini"); VKeyConfig[DXVK_NONE]=DXVK_NONE; - VKeyConfig[DXVK_CLIPTOGGLE]= GetPrivateProfileInt("keymapping", "cliptoggle", 0, InitPath); - VKeyConfig[DXVK_REFRESH]= GetPrivateProfileInt("keymapping", "refresh", 0, InitPath); - VKeyConfig[DXVK_LOGTOGGLE]= GetPrivateProfileInt("keymapping", "logtoggle", 0, InitPath); - VKeyConfig[DXVK_PLOCKTOGGLE]= GetPrivateProfileInt("keymapping", "plocktoggle", 0, InitPath); - VKeyConfig[DXVK_FPSTOGGLE]= GetPrivateProfileInt("keymapping", "fpstoggle", 0, InitPath); - VKeyConfig[DXVK_TIMEFAST]= GetPrivateProfileInt("keymapping", "timefast", 0, InitPath); - VKeyConfig[DXVK_TIMESLOW]= GetPrivateProfileInt("keymapping", "timeslow", 0, InitPath); - VKeyConfig[DXVK_TIMETOGGLE]= GetPrivateProfileInt("keymapping", "timetoggle", 0, InitPath); - VKeyConfig[DXVK_ALTF4]= GetPrivateProfileInt("keymapping", "altf4", 0x73, InitPath); - - int idx; - for(idx=1; idx. #include "dxwnd.h" #include "dxwcore.hpp" -#define VERSION "2.02.74" +#define VERSION "2.02.75" #define DDTHREADLOCK 1 @@ -64,7 +64,11 @@ BOOL APIENTRY DllMain( HANDLE hmodule, DisableThreadLibraryCalls((HMODULE)hmodule); hMapping = CreateFileMapping((HANDLE)0xffffffff, NULL, PAGE_READWRITE, 0, sizeof(DxWndStatus)+sizeof(TARGETMAP)*MAXTARGETS, "UniWind_TargetList"); + if(!hMapping) return false; + // v2.0.2.75: beware: some tasks (namely, Flash player) get dxwnd.dll loaded, but can't create the file mapping + // this situation has to be intercepted, or it can cause the dll to cause faults that may crash the program. pStatus = (DXWNDSTATUS *)MapViewOfFile(hMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DXWNDSTATUS)+sizeof(TARGETMAP)*MAXTARGETS); + if(!pStatus) return false; pMapping = (TARGETMAP *)((char *)pStatus + sizeof(DXWNDSTATUS)); hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "UniWind_Mutex"); if(!hMutex) hMutex = CreateMutex(0, FALSE, "UniWind_Mutex"); diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 547d9d9..0518d09 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index 7ddbaf8..05f954f 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -41,6 +41,8 @@ typedef void (WINAPI *SetGammaRamp_Type)(void *, UINT, DWORD, D3DGAMMARAMP *); typedef void (WINAPI *GetGammaRamp_Type)(void *, UINT, D3DGAMMARAMP *); 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 *SetTexture8_Type)(void *, DWORD, void *); typedef HRESULT (WINAPI *SetTexture9_Type)(void *, DWORD, void *); @@ -95,6 +97,8 @@ 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); @@ -154,6 +158,8 @@ 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; @@ -460,6 +466,7 @@ void HookD3DDevice8(void** ppD3Ddev8) SetHook((void *)(**(DWORD **)ppD3Ddev8 + 24), extGetDirect3D8, (void **)&pGetDirect3D8, "GetDirect3D(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 32), extGetDisplayMode8, (void **)&pGetDisplayMode8, "GetDisplayMode(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 44), extSetCursorPosition8, (void **)&pSetCursorPosition8, "SetCursorPosition(D8)"); + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 48), extShowCursor8, (void **)&pShowCursor8, "ShowCursor(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 52), extCreateAdditionalSwapChain, (void **)&pCreateAdditionalSwapChain, "CreateAdditionalSwapChain(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 56), extReset, (void **)&pReset, "Reset(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 60), extPresent, (void **)&pPresent, "Present(D8)"); @@ -491,6 +498,7 @@ void HookD3DDevice9(void** ppD3Ddev9) 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 + 64), extReset, (void **)&pReset, "Reset(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 68), extPresent, (void **)&pPresent, "Present(D9)"); @@ -711,18 +719,22 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) } } - res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); - if(res){ - OutTraceDW("FAILED! %x\n", res); - return res; + if(!(dxw.dwFlags4 & NOD3DRESET)){ + res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); + if(res == D3DERR_INVALIDCALL){ + OutTraceDW("FAILED! D3DERR_INVALIDCALL\n", res); + return D3DERR_INVALIDCALL; + } + if(res){ + OutTraceDW("FAILED! %x\n", res); + return res; + } + OutTraceDW("SUCCESS!\n"); + (dwD3DVersion == 8) ? HookD3DDevice8(&pd3dd) : HookD3DDevice9(&pd3dd); } - OutTraceDW("SUCCESS!\n"); - - if(dwD3DVersion == 8){ - HookD3DDevice8(&pd3dd); - } - else { - HookD3DDevice9(&pd3dd); + else{ + OutTraceDW("SKIPPED!\n"); + res=D3D_OK; } dxw.SetScreenSize(pPresParam->BackBufferWidth, pPresParam->BackBufferHeight); @@ -1521,3 +1533,31 @@ ULONG WINAPI extSetTexture9(void *lpd3dd, DWORD Stage, void* pTexture) OutTraceD3D("Device::SetTexture(9): d3dd=%x stage=%x\n", lpd3dd, Stage); return DD_OK; } + +BOOL WINAPI extShowCursor8(void *lpd3dd, BOOL bShow) +{ + BOOL res, bNew; + bNew=bShow; + if(dxw.dwFlags2 & SHOWHWCURSOR) bNew=TRUE; + if(dxw.dwFlags1 & HIDEHWCURSOR) bNew=FALSE; + res=(*pShowCursor8)(lpd3dd, bNew); + if(bNew==bShow) + OutTraceD3D("Device::ShowCursor(8): d3dd=%x show=%x res=%x\n", lpd3dd, bNew, res); + else + OutTraceD3D("Device::ShowCursor(8): d3dd=%x show=%x->%x res=%x\n", lpd3dd, bShow, bNew, res); + return res; +} + +BOOL WINAPI extShowCursor9(void *lpd3dd, BOOL bShow) +{ + BOOL res, bNew; + bNew=bShow; + if(dxw.dwFlags2 & SHOWHWCURSOR) bNew=TRUE; + if(dxw.dwFlags1 & HIDEHWCURSOR) bNew=FALSE; + res=(*pShowCursor9)(lpd3dd, bNew); + if(bNew==bShow) + OutTraceD3D("Device::ShowCursor(9): d3dd=%x show=%x res=%x\n", lpd3dd, bNew, res); + else + OutTraceD3D("Device::ShowCursor(9): d3dd=%x show=%x->%x res=%x\n", lpd3dd, bShow, bNew, res); + return res; +} diff --git a/dll/hd3d7.cpp b/dll/hd3d7.cpp index 59a779b..28bd955 100644 --- a/dll/hd3d7.cpp +++ b/dll/hd3d7.cpp @@ -806,7 +806,7 @@ HRESULT WINAPI extD3DGetCaps(void *d3dd, LPD3DDEVICEDESC lpd3dd ,LPD3DDEVICEDESC HRESULT WINAPI extSetRenderState(SetRenderState3_Type pSetRenderState, int version, void *d3dd, D3DRENDERSTATETYPE State, DWORD Value) { HRESULT res; - OutTraceD3D("SetRenderState(%d): d3dd=%x State=%x(%s) Value=%x\n", version, d3dd, State, ExplainD3DRenderState(State), Value); + OutTraceB("SetRenderState(%d): d3dd=%x State=%x(%s) Value=%x\n", version, d3dd, State, ExplainD3DRenderState(State), Value); if((dxw.dwFlags4 & ZBUFFERALWAYS) && (State == D3DRENDERSTATE_ZFUNC)) { OutTraceD3D("SetRenderState: FIXED State=ZFUNC Value=%s->D3DCMP_ALWAYS\n", ExplainRenderstateValue(Value)); diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index 9a2c292..cbd43b3 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -35,14 +35,14 @@ static HookEntry_Type LimitHooks[]={ }; static HookEntry_Type TimeHooks[]={ - {HOOK_IAT_CANDIDATE, "GetTickCount", (FARPROC)GetTickCount, (FARPROC *)&pGetTickCount, (FARPROC)extGetTickCount}, - {HOOK_IAT_CANDIDATE, "GetLocalTime", (FARPROC)GetLocalTime, (FARPROC *)&pGetLocalTime, (FARPROC)extGetLocalTime}, - {HOOK_IAT_CANDIDATE, "GetSystemTime", (FARPROC)GetSystemTime, (FARPROC *)&pGetSystemTime, (FARPROC)extGetSystemTime}, - {HOOK_IAT_CANDIDATE, "GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime}, - {HOOK_IAT_CANDIDATE, "Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep}, - {HOOK_IAT_CANDIDATE, "SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx}, - {HOOK_IAT_CANDIDATE, "QueryPerformanceCounter", (FARPROC)QueryPerformanceCounter, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter}, - {HOOK_IAT_CANDIDATE, "QueryPerformanceFrequency", (FARPROC)QueryPerformanceFrequency, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency}, + {HOOK_HOT_CANDIDATE, "GetTickCount", (FARPROC)GetTickCount, (FARPROC *)&pGetTickCount, (FARPROC)extGetTickCount}, + {HOOK_HOT_CANDIDATE, "GetLocalTime", (FARPROC)GetLocalTime, (FARPROC *)&pGetLocalTime, (FARPROC)extGetLocalTime}, + {HOOK_HOT_CANDIDATE, "GetSystemTime", (FARPROC)GetSystemTime, (FARPROC *)&pGetSystemTime, (FARPROC)extGetSystemTime}, + {HOOK_HOT_CANDIDATE, "GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime}, + {HOOK_HOT_CANDIDATE, "Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep}, + {HOOK_HOT_CANDIDATE, "SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx}, + {HOOK_HOT_CANDIDATE, "QueryPerformanceCounter", (FARPROC)QueryPerformanceCounter, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter}, + {HOOK_HOT_CANDIDATE, "QueryPerformanceFrequency", (FARPROC)QueryPerformanceFrequency, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; diff --git a/dll/winmm.cpp b/dll/winmm.cpp index e594511..8783e4e 100644 --- a/dll/winmm.cpp +++ b/dll/winmm.cpp @@ -15,9 +15,9 @@ static HookEntry_Type Hooks[]={ }; static HookEntry_Type TimeHooks[]={ - {HOOK_IAT_CANDIDATE, "timeGetTime", NULL, (FARPROC *)&ptimeGetTime, (FARPROC)exttimeGetTime}, - {HOOK_IAT_CANDIDATE, "timeKillEvent", NULL, (FARPROC *)&ptimeKillEvent, (FARPROC)exttimeKillEvent}, - {HOOK_IAT_CANDIDATE, "timeSetEvent", NULL, (FARPROC *)&ptimeSetEvent, (FARPROC)exttimeSetEvent}, + {HOOK_HOT_CANDIDATE, "timeGetTime", NULL, (FARPROC *)&ptimeGetTime, (FARPROC)exttimeGetTime}, + {HOOK_HOT_CANDIDATE, "timeKillEvent", NULL, (FARPROC *)&ptimeKillEvent, (FARPROC)exttimeKillEvent}, + {HOOK_HOT_CANDIDATE, "timeSetEvent", NULL, (FARPROC *)&ptimeSetEvent, (FARPROC)exttimeSetEvent}, {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; diff --git a/dll/wndproc.cpp b/dll/wndproc.cpp index 102b820..98a1a86 100644 --- a/dll/wndproc.cpp +++ b/dll/wndproc.cpp @@ -19,16 +19,25 @@ typedef struct { #define MAXWNDHSTACK 256 -wndstack_entry WhndStack[MAXWNDHSTACK]; +wndstack_entry *WhndStack; static int WhndTOS = 0; +static int WhndSize = 0; void WhndStackInit() { + WhndSize = MAXWNDHSTACK; + WhndStack = (wndstack_entry *)malloc(WhndSize * sizeof(wndstack_entry)); } void WhndStackPush(HWND hwnd, WNDPROC wndproc) { int StackIdx; + + if(WhndTOS == WhndSize){ + WhndSize += MAXWNDHSTACK; + WhndStack = (wndstack_entry *)realloc(WhndStack, WhndSize * sizeof(wndstack_entry)); + //OutTraceDW("DEBUG: WNDPROC STACK new size=%d\n", WhndSize); + } // wndproc values of 0xFFFFxxxx type seems to be error codes rather than valid callback addresses .... // v2.02.36 using CallWindowProc you can pass WinProc handles, so you don't need to eliminate them! //if (((DWORD)wndproc & 0xFFFF0000) == 0xFFFF0000) return; @@ -40,12 +49,6 @@ void WhndStackPush(HWND hwnd, WNDPROC wndproc) return; } // push if not already there. - if(WhndTOS>=MAXWNDHSTACK) { - char sMsg[80]; - sprintf(sMsg, "Table overflow: %d entries used", MAXWNDHSTACK); - MessageBox(0, sMsg, "WhndStackPush", MB_OK | MB_ICONEXCLAMATION); - return; - } WhndStack[WhndTOS].hwnd=hwnd; WhndStack[WhndTOS].wndproc=wndproc; WhndTOS++; @@ -54,7 +57,7 @@ void WhndStackPush(HWND hwnd, WNDPROC wndproc) WNDPROC WhndGetWindowProc(HWND hwnd) { int StackIdx; - for(StackIdx=0; StackIdxm_NoAlphaChannel); DDX_Check(pDX, IDC_FIXREFCOUNTER, cTarget->m_FixRefCounter); DDX_Check(pDX, IDC_RETURNNULLREF, cTarget->m_ReturnNullRef); + DDX_Check(pDX, IDC_NOD3DRESET, cTarget->m_NoD3DReset); DDX_Check(pDX, IDC_NOFLIPEMULATION, cTarget->m_NoFlipEmulation); } diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp index 6288195..7a08af9 100644 --- a/host/TargetDlg.cpp +++ b/host/TargetDlg.cpp @@ -46,6 +46,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_NoAlphaChannel = FALSE; m_FixRefCounter = TRUE; m_ReturnNullRef = FALSE; + m_NoD3DReset = FALSE; m_SuppressChild = FALSE; m_HideDesktop = FALSE; m_LockSysColors = FALSE; diff --git a/host/TargetDlg.h b/host/TargetDlg.h index cf3b960..6c3078b 100644 --- a/host/TargetDlg.h +++ b/host/TargetDlg.h @@ -146,6 +146,7 @@ public: BOOL m_NoAlphaChannel; BOOL m_FixRefCounter; BOOL m_ReturnNullRef; + BOOL m_NoD3DReset; BOOL m_SuppressChild; BOOL m_HideDesktop; BOOL m_LockSysColors; diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index 0cb5c3d..77b0ef7 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index ce02451..24a16db 100644 --- a/host/dxwndhost.rc +++ b/host/dxwndhost.rc @@ -352,6 +352,7 @@ BEGIN CONTROL "Add proxy libs",IDC_ADDPROXYLIBS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,15,200,123,12 CONTROL "Compensate Flip emulation",IDC_NOFLIPEMULATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,76,119,10 CONTROL "Return 0 ref counter",IDC_RETURNNULLREF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,184,123,12 + CONTROL "Suppress D3D8/9 Reset",IDC_NOD3DRESET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,196,123,12 END IDD_TAB_INPUT DIALOGEX 0, 0, 300, 240 diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index bfbcff9..2070908 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp index bd2ef69..86fe6f7 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -184,6 +184,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_NoAlphaChannel) t->flags4 |= NOALPHACHANNEL; if(dlg->m_FixRefCounter) t->flags4 |= FIXREFCOUNTER; if(dlg->m_ReturnNullRef) t->flags4 |= RETURNNULLREF; + if(dlg->m_NoD3DReset) t->flags4 |= NOD3DRESET; if(dlg->m_SuppressChild) t->flags4 |= SUPPRESSCHILD; if(dlg->m_HideDesktop) t->flags4 |= HIDEDESKTOP; if(dlg->m_LockSysColors) t->flags3 |= LOCKSYSCOLORS; @@ -342,6 +343,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_NoAlphaChannel = t->flags4 & NOALPHACHANNEL ? 1 : 0; dlg->m_FixRefCounter = t->flags4 & FIXREFCOUNTER ? 1 : 0; dlg->m_ReturnNullRef = t->flags4 & RETURNNULLREF ? 1 : 0; + dlg->m_NoD3DReset = t->flags4 & NOD3DRESET ? 1 : 0; dlg->m_SuppressChild = t->flags4 & SUPPRESSCHILD ? 1 : 0; dlg->m_HideDesktop = t->flags4 & HIDEDESKTOP ? 1 : 0; dlg->m_LockSysColors = t->flags3 & LOCKSYSCOLORS ? 1 : 0; @@ -823,6 +825,8 @@ void CDxwndhostView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) *pResult = 0; } +static char ImportExportPath[4096] = {0}; + void CDxwndhostView::OnExport() { int i; @@ -851,21 +855,23 @@ void CDxwndhostView::OnImport() path[0]=0; CListCtrl& listctrl = GetListCtrl(); - char buffer[4096] = {0}; + //static char buffer[4096] = {0}; + //static char dirbuffer[4096] = {0}; char folder[MAX_PATH+1]; char pathname[MAX_PATH+1]; OPENFILENAME ofn = {0}; ofn.lStructSize = sizeof(ofn); - ofn.lpstrFile = (LPSTR)buffer; + ofn.lpstrFile = (LPSTR)ImportExportPath; + //ofn.lpstrInitialDir = (LPSTR)dirbuffer; ofn.nMaxFile = 4096; ofn.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER; ofn.lpstrDefExt = "dxw"; if(GetOpenFileName(&ofn)){ - if(buffer[ofn.nFileOffset - 1] != '\0'){ + if(ImportExportPath[ofn.nFileOffset - 1] != '\0'){ // Single-Select // "buffer" - name of file - LoadConfigItem(&TargetMaps[i], &TitleMaps[i], 0, buffer); + LoadConfigItem(&TargetMaps[i], &TitleMaps[i], 0, ImportExportPath); listitem.mask = LVIF_TEXT | LVIF_IMAGE; listitem.iItem = i; listitem.iSubItem = 0; @@ -875,7 +881,7 @@ void CDxwndhostView::OnImport() } else{ // Multi-Select - char* p = buffer; + char* p = ImportExportPath; strcpy(folder, p); strcat(folder, "\\"); p += lstrlen((LPSTR)p) + 1;