This commit is contained in:
恍兮惚兮 2024-12-31 23:38:49 +08:00
parent da8d04f82a
commit 3b085a9440
8 changed files with 109 additions and 141 deletions

View File

@ -1239,7 +1239,7 @@ bool InsertBGI4Hook_1()
hp.address = addr;
hp.type = CODEC_UTF16 | USING_STRING;
hp.filter_fun = BGI7Filter;
hp.offset = GETARG2;
hp.offset = GETARG(2);
ConsoleOutput("BGI4");
return NewHook(hp, "BGI4");

View File

@ -67,7 +67,7 @@ CHAR *__fastcall sub_1400F5BC0(LPSTR lpMultiByteStr, LPCWCH lpWideCharStr)
hp.address = addr;
hp.type = CODEC_UTF16 | USING_STRING;
hp.filter_fun = BGI7Filter;
hp.offset = GETARG2;
hp.offset = GETARG(2);
return NewHook(hp, "BGI");
}

View File

@ -2054,7 +2054,7 @@ namespace
auto s = buffer->strA();
HookParam hp;
hp.address = (uintptr_t)F01009E600FAF6000_collect;
hp.offset = GETARG1;
hp.offset = GETARG(1);
hp.type = USING_STRING;
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
@ -2246,7 +2246,7 @@ namespace
auto s = buffer->strA();
HookParam hp;
hp.address = (uintptr_t)TT0100A4700BC98000;
hp.offset = GETARG1;
hp.offset = GETARG(1);
hp.type = CODEC_UTF8 | USING_STRING;
static auto _ = NewHook(hp, "0100A4700BC98000");
TT0100A4700BC98000(s.c_str());
@ -2265,7 +2265,7 @@ namespace
strReplace(s, L"/player", L"");
HookParam hp;
hp.address = (uintptr_t)F01006530151F0000_collect;
hp.offset = GETARG1;
hp.offset = GETARG(1);
hp.type = CODEC_UTF16 | USING_STRING;
static auto _ = NewHook(hp, "01006530151F0000");
F01006530151F0000_collect(s.c_str());

View File

