BigBoiCJ / SteamAutoCracker

An open-source script that automatically Cracks (removes DRM from) Steam games
https://cs.rin.ru/forum/viewtopic.php?f=10&t=120610
BSD 3-Clause "New" or "Revised" License
780 stars 55 forks source link

pefile replacement #76

Open axet opened 2 months ago

axet commented 2 months ago

Allow to work on linux (get rid of win32api)

diff --git a/sac_lib/get_file_version.py b/sac_lib/get_file_version.py
index da53c0b..cacc012 100644
--- a/sac_lib/get_file_version.py
+++ b/sac_lib/get_file_version.py
@@ -1,5 +1,5 @@
-import win32api
+import pefile

 def GetFileVersion(filename: str) -> str:
-    fileInfos = win32api.GetFileVersionInfo(filename, "\\")
-    return "%d.%d.%d.%d" % (fileInfos['FileVersionMS'] / 65536, fileInfos['FileVersionMS'] % 65536, fileInfos['FileVersionLS'] / 65536, fileInfos['FileVersionLS'] % 65536)
\ No newline at end of file
+    fileInfos = pefile.PE(filename).VS_FIXEDFILEINFO
+    return "%d.%d.%d.%d" % (fileInfos.FileVersionMS >> 16, fileInfos.FileVersionMS & 0xFFFF, fileInfos.FileVersionLS >> 16, fileInfos.FileVersionLS & 0xFFFF)
BigBoiCJ commented 1 month ago

Thanks! I'll test it and update if it works :)

How did you get all these colors? That's nice, didn't know that was possible to be shown in a github issue message

(and again for the really late response)