Closed DankRank closed 2 years ago
Hey there, this was done for some games that would basically require it otherwise they'd crash after being unpacked. I can add an option to make this optional though in the future.
If possible, could you upload some of your example exe's that you have with the stub and DRM free versions? I do not have many samples that I have both a Steam packed version and a DRM free version, so more would help.
Here they are. thsteam.zip
New steam releases from the same series.
1043230
, 1043240
, 1079170
, 1100170
, 1100180
morethsteam.zip
this was done for some games that would basically require it otherwise they'd crash after being unpacked
Maybe whether or not it's needed depends on the stub variant?
Turns out my proposed fix is incomplete. OptionalHeader.SizeOfImage must be aligned. Currently it relies on VirtualSize being aligned.
Hey there, didn't forget about this issue, just haven't had time to do anything regarding this project lately. It's still on the backburner to get finished though. I'd probably opt. for a configurable option to force alignments or not in the future to allow current behavior to work still like normal, then having the option to disable the alignments as a checkbox like the other features.
Thanks for the additional files, I've downloaded them and will take a look when I do eventually get time.
To my recollection, AES doesn't change data size. Unless SteamDRM is modifying the Virtual Sizes, realignment should not even be necessary. atom0s, do you have any examples of games that require it? I'd like to take a peek if possible.
AES only preserves data size if padding is used. Steams DRM does not use padding for their encryption so the data size does adjust between encrypted and decrypted.
I've temporarily commented out the RebuildSections code modifying actual Section offsets/sizes. Excluding DOS stub because I wipe mine and the CRC is updated, I get 1:1 sections with Retail. (Only note the Sections alignment match the Retail alignments from post above. Seems to work for every executable I encounter so far, even 64-bit ones.
A while back I patched the dll for my needs. It fixes both VirtualSize and SizeOfImage. Steamless.API.dll.zip (based on v3.0.0.9)
I also made a tool for fixing the DOS stub. It replaces the space between MZ and PE headers by the usual stub followed by NULs. The end result is that if you run both the retail and the unpacked exes through it, you will get two identical files. UnVLV.zip (source included) This obviously only works on exes made with Microsoft linker.
Already added the necessary code into my fork. Also added CRC repair. I did the same thing but with the latest source.
This is now available as a new option on the UI to disable section realignment when unpacking. It'll be in the next full release.
@atom0s You also need to round SizeOfImage up to a SectionAlignment for it to work. E.g. like this:
ntHeaders.OptionalHeader.SizeOfImage = this.GetAlignment(this.Sections.Last().VirtualAddress + this.Sections.Last().VirtualSize, ntHeaders.OptionalHeader.SectionAlignment);
I'm aware, it's not done yet as I am working on some other parts of this atm and plan to clean it up more before a full release is made.
When unpacking a game, Steamless rounds the virtual section size up to the page alignment. This is actually not necessary. Nearly all PE executables out there (both 32 and 64 bit) have those unaligned.
I think removing those lines will fix it, but I'm not sure, as I'm not familiar with the code. https://github.com/atom0s/Steamless/blob/9765d3e5b35b84fe8ec2e9eadaf6478561da30db/Steamless.API/PE32/Pe32File.cs#L315 https://github.com/atom0s/Steamless/blob/9765d3e5b35b84fe8ec2e9eadaf6478561da30db/Steamless.API/PE64/Pe64File.cs#L315
Background: I unpacked a couple of Variant31.x86 games (ids: 745880, 924650, 937570, 937580) and compared them with their retail (DRM-free) versions. The only differences were MS-DOS stub (which is clobbered by SteamStub), and virtual section sizes.