Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appcache: add new magic for Steam Client Beta (June 2024) #463

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions steam/utils/appcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

>>> header, apps = parse_appinfo(open('/d/Steam/appcache/appinfo.vdf', 'rb'))
>>> header
{'magic': b"(DV\\x07", 'universe': 1}
{'magic': b")DV\\x07", 'universe': 1}
>>> next(apps)
{'appid': 5,
'size': 79,
Expand Down Expand Up @@ -43,6 +43,7 @@

uint32 = struct.Struct('<I')
uint64 = struct.Struct('<Q')
int64 = struct.Struct('<q')

def parse_appinfo(fp):
"""Parse appinfo.vdf from the Steam appcache folder
Expand All @@ -53,7 +54,7 @@ def parse_appinfo(fp):
:return: (header, apps iterator)
"""
# format:
# uint32 - MAGIC: "'DV\x07" or "(DV\x07"
# uint32 - MAGIC: "'DV\x07" or "(DV\x07" or b")DV\x07"
# uint32 - UNIVERSE: 1
# ---- repeated app sections ----
# uint32 - AppID
Expand All @@ -69,11 +70,23 @@ def parse_appinfo(fp):
# uint32 - EOF: 0

magic = fp.read(4)
if magic not in (b"'DV\x07", b"(DV\x07"):
if magic not in (b"'DV\x07", b"(DV\x07", b")DV\x07"):
raise SyntaxError("Invalid magic, got %s" % repr(magic))

universe = uint32.unpack(fp.read(4))[0]

if magic == b')DV\x07':
# Read until end of null-terminated table string
string_table_offset = struct.unpack('q', fp.read(8))[0]
offset = fp.tell()
fp.seek(string_table_offset)
uint32.unpack(fp.read(4))[0]

c = b''
while c != b'\x00' or not c:
c = fp.read(1)
fp.seek(offset)

def apps_iter():
while True:
appid = uint32.unpack(fp.read(4))[0]
Expand All @@ -91,10 +104,11 @@ def apps_iter():
'change_number': uint32.unpack(fp.read(4))[0],
}

if magic == b"(DV\x07":
if magic != b"'DV\x07":
app['data_sha1'] = fp.read(20)

app['data'] = binary_load(fp)
# TODO reading data doesn't work
app['data'] = binary_load(fp)

yield app

Expand Down