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

Closed
opened 2026-11-28 15:48:08 +00:00 by AnastasisKon · 3 comments
AnastasisKon commented 2026-11-28 15:48:08 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T15:48:08Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6667645247 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T15:48:08Z. --- ## 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 commented 2026-11-28 15:48:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T15:48:53Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7241755819 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7241755819). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T15:48:53Z. --- /claim
github-actions[bot] commented 2026-11-28 15:49:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T15:49:02Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7241757700 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7241757700). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T15:49:02Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #622` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 16:31:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T16:31:46Z.


Merged with the PR that serves these calls; closing.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7242312186 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/622#issuecomment-7242312186). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T16:31:46Z. --- Merged with the PR that serves these calls; closing.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#622
No description provided.