-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest.cpp
29 lines (26 loc) · 834 Bytes
/
Test.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
#include "Test.h"
uint32_t changeBlockColor() {
return 0x00FF00FF;
}
void Test::installHook()
{
uintptr_t moduleBase = (uintptr_t)GetModuleHandleW(L"Minecraft.Windows.exe");
uintptr_t ColorAddr = moduleBase + 0x17A971E;
int ColorOffset = *reinterpret_cast<int*>(ColorAddr + 3);
uintptr_t** DirtVtable = reinterpret_cast<uintptr_t**>(ColorAddr + ColorOffset + 7);
if (ColorAddr != 0x0 || DirtVtable != 0x0) {
void* ColorAddr = (void*)DirtVtable[129];
if (MH_CreateHook(ColorAddr, &changeBlockColor, reinterpret_cast<LPVOID*>(NULL)) == MH_OK) {
std::cout << "Hook Created!" << "\n";
if (MH_EnableHook(ColorAddr) == MH_OK) {
std::cout << "Successfully Hooked!" << std::endl;
}
else {
std::cout << "Failed to hook" << std::endl;
}
}
else {
std::cout << "Failed to create" << std::endl;
}
}
}