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.DumpPayloadToDisk = false;
|
||||||
this.DumpSteamDrmpToDisk = false;
|
this.DumpSteamDrmpToDisk = false;
|
||||||
this.UseExperimentalFeatures = false;
|
this.UseExperimentalFeatures = false;
|
||||||
|
this.DontRealignSections = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -83,5 +84,14 @@ namespace Steamless.API.Model
|
||||||
get => this.Get<bool>("UseExperimentalFeatures");
|
get => this.Get<bool>("UseExperimentalFeatures");
|
||||||
set => this.Set("UseExperimentalFeatures", value);
|
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>
|
/// <summary>
|
||||||
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
||||||
/// correct the new SizeOfImage after alignment is completed.
|
/// correct the new SizeOfImage after alignment is completed.
|
||||||
|
///
|
||||||
|
/// <param name="realign"></param>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RebuildSections()
|
public void RebuildSections(bool realign = true)
|
||||||
{
|
{
|
||||||
for (var x = 0; x < this.Sections.Count; x++)
|
for (var x = 0; x < this.Sections.Count; x++)
|
||||||
{
|
{
|
||||||
// Obtain the current section and realign the data..
|
// Obtain the current section and realign the data..
|
||||||
var section = this.Sections[x];
|
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);
|
if (realign)
|
||||||
section.PointerToRawData = this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment);
|
{
|
||||||
section.SizeOfRawData = this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment);
|
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..
|
// Store the sections updates..
|
||||||
this.Sections[x] = section;
|
this.Sections[x] = section;
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace Steamless.API.PE64
|
||||||
// Read the Tls directory..
|
// Read the Tls directory..
|
||||||
this.TlsDirectory = Pe64Helpers.GetStructure<NativeApi64.ImageTlsDirectory64>(this.FileData, (int)addr);
|
this.TlsDirectory = Pe64Helpers.GetStructure<NativeApi64.ImageTlsDirectory64>(this.FileData, (int)addr);
|
||||||
|
|
||||||
if (this.TlsDirectory.AddressOfCallBacks == 0)
|
if (this.TlsDirectory.AddressOfCallBacks == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Read the Tls callbacks..
|
// Read the Tls callbacks..
|
||||||
|
@ -307,17 +307,23 @@ namespace Steamless.API.PE64
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
/// Rebuilds the sections by aligning them as needed. Updates the Nt headers to
|
||||||
/// correct the new SizeOfImage after alignment is completed.
|
/// correct the new SizeOfImage after alignment is completed.
|
||||||
|
///
|
||||||
|
/// <param name="realign"></param>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RebuildSections()
|
public void RebuildSections(bool realign = true)
|
||||||
{
|
{
|
||||||
for (var x = 0; x < this.Sections.Count; x++)
|
for (var x = 0; x < this.Sections.Count; x++)
|
||||||
{
|
{
|
||||||
// Obtain the current section and realign the data..
|
// Obtain the current section and realign the data..
|
||||||
var section = this.Sections[x];
|
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);
|
if (realign)
|
||||||
section.PointerToRawData = (uint)this.GetAlignment(section.PointerToRawData, this.NtHeaders.OptionalHeader.FileAlignment);
|
{
|
||||||
section.SizeOfRawData = (uint)this.GetAlignment(section.SizeOfRawData, this.NtHeaders.OptionalHeader.FileAlignment);
|
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..
|
// Store the sections updates..
|
||||||
this.Sections[x] = section;
|
this.Sections[x] = section;
|
||||||
|
|
|
@ -286,7 +286,7 @@ namespace Steamless.Unpacker.Variant20.x86
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
@ -433,7 +433,7 @@ namespace Steamless.Unpacker.Variant21.x86
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
|
|
||||||
// Open the unpacked file for writing..
|
// Open the unpacked file for writing..
|
||||||
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
||||||
|
|
|
@ -432,7 +432,7 @@ namespace Steamless.Unpacker.Variant30.x64
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
|
|
||||||
// Open the unpacked file for writing..
|
// Open the unpacked file for writing..
|
||||||
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
||||||
|
|
|
@ -437,7 +437,7 @@ namespace Steamless.Unpacker.Variant30.x86
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
|
|
||||||
// Open the unpacked file for writing..
|
// Open the unpacked file for writing..
|
||||||
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
||||||
|
|
|
@ -434,7 +434,7 @@ namespace Steamless.Unpacker.Variant31.x64
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
|
|
||||||
// Open the unpacked file for writing..
|
// Open the unpacked file for writing..
|
||||||
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
||||||
|
|
|
@ -433,7 +433,7 @@ namespace Steamless.Unpacker.Variant31.x86
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Rebuild the file sections..
|
// Rebuild the file sections..
|
||||||
this.File.RebuildSections();
|
this.File.RebuildSections(this.Options.DontRealignSections == false);
|
||||||
|
|
||||||
// Open the unpacked file for writing..
|
// Open the unpacked file for writing..
|
||||||
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
var unpackedPath = this.File.FilePath + ".unpacked.exe";
|
||||||
|
|
|
@ -84,12 +84,14 @@
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</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="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="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="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="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="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>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue