r0fld4nc3 / Stellaris-Exe-Checksum-Patcher

Patch the game's executable so that Ironman mode can be played with Mods henceforth enabling the pursuit of Achievements with Mods.
GNU Lesser General Public License v2.1
75 stars 3 forks source link

[Feature Request] Linux Support #12

Open madmaxgrey opened 5 months ago

madmaxgrey commented 5 months ago

any plan's on porting the Patcher to Linux, i know its a whole headache when it comes to stuff having to be ran using Proton etc.. but most be possible

r0fld4nc3 commented 5 months ago

Heya @madmaxgrey ! Yes it's planned, and actually mostly implemented on the dev branch.

I've now inlcuded support for MacOS, Linux and Windows, however, I'm still having some trouble actually making the checksums bypass on Linux/MacOS, so before merging into the main branch, I'm trying to get it to work. Hopefully it won't be much longer 🤞

In regards to being run with Proton, I'm also making sure I can differentiate between the two. I need a bit further testing for it to be fair because I think in my integration, I completely forgot there were the 2 versions, so I need to revise some things to try and make it detect if it's native or Proton.

madmaxgrey commented 5 months ago

awesome to know thank you so much :)

alexgmin commented 3 months ago

@r0fld4nc3 So, I was testing the linux support on the v1-1-0-dev branch, and I had to make some changes to make it kinda work.

First, since the app directory is set to this: program_data_path = pathlib.Path("/usr/local/var/")

It will fail due to not having permissions to write there by default unless you run it via sudo. This should probably be set to something like ~/.local/share/.

Then, in my case, the patcher fails because it doesn't find the steam library path. The reason is that it looks by default at ~/.steam. However, I think this changes on newer installations, and now .steam contains this:

❯ ll /home/username/.steam/
bin -> /home/username/.steam/bin32
bin32 -> /home/username/.local/share/Steam/ubuntu12_32
bin64 -> /home/username/.local/share/Steam/ubuntu12_64
registry.vdf
root -> /home/username/.local/share/Steam
sdk32 -> /home/username/.local/share/Steam/linux32
sdk64 -> /home/username/.local/share/Steam/linux64
steam -> /home/username/.local/share/Steam
steam.pid
steam.pipe
steam.token

And it will not find the config folder, since it's at /home/username/.steam/steam/.config if you follow the symlink. /home/username/.local/share/Steam/config would be the real path if you don't.

To fix it I added self.steam_install = os.path.join(self.steam_install, Path('steam')) before this line https://github.com/r0fld4nc3/Stellaris-Exe-Checksum-Patcher/blob/53e5f74193b77a8ba1598bd2e23b6d8eab9ba7fb/src/utils/steam_helper.py#L171

I'm not fully familiar with the structure of the steam library on linux, but with the last change and changing the app folder so it doesn't have to the run as root I managed to patch the stellaris binary.

However, it doesn't work since it shows the checksum as modified if I add a mod that disabled achievements. I haven't investigated why.

All of this was on a native linux install of today's patch, 3.12.5, but in 3.12.4 the checksum is still modified.

r0fld4nc3 commented 3 months ago

Hey @alexgmin ! Thanks so much for the detailed breakdown! I wouldn't count on the changes to it being finished or close to it for now, for Linux at least as I willl likely end up redoing some of it! But I'll surely take what you posted into consideration, especially the folders for permissions.

I'm in the process of getting Linux running here on a dual boot machine plus regular tiredness from regular working hours make managing this and every other project I have a bit tough, but I'll get there.

Depending on the linux distro and user installation of course, a lot of things can vary and I'll try to implement a better and fixed dynamic approach but if it fails I'll likely also add the option to add it manually by having the user just give the path to it.

In regards to the patch not working on Linux at the moment, it's because I need to re-run it again to find the hex as I believe the hex block is different from the Windows one, so I need to grab it.

Once I can look at it without feeling like I need to sleep again I will definitely look more into it. Thank you, again!

alexgmin commented 3 months ago

Happy to help!

When I tried it manually a few months ago the hex block for linux in this guide (that also mentions this project) for the linux native version worked.

However I tried looking into the ghidra guide to edit and as far I can see in the decompiled version, the origin HEX block edit should still work, since it forces the validation to be true. So I don't know why it's not working, and decompiled code is not one of my strengths.

I may have to check in previous versions of stellaris to see when it stopped working.

r0fld4nc3 commented 3 months ago

@alexgmin Odd that it wouldn't in this case then, but for sure nothing a bit more testing on my part couldn't fix! I'm sorry that it isn't working now, maybe I missed something along the way.

I suspect PDX changed something recently that changed the executable, however, the hex block is still the same I had to update the patching method to find it, so I'm not sure either as I didn't look into Ghidra again.