migrate off legacy api calls

This commit is contained in:
Akash Mozumdar 2018-06-15 04:32:35 -04:00
parent b7764ad860
commit 5890f0022c
7 changed files with 157 additions and 245 deletions

View File

@ -952,19 +952,6 @@ BOOL IthCheckFile(LPCWSTR file)
if (hFile != INVALID_HANDLE_VALUE) { if (hFile != INVALID_HANDLE_VALUE) {
CloseHandle(hFile); CloseHandle(hFile);
return TRUE; return TRUE;
} else if (!wcschr(file, L':')) { // jichi: this is relative path
// jichi 9/22/2013: Change current directory to the same as main module path
// Otherwise NtFile* would not work for files with relative paths.
if (const wchar_t *path = GetMainModulePath()) // path to VNR's python exe
if (const wchar_t *base = wcsrchr(path, L'\\')) {
size_t dirlen = base - path + 1;
if (dirlen + wcslen(file) < MAX_PATH) {
wchar_t buf[MAX_PATH];
wcsncpy(buf, path, dirlen);
wcscpy(buf + dirlen, file);
return IthCheckFile(buf);
}
}
} }
} else { // not wine } else { // not wine
HANDLE hFile; HANDLE hFile;

View File

@ -7,56 +7,18 @@
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(disable:4800) // C4800: forcing value to bool # pragma warning(disable:4800) // C4800: forcing value to bool
#endif // _MSC_VER #endif // _MSC_VER
#include "ntdll/ntdll.h" #include "ntdll/ntdll.h"
// jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming? // jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming?
extern "C" { extern "C" {
//int disasm(BYTE *opcode0); // jichi 8/15/2013: move disasm to separate file
extern WORD *NlsAnsiCodePage;
int FillRange(LPCWSTR name,DWORD *lower, DWORD *upper); int FillRange(LPCWSTR name,DWORD *lower, DWORD *upper);
int MB_WC(char *mb, wchar_t *wc);
//int MB_WC_count(char *mb, int mb_length);
int WC_MB(wchar_t *wc, char *mb);
// jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0 // jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0
DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP
// jichi 2/5/2014: The same as SearchPattern except it uses 0xff to match everything
// According to @Andys, 0xff seldom appear in the source code: http://sakuradite.com/topic/124
enum : BYTE { SP_ANY = 0xff };
#define SP_ANY_2 SP_ANY,SP_ANY
#define SP_ANY_3 SP_ANY,SP_ANY,SP_ANY
#define SP_ANY_4 SP_ANY,SP_ANY,SP_ANY,SP_ANY
DWORD SearchPatternEx(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length, BYTE wildcard=SP_ANY);
BOOL IthInitSystemService();
void IthCloseSystemService();
DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size); DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size);
BOOL IthCheckFile(LPCWSTR file);
BOOL IthFindFile(LPCWSTR file);
BOOL IthGetFileInfo(LPCWSTR file, LPVOID info, DWORD size = 0x1000); BOOL IthGetFileInfo(LPCWSTR file, LPVOID info, DWORD size = 0x1000);
BOOL IthCheckFileFullPath(LPCWSTR file);
HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition);
HANDLE IthCreateFileInDirectory(LPCWSTR name, HANDLE dir, DWORD option, DWORD share, DWORD disposition);
HANDLE IthCreateDirectory(LPCWSTR name);
HANDLE IthCreateFileFullPath(LPCWSTR fullpath, DWORD option, DWORD share, DWORD disposition);
HANDLE IthPromptCreateFile(DWORD option, DWORD share, DWORD disposition);
HANDLE IthCreateSection(LPCWSTR name, DWORD size, DWORD right);
HANDLE IthCreateEvent(LPCWSTR name, DWORD auto_reset=0, DWORD init_state=0);
HANDLE IthOpenEvent(LPCWSTR name);
void IthSetEvent(HANDLE hEvent);
void IthResetEvent(HANDLE hEvent);
HANDLE IthCreateMutex(LPCWSTR name, BOOL InitialOwner, DWORD *exist=0);
HANDLE IthOpenMutex(LPCWSTR name);
BOOL IthReleaseMutex(HANDLE hMutex);
//DWORD IthWaitForSingleObject(HANDLE hObject, DWORD dwTime);
HANDLE IthCreateThread(LPCVOID start_addr, DWORD param, HANDLE hProc=(HANDLE)-1);
DWORD GetExportAddress(DWORD hModule,DWORD hash); DWORD GetExportAddress(DWORD hModule,DWORD hash);
void IthSleep(int time); // jichi 9/28/2013: in ms
void IthSystemTimeToLocalTime(LARGE_INTEGER *ptime);
void FreeThreadStart(HANDLE hProc);
void CheckThreadStart();
} // extern "C" } // extern "C"
#ifdef ITH_HAS_HEAP #ifdef ITH_HAS_HEAP
@ -78,55 +40,6 @@ inline DWORD GetHash(LPSTR str)
return hash; return hash;
} }
inline DWORD GetHash(LPCWSTR str)
{
DWORD hash = 0;
//for (; *str; str++)
while (*str)
hash = ((hash>>7) | (hash<<25)) + *str++;
return hash;
}
inline void IthBreak()
{ if (debug) __debugbreak(); }
inline LPCWSTR GetMainModulePath()
{
__asm
{
mov eax, fs:[0x30]
mov eax, [eax + 0xC]
mov eax, [eax + 0xC]
mov eax, [eax + 0x28]
}
}
// jichi 9/28/2013: Add this to lock NtWriteFile in wine
class IthMutexLocker
{
HANDLE m;
public:
explicit IthMutexLocker(HANDLE mutex) : m(mutex)
{ NtWaitForSingleObject(m, 0, 0); }
~IthMutexLocker() { if (m != INVALID_HANDLE_VALUE) IthReleaseMutex(m); }
bool locked() const { return m != INVALID_HANDLE_VALUE; }
void unlock() { if (m != INVALID_HANDLE_VALUE) { IthReleaseMutex(m); m = INVALID_HANDLE_VALUE; } }
};
void IthCoolDown();
BOOL IthIsWine(); BOOL IthIsWine();
BOOL IthIsWindowsXp();
//BOOL IthIsWindows8OrGreater(); // not public
/** Get current dll path.
* @param buf
* @param len
* @return length of the path excluding \0
*/
size_t IthGetCurrentModulePath(wchar_t *buf, size_t len);
// EOF // EOF

View File

