Commit Graph

38 Commits

Author SHA1 Message Date
be8570ace1 Merge remote-tracking branch 'origin/main' into triage-r43
# Conflicts:
#	docs/runtime_imports.md
#	runtime/CMakeLists.txt
#	runtime/shims/xgameruntime.cpp
#	runtime/test/xmem_test.cpp
#	tools/rdna2spirv.py
2026-11-22 22:12:50 -05:00
c45e650eab Merge pull request #3576 from Felix Croasdale 2026-11-22 17:02:48 -05:00
c36370a253 Merge pull request #3408 from Dominik 2026-11-22 17:01:53 -05:00
fc0cbecfda Merge pull request #2218 from Dominik 2026-11-22 16:59:05 -05:00
4c52ce27a6 Seven fixes from an outside contributor (sent as patches, applied without the author's name)
- rdna2spirv: declare each packed vertex input register once; a register whose elements disagree on the component
  type is refused (SHADER-644).
- runtime: a title's VirtualAlloc drops the console's MEM_GRAPHICS / MEM_TITLE type bits the host rejects (RT-217).
- runtime: XPersistentLocalStorageImpl is served from <overlay>\persistent with the package's 2048 MB quota
  (RT-219; layout from the public docs, not measured in a caller).
- runtime: G:\ names the package and T:\ a scratch folder in the overlay; paths under the configured folders and
  every path with no folders configured stay host paths (RT-218).
- winhttp_offline: header blocks and timeouts the host WinHTTP rejects are rejected the same way.
- cfg_structure.run: a limit of zero or less runs no blocks.
- shader_meta: an s_movk_i32 with a register operand and a float immediate beyond float32 are left unknown instead
  of raising.

Each comes with a test that fails on the old code. Conflicts with main resolved here (internal_dir() hides T:'s
folder; both file_system_test blocks kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:55:46 -05:00
5edd926878 xgameruntime: serve XGameImpl (IXGameImpl3) offline through QueryApiImpl
IXGameImpl3 : IXGameImpl2 : IXGameImpl (xgameruntime include/xgame.idl), slots
3-5: XGameGetXboxTitleId gives MicrosoftGame.Config's <TitleId> (E_FAIL without
one, E_INVALIDARG for a null pointer), void XLaunchNewGame is logged and
returns, XLaunchRestartOnCrash succeeds with nothing registered. A retail Gen9
title asks QueryApiImpl for this class (Freminet/ScarlettX's observation).

The config reader is shared with XPackageGetUserLocale. The two tests that used
XGameImpl's id as their example of an unserved class now use XGameSaveImpl's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:10:59 +00:00
f74b8eb87e xgameruntime: read LEONIDA_GAME_DIR wide for MicrosoftGame.Config
GetEnvironmentVariableA narrowed a game folder named outside the ANSI code page
(e.g. a runic or CJK character on cp1252), so the package locale lookup missed
its MicrosoftGame.Config. Read the variable and open the file wide. The test
uses U+16A0, which no ANSI code page has (it fails with the narrow read).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:10:40 +00:00
4f6b753693 xgameruntime_test: the IXSystemImpl5 check's flag no longer hides the entry-point check's (C4456)
93e65132 added the IXSystemImpl5 inheritance check with a `bool all`,
which hides the `bool all` of the GetProcAddress check at line 188;
MSVC reports C4456 at line 400. The inner flag is now all_inherited.
No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:58:05 -06:00
e3662721ea xgameruntime: XPackageImpl review fixes (progress, bool slots, locale, IIDs, --game-dir)
Review (@Flyander):
- slot 7 is void XPackageGetInstallationProgress(monitor,
  XPackageInstallationProgress*): it now writes an installed, launchable,
  completed package instead of an HRESULT stub ignoring its output.
- slots 8, 10, 22, 34 are bool methods (UpdateInstallationMonitor, the two
  Unregister* calls, UninstallPackage); E_NOTIMPL read as true. They return
  false / true / true / false, as documented for nothing to do offline.
- XPackageGetUserLocale returns the package-declared locale closest to the
  user's (MicrosoftGame.Config <Resource Language>, from LEONIDA_GAME_DIR or
  --game-dir), never the host locale; with none declared it succeeds
  without writing, as Microsoft documents.
- QueryInterface answers IXPackageImpl and IXPackageImpl2 too (the IDL
  chain IXPackageImpl3 : IXPackageImpl2 : IXPackageImpl).
And @Ingenioeren's finding: XPackageGetMountPath uses gta6rt's --game-dir
(rt::fs::game_dir()) after LEONIDA_GAME_DIR, before the launcher folder.

xgameruntime_test links file_system.cpp; +6 checks (88).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:22:37 +00:00
ae2f7bf6d3 xgameruntime: serve XPackageImpl (IXPackageImpl3) through QueryApiImpl
libHttpClient.GDK.dll asks QueryApiImpl for XPackageImpl with IXPackageImpl3's
id through 30 thunks (slots 3-19, 22, 24-27, 30, 32-34, 37-40), each in
the argument shape of the method at that position of xgameruntime-docs'
IXPackageImpl (3-34), IXPackageImpl2 (35-38) and IXPackageImpl3 (39-40)
lists, e.g. 10 (monitor, token, bool), 14 (id, count, selectors), 24-26
the mount path trio, 39 (kind, scope, context, callback).

Slots with an offline answer forward to the XPackage functions already
on main, so the vtable and the named exports agree: 3 the package
identifier, 4 packaged process, 25 the mount path; plus 11 the host user's
locale, 24 the mount path size (exactly what 25 needs) and 26 closing a
mount (nothing to release). Every other slot logs its number once and
returns E_NOTIMPL, so the first boot lists what the title needs.

xgameruntime_test +6 (80): the IXPackageImpl3 id, 3 and 4 equal the
exports, the locale and its short-buffer error, 24/25 sizes, 5/40 stubs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:20:50 +00:00
2428954112 xgameruntime: refuse XThreadingImpl slot 8 (XAsyncBeginAlloc) instead of answering S_OK
Slot 8 is the private XAsyncBeginAlloc: no public page, never called by the package's DLLs, signature not measured.
The generic private slot answered 0, so a caller got S_OK for an async call whose provider never received
XAsyncOp::Begin and whose completion never arrives. It now returns E_NOTIMPL and logs once.

Test: xgameruntime_test calls slot 8 with a provider that counts XAsyncOp::Begin and requires either a failure or one
Begin. Fails on ec8ec4c9 (S_OK, 0 Begin), passes with the change; the mutant answering S_OK is caught.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:01:12 +01:00
15f5b2fbc0 Fix what the round-41 merges broke
- tests/semantic: BaseVertex/BaseInstance read 0 in the wave interpreter; the LDS MockGens follow
  SHADER-309 (lds_bound, lds_access, lds_atomic); abs emission tests load their operand, since
  SHADER-315 folds scalar ALU on constants.
- test_translate: the dynamic gather sampler is a loaded word, not s16 + 0 (SHADER-315 folds it).
- test_world_build: DDS downscale weights colours by alpha (62804d0d).
- test_fspx_shaders_stage: the fake disassembler writes the listing make_game now checks.
- xgameruntime_test: re-read the package id after clearing the LEONIDA_PACKAGE_ID override.
- docs: one row per topic again in design.md (72 topics) and README.md; one Other languages line;
  embedded_shaders.md keeps one copy of each bullet; animation.md links the heading anchor.
- tools/scripts: character_textures uses report_paths.same_report_path; stdout guard on six programs;
  LF write in vs_input_survey; the cl.exe fallback compiles winhttp_offline.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:30:33 -05:00
5864f1875c Merge pull request #2372 from Dominik 2026-11-22 13:14:20 -05:00
c5ab4bba97 Merge pull request #2327 from Dominik 2026-11-22 13:13:54 -05:00
99e5a1da3c Merge pull request #2203 from Dominik 2026-11-22 13:13:18 -05:00
c457e0a7bd Merge pull request #2116 from swam122yam-glitch 2026-11-22 13:13:03 -05:00
c8f8c00e34 Merge pull request #1798 from SHAURYASANYAL3 2026-11-22 13:12:34 -05:00
6e65dc9ec2 xgameruntime: resolve MSVC C4201 nameless struct and C4996 strncpy warnings 2026-11-22 23:15:27 +05:30
5ab5c208c9 xgameruntime: deny mounting game package identifier with E_ACCESSDENIED 2026-11-22 23:15:27 +05:30
4a90673850 xgameruntime: validate installed package identifiers and reject unknown packages in XPackageMount 2026-11-22 23:15:26 +05:30
cb8c6445fc xgameruntime: implement XPackageMount and handle registry for mount path getters 2026-11-22 23:15:26 +05:30
48cf34f3a8 xgameruntime: implement XPackageGetMountPathSize and validate XPackageMountHandle per GDK spec 2026-11-22 23:14:50 +05:30
93e6513237 xgameruntime: XSystemImpl answers its inherited interface ids; sandbox id needs 16 bytes
Review (@Flyander):
- QueryInterface accepted the class id and IXSystemImpl5 only. The IDL
  chain is IXSystemImpl5 : IXSystemImpl4 : IXSystemImpl3 : IXSystemImpl2 :
  IXSystemImpl (xgameruntime include/xsystem.idl), so every one of them is
  served by the same vtable. RuntimeObject now carries a null-terminated
  list of interface ids instead of one newer id (XNetworkingImpl's list is
  IXNetworkingImpl2).
- XSystemGetXboxLiveSandboxId requires sandboxIdSize >=
  XSystemXboxLiveSandboxIdMaxBytes (16); buffers of 7-15 bytes returned
  S_OK. copy_id takes the API minimum.

Tests: a 15-byte sandbox buffer is refused, 16 accepted; all five
IXSystemImpl ids give the same object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:10:41 +00:00
6cb7735c22 xgameruntime: own gameplatformservices.dll, XCurl's other way into the runtime
XCurl.dll reads HKLM\Microsoft\GamingServices ServiceRetryTimeout, then
LoadLibraryExW(L"gameplatformservices.dll", nullptr,
LOAD_LIBRARY_SEARCH_SYSTEM32) and GetProcAddress'es GetApiVersionImpl and
QueryApiImpl (disassembled, no code run). The shims didn't own that module,
so the load went to the host: on a PC with Gaming Services it would reach
the real PC runtime's QueryApiImpl and bypass the offline classes; without
it XCurl returns 0x87E00196. Either way the result depended on what the
player has installed.

The shim table now serves gameplatformservices.dll!QueryApiImpl (the
offline one) and GetApiVersionImpl(uint64_t*, uint64_t*), measured at its
call site (two pointers to 64-bit locals, result unread; XCurl compares the
pair with the last one it saw), writing the same two values every call.
owns_dll() follows from the table, so library_loader answers the load.

xgameruntime_test: the LoadLibraryExW(..., SEARCH_SYSTEM32) load, the
versions and the shared QueryApiImpl (+3, 65). docs/runtime_imports.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:49:51 +00:00
1ab9ac784c xgameruntime: XSystemIsHandleValid returns bool, XSystemAllowFullDownloadBandwidth void
Checked against Microsoft's reference pages: bool XSystemIsHandleValid(
XSystemHandle) and void XSystemAllowFullDownloadBandwidth(bool). Slot 7
returned an HRESULT, so S_OK (0) read as "not valid" to a conforming
caller. The test calls both with the documented types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:44:21 +00:00
ade957c80f xgameruntime: serve XSystemImpl (IXSystemImpl5) offline through QueryApiImpl
libHttpClient.GDK.dll asks QueryApiImpl for XSystemImpl with IXSystemImpl5's
interface id and calls slots 3-8 (thunks disassembled, no code run): three
(size, buffer, used) id queries, then two pointers, one pointer and a bool:
xgameruntime-docs' IXSystemImpl list (console id, Xbox Live sandbox id,
app-specific device id), IXSystemImpl3's (XSystemHandleTrack,
XSystemIsHandleValid) and IXSystemImpl4's (XSystemAllowFullDownloadBandwidth),
IXSystemImpl2 and 5 adding no known method.

Offline answers: the existing 39-byte console-id placeholder, sandbox
RETAIL, a 45-byte app-specific device-id placeholder (short buffers get
ERROR_INSUFFICIENT_BUFFER, null E_INVALIDARG), handle tracking accepted and
never called back, a non-null handle valid, bandwidth S_OK.

docs/runtime_imports.md: libHttpClient calls five classes through thunks
(not only an id table, as the table said): their slot ranges, with the
XSystemImpl and XPackageImpl rows. xgameruntime_test +5 checks (74).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:44:20 +00:00
42b177e3d8 xgameruntime: URL security-info results take Microsoft's parameter order
Review (@Flyander): XNetworkingQuerySecurityInformationForUrl[Utf16]AsyncResult
is (XAsyncBlock*, size_t bufferByteCount, size_t* bufferByteCountUsed,
uint8_t* buffer, XNetworkingSecurityInformation** information); slots 10 and 13
had the last three as buffer, information, used, so a conforming caller got
nullptr written into its buffer and its used count left unset.

xgameruntime_test: both slots with a sentinel buffer and distinct outputs;
the buffer stays untouched, used and information are zeroed in place (both
checks fail with the old order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:43:05 +00:00
da17ead525 xgameruntime: serve XNetworkingImpl offline through QueryApiImpl
XCurl.dll asks QueryApiImpl for XNetworkingImpl with IXNetworkingImpl2's
interface id and calls slots 11-17 (measured with the #1877 thunk
disassembly, docs/runtime_imports.md): the UTF-16 URL security-information
async trio, the server certificate check, the connectivity hint and its
change registration. QueryApiImpl refused the class, so each of those
calls failed with class-not-provided.

The class answers as a console without a network: the connectivity hint is
initialized with level None; the preferred-port and URL security-info
queries fail with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE), the *Async
ones by completing their XAsyncBlock with it through XAsyncRun; the
certificate check fails the same way; change registrations return tokens
whose callbacks never fire; IXNetworkingImpl2's three additions are
E_NOTIMPL. RuntimeObject gains an optional newer interface id so
QueryInterface answers IXNetworkingImpl2 too.

