Commit b0e560a0 authored by atom0s's avatar atom0s

Removed unneeded comment information.

Added rescanning for stub headers that flip instructions in variant 3.
Added support for variant 3 v3.0.0 again. (Rewritten partially to account for some old bugs.)
Fixed unpacking issue in v3.1 when a code section is not encrypted.
parent ae21a769
......@@ -45,36 +45,47 @@ namespace Steamless.Unpackers
// Try and determine the packer version used..
var bindSection = file.GetSectionData(".bind");
var offset = Pe32Helpers.FindPattern(bindSection, "55 8B EC 81 EC ?? ?? ?? ?? 53 ?? ?? ?? ?? ?? 68");
var drmHeaderSize = 0;
if (offset == 0)
{
// Todo: Manually attempt each version of the variant 3 unpackers..
Program.Output("Could not determine the variant version to unpack with!", ConsoleOutputType.Error);
return false;
// Try again with the last two instructions flipped..
offset = Pe32Helpers.FindPattern(bindSection, "55 8B EC 81 EC ?? ?? ?? ?? 53 ?? ?? ?? ?? ?? 8D 83");
if (offset == 0)
{
// Todo: Manually attempt each version of the variant 3 unpackers..
Program.Output("Could not determine the variant version to unpack with!", ConsoleOutputType.Error);
return false;
}
else
{
// Obtain the DRM header size..
drmHeaderSize = BitConverter.ToInt32(bindSection, (int)offset + 22);
}
}
else
{
// Obtain the DRM header size..
drmHeaderSize = BitConverter.ToInt32(bindSection, (int)offset + 16);
}
// Obtain the DRM header size from the initial memcpy call..
var drmHeaderSize = BitConverter.ToInt32(bindSection, (int)offset + 16);
// Attempt to handle the given DRM header size..
switch (drmHeaderSize)
{
//
// Variant Version v3.0.0 (?)
// Known Usages:
// -> The Wolf Amoung Us
case 0xB0:
return false;
// Variant Version v3.0.0 (?)
// Known Usages:
// -> Grim Dawn (pre b30)
case 0xD0:
return false;
//
case 0xB0: // Older version of v3.0.0
case 0xD0: // Newer version of v3.0.0
{
var unpacker = new Variant3_0();
return unpacker.Process(file);
}
//
// Variant Version v3.0.1 (?)
// Known Usages
// -> Grim Dawn (post b30)
//
case 0xF0:
{
var unpacker = new Variant3_1();
......
This diff is collapsed.
......@@ -94,6 +94,7 @@ namespace Steamless.Unpackers.Variant3
{
// Store the file object for later usage..
this.File = file;
this.CodeSectionIndex = -1;
// Announce the packer version being used..
Program.Output("File is packed with SteamStub Variant #3.1!\n", ConsoleOutputType.Success);
......@@ -246,6 +247,10 @@ namespace Steamless.Unpackers.Variant3
else
Program.Output(" --> .bind section was kept!", ConsoleOutputType.Info);
// Skip finding the code section if we are not encrypted..
if ((this.StubHeader.Flags & (uint)DrmFlags.NoEncryption) == (uint)DrmFlags.NoEncryption)
return true;
// Find the code section..
var codeSection = this.File.GetOwnerSection(this.StubHeader.CodeSectionVirtualAddress);
if (codeSection.PointerToRawData == 0 || codeSection.SizeOfRawData == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment