1
0
Fork 0
mirror of https://github.com/atom0s/Steamless.git synced 2024-12-19 23:07:41 +01:00

API: Add ToString overrides to the section entries to allow easier debugging.

Unpacker: v31.x64 - Remove code section size check. (Some virtualized files will have an empty code section.)
Unpacker: v31.x64 - Allow empty code section files to still unpack by skipping decryption step.
This commit is contained in:
atom0s 2022-03-22 14:44:49 -07:00
parent 5b02106fca
commit f83d140ebf
No known key found for this signature in database
GPG key ID: 37D5FD3494D79AF8
3 changed files with 26 additions and 2 deletions

View file

@ -367,6 +367,15 @@ namespace Steamless.API.PE32
/// Gets if this structure is valid for a PE file. /// Gets if this structure is valid for a PE file.
/// </summary> /// </summary>
public bool IsValid => this.SizeOfRawData != 0 && this.PointerToRawData != 0; public bool IsValid => this.SizeOfRawData != 0 && this.PointerToRawData != 0;
/// <summary>
/// Overrides the ToString handler to return the section name.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return this.SectionName;
}
} }
/// <summary> /// <summary>

View file

@ -363,6 +363,15 @@ namespace Steamless.API.PE64
/// Gets if this structure is valid for a PE file. /// Gets if this structure is valid for a PE file.
/// </summary> /// </summary>
public bool IsValid => this.SizeOfRawData != 0 && this.PointerToRawData != 0; public bool IsValid => this.SizeOfRawData != 0 && this.PointerToRawData != 0;
/// <summary>
/// Overrides the ToString handler to return the section name.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return this.SectionName;
}
} }
/// <summary> /// <summary>

View file

@ -358,8 +358,6 @@ namespace Steamless.Unpacker.Variant31.x64
// Find the code section.. // Find the code section..
var codeSection = this.File.GetOwnerSection(this.StubHeader.CodeSectionVirtualAddress); var codeSection = this.File.GetOwnerSection(this.StubHeader.CodeSectionVirtualAddress);
if (codeSection.PointerToRawData == 0 || codeSection.SizeOfRawData == 0)
return false;
// Store the code sections index.. // Store the code sections index..
this.CodeSectionIndex = this.File.GetSectionIndex(codeSection); this.CodeSectionIndex = this.File.GetSectionIndex(codeSection);
@ -389,6 +387,14 @@ namespace Steamless.Unpacker.Variant31.x64
this.Log($" --> {codeSection.SectionName} linked as main code section.", LogMessageType.Debug); this.Log($" --> {codeSection.SectionName} linked as main code section.", LogMessageType.Debug);
this.Log($" --> {codeSection.SectionName} section is encrypted.", LogMessageType.Debug); this.Log($" --> {codeSection.SectionName} section is encrypted.", LogMessageType.Debug);
if (codeSection.SizeOfRawData == 0)
{
this.Log($" --> {codeSection.SectionName} section is empty; skipping decryption.", LogMessageType.Debug);
this.CodeSectionData = new byte[] { };
return true;
}
// Obtain the code section data.. // Obtain the code section data..
var codeSectionData = new byte[codeSection.SizeOfRawData + this.StubHeader.CodeSectionStolenData.Length]; var codeSectionData = new byte[codeSection.SizeOfRawData + this.StubHeader.CodeSectionStolenData.Length];
Array.Copy(this.StubHeader.CodeSectionStolenData, (long)0, codeSectionData, 0, this.StubHeader.CodeSectionStolenData.Length); Array.Copy(this.StubHeader.CodeSectionStolenData, (long)0, codeSectionData, 0, this.StubHeader.CodeSectionStolenData.Length);