From 05de2db240d2e533f3ba0705e69af3200d41fc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Wed, 30 Oct 2024 13:39:02 +0800 Subject: [PATCH] URGP --- LunaHook/engine32/RUGP.cpp | 20 ++++++++++++++++++++ LunaHook/texthook.cc | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/LunaHook/engine32/RUGP.cpp b/LunaHook/engine32/RUGP.cpp index 01940d7..c106446 100644 --- a/LunaHook/engine32/RUGP.cpp +++ b/LunaHook/engine32/RUGP.cpp @@ -32,6 +32,11 @@ namespace if (i < 4) { hp->offset = i << 2; + if (i == 2 && hp->user_value != 1) + { + hp->split = get_stack(1); + hp->type |= USING_SPLIT; + } *data = val; *len = 2; hp->text_fun = nullptr; @@ -66,6 +71,21 @@ namespace return false; if (DWORD i = SafeFindEnclosingAlignedFunction((DWORD)s, 0x200)) { + auto [s, e] = Util::QueryModuleLimits((HMODULE)low); + auto refs = findxref_reverse_checkcallop(i, s, e, 0xe8); + if (refs.size() == 1) + { + auto f2 = findfuncstart(refs[0], 0x100, true); + if (f2) + { + HookParam hp; + hp.address = f2; + hp.text_fun = SpecialHookRUGP1; + hp.user_value = 1; + hp.type = CODEC_ANSI_BE | USING_CHAR; + return NewHook(hp, "rUGP"); + } + } HookParam hp; hp.address = i; hp.text_fun = SpecialHookRUGP1; diff --git a/LunaHook/texthook.cc b/LunaHook/texthook.cc index c366465..5f28856 100644 --- a/LunaHook/texthook.cc +++ b/LunaHook/texthook.cc @@ -93,7 +93,17 @@ uintptr_t getasbaddr(const HookParam &hp) { if (hp.type & FUNCTION_OFFSET) { - if (FARPROC function = GetProcAddress(GetModuleHandleW(hp.module), hp.function)) + FARPROC function = NULL; + try + { + auto ordinal = std::stoi(hp.function); + function = GetProcAddress(GetModuleHandleW(hp.module), (LPCSTR)ordinal); + } + catch (...) + { + function = GetProcAddress(GetModuleHandleW(hp.module), hp.function); + } + if (function) address += (uint64_t)function; else return ConsoleOutput(FUNC_MISSING), 0;