Skip to content

Instantly share code, notes, and snippets.

@Matoking
Created June 28, 2024 11:41
Show Gist options
  • Save Matoking/22e19d0394486550a554c8b4a267e2bb to your computer and use it in GitHub Desktop.
Save Matoking/22e19d0394486550a554c8b4a267e2bb to your computer and use it in GitHub Desktop.
print_appinfo_field_name_table.py
# Licensed under Creative Commons Zero
#
# Prints the list of field names stored at the end of the `appinfo.vdf` file
# which is needed to parse the binary VDF segments in the same file.
# This list can then be provided to `vdf.binary_load` as the `field_names` kwarg.
from pathlib import Path
import struct
appinfo_path = Path.home() / ".steam" / "steam" / "appcache" / "appinfo.vdf"
with appinfo_path.open("rb") as file_:
# Read the offset in appinfo.vdf
file_.seek(8)
table_offset = struct.unpack("<L", file_.read(4))[0]
file_.seek(table_offset)
# Retrieve the number of field names
field_name_count = struct.unpack("<L", file_.read(4))[0]
field_names = []
# Retrieve each null-terminated string
for _ in range(0, field_name_count):
field_name = bytearray()
while True:
field_name += file_.read(1)
if field_name[-1] == 0:
field_name = field_name[0:-1]
field_name = field_name.decode("utf-8")
field_names.append(field_name)
break
print(field_names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment