@@ -367,6 +367,7 @@ bool DetectGame()
367367 {
368368 spdlog::info (" Detected launcher for game: {} (app {})" , info.GameTitle .c_str (), info.SteamAppId );
369369 eGameType = LAUNCHER ;
370+ unityPlayer = GetModuleHandleA (" UnityPlayer.dll" );
370371 game = &info;
371372 return true ;
372373 }
@@ -384,9 +385,7 @@ bool DetectGame()
384385 eGameType = type;
385386 game = &info;
386387
387- engineModule = GetModuleHandleA (" Engine.dll" );
388- HMODULE engineModule = GetModuleHandleA (" Engine.dll" );
389- if (!engineModule)
388+ if (engineModule = GetModuleHandleA (" Engine.dll" ); !engineModule)
390389 {
391390 spdlog::error (" Failed to get Engine.dll module handle" );
392391 }
@@ -765,10 +764,8 @@ void Init_AspectFOVFix()
765764 if (eGameType & MGS3 && bAspectFix)
766765 {
767766 // MGS 3: Fix gameplay aspect ratio
768- uint8_t * MGS3_GameplayAspectScanResult = Memory::PatternScanSilent (baseModule, " F3 0F ?? ?? E8 ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ??" );
769- if (MGS3_GameplayAspectScanResult)
767+ if (uint8_t * MGS3_GameplayAspectScanResult = Memory::PatternScan (baseModule, " F3 0F ?? ?? E8 ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ??" , " MGS 3: Aspect Ratio" , NULL , NULL ))
770768 {
771- spdlog::info (" MGS 3: Aspect Ratio: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS3_GameplayAspectScanResult - (uintptr_t )baseModule);
772769 DWORD64 MGS3_GameplayAspectAddress = Memory::GetAbsolute ((uintptr_t )MGS3_GameplayAspectScanResult + 0x5 );
773770 spdlog::info (" MGS 3: Aspect Ratio: Function address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS3_GameplayAspectAddress - (uintptr_t )baseModule);
774771
@@ -778,19 +775,15 @@ void Init_AspectFOVFix()
778775 {
779776 ctx.xmm1 .f32 [0 ] /= fAspectMultiplier ;
780777 });
781- }
782- else if (!MGS3_GameplayAspectScanResult)
783- {
784- spdlog::error (" MG/MG2 | MGS 3: Aspect Ratio: Pattern scan failed." );
778+ LOG_HOOK (MGS3_GameplayAspectMidHook, " MGS 3: Aspect Ratio" , NULL , NULL )
779+
785780 }
786781 }
787782 else if (eGameType & MGS2 && bAspectFix)
788783 {
789784 // MGS 2: Fix gameplay aspect ratio
790- uint8_t * MGS2_GameplayAspectScanResult = Memory::PatternScanSilent (baseModule, " 48 8D ?? ?? ?? E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? F3 44 ?? ?? ?? ?? ?? ?? ??" );
791- if (MGS2_GameplayAspectScanResult)
785+ if (uint8_t * MGS2_GameplayAspectScanResult = Memory::PatternScan (baseModule, " 48 8D ?? ?? ?? E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? F3 44 ?? ?? ?? ?? ?? ?? ??" , " MGS 2: Aspect Ratio" , NULL , NULL ))
792786 {
793- spdlog::info (" MGS 2: Aspect Ratio: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS2_GameplayAspectScanResult - (uintptr_t )baseModule);
794787 DWORD64 MGS2_GameplayAspectAddress = Memory::GetAbsolute ((uintptr_t )MGS2_GameplayAspectScanResult + 0xB );
795788 spdlog::info (" MGS 2: Aspect Ratio: Function address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS2_GameplayAspectAddress - (uintptr_t )baseModule);
796789
@@ -800,22 +793,16 @@ void Init_AspectFOVFix()
800793 {
801794 ctx.xmm0 .f32 [0 ] /= fAspectMultiplier ;
802795 });
803- }
804- else if (!MGS2_GameplayAspectScanResult)
805- {
806- spdlog::error (" MGS 2: Aspect Ratio: Pattern scan failed." );
796+ LOG_HOOK (MGS2_GameplayAspectMidHook, " MGS 2: Aspect Ratio" , NULL , NULL )
807797 }
808798 }
809799
810800 // Convert FOV to vert- to match 16:9 horizontal field of view
811801 if (eGameType & MGS3 && bFOVFix)
812802 {
813803 // MGS 3: FOV
814- uint8_t * MGS3_FOVScanResult = Memory::PatternScanSilent (baseModule, " F3 0F ?? ?? ?? ?? ?? ?? 44 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? F3 ?? ?? ?? ?? E8 ?? ?? ?? ??" );
815- if (MGS3_FOVScanResult)
804+ if (uint8_t * MGS3_FOVScanResult = Memory::PatternScan (baseModule, " F3 0F ?? ?? ?? ?? ?? ?? 44 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? F3 ?? ?? ?? ?? E8 ?? ?? ?? ??" , " MGS 3: FOV" , NULL , NULL ))
816805 {
817- spdlog::info (" MGS 3: FOV: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS3_FOVScanResult - (uintptr_t )baseModule);
818-
819806 static SafetyHookMid MGS3_FOVMidHook{};
820807 MGS3_FOVMidHook = safetyhook::create_mid (MGS3_FOVScanResult,
821808 [](SafetyHookContext& ctx)
@@ -825,20 +812,14 @@ void Init_AspectFOVFix()
825812 ctx.xmm2 .f32 [0 ] *= fAspectMultiplier ;
826813 }
827814 });
828- }
829- else if (!MGS3_FOVScanResult)
830- {
831- spdlog::error (" MGS 3: FOV: Pattern scan failed." );
815+ LOG_HOOK (MGS3_FOVMidHook, " MG3 2: FOV" , NULL , NULL )
832816 }
833817 }
834818 else if (eGameType & MGS2 && bFOVFix)
835819 {
836820 // MGS 2: FOV
837- uint8_t * MGS2_FOVScanResult = Memory::PatternScanSilent (baseModule, " 44 ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 44 ?? ?? ?? ?? 48 ?? ?? 48 ?? ?? ?? ?? 00 00" );
838- if (MGS2_FOVScanResult)
821+ if (uint8_t * MGS2_FOVScanResult = Memory::PatternScan (baseModule, " 44 ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? 44 ?? ?? ?? ?? 48 ?? ?? 48 ?? ?? ?? ?? 00 00" , " MGS 2: FOV" , NULL , NULL ))
839822 {
840- spdlog::info (" MGS 2: FOV: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS2_FOVScanResult - (uintptr_t )baseModule);
841-
842823 static SafetyHookMid MGS2_FOVMidHook{};
843824 MGS2_FOVMidHook = safetyhook::create_mid (MGS2_FOVScanResult,
844825 [](SafetyHookContext& ctx)
@@ -848,11 +829,9 @@ void Init_AspectFOVFix()
848829 ctx.xmm2 .f32 [0 ] *= fAspectMultiplier ;
849830 }
850831 });
832+ LOG_HOOK (MGS2_FOVMidHook, " MGS 2: FOV" , NULL , NULL )
851833 }
852- else if (!MGS2_FOVScanResult)
853- {
854- spdlog::error (" MGS 2: FOV: Pattern scan failed." );
855- }
834+
856835 }
857836
858837}
@@ -1038,42 +1017,20 @@ void Init_Miscellaneous()
10381017 {
10391018 // Launcher | MG/MG2 | MGS 2 | MGS 3: Disable mouse cursor
10401019 // Thanks again emoose!
1041- uint8_t * MGS2_MGS3_MouseCursorScanResult = Memory::PatternScanSilent (baseModule, " BA 00 7F 00 00 33 ?? FF ?? ?? ?? ?? ?? 48 ?? ??" );
1042- if (eGameType & LAUNCHER )
1043- {
1044- unityPlayer = GetModuleHandleA (" UnityPlayer.dll" );
1045- MGS2_MGS3_MouseCursorScanResult = Memory::PatternScanSilent (unityPlayer, " BA 00 7F 00 00 33 ?? FF ?? ?? ?? ?? ?? 48 ?? ??" );
1046- }
1047-
1048- if (MGS2_MGS3_MouseCursorScanResult)
1020+ if (uint8_t * MGS2_MGS3_MouseCursorScanResult = Memory::PatternScan (eGameType & LAUNCHER ? unityPlayer : baseModule, " BA 00 7F 00 00 33 ?? FF ?? ?? ?? ?? ?? 48 ?? ??" , " Launcher | MG/MG2 | MGS 2 | MGS 3: Mouse Cursor" , NULL , NULL ))
10491021 {
1050- if (eGameType & LAUNCHER )
1051- {
1052- spdlog::info (" Launcher | MG/MG2 | MGS 2 | MGS 3: Mouse Cursor: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS2_MGS3_MouseCursorScanResult - (uintptr_t )unityPlayer);
1053- }
1054- else
1055- {
1056- spdlog::info (" Launcher | MG/MG2 | MGS 2 | MGS 3: Mouse Cursor: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS2_MGS3_MouseCursorScanResult - (uintptr_t )baseModule);
1057- }
10581022 // The game enters 32512 in the RDX register for the function USER32.LoadCursorA to load IDC_ARROW (normal select arrow in windows)
10591023 // Set this to 0 and no cursor icon is loaded
10601024 Memory::PatchBytes ((uintptr_t )MGS2_MGS3_MouseCursorScanResult + 0x2 , " \x00 " , 1 );
10611025 spdlog::info (" Launcher | MG/MG2 | MGS 2 | MGS 3: Mouse Cursor: Patched instruction." );
10621026 }
1063- else if (!MGS2_MGS3_MouseCursorScanResult)
1064- {
1065- spdlog::error (" Launcher | MG/MG2 | MGS 2 | MGS 3: Mouse Cursor: Pattern scan failed." );
1066- }
10671027 }
10681028 }
10691029
10701030 if ((bDisableTextureFiltering || iAnisotropicFiltering > 0 ) && (eGameType & (MGS2 |MGS3 )))
10711031 {
1072- uint8_t * MGS3_SetSamplerStateInsnScanResult = Memory::PatternScanSilent (baseModule, " 48 8B ?? ?? ?? ?? ?? 44 39 ?? ?? 38 ?? ?? ?? 74 ?? 44 89 ?? ?? ?? ?? ?? ?? EB ?? 48 ?? ??" );
1073- if (MGS3_SetSamplerStateInsnScanResult)
1032+ if (uint8_t * MGS3_SetSamplerStateInsnScanResult = Memory::PatternScan (baseModule, " 48 8B ?? ?? ?? ?? ?? 44 39 ?? ?? 38 ?? ?? ?? 74 ?? 44 89 ?? ?? ?? ?? ?? ?? EB ?? 48 ?? ??" , " MGS 2 | MGS 3: Texture Filtering" , NULL , NULL ))
10741033 {
1075- spdlog::info (" MGS 2 | MGS 3: Texture Filtering: Address is {:s}+{:x}" , sExeName .c_str (), (uintptr_t )MGS3_SetSamplerStateInsnScanResult - (uintptr_t )baseModule);
1076-
10771034 static SafetyHookMid SetSamplerStateInsnXMidHook{};
10781035 SetSamplerStateInsnXMidHook = safetyhook::create_mid (MGS3_SetSamplerStateInsnScanResult + 0x7 ,
10791036 [](SafetyHookContext& ctx)
@@ -1086,12 +1043,9 @@ void Init_Miscellaneous()
10861043 // 0x1 = D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR (Linear mips is essentially perspective correction.) 0x55 = D3D11_FILTER_ANISOTROPIC
10871044 ctx.r9 = bDisableTextureFiltering ? 0x1 : 0x55 ;
10881045 });
1089-
1090- }
1091- else if (!MGS3_SetSamplerStateInsnScanResult)
1092- {
1093- spdlog::error (" MGS 2 | MGS 3: Texture Filtering: Pattern scan failed." );
1046+ LOG_HOOK (SetSamplerStateInsnXMidHook, " MGS 2 | MGS 3: Texture Filtering" , NULL , NULL )
10941047 }
1048+
10951049 }
10961050
10971051 if (eGameType & MGS3 && bMouseSensitivity)
0 commit comments