diff --git a/inc/hook.h b/inc/hook.h index 12303d0..3f3cb82 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -9,7 +9,7 @@ #define SKIP_HOOK3 0x00000002l typedef struct HOOKLISTDATA { char function_name[32]; PROC new_function; PROC* function; DWORD flags; } HOOKLISTDATA; -typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[27]; } HOOKLIST; +typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[28]; } HOOKLIST; typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT); typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*); @@ -44,6 +44,7 @@ typedef int (WINAPI* SETDIBITSTODEVICEPROC)( typedef int (WINAPI* STRETCHDIBITSPROC)( HDC, int, int, int, int, int, int, int, int, const VOID*, const BITMAPINFO*, UINT, DWORD); +typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd); typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD); typedef BOOL(WINAPI* PEEKMESSAGEAPROC)(LPMSG, HWND, UINT, UINT, UINT); @@ -85,6 +86,7 @@ extern GETFOREGROUNDWINDOWPROC real_GetForegroundWindow; extern STRETCHBLTPROC real_StretchBlt; extern SETDIBITSTODEVICEPROC real_SetDIBitsToDevice; extern STRETCHDIBITSPROC real_StretchDIBits; +extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow; extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA; extern PEEKMESSAGEAPROC real_PeekMessageA; extern GETDEVICECAPSPROC real_GetDeviceCaps; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index 709f53a..009cac8 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -29,6 +29,7 @@ int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UI BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow); HWND WINAPI fake_GetTopWindow(HWND hWnd); HWND WINAPI fake_GetForegroundWindow(void); +BOOL WINAPI fake_SetForegroundWindow(HWND hWnd); HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId); BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg); int WINAPI fake_GetDeviceCaps(HDC hdc, int index); diff --git a/src/hook.c b/src/hook.c index 4b4a4e5..3cf9cae 100644 --- a/src/hook.c +++ b/src/hook.c @@ -45,6 +45,7 @@ GETFOREGROUNDWINDOWPROC real_GetForegroundWindow = GetForegroundWindow; STRETCHBLTPROC real_StretchBlt = StretchBlt; SETDIBITSTODEVICEPROC real_SetDIBitsToDevice = SetDIBitsToDevice; STRETCHDIBITSPROC real_StretchDIBits = StretchDIBits; +SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow; SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA; PEEKMESSAGEAPROC real_PeekMessageA = PeekMessageA; GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps; @@ -87,6 +88,7 @@ static HOOKLIST g_hooks[] = { "GetTopWindow", (PROC)fake_GetTopWindow, (PROC*)&real_GetTopWindow, 0 }, { "GetForegroundWindow", (PROC)fake_GetForegroundWindow, (PROC*)&real_GetForegroundWindow, 0 }, { "PeekMessageA", (PROC)fake_PeekMessageA, (PROC*)&real_PeekMessageA, 0 }, + { "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 }, { "", NULL, NULL, 0 } } }, diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 37222a9..9c94b8a 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -558,6 +558,16 @@ HWND WINAPI fake_GetForegroundWindow() return real_GetForegroundWindow(); } +BOOL WINAPI fake_SetForegroundWindow(HWND hWnd) +{ + if (g_ddraw && g_ddraw->bnet_active) + { + return TRUE; + } + + return real_SetForegroundWindow(hWnd); +} + HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId) { if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod)