host_posix: DebugBreak, FormatMessageW and _ldsign for the upscaler DLL #153

Manually merged
github merged 1 commit from gh-pr/153/head into gh-pr/153/base 2026-11-27 00:51:36 +00:00
Owner

@⁠Olima34 on GitHub · 2026-11-26 21:42 UTC · original
Olima34:feat/fidelityfx-imports → main · +336 −4 · 7 files · 1 commits · merged 2026-11-26 22:39 UTC

The three imports #135 named for the late-loaded amd_fidelityfx_upscaler_xbox.dll. A run on an M5 Pro (Series S, d41052c) logs native imports bound hle=7 host=42 missing=3 unresolved=api-ms-win-crt-math-l1-1-0.dll!_ldsign, api-ms-win-core-debug-l1-1-0.dll!DebugBreak, api-ms-win-core-localization-l1-2-0.dll!FormatMessageW. Until now all three were stubs returning 0.

  1. _ldsign (ucrt/math.rs): an alias of _dsign. Microsoft Learn ("Floating-point primitives") gives int _ldsign(long double) and promises only a nonzero result when the sign bit is set. On MSVC x64, long double is double.
  2. DebugBreak: a Windows-ABI stub, _victory_DebugBreak in victory-loader seh/dispatch.rs. It tail-calls RaiseException(EXCEPTION_BREAKPOINT, 0, 0, NULL), so the captured context is the caller's. It is bound like RaiseException. A vectored handler or __except takes it; with none it goes down the loader's unhandled path, as on Windows, never a silent no-op.
    Guess, marked in code and docs: Windows' record points at the int3 in DbgBreakPoint, with one parameter. Here it points at the return address with none, and a handler that continues resumes after the call.
  3. FormatMessageW (system.rs):
    • FROM_SYSTEM: English text for common Win32 errors, 0x8007xxxx HRESULTs, and E_NOTIMPL, E_NOINTERFACE, E_POINTER and E_FAIL, each ending in \r\n.
    • FROM_STRING: %1..%99 with !s! / !ls! / !ws! / !d! / !i! / !u! / !x! / !X!, and the escapes %0 %n %t %% %. %!.
    • Also handled: IGNORE_INSERTS, ARGUMENT_ARRAY or a va_list, ALLOCATE_BUFFER (as FormatMessageA does here) and MAX_WIDTH_MASK.
    • FROM_HMODULE, unknown flags and a null %s fail with ERROR_INVALID_PARAMETER. A buffer that is too small fails with ERROR_INSUFFICIENT_BUFFER.
    • Guess, marked: an unknown message id gives Error 0x%08X\r\n, where Windows fails with ERROR_MR_MID_NOT_FOUND.

Tests.

  • system::the_upscaler_dll_finds_its_debug_localization_and_math_imports looks up the exact three dll!name from the log.
  • system::format_message_w_formats_system_errors_and_inserts.
  • math::long_double_sign_is_the_double_one.
  • The native probe's probe_seh gains E_BREAK (__except sees 0x80000003) and E_BREAK_CONTINUE (a continuing filter returns from DebugBreak).

Without the registrations, the lookup test and the probe fail.

victory-hle (262), victory-loader (22) and native_probe (16) tests on x86_64-apple-darwin, Windows clippy and cargo xtask policy pass. One PR rather than three, because all three are one DLL's imports and share one lookup test and one docs paragraph.

