2024-10-26 02:23:45 +08:00
|
|
|
#include "NNNConfig.h"
|
|
|
|
bool NNNConfig::attach_function()
|
|
|
|
{
|
|
|
|
// blackcyc
|
|
|
|
// 夢幻廻廊
|
|
|
|
// 復讐の女仕官ハイネ ~肢体に刻まれる淫欲のプログラム~
|
|
|
|
// https://vndb.org/v24955
|
2024-03-10 15:34:02 +08:00
|
|
|
const BYTE bytes[] = {
|
2024-10-26 02:23:45 +08:00
|
|
|
//clang-format off
|
|
|
|
0x68, 0xE8, 0x03, 0x00, 0x00, 0x6a, 0x00,
|
|
|
|
//clang-format on
|
|
|
|
|
2024-03-10 15:34:02 +08:00
|
|
|
};
|
|
|
|
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
|
2024-10-26 02:23:45 +08:00
|
|
|
if (addr == 0)
|
|
|
|
return false;
|
2024-02-07 20:59:24 +08:00
|
|
|
|
2024-03-10 15:34:02 +08:00
|
|
|
addr = addr + sizeof(bytes);
|
2024-10-26 02:23:45 +08:00
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if (*(BYTE *)addr == 0xe8)
|
|
|
|
{
|
2024-03-10 15:34:02 +08:00
|
|
|
addr += 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
addr += 1;
|
|
|
|
}
|
2024-10-26 02:23:45 +08:00
|
|
|
uintptr_t offset = *(uintptr_t *)(addr);
|
|
|
|
uintptr_t funcaddr = offset + addr + 4;
|
|
|
|
const BYTE check[] = {0x83, 0xEC, 0x1C};
|
|
|
|
auto checkoffset = MemDbg::findBytes(check, sizeof(check), funcaddr, funcaddr + 0x20);
|
|
|
|
|
|
|
|
if (checkoffset == 0)
|
|
|
|
offset = get_stack(5);
|
|
|
|
else
|
|
|
|
offset = get_stack(6);
|
2024-03-10 15:34:02 +08:00
|
|
|
HookParam hp;
|
|
|
|
hp.address = funcaddr;
|
|
|
|
hp.offset = offset;
|
2024-03-11 14:05:04 +08:00
|
|
|
hp.type = USING_STRING;
|
2024-10-26 02:23:45 +08:00
|
|
|
hp.text_fun = [](hook_stack *stack, HookParam *, uintptr_t *data, uintptr_t *split, size_t *len)
|
|
|
|
{
|
|
|
|
// 当前文本可以过滤重复,上一条文本会按照换行符切分不停刷新。
|
|
|
|
static std::unordered_map<uintptr_t, std::string> everythreadlast;
|
|
|
|
if (everythreadlast.find(stack->retaddr) == everythreadlast.end())
|
|
|
|
everythreadlast[stack->retaddr] = "";
|
|
|
|
auto thisstr = std::string((char *)*data);
|
|
|
|
if (everythreadlast[stack->retaddr] == thisstr)
|
|
|
|
return;
|
|
|
|
everythreadlast[stack->retaddr] = thisstr;
|
|
|
|
*len = everythreadlast[stack->retaddr].size();
|
|
|
|
};
|
2024-03-10 15:34:02 +08:00
|
|
|
return NewHook(hp, "NNNhook");
|
2024-10-26 02:23:45 +08:00
|
|
|
}
|