diff --git a/Include/dxwnd.h b/Include/dxwnd.h index cfbb4aa..67ef3b2 100644 --- a/Include/dxwnd.h +++ b/Include/dxwnd.h @@ -65,7 +65,7 @@ #define HOOKOPENGL 0x00020000 // Hook OpenGL calls #define WALLPAPERMODE 0x00040000 // mouse events are discarded (good for screensaver-like) #define SHOWHWCURSOR 0x00080000 // enable hardware cursor -#define HOOKGDI 0x00100000 // Hook GDI functions +#define GDISTRETCHED 0x00100000 // Stretch GDI/user32 coordinates to adapt to window size #define SHOWFPSOVERLAY 0x00200000 // shows FPS value to status win / log / screen overlay #define FAKEVERSION 0x00400000 // pretends the platvorm is a given window version / subversion #define FULLRECTBLT 0x00800000 // blit to primary surface using NULL source & dest rect @@ -94,7 +94,7 @@ #define NOWINDOWMOVE 0x00001000 // Do not try to update window position & size on D3D rendering #define DISABLEHAL 0x00002000 // Disable HAL support (IID_IDirect3DHALDevice) #define LOCKSYSCOLORS 0x00004000 // Lock Sys Colors changes by SetSysColors() call -#define EMULATEDC 0x00008000 // ........ +#define GDIEMULATEDC 0x00008000 // Map GDI/user32 calls to primary to a memory surface to be stretch-blitted to the primary #define FULLSCREENONLY 0x00010000 // assume that the program is always in fullscreen mode #define FONTBYPASS 0x00020000 // bypass font unsupported API #define YUV2RGB 0x00040000 // Simulate YUV to RGB color conversion @@ -125,6 +125,8 @@ #define NOPERFCOUNTER 0x00000200 // Disables the GetPerfCounter performance metrics API,as if it was not supported.... #define ADDPROXYLIBS 0x00000400 // Add proxy libs to otherwise hook-resilient system libraries (e.g. d3d9.dll) #define INTERCEPTRDTSC 0x00000800 // Intercapts RDTSC opcodes to hook at assembly level +#define LIMITSCREENRES 0x00001000 // Limit available screen resolution up to defined maximum +#define NOFILLRECT 0x00002000 // Suppress FillRect calls // logging Tflags DWORD: #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general @@ -170,6 +172,7 @@ typedef struct TARGETMAP short MaxFPS; short InitTS; short FakeVersionId; + short MaxScreenRes; }TARGETMAP; typedef struct @@ -244,3 +247,13 @@ typedef enum { DXW_DESKTOP_WORKAREA, DXW_DESKTOP_FULL } Coordinates_Types; + +typedef enum { + DXW_NO_LIMIT = 0, + DXW_LIMIT_320x200, + DXW_LIMIT_400x300, + DXW_LIMIT_640x480, + DXW_LIMIT_800x600, + DXW_LIMIT_1024x768, + DXW_LIMIT_1280x960 +} ResolutionLimits_Types; diff --git a/build/d3d9.dll b/build/d3d9.dll index 91a98d9..4accda6 100644 --- a/build/d3d9.dll +++ b/build/d3d9.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ddc18c4773ec0f8981f5d14895d303d8c4197b3768400b7fb281aa5954c1cfd -size 108544 +oid sha256:2886c8ffed47b9881f488c1ff15fac4653f83576d77cb1f4462caf7ebe2ded94 +size 556544 diff --git a/build/dxwnd.dll b/build/dxwnd.dll index d746fa5..c8f3fe6 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5bb7397123c001be9c2787f7e9eda53c0dcfb9077fac2cc5107e0598a37e96b6 -size 438784 +oid sha256:c24abb81ba8ba231b637a91ce227ef7f0ec20bccc36f9e8bea78f3e76d5ac2a2 +size 445440 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index 8021441..d304327 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41a91cd3edf9a9dfce166c8da6de6d4967d027ec4aa9acf8560a0c996ff46f4d -size 533504 +oid sha256:663ef886bb9f08ed3fea88ec675f0f213b8c60490183f2ad44984e5c7b6ef08d +size 535040 diff --git a/build/dxwnd.ini b/build/dxwnd.ini index 9327504..3371bb4 100644 --- a/build/dxwnd.ini +++ b/build/dxwnd.ini @@ -1776,11 +1776,11 @@ module77= opengllib77= ver77=9 coord77=0 -flag77=1753227296 -flagg77=139460608 -flagh77=20 +flag77=134217760 +flagg77=134217728 +flagh77=16 flagi77=1024 -tflag77=6163 +tflag77=6162 initx77=0 inity77=0 minx77=0 @@ -2391,6 +2391,29 @@ sizx103=800 sizy103=600 maxfps103=0 initts103=0 +title104=Serious Sam - The Second Encounter Demo +path104=D:\Games\Serious Sam - The Second Encounter Demo\Bin\SeriousSam.exe +module104= +opengllib104= +ver104=0 +coord104=0 +flag104=671088674 +flagg104=1208156160 +flagh104=20 +flagi104=4 +tflag104=64 +initx104=0 +inity104=0 +minx104=0 +miny104=0 +maxx104=0 +maxy104=0 +posx104=50 +posy104=50 +sizx104=800 +sizy104=600 +maxfps104=0 +initts104=4 [window] posx=995 posy=119 diff --git a/build/exports/Ed Hunter.dxw b/build/exports/Ed Hunter.dxw new file mode 100644 index 0000000..17f36dd --- /dev/null +++ b/build/exports/Ed Hunter.dxw @@ -0,0 +1,26 @@ +[target] +title0=Ed Hunter +path0=D:\Games\Ed Hunter\EDHUNTER.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217762 +flagg0=1208025088 +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=2 +winver0=0 +maxres0=-1 diff --git a/build/exports/G-Nome.dxw b/build/exports/G-Nome.dxw new file mode 100644 index 0000000..6bf8d97 --- /dev/null +++ b/build/exports/G-Nome.dxw @@ -0,0 +1,26 @@ +[target] +title0=G-Nome +path0=D:\Games\G-Nome\G-NOME.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671088674 +flagg0=1207959552 +flagh0=32788 +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/Hollywood Monsters.dxw b/build/exports/Hollywood Monsters.dxw new file mode 100644 index 0000000..797fac0 --- /dev/null +++ b/build/exports/Hollywood Monsters.dxw @@ -0,0 +1,26 @@ +[target] +title0=Hollywood Monsters +path0=D:\Games\Hollywood Monsters\monsters.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217762 +flagg0=1209008384 +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/Sid Meier's Civilization III Complete.dxw b/build/exports/Sid Meier's Civilization III Complete.dxw new file mode 100644 index 0000000..e52247c --- /dev/null +++ b/build/exports/Sid Meier's Civilization III Complete.dxw @@ -0,0 +1,26 @@ +[target] +title0=Sid Meier's Civilization III Complete +path0=D:\Games\Sid Meier's Civilization III Complete\Conquests\Civ3Conquests.exe +module0=jgl +opengllib0= +ver0=0 +coord0=0 +flag0=-1174405087 +flagg0=1213333504 +flagh0=65556 +flagi0=4100 +tflag0=6483 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=1024 +sizy0=768 +maxfps0=0 +initts0=6 +winver0=0 +maxres0=5 diff --git a/build/exports/Stratego.dxw b/build/exports/Stratego.dxw new file mode 100644 index 0000000..ea34a51 --- /dev/null +++ b/build/exports/Stratego.dxw @@ -0,0 +1,26 @@ +[target] +title0=Stratego +path0=D:\Games\Stratego\Stratego.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234146 +flagg0=1209008128 +flagh0=131092 +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/readme-relnotes.txt b/build/readme-relnotes.txt index 1987671..b8efc6f 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -341,3 +341,18 @@ GUI: added desktop color setting v2.02.50 Added "Intercept RDTSC" option: so far, tested on Unreal Tournament only. To implement RDTSC detection, I owe a big thank you to Olly who shared the disasm lib used to browse the assembly code. + +v2.02.51/52 +Hooked window timers: now "Ed Hunter" can be time stretched +added NOFILLRECT debug option +fixed WM_DISPLAYCHANGE handling (x,y swapped coordinates?) +fixed int64 arithmetic for performance counters +Added (untested !!!) handling for RDTSCP opcode with "Intercept RDTSC" option +Added "Limit screen resolution" option: seems necessary for "Sid Meyer's Civilization III" to work +Improved initial window coordinate & style handling +fixed virtual screen size showing into status panel +hooked SetPixelFormat, GetPixelFormat, ChoosePixelFormat and DescribePixelFormat to redirect desktop hwnd and make wglCreateContext work (needed for Civ III) +fixed log message for TextOut parameters +hooked DisableD3DSpy (invoked by The Bard's Tale) +fixed extglViewport coordinate remapping when invoked with CW_USEDEFAULT values (Civ III) +fixed bug in DirectDarawCreate/Ex hooking with wrong module handle diff --git a/d3d9proxy/Release/BuildLog.htm b/d3d9proxy/Release/BuildLog.htm deleted file mode 100644 index a7bded1..0000000 Binary files a/d3d9proxy/Release/BuildLog.htm and /dev/null differ diff --git a/d3d9proxy/Release/d3d9.dll.intermediate.manifest b/d3d9proxy/Release/d3d9.dll.intermediate.manifest deleted file mode 100644 index ecea6f7..0000000 --- a/d3d9proxy/Release/d3d9.dll.intermediate.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/d3d9proxy/Release/d3d9.pch b/d3d9proxy/Release/d3d9.pch deleted file mode 100644 index 03b39ea..0000000 Binary files a/d3d9proxy/Release/d3d9.pch and /dev/null differ diff --git a/d3d9proxy/Release/mt.dep b/d3d9proxy/Release/mt.dep deleted file mode 100644 index 8db6ed8..0000000 --- a/d3d9proxy/Release/mt.dep +++ /dev/null @@ -1 +0,0 @@ -Manifest resource last updated at 22:26:06.50 on 27/12/2013 diff --git a/d3d9proxy/Release/myIDirect3D9.obj b/d3d9proxy/Release/myIDirect3D9.obj deleted file mode 100644 index 02ed6f6..0000000 Binary files a/d3d9proxy/Release/myIDirect3D9.obj and /dev/null differ diff --git a/d3d9proxy/Release/myIDirect3DDevice9.obj b/d3d9proxy/Release/myIDirect3DDevice9.obj deleted file mode 100644 index a1b9525..0000000 Binary files a/d3d9proxy/Release/myIDirect3DDevice9.obj and /dev/null differ diff --git a/d3d9proxy/Release/proxydll.exp b/d3d9proxy/Release/proxydll.exp deleted file mode 100644 index e7a865f..0000000 Binary files a/d3d9proxy/Release/proxydll.exp and /dev/null differ diff --git a/d3d9proxy/Release/proxydll.lib b/d3d9proxy/Release/proxydll.lib deleted file mode 100644 index d3b94f7..0000000 Binary files a/d3d9proxy/Release/proxydll.lib and /dev/null differ diff --git a/d3d9proxy/Release/proxydll.obj b/d3d9proxy/Release/proxydll.obj deleted file mode 100644 index 4857036..0000000 Binary files a/d3d9proxy/Release/proxydll.obj and /dev/null differ diff --git a/d3d9proxy/Release/stdafx.obj b/d3d9proxy/Release/stdafx.obj deleted file mode 100644 index add114b..0000000 Binary files a/d3d9proxy/Release/stdafx.obj and /dev/null differ diff --git a/d3d9proxy/Release/vc90.idb b/d3d9proxy/Release/vc90.idb deleted file mode 100644 index 3da92cd..0000000 Binary files a/d3d9proxy/Release/vc90.idb and /dev/null differ diff --git a/d3d9proxy/Release/vc90.pdb b/d3d9proxy/Release/vc90.pdb deleted file mode 100644 index e9b6438..0000000 Binary files a/d3d9proxy/Release/vc90.pdb and /dev/null differ diff --git a/d3d9proxy/proxydll.suo b/d3d9proxy/proxydll.suo index 9cd9b24..4b70fff 100644 Binary files a/d3d9proxy/proxydll.suo and b/d3d9proxy/proxydll.suo differ diff --git a/d3d9proxy/proxydll.sln b/d3d9proxy/proxydll.vs2008.sln similarity index 91% rename from d3d9proxy/proxydll.sln rename to d3d9proxy/proxydll.vs2008.sln index c88932b..f472e14 100644 --- a/d3d9proxy/proxydll.sln +++ b/d3d9proxy/proxydll.vs2008.sln @@ -1,6 +1,7 @@ + Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxydll", "proxydll.vcproj", "{02EB97D5-B1C5-411E-8274-83A95985DE6F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxydll", "proxydll.vs2008.vcproj", "{02EB97D5-B1C5-411E-8274-83A95985DE6F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/d3d9proxy/proxydll.vs2008.suo b/d3d9proxy/proxydll.vs2008.suo new file mode 100644 index 0000000..a237713 Binary files /dev/null and b/d3d9proxy/proxydll.vs2008.suo differ diff --git a/d3d9proxy/proxydll.vcproj b/d3d9proxy/proxydll.vs2008.vcproj similarity index 100% rename from d3d9proxy/proxydll.vcproj rename to d3d9proxy/proxydll.vs2008.vcproj diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 0e6efb7..6594317 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -846,7 +846,7 @@ int Set_dwSize_From_DDraw(LPDIRECTDRAW lpdd) return (lpddHookedVersion(lpdd) < 4) ? sizeof(DDSURFACEDESC) : sizeof(DDSURFACEDESC2); } -static void HookDDSession(LPDIRECTDRAW *lplpdd, int dxversion) +void HookDDSession(LPDIRECTDRAW *lplpdd, int dxversion) { OutTraceDW("Hooking directdraw session dd=%x dxversion=%d thread_id=%x\n", *lplpdd, dxversion, GetCurrentThreadId()); @@ -907,11 +907,12 @@ static void HookDDSession(LPDIRECTDRAW *lplpdd, int dxversion) // IDIrectDraw::GetAvailableVidMem if (dxversion == 2) SetHook((void *)(**(DWORD **)lplpdd + 92), extGetAvailableVidMem2, (void **)&pGetAvailableVidMem2, "GetAvailableVidMem(D2)"); - if (dxversion == 4) - SetHook((void *)(**(DWORD **)lplpdd + 92), extGetAvailableVidMem4, (void **)&pGetAvailableVidMem4, "GetAvailableVidMem(D4)"); - // IDIrectDraw::TestCooperativeLevel - if (dxversion >= 4) - SetHook((void *)(**(DWORD **)lplpdd + 104), extTestCooperativeLevel, (void **)&pTestCooperativeLevel, "TestCooperativeLevel(D)"); + if (dxversion >= 4){ + // IDIrectDraw::GetAvailableVidMem + SetHook((void *)(**(DWORD **)lplpdd + 92), extGetAvailableVidMem4, (void **)&pGetAvailableVidMem4, "GetAvailableVidMem(D4)"); + // IDIrectDraw::TestCooperativeLevel + SetHook((void *)(**(DWORD **)lplpdd + 104), extTestCooperativeLevel, (void **)&pTestCooperativeLevel, "TestCooperativeLevel(D)"); + } if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; // Just proxed ... @@ -1369,10 +1370,13 @@ HRESULT WINAPI extDirectDrawCreate(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplpdd, I if(!pDirectDrawCreate){ // not hooked yet.... HINSTANCE hinst; hinst = LoadLibrary("ddraw.dll"); + if(!hinst){ + OutTraceE("LoadLibrary ERROR err=%d at %d\n", GetLastError(), __LINE__); + } pDirectDrawCreate = (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate"); if(pDirectDrawCreate) - HookAPI(NULL, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); + HookAPI(hinst, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate); // v2.02.52 else{ char sMsg[81]; sprintf_s(sMsg, 80, "DirectDrawCreate hook failed: error=%d\n", GetLastError()); @@ -1443,7 +1447,7 @@ HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *lpguid, pDirectDrawCreateEx = (DirectDrawCreateEx_Type)GetProcAddress(hinst, "DirectDrawCreateEx"); if(pDirectDrawCreateEx) - HookAPI(NULL, "ddraw.dll", pDirectDrawCreateEx, "DirectDrawCreateEx", extDirectDrawCreateEx); + HookAPI(hinst, "ddraw.dll", pDirectDrawCreateEx, "DirectDrawCreateEx", extDirectDrawCreateEx); // v2.02.52 else{ char sMsg[81]; sprintf_s(sMsg, 80, "DirectDrawCreateEx hook failed: error=%d\n", GetLastError()); @@ -1481,7 +1485,7 @@ HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *lpguid, } OutTraceDDRAW("DirectDrawCreateEx: lpdd=%x guid=%s DDVersion=%d\n", *lplpdd, mode, dxw.dwDDVersion); - HookDDSession(lplpdd,dxw.dwDDVersion); + HookDDSession(lplpdd, dxw.dwDDVersion); return 0; } @@ -1543,7 +1547,7 @@ HRESULT WINAPI extQueryInterfaceD(void *lpdd, REFIID riid, LPVOID *obp) dwLocalD3DVersion = 7; break; } - if (! *obp) { + if (! *obp){ OutTraceDDRAW("QueryInterface(D): Interface for DX version %d not found\n", dwLocalDDVersion); return(0); } @@ -1806,35 +1810,6 @@ HRESULT WINAPI extGetDisplayMode(LPDIRECTDRAW lpdd, LPDDSURFACEDESC lpddsd) return 0; } -void FixWindowFrame(HWND hwnd) -{ - LONG nOldStyle; - - OutTraceDW("FixWindowFrame: hwnd=%x\n", hwnd); - - nOldStyle=(*pGetWindowLong)(hwnd, GWL_STYLE); - if (!nOldStyle){ - OutTraceE("GetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); - return; - } - - OutTraceDW("FixWindowFrame: style=%x(%s)\n",nOldStyle,ExplainStyle(nOldStyle)); - - // fix style - if (!(*pSetWindowLong)(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW)){ - OutTraceE("SetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); - return; - } - // fix exstyle - if (!(*pSetWindowLong)(hwnd, GWL_EXSTYLE, 0)){ - OutTraceE("SetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); - return; - } - - // ShowWindow retcode means in no way an error code! Better ignore it. - (*pShowWindow)(hwnd, SW_RESTORE); - return; -} HRESULT WINAPI extSetCooperativeLevel(void *lpdd, HWND hwnd, DWORD dwflags) { @@ -1863,7 +1838,7 @@ HRESULT WINAPI extSetCooperativeLevel(void *lpdd, HWND hwnd, DWORD dwflags) dwflags |= DDSCL_NORMAL; res=(*pSetCooperativeLevel)(lpdd, hwnd, dwflags); AdjustWindowFrame(hwnd, dxw.GetScreenWidth(), dxw.GetScreenHeight()); - if (dxw.dwFlags1 & FIXWINFRAME) FixWindowFrame(hwnd); + if (dxw.dwFlags1 & FIXWINFRAME) dxw.FixWindowFrame(hwnd); } else{ RECT client; diff --git a/dll/dinput.cpp b/dll/dinput.cpp index 6b83488..b14e60f 100644 --- a/dll/dinput.cpp +++ b/dll/dinput.cpp @@ -96,13 +96,14 @@ HRESULT WINAPI extDirectInputCreate(HINSTANCE hinst, { HRESULT res; - OutTraceDW("DirectInputCreate: dwVersion = %x\n", + OutTraceDW("DirectInputCreate: dwVersion=%x\n", dwversion); res = (*pDirectInputCreate)(hinst, dwversion, lplpdi, pu); if(res) return res; - SetHook((void *)(**(DWORD **)lplpdi + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)"); SetHook((void *)(**(DWORD **)lplpdi), extQueryInterfaceI, (void **)&pQueryInterfaceI, "QueryInterface(I)"); + SetHook((void *)(**(DWORD **)lplpdi + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)"); + //SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)"); return 0; } @@ -111,12 +112,13 @@ HRESULT WINAPI extDirectInputCreateEx(HINSTANCE hinst, { HRESULT res; - OutTraceDW("DirectInputCreateEx: dwVersion = %x REFIID = %x\n", + OutTraceDW("DirectInputCreateEx: dwVersion=%x REFIID=%x\n", dwversion, riidltf.Data1); res = (*pDirectInputCreateEx)(hinst, dwversion, riidltf, ppvout, pu); if(res) return res; SetHook((void *)(**(DWORD **)ppvout + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)"); + //SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)"); SetHook((void *)(**(DWORD **)ppvout + 36), extDICreateDeviceEx, (void **)pDICreateDeviceEx, "DICreateDeviceEx(I)"); return 0; } @@ -125,7 +127,7 @@ HRESULT WINAPI extQueryInterfaceI(void * lpdi, REFIID riid, LPVOID *obp) { HRESULT res; - OutTraceDW("lpDI->QueryInterface: REFIID = %x\n", + OutTraceDW("QueryInterface(I): REFIID=%x\n", riid.Data1); res = (*pQueryInterfaceI)(lpdi, riid, obp); @@ -145,11 +147,15 @@ HRESULT WINAPI extDirectInput8Create(HINSTANCE hinst, { HRESULT res; - OutTraceDW("DirectInput8Create: dwVersion = %x REFIID = %x\n", + OutTraceDW("DirectInput8Create: dwVersion=%x REFIID=%x\n", dwversion, riidltf.Data1); res = (*pDirectInputCreateEx)(hinst, dwversion, riidltf, ppvout, pu); - if(res) return res; + if(res) { + OutTraceE("DirectInput8Create: ERROR res=%x\n", res); + return res; + } + OutTraceDW("DirectInput8Create: di=%x\n", *ppvout); SetHook((void *)(**(DWORD **)ppvout + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I8)"); return 0; } @@ -159,11 +165,14 @@ HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT lpdi, REFGUID rguid, { HRESULT res; - OutTraceDW("lpDI->CreateDevice: REFGUID = %x\n", - rguid.Data1); + OutTraceDW("CreateDevice(I): REFGUID=%x\n", rguid.Data1); res = (*pDICreateDevice)(lpdi, rguid, lplpdid, pu); - if(res) return res; + if(res) { + OutTraceE("CreateDevice(I): ERROR res=%x\n", res); + return res; + } + OutTraceDW("CreateDevice(I): did=%x\n", *lplpdid); SetHook((void *)(**(DWORD **)lplpdid + 36), extGetDeviceState, (void **)&pGetDeviceState, "GetDeviceState(I)"); SetHook((void *)(**(DWORD **)lplpdid + 40), extGetDeviceData, (void **)&pGetDeviceData, "GetDeviceData(I)"); SetHook((void *)(**(DWORD **)lplpdid + 44), extSetDataFormat, (void **)&pSetDataFormat, "SetDataFormat(I)"); @@ -176,11 +185,14 @@ HRESULT WINAPI extDICreateDeviceEx(LPDIRECTINPUT lpdi, REFGUID rguid, { HRESULT res; - OutTraceDW("lpDI->CreateDeviceEx: GUID = %x REFIID = %x\n", - rguid.Data1, riid.Data1); + OutTraceDW("CreateDeviceEx(I): GUID=%x REFIID=%x\n", rguid.Data1, riid.Data1); res = (*pDICreateDeviceEx)(lpdi, rguid, riid, pvout, pu); - if(res) return res; + if(res) { + OutTraceE("CreateDeviceEx(I): ERROR res=%x\n", res); + return res; + } + OutTraceDW("CreateDeviceEx(I): did=%x\n", *pvout); SetHook((void *)(**(DWORD **)pvout + 36), extGetDeviceState, (void **)&pGetDeviceState, "GetDeviceState(I)"); SetHook((void *)(**(DWORD **)pvout + 40), extGetDeviceData, (void **)&pGetDeviceData, "GetDeviceData(I)"); SetHook((void *)(**(DWORD **)pvout + 44), extSetDataFormat, (void **)&pSetDataFormat, "SetDataFormat(I)"); @@ -195,7 +207,7 @@ HRESULT WINAPI extGetDeviceData(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPVOID unsigned int i; POINT p; - OutTraceDW("GetDeviceData cbdata:%i\n", cbdata); + OutTraceDW("GetDeviceData(I): cbdata=%i\n", cbdata); res = (*pGetDeviceData)(lpdid, cbdata, rgdod, pdwinout, dwflags); if(res) return res; @@ -235,7 +247,7 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO HRESULT res; POINT p = {0, 0}; - OutTraceDW("GetDeviceState cbData:%i %i\n", cbdata, dxw.bActive); + OutTraceDW("GetDeviceState(I): cbData=%i,%i\n", cbdata, dxw.bActive); res = (*pGetDeviceState)(lpdid, cbdata, lpvdata); if(res) return res; @@ -266,7 +278,7 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE lpdid, LPCDIDATAFORMAT lpdf) { - OutTraceDW("SetDataFormat: flags = 0x%x\n", lpdf->dwFlags); + OutTraceDW("SetDataFormat(I): flags=0x%x\n", lpdf->dwFlags); if(lpdf->dwFlags & DIDF_ABSAXIS) dxw.bDInputAbs = 1; if(lpdf->dwFlags & DIDF_RELAXIS) dxw.bDInputAbs = 0; @@ -275,7 +287,7 @@ HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE lpdid, LPCDIDATAFORMAT lpdf) HRESULT WINAPI extDISetCooperativeLevel(LPDIRECTINPUTDEVICE lpdid, HWND hwnd, DWORD dwflags) { - OutTraceDW("lpDI->SetCooperativeLevel\n"); + OutTraceDW("SetCooperativeLevel(I)\n"); dwflags = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; return (*pDISetCooperativeLevel)(lpdid, hwnd, dwflags); @@ -290,7 +302,7 @@ void GetMousePosition(int *x, int *y) extGetCursorPos(&p); *x = p.x; *y = p.y; - OutTraceDW("GetMousePosition: x,y=(%d,%d)\n", *x, *y); + OutTraceDW("GetMousePosition(I): x,y=(%d,%d)\n", *x, *y); } void InitPosition(int x, int y, int minx, int miny, int maxx, int maxy) @@ -304,3 +316,13 @@ void InitPosition(int x, int y, int minx, int miny, int maxx, int maxy) iCurMaxX = maxx; iCurMaxY = maxy; } + +//HRESULT WINAPI extEnumDevices(void *lpdi, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) +//{ +// HRESULT res; +// OutTraceDW("EnumDevices(I): di=%x DevType=%x CallBack=%x Ref=%x Flags=%x\n", lpdi, dwDevType, lpCallback, pvRef, dwFlags); +// res=(*pEnumDevices)( lpdi, dwDevType, lpCallback, pvRef, dwFlags); +// OutTraceDW("EnumDevices(I): res=%x\n", res); +// return res; +//} + diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index 1556ca0..f800f35 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -50,7 +50,7 @@ static char *Flag2Names[32]={ "KEEPCURSORFIXED", "DISABLEGAMMARAMP", "DIFFERENTIALMOUSE", "FIXNCHITTEST", "LIMITFPS", "SKIPFPS", "SHOWFPS", "HIDEMULTIMONITOR", "TIMESTRETCH", "HOOKOPENGL", "WALLPAPERMODE", "SHOWHWCURSOR", - "HOOKGDI", "SHOWFPSOVERLAY", "FAKEVERSION", "FULLRECTBLT", + "GDISTRETCHED", "SHOWFPSOVERLAY", "FAKEVERSION", "FULLRECTBLT", "NOPALETTEUPDATE", "SUPPRESSIME", "NOBANNER", "WINDOWIZE", "LIMITRESOURCES", "STARTDEBUG", "SETCOMPATIBILITY", "WIREFRAME", }; @@ -59,7 +59,7 @@ static char *Flag3Names[32]={ "FORCEHOOKOPENGL", "MARKBLIT", "HOOKDLLS", "SUPPRESSD3DEXT", "HOOKENABLED", "FIXD3DFRAME", "FORCE16BPP", "BLACKWHITE", "SAVECAPS", "SINGLEPROCAFFINITY", "EMULATEREGISTRY", "CDROMDRIVETYPE", - "NOWINDOWMOVE", "DISABLEHAL", "LOCKSYSCOLORS", "EMULATEDC", + "NOWINDOWMOVE", "DISABLEHAL", "LOCKSYSCOLORS", "GDIEMULATEDC", "FULLSCREENONLY", "FONTBYPASS", "YUV2RGB", "RGB2YUV", "BUFFEREDIOFIX", "FILTERMESSAGES", "PEEKALLMESSAGES", "SURFACEWARN", "ANALYTICMODE", "FORCESHEL", "CAPMASK", "COLORFIX", @@ -70,7 +70,7 @@ static char *Flag4Names[32]={ "NOALPHACHANNEL", "SUPPRESSCHILD", "FIXREFCOUNTER", "SHOWTIMESTRETCH", "ZBUFFERCLEAN", "ZBUFFER0CLEAN", "ZBUFFERALWAYS", "DISABLEFOGGING", "NOPOWER2FIX", "NOPERFCOUNTER", "ADDPROXYLIBS", "INTERCEPTRDTSC", - "", "", "", "", + "LIMITSCREENRES", "NOFILLRECT", "", "", "", "", "", "", "", "", "", "", "", "", "", "", @@ -871,10 +871,12 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp extern LPRECT lpClipRegion; static BOOL DoOnce = TRUE; static BOOL IsToBeLocked; + static int LastTimeShift; if(DoOnce){ DoOnce=FALSE; IsToBeLocked=(dxw.dwFlags1 & LOCKWINPOS); + LastTimeShift=dxw.TimeShift; } // v2.1.93: adjust clipping region @@ -918,6 +920,9 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp } } + if(LastTimeShift != dxw.TimeShift) dxw.RenewTimers(); + LastTimeShift=dxw.TimeShift; + switch(message){ // v2.02.13: added WM_GETMINMAXINFO/WM_NCCALCSIZE interception - (see Actua Soccer 3 problems...) //case WM_NCDESTROY: @@ -1004,20 +1009,22 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp case WM_DISPLAYCHANGE: if ((dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen()){ OutTraceDW("WindowProc: prevent WM_DISPLAYCHANGE depth=%d size=(%d,%d)\n", - wparam, HIWORD(lparam), LOWORD(lparam)); + wparam, LOWORD(lparam), HIWORD(lparam)); // v2.02.43: unless EMULATESURFACE is set, lock the screen resolution only, but not the color depth! if(dxw.dwFlags1 & EMULATESURFACE) return 0; // let rparam (color depth) change, but override lparam (screen width & height.) - lparam = MAKELPARAM((LONG)dxw.GetScreenHeight(), (LONG)dxw.GetScreenWidth()); + lparam = MAKELPARAM((LONG)dxw.GetScreenWidth(), (LONG)dxw.GetScreenHeight()); //return 0; } break; case WM_WINDOWPOSCHANGING: case WM_WINDOWPOSCHANGED: - LPWINDOWPOS wp; - wp = (LPWINDOWPOS)lparam; - dxwFixWindowPos("WindowProc", hwnd, lparam); - OutTraceDW("WindowProc: WM_WINDOWPOSCHANGING fixed size=(%d,%d)\n", wp->cx, wp->cy); + if(dxw.IsFullScreen()){ + LPWINDOWPOS wp; + wp = (LPWINDOWPOS)lparam; + dxwFixWindowPos("WindowProc", hwnd, lparam); + OutTraceDW("WindowProc: WM_WINDOWPOSCHANGING fixed size=(%d,%d)\n", wp->cx, wp->cy); + } break; case WM_ENTERSIZEMOVE: if(IsToBeLocked){ @@ -1352,8 +1359,7 @@ LONG CALLBACK Int3Handler(PEXCEPTION_POINTERS ExceptionInfo) mov myPerfCount.HighPart, edx } #endif - myPerfCount.HighPart = dxw.StretchCounter(myPerfCount.HighPart); - myPerfCount.LowPart = dxw.StretchCounter(myPerfCount.LowPart); + myPerfCount = dxw.StretchCounter(myPerfCount); OutTraceDW("Int3Handler: INT3 at=%x tick=%x RDTSC=%x:%x\n", ExceptionInfo->ExceptionRecord->ExceptionAddress, (*pGetTickCount)(), myPerfCount.HighPart, myPerfCount.LowPart); @@ -1500,6 +1506,7 @@ static void ReplaceRDTSC() HMODULE psapilib; GetModuleInformation_Type pGetModuleInformation; DWORD dwSegSize; + DWORD oldprot; dwAttrib = GetFileAttributes("dxwnd.dll"); if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) return; @@ -1515,7 +1522,7 @@ static void ReplaceRDTSC() pPreparedisasm=(Preparedisasm_Type)(*pGetProcAddress)(disasmlib, "Preparedisasm"); pFinishdisasm=(Finishdisasm_Type)(*pGetProcAddress)(disasmlib, "Finishdisasm"); pDisasm=(Disasm_Type)(*pGetProcAddress)(disasmlib, "Disasm"); - OutTraceDW("DXWND: Load disasm.dll ptrs=%x,%x,%x,%x\n", pGeterrwarnmessage, pPreparedisasm, pFinishdisasm, pDisasm); + //OutTraceDW("DXWND: Load disasm.dll ptrs=%x,%x,%x,%x\n", pGeterrwarnmessage, pPreparedisasm, pFinishdisasm, pDisasm); // getting segment size psapilib=(*pLoadLibraryA)("psapi.dll"); @@ -1546,7 +1553,6 @@ static void ReplaceRDTSC() if (cmdlen==0) break; // search for RDTSC opcode 0x0F31 if((*(opcodes+offset) == 0x0F) && (*(opcodes+offset+1) == 0x31)){ - DWORD oldprot; OutTraceDW("DXWND: RDTSC opcode found at addr=%x\n", (opcodes+offset)); if(!VirtualProtect((LPVOID)(opcodes+offset), 4, PAGE_READWRITE, &oldprot)) { OutTrace("VirtualProtect ERROR: target=%x err=%d at %d\n", opcodes+offset, GetLastError(), __LINE__); @@ -1559,6 +1565,21 @@ static void ReplaceRDTSC() return; // error condition } } + // search for RDTSCP opcode 0x0F01F9 + if((*(opcodes+offset) == 0x0F) && (*(opcodes+offset+1) == 0x01) && (*(opcodes+offset+2) == 0xF9)){ + OutTraceDW("DXWND: RDTSC opcode found at addr=%x\n", (opcodes+offset)); + if(!VirtualProtect((LPVOID)(opcodes+offset), 4, PAGE_READWRITE, &oldprot)) { + OutTrace("VirtualProtect ERROR: target=%x err=%d at %d\n", opcodes+offset, GetLastError(), __LINE__); + return; // error condition + } + *(opcodes+offset) = 0xCC; // __asm INT3 + *(opcodes+offset+1) = 0x90; // __asm NOP + *(opcodes+offset+2) = 0x90; // __asm NOP + if(!VirtualProtect((LPVOID)(opcodes+offset), 4, oldprot, &oldprot)){ + OutTrace("VirtualProtect ERROR; target=%x, err=%d at %d\n", opcodes+offset, GetLastError(), __LINE__); + return; // error condition + } + } offset+=cmdlen; if((offset+0x10) > dwSegSize) break; } @@ -1577,7 +1598,10 @@ void HookInit(TARGETMAP *target, HWND hwnd) "Automatic", "DirectX1~6", "", "", "", "", "", "DirectX7", "DirectX8", "DirectX9", "DirectX10", "DirectX11", "None", "" }; - + static char *Resolutions[]={ + "unlimited", "320x200", "640x480", "800x600", "1024x768", "1280x960", "" // terminator + }; + dxw.InitTarget(target); if(hwnd){ // v2/02.32: skip this when in code injection mode. @@ -1593,8 +1617,10 @@ void HookInit(TARGETMAP *target, HWND hwnd) OutTrace("HookInit: path=\"%s\" module=\"%s\" dxversion=%s pos=(%d,%d) size=(%d,%d)", target->path, target->module, dxversions[dxw.dwTargetDDVersion], target->posx, target->posy, target->sizx, target->sizy); - if(hwnd) OutTrace(" hWnd=%x dxw.hParentWnd=%x desktop=%x\n", hwnd, dxw.hParentWnd, GetDesktopWindow()); + if(hwnd) OutTrace(" hWnd=%x(hdc=%x) dxw.hParentWnd=%x(hdc=%x) desktop=%x(hdc=%x)\n", + hwnd, GetDC(hwnd), dxw.hParentWnd, GetDC(dxw.hParentWnd), GetDesktopWindow(), GetDC(GetDesktopWindow())); else OutTrace("\n"); + if (dxw.dwFlags4 & LIMITSCREENRES) OutTrace("HookInit: max resolution=%s\n", (dxw.MaxScreenRes<6)?Resolutions[dxw.MaxScreenRes]:"unknown"); } if (hwnd && IsDebug){ @@ -1605,6 +1631,7 @@ void HookInit(TARGETMAP *target, HWND hwnd) dwStyle=GetWindowLong(dxw.hParentWnd, GWL_STYLE); dwExStyle=GetWindowLong(dxw.hParentWnd, GWL_EXSTYLE); OutTrace("HookInit: dxw.hParentWnd style=%x(%s) exstyle=%x(%s)\n", dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle)); + OutTrace("HookInit: target window pos=(%d,%d) size=(%d,%d)\n", dxw.iPosX, dxw.iPosY, dxw.iSizX, dxw.iSizY); } HookSysLibsInit(); // this just once... @@ -1662,7 +1689,20 @@ void HookInit(TARGETMAP *target, HWND hwnd) InitScreenParameters(); if(hwnd) HookWindowProc(hwnd); - if (IsDebug) OutTraceDW("MoveWindow: target pos=(%d,%d) size=(%d,%d)\n", dxw.iPosX, dxw.iPosY, dxw.iSizX, dxw.iSizY); //v2.02.09 + // initialize window: if + // 1) not in injection mode (hwnd != 0) and + // 2) supposedly in fullscreen mode (dxw.IsFullScreen()) and + // 3) configuration ask for a overlapped bordered window (dxw.dwFlags1 & FIXWINFRAME) then + // update window styles: just this window or, when FIXPARENTWIN is set, the father one as well. + + if (hwnd && dxw.IsFullScreen() && (dxw.dwFlags1 & FIXWINFRAME)) { + dxw.FixWindowFrame(dxw.hChildWnd); + AdjustWindowPos(dxw.hChildWnd, target->sizx, target->sizy); + if(dxw.dwFlags1 & FIXPARENTWIN) { + dxw.FixWindowFrame(dxw.hParentWnd); + AdjustWindowPos(dxw.hParentWnd, target->sizx, target->sizy); + } + } } LPCSTR ProcToString(LPCSTR proc) diff --git a/dll/dxkernel32.cpp b/dll/dxkernel32.cpp deleted file mode 100644 index 01904f3..0000000 --- a/dll/dxkernel32.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include "dxwnd.h" -#include "dxwcore.hpp" -#include "syslibs.h" -#include "dxhook.h" - -static HookEntry_Type Hooks[]={ - {"IsDebuggerPresent", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extIsDebuggerPresent}, - {"GlobalMemoryStatus", (FARPROC)GlobalMemoryStatus, (FARPROC *)&pGlobalMemoryStatus, (FARPROC)extGlobalMemoryStatus}, - {"GetProcAddress", (FARPROC)GetProcAddress, (FARPROC *)&pGetProcAddress, (FARPROC)extGetProcAddress}, - {"LoadLibraryA", (FARPROC)LoadLibraryA, (FARPROC *)&pLoadLibraryA, (FARPROC)extLoadLibraryA}, - {"LoadLibraryExA", (FARPROC)LoadLibraryExA, (FARPROC *)&pLoadLibraryExA, (FARPROC)extLoadLibraryExA}, - {"LoadLibraryW", (FARPROC)LoadLibraryW, (FARPROC *)&pLoadLibraryW, (FARPROC)extLoadLibraryW}, - {"LoadLibraryExW", (FARPROC)LoadLibraryExW, (FARPROC *)&pLoadLibraryExW, (FARPROC)extLoadLibraryExW}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type LimitHooks[]={ - {"GetDiskFreeSpaceA", (FARPROC)GetDiskFreeSpaceA, (FARPROC *)&pGetDiskFreeSpaceA, (FARPROC)extGetDiskFreeSpaceA}, - {"GlobalMemoryStatus", (FARPROC)GlobalMemoryStatus, (FARPROC *)&pGlobalMemoryStatus, (FARPROC)extGlobalMemoryStatus}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type TimeHooks[]={ - {"GetTickCount", (FARPROC)GetTickCount, (FARPROC *)&pGetTickCount, (FARPROC)extGetTickCount}, - {"GetLocalTime", (FARPROC)GetLocalTime, (FARPROC *)&pGetLocalTime, (FARPROC)extGetLocalTime}, - {"GetSystemTime", (FARPROC)GetSystemTime, (FARPROC *)&pGetSystemTime, (FARPROC)extGetSystemTime}, - {"GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime}, - {"Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep}, - {"SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx}, - {"SetTimer", (FARPROC)SetTimer, (FARPROC *)&pSetTimer, (FARPROC)extSetTimer}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type VersionHooks[]={ - {"GetVersion", (FARPROC)GetVersion, (FARPROC *)&pGetVersion, (FARPROC)extGetVersion}, - {"GetVersionEx", (FARPROC)GetVersionEx, (FARPROC *)&pGetVersionEx, (FARPROC)extGetVersionEx}, - {0, NULL, 0, 0} // terminator -}; - -void HookKernel32(HMODULE module) -{ - HookLibrary(module, Hooks, "kernel32.dll"); - - if(dxw.dwFlags2 & LIMITRESOURCES) HookLibrary(module, LimitHooks, "kernel32.dll"); - - if(dxw.dwFlags2 & LIMITRESOURCES) HookLibrary(module, TimeHooks, "kernel32.dll"); - - if(dxw.dwFlags2 & FAKEVERSION) HookLibrary(module, VersionHooks, "kernel32.dll"); -} - -FARPROC Remap_kernel32_ProcAddress(LPCSTR proc, HMODULE hModule) -{ - FARPROC addr; - - if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; - - if(dxw.dwFlags2 & LIMITRESOURCES) - if (addr=RemapLibrary(proc, hModule, LimitHooks)) return addr; - - if(dxw.dwFlags2 & TIMESTRETCH) - if (addr=RemapLibrary(proc, hModule, TimeHooks)) return addr; - - if(dxw.dwFlags2 & FAKEVERSION) - if (addr=RemapLibrary(proc, hModule, VersionHooks)) return addr; - - return NULL; -} - - -int WINAPI extIsDebuggerPresent(void) -{ - OutTraceD("extIsDebuggerPresent: return FALSE\n"); - return FALSE; -} - -BOOL WINAPI extGetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters) -{ - BOOL ret; - OutTraceD("GetDiskFreeSpace: RootPathName=\"%s\"\n", lpRootPathName); - ret=(*pGetDiskFreeSpaceA)(lpRootPathName, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters); - if(!ret) OutTraceE("GetDiskFreeSpace: ERROR err=%d at %d\n", GetLastError(), __LINE__); - *lpNumberOfFreeClusters = 16000; - return ret; -} - -/* ------------------------------------------------------------------------------- - -GlobalMemoryStatus: MSDN documents that on modern PCs that have more than DWORD -memory values the GlobalMemoryStatus sets the fields to -1 (0xFFFFFFFF) and you -should use GlobalMemoryStatusEx instead. -But in some cases the value is less that DWORD max, but greater that DWORD>>1, that -is the calling application may get a big value and see it as a signed negative -value, as it happened to Nocturne on my PC. That's why it's not adviseable to write: -if(lpBuffer->dwTotalPhys== -1) ... -but this way: -if ((int)lpBuffer->dwTotalPhys < 0) ... -and also don't set -BIGENOUGH 0x80000000 // possibly negative!!! -but: -BIGENOUGH 0x20000000 // surely positive !!! - -/* ---------------------------------------------------------------------------- */ -#define BIGENOUGH 0x20000000 - -void WINAPI extGlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) -{ - (*pGlobalMemoryStatus)(lpBuffer); - OutTraceD("GlobalMemoryStatus: Length=%x MemoryLoad=%x " - "TotalPhys=%x AvailPhys=%x TotalPageFile=%x AvailPageFile=%x TotalVirtual=%x AvailVirtual=%x\n", - lpBuffer->dwMemoryLoad, lpBuffer->dwTotalPhys, lpBuffer->dwAvailPhys, - lpBuffer->dwTotalPageFile, lpBuffer->dwAvailPageFile, lpBuffer->dwTotalVirtual, lpBuffer->dwAvailVirtual); - if(lpBuffer->dwLength==sizeof(MEMORYSTATUS)){ - if ((int)lpBuffer->dwTotalPhys < 0) lpBuffer->dwTotalPhys = BIGENOUGH; - if ((int)lpBuffer->dwAvailPhys < 0) lpBuffer->dwAvailPhys = BIGENOUGH; - if ((int)lpBuffer->dwTotalPageFile < 0) lpBuffer->dwTotalPageFile = BIGENOUGH; - if ((int)lpBuffer->dwAvailPageFile < 0) lpBuffer->dwAvailPageFile = BIGENOUGH; - if ((int)lpBuffer->dwTotalVirtual < 0) lpBuffer->dwTotalVirtual = BIGENOUGH; - if ((int)lpBuffer->dwAvailVirtual < 0) lpBuffer->dwAvailVirtual = BIGENOUGH; - } -} - -/* -From MSDN: -Operating system Version number dwMajorVersion dwMinorVersion Other -Windows 8 6.2 6 2 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION -Windows Server 2012 6.2 6 2 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION -Windows 7 6.1 6 1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION -Windows Server 2008 R2 6.1 6 1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION -Windows Server 2008 6.0 6 0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION -Windows Vista 6.0 6 0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION -Windows Server 2003 R2 5.2 5 2 GetSystemMetrics(SM_SERVERR2) != 0 -Windows Home Server 5.2 5 2 OSVERSIONINFOEX.wSuiteMask & VER_SUITE_WH_SERVER -Windows Server 2003 5.2 5 2 GetSystemMetrics(SM_SERVERR2) == 0 -Windows XP Pro x64 Ed. 5.2 5 2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) -Windows XP 5.1 5 1 Not applicable -Windows 2000 5.0 5 0 Not applicable -From http://delphi.about.com/cs/adptips2000/a/bltip1100_2.htm -Windows 95 4.0 4 0 -Windows 98/SE" 4.10 4 10 if osVerInfo.szCSDVersion[1] = 'A' then Windows98SE -Windows ME 4.90 4 90 -*/ - -static struct {char bMajor; char bMinor; char *sName;} WinVersions[9]= -{ - {4, 0, "Windows 95"}, - {4,10, "Windows 98/SE"}, - {4,90, "Windows ME"}, - {5, 0, "Windows 2000"}, - {5, 1, "Windows XP"}, - {5, 2, "Windows Server 2003"}, - {6, 0, "Windows Vista"}, - {6, 1, "Windows 7"}, - {6, 2, "Windows 8"} -}; - -BOOL WINAPI extGetVersionEx(LPOSVERSIONINFO lpVersionInfo) -{ - BOOL ret; - - ret=(*pGetVersionEx)(lpVersionInfo); - if(!ret) { - OutTraceE("GetVersionEx: ERROR err=%d\n", GetLastError()); - return ret; - } - - OutTraceD("GetVersionEx: version=%d.%d build=(%d)\n", - lpVersionInfo->dwMajorVersion, lpVersionInfo->dwMinorVersion, lpVersionInfo->dwBuildNumber); - - if(dxw.dwFlags2 & FAKEVERSION) { - // fake Win XP build 0 - lpVersionInfo->dwMajorVersion = WinVersions[dxw.FakeVersionId].bMajor; - lpVersionInfo->dwMinorVersion = WinVersions[dxw.FakeVersionId].bMinor; - lpVersionInfo->dwBuildNumber = 0; - OutTraceD("GetVersionEx: FIXED version=%d.%d build=(%d) os=\"%s\"\n", - lpVersionInfo->dwMajorVersion, lpVersionInfo->dwMinorVersion, lpVersionInfo->dwBuildNumber, - WinVersions[dxw.FakeVersionId].sName); - } - return TRUE; -} - -DWORD WINAPI extGetVersion(void) -{ - DWORD dwVersion; - DWORD dwMajorVersion; - DWORD dwMinorVersion; - DWORD dwBuild = 0; - - dwVersion = (*pGetVersion)(); - - // Get the Windows version. - - dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); - dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); - - // Get the build number. - - if (dwVersion < 0x80000000) - dwBuild = (DWORD)(HIWORD(dwVersion)); - - OutTraceD("GetVersion: version=%d.%d build=(%d)\n", dwMajorVersion, dwMinorVersion, dwBuild); - - if(dxw.dwFlags2 & FAKEVERSION) { - dwVersion = WinVersions[dxw.FakeVersionId].bMajor | (WinVersions[dxw.FakeVersionId].bMinor << 8); - dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); - dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); - dwBuild = (DWORD)(HIWORD(dwVersion)); - OutTraceD("GetVersion: FIXED version=%d.%d build=(%d) os=\"%s\"\n", - dwMajorVersion, dwMinorVersion, dwBuild, WinVersions[dxw.FakeVersionId].sName); - } - - return dwVersion; -} - -/* ------------------------------------------------------------------------------- - -time related APIs - -/* ---------------------------------------------------------------------------- */ - -DWORD WINAPI extGetTickCount(void) -{ - return dxw.GetTickCount(); -} - -void WINAPI extGetSystemTime(LPSYSTEMTIME lpSystemTime) -{ - dxw.GetSystemTime(lpSystemTime); - if (IsDebug) OutTrace("GetSystemTime: %02d:%02d:%02d.%03d\n", - lpSystemTime->wHour, lpSystemTime->wMinute, lpSystemTime->wSecond, lpSystemTime->wMilliseconds); -} - -void WINAPI extGetLocalTime(LPSYSTEMTIME lpLocalTime) -{ - SYSTEMTIME SystemTime; - dxw.GetSystemTime(&SystemTime); - SystemTimeToTzSpecificLocalTime(NULL, &SystemTime, lpLocalTime); - if (IsDebug) OutTrace("GetLocalTime: %02d:%02d:%02d.%03d\n", - lpLocalTime->wHour, lpLocalTime->wMinute, lpLocalTime->wSecond, lpLocalTime->wMilliseconds); -} - -UINT_PTR WINAPI extSetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc) -{ - UINT uShiftedElapse; - // beware: the quicker the time flows, the more the time clicks are incremented, - // and the lesser the pauses must be lasting! Shift operations are reverted in - // GetSystemTime vs. Sleep or SetTimer - uShiftedElapse = dxw.StretchTime(uElapse); - if (IsDebug) OutTrace("SetTimer: elapse=%d->%d timeshift=%d\n", uElapse, uShiftedElapse, dxw.TimeShift); - return (*pSetTimer)(hWnd, nIDEvent, uShiftedElapse, lpTimerFunc); -} - -VOID WINAPI extSleep(DWORD dwMilliseconds) -{ - DWORD dwNewDelay; - dwNewDelay=dwMilliseconds; - if (dwMilliseconds!=INFINITE && dwMilliseconds!=0){ - dwNewDelay = dxw.StretchTime(dwMilliseconds); - if (dwNewDelay==0){ // oh oh! troubles... - if (dxw.TimeShift > 0) dwNewDelay=1; // minimum allowed... - else dwNewDelay = INFINITE-1; // maximum allowed !!! - } - } - if (IsDebug) OutTrace("Sleep: msec=%d->%d timeshift=%d\n", dwMilliseconds, dwNewDelay, dxw.TimeShift); - (*pSleep)(dwNewDelay); -} - -DWORD WINAPI extSleepEx(DWORD dwMilliseconds, BOOL bAlertable) -{ - DWORD dwNewDelay; - dwNewDelay=dwMilliseconds; - if (dwMilliseconds!=INFINITE && dwMilliseconds!=0){ - dwNewDelay = dxw.StretchTime(dwMilliseconds); - if (dwNewDelay==0){ // oh oh! troubles... - if (dxw.TimeShift > 0) dwNewDelay=1; // minimum allowed... - else dwNewDelay = INFINITE-1; // maximum allowed !!! - } - } - if (IsDebug) OutTrace("SleepEx: msec=%d->%d alertable=%x, timeshift=%d\n", dwMilliseconds, dwNewDelay, bAlertable, dxw.TimeShift); - return (*pSleepEx)(dwNewDelay, bAlertable); -} - -void WINAPI extGetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) -{ - if (IsDebug) OutTrace("GetSystemTimeAsFileTime\n"); - dxw.GetSystemTimeAsFileTime(lpSystemTimeAsFileTime); -} \ No newline at end of file diff --git a/dll/dxole32.cpp b/dll/dxole32.cpp deleted file mode 100644 index edc6796..0000000 --- a/dll/dxole32.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include -#include "dxwnd.h" -#include "dxwcore.hpp" -#include "syslibs.h" -#include "dxhook.h" -#include "dxhelper.h" - -static HookEntry_Type Hooks[]={ - {"CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance}, - // {"CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx}, remote object creation.... - {0, NULL, 0, 0} // terminator -}; - -extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *); -extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *); - -void HookOle32(HMODULE module) -{ - HookLibrary(module, Hooks, "ole32.dll"); -} - -FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule) -{ - FARPROC addr; - if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; - return NULL; -} - -// ------------------------------------------------------------------------------------- -// Ole32 CoCreateInstance handling: you can create DirectDraw objects through it! -// utilized so far in a single game: Axiz & Allies -// ------------------------------------------------------------------------------------- - -static void HookDDSession(LPDIRECTDRAW *, int); - -HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv) -{ - HRESULT res; - OutTraceD("CoCreateInstance: rclsid=%x UnkOuter=%x ClsContext=%x refiid=%x\n", - rclsid, pUnkOuter, dwClsContext, riid); - - // CLSID e436ebb3 implies loading quartz.dll to play movies through dshow: - // quartz.dll must be hooked. - if (*(DWORD *)&rclsid==0xe436ebb3){ - HMODULE qlib; - OutTraceD("CoCreateInstance: CLSID_FilterGraph RIID=%x\n", *(DWORD *)&riid); - qlib=(*pLoadLibraryA)("quartz.dll"); - OutTraceD("CoCreateInstance: quartz lib handle=%x\n", qlib); - HookKernel32(qlib); - HookUser32(qlib); - HookWinMM(qlib); - } - - res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv); - if(res) - OutTraceE("CoCreateInstance: ERROR res=%x\n", res); - else - OutTraceD("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv); - - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ - LPDIRECTDRAW lpOldDDraw; - OutTraceD("CoCreateInstance: CLSID_DirectDraw object\n"); - switch (*(DWORD *)&riid){ - case 0x6C14DB80: - OutTraceD("DirectDrawCreate: IID_DirectDraw RIID\n"); - res=extDirectDrawCreate(NULL, (LPDIRECTDRAW *)&ppv, 0); - if(res)OutTraceD("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); - break; - case 0xB3A6F3E0: - OutTraceD("DirectDrawCreate: IID_DirectDraw2 RIID\n"); - res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); - if(res)OutTraceD("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); - res=lpOldDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)&ppv); - if(res)OutTraceD("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); - lpOldDDraw->Release(); - break; - case 0x9c59509a: - OutTraceD("DirectDrawCreate: IID_DirectDraw4 RIID\n"); - res=extDirectDrawCreate(NULL, &lpOldDDraw, 0); - if(res)OutTraceD("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res)); - res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&ppv); - if(res)OutTraceD("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res)); - lpOldDDraw->Release(); - case 0x15e65ec0: - OutTraceD("CoCreateInstance: IID_DirectDraw7 RIID\n"); - res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)&ppv, IID_IDirectDraw7, 0); - if(res)OutTraceD("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res)); - break; - case 0xe436ebb3: - break; - } - } - else - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); - - return res; -} diff --git a/dll/dxuser32.cpp b/dll/dxuser32.cpp deleted file mode 100644 index 6bb89df..0000000 --- a/dll/dxuser32.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "dxwnd.h" -#include "dxwcore.hpp" -#include "syslibs.h" -#include "dxhook.h" - -static HookEntry_Type Hooks[]={ - {"ChangeDisplaySettingsA", NULL, (FARPROC *)&pChangeDisplaySettings, (FARPROC)extChangeDisplaySettings}, - {"ChangeDisplaySettingsExA", NULL, (FARPROC *)&pChangeDisplaySettingsEx, (FARPROC)extChangeDisplaySettingsEx}, - {"BeginPaint", NULL, (FARPROC *)&pBeginPaint, (FARPROC)&extBeginPaint}, - {"EndPaint", NULL, (FARPROC *)&pEndPaint, (FARPROC)extEndPaint}, - {"ShowCursor", NULL, (FARPROC *)&pShowCursor, (FARPROC)extShowCursor}, - {"CreateDialogIndirectParamA", NULL, (FARPROC *)&pCreateDialogIndirectParam, (FARPROC)extCreateDialogIndirectParam}, - {"CreateDialogParamA", NULL, (FARPROC *)&pCreateDialogParam, (FARPROC)extCreateDialogParam}, - {"MoveWindow", NULL, (FARPROC *)&pMoveWindow, (FARPROC)extMoveWindow}, - {"ChangeDisplaySettingsA", NULL, (FARPROC *)&pChangeDisplaySettings, (FARPROC)extChangeDisplaySettings}, - {"ChangeDisplaySettingsExA", NULL, (FARPROC *)&pChangeDisplaySettingsEx, (FARPROC)extChangeDisplaySettingsEx}, - {"EnumDisplaySettingsA", NULL, (FARPROC *)&pEnumDisplaySettings, (FARPROC)extEnumDisplaySettings}, - {"GetClipCursor", NULL, (FARPROC *)&pGetClipCursor, (FARPROC)extGetClipCursor}, - {"ClipCursor", NULL, (FARPROC *)&pClipCursor, (FARPROC)extClipCursor}, - {"FillRect", NULL, (FARPROC *)&pFillRect, (FARPROC)extFillRect}, - {"DefWindowProcA", NULL, (FARPROC *)&pDefWindowProc, (FARPROC)extDefWindowProc}, - {"CreateWindowExA", NULL, (FARPROC *)&pCreateWindowExA, (FARPROC)extCreateWindowExA}, - {"RegisterClassExA", NULL, (FARPROC *)&pRegisterClassExA, (FARPROC)extRegisterClassExA}, - {"GetSystemMetrics", NULL, (FARPROC *)&pGetSystemMetrics, (FARPROC)extGetSystemMetrics}, - {"GetDesktopWindow", NULL, (FARPROC *)&pGetDesktopWindow, (FARPROC)extGetDesktopWindow}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type DDHooks[]={ - {"GetDC", NULL, (FARPROC *)&pGDIGetDC, (FARPROC)extDDGetDC}, - {"GetWindowDC", NULL, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extDDGetDC}, - {"ReleaseDC", NULL, (FARPROC *)&pGDIReleaseDC, (FARPROC)extDDReleaseDC}, - {"InvalidateRect", NULL, (FARPROC *)&pInvalidateRect, (FARPROC)extDDInvalidateRect}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type GDIHooks[]={ - {"GetDC", NULL, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC}, - {"GetWindowDC", NULL, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetDC}, - {"ReleaseDC", NULL, (FARPROC *)&pGDIReleaseDC, (FARPROC)extGDIReleaseDC}, - {"InvalidateRect", NULL, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type RemapHooks[]={ - {"ScreenToClient", NULL, (FARPROC *)&pScreenToClient, (FARPROC)extScreenToClient}, - {"ClientToScreen", NULL, (FARPROC *)&pClientToScreen, (FARPROC)extClientToScreen}, - {"GetClientRect", NULL, (FARPROC *)&pGetClientRect, (FARPROC)extGetClientRect}, - {"GetWindowRect", NULL, (FARPROC *)&pGetWindowRect, (FARPROC)extGetWindowRect}, - {"MapWindowPoints", NULL, (FARPROC *)&pMapWindowPoints, (FARPROC)extMapWindowPoints}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type MessageHooks[]={ - {"PeekMessageA", NULL, (FARPROC *)&pPeekMessage, (FARPROC)extPeekMessage}, - {"GetMessageA", NULL, (FARPROC *)&pGetMessage, (FARPROC)extGetMessage}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type MouseHooks[]={ - {"GetCursorPos", NULL, (FARPROC *)&pGetCursorPos, (FARPROC)extGetCursorPos}, - {"SetCursor", NULL, (FARPROC *)&pSetCursor, (FARPROC)extSetCursor}, - {"SendMessageA", NULL, (FARPROC *)&pSendMessage, (FARPROC)extSendMessage}, // ??? - //{"SetPhysicalCursorPos", NULL, (FARPROC *)&pSetCursor, (FARPROC)extSetCursor}, // ??? - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type WinHooks[]={ - {"ShowWindow", NULL, (FARPROC *)&pShowWindow, (FARPROC)extShowWindow}, - {"SetWindowLongA", (FARPROC)SetWindowLongA, (FARPROC *)&pSetWindowLong, (FARPROC)extSetWindowLong}, - {"GetWindowLongA", (FARPROC)GetWindowLongA, (FARPROC *)&pGetWindowLong, (FARPROC)extGetWindowLong}, - {"SetWindowPos", (FARPROC)SetWindowPos, (FARPROC *)&pSetWindowPos, (FARPROC)extSetWindowPos}, - {"DeferWindowPos", (FARPROC)DeferWindowPos, (FARPROC *)&pGDIDeferWindowPos, (FARPROC)extDeferWindowPos}, - {"CallWindowProcA", (FARPROC)CallWindowProcA, (FARPROC *)&pCallWindowProc, (FARPROC)extCallWindowProc}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type MouseHooks2[]={ - {"SetCursorPos", (FARPROC)SetCursorPos, (FARPROC *)&pSetCursorPos, (FARPROC)extSetCursorPos}, - {0, NULL, 0, 0} // terminator -}; - -FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule) -{ - FARPROC addr; - if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; - - if (addr=RemapLibrary(proc, hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks)) return addr; - - if (dxw.dwFlags1 & CLIENTREMAPPING) - if (addr=RemapLibrary(proc, hModule, RemapHooks)) return addr; - - if (dxw.dwFlags1 & MESSAGEPROC) - if (addr=RemapLibrary(proc, hModule, MessageHooks)) return addr; - - if(dxw.dwFlags1 & MODIFYMOUSE) - if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr; - - if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)) - if (addr=RemapLibrary(proc, hModule, WinHooks)) return addr; - - if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) - if (addr=RemapLibrary(proc, hModule, MouseHooks2)) return addr; - - return NULL; -} - -void HookUser32(HMODULE hModule) -{ - HookLibrary(hModule, Hooks, "user32.dll"); - - HookLibrary(hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks, "user32.dll"); - if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, "user32.dll"); - if (dxw.dwFlags1 & MESSAGEPROC) HookLibrary(hModule, MessageHooks, "user32.dll"); - if(dxw.dwFlags1 & MODIFYMOUSE)HookLibrary(hModule, MouseHooks, "user32.dll"); - if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))HookLibrary(hModule, WinHooks, "user32.dll"); - if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) HookLibrary(hModule, MouseHooks2, "user32.dll"); - return; -} diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index f730c5a..feb3377 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -24,11 +24,10 @@ dxwCore::dxwCore() bDInputAbs = 0; TimeShift = 0; lpDDSPrimHDC = NULL; - //IsWithinDDraw = FALSE; - //IsGDIPalette = FALSE; memset(PrimSurfaces, 0, sizeof(PrimSurfaces)); ResetEmulatedDC(); MustShowOverlay=FALSE; + TimerEvent.uTimerId = 0; } dxwCore::~dxwCore() @@ -73,10 +72,29 @@ void dxwCore::InitTarget(TARGETMAP *target) if(TimeShift < -8) TimeShift = -8; if(TimeShift > 8) TimeShift = 8; FakeVersionId = target->FakeVersionId; + MaxScreenRes = target->MaxScreenRes; Coordinates = target->coordinates; MustShowOverlay=((dwFlags2 & SHOWFPSOVERLAY) || (dwFlags4 & SHOWTIMESTRETCH)); } +void dxwCore::SetScreenSize(void) +{ + SetScreenSize(800, 600); // set to default screen resolution +} + +void dxwCore::SetScreenSize(int x, int y) +{ + DXWNDSTATUS *p; + OutTraceDW("DXWND: set screen size=(%d,%d)\n", x, y); + if(x) dwScreenWidth=x; + if(y) dwScreenHeight=y; + p = GetHookInfo(); + if(p) { + p->Width = (short)dwScreenWidth; + p->Height = (short)dwScreenHeight; + } +} + /* ------------------------------------------------------------------ */ // Primary surfaces auxiliary functions /* ------------------------------------------------------------------ */ @@ -389,16 +407,16 @@ void dxwCore::EraseClipCursor() void dxwCore::SethWnd(HWND hwnd) { RECT WinRect; - if (pGetWindowRect){ - (*pGetWindowRect)(hwnd, &WinRect); - OutTraceDW("SethWnd: setting main win=%x pos=(%d,%d)-(%d,%d)\n", - hwnd, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom); - } - else { - OutTraceDW("SethWnd: setting main win=%x\n", hwnd); - } + if(!pGetWindowRect) pGetWindowRect=::GetWindowRect; + if(!pGDIGetDC) pGDIGetDC=::GetDC; + hWnd=hwnd; - hWndFPS=hwnd; + hWndFPS=hwnd; + RealHDC=(*pGDIGetDC)(hwnd); + + (*pGetWindowRect)(hwnd, &WinRect); + OutTraceDW("SethWnd: setting main win=%x hdc=%x pos=(%d,%d)-(%d,%d)\n", + hwnd, RealHDC, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom); } void dxwCore::FixWorkarea(LPRECT workarea) @@ -827,6 +845,24 @@ static DWORD TimeShifter(DWORD val, int shift) return val; } +static LARGE_INTEGER TimeShifter64(LARGE_INTEGER val, int shift) +{ + int exp, reminder; + if (shift > 0) { + exp = shift >> 1; + reminder = shift & 0x1; + if (reminder) val.QuadPart -= (val.QuadPart >> 2); // val * (1-1/4) = val * 3/4 + val.QuadPart >>= exp; // val * 2^exp + } + if (shift < 0) { + exp = (-shift) >> 1; + reminder = (-shift) & 0x1; + val.QuadPart <<= exp; // val / 2^exp + if (reminder) val.QuadPart += (val.QuadPart >> 1); // val * (1+1/2) = val * 3/2 + } + return val; +} + DWORD dxwCore::GetTickCount(void) { DWORD dwTick; @@ -857,6 +893,13 @@ DWORD dxwCore::StretchCounter(DWORD dwTimer) return dwTimer; } +LARGE_INTEGER dxwCore::StretchCounter(LARGE_INTEGER dwTimer) +{ + TimeShift=GetHookInfo()->TimeShift; + dwTimer = TimeShifter64(dwTimer, TimeShift); + return dwTimer; +} + void dxwCore::GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { DWORD dwTick; @@ -1169,6 +1212,36 @@ int dxwCore::GetDLLIndex(char *lpFileName) return idx; } +void dxwCore::FixWindowFrame(HWND hwnd) +{ + LONG nOldStyle; + + OutTraceDW("FixWindowFrame: hwnd=%x\n", hwnd); + + nOldStyle=(*pGetWindowLong)(hwnd, GWL_STYLE); + if (!nOldStyle){ + OutTraceE("FixWindowFrame: GetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); + return; + } + + OutTraceDW("FixWindowFrame: style=%x(%s)\n",nOldStyle,ExplainStyle(nOldStyle)); + + // fix style + if (!(*pSetWindowLong)(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW)){ + OutTraceE("FixWindowFrame: SetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); + return; + } + // fix exstyle + if (!(*pSetWindowLong)(hwnd, GWL_EXSTYLE, 0)){ + OutTraceE("FixWindowFrame: SetWindowLong ERROR %d at %d\n",GetLastError(),__LINE__); + return; + } + + // ShowWindow retcode means in no way an error code! Better ignore it. + (*pShowWindow)(hwnd, SW_RESTORE); + return; +} + void dxwCore::FixStyle(char *ApiName, HWND hwnd, WPARAM wParam, LPARAM lParam) { LPSTYLESTRUCT lpSS; @@ -1222,6 +1295,7 @@ HDC dxwCore::AcquireEmulatedDC(HWND hwnd) HDC dxwCore::AcquireEmulatedDC(HDC wdc) { + RealHDC=wdc; //HDC wdc; //if(!(wdc=(*pGDIGetDC)(hwnd))) //OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__); @@ -1254,7 +1328,7 @@ BOOL dxwCore::ReleaseEmulatedDC(HWND hwnd) OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__); if(!(*pGDIStretchBlt)(wdc, 0, 0, client.right, client.bottom, VirtualHDC, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), SRCCOPY)) OutTraceE("StretchBlt: ERROR err=%d at=%d\n", GetLastError(), __LINE__); - (*pInvalidateRect)(hwnd, NULL, 0); + //(*pInvalidateRect)(hwnd, NULL, 0); ret=TRUE; return ret; } @@ -1269,5 +1343,46 @@ void dxwCore::ResetEmulatedDC() BOOL dxwCore::IsVirtual(HDC hdc) { - return (hdc==VirtualHDC) && (dwFlags3 & EMULATEDC); + return (hdc==VirtualHDC) && (dwFlags3 & GDIEMULATEDC); +} + +void dxwCore::PushTimer(UINT uTimerId, UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent) +{ + // save current timer + TimerEvent.uTimerId = uTimerId; + TimerEvent.uDelay = uDelay; + TimerEvent.uResolution = uResolution; + TimerEvent.lpTimeProc = lpTimeProc; + TimerEvent.dwUser = dwUser; + TimerEvent.fuEvent = fuEvent; +} + +void dxwCore::PopTimer(UINT uTimerId) +{ + // clear current timer + if(uTimerId != TimerEvent.uTimerId){ + // this should never happen, unless there are more than 1 timer! + char msg[256]; + sprintf(msg,"PopTimer: TimerId=%x last=%x\n", uTimerId, TimerEvent.uTimerId); + MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION); + return; + } + TimerEvent.uTimerId = 0; + TimerEvent.uDelay = 0; + TimerEvent.uResolution = 0; + TimerEvent.lpTimeProc = NULL; + TimerEvent.dwUser = 0; + TimerEvent.fuEvent = 0; +} + +void dxwCore::RenewTimers() +{ + if(ptimeKillEvent && ptimeSetEvent && TimerEvent.uTimerId){ + UINT NewDelay; + MMRESULT res; + (*ptimeKillEvent)(TimerEvent.uTimerId); + NewDelay = dxw.StretchTime(TimerEvent.uDelay); + res=(*ptimeSetEvent)(NewDelay, TimerEvent.uResolution, TimerEvent.lpTimeProc, TimerEvent.dwUser, TimerEvent.fuEvent); + TimerEvent.uTimerId = res; + } } diff --git a/dll/dxwcore.hpp b/dll/dxwcore.hpp index eb25a1e..cd7b77a 100644 --- a/dll/dxwcore.hpp +++ b/dll/dxwcore.hpp @@ -3,6 +3,15 @@ #define DDSQLEN 0x10 +typedef struct { + UINT uTimerId; + UINT uDelay; + UINT uResolution; + LPTIMECALLBACK lpTimeProc; + DWORD_PTR dwUser; + UINT fuEvent; +} TimerEvent_Type; + class dxwCore { // Construction/destruction @@ -17,8 +26,8 @@ public: // methods void SethWnd(HWND hwnd, HWND hwndfps) {hWnd=hwnd; hWndFPS=hwndfps;} void InitWindowPos(int, int, int, int); HWND GethWnd(void) {return hWnd;} - void SetScreenSize(void) {dwScreenWidth=800; dwScreenHeight=600;} - void SetScreenSize(int x, int y) {if(x)dwScreenWidth=x; if(y)dwScreenHeight=y;} + void SetScreenSize(void); + void SetScreenSize(int x, int y); DWORD GetScreenWidth(void) {return dwScreenWidth;} DWORD GetScreenHeight(void) {return dwScreenHeight;} void SetFullScreen(BOOL); @@ -61,10 +70,11 @@ public: // methods void MarkRegularSurface(LPDIRECTDRAWSURFACE); void SetPrimarySurface(void); void ResetPrimarySurface(void); - void GetSystemTime(LPSYSTEMTIME lpSystemTime); - void GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); + void GetSystemTime(LPSYSTEMTIME); + void GetSystemTimeAsFileTime(LPFILETIME); DWORD StretchTime(DWORD); DWORD StretchCounter(DWORD); + LARGE_INTEGER dxwCore::StretchCounter(LARGE_INTEGER); void ShowOverlay(); void ShowOverlay(HDC); void ShowOverlay(LPDIRECTDRAWSURFACE); @@ -75,6 +85,7 @@ public: // methods POINT ScreenToClient(POINT); int GetDLLIndex(char *); void FixStyle(char *, HWND, WPARAM, LPARAM); + void FixWindowFrame(HWND); HDC AcquireEmulatedDC(HWND); HDC AcquireEmulatedDC(HDC); BOOL ReleaseEmulatedDC(HWND); @@ -82,6 +93,9 @@ public: // methods void ResetEmulatedDC(); int VirtualOffsetX, VirtualOffsetY; void DumpPalette(DWORD, LPPALETTEENTRY); + void PushTimer(UINT, UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT); + void PopTimer(UINT); + void RenewTimers(); public: // simple data variables DDPIXELFORMAT ActualPixelFormat; @@ -111,7 +125,10 @@ public: // simple data variables WORD palNumEntries; PALETTEENTRY palPalEntry[256]; short FakeVersionId; - int Coordinates; + short Coordinates; + short MaxScreenRes; + HDC RealHDC; + HDC VirtualHDC; // Implementation protected: @@ -121,7 +138,6 @@ protected: HWND hWnd, hWndFPS; DWORD PrimSurfaces[DDSQLEN+1]; DWORD BackSurfaces[DDSQLEN+1]; - HDC VirtualHDC; HBITMAP VirtualPic; private: @@ -130,6 +146,7 @@ private: BOOL MustShowOverlay; void ShowFPS(HDC); void ShowTimeStretching(HDC); + TimerEvent_Type TimerEvent; }; extern dxwCore dxw; diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index f92310b..7a8e08e 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.50" +#define VERSION "2.02.52" #define DDTHREADLOCK 1 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 7913447..9fb5a5d 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 f74fe4d..6247fee 100644 --- a/dll/gdi32.cpp +++ b/dll/gdi32.cpp @@ -23,8 +23,8 @@ static void Stopper(char *s, int line) /* dlg->m_DCEmulationMode = 0; - if(t->flags2 & HOOKGDI) dlg->m_DCEmulationMode = 1; - if(t->flags3 & EMULATEDC) dlg->m_DCEmulationMode = 2; + if(t->flags2 & GDISTRETCHED) dlg->m_DCEmulationMode = 1; + if(t->flags3 & GDIEMULATEDC) dlg->m_DCEmulationMode = 2; if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3; */ @@ -43,6 +43,10 @@ static HookEntry_Type Hooks[]={ //{"SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice}, //{"CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap}, //{"SetMapMode", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extSetMapMode}, + {"SetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDISetPixelFormat, (FARPROC)extGDISetPixelFormat}, + {"GetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDIGetPixelFormat, (FARPROC)extGDIGetPixelFormat}, + {"ChoosePixelFormat", (FARPROC)NULL, (FARPROC *)&pChoosePixelFormat, (FARPROC)extChoosePixelFormat}, + {"DescribePixelFormat", (FARPROC)NULL, (FARPROC *)&pDescribePixelFormat, (FARPROC)extDescribePixelFormat}, {0, NULL, 0, 0} // terminator }; @@ -62,6 +66,7 @@ static HookEntry_Type ScaledHooks[]={ {"Rectangle", (FARPROC)Rectangle, (FARPROC *)&pGDIRectangle, (FARPROC)extRectangle}, {"TextOutA", (FARPROC)TextOutA, (FARPROC *)&pGDITextOutA, (FARPROC)extTextOutA}, {"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox}, + {"GetRegionBox", (FARPROC)NULL, (FARPROC *)&pGDIGetRegionBox, (FARPROC)extGetRegionBox}, {"Polyline", (FARPROC)NULL, (FARPROC *)&pPolyline, (FARPROC)extPolyline}, {"PolyBezierTo", (FARPROC)NULL, (FARPROC *)&pPolyBezierTo, (FARPROC)extPolyBezierTo}, {"PolylineTo", (FARPROC)NULL, (FARPROC *)&pPolylineTo, (FARPROC)extPolylineTo}, @@ -80,10 +85,35 @@ static HookEntry_Type ScaledHooks[]={ {"CreatePolygonRgn", (FARPROC)NULL, (FARPROC *)&pCreatePolygonRgn, (FARPROC)extCreatePolygonRgn}, {"DrawTextA", (FARPROC)NULL, (FARPROC *)&pDrawText, (FARPROC)extDrawText}, {"DrawTextExA", (FARPROC)NULL, (FARPROC *)&pDrawTextEx, (FARPROC)extDrawTextEx}, + + // same as emulated GDI ... + {"CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extGDICreateCompatibleDC}, + {"DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extGDIDeleteDC}, + {"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extGDICreateDC}, + // CreateDCW ..... + {"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extGDIBitBlt}, + {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extGDIStretchBlt}, + {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extGDIPatBlt}, + {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt}, + {0, NULL, 0, 0} // terminator }; static HookEntry_Type EmulateHooks[]={ + // useless CreateCompatibleDC: it maps VirtualHDC on top of VirtualHDC, then does nothing.... + //{"CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extEMUCreateCompatibleDC}, + // useless DeleteDC: it's just a proxy + //{"DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extGDIDeleteDC}, + {"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extGDICreateDC}, + // CreateDCW ..... + {"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extGDIBitBlt}, + {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extGDIStretchBlt}, + {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extGDIPatBlt}, + {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt}, + + {"GetObjectType", (FARPROC)GetObjectType, (FARPROC *)&pGetObjectType, (FARPROC)extGetObjectType}, + {"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox}, + {0, NULL, 0, 0} // terminator }; @@ -95,21 +125,13 @@ static HookEntry_Type DDHooks[]={ {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extDDStretchBlt}, // {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extDDPatBlt}, // missing one ... // {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt}, + + {"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox}, + {0, NULL, 0, 0} // terminator }; -static HookEntry_Type GDIHooks[]={ - {"CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extGDICreateCompatibleDC}, - {"DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extGDIDeleteDC}, - {"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extGDICreateDC}, - {"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extGDIBitBlt}, - {"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extGDIStretchBlt}, - {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extGDIPatBlt}, - {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt}, - {0, NULL, 0, 0} // terminator -}; - -static HookEntry_Type EmuHooks[]={ +static HookEntry_Type TextHooks[]={ {"CreateFontA", (FARPROC)CreateFont, (FARPROC *)&pGDICreateFont, (FARPROC)extCreateFont}, {"CreateFontIndirectA", (FARPROC)CreateFontIndirectA, (FARPROC *)&pGDICreateFontIndirect, (FARPROC)extCreateFontIndirect}, {0, NULL, 0, 0} // terminator @@ -139,7 +161,8 @@ void HookGDI32Init() HookLibInit(Hooks); HookLibInit(RemapHooks); HookLibInit(DDHooks); - HookLibInit(EmuHooks); + HookLibInit(EmulateHooks); + HookLibInit(TextHooks); HookLibInit(GammaHooks); } @@ -147,35 +170,14 @@ void HookGDI32(HMODULE module) { HookLibrary(module, Hooks, libname); - if(dxw.dwFlags1 & CLIENTREMAPPING) - HookLibrary(module, RemapHooks, libname); - - if(dxw.dwFlags3 & EMULATEDC){ - HookLibrary(module, EmulateHooks, libname); - HookLibrary(module, ScaledHooks, libname); - HookLibrary(module, GDIHooks, libname); - } - - if(dxw.dwFlags2 & HOOKGDI){ - HookLibrary(module, EmulateHooks, libname); - HookLibrary(module, ScaledHooks, libname); - HookLibrary(module, GDIHooks, libname); - } - - if(dxw.dwFlags1 & MAPGDITOPRIMARY){ - HookLibrary(module, EmulateHooks, libname); - HookLibrary(module, ScaledHooks, libname); - HookLibrary(module, DDHooks, libname); - } - - if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC)) - HookLibrary(module, EmuHooks, libname); - - if(dxw.dwFlags2 & DISABLEGAMMARAMP) - HookLibrary(module, GammaHooks, libname); - - if(dxw.dwFlags3 & FONTBYPASS) // v2.02.33 - for "Stratego" compatibility option - HookLibrary(module, FontHooks, libname); + if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(module, RemapHooks, libname); + if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(module, ScaledHooks, libname); + if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(module, EmulateHooks, libname); + if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(module, DDHooks, libname); + if (dxw.dwFlags1 & FIXTEXTOUT) HookLibrary(module, TextHooks, libname); + if (dxw.dwFlags2 & DISABLEGAMMARAMP) HookLibrary(module, GammaHooks, libname); + // v2.02.33 - for "Stratego" compatibility option + if(dxw.dwFlags3 & FONTBYPASS) HookLibrary(module, FontHooks, libname); } FARPROC Remap_GDI32_ProcAddress(LPCSTR proc, HMODULE hModule) @@ -184,35 +186,14 @@ FARPROC Remap_GDI32_ProcAddress(LPCSTR proc, HMODULE hModule) if(addr=RemapLibrary(proc, hModule, Hooks)) return addr; - if(dxw.dwFlags1 & CLIENTREMAPPING) - if(addr=RemapLibrary(proc, hModule, RemapHooks)) return addr; - - if(dxw.dwFlags3 & EMULATEDC){ - if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, GDIHooks)) return addr; - } - - if(dxw.dwFlags2 & HOOKGDI){ - if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, GDIHooks)) return addr; - } - - if(dxw.dwFlags1 & MAPGDITOPRIMARY){ - if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr; - } - - if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC)) - if(addr=RemapLibrary(proc, hModule, EmuHooks)) return addr; - - if(dxw.dwFlags2 & DISABLEGAMMARAMP) - if(addr=RemapLibrary(proc, hModule, GammaHooks)) return addr; - - if(dxw.dwFlags3 & FONTBYPASS) // v2.02.33 - for "Stratego" compatibility option - if(addr=RemapLibrary(proc, hModule, FontHooks)) return addr; + if (dxw.dwFlags1 & CLIENTREMAPPING) if(addr=RemapLibrary(proc, hModule, RemapHooks)) return addr; + if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr; + if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; + if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr; + if (dxw.dwFlags1 & FIXTEXTOUT) if(addr=RemapLibrary(proc, hModule, TextHooks)) return addr; + if (dxw.dwFlags2 & DISABLEGAMMARAMP) if(addr=RemapLibrary(proc, hModule, GammaHooks)) return addr; + // v2.02.33 - for "Stratego" compatibility option + if (dxw.dwFlags3 & FONTBYPASS) if(addr=RemapLibrary(proc, hModule, FontHooks)) return addr; return NULL; } @@ -417,7 +398,7 @@ int WINAPI extGetDeviceCaps(HDC hdc, int nindex) BOOL WINAPI extTextOutA(HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cchString) { BOOL ret; - OutTraceDW("TextOut: hdc=%x xy=(%d,%d) str=(%d)\"%s\"\n", hdc, nXStart, nYStart, cchString, lpString); + OutTraceDW("TextOut: hdc=%x xy=(%d,%d) str=(%d)\"%.*s\"\n", hdc, nXStart, nYStart, cchString, cchString, lpString); if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc))){ dxw.MapClient(&nXStart, &nYStart); @@ -501,6 +482,8 @@ HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground) { HPALETTE ret; + if(hdc==dxw.RealHDC) hdc= dxw.VirtualHDC; + ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground); OutTraceDW("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret); if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){ @@ -841,23 +824,31 @@ BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHe HRESULT res; extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *); - OutTraceDW("GDI.BitBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d dwRop=%x(%s)\n", + OutTraceDW("GDI.BitBlt(PRIMARY): HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d dwRop=%x(%s)\n", hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop, ExplainROP(dwRop)); ret=1; // OK - if(hdcDest==0) hdcDest=PrimHDC; if(hdcDest==0) { - dxw.ResetPrimarySurface(); - dxw.SetPrimarySurface(); - res=extGetDC(dxw.lpDDSPrimHDC, &PrimHDC); hdcDest=PrimHDC; + if(hdcDest==0) { + dxw.ResetPrimarySurface(); + dxw.SetPrimarySurface(); + res=extGetDC(dxw.lpDDSPrimHDC, &PrimHDC); + hdcDest=PrimHDC; + } } res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__); - res=(*pGDIBitBlt)(NULL, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); - if(!res) ret=0; + + //dxw.SetPrimarySurface(); + //OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC); + //sBlt("GDI.BitBlt", dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL, 0); + //res=(*pUnlockMethod(dxw.lpDDSPrimHDC))(dxw.lpDDSPrimHDC, NULL); + + //res=(*pGDIBitBlt)(NULL, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); + //if(!res) ret=0; return ret; } @@ -865,7 +856,6 @@ BOOL WINAPI extDDStretchBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int HDC hdcSrc, int nXSrc, int nYSrc, int nWSrc, int nHSrc, DWORD dwRop) { BOOL ret; - HRESULT res; RECT ClientRect; OutTraceDW("GDI.StretchBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d nWSrc=%x nHSrc=%x dwRop=%x\n", @@ -879,10 +869,10 @@ BOOL WINAPI extDDStretchBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int return ret; } } - dxw.SetPrimarySurface(); - OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC); - sBlt("GDI.StretchBlt", dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL, 0); - res=(*pUnlockMethod(dxw.lpDDSPrimHDC))(dxw.lpDDSPrimHDC, NULL); + //dxw.SetPrimarySurface(); + //OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC); + //sBlt("GDI.StretchBlt", dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL, 0); + //res=(*pUnlockMethod(dxw.lpDDSPrimHDC))(dxw.lpDDSPrimHDC, NULL); return ret; } @@ -897,6 +887,10 @@ HDC WINAPI extGDICreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMOD WinHDC=(*pGDIGetDC)(dxw.GethWnd()); RetHDC=(*pGDICreateCompatibleDC)(WinHDC); (*pGDIReleaseDC)(dxw.GethWnd(), WinHDC); + + if(dxw.dwFlags3 & GDIEMULATEDC){ + RetHDC=dxw.AcquireEmulatedDC(dxw.GethWnd()); + } } else{ RetHDC=(*pGDICreateDC)(Driver, Device, Output, InitData); @@ -911,8 +905,6 @@ HDC WINAPI extGDICreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMOD HDC WINAPI extGDICreateCompatibleDC(HDC hdc) { HDC RetHdc, SrcHdc; - extern LPDIRECTDRAWSURFACE lpDDSHDC; - extern GetDC_Type pGetDC; DWORD LastError; OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc); @@ -932,6 +924,34 @@ HDC WINAPI extGDICreateCompatibleDC(HDC hdc) return RetHdc; } +//HDC WINAPI extEMUCreateCompatibleDC(HDC hdc) +//{ +// HDC RetHdc, SrcHdc; +// DWORD LastError; +// +// OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc); +// if((hdc==0) || (hdc==dxw.RealHDC)){ +// SrcHdc=dxw.AcquireEmulatedDC(dxw.GethWnd()); +// OutTraceDW("GDI.CreateCompatibleDC: using emulated HDC hWnd=%x hdc=%x\n", dxw.GethWnd(), SrcHdc); +// } +// +// // eliminated error message for errorcode 0. +// SetLastError(0); +// RetHdc=(*pGDICreateCompatibleDC)(hdc); +// LastError=GetLastError(); +// if(!LastError) +// OutTraceDW("GDI.CreateCompatibleDC: returning HDC=%x\n", RetHdc); +// else +// OutTraceE("GDI.CreateCompatibleDC ERROR: err=%d at %d\n", LastError, __LINE__); +// return RetHdc; +//} + +//BOOL WINAPI extEMUBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop) +//{ +// if (hdcDest==dxw.RealHDC) hdcDest=dxw.VirtualHDC; +// return (*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); +//} + BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop) { BOOL res; @@ -947,6 +967,11 @@ BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH // the screen surface later on, on ReleaseDC or ddraw Blit / Flip operation. Scaling of rect coordinates is // needed only in the first case, and must be avoided on the second, otherwise the image would be scaled twice! + if(dxw.dwFlags3 & GDIEMULATEDC){ + if (hdcDest==dxw.RealHDC) hdcDest=dxw.VirtualHDC; + //return (*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); + } + if (OBJ_DC == GetObjectType(hdcDest)){ //if(dxw.IsRealDesktop(WindowFromDC(hdcDest))) hdcDest=GetDC(dxw.GethWnd()); // ?????? if (dxw.HandleFPS()) return TRUE; @@ -1170,7 +1195,26 @@ int WINAPI extGetClipBox(HDC hdc, LPRECT lprc) // virtual desktop area as the current clipbox...!!! *lprc=dxw.GetScreenRect(); } - OutTraceDW("GetClipBox: ret=%x(%s)\n", ret, sRetCodes[ret]); + OutTraceDW("GetClipBox: ret=%x(%s) rect=(%d,%d)-(%d,%d)\n", + ret, sRetCodes[ret], lprc->left, lprc->top, lprc->right, lprc->bottom); + return ret; +} + +int WINAPI extGetRegionBox(HDC hdc, LPRECT lprc) +{ + int ret; + char *sRetCodes[4]={"ERROR", "NULLREGION", "SIMPLEREGION", "COMPLEXREGION"}; + OutTraceDW("GetRegionBox: hdc=%x\n", hdc); + ret=(*pGDIGetRegionBox)(hdc, lprc); + if (dxw.IsFullScreen() && (OBJ_DC == GetObjectType(hdc)) && (ret!=ERROR)){ + OutTraceDW("GetRegionBox: scaling main win coordinates (%d,%d)-(%d,%d)\n", + lprc->left, lprc->top, lprc->right, lprc->bottom); + // current implementation is NOT accurate, since it always returns the whole + // virtual desktop area as the current regionbox...!!! + *lprc=dxw.GetScreenRect(); + } + OutTraceDW("GetRegionBox: ret=%x(%s) rect=(%d,%d)-(%d,%d)\n", + ret, sRetCodes[ret], lprc->left, lprc->top, lprc->right, lprc->bottom); return ret; } @@ -1798,15 +1842,106 @@ UINT WINAPI extSetSystemPaletteUse(HDC hdc, UINT uUsage) return SYSPAL_NOSTATIC256; } +//BEWARE: SetPixelFormat must be issued on the same hdc used by OpenGL wglCreateContext, otherwise +// a failure err=2000 ERROR INVALID PIXEL FORMAT occurs!! + +BOOL WINAPI extGDISetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) +{ + BOOL res; + OutTraceDW("SetPixelFormat: hdc=%x PixelFormat=%d Flags=%x PixelType=%x(%s) ColorBits=%d RGBdepth=(%d,%d,%d) RGBshift=(%d,%d,%d)\n", + hdc, iPixelFormat, + ppfd->dwFlags, ppfd->iPixelType, ppfd->iPixelType?"PFD_TYPE_COLORINDEX":"PFD_TYPE_RGBA", ppfd->cColorBits, + ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, + ppfd->cRedShift, ppfd->cGreenShift, ppfd->cBlueShift); + //if(dxw.dwFlags1 & EMULATESURFACE) { + // OutTraceDW("SetPixelFormat: prevent pixelformat change\n"); + // return TRUE; + //} + if(dxw.IsDesktop(WindowFromDC(hdc))){ + HDC oldhdc = hdc; + hdc=(*pGDIGetDC)(dxw.GethWnd()); + OutTraceDW("SetPixelFormat: remapped desktop hdc=%x->%x hWnd=%x\n", oldhdc, hdc, dxw.GethWnd()); + } + res=(*pGDISetPixelFormat)(hdc, iPixelFormat, ppfd); + dxw.ActualPixelFormat.dwRGBBitCount = ppfd->cColorBits; + if(!res) OutTraceE("SetPixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__); + return res; +} + +int WINAPI extGDIGetPixelFormat(HDC hdc) +{ + int res; + OutTraceDW("GetPixelFormat: hdc=%x\n", hdc); + if(dxw.IsDesktop(WindowFromDC(hdc))){ + HDC oldhdc = hdc; + hdc=(*pGDIGetDC)(dxw.GethWnd()); + OutTraceDW("GetPixelFormat: remapped desktop hdc=%x->%x hWnd=%x\n", oldhdc, hdc, dxw.GethWnd()); + } + res=(*pGDIGetPixelFormat)(hdc); + if(!res) OutTraceE("GetPixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__); + else OutTraceDW("GetPixelFormat: res=%d\n", res); + return res; +} + +int WINAPI extChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd) +{ + int res; + OutTraceDW("ChoosePixelFormat: hdc=%x Flags=%x PixelType=%x(%s) ColorBits=%d RGBdepth=(%d,%d,%d) RGBshift=(%d,%d,%d)\n", + hdc, + ppfd->dwFlags, ppfd->iPixelType, ppfd->iPixelType?"PFD_TYPE_COLORINDEX":"PFD_TYPE_RGBA", ppfd->cColorBits, + ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, + ppfd->cRedShift, ppfd->cGreenShift, ppfd->cBlueShift); + //PIXELFORMATDESCRIPTOR myppfd; + //memcpy(&myppfd, ppfd, sizeof(PIXELFORMATDESCRIPTOR)); + //myppfd.dwFlags |= PFD_DRAW_TO_WINDOW; + //res=(*pChoosePixelFormat)(hdc, &myppfd); + res=(*pChoosePixelFormat)(hdc, ppfd); + if(!res) OutTraceE("ChoosePixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__); + else OutTraceDW("ChoosePixelFormat: res=%d\n", res); + return res; +} + +int WINAPI extDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) +{ + int res; + OutTraceDW("DescribePixelFormat: hdc=%x PixelFormat=%d Bytes=%d\n", hdc, iPixelFormat, nBytes); + res=(*pDescribePixelFormat)(hdc, iPixelFormat, nBytes, ppfd); + if(!res){ + OutTraceE("DescribePixelFormat: ERROR err=%d at=%d\n", GetLastError(), __LINE__); + return res; + } + if (ppfd && nBytes==sizeof(PIXELFORMATDESCRIPTOR)){ + OutTraceDW("DescribePixelFormat: res=%d Flags=%x PixelType=%x(%s) ColorBits=%d RGBdepth=(%d,%d,%d) RGBshift=(%d,%d,%d)\n", + res, + ppfd->dwFlags, ppfd->iPixelType, ppfd->iPixelType?"PFD_TYPE_COLORINDEX":"PFD_TYPE_RGBA", ppfd->cColorBits, + ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, + ppfd->cRedShift, ppfd->cGreenShift, ppfd->cBlueShift); + } + else { + OutTraceDW("DescribePixelFormat: res=%d\n", res); + } + return res; +} + +DWORD WINAPI extGetObjectType(HGDIOBJ h) +{ + DWORD res; + res=(*pGetObjectType)(h); + OutTraceDW("GetObjectType: h=%x type=%x", h, res); + if(h==dxw.VirtualHDC) { + OutTraceDW("GetObjectType: REMAP h=%x type=%x->%x", h, res, OBJ_DC); + res=OBJ_DC; + } + return res; +} + #if 0 int WINAPI extSetMapMode(HDC hdc, int fnMapMode) { OutTraceDW("SetMapMode: hdc=%x MapMode=%d\n", hdc, fnMapMode); return TRUE; } -#endif -#if 0 // to map: // GetCurrentPositionEx // GetViewportExtEx diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index d05e063..e4eef40 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -17,6 +17,7 @@ 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); typedef UINT (WINAPI *GetAdapterCount_Type)(void *); typedef HRESULT (WINAPI *GetAdapterIdentifier_Type)(void *, UINT, DWORD, D3DADAPTER_IDENTIFIER9 *); @@ -85,6 +86,8 @@ void WINAPI extSetCursorPosition9(void *, int, int, DWORD); void WINAPI extSetCursorPosition8(void *, int, int, DWORD); ULONG WINAPI extAddRef9(void *); ULONG WINAPI extRelease9(void *); +BOOL WINAPI voidDisableD3DSpy(void); + HRESULT WINAPI extD3D10CreateDevice(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, ID3D10Device **); @@ -152,6 +155,11 @@ void dxwCopyProxyLib9() char sSourcePath[MAX_FILE_PATH+1]; char *p; + // don't do this more than once per process activation + static BOOL DoOnce=FALSE; + if(DoOnce) return; + DoOnce=TRUE; + dwAttrib = GetFileAttributes("dxwnd.dll"); if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) return; GetModuleFileName(GetModuleHandle("dxwnd"), sSourcePath, MAX_FILE_PATH); @@ -188,6 +196,12 @@ void WINAPI voidDebugSetMute(void) OutTraceDW("DebugSetMute: SUPPRESSED\n"); } +BOOL WINAPI voidDisableD3DSpy(void) +{ + OutTraceD3D("DisableD3DSpy: SUPPRESSED\n"); + return FALSE; +} + FARPROC Remap_d3d9_ProcAddress(LPCSTR proc, HMODULE hModule) { // NULL -> keep the original call address @@ -215,17 +229,18 @@ FARPROC Remap_d3d9_ProcAddress(LPCSTR proc, HMODULE hModule) if (!strcmp(proc,"Direct3DShaderValidatorCreate9")){ OutTraceDW("GetProcAddress: suppressing Direct3DShaderValidatorCreate9\n"); return (FARPROC)voidDirect3DShaderValidatorCreate9; - //return (FARPROC)-1; } if (!strcmp(proc,"DebugSetLevel")){ OutTraceDW("GetProcAddress: suppressing DebugSetLevel\n"); return (FARPROC)voidDebugSetLevel; - //return (FARPROC)-1; } if (!strcmp(proc,"DebugSetMute")){ OutTraceDW("GetProcAddress: suppressing DebugSetMute\n"); return (FARPROC)voidDebugSetMute; - //return (FARPROC)-1; + } + if (!strcmp(proc,"DisableD3DSpy")){ + OutTraceDW("GetProcAddress: suppressing DisableD3DSpy\n"); + return (FARPROC)voidDisableD3DSpy; } return NULL; } @@ -1257,4 +1272,5 @@ ULONG WINAPI extRelease9(void *lpdd3dd) res=(*pRelease9)(lpdd3dd); OutTraceD3D("Device::Release(9): dd3dd=%x res=%x\n", lpdd3dd, res); return res; -} \ No newline at end of file +} + diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index 46edc39..f42d349 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -65,26 +65,6 @@ void HookKernel32(HMODULE module) if(dxw.dwFlags2 & TIMESTRETCH) HookLibrary(module, TimeHooks, libname); if(dxw.dwFlags2 & FAKEVERSION) HookLibrary(module, VersionHooks, libname); if(dxw.dwFlags4 & SUPPRESSCHILD) HookLibrary(module, SuppressChildHooks, libname); - -#if 0 - if(dxw.dwFlags2 & TIMESTRETCH){ - HINSTANCE hinst; - LARGE_INTEGER myPerfCount; - hinst = LoadLibrary("kernel32.dll"); - pQueryPerformanceFrequency=(QueryPerformanceFrequency_Type)GetProcAddress(hinst, "QueryPerformanceFrequency"); - pQueryPerformanceCounter=(QueryPerformanceCounter_Type)GetProcAddress(hinst, "QueryPerformanceCounter"); - pGetTickCount=(GetTickCount_Type)GetProcAddress(hinst, "GetTickCount"); - if(pQueryPerformanceFrequency){ - HookAPI(hinst, "kernel32.dll", pQueryPerformanceFrequency, "QueryPerformanceFrequency", extQueryPerformanceFrequency); - HookAPI(hinst, "kernel32.dll", pQueryPerformanceCounter, "QueryPerformanceCounter", extQueryPerformanceCounter); - extQueryPerformanceFrequency(&myPerfCount); - } - if(pGetTickCount){ - HookAPI(hinst, "kernel32.dll", pGetTickCount, "GetTickCount", extGetTickCount); - extGetTickCount(); - } - } -#endif } void HookKernel32Init() @@ -376,7 +356,10 @@ HMODULE WINAPI LoadLibraryExWrapper(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFl idx=SYSLIBIDX_OPENGL; SysLibs[idx]=libhandle; } - if (idx == -1) HookModule(libhandle, 0); + if (idx == -1) { + OutTraceDW("%s: hooking lib=\"%s\" handle=%x\n", api, lpFileName, libhandle); + HookModule(libhandle, 0); + } #if 0 switch(idx){ case SYSLIBIDX_DIRECTDRAW: HookDirectDraw(libhandle, 0); break; @@ -747,13 +730,11 @@ BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount) LARGE_INTEGER myPerfCount; if(dxw.dwFlags4 & NOPERFCOUNTER){ ret=0; - myPerfCount.HighPart = 0; - myPerfCount.LowPart = 0; + myPerfCount.QuadPart = 0; } else{ ret=(*pQueryPerformanceCounter)(&myPerfCount); - myPerfCount.HighPart = dxw.StretchCounter(myPerfCount.HighPart); - myPerfCount.LowPart = dxw.StretchCounter(myPerfCount.LowPart); + myPerfCount = dxw.StretchCounter(myPerfCount); } *lpPerformanceCount = myPerfCount; OutTraceB("QueryPerformanceCounter: ret=%x Count=%x-%x\n", ret, lpPerformanceCount->HighPart, lpPerformanceCount->LowPart); diff --git a/dll/ole32.bad.cpp b/dll/ole32.bad.cpp new file mode 100644 index 0000000..c8bdc64 --- /dev/null +++ b/dll/ole32.bad.cpp @@ -0,0 +1,179 @@ +#include +#include "dxwnd.h" +#include "dxwcore.hpp" +#include "syslibs.h" +#include "dxhook.h" +#include "dxhelper.h" + +extern void HookModule(HMODULE, int); + +static HookEntry_Type Hooks[]={ + {"CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance}, + {"CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx}, + {"CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize}, + {0, NULL, 0, 0} // terminator +}; + +extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *); +extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *); + +void HookOle32(HMODULE module) +{ + HookLibrary(module, Hooks, "ole32.dll"); +} + +FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule) +{ + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; + return NULL; +} + +// so far, there are 4 additional libraries that could be loaded by meand of a CoCreateInstance call.... + +#define ADDITIONAL_MODULE_COUNT 4 +struct { + BOOL Hooked; + char *ModuleName; +} AddedModules[ADDITIONAL_MODULE_COUNT]= +{ + {FALSE, "quartz"}, + {FALSE, "ddrawex"}, + {FALSE, "amstream"}, + {FALSE, "dplayx"} +}; + +static void HookAdditionalModules() +{ + for(int i=0; i%x\n", *ppv, *(DWORD *)*ppv); + + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ + OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n"); + switch (*(DWORD *)&riid){ + case 0x6C14DB80: + OutTraceDW("CoCreateInstance: IID_DirectDraw RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 1); + break; + case 0xB3A6F3E0: + OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 2); + break; + case 0x9c59509a: + OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 4); + case 0x15e65ec0: + OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 7); + break; + case 0xe436ebb3: + break; + } + } + else + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + + HookAdditionalModules(); + return res; +} + +HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID rclsid, IUnknown *punkOuter, DWORD dwClsCtx, COSERVERINFO *pServerInfo, DWORD dwCount, MULTI_QI *pResults) +{ + HRESULT res; + DWORD i; + + OutTraceDW("CoCreateInstanceEx: rclsid=%x UnkOuter=%x ClsContext=%x Count=%d\n", + rclsid, punkOuter, dwClsCtx, dwCount); + + res=(*pCoCreateInstanceEx)(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults); + if(res) { + OutTraceE("CoCreateInstanceEx: ERROR res=%x\n", res); + return res; + } + + for(i=0; i +#include "dxwnd.h" +#include "dxwcore.hpp" +#include "syslibs.h" +#include "dxhook.h" +#include "dxhelper.h" + +extern void HookModule(HMODULE, int); + +static HookEntry_Type Hooks[]={ + {"CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance}, + {"CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx}, + {"CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize}, + {0, NULL, 0, 0} // terminator +}; + +extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *); +extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *); + +void HookOle32(HMODULE module) +{ + HookLibrary(module, Hooks, "ole32.dll"); +} + +FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule) +{ + FARPROC addr; + if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; + return NULL; +} + +// so far, there are 4 additional libraries that could be loaded by meand of a CoCreateInstance call.... + +#define ADDITIONAL_MODULE_COUNT 4 +struct { + BOOL Hooked; + char *ModuleName; +} AddedModules[ADDITIONAL_MODULE_COUNT]= +{ + {FALSE, "quartz"}, + {FALSE, "ddrawex"}, + {FALSE, "amstream"}, + {FALSE, "dplayx"} +}; + +static void HookAdditionalModules() +{ + for(int i=0; i%x\n", *ppv, *(DWORD *)*ppv); + + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ + LPDIRECTDRAW lpOldDDraw; + OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n"); + switch (*(DWORD *)&riid){ + 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)); + break; + case 0xB3A6F3E0: + OutTraceDW("DirectDrawCreate: 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("DirectDrawCreate: 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(); + 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); + + HookAdditionalModules(); + return res; +} + +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)); + + res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv); + if(res) + OutTraceE("CoCreateInstance: ERROR res=%x\n", res); + else + OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv); + + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ + OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n"); + switch (*(DWORD *)&riid){ + case 0x6C14DB80: + OutTraceDW("CoCreateInstance: IID_DirectDraw RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 1); + break; + case 0xB3A6F3E0: + OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 2); + break; + case 0x9c59509a: + OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 4); + case 0x15e65ec0: + OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID lpdd=%x\n", *ppv); + HookDDSession((LPDIRECTDRAW *)ppv, 7); + break; + case 0xe436ebb3: + break; + } + } + else + if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv); + + HookAdditionalModules(); + return res; +} + +HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID rclsid, IUnknown *punkOuter, DWORD dwClsCtx, COSERVERINFO *pServerInfo, DWORD dwCount, MULTI_QI *pResults) +{ + HRESULT res; + DWORD i; + + OutTraceDW("CoCreateInstanceEx: rclsid=%x UnkOuter=%x ClsContext=%x Count=%d\n", + rclsid, punkOuter, dwClsCtx, dwCount); + + res=(*pCoCreateInstanceEx)(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults); + if(res) { + OutTraceE("CoCreateInstanceEx: ERROR res=%x\n", res); + return res; + } + + for(i=0; i%x\n", *ppv, *(DWORD *)*ppv); - - if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){ - LPDIRECTDRAW lpOldDDraw; - OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n"); - switch (*(DWORD *)&riid){ - 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)); - break; - case 0xB3A6F3E0: - OutTraceDW("DirectDrawCreate: 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("DirectDrawCreate: 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(); - 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); - - HookAdditionalModules(); - return res; -} - HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv) { HRESULT res; diff --git a/dll/opengl.cpp b/dll/opengl.cpp index 5f6606a..9688381 100644 --- a/dll/opengl.cpp +++ b/dll/opengl.cpp @@ -167,11 +167,15 @@ void WINAPI extglViewport(GLint x, GLint y, GLsizei width, GLsizei height { RECT client; POINT p={0,0}; + HWND hwnd; //if (dxw.dwFlags2 & HANDLEFPS) if(dxw.HandleFPS()) return; - (*pGetClientRect)(dxw.GethWnd(), &client); + hwnd=dxw.GethWnd(); + (*pGetClientRect)(hwnd, &client); OutTraceDW("glViewport: declared pos=(%d,%d) size=(%d,%d)\n", x, y, width, height); - if(IsDebug) OutTrace("glViewport: DEBUG win=(%d,%d) screen=(%d,%d)\n", - client.right, client.bottom, dxw.GetScreenWidth(), dxw.GetScreenHeight()); + if(IsDebug) OutTrace("glViewport: DEBUG hwnd=%x win=(%d,%d) screen=(%d,%d)\n", + hwnd, client.right, client.bottom, dxw.GetScreenWidth(), dxw.GetScreenHeight()); + if(x==CW_USEDEFAULT) x=0; + if(y==CW_USEDEFAULT) y=0; x = (x * (GLint)client.right) / (GLint)dxw.GetScreenWidth(); y = (y * (GLint)client.bottom) / (GLint)dxw.GetScreenHeight(); width = (width * (GLint)client.right) / (GLint)dxw.GetScreenWidth(); @@ -244,6 +248,9 @@ void WINAPI extglClear(GLbitfield mask) return; } +//BEWARE: SetPixelFormat must be issued on the same hdc used by OpenGL wglCreateContext, otherwise +// a failure err=2000 ERROR INVALID PIXEL FORMAT occurs!! + HGLRC WINAPI extwglCreateContext(HDC hdc) { HGLRC ret; @@ -252,7 +259,7 @@ HGLRC WINAPI extwglCreateContext(HDC hdc) if(dxw.IsDesktop(WindowFromDC(hdc))){ HDC oldhdc = hdc; hdc=(*pGDIGetDC)(dxw.GethWnd()); - OutTraceDW("wglCreateContext: remapped desktop hdc=%x->%x\n", oldhdc, hdc); + OutTraceDW("wglCreateContext: remapped desktop hdc=%x->%x hWnd=%x\n", oldhdc, hdc, dxw.GethWnd()); } ret=(*pwglCreateContext)(hdc); if(ret){ @@ -262,7 +269,7 @@ HGLRC WINAPI extwglCreateContext(HDC hdc) OutTraceDW("wglCreateContext: SET hwnd=%x\n", hwnd); } else { - OutTraceDW("wglCreateContext: ERROR err=%x\n", GetLastError()); + OutTraceDW("wglCreateContext: ERROR err=%d\n", GetLastError()); } return ret; } @@ -277,12 +284,6 @@ PROC WINAPI extwglGetProcAddress(LPCSTR proc) return procaddr; } -int WINAPI extChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd) -{ - // to do .... - return 0; -} - BOOL WINAPI extwglMakeCurrent(HDC hdc, HGLRC hglrc) { BOOL ret; diff --git a/dll/syslibs.h b/dll/syslibs.h index ca48113..b1b6b27 100644 --- a/dll/syslibs.h +++ b/dll/syslibs.h @@ -45,6 +45,7 @@ typedef HPALETTE(WINAPI *GDICreatePalette_Type)(CONST LOGPALETTE *); typedef HDWP (WINAPI *DeferWindowPos_Type)(HDWP, HWND, HWND, int, int, int, int, UINT); typedef BOOL (WINAPI *DeleteDC_Type)(HDC); typedef int (WINAPI *GetClipBox_Type)(HDC, LPRECT); +typedef int (WINAPI *GetRegionBox_Type)(HDC, LPRECT); typedef int (WINAPI *GetDeviceCaps_Type)(HDC, int); typedef BOOL (WINAPI *GetDeviceGammaRamp_Type)(HDC, LPVOID); typedef BOOL (WINAPI *GetSystemPaletteEntries_Type)(HDC, UINT, UINT, LPPALETTEENTRY); @@ -90,6 +91,12 @@ typedef BOOL (WINAPI *SetWindowOrgEx_Type)(HDC, int, int, LPPOINT); typedef BOOL (WINAPI *GetCurrentPositionEx_Type)(HDC, LPPOINT); typedef BOOL (WINAPI *AnimatePalette_Type)(HPALETTE, UINT, UINT, const PALETTEENTRY *); typedef UINT (WINAPI *SetSystemPaletteUse_Type)(HDC, UINT); +typedef BOOL (WINAPI *GDISetPixelFormat_Type)(HDC, int, const PIXELFORMATDESCRIPTOR *); +typedef BOOL (WINAPI *GDIGetPixelFormat_Type)(HDC); +typedef int (WINAPI *ChoosePixelFormat_Type)(HDC, const PIXELFORMATDESCRIPTOR *); +typedef int (WINAPI *DescribePixelFormat_Type)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); +typedef DWORD (WINAPI *GetObjectType_Type)(HGDIOBJ); + // Kernel32.dll: typedef BOOL (WINAPI *GetDiskFreeSpaceA_Type)(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); @@ -235,6 +242,7 @@ DXWEXTERN GDICreatePalette_Type pGDICreatePalette DXWINITIALIZED; DXWEXTERN DeferWindowPos_Type pGDIDeferWindowPos DXWINITIALIZED; DXWEXTERN DeleteDC_Type pGDIDeleteDC DXWINITIALIZED; DXWEXTERN GetClipBox_Type pGDIGetClipBox DXWINITIALIZED; +DXWEXTERN GetRegionBox_Type pGDIGetRegionBox DXWINITIALIZED; DXWEXTERN GetDeviceCaps_Type pGDIGetDeviceCaps DXWINITIALIZED; DXWEXTERN GetDeviceGammaRamp_Type pGDIGetDeviceGammaRamp DXWINITIALIZED; DXWEXTERN GetSystemPaletteEntries_Type pGDIGetSystemPaletteEntries DXWINITIALIZED; @@ -284,6 +292,11 @@ DXWEXTERN CreateScalableFontResourceW_Type pCreateScalableFontResourceW DXWINITI DXWEXTERN AddFontResourceW_Type pAddFontResourceW DXWINITIALIZED; DXWEXTERN AnimatePalette_Type pAnimatePalette DXWINITIALIZED; DXWEXTERN SetSystemPaletteUse_Type pSetSystemPaletteUse DXWINITIALIZED; +DXWEXTERN GDISetPixelFormat_Type pGDISetPixelFormat DXWINITIALIZED; +DXWEXTERN GDIGetPixelFormat_Type pGDIGetPixelFormat DXWINITIALIZED; +DXWEXTERN ChoosePixelFormat_Type pChoosePixelFormat DXWINITIALIZED; +DXWEXTERN DescribePixelFormat_Type pDescribePixelFormat DXWINITIALIZED; +DXWEXTERN GetObjectType_Type pGetObjectType DXWINITIALIZED; // Kernel32.dll: DXWEXTERN GetDiskFreeSpaceA_Type pGetDiskFreeSpaceA DXWINITIALIZED; @@ -405,6 +418,7 @@ extern BOOL WINAPI extImmGetOpenStatus(HIMC); // GDI32.dll: extern BOOL WINAPI extGDIBitBlt(HDC, int, int, int, int, HDC, int, int, DWORD); extern HDC WINAPI extGDICreateCompatibleDC(HDC); +extern HDC WINAPI extEMUCreateCompatibleDC(HDC); extern HDC WINAPI extDDCreateCompatibleDC(HDC); extern HDC WINAPI extGDICreateDC(LPSTR, LPSTR, LPSTR, CONST DEVMODE *); extern HDC WINAPI extDDCreateDC(LPSTR, LPSTR, LPSTR, CONST DEVMODE *); @@ -415,6 +429,7 @@ extern HDWP WINAPI extDeferWindowPos(HDWP, HWND, HWND, int, int, int, int, UINT) extern BOOL WINAPI extGDIDeleteDC(HDC); extern BOOL WINAPI extDDDeleteDC(HDC); extern int WINAPI extGetClipBox(HDC, LPRECT); +extern int WINAPI extGetRegionBox(HDC, LPRECT); extern int WINAPI extGetDeviceCaps(HDC, int); extern BOOL WINAPI extGetDeviceGammaRamp(HDC, LPVOID); extern UINT WINAPI extGetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY); @@ -466,6 +481,11 @@ extern BOOL WINAPI extCreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWS extern int WINAPI extAddFontResourceW(LPCWSTR); extern BOOL WINAPI extAnimatePalette(HPALETTE, UINT, UINT, const PALETTEENTRY *); extern UINT WINAPI extSetSystemPaletteUse(HDC, UINT); +extern BOOL WINAPI extGDISetPixelFormat(HDC, int, const PIXELFORMATDESCRIPTOR *); +extern int WINAPI extGDIGetPixelFormat(HDC); +extern int WINAPI extChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *); +extern int WINAPI extDescribePixelFormat(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); +extern DWORD WINAPI extGetObjectType(HGDIOBJ); // Kernel32.dll: extern BOOL WINAPI extGetDiskFreeSpaceA(LPCSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); @@ -530,7 +550,7 @@ extern HDC WINAPI extDDGetWindowDC(HWND); extern LONG WINAPI extGetWindowLong(HWND, int); extern BOOL WINAPI extGetWindowRect(HWND, LPRECT); extern BOOL WINAPI extInvalidateRect(HWND, RECT *, BOOL); -extern BOOL WINAPI extDDInvalidateRect(HWND, RECT *, BOOL); +//extern BOOL WINAPI extDDInvalidateRect(HWND, RECT *, BOOL); extern int WINAPI extMapWindowPoints(HWND, HWND, LPPOINT, UINT); extern BOOL WINAPI extMoveWindow(HWND, int, int, int, int, BOOL); extern BOOL WINAPI extPeekMessage(LPMSG, HWND, UINT, UINT, UINT); diff --git a/dll/user32.cpp b/dll/user32.cpp index ba15b7c..fd5da7c 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -50,8 +50,9 @@ static HookEntry_Type Hooks[]={ static HookEntry_Type EmulateHooks[]={ {"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC}, - //{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetDC}, // not ready yet + {"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC}, {"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extGDIReleaseDC}, + {"InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect}, {0, NULL, 0, 0} // terminator }; @@ -59,14 +60,14 @@ static HookEntry_Type DDHooks[]={ {"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extDDGetDC}, {"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extDDGetDC}, {"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extDDReleaseDC}, - {"InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extDDInvalidateRect}, + {"InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect}, {0, NULL, 0, 0} // terminator }; -static HookEntry_Type GDIHooks[]={ +static HookEntry_Type ScaledHooks[]={ {"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC}, {"GetDCEx", (FARPROC)NULL, (FARPROC *)&pGDIGetDCEx, (FARPROC)extGDIGetDCEx}, - {"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetDC}, + {"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC}, {"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extGDIReleaseDC}, {"InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect}, {0, NULL, 0, 0} // terminator @@ -115,18 +116,18 @@ FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule) { FARPROC addr; if (addr=RemapLibrary(proc, hModule, Hooks)) return addr; - if ((dxw.dwFlags3 & EMULATEDC) || (dxw.dwFlags2 & HOOKGDI) || (dxw.dwFlags1 & MAPGDITOPRIMARY)) - if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; - if (addr=RemapLibrary(proc, hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks)) return addr; - if (dxw.dwFlags1 & CLIENTREMAPPING) - if (addr=RemapLibrary(proc, hModule, RemapHooks)) return addr; - if(dxw.dwFlags1 & MODIFYMOUSE) - if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr; + if (dxw.dwFlags1 & CLIENTREMAPPING) if (addr=RemapLibrary(proc, hModule, RemapHooks)) return addr; + + if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr; + if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr; + if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr; + + if (dxw.dwFlags1 & MODIFYMOUSE) if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr; if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)) if (addr=RemapLibrary(proc, hModule, WinHooks)) return addr; - if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) + if ((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) if (addr=RemapLibrary(proc, hModule, MouseHooks2)) return addr; - if(dxw.dwFlags3 & PEEKALLMESSAGES) + if (dxw.dwFlags3 & PEEKALLMESSAGES) if (addr=RemapLibrary(proc, hModule, PeekAllHooks)) return addr; return NULL; } @@ -136,18 +137,16 @@ static char *libname = "user32.dll"; void HookUser32(HMODULE hModule) { HookLibrary(hModule, Hooks, libname); - //if ((dxw.dwFlags3 & EMULATEDC) || (dxw.dwFlags2 & HOOKGDI) || (dxw.dwFlags1 & MAPGDITOPRIMARY)) - // HookLibrary(hModule, EmulateHooks, libname); - //HookLibrary(hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks, libname); - if (dxw.dwFlags3 & EMULATEDC) HookLibrary(hModule, EmulateHooks, libname); - if (dxw.dwFlags2 & HOOKGDI) HookLibrary(hModule, GDIHooks, libname); + if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(hModule, EmulateHooks, libname); + if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(hModule, ScaledHooks, libname); if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(hModule, DDHooks, libname); if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname); - if(dxw.dwFlags1 & MODIFYMOUSE)HookLibrary(hModule, MouseHooks, libname); - if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))HookLibrary(hModule, WinHooks, libname); + if(dxw.dwFlags1 & MODIFYMOUSE) HookLibrary(hModule, MouseHooks, libname); + if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)) HookLibrary(hModule, WinHooks, libname); if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) HookLibrary(hModule, MouseHooks2, libname); if(dxw.dwFlags3 & PEEKALLMESSAGES) HookLibrary(hModule, PeekAllHooks, libname); + return; } @@ -196,7 +195,7 @@ int LastCurPosX, LastCurPosY; extern GetDC_Type pGetDC; extern ReleaseDC_Type pReleaseDC; extern DEVMODE *pSetDevMode; -extern void FixWindowFrame(HWND); +//extern void FixWindowFrame(HWND); extern LRESULT CALLBACK extChildWindowProc(HWND, UINT, WPARAM, LPARAM); extern HRESULT WINAPI sBlt(char *, LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, LPRECT, DWORD, LPDDBLTFX, BOOL); @@ -207,7 +206,7 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, BOOL WideChar, void *lpDevMode, HRESULT res; DWORD dmFields, dmBitsPerPel, dmPelsWidth, dmPelsHeight; - // v2.02.32: reset the emulated DC used in EMULATEDC mode + // v2.02.32: reset the emulated DC used in GDIEMULATEDC mode dxw.ResetEmulatedDC(); if(lpDevMode){ @@ -268,100 +267,6 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, BOOL WideChar, void *lpDevMode, } } -#if 0 -LONG WINAPI MyChangeDisplaySettingsA(char *fname, DEVMODEA *lpDevMode, DWORD dwflags) -{ - HRESULT res; - - // v2.02.32: reset the emulated DC used in EMULATEDC mode - dxw.ResetEmulatedDC(); - - // save desired settings first v.2.1.89 - // v2.1.95 protect when lpDevMode is null (closing game... Jedi Outcast) - // v2.2.23 consider new width/height only when dmFields flags are set. - if(lpDevMode && (lpDevMode->dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT))){ - RECT client; - dxw.SetScreenSize(lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight); - // v2.02.31: when main win is bigger that expected resolution, you're in windowed fullscreen mode - //(*pGetClientRect)((dxw.dwFlags1 & FIXPARENTWIN) ? dxw.hParentWnd : dxw.GethWnd(), &client); - (*pGetClientRect)(dxw.GethWnd(), &client); - OutTraceDW("%s: current hWnd=%x size=(%d,%d)\n", fname, dxw.GethWnd(), client.right, client.bottom); - if((client.right>=(LONG)lpDevMode->dmPelsWidth) && (client.bottom>=(LONG)lpDevMode->dmPelsHeight)) { - OutTraceDW("%s: entering FULLSCREEN mode\n", fname); - dxw.SetFullScreen(TRUE); - } - } - - if ((dwflags==0 || dwflags==CDS_FULLSCREEN) && lpDevMode){ - if (dxw.dwFlags1 & EMULATESURFACE || !(lpDevMode->dmFields & DM_BITSPERPEL)){ - OutTraceDW("%s: BYPASS res=DISP_CHANGE_SUCCESSFUL\n", fname); - return DISP_CHANGE_SUCCESSFUL; - } - else{ - DEVMODEA NewMode; - if(dwflags==CDS_FULLSCREEN) dwflags=0; // no FULLSCREEN - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &NewMode); - OutTraceDW("ChangeDisplaySettings: CURRENT wxh=(%dx%d) BitsPerPel=%d -> %d\n", - NewMode.dmPelsWidth, NewMode.dmPelsHeight, NewMode.dmBitsPerPel, - lpDevMode->dmBitsPerPel); - NewMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - NewMode.dmBitsPerPel = lpDevMode->dmBitsPerPel; - res=(*pChangeDisplaySettingsA)(&NewMode, 0); - if(res) OutTraceE("ChangeDisplaySettings: ERROR err=%d at %d\n", GetLastError(), __LINE__); - return res; - } - } - else - return (*pChangeDisplaySettingsA)(lpDevMode, dwflags); -} - -LONG WINAPI MyChangeDisplaySettingsW(char *fname, DEVMODEW *lpDevMode, DWORD dwflags) -{ - HRESULT res; - - // v2.02.32: reset the emulated DC used in EMULATEDC mode - dxw.ResetEmulatedDC(); - - // save desired settings first v.2.1.89 - // v2.1.95 protect when lpDevMode is null (closing game... Jedi Outcast) - // v2.2.23 consider new width/height only when dmFields flags are set. - if(lpDevMode && (lpDevMode->dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT))){ - RECT client; - dxw.SetScreenSize(lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight); - // v2.02.31: when main win is bigger that expected resolution, you're in windowed fullscreen mode - //(*pGetClientRect)((dxw.dwFlags1 & FIXPARENTWIN) ? dxw.hParentWnd : dxw.GethWnd(), &client); - (*pGetClientRect)(dxw.GethWnd(), &client); - OutTraceDW("%s: current hWnd=%x size=(%d,%d)\n", fname, dxw.GethWnd(), client.right, client.bottom); - if((client.right>=(LONG)lpDevMode->dmPelsWidth) && (client.bottom>=(LONG)lpDevMode->dmPelsHeight)) { - OutTraceDW("%s: entering FULLSCREEN mode\n", fname); - dxw.SetFullScreen(TRUE); - } - } - - if ((dwflags==0 || dwflags==CDS_FULLSCREEN) && lpDevMode){ - if (dxw.dwFlags1 & EMULATESURFACE || !(lpDevMode->dmFields & DM_BITSPERPEL)){ - OutTraceDW("%s: BYPASS res=DISP_CHANGE_SUCCESSFUL\n", fname); - return DISP_CHANGE_SUCCESSFUL; - } - else{ - DEVMODEA NewMode; - if(dwflags==CDS_FULLSCREEN) dwflags=0; // no FULLSCREEN - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &NewMode); - OutTraceDW("ChangeDisplaySettings: CURRENT wxh=(%dx%d) BitsPerPel=%d -> %d\n", - NewMode.dmPelsWidth, NewMode.dmPelsHeight, NewMode.dmBitsPerPel, - lpDevMode->dmBitsPerPel); - NewMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - NewMode.dmBitsPerPel = lpDevMode->dmBitsPerPel; - res=(*pChangeDisplaySettingsA)(&NewMode, 0); - if(res) OutTraceE("ChangeDisplaySettings: ERROR err=%d at %d\n", GetLastError(), __LINE__); - return res; - } - } - else - return (*pChangeDisplaySettingsW)(lpDevMode, dwflags); -} -#endif - void dxwFixWindowPos(char *ApiName, HWND hwnd, LPARAM lParam) { LPWINDOWPOS wp; @@ -556,17 +461,6 @@ static POINT FixMessagePt(HWND hwnd, POINT point) // // -------------------------------------------------------------------------- -BOOL WINAPI extDDInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase) -{ - if(lpRect) - OutTraceDW("InvalidateRect: hwnd=%x rect=(%d,%d)-(%d,%d) erase=%x\n", - hwnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase); - else - OutTraceDW("InvalidateRect: hwnd=%x rect=NULL erase=%x\n", - hwnd, bErase); - - return (*pInvalidateRect)(hwnd, NULL, bErase); -} BOOL WINAPI extInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase) { @@ -577,7 +471,18 @@ BOOL WINAPI extInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase) OutTraceDW("InvalidateRect: hwnd=%x rect=NULL erase=%x\n", hwnd, bErase); - return (*pInvalidateRect)(hwnd, NULL, bErase); + //if(dxw.dwFlags3 & GDIEMULATEDC) return TRUE; + + if(dxw.IsFullScreen() && dxw.IsRealDesktop(hwnd)) { + hwnd=dxw.GethWnd(); + dxw.MapClient(lpRect); + return (*pInvalidateRect)(hwnd, lpRect, bErase); + } + else{ + //dxw.MapClient(lpRect); + // just exagerate ... + return (*pInvalidateRect)(hwnd, NULL, bErase); + } } BOOL WINAPI extShowWindow(HWND hwnd, int nCmdShow) @@ -587,10 +492,19 @@ BOOL WINAPI extShowWindow(HWND hwnd, int nCmdShow) OutTraceDW("ShowWindow: hwnd=%x, CmdShow=%x(%s)\n", hwnd, nCmdShow, ExplainShowCmd(nCmdShow)); if (dxw.dwFlags1 & PREVENTMAXIMIZE){ if(nCmdShow==SW_MAXIMIZE){ - OutTraceDW("ShowWindow: suppress maximize\n"); + OutTraceDW("ShowWindow: suppress SW_MAXIMIZE maximize\n"); nCmdShow=SW_SHOWNORMAL; } - } + if(nCmdShow==SW_SHOWDEFAULT){ + STARTUPINFO StartupInfo; + GetStartupInfo(&StartupInfo); + OutTraceDW("DEBUG: StartupInfo dwFlags=%x ShowWindow=%x\n", StartupInfo.dwFlags, StartupInfo.wShowWindow); + if((StartupInfo.dwFlags & STARTF_USESHOWWINDOW) && (StartupInfo.wShowWindow == SW_MAXIMIZE)){ + OutTraceDW("ShowWindow: suppress SW_SHOWDEFAULT maximize\n"); + nCmdShow=SW_SHOWNORMAL; + } + } +} res=(*pShowWindow)(hwnd, nCmdShow); @@ -661,7 +575,7 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong) } } - if (nIndex==GWL_WNDPROC){ + if ((nIndex==GWL_WNDPROC) && dxw.IsFullScreen()){ // v2.02.51 - see A10 Cuba.... WNDPROC lres; WNDPROC OldProc; // GPL fix @@ -1277,7 +1191,7 @@ static HWND WINAPI extCreateWindowCommon( } if ((dxw.dwFlags1 & FIXWINFRAME) && !(dwStyle & WS_CHILD)) - FixWindowFrame(wndh); + dxw.FixWindowFrame(wndh); // to do: handle inner child, and leave dialogue & modal child alone!!! if ((dwStyle & WS_CHILD) && (dxw.dwFlags1 & HOOKCHILDWIN)){ @@ -1398,6 +1312,11 @@ int WINAPI extFillRect(HDC hdc, const RECT *lprc, HBRUSH hbr) RECT rc; OutTraceDW("FillRect: hdc=%x hbrush=%x rect=(%d,%d)-(%d,%d)\n", hdc, hbr, lprc->left, lprc->top, lprc->right, lprc->bottom); + if(dxw.dwFlags4 & NOFILLRECT) { + OutTraceDW("FillRect: SUPPRESSED\n", hdc, hbr, lprc->left, lprc->top, lprc->right, lprc->bottom); + return TRUE; + } + // when not in fullscreen mode, just proxy the call // better not: some games may use excessive coordinates: see "Premier Manager 98" // if(!dxw.IsFullScreen()) return (*pFillRect)(hdc, lprc, hbr); @@ -1408,6 +1327,11 @@ int WINAPI extFillRect(HDC hdc, const RECT *lprc, HBRUSH hbr) if((DWORD)rc.right > dxw.GetScreenWidth()) rc.right = dxw.GetScreenWidth(); if((DWORD)rc.bottom > dxw.GetScreenHeight()) rc.bottom = dxw.GetScreenHeight(); if(dxw.IsFullScreen()){ + // ???? how to handle FillRect for primary window ??? + //if(hdc==(*pGDIGetDC)(dxw.GethWnd())) { + // dxw.MapClient(&rc); + //} + //else if(OBJ_DC == GetObjectType(hdc)) dxw.MapWindow(&rc); //else dxw.MapClient(&rc); OutTraceDW("FillRect: fixed rect=(%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom); @@ -1521,13 +1445,33 @@ BOOL WINAPI extGetClipCursor(LPRECT lpRect) LONG WINAPI extEnumDisplaySettings(LPCTSTR lpszDeviceName, DWORD iModeNum, DEVMODE *lpDevMode) { + LONG res; OutTraceDW("EnumDisplaySettings: Devicename=%s ModeNum=%x\n", lpszDeviceName, iModeNum); if(pSetDevMode && iModeNum==ENUM_CURRENT_SETTINGS){ lpDevMode=pSetDevMode; return 1; } - else - return (*pEnumDisplaySettings)(lpszDeviceName, iModeNum, lpDevMode); + else{ + res=(*pEnumDisplaySettings)(lpszDeviceName, iModeNum, lpDevMode); + if(dxw.dwFlags4 & LIMITSCREENRES){ + #define HUGE 100000 + DWORD maxw, maxh; + switch(dxw.MaxScreenRes){ + case DXW_NO_LIMIT: maxw=HUGE; maxh=HUGE; break; + case DXW_LIMIT_320x200: maxw=320; maxh=200; break; + case DXW_LIMIT_640x480: maxw=640; maxh=480; break; + case DXW_LIMIT_800x600: maxw=800; maxh=600; break; + case DXW_LIMIT_1024x768: maxw=1024; maxh=768; break; + case DXW_LIMIT_1280x960: maxw=1280; maxh=960; break; + } + if((lpDevMode->dmPelsWidth > maxw) || (lpDevMode->dmPelsHeight > maxh)){ + OutTraceDW("EnumDisplaySettings: limit device size=(%d,%d)\n", maxw, maxh); + lpDevMode->dmPelsWidth = maxw; + lpDevMode->dmPelsHeight = maxh; + } + } + return res; + } } LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *lpDevMode, DWORD dwflags) @@ -1582,6 +1526,28 @@ LONG WINAPI extChangeDisplaySettingsExW(LPCTSTR lpszDeviceName, DEVMODEW *lpDevM return MyChangeDisplaySettings("ChangeDisplaySettingsExW", TRUE, lpDevMode, dwflags); } +//HDC WINAPI extEMUGetDC(HWND hwnd) +//{ +// HDC ret; +// +// OutTraceDW("GDI.GetDC: hwnd=%x\n", hwnd); +// +// if (dxw.IsDesktop(hwnd)) { +// OutTraceDW("GDI.GetDC: desktop remapping hwnd=%x->%x\n", hwnd, dxw.GethWnd()); +// hwnd=dxw.GethWnd(); +// ret=dxw.AcquireEmulatedDC(hwnd); +// } +// else{ +// ret=(*pGDIGetDC)(hwnd); +// } +// if(ret) +// OutTraceDW("GDI.GetDC: hwnd=%x ret=%x\n", lochwnd, ret); +// else +// OutTraceE("GDI.GetDC ERROR: hwnd=%x err=%d at %d\n", lochwnd, err, __LINE__); +// +// return ret; +//} + HDC WINAPI extGDIGetDC(HWND hwnd) { HDC ret; @@ -1594,10 +1560,12 @@ HDC WINAPI extGDIGetDC(HWND hwnd) lochwnd=dxw.GethWnd(); } - if(dxw.dwFlags3 & EMULATEDC) + ret=(*pGDIGetDC)(lochwnd); + + if((dxw.dwFlags3 & GDIEMULATEDC) && (dxw.IsDesktop(hwnd))){ ret=dxw.AcquireEmulatedDC(lochwnd); - else - ret=(*pGDIGetDC)(lochwnd); + OutTraceDW("GDI.GetDC(GDIEMULATEDC): remapping hdc=%x->%x\n", (*pGDIGetDC)(hwnd), ret); + } if(ret){ OutTraceDW("GDI.GetDC: hwnd=%x ret=%x\n", lochwnd, ret); @@ -1631,7 +1599,7 @@ HDC WINAPI extGDIGetDCEx(HWND hwnd, HRGN hrgnClip, DWORD flags) lochwnd=dxw.GethWnd(); } - if(dxw.dwFlags3 & EMULATEDC) + if(dxw.dwFlags3 & GDIEMULATEDC) ret=dxw.AcquireEmulatedDC(lochwnd); else ret=(*pGDIGetDC)(lochwnd); @@ -1666,7 +1634,10 @@ HDC WINAPI extGDIGetWindowDC(HWND hwnd) lochwnd=dxw.GethWnd(); } - ret=(*pGDIGetWindowDC)(lochwnd); + if(dxw.IsDesktop(hwnd) && dxw.IsFullScreen()) + ret=(*pGDIGetDC)(lochwnd); + else + ret=(*pGDIGetWindowDC)(lochwnd); if(ret){ OutTraceDW("GDI.GetWindowDC: hwnd=%x ret=%x\n", lochwnd, ret); @@ -1693,7 +1664,7 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC) OutTraceDW("GDI.ReleaseDC: hwnd=%x hdc=%x\n", hwnd, hDC); if (dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd(); - if(dxw.dwFlags3 & EMULATEDC) + if(dxw.dwFlags3 & GDIEMULATEDC) res=dxw.ReleaseEmulatedDC(hwnd); else res=(*pGDIReleaseDC)(hwnd, hDC); @@ -1702,6 +1673,8 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC) return(res); } +HDC EmuHDC; + HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint) { HDC hdc; @@ -1714,17 +1687,24 @@ HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint) // if not in fullscreen mode, that's all! if(!dxw.IsFullScreen()) return hdc; - if(dxw.dwFlags3 & EMULATEDC) return dxw.AcquireEmulatedDC(hwnd); + if((dxw.dwFlags3 & GDIEMULATEDC) && dxw.IsFullScreen() && dxw.IsDesktop(hwnd)) { + EmuHDC = dxw.AcquireEmulatedDC(hwnd); + OutTraceDW("GDI.BeginPaint(GDIEMULATEDC): hdc=%x emulated hdc=%x\n", hdc, EmuHDC); + hdc=EmuHDC; + lpPaint->hdc=EmuHDC; + dxw.MapClient(&lpPaint->rcPaint); + return hdc; + } // on MAPGDITOPRIMARY, return the PrimHDC handle instead of the window DC if(dxw.dwFlags1 & MAPGDITOPRIMARY) { if(pGetDC && dxw.lpDDSPrimHDC){ extGetDC(dxw.lpDDSPrimHDC,&PrimHDC); - OutTraceDW("GDI.BeginPaint: redirect hdc=%x -> PrimHDC=%x\n", hdc, PrimHDC); + OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): redirect hdc=%x -> PrimHDC=%x\n", hdc, PrimHDC); hdc=PrimHDC; } else { - OutTraceDW("GDI.BeginPaint: hdc=%x\n", hdc); + OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x\n", hdc); } } @@ -1736,6 +1716,7 @@ HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint) lpPaint->rcPaint.bottom=dxw.GetScreenHeight(); } + OutTraceDW("GDI.BeginPaint: hdc=%x\n", hdc); return hdc; } @@ -1744,12 +1725,12 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint) BOOL ret; HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc); - OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x\n", hwnd, lpPaint); + OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x\n", hwnd, lpPaint, lpPaint->hdc); - if((dxw.dwFlags3 & EMULATEDC) && dxw.IsFullScreen()){ + if((dxw.dwFlags3 & GDIEMULATEDC) && dxw.IsFullScreen() && dxw.IsDesktop(hwnd)){ + OutTraceDW("GDI.EndPaint(GDIEMULATEDC): hwnd=%x\n", hwnd); ret=dxw.ReleaseEmulatedDC(hwnd); - ret=(*pEndPaint)(hwnd, lpPaint); - OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret); + ret=(*pEndPaint)(hwnd, lpPaint); // useful ???? seems not .... if(!ret) OutTraceE("GDI.EndPaint ERROR: err=%d at %d\n", GetLastError(), __LINE__); return ret; } diff --git a/dll/winmm.cpp b/dll/winmm.cpp index e11d78e..3ba6458 100644 --- a/dll/winmm.cpp +++ b/dll/winmm.cpp @@ -49,9 +49,11 @@ DWORD WINAPI exttimeGetTime(void) MMRESULT WINAPI exttimeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent) { MMRESULT res; - //uDelay = uDelay * 8; + UINT NewDelay; OutTraceDW("timeSetEvent: Delay=%d Resolution=%d Event=%x\n", uDelay, uResolution, fuEvent); - res=(*ptimeSetEvent)(uDelay, uResolution, lpTimeProc, dwUser, fuEvent); + NewDelay = dxw.StretchTime(uDelay); + res=(*ptimeSetEvent)(NewDelay, uResolution, lpTimeProc, dwUser, fuEvent); + if(res) dxw.PushTimer(res, uDelay, uResolution, lpTimeProc, dwUser, fuEvent); OutTraceDW("timeSetEvent: ret=%x\n", res); return res; } @@ -61,6 +63,7 @@ MMRESULT WINAPI exttimeKillEvent(UINT uTimerID) MMRESULT res; OutTraceDW("timeKillEvent: TimerID=%x\n", uTimerID); res=(*ptimeKillEvent)(uTimerID); + if(res==TIMERR_NOERROR) dxw.PopTimer(uTimerID); OutTraceDW("timeKillEvent: ret=%x\n", res); return res; } diff --git a/host/Resource.h b/host/Resource.h index db1583a..23b26e5 100644 --- a/host/Resource.h +++ b/host/Resource.h @@ -46,6 +46,7 @@ #define IDC_DIRECTX11 307 #define IDC_FILE 1000 #define IDC_OPEN 1001 +#define IDC_MODULE 1002 #define IDC_STATUSINFO 1005 #define IDC_VERSION 1006 #define IDC_UNNOTIFY 1007 @@ -135,6 +136,7 @@ #define IDC_FORCEWINRESIZE 1096 #define IDC_FORCE16BPP 1097 #define IDC_FORCEHOOKOPENGL 1098 +#define IDC_LISTRES 1098 #define IDC_DESKTOPCENTER 1099 #define IDC_COORDINATES 1100 #define IDC_SUPPRESSD3DEXT 1101 @@ -181,6 +183,7 @@ #define IDC_NOALPHACHANNEL 1143 #define IDC_SUPPRESSCHILD 1144 #define IDC_FIXREFCOUNTER 1145 +#define IDC_LIMITSCREENRES 1145 #define IDC_SHOWTIMESTRETCH 1146 #define IDC_ZBUFFERALWAYS 1147 #define IDC_ZBUFFER0CLEAN 1148 @@ -196,6 +199,7 @@ #define IDC_OUTREGISTRY 1159 #define IDC_ADDPROXYLIBS 1160 #define IDC_INTERCEPTRDTSC 1161 +#define IDC_NOFILLRECT 1162 #define ID_MODIFY 32771 #define ID_DELETE 32772 #define ID_ADD 32773 @@ -249,7 +253,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 159 #define _APS_NEXT_COMMAND_VALUE 32830 -#define _APS_NEXT_CONTROL_VALUE 1095 +#define _APS_NEXT_CONTROL_VALUE 1099 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/host/TabDebug.cpp b/host/TabDebug.cpp index 3b7f52d..ea57c1d 100644 --- a/host/TabDebug.cpp +++ b/host/TabDebug.cpp @@ -39,6 +39,7 @@ void CTabDebug::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_NODDRAWBLT, cTarget->m_NoDDRAWBlt); DDX_Check(pDX, IDC_NODDRAWFLIP, cTarget->m_NoDDRAWFlip); DDX_Check(pDX, IDC_NOGDIBLT, cTarget->m_NoGDIBlt); + DDX_Check(pDX, IDC_NOFILLRECT, cTarget->m_NoFillRect); DDX_Check(pDX, IDC_EMULATEREGISTRY, cTarget->m_EmulateRegistry); DDX_Check(pDX, IDC_ZBUFFERALWAYS, cTarget->m_ZBufferAlways); } @@ -53,17 +54,3 @@ END_MESSAGE_MAP() // CTabCompat message handlers -//BOOL CTabCompat::OnInitDialog() -//{ -// AfxEnableControlContainer(); -// CListBox *List; -// CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent())); -// int i; -// List=(CListBox *)this->GetDlgItem(IDC_LISTFAKE); -// List->ResetContent(); -// for(i=0; i<9; i++) List->AddString(WinVersions[i].sName); -// List->SetCurSel(cTarget->m_FakeVersion); -// CDialog::OnInitDialog(); -// return TRUE; -//} - diff --git a/host/TabProgram.cpp b/host/TabProgram.cpp index bc3f919..3f679d2 100644 --- a/host/TabProgram.cpp +++ b/host/TabProgram.cpp @@ -30,6 +30,7 @@ void CTabProgram::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_FILE, cTarget->m_File); DDX_Text(pDX, IDC_FILE, cTarget->m_FilePath); DDX_Text(pDX, IDC_TITLE, cTarget->m_Title); + DDX_Text(pDX, IDC_MODULE, cTarget->m_Module); DDX_Check(pDX, IDC_UNNOTIFY, cTarget->m_UnNotify); DDX_Check(pDX, IDC_WINDOWIZE, cTarget->m_Windowize); DDX_Check(pDX, IDC_HOOKDLLS, cTarget->m_HookDLLs); diff --git a/host/TabWindow.cpp b/host/TabWindow.cpp index af3e130..be75b33 100644 --- a/host/TabWindow.cpp +++ b/host/TabWindow.cpp @@ -54,15 +54,39 @@ void CTabWindow::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_USERGB565, cTarget->m_UseRGB565); DDX_Check(pDX, IDC_LOCKSYSCOLORS, cTarget->m_LockSysColors); + // screen resolution management + DDX_Check(pDX, IDC_LIMITSCREENRES, cTarget->m_LimitScreenRes); + DDX_LBIndex(pDX, IDC_LISTRES, cTarget->m_MaxScreenRes); + // 3D management DDX_Check(pDX, IDC_WIREFRAME, cTarget->m_WireFrame); DDX_Check(pDX, IDC_DISABLEFOGGING, cTarget->m_DisableFogging); } +static char *Resolutions[]={ + "unlimited", + "320x200", + "400x300", + "640x480", + "800x600", + "1024x768", + "1280x960", + "" // terminator +}; + BOOL CTabWindow::OnInitDialog() { AfxEnableControlContainer(); + + CListBox *List; + CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent())); + int i; + List=(CListBox *)this->GetDlgItem(IDC_LISTRES); + List->ResetContent(); + for(i=0; strlen(Resolutions[i]); i++) List->AddString(Resolutions[i]); + List->SetCurSel(cTarget->m_MaxScreenRes); + CDialog::OnInitDialog(); return TRUE; } @@ -76,3 +100,5 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTabWindow message handlers + + diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp index 583f951..1993abc 100644 --- a/host/TargetDlg.cpp +++ b/host/TargetDlg.cpp @@ -49,6 +49,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_LockSysColors = FALSE; m_ForceYUVtoRGB = FALSE; m_ForceRGBtoYUV = FALSE; + m_LimitScreenRes = FALSE; m_SaveCaps = FALSE; m_SingleProcAffinity = FALSE; m_LimitResources = FALSE; @@ -130,6 +131,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_NoDDRAWBlt = FALSE; m_NoDDRAWFlip = FALSE; m_NoGDIBlt = FALSE; + m_NoFillRect = FALSE; m_AnalyticMode = FALSE; m_NoPaletteUpdate = FALSE; m_WireFrame = FALSE; diff --git a/host/TargetDlg.h b/host/TargetDlg.h index a1705c1..1a6f6b3 100644 --- a/host/TargetDlg.h +++ b/host/TargetDlg.h @@ -113,6 +113,7 @@ public: BOOL m_NoDDRAWBlt; BOOL m_NoDDRAWFlip; BOOL m_NoGDIBlt; + BOOL m_NoFillRect; BOOL m_AnalyticMode; BOOL m_NoPaletteUpdate; BOOL m_LimitResources; @@ -144,6 +145,7 @@ public: BOOL m_Force16BPP; BOOL m_ForceYUVtoRGB; BOOL m_ForceRGBtoYUV; + BOOL m_LimitScreenRes; int m_InitX; int m_InitY; int m_MaxX; @@ -157,6 +159,7 @@ public: int m_MaxFPS; int m_InitTS; int m_FakeVersionId; + int m_MaxScreenRes; //}}AFX_DATA diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index 6b0a4ac..ac4e647 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index ea44755..8573541 100644 --- a/host/dxwndhost.rc +++ b/host/dxwndhost.rc @@ -199,15 +199,18 @@ END // Dialog // -IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 78 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "DXWnd Version Information" FONT 9, "Arial", 400, 0, 0x0 BEGIN ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 LTEXT "",IDC_VERSION,40,10,119,8,SS_NOPREFIX - LTEXT "Copyright (C) 2004-2012 SFB7 GHO",IDC_STATIC,40,25,119,8 + LTEXT "Copyright (C) 2004-2014 SFB7 GHO",IDC_STATIC,40,25,119,8 DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP + LTEXT "thank you also to:",IDC_STATIC,40,40,119,8 + LTEXT "Olly (www.ollydbg.de) for disasm lib",IDC_STATIC,40,50,119,8 + LTEXT "Michael Koch for d3d9 proxy dll",IDC_STATIC,40,60,181,8 END IDD_TARGET DIALOGEX 0, 0, 273, 248 @@ -256,6 +259,8 @@ BEGIN EDITTEXT IDC_FILE,39,31,162,14,ES_AUTOHSCROLL LTEXT "Path:",IDC_STATIC,11,33,22,9 PUSHBUTTON "...",IDC_OPEN,207,31,12,14 + EDITTEXT IDC_MODULE,39,49,161,14,ES_AUTOHSCROLL + LTEXT "Module:",IDC_STATIC,11,52,25,9 LTEXT "Window initial position && size",IDC_STATIC,18,198,115,9 LTEXT "X",IDC_STATIC,18,214,9,9 LTEXT "Y",IDC_STATIC,49,214,9,9 @@ -265,27 +270,27 @@ BEGIN EDITTEXT IDC_POSY,55,210,19,14,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT EDITTEXT IDC_SIZX,85,210,19,14,ES_AUTOHSCROLL,WS_EX_RIGHT EDITTEXT IDC_SIZY,113,210,19,14,ES_AUTOHSCROLL,WS_EX_RIGHT - CONTROL "Do not notify on task switch",IDC_UNNOTIFY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,81,124,10 - CONTROL "Optimize CPU (DirectX1 - 7)",IDC_SAVELOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,117,109,10 - CONTROL "Intercept Alt-F4 key",IDC_HANDLEALTF4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,93,109,10 - CONTROL "Run in Window",IDC_WINDOWIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,105,124,10 - GROUPBOX "Generic",IDC_STATIC,7,56,286,106 - CONTROL "No banner",IDC_NOBANNER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,81,108,10 - CONTROL "use DLL Injection",IDC_STARTDEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,93,100,10 - CONTROL "Remap Client Rect",IDC_CLIENTREMAPPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,69,115,10 - CONTROL "Hook all DLLs",IDC_HOOKDLLS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,117,124,10 - CONTROL "Hook enabled",IDC_HOOKENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,69,124,10 - CONTROL "X,Y coordinates",IDC_COORDINATES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,170,190,95,10 - CONTROL "Desktop center",IDC_DESKTOPCENTER,"Button",BS_AUTORADIOBUTTON,170,200,95,10 - CONTROL "Desktop work area",IDC_DESKTOPWORKAREA,"Button",BS_AUTORADIOBUTTON,170,210,95,10 - CONTROL "Desktop",IDC_DESKTOPFULL,"Button",BS_AUTORADIOBUTTON,170,220,95,10 - CONTROL "Hook child WindowProc",IDC_HOOKCHILDWIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,105,104,10 - CONTROL "Fullscreen only",IDC_FULLSCREENONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,129,114,10 - CONTROL "Filter offending messages",IDC_FILTERMESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,141,114,10 - CONTROL "Peek all messages in queue",IDC_PEEKALLMESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,141,114,10 - GROUPBOX "Position",IDC_STATIC,7,168,286,66 - CONTROL "Keep aspect ratio",IDC_KEEPASPECTRATIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,179,115,10 - CONTROL "Hook OpenGL",IDC_HOOKOPENGL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,129,115,10 + CONTROL "Do not notify on task switch",IDC_UNNOTIFY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,93,124,10 + CONTROL "Optimize CPU (DirectX1 - 7)",IDC_SAVELOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,129,109,10 + CONTROL "Intercept Alt-F4 key",IDC_HANDLEALTF4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,105,109,10 + CONTROL "Run in Window",IDC_WINDOWIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,117,124,10 + GROUPBOX "Generic",IDC_STATIC,7,65,286,106 + CONTROL "No banner",IDC_NOBANNER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,93,108,10 + CONTROL "use DLL Injection",IDC_STARTDEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,105,100,10 + CONTROL "Remap Client Rect",IDC_CLIENTREMAPPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,81,115,10 + CONTROL "Hook all DLLs",IDC_HOOKDLLS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,129,124,10 + CONTROL "Hook enabled",IDC_HOOKENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,81,124,10 + CONTROL "X,Y coordinates",IDC_COORDINATES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,170,184,95,10 + CONTROL "Desktop center",IDC_DESKTOPCENTER,"Button",BS_AUTORADIOBUTTON,170,194,95,10 + CONTROL "Desktop work area",IDC_DESKTOPWORKAREA,"Button",BS_AUTORADIOBUTTON,170,204,95,10 + CONTROL "Desktop",IDC_DESKTOPFULL,"Button",BS_AUTORADIOBUTTON,170,214,95,10 + CONTROL "Hook child WindowProc",IDC_HOOKCHILDWIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,117,104,10 + CONTROL "Fullscreen only",IDC_FULLSCREENONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,141,114,10 + CONTROL "Filter offending messages",IDC_FILTERMESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,153,114,10 + CONTROL "Peek all messages in queue",IDC_PEEKALLMESSAGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,153,114,10 + GROUPBOX "Position",IDC_STATIC,7,172,286,56 + CONTROL "Keep aspect ratio",IDC_KEEPASPECTRATIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,185,115,10 + CONTROL "Hook OpenGL",IDC_HOOKOPENGL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,141,115,10 END IDD_TAB_LOG DIALOGEX 0, 0, 300, 240 @@ -423,12 +428,15 @@ BEGIN CONTROL "Simulate 16BPP desktop",IDC_INIT16BPP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,28,115,10 CONTROL "Disable setting gamma ramp",IDC_DISABLEGAMMARAMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,88,119,10 CONTROL "Forces 16BPP desktop",IDC_FORCE16BPP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,40,119,10 - CONTROL "3D Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,136,96,10 + CONTROL "3D Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,206,96,10 CONTROL "Simulate BW monitor",IDC_BLACKWHITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,52,96,10 CONTROL "Set 16BPP RGB565 encoding",IDC_USERGB565,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,64,126,9 CONTROL "Lock Sys Colors",IDC_LOCKSYSCOLORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,76,126,9 - GROUPBOX "3D effects",IDC_STATIC,149,122,144,111 - CONTROL "Disable Fogging",IDC_DISABLEFOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,147,96,10 + GROUPBOX "3D effects",IDC_STATIC,149,191,144,43 + CONTROL "Disable Fogging",IDC_DISABLEFOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,217,96,10 + GROUPBOX "Screen resolution",IDC_STATIC,149,123,144,64 + CONTROL "Limit resolution:",IDC_LIMITSCREENRES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,136,63,10 + LISTBOX IDC_LISTRES,226,133,57,26,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP END IDD_TAB_EMPTY DIALOGEX 0, 0, 300, 240 @@ -497,6 +505,7 @@ BEGIN GROUPBOX "Visual flags",IDC_STATIC,153,7,140,139 CONTROL "Emulate Registry",IDC_EMULATEREGISTRY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,84,124,10 CONTROL "Force D3DCMP_ALWAYS setting ",IDC_ZBUFFERALWAYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,164,127,10 + CONTROL "Suppress FillRect",IDC_NOFILLRECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,160,60,127,10 END IDD_PALETTE DIALOGEX 0, 0, 169, 167 @@ -559,7 +568,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 228 TOPMARGIN, 7 - BOTTOMMARGIN, 48 + BOTTOMMARGIN, 71 END IDD_TARGET, DIALOG diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 41d0bf3..ec505eb 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 60df71f..1454047 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -130,13 +130,13 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) case 2: t->flags |= LOCKEDSURFACE; break; case 3: t->flags |= EMULATESURFACE; break; } - t->flags2 &= ~HOOKGDI; + t->flags2 &= ~GDISTRETCHED; t->flags &= ~MAPGDITOPRIMARY; - t->flags3 &= ~EMULATEDC; + t->flags3 &= ~GDIEMULATEDC; switch(dlg->m_DCEmulationMode){ case 0: break; - case 1: t->flags2 |= HOOKGDI; break; - case 2: t->flags3 |= EMULATEDC; break; + case 1: t->flags2 |= GDISTRETCHED; break; + case 2: t->flags3 |= GDIEMULATEDC; break; case 3: t->flags |= MAPGDITOPRIMARY; break; } if(dlg->m_HookDI) t->flags |= HOOKDI; @@ -180,6 +180,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_LockSysColors) t->flags3 |= LOCKSYSCOLORS; if(dlg->m_ForceYUVtoRGB) t->flags3 |= YUV2RGB; if(dlg->m_ForceRGBtoYUV) t->flags3 |= RGB2YUV; + if(dlg->m_LimitScreenRes) t->flags4 |= LIMITSCREENRES; if(dlg->m_SaveCaps) t->flags3 |= SAVECAPS; if(dlg->m_SingleProcAffinity) t->flags3 |= SINGLEPROCAFFINITY; if(dlg->m_SaveLoad) t->flags |= SAVELOAD; @@ -241,6 +242,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_NoDDRAWBlt) t->flags3 |= NODDRAWBLT; if(dlg->m_NoDDRAWFlip) t->flags3 |= NODDRAWFLIP; if(dlg->m_NoGDIBlt) t->flags3 |= NOGDIBLT; + if(dlg->m_NoFillRect) t->flags4 |= NOFILLRECT; if(dlg->m_AnalyticMode) t->flags3 |= ANALYTICMODE; t->initx = dlg->m_InitX; t->inity = dlg->m_InitY; @@ -255,6 +257,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) t->MaxFPS = dlg->m_MaxFPS; t->InitTS = dlg->m_InitTS-8; t->FakeVersionId = dlg->m_FakeVersionId; + t->MaxScreenRes = dlg->m_MaxScreenRes; strcpy_s(t->module, sizeof(t->module), dlg->m_Module); strcpy_s(t->OpenGLLib, sizeof(t->OpenGLLib), dlg->m_OpenGLLib); } @@ -284,8 +287,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) if(t->flags & EMULATESURFACE) dlg->m_DxEmulationMode = 3; dlg->m_DCEmulationMode = 0; - if(t->flags2 & HOOKGDI) dlg->m_DCEmulationMode = 1; - if(t->flags3 & EMULATEDC) dlg->m_DCEmulationMode = 2; + if(t->flags2 & GDISTRETCHED) dlg->m_DCEmulationMode = 1; + if(t->flags3 & GDIEMULATEDC) dlg->m_DCEmulationMode = 2; if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3; dlg->m_HookDI = t->flags & HOOKDI ? 1 : 0; @@ -318,6 +321,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_LockSysColors = t->flags3 & LOCKSYSCOLORS ? 1 : 0; dlg->m_ForceRGBtoYUV = t->flags3 & RGB2YUV ? 1 : 0; dlg->m_ForceYUVtoRGB = t->flags3 & YUV2RGB ? 1 : 0; + dlg->m_LimitScreenRes = t->flags4 & LIMITSCREENRES ? 1 : 0; dlg->m_SaveCaps = t->flags3 & SAVECAPS ? 1 : 0; dlg->m_SingleProcAffinity = t->flags3 & SINGLEPROCAFFINITY ? 1 : 0; dlg->m_LimitResources = t->flags2 & LIMITRESOURCES ? 1 : 0; @@ -390,6 +394,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_NoDDRAWBlt = t->flags3 & NODDRAWBLT ? 1 : 0; dlg->m_NoDDRAWFlip = t->flags3 & NODDRAWFLIP ? 1 : 0; dlg->m_NoGDIBlt = t->flags3 & NOGDIBLT ? 1 : 0; + dlg->m_NoFillRect = t->flags4 & NOFILLRECT ? 1 : 0; dlg->m_AnalyticMode = t->flags3 & ANALYTICMODE ? 1 : 0; dlg->m_InitX = t->initx; dlg->m_InitY = t->inity; @@ -404,6 +409,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_MaxFPS = t->MaxFPS; dlg->m_InitTS = t->InitTS+8; dlg->m_FakeVersionId = t->FakeVersionId; + dlg->m_MaxScreenRes = t->MaxScreenRes; } static void SaveConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPath) @@ -474,6 +480,13 @@ static void SaveConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitP sprintf_s(key, sizeof(key), "initts%i", i); sprintf_s(val, sizeof(val), "%i", TargetMap->InitTS); WritePrivateProfileString("target", key, val, InitPath); + + sprintf_s(key, sizeof(key), "winver%i", i); + sprintf_s(val, sizeof(val), "%i", TargetMap->FakeVersionId); + WritePrivateProfileString("target", key, val, InitPath); + sprintf_s(key, sizeof(key), "maxres%i", i); + sprintf_s(val, sizeof(val), "%i", TargetMap->MaxScreenRes); + WritePrivateProfileString("target", key, val, InitPath); } static void ClearTarget(int i, char *InitPath) @@ -519,6 +532,11 @@ static void ClearTarget(int i, char *InitPath) WritePrivateProfileString("target", key, 0, InitPath); sprintf_s(key, sizeof(key), "initts%i", i); WritePrivateProfileString("target", key, 0, InitPath); + + sprintf_s(key, sizeof(key), "winver%i", i); + WritePrivateProfileString("target", key, 0, InitPath); + sprintf_s(key, sizeof(key), "maxres%i", i); + WritePrivateProfileString("target", key, 0, InitPath); } static int LoadConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPath) @@ -584,12 +602,17 @@ static int LoadConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPa sprintf_s(key, sizeof(key), "initts%i", i); TargetMap->InitTS = GetPrivateProfileInt("target", key, 0, InitPath); + sprintf_s(key, sizeof(key), "winver%i", i); + TargetMap->FakeVersionId = GetPrivateProfileInt("target", key, 0, InitPath); + sprintf_s(key, sizeof(key), "maxres%i", i); + TargetMap->MaxScreenRes = GetPrivateProfileInt("target", key, 0, InitPath); + if (!gbDebug){ // clear debug flags TargetMap->flags &= ~(0); TargetMap->flags2 &= ~(FULLRECTBLT); TargetMap->flags3 &= ~(YUV2RGB|RGB2YUV|SURFACEWARN|ANALYTICMODE|NODDRAWBLT|NODDRAWFLIP|NOGDIBLT); - TargetMap->flags4 &= ~(0); + TargetMap->flags4 &= ~(NOFILLRECT); } return TRUE; }