Kernel: a title image's file name that fits clears the last error #186
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!186
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/186/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?
@Maraco91 on GitHub · 2026-11-24 01:15 UTC · original
Maraco91:kernel/module-file-name-last-error→main· +49 −1 · 1 files · 1 commits · merged 2026-11-25 00:08 UTCWhat
GetModuleFileNameA/Wfor a title image (the exe byNULL, or a title DLL) answers from our own record of its original path.copy_truncatedsetsERROR_INSUFFICIENT_BUFFERwhen the name is cut, but leaves the thread's last error alone when the name fits. The host clears it on success, and callers rely on that, because the return value alone cannot tell "cut" from "filled the buffer exactly":With our answer, the first loop spins forever once its first buffer was too small, and the second fails whenever some earlier call on the thread left 122 behind. Other modules' names go to the host and were already right; only title images took this path.
xgame.rsnotes that Grand Theft Auto VI reads its own path withGetModuleFileNameA; I do not know which of these shapes its code has (I have no game files).A name that fits now sets the last error to 0. The truncated and zero-size cases are unchanged.
Tested
Windows 11 Pro 10.0.26200, rustc 1.98.1 (
x86_64-pc-windows-msvc), no game data, no GPU involved.New unit test
a_module_name_that_fits_clears_the_last_error. It first pins down what the host does, on a host module (kernel32.dll, which our functions pass through): with the last error preset to 122, a successfulGetModuleFileNameWandGetModuleFileNameAboth leave it at 0 on this machine. Then the same for a title image: too small (returns the size, last error 122, as before), then with room, wide and narrow, and an exact fit (17 characters in 18); control: 17 characters in 17 is still cut and still reports 122.main(d2a4bae) + the test only:cargo test -p victory-hle --lib a_module_name_that_fitsfails at the first title-image check:a title image, wide: left: 122, right: 0. The two host checks before it pass.cargo test -p victory-hle --lib kernel::: 4 passed, 0 failed.cargo clippy -p victory-hle --tests: nothing inkernel.rs.rustfmt --check kernel.rs: clean.cargo xtask policy --staged: ok.Not tested: a title run; Windows 10 (the reset on success dates from Vista as far as I know, but I only ran Windows 11).
AI-assisted (Claude Code); the tests above were run on the machine described.
🤖 Generated with Claude Code
@DaviTostes on GitHub · 2026-11-24 01:24 UTC · original
Tested
3c7d845under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build withcargo xwin ... --target x86_64-pc-windows-msvc -p victory-hleand a native Microsoftd3dcompiler_47: pass.victory_hle: 86 passed, 1 failed — the failure ismodules::net::tests::only_loopback_is_reachable(Wine lacksWSAConnectByList, as in #118), not this PR. The test this PR adds passes.No game data used.