@ -4368,7 +4368,7 @@ void SpecialHookRUGP1(DWORD esp_base, HookParam *hp, BYTE, DWORD *data, DWORD *s
bool InsertRUGP1Hook() bool InsertRUGP1Hook()
{ {
DWORD low, high; DWORD low, high;
if (!IthCheckFile(L"rvmm.dll") || !SafeFillRange(L"rvmm.dll", &low, &high)) { if (!Util::CheckFile(L"rvmm.dll") || !SafeFillRange(L"rvmm.dll", &low, &high)) {
ConsoleOutput("vnreng:rUGP: rvmm.dll does not exist"); ConsoleOutput("vnreng:rUGP: rvmm.dll does not exist");
return false; return false;
} }
@ -4511,7 +4511,7 @@ bool InsertRUGP1Hook()
bool InsertRUGP2Hook() bool InsertRUGP2Hook()
{ {
DWORD low, high; DWORD low, high;
if (!IthCheckFile(L"vm60.dll") || !SafeFillRange(L"vm60.dll", &low, &high)) { if (!Util::CheckFile(L"vm60.dll") || !SafeFillRange(L"vm60.dll", &low, &high)) {
ConsoleOutput("vnreng:rUGP2: vm60.dll does not exist"); ConsoleOutput("vnreng:rUGP2: vm60.dll does not exist");
return false; return false;
} }
@ -5546,7 +5546,7 @@ static bool InsertSystem43NewHook(ULONG startAddress, ULONG stopAddress, LPCSTR
bool InsertSystem43Hook() bool InsertSystem43Hook()
{ {
//bool patched = IthCheckFile(L"AliceRunPatch.dll"); //bool patched = Util::CheckFile(L"AliceRunPatch.dll");
bool patched = ::GetModuleHandleA("AliceRunPatch.dll"); bool patched = ::GetModuleHandleA("AliceRunPatch.dll");
ULONG startAddress, stopAddress; ULONG startAddress, stopAddress;
if (patched ? if (patched ?
@ -5777,7 +5777,7 @@ void SpecialHookShina1(DWORD esp_base, HookParam *hp, BYTE, DWORD *data, DWORD *
int GetShinaRioVersion() int GetShinaRioVersion()
{ {
int ret = 0; int ret = 0;
HANDLE hFile = IthCreateFile(L"RIO.INI", FILE_READ_DATA, FILE_SHARE_READ, FILE_OPEN); HANDLE hFile = CreateFileW(L"RIO.INI", FILE_READ_DATA, FILE_SHARE_READ, nullptr, FILE_OPEN, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) { if (hFile == INVALID_HANDLE_VALUE) {
size_t len = ::wcslen(process_name_); size_t len = ::wcslen(process_name_);
if (len > 3) { if (len > 3) {
@ -5786,7 +5786,7 @@ int GetShinaRioVersion()
fname[len -1] = 'i'; fname[len -1] = 'i';
fname[len -2] = 'n'; fname[len -2] = 'n';
fname[len -3] = 'i'; fname[len -3] = 'i';
hFile = IthCreateFile(fname, FILE_READ_DATA, FILE_SHARE_READ, FILE_OPEN); hFile = CreateFileW(fname, FILE_READ_DATA, FILE_SHARE_READ, nullptr, FILE_OPEN, FILE_ATTRIBUTE_NORMAL, nullptr);
} }
} }
@ -5795,7 +5795,7 @@ int GetShinaRioVersion()
//char *buffer,*version;//,*ptr; //char *buffer,*version;//,*ptr;
enum { BufferSize = 0x40 }; enum { BufferSize = 0x40 };
char buffer[BufferSize]; char buffer[BufferSize];
NtReadFile(hFile, 0, 0, 0, &ios, buffer, BufferSize, 0, 0); ReadFile(hFile, buffer, BufferSize, nullptr, nullptr);
CloseHandle(hFile); CloseHandle(hFile);
if (buffer[0] == '[') { if (buffer[0] == '[') {
buffer[0x3f] = 0; // jichi 8/24/2013: prevent strstr from overflow buffer[0x3f] = 0; // jichi 8/24/2013: prevent strstr from overflow
@ -6515,7 +6515,7 @@ bool InsertCatSystemHook()
hp.length_offset = 1; // only 1 character hp.length_offset = 1; // only 1 character
// jichi 12/23/2014: Modify split for new catsystem // jichi 12/23/2014: Modify split for new catsystem
bool newEngine = IthCheckFile(L"cs2conf.dll"); bool newEngine = Util::CheckFile(L"cs2conf.dll");
if (newEngine) { if (newEngine) {
hp.text_fun = SpecialHookCatSystem3; // type not needed hp.text_fun = SpecialHookCatSystem3; // type not needed
NewHook(hp, "CatSystem3"); NewHook(hp, "CatSystem3");
@ -7106,7 +7106,7 @@ bool InsertMalie4Hook()
bool InsertMalieHook() bool InsertMalieHook()
{ {
if (IthCheckFile(L"tools.dll")) if (Util::CheckFile(L"tools.dll"))
return InsertMalieHook1(); // jichi 3/5/2015: For old light games such as Dies irae. return InsertMalieHook1(); // jichi 3/5/2015: For old light games such as Dies irae.
else { // For old Malie games before 2015 else { // For old Malie games before 2015
@ -7115,8 +7115,8 @@ bool InsertMalieHook()
bool ok = false; bool ok = false;
// jichi 3/12/2015: Disable MalieHook2 which will crash シルヴァリオ ヴェンッ<E383B3> // jichi 3/12/2015: Disable MalieHook2 which will crash シルヴァリオ ヴェンッ<E383B3>
//if (!IthCheckFile(L"gdiplus.dll")) //if (!Util::CheckFile(L"gdiplus.dll"))
if (IthFindFile(L"System\\*")) { // Insert old Malie hook. There are usually System/cursor.cur if (Util::CheckFile(L"System\\*")) { // Insert old Malie hook. There are usually System/cursor.cur
ok = InsertMalieHook2() || ok; ok = InsertMalieHook2() || ok;
ok = InsertMalie2Hook() || ok; // jichi 8/20/2013 ok = InsertMalie2Hook() || ok; // jichi 8/20/2013
} }
@ -7694,7 +7694,7 @@ bool InsertLiveHook()
void InsertBrunsHook() void InsertBrunsHook()
{ {
if (IthCheckFile(L"libscr.dll")) { if (Util::CheckFile(L"libscr.dll")) {
HookParam hp = {}; HookParam hp = {};
hp.offset = 4; hp.offset = 4;
hp.length_offset = 1; hp.length_offset = 1;
@ -7702,13 +7702,13 @@ void InsertBrunsHook()
// jichi 12/27/2013: This function does not work for the latest bruns games anymore // jichi 12/27/2013: This function does not work for the latest bruns games anymore
hp.function = 0x8b24c7bc; hp.function = 0x8b24c7bc;
//?push_back@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXG@Z //?push_back@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXG@Z
if (IthCheckFile(L"msvcp90.dll")) if (Util::CheckFile(L"msvcp90.dll"))
hp.module = 0xc9c36a5b; // 3385027163 hp.module = 0xc9c36a5b; // 3385027163
else if (IthCheckFile(L"msvcp80.dll")) else if (Util::CheckFile(L"msvcp80.dll"))
hp.module = 0xa9c36a5b; // 2848156251 hp.module = 0xa9c36a5b; // 2848156251
else if (IthCheckFile(L"msvcp100.dll")) // jichi 8/17/2013: MSVCRT 10.0 and 11.0 else if (Util::CheckFile(L"msvcp100.dll")) // jichi 8/17/2013: MSVCRT 10.0 and 11.0
hp.module = 0xb571d760; // 3044136800; hp.module = 0xb571d760; // 3044136800;
else if (IthCheckFile(L"msvcp110.dll")) else if (Util::CheckFile(L"msvcp110.dll"))
hp.module = 0xd571d760; // 3581007712; hp.module = 0xd571d760; // 3581007712;
if (hp.module) { if (hp.module) {
ConsoleOutput("vnreng: INSERT Brus#1"); ConsoleOutput("vnreng: INSERT Brus#1");
@ -7974,7 +7974,7 @@ bool InsertCandyHook2()
bool InsertCandyHook() bool InsertCandyHook()
{ {
//if (0 == _wcsicmp(process_name_, L"systemc.exe")) //if (0 == _wcsicmp(process_name_, L"systemc.exe"))
if (IthCheckFile(L"SystemC.exe")) if (Util::CheckFile(L"SystemC.exe"))
return InsertCandyHook1(); return InsertCandyHook1();
else else
return InsertCandyHook2(); return InsertCandyHook2();
@ -8432,13 +8432,13 @@ int GetSystemAoiVersion() // return result is cached
{ {
static int ret = 0; static int ret = 0;
if (!ret) { if (!ret) {
if (IthCheckFile(L"Aoi4.dll")) if (Util::CheckFile(L"Aoi4.dll"))
ret = 4; ret = 4;
else if (IthCheckFile(L"Aoi5.dll")) else if (Util::CheckFile(L"Aoi5.dll"))
ret = 5; ret = 5;
else if (IthCheckFile(L"Aoi6.dll")) // not exist yet, for future version else if (Util::CheckFile(L"Aoi6.dll")) // not exist yet, for future version
ret = 6; ret = 6;
else if (IthCheckFile(L"Aoi7.dll")) // not exist yet, for future version else if (Util::CheckFile(L"Aoi7.dll")) // not exist yet, for future version
ret = 7; ret = 7;
else // AoiLib.dll, etc else // AoiLib.dll, etc
ret = 3; ret = 3;

View File

@ -42,7 +42,7 @@ namespace Engine { namespace { // unnamed
bool DetermineGameHooks() // 7/19/2015 bool DetermineGameHooks() // 7/19/2015
{ {
#if 0 // jichi 7/19/2015: Disabled as it will crash the game #if 0 // jichi 7/19/2015: Disabled as it will crash the game
if (IthFindFile(L"UE3ShaderCompileWorker.exe") && IthFindFile(L"awesomium_process.exe")) { if (Util::CheckFile(L"UE3ShaderCompileWorker.exe") && Util::CheckFile(L"awesomium_process.exe")) {
InsertLovaGameHook(); InsertLovaGameHook();
return true; return true;
} }
@ -58,23 +58,23 @@ bool DeterminePCEngine()
return true; return true;
} }
if (IthFindFile(L"PPSSPP*.exe")) { // jichi 7/12/2014 PPSSPPWindows.exe, PPSSPPEX.exe PPSSPPSP.exe if (Util::CheckFile(L"PPSSPP*.exe")) { // jichi 7/12/2014 PPSSPPWindows.exe, PPSSPPEX.exe PPSSPPSP.exe
InsertPPSSPPHooks(); InsertPPSSPPHooks();
return true; return true;
} }
if (IthFindFile(L"pcsx2*.exe")) { // jichi 7/19/2014 PCSX2.exe or PCSX2WX.exe if (Util::CheckFile(L"pcsx2*.exe")) { // jichi 7/19/2014 PCSX2.exe or PCSX2WX.exe
InsertPCSX2Hooks(); InsertPCSX2Hooks();
return true; return true;
} }
if (IthFindFile(L"Dolphin.exe")) { // jichi 7/20/2014 if (Util::CheckFile(L"Dolphin.exe")) { // jichi 7/20/2014
InsertGCHooks(); InsertGCHooks();
return true; return true;
} }
// jichi 5/14/2015: Skip hijacking BALDRSKY ZEROs // jichi 5/14/2015: Skip hijacking BALDRSKY ZEROs
if (IthCheckFile(L"bsz_Data\\Mono\\mono.dll") || IthCheckFile(L"bsz2_Data\\Mono\\mono.dll")) { if (Util::CheckFile(L"bsz_Data\\Mono\\mono.dll") || Util::CheckFile(L"bsz2_Data\\Mono\\mono.dll")) {
ConsoleOutput("vnreng: IGNORE BALDRSKY ZEROs"); ConsoleOutput("vnreng: IGNORE BALDRSKY ZEROs");
return true; return true;
} }
@ -96,12 +96,12 @@ bool DeterminePCEngine()
bool DetermineEngineByFile1() bool DetermineEngineByFile1()
{ {
if (IthFindFile(L"*.xp3") || Util::SearchResourceString(L"TVP(KIRIKIRI)")) { if (Util::CheckFile(L"*.xp3") || Util::SearchResourceString(L"TVP(KIRIKIRI)")) {
if (Util::SearchResourceString(L"TVP(KIRIKIRI) Z ")) { // TVP(KIRIKIRI) Z CORE if (Util::SearchResourceString(L"TVP(KIRIKIRI) Z ")) { // TVP(KIRIKIRI) Z CORE
// jichi 11/24/2014: Disabled that might crash VBH // jichi 11/24/2014: Disabled that might crash VBH
//if (IthCheckFile(L"plugin\\KAGParser.dll")) //if (Util::CheckFile(L"plugin\\KAGParser.dll"))
// InsertKAGParserHook(); // InsertKAGParserHook();
//else if (IthCheckFile(L"plugin\\KAGParserEx.dll")) //else if (Util::CheckFile(L"plugin\\KAGParserEx.dll"))
// InsertKAGParserExHook(); // InsertKAGParserExHook();
if (InsertKiriKiriZHook()) if (InsertKiriKiriZHook())
return true; return true;
@ -120,89 +120,89 @@ bool DetermineEngineByFile1()
InsertSideBHook(); InsertSideBHook();
return true; return true;
} }
if (IthFindFile(L"bgi.*") || IthFindFile(L"sysgrp.arc")) { if (Util::CheckFile(L"bgi.*") || Util::CheckFile(L"sysgrp.arc")) {
InsertBGIHook(); InsertBGIHook();
return true; return true;
} }
if (IthCheckFile(L"Bootup.dat") && InsertBootupHook()) // 5/22/2015 Bootup if (Util::CheckFile(L"Bootup.dat") && InsertBootupHook()) // 5/22/2015 Bootup
// lstrlenW can also find text with repetition though // lstrlenW can also find text with repetition though
return true; return true;
if (IthCheckFile(L"AGERC.DLL")) { // 6/1/2014 jichi: Eushully, AGE.EXE if (Util::CheckFile(L"AGERC.DLL")) { // 6/1/2014 jichi: Eushully, AGE.EXE
InsertEushullyHook(); InsertEushullyHook();
return true; return true;
} }
if (IthFindFile(L"data*.arc") && IthFindFile(L"stream*.arc")) { if (Util::CheckFile(L"data*.arc") && Util::CheckFile(L"stream*.arc")) {
InsertMajiroHook(); InsertMajiroHook();
return true; return true;
} }
// jichi 5/31/2014 // jichi 5/31/2014
if (//IthCheckFile(L"Silkys.exe") || // It might or might not have Silkys.exe if (//Util::CheckFile(L"Silkys.exe") || // It might or might not have Silkys.exe
// data, effect, layer, mes, music // data, effect, layer, mes, music
IthCheckFile(L"data.arc") && IthCheckFile(L"effect.arc") && IthCheckFile(L"mes.arc")) { Util::CheckFile(L"data.arc") && Util::CheckFile(L"effect.arc") && Util::CheckFile(L"mes.arc")) {
InsertElfHook(); InsertElfHook();
return true; return true;
} }
// jichi 6/9/2015: Skip Silkys Sakura // jichi 6/9/2015: Skip Silkys Sakura
if ( // Almost the same as Silkys except mes.arc is replaced by Script.arc if ( // Almost the same as Silkys except mes.arc is replaced by Script.arc
IthCheckFile(L"data.arc") && IthCheckFile(L"effect.arc") && IthCheckFile(L"Script.arc")) { Util::CheckFile(L"data.arc") && Util::CheckFile(L"effect.arc") && Util::CheckFile(L"Script.arc")) {
InsertSilkysHook(); InsertSilkysHook();
return true; return true;
} }
if (IthFindFile(L"data\\pack\\*.cpz")) { if (Util::CheckFile(L"data\\pack\\*.cpz")) {
InsertCMVSHook(); InsertCMVSHook();
return true; return true;
} }
// jichi 10/12/2013: Restore wolf engine // jichi 10/12/2013: Restore wolf engine
// jichi 10/18/2013: Check for data/*.wolf // jichi 10/18/2013: Check for data/*.wolf
if (IthFindFile(L"data.wolf") || IthFindFile(L"data\\*.wolf")) { if (Util::CheckFile(L"data.wolf") || Util::CheckFile(L"data\\*.wolf")) {
InsertWolfHook(); InsertWolfHook();
return true; return true;
} }
if (IthCheckFile(L"AdvData\\DAT\\NAMES.DAT")) { if (Util::CheckFile(L"AdvData\\DAT\\NAMES.DAT")) {
InsertCircusHook1(); InsertCircusHook1();
return true; return true;
} }
if (IthCheckFile(L"AdvData\\GRP\\NAMES.DAT")) { if (Util::CheckFile(L"AdvData\\GRP\\NAMES.DAT")) {
InsertCircusHook2(); InsertCircusHook2();
return true; return true;
} }
if (IthFindFile(L"*.noa") || IthFindFile(L"data\\*.noa")) { if (Util::CheckFile(L"*.noa") || Util::CheckFile(L"data\\*.noa")) {
InsertCotophaHook(); InsertCotophaHook();
return true; return true;
} }
if (IthFindFile(L"*.pfs")) { // jichi 10/1/2013 if (Util::CheckFile(L"*.pfs")) { // jichi 10/1/2013
InsertArtemisHook(); InsertArtemisHook();
return true; return true;
} }
if (IthFindFile(L"*.int")) { if (Util::CheckFile(L"*.int")) {
InsertCatSystemHook(); InsertCatSystemHook();
return true; return true;
} }
if (IthCheckFile(L"message.dat")) { if (Util::CheckFile(L"message.dat")) {
InsertAtelierHook(); InsertAtelierHook();
return true; return true;
} }
if (IthCheckFile(L"Check.mdx")) { // jichi 4/1/2014: AUGame if (Util::CheckFile(L"Check.mdx")) { // jichi 4/1/2014: AUGame
InsertTencoHook(); InsertTencoHook();
return true; return true;
} }
// jichi 12/25/2013: It may or may not be QLIE. // jichi 12/25/2013: It may or may not be QLIE.
// AlterEgo also has GameData/sound.pack but is not QLIE // AlterEgo also has GameData/sound.pack but is not QLIE
if (IthFindFile(L"GameData\\*.pack") && InsertQLIEHook()) if (Util::CheckFile(L"GameData\\*.pack") && InsertQLIEHook())
return true; return true;
if (IthCheckFile(L"dll\\Pal.dll")) { if (Util::CheckFile(L"dll\\Pal.dll")) {
InsertPalHook(); InsertPalHook();
return true; return true;
} }
if (IthFindFile(L"*.pac")) { if (Util::CheckFile(L"*.pac")) {
// jichi 6/3/2014: AMUSE CRAFT and SOFTPAL // jichi 6/3/2014: AMUSE CRAFT and SOFTPAL
// Selectively insert, so that lstrlenA can still get correct text if failed // Selectively insert, so that lstrlenA can still get correct text if failed
//if (IthCheckFile(L"dll\\resource.dll") && IthCheckFile(L"dll\\pal.dll") && InsertAmuseCraftHook()) //if (Util::CheckFile(L"dll\\resource.dll") && Util::CheckFile(L"dll\\pal.dll") && InsertAmuseCraftHook())
// return true; // return true;
if (IthCheckFile(L"Thumbnail.pac")) { if (Util::CheckFile(L"Thumbnail.pac")) {
//ConsoleOutput("vnreng: IGNORE NeXAS"); //ConsoleOutput("vnreng: IGNORE NeXAS");
InsertNeXASHook(); // jichi 7/6/2014: GIGA InsertNeXASHook(); // jichi 7/6/2014: GIGA
return true; return true;
@ -214,23 +214,23 @@ bool DetermineEngineByFile1()
} }
} }
// jichi 12/27/2014: LunaSoft // jichi 12/27/2014: LunaSoft
if (IthFindFile(L"Pac\\*.pac")) { if (Util::CheckFile(L"Pac\\*.pac")) {
InsertLunaSoftHook(); InsertLunaSoftHook();
return true; return true;
} }
// jichi 9/16/2013: Add Gesen18 // jichi 9/16/2013: Add Gesen18
if (IthFindFile(L"*.szs") || IthFindFile(L"Data\\*.szs")) { if (Util::CheckFile(L"*.szs") || Util::CheckFile(L"Data\\*.szs")) {
InsertUnicornHook(); InsertUnicornHook();
return true; return true;
} }
// jichi 12/22/2013: Add rejet // jichi 12/22/2013: Add rejet
if (IthCheckFile(L"gd.dat") && IthCheckFile(L"pf.dat") && IthCheckFile(L"sd.dat")) { if (Util::CheckFile(L"gd.dat") && Util::CheckFile(L"pf.dat") && Util::CheckFile(L"sd.dat")) {
InsertRejetHook(); InsertRejetHook();
return true; return true;
} }
// Only examined with version 1.0 // Only examined with version 1.0
//if (IthFindFile(L"Adobe AIR\\Versions\\*\\Adobe AIR.dll")) { // jichi 4/15/2014: FIXME: Wildcard not working //if (Util::CheckFile(L"Adobe AIR\\Versions\\*\\Adobe AIR.dll")) { // jichi 4/15/2014: FIXME: Wildcard not working
if (IthCheckFile(L"Adobe AIR\\Versions\\1.0\\Adobe AIR.dll")) { // jichi 4/15/2014: Adobe AIR if (Util::CheckFile(L"Adobe AIR\\Versions\\1.0\\Adobe AIR.dll")) { // jichi 4/15/2014: Adobe AIR
InsertAdobeAirHook(); InsertAdobeAirHook();
return true; return true;
} }
@ -239,51 +239,51 @@ bool DetermineEngineByFile1()
bool DetermineEngineByFile2() bool DetermineEngineByFile2()
{ {
if (IthCheckFile(L"resident.dll")) { if (Util::CheckFile(L"resident.dll")) {
InsertRetouchHook(); InsertRetouchHook();
return true; return true;
} }
if (IthCheckFile(L"Malie.ini") || IthCheckFile(L"Malie.exe")) { // jichi: 9/9/2014: Add malie.exe in case malie.ini is missing if (Util::CheckFile(L"Malie.ini") || Util::CheckFile(L"Malie.exe")) { // jichi: 9/9/2014: Add malie.exe in case malie.ini is missing
InsertMalieHook(); InsertMalieHook();
return true; return true;
} }
if (IthCheckFile(L"live.dll")) { if (Util::CheckFile(L"live.dll")) {
InsertLiveHook(); InsertLiveHook();
return true; return true;
} }
// 9/5/2013 jichi // 9/5/2013 jichi
if (IthCheckFile(L"aInfo.db")) { if (Util::CheckFile(L"aInfo.db")) {
InsertNextonHook(); InsertNextonHook();
return true; return true;
} }
if (IthFindFile(L"*.lpk")) { if (Util::CheckFile(L"*.lpk")) {
InsertLucifenHook(); InsertLucifenHook();
return true; return true;
} }
if (IthCheckFile(L"cfg.pak")) { if (Util::CheckFile(L"cfg.pak")) {
InsertWaffleHook(); InsertWaffleHook();
return true; return true;
} }
if (IthCheckFile(L"Arc00.dat")) { if (Util::CheckFile(L"Arc00.dat")) {
InsertTinkerBellHook(); InsertTinkerBellHook();
return true; return true;
} }
if (IthFindFile(L"*.vfs")) { // jichi 7/6/2014: Better to test AoiLib.dll? ja.wikipedia.org/wiki/ソフトハウスキャラ if (Util::CheckFile(L"*.vfs")) { // jichi 7/6/2014: Better to test AoiLib.dll? ja.wikipedia.org/wiki/ソフトハウスキャラ
InsertSystemAoiHook(); InsertSystemAoiHook();
return true; return true;
} }
if (IthFindFile(L"*.mbl")) { if (Util::CheckFile(L"*.mbl")) {
InsertMBLHook(); InsertMBLHook();
return true; return true;
} }
// jichi 8/1/2014: YU-RIS engine, lots of clockup game also has this pattern // jichi 8/1/2014: YU-RIS engine, lots of clockup game also has this pattern
if (IthFindFile(L"pac\\*.ypf") || IthFindFile(L"*.ypf")) { if (Util::CheckFile(L"pac\\*.ypf") || Util::CheckFile(L"*.ypf")) {
// jichi 8/14/2013: CLOCLUP: "ノーブレスオブリージュ" would crash the game. // jichi 8/14/2013: CLOCLUP: "ノーブレスオブリージュ" would crash the game.
if (!IthCheckFile(L"noblesse.exe")) if (!Util::CheckFile(L"noblesse.exe"))
InsertYurisHook(); InsertYurisHook();
return true; return true;
} }
if (IthFindFile(L"*.npa")) { if (Util::CheckFile(L"*.npa")) {
InsertNitroplusHook(); InsertNitroplusHook();
return true; return true;
} }
@ -292,7 +292,7 @@ bool DetermineEngineByFile2()
bool DetermineEngineByFile3() bool DetermineEngineByFile3()
{ {
//if (IthCheckFile(L"libscr.dll")) { // already checked //if (Util::CheckFile(L"libscr.dll")) { // already checked
// InsertBrunsHook(); // InsertBrunsHook();
// return true; // return true;
//} //}
@ -304,48 +304,48 @@ bool DetermineEngineByFile3()
// -loadpath // -loadpath
// . // .
// am.cfg // am.cfg
if (IthCheckFile(L"args.txt")) { if (Util::CheckFile(L"args.txt")) {
InsertBrunsHook(); InsertBrunsHook();
return true; return true;
} }
if (IthCheckFile(L"emecfg.ecf")) { if (Util::CheckFile(L"emecfg.ecf")) {
InsertEMEHook(); InsertEMEHook();
return true; return true;
} }
if (IthCheckFile(L"rrecfg.rcf")) { if (Util::CheckFile(L"rrecfg.rcf")) {
InsertRREHook(); InsertRREHook();
return true; return true;
} }
if (IthFindFile(L"*.fpk") || IthFindFile(L"data\\*.fpk")) { if (Util::CheckFile(L"*.fpk") || Util::CheckFile(L"data\\*.fpk")) {
InsertCandyHook(); InsertCandyHook();
return true; return true;
} }
if (IthFindFile(L"arc.a*")) { if (Util::CheckFile(L"arc.a*")) {
InsertApricoTHook(); InsertApricoTHook();
return true; return true;
} }
if (IthFindFile(L"*.mpk")) { if (Util::CheckFile(L"*.mpk")) {
InsertStuffScriptHook(); InsertStuffScriptHook();
return true; return true;
} }
if (IthFindFile(L"USRDIR\\*.mpk")) { // jichi 12/2/2014 if (Util::CheckFile(L"USRDIR\\*.mpk")) { // jichi 12/2/2014
InsertStuffScriptHook(); InsertStuffScriptHook();
return true; return true;
} }
if (IthCheckFile(L"Execle.exe")) { if (Util::CheckFile(L"Execle.exe")) {
InsertTriangleHook(); InsertTriangleHook();
return true; return true;
} }
// jichi 2/28/2015: No longer work for "大正×対称アリス episode I" from Primula // jichi 2/28/2015: No longer work for "大正×対称アリス episode I" from Primula
//if (IthCheckFile(L"PSetup.exe")) { //if (Util::CheckFile(L"PSetup.exe")) {
// InsertPensilHook(); // InsertPensilHook();
// return true; // return true;
//} //}
if (IthCheckFile(L"Yanesdk.dll")) { if (Util::CheckFile(L"Yanesdk.dll")) {
InsertAB2TryHook(); InsertAB2TryHook();
return true; return true;
} }
if (IthFindFile(L"*.med")) { if (Util::CheckFile(L"*.med")) {
InsertMEDHook(); InsertMEDHook();
return true; return true;
} }
@ -354,57 +354,57 @@ bool DetermineEngineByFile3()
bool DetermineEngineByFile4() bool DetermineEngineByFile4()
{ {
if (IthCheckFile(L"EAGLS.dll")) { // jichi 3/24/2014: E.A.G.L.S if (Util::CheckFile(L"EAGLS.dll")) { // jichi 3/24/2014: E.A.G.L.S
//ConsoleOutput("vnreng: IGNORE EAGLS"); //ConsoleOutput("vnreng: IGNORE EAGLS");
InsertEaglsHook(); InsertEaglsHook();
return true; return true;
} }
if (IthCheckFile(L"bmp.pak") && IthCheckFile(L"dsetup.dll")) { if (Util::CheckFile(L"bmp.pak") && Util::CheckFile(L"dsetup.dll")) {
// 1/1/2016 jich: skip izumo4 from studio ego that is not supported by debonosu // 1/1/2016 jich: skip izumo4 from studio ego that is not supported by debonosu
if (IthFindFile(L"*izumo4*.exe")) { if (Util::CheckFile(L"*izumo4*.exe")) {
PcHooks::hookLstrFunctions(); PcHooks::hookLstrFunctions();
return true; return true;
} }
InsertDebonosuHook(); InsertDebonosuHook();
return true; return true;
} }
if (IthCheckFile(L"C4.EXE") || IthCheckFile(L"XEX.EXE")) { if (Util::CheckFile(L"C4.EXE") || Util::CheckFile(L"XEX.EXE")) {
InsertC4Hook(); InsertC4Hook();
return true; return true;
} }
if (IthCheckFile(L"Rio.arc") && IthFindFile(L"Chip*.arc")) { if (Util::CheckFile(L"Rio.arc") && Util::CheckFile(L"Chip*.arc")) {
InsertWillPlusHook(); InsertWillPlusHook();
return true; return true;
} }
if (IthFindFile(L"*.tac")) { if (Util::CheckFile(L"*.tac")) {
InsertTanukiHook(); InsertTanukiHook();
return true; return true;
} }
if (IthFindFile(L"*.gxp")) { if (Util::CheckFile(L"*.gxp")) {
InsertGXPHook(); InsertGXPHook();
return true; return true;
} }
if (IthFindFile(L"*.aos")) { // jichi 4/2/2014: AOS hook if (Util::CheckFile(L"*.aos")) { // jichi 4/2/2014: AOS hook
InsertAOSHook(); InsertAOSHook();
return true; return true;
} }
if (IthFindFile(L"*.at2")) { // jichi 12/23/2014: Mink, sample files: voice.at2, voice.det, voice.nme if (Util::CheckFile(L"*.at2")) { // jichi 12/23/2014: Mink, sample files: voice.at2, voice.det, voice.nme
InsertMinkHook(); InsertMinkHook();
return true; return true;
} }
if (IthFindFile(L"*.ykc")) { // jichi 7/15/2014: YukaSystem1 is not supported, though if (Util::CheckFile(L"*.ykc")) { // jichi 7/15/2014: YukaSystem1 is not supported, though
//ConsoleOutput("vnreng: IGNORE YKC:Feng/HookSoft(SMEE)"); //ConsoleOutput("vnreng: IGNORE YKC:Feng/HookSoft(SMEE)");
InsertYukaSystem2Hook(); InsertYukaSystem2Hook();
return true; return true;
} }
if (IthFindFile(L"model\\*.hed")) { // jichi 9/8/2014: EXP if (Util::CheckFile(L"model\\*.hed")) { // jichi 9/8/2014: EXP
InsertExpHook(); InsertExpHook();
return true; return true;
} }
// jichi 2/6/2015 平安亭 // jichi 2/6/2015 平安亭
// dPi.dat, dPih.dat, dSc.dat, dSch.dat, dSo.dat, dSoh.dat, dSy.dat // dPi.dat, dPih.dat, dSc.dat, dSch.dat, dSo.dat, dSoh.dat, dSy.dat
//if (IthCheckFile(L"dSoh.dat")) { // no idea why this file does not work //if (Util::CheckFile(L"dSoh.dat")) { // no idea why this file does not work
if (IthCheckFile(L"dSch.dat")) { if (Util::CheckFile(L"dSch.dat")) {
InsertSyuntadaHook(); InsertSyuntadaHook();
return true; return true;
} }
@ -414,7 +414,7 @@ bool DetermineEngineByFile4()
// - PSetup.exe no longer exists // - PSetup.exe no longer exists
// - MovieTexture.dll information shows MovieTex dynamic library, copyright Pensil 2013 // - MovieTexture.dll information shows MovieTex dynamic library, copyright Pensil 2013
// - ta_trial.exe information shows 2XT - Primula Adventure Engine // - ta_trial.exe information shows 2XT - Primula Adventure Engine
if (IthCheckFile(L"PSetup.exe") || IthFindFile(L"PENCIL.*") || Util::SearchResourceString(L"2XT -")) { if (Util::CheckFile(L"PSetup.exe") || Util::CheckFile(L"PENCIL.*") || Util::SearchResourceString(L"2XT -")) {
InsertPensilHook(); InsertPensilHook();
return true; return true;
} }
@ -427,7 +427,7 @@ bool DetermineEngineByProcessName()
wcscpy(str, process_name_); wcscpy(str, process_name_);
_wcslwr(str); // lower case _wcslwr(str); // lower case
if (wcsstr(str,L"reallive") || IthCheckFile(L"Reallive.exe") || IthCheckFile(L"REALLIVEDATA\\Start.ini")) { if (wcsstr(str,L"reallive") || Util::CheckFile(L"Reallive.exe") || Util::CheckFile(L"REALLIVEDATA\\Start.ini")) {
InsertRealliveHook(); InsertRealliveHook();
return true; return true;
} }
@ -439,39 +439,39 @@ bool DetermineEngineByProcessName()
//} //}
// jichi 8/17/2013: Handle "~" // jichi 8/17/2013: Handle "~"
if (wcsstr(str, L"siglusengine") || !wcsncmp(str, L"siglus~", 7) || IthCheckFile(L"SiglusEngine.exe")) { if (wcsstr(str, L"siglusengine") || !wcsncmp(str, L"siglus~", 7) || Util::CheckFile(L"SiglusEngine.exe")) {
InsertSiglusHook(); InsertSiglusHook();
return true; return true;
} }
if (wcsstr(str, L"taskforce2") || !wcsncmp(str, L"taskfo~", 7) || IthCheckFile(L"Taskforce2.exe")) { if (wcsstr(str, L"taskforce2") || !wcsncmp(str, L"taskfo~", 7) || Util::CheckFile(L"Taskforce2.exe")) {
InsertTaskforce2Hook(); InsertTaskforce2Hook();
return true; return true;
} }
if (wcsstr(str,L"rugp") || IthCheckFile(L"rugp.exe")) { if (wcsstr(str,L"rugp") || Util::CheckFile(L"rugp.exe")) {
InsertRUGPHook(); InsertRUGPHook();
return true; return true;
} }
// jichi 8/17/2013: Handle "~" // jichi 8/17/2013: Handle "~"
if (wcsstr(str, L"igs_sample") || !wcsncmp(str, L"igs_sa~", 7) || IthCheckFile(L"igs_sample.exe")) { if (wcsstr(str, L"igs_sample") || !wcsncmp(str, L"igs_sa~", 7) || Util::CheckFile(L"igs_sample.exe")) {
InsertIronGameSystemHook(); InsertIronGameSystemHook();
return true; return true;
} }
if (wcsstr(str, L"bruns") || IthCheckFile(L"bruns.exe")) { if (wcsstr(str, L"bruns") || Util::CheckFile(L"bruns.exe")) {
InsertBrunsHook(); InsertBrunsHook();
return true; return true;
} }
if (wcsstr(str, L"anex86") || IthCheckFile(L"anex86.exe")) { if (wcsstr(str, L"anex86") || Util::CheckFile(L"anex86.exe")) {
InsertAnex86Hook(); InsertAnex86Hook();
return true; return true;
} }
// jichi 8/17/2013: Handle "~" // jichi 8/17/2013: Handle "~"
if (wcsstr(str, L"shinydays") || !wcsncmp(str, L"shinyd~", 7) || IthCheckFile(L"ShinyDays.exe")) { if (wcsstr(str, L"shinydays") || !wcsncmp(str, L"shinyd~", 7) || Util::CheckFile(L"ShinyDays.exe")) {
InsertShinyDaysGameHook(); InsertShinyDaysGameHook();
return true; return true;
} }
@ -483,7 +483,7 @@ bool DetermineEngineByProcessName()
// return true; // return true;
//} //}
if (wcsstr(process_name_, L"SAISYS") || IthCheckFile(L"SaiSys.exe")) { // jichi 4/19/2014: Marine Heart if (wcsstr(process_name_, L"SAISYS") || Util::CheckFile(L"SaiSys.exe")) { // jichi 4/19/2014: Marine Heart
InsertMarineHeartHook(); InsertMarineHeartHook();
return true; return true;
} }
@ -492,7 +492,7 @@ bool DetermineEngineByProcessName()
// jichi 8/24/2013: Checking for Rio.ini or $procname.ini // jichi 8/24/2013: Checking for Rio.ini or $procname.ini
//wcscpy(str+len-4, L"_?.war"); //wcscpy(str+len-4, L"_?.war");
//if (IthFindFile(str)) { //if (Util::CheckFile(str)) {
// InsertShinaHook(); // InsertShinaHook();
// return true; // return true;
//} //}
@ -504,22 +504,22 @@ bool DetermineEngineByProcessName()
str[len - 2] = L'i'; str[len - 2] = L'i';
str[len - 1] = L'n'; str[len - 1] = L'n';
str[len] = 0; str[len] = 0;
if ((IthCheckFile(str) || IthCheckFile(L"trial.bin")) // jichi 7/8/2014: add trial.bin if ((Util::CheckFile(str) || Util::CheckFile(L"trial.bin")) // jichi 7/8/2014: add trial.bin
&& InsertCaramelBoxHook()) && InsertCaramelBoxHook())
return true; return true;
// jichi 7/23/2015 It also has gameexe.bin existed // jichi 7/23/2015 It also has gameexe.bin existed
if (IthCheckFile(L"configure.cfg") && IthCheckFile(L"gfx.bin")) { if (Util::CheckFile(L"configure.cfg") && Util::CheckFile(L"gfx.bin")) {
InsertEscudeHook(); InsertEscudeHook();
return true; return true;
} }
// This must appear at last since str is modified // This must appear at last since str is modified
wcscpy(str + len - 4, L"_checksum.exe"); wcscpy(str + len - 4, L"_checksum.exe");
if (IthCheckFile(str)) { if (Util::CheckFile(str)) {
InsertRyokuchaHook(); InsertRyokuchaHook();
if (IthFindFile(L"*.iar") && IthFindFile(L"*.sec5")) // jichi 9/27/2014: For new Ryokucha games if (Util::CheckFile(L"*.iar") && Util::CheckFile(L"*.sec5")) // jichi 9/27/2014: For new Ryokucha games
InsertScenarioPlayerHook(); InsertScenarioPlayerHook();
return true; return true;
} }
@ -533,12 +533,12 @@ bool DetermineEngineOther()
return true; return true;
// jichi 1/19/2015: Disable inserting Lstr for System40 // jichi 1/19/2015: Disable inserting Lstr for System40
// See: http://sakuradite.com/topic/618 // See: http://sakuradite.com/topic/618
if (IthCheckFile(L"System40.ini")) { if (Util::CheckFile(L"System40.ini")) {
ConsoleOutput("vnreng: IGNORE old System40.ini"); ConsoleOutput("vnreng: IGNORE old System40.ini");
return true; return true;
} }
// jichi 12/26/2013: Add this after alicehook // jichi 12/26/2013: Add this after alicehook
if (IthCheckFile(L"AliceStart.ini")) { if (Util::CheckFile(L"AliceStart.ini")) {
InsertSystem43Hook(); InsertSystem43Hook();
return true; return true;
} }
@ -556,7 +556,8 @@ bool DetermineEngineOther()
name[len] = L'x'; name[len] = L'x';
name[len+1] = L'e'; name[len+1] = L'e';
name[len+2] = 0; name[len+2] = 0;
if (IthCheckFile(name)) { if (Util::CheckFile(name)) {
sizeof(FILE_BOTH_DIR_INFORMATION);
name[len-2] = L'*'; name[len-2] = L'*';
name[len-1] = 0; name[len-1] = 0;
wcscpy(static_search_name,name); wcscpy(static_search_name,name);
@ -586,37 +587,37 @@ bool DetermineEngineOther()
// Put the patterns that might break other games at last // Put the patterns that might break other games at last
bool DetermineEngineAtLast() bool DetermineEngineAtLast()
{ {
if (IthCheckFile(L"MovieTexture.dll") && (InsertPensilHook() || Insert2RMHook())) // MovieTexture.dll also exists in 2RM games such as 母子愛2体験版, which is checked first if (Util::CheckFile(L"MovieTexture.dll") && (InsertPensilHook() || Insert2RMHook())) // MovieTexture.dll also exists in 2RM games such as 母子愛2体験版, which is checked first
return true; return true;
if (IthFindFile(L"system") && IthFindFile(L"system.dat")) { // jichi 7/31/2015 if (Util::CheckFile(L"system") && Util::CheckFile(L"system.dat")) { // jichi 7/31/2015
InsertAbelHook(); InsertAbelHook();
return true; return true;
} }
if (IthFindFile(L"data\\*.cpk")) { // jichi 12/2/2014 if (Util::CheckFile(L"data\\*.cpk")) { // jichi 12/2/2014
Insert5pbHook(); Insert5pbHook();
return true; return true;
} }
// jichi 7/6/2014: named as ScenarioPlayer since resource string could be: scenario player program for xxx // jichi 7/6/2014: named as ScenarioPlayer since resource string could be: scenario player program for xxx
// Do this at last as it is common // Do this at last as it is common
if (IthFindFile(L"*.iar") && IthFindFile(L"*.sec5")) { // jichi 4/18/2014: Other game engine could also have *.iar such as Ryokucha if (Util::CheckFile(L"*.iar") && Util::CheckFile(L"*.sec5")) { // jichi 4/18/2014: Other game engine could also have *.iar such as Ryokucha
InsertScenarioPlayerHook(); InsertScenarioPlayerHook();
return true; return true;
} }
//if (IthCheckFile(L"arc0.dat") && IthCheckFile(L"script.dat") // jichi 11/14/2014: too common //if (Util::CheckFile(L"arc0.dat") && Util::CheckFile(L"script.dat") // jichi 11/14/2014: too common
if (Util::SearchResourceString(L"HorkEye")) { // appear in copyright: Copyright (C) HorkEye, http://horkeye.com if (Util::SearchResourceString(L"HorkEye")) { // appear in copyright: Copyright (C) HorkEye, http://horkeye.com
InsertHorkEyeHook(); InsertHorkEyeHook();
return true; return true;
} }
if (IthCheckFile(L"comnArc.arc") // jichi 8/17/2014: this file might exist in multiple files if (Util::CheckFile(L"comnArc.arc") // jichi 8/17/2014: this file might exist in multiple files
&& InsertNexton1Hook()) // old nexton game && InsertNexton1Hook()) // old nexton game
return true; return true;
if (IthCheckFile(L"arc.dat") // jichi 9/27/2014: too common if (Util::CheckFile(L"arc.dat") // jichi 9/27/2014: too common
&& InsertApricoTHook()) && InsertApricoTHook())
return true; return true;
if (IthFindFile(L"*.pak") // jichi 12/25/2014: too common if (Util::CheckFile(L"*.pak") // jichi 12/25/2014: too common
&& InsertLeafHook()) && InsertLeafHook())
return true; return true;
if (IthFindFile(L"*.dat") // mireado 08/22/2016: too common if (Util::CheckFile(L"*.dat") // mireado 08/22/2016: too common
&& InsertNekopackHook()) && InsertNekopackHook())
return true; return true;
// jichi 10/31/2014 // jichi 10/31/2014
@ -629,14 +630,14 @@ bool DetermineEngineAtLast()
InsertAdobeFlash10Hook(); // only v10 might be supported. Otherwise, fallback to Lstr hooks InsertAdobeFlash10Hook(); // only v10 might be supported. Otherwise, fallback to Lstr hooks
return true; return true;
} }
if (IthFindFile(L"dat\\*.arc")) { // jichi 2/6/2015 if (Util::CheckFile(L"dat\\*.arc")) { // jichi 2/6/2015
InsertFocasLensHook(); // Touhou InsertFocasLensHook(); // Touhou
return true; return true;
} }
// jichi 8/23/2015: Tamamo // jichi 8/23/2015: Tamamo
if (IthCheckFile(L"data.pck") && IthCheckFile(L"image.pck") && IthCheckFile(L"script.pck")) { if (Util::CheckFile(L"data.pck") && Util::CheckFile(L"image.pck") && Util::CheckFile(L"script.pck")) {
//if (IthCheckFile(L"QtGui.dll")) //if (Util::CheckFile(L"QtGui.dll"))
InsertTamamoHook(); InsertTamamoHook();
return true; return true;
} }
@ -649,14 +650,14 @@ bool DetermineEngineGeneric()
{ {
bool ret = false; bool ret = false;
if (IthCheckFile(L"AlterEgo.exe")) { if (Util::CheckFile(L"AlterEgo.exe")) {
ConsoleOutput("vnreng: AlterEgo, INSERT WideChar hooks"); ConsoleOutput("vnreng: AlterEgo, INSERT WideChar hooks");
ret = true; ret = true;
} else if (IthFindFile(L"data\\Sky\\*")) { } else if (Util::CheckFile(L"data\\Sky\\*")) {
ConsoleOutput("vnreng: TEATIME, INSERT WideChar hooks"); ConsoleOutput("vnreng: TEATIME, INSERT WideChar hooks");
ret = true; ret = true;
} }
//} else if (IthFindFile(L"image\\*.po2") || IthFindFile(L"image\\*.jo2")) { //} else if (Util::CheckFile(L"image\\*.po2") || Util::CheckFile(L"image\\*.jo2")) {
// ConsoleOutput("vnreng: HarukaKanata, INSERT WideChar hooks"); // はるかかなた // ConsoleOutput("vnreng: HarukaKanata, INSERT WideChar hooks"); // はるかかなた
// ret = true; // ret = true;
//} //}
@ -667,85 +668,85 @@ bool DetermineEngineGeneric()
bool DetermineNoEngine() bool DetermineNoEngine()
{ {
//if (IthFindFile(L"*\\Managed\\UnityEngine.dll")) { // jichi 12/3/2013: Unity (BALDRSKY ZERO) //if (Util::CheckFile(L"*\\Managed\\UnityEngine.dll")) { // jichi 12/3/2013: Unity (BALDRSKY ZERO)
// ConsoleOutput("vnreng: IGNORE Unity"); // ConsoleOutput("vnreng: IGNORE Unity");
// return true; // return true;
//} //}
//if (IthCheckFile(L"bsz_Data\\Managed\\UnityEngine.dll") || IthCheckFile(L"bsz2_Data\\Managed\\UnityEngine.dll")) { //if (Util::CheckFile(L"bsz_Data\\Managed\\UnityEngine.dll") || Util::CheckFile(L"bsz2_Data\\Managed\\UnityEngine.dll")) {
// ConsoleOutput("vnreng: IGNORE Unity"); // ConsoleOutput("vnreng: IGNORE Unity");
// return true; // return true;
//} //}
// jichi 6/7/2015: RPGMaker v3 // jichi 6/7/2015: RPGMaker v3
if (IthFindFile(L"*.rgss3a")) { if (Util::CheckFile(L"*.rgss3a")) {
ConsoleOutput("vnreng: IGNORE RPGMaker RGSS3"); ConsoleOutput("vnreng: IGNORE RPGMaker RGSS3");
return true; return true;
} }
// jichi 11/22/2015: 凍京NECRO 体験版 // jichi 11/22/2015: 凍京NECRO 体験版
if (IthFindFile(L"*.npk")) { if (Util::CheckFile(L"*.npk")) {
ConsoleOutput("vnreng: IGNORE new Nitroplus"); ConsoleOutput("vnreng: IGNORE new Nitroplus");
return true; return true;
} }
// 8/29/2015 jichi: minori, text in GetGlyphOutlineA // 8/29/2015 jichi: minori, text in GetGlyphOutlineA
if (IthFindFile(L"*.paz")) { if (Util::CheckFile(L"*.paz")) {
ConsoleOutput("vnreng: IGNORE minori"); ConsoleOutput("vnreng: IGNORE minori");
return true; return true;
} }
// 7/28/2015 jichi: Favorite games // 7/28/2015 jichi: Favorite games
if (IthFindFile(L"*.hcb")) { if (Util::CheckFile(L"*.hcb")) {
ConsoleOutput("vnreng: IGNORE FVP"); ConsoleOutput("vnreng: IGNORE FVP");
return true; return true;
} }
// jichi 2/14/2015: Guilty+ × (PK) // jichi 2/14/2015: Guilty+ × (PK)
if (IthCheckFile(L"rio.ini") || IthFindFile(L"*.war")) { if (Util::CheckFile(L"rio.ini") || Util::CheckFile(L"*.war")) {
ConsoleOutput("vnreng: IGNORE unknown ShinaRio"); ConsoleOutput("vnreng: IGNORE unknown ShinaRio");
return true; return true;
} }
if (IthCheckFile(L"AdvHD.exe") || IthCheckFile(L"AdvHD.dll")) { if (Util::CheckFile(L"AdvHD.exe") || Util::CheckFile(L"AdvHD.dll")) {
ConsoleOutput("vnreng: IGNORE Adv Player HD"); // supposed to be WillPlus ConsoleOutput("vnreng: IGNORE Adv Player HD"); // supposed to be WillPlus
return true; return true;
} }
if (IthCheckFile(L"ScrPlayer.exe")) { if (Util::CheckFile(L"ScrPlayer.exe")) {
ConsoleOutput("vnreng: IGNORE ScrPlayer"); ConsoleOutput("vnreng: IGNORE ScrPlayer");
return true; return true;
} }
if (IthCheckFile(L"nnnConfig2.exe")) { if (Util::CheckFile(L"nnnConfig2.exe")) {
ConsoleOutput("vnreng: IGNORE Nya NNNConfig"); ConsoleOutput("vnreng: IGNORE Nya NNNConfig");
return true; return true;
} }
// jichi 4/30/2015: Skip games made from らすこう, such as とある人妻のネトラレ事情 // jichi 4/30/2015: Skip games made from らすこう, such as とある人妻のネトラレ事情
// It has garbage from lstrlenW. Correct text is supposed to be in TabbedTextOutA. // It has garbage from lstrlenW. Correct text is supposed to be in TabbedTextOutA.
if (IthCheckFile(L"data_cg.dpm")) { if (Util::CheckFile(L"data_cg.dpm")) {
ConsoleOutput("vnreng: IGNORE DPM data_cg.dpm"); ConsoleOutput("vnreng: IGNORE DPM data_cg.dpm");
return true; return true;
} }
//if (IthCheckFile(L"AGERC.DLL")) { // jichi 3/17/2014: Eushully, AGE.EXE //if (Util::CheckFile(L"AGERC.DLL")) { // jichi 3/17/2014: Eushully, AGE.EXE
// ConsoleOutput("vnreng: IGNORE Eushully"); // ConsoleOutput("vnreng: IGNORE Eushully");
// return true; // return true;
//} //}
if (IthCheckFile(L"game_sys.exe")) { if (Util::CheckFile(L"game_sys.exe")) {
ConsoleOutput("vnreng: IGNORE Atelier Kaguya BY/TH"); ConsoleOutput("vnreng: IGNORE Atelier Kaguya BY/TH");
return true; return true;
} }
if (IthFindFile(L"*.bsa")) { if (Util::CheckFile(L"*.bsa")) {
ConsoleOutput("vnreng: IGNORE Bishop"); ConsoleOutput("vnreng: IGNORE Bishop");
return true; return true;
} }
// jichi 3/19/2014: Escude game // jichi 3/19/2014: Escude game
// Example: bgm.bin gfx.bin maou.bin script.bin snd.bin voc.bin // Example: bgm.bin gfx.bin maou.bin script.bin snd.bin voc.bin
if (IthCheckFile(L"gfx.bin") && IthCheckFile(L"snd.bin") && IthCheckFile(L"voc.bin")) { if (Util::CheckFile(L"gfx.bin") && Util::CheckFile(L"snd.bin") && Util::CheckFile(L"voc.bin")) {
ConsoleOutput("vnreng: IGNORE Escude"); ConsoleOutput("vnreng: IGNORE Escude");
return true; return true;
} }
@ -764,12 +765,12 @@ bool DetermineNoEngine()
return true; return true;
} }
if (IthCheckFile(L"MovieTexture.dll")) { if (Util::CheckFile(L"MovieTexture.dll")) {
ConsoleOutput("vnreng: IGNORE MovieTexture"); ConsoleOutput("vnreng: IGNORE MovieTexture");
return true; return true;
} }
if (wcsstr(process_name_, L"lcsebody") || !wcsncmp(process_name_, L"lcsebo~", 7) || IthFindFile(L"lcsebody*")) { // jichi 3/19/2014: LC-ScriptEngine, GetGlyphOutlineA if (wcsstr(process_name_, L"lcsebody") || !wcsncmp(process_name_, L"lcsebo~", 7) || Util::CheckFile(L"lcsebody*")) { // jichi 3/19/2014: LC-ScriptEngine, GetGlyphOutlineA
ConsoleOutput("vnreng: IGNORE lcsebody"); ConsoleOutput("vnreng: IGNORE lcsebody");
return true; return true;
} }
@ -783,7 +784,7 @@ bool DetermineNoEngine()
} }
*(DWORD *)(str + i + 1) = 0x630068; //.hcb *(DWORD *)(str + i + 1) = 0x630068; //.hcb
*(DWORD *)(str + i + 3) = 0x62; *(DWORD *)(str + i + 3) = 0x62;
if (IthCheckFile(str)) { if (Util::CheckFile(str)) {
ConsoleOutput("vnreng: IGNORE FVP"); // jichi 10/3/2013: such like アトリエかぐや ConsoleOutput("vnreng: IGNORE FVP"); // jichi 10/3/2013: such like アトリエかぐや
return true; return true;
} }

View File

@ -138,8 +138,6 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID unused)
DisableThreadLibraryCalls(hModule); DisableThreadLibraryCalls(hModule);
IthInitSystemService();
swprintf(hm_section, ITH_SECTION_ L"%d", GetCurrentProcessId()); swprintf(hm_section, ITH_SECTION_ L"%d", GetCurrentProcessId());
// jichi 9/25/2013: Interprocedural communication with vnrsrv. // jichi 9/25/2013: Interprocedural communication with vnrsrv.
@ -202,7 +200,6 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID unused)
CloseHandle(hSection); CloseHandle(hSection);
CloseHandle(hMutex); CloseHandle(hMutex);
IthCloseSystemService();
delete ::tree; delete ::tree;
CloseHandle(hmMutex); CloseHandle(hmMutex);

View File

@ -186,6 +186,19 @@ DWORD Util::FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig)
} }
return 0; return 0;
} }
bool Util::CheckFile(LPCWSTR name)
{
WIN32_FIND_DATAW unused;
HANDLE file = FindFirstFileW(name, &unused);
if (file != INVALID_HANDLE_VALUE)
{
FindClose(file);
return true;
}
return false;
}
DWORD Util::FindEntryAligned(DWORD start, DWORD back_range) DWORD Util::FindEntryAligned(DWORD start, DWORD back_range)
{ {
start &= ~0xf; start &= ~0xf;

View File

@ -18,6 +18,7 @@ DWORD FindCallAndEntryAbs(DWORD fun, DWORD size, DWORD pt, DWORD sig);
DWORD FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig); DWORD FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig);
DWORD FindEntryAligned(DWORD start, DWORD back_range); DWORD FindEntryAligned(DWORD start, DWORD back_range);
DWORD FindImportEntry(DWORD hModule, DWORD fun); DWORD FindImportEntry(DWORD hModule, DWORD fun);
bool CheckFile(LPCWSTR name);
// jichi 4/15/2014: Copied from ITH CLI, for debugging purpose // jichi 4/15/2014: Copied from ITH CLI, for debugging purpose
DWORD FindModuleBase(DWORD hash); DWORD FindModuleBase(DWORD hash);