From 29d23935ad012b55490999a1147656980c7c9d12 Mon Sep 17 00:00:00 2001 From: k1mlka Date: Mon, 7 Dec 2020 15:13:43 +0800 Subject: [PATCH] versatile way --- texthook/engine/engine.cc | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 7683c9c..8a12f0e 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -16396,28 +16396,18 @@ bool InsertShinyDaysGameHook() 0xff,0x83,0x70,0x03,0x00,0x00,0x33,0xf6, 0xc6,0x84,0x24,0x90,0x02,0x00,0x00,0x02 }; - LPVOID addr = (LPVOID)0x42ad94; - if (::memcmp(addr, bytes, sizeof(bytes)) == 0) { - HookParam hp = {}; - hp.address = 0x42ad9c; - hp.text_fun = SpecialGameHookShinyDays; - hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; - ConsoleOutput("vnreng: INSERT ShinyDays"); - NewHook(hp, "ShinyDays 1.00"); - return true; - } - addr = (LPVOID)0x42b7f4; - if (::memcmp(addr, bytes, sizeof(bytes)) == 0) { - HookParam hp = {}; - hp.address = 0x42b7fc; - hp.text_fun = SpecialGameHookShinyDays; - hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; - ConsoleOutput("vnreng: INSERT ShinyDays"); - NewHook(hp, "ShinyDays 1.00d"); - return true; + + for (auto addr : Util::SearchMemory(bytes, sizeof(bytes))) { + HookParam hp = {}; + hp.address = addr + 0x8; + hp.text_fun = SpecialGameHookShinyDays; + hp.type = USING_UNICODE | USING_STRING | NO_CONTEXT; + ConsoleOutput("Textractor: INSERT ShinyDays"); + NewHook(hp, "ShinyDays"); + return true; } - ConsoleOutput("vnreng:ShinyDays: only work for 1.00 and 1.00d"); + ConsoleOutput("Textractor:ShinyDays: pattern not found"); return false; }