better renpy hook

This commit is contained in:
Akash Mozumdar 2020-01-16 17:48:31 -07:00
parent 2482c26316
commit 622a7214f3

View File

@ -16658,11 +16658,18 @@ bool InsertAdobeFlash10Hook()
*/
bool InsertRenpyHook()
{
for (int pythonMinorVersion = 0; pythonMinorVersion <= 8; ++pythonMinorVersion)
{
wchar_t python[] = L"python2X.dll";
python[7] = L'0' + pythonMinorVersion;
if (HMODULE module = GetModuleHandleW(python))
{
wcscpy_s(spDefault.exportModule, python);
HookParam hp = {};
hp.address = (DWORD)GetProcAddress(GetModuleHandleW(L"python27"), "PyUnicodeUCS2_Format");
hp.address = (DWORD)GetProcAddress(module, "PyUnicodeUCS2_Format");
if (!hp.address)
{
ConsoleOutput("Textractor: Ren'py failed: failed to find python27.dll or PyUnicodeUCS2_Format");
ConsoleOutput("Textractor: Ren'py failed: failed to find PyUnicodeUCS2_Format");
return false;
}
hp.offset = 4;
@ -16674,6 +16681,10 @@ bool InsertRenpyHook()
NewHook(hp, "Ren'py");
return true;
}
}
ConsoleOutput("Textractor: Ren'py failed: failed to find python2X.dll");
return false;
}
void InsertMonoHook(HMODULE h)
{