63 lines
1.8 KiB
C++
Raw Normal View History

2024-11-02 15:49:09 +08:00
#include "AIL2.h"
bool InsertAIL2Hook()
{
auto findalign = [](uintptr_t addr1)
{
const BYTE pattern[] = {0x90, 0x90, 0x83, 0xec};
2024-02-07 20:59:24 +08:00
return reverseFindBytes(pattern, sizeof(pattern), processStartAddress, addr1) + 2;
};
2024-11-02 15:49:09 +08:00
bool succ = false;
2024-02-07 20:59:24 +08:00
BYTE bytes1[] = {
2024-11-02 15:49:09 +08:00
// .text:0042E5DF 3C 66 cmp al, 66h; 'f'
//.text:0042E5E1 74 57 jz short loc_42E63A
//.text : 0042E5E1
//.text : 0042E5E3 3C 70 cmp al, 70h; 'p'
//.text:0042E5E5 74 4C jz short loc_42E633
//.text : 0042E5E5
//.text : 0042E5E7 3C 73 cmp al, 73h; 's'
//.text:0042E5E9 74 37 jz short loc_42E622
0x3c, 0x66,
0x74, XX,
0x3c, 0x70,
0x74, XX,
0x3c, 0x73,
0x74, XX};
2024-02-07 20:59:24 +08:00
auto addr1 = MemDbg::findBytes(bytes1, sizeof(bytes1), processStartAddress, processStopAddress);
2024-11-02 15:49:09 +08:00
if (addr1 == 0)
return false;
2024-02-07 20:59:24 +08:00
addr1 = findalign(addr1);
2024-11-02 15:49:09 +08:00
if (addr1 == 0)
return false;
2024-02-07 20:59:24 +08:00
ConsoleOutput("AIL1 %p", addr1);
HookParam hp;
hp.address = addr1;
hp.codepage = 932;
2024-11-02 15:49:09 +08:00
hp.offset = get_stack(3);
2024-02-07 20:59:24 +08:00
hp.type = USING_STRING;
2024-11-02 15:49:09 +08:00
succ |= NewHook(hp, "AIL1");
BYTE bytes[] = {// if ( v12 != 32 && v12 != 33088 )
0x3d, 0x40, 0x81, 0x00, 0x00, 0x0f};
2024-02-07 20:59:24 +08:00
addr1 = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
2024-11-02 15:49:09 +08:00
if (addr1 == 0)
return succ;
2024-02-07 20:59:24 +08:00
addr1 = MemDbg::findEnclosingAlignedFunction(addr1);
2024-11-02 15:49:09 +08:00
if (addr1 == 0)
return succ;
2024-02-07 20:59:24 +08:00
hp = {};
hp.address = addr1;
hp.codepage = 932;
2024-11-02 15:49:09 +08:00
hp.offset = get_stack(4);
2024-02-07 20:59:24 +08:00
hp.type = USING_STRING | USING_SPLIT;
hp.split_index = 0;
2024-11-02 15:49:09 +08:00
succ |= NewHook(hp, "AIL2");
2024-02-07 20:59:24 +08:00
return succ;
}
2024-11-02 15:49:09 +08:00
bool AIL2::attach_function()
{
// アイル
2024-02-07 20:59:24 +08:00
2024-11-02 15:49:09 +08:00
return InsertAIL2Hook();
}