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

* Unpacker v2.1 (x86) - Updated the header to handle the StubData more correctly.

This commit is contained in:
atom0s 2022-04-24 21:34:23 -07:00
parent 0b67eab1d1
commit 1bdd96e657
No known key found for this signature in database
GPG key ID: 37D5FD3494D79AF8
2 changed files with 32 additions and 4 deletions

View file

@ -54,8 +54,13 @@ namespace Steamless.Unpacker.Variant21.x86.Classes
public uint SteamDRMPDllSize; // The offset inside of the payload data holding the size of the SteamDRMP.dll file data. public uint SteamDRMPDllSize; // The offset inside of the payload data holding the size of the SteamDRMP.dll file data.
public uint XTeaKeys; // The offset inside of the payload data holding the address to the Xtea keys to decrypt the SteamDRMP.dll file. public uint XTeaKeys; // The offset inside of the payload data holding the address to the Xtea keys to decrypt the SteamDRMP.dll file.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x2B8)] //
public byte[] StubData; // Misc stub data, such as strings, error messages, etc. // The 'StubData' field is dynamically sized based on the needs of the stub version and used options. This is effectively
// impossible to 'size' correctly for all header versions, so instead it will be treated separately.
//
// [MarshalAs(UnmanagedType.ByValArray, SizeConst = ???)]
// public byte[] StubData; // Misc stub data, such as strings, error messages, etc.
//
} }
/// <summary> /// <summary>
@ -84,7 +89,12 @@ namespace Steamless.Unpacker.Variant21.x86.Classes
public uint SteamDRMPDllSize; // The offset inside of the payload data holding the size of the SteamDRMP.dll file data. public uint SteamDRMPDllSize; // The offset inside of the payload data holding the size of the SteamDRMP.dll file data.
public uint XTeaKeys; // The offset inside of the payload data holding the address to the Xtea keys to decrypt the SteamDRMP.dll file. public uint XTeaKeys; // The offset inside of the payload data holding the address to the Xtea keys to decrypt the SteamDRMP.dll file.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x31C)] //
public byte[] StubData; // Misc stub data, such as strings, error messages, etc. // The 'StubData' field is dynamically sized based on the needs of the stub version and used options. This is effectively
// impossible to 'size' correctly for all header versions, so instead it will be treated separately.
//
// [MarshalAs(UnmanagedType.ByValArray, SizeConst = ???)]
// public byte[] StubData; // Misc stub data, such as strings, error messages, etc.
//
} }
} }

View file

@ -187,6 +187,13 @@ namespace Steamless.Unpacker.Variant21.x86
/// <returns></returns> /// <returns></returns>
private bool Step1() private bool Step1()
{ {
/**
* Note: This version of the stub has a variable length header due to how it builds the
* header information. When the stub is generated, the header has additional string data
* that can be dynamically built based on the various options of the protection being used
* and other needed API imports. Inside of the stub header, this field is 'StubData'.
*/
// Obtain the file entry offset.. // Obtain the file entry offset..
var fileOffset = this.File.GetFileOffsetFromRva(this.File.NtHeaders.OptionalHeader.AddressOfEntryPoint); var fileOffset = this.File.GetFileOffsetFromRva(this.File.NtHeaders.OptionalHeader.AddressOfEntryPoint);
@ -207,9 +214,15 @@ namespace Steamless.Unpacker.Variant21.x86
// Determine how to handle the header based on the size.. // Determine how to handle the header based on the size..
if ((structSize / 4) == 0xD0) if ((structSize / 4) == 0xD0)
{
this.StubHeader = Pe32Helpers.GetStructure<SteamStub32Var21Header_D0Variant>(headerData); this.StubHeader = Pe32Helpers.GetStructure<SteamStub32Var21Header_D0Variant>(headerData);
this.StubData = headerData.Skip(Marshal.SizeOf(typeof(SteamStub32Var21Header_D0Variant))).ToArray();
}
else else
{
this.StubHeader = Pe32Helpers.GetStructure<SteamStub32Var21Header>(headerData); this.StubHeader = Pe32Helpers.GetStructure<SteamStub32Var21Header>(headerData);
this.StubData = headerData.Skip(Marshal.SizeOf(typeof(SteamStub32Var21Header))).ToArray();
}
return true; return true;
} }
@ -755,6 +768,11 @@ namespace Steamless.Unpacker.Variant21.x86
/// </summary> /// </summary>
private dynamic StubHeader { get; set; } private dynamic StubHeader { get; set; }
/// <summary>
/// Gets or sets the dynamic field 'StubData' from the header.
/// </summary>
private byte[] StubData { get; set; }
/// <summary> /// <summary>
/// Gets or sets the payload data. /// Gets or sets the payload data.
/// </summary> /// </summary>