1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-25 01:57:47 +01:00

hook SetWindowsHookExA

This commit is contained in:
FunkyFr3sh 2021-06-06 19:03:38 +02:00
parent 2214751089
commit 242c40a197
4 changed files with 16 additions and 0 deletions

View File

@ -30,6 +30,7 @@ typedef BOOL (WINAPI* ENABLEWINDOWPROC)(HWND, BOOL);
typedef HWND (WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); typedef HWND (WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
typedef BOOL (WINAPI* DESTROYWINDOWPROC)(HWND); typedef BOOL (WINAPI* DESTROYWINDOWPROC)(HWND);
typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT); typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT);
typedef HHOOK (WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int); typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
typedef HMODULE (WINAPI* LOADLIBRARYAPROC)(LPCSTR); typedef HMODULE (WINAPI* LOADLIBRARYAPROC)(LPCSTR);
typedef HMODULE (WINAPI* LOADLIBRARYWPROC)(LPCWSTR); typedef HMODULE (WINAPI* LOADLIBRARYWPROC)(LPCWSTR);
@ -58,6 +59,7 @@ extern ENABLEWINDOWPROC real_EnableWindow;
extern CREATEWINDOWEXAPROC real_CreateWindowExA; extern CREATEWINDOWEXAPROC real_CreateWindowExA;
extern DESTROYWINDOWPROC real_DestroyWindow; extern DESTROYWINDOWPROC real_DestroyWindow;
extern MAPWINDOWPOINTSPROC real_MapWindowPoints; extern MAPWINDOWPOINTSPROC real_MapWindowPoints;
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
extern GETDEVICECAPSPROC real_GetDeviceCaps; extern GETDEVICECAPSPROC real_GetDeviceCaps;
extern LOADLIBRARYAPROC real_LoadLibraryA; extern LOADLIBRARYAPROC real_LoadLibraryA;
extern LOADLIBRARYWPROC real_LoadLibraryW; extern LOADLIBRARYWPROC real_LoadLibraryW;

View File

@ -26,6 +26,7 @@ LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex);
BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable); BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable);
BOOL WINAPI fake_DestroyWindow(HWND hWnd); BOOL WINAPI fake_DestroyWindow(HWND hWnd);
int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints); int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints);
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
int WINAPI fake_GetDeviceCaps(HDC hdc, int index); int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName); HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName); HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);

View File

@ -38,6 +38,7 @@ ENABLEWINDOWPROC real_EnableWindow = EnableWindow;
CREATEWINDOWEXAPROC real_CreateWindowExA = CreateWindowExA; CREATEWINDOWEXAPROC real_CreateWindowExA = CreateWindowExA;
DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow; DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow;
MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints; MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints;
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps; GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA; LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA;
LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW; LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW;
@ -439,6 +440,7 @@ void hook_early_init()
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateW", (PROC)fake_DirectInputCreateW); hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateW", (PROC)fake_DirectInputCreateW);
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateEx", (PROC)fake_DirectInputCreateEx); hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateEx", (PROC)fake_DirectInputCreateEx);
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create); hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
hook_patch_iat(GetModuleHandle("AcGenral"), FALSE, "user32.dll", "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA);
} }
void hook_exit() void hook_exit()
@ -491,4 +493,5 @@ void hook_exit()
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateW", (PROC)fake_DirectInputCreateW); hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateW", (PROC)fake_DirectInputCreateW);
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateEx", (PROC)fake_DirectInputCreateEx); hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateEx", (PROC)fake_DirectInputCreateEx);
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create); hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
hook_patch_iat(GetModuleHandle("AcGenral"), TRUE, "user32.dll", "SetWindowsHookExA", (PROC)fake_SetWindowsHookExA);
} }

View File

@ -364,6 +364,16 @@ int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UI
return real_MapWindowPoints(hWndFrom, hWndTo, lpPoints, cPoints); return real_MapWindowPoints(hWndFrom, hWndTo, lpPoints, cPoints);
} }
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)
{
if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod)
{
return NULL;
}
return real_SetWindowsHookExA(idHook, lpfn, hmod, dwThreadId);
}
int WINAPI fake_GetDeviceCaps(HDC hdc, int index) int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
{ {
if (g_ddraw && if (g_ddraw &&