1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

don't let messages pass through with peek/getmessage hooks

This commit is contained in:
FunkyFr3sh 2024-09-11 15:47:31 +02:00
parent 2353363e6d
commit a9f0b8f8f5
2 changed files with 20 additions and 9 deletions

View File

@ -612,7 +612,7 @@ HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, D
return result;
}
BOOL HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
void HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
{
if (g_ddraw.ref && g_ddraw.width)
{
@ -645,7 +645,14 @@ BOOL HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
InterlockedExchange((LONG*)&g_ddraw.cursor.y, y);
mouse_lock();
//return FALSE;
if (!wMsgFilterMin &&
!wMsgFilterMax &&
!(wRemoveMsg & (PM_QS_INPUT | PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE)))
{
lpMsg->message = WM_NULL;
break;
}
}
/* fall through for lParam */
}
@ -666,7 +673,13 @@ BOOL HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
if (!g_config.devmode && !g_mouse_locked)
{
// Does not work with 'New Robinson'
//return FALSE;
if (!wMsgFilterMin &&
!wMsgFilterMax &&
!(wRemoveMsg & (PM_QS_INPUT | PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE)))
{
lpMsg->message = WM_NULL;
break;
}
}
if (lpMsg->message == WM_MOUSEWHEEL)
@ -709,11 +722,8 @@ BOOL HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMa
break;
}
}
}
return TRUE;
}
BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
@ -747,7 +757,7 @@ BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wM
if (g_config.hook_getmessage)
{
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, PM_REMOVE);
}
}
@ -785,7 +795,7 @@ BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT w
if (g_config.hook_peekmessage)
{
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
}
}

View File

@ -22,7 +22,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
if (uMsg != WM_MOUSEMOVE && uMsg != WM_NCMOUSEMOVE && uMsg != WM_NCHITTEST && uMsg != WM_SETCURSOR &&
uMsg != WM_KEYUP && uMsg != WM_KEYDOWN && uMsg != WM_CHAR && uMsg != WM_DEADCHAR && uMsg != WM_INPUT &&
uMsg != WM_UNICHAR && uMsg != WM_IME_CHAR && uMsg != WM_IME_KEYDOWN && uMsg != WM_IME_KEYUP && uMsg != WM_TIMER &&
uMsg != WM_D3D9DEVICELOST)
uMsg != WM_D3D9DEVICELOST && uMsg != WM_NULL)
{
TRACE(
" uMsg = %s (%d), wParam = %08X (%d), lParam = %08X (%d, LO=%d HI=%d)\n",
@ -42,6 +42,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
switch (uMsg)
{
case WM_NULL:
case WM_MOVING:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP: