From d8f78e0060d37349be285447dddae25d7941a3b0 Mon Sep 17 00:00:00 2001 From: Julian Xhokaxhiu Date: Thu, 24 Oct 2024 17:58:26 +0200 Subject: [PATCH] AppUI: Auto-patch for 4GB support --- AppCore/StringKey.cs | 4 +++- AppUI/AppUI.csproj | 2 ++ AppUI/Classes/GameConverter.cs | 5 +++-- AppUI/Classes/GameLauncher.cs | 18 +++++++++++++++--- .../Languages/StringResources.br.xaml | 3 +++ .../Languages/StringResources.de.xaml | 3 +++ .../Languages/StringResources.es.xaml | 3 +++ .../Languages/StringResources.fr.xaml | 3 +++ .../Languages/StringResources.gr.xaml | 3 +++ .../Languages/StringResources.it.xaml | 3 +++ .../Languages/StringResources.ja.xaml | 3 +++ AppUI/Resources/StringResources.xaml | 3 +++ 12 files changed, 47 insertions(+), 6 deletions(-) diff --git a/AppCore/StringKey.cs b/AppCore/StringKey.cs index e6dac636..c8e702d4 100644 --- a/AppCore/StringKey.cs +++ b/AppCore/StringKey.cs @@ -653,6 +653,8 @@ public enum StringKey DoYouWantToDisableDEP, SystemDEPDisabledPleaseReboot, CannotContinueWithDEPEnabled, - SomethingWentWrongWhileDisablingDEP + SomethingWentWrongWhileDisablingDEP, + App4GBPatchRequired, + App4GBPatchApplied } } diff --git a/AppUI/AppUI.csproj b/AppUI/AppUI.csproj index 0a74f145..8389894c 100644 --- a/AppUI/AppUI.csproj +++ b/AppUI/AppUI.csproj @@ -596,6 +596,8 @@ + + 4.6.1 diff --git a/AppUI/Classes/GameConverter.cs b/AppUI/Classes/GameConverter.cs index 624e1a02..46308ebf 100644 --- a/AppUI/Classes/GameConverter.cs +++ b/AppUI/Classes/GameConverter.cs @@ -144,7 +144,8 @@ public bool IsGamePirated() { byte[][] requiredHashes = { Convert.FromHexString("1C9A6F4B6F554B1B4ECB38812F9396A026A677D6"), // Steam - Convert.FromHexString("3D02CFD6441C89A0062B5D8F842C0271C5F2F410"), // Steam 4GB + Convert.FromHexString("3D02CFD6441C89A0062B5D8F842C0271C5F2F410"), // Steam 4GB NTCore + Convert.FromHexString("769B90800B17AF7A7DC31A0C4C37F256AF934876"), // Steam 4GB 7thHeaven auto-patch }; using (FileStream fs = new FileStream(Path.Combine(InstallPath, "ff7_en.exe"), FileMode.Open)) { @@ -289,7 +290,7 @@ internal bool BackupExe(string backupFolderPath) { Directory.CreateDirectory(backupFolderPath); - string ff7ExePath = Path.Combine(InstallPath, "ff7.exe"); + string ff7ExePath = Sys.Settings.FF7Exe; try { diff --git a/AppUI/Classes/GameLauncher.cs b/AppUI/Classes/GameLauncher.cs index 55cc5948..b8447ebf 100644 --- a/AppUI/Classes/GameLauncher.cs +++ b/AppUI/Classes/GameLauncher.cs @@ -1,10 +1,10 @@ using AppCore; using AppWrapper; +using AsmResolver; using Iros; using Iros.Workshop; using Microsoft.Win32; using AppUI.Windows; -using AppUI; using AppUI.ViewModels; using SharpCompress.Archives; using SharpCompress.Archives.Zip; @@ -17,10 +17,11 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; -using System.Windows.Forms; -using System.Windows.Interop; using System.Xml; using Profile = Iros.Workshop.Profile; +using AsmResolver.PE.File; +using System.Windows.Shell; +using AsmResolver.PE.File.Headers; namespace AppUI.Classes { @@ -282,6 +283,17 @@ public static async Task LaunchGame(bool varDump, bool debug, bool launchW } } + // Auto-patch for 4GB support + Instance.RaiseProgressChanged(ResourceHelper.Get(StringKey.App4GBPatchRequired)); + PEFile file = PEFile.FromFile(Sys.Settings.FF7Exe); + if (!file.FileHeader.Characteristics.HasFlag(AsmResolver.PE.File.Headers.Characteristics.LargeAddressAware)) + { + converter.BackupExe(backupFolderPath); + file.FileHeader.Characteristics |= Characteristics.LargeAddressAware; + file.Write(Sys.Settings.FF7Exe); + Instance.RaiseProgressChanged(ResourceHelper.Get(StringKey.App4GBPatchApplied)); + } + // // Copy the new launcher to the game path // diff --git a/AppUI/Resources/Languages/StringResources.br.xaml b/AppUI/Resources/Languages/StringResources.br.xaml index 32969b3b..48b5c0a5 100644 --- a/AppUI/Resources/Languages/StringResources.br.xaml +++ b/AppUI/Resources/Languages/StringResources.br.xaml @@ -1262,4 +1262,7 @@ Você quer aplicar essa configuração e tentar de novo? DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. \ No newline at end of file diff --git a/AppUI/Resources/Languages/StringResources.de.xaml b/AppUI/Resources/Languages/StringResources.de.xaml index 26f08399..b584d61d 100644 --- a/AppUI/Resources/Languages/StringResources.de.xaml +++ b/AppUI/Resources/Languages/StringResources.de.xaml @@ -1270,4 +1270,7 @@ Möchten Sie die Einstellung übernehmen und es erneut versuchen?DEP-Modus erfolgreich aktualisiert. Bitte starten Sie den PC neu, damit die Änderung wirksam wird. DEP-Modus ist fehlerhaft. Bitte zum Fortfahren anpassen, indem Sie die hier beschriebenen Schritte befolgen: https://7thheaven.rocks/help/dep.html Beim Versuch, DEP anzupassen, ist ein Fehler aufgetreten. Sie können es dennoch manuell durchführen. Bitte befolgen Sie die hier beschriebenen Schritte: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. \ No newline at end of file diff --git a/AppUI/Resources/Languages/StringResources.es.xaml b/AppUI/Resources/Languages/StringResources.es.xaml index 3e74dfd6..f2d53de7 100644 --- a/AppUI/Resources/Languages/StringResources.es.xaml +++ b/AppUI/Resources/Languages/StringResources.es.xaml @@ -1271,4 +1271,7 @@ Por último, si quieres usar archivos .OGG de alta calidad, cambia la opción de DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. diff --git a/AppUI/Resources/Languages/StringResources.fr.xaml b/AppUI/Resources/Languages/StringResources.fr.xaml index 39383375..bfc41ba6 100644 --- a/AppUI/Resources/Languages/StringResources.fr.xaml +++ b/AppUI/Resources/Languages/StringResources.fr.xaml @@ -1257,4 +1257,7 @@ Voulez-vous appliquer ce réglage et essayer à nouveau ? DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. diff --git a/AppUI/Resources/Languages/StringResources.gr.xaml b/AppUI/Resources/Languages/StringResources.gr.xaml index 7c6beb9b..0581a04b 100644 --- a/AppUI/Resources/Languages/StringResources.gr.xaml +++ b/AppUI/Resources/Languages/StringResources.gr.xaml @@ -1265,4 +1265,7 @@ Once done, do close the game and the launcher, and finally retry to click Play h DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. diff --git a/AppUI/Resources/Languages/StringResources.it.xaml b/AppUI/Resources/Languages/StringResources.it.xaml index 65fc2ee5..1e1cc08a 100644 --- a/AppUI/Resources/Languages/StringResources.it.xaml +++ b/AppUI/Resources/Languages/StringResources.it.xaml @@ -1261,4 +1261,7 @@ Vuoi applicare questa modifica e riprovare? DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. \ No newline at end of file diff --git a/AppUI/Resources/Languages/StringResources.ja.xaml b/AppUI/Resources/Languages/StringResources.ja.xaml index bcda8a8c..a87dad74 100644 --- a/AppUI/Resources/Languages/StringResources.ja.xaml +++ b/AppUI/Resources/Languages/StringResources.ja.xaml @@ -1226,4 +1226,7 @@ Do you want to apply the setting and try again? DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully. \ No newline at end of file diff --git a/AppUI/Resources/StringResources.xaml b/AppUI/Resources/StringResources.xaml index b1d54761..bef107c5 100644 --- a/AppUI/Resources/StringResources.xaml +++ b/AppUI/Resources/StringResources.xaml @@ -1273,4 +1273,7 @@ Do you want to apply the setting and try again? DEP mode successfully updated. Please reboot the PC for the change to take effect. DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html Something went wrong while trying to adjust DEP. You can still do it manually. Please follow steps described here: https://7thheaven.rocks/help/dep.html + + Ensuring Game exe has the 4GB patch applied... + 4GB patch applied successfully.