From ab2d86f983ecd8f7d015b66ff51834250ace95ed Mon Sep 17 00:00:00 2001 From: FunkyFr3sh <cc.red.alert.1@googlemail.com> Date: Thu, 16 Jan 2025 06:29:04 +0100 Subject: [PATCH] don't use DisableProcessWindowsGhosting, it got too bad side-effects --- inc/dllmain.h | 1 - src/dllmain.c | 5 ----- src/winapi_hooks.c | 8 ++++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/inc/dllmain.h b/inc/dllmain.h index 13039f8..f7e028b 100644 --- a/inc/dllmain.h +++ b/inc/dllmain.h @@ -31,7 +31,6 @@ typedef BOOL(__stdcall* SETPROCESSDPIAWARENESSCONTEXTPROC)(DPI_AWARENESS_CONTEXT #if (_WIN32_WINNT < _WIN32_WINNT_WINXP) #define SetThreadExecutionState(a) -#define DisableProcessWindowsGhosting() #endif #endif diff --git a/src/dllmain.c b/src/dllmain.c index e596372..8832177 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -57,11 +57,6 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) g_dbg_exception_handle = add_handler(1, (PVECTORED_EXCEPTION_HANDLER)dbg_vectored_exception_handler); } - if (g_config.darkcolony_hack) - { - DisableProcessWindowsGhosting(); - } - char buf[1024]; if (GetEnvironmentVariable("__COMPAT_LAYER", buf, sizeof(buf))) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index c44cd3a..33655c1 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -780,6 +780,14 @@ BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wM BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) { + if (g_config.darkcolony_hack && !hWnd) + { + hWnd = g_ddraw.hwnd; + + MSG msg; + real_PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE); + } + if (g_config.limiter_type == LIMIT_PEEKMESSAGE && g_ddraw.ticks_limiter.tick_length > 0 && InterlockedExchange(&g_ddraw.render.screen_updated, FALSE))