XGameRuntime: fix XPackageGetIdentifier crash, atomic GameSave, locale fallback, and controller ID #97
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!97
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/97/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@raylitebull on GitHub · 2026-11-23 11:11 UTC · original
raylitebull:fix/xgameruntime-package-and-saves→main· +400 −19 · 5 files · 1 commits · merged 2026-11-23 11:25 UTCSummary
Fixes a crash, save-atomicity/NTFS bugs, locale fallback, and controller lookup in
crates/xcl/src/hle/xgameruntime/andcrates/xcl/src/manifest.rs:XPackageGetIdentifier(slot 27) 3-arg signature crash (mod.rs,api.rs):gdk_table.rsalready maps IID0b9d556eab7043f4baa09999ac4cb040slot 27 to"XPackageGetIdentifier"(verified against Windowsxgameruntime.dll— this is a wrong function wiring on the already-correct IID/slot layout, not GDK version drift).XPackageGetCurrentProcessPackageIdentifier(size, buf)instead of 3-argXPackageGetIdentifier(pathOrName, size, buf), causing the caller'sbufferSize(e.g.64) to be dereferenced as a pointer (0xC0000005).XPackageGetIdentifierand wired slot 27 to it.XGameSaveatomic writes, temp-name isolation, NTFS case-insensitivity, and nulloutcheck (gamesave.rs):path.with_extension("xcltmp")(which overwrote real.xcltmpblobs, made.xcltmpwrites in-place, collided across concurrent writes likeslot.sav/slot.meta, skippedsync_all(), and was enumerated as a real blob byblobs_of()) withwrite_atomic()using unique sibling temp files~xcltmp.<pid>.<counter>(unreachable fromenc()since~encodes to%7E),File::sync_all(), andMoveFileExW(..., MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)with cleanup on failure.blobs_of()skips~xcltmp.files.each_container,each_blob, andread_layout(preferring exact matches first) so overwriting"Meta"as"meta"and reading"meta"works on NTFS.!out.is_null()inXGameSaveInitializeProviderResultbeforeXAsyncGetResultso nulloutreturnsE_INVALIDARGwithout consuming the result or leakingBox<Provider>.XPackageGetUserLocaleMicrosoftGame.Config<Resources>fallback (launcher.rs,manifest.rs,api.rs):<Resources><Resource Language="..."/></Resources>intoManifest::languages(respecting existing UTF-8/UTF-16 decoding and XML comment stripping).-/_normalized) -> primary-language subtag match (e.g.fr-CA->fr-FR) -> first declared language (e.g.hr-HR->en-US) -> raw OS locale only when<Resources>is absent.XUserFindControllerForUserWithUiAsyncdevice ID (mod.rs):gameinput::gamepad_device_id()instead of 32 zero bytes soIGameInput::FindDeviceFromIdmatches the emulated controller.(Note: The
XGameSaveDeleteContainer(p, "")empty-name root-wipe data-loss fix was submitted separately in #95 so it can land independently.)Testing
origin/main):XPACKAGEslot 27 with(path, 64, buf)crashed with0xC0000005writing to0x40.save.datdestroyedsave.xcltmp, and leftover.xcltmpfiles appeared in blob enumeration."Meta"as"meta"caused reading"meta"to returnE_GS_BLOB_NOT_FOUND.XGameSaveInitializeProviderResult(blk, null)consumed the async result and returnedS_OK.XPackageGetUserLocalereturned raw OS locale instead of matching<Resources>languages.XUserFindControllerForUserWithUiAsyncreturned 32 zero bytes.xpackage_get_identifier_slot_27_uses_three_args&legacy_console_iids_map_to_their_own_slotsatomic_writes_preserve_xcltmp_blobs_and_skip_leftover_tempscase_insensitive_blob_and_container_matching_on_ntfsinitialize_provider_result_rejects_null_out_without_consuming_asyncparses_declared_resources_languages_with_comments_and_utf16&user_locale_selection_matches_manifest_resourcesuser_device_association_and_controller_lookuporigin/main(60599a9):cargo build --workspaceandcargo test --workspace -- --test-threads=4pass with 0 failures and 0 new warnings.@ivall on GitHub · 2026-11-23 11:25 UTC · original
Merged. It conflicted with #95 in
gamesave.rs(both added tests at the same place, #95 also the empty-name check inXGameSaveDeleteContainer); resolved keeping both. Merged together with #95–#102 and checked on Windows 11 with an RX 9070:cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!