From e06b8f27c8ee69c95d477d12e37fe8fece6bc73d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 9 Aug 2018 15:27:44 -0400 Subject: [PATCH] bugfix engine and add hook for renpy --- vnrhook/src/engine/engine.cc | 21 ++++++++++++++++++++- vnrhook/src/engine/engine.h | 1 + vnrhook/src/engine/match.cc | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/vnrhook/src/engine/engine.cc b/vnrhook/src/engine/engine.cc index 8f314db..305b7e6 100644 --- a/vnrhook/src/engine/engine.cc +++ b/vnrhook/src/engine/engine.cc @@ -5746,7 +5746,7 @@ void SpecialHookShina1(DWORD esp_base, HookParam *hp, BYTE, DWORD *data, DWORD * int GetShinaRioVersion() { int ret = 0; - HANDLE hFile = CreateFileW(L"RIO.INI", FILE_READ_DATA, FILE_SHARE_READ, nullptr, FILE_OPEN, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE hFile = CreateFileW(L"RIO.INI", FILE_READ_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { size_t len = ::wcslen(processName); if (len > 3) { @@ -16435,6 +16435,25 @@ bool InsertAdobeFlash10Hook() return true; } +bool InsertRenpyHook() +{ + HookParam hp = {}; + hp.address = (DWORD)GetProcAddress(GetModuleHandleW(L"python27"), "PyUnicodeUCS2_Format"); + if (!hp.address) + { + ConsoleOutput("NextHooker: Ren'py failed: failed to find python27.dll or PyUnicodeUCS2_Format"); + return false; + } + hp.offset = pusha_eax_off - 4; + hp.index = 0xc; + hp.length_offset = 0; + hp.split = pusha_ebx_off - 4; + hp.type = USING_STRING | USING_UNICODE | NO_CONTEXT | DATA_INDIRECT | USING_SPLIT; + //hp.filter_fun = [](void* str, auto, auto, auto) { return *(wchar_t*)str != L'%'; }; + NewHook(hp, "Ren'py"); + return true; +} + /** jichi 12/26/2014 Mono * Sample game: [141226] ハ�レ�めいと */ diff --git a/vnrhook/src/engine/engine.h b/vnrhook/src/engine/engine.h index 67560cf..8ec064a 100644 --- a/vnrhook/src/engine/engine.h +++ b/vnrhook/src/engine/engine.h @@ -132,6 +132,7 @@ bool InsertQLIEHook(); // QLiE: GameData/*.pack //bool InsertRai7Hook(); // Rai7puk: rai7.exe bool InsertRejetHook(); // Rejet: Module/{gd.dat,pf.dat,sd.dat} bool InsertRUGPHook(); // rUGP: rUGP.exe +bool InsertRenpyHook(); // Ren'py: python27.dll bool InsertRetouchHook(); // Retouch: resident.dll bool InsertRREHook(); // RunrunEngine: rrecfg.rcf bool InsertShinaHook(); // ShinaRio: Rio.ini diff --git a/vnrhook/src/engine/match.cc b/vnrhook/src/engine/match.cc index 80c5b80..d34f00a 100644 --- a/vnrhook/src/engine/match.cc +++ b/vnrhook/src/engine/match.cc @@ -99,6 +99,13 @@ bool DetermineEngineByFile1() return true; } + // Artikash 8/9/2018: Renpy - sample game https://vndb.org/v19843 + if (GetModuleHandleW(L"python27")) + { + InsertRenpyHook(); + return true; + } + if (Util::CheckFile(L"*.xp3") || Util::SearchResourceString(L"TVP(KIRIKIRI)")) { if (Util::SearchResourceString(L"TVP(KIRIKIRI) Z ")) { // TVP(KIRIKIRI) Z CORE // jichi 11/24/2014: Disabled that might crash VBH