atom0s / Steamless

Steamless is a DRM remover of the SteamStub variants. The goal of Steamless is to make a single solution for unpacking all Steam DRM-packed files. Steamless aims to support as many games as possible.
Other
3.08k stars 195 forks source link

Creates corrupted exe when running under Wine/Mono #76

Closed davispuh closed 1 year ago

davispuh commented 2 years ago

Hi,

I found that if you use provided Steamless.exe or Steamless.CLI.exe under Wine/Mono everything will appear working but the unpacked exe won't be valid and won't run. Unpacking in Windows works fine.

$ ./Steamless.CLI.exe Game.exe
[...]
[Steamless.Unpacker.Variant31.x64] File is packed with SteamStub Variant 3.1 (x64)!
[Steamless.Unpacker.Variant31.x64] Step 1 - Read, decode and validate the SteamStub DRM header.
[Steamless.Unpacker.Variant31.x64] Step 2 - Read, decode and process the payload data.
[Steamless.Unpacker.Variant31.x64]  --> File has payload data!
[Steamless.Unpacker.Variant31.x64] Step 3 - Read, decode and dump the SteamDRMP.dll file.
[Steamless.Unpacker.Variant31.x64]  --> File has SteamDRMP.dll file!
[Steamless.Unpacker.Variant31.x64] Step 4 - Handle .bind section. Find code section.
[Steamless.Unpacker.Variant31.x64]  --> .bind section was removed from the file.
[Steamless.Unpacker.Variant31.x64] Step 5 - Read, decrypt and process code section.
[Steamless.Unpacker.Variant31.x64]  --> .text linked as main code section.
[Steamless.Unpacker.Variant31.x64]  --> .text section is encrypted.
[Steamless.Unpacker.Variant31.x64] Step 6 - Rebuild and save the unpacked file.
[Steamless.Unpacker.Variant31.x64]  --> Unpacked file saved to disk!
[Steamless.Unpacker.Variant31.x64]  --> File Saved As: Game.exe.unpacked.exe
[Steamless] Successfully unpacked file!
$ ./Game.exe.unpacked.exe
winevdm: can't exec 'Z:\Game.exe.unpacked.exe': error=21

In Windows 10 it will show img

davispuh commented 2 years ago

Output wine showed when executing Steamless

005c:fixme:mountmgr:create_disk_device IoCreateDevice L"\\Device\\HarddiskVolume31" got c0000035
005c:fixme:mountmgr:create_disk_device IoCreateDevice L"\\Device\\HarddiskVolume31" got c0000035
0114:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.5.2" not implemented
0114:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.5.2" not implemented
0114:fixme:ntdll:NtQuerySystemInformation info_class SYSTEM_PERFORMANCE_INFORMATION
davispuh commented 2 years ago

Diff between non-working (Wine/Mono) and working exe (Windows)

--- broken.exe 
+++ working.exe
 00000000  4d 5a 90 00 03 00 00 00  04 00 00 00 ff ff 00 00  |MZ..............|
 00000010  b8 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00  |........@.......|
 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
 00000030  00 00 00 00 00 00 00 00  00 00 00 00 10 01 00 00  |................|
 00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
 00000030  00 00 00 00 00 00 00 00  00 00 00 00 10 01 00 00  |................|
 00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
 *
-00000110  50 45 75 00 64 86 06 00  c7 01 61 5e 00 00 00 00  |PEu.d.....a^....|
+00000110  50 45 00 00 64 86 06 00  c7 01 61 5e 00 00 00 00  |PE..d.....a^....|
 00000120  00 00 00 00 f0 00 22 00  0b 02 0e 10 00 9e 00 00  |......".........|
 00000130  00 5e 09 00 00 00 00 00  60 12 00 00 00 10 00 00  |.^......`.......|
 00000140  00 00 00 40 01 00 00 00  00 10 00 00 00 02 00 00  |...@............|
 *
 000001e0  00 00 00 00 00 00 00 00  d0 22 01 00 00 01 00 00  |........."......|
 000001f0  00 00 00 00 00 00 00 00  00 b0 00 00 20 02 00 00  |............ ...|
 00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
-00000210  00 00 00 00 00 00 00 00  2e 74 65 78 74 02 73 00  |.........text.s.|
+00000210  00 00 00 00 00 00 00 00  2e 74 65 78 74 00 00 00  |.........text...|
 00000220  70 9d 00 00 00 10 00 00  00 9e 00 00 00 04 00 00  |p...............|
 00000230  00 00 00 00 00 00 00 00  00 00 00 00 20 00 00 60  |............ ..`|
-00000240  2e 72 64 61 74 61 73 00  de 88 00 00 00 b0 00 00  |.rdatas.........|
+00000240  2e 72 64 61 74 61 00 00  de 88 00 00 00 b0 00 00  |.rdata..........|
 00000250  00 8a 00 00 00 a2 00 00  00 00 00 00 00 00 00 00  |................|
-00000260  00 00 00 00 40 00 00 40  2e 64 61 74 61 02 73 00  |....@..@.data.s.|
+00000260  00 00 00 00 40 00 00 40  2e 64 61 74 61 00 00 00  |....@..@.data...|
 00000270  c8 1b 00 00 00 40 01 00  00 0a 00 00 00 2c 01 00  |.....@.......,..|
 00000280  00 00 00 00 00 00 00 00  00 00 00 00 40 00 00 c0  |............@...|
