Kernel: a title image's file name that fits clears the last error #186
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/186"
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?
Imported from Marvisak/VIctory. Originally posted by Maraco91 on 2026-11-24T01:15:23Z.
What
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
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:24:05Z.
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.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:55:43Z.
Review: APPROVED
Tested
3c7d845on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (265 passed, 0 failed), includinga_module_name_that_fits_clears_the_last_error. Its first half shows that the host's ownGetModuleFileNameW/Aforkernel32.dllclears a staleERROR_INSUFFICIENT_BUFFERon Windows 11, so matching that is right.Setting
ERROR_SUCCESSonly on the "fits" path keeps the truncated case and the zero-size case atERROR_INSUFFICIENT_BUFFER. The exact-fit boundary test (18 bytes fits, 17 doesn't) pins the off-by-one. It also composes with #373, which is in our fork: a null buffer goes throughtitle_bufferto an empty slice, which still takes the insufficient-buffer branch.No issues found.
AI-assisted (Claude Code).