LunaHook-mirror/LunaHook/engine32/Aksys.cpp

66 lines
1.5 KiB
C++
Raw Normal View History

2024-11-02 15:49:09 +08:00
#include "Aksys.h"
2024-03-01 02:13:32 +08:00
namespace
{
2024-11-02 15:49:09 +08:00
bool _Aksys()
2024-03-01 02:13:32 +08:00
{
2024-11-02 15:49:09 +08:00
// https://vndb.org/v25385
// Spirit Hunter: NG
/*
int __usercall sub_4CDD70@<eax>(const char *a1@<edx>, int a2, _DWORD *a3, int *a4)
2024-03-01 02:13:32 +08:00
{
2024-11-02 15:49:09 +08:00
int result; // eax
const char *v6; // [esp+Ch] [ebp-8h] BYREF
*a3 = strlen(a1);
if ( *a1 && a2 )
2024-03-01 02:13:32 +08:00
{
2024-11-02 15:49:09 +08:00
v6 = a1;
if ( (unsigned __int8)sub_4CAEB0(&v6) )
{
*a4 = sub_4CAF70(0, 0, 0x3A4u, (const unsigned __int16 *)a1, 0xFDE9u);
return 0;
}
else
{
return -2141454316;
}
2024-03-01 02:13:32 +08:00
}
else
{
2024-11-02 15:49:09 +08:00
result = 0;
*a4 = 0;
2024-03-01 02:13:32 +08:00
}
2024-11-02 15:49:09 +08:00
return result;
2024-03-01 02:13:32 +08:00
}
2024-11-02 15:49:09 +08:00
*/
BYTE bytes[] = {
0x68, 0xe9, 0xfd, 0, 0,
0x56,
0x68, 0xa4, 0x03, 0, 0,
0x33, XX,
0x33, XX,
0xe8};
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
if (!addr)
return false;
addr = findfuncstart(addr);
if (!addr)
return false;
HookParam hp;
hp.address = addr;
hp.offset = get_reg(regs::edx);
hp.split = get_reg(regs::edx);
hp.type = USING_STRING | USING_SPLIT;
hp.filter_fun = [](LPVOID data, size_t *size, HookParam *)
2024-03-01 02:13:32 +08:00
{
2024-11-02 15:49:09 +08:00
StringFilter((char *)data, size, "@1r", 3);
StringFilter((char *)data, size, "@-1r", 4);
return (StringToWideString(std::string((char *)data, *size), 932).has_value());
};
return NewHook(hp, "Aksys");
2024-03-01 02:13:32 +08:00
}
}
2024-11-02 15:49:09 +08:00
bool Aksys::attach_function()
{
return _Aksys();
}