2024-10-03 14:53:59 +08:00
|
|
|
#include "Godot.h"
|
2024-02-07 20:59:24 +08:00
|
|
|
|
2024-10-03 14:53:59 +08:00
|
|
|
bool InsertGodotHook_X64()
|
|
|
|
{
|
|
|
|
const BYTE bytes[] = {0x8B, 0x40, 0xFC, 0x83, 0xF8, 0x01, 0x83, 0xD0, 0xFF, 0x41, 0x39, 0xC6};
|
2024-02-07 20:59:24 +08:00
|
|
|
|
|
|
|
ULONG64 range = min(processStopAddress - processStartAddress, MAX_REL_ADDR);
|
2024-10-03 14:53:59 +08:00
|
|
|
for (auto addr : Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStartAddress + range))
|
|
|
|
{
|
2024-02-07 20:59:24 +08:00
|
|
|
HookParam myhp;
|
|
|
|
myhp.address = addr;
|
|
|
|
|
|
|
|
myhp.type = USING_STRING | CODEC_UTF16 | NO_CONTEXT; // /HQ 不使用上下文区分 把所有线程的文本都提取
|
2024-10-03 14:53:59 +08:00
|
|
|
// myhp.padding = 0xc;//[esp+4]+padding
|
|
|
|
// data_offset
|
|
|
|
myhp.offset = get_reg(regs::rax);
|
|
|
|
myhp.text_fun = [](hook_stack *stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t *count)
|
2024-02-07 20:59:24 +08:00
|
|
|
{
|
2024-10-03 14:53:59 +08:00
|
|
|
*data = (stack->rax);
|
|
|
|
int len = *(int *)(*data - 4);
|
|
|
|
if (len != wcslen((wchar_t *)*data))
|
|
|
|
return;
|
|
|
|
*count = len * 2;
|
2024-02-07 20:59:24 +08:00
|
|
|
};
|
|
|
|
char nameForUser[HOOK_NAME_SIZE] = "RichTextLabel_add_text";
|
2024-10-03 14:53:59 +08:00
|
|
|
|
2024-02-07 20:59:24 +08:00
|
|
|
ConsoleOutput("Insert: Godot_add_text_X64 Hook ");
|
|
|
|
return NewHook(myhp, nameForUser);
|
|
|
|
}
|
|
|
|
|
|
|
|
ConsoleOutput("Godot_x64: pattern not found");
|
|
|
|
return false;
|
|
|
|
}
|
2024-10-03 14:53:59 +08:00
|
|
|
bool InsertGodotHook2_X64()
|
|
|
|
{
|
|
|
|
|
2024-02-07 20:59:24 +08:00
|
|
|
/*
|
2024-10-03 14:53:59 +08:00
|
|
|
* Sample games:
|
|
|
|
* https://vndb.org/r109138
|
|
|
|
*/
|
2024-02-07 20:59:24 +08:00
|
|
|
const BYTE bytes[] = {
|
2024-10-03 14:53:59 +08:00
|
|
|
0x48, 0x8B, 0x94, 0x24, XX4, // mov rdx,[rsp+000001C0] <- hook here
|
|
|
|
0x4C, 0x89, 0xE1, // mov rcx,r12
|
|
|
|
0xE8, XX4, // call NULL-Windows.exe+D150
|
|
|
|
0x49, 0x8B, 0x06, // mov rax,[r14]
|
|
|
|
0x48, 0x85, 0xC0, // test rax,rax
|
|
|
|
0x0F, 0x85, XX4 // jne NULL-Windows.exe+A359D4
|
2024-02-07 20:59:24 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
ULONG64 range = min(processStopAddress - processStartAddress, X64_MAX_REL_ADDR);
|
2024-10-03 14:53:59 +08:00
|
|
|
for (auto addr : Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStartAddress + range))
|
|
|
|
{
|
2024-02-07 20:59:24 +08:00
|
|
|
HookParam hp;
|
|
|
|
hp.address = addr;
|
2024-10-03 14:53:59 +08:00
|
|
|
hp.offset = get_reg(regs::rcx);
|
2024-02-07 20:59:24 +08:00
|
|
|
hp.type = USING_STRING | CODEC_UTF16;
|
|
|
|
ConsoleOutput("INSERT Godot2_x64 Hook ");
|
|
|
|
return NewHook(hp, "Godot2_x64");
|
|
|
|
}
|
|
|
|
|
|
|
|
ConsoleOutput("Godot2_x64: pattern not found");
|
|
|
|
return false;
|
|
|
|
}
|
2024-10-03 14:53:59 +08:00
|
|
|
bool Godot::attach_function()
|
|
|
|
{
|
|
|
|
auto _ = InsertGodotHook_X64();
|
|
|
|
_ = InsertGodotHook2_X64() || _;
|
2024-02-07 20:59:24 +08:00
|
|
|
return _;
|
|
|
|
}
|