hook GetKeyState and GetAsyncKeyState for infantry
This commit is contained in:
parent
c52544ad6f
commit
871ccbf196
6 changed files with 35 additions and 3 deletions
|
@ -49,6 +49,8 @@ SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow;
|
|||
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
|
||||
PEEKMESSAGEAPROC real_PeekMessageA = PeekMessageA;
|
||||
GETMESSAGEAPROC real_GetMessageA = GetMessageA;
|
||||
GETKEYSTATEPROC real_GetKeyState = GetKeyState;
|
||||
GETASYNCKEYSTATEPROC real_GetAsyncKeyState = GetAsyncKeyState;
|
||||
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
|
||||
CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA;
|
||||
CREATEFONTAPROC real_CreateFontA = CreateFontA;
|
||||
|
@ -93,6 +95,8 @@ HOOKLIST g_hook_hooklist[] =
|
|||
{ "GetForegroundWindow", (PROC)fake_GetForegroundWindow, (PROC*)&real_GetForegroundWindow, 0 },
|
||||
{ "PeekMessageA", (PROC)fake_PeekMessageA, (PROC*)&real_PeekMessageA, 0 },
|
||||
{ "GetMessageA", (PROC)fake_GetMessageA, (PROC*)&real_GetMessageA, 0 },
|
||||
{ "GetKeyState", (PROC)fake_GetKeyState, (PROC*)&real_GetKeyState, 0 },
|
||||
{ "GetAsyncKeyState", (PROC)fake_GetAsyncKeyState, (PROC*)&real_GetAsyncKeyState, 0 },
|
||||
{ "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 },
|
||||
{ "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA, (PROC*)&real_SetWindowsHookExA, 0 },
|
||||
{ "", NULL, NULL, 0 }
|
||||
|
|
|
@ -716,6 +716,28 @@ BOOL WINAPI fake_PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT w
|
|||
return result;
|
||||
}
|
||||
|
||||
SHORT WINAPI fake_GetKeyState(int nVirtKey)
|
||||
{
|
||||
if (g_config.infantryhack && g_ddraw && g_ddraw->hwnd)
|
||||
{
|
||||
if (real_GetForegroundWindow() != g_ddraw->hwnd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return GetKeyState(nVirtKey);
|
||||
}
|
||||
|
||||
SHORT WINAPI fake_GetAsyncKeyState(int vKey)
|
||||
{
|
||||
if (g_config.infantryhack && g_ddraw && g_ddraw->hwnd)
|
||||
{
|
||||
if (real_GetForegroundWindow() != g_ddraw->hwnd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return GetAsyncKeyState(vKey);
|
||||
}
|
||||
|
||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
|
||||
{
|
||||
if (g_ddraw &&
|
||||
|
|
|
@ -667,7 +667,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
{
|
||||
/* let it pass through once (tiberian sun) */
|
||||
static BOOL one_time;
|
||||
|
||||
|
||||
if (wParam && !one_time && g_config.tshack)
|
||||
{
|
||||
one_time = TRUE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue