forked from TheIndra55/TRLAU-menu-hook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlHooks.cpp
53 lines (39 loc) · 1.38 KB
/
ControlHooks.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
#include "Hooking.hpp"
//int GetNumButtons()
//{
// return 21 /* game default */;
//}
char(__thiscall* UIDataList__AllocateRunData)(DWORD _this, int a2, int a3, int a4, int a5, int a6);
char(__thiscall* UIDataList__AddItem)(DWORD _this, int processFunc, void* data, int getDataFunc, int a5, const char* a6);
const char* GetControlText(void* data, int index, int textIndex)
{
if (textIndex)
{
return "DEL";
}
return "Binoculars";
}
char UIControllerConfigDataList(int a1, int a2)
{
// since the game controller config is complex and hardcoded array size
// we construct the controller config data list ourself and add our own control
if (!UIDataList__AllocateRunData(a1, 22, a2, 0x4EC5E0, 0x4EC5F0, 0x4ECB10))
return 1;
for (int i = 0; i < 21; i++)
{
UIDataList__AddItem(a1, 0x4ECB30, (void*)i, 0x4ECBE0, 0, 0);
}
// hardcoded for now since internal controls array is a fixed size
UIDataList__AddItem(a1, 0, 0, (int)GetControlText, 0, 0);
return 1;
}
void InstallControlHooks()
{
//MH_CreateHook((void*)0x004EC280, GetNumButtons, nullptr);
#if TRAE
UIDataList__AllocateRunData = reinterpret_cast<char(__thiscall*)(DWORD, int, int, int, int, int)>(0x004ED600);
UIDataList__AddItem = reinterpret_cast<char(__thiscall*)(DWORD, int, void*, int, int, const char*)>(0x004ED6C0);
MH_CreateHook((void*)0x004ECCB0, UIControllerConfigDataList, nullptr);
MH_EnableHook(MH_ALL_HOOKS);
#endif
}