@ -12,6 +12,7 @@
// #define LPASTE(s) L##s
// #define L(s) LPASTE(s)
constexpr short arg_sz = (short)sizeof(void *);
std::set<void *> hookonce;
std::mutex hookoncelock;
#define NEW_HOOK(ptr, _dll, _fun, _data, _data_ind, _split_off, _split_ind, _type, _len_off) \
@ -19,12 +20,12 @@ std::mutex hookoncelock;
HookParam hp; \
wcsncpy_s(hp.module, _dll, MAX_MODULE_SIZE - 1); \
strncpy_s(hp.function, #_fun, MAX_MODULE_SIZE - 1); \
hp.offset = _data; \
hp.index = _data_ind; \
hp.split = _split_off; \
hp.split_index = _split_ind; \
hp.offset = GETARG(_data); \
hp.index = GETARG(_data_ind); \
hp.split = GETARG(_split_off); \
hp.split_index = GETARG(_split_ind); \
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
hp.length_offset = _len_off; \
hp.length_offset = GETARG(_len_off) / arg_sz; \
auto currptr = GetModuleHandle(hp.module) ? GetProcAddress(GetModuleHandle(hp.module), hp.function) : nullptr; \
if (currptr) \
{ \
@ -49,12 +50,12 @@ std::mutex hookoncelock;
if (GetModuleFileNameW(_module, path, MAX_PATH)) \
wcsncpy_s(hp.module, wcsrchr(path, L'\\') + 1, MAX_MODULE_SIZE - 1); \
strncpy_s(hp.function, #_fun, MAX_MODULE_SIZE - 1); \
hp.offset = _data; \
hp.index = _data_ind; \
hp.split = _split_off; \
hp.split_index = _split_ind; \
hp.offset = GETARG(_data); \
hp.index = GETARG(_data_ind); \
hp.split = GETARG(_split_off); \
hp.split_index = GETARG(_split_ind); \
hp.type = _type | MODULE_OFFSET | FUNCTION_OFFSET; \
hp.length_offset = _len_off; \
hp.length_offset = GETARG(_len_off) / arg_sz; \
auto currptr = GetProcAddress(_module, hp.function); \
if (currptr) \
{ \
@ -68,33 +69,6 @@ std::mutex hookoncelock;
} \
}
#ifndef _WIN64
enum args
{
s_retaddr = 0,
s_arg1 = 4 * 1, // 0x4
s_arg2 = 4 * 2, // 0x8
s_arg3 = 4 * 3, // 0xc
s_arg4 = 4 * 4, // 0x10
s_arg5 = 4 * 5, // 0x14
s_arg6 = 4 * 6, // 0x18
s_arg7 = 4 * 7
};
#else // _WIN32
enum args
{
s_retaddr = 0x0,
s_arg1 = -0x20,
s_arg2 = -0x28,
s_arg3 = -0x50,
s_arg4 = -0x58,
s_arg5 = 0x8,
s_arg6 = 0x10,
s_arg7 = 0x18
};
#endif // _WIN64
constexpr short arg_sz = (short)sizeof(void *);
void PcHooks::hookGdiGdiplusD3dxFunctions()
{
for (std::wstring DXVersion : {L"d3dx9", L"d3dx10"})
@ -112,40 +86,40 @@ void PcHooks::hookGdiGdiplusD3dxFunctions()
void PcHooks::hookGDIFunctions(void *ptr)
{
// gdi32.dll
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32A, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetCharacterPlacementA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphIndicesA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphOutlineA, s_arg2, 0, s_arg1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", ExtTextOutA, s_arg6, 0, s_arg1, 0, USING_STRING, s_arg7 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", TextOutA, s_arg4, 0, s_arg1, 0, USING_STRING, s_arg5 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsA, s_arg2, 0, s_arg1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsFloatA, s_arg2, 0, s_arg1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidth32A, s_arg2, 0, s_arg1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidthFloatA, s_arg2, 0, s_arg1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32A, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetCharacterPlacementA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphIndicesA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphOutlineA, 2, 0, 1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", ExtTextOutA, 6, 0, 1, 0, USING_STRING, 7)
NEW_HOOK(ptr, L"gdi32.dll", TextOutA, 4, 0, 1, 0, USING_STRING, 5)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsA, 2, 0, 1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsFloatA, 2, 0, 1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidth32A, 2, 0, 1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidthFloatA, 2, 0, 1, 0, CODEC_ANSI_BE, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32W, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetCharacterPlacementW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphIndicesW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphOutlineW, s_arg2, 0, s_arg1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentPoint32W, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetTextExtentExPointW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetCharacterPlacementW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphIndicesW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"gdi32.dll", GetGlyphOutlineW, 2, 0, 1, 0, CODEC_UTF16, 0)
// ExtTextOutW全是乱码没卵用
// NEW_HOOK(ptr, L"gdi32.dll", ExtTextOutW, s_arg6, 0,s_arg1,0, CODEC_UTF16|USING_STRING, s_arg7 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", TextOutW, s_arg4, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg5 / arg_sz)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsW, s_arg2, 0, s_arg1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsFloatW, s_arg2, 0, s_arg1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidth32W, s_arg2, 0, s_arg1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidthFloatW, s_arg2, 0, s_arg1, 0, CODEC_UTF16, 0)
// NEW_HOOK(ptr, L"gdi32.dll", ExtTextOutW, 6, 0,1,0, CODEC_UTF16|USING_STRING, 7 )
NEW_HOOK(ptr, L"gdi32.dll", TextOutW, 4, 0, 1, 0, CODEC_UTF16 | USING_STRING, 5)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsW, 2, 0, 1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharABCWidthsFloatW, 2, 0, 1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidth32W, 2, 0, 1, 0, CODEC_UTF16, 0)
NEW_HOOK(ptr, L"gdi32.dll", GetCharWidthFloatW, 2, 0, 1, 0, CODEC_UTF16, 0)
// user32.dll
NEW_HOOK(ptr, L"user32.dll", DrawTextA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", DrawTextExA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", TabbedTextOutA, s_arg4, 0, s_arg1, 0, USING_STRING, s_arg5 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", GetTabbedTextExtentA, s_arg2, 0, s_arg1, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", DrawTextW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", DrawTextExW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", TabbedTextOutW, s_arg4, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg5 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", GetTabbedTextExtentW, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"user32.dll", DrawTextA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", DrawTextExA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", TabbedTextOutA, 4, 0, 1, 0, USING_STRING, 5)
NEW_HOOK(ptr, L"user32.dll", GetTabbedTextExtentA, 2, 0, 1, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", DrawTextW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", DrawTextExW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", TabbedTextOutW, 4, 0, 1, 0, CODEC_UTF16 | USING_STRING, 5)
NEW_HOOK(ptr, L"user32.dll", GetTabbedTextExtentW, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
}
// jichi 6/18/2015: GDI+ functions
@ -162,21 +136,21 @@ void PcHooks::hookGDIPlusFunctions()
// Use arg1 pionter to GpGraphics as split
// using namespace Gdiplus::DllExports;
// Use arg5 style as split
NEW_MODULE_HOOK(hModule, GdipAddPathString, s_arg2, 0, s_arg5, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipAddPathStringI, s_arg2, 0, s_arg5, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipMeasureCharacterRanges, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipDrawString, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipMeasureString, s_arg2, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipDrawDriverString, s_arg1, 0, s_arg3, 0, CODEC_UTF16 | USING_STRING, s_arg2 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipMeasureDriverString, s_arg1, 0, s_arg3, 0, CODEC_UTF16 | USING_STRING, s_arg2 / arg_sz)
NEW_MODULE_HOOK(hModule, GdipAddPathString, 2, 0, 5, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_MODULE_HOOK(hModule, GdipAddPathStringI, 2, 0, 5, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_MODULE_HOOK(hModule, GdipMeasureCharacterRanges, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_MODULE_HOOK(hModule, GdipDrawString, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_MODULE_HOOK(hModule, GdipMeasureString, 2, 0, 1, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_MODULE_HOOK(hModule, GdipDrawDriverString, 1, 0, 3, 0, CODEC_UTF16 | USING_STRING, 2)
NEW_MODULE_HOOK(hModule, GdipMeasureDriverString, 1, 0, 3, 0, CODEC_UTF16 | USING_STRING, 2)
}
void PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
{
if (GetProcAddress(d3dxModule, "D3DXCreateTextA"))
{
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextA, s_arg3, 0, 0, 0, USING_STRING, 0)
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextW, s_arg3, 0, 0, 0, USING_STRING | CODEC_UTF16, 0)
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextA, 3, 0, 0, 0, USING_STRING, 0)
NEW_MODULE_HOOK(d3dxModule, D3DXCreateTextW, 3, 0, 0, 0, USING_STRING | CODEC_UTF16, 0)
}
// Second call in D3DX(10)CreateFontIndirect is D3DXFont constructor, which sets up the vtable
@ -211,8 +185,8 @@ void PcHooks::hookD3DXFunctions(HMODULE d3dxModule)
HookParam hp;
hp.address = (*font.vtable)[14];
hp.offset = s_arg3;
hp.length_offset = s_arg4 / arg_sz;
hp.offset = 3;
hp.length_offset = 4;
hp.type = USING_STRING;
auto suc = NewHook(hp, "ID3DXFont::DrawTextA");
hp.address = (*font.vtable)[15];
@ -236,13 +210,13 @@ void PcHooks::hookOtherPcFunctions(void *ptr)
// Lstr functions usually extracts rubbish, and might crash certain games like 「Magical Marriage Lunatics!!」
// Needed by Gift
// Use arg1 address for both split and data
NEW_HOOK(ptr, L"kernel32.dll", lstrlenA, s_arg1, 0, s_arg1, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpyA, s_arg2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpynA, s_arg2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrlenA, 1, 0, 1, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpyA, 2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpynA, 2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrlenW, s_arg1, 0, s_arg1, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpyW, s_arg2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpynW, s_arg2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrlenW, 1, 0, 1, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpyW, 2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"kernel32.dll", lstrcpynW, 2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
// size_t strlen(const char *str);
// size_t strlen_l(const char *str, _locale_t locale);
@ -297,31 +271,31 @@ void PcHooks::hookOtherPcFunctions(void *ptr)
// 2/29/2020 Artikash: TODO: Sort out what to do for string comparison functions
// http://sakuradite.com/topic/159
NEW_HOOK(ptr, L"kernel32.dll", MultiByteToWideChar, s_arg3, 0, 4, 0, USING_STRING, s_arg4 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", WideCharToMultiByte, s_arg3, 0, 4, 0, CODEC_UTF16 | USING_STRING, s_arg4 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", MultiByteToWideChar, 3, 0, 4, 0, USING_STRING, 4)
NEW_HOOK(ptr, L"kernel32.dll", WideCharToMultiByte, 3, 0, 4, 0, CODEC_UTF16 | USING_STRING, 4)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeA, s_arg3, 0, 0, 0, USING_STRING, s_arg4 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeExA, s_arg3, 0, 0, 0, USING_STRING, s_arg4 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", FoldStringA, s_arg2, 0, 0, 0, USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeW, s_arg2, 0, 0, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeExW, s_arg3, 0, 0, 0, CODEC_UTF16 | USING_STRING, s_arg4 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", FoldStringW, s_arg2, 0, 0, 0, CODEC_UTF16 | USING_STRING, s_arg3 / arg_sz)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeA, 3, 0, 0, 0, USING_STRING, 4)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeExA, 3, 0, 0, 0, USING_STRING, 4)
NEW_HOOK(ptr, L"kernel32.dll", FoldStringA, 2, 0, 0, 0, USING_STRING, 3)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeW, 2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"kernel32.dll", GetStringTypeExW, 3, 0, 0, 0, CODEC_UTF16 | USING_STRING, 4)
NEW_HOOK(ptr, L"kernel32.dll", FoldStringW, 2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 3)
NEW_HOOK(ptr, L"user32.dll", CharNextA, s_arg1, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharNextW, s_arg1, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevA, s_arg1, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevW, s_arg1, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharNextExA, s_arg2, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevExA, s_arg2, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharNextA, 1, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharNextW, 1, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevA, 1, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevW, 1, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharNextExA, 2, 0, 0, 0, DATA_INDIRECT, 0)
NEW_HOOK(ptr, L"user32.dll", CharPrevExA, 2, 0, 0, 0, CODEC_UTF16 | DATA_INDIRECT, 0)
// トキノ戦華
NEW_HOOK(ptr, L"user32.dll", wvsprintfA, s_arg2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"user32.dll", wvsprintfW, s_arg2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_HOOK(ptr, L"user32.dll", wvsprintfA, 2, 0, 0, 0, USING_STRING, 0)
NEW_HOOK(ptr, L"user32.dll", wvsprintfW, 2, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
if (HMODULE module = GetModuleHandleW(L"OLEAUT32.dll"))
{
NEW_MODULE_HOOK(module, SysAllocString, s_arg1, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_MODULE_HOOK(module, SysAllocStringLen, s_arg1, 0, 0, 0, CODEC_UTF16 | USING_STRING | KNOWN_UNSTABLE, s_arg2 / arg_sz)
NEW_MODULE_HOOK(module, SysAllocString, 1, 0, 0, 0, CODEC_UTF16 | USING_STRING, 0)
NEW_MODULE_HOOK(module, SysAllocStringLen, 1, 0, 0, 0, CODEC_UTF16 | USING_STRING | KNOWN_UNSTABLE, 2)
}
}

View File

@ -109,31 +109,31 @@ bool InsertPPSSPPHLEHooks()
auto functions = std::vector<PPSSPPFunction>{
// https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceCcc.cpp
// {"sceCccStrlenSJIS", GETARG1, USING_STRING, 0, "sceCccStrlenSJIS("},
// {"sceCccStrlenUTF8", GETARG1, CODEC_UTF8 | USING_STRING, 0, "sceCccStrlenUTF8("},
// {"sceCccStrlenUTF16", GETARG1, CODEC_UTF16 | USING_STRING, 0, "sceCccStrlenUTF16("},
// {"sceCccStrlenSJIS", GETARG(1), USING_STRING, 0, "sceCccStrlenSJIS("},
// {"sceCccStrlenUTF8", GETARG(1), CODEC_UTF8 | USING_STRING, 0, "sceCccStrlenUTF8("},
// {"sceCccStrlenUTF16", GETARG(1), CODEC_UTF16 | USING_STRING, 0, "sceCccStrlenUTF16("},
// {"sceCccSJIStoUTF8", GETARG3, USING_STRING, 0, "sceCccSJIStoUTF8("},
// {"sceCccSJIStoUTF16", GETARG3, USING_STRING, 0, "sceCccSJIStoUTF16("},
// {"sceCccUTF8toSJIS", GETARG3, CODEC_UTF8 | USING_STRING, 0, "sceCccUTF8toSJIS("},
// {"sceCccUTF8toUTF16", GETARG3, CODEC_UTF8 | USING_STRING, 0, "sceCccUTF8toUTF16("},
// {"sceCccUTF16toSJIS", GETARG3, CODEC_UTF16 | USING_STRING, 0, "sceCccUTF16toSJIS("},
// {"sceCccUTF16toUTF8", GETARG3, CODEC_UTF16 | USING_STRING, 0, "sceCccUTF16toUTF8("},
// {"sceCccSJIStoUTF8", GETARG(3), USING_STRING, 0, "sceCccSJIStoUTF8("},
// {"sceCccSJIStoUTF16", GETARG(3), USING_STRING, 0, "sceCccSJIStoUTF16("},
// {"sceCccUTF8toSJIS", GETARG(3), CODEC_UTF8 | USING_STRING, 0, "sceCccUTF8toSJIS("},
// {"sceCccUTF8toUTF16", GETARG(3), CODEC_UTF8 | USING_STRING, 0, "sceCccUTF8toUTF16("},
// {"sceCccUTF16toSJIS", GETARG(3), CODEC_UTF16 | USING_STRING, 0, "sceCccUTF16toSJIS("},
// {"sceCccUTF16toUTF8", GETARG(3), CODEC_UTF16 | USING_STRING, 0, "sceCccUTF16toUTF8("},
// https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceFont.cpp
{"sceFontGetCharInfo", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetCharInfo("},
{"sceFontGetShadowInfo", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetShadowInfo("},
{"sceFontGetCharImageRect", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetCharImageRect("},
{"sceFontGetShadowImageRect", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetShadowImageRect("},
{"sceFontGetCharGlyphImage", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetCharGlyphImage("},
//{"sceFontGetCharGlyphImage_Clip", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetCharGlyphImage_Clip("},
{"sceFontGetShadowGlyphImage", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetShadowGlyphImage("},
//{"sceFontGetShadowGlyphImage_Clip", GETARG2, CODEC_UTF16, GETARG1, "sceFontGetShadowGlyphImage_Clip("},
{"sceFontGetCharInfo", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetCharInfo("},
{"sceFontGetShadowInfo", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetShadowInfo("},
{"sceFontGetCharImageRect", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetCharImageRect("},
{"sceFontGetShadowImageRect", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetShadowImageRect("},
{"sceFontGetCharGlyphImage", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetCharGlyphImage("},
//{"sceFontGetCharGlyphImage_Clip", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetCharGlyphImage_Clip("},
{"sceFontGetShadowGlyphImage", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetShadowGlyphImage("},
//{"sceFontGetShadowGlyphImage_Clip", GETARG(2), CODEC_UTF16, GETARG(1), "sceFontGetShadowGlyphImage_Clip("},
// https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceKernelInterrupt.cpp
// {"sysclib_strcat", GETARG2, USING_STRING, 0, "Untested sysclib_strcat("},
// {"sysclib_strcpy", GETARG2, USING_STRING, 0, "Untested sysclib_strcpy("},
// {"sysclib_strlen", GETARG1, USING_STRING, 0, "Untested sysclib_strlen("}
// {"sysclib_strcat", GETARG(2), USING_STRING, 0, "Untested sysclib_strcat("},
// {"sysclib_strcpy", GETARG(2), USING_STRING, 0, "Untested sysclib_strcpy("},
// {"sysclib_strlen", GETARG(1), USING_STRING, 0, "Untested sysclib_strlen("}
};
auto succ = false;

View File

@ -1163,7 +1163,7 @@ namespace ppsspp
auto s = buffer->strA();
HookParam hp;
hp.address = (uintptr_t)ULJM06115_C;
hp.offset = GETARG1;
hp.offset = GETARG(1);
hp.type = USING_STRING;
static auto _ = NewHook(hp, "ULJM06115");
ULJM06115_C(s.data());

View File

@ -64,8 +64,8 @@ namespace
{
HookParam hp_internal;
hp_internal.address = (uintptr_t)luna_internal_renpy_call_host;
hp_internal.offset = GETARG1;
hp_internal.split = GETARG2;
hp_internal.offset = GETARG(1);
hp_internal.split = GETARG(2);
hp_internal.type = USING_SPLIT | USING_STRING | CODEC_UTF16 | EMBED_ABLE | EMBED_AFTER_NEW | NO_CONTEXT;
NewHook(hp_internal, "luna_internal_renpy_call_host");
PyRunScript(LoadResData(L"renpy_hook_text", L"PYSOURCE").c_str());

View File

@ -136,7 +136,7 @@ struct hook_context
{
return (hook_context *)(lpDataBase - offsetof(hook_context, base));
}
inline uintptr_t &argof(int idx)
constexpr uintptr_t &argof(int idx)
{
#ifdef _WIN64
auto offset = 0;
@ -158,21 +158,15 @@ struct hook_context
#endif
}
};
#define regoffset(reg) ((int)offsetof(hook_context, reg) - (int)offsetof(hook_context, base))
#define stackoffset(idx) ((int)offsetof(hook_context, stack[idx]) - (int)offsetof(hook_context, base))
#define ___baseoffset (int)offsetof(hook_context, base)
#define regoffset(reg) ((int)offsetof(hook_context, reg) - ___baseoffset)
#define stackoffset(idx) ((int)offsetof(hook_context, stack[idx]) - ___baseoffset)
#define GETARG(i) (((int)(size_t) & reinterpret_cast<char const volatile &>((((hook_context *)0)->argof(i)))) - ___baseoffset)
#ifndef _WIN64
#define GETARG1 stackoffset(1)
#define GETARG2 stackoffset(2)
#define GETARG3 stackoffset(3)
#define GETARG4 stackoffset(4)
#define THISCALLARG1 stack[1]
#define LASTRETVAL eax
#define THISCALLTHIS ecx
#else
#define GETARG1 regoffset(rcx)
#define GETARG2 regoffset(rdx)
#define GETARG3 regoffset(r8)
#define GETARG4 regoffset(r9)
#define THISCALLARG1 rdx
#define LASTRETVAL rax
#define THISCALLTHIS rcx