90 lines
2.6 KiB
C++
Raw Normal View History

2024-10-03 14:53:59 +08:00
#include "mono.h"
#include "mono/monocommon.hpp"
namespace
{
bool monobdwgc()
{
2024-02-07 20:59:24 +08:00
HMODULE module = GetModuleHandleW(L"mono-2.0-bdwgc.dll");
2024-10-03 14:53:59 +08:00
if (module == 0)
return false;
2024-02-07 20:59:24 +08:00
auto [minAddress, maxAddress] = Util::QueryModuleLimits(module);
BYTE bytes[] = {
2024-10-03 14:53:59 +08:00
0x81, 0xF9, 0x80, 0x00, 0x00, 0x00,
0x73, 0x05,
0x49, 0x8B, 0xCC
/*
_BYTE *__fastcall sub_18005B290(
_WORD *a1,
int a2,
__int64 a3,
_DWORD *a4,
__int64 (__fastcall *a5)(__int64, __int64),
__int64 a6,
__int64 a7)
2024-02-07 20:59:24 +08:00
2024-10-03 14:53:59 +08:00
if ( (_DWORD)v26 )
2024-02-07 20:59:24 +08:00
{
2024-10-03 14:53:59 +08:00
if ( (unsigned int)v26 >= 0x80 )
2024-02-07 20:59:24 +08:00
{
2024-10-03 14:53:59 +08:00
if ( (unsigned int)v26 >= 0x800 )
2024-02-07 20:59:24 +08:00
{
2024-10-03 14:53:59 +08:00
if ( (unsigned int)v26 >= 0x10000 )
2024-02-07 20:59:24 +08:00
{
2024-10-03 14:53:59 +08:00
if ( (unsigned int)v26 >= 0x200000 )
2024-02-07 20:59:24 +08:00
{
2024-10-03 14:53:59 +08:00
if ( (unsigned int)v26 >= 0x4000000 )
{
v17 = 6i64;
if ( (unsigned int)v26 >= 0x80000000 )
*/
2024-02-07 20:59:24 +08:00
};
2024-10-03 14:53:59 +08:00
auto addrs = Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, minAddress, maxAddress);
auto suc = false;
for (auto addr : addrs)
{
const BYTE align[] = {0xCC, 0xCC, 0xCC, 0xCC};
addr = reverseFindBytes(align, sizeof(align), addr - 0x100, addr);
if (addr == 0)
continue;
2024-02-07 20:59:24 +08:00
ConsoleOutput("monobdwgcdll %p", addr);
HookParam hp;
2024-10-03 14:53:59 +08:00
hp.address = addr + 4;
hp.offset = get_reg(regs::rcx);
hp.type = CODEC_UTF16 | USING_STRING;
hp.text_fun = [](auto, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t *len)
{
std::wstring str = std::wstring((LPWSTR)*data);
*split = str.find(L"OnShowComplete") != str.npos;
*len = wcslen((wchar_t *)*data) * 2;
2024-02-07 20:59:24 +08:00
};
2024-10-03 14:53:59 +08:00
hp.filter_fun = [](void *data, size_t *len, HookParam *hp)
{
std::wstring str = std::wstring((LPWSTR)data, *len / 2);
if (str.find(L"OnShowComplete") != str.npos)
{
2024-02-07 20:59:24 +08:00
str = std::regex_replace(str, std::wregex(L"\n"), L"");
std::wregex reg1(L"\\((.*?)\\)");
2024-10-03 14:53:59 +08:00
std::wsmatch match;
std::regex_search(str, match, reg1);
auto result1 = match[1].str();
std::regex_search(str, match, std::wregex(L" Text:(.*?)Next:(.*?)"));
result1 = match[1].str();
write_string_overwrite(data, len, result1);
2024-02-07 20:59:24 +08:00
}
return true;
};
2024-10-03 14:53:59 +08:00
suc |= NewHook(hp, "monobdwgcdll");
2024-02-07 20:59:24 +08:00
}
return suc;
2024-10-03 14:53:59 +08:00
}
2024-02-07 20:59:24 +08:00
}
2024-10-03 14:53:59 +08:00
bool mono::attach_function()
{
bool common = monocommon::hook_mono_il2cpp();
2024-05-14 10:51:19 +08:00
return common;
2024-02-07 20:59:24 +08:00
}