forked from Public-Mirror/Textractor
fix function finding (restore to ithvnr) - should fix system40 and rugp2 hooks
This commit is contained in:
parent
a8ae2156d9
commit
3c33d11d80
@ -4494,7 +4494,8 @@ bool InsertRUGP1Hook()
|
||||
*/
|
||||
bool InsertRUGP2Hook()
|
||||
{
|
||||
if (!Util::CheckFile(L"vm60.dll") /*|| !SafeFillRange(L"vm60.dll", &low, &high)*/) {
|
||||
auto module = GetModuleHandleW(L"vm60.dll");
|
||||
if (!module /*|| !SafeFillRange(L"vm60.dll", &low, &high)*/) {
|
||||
ConsoleOutput("vnreng:rUGP2: vm60.dll does not exist");
|
||||
return false;
|
||||
}
|
||||
@ -4508,7 +4509,7 @@ bool InsertRUGP2Hook()
|
||||
0x89,0x75, 0x0c // 1001e527 8975 0c mov dword ptr ss:[ebp+0xc],esi
|
||||
};
|
||||
enum { addr_offset = 0x1001e51d - 0x1001e515 };
|
||||
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
|
||||
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), (DWORD)module, Util::QueryModuleLimits(module).second);
|
||||
//GROWL_DWORD(addr);
|
||||
if (!addr) {
|
||||
ConsoleOutput("vnreng:rUGP2: pattern not found");
|
||||
@ -4631,20 +4632,15 @@ static void InsertAliceHook2(DWORD addr)
|
||||
// jichi 5/13/2015: Looking for function entries in StoatSpriteEngine.dll
|
||||
bool InsertAliceHook()
|
||||
{
|
||||
DWORD addr;
|
||||
if (addr = (DWORD)GetProcAddress(GetModuleHandleW(L"SACT2.dll"), "SP_TextDraw")) {
|
||||
if (auto addr = Util::FindFunction("SP_TextDraw")) {
|
||||
InsertAliceHook1(addr);
|
||||
return true;
|
||||
}
|
||||
if (addr = (DWORD)GetProcAddress(GetModuleHandleW(L"SACTDX.dll"), "SP_TextDraw")) {
|
||||
InsertAliceHook1(addr);
|
||||
return true;
|
||||
}
|
||||
//if (GetFunctionAddr("SP_SetTextSprite", &addr, &low, &high, 0) && addr) {
|
||||
// InsertAliceHook2(addr);
|
||||
// return true;
|
||||
//}
|
||||
if (addr = (DWORD)GetProcAddress(GetModuleHandleW(L"StoatSpriteEngine.dll"), "SP_SetTextSprite")) { // Artikash 6/27/2018 not sure if this works
|
||||
if (auto addr = Util::FindFunction("SP_SetTextSprite")) { // Artikash 6/27/2018 not sure if this works
|
||||
InsertAliceHook2(addr);
|
||||
return true;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "util/util.h"
|
||||
#include "ithsys/ithsys.h"
|
||||
#include "main.h"
|
||||
#include <Psapi.h>
|
||||
|
||||
namespace { // unnamed
|
||||
|
||||
@ -345,6 +346,15 @@ std::vector<uint64_t> SearchMemory(const void* bytes, short length, DWORD protec
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uintptr_t FindFunction(const char* function)
|
||||
{
|
||||
static HMODULE modules[300] = {};
|
||||
static auto _ = EnumProcessModules(GetCurrentProcess(), modules, sizeof(modules), DUMMY);
|
||||
for (auto module : modules) if (auto addr = GetProcAddress(module, function)) return (uintptr_t)addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -22,6 +22,7 @@ bool SearchResourceString(LPCWSTR str);
|
||||
|
||||
std::pair<uint64_t, uint64_t> QueryModuleLimits(HMODULE module);
|
||||
std::vector<uint64_t> SearchMemory(const void* bytes, short length, DWORD protect = PAGE_EXECUTE, uintptr_t minAddr = 0, uintptr_t maxAddr = -1ULL);
|
||||
uintptr_t FindFunction(const char* function);
|
||||
|
||||
} // namespace Util
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user