hle(host_posix): the process calls a title makes at startup (error mode, priority class, IsWow64Process2, its own image path) are stubs #626

Closed
opened 2026-11-28 15:52:26 +00:00 by github-bot · 3 comments
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 15:48 UTC · original

Summary

The calls a title makes about its own process at startup had no implementation in host_posix/system.rs, so each landed in the loader's import stub:

Call What the stub did
SetErrorMode / SetThreadErrorMode / GetErrorMode nothing: a title that turns off the fault and critical-error boxes and then reads the mode back gets 0
SetPriorityClass / GetPriorityClass nothing: a title that raises its class and prints it in a crash log logs 0
IsWow64Process2 nothing: a title asking what machine it is gets 0 for both answers
QueryFullProcessImageNameW nothing: a title logging its own path logs an empty string

None of them can fail a title outright, which is why they went unnoticed, but each is a silent wrong answer in the one place a crash log is written from.

What the change does

  • One error mode for the process (SetErrorMode and SetThreadErrorMode both write it and report the value they replaced, GetErrorMode reads it). Shortcut, written down: Windows keeps a per-thread mode beside the process one.
  • The priority class is validated against the six Windows classes and remembered, not applied: raising a process's own scheduling class is privileged on macOS, and a title only reads back what it set. A handle that is not this process (the pseudo handle is the only one a title can hold here) is ERROR_INVALID_HANDLE.
  • IsWow64Process2 reports no emulated 32-bit process and IMAGE_FILE_MACHINE_AMD64 as the native machine, because that is the machine whose code runs here; a title told ARM64 takes paths (arm64 binaries, different threading) this host does not serve.
  • QueryFullProcessImageNameW returns the main image's path from GetModuleFileNameW, with its NUL and its length without it back in size; a buffer that is too small is ERROR_INSUFFICIENT_BUFFER and is left untouched.

Tests

Three new ones in system.rs: the error mode round-trips and reports what it replaced; the priority class is remembered, an unknown class is ERROR_INVALID_PARAMETER, and a foreign handle is not answered; the process is AMD64, both IsWow64Process2 outputs are optional, and the image path comes back NUL-terminated with its length, while a two-unit buffer is refused.

**@⁠AnastasisKon** on GitHub · 2026-11-28 15:48 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622) ## Summary The calls a title makes about its own process at startup had no implementation in `host_posix/system.rs`, so each landed in the loader's import stub: | Call | What the stub did | |---|---| | `SetErrorMode` / `SetThreadErrorMode` / `GetErrorMode` | nothing: a title that turns off the fault and critical-error boxes and then reads the mode back gets 0 | | `SetPriorityClass` / `GetPriorityClass` | nothing: a title that raises its class and prints it in a crash log logs 0 | | `IsWow64Process2` | nothing: a title asking what machine it is gets 0 for both answers | | `QueryFullProcessImageNameW` | nothing: a title logging its own path logs an empty string | None of them can fail a title outright, which is why they went unnoticed, but each is a silent wrong answer in the one place a crash log is written from. ## What the change does - One error mode for the process (`SetErrorMode` and `SetThreadErrorMode` both write it and report the value they replaced, `GetErrorMode` reads it). Shortcut, written down: Windows keeps a per-thread mode beside the process one. - The priority class is validated against the six Windows classes and remembered, not applied: raising a process's own scheduling class is privileged on macOS, and a title only reads back what it set. A handle that is not this process (the pseudo handle is the only one a title can hold here) is `ERROR_INVALID_HANDLE`. - `IsWow64Process2` reports no emulated 32-bit process and `IMAGE_FILE_MACHINE_AMD64` as the native machine, because that is the machine whose code runs here; a title told ARM64 takes paths (arm64 binaries, different threading) this host does not serve. - `QueryFullProcessImageNameW` returns the main image's path from `GetModuleFileNameW`, with its NUL and its length without it back in `size`; a buffer that is too small is `ERROR_INSUFFICIENT_BUFFER` and is left untouched. ## Tests Three new ones in `system.rs`: the error mode round-trips and reports what it replaced; the priority class is remembered, an unknown class is `ERROR_INVALID_PARAMETER`, and a foreign handle is not answered; the process is AMD64, both `IsWow64Process2` outputs are optional, and the image path comes back NUL-terminated with its length, while a two-unit buffer is refused.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 15:52:27 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 15:48 UTC · original

/claim

**@⁠AnastasisKon** on GitHub · 2026-11-28 15:48 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7241755819) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 15:49 UTC · original

Claimed by @⁠AnastasisKon. Open a draft pull request with Refs #622 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 15:49 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7241757700) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #622` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 16:31 UTC · original

Merged with the PR that serves these calls; closing.

**@⁠AnastasisKon** on GitHub · 2026-11-28 16:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7242312186) Merged with the PR that serves these calls; closing.
This discussion has been locked. Commenting is limited to contributors.
No description provided.