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

hook SetForegroundWindow for profile links

This commit is contained in:
FunkyFr3sh 2023-04-09 20:06:51 +02:00
parent f86ad29835
commit 766e4b434c
4 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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 }
}
},

View File

@ -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)