LunaHook-mirror/LunaHook/engine32/Regista.cpp

51 lines
1.4 KiB
C++
Raw Normal View History

2024-02-07 20:59:24 +08:00
#include"Regista.h"
namespace{
//ルートダブル -Before Crime * After Days-
bool old() {
const BYTE bytes[] = {
0x8a, 0x10, 0x83, 0xC0, 0x04, 0x83, 0xc1, 0x04, 0x84, 0xd2, 0x74
};
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
ConsoleOutput("%p", addr);
if (addr == 0)return false;
addr = findfuncstart(addr,0x40);
ConsoleOutput("%p", addr);
if (addr == 0)return false;
HookParam hp;
hp.address = addr;
hp.offset=get_stack(1);
hp.type = DATA_INDIRECT;
hp.index = 0;
return NewHook(hp, "Regista");
}
bool _2(){
const BYTE bytes[] = {
//old不是很好old是strcmp有很多乱七八糟的这个是脚本的一些控制字符判断和shiftjis范围判断。
0x80 ,0xF9 ,0x81 ,
XX2,
0x80 ,0xF9 ,0x9F,
XX2,
0x80 ,0xF9 ,0xE0,
XX2,
0x80 ,0xF9 ,0xFC,
};
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
ConsoleOutput("%p", addr);
if (addr == 0)return false;
const BYTE start[] = {
0xCC,0xCC,0xCC,0xCC
};
addr = reverseFindBytes(start, sizeof(start), addr - 0x40, addr);
if (addr == 0)return false;
HookParam hp;
hp.address = addr+4;
hp.offset=get_reg(regs::edx);
hp.type=USING_STRING;
return NewHook(hp, "Regista");
}
}
bool Regista::attach_function() {
return _2()||old();
}