xgameruntime_test (+8 checks, 69): both interface ids, the hint, the async
call completing with no network and its result size, the certificate
check, register/unregister, the port query and slot 20. tiny_gdk_load's
refused-class check uses an id no class has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:43:03 +00:00
f0c95d4711 xgameruntime: serve XNetworkingImpl offline through QueryApiImpl
- Handle IXNetworkingImpl2 query for class {37e56907-2f10-41e8-b72f-36edb185331a}.
- Return offline answers matching console behavior without network:
  * Connectivity hint: networkInitialized=true, level=None (1), cost=Unknown (0).
  * Port query and URL security queries fail with ERROR_NETWORK_UNREACHABLE.
  * Async queries complete through XAsync with ERROR_NETWORK_UNREACHABLE.
  * Correct ABI parameter order for AsyncResult:
    (async, bufferByteCount, bufferByteCountUsed*, buffer*, information**).
  * VerifyServerCertificate fails offline with ERROR_NETWORK_UNREACHABLE.
  * Registration tokens are tracked without firing offline.
  * IXNetworkingImpl2 extension methods return E_NOTIMPL.
- Update docs and tests in xgameruntime_test and tiny_gdk_load.
2026-11-22 22:11:48 +05:30
e417570454 xgameruntime: XErrorReport returns HRESULT, XErrorSetOptions void
#1877's IXErrorImpl slot 3 returned void, but xgameruntime-docs gives
HRESULT WINAPI XErrorReport(HRESULT status, const char* message), so a
caller that checks the result read whatever was left in rax. It now returns
S_OK after reporting. Slot 5 matches Microsoft's void XErrorSetOptions(
XErrorOptions, XErrorOptions) instead of returning an HRESULT nobody reads
(XErrorSetCallback was already void). The test checks slot 3's S_OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:41:02 +00:00
5f5d6d1949 xgameruntime: serve XNetworkingImpl (IXNetworkingImpl2) through QueryApiImpl
- QueryApiImpl hands out XNetworkingImpl (IXNetworkingImpl2, slots 3-20)
  for its class GUID {37e56907-2f10-41e8-b72f-36edb185331a}.
