hle(kernel, files), loader(native): Win32 module paths/exports, thread notices, callers, and MiniDumpWriteDump #574

Open
github-bot wants to merge 1 commit from github-bot/gh-570 into main AGit
Owner

@⁠Sheffy007 on GitHub · 2026-11-28 05:34 UTC · original
Sheffy007:fix/native-module-paths-exports-notices → main · +825 −31 · 8 files · 1 commits · open

Closes #570
Refs #460, #525

Summary

  • Mounted Win32 module paths & file helpers (crates/victory-hle/src/host_posix/files.rs, modules/kernel.rs, runtime.rs):
    • Formats GetModuleFileNameW / GetModuleFileNameA paths on native macOS through mounted host_posix::files drives (longest-prefix match, e.g. G:\Game.exe matching GetCommandLineW), sets ERROR_MOD_NOT_FOUND (126) on invalid handles, and preserves explicit <drive>: / UNC paths in runtime::set_image_path.
    • Adds GetFullPathNameW, GetFullPathNameA, DeleteFileA, CreateDirectoryA, RemoveDirectoryA, and GetDiskFreeSpaceW in host_posix::files.
  • Main-executable exports & dbghelp.dll!MiniDumpWriteDump (crates/victory-loader/src/native/image.rs, dll.rs, crates/victory-hle/src/modules/kernel.rs, host.rs):
    • Tracks mapped NativeImage export directories (dll::resolve_mapped_export) so GetProcAddress(NULL, ...) / GetProcAddress(GetModuleHandleW(NULL), ...) resolves exports on the main .exe and sets ERROR_PROC_NOT_FOUND / ERROR_MOD_NOT_FOUND.
    • Answers dbghelp.dll!MiniDumpWriteDump on non-Windows hosts with a stub that sets ERROR_NOT_SUPPORTED (50) and returns 0, eliminating the startup GetProcAddress: not implemented warning from Breakpad (#521).
  • DisableThreadLibraryCalls & DLL_THREAD_DETACH order (crates/victory-loader/src/native/run.rs, image.rs, modules/kernel.rs):
    • Records DisableThreadLibraryCalls calls made inside DllMain(DLL_PROCESS_ATTACH) before register_dll_thread_notices runs, refuses modules with static TLS (ERROR_RING2_STACK_IN_USE, 0), rejects invalid handles (ERROR_INVALID_HANDLE, 0), and delivers DLL_THREAD_DETACH in reverse load order (DllMain before TLS callbacks).
  • Native caller backtraces (crates/victory-loader/src/native/dump.rs, modules/kernel.rs):
    • Adds dump::caller_locations() and wires kernel::host::callers() on native macOS so exit, abort, terminate, TerminateProcess, and refused-DLL logs include <module>+<rva> caller chains.

Verification

  • cargo test -p victory-loader --target x86_64-apple-darwin --locked -- --test-threads=1 (33 passed, including disable_thread_calls_and_thread_detach_order_follow_windows)
  • cargo test -p victory-hle --lib --target x86_64-apple-darwin --locked -- --test-threads=1 (175 passed, including native_module_paths_main_exports_dbghelp_and_callers and win32_path_get_full_path_name_and_narrow_dir_ops_match_win32)
  • cargo test -p victory-hle --test native_probe --target x86_64-apple-darwin --locked -- --test-threads=1 (17 passed)
  • cargo test -p victory-loader --locked -- --test-threads=1 & cargo test -p victory-hle --lib --locked -- --test-threads=1
  • cargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy

cc @⁠Olima34

**@⁠Sheffy007** on GitHub · 2026-11-28 05:34 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/570) `Sheffy007:fix/native-module-paths-exports-notices` → `main` · +825 −31 · 8 files · 1 commits · open Closes #570 Refs #460, #525 ### Summary - **Mounted Win32 module paths & file helpers (`crates/victory-hle/src/host_posix/files.rs`, `modules/kernel.rs`, `runtime.rs`):** - Formats `GetModuleFileNameW` / `GetModuleFileNameA` paths on native macOS through mounted `host_posix::files` drives (longest-prefix match, e.g. `G:\Game.exe` matching `GetCommandLineW`), sets `ERROR_MOD_NOT_FOUND` (`126`) on invalid handles, and preserves explicit `<drive>:` / UNC paths in `runtime::set_image_path`. - Adds `GetFullPathNameW`, `GetFullPathNameA`, `DeleteFileA`, `CreateDirectoryA`, `RemoveDirectoryA`, and `GetDiskFreeSpaceW` in `host_posix::files`. - **Main-executable exports & `dbghelp.dll!MiniDumpWriteDump` (`crates/victory-loader/src/native/image.rs`, `dll.rs`, `crates/victory-hle/src/modules/kernel.rs`, `host.rs`):** - Tracks mapped `NativeImage` export directories (`dll::resolve_mapped_export`) so `GetProcAddress(NULL, ...)` / `GetProcAddress(GetModuleHandleW(NULL), ...)` resolves exports on the main `.exe` and sets `ERROR_PROC_NOT_FOUND` / `ERROR_MOD_NOT_FOUND`. - Answers `dbghelp.dll!MiniDumpWriteDump` on non-Windows hosts with a stub that sets `ERROR_NOT_SUPPORTED` (`50`) and returns `0`, eliminating the startup `GetProcAddress: not implemented` warning from Breakpad (`#521`). - **`DisableThreadLibraryCalls` & `DLL_THREAD_DETACH` order (`crates/victory-loader/src/native/run.rs`, `image.rs`, `modules/kernel.rs`):** - Records `DisableThreadLibraryCalls` calls made inside `DllMain(DLL_PROCESS_ATTACH)` before `register_dll_thread_notices` runs, refuses modules with static TLS (`ERROR_RING2_STACK_IN_USE`, `0`), rejects invalid handles (`ERROR_INVALID_HANDLE`, `0`), and delivers `DLL_THREAD_DETACH` in reverse load order (`DllMain` before TLS callbacks). - **Native caller backtraces (`crates/victory-loader/src/native/dump.rs`, `modules/kernel.rs`):** - Adds `dump::caller_locations()` and wires `kernel::host::callers()` on native macOS so `exit`, `abort`, `terminate`, `TerminateProcess`, and refused-DLL logs include `<module>+<rva>` caller chains. ### Verification - `cargo test -p victory-loader --target x86_64-apple-darwin --locked -- --test-threads=1` (33 passed, including `disable_thread_calls_and_thread_detach_order_follow_windows`) - `cargo test -p victory-hle --lib --target x86_64-apple-darwin --locked -- --test-threads=1` (175 passed, including `native_module_paths_main_exports_dbghelp_and_callers` and `win32_path_get_full_path_name_and_narrow_dir_ops_match_win32`) - `cargo test -p victory-hle --test native_probe --target x86_64-apple-darwin --locked -- --test-threads=1` (17 passed) - `cargo test -p victory-loader --locked -- --test-threads=1` & `cargo test -p victory-hle --lib --locked -- --test-threads=1` - `cargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy` cc @⁠Olima34
- Translate GetModuleFileNameW/A paths through mounted host_posix::files
  drives (longest-prefix match, e.g. G:\Game.exe) and set ERROR_MOD_NOT_FOUND
  for unknown module handles; add GetFullPathNameW/A, DeleteFileA,
  CreateDirectoryA, RemoveDirectoryA, and GetDiskFreeSpaceW.
- Track mapped NativeImage metadata and exports so GetProcAddress resolves
  exports on the main executable (NULL or GetModuleHandle(NULL)) and sets
  ERROR_PROC_NOT_FOUND / ERROR_MOD_NOT_FOUND accurately.
- Provide an ERROR_NOT_SUPPORTED stub for dbghelp.dll!MiniDumpWriteDump on
  non-Windows hosts instead of logging an unimplemented GetProcAddress warning.
- Honour DisableThreadLibraryCalls made during DllMain(DLL_PROCESS_ATTACH)
  before register_dll_thread_notices runs, reject images with static TLS,
  and deliver DLL_THREAD_DETACH in reverse load order (DllMain before TLS
  callbacks).
- Implement native::dump::caller_locations and wire kernel::host::callers
  on native macOS.

Closes #566
Refs #456, #521
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:41:18 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/574/head:github-bot/gh-570'
git switch 'github-bot/gh-570'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-570'
git switch 'github-bot/gh-570'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-570'
git switch 'github-bot/gh-570'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-570'
git switch 'main'
git merge --squash 'github-bot/gh-570'
git switch 'main'
git merge --ff-only 'github-bot/gh-570'
git switch 'main'
git merge 'github-bot/gh-570'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.