65 lines
1.5 KiB
C++
Raw Normal View History

2024-10-03 14:53:59 +08:00
#include "CMVS.h"
namespace
{
bool EMbed()
{
// 有多个,但是只有最后一个是有效的
const uint8_t bytes[] = {
0xB8, 0x42, 0x81, 0x00, 0x00,
0x66, XX2, 0x74, XX,
0xB8, 0x76, 0x81, 0x00, 0x00,
0x66, XX2, 0x74, XX,
0xB8, 0x78, 0x81, 0x00, 0x00,
2024-11-02 15:49:09 +08:00
0x66, XX2, 0x74, XX};
2024-10-03 14:53:59 +08:00
bool res = false;
auto addr = processStartAddress;
std::vector<uintptr_t> already;
while (addr)
{
addr = MemDbg::findBytes(bytes, sizeof(bytes), addr + 1, processStopAddress);
if (addr == 0)
continue;
2024-02-07 20:59:24 +08:00
auto f = MemDbg::findEnclosingAlignedFunction(addr);
2024-10-03 14:53:59 +08:00
if (f == 0)
continue;
if (std::find(already.begin(), already.end(), f) != already.end())
continue;
2024-02-07 20:59:24 +08:00
already.push_back(f);
2024-10-03 14:53:59 +08:00
}
if (already.size())
{
HookParam hp;
hp.address = already.back();
hp.offset = get_reg(regs::rdx);
hp.type = EMBED_ABLE | USING_STRING | EMBED_BEFORE_SIMPLE | EMBED_AFTER_NEW | EMBED_DYNA_SJIS;
hp.hook_font = F_GetGlyphOutlineA;
res |= NewHook(hp, "EmbedCMVS");
}
return res;
2024-02-07 20:59:24 +08:00
}
2024-10-03 14:53:59 +08:00
bool CMVSh()
{
DWORD align = 0xCCCCCCCC;
auto addr = MemDbg::findCallerAddress((uintptr_t)::GetGlyphOutlineA, align, processStartAddress, processStopAddress);
if (!addr)
return false;
2024-02-07 20:59:24 +08:00
2024-10-03 14:53:59 +08:00
HookParam hp;
hp.address = addr + 4;
hp.offset = get_reg(regs::r8);
hp.type = CODEC_ANSI_BE;
2024-02-07 20:59:24 +08:00
2024-10-03 14:53:59 +08:00
return NewHook(hp, "CMVS");
}
2024-02-07 20:59:24 +08:00
}
2024-10-03 14:53:59 +08:00
bool CMVS::attach_function()
{
bool b1 = CMVSh();
bool b2 = EMbed();
return b1 || b2;
2024-02-07 20:59:24 +08:00
}