- Serves the slots XCurl.dll calls:
  * Slot 15: XNetworkingGetConnectivityHint reports an initialized network
    with unrestricted internet access offline.
  * Slot 14: XNetworkingVerifyServerCertificate returns S_OK.
  * Slots 16 & 17: XNetworkingRegisterConnectivityHintChanged and
    XNetworkingUnregisterConnectivityHintChanged manage registration tokens.
  * Slots 11-13: Async UTF-16 security information query stubs.
- Updated docs/runtime_imports.md layout table.
- Extended runtime/test/xgameruntime_test.cpp and tiny_gdk_load.cpp
  to verify XNetworkingImpl resolution and slot execution.
2026-11-22 21:28:40 +05:30
a9929f9044 Merge pull request #1877 from Dominik 2026-11-22 09:49:01 -05:00
c88423448e xgameruntime: serve XThreadingImpl and XErrorImpl through QueryApiImpl
A GDK title reaches XTaskQueue/XAsync/XThread/XError through
xgameruntime.lib thunks, not named imports: QueryApiImpl(class, class),
one vtable slot with `this` first, then Release. QueryApiImpl refused
every class, so none of those calls could work.

The slot order is xgameruntime-docs' Layout list after IUnknown, and is
measured: the thunks linked into the package's libHttpClient.GDK.dll and
XCurl.dll (disassembled, not run) call IXThreadingImpl slots 3-7 and 9-30
and IXErrorImpl slot 3, each with the argument shape of the documented
function at that position (docs/runtime_imports.md, "Class layouts,
measured").

- XThreadingImpl: 28 slots forwarded to third_party/xtaskqueue (the same
  code the named exports use), a per-thread time-sensitive flag, and the
  two private slots (XAsyncBeginAlloc, XTaskQueueIsEmpty) logged once.
- XErrorImpl: XErrorReport (the docs' "_unknown_" slot; HRESULT + string)
  logs and calls the XErrorSetCallback callback; XErrorSetOptions is S_OK.
- Process-wide singletons; QueryInterface answers IUnknown and the class.
- xgameruntime_test drives both slot by slot; tiny_gdk_load (under
  gta6rt --run) creates and closes a queue through slots 12 and 17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:46:09 +00:00
350328732a xgameruntime: conform XSystemAnalyticsInfo and XPackage APIs to GDK ABI specification 2026-11-22 20:11:42 +05:30
ea2f274a27 xgameruntime: implement XPackageGetCurrentProcessPackagePath, XPackageIsPackagedProcess, XSystemGetAnalyticsInfo 2026-11-22 19:45:12 +05:30
f90a9ead2c fix(library_loader): make pseudo-handle state immortal across teardown and reject null proc names 2026-11-22 10:29:25 -03:00
6f5b59ea81 runtime: serve LoadLibrary/GetProcAddress of shim-owned modules; xgameruntime.lib's run-time entry points
The package's GDK modules don't import xgameruntime.dll. libHttpClient.GDK.dll and XCurl.dll have no import
entry for it, but both carry the wide string "xgameruntime.dll" and the names InitializeApiImpl[Ex|Ex2],
QueryApiImpl and UninitializeApiImpl next to a statically linked XGameRuntimeInitialize: xgameruntime.lib's
thunks LoadLibraryW the runtime and GetProcAddress those names. Bound to the host, that bypasses the offline
shim. The executable is very likely built the same way.

- library_loader.cpp: LoadLibrary*/GetModuleHandle*/GetProcAddress/FreeLibrary for kernel32, kernelbase and the
  api-ms-win-core-libraryloader sets. A module the registry owns (rt::shims::owns_dll) gets a pseudo-handle and
  GetProcAddress resolves through the registry; an unserved name is NULL with ERROR_PROC_NOT_FOUND. Every other
  module goes to the host.
- xgameruntime.cpp: the five entry points, with the signatures and the unknown-class error documented by
  xodus-gaming/xgameruntime-docs (GPL-3.0, facts only). QueryApiImpl logs the class and interface ids and refuses
  them, so the first boot with the executable names the COM interfaces to implement.
- xgameruntime_test drives the path through XCurl.dll's api-set binding; docs/runtime_imports.md records the
  measurement and the new dry-run counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:58:12 +00:00
36bc1200ad Runtime: offline xgameruntime shim (XGameRuntime, XSystem, XTaskQueue, XAsync)
Every GDK title calls XGameRuntimeInitialize first and builds its async work on
XTaskQueue/XAsync. Add an xgameruntime.dll shim table for those, ahead of the
executable: XGameRuntimeInitialize/Uninitialize (reference counted),
XSystemGetDeviceType (Series X; LEONIDA_DEVICE_TYPE overrides) and
XSystemGetConsoleId (placeholder), plus the 23 XTaskQueue/XAsync functions.

XTaskQueue/XAsync come from microsoft/libHttpClient (MIT), copied unmodified
into third_party/xtaskqueue (task queue only, no HTTP stack); a small pch.h
stand-in lets them build alone. xgameruntime_test drives the table through
the shim registry the way a title boots. Nothing goes online.
2026-11-21 23:06:10 +01:00