Runtime: fix ANSI CP_ACP path encoding, HLE alias stubs/handles, forwarders, and stub creation race #101
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!101
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/101/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/resolver-aliases-and-ansi-paths→main· +568 −51 · 5 files · 1 commits · merged 2026-11-23 11:25 UTCSummary
Fixes ANSI path codepage encoding, HLE alias stub return codes,
GetModuleHandleparity for console-only aliases, ordinal/forwarder resolution, and amake_stub_infoTOCTOU race incrates/xcl/src/{util.rs, resolver.rs, stubs.rs, modules.rs, hle/kernelx.rs}:write_ansi_outCP_ACPencoding (util.rs):CP_ACPmatchesutil::from_ansi_ptr,vfs_hooks::w_to_a, and WindowsGetModuleFileNameA.WideCharToMultiByte(CP_ACP, ...)and character-boundary-safe truncation (binary-searching complete Unicode scalar-value UTF-16 prefixes so DBCS/UTF-8 multi-byte sequences and surrogate pairs are never split, settingERROR_INSUFFICIENT_BUFFERon truncation).GetACP() == 1252):C:\Jeux\Été\game.exe(CP1252) andC:\Hry\Český_Život\game.exe(CP1250) round-trip cleanly viafrom_ansi_ptr.C:\Games\漢\game.exe(CJK outside CP1250/CP1252) substitutes'?'(C:\Games\?\game.exe, NUL-terminated, matching WindowsGetModuleFileNameA) and round-trips on codepages representing'漢'.HLE alias stub return fallback (
stubs.rs,resolver.rs):StubDb::return_for_with_fallback(dll, fallback_dll, name)so routed HLE alias DLLs (xgameplatform.dll,xgameruntime.thunks.dll,d3d12x.dll, etc.) inherit their canonical module'sstubdb.tomldefault (E_NOTIMPL) instead of silently returning0(S_OK), while BOOL/handle families (kernelx.dll) keep0, per-alias overrides still win, and every stub call continues to be recorded inreport.json.GetModuleHandleW/A/Exparity for console-only aliases & loaded@stubDLLs (hle/kernelx.rs,modules.rs,resolver.rs):aliases_are_system()aliases, tries WindowsGetModuleHandleWfirst (preserving real handles forkernel32.dll, etc.) and falls back tomodules::hle_handle(m.name)when Windows returns0(advapi32legacy.dll,kernel32legacy.dll,minappmodelx.dll).Route::Stub, returnsmodules::find_hle_handle(&key).unwrap_or(0)so unloaded optional probes still return0while loaded@stubDLLs matchLoadLibrary.Ordinal fallback &
GetProcAddressforwarder contract (resolver.rs):resolve_hlefall through tosystem_proconly whenc == key(preventing cross-DLL ordinal mismatches on console-only aliases).allow_stubthroughresolve_export_of_mappedsoget_proc_addressreturnsNoneinstead of synthesizing stubs on unresolvable forwarders, and switched forwarder splitting torsplit_once('.')to support dotted DLL names.stubs::make_stub_infoTOCTOU race (stubs.rs):BY_KEYacross lookup, thunk allocation,ALLpush, and map insert (strict lock orderBY_KEY-> leafARENA/ALL), eliminating duplicate thunks and duplicateALLentries under concurrency.Testing
ansi_out_encodes_codepage_and_truncates_on_char_boundaries(CP1252, CP1250"Č"/"Ž", CJK'漢', CP932 DBCS, UTF-8 surrogate pair)make_stub_info_is_race_free_under_concurrency(8 threads × 50 iterations stress test)hle_alias_stubs_inherit_canonical_module_defaultordinal_imports_fall_through_only_to_matching_system_dllmapped_forwarders_preserve_get_proc_address_contract_and_dotted_dll_namesget_module_handle_matches_load_library_for_console_aliases_and_stubsbuiltin_db_parses_with_overridesorigin/main(60599a9):cargo build --workspaceandcargo test --workspace -- --test-threads=4pass with 0 failures and 0 new warnings.github-bot referenced this pull request2026-11-26 05:24:21 +00:00
@ivall on GitHub · 2026-11-23 11:25 UTC · original
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!