-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlighthook.cpp
60 lines (44 loc) · 1.8 KB
/
lighthook.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <cstdint>
#include <MinHook.h>
class InputHandler_PIUIO {
public:
char pad[0xA0];
uint32_t GameLights[2][33];
};
uintptr_t oSetLightsMappings;
void __fastcall hk_InputHandler_PIUIO_SetLightsMappings(InputHandler_PIUIO* handler) {
(decltype(&hk_InputHandler_PIUIO_SetLightsMappings)(oSetLightsMappings))(handler);
handler->GameLights[0][0] = 4;
handler->GameLights[0][1] = 8;
handler->GameLights[0][2] = 16;
handler->GameLights[0][3] = 32;
handler->GameLights[0][4] = 64;
handler->GameLights[1][0] = 0x40000;
handler->GameLights[1][1] = 0x80000;
handler->GameLights[1][2] = 0x100000;
handler->GameLights[1][3] = 0x200000;
handler->GameLights[1][4] = 0x400000;
}
extern "C" __declspec(dllexport) void HidD_SetFeature() {
}
extern "C" __declspec(dllexport) void HidD_GetAttributes() {
}
extern "C" __declspec(dllexport) void HidD_GetHidGuid() {
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call != DLL_PROCESS_ATTACH)
return true;
if (MH_Initialize() != MH_OK)
MessageBoxA(NULL, "Failed to initialize MinHook", NULL, MB_ICONERROR);
uintptr_t pPXXBase = reinterpret_cast<uintptr_t>(GetModuleHandleA(NULL));
uintptr_t pSetLightsMappings = pPXXBase + 0x22A580;
if (MH_CreateHook(reinterpret_cast<LPVOID>(pSetLightsMappings), hk_InputHandler_PIUIO_SetLightsMappings, reinterpret_cast<LPVOID*>(&oSetLightsMappings)))
MessageBoxA(NULL, "Failed to hook InputHandler_PIUIO::SetLightsMappings", NULL, MB_ICONERROR);
if (MH_EnableHook(MH_ALL_HOOKS))
MessageBoxA(NULL, "Failed to enable hooks", NULL, MB_ICONERROR);
return true;
}