From de6976db404b498390ae6576bb1d21fddd097c7a Mon Sep 17 00:00:00 2001 From: kaokao Date: Wed, 2 Aug 2023 08:55:23 +0800 Subject: [PATCH 1/2] fix tms192.2 & update vs tool to latest version --- EmuExtra/EmuExtra.vcxproj | 10 ++-- EmuExtra_v20/EmuExtra_v20.vcxproj | 10 ++-- EmuLoader/EmuLoader.cpp | 12 ++--- EmuLoader/EmuLoader.vcxproj | 10 ++-- EmuLoader64/EmuLoader64.vcxproj | 10 ++-- EmuMain/AobList.h | 6 ++- EmuMain/EmuMain.cpp | 78 ++++++++++++++++++++++++++++++- EmuMain/EmuMain.vcxproj | 10 ++-- EmuMain/RemoveCRC.cpp | 23 +++++++-- EmuMain64/EmuMain64.vcxproj | 10 ++-- HeapTest/HeapTest.vcxproj | 10 ++-- RunEmu/RunEmu.vcxproj | 10 ++-- RunEmu64/RunEmu64.vcxproj | 10 ++-- StringPool/StringPool.vcxproj | 10 ++-- SupportUTF8/SupportUTF8.vcxproj | 10 ++-- 15 files changed, 163 insertions(+), 66 deletions(-) diff --git a/EmuExtra/EmuExtra.vcxproj b/EmuExtra/EmuExtra.vcxproj index ee07e1b..ba3488b 100644 --- a/EmuExtra/EmuExtra.vcxproj +++ b/EmuExtra/EmuExtra.vcxproj @@ -23,32 +23,32 @@ {ABDA27D6-7C53-4B03-BB51-798D902B8B52} Win32Proj EmuExtra - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/EmuExtra_v20/EmuExtra_v20.vcxproj b/EmuExtra_v20/EmuExtra_v20.vcxproj index 7e0751d..ca41651 100644 --- a/EmuExtra_v20/EmuExtra_v20.vcxproj +++ b/EmuExtra_v20/EmuExtra_v20.vcxproj @@ -23,32 +23,32 @@ {4794B654-944A-4263-9C87-011D13D67444} Win32Proj EmuExtrav20 - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/EmuLoader/EmuLoader.cpp b/EmuLoader/EmuLoader.cpp index f8d6e0d..816ef91 100644 --- a/EmuLoader/EmuLoader.cpp +++ b/EmuLoader/EmuLoader.cpp @@ -17,7 +17,7 @@ std::vector vFastLoadDlls; std::vector vDelayLoadDlls; -// メモリ展開前に読み込む +// 繝。繝「繝ェ螻暮幕蜑阪↓隱ュ縺ソ霎シ繧 bool FastLoad() { for (size_t i = 0; i < vFastLoadDlls.size(); i++) { if (LoadLibraryW(vFastLoadDlls[i].c_str())) { @@ -27,7 +27,7 @@ bool FastLoad() { return true; } -// メモリ展開後に読み込む +// 繝。繝「繝ェ螻暮幕蠕後↓隱ュ縺ソ霎シ繧 bool bAlreadyLoaded = false; bool DelayLoad() { if (bAlreadyLoaded) { @@ -108,8 +108,8 @@ bool EmuLoader(HMODULE hDll) { return false; } - // FixThemida.dll, 起動できない問題の修正 - // LocalHost.dll, 接続先の変更 + // FixThemida.dll, 襍キ蜍輔〒縺阪↑縺蝠城。後ョ菫ョ豁」 + // LocalHost.dll, 謗・邯壼医ョ螟画峩 for (size_t i = 1; i <= 10; i++) { std::wstring wDllName; conf.Read(FAST_LOAD, L"DLL_" + std::to_wstring(i), wDllName); @@ -124,8 +124,8 @@ bool EmuLoader(HMODULE hDll) { } } - // EmuMain.dll, GameGuard, HackShield, XignCodeの削除とMSCRCの削除またはBypass, ウィンドウ化などゲーム起動に関する修正 - // EmuExtra.dll, ゲーム内の処理の変更 + // EmuMain.dll, GameGuard, HackShield, XignCode縺ョ蜑企勁縺ィMSCRC縺ョ蜑企勁縺セ縺溘ッBypass, 繧ヲ繧」繝ウ繝峨え蛹悶↑縺ゥ繧イ繝シ繝襍キ蜍輔↓髢「縺吶k菫ョ豁」 + // EmuExtra.dll, 繧イ繝シ繝蜀縺ョ蜃ヲ逅縺ョ螟画峩 for (size_t i = 1; i <= 10; i++) { std::wstring wDllName; conf.Read(DELAY_LOAD, L"DLL_" + std::to_wstring(i), wDllName); diff --git a/EmuLoader/EmuLoader.vcxproj b/EmuLoader/EmuLoader.vcxproj index 63bccba..91ee313 100644 --- a/EmuLoader/EmuLoader.vcxproj +++ b/EmuLoader/EmuLoader.vcxproj @@ -23,32 +23,32 @@ {32C25F66-CFDE-4489-994E-85A913869680} Win32Proj EmuLoader - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/EmuLoader64/EmuLoader64.vcxproj b/EmuLoader64/EmuLoader64.vcxproj index ceeeb33..7fb4aad 100644 --- a/EmuLoader64/EmuLoader64.vcxproj +++ b/EmuLoader64/EmuLoader64.vcxproj @@ -23,32 +23,32 @@ {9BDA1F45-7D15-4EB2-B06D-2BD7898658C4} Win32Proj EmuLoader64 - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/EmuMain/AobList.h b/EmuMain/AobList.h index c84fad9..4a6983f 100644 --- a/EmuMain/AobList.h +++ b/EmuMain/AobList.h @@ -144,11 +144,15 @@ std::wstring AOB_HSUpdate[] = { }; // CSecurityClient::IsInstantiated -std::wstring AOB_EasyRemoveHS[] = { +std::wstring AOB_EasyRemoveAntiCheat[] = { // v334.2 L"33 C0 39 ?? ?? ?? ?? ?? 0F 95 C0 C3 CC CC CC CC C7 01 ?? ?? ?? ?? C3", // TMS157.2 L"33 C0 39 ?? ?? ?? ?? ?? 0F 95 C0 C3 8B ?? ?? 04 85 C0 74 05 83 ?? 0C EB 02 33 C0", + // TMS191 + L"83 ?? ?? ?? ?? ?? 00 0F 95 C0 C3 A1 ?? ?? ?? ?? C3 8B 01 8B", + // TMS192.2 + L"83 ?? ?? ?? ?? ?? 00 0F 95 C0 C3 8B 44 24 04 85 C0 74 05 83 C0 0C EB 02 33 C0 83", }; std::wstring AOB_StartKeyCrypt[] = { diff --git a/EmuMain/EmuMain.cpp b/EmuMain/EmuMain.cpp index 5a252eb..f92ec08 100644 --- a/EmuMain/EmuMain.cpp +++ b/EmuMain/EmuMain.cpp @@ -22,19 +22,42 @@ void RemoveHackShield(Rosemary &r) { // but it disables HackShield // if you get crash with this code, you should check MSCRC // there are some CRCs that checks only certain function memory, CSecurityClient__IsInstantiated is scaned by the CRC +<<<<<<< Updated upstream bool RemoveHS_EasyVer(Rosemary &r) { ULONG_PTR uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveHS[0]); +======= +bool RemoveAntiCheat_EasyVer(Rosemary &r) { + // HS + ULONG_PTR Call = r.Scan(L"E8 ?? ?? ?? ?? 85 C0 74 0A E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 ?? ?? 00 0F"); + ULONG_PTR uCSecurityClient__IsInstantiated; + + if (Call) { + uCSecurityClient__IsInstantiated = Call + 0x05 + *(signed long int*)(Call + 0x01); + } else {/// XIGNCODE + // TSingleton::GetInstance call + auto Call = r.Scan(L"E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 7D 08 00 0F ?? ?? ?? ?? ?? 6A 00 68 00 00 00 80 6A 02 6A"); + //auto Call = r.Scan(L"A1 ?? ?? ?? ?? 3B C3 74 24 8D ?? 44 E8 ?? ?? ?? ?? 3B C3 74"); + uCSecurityClient__IsInstantiated = (Call + 0x05 + *(signed long int*)(Call + 0x01)) + 0x06;//TMS192.2 5C9A49 + if (!Call) return false; + } + +/* ULONG_PTR uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveAntiCheat[0]); +>>>>>>> Stashed changes if (!uCSecurityClient__IsInstantiated) { - uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveHS[1]); + uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveAntiCheat[1]); if (!uCSecurityClient__IsInstantiated) return false; } SCANRES(uCSecurityClient__IsInstantiated); +<<<<<<< Updated upstream r.Patch(uCSecurityClient__IsInstantiated, L"31 C0 C3"); //AOBPatch(EasyRemoveHS, L"31 C0 C3"); +======= + //AOBPatch(EasyRemoveAntiCheat, L"31 C0 C3"); +>>>>>>> Stashed changes AOBPatch(StartKeyCrypt, L"31 C0 C3"); AOBPatch(StopKeyCrypt, L"31 C0 C3"); @@ -86,6 +109,59 @@ void EmuMain() { RemoveHS_EasyVer(r); //RemoveHackShield(r); +<<<<<<< Updated upstream Disable_AntiDebug(r); FixClient(r); +======= + SCANRES(uGamania); + + switch (GetMSVersion()) { + case 157: + { + r.JMP(0xAC0A82, r.Scan(L"68 FF 00 00 00 6A 00 6A 00 8B ?? ?? ?? ?? ?? 83 ?? ?? ?? 6A 03 FF 15"));//TMS157.2 MSCRC CWvsApp::Run first VM (ManipulatePacket) + r.Patch(0x77068C, L"B8 32 00 00 00 C3");//calc_accr ・エゥヌ50%セイvMISS + //r.Patch(0x77068C, L"B8 14 00 00 00 C3");//calc_accr ・エゥヌ80%セイvMISS + break; + } + default: + { + break; + } + } + + break; + } + case MS_MSEA: { + RemoveHackShield(r); + + switch (GetMSVersion()) { + case 97: + { + r.Patch(0x00454AEA, L"31 C0 C3"); // hide DLL MSEA v97 + //r.Patch(0x00AB83A0, L"83 C4 14"); // MSEA v97 MSCRC function + //r.JMP(0x00AB83A0 + 3, 0x00AB9C8F); // MSEA v97 MSCRC function + break; + } + case 102: + { + r.Patch(0x004C1930, L"31 C0 C3"); // hide DLL MSEA v102 + break; + } + default: + { + break; + } + } + + break; + } + default: + { + RemoveHackShield(r); + Disable_AntiDebug(r); + FixClient(r); + break; + } + } +>>>>>>> Stashed changes } \ No newline at end of file diff --git a/EmuMain/EmuMain.vcxproj b/EmuMain/EmuMain.vcxproj index 0a86852..5d83f12 100644 --- a/EmuMain/EmuMain.vcxproj +++ b/EmuMain/EmuMain.vcxproj @@ -23,32 +23,32 @@ {B2EC0212-6675-4F7D-8F0C-D4132B64DD68} Win32Proj EmuMain - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/EmuMain/RemoveCRC.cpp b/EmuMain/RemoveCRC.cpp index b03e273..63759af 100644 --- a/EmuMain/RemoveCRC.cpp +++ b/EmuMain/RemoveCRC.cpp @@ -90,7 +90,7 @@ bool RemoveCRC_OnEnterField_194(Rosemary &r) { ULONG_PTR uOnEnterField_Enter_VM = uOnEnterField + 0x3D; ULONG_PTR uOnEnterField_Leave_VM = r.Scan(L"89 ?? 89 ?? 89 ?? 90 E8 ?? ?? ?? ?? 89 45 ?? E8 ?? ?? ?? ?? 85 C0 74"); - if (!uOnEnterField_Leave_VM) { + if (!uOnEnterField_Enter_VM || !uOnEnterField_Leave_VM) { return false; } @@ -99,6 +99,20 @@ bool RemoveCRC_OnEnterField_194(Rosemary &r) { return true; } +bool RemoveCRC_OnEnterField_TMS192_2(Rosemary& r) { + + ULONG_PTR uOnEnterField_Enter_VM = r.Scan(L"E9 ?? ?? ?? ?? 50 EB 55 2C 8A 4A 9C AF 79 54 A0"); + //+0x91 + ULONG_PTR uOnEnterField_Leave_VM = r.Scan(L"8B ?? ?? ?? ?? ?? 81 ?? EC 68 00 00 E8 ?? ?? ?? ?? 8B C8 E8 ?? ?? ?? ?? 8B"); + + if (!uOnEnterField_Enter_VM || !uOnEnterField_Leave_VM) { + return false; + } + + r.JMP(uOnEnterField_Enter_VM, uOnEnterField_Leave_VM); + DEBUG(L"RemoveCRC_OnEnterField (TMSv192.2): " + DWORDtoString(uOnEnterField_Enter_VM) + L" -> " + DWORDtoString(uOnEnterField_Leave_VM)); + return true; +} bool RemoveCRC_v334(Rosemary &r) { ULONG_PTR uOnSomething = r.Scan(L"55 8B EC 6A FF 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 81 EC ?? ?? ?? ?? 53 56 57 A1 ?? ?? ?? ?? 33 C5 50 8D 45 F4 64 A3 00 00 00 00 89 8D ?? ?? ?? ?? C7 45 BC 00 00 00 00 33 C0 89 45 C0 89 45 C4 89 45 C8 89 45 CC 89 45 D0 89 45 D4 C7 45 B0 00 00 00 00 33 C9 89 4D B4 89 4D B8 E8"); @@ -126,14 +140,17 @@ bool RemoveCRC(Rosemary &r) { check++; } + if (RemoveCRC_OnEnterField_TMS192_2(r)) { + check++; + } + if (RemoveCRC_v334(r)) { check++; } if (RemoveCRC_OnEnterField(r)) { check++; - } - else { + } else { if (RemoveCRC_OnEnterField_194(r)) { check++; } diff --git a/EmuMain64/EmuMain64.vcxproj b/EmuMain64/EmuMain64.vcxproj index 77aa4d9..d041fe0 100644 --- a/EmuMain64/EmuMain64.vcxproj +++ b/EmuMain64/EmuMain64.vcxproj @@ -23,32 +23,32 @@ {007565B5-C36F-4878-904E-D43F28A2E7E2} Win32Proj EmuMain64 - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/HeapTest/HeapTest.vcxproj b/HeapTest/HeapTest.vcxproj index 670fa19..1a0dd55 100644 --- a/HeapTest/HeapTest.vcxproj +++ b/HeapTest/HeapTest.vcxproj @@ -23,32 +23,32 @@ {8285A95C-AADA-4B1F-AE2C-80E2318700AE} Win32Proj HeapTest - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/RunEmu/RunEmu.vcxproj b/RunEmu/RunEmu.vcxproj index d0f8b76..bdc9a71 100644 --- a/RunEmu/RunEmu.vcxproj +++ b/RunEmu/RunEmu.vcxproj @@ -23,32 +23,32 @@ {8AC641A7-94A1-4438-9909-F0E865AB0B7B} Win32Proj RunEmu - 10.0.17763.0 + 10.0 Application true - v141 + v143 Unicode Application false - v141 + v143 true Unicode Application true - v141 + v143 Unicode Application false - v141 + v143 true Unicode diff --git a/RunEmu64/RunEmu64.vcxproj b/RunEmu64/RunEmu64.vcxproj index 3defec5..eb77ae4 100644 --- a/RunEmu64/RunEmu64.vcxproj +++ b/RunEmu64/RunEmu64.vcxproj @@ -23,32 +23,32 @@ {934728D1-C7DE-48A6-B848-45D98F49C986} Win32Proj RunEmu64 - 10.0.17763.0 + 10.0 Application true - v141 + v143 Unicode Application false - v141 + v143 true Unicode Application true - v141 + v143 Unicode Application false - v141 + v143 true Unicode diff --git a/StringPool/StringPool.vcxproj b/StringPool/StringPool.vcxproj index 169a18f..2186ed0 100644 --- a/StringPool/StringPool.vcxproj +++ b/StringPool/StringPool.vcxproj @@ -23,32 +23,32 @@ {6D5529B4-218F-4986-B0D7-CD55097054CC} Win32Proj StringPool - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode DynamicLibrary true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode diff --git a/SupportUTF8/SupportUTF8.vcxproj b/SupportUTF8/SupportUTF8.vcxproj index a4b464c..0d83bca 100644 --- a/SupportUTF8/SupportUTF8.vcxproj +++ b/SupportUTF8/SupportUTF8.vcxproj @@ -23,32 +23,32 @@ {22175D3F-4576-47AB-9E29-0AAC8FA2EAC8} Win32Proj SupportUTF8 - 10.0.17763.0 + 10.0 Application true - v141 + v143 Unicode DynamicLibrary false - v141 + v143 true Unicode Application true - v141 + v143 Unicode Application false - v141 + v143 true Unicode From 7b51d2823f8babe41777306f7d3e6bf0ce153b2b Mon Sep 17 00:00:00 2001 From: kaokao Date: Wed, 2 Aug 2023 08:58:41 +0800 Subject: [PATCH 2/2] fix tms192.2 & update vs tool to latest version --- EmuLoader/EmuLoader.cpp | 15 ++++++ EmuMain/AobList.h | 2 +- EmuMain/CRCBypass.cpp | 2 +- EmuMain/CRCBypass334.cpp | 2 +- EmuMain/DllMain.cpp | 98 ++++++++++++++++++++++++++++++++++++++++ EmuMain/EmuMain.cpp | 73 ++++++++++++++++-------------- EmuMain/EmuMain.h | 10 ++++ 7 files changed, 166 insertions(+), 36 deletions(-) diff --git a/EmuLoader/EmuLoader.cpp b/EmuLoader/EmuLoader.cpp index 816ef91..87a02fb 100644 --- a/EmuLoader/EmuLoader.cpp +++ b/EmuLoader/EmuLoader.cpp @@ -1,5 +1,7 @@ #include"../Share/Simple/Simple.h" #include"../Share/Hook/SimpleHook.h" +#include +#pragma intrinsic(_ReturnAddress) #ifndef _WIN64 @@ -92,11 +94,24 @@ LSTATUS APIENTRY RegCreateKeyExA_Hook(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved return _RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition); } +decltype(GetStartupInfoA) *_GetStartupInfoA = NULL; +auto WINAPI GetStartupInfoA_Hook(LPSTARTUPINFOA lpStartupInfo) { + if (!bAlreadyLoaded) { + if (lpStartupInfo && SimpleHook::IsCallerEXE(_ReturnAddress())) { + DEBUG(L"DelayLoad GetStartupInfoA"); + DelayLoad(); + } + } + return _GetStartupInfoA(lpStartupInfo); +} + bool EnableHook() { SHook(CreateMutexExW); // v334.2 SHook(RegCreateKeyExA); + // TMS (cause DNS Resolution on CreateMutexExW before) + SHook(GetStartupInfoA); return true; } diff --git a/EmuMain/AobList.h b/EmuMain/AobList.h index 4a6983f..a385563 100644 --- a/EmuMain/AobList.h +++ b/EmuMain/AobList.h @@ -1,4 +1,4 @@ -#ifndef __AOB_LIST_H__ +サソ#ifndef __AOB_LIST_H__ #define __AOB_LIST_H__ #include diff --git a/EmuMain/CRCBypass.cpp b/EmuMain/CRCBypass.cpp index f54cf67..f477161 100644 --- a/EmuMain/CRCBypass.cpp +++ b/EmuMain/CRCBypass.cpp @@ -1,4 +1,4 @@ -#include"CRCBypass.h" +サソ#include"CRCBypass.h" std::vector vSection; std::vector vBackup; diff --git a/EmuMain/CRCBypass334.cpp b/EmuMain/CRCBypass334.cpp index 9e51102..a1433fc 100644 --- a/EmuMain/CRCBypass334.cpp +++ b/EmuMain/CRCBypass334.cpp @@ -1,4 +1,4 @@ -#include"CRCBypass.h" +サソ#include"CRCBypass.h" // v334.0 VMProtect CRC Bypass DWORD MSCRC1 = 0x015BCBD9; diff --git a/EmuMain/DllMain.cpp b/EmuMain/DllMain.cpp index eebd3d9..831ce9c 100644 --- a/EmuMain/DllMain.cpp +++ b/EmuMain/DllMain.cpp @@ -1,10 +1,108 @@ #include"EmuMain.h" +MSRegion gConfig_Region = MS_JMS; +int gConfig_Version = 0; +bool gDisable_MemoryDump = false; + +MSRegion GetMSRegion() { + return gConfig_Region; +} + +bool SetMSRegion(std::wstring wRegion) { + // default is JMS + if (wRegion.compare(L"TWMS") == 0) { + gConfig_Region = MS_TWMS; + return true; + } + + if (wRegion.compare(L"MSEA") == 0) { + gConfig_Region = MS_MSEA; + return true; + } + + return false; +} + +std::wstring GetMSRegionString() { + + switch (GetMSRegion()) { + case MS_JMS: + { + return L"JMS"; + } + case MS_TWMS: + { + return L"TWMS"; + } + case MS_MSEA: + { + return L"MSEA"; + } + default: + { + break; + } + } + + return L"Unknown"; +} + +int GetMSVersion() { + return gConfig_Version; +} + +void SetMSVersion(int version) { + gConfig_Version = version; +} + +bool GetMSDisableMemoryDump() { + return gDisable_MemoryDump; +} + +void SetMSDisableMemoryDump(bool flag) { + gDisable_MemoryDump = flag; +} + + +#ifndef _WIN64 +#define DLL_NAME L"EmuMain" +#else +#define DLL_NAME L"EmuMain64" +#endif + +#define INI_FILE_NAME DLL_NAME".ini" + +bool LoadConfig(HMODULE hDll) { + Config conf(INI_FILE_NAME, hDll); + std::wstring wRegion, wVersion, wMemoryDump; + + // Region + if (conf.Read(DLL_NAME, L"Region", wRegion)) { + SetMSRegion(wRegion); + DEBUG(L"Region=" + GetMSRegionString()); + } + // Version + if (conf.Read(DLL_NAME, L"Version", wVersion)) { + int ver = _wtoi(wVersion.c_str()); + SetMSVersion(ver); + DEBUG(L"Version=" + std::to_wstring(GetMSVersion())); + } + // MSCRC Option + if (conf.Read(DLL_NAME, L"DisableMemoryDump", wMemoryDump)) { + int val = _wtoi(wMemoryDump.c_str()); + SetMSDisableMemoryDump(val); + DEBUG(L"VeDisableMemoryDump=" + std::to_wstring(GetMSDisableMemoryDump())); + } + return true; +} + + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: { DisableThreadLibraryCalls(hinstDLL); + LoadConfig(hinstDLL); EmuMain(); break; } diff --git a/EmuMain/EmuMain.cpp b/EmuMain/EmuMain.cpp index f92ec08..f2e17a8 100644 --- a/EmuMain/EmuMain.cpp +++ b/EmuMain/EmuMain.cpp @@ -22,10 +22,6 @@ void RemoveHackShield(Rosemary &r) { // but it disables HackShield // if you get crash with this code, you should check MSCRC // there are some CRCs that checks only certain function memory, CSecurityClient__IsInstantiated is scaned by the CRC -<<<<<<< Updated upstream -bool RemoveHS_EasyVer(Rosemary &r) { - ULONG_PTR uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveHS[0]); -======= bool RemoveAntiCheat_EasyVer(Rosemary &r) { // HS ULONG_PTR Call = r.Scan(L"E8 ?? ?? ?? ?? 85 C0 74 0A E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 ?? ?? 00 0F"); @@ -42,27 +38,28 @@ bool RemoveAntiCheat_EasyVer(Rosemary &r) { } /* ULONG_PTR uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveAntiCheat[0]); ->>>>>>> Stashed changes if (!uCSecurityClient__IsInstantiated) { uCSecurityClient__IsInstantiated = r.Scan(AOB_EasyRemoveAntiCheat[1]); if (!uCSecurityClient__IsInstantiated) return false; - } + }*/ SCANRES(uCSecurityClient__IsInstantiated); - -<<<<<<< Updated upstream r.Patch(uCSecurityClient__IsInstantiated, L"31 C0 C3"); - //AOBPatch(EasyRemoveHS, L"31 C0 C3"); -======= + //AOBPatch(EasyRemoveAntiCheat, L"31 C0 C3"); ->>>>>>> Stashed changes - AOBPatch(StartKeyCrypt, L"31 C0 C3"); - AOBPatch(StopKeyCrypt, L"31 C0 C3"); + ULONG_PTR uKeyCryptCall = r.Scan(L"E8 ?? ?? ?? ?? EB 05 E8 ?? ?? ?? ?? 66"); + ULONG_PTR uStartKeyCrypt = uKeyCryptCall + 0x05 + *(signed long int*)(uKeyCryptCall + 0x01); + ULONG_PTR uStopKeyCrypt = uKeyCryptCall + 0x0C + *(signed long int*)(uKeyCryptCall + 0x08); + r.Patch(uStartKeyCrypt, L"31 C0 C3"); + r.Patch(uStopKeyCrypt, L"31 C0 C3"); - //TMS157.2 HS things check + //AOBPatch(StartKeyCrypt, L"31 C0 C3"); + //AOBPatch(StopKeyCrypt, L"31 C0 C3"); + + //TMS157.2 HS things (when enter character select page) ULONG_PTR uHS_things = r.Scan(L"83 ?? ?? ?? ?? ?? 00 74 45 83 ?? ?? 00 A1 ?? ?? ?? ?? FF ?? ?? ?? ?? ?? 8D ?? EC 68 ?? ?? ?? ?? 50 C6 ?? ?? 02 E8"); r.JMP(uHS_things, uHS_things + 0x4E); //r.JMP(0x60ED4F, 0x60ED9D); @@ -74,16 +71,10 @@ bool RemoveAntiCheat_EasyVer(Rosemary &r) { void FixClient(Rosemary &r) { // JMS v186 or before AOBPatch_ADD(WindowMode_PreBB, 0x03, L"00 00 00 00"); - // JMS v187 only, later version of bigbang client has window mode option (it will cause TMS crash) - //AOBPatch(WindowMode_PostBB, L"31 C0 C3"); - AOBPatch(Launcher, L"B8 01 00 00 00 C3"); AOBPatch(Ad, L"B8 01 00 00 00 C3"); // v194.0 has System Settings causes crash without using this code AOBPatch(MapleNetwork, L"31 C0 C2 08 00"); - - // TMS old default DNS (not available cause crash) - r.StringPatch("tw.login.maplestory.gamania.com", "127.0.0.1"); } // Hardware BreakPoint Detection @@ -96,23 +87,40 @@ void EmuMain() { Rosemary r; if (!RemoveCRC(r)) { - CRCBypass(r); + // if flag is true, Memory Dump Method is ignored + if (!GetMSDisableMemoryDump()) { + CRCBypass(r); + } } - //r.Patch(0x00454AEA, L"31 C0 C3"); // hide DLL MSEA v97 - //r.Patch(0x004C1930, L"31 C0 C3"); // hide DLL MSEA v102 - //r.Patch(0x00AB83A0, L"83 C4 14"); // MSEA v97 MSCRC function - //r.JMP(0x00AB83A0 + 3, 0x00AB9C8F); // MSEA v97 MSCRC function + switch (GetMSRegion()) { + case MS_JMS: { + RemoveHackShield(r); + Disable_AntiDebug(r); + FixClient(r); - r.JMP(0xAC0A82, r.Scan(L"68 FF 00 00 00 6A 00 6A 00 8B ?? ?? ?? ?? ?? 83 ?? ?? ?? 6A 03 FF 15"));//TMS157.2 MSCRC ManipulatePacket + switch (GetMSVersion()) { + case 187: + { + // JMS v187 only, later version of bigbang client has window mode option (it will cause TMS crash) + AOBPatch(WindowMode_PostBB, L"31 C0 C3"); + break; + } + default: + { + break; + } + } - RemoveHS_EasyVer(r); - //RemoveHackShield(r); + break; + } + case MS_TWMS: { + RemoveAntiCheat_EasyVer(r); + Disable_AntiDebug(r); + FixClient(r); + // TMS old default DNS (not available cause crash) + ULONG_PTR uGamania = r.StringPatch("tw.login.maplestory.gamania.com", "127.0.0.1"); -<<<<<<< Updated upstream - Disable_AntiDebug(r); - FixClient(r); -======= SCANRES(uGamania); switch (GetMSVersion()) { @@ -163,5 +171,4 @@ void EmuMain() { break; } } ->>>>>>> Stashed changes } \ No newline at end of file diff --git a/EmuMain/EmuMain.h b/EmuMain/EmuMain.h index e2aca4f..656a1f4 100644 --- a/EmuMain/EmuMain.h +++ b/EmuMain/EmuMain.h @@ -4,6 +4,16 @@ #include"../Share/Simple/Simple.h" #include"../Share/Hook/SimpleHook.h" +enum MSRegion { + MS_JMS, // default + MS_TWMS, + MS_MSEA +}; + void EmuMain(); +MSRegion GetMSRegion(); +int GetMSVersion(); +bool GetMSDisableMemoryDump(); + #endif \ No newline at end of file