**@⁠Olima34** on GitHub · 2026-11-26 21:42 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/153) `Olima34:feat/fidelityfx-imports` → `main` · +336 −4 · 7 files · 1 commits · merged 2026-11-26 22:39 UTC The three imports #135 named for the late-loaded `amd_fidelityfx_upscaler_xbox.dll`. A run on an M5 Pro (Series S, `d41052c`) logs `native imports bound hle=7 host=42 missing=3 unresolved=api-ms-win-crt-math-l1-1-0.dll!_ldsign, api-ms-win-core-debug-l1-1-0.dll!DebugBreak, api-ms-win-core-localization-l1-2-0.dll!FormatMessageW`. Until now all three were stubs returning 0. 1. **`_ldsign`** (`ucrt/math.rs`): an alias of `_dsign`. Microsoft Learn ("Floating-point primitives") gives `int _ldsign(long double)` and promises only a nonzero result when the sign bit is set. On MSVC x64, `long double` is `double`. 2. **`DebugBreak`**: a Windows-ABI stub, `_victory_DebugBreak` in `victory-loader` `seh/dispatch.rs`. It tail-calls `RaiseException(EXCEPTION_BREAKPOINT, 0, 0, NULL)`, so the captured context is the caller's. It is bound like `RaiseException`. A vectored handler or `__except` takes it; with none it goes down the loader's unhandled path, as on Windows, never a silent no-op. Guess, marked in code and docs: Windows' record points at the `int3` in `DbgBreakPoint`, with one parameter. Here it points at the return address with none, and a handler that continues resumes after the call. 3. **`FormatMessageW`** (`system.rs`): - `FROM_SYSTEM`: English text for common Win32 errors, `0x8007xxxx` HRESULTs, and E_NOTIMPL, E_NOINTERFACE, E_POINTER and E_FAIL, each ending in `\r\n`. - `FROM_STRING`: `%1`..`%99` with `!s!` / `!ls!` / `!ws!` / `!d!` / `!i!` / `!u!` / `!x!` / `!X!`, and the escapes `%0 %n %t %% %. %!`. - Also handled: `IGNORE_INSERTS`, `ARGUMENT_ARRAY` or a `va_list`, `ALLOCATE_BUFFER` (as `FormatMessageA` does here) and `MAX_WIDTH_MASK`. - `FROM_HMODULE`, unknown flags and a null `%s` fail with `ERROR_INVALID_PARAMETER`. A buffer that is too small fails with `ERROR_INSUFFICIENT_BUFFER`. - Guess, marked: an unknown message id gives `Error 0x%08X\r\n`, where Windows fails with `ERROR_MR_MID_NOT_FOUND`. **Tests.** - `system::the_upscaler_dll_finds_its_debug_localization_and_math_imports` looks up the exact three `dll!name` from the log. - `system::format_message_w_formats_system_errors_and_inserts`. - `math::long_double_sign_is_the_double_one`. - The native probe's `probe_seh` gains `E_BREAK` (`__except` sees `0x80000003`) and `E_BREAK_CONTINUE` (a continuing filter returns from `DebugBreak`). Without the registrations, the lookup test and the probe fail. victory-hle (262), victory-loader (22) and native_probe (16) tests on x86_64-apple-darwin, Windows clippy and `cargo xtask policy` pass. One PR rather than three, because all three are one DLL's imports and share one lookup test and one docs paragraph.
amd_fidelityfx_upscaler_xbox.dll, loaded late, imports three functions
the native host stubbed to return 0 (#123, named since #135).

- _ldsign (api-ms-win-crt-math) is _dsign: long double is double on
  this ABI, and both give nonzero (0x8000) for a set sign bit.
- DebugBreak (api-ms-win-core-debug) is RaiseException
  (EXCEPTION_BREAKPOINT) for its caller, a tail call into the loader's
  RaiseException. A vectored handler or __except takes it; with none it
  is unhandled, as on Windows. Where the record differs from Windows'
  int3 is a guess, marked.
- FormatMessageW (api-ms-win-core-localization) does FROM_SYSTEM with
  the English text of common errors, FROM_STRING with %1..%99 inserts
  and escapes, IGNORE_INSERTS, ARGUMENT_ARRAY or a va_list,
  ALLOCATE_BUFFER and MAX_WIDTH_MASK. Other flags fail with
  ERROR_INVALID_PARAMETER. Text for an unknown id is a guess, marked.

The native probe checks DebugBreak through __except and a filter that
continues.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:51:34 +00:00
github manually merged commit 28f64a6caa into gh-pr/153/base 2026-11-27 00:51:36 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 22:39 UTC · original · approved these changes

Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 22:39 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/153#pullrequestreview-6081187606) · **approved these changes** Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.