Skip to content

Instantly share code, notes, and snippets.

@floxay
Last active April 26, 2024 20:01
Show Gist options
  • Save floxay/a6bdacbd8db2298be602d330a43976da to your computer and use it in GitHub Desktop.
Save floxay/a6bdacbd8db2298be602d330a43976da to your computer and use it in GitHub Desktop.
Get VALORANT client/build version from game executable
import pefile
def get_product_version(data: bytes) -> str:
pe = pefile.PE(data=data, fast_load=True)
pe.parse_data_directories(
directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]]
)
for file_info in pe.FileInfo:
for entry in file_info:
if entry.name == "StringFileInfo":
for string_table in entry.StringTable:
if pv := string_table.entries.get(b"ProductVersion", None):
return pv.decode()
return "1"
def get_client_version(game_path, patchline):
with open(
f"{game_path}/{patchline}/ShooterGame/Binaries/Win64/VALORANT-Win64-Shipping.exe",
"rb",
) as game_bin:
data = game_bin.read()
pattern = "++Ares-Core+".encode("utf-16-le")
pos = data.find(pattern) + len(pattern)
branch, build_date, build_version, version, *_ = filter(
None, data[pos : pos + 128].decode("utf-16-le").split("\x00")
)
# in some cases build version is not included in this block
if "." in build_version:
version = build_version
build_version = get_product_version(data)
# just to follow what the game does
return "%s%s-%s-%d" % (
branch,
"-shipping",
build_version,
int(version.rsplit(".", 1)[1]),
)
print(get_client_version(game_path=R"C:\Riot Games\VALORANT", patchline="live"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment