diff --git a/Steamless.Unpacker.Variant21.x86/Classes/SteamStubHeader.cs b/Steamless.Unpacker.Variant21.x86/Classes/SteamStubHeader.cs
index 9199612..0857670 100644
--- a/Steamless.Unpacker.Variant21.x86/Classes/SteamStubHeader.cs
+++ b/Steamless.Unpacker.Variant21.x86/Classes/SteamStubHeader.cs
@@ -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 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.
+ //
}
///
@@ -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 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.
+ //
}
}
\ No newline at end of file
diff --git a/Steamless.Unpacker.Variant21.x86/Main.cs b/Steamless.Unpacker.Variant21.x86/Main.cs
index df4cedf..d00bad6 100644
--- a/Steamless.Unpacker.Variant21.x86/Main.cs
+++ b/Steamless.Unpacker.Variant21.x86/Main.cs
@@ -187,6 +187,13 @@ namespace Steamless.Unpacker.Variant21.x86
///
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..
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..
if ((structSize / 4) == 0xD0)
+ {
this.StubHeader = Pe32Helpers.GetStructure(headerData);
+ this.StubData = headerData.Skip(Marshal.SizeOf(typeof(SteamStub32Var21Header_D0Variant))).ToArray();
+ }
else
+ {
this.StubHeader = Pe32Helpers.GetStructure(headerData);
+ this.StubData = headerData.Skip(Marshal.SizeOf(typeof(SteamStub32Var21Header))).ToArray();
+ }
return true;
}
@@ -755,6 +768,11 @@ namespace Steamless.Unpacker.Variant21.x86
///
private dynamic StubHeader { get; set; }
+ ///
+ /// Gets or sets the dynamic field 'StubData' from the header.
+ ///
+ private byte[] StubData { get; set; }
+
///
/// Gets or sets the payload data.
///