Skip to content

Commit

Permalink
AppUI: Auto-patch for 4GB support
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Oct 24, 2024
1 parent 9d63947 commit d8f78e0
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 6 deletions.
4 changes: 3 additions & 1 deletion AppCore/StringKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ public enum StringKey
DoYouWantToDisableDEP,
SystemDEPDisabledPleaseReboot,
CannotContinueWithDEPEnabled,
SomethingWentWrongWhileDisablingDEP
SomethingWentWrongWhileDisablingDEP,
App4GBPatchRequired,
App4GBPatchApplied
}
}
2 changes: 2 additions & 0 deletions AppUI/AppUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AsmResolver" Version="5.5.1" />
<PackageReference Include="AsmResolver.PE.File" Version="5.5.1" />
<PackageReference Include="Extended.Wpf.Toolkit">
<Version>4.6.1</Version>
</PackageReference>
Expand Down
5 changes: 3 additions & 2 deletions AppUI/Classes/GameConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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
{
Expand Down
18 changes: 15 additions & 3 deletions AppUI/Classes/GameLauncher.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -282,6 +283,17 @@ public static async Task<bool> 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
//
Expand Down
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.br.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1262,4 +1262,7 @@ Você quer aplicar essa configuração e tentar de novo?</system:String>
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.de.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1270,4 +1270,7 @@ Möchten Sie die Einstellung übernehmen und es erneut versuchen?</system:String
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP-Modus erfolgreich aktualisiert. Bitte starten Sie den PC neu, damit die Änderung wirksam wird.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP-Modus ist fehlerhaft. Bitte zum Fortfahren anpassen, indem Sie die hier beschriebenen Schritte befolgen: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.es.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1271,4 +1271,7 @@ Por último, si quieres usar archivos .OGG de alta calidad, cambia la opción de
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.fr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1257,4 +1257,7 @@ Voulez-vous appliquer ce réglage et essayer à nouveau ?</system:String>
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.gr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1265,4 +1265,7 @@ Once done, do close the game and the launcher, and finally retry to click Play h
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.it.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1261,4 +1261,7 @@ Vuoi applicare questa modifica e riprovare?</system:String>
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/Languages/StringResources.ja.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,4 +1226,7 @@ Do you want to apply the setting and try again?</system:String>
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>
3 changes: 3 additions & 0 deletions AppUI/Resources/StringResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,4 +1273,7 @@ Do you want to apply the setting and try again?</system:String>
<system:String x:Key="SystemDEPDisabledPleaseReboot">DEP mode successfully updated. Please reboot the PC for the change to take effect.</system:String>
<system:String x:Key="CannotContinueWithDEPEnabled">DEP mode is incorrect. Please adjust it to continue, following the steps described here: https://7thheaven.rocks/help/dep.html</system:String>
<system:String x:Key="SomethingWentWrongWhileDisablingDEP">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</system:String>

<system:String x:Key="App4GBPatchRequired">Ensuring Game exe has the 4GB patch applied...</system:String>
<system:String x:Key="App4GBPatchApplied">4GB patch applied successfully.</system:String>
</ResourceDictionary>

0 comments on commit d8f78e0

Please sign in to comment.