diff --git a/dzgui/api/pefile.py b/dzgui/api/pefile.py index 7c86987..15e028f 100644 --- a/dzgui/api/pefile.py +++ b/dzgui/api/pefile.py @@ -255,16 +255,28 @@ class PeFileError(Exception): pass + def parse_version_number(data: BinaryIO) -> FileVersion: # https://learn.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo - minor = struct.unpack("> 16 & 0xFFFF - major = struct.unpack("> 0 & 0xFFFF - build = struct.unpack("> 0 & 0xFFFF - # NOTE: 0-pad revision number - revision = str(struct.unpack("> 16 & 0xFFFF) - offset = 3 - len(revision) - padded = "0" * offset + revision - return FileVersion(major, minor, build, padded) + """ + Note: structure differs from standard VS_FIXEDFILEINFO + Major: lower 16 bits of first DWORD + Minor: upper 16 bits of first DWORD + Build: lower 16 bits of third DWORD + Revision: upper 16 bits of second DWORD, zero-padded + Lower 16 bits of revision DWORD appear unused. + """ + major_minor = struct.unpack("> 16) & 0xFFFF + build = build_dword & 0xFFFF + revision = (revision_pair >> 16) & 0xFFFF + revision = f"{revision:03d}" + + return FileVersion(major, minor, build, revision) def seek_to_hex(address: str, data: BinaryIO) -> None: diff --git a/pyproject.toml b/pyproject.toml index 278f5e4..1d52faa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux" authors = [ {name = "aclist"} ] -version = "7.0.0b27" +version = "7.0.0b28" license = "GPL-3.0-or-later" license-files = ["LICENSE"] readme = "README.md"