mirror of
https://github.com/atom0s/Steamless.git
synced 2024-12-19 23:07:41 +01:00
API: Add new option to allow disabling of section realignment.
Core: Add support for new disable section realignment option. Unpacker: v20.x86 - Add support for new disable section realignment option. Unpacker: v21.x86 - Add support for new disable section realignment option. Unpacker: v30.x86 - Add support for new disable section realignment option. Unpacker: v30.x64 - Add support for new disable section realignment option. Unpacker: v31.x86 - Add support for new disable section realignment option. Unpacker: v31.x64 - Add support for new disable section realignment option.
This commit is contained in:
parent
75afb9e425
commit
079a086129
10 changed files with 41 additions and 17 deletions
|
@ -37,6 +37,7 @@ namespace Steamless.API.Model
|
|||
this.DumpPayloadToDisk = false;
|
||||
this.DumpSteamDrmpToDisk = false;
|
||||
this.UseExperimentalFeatures = false;
|
||||
this.DontRealignSections = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -83,5 +84,14 @@ namespace Steamless.API.Model
|
|||
get => this.Get<bool>("UseExperimentalFeatures");
|
||||
set => this.Set("UseExperimentalFeatures", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the don't realign sections option value.
|
||||
/// </summary>
|
||||
public bool DontRealignSections
|
||||
{
|
||||
get => this.Get<bool>("DontRealignSections");
|
||||
set => this.Set("DontRealignSections", value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -304,17 +304,23 @@ namespace Steamless.API.PE32
|
|||
/// <summary>
|
||||
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
||||
/// correct the new SizeOfImage after alignment is completed.
|
||||
///
|
||||
/// <param name="realign"></param>
|
||||
/// </summary>
|
||||
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;
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace Steamless.API.PE64
|
|||
// Read the Tls directory..
|
||||
this.TlsDirectory = Pe64Helpers.GetStructure<NativeApi64.ImageTlsDirectory64>(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
|
|||
/// <summary>
|
||||
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
||||
/// correct the new SizeOfImage after alignment is completed.
|
||||
///
|
||||
/// <param name="realign"></param>
|
||||
/// </summary>
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -84,12 +84,14 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" Content="Verbose Output" Margin="2" ToolTip="If enabled, Steamless will allow logging of debug messages." IsChecked="{Binding Options.VerboseOutput}" />
|
||||
<CheckBox Grid.Row="1" Content="Keep Bind Section" Margin="2" ToolTip="The bind section should be kept within the file after unpacking." IsChecked="{Binding Options.KeepBindSection}" />
|
||||
<CheckBox Grid.Row="2" Content="Dump Payload To Disk" Margin="2" ToolTip="Dumps the payload to disk where the target file is located. (File will be saved with the .payload extension.)" IsChecked="{Binding Options.DumpPayloadToDisk}" />
|
||||
<CheckBox Grid.Row="3" Content="Dump SteamDRMP.dll To Disk" Margin="2" ToolTip="Dumps the SteamDRMP.dll to disk where the target file is located." IsChecked="{Binding Options.DumpSteamDrmpToDisk}" />
|
||||
<CheckBox Grid.Row="4" Content="Use Experimental Features" Margin="2" ToolTip="Enables the use of experimental features." IsChecked="{Binding Options.UseExperimentalFeatures}" />
|
||||
<CheckBox Grid.Row="5" Content="Don't Realign Sections" Margin="2" ToolTip="Disables realignment of sections when unpacking." IsChecked="{Binding Options.DontRealignSections}" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
|
|
Loading…
Reference in a new issue