mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
#251 hook GetMessage for Enemy Infestation
This commit is contained in:
parent
43aa290d1e
commit
24a73ccc6d
@ -45,6 +45,7 @@ typedef struct CNCDDRAWCONFIG
|
|||||||
int resolutions;
|
int resolutions;
|
||||||
int fixchilds;
|
int fixchilds;
|
||||||
BOOL hook_peekmessage;
|
BOOL hook_peekmessage;
|
||||||
|
BOOL hook_getmessage;
|
||||||
|
|
||||||
/* Undocumented settings */
|
/* Undocumented settings */
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ typedef int (WINAPI* STRETCHDIBITSPROC)(
|
|||||||
typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd);
|
typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd);
|
||||||
typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
|
typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
|
||||||
typedef BOOL(WINAPI* PEEKMESSAGEAPROC)(LPMSG, HWND, UINT, UINT, UINT);
|
typedef BOOL(WINAPI* PEEKMESSAGEAPROC)(LPMSG, HWND, UINT, UINT, UINT);
|
||||||
|
typedef BOOL(WINAPI* GETMESSAGEAPROC)(LPMSG, HWND, UINT, UINT);
|
||||||
|
|
||||||
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
|
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
|
||||||
typedef HFONT(WINAPI* CREATEFONTINDIRECTAPROC)(CONST LOGFONT*);
|
typedef HFONT(WINAPI* CREATEFONTINDIRECTAPROC)(CONST LOGFONT*);
|
||||||
@ -92,6 +92,7 @@ extern STRETCHDIBITSPROC real_StretchDIBits;
|
|||||||
extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow;
|
extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow;
|
||||||
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
|
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
|
||||||
extern PEEKMESSAGEAPROC real_PeekMessageA;
|
extern PEEKMESSAGEAPROC real_PeekMessageA;
|
||||||
|
extern GETMESSAGEAPROC real_GetMessageA;
|
||||||
extern GETDEVICECAPSPROC real_GetDeviceCaps;
|
extern GETDEVICECAPSPROC real_GetDeviceCaps;
|
||||||
extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA;
|
extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA;
|
||||||
extern CREATEFONTAPROC real_CreateFontA;
|
extern CREATEFONTAPROC real_CreateFontA;
|
||||||
|
@ -32,6 +32,7 @@ HWND WINAPI fake_GetForegroundWindow(void);
|
|||||||
BOOL WINAPI fake_SetForegroundWindow(HWND hWnd);
|
BOOL WINAPI fake_SetForegroundWindow(HWND hWnd);
|
||||||
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
|
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);
|
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
|
||||||
|
BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
|
||||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||||
|
|
||||||
BOOL WINAPI fake_StretchBlt(
|
BOOL WINAPI fake_StretchBlt(
|
||||||
|
@ -62,6 +62,7 @@ void cfg_load()
|
|||||||
GET_INT(g_config.resolutions, "resolutions", RESLIST_NORMAL);
|
GET_INT(g_config.resolutions, "resolutions", RESLIST_NORMAL);
|
||||||
GET_INT(g_config.fixchilds, "fixchilds", FIX_CHILDS_DETECT_PAINT);
|
GET_INT(g_config.fixchilds, "fixchilds", FIX_CHILDS_DETECT_PAINT);
|
||||||
GET_BOOL(g_config.hook_peekmessage, "hook_peekmessage", FALSE);
|
GET_BOOL(g_config.hook_peekmessage, "hook_peekmessage", FALSE);
|
||||||
|
GET_BOOL(g_config.hook_getmessage, "hook_getmessage", FALSE);
|
||||||
|
|
||||||
/* Undocumented settings */
|
/* Undocumented settings */
|
||||||
|
|
||||||
@ -264,8 +265,9 @@ static void cfg_create_ini()
|
|||||||
"; Note: Disables upscaling if a child window was detected (to ensure the game is fully playable, may look weird though)\n"
|
"; Note: Disables upscaling if a child window was detected (to ensure the game is fully playable, may look weird though)\n"
|
||||||
"fixchilds=2\n"
|
"fixchilds=2\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Enable the following setting if your cursor doesn't work properly when upscaling is enabled\n"
|
"; Enable one of the following settings if your cursor doesn't work properly when upscaling is enabled\n"
|
||||||
"hook_peekmessage=false\n"
|
"hook_peekmessage=false\n"
|
||||||
|
"hook_getmessage=false\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"; Undocumented settings - You may or may not change these (You should rather focus on the settings above)\n"
|
"; Undocumented settings - You may or may not change these (You should rather focus on the settings above)\n"
|
||||||
|
@ -47,6 +47,7 @@ STRETCHDIBITSPROC real_StretchDIBits = StretchDIBits;
|
|||||||
SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow;
|
SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow;
|
||||||
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
|
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
|
||||||
PEEKMESSAGEAPROC real_PeekMessageA = PeekMessageA;
|
PEEKMESSAGEAPROC real_PeekMessageA = PeekMessageA;
|
||||||
|
GETMESSAGEAPROC real_GetMessageA = GetMessageA;
|
||||||
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
|
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
|
||||||
CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA;
|
CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA;
|
||||||
CREATEFONTAPROC real_CreateFontA = CreateFontA;
|
CREATEFONTAPROC real_CreateFontA = CreateFontA;
|
||||||
@ -90,6 +91,7 @@ HOOKLIST g_hook_hooklist[] =
|
|||||||
{ "GetTopWindow", (PROC)fake_GetTopWindow, (PROC*)&real_GetTopWindow, 0 },
|
{ "GetTopWindow", (PROC)fake_GetTopWindow, (PROC*)&real_GetTopWindow, 0 },
|
||||||
{ "GetForegroundWindow", (PROC)fake_GetForegroundWindow, (PROC*)&real_GetForegroundWindow, 0 },
|
{ "GetForegroundWindow", (PROC)fake_GetForegroundWindow, (PROC*)&real_GetForegroundWindow, 0 },
|
||||||
{ "PeekMessageA", (PROC)fake_PeekMessageA, (PROC*)&real_PeekMessageA, 0 },
|
{ "PeekMessageA", (PROC)fake_PeekMessageA, (PROC*)&real_PeekMessageA, 0 },
|
||||||
|
{ "GetMessageA", (PROC)fake_GetMessageA, (PROC*)&real_GetMessageA, 0 },
|
||||||
{ "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 },
|
{ "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 },
|
||||||
{ "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA, (PROC*)&real_SetWindowsHookExA, 0 },
|
{ "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA, (PROC*)&real_SetWindowsHookExA, 0 },
|
||||||
{ "", NULL, NULL, 0 }
|
{ "", NULL, NULL, 0 }
|
||||||
|
@ -593,11 +593,9 @@ HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, D
|
|||||||
return real_SetWindowsHookExA(idHook, lpfn, hmod, dwThreadId);
|
return real_SetWindowsHookExA(idHook, lpfn, hmod, dwThreadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
|
BOOL HandleMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
|
||||||
{
|
{
|
||||||
BOOL result = real_PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
|
if (g_ddraw && g_ddraw->width)
|
||||||
|
|
||||||
if (result && g_ddraw && g_ddraw->width && g_config.hook_peekmessage)
|
|
||||||
{
|
{
|
||||||
switch (lpMsg->message)
|
switch (lpMsg->message)
|
||||||
{
|
{
|
||||||
@ -690,10 +688,30 @@ BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT w
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI fake_GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
|
||||||
|
{
|
||||||
|
BOOL result = real_GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
|
||||||
|
|
||||||
|
if (result && g_config.hook_getmessage)
|
||||||
|
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
|
||||||
|
{
|
||||||
|
BOOL result = real_PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
|
||||||
|
|
||||||
|
if (result && g_config.hook_peekmessage)
|
||||||
|
HandleMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user