Kernel: GetModuleFileName of a title image into a null buffer #373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/373"
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 marquezinii on 2026-11-24T02:43:10Z.
GetModuleFileNameW/Afor a title image builtslice::from_raw_parts_mut(out, size)from the title's pointer. A slice may not start at null even when it is empty, so a size query likeGetModuleFileNameW(module, NULL, 0)was undefined behaviour; in a debug build it is a failed precondition check inside anextern "system"function, which aborts the process (0xc0000409).A null buffer is now treated as no buffer: nothing is written, the call returns 0 and sets
ERROR_INSUFFICIENT_BUFFER, which is whatcopy_truncatedalready does for an empty one.Tested: a new test asks for a title image's name with
(NULL, 0)through both functions. Before the change the test binary aborts with 0xc0000409; now both return 0 and the last error is 122.cargo test -p victory-hlepasses and clippy reports nothing new.This touches the two call sites only, not
copy_truncated, so it should not get in the way of #186.Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:09:07Z.
Thanks @marquezinii for this null-buffer fix. I tested head
c000581df2cf12aaadfe49025f9abba8b5993c8ewith:Result: 1 passed, 0 failed (86 filtered out). The regression test calls both
GetModuleFileNameWandGetModuleFileNameAfor a title image with(NULL, 0)and verifies the no-buffer error behavior, covering the path that previously formed a slice from a null pointer.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:26:51Z.
Review: APPROVED
Tested
c000581on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (265 passed, 0 failed), includinga_title_image_name_into_no_buffer.slice::from_raw_parts_mut(null, 0)is undefined behaviour, and debug builds' precondition check turns it into an abort inside anextern "system"function. Routing both entry points throughtitle_buffer, which maps null to&mut [], letscopy_truncatedhandle the size query the way it already handles an empty buffer: return 0 withERROR_INSUFFICIENT_BUFFER.No issues found.
AI-assisted (Claude Code).