-00000290  2e 70 64 61 74 61 73 00  18 0c 00 00 00 60 01 00  |.pdatas......`..|
+00000290  2e 70 64 61 74 61 00 00  18 0c 00 00 00 60 01 00  |.pdata.......`..|
 000002a0  00 0e 00 00 00 36 01 00  00 00 00 00 00 00 00 00  |.....6..........|
-000002b0  00 00 00 00 40 00 00 40  2e 72 73 72 63 02 73 00  |....@..@.rsrc.s.|
+000002b0  00 00 00 00 40 00 00 40  2e 72 73 72 63 00 00 00  |....@..@.rsrc...|
 000002c0  d8 a0 08 00 00 70 01 00  00 a2 08 00 00 44 01 00  |.....p.......D..|
 000002d0  00 00 00 00 00 00 00 00  00 00 00 00 40 00 00 40  |............@..@|
-000002e0  2e 72 65 6c 6f 63 73 00  14 06 00 00 00 20 0a 00  |.relocs...... ..|
+000002e0  2e 72 65 6c 6f 63 00 00  14 06 00 00 00 20 0a 00  |.reloc....... ..|
 000002f0  00 08 00 00 00 e6 09 00  00 00 00 00 00 00 00 00  |................|
 00000300  00 00 00 00 40 00 00 42  00 00 00 00 00 00 00 00  |....@..B........|
 00000310  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

Looks like for some reason in broken there's bunch of s added...

layercak3 commented 2 years ago

Do you get the same behaviour with https://github.com/sandsmark/Steamless/commit/050a3b784b23455c3eefb92aecfae9885388668b.patch applied? That fixes crashing when performing the unpacking process when running Steamless with native Mono on Linux (no Wine). I had the same problem as you when I used to run the program under Wine, but I ran my Steamless install (which contains that patch) under Wine just now and it started producing valid executables.

I do recall someone getting it to work by installing some .NET things with winetricks, but using Wine's built-in Mono I understand is more convenient.

Questions for atom0s:

ghost commented 2 years ago

Spent a day figuring this out and here's a guide for fully working Steamless on Linux.

Install Bottles. I recommend from AUR instead of Flatpak unless you want to put up with problems because of Flatpak's sandboxing and no Flatseal doesn't fix this, not going to argue this point.

  1. Create a new Bottle: i. Click the "Create a new Bottle" button (or the "+" button in the upper left) ii. Name it Steamless iii. Select the "Application" environment iv. Click "Create"

  2. Add msxml3 override: i. Utilities ii. Wine config iii. Libraries iv. Select msxml3 under "New override for library" v. Click "Add" > "OK"

  3. Enable mscoree override: i. Utilities ii. Wine config iii. Libraries iv. Select mscoree under "Existing overrides" v. Click "Edit" > "Native then builtin"

  4. Under the "Dependencies" tab, install the following: dotnet452

  5. Under the "Programs" tab, click the "+" button up top and browse and select your executables:

    • Steamless.exe
    • Steamless.CLI.exe
    • etc.
  6. Run Steamless. Enjoy!

atom0s commented 1 year ago

Hello, sorry for the late reply to this.

First, I want to say that Linux support is not within the scope of Steamless now and probably never anytime soon. I don't personally touch/use Linux and I have no real interest in doing any kind of maintenance to Steamless to ensure it continues to work on Linux each time I push changes. Steamless only contains valid C# code so it is ultimately up to the platforms implementation of C#, .NET and WPF to ensure things work correctly. I do not plan to ever do any kind of workarounds inside of Steamless to ensure it works on a specific platform. I also will not restrict myself to a specific .NET version or framework or similar to ensure that it continues to work on Linux either.

@davispuh -- That kind of issue looks to be a full-blown bug in whatever version of Wine/Mono you are using. There is no reason extra data like that should be injected randomly into the stream while the file is being written. Steamless is not using any kind of fancy or custom data building or writing. It's all basic byte arrays which are standard/stock to the .NET framework/runtime. If you haven't resolved it already, I'd suggest either trying and updating your version of Wine and Mono, any custom Linux built .NET libraries and so on and see if that helps. If not, I'd suggest trying and building Steamless yourself on Linux directly as well instead of using the prebuilt binaries for Windows.

@AtticFinder65536 -- Thanks for the patch, but the way you did things was not technically valid and thus is being rejected as-is. To answer your questions:

Does that patch have any side effects or other problems? I don't completely understand it because I'm not skilled enough but I doubt it. If there are no negative consequences it would be nice to upstream it.

Yes, the patch you submitted is technically not the correct way to fix the issue as you are leaving the type attributes meant for an array on a non-array type. I have pushed several things tonight including a fix to the issue you were trying to do in your patch so that should be working now on the latest codebase.

Would a PR 'adding' Linux support be merged in the current codebase now that a CLI exists (i.e. change a few lines to make it compile and run with mono on mac/linux/etc.)? All that needs to be done is merge this patch + move ViewModelBase.cs and NavigatedEventArgs.cs into Steamless/ (the GUI project) rather than the API project. I would make a public fork but the license doesn't give me permission to.

Sorry but I do not plan to alter the layout of the project in order to 'fix' any kind of problems that Mono/Wine have in properly handling C#/WPF.

If there is an issue on Linux using Mono/Wine in running Steamless due to where those two files you mentioned are located in the project, that sounds like a bug that should be reported to those projects in order to correct their handling of the language itself. Everything in Steamless is laid out in a manner that is fully valid to the MVVM coding pattern.

@ghost573 -- Thanks for your instructions, hopefully that will help any others who plan to make use of Steamless on Linux. :)