Files
xcl/scripts/gen_gdk_table.py
ivall 576b4db5d8 XGameRuntime from the GDK function table: persistent local storage, console device type, more APIs
- Persistent local storage was passed to the PC runtime, which fails it for an unpackaged
  process: now XCL's own.
- XSystemGetDeviceType is computed by the thunk library from HKLM\...\OEM ConsoleMode
  (mapping read from the game's XCurl.dll): kernelx answers that registry key (0x64 Series X,
  0x60 Series S); advapi32 imports go through kernelx.
- gdk_table.rs: the GDK runtime's 396 functions with class, interface and slot as the public
  PC GDK's thunk library calls them. XCL's objects are built from it by function name: the
  interface versions of a class share a vtable, unknown versions get the main one, and
  unimplemented functions are reported by name. Agrees with the slots the game's own thunks
  use (test) and fixes two guessed XPackage slots.
- New: XUser devices and the remaining XUser calls, XPackage (locale, chunks, install,
  MountWithUi, EnumeratePackages), XSystem, analytics, runtime features, XDisplay, XGameEvent
  (offline); XAppBroadcast / XAppCapture refused.
- Pipelines: releasing a stand-in releases its background-built pipeline and forgets the
  address; PSO tests work with a cold DXIL cache.
2026-11-21 16:22:32 +01:00

25 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Generate crates/xcl/src/hle/xgameruntime/gdk_table.rs from a table of the GDK runtime's
functions: every function with the class, interface and vtable slot its thunk uses
(QueryApiImpl protocol), as extracted from the public PC GDK's xgameruntime.lib. Input lines:
`NAME(function, "class guid", "interface guid", slot)`.
usage: python scripts/gen_gdk_table.py <table file>"""
import io, os, re, sys
src = io.open(sys.argv[1], encoding='utf-8').read()
origin = re.search(r'Source\s*:\s*(\S+)', src)
rows = re.findall(r'\w+\((\w+), "([0-9A-Fa-f-]{36})", "([0-9A-Fa-f-]{36})", (\d+)\)', src)
assert rows, 'no rows'
hexg = lambda g: '0x' + g.replace('-', '').lower()
OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'crates', 'xcl', 'src', 'hle', 'xgameruntime', 'gdk_table.rs')
with io.open(OUT, 'w', encoding='utf-8', newline='\n') as f:
f.write('//! Generated by scripts/gen_gdk_table.py – do not edit.\n')
f.write(f'//! The GDK runtime\'s functions as the public PC GDK\'s xgameruntime.lib ({origin.group(1) if origin else "?"}) calls them:\n')
f.write('//! the (class, interface) its thunk asks QueryApiImpl for and the vtable slot it calls.\n\n')
f.write('/// (function, class id, interface id, slot)\n')
f.write('pub static API: &[(&str, u128, u128, u8)] = &[\n')
for name, c, i, slot in sorted(rows, key=lambda r: (r[1], r[2], int(r[3]))):
f.write(f' ("{name}", {hexg(c)}, {hexg(i)}, {slot}),\n')
f.write('];\n')
print(len(rows), 'rows ->', os.path.normpath(OUT))