diff --git a/Steamless.API/Model/SteamlessOptions.cs b/Steamless.API/Model/SteamlessOptions.cs index 56bda8e..a9494e3 100644 --- a/Steamless.API/Model/SteamlessOptions.cs +++ b/Steamless.API/Model/SteamlessOptions.cs @@ -37,6 +37,7 @@ namespace Steamless.API.Model this.DumpPayloadToDisk = false; this.DumpSteamDrmpToDisk = false; this.UseExperimentalFeatures = false; + this.DontRealignSections = false; } /// @@ -83,5 +84,14 @@ namespace Steamless.API.Model get => this.Get("UseExperimentalFeatures"); set => this.Set("UseExperimentalFeatures", value); } + + /// + /// Gets or sets the don't realign sections option value. + /// + public bool DontRealignSections + { + get => this.Get("DontRealignSections"); + set => this.Set("DontRealignSections", value); + } } } \ No newline at end of file diff --git a/Steamless.API/PE32/Pe32File.cs b/Steamless.API/PE32/Pe32File.cs index b16d00f..c49098d 100644 --- a/Steamless.API/PE32/Pe32File.cs +++ b/Steamless.API/PE32/Pe32File.cs @@ -304,17 +304,23 @@ namespace Steamless.API.PE32 /// /// Rebuilds the sections by aligning them as needed. Updates the Nt headers to /// correct the new SizeOfImage after alignment is completed. + /// + /// /// - public void RebuildSections() + public void RebuildSections(bool realign = true) { for (var x = 0; x < this.Sections.Count; x++) { // Obtain the current section and realign the data.. var section = this.Sections[x]; - section.VirtualAddress = this.GetAlignment(section.VirtualAddress, this.NtHeaders.OptionalHeader.SectionAlignment); - section.VirtualSize = this.GetAlignment(section.VirtualSize, this.NtHeaders.OptionalHeader.SectionAlignment); - section.PointerToRawData = this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment); - section.SizeOfRawData = this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment); + + if (realign) + { + section.VirtualAddress = this.GetAlignment(section.VirtualAddress, this.NtHeaders.OptionalHeader.SectionAlignment); + section.VirtualSize = this.GetAlignment(section.VirtualSize, this.NtHeaders.OptionalHeader.SectionAlignment); + section.PointerToRawData = this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment); + section.SizeOfRawData = this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment); + } // Store the sections updates.. this.Sections[x] = section; diff --git a/Steamless.API/PE64/Pe64File.cs b/Steamless.API/PE64/Pe64File.cs index aba0206..19e8164 100644 --- a/Steamless.API/PE64/Pe64File.cs +++ b/Steamless.API/PE64/Pe64File.cs @@ -140,7 +140,7 @@ namespace Steamless.API.PE64 // Read the Tls directory.. this.TlsDirectory = Pe64Helpers.GetStructure(this.FileData, (int)addr); - if (this.TlsDirectory.AddressOfCallBacks == 0) + if (this.TlsDirectory.AddressOfCallBacks == 0) return true; // Read the Tls callbacks.. @@ -307,17 +307,23 @@ namespace Steamless.API.PE64 /// /// Rebuilds the sections by aligning them as needed. Updates the Nt headers to /// correct the new SizeOfImage after alignment is completed. + /// + /// /// - public void RebuildSections() + public void RebuildSections(bool realign = true) { for (var x = 0; x < this.Sections.Count; x++) { // Obtain the current section and realign the data.. var section = this.Sections[x]; - section.VirtualAddress = (uint)this.GetAlignment(section.VirtualAddress, this.NtHeaders.OptionalHeader.SectionAlignment); - section.VirtualSize = (uint)this.GetAlignment(section.VirtualSize, this.NtHeaders.OptionalHeader.SectionAlignment); - section.PointerToRawData = (uint)this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment); - section.SizeOfRawData = (uint)this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment); + + if (realign) + { + section.VirtualAddress = (uint)this.GetAlignment(section.VirtualAddress, this.NtHeaders.OptionalHeader.SectionAlignment); + section.VirtualSize = (uint)this.GetAlignment(section.VirtualSize, this.NtHeaders.OptionalHeader.SectionAlignment); + section.PointerToRawData = (uint)this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment); + section.SizeOfRawData = (uint)this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment); + } // Store the sections updates.. this.Sections[x] = section; diff --git a/Steamless.Unpacker.Variant20.x86/Main.cs b/Steamless.Unpacker.Variant20.x86/Main.cs index f7d19c8..3c29fe1 100644 --- a/Steamless.Unpacker.Variant20.x86/Main.cs +++ b/Steamless.Unpacker.Variant20.x86/Main.cs @@ -286,7 +286,7 @@ namespace Steamless.Unpacker.Variant20.x86 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); } catch { diff --git a/Steamless.Unpacker.Variant21.x86/Main.cs b/Steamless.Unpacker.Variant21.x86/Main.cs index be6c3b0..b6fc477 100644 --- a/Steamless.Unpacker.Variant21.x86/Main.cs +++ b/Steamless.Unpacker.Variant21.x86/Main.cs @@ -433,7 +433,7 @@ namespace Steamless.Unpacker.Variant21.x86 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); // Open the unpacked file for writing.. var unpackedPath = this.File.FilePath + ".unpacked.exe"; diff --git a/Steamless.Unpacker.Variant30.x64/Main.cs b/Steamless.Unpacker.Variant30.x64/Main.cs index 7a4e086..0ef140c 100644 --- a/Steamless.Unpacker.Variant30.x64/Main.cs +++ b/Steamless.Unpacker.Variant30.x64/Main.cs @@ -432,7 +432,7 @@ namespace Steamless.Unpacker.Variant30.x64 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); // Open the unpacked file for writing.. var unpackedPath = this.File.FilePath + ".unpacked.exe"; diff --git a/Steamless.Unpacker.Variant30.x86/Main.cs b/Steamless.Unpacker.Variant30.x86/Main.cs index ef66fd4..c206fb2 100644 --- a/Steamless.Unpacker.Variant30.x86/Main.cs +++ b/Steamless.Unpacker.Variant30.x86/Main.cs @@ -437,7 +437,7 @@ namespace Steamless.Unpacker.Variant30.x86 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); // Open the unpacked file for writing.. var unpackedPath = this.File.FilePath + ".unpacked.exe"; diff --git a/Steamless.Unpacker.Variant31.x64/Main.cs b/Steamless.Unpacker.Variant31.x64/Main.cs index 93c3901..ee52e38 100644 --- a/Steamless.Unpacker.Variant31.x64/Main.cs +++ b/Steamless.Unpacker.Variant31.x64/Main.cs @@ -434,7 +434,7 @@ namespace Steamless.Unpacker.Variant31.x64 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); // Open the unpacked file for writing.. var unpackedPath = this.File.FilePath + ".unpacked.exe"; diff --git a/Steamless.Unpacker.Variant31.x86/Main.cs b/Steamless.Unpacker.Variant31.x86/Main.cs index 8ad1a74..d5e2308 100644 --- a/Steamless.Unpacker.Variant31.x86/Main.cs +++ b/Steamless.Unpacker.Variant31.x86/Main.cs @@ -433,7 +433,7 @@ namespace Steamless.Unpacker.Variant31.x86 try { // Rebuild the file sections.. - this.File.RebuildSections(); + this.File.RebuildSections(this.Options.DontRealignSections == false); // Open the unpacked file for writing.. var unpackedPath = this.File.FilePath + ".unpacked.exe"; diff --git a/Steamless/View/MainView.xaml b/Steamless/View/MainView.xaml index 48ec945..d36a71f 100644 --- a/Steamless/View/MainView.xaml +++ b/Steamless/View/MainView.xaml @@ -84,12 +84,14 @@ + +