Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de3dd496be
|
||
|
|
39a747f2a3 | ||
|
|
47f010a7b7 | ||
|
|
28c7760d28 |
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ barrier. It is written for the person who has just met one; the details for deve
|
||||
FrameLedger is a desktop program: its own window, its dialogs, its document windows, the icon by the clock and the
|
||||
notices Windows shows for it. It draws nothing inside a game, so it cannot make a game itself any easier to use.
|
||||
|
||||
*Beta software: this page describes version 0.1.0-beta.45. In the app: Help ▸ Accessibility.*
|
||||
*Beta software: this page describes version 0.1.0-beta.46. In the app: Help ▸ Accessibility.*
|
||||
|
||||
## What FrameLedger aims for
|
||||
|
||||
|
||||
+8
-5
@@ -35,12 +35,14 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
### Added
|
||||
|
||||
- **The limitations, the accuracy statement and the user guide say what the first real sessions on 0.1.0-beta.45
|
||||
showed** (2026-11-13, six games): five of its six new readings were read in real games — every Streamline game
|
||||
asked whether its features are supported — and no game allocated a feature's resources after FrameLedger was in
|
||||
it, so that row has not been seen. No code changes.
|
||||
- **For developers, nothing a user installs: a probe for NVIDIA Reflex latency** (owner decision D132). An
|
||||
unshipped tool, `fl-probe-reflex`, and a stand-in `nvapi64.dll` among the test fixtures measure what it would take
|
||||
to read the driver's latency report from inside a game - on FrameLedger's own test program and against the
|
||||
installed driver, never in a game. What it found is `docs/spike-notes/31-reflex-route-d-harness.md`; whether a
|
||||
real game is tried next is the owner's decision. Nothing in the App, the Agent or the part that runs inside a
|
||||
game changed.
|
||||
|
||||
## Releases
|
||||
|
||||
@@ -48,6 +50,7 @@ Newest first. Each file holds that release's section exactly as it stood here.
|
||||
|
||||
| Version | Date | Notes |
|
||||
|---|---|---|
|
||||
| `0.1.0-beta.46` | 2026-11-13 | [`docs/changelog/0.1.0-beta.46.md`](docs/changelog/0.1.0-beta.46.md) |
|
||||
| `0.1.0-beta.45` | 2026-11-12 | [`docs/changelog/0.1.0-beta.45.md`](docs/changelog/0.1.0-beta.45.md) |
|
||||
| `0.1.0-beta.44` | 2026-11-12 | [`docs/changelog/0.1.0-beta.44.md`](docs/changelog/0.1.0-beta.44.md) |
|
||||
| `0.1.0-beta.43` | 2026-11-12 | [`docs/changelog/0.1.0-beta.43.md`](docs/changelog/0.1.0-beta.43.md) |
|
||||
|
||||
@@ -205,6 +205,8 @@ tools/ # accuracy-check, changelog-check, chokepoint-che
|
||||
# (--vulkan since #140, --opengl since #141)
|
||||
# fl-probe-* -> guard, hook profile, interposer, NVAPI, process
|
||||
# stats, signer, Vulkan layer; fl-baseline-probe;
|
||||
# and fl-probe-reflex (2026-11-13, D132: the spike of Reflex route D,
|
||||
# spike-notes §31 - unshipped, with a stand-in nvapi64.dll among the stubs);
|
||||
# vendor-stubs/ -> fixture DLLs with the vendors' export names
|
||||
rules/detection-rules.json # engine/platform/capability + anticheat blocklist
|
||||
guide/ # the user guide (beta.12, D44): ~~eight~~ short English pages for players, embedded in the
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ hooking on for — and reading the graphics calls the game makes. That is why it
|
||||
resolution, the upscaler, frame generation and ray tracing apart. It is also where its limits come from. This
|
||||
page lists them in plain words; each item links to the document that has the details.
|
||||
|
||||
*Beta software: this page describes version 0.1.0-beta.45.*
|
||||
*Beta software: this page describes version 0.1.0-beta.46.*
|
||||
|
||||
## Games it will not measure
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ app too (Help ▸ User guide, Help ▸ Limitations, Help ▸ Accessibility), and
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.45`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.46`** (2026-11-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
@@ -205,7 +205,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
|
||||
|
||||
## Install
|
||||
|
||||
> **The latest beta is `v0.1.0-beta.45` (2026-11-12); before it `v0.1.0-beta.44` (2026-11-12), `v0.1.0-beta.43` (2026-11-12), `v0.1.0-beta.42` (2026-11-12), `v0.1.0-beta.41` (2026-11-12), `v0.1.0-beta.40` (2026-11-12), `v0.1.0-beta.39` (2026-11-11), `v0.1.0-beta.38` (2026-11-11), `v0.1.0-beta.37` (2026-11-11), `v0.1.0-beta.36` (2026-11-10), `v0.1.0-beta.35` (2026-11-09), `v0.1.0-beta.34` (2026-11-06), `v0.1.0-beta.33` (2026-11-03), `v0.1.0-beta.32` (2026-10-31), `v0.1.0-beta.31` (2026-10-26), `v0.1.0-beta.30` (2026-10-26), `v0.1.0-beta.29` (2026-10-25), `v0.1.0-beta.28` (2026-10-20), `v0.1.0-beta.27` (2026-10-20), `v0.1.0-beta.26` (2026-10-19), `v0.1.0-beta.25` (2026-10-19), `v0.1.0-beta.24` (2026-10-19), `v0.1.0-beta.23` (2026-10-14), `v0.1.0-beta.22` (2026-10-13), `v0.1.0-beta.21` (2026-10-13), `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read the notes of the one you install — `CHANGELOG.md` links each release's own file under `docs/changelog/` — for what it measures, what it does not yet, and how to update, before installing. A source build is `docs/12_BUILD.md`.
|
||||
> **The latest beta is `v0.1.0-beta.46` (2026-11-13); before it `v0.1.0-beta.45` (2026-11-12), `v0.1.0-beta.44` (2026-11-12), `v0.1.0-beta.43` (2026-11-12), `v0.1.0-beta.42` (2026-11-12), `v0.1.0-beta.41` (2026-11-12), `v0.1.0-beta.40` (2026-11-12), `v0.1.0-beta.39` (2026-11-11), `v0.1.0-beta.38` (2026-11-11), `v0.1.0-beta.37` (2026-11-11), `v0.1.0-beta.36` (2026-11-10), `v0.1.0-beta.35` (2026-11-09), `v0.1.0-beta.34` (2026-11-06), `v0.1.0-beta.33` (2026-11-03), `v0.1.0-beta.32` (2026-10-31), `v0.1.0-beta.31` (2026-10-26), `v0.1.0-beta.30` (2026-10-26), `v0.1.0-beta.29` (2026-10-25), `v0.1.0-beta.28` (2026-10-20), `v0.1.0-beta.27` (2026-10-20), `v0.1.0-beta.26` (2026-10-19), `v0.1.0-beta.25` (2026-10-19), `v0.1.0-beta.24` (2026-10-19), `v0.1.0-beta.23` (2026-10-14), `v0.1.0-beta.22` (2026-10-13), `v0.1.0-beta.21` (2026-10-13), `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read the notes of the one you install — `CHANGELOG.md` links each release's own file under `docs/changelog/` — for what it measures, what it does not yet, and how to update, before installing. A source build is `docs/12_BUILD.md`.
|
||||
|
||||
1. Download the latest `FrameLedger.App-win-Setup.exe` from [Releases](https://github.com/poli0981/frameledger/releases). It installs into `%LOCALAPPDATA%\FrameLedger.App`; your data stays in `%LOCALAPPDATA%\FrameLedger`, and uninstalling asks before touching it.
|
||||
2. SmartScreen may warn — releases are not code-signed (free, open-source project). Verify the SHA-256 checksum published with each release, then **More info → Run anyway**.
|
||||
|
||||
@@ -35,6 +35,7 @@ Targets:
|
||||
- `hook-harness` → the dummy **D3D11 + D3D12** app, WARP + composition swapchain so it runs headless on CI (`17_HOOK_ENGINE` §Test harness). D3D12 is device → command queue → swapchain, which is the acquisition asymmetry a D3D11-only fixture cannot exercise. ~~Vulkan and OpenGL modes to follow as those hooks land.~~ **`--vulkan --hold-presenting N` since 2026-09-06 (P1 item 3):** a real swapchain on a hidden window through the real loader, reached by `LoadLibraryW("vulkan-1.dll")` so only the vendored headers are needed and CI (no loader) still builds it; exit 77 = cannot run here, which the ctest reads as SKIP. **`--opengl --hold-presenting N` since the same day (P1 item 4):** a real context on a hidden window, `SwapBuffers`'d through gdi32 as a title does, on Microsoft's generic renderer — so it runs on CI.
|
||||
- `fl-probe-hookprofile` → build-profile probes for `/guard:cf` and `-D_HAS_EXCEPTIONS=0` (`20_OPEN_QUESTIONS` §H1/§H3)
|
||||
- `fl-probe-guard` → measures the Windows APIs the guard is built on, unelevated (`spike-notes.md` §1). Not the guard, and takes no injection rights.
|
||||
- `fl-probe-reflex` → the instrument of `spike-notes` §31 (2026-11-13, owner decision D132): the call sequence Reflex route D would put into the Overlay — find `nvapi64.dll` only if the process already holds it, resolve the driver's two getters by interface id, call them — in an unshipped probe built with the Overlay's flags. `--stub` runs it against `fl_stub_nvapi64` → `nvapi64.dll` (a stand-in with knobs for a missing getter, an empty report, an error and a call that does not return; its outputs in a directory of their own, so that its `nvapi64.lib` is never beside the vendored one's name) and is ctest `fl_reflex_probe_stub`; `--real` runs it against the installed driver on an NVIDIA adapter, with the probe setting the latency markers a game would, in its own process — a measurement, never a test. It takes the vendored NVAPI headers' include directory and **does not link `nvapi64.lib`**. Nothing shipped includes its header.
|
||||
- `fl_stub_sl_interposer` → `sl.interposer.dll`, and `fl_stub_sl_common` → `sl.common.dll` (`src/native/tools/vendor-stubs/`). **Fixtures, never shipped**, built under `FL_BUILD_TOOLS`; nothing `12_BUILD` publishes references them. They export the **measured** vendor names from `docs/vendor-exports.json` so the Overlay's symbol resolution is observable, and the second is a **decoy** exporting the same name from a different module — without it, "we resolve module-scoped" is a property no test can falsify. Their **output filenames are the vendor's and their version blocks are ours**: `fl_add_version_resource` takes the real filename so a file called `sl.interposer.dll` in our build tree still says plainly that it is FrameLedger's, which `19_SAFETY` requires of everything we build.
|
||||
- `fl_stub_ffx_dx12` → `amd_fidelityfx_dx12.dll`, `fl_stub_ffx_upscaler` → `amd_fidelityfx_upscaler_dx12.dll`, `fl_stub_ffx_fg` → `amd_fidelityfx_framegeneration_dx12.dll` — the three AMD **leaves** — and `fl_stub_ffx_loader` → `amd_fidelityfx_loader_dx12.dll`, a **forwarding stand-in** bound to the two 2.x leaves through their FrameLedger-named *direct* entry — the way the real loader was measured to bypass the leaves' exports — so `--hold-presenting-ffx` can push every dispatch through a loader that is hooked along with the leaves and prove the count reads 1× (2026-09-04). Same rules as the Streamline stubs: fixtures, never shipped, vendor filenames with our version blocks. `fl_stub_ffx_fsr3_host` → `ffx_fsr3_x64.dll` (2026-09-05): the FSR 3.0 **host** facade, exporting the four names `SpeaksFsr3Host` probes for through the vendored `fsr3-v3.0.4` header's own `FFX_API`; `--ffx-topology fsr3host|fsr3host+mono` drives it, and `hookinventory-check` Pass C reads it as the export parser's second positive control.
|
||||
- **`fl_fidelityfx_headers`** → an INTERFACE target over the five vendored FidelityFX ffx-api headers (`src/native/third_party/fidelityfx/`, tag v2.3.0, MIT by exception). Three include directories because upstream's headers include each other by relative path; include directories only and nothing to link — no `.lib` is vendored — and `hookinventory-check` Pass C reads the Overlay's export table because `ffx_api.h` declares its entry points `__declspec(dllexport)` unconditionally.
|
||||
|
||||
@@ -158,6 +158,13 @@ own work item on the STA thread and puts back — and with the keys a parameter,
|
||||
> Until the run happens, the honest state of this line is *unmeasured*, not *passing*.
|
||||
3. Results recorded in the release notes ("measured overhead this release: …").
|
||||
|
||||
**What a patch costs when it goes in and comes out (since 0.1.0-beta.46) is not the per-present number above**, and
|
||||
is measured where it happens: `fl_guard`'s Streamline `[advanced]` case prints the microseconds of each install
|
||||
batch and of the stop's one restore (the Overlay's `PATCH_BATCH` lines), and the time from the unhook request to
|
||||
`UNHOOKED`; it asserts that every lazily installed patch is under a batch line, that the stop is one, and that the
|
||||
restore stays under a second — the bound the one-patch-at-a-time stop did not meet on the development PC. In a real
|
||||
game the same lines are in `logs\overlay-<pid>-….log`.
|
||||
|
||||
## Tier cross-validation (accuracy regression net) — **GONE, 2026-08-28, and this is the entry to read before planning P5**
|
||||
|
||||
~~Run the same game session with Tier 1 and Tier 2 simultaneously where possible (ETW does not conflict with hooking) and compare frametime distributions: Avg/1% Low must agree within **1%**. Divergence beyond that means one of the two paths is wrong and blocks the release. This is also the check that would have caught the original detection-accuracy problem.~~
|
||||
|
||||
+61
-5
@@ -196,8 +196,8 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|
||||
| NGX parameter accessors (`NVSDK_NGX_Parameter_SetI/GetI/SetUI`) — **exported by `sl.common.dll` only; see below** | `Width`/`Height` (render) vs `OutWidth`/`OutHeight` (output), `PerfQualityValue` (quality preset), sharpness |
|
||||
| ✅ Streamline: `slEvaluateFeature` · ~~⏳ `slInit`~~ *(not hooked, and not to be: owner decision D129, 2026-11-12 — its row below says why)*, ~~`slSetFeatureLoaded`~~ *(its own row below since beta.45)*, ~~`slSetConstants`~~ *(its own row below since beta.43)*, ~~`slGetFeatureRequirements`~~ *(its own row below since beta.44, with `slGetFeatureVersion`)* | Feature set actually active when the game goes through SL rather than NGX directly (`kFeatureDLSS`, `DLSS_G`, `DLSS_RR`, `Reflex`, `NIS`; since beta.34 `kFeatureDLSS_NR` — DLSS 5's neural rendering, its own fact bit and family `FL_HOOK_SL_NEURAL_RENDERING`, D84; rule 4: the `feature` argument of the API hooked, nothing else). **Built 2026-08-09**, identity only: one MinHook detour on `sl.interposer.dll!slEvaluateFeature`, resolved **module-scoped** and installed lazily by the watchdog. Sets `FL_MEASURED_UPSCALER` + `FL_HOOK_UPSCALER_IDENTITY`; decodes `kFeatureDLSS`/`kFeatureNIS` and reports `FL_UPSCALER_UNKNOWN` for anything else. **Never `FL_UPSCALER_NONE`** — a Streamline-only writer cannot see FFX, XeSS or NGX-direct, and `NONE` is the only one of the three states that may be aggregated as a negative. **Since 0.1.0-beta.40 (Advanced metrics train B, D111), and only while the Agent asks** (`FlControlBlock.advancedRequested`): the `sl::DLSSOptions` a title chains into `inputs` — the struct the quality mode is read from — is read further: `outputWidth`/`outputHeight`, `preExposure`, `exposureScale`, `colorBuffersHDR`, the five presets of version 1, and where the struct's own `structVersion` proves them present `ultraQualityPreset` and `useAutoExposure` (≥ 2) and `alphaUpscalingEnabled` (≥ 3) — §Which struct version carries which field. Rule 4: more members of the same argument of the same call; `fl_adv_fields.h` is the one place, `tools/overlay-fields-check.ps1` holds it. No new patch site. **Measured** (the header's own functions, `/O2 /guard:cf /Qspectre /MT`, 20 M calls × 3): +9.5–11.7 ns per evaluation that chains the options while asked; with the word at 0, one relaxed load and a branch not taken — below what the bench resolves. Most titles set these through `slDLSSSetOptions`, which is not an export, and read N/A (train D) |
|
||||
| ✅ Streamline: `slSetConstants` (0.1.0-beta.43, Advanced metrics train B; owner decisions D111–D116, D122) | **What the game tells Streamline about a frame**, once per frame and viewport, read from the `sl::Constants` it passes — rule 4: an argument of the call hooked, and of it only the members named here. **Read:** `jitterOffset`, `mvecScale`, `cameraNear`, `cameraFar`, `cameraFOV`, `cameraAspectRatio` and the seven `Boolean`s (`depthInverted`, `cameraMotionIncluded`, `motionVectors3D`, `reset`, `orthographicProjection`, `motionVectorsDilated`, `motionVectorsJittered`). **Never read:** the five matrices (bytes 32..351 of the struct), `cameraPinholeOffset`, and the camera's position and three axes (bytes 368..423) — `tools/overlay-fields-check.ps1` refuses their names anywhere in code loaded into a game, and ctest `fl_adv_fields` publishes two structs that differ in every one of those bytes and gets the same bytes out. **The one row that is not installed unless asked for** (D111): `InstallByFamily` returns before it resolves the symbol in a process the Agent has never asked for Advanced metrics — resolving takes a reference on the module — so with the option off the export's first bytes are the file's (`fl_guard` `[advanced]` reads them from the target). Once asked, the patch goes in on that watchdog tick and stays for the life of the process; the detour forwards without looking while the request is off, and after a stop (`MayObserve`). **Every call** checks the struct's GUID and a `structVersion` of at least 1 before any member is read, and the viewport handle's the same way; every member read is one version 1 carries, so a version-1 struct laid against unreadable memory is read whole without a fault (the same ctest). **Summaries are the first viewport's**: a title with two viewports sets constants for each every frame, and "the last value" across them would flip twice a frame; the call count is of every viewport. `FLT_MAX` is Streamline's "not set" here and is kept nowhere (D119's plane at infinity is FidelityFX's). Family `FL_HOOK_SL_CONSTANTS` (bit 13), published with the patch: it entitles no field of a frame record, and tells "hooked, never called" from "not hooked". **Measured overhead** (the detour's body on the headers, the Overlay's flags, 20 million calls a run, three runs): not asked **+0.57 / +0.60 / +0.58 ns**; asked, the summarised viewport **+19.61 / +19.54 / +19.79 ns**; asked, another viewport +5.83 / +6.01 / +5.62 ns. |
|
||||
| ✅ Streamline: `slGetFeatureVersion` and `slGetFeatureRequirements` (0.1.0-beta.44, Advanced metrics train B's third step; owner decisions D111–D116, D122) | **What Streamline answers when the game asks about a feature** — which version it is, and what it requires. Two rows, two patches, two detours of one shape: **the original runs first, exactly once, on every path, with both arguments forwarded untouched**, and the struct the game passed is read only when the original said `eOk` — a refusal leaves the struct as the game made it, which is not an answer. Rule 4: an argument of the call hooked, read after the call, and of it only the members named here. **Read from `sl::FeatureVersion`:** `versionSL`, `versionNGX`. **Read from `sl::FeatureRequirements`:** `flags`, `maxNumCPUThreads`, `maxNumViewports`, `numRequiredTags`, `osVersionDetected`, `osVersionRequired`, `driverVersionDetected`, `driverVersionRequired`. **Never read:** `requiredTags` — the pointer the count belongs to — and everything after `driverVersionRequired`: the Vulkan queue counts and the pointers to the names of extensions and features. **No pointer of the game's is followed** (`tools/overlay-fields-check.ps1`, parameters `fv` and `fr`; ctest `fl_adv_fields`: two answers that differ only in those bytes publish the same region, and an answer cut off where the Vulkan members begin, laid against unreadable memory, is read without a fault; the injected `fl_guard` case's stub hands back wild pointers and no fault is counted). **Installed only where asked for** (D111), as `slSetConstants` is: `InstallByFamily` returns before it resolves either symbol in a process the Agent has never asked for Advanced metrics; once in, a patch stays for the life of the process and its detour forwards without looking while the request is off. **They are the first two rows of the table**: a game asks these while it starts, the watchdog patches rows in the table's order, and each patch stops the game's threads for a moment (0.1–0.25 s apart in the owner's logs of 2026-11-12, where `slSetConstants` was the fifth Streamline patch in, 1.9–7.8 s after the attach). In a process never asked they are passed over and the order changes nothing. ~~**Most sessions will still have missed the calls** — an attach after the game's start-up is the usual case — and the session then says the call was hooked and the game did not ask again.~~ *(Measured 2026-11-12, the owner's eight sessions on beta.44: both calls were read in six of six Streamline sessions on five games — Unreal's Streamline plugin asks again after the attach, Cyberpunk 2077 asks again for requirements and not for versions. A game that asks only while starting still reads "hooked, not asked again".)* Three conditions before a read, as for `slSetConstants`: the Agent is asking, observing has not stopped, and the struct carries its own GUID and a version of at least 1 on this call (a struct with another GUID is not kept: the injected case sends one). Every member read is version 1's (§Which struct version carries which field). **Twelve slots** in region 5 (`FlAdvancedState.features`, layout 5 as it was), one per feature in the order first asked about; the last answer about a feature is the one kept; a thirteenth feature is not kept. **A new request does not empty them**: what version a feature is and what it requires are facts about the process, and a second session of a game that kept running would otherwise have nothing where the first had the answer — the one group `Reset` leaves, with its bit of the mask. Streamline 1.x is refused before anything is resolved (`SpeaksStreamline2`). Families `FL_HOOK_SL_FEATURE_VERSION` (bit 15) and `FL_HOOK_SL_FEATURE_REQUIREMENTS` (bit 16), each published with its patch; neither entitles a field of a frame record. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features asked about in turn): the version — not asked **+0.58 / +0.61 / +0.58 ns**, asked **+14.82 / +14.54 / +14.47 ns**; the requirements — not asked **+0.58 / +0.63 / +0.61 ns**, asked **+20.88 / +21.01 / +20.96 ns**. A game makes these calls a handful of times. |
|
||||
| ✅ Streamline: `slIsFeatureSupported`, `slIsFeatureLoaded`, `slSetFeatureLoaded` (0.1.0-beta.45; owner decisions D129–D131) | **Whether a feature is supported, whether it is loaded, and the game switching it on and off.** Three rows, three patches. Rule 4: bare arguments and results of the calls hooked, and no vendor struct at all — the feature's id; the `sl::Result` `slIsFeatureSupported` returned, **every result**, since a refusal is the answer to that question (the original runs first, both arguments forwarded untouched); the `bool` `slIsFeatureLoaded` wrote, read only when it returned `eOk`; the `bool` the game passed to `slSetFeatureLoaded`, noted before the call. **The adapter `slIsFeatureSupported` is asked about is never read** (D131): `sl::AdapterInfo` holds the adapter's LUID or a Vulkan physical device; the detour forwards the reference and `tools/overlay-fields-check.ps1` refuses the names of its members (`deviceLUID`, `deviceLUIDSizeInBytes`, `vkPhysicalDevice`) anywhere in the Overlay and the Vulkan layer — the fixture's adapter carries a wild pointer. **Installed only where asked for** (D111), as the four rows before them. `slIsFeatureSupported` and `slIsFeatureLoaded` follow the two rows of beta.44 at the head of the table; `slSetFeatureLoaded` follows `slSetConstants`. **Kept in word 1 of the feature's slot** (region 5, layout 5 as it was): bit 2 and the result in bits 8..15, bits 3 and 4, bits 5 and 6 — the last two a session's, cleared by a new request; the rest the process's, kept (`fl_adv_fields.h` `kFeatureSessionBits`). A refused feature therefore has a slot now, with nothing in it but that word. The declarations of the three functions are the same from Streamline v2.0.0 to v2.14.16, and `sl::Result` is the same forty codes in the same order at all sixteen tags (`include/sl_result.h`, `05a3c7e3889c` … `8a844b68ff55`), so a code means the same whatever interposer answered. Families `FL_HOOK_SL_FEATURE_SUPPORTED` (bit 17), `FL_HOOK_SL_FEATURE_LOADED` (18), `FL_HOOK_SL_SET_FEATURE_LOADED` (19), each published with its patch. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features in turn): `slIsFeatureSupported` — not asked **+1.50 / +1.48 / +1.50 ns**, asked **+11.97 / +11.98 / +12.08 ns**; `slIsFeatureLoaded` — **+1.79 / +1.77 / +1.89 ns**, **+12.35 / +12.31 / +12.33 ns**; `slSetFeatureLoaded` — **+1.44 / +1.47 / +1.80 ns**, **+11.28 / +11.54 / +11.45 ns**. **`slInit` is not a row and will not be** (D129): a game calls it once, before the Overlay is in the process or before a patch can land — launch mode waits for the presentation runtime before it injects, nothing is ever patched on a game's thread (§H2), and a row that exists only for Advanced metrics waits for the Agent's request. **A stop takes about 160 ms for every patch it restores** (measured on the fixture, 0.1.0-beta.45: each `MH_DisableHook` snapshots the system's threads): twelve patches took 1.9 s, fifteen 2.4 s, and the watchdog's wait for the stop's log lines, 2 s until then, is now a quarter of a second for every patch the registry can hold. |
|
||||
| ✅ Streamline: `slGetFeatureVersion` and `slGetFeatureRequirements` (0.1.0-beta.44, Advanced metrics train B's third step; owner decisions D111–D116, D122) | **What Streamline answers when the game asks about a feature** — which version it is, and what it requires. Two rows, two patches, two detours of one shape: **the original runs first, exactly once, on every path, with both arguments forwarded untouched**, and the struct the game passed is read only when the original said `eOk` — a refusal leaves the struct as the game made it, which is not an answer. Rule 4: an argument of the call hooked, read after the call, and of it only the members named here. **Read from `sl::FeatureVersion`:** `versionSL`, `versionNGX`. **Read from `sl::FeatureRequirements`:** `flags`, `maxNumCPUThreads`, `maxNumViewports`, `numRequiredTags`, `osVersionDetected`, `osVersionRequired`, `driverVersionDetected`, `driverVersionRequired`. **Never read:** `requiredTags` — the pointer the count belongs to — and everything after `driverVersionRequired`: the Vulkan queue counts and the pointers to the names of extensions and features. **No pointer of the game's is followed** (`tools/overlay-fields-check.ps1`, parameters `fv` and `fr`; ctest `fl_adv_fields`: two answers that differ only in those bytes publish the same region, and an answer cut off where the Vulkan members begin, laid against unreadable memory, is read without a fault; the injected `fl_guard` case's stub hands back wild pointers and no fault is counted). **Installed only where asked for** (D111), as `slSetConstants` is: `InstallByFamily` returns before it resolves either symbol in a process the Agent has never asked for Advanced metrics; once in, a patch stays for the life of the process and its detour forwards without looking while the request is off. **They are the first two rows of the table**: a game asks these while it starts, the watchdog patches rows in the table's order, and each patch stops the game's threads for a moment (0.1–0.25 s apart in the owner's logs of 2026-11-12, where `slSetConstants` was the fifth Streamline patch in, 1.9–7.8 s after the attach). *(Since 0.1.0-beta.46 the rows a tick finds go in together, under one stop of the threads — §Unhooking, Batches — so the order no longer decides which row waits behind which; it is still the order of their log lines.)* In a process never asked they are passed over and the order changes nothing. ~~**Most sessions will still have missed the calls** — an attach after the game's start-up is the usual case — and the session then says the call was hooked and the game did not ask again.~~ *(Measured 2026-11-12, the owner's eight sessions on beta.44: both calls were read in six of six Streamline sessions on five games — Unreal's Streamline plugin asks again after the attach, Cyberpunk 2077 asks again for requirements and not for versions. A game that asks only while starting still reads "hooked, not asked again".)* Three conditions before a read, as for `slSetConstants`: the Agent is asking, observing has not stopped, and the struct carries its own GUID and a version of at least 1 on this call (a struct with another GUID is not kept: the injected case sends one). Every member read is version 1's (§Which struct version carries which field). **Twelve slots** in region 5 (`FlAdvancedState.features`, layout 5 as it was), one per feature in the order first asked about; the last answer about a feature is the one kept; a thirteenth feature is not kept. **A new request does not empty them**: what version a feature is and what it requires are facts about the process, and a second session of a game that kept running would otherwise have nothing where the first had the answer — the one group `Reset` leaves, with its bit of the mask. Streamline 1.x is refused before anything is resolved (`SpeaksStreamline2`). Families `FL_HOOK_SL_FEATURE_VERSION` (bit 15) and `FL_HOOK_SL_FEATURE_REQUIREMENTS` (bit 16), each published with its patch; neither entitles a field of a frame record. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features asked about in turn): the version — not asked **+0.58 / +0.61 / +0.58 ns**, asked **+14.82 / +14.54 / +14.47 ns**; the requirements — not asked **+0.58 / +0.63 / +0.61 ns**, asked **+20.88 / +21.01 / +20.96 ns**. A game makes these calls a handful of times. |
|
||||
| ✅ Streamline: `slIsFeatureSupported`, `slIsFeatureLoaded`, `slSetFeatureLoaded` (0.1.0-beta.45; owner decisions D129–D131) | **Whether a feature is supported, whether it is loaded, and the game switching it on and off.** Three rows, three patches. Rule 4: bare arguments and results of the calls hooked, and no vendor struct at all — the feature's id; the `sl::Result` `slIsFeatureSupported` returned, **every result**, since a refusal is the answer to that question (the original runs first, both arguments forwarded untouched); the `bool` `slIsFeatureLoaded` wrote, read only when it returned `eOk`; the `bool` the game passed to `slSetFeatureLoaded`, noted before the call. **The adapter `slIsFeatureSupported` is asked about is never read** (D131): `sl::AdapterInfo` holds the adapter's LUID or a Vulkan physical device; the detour forwards the reference and `tools/overlay-fields-check.ps1` refuses the names of its members (`deviceLUID`, `deviceLUIDSizeInBytes`, `vkPhysicalDevice`) anywhere in the Overlay and the Vulkan layer — the fixture's adapter carries a wild pointer. **Installed only where asked for** (D111), as the four rows before them. `slIsFeatureSupported` and `slIsFeatureLoaded` follow the two rows of beta.44 at the head of the table; `slSetFeatureLoaded` follows `slSetConstants`. **Kept in word 1 of the feature's slot** (region 5, layout 5 as it was): bit 2 and the result in bits 8..15, bits 3 and 4, bits 5 and 6 — the last two a session's, cleared by a new request; the rest the process's, kept (`fl_adv_fields.h` `kFeatureSessionBits`). A refused feature therefore has a slot now, with nothing in it but that word. The declarations of the three functions are the same from Streamline v2.0.0 to v2.14.16, and `sl::Result` is the same forty codes in the same order at all sixteen tags (`include/sl_result.h`, `05a3c7e3889c` … `8a844b68ff55`), so a code means the same whatever interposer answered. Families `FL_HOOK_SL_FEATURE_SUPPORTED` (bit 17), `FL_HOOK_SL_FEATURE_LOADED` (18), `FL_HOOK_SL_SET_FEATURE_LOADED` (19), each published with its patch. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs, eight features in turn): `slIsFeatureSupported` — not asked **+1.50 / +1.48 / +1.50 ns**, asked **+11.97 / +11.98 / +12.08 ns**; `slIsFeatureLoaded` — **+1.79 / +1.77 / +1.89 ns**, **+12.35 / +12.31 / +12.33 ns**; `slSetFeatureLoaded` — **+1.44 / +1.47 / +1.80 ns**, **+11.28 / +11.54 / +11.45 ns**. **`slInit` is not a row and will not be** (D129): a game calls it once, before the Overlay is in the process or before a patch can land — launch mode waits for the presentation runtime before it injects, nothing is ever patched on a game's thread (§H2), and a row that exists only for Advanced metrics waits for the Agent's request. **A stop takes about 160 ms for every patch it restores** (measured on the fixture, 0.1.0-beta.45: each `MH_DisableHook` snapshots the system's threads): twelve patches took 1.9 s, fifteen 2.4 s, and the watchdog's wait for the stop's log lines, 2 s until then, is now a quarter of a second for every patch the registry can hold. **Since 0.1.0-beta.46 (D134) a stop restores its patches under one stop of the threads**: eighteen in 76–90 ms on the fixture, where one by one they took 1.37–1.56 s (§Unhooking, Batches). |
|
||||
| ✅ Streamline: `slAllocateResources`, `slFreeResources`, `slShutdown` (0.1.0-beta.45; owner decision D130) | **The game allocating and freeing a feature's resources, and shutting Streamline down — counted, and nothing else.** Three rows, three patches. Rule 4: the feature's id is the only argument looked at; the command buffer and the viewport of the two resource calls are forwarded and never read (the fixture's command buffer is a wild pointer), and `slShutdown` has no argument. **`slFreeResources` and `slShutdown` are on a game's way out**: each detour notes the call first and then calls the original, exactly once, and runs nothing of ours after it returns; the fixture goes on calling the stub after `slShutdown`, through every detour. **Installed only where asked for** (D111); the last three Streamline rows of the table. **Kept** in word 1 of the feature's slot as two four-bit counts — allocations in bits 16..19, frees in 20..23, each stopping at 15 and never carrying into its neighbour — and, for `slShutdown`, in `FlAdvancedState.slShutdowns` (@308, the first of three reserved words; layout 5 as it was) with `FL_ADV_VALID_SL_SHUTDOWN` (bit 6 of the mask). All three are a session's: a new request clears them. Families `FL_HOOK_SL_ALLOCATE_RESOURCES` (bit 20), `FL_HOOK_SL_FREE_RESOURCES` (21), `FL_HOOK_SL_SHUTDOWN` (22). The three declarations are the same from Streamline v2.0.0 to v2.14.16. **Measured overhead** (the detours' bodies on the headers, the Overlay's flags, 20 million calls a run, three runs): `slAllocateResources` — not asked **+0.70 / +0.72 / +0.80 ns**, asked **+10.43 / +10.53 / +10.74 ns**; `slFreeResources` — **+0.61 / +0.84 / +0.58 ns**, **+10.33 / +10.57 / +10.44 ns**; `slShutdown` — not asked within the bench's noise (+0.06 / −0.12 / +0.04 ns), asked **+3.39 / +3.37 / +3.52 ns**. Inventory 23 → 26 rows; a Streamline title with Advanced metrics asked for now carries thirteen patches on the interposer, and a stop restores each in about 160 ms (the row above). **In real games (2026-11-13: six sessions, five games)** `slAllocateResources` was not called once after the attach, `slFreeResources` once in one game (Phantom Blade Zero, frame generation's) and `slShutdown` once in one (Dying Light: The Beast); no session counted a fault, and the two games that fault while closing did so at the offsets they had before these hooks. Installing the thirteen interposer patches took 0.7 s to 2.8 s of a game's start, 57 to 215 ms a patch. The owner's word on both (2026-11-13): `slAllocateResources` keeps its patch and is looked at again with more sessions (D135); installs and restores are to be batched, one stop of the threads for a batch (D134, 0.1.0-beta.46). |
|
||||
| ✅ Streamline: `slSetTag` — **and, since 2026-09-05, every tag's TYPE** (`slTagCensus`; a HUD-less / UI tag marks the present `FL_FG_DLSS_G`, rule 4: the same argument) | The **global** resource tags, where a title states the size of the buffer it is upscaling *from*: `kBufferTypeScalingInputColor`'s extent → `renderW/H` — **or, since 2026-09-05, the size the tagged `sl::Resource` declares when the extent is zero** (`TagSize` in `fl_sl_inputs.h`, shared by all three tag routes; GUID-checked; a Resource declaring no size is still the honest unknown). **Built 2026-08-15** (`FL_HOOK_UPSCALER_PARAMS`), and it is an ALTERNATIVE to the local tags in `slEvaluateFeature`'s `inputs`, not a layer over them — `sl_core_api.h:258` says global and local tags "do NOT interact", so a title using one yields nothing from the other and both are read. Published only on a frame where an evaluation was also seen, because a tag is viewport state that outlives any one frame. This row was MISSING from this table while the hook shipped, which is the gap the banner above now names |
|
||||
| ✅ Streamline: `slSetTagForFrame` — **and every tag's TYPE, as above** | The same global tags through **Streamline 2.8's frame-based entry point**, which deprecates `slSetTag`: `(const FrameToken&, const ViewportHandle&, const ResourceTag*, uint32_t, CommandBuffer*)` — the token first, then exactly `slSetTag`'s list, handed to the same tag walk. **Built 2026-09-04** (`FL_HOOK_UPSCALER_PARAMS`, its own trampoline; the family is now **published when whole** — once every tag export the loaded interposer has is patched — because publishing on the first row entitled records the second was not yet producing, 38 of 41 on the fixture: the ffx leaves' #110 defect again, fixed the same way). Measured need: Dying Light: The Beast (SL 2.8.0) published `Dlss` identity on every batch and the params bit on none across three captures, because a 2.8 title that tags per frame never calls the deprecated export. The token is not read; the frame count stays with `slGetNewFrameToken`. The installer picks this detour by SYMBOL (`kSymbolSlSetTagForFrame`, bound to the row by `static_assert`), not by family, since the two rows share a family bit and differ in signature |
|
||||
@@ -714,7 +714,7 @@ Every hook body is wrapped:
|
||||
```
|
||||
|
||||
- Any SEH exception inside our code ⇒ increment `faultCount`, record which hook, **return control to the original function** so the game continues.
|
||||
- 3 faults total ⇒ set `status = self_disabled`, ~~uninstall all hooks (`MH_DisableHook(MH_ALL_HOOKS)`)~~ restore each patch's prologue only while its bytes are still our jump (compare-and-restore per patch through `StopObserving`, §Unhooking, §H7 — `MH_ALL_HOOKS` would have removed an overlay chained after us; corrected 2026-09-27), stop writing, stay dormant. The Agent sees the flag and finalizes the session as `degraded`.
|
||||
- 3 faults total ⇒ set `status = self_disabled`, ~~uninstall all hooks (`MH_DisableHook(MH_ALL_HOOKS)`)~~ restore each patch's prologue only while its bytes are still our jump (compare-and-restore per patch through `StopObserving`, §Unhooking, §H7 — `MH_ALL_HOOKS` would have removed an overlay chained after us; corrected 2026-09-27; since 0.1.0-beta.46 the patches that are still ours come out together, under one stop of the threads — §Unhooking, Batches), stop writing, stay dormant. The Agent sees the flag and finalizes the session as `degraded`.
|
||||
- Never `__try` around the call to the original function — only around *our* code, so we never mask a game bug as ours or vice versa.
|
||||
- The trampoline call to the original is always executed exactly once, on every path, including error paths.
|
||||
|
||||
@@ -761,6 +761,55 @@ Every hook body is wrapped:
|
||||
> the shipped sequence against real MinHook patches: a full registry leaves the target's bytes untouched and
|
||||
> MinHook unasked; a stop arranged between the enable and the re-read ends with the function unpatched; a failed
|
||||
> patch gives its slot back; a slot is invisible to the walk until committed.
|
||||
>
|
||||
> **Batches, 0.1.0-beta.46 (owner decision D134): one stop of the game's threads for a group of patches.** MinHook
|
||||
> writes a jump with every other thread of the process stopped — a snapshot of the system's threads, then a
|
||||
> suspend, a context read and a resume for each of the process's — and `MH_EnableHook` / `MH_DisableHook` for one
|
||||
> target do all of that for one jump. The owner's logs of 2026-11-13 put a number on it: the thirteen Streamline
|
||||
> patches took 0.74 s to 2.8 s of a game's start, 57 to 215 ms each, and a stop restored its patches the same way.
|
||||
> MinHook 1.3.4 can queue — `MH_QueueEnableHook` / `MH_QueueDisableHook` mark a hook, `MH_ApplyQueued` executes
|
||||
> every mark under one stop — and `fl_patch_registry.h` now has the two sequences that use it:
|
||||
> `fl::patch::Batch` (`Add`: slot and create, nothing marked; `Commit`: enable them all) and
|
||||
> `fl::patch::RestoreAll`, which is the stop's walk. `InstallUpscalerHooks` queues every row a tick finds
|
||||
> something for and commits once, before the families that are published "when whole"; `InstallRtHooks` batches
|
||||
> its two; `StopObserving` calls `RestoreAll`. A patch's `HOOK_INSTALLED` line, family bit and latch still come in
|
||||
> that order and only once it is in. The loader detour, OpenGL and the three DXGI patches of init are as they were.
|
||||
>
|
||||
> **What the queue makes dangerous, and what the code therefore never does** (the plan was reviewed against
|
||||
> `hook.c` before a line was written, and its first form was refused). `MH_ApplyQueued` applies **every** hook
|
||||
> whose mark differs from its state — the process has one table, not one per caller. So (1) **no mark is ever left
|
||||
> standing**: a hook that failed to enable has its mark removed, or the next apply — the stop's own — would enable
|
||||
> it; (2) **only a patch that is still ours is ever marked for a restore** (`StillOurs`, as before; §H7), and
|
||||
> nothing is marked "all" — the refused draft marked everything and then un-marked what it must not restore, and
|
||||
> un-marking a hook that is already out marks it for *enabling*: the stop would have put a patch back in after the
|
||||
> stop; (3) **mark, apply and commit happen inside a gate** (`MinHookEngine::BeginQueue`, a slim lock taken
|
||||
> exclusively) so the watchdog's apply cannot execute the stop's marks nor the stop's the watchdog's. The gate is
|
||||
> held for one apply and never across a symbol lookup, which takes the loader's lock. It is the one lock in the
|
||||
> Overlay, and it is on no hook body's path: the only way from a hook to it is the stop itself, which already
|
||||
> waited for MinHook's own lock and a stop of the threads for every patch. Its owner re-enters it without
|
||||
> waiting. **The verdict on an install is the engine's, not the bytes'**: a foreign overlay patching over us a
|
||||
> moment after the apply would read as "not in", and treating that as a failure would mark a restore nobody had
|
||||
> compared. `MH_ApplyQueued` stops at the first hook that fails and says only that one did; the ones after it
|
||||
> are then enabled — or, in the stop, restored — one at a time, so one bad patch still costs one patch.
|
||||
> The write-then-read pair is unchanged: the stop clears the flag and then walks; `Commit` commits its slots and
|
||||
> then re-reads the flag, and takes out — compared first — what it put in when the flag is clear. A stop that
|
||||
> lands before the commit enables nothing.
|
||||
>
|
||||
> **Measured** on `hook-harness`'s Streamline target, the development PC, three runs before and after (`fl_guard`
|
||||
> `[advanced]` prints them): the nine Advanced-only patches went in one by one over 0.60 s / 0.70 s / 0.60 s
|
||||
> from the first log line to the ninth, 76–88 ms each; as one batch they take **81 / 90 / 78 ms**. The stop restored
|
||||
> eighteen patches in 1.37 s / 1.56 s / 1.37 s; under one apply, **77 / 90 / 76 ms** — and from the Agent's request
|
||||
> to `UNHOOKED`, 1.27–1.48 s became 94–110 ms. One stop of the threads costs what it cost for one patch, whether it
|
||||
> covers four, nine or eighteen. A new log line says so in the field: `PATCH_BATCH install` / `restore`, `a` the
|
||||
> microseconds, `b` the patches. **Not measured:** a real game — how long one stop of the threads is with a few
|
||||
> hundred of them, and whether any title minds patches arriving together (owner-only item 44). One more thing the
|
||||
> queue changes for the better: MinHook's single-target disable does not move a thread that is suspended inside
|
||||
> the patched bytes (`hook.c` passes the enable action to its thread fix-up in both directions); the queued apply
|
||||
> does. ctest `fl_unhook_inline` drives `Batch` and `RestoreAll` against real MinHook (three in under one apply,
|
||||
> a duplicate target refused without holding the others up, a foreign patch left byte for byte) and against a
|
||||
> model of MinHook's table for what real MinHook cannot be made to do on demand: an apply that fails halfway or
|
||||
> not at all, a stop inside the apply, a committed patch that is already out — the refused draft's failure — and
|
||||
> that no mark is ever standing or made outside the gate.
|
||||
|
||||
~~`FlRequestUnhook()` (or the control flag) ⇒ `MH_DisableHook(MH_ALL_HOOKS)`, restore vtable entries **only where they are still ours**, flush the ring, set status.~~ *(Corrected 2026-10-04: both reach `StopObserving` — compare-and-restore per patch as the note above says, then the status; there is no `MH_ALL_HOOKS`, no vtable entry and no ring flush. The watchdog flushes the native log on its way out.)* **The DLL is not `FreeLibrary`'d from the live process** — a thread could still be inside a trampoline. It goes dormant and unloads with the process. This is deliberate and documented.
|
||||
|
||||
@@ -789,6 +838,12 @@ before it. And when the slot has changed, going dormant costs nothing: we stay
|
||||
loaded anyway, and our detour remains in someone else's chain doing nothing
|
||||
harmful.
|
||||
|
||||
> **Said plainly, 2026-11-13: for the inline patches that re-check has never been made.** MinHook owns the write
|
||||
> window — it stops the threads, changes the protection and writes — and `StillOurs` is asked before it is called,
|
||||
> not inside. Between the two a foreign overlay could patch over us, on a thread MinHook has not stopped yet. The
|
||||
> batches of 0.1.0-beta.46 neither close that window nor widen it: the comparison and the write are apart by one
|
||||
> stop of the threads, as they were for each patch, once instead of once a patch.
|
||||
|
||||
Verified by `hook-harness --probe-unhook` (ctest `fl_unhook_preserves_foreign`),
|
||||
which simulates the foreign hooker rather than depending on RTSS being
|
||||
installed, so it is deterministic and runs on CI. Both halves are asserted: we
|
||||
@@ -810,7 +865,8 @@ No logging in hook bodies. A small fixed-size in-memory ring of structured event
|
||||
> writing), and since beta.42 `PATCH_FAILED` (a patch that did not go in, once per target and reason — §Unhooking)
|
||||
> and `FFX_DISPATCH`, `FFX_QUERY`, `UPSCALE_ROUTE`, `RUNTIME_CENSUS` (the note at the end of this section), and
|
||||
> since beta.43 `FFX_CONFIGURE` — each configure type a hooked ffx module was handed, in a process where
|
||||
> `ffxConfigure` is hooked at all (one asked for Advanced metrics).
|
||||
> `ffxConfigure` is hooked at all (one asked for Advanced metrics) — and since beta.46 `PATCH_BATCH`: one line an
|
||||
> apply, `install` or `restore`, `a` the microseconds it took and `b` the patches it covered (§Unhooking, Batches).
|
||||
> **Three flush points — four since beta.42, the same note —, none on a present path:** the end of `InitThread` (so the
|
||||
> file exists from the start of the session and a crash mid-session still leaves it), the watchdog when
|
||||
> `FlControlBlock.logFlushRequested` changes (a counter the Agent bumps at session end; nothing clears it),
|
||||
@@ -822,7 +878,7 @@ No logging in hook bodies. A small fixed-size in-memory ring of structured event
|
||||
> it reads 0. When the stop ran on a presenting thread — `MayObserve`'s one-frame safety stop — the watchdog's one
|
||||
> final flush could run while that thread was still writing, and the lines after it (the kernelbase loader detour is
|
||||
> the last patch) reached the ring after the last flush ever made. The stop now says when its last line is in, and
|
||||
> wakes the watchdog; the final flush waits for that, bounded at 2 s, then writes `STOP_FLUSHED`. And each slot has a
|
||||
> wakes the watchdog; the final flush waits for that, bounded at 2 s *(a quarter of a second for every patch the registry can hold since beta.45; the stop is one apply since beta.46 and the bound is for its fallback)*, then writes `STOP_FLUSHED`. And each slot has a
|
||||
> commit word written after its fields: `LogNote` claims a slot with one `fetch_add` and fills it afterwards, so a
|
||||
> flush on another thread could print a slot still being filled. A flush now prints only slots whose writer has
|
||||
> finished — an ordinary flush stops at the first that is not, for the next one; the final flush names it in a `#`
|
||||
|
||||
@@ -1549,6 +1549,13 @@ probe never showed a deadlock.
|
||||
> real-game leg — a title that pulls Streamline or D3D12 in lazily, hooked through the wake — which the
|
||||
> `loader detour:` report line will show as a non-zero wake count with the family present from the first
|
||||
> bucket.
|
||||
>
|
||||
> **0.1.0-beta.46 (owner decision D134): one suspension for a batch, and the rule is as it was.** The rows a
|
||||
> watchdog tick finds are enabled under one `MH_ApplyQueued` — one stop of the threads where there was one a row
|
||||
> (`17_HOOK_ENGINE` §Unhooking, Batches). Still only on the watchdog, never from the detour and never on a game's
|
||||
> thread; the gate around the queue is not held across a symbol lookup, so it is never held with the loader's lock
|
||||
> wanted. What a stop of the threads costs in a real game was read from the owner's logs of 2026-11-13: 57 to
|
||||
> 215 ms, thirteen times over for a Streamline title until this release.
|
||||
|
||||
### H11 ◐ · XeFG and FSR3-FG identity — **AMD built 2026-09-04 through the ffx-api leaves, complete 2026-09-06; Intel closed by licence; FSR 3.0 host route built 2026-09-05**
|
||||
|
||||
@@ -1863,7 +1870,7 @@ Moved verbatim, in this order.
|
||||
| M12 ❓ | **Advanced metrics — which NVAPI rows answer on real hardware (D101, 2026-11-11).** `18_GPU_VENDOR_APIS` §The inventory lists sixty `nvapi.` rows whose reach is `Agent`. They are declared in the vendored headers; **none has been called on a GPU**, and CI has no driver, so it never takes that branch. Unknown per row: whether the RTX 5080 on the current driver answers or returns `NVAPI_NOT_SUPPORTED` (the memory-temperature target already does not exist on that card). | **The measurement is the bridge's probe on the owner's PC**, then the page itself (the release's owner-only item). Pre-committed: a call that does not answer → that row is N/A with NVAPI's own status as the reason, and nothing is put in its place; a call that hangs or faults twice → the row is off for the session (§Runtime policy); a value that contradicts the vendor's own tool → the row is withheld until it is explained. **Half answered the same day, by the bridge's own test on the dev box** (ctest `fl_nvapi_bridge`, AVAILABLE branch; RTX 5080): every fact answers (`present = 0xFFFFF`), eight of ten live groups answer (`0x33F` — no board and no power-supply temperature sensor on this card: N/A, by the first pre-committed outcome), the display answers its four groups, the global profile lists 24 settings; figures in `18_GPU_VENDOR_APIS` §L3. **Still open**: the same values on the page beside the vendor's own tool, and the session rows (`nvapi.session.*`), which need a game. **And one thing seen once and not explained**: in one test run of about a dozen that day, `FlNvReadLive` came back with no field at all although `FlNvReadFacts`, a moment earlier in the same process, had answered everything; nine further runs did not show it. A handle the driver invalidated is the usual cause of that shape, and nothing here re-enumerates after `FlNvInit`. Pre-committed for the reader that owns the thread: two readings in a row with no field → release and initialise the bridge again, once, and say so in the log; if that does not bring the fields back the layer is off for the session, as any layer that fails twice is. |
|
||||
| M13 ❓ | **Advanced metrics — LibreHardwareMonitor's CPU, memory, motherboard and storage groups, elevated, with PawnIO (D103, 2026-11-11).** Never opened by any build: §M10's elevated run has not been taken either, and this is a larger surface — a sensor chip on the LPC bus, the embedded controller, SPD over SMBus, SMART. Unknown: whether each group opens on the owner's board, what a refresh costs, whether opening the storage group touches removable drives (this PC once had a failing USB drive), and whether any group enables a privilege (`PrivilegeFootprintTests`). | **One elevated run with the probe verb, before the option exists.** Pre-committed: the storage group cannot be opened without touching removable drives → `lhm.storage.*` stays N/A in beta.39 and its reach reads `Deferred`; a node that throws twice → skipped for the session; the Agent above 1% of one core or 150 MB with the option on (NFR-2) → the slow groups are read less often or dropped before the release; a privilege enabled by a group → that group is not opened, and the owner is asked. **Two of the four answered 2026-11-11, before the option exists.** (1) **Storage: not opened, by the first outcome.** LibreHardwareMonitor 0.9.6's `StorageGroup` lists every drive through DiskInfoToolkit's `ReloadStorages` with no filter by bus and follows drives plugged in later — it cannot be opened without touching removable drives. `lhm.storage.*` reads `Deferred`, and `LhmGroups` has no member for it. (2) **Cost, unelevated, measured with `probe-advanced`** on the dev box: one refresh of the graphics-card group alone is 14 ms of processor time (62 ms elapsed) — 1.4% of one core at one a second, above NFR-2 — and one NVAPI read 0.4 ms. By the third outcome the sensor library is read every fifth tick (0.28%). **Still open, and the owner's**: the same probe as administrator with PawnIO — whether the processor, memory and motherboard groups open on this board, what they cost, and `PrivilegeFootprintTests`' new case on a token that holds the privileges (CI's does; the dev box's unelevated run passes by construction). **The first run was taken on 2026-11-12, by the owner, in ordinary use** (0.1.0-beta.40, the Agent as administrator with PawnIO, an i7-14700KF on a board with an IT8689E chip, an RTX 5080), and read here from a copy of the ledger and the Agent's log, not from a probe. **The groups open and read**: nine of ten sessions stored 119 processor series (a clock and a load per thread, temperatures, powers, voltages), 14 memory series and 21 motherboard series (six fans, six temperatures, nine voltages) beside the card's 41 — 195 from the sensor library in all. **No value was compared with another tool**; that is still the owner's. **Two faults, one cause** (`Infrastructure.Telemetry.LhmLibrary`): the Agent held up to three `Computer`s at once, and the library keeps the driver it reads the processor through and its bus mutexes per process — closing one `Computer` let go of them under the others. After seven sessions the Advanced reader's processor device threw `NullReferenceException` twice and was left alone (the page lost the processor until the reader reopened); once a session's start met another instance's close, the reader's `Open` threw `ObjectDisposedException`, and that session stored 17 series instead of 212. **Fixed 2026-11-12**: opens and closes are serialised and a `Computer` is parked, not closed, while another is in use. The cause is read from the log's timing and was not reproduced — it needs this elevation — so **whether the faults are gone is the owner's next sessions to show**: no `advanced: a device is left alone` and no `did not open` in the Agent's log. **First evidence, 2026-11-12, 0.1.0-beta.41, the same PC:** seven sessions between 06:38 and 07:01 with no `advanced:` line at all, each with the option on storing 212 or 213 series; on beta.40 that morning the processor device faulted out after each of six sessions (04:34–05:07) — thirteen of sixteen over the night. The reader failing to open was seen once in sixteen, so this is not yet enough to call that one gone. Still open: any value beside another tool. |
|
||||
| M16 ✅ | **The L2 telemetry layer's cost — the first number, and it is above NFR-2 (found 2026-11-11, measuring something else).** `LhmTelemetrySource` refreshes LibreHardwareMonitor's graphics-card group once a second in every recorded session. `probe-advanced` measured that refresh, through the same library and the same group, at **14 ms of processor time** on the dev box (RTX 5080, 41 mapped sensors, about twenty of them the Direct3D engine nodes the library enumerates per card) — 1.4% of one core, where NFR-2 allows the whole Agent 1% during capture and `14_TESTING` §Hook overhead's Agent figure has never been measured. This is a measurement of the call, not yet of a session: L2's own poller was not instrumented. | **Measure L2 in a session** (the Agent's processor time over a ten-minute capture, telemetry at 1000 ms and at 2000 ms). Pre-committed: at or under 1% → this row closes with the number; above → the owner chooses between a slower default for `telemetry.interval_ms`, reading the sensors the layer keeps from NVAPI on NVIDIA cards (L3 already has most, at 0.4 ms), or amending NFR-2 to what is measured. Not decided here, and nothing about L2 changes in the Advanced-metrics train. **Measured in a real Agent, 2026-11-11 (owner decision D110), and answered (D117).** `tools/agent-cost.ps1` runs the shipped `FrameLedger.Agent.exe --console capture` against a copy of hook-harness in a scratch data folder — a session that is not hooked, so the telemetry poller runs as in every session and nothing drains frames — and reads the Agent process's own processor time at exit; the cost per second is the slope between a 45 s and a 165 s session, two runs of each. Dev box (RTX 5080, not elevated, layers `l1+lhm+nvapi`): **19.3 ms of processor time per second of session = 1.93 % of one core with Advanced metrics off** (2,312 and 2,312 ms over 45 s; 4,594 and 4,656 ms over 165 s), **20.4 ms = 2.04 % with it on** (2,984 and 3,000; 5,547 and 5,344); peak working set 113 MiB and 119 MiB. A first pass with 30 s and 90 s sessions gave 1.56 % and 2.21 % — its two short runs differed by 670 ms, which is why the lengths were raised. So the probe's number holds in a session: the Agent's steady cost is about twice NFR-2's 1 %, nearly all of it the layer every session has always used, and the new option adds about a tenth of a percent. **The owner's answer: NFR-2 is amended to ≤ 2.5 % of one core** — the limit had never been measured, the sensors keep their one reading a second, and nothing in the code changes. Not measured: a hooked session (the drain's cost on top), a session with the Agent elevated and PawnIO's groups open, another PC. |
|
||||
| M14 ❓ | **Reflex latency per frame — is there a route within rules 4 and 5? (Train C, 2026-11-11.)** `17_HOOK_ENGINE` §Memory / latency names hooks on `NvAPI_D3D_SetSleepMode` / `SetLatencyMarker` and a call to `NvAPI_D3D_GetLatency`. NVAPI resolves all three through `nvapi_QueryInterface` by id — they are not exports, so a hook on them is a patch at an address learned at run time, the class refused on 2026-08-09. The route to try first needs no hook: the Overlay's own background thread **calls** `GetLatency` with the device of the swap chain it already hooks, once a second (the call returns the last 64 frames' reports). Unknown: whether calling into the driver from that thread is safe on every device kind, what it costs, what it returns when the game never enabled Reflex, and what it means for the Disclaimer's sentence about that thread. | **A spike on `hook-harness` and a stub first, then one real title.** Pre-committed: no route without a patch at a run-time address or a loader-lock call on the game's thread → Reflex stays N/A and the page says why; overhead above NFR-1 → the same. The owner says go or no on the spike's result. **2026-11-12 — the reading that comes before that spike is `spike-notes` §30** (owner decision D130: a document first, beside 0.1.0-beta.45; nothing was run). It finds: a hook on NVAPI's latency functions is the refused class, and a hook on Streamline's Reflex and PCL functions is train D's wrapper (§M15) — and would miss a game that fetched them before the attach, as `slInit` is missed (D129); the Overlay calling `slReflexGetState` itself breaks the thread contract the vendor's header states; **what remains is the route named in this row**, the Overlay calling two driver getters with the game's device, and a no-injection ETW route that gives the game-side markers only and makes the game post messages to its own window. Corrected there: `nvapi64.dll` exports **two** functions on the dev box (`nvapi_Direct_GetMethod` beside `nvapi_QueryInterface`), not one. The go or no is the owner's, and a go needs the owner's ruling that calling a driver getter with the game's device is inside rule 4. **2026-11-13 — the owner answered (D132, D133).** Route D goes to the spike this row names, on `hook-harness` and a stub `nvapi64.dll`, with the ruling: a driver's read-only getter called with the device of the swap chain the Overlay hooks is inside rule 4 (`CLAUDE.md`, the rule's note of that day). No real game before the owner has seen the result, and nothing shipped changes for the spike (`spike-notes` §31, written after 0.1.0-beta.46). Route C is **refused**; the ETW route **stays closed**, and §G is not reopened. |
|
||||
| M14 ❓ | **Reflex latency per frame — is there a route within rules 4 and 5? (Train C, 2026-11-11.)** `17_HOOK_ENGINE` §Memory / latency names hooks on `NvAPI_D3D_SetSleepMode` / `SetLatencyMarker` and a call to `NvAPI_D3D_GetLatency`. NVAPI resolves all three through `nvapi_QueryInterface` by id — they are not exports, so a hook on them is a patch at an address learned at run time, the class refused on 2026-08-09. The route to try first needs no hook: the Overlay's own background thread **calls** `GetLatency` with the device of the swap chain it already hooks, once a second (the call returns the last 64 frames' reports). Unknown: whether calling into the driver from that thread is safe on every device kind, what it costs, what it returns when the game never enabled Reflex, and what it means for the Disclaimer's sentence about that thread. | **A spike on `hook-harness` and a stub first, then one real title.** Pre-committed: no route without a patch at a run-time address or a loader-lock call on the game's thread → Reflex stays N/A and the page says why; overhead above NFR-1 → the same. The owner says go or no on the spike's result. **2026-11-12 — the reading that comes before that spike is `spike-notes` §30** (owner decision D130: a document first, beside 0.1.0-beta.45; nothing was run). It finds: a hook on NVAPI's latency functions is the refused class, and a hook on Streamline's Reflex and PCL functions is train D's wrapper (§M15) — and would miss a game that fetched them before the attach, as `slInit` is missed (D129); the Overlay calling `slReflexGetState` itself breaks the thread contract the vendor's header states; **what remains is the route named in this row**, the Overlay calling two driver getters with the game's device, and a no-injection ETW route that gives the game-side markers only and makes the game post messages to its own window. Corrected there: `nvapi64.dll` exports **two** functions on the dev box (`nvapi_Direct_GetMethod` beside `nvapi_QueryInterface`), not one. The go or no is the owner's, and a go needs the owner's ruling that calling a driver getter with the game's device is inside rule 4. **2026-11-13 — the owner answered (D132, D133).** Route D goes to the spike this row names, on `hook-harness` and a stub `nvapi64.dll`, with the ruling: a driver's read-only getter called with the device of the swap chain the Overlay hooks is inside rule 4 (`CLAUDE.md`, the rule's note of that day). No real game before the owner has seen the result, and nothing shipped changes for the spike (`spike-notes` §31, written after 0.1.0-beta.46). Route C is **refused**; the ETW route **stays closed**, and §G is not reopened. **2026-11-13 — the harness spike is done (`spike-notes` §31), and none of its stop conditions fired.** With a stand-in module: nothing is called or loaded when `nvapi64.dll` is absent, a missing getter is refused whole, an error and a report of nothing read as what they are, and a call the driver holds for seconds stops only the thread that made it — so not the watchdog. With the installed driver (32.0.16.2114, RTX 5080), in the probe's own process and with the probe setting the markers a game would: no fault before `NvAPI_Initialize`, without markers, or across 38 million reads beside a marker-setting thread; a call costs half a microsecond to a microsecond and a half; the report is readable from markers alone, in microseconds; and the Direct3D 12 **device** — the object the Overlay already holds — is what the driver takes. What only a game can say is unanswered: a game's own device, a real report, another driver. **The owner's next word is go or no for one real title**; a go is a plan of its own first. |
|
||||
| M15 ❓ | **The Streamline state behind `slGetFeatureFunction` — re-examined, not reopened (Train D, 2026-11-11).** The owner asked for the refusal in `handoff/history/p0-queue-1-6.md` to be looked at again. `18_GPU_VENDOR_APIS` §The trains states the route to try (hook the export, hand back a wrapper for a fixed list of names) and what it raises: the wrapper is a write to what the game receives, which rule 4 forbids as written; a wrapper must outlive the Overlay's unhook; a game that fetched its functions before the hook existed is never seen. | **A written design against each of the five grounds, then a spike.** Pre-committed: any ground unanswered → the route stays refused, and `sl.dlssg.*`, `sl.reflex.*` and the rest of that block read N/A with "refused" as the reason. Proceeding needs the owner's amendment of rule 4, asked with the rule quoted. |
|
||||
| M10 ✅ | ~~PDH `\GPU Engine(*)\Utilization Percentage` summed across engines does not reproduce the Task Manager figure the doc invokes. Decide what we actually report and label it accordingly~~ **Decided 2026-09-09 (PR-E1): L1 does not read the engine counters at all.** `LoadPct` is L2's vendor-reported `GPU Core` load (measured ✓ on NVIDIA, §M5 row R1) and is labelled *GPU load (vendor)* wherever it is shown; on a machine without L2 the field is N/A, never a sum that is not the number the user expects. What L1 does read from PDH is one counter, `\GPU Adapter Memory(luid_…_phys_0)\Dedicated Usage`, bound by LUID — the figure Task Manager labels "Dedicated GPU memory", measured 1301 MB at an idle desktop on the RTX 5080. Reopening this needs a measurement of `max(engine)` against Task Manager's own number, not a decision |
|
||||
|
||||
|
||||
+122
-147
@@ -84,6 +84,7 @@ owner-only items stay below; the history of every train, the passed owner-only i
|
||||
| `§beta.42`, what the owner's seven sessions on beta.42 showed (D121 answered, the guard's lost launches), beta.43's design as planned | [`handoff/history/0.1.0-beta.42.md`](handoff/history/0.1.0-beta.42.md) |
|
||||
| `§beta.43`, what the owner's nine sessions on beta.43 showed, session by session (item 41), the traps of that train | [`handoff/history/0.1.0-beta.43.md`](handoff/history/0.1.0-beta.43.md) |
|
||||
| `§beta.44`, what the owner's eight sessions on beta.44 showed, session by session (item 42), this release's facts, the traps of that train | [`handoff/history/0.1.0-beta.44.md`](handoff/history/0.1.0-beta.44.md) |
|
||||
| `§beta.45`, what the owner's seven sessions on beta.45 showed, session by session (item 43), that release's facts and SonarCloud's gate on its commit, the traps of that train | [`handoff/history/0.1.0-beta.45.md`](handoff/history/0.1.0-beta.45.md) |
|
||||
| `§Owner-only`, an open item | [§Owner-only](#owner-only--no-pr-can-close-these) below |
|
||||
| `§Owner-only`, a passed item (3, 12, 14–19, 38, 39) | [`handoff/owner-only-passed.md`](handoff/owner-only-passed.md) |
|
||||
| `§Traps`, `§Two corrections carried forward` | [`handoff/traps.md`](handoff/traps.md) |
|
||||
@@ -91,168 +92,112 @@ owner-only items stay below; the history of every train, the passed owner-only i
|
||||
|
||||
---
|
||||
|
||||
## **START HERE** — 2026-11-12, 0.1.0-beta.45: six more of Streamline's calls, hooked only where asked; `slInit` stays out; the Reflex spike as a document
|
||||
## **START HERE** — 2026-11-13, 0.1.0-beta.46: patches go in and come out under one stop of the game's threads; Reflex route D goes to a harness spike
|
||||
|
||||
*Status is `docs/changelog/0.1.0-beta.45.md`; this is what no other file carries.* The owner ran eight sessions on
|
||||
beta.44 the evening it was released and said: add the three new ones, update, go on. They were read from a copy of
|
||||
the ledger and the logs (#426); asked to reopen D112, the owner was shown why `slInit` cannot be seen and chose to
|
||||
leave it out (D129), chose six other calls for one release (D130), and approved the plan with Privacy Policy 2.19's
|
||||
wording. Four pull requests and this one: #427 (`slIsFeatureSupported`, `slIsFeatureLoaded`, `slSetFeatureLoaded`
|
||||
in the Overlay; D129–D131), #428 (`slAllocateResources`, `slFreeResources`, `slShutdown`), #429 (the Agent, the
|
||||
App, Privacy Policy 2.19), #430 (train C's spike, a document: `spike-notes` §30). **What the eight sessions on
|
||||
beta.44 showed, session by session, is [`handoff/history/0.1.0-beta.44.md`](handoff/history/0.1.0-beta.44.md)**;
|
||||
what each pull request built is [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory (the two rows of the six
|
||||
calls, with their measured cost) and [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B (the fourth step).
|
||||
*Status is `docs/changelog/0.1.0-beta.46.md`; this is what no other file carries.* The owner ran seven sessions on
|
||||
beta.45 the day after it was released and said: check the logs and go on. They were read from a copy of the ledger
|
||||
and the logs (#433), and the same day the owner took four decisions on what they showed (D132–D135) and approved
|
||||
the plan. Two pull requests and this one: #433 (what the sessions showed; the decisions; rule 4's note in
|
||||
`CLAUDE.md`), #434 (the batches, D134). **What the seven sessions on beta.45 showed, session by session, is
|
||||
[`handoff/history/0.1.0-beta.45.md`](handoff/history/0.1.0-beta.45.md)**; what the batches are, what the queue
|
||||
makes dangerous and what was measured is [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Unhooking, *Batches*.
|
||||
|
||||
### What this release decided, beyond D129–D131
|
||||
### What this release decided, beyond D132–D135
|
||||
|
||||
- **Everything the six calls give is word 1 of a feature's slot, and one reserved word.** Bits 2–4 the two answers
|
||||
(supported, with the `sl::Result` in bits 8..15; loaded and its value), bits 5–6 the game switching the feature
|
||||
off and on, bits 16..19 and 20..23 two counts that stop at fifteen and never carry; `slShutdowns` took the first
|
||||
of three reserved words (@308). Layout 5 and schema 23 as they were. **The answers are the process's and a new
|
||||
request keeps them; the switching, the counts and the shutdowns are a session's and a new request clears them.**
|
||||
- **A refusal is the answer.** `slIsFeatureSupported`'s detour calls the original first and keeps whatever it
|
||||
returned; the page names it by NVIDIA's enumerator (forty codes, the same order at sixteen upstream tags from
|
||||
v2.0.0 to v2.14.16), `result <n>` past the list, 255 for a code a byte could not carry.
|
||||
- **The two calls on a game's way out note the call, then call the original, and run nothing after it** —
|
||||
`slFreeResources` and `slShutdown`. The fixture shuts Streamline down and goes on using the stub through every
|
||||
detour.
|
||||
- **The adapter is never read** (D131), and the build refuses the names of `sl::AdapterInfo`'s members in the code
|
||||
loaded into a game (`overlay-fields-check`); the fixture hands a wild LUID pointer.
|
||||
- **A stop restores its patches one after another, about 160 ms each.** MinHook stops every thread of the process
|
||||
for each `MH_DisableHook`. With six more patches the stop's last log lines were cut at the two seconds the
|
||||
Overlay waited for them; the wait is now sized to the patch table (`250 ms × kMaxPatches`). The patches were
|
||||
always restored; `UNHOOKED` is written after the last. **Not changed, and proposed**: queueing the restores (and
|
||||
the installs) so the threads are stopped once — a change to the hook engine's order of operations, which wants
|
||||
its own pull request, its own measurement and the owner's word. Until then a stop in a Streamline game with
|
||||
Advanced metrics on takes two to three seconds on the thread that stops.
|
||||
- **Six calls are one sentence on the page**, each by its function's name under which of three things became of
|
||||
it; a row stored before this release has none of the six and no such sentence.
|
||||
- **`AdvancedReach.BeforeAttach` is a reason of its own** for `sl.init.preferences`: not "a later release". No
|
||||
catalog entry carries `NewHook` any more; the value stays, for rows a later train may add.
|
||||
- **Where the rows sit in the table** (rows are patched in its order): the two questions after beta.44's two, at
|
||||
the head; `slSetFeatureLoaded` after `slSetConstants`; the three counted calls last of the Streamline block.
|
||||
- **Train C's spike is a reading** (`spike-notes` §30): hooking NVAPI's or Streamline's latency functions is
|
||||
refused or is train D's wrapper; the Overlay calling `slReflexGetState` breaks the vendor's thread contract;
|
||||
what remains is the Overlay calling two driver getters with the game's device, and a no-injection ETW route
|
||||
that gives half the number. It ends in three questions that are the owner's.
|
||||
- **The first design was wrong, and reading MinHook's source before writing a line is what found it.** It marked
|
||||
every hook for disabling and then un-marked the ones it must not restore. `MH_ApplyQueued` applies every hook
|
||||
whose mark differs from its state; un-marking a hook that is already out marks it for *enabling*, and the stop's
|
||||
own apply would have put a patch back in after the stop — logged as "declined", with the status `UNHOOKED`. The
|
||||
rules that replaced it are in `fl_patch_registry.h`: no mark left standing, only a patch that is still ours
|
||||
marked for a restore, nothing marked "all", and mark–apply–commit inside a gate.
|
||||
- **The gate is the Overlay's one lock, and it is on no hook body's path.** A slim lock, exclusive, held for one
|
||||
apply, never across a symbol lookup (the loader's lock). The one way from a hook to it is the stop, which always
|
||||
waited for MinHook's own lock and a stop of the threads. Its owner re-enters it without waiting: a slim lock taken
|
||||
twice by one thread never returns.
|
||||
- **The verdict on an install is the engine's, not the bytes'.** Reading the target back after the apply would take
|
||||
a foreign overlay that patched over us in that instant for a failure, and mark a restore nobody had compared.
|
||||
- **An apply stops at its first failure and says only that one failed.** The hooks after it are enabled — in the
|
||||
stop, restored — one at a time, so one bad patch still costs one patch, and a stop still takes everything out.
|
||||
- **One stop of the threads costs what it cost for one patch**: 77–91 ms on the fixture for four, nine or eighteen.
|
||||
What it costs in a game with a few hundred threads is not known; the `PATCH_BATCH` line's `a=` is there to say.
|
||||
- **Init's three DXGI patches, the loader detour and OpenGL are as they were** — three already went in together,
|
||||
the other two are one each. Ray tracing's two are a batch of their own, apart from the upscaler rows', so that a
|
||||
batch's size in a test does not depend on which tick a D3D12 device appeared in.
|
||||
- **`fl_guard`'s timing assertion is on the restore only** (under a second for eighteen patches): the time from an
|
||||
Advanced request to its families includes the wait for the watchdog's tick, and batching changes the tick's
|
||||
phase, so that number went *up* in the test while the install itself went from 0.6 s to 0.08 s. The install is
|
||||
asserted by count — every lazily installed patch under a `PATCH_BATCH` line — not by time.
|
||||
- ~~**The spike of route D is still to be written**~~ **The spike of route D was run the same day** (`spike-notes`
|
||||
§31; `tools/fl-probe-reflex`, ctest `fl_reflex_probe_stub`): a decision table written before the runs, a stand-in
|
||||
`nvapi64.dll`, then the installed driver in the probe's own process. None of §30's stop conditions fired. Two
|
||||
things it decided that a plan must keep: **the call belongs on the presenting thread, once a second** — a call
|
||||
the driver holds stops the thread that made it, so not the watchdog, and at a microsecond or so it needs no thread
|
||||
of its own — and **the newest frames of a report are not final** (one run read a span of half an hour in the
|
||||
newest frame). Rule 4's note (D132) is in `CLAUDE.md`; nothing shipped calls a driver.
|
||||
|
||||
### Traps this train left
|
||||
|
||||
- **The catalog table of `18_GPU_VENDOR_APIS` is compared with the catalog row for row by a test**: a catalog
|
||||
entry and its row go in the same commit, or the Application tests are red.
|
||||
- **Qodana's native report again found an index into the feature slots computed as a 32-bit product** (#427, the
|
||||
harness's probe): write `size_t{2} * FL_ADV_FEATURE_WORDS`. It is advisory and auto-merge does not wait for it;
|
||||
both reports were read before each merge.
|
||||
- **A second `region` inside the probe's block is C4456**, and warnings are errors: name the inner one otherwise.
|
||||
- **A test method over sixty lines is MA0051** in the test projects too; split the assertions by what they cover.
|
||||
- **The injected test waits for the stop**: with eighteen patches a stop takes about three seconds, so its wait is
|
||||
200 iterations.
|
||||
- **The shell tool refuses `sleep N; command`**: wait in a background `until` loop.
|
||||
- **After a lower pull request is squashed**, `git diff <old tip> origin/main` empty proves the squash is the
|
||||
branch; then `git rebase --onto origin/main <old tip> <next branch>` and a forced push with lease.
|
||||
|
||||
### What the owner's seven sessions on beta.45 showed (2026-11-13)
|
||||
|
||||
The owner ran seven sessions on six games the day after the release and said: check the logs and go on. Read from
|
||||
a copy of the ledger (sessions 190–196), the seven overlay logs, the Agent's log and Windows' application log —
|
||||
no FrameLedger binary was run against the owner's data. **Every session is hooked, `normal`, with no fault
|
||||
counted, no dropped record and no `PATCH_FAILED`; the count of early ends is 0 on all six games.** The update
|
||||
showed the terms once: Privacy Policy 2.19 was accepted at 07:23:36.
|
||||
|
||||
| Game (session, length) | Interposer | `slIsFeatureSupported` | `slIsFeatureLoaded` | `slSetFeatureLoaded` | allocate | free | shutdown |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Phantom Blade Zero (190, 2 h 48 min; 191, 1 h 32 min) | 2.14.1 | **read** — Reflex, DLSS frame generation, PCL `eOk`; ImGUI and DeepDVC `eErrorFeatureMissing` | **read** — Reflex, frame generation *on* | not called | not called | **read** — frame generation, 1 | not called |
|
||||
| Cyberpunk 2077 (193, 7 min) | 2.14.1 | **read** — frame generation, DLSS, ray reconstruction, Reflex `eOk`; NIS `eErrorFeatureMissing` | **read** — the four *on* | **read** — the four, *on and off* | not called | not called | not called |
|
||||
| Dying Light: The Beast (194, 4 min) | 2.8.0 | **read** — DLSS, frame generation, PCL, Reflex, NIS `eOk` | not called | **read** — all five, *on and off* | not called | not called | **read** — 1 |
|
||||
| Hogwarts Legacy (195, 4 min) | 2.14.16 | **read** — frame generation, Reflex, DeepDVC, DLSS 5's `kFeatureDLSS_NR`, PCL `eOk`; ImGUI `eErrorFeatureMissing` | **read** — the first four *on* | not called | not called | not called | not called |
|
||||
| Black Myth: Wukong (196, 3 min) | 2.7.4 | **read** — frame generation, Reflex, PCL `eOk` | not called | not called | not called | not called | not called |
|
||||
| Kingdom Come: Deliverance II (192, 4 min) | none | not hooked | not hooked | not hooked | not hooked | not hooked | not hooked |
|
||||
|
||||
- **`slIsFeatureSupported` was read in every Streamline session, and `slAllocateResources` in none.** Item 43
|
||||
wrote the meaning of that before the run: a call no game makes after the attach gives nothing in attach mode, and
|
||||
whether it keeps its patch is the owner's to say. `slFreeResources` and `slShutdown` were each read once, in one
|
||||
game each; `slIsFeatureLoaded` in three games, `slSetFeatureLoaded` in two.
|
||||
- **A refusal reads as one.** Phantom Blade Zero and Hogwarts Legacy ask about `kFeatureImGUI`, Streamline's
|
||||
debug overlay, and are told it is missing; Cyberpunk 2077 is told the same of NIS, which Dying Light is told is
|
||||
supported. Phantom Blade Zero is told DeepDVC is missing although Streamline answered its requirements.
|
||||
- **The count says how often, not when.** Dying Light's one shutdown and Phantom Blade Zero's one freeing of frame
|
||||
generation's resources may each be the game closing; nothing in a session says. Dying Light switched all five
|
||||
features off and on.
|
||||
- **The way out is as it was.** Hogwarts Legacy faulted at its exit in `_nvngx.dll`, `0xc0000005` at offset
|
||||
`0x6aa85` — the offset of its six before, since 2026-11-06, hooked or not — and Black Myth: Wukong in
|
||||
Steam's `crashhandler64.dll`, `0xc0000409` at `0x39b49`, the offset of its three before (Steam's file is now
|
||||
11.23.65.88). Windows' log has no fault for the other four games; the two hooks on a game's way out were in all
|
||||
five Streamline games.
|
||||
- **Rates are where they were**, for what a comparison without the same scene is worth: Phantom Blade Zero ×4 at
|
||||
64 → 255 (beta.44: 63 → 251), Wukong 85 → 341 (90 → 361), Cyberpunk 2077 164 → 327 (137 → 275), Dying Light ×4
|
||||
at 48 → 194 (beta.42: 54 → 216), Kingdom Come 58.8 presented (59.3).
|
||||
- **An install stops the game's threads once a patch, as a restore does.** The thirteen interposer patches took
|
||||
0.74 s on Phantom Blade Zero, 1.2 s on Cyberpunk 2077, 1.7 s on Dying Light and Wukong (twelve there) and
|
||||
**2.8 s on Hogwarts Legacy** — 57 to 215 ms a patch, while the game starts. That is the cost the proposal to
|
||||
queue patches (§What this release decided) would cut, measured on real games.
|
||||
- **No stop was exercised.** Every session ended with the game closing, so no log has an `UNHOOK_RESTORED` line.
|
||||
Item 43 (g) said a log "ends with an `UNHOOK_RESTORED` line for each patch": that is true only of a session
|
||||
stopped while its game runs, and the item was worded wrongly.
|
||||
- **Not exercised: off means off** — Advanced metrics was on in every session. **Not visible in the data**: (c), whether *loaded* agrees with the game's own menu, and (h), the
|
||||
catalog's wording on the page — both are what the owner sees.
|
||||
- **For train C's spike**: Streamline says Reflex is supported in all five games and loaded in the three that
|
||||
ask; Cyberpunk 2077 and Dying Light switch it off and on (`spike-notes` §30 has the note).
|
||||
- **GPG's agent had restarted and the pinentry timed out three times in a row**; nothing could be committed until
|
||||
the owner unlocked the key (`echo test | gpg --clearsign` in the owner's own terminal). Say so and go on with
|
||||
what needs no commit — planning did not.
|
||||
- **A here-document still eats backslashes** (a `\n` inside a C++ string in an edit script): write the script to a
|
||||
file. It cost one failed edit again.
|
||||
- **A Catch2 `WARN` longer than the console's width wraps**, and a filter on its first words loses the number at
|
||||
its end: keep a measured line short.
|
||||
- **To measure the old build beside the new one**: `git stash push -- <the changed sources>`, build, run the one
|
||||
test case by name (its `INFO` log prints when a new assertion fails, which it does on the old build), `git stash
|
||||
pop`, build again.
|
||||
- **SonarCloud's gate was red on #434 before it merged, on three things it was right about**: a `LARGE_INTEGER`
|
||||
initialised with `{}` and read through `QuadPart` (cpp:S6232 - write `{.QuadPart = 0}`, as the rest of the file
|
||||
does since #336), a `strlen` in a test, and a test model indexed with what a lookup returned unchecked. Its job is
|
||||
advisory and auto-merge does not wait for it: the pull request was held until the fix was analysed.
|
||||
- **`docs/14_TESTING` and the changelog are where a non-per-present cost goes**; "measured overhead" in a pull
|
||||
request body means what the change can move — here the install and the stop, not a present.
|
||||
|
||||
### NEXT
|
||||
|
||||
1. ~~**The owner runs item 43**~~ **Run and read 2026-11-13** (§What the owner's seven sessions on beta.45
|
||||
showed): five of the six calls read in real games, nothing different on the way out, no fault. *Off means off*
|
||||
was not exercised, and `slAllocateResources` was called by no game.
|
||||
2. ~~**The owner reads `spike-notes` §30 and answers its three questions.**~~ **Answered 2026-11-13 (D132,
|
||||
D133)**: route D goes to a spike on `hook-harness` and a stub — the owner ruled that a driver's read-only getter
|
||||
called with the device of the hooked swap chain is inside rule 4 — and no real game is touched before the owner
|
||||
has seen its result (`spike-notes` §31, to be written after 0.1.0-beta.46 is tagged); route C is refused; the
|
||||
ETW route stays closed. No shipped code changes for the spike.
|
||||
3. ~~**The stop's cost** (above): whether to batch the restores is the owner's to say.~~ **Decided 2026-11-13
|
||||
(D134): batch them, installs too** — a pull request of its own, measured on the harness, released alone as
|
||||
**0.1.0-beta.46**. The plan was reviewed against MinHook's source before it was approved: `MH_ApplyQueued`
|
||||
applies every entry whose queued state differs, not only the caller's, so the queue-to-apply sequence is
|
||||
serialised, only targets that are still ours are ever queued for a restore, and nothing is queued "for all".
|
||||
4. **`slAllocateResources` keeps its patch** (D135); looked at again with more sessions.
|
||||
5. **Train D** after train C, the same way: a spike first.
|
||||
1. **The owner runs item 44** — the first real games on the batches, and the first stop while a game runs since
|
||||
beta.43. Not first on a game under the user-mode exception's trial (D38).
|
||||
2. ~~**The spike of Reflex route D on `hook-harness`**~~ **Done 2026-11-13** (`spike-notes` §31): on the harness
|
||||
and against the installed driver the two getters are harmless, cost about a microsecond and return a readable
|
||||
report, and the Direct3D 12 device the Overlay holds is what the driver takes. **The owner's next word is go or no
|
||||
for one real title** — a go is a plan of its own before any code (where the numbers go, the Disclaimer's and the
|
||||
Privacy Policy's wording, `nvapi-readonly-check` over the Overlay). Routes C and E are closed (D133).
|
||||
3. **`slAllocateResources`** keeps its patch (D135); looked at again when there are more sessions.
|
||||
4. **Train D** after train C, the same way: a spike first — and §30 found its hook would miss a game that fetched
|
||||
its functions before the attach.
|
||||
|
||||
### Left open by this session
|
||||
|
||||
- ~~**This release's own facts** — the tag's run, the digests, the delta — are not in any file yet: the release is cut
|
||||
after this text. Record them in the next pull request, with what SonarCloud and Qodana said.~~ **Recorded
|
||||
2026-11-12: 0.1.0-beta.45 was released 2026-11-12T16:40:42Z** (23:40 in the owner's time zone) from the signed
|
||||
tag on `550d830` (#431), by run 43257803723 — green at the first attempt, one run for the one tag push. Eight
|
||||
2026-11-13: 0.1.0-beta.46 was released 2026-11-13T11:10:28Z** (18:10 in the owner's time zone) from the signed
|
||||
tag on `47f010a` (#435), by run 43412434074 — green at the first attempt, one run for the one tag push. Eight
|
||||
assets; the seven digests of `SHA256SUMS.txt` equal the ones GitHub computed; the four shipped natives carry
|
||||
`FL_BUILD_ID v0.1.0-beta.45`. The delta from beta.44 is 1,762,465 bytes beside a full package of 110,767,499 —
|
||||
"Delta processed 0452 files. 0024 patched, 0428 unchanged". The wiki was published by run 43261335359. The
|
||||
rehearsal on the release branch (run 43253780609, at `f4e3fe2`, the released tree) had made a delta of 1,779,418
|
||||
bytes with the same file counts. **Qodana's two reports are green on `550d830`.** On the way Qodana's native
|
||||
report found two index products in the harness's probe (#427), fixed before that pull request merged; every
|
||||
later report was clean, and each was read before its merge. No required check failed on this train.
|
||||
**SonarCloud's quality gate failed on `550d830`, on one condition: duplicated lines on new code, 3.7 % where the
|
||||
gate allows 3 %.** No issue is open and coverage on new code is 98.6 %. The 39 lines are the six new members of
|
||||
`FlHookFamily` (`ShmLayout.cs`) and of its Domain mirror `HookFamilies` — two enums that are the same on purpose
|
||||
(Domain references nothing, and `MetricEnumMirrorTests` fails when they differ), which six members at once took
|
||||
over a threshold that two at a time had stayed under. The job is advisory and the release was already cut. The
|
||||
pull request that records this leaves the Domain's mirror out of duplication detection, with the reason in
|
||||
`SonarQube.Analysis.xml` and in `13_CI_CD` §SonarCloud; **whether the gate is green again is for the analysis of
|
||||
that commit on `main` to say**, and it is not in this text. *(It said so the same night: green on `d3e8dd3`,
|
||||
duplicated lines on new code 0.0 %, no issue open.)* One more thing the train showed: main's branch
|
||||
protection wants a pull request up to date, so of two that were green at once the second (#430) had to be
|
||||
rebased after the first merged, and ran its checks again.
|
||||
- ~~**No real game was run on this build.** Six new patch sites, tested with the harness and the stub; their cost
|
||||
measured on the headers.~~ **Seven sessions on six games, 2026-11-13** (§What the owner's seven sessions on
|
||||
beta.45 showed). The published release notes say the six calls "have not been run in a real game"; a released
|
||||
file is not edited.
|
||||
- **`slAllocateResources` has a patch no game has used**: not called after the attach in any of six sessions on
|
||||
five games. ~~Whether it stays is the owner's.~~ It stays for now (D135, 2026-11-13).
|
||||
- **Off means off (item 42 (f)) has never been exercised on a real game**; it is item 43 (f) now, for all ten.
|
||||
`FL_BUILD_ID v0.1.0-beta.46`. The delta from beta.45 is 634,023 bytes beside a full package of 110,767,120 —
|
||||
"Delta processed 0452 files. 0021 patched, 0431 unchanged". The wiki was published by run 43414965433. The
|
||||
rehearsal on the release branch (run 43409330961, at `7b4ecd7`, the released tree) had made a delta of 668,012
|
||||
bytes with the same file counts. **SonarCloud answered on `47f010a`: the quality gate passed and no issue is open
|
||||
on `main`. Qodana's two reports are green on that commit.** On the way SonarCloud was red on #434 (six issues
|
||||
in the new code, fixed before it merged — §Traps), and no required check failed.
|
||||
- **A local gate once counted `fl_guard` as passed after 0.66 s** (2026-11-13 17:30, the spike's branch). The
|
||||
security software on the development PC was switched on for three minutes while the gate ran; the freshly linked
|
||||
`fl_guard_test.exe` was removed from the build tree, **ctest reported the run that was cut short as `Passed`**
|
||||
(the suite takes 181 s), and the gate went red only because the next test, `fl_prescan`, runs the same executable
|
||||
and could not find it. Run again with that software off, the gate was green. Nothing was changed for it: a test
|
||||
whose process ends early with a zero exit code is a pass to ctest, and the suite has no line it must print to
|
||||
count. Worth a guard of its own (a `PASS_REGULAR_EXPRESSION` on Catch2's last line, or a minimum number of test
|
||||
cases); proposed, not done.
|
||||
- **No real game was run on this build.** The order in which patches reach a game changed for every game.
|
||||
- **Off means off has never been exercised on a real game** (item 43 (f), now item 44 (g)); nor (c) and (h) of
|
||||
item 43, which only the owner sees.
|
||||
- **Valor Mortis's crash at 51 s** (twice, beta.40 and beta.44) **and Black Myth: Wukong's fault in Steam's crash
|
||||
handler at every exit** are not explained. One session of each with hooking off is the comparison that is missing.
|
||||
- **What item 41 left unexercised**: a configure through the FidelityFX 2.3 loader (Cyberpunk 2077 with FSR frame
|
||||
generation), a game with neither library.
|
||||
- **A fault while a game is closing is not seen by a hooked session** (D127: written down, not changed).
|
||||
- **For the inline patches the comparison has never been re-made under the write window** (`17_HOOK_ENGINE`
|
||||
§Compare-and-restore says so now): MinHook owns that window.
|
||||
- **`docs/LIST_GAME_TESTED.md` is as of 2026-11-06**: refreshing it is a new copy of the ledger and the owner's review.
|
||||
- **Item 40 (d)** was not exercised and the owner has not said item 40 passed. **Items 36 (d) and 37 are still open.**
|
||||
- **What an empty process snapshot does to the watcher's tick in a real session** was not looked into (seen once in
|
||||
@@ -260,8 +205,8 @@ showed the terms once: Privacy Policy 2.19 was accepted at 07:23:36.
|
||||
- **`LIMITATIONS.md` and the accuracy statement still say the processor's, the memory's and the motherboard's
|
||||
sensors "have never been read on real hardware"** — the owner's to reword. The alpha line still rests (D98).
|
||||
|
||||
**Owner-only:** item 43; the three questions of `spike-notes` §30; one session each of Valor Mortis and Black
|
||||
Myth: Wukong with hooking off; what item 41 left unexercised; item 40 (d).
|
||||
**Owner-only:** item 44; the go or no on `spike-notes` §31 (one real title); one session each of Valor Mortis and
|
||||
Black Myth: Wukong with hooking off; what item 41 left unexercised; item 40 (d).
|
||||
|
||||
## Owner-only — no PR can close these
|
||||
|
||||
@@ -705,8 +650,8 @@ Myth: Wukong with hooking off; what item 41 left unexercised; item 40 (d).
|
||||
starting the game afresh runs it without any of the ten hooks, and if that cures it the hook is one of the
|
||||
six new ones or the four before — the overlay log's last `HOOK_INSTALLED` lines and Windows' fault entry say
|
||||
which is nearer. A game that will not start at all: *Disable all hooking* (Settings ▸ Capture).
|
||||
**Seven sessions were run on 2026-11-13 and read the same day** (START HERE §What the owner's seven sessions on
|
||||
beta.45 showed): (a) happened — Privacy Policy 2.19 accepted once; (b) five Streamline games, six sessions —
|
||||
**Seven sessions were run on 2026-11-13 and read the same day** ([`handoff/history/0.1.0-beta.45.md`](handoff/history/0.1.0-beta.45.md) §What the owner's
|
||||
seven sessions on beta.45 showed): (a) happened — Privacy Policy 2.19 accepted once; (b) five Streamline games, six sessions —
|
||||
`slIsFeatureSupported` read in all, `slIsFeatureLoaded` in three games, `slSetFeatureLoaded` in two,
|
||||
`slFreeResources` and `slShutdown` once in one game each, **`slAllocateResources` in none**; (d) held on Kingdom
|
||||
Come: Deliverance II; (e) **nothing different**: Hogwarts Legacy and Black Myth: Wukong fault while closing in
|
||||
@@ -715,6 +660,36 @@ Myth: Wukong with hooking off; what item 41 left unexercised; item 40 (d).
|
||||
`UNHOOK_RESTORED` lines was not exercised and was worded wrongly. **(f) was not exercised; (c) and (h) are the
|
||||
owner's to say.** Taken as passed on the owner's "check the logs and go on", 2026-11-13; (f) stays open.
|
||||
`slAllocateResources` keeps its patch (D135, the same day).
|
||||
44. **beta.46 — hooks in and out under one stop of the threads, in real games** (D134). **Not first on a game under
|
||||
the user-mode exception's trial** (D38): a crash there ends the exception for good. (a) **The update from
|
||||
beta.45**: Help ▸ Check for updates, *Restart to update* with no game running; **the terms window does not
|
||||
show** (nothing new is read). (b) **Any Streamline game with Advanced metrics on** (Hogwarts Legacy first — its
|
||||
thirteen patches took 2.8 s on beta.45 — then Phantom Blade Zero, Cyberpunk 2077, Dying Light: The Beast, Black
|
||||
Myth: Wukong): play as usual and close the game. Its `logs\overlay-<pid>-….log` has `PATCH_BATCH install`
|
||||
lines, and the `sl.interposer.dll` `HOOK_INSTALLED` lines above each carry **the same time** to the thousandth
|
||||
of a second, not times 0.06–0.2 s apart. Say the `a=` of each `PATCH_BATCH` line: it is the microseconds the
|
||||
game's threads were stopped for that batch. (c) **How the game's start feels**: no worse than on beta.45 — the
|
||||
hitching while a game with Streamline starts should, if anything, be shorter. (d) **A stop while the game
|
||||
runs**, which no session has exercised since beta.43: with a game running and being recorded, switch *Disable
|
||||
all hooking* on in Settings ▸ Capture; the part inside the game stops at its next safety scan, within 30
|
||||
seconds. The game must go on running without a freeze of seconds; the log then has `STOP`, an `UNHOOK_RESTORED`
|
||||
line for every patch, one `PATCH_BATCH restore` line and `STOP_FLUSHED … a=1`. Switch it back off afterwards. (e) **A game with no
|
||||
Streamline** (Kingdom Come: Deliverance II, Lies of P): its FSR rows are under `PATCH_BATCH` lines as well, and
|
||||
the session reads as before. (f) **Nothing else moved**: no crash, no `PATCH_FAILED`, no `UNHOOK_DECLINED`
|
||||
unless another overlay is running, the same hooks in `HOOK_INSTALLED` as on beta.45 for the same game, frame
|
||||
rates and the frame-generation factor as before, the Advanced rows as before. (g) **Off means off** (item 43
|
||||
(f), never run): with Advanced metrics off, start a game afresh; no `HOOK_INSTALLED` line names any of the ten
|
||||
Advanced-only calls.
|
||||
**What each outcome means, written before the run.** A `PATCH_BATCH install` whose `a=` is about what one
|
||||
patch cost on beta.45 (60 000–220 000) is the expected answer: one stop of the threads. An `a=` of a second or
|
||||
more: one stop is long in that game — say which game and the number; it is still one where there were thirteen,
|
||||
but it is what would decide whether batches need a ceiling. `HOOK_INSTALLED` lines of one batch with different
|
||||
times: the batch fell back to one patch at a time — the log then also has a `PATCH_FAILED` — say so with the
|
||||
log. A game that hitches at its start as it did not on beta.45, or freezes at (d): say so at once, with the
|
||||
game; 0.1.0-beta.45 is the build without this change. A hook that was in on beta.45 and is not on beta.46
|
||||
(compare the `HOOK_INSTALLED` lines), or a session that reads *not hooked* where it read *read*: the batch lost
|
||||
a patch — the log's `PATCH_FAILED` line names it and why. A crash in play or at exit that is new: say so at
|
||||
once; *Disable all hooking* runs the game with nothing patched after the start.
|
||||
|
||||
**Answered 2026-08-05, do not re-ask:** remove `gameguard` and keep `guard` (approved
|
||||
over a red `Rules` gate, with the reasoning recorded in the merge commit); vendor NVAPI
|
||||
@@ -862,7 +837,7 @@ Where each owner decision is recorded — the file and its section, and a label
|
||||
| D131 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory | the adapter a game asks `slIsFeatureSupported` about (`sl::AdapterInfo`: a LUID, or a Vulkan physical device) is never read — the feature's id and the result only; a build check refuses the struct's member names in code loaded into a game |
|
||||
| D132 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14, `CLAUDE.md` rule 4's note of 2026-11-13 | Reflex route D goes to a spike on `hook-harness` and a stub first — and the ruling a go needed: calling a driver's read-only getter with the device of the swap chain the Overlay hooks is inside rule 4. No real game before the owner has seen the result |
|
||||
| D133 | [`20_OPEN_QUESTIONS.md`](20_OPEN_QUESTIONS.md) §M14, [`spike-notes/30-reflex-latency.md`](spike-notes/30-reflex-latency.md) | Reflex route C (the Overlay calling `slReflexGetState`) is refused; the no-injection ETW route stays closed, and §G with it |
|
||||
| D134 | `HANDOFF` START HERE §NEXT | installs and restores are batched through MinHook's queue — one stop of the game's threads for a batch, not one a patch — in a pull request of its own, measured, released alone (0.1.0-beta.46) |
|
||||
| D134 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Unhooking, *Batches* | installs and restores are batched through MinHook's queue — one stop of the game's threads for a batch, not one a patch — in a pull request of its own, measured, released alone (0.1.0-beta.46) |
|
||||
| D135 | [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory | `slAllocateResources` keeps its patch although no game called it in the first six sessions; looked at again when there are more |
|
||||
| D109 | [`../legal/DISCLAIMER.md`](../legal/DISCLAIMER.md) §5, §5A | asked on 2026-11-11 with both sentences quoted: the Disclaimer goes to 2.15 with the Privacy Policy — PawnIO and the admin mode are no longer "for the CPU temperature" alone; with Advanced metrics on they also read the processor's, the memory's and the motherboard's sensors. The admin mode's disclosure follows (`agent-admin-dialog/2`) |
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<!-- Moved from CHANGELOG.md's [Unreleased] when 0.1.0-beta.46 was cut, 2026-11-13 (D66). CHANGELOG.md lists every release. -->
|
||||
|
||||
## [0.1.0-beta.46] - 2026-11-13
|
||||
|
||||
**The forty-sixth pre-release: hooks go into a game together, and come out together.** Putting a hook in or taking
|
||||
it out stops every thread of the game for a moment. Until now that happened once for every hook: in the first real
|
||||
sessions on 0.1.0-beta.45 the thirteen NVIDIA Streamline hooks took between 0.7 and 2.8 seconds of a game's start,
|
||||
and stopping a session took about a sixth of a second for each hook. The hooks FrameLedger finds something for at
|
||||
one moment are now put in under **one** stop of the game's threads, and a stop takes all of them out under one.
|
||||
This release is that change and nothing else in the part that runs inside a game; the pages are also brought up to
|
||||
date with what those first sessions showed. The same unsigned installer: verify its hash against `SHA256SUMS.txt`,
|
||||
then *More info → Run anyway*.
|
||||
|
||||
**What it is not, yet.** It has **not been run in a real game**. On FrameLedger's own test program nine hooks go
|
||||
in within 78–90 thousandths of a second where they took 0.6–0.7 seconds, and eighteen come out within 76–90 where
|
||||
they took 1.4–1.6 seconds; how long one stop of the threads is in a game with a few hundred of them, and whether
|
||||
any game minds its hooks arriving together, are for the first real sessions to say. Nothing new is read and
|
||||
nothing a hook reads has changed, so the terms are the ones you accepted. Of 0.1.0-beta.45's six new readings five
|
||||
have now been read in real games; no game run so far set up a feature's resources after FrameLedger was in it, so
|
||||
that row has not been seen. Everything 0.1.0-beta.45's notes say is not yet done still stands.
|
||||
|
||||
**Updating from `0.1.0-beta.45`:** Help ▸ Check for updates, then *Restart to update* with no game running. **The
|
||||
terms are not shown again** (Privacy Policy 2.19 as before). No change to the ledger (schema 23), the detection
|
||||
rules stay at `2026.11.2`. **The code loaded into a game changed in this release**, so a game that was running
|
||||
during the update keeps the old part until it is started again.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Hooks go into a game together, and come out together** (owner decision D134). Putting a hook in or taking it
|
||||
out stops every thread of the game for a moment, and until now that happened once for every hook: the thirteen
|
||||
Streamline hooks took 0.7 to 2.8 seconds of a game's start in real sessions (2026-11-13), and stopping a session
|
||||
took about a sixth of a second for each hook — two to three seconds, sometimes on the thread that draws. The
|
||||
hooks a moment finds are now put in under **one** stop of the threads, and a stop takes all of them out under
|
||||
one. On FrameLedger's own test program: nine hooks in 78–90 ms where they took 0.6–0.7 s; eighteen out in
|
||||
76–90 ms where they took 1.4–1.6 s. What a hook reads and when it is installed are unchanged, and no hook's own
|
||||
code changed. The log of the part inside the game has a new line for each such moment (`PATCH_BATCH`, with the
|
||||
time it took and the number of hooks). **Not run in a real game yet.**
|
||||
|
||||
- **The limitations, the accuracy statement and the user guide say what the first real sessions on 0.1.0-beta.45
|
||||
showed** (2026-11-13, six games): five of its six new readings were read in real games — every Streamline game
|
||||
asked whether its features are supported — and no game allocated a feature's resources after FrameLedger was in
|
||||
it, so that row has not been seen. No code changes.
|
||||
@@ -0,0 +1,175 @@
|
||||
# HANDOFF history — 0.1.0-beta.45
|
||||
|
||||
*Moved verbatim from `docs/HANDOFF.md` when 0.1.0-beta.46 was cut, 2026-11-13 (owner decision D66); `docs/HANDOFF.md` §How this file is split lists every part. Nothing below was edited, so its "below" and "above" mean HANDOFF.md as it stood then, and a path it writes is relative to `docs/`. **Its §NEXT says 0.1.0-beta.46 is to come**: it was released the next day, and what it built and decided is HANDOFF.md's section for it.*
|
||||
|
||||
## **START HERE** — 2026-11-12, 0.1.0-beta.45: six more of Streamline's calls, hooked only where asked; `slInit` stays out; the Reflex spike as a document
|
||||
|
||||
*Status is `docs/changelog/0.1.0-beta.45.md`; this is what no other file carries.* The owner ran eight sessions on
|
||||
beta.44 the evening it was released and said: add the three new ones, update, go on. They were read from a copy of
|
||||
the ledger and the logs (#426); asked to reopen D112, the owner was shown why `slInit` cannot be seen and chose to
|
||||
leave it out (D129), chose six other calls for one release (D130), and approved the plan with Privacy Policy 2.19's
|
||||
wording. Four pull requests and this one: #427 (`slIsFeatureSupported`, `slIsFeatureLoaded`, `slSetFeatureLoaded`
|
||||
in the Overlay; D129–D131), #428 (`slAllocateResources`, `slFreeResources`, `slShutdown`), #429 (the Agent, the
|
||||
App, Privacy Policy 2.19), #430 (train C's spike, a document: `spike-notes` §30). **What the eight sessions on
|
||||
beta.44 showed, session by session, is [`handoff/history/0.1.0-beta.44.md`](handoff/history/0.1.0-beta.44.md)**;
|
||||
what each pull request built is [`17_HOOK_ENGINE.md`](17_HOOK_ENGINE.md) §Hook inventory (the two rows of the six
|
||||
calls, with their measured cost) and [`18_GPU_VENDOR_APIS.md`](18_GPU_VENDOR_APIS.md) §Train B (the fourth step).
|
||||
|
||||
### What this release decided, beyond D129–D131
|
||||
|
||||
- **Everything the six calls give is word 1 of a feature's slot, and one reserved word.** Bits 2–4 the two answers
|
||||
(supported, with the `sl::Result` in bits 8..15; loaded and its value), bits 5–6 the game switching the feature
|
||||
off and on, bits 16..19 and 20..23 two counts that stop at fifteen and never carry; `slShutdowns` took the first
|
||||
of three reserved words (@308). Layout 5 and schema 23 as they were. **The answers are the process's and a new
|
||||
request keeps them; the switching, the counts and the shutdowns are a session's and a new request clears them.**
|
||||
- **A refusal is the answer.** `slIsFeatureSupported`'s detour calls the original first and keeps whatever it
|
||||
returned; the page names it by NVIDIA's enumerator (forty codes, the same order at sixteen upstream tags from
|
||||
v2.0.0 to v2.14.16), `result <n>` past the list, 255 for a code a byte could not carry.
|
||||
- **The two calls on a game's way out note the call, then call the original, and run nothing after it** —
|
||||
`slFreeResources` and `slShutdown`. The fixture shuts Streamline down and goes on using the stub through every
|
||||
detour.
|
||||
- **The adapter is never read** (D131), and the build refuses the names of `sl::AdapterInfo`'s members in the code
|
||||
loaded into a game (`overlay-fields-check`); the fixture hands a wild LUID pointer.
|
||||
- **A stop restores its patches one after another, about 160 ms each.** MinHook stops every thread of the process
|
||||
for each `MH_DisableHook`. With six more patches the stop's last log lines were cut at the two seconds the
|
||||
Overlay waited for them; the wait is now sized to the patch table (`250 ms × kMaxPatches`). The patches were
|
||||
always restored; `UNHOOKED` is written after the last. **Not changed, and proposed**: queueing the restores (and
|
||||
the installs) so the threads are stopped once — a change to the hook engine's order of operations, which wants
|
||||
its own pull request, its own measurement and the owner's word. Until then a stop in a Streamline game with
|
||||
Advanced metrics on takes two to three seconds on the thread that stops.
|
||||
- **Six calls are one sentence on the page**, each by its function's name under which of three things became of
|
||||
it; a row stored before this release has none of the six and no such sentence.
|
||||
- **`AdvancedReach.BeforeAttach` is a reason of its own** for `sl.init.preferences`: not "a later release". No
|
||||
catalog entry carries `NewHook` any more; the value stays, for rows a later train may add.
|
||||
- **Where the rows sit in the table** (rows are patched in its order): the two questions after beta.44's two, at
|
||||
the head; `slSetFeatureLoaded` after `slSetConstants`; the three counted calls last of the Streamline block.
|
||||
- **Train C's spike is a reading** (`spike-notes` §30): hooking NVAPI's or Streamline's latency functions is
|
||||
refused or is train D's wrapper; the Overlay calling `slReflexGetState` breaks the vendor's thread contract;
|
||||
what remains is the Overlay calling two driver getters with the game's device, and a no-injection ETW route
|
||||
that gives half the number. It ends in three questions that are the owner's.
|
||||
|
||||
### Traps this train left
|
||||
|
||||
- **The catalog table of `18_GPU_VENDOR_APIS` is compared with the catalog row for row by a test**: a catalog
|
||||
entry and its row go in the same commit, or the Application tests are red.
|
||||
- **Qodana's native report again found an index into the feature slots computed as a 32-bit product** (#427, the
|
||||
harness's probe): write `size_t{2} * FL_ADV_FEATURE_WORDS`. It is advisory and auto-merge does not wait for it;
|
||||
both reports were read before each merge.
|
||||
- **A second `region` inside the probe's block is C4456**, and warnings are errors: name the inner one otherwise.
|
||||
- **A test method over sixty lines is MA0051** in the test projects too; split the assertions by what they cover.
|
||||
- **The injected test waits for the stop**: with eighteen patches a stop takes about three seconds, so its wait is
|
||||
200 iterations.
|
||||
- **The shell tool refuses `sleep N; command`**: wait in a background `until` loop.
|
||||
- **After a lower pull request is squashed**, `git diff <old tip> origin/main` empty proves the squash is the
|
||||
branch; then `git rebase --onto origin/main <old tip> <next branch>` and a forced push with lease.
|
||||
|
||||
### What the owner's seven sessions on beta.45 showed (2026-11-13)
|
||||
|
||||
The owner ran seven sessions on six games the day after the release and said: check the logs and go on. Read from
|
||||
a copy of the ledger (sessions 190–196), the seven overlay logs, the Agent's log and Windows' application log —
|
||||
no FrameLedger binary was run against the owner's data. **Every session is hooked, `normal`, with no fault
|
||||
counted, no dropped record and no `PATCH_FAILED`; the count of early ends is 0 on all six games.** The update
|
||||
showed the terms once: Privacy Policy 2.19 was accepted at 07:23:36.
|
||||
|
||||
| Game (session, length) | Interposer | `slIsFeatureSupported` | `slIsFeatureLoaded` | `slSetFeatureLoaded` | allocate | free | shutdown |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Phantom Blade Zero (190, 2 h 48 min; 191, 1 h 32 min) | 2.14.1 | **read** — Reflex, DLSS frame generation, PCL `eOk`; ImGUI and DeepDVC `eErrorFeatureMissing` | **read** — Reflex, frame generation *on* | not called | not called | **read** — frame generation, 1 | not called |
|
||||
| Cyberpunk 2077 (193, 7 min) | 2.14.1 | **read** — frame generation, DLSS, ray reconstruction, Reflex `eOk`; NIS `eErrorFeatureMissing` | **read** — the four *on* | **read** — the four, *on and off* | not called | not called | not called |
|
||||
| Dying Light: The Beast (194, 4 min) | 2.8.0 | **read** — DLSS, frame generation, PCL, Reflex, NIS `eOk` | not called | **read** — all five, *on and off* | not called | not called | **read** — 1 |
|
||||
| Hogwarts Legacy (195, 4 min) | 2.14.16 | **read** — frame generation, Reflex, DeepDVC, DLSS 5's `kFeatureDLSS_NR`, PCL `eOk`; ImGUI `eErrorFeatureMissing` | **read** — the first four *on* | not called | not called | not called | not called |
|
||||
| Black Myth: Wukong (196, 3 min) | 2.7.4 | **read** — frame generation, Reflex, PCL `eOk` | not called | not called | not called | not called | not called |
|
||||
| Kingdom Come: Deliverance II (192, 4 min) | none | not hooked | not hooked | not hooked | not hooked | not hooked | not hooked |
|
||||
|
||||
- **`slIsFeatureSupported` was read in every Streamline session, and `slAllocateResources` in none.** Item 43
|
||||
wrote the meaning of that before the run: a call no game makes after the attach gives nothing in attach mode, and
|
||||
whether it keeps its patch is the owner's to say. `slFreeResources` and `slShutdown` were each read once, in one
|
||||
game each; `slIsFeatureLoaded` in three games, `slSetFeatureLoaded` in two.
|
||||
- **A refusal reads as one.** Phantom Blade Zero and Hogwarts Legacy ask about `kFeatureImGUI`, Streamline's
|
||||
debug overlay, and are told it is missing; Cyberpunk 2077 is told the same of NIS, which Dying Light is told is
|
||||
supported. Phantom Blade Zero is told DeepDVC is missing although Streamline answered its requirements.
|
||||
- **The count says how often, not when.** Dying Light's one shutdown and Phantom Blade Zero's one freeing of frame
|
||||
generation's resources may each be the game closing; nothing in a session says. Dying Light switched all five
|
||||
features off and on.
|
||||
- **The way out is as it was.** Hogwarts Legacy faulted at its exit in `_nvngx.dll`, `0xc0000005` at offset
|
||||
`0x6aa85` — the offset of its six before, since 2026-11-06, hooked or not — and Black Myth: Wukong in
|
||||
Steam's `crashhandler64.dll`, `0xc0000409` at `0x39b49`, the offset of its three before (Steam's file is now
|
||||
11.23.65.88). Windows' log has no fault for the other four games; the two hooks on a game's way out were in all
|
||||
five Streamline games.
|
||||
- **Rates are where they were**, for what a comparison without the same scene is worth: Phantom Blade Zero ×4 at
|
||||
64 → 255 (beta.44: 63 → 251), Wukong 85 → 341 (90 → 361), Cyberpunk 2077 164 → 327 (137 → 275), Dying Light ×4
|
||||
at 48 → 194 (beta.42: 54 → 216), Kingdom Come 58.8 presented (59.3).
|
||||
- **An install stops the game's threads once a patch, as a restore does.** The thirteen interposer patches took
|
||||
0.74 s on Phantom Blade Zero, 1.2 s on Cyberpunk 2077, 1.7 s on Dying Light and Wukong (twelve there) and
|
||||
**2.8 s on Hogwarts Legacy** — 57 to 215 ms a patch, while the game starts. That is the cost the proposal to
|
||||
queue patches (§What this release decided) would cut, measured on real games.
|
||||
- **No stop was exercised.** Every session ended with the game closing, so no log has an `UNHOOK_RESTORED` line.
|
||||
Item 43 (g) said a log "ends with an `UNHOOK_RESTORED` line for each patch": that is true only of a session
|
||||
stopped while its game runs, and the item was worded wrongly.
|
||||
- **Not exercised: off means off** — Advanced metrics was on in every session. **Not visible in the data**: (c), whether *loaded* agrees with the game's own menu, and (h), the
|
||||
catalog's wording on the page — both are what the owner sees.
|
||||
- **For train C's spike**: Streamline says Reflex is supported in all five games and loaded in the three that
|
||||
ask; Cyberpunk 2077 and Dying Light switch it off and on (`spike-notes` §30 has the note).
|
||||
|
||||
### NEXT
|
||||
|
||||
1. ~~**The owner runs item 43**~~ **Run and read 2026-11-13** (§What the owner's seven sessions on beta.45
|
||||
showed): five of the six calls read in real games, nothing different on the way out, no fault. *Off means off*
|
||||
was not exercised, and `slAllocateResources` was called by no game.
|
||||
2. ~~**The owner reads `spike-notes` §30 and answers its three questions.**~~ **Answered 2026-11-13 (D132,
|
||||
D133)**: route D goes to a spike on `hook-harness` and a stub — the owner ruled that a driver's read-only getter
|
||||
called with the device of the hooked swap chain is inside rule 4 — and no real game is touched before the owner
|
||||
has seen its result (`spike-notes` §31, to be written after 0.1.0-beta.46 is tagged); route C is refused; the
|
||||
ETW route stays closed. No shipped code changes for the spike.
|
||||
3. ~~**The stop's cost** (above): whether to batch the restores is the owner's to say.~~ **Decided 2026-11-13
|
||||
(D134): batch them, installs too** — a pull request of its own, measured on the harness, released alone as
|
||||
**0.1.0-beta.46**. The plan was reviewed against MinHook's source before it was approved: `MH_ApplyQueued`
|
||||
applies every entry whose queued state differs, not only the caller's, so the queue-to-apply sequence is
|
||||
serialised, only targets that are still ours are ever queued for a restore, and nothing is queued "for all".
|
||||
4. **`slAllocateResources` keeps its patch** (D135); looked at again with more sessions.
|
||||
5. **Train D** after train C, the same way: a spike first.
|
||||
|
||||
### Left open by this session
|
||||
|
||||
- ~~**This release's own facts** — the tag's run, the digests, the delta — are not in any file yet: the release is cut
|
||||
after this text. Record them in the next pull request, with what SonarCloud and Qodana said.~~ **Recorded
|
||||
2026-11-12: 0.1.0-beta.45 was released 2026-11-12T16:40:42Z** (23:40 in the owner's time zone) from the signed
|
||||
tag on `550d830` (#431), by run 43257803723 — green at the first attempt, one run for the one tag push. Eight
|
||||
assets; the seven digests of `SHA256SUMS.txt` equal the ones GitHub computed; the four shipped natives carry
|
||||
`FL_BUILD_ID v0.1.0-beta.45`. The delta from beta.44 is 1,762,465 bytes beside a full package of 110,767,499 —
|
||||
"Delta processed 0452 files. 0024 patched, 0428 unchanged". The wiki was published by run 43261335359. The
|
||||
rehearsal on the release branch (run 43253780609, at `f4e3fe2`, the released tree) had made a delta of 1,779,418
|
||||
bytes with the same file counts. **Qodana's two reports are green on `550d830`.** On the way Qodana's native
|
||||
report found two index products in the harness's probe (#427), fixed before that pull request merged; every
|
||||
later report was clean, and each was read before its merge. No required check failed on this train.
|
||||
**SonarCloud's quality gate failed on `550d830`, on one condition: duplicated lines on new code, 3.7 % where the
|
||||
gate allows 3 %.** No issue is open and coverage on new code is 98.6 %. The 39 lines are the six new members of
|
||||
`FlHookFamily` (`ShmLayout.cs`) and of its Domain mirror `HookFamilies` — two enums that are the same on purpose
|
||||
(Domain references nothing, and `MetricEnumMirrorTests` fails when they differ), which six members at once took
|
||||
over a threshold that two at a time had stayed under. The job is advisory and the release was already cut. The
|
||||
pull request that records this leaves the Domain's mirror out of duplication detection, with the reason in
|
||||
`SonarQube.Analysis.xml` and in `13_CI_CD` §SonarCloud; **whether the gate is green again is for the analysis of
|
||||
that commit on `main` to say**, and it is not in this text. *(It said so the same night: green on `d3e8dd3`,
|
||||
duplicated lines on new code 0.0 %, no issue open.)* One more thing the train showed: main's branch
|
||||
protection wants a pull request up to date, so of two that were green at once the second (#430) had to be
|
||||
rebased after the first merged, and ran its checks again.
|
||||
- ~~**No real game was run on this build.** Six new patch sites, tested with the harness and the stub; their cost
|
||||
measured on the headers.~~ **Seven sessions on six games, 2026-11-13** (§What the owner's seven sessions on
|
||||
beta.45 showed). The published release notes say the six calls "have not been run in a real game"; a released
|
||||
file is not edited.
|
||||
- **`slAllocateResources` has a patch no game has used**: not called after the attach in any of six sessions on
|
||||
five games. ~~Whether it stays is the owner's.~~ It stays for now (D135, 2026-11-13).
|
||||
- **Off means off (item 42 (f)) has never been exercised on a real game**; it is item 43 (f) now, for all ten.
|
||||
- **Valor Mortis's crash at 51 s** (twice, beta.40 and beta.44) **and Black Myth: Wukong's fault in Steam's crash
|
||||
handler at every exit** are not explained. One session of each with hooking off is the comparison that is missing.
|
||||
- **What item 41 left unexercised**: a configure through the FidelityFX 2.3 loader (Cyberpunk 2077 with FSR frame
|
||||
generation), a game with neither library.
|
||||
- **A fault while a game is closing is not seen by a hooked session** (D127: written down, not changed).
|
||||
- **`docs/LIST_GAME_TESTED.md` is as of 2026-11-06**: refreshing it is a new copy of the ledger and the owner's review.
|
||||
- **Item 40 (d)** was not exercised and the owner has not said item 40 passed. **Items 36 (d) and 37 are still open.**
|
||||
- **What an empty process snapshot does to the watcher's tick in a real session** was not looked into (seen once in
|
||||
a test on 2026-11-12).
|
||||
- **`LIMITATIONS.md` and the accuracy statement still say the processor's, the memory's and the motherboard's
|
||||
sensors "have never been read on real hardware"** — the owner's to reword. The alpha line still rests (D98).
|
||||
|
||||
**Owner-only:** item 43; the three questions of `spike-notes` §30; one session each of Valor Mortis and Black
|
||||
Myth: Wukong with hooking off; what item 41 left unexercised; item 40 (d).
|
||||
@@ -54,3 +54,4 @@ Each section below lives in its own file under `docs/spike-notes/`, moved verbat
|
||||
| §28 | The main line on .NET 11's release — the whole gate, and what the analyses read (2026-11-11, beta.37, D94–D96) | [`spike-notes/28-dotnet11-main.md`](spike-notes/28-dotnet11-main.md) |
|
||||
| §29 | C# 15 against the checks — the canary, and where its constructs would go (2026-11-11, beta.37, D96) | [`spike-notes/29-csharp15-canary.md`](spike-notes/29-csharp15-canary.md) |
|
||||
| §30 | Reflex latency per frame — the routes there are, and what each would cost; a reading, nothing run (2026-11-12, beside beta.45, D130; §M14) | [`spike-notes/30-reflex-latency.md`](spike-notes/30-reflex-latency.md) |
|
||||
| §31 | Reflex route D on the harness — the driver's two getters called from an unshipped probe, against a stand-in module and the installed driver; no game touched (2026-11-13, after beta.46, D132; §M14) | [`spike-notes/31-reflex-route-d-harness.md`](spike-notes/31-reflex-route-d-harness.md) |
|
||||
@@ -173,4 +173,5 @@ route.
|
||||
2. **Route C: refused.**
|
||||
3. **Route E: left closed**; §G is not reopened.
|
||||
|
||||
The spike is `spike-notes` §31, written after 0.1.0-beta.46 is tagged.
|
||||
The spike is [`spike-notes` §31](31-reflex-route-d-harness.md), run on 2026-11-13: none of the stop conditions
|
||||
above fired on the harness, and it ends in the question of one real title.
|
||||
@@ -0,0 +1,96 @@
|
||||
## 31 · Reflex route D on the harness — the driver's two getters, called from a probe *(2026-11-13, after 0.1.0-beta.46, owner decisions D132, D133; `20_OPEN_QUESTIONS` §M14)*
|
||||
|
||||
**Why this was measured.** §30 read the routes to Reflex latency per frame and left one that needs no patch: the
|
||||
Overlay calling the driver's two getters, `NvAPI_D3D_GetLatency` and `NvAPI_D3D_GetSleepStatus`, with the device of
|
||||
the swap chain it hooks. The owner said go on 2026-11-13 (D132) — **to a spike on the harness first** — and ruled
|
||||
that such a call is inside rule 4 (`CLAUDE.md`, the rule's note). This is that spike. **No shipped code changed and
|
||||
no game was touched**: the call sequence lives in an unshipped probe, and nothing loaded into a game includes it.
|
||||
|
||||
**The instrument.** `src/native/tools/fl-probe-reflex` (built with the Overlay's flags; ctest
|
||||
`fl_reflex_probe_stub` for the half a build machine can run):
|
||||
|
||||
- `fl_reflex_candidate.h` — what would move into the Overlay: find `nvapi64.dll` **if the process already holds
|
||||
it** (never load it), ask its export `nvapi_QueryInterface` for the two getters by the ids of the vendored
|
||||
`nvapi_interface.h`, call them SEH-guarded, summarise the sixty-four frames. It does not link `nvapi64.lib`:
|
||||
the static library loads the DLL itself, from a trusted location and with a signature check.
|
||||
- `--stub`: against `tools/vendor-stubs/stub_nvapi64.cpp`, a stand-in module with knobs for what a driver cannot be
|
||||
made to do on demand.
|
||||
- `--real`: against the installed driver on this PC's NVIDIA adapter, **with the probe playing the game's part** —
|
||||
it loads `nvapi64.dll`, calls `NvAPI_Initialize`, and **sets latency markers on its own device** for a few
|
||||
hundred frames. That is a write, and it is said here plainly: a getter has nothing to return without it, the
|
||||
process is the probe's own, and no shipped binary contains the call (D108's read-only rule is about the Agent's
|
||||
bridge; rule 4's note is about a game). The owner was told and approved it with the plan.
|
||||
|
||||
### The decision table, written before any run
|
||||
|
||||
| # | Measured | Outcome → consequence |
|
||||
|---|---|---|
|
||||
| M1 | Stub: the module absent; a getter absent; an error; a report of nothing; sixty-four reports; both device kinds | Anything called or loaded when the module is absent, or a wrong classification → the candidate is wrong and is fixed before any driver run. Otherwise: these cases are harmless as written. |
|
||||
| M2 | Stub: a call that does not return for 1.5 s, made on a thread of its own and made by a thread that has other work | Made by the busy thread, that thread stands still → **the call may not be made on the Overlay's watchdog** (it supervises, installs and flushes): a thread of its own, or the presenting thread if M6 allows. A thread of its own is a second background thread, and the Disclaimer's sentence about "one" changes. |
|
||||
| M3 | Real: the getters **before** `NvAPI_Initialize` | A fault → a game that holds the module but has not initialised it would fault under us, and the Overlay cannot initialise NVAPI itself (not a getter): **route D stops** unless initialisation can be known without a call. An error status → harmless: read as "not available". |
|
||||
| M4 | Real: initialised, 120 frames, **no marker** | Zero frames or an error → as the header says: a game that does not use Reflex reads N/A. Frames with content → record what the driver fills in by itself. |
|
||||
| M5 | Real: 300 frames **with markers** | Frames with sensible spans → the report is readable by a third party in the process. Zero frames → markers alone are not enough (a sleep mode is needed too): route D reads only games that set one, and the note says so. |
|
||||
| M6 | Real: the cost of one call (2000 calls, on the presenting thread) | NFR-1 allows 1 µs a present. Once a second on the presenting thread costs `call / presents-a-second` a present: at 60 a second a call may cost 60 µs. Median within that → the presenting thread, once a second, is allowed. Above it, or a worst case over 1 ms → **never on the presenting thread**; a thread of its own (M2). |
|
||||
| M7 | Real: the getters on another thread four times a second for 60 s, beside a thread that presents and sets markers | **Any fault → route D stops** (pre-committed, §30). Error statuses or empty reports → recorded; they decide whether a read is trusted. Frames a second beside the poller more than 0.5 % below alone → the rate is too high or the route too costly: lower it and measure again, or stop. |
|
||||
| M8 | Real, Direct3D 12: read with the device, read with the queue, markers on each | The device works → the Overlay already holds it (`g_d3d12Device`). **Only the queue works → Direct3D 12 is out of reach**: the Overlay does not hold the queue (`ResolveApi`: `GetDevice` does not return it) and may not go looking for it. Route D would then be Direct3D 11 only. |
|
||||
| M9 | Real: the unit of the report's times | The gap between two frames' `simStartTime` against the probe's own frame time. Whatever it is, is recorded; a unit that cannot be told → the spans are not shown as times. |
|
||||
|
||||
Not in this spike, whatever it shows: anything in a game; where the numbers would go (shared memory, the Agent, the
|
||||
page); the wording of the Disclaimer and the Privacy Policy. Those are a plan of their own, after the owner's go.
|
||||
|
||||
### Results
|
||||
|
||||
**Where.** The dev box of §Environment: Windows 11 Pro build 29648, RTX 5080, NVIDIA driver 32.0.16.2114
|
||||
(`nvapi64.dll` of the same version), 2026-11-13. `--stub` on software devices; `--real` three times (and a fourth,
|
||||
shorter, after a fix to the probe — row M6), on the NVIDIA
|
||||
adapter, each with a 256×256 composition swap chain presented without a wait — some 14,000 to 17,000 frames a
|
||||
second, which is what makes the cost of anything beside it visible and is nothing like a game.
|
||||
|
||||
| # | What was seen | Against the table |
|
||||
|---|---|---|
|
||||
| M1 | Stub, all 20 checks pass: with the module absent `Resolve` says so, calls nothing and loads nothing; a module without the getters is refused whole; an error comes back as the error; a report of nothing is zero frames; sixty-four reports are read as the header lays them out; the driver is handed the device and only the device, Direct3D 11 and Direct3D 12 alike; no device, no call. | Harmless as written. |
|
||||
| M2 | A call held for 1.5 s on a thread of its own: another thread ticked 16 times in its first second. The same call made by that ticking thread: **0 ticks** in the second. | **Not on the watchdog.** A thread of its own, or the presenting thread (M6). |
|
||||
| M3 | The getters **before** `NvAPI_Initialize`, with the module loaded: both resolve, `GetLatency` returns `NVAPI_OK` and sixty-four empty frames. No fault, three runs. | Harmless: an uninitialised NVAPI reads as "nothing reported". |
|
||||
| M4 | Initialised, 120 frames, no marker: `NVAPI_OK`, zero frames with anything; the sleep status is `NVAPI_OK` with every field zero. | As the header says. A game that does not use Reflex reads N/A, and the read costs it nothing else. |
|
||||
| M5 | 300 frames with markers, **no sleep mode set**: sixty-four frames, the newest one or two ids behind the last frame drawn. Per frame the driver fills simulation end, render submit start/end, present start/end, driver end, OS queue start/end and GPU start/end; `inputSampleTime` and `driverStartTime` stay zero (the probe sets no input marker). | **Readable by a third party in the process, from markers alone.** |
|
||||
| M6 | 2000 calls back to back on the presenting thread: `GetLatency` median **0.50 µs** in the three runs (mean 0.53–0.54, worst 1.2 / 1.5 / 3.0 µs) and **1.50 µs in a fourth**, made that evening after a fix to the probe, with the PC doing other things (mean 1.54, worst 70 µs); `GetSleepStatus` median 0.10 µs in all four, worst 0.7 / 0.8 / 62 / 12 µs. | **Far within NFR-1 once a second**: at 60 presents a second a call may cost 60 µs, and the medians are 0.5–1.5. **Not within it at every present**: the fourth run's median alone is over the microsecond NFR-1 allows a present, and single calls of 62 and 70 µs were seen. Once a second is what is proposed. |
|
||||
| M7 | 60 s, four reads a second from another thread beside the presenting, marker-setting thread, three runs: **228 reads each, none not OK, none faulted, none empty**; worst read 103 / 112 / 248 µs on the polling thread; no marker error. Frames a second beside the poller against alone: −1.3 % (one 60 s leg against one 5 s leg), then in six alternating 10 s legs −1.4 % and −0.6 % — **with single legs between +5.9 % and −9.9 %**. | **No fault: the route does not stop.** The half-percent line cannot be read off this: the loop's own drift from leg to leg is ten times it, in both directions. So a dose was measured instead — next row. |
|
||||
| M7b | The same poller **never pausing**: 38.3 million reads in 30 s (**1.28 million a second**), none not OK, none faulted, worst read 2.7 ms; frames a second −3.3 % (legs −1.1 %, −5.3 %, −3.7 %). | Three hundred thousand times the proposed rate costs about three percent of an uncapped loop. Four reads a second is that divided by 320,000: not measurable, and not half a percent. **The driver also took 38 million reads beside some three million marker calls without an error** — the concurrency §30 could only infer. |
|
||||
| M8 | Direct3D 12: markers set with the **device** — no error; read with the device and read with the queue both return the same sixty-four frames; the sleep status is `NVAPI_OK` with either; markers set with the queue work as well and are read back with the device. | **The device works**, and it is the object the Overlay already holds. |
|
||||
| M9 | `simStartTime` of two neighbouring frames 91 and 43 apart in two runs where the probe measured 81 and 64 µs a frame, and the absolute values are the time of day (1 794 560 148 756 529 on 2026-11-13). | **Microseconds, on the clock of the Unix epoch.** Spans are differences of two of them. |
|
||||
|
||||
**One thing seen that is not understood.** In the first of the three runs the newest frame of the Direct3D 11
|
||||
report had a `presentEndTime` 1 844 674 519 µs — half an hour — after its own `simStartTime`; the other two runs
|
||||
show 36–72 µs there, and the Direct3D 12 reads 46–51 µs every time. The frame was the newest in the report, read
|
||||
within microseconds of being presented. Whatever it was, **the newest frames of a report are not final**: a reader
|
||||
must not take the last few as complete, and must refuse a span that no frame can have.
|
||||
|
||||
### What this settles, and what it does not
|
||||
|
||||
- **Settled, on this driver and this adapter**: the two getters can be found without loading anything and called
|
||||
with a Direct3D 11 device or the Direct3D 12 device the Overlay holds; they do not fault before initialisation,
|
||||
without markers, or beside a thread that sets markers at 16,000 frames a second; a call costs half a microsecond
|
||||
to a microsecond and a half;
|
||||
the report is readable from markers alone and its unit is known. None of §30's stop conditions fired: no fault or
|
||||
hang attributable to the call, no overhead near NFR-1, and the Direct3D 12 device is the one already held.
|
||||
- **Decided by M2 and M6 together**: the call belongs on the **presenting thread, once a second** — a microsecond
|
||||
or so a second, with a worst case seen of 70 µs — not on the watchdog and not on a new thread. So the Disclaimer's "one background thread"
|
||||
would not change; what would change is its list of what the part inside the game does at a present.
|
||||
- **Not settled, because only a game can say**: a game's own device — many threads, deferred contexts, a device a
|
||||
game is about to release; what a real title's report holds (input sample, the GPU times of a real frame, frame
|
||||
generation's `aiFrameTimeUs`); whether a title that uses Reflex through Streamline alone leaves `nvapi64.dll`
|
||||
findable by name (not looked at); a driver other than 32.0.16.2114, and any card but this
|
||||
one; a call that blocks — the stub shows what a block does to its thread, and nothing here made the driver block.
|
||||
- **Not looked into**: Direct3D 11 in the Overlay, which keeps no D3D11 device today (`ResolveApi` releases it):
|
||||
reading there means holding one, a reference the Overlay does not take now; and the incomplete newest frame above.
|
||||
|
||||
### The question for the owner
|
||||
|
||||
**Go to one real title, or stop here?** A go means a plan of its own before any code: the two calls in the present
|
||||
detour once a second, **only while a session asks for Advanced metrics** (D111), only where the game already
|
||||
loaded `nvapi64.dll`, Direct3D 12 first (the device is already held); a place for the numbers — a series beside the
|
||||
frames, since a report arrives after its frame's record is written (§30); `nvapi-readonly-check` extended to the
|
||||
Overlay and taught that `Sleep` is a writer; the Disclaimer's and the Privacy Policy's wording; the first run on a
|
||||
title of the owner's choosing that is not inside the anti-cheat exception's trial (D38), with what each outcome
|
||||
means written before it. A no leaves `nvapi.reflex.*` and `sl.reflex.*` at N/A with the reason, and this note as
|
||||
the record of why it was within reach.
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
HTML comments are not part of the block.
|
||||
-->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.45`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.46`** (2026-11-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ Frame timing is derived from high-resolution timestamps taken at the moment the
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-11-11.** The software is a beta; its latest
|
||||
> **beta is `0.1.0-beta.45`** (2026-11-12), an unsigned installer built from that tag with its
|
||||
> **beta is `0.1.0-beta.46`** (2026-11-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it (alphas — experimental builds that try a newer .NET — are published apart). The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
@@ -323,9 +323,11 @@ static_assert(kFamilySlConstants != kFamilyEvaluateFeature && kFamilySlConstants
|
||||
// Vulkan extensions and features -- are never followed (fl_adv_fields.h; tools/overlay-fields-check.ps1).
|
||||
//
|
||||
// INSTALLED ONLY WHERE ASKED FOR, as slSetConstants is (D111), a row and a bit each. THEY ARE THE FIRST ROWS OF THE
|
||||
// TABLE because a game asks while it starts: the watchdog patches the rows in the table's order, each patch stops
|
||||
// the game's threads for a moment, and in a process that was asked these two are the ones that cannot wait. In a
|
||||
// process never asked they are passed over before anything is resolved, and the order changes nothing.
|
||||
// TABLE because a game asks while it starts: until 0.1.0-beta.46 the watchdog patched the rows one by one in the
|
||||
// table's order, each patch stopped the game's threads for a moment, and in a process that was asked these two were
|
||||
// the ones that could not wait. The rows a tick finds now go in together, under one stop of the threads (D134), and
|
||||
// the table's order is the order of their log lines. In a process never asked they are passed over before anything
|
||||
// is resolved.
|
||||
inline constexpr uint32_t kFamilySlFeatureVersion = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION);
|
||||
inline constexpr uint32_t kFamilySlFeatureRequirements = static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_REQUIREMENTS);
|
||||
static_assert(kFamilySlFeatureVersion != kFamilySlFeatureRequirements &&
|
||||
|
||||
@@ -57,7 +57,8 @@ enum class InstallResult : std::uint32_t {
|
||||
CreateFailed =
|
||||
4, // the hooker could not create the hook (MinHook: already created, unsupported prologue, memory)
|
||||
EnableFailed = 5, // created, not enabled: no patch at the target
|
||||
StoppedDuring = 6, // the stop ran while this patch went in; the installer took it out again
|
||||
StoppedDuring = 6, // the stop ran while this patch went in; the installer took it out again, or never put it in
|
||||
Pending = 7, // in a Batch, created and waiting for its Commit; never logged
|
||||
};
|
||||
|
||||
template <std::uint32_t Capacity>
|
||||
@@ -176,6 +177,222 @@ InstallResult Install(Registry<Capacity>& registry, const std::atomic<std::uint3
|
||||
return InstallResult::Installed;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// BATCHES (0.1.0-beta.46, owner decision D134): several patches in, or every patch out, for ONE stop of the process's
|
||||
// threads instead of one a patch.
|
||||
//
|
||||
// WHY. MinHook stops every thread of the process to write a jump: a snapshot of the system's threads, then a suspend,
|
||||
// a context read and a resume for each of this process's. Enabling or disabling ONE hook does all of that for one
|
||||
// jump. In the owner's games of 2026-11-13 the thirteen Streamline patches took 0.7 s to 2.8 s of a game's start that
|
||||
// way, 57 to 215 ms each, and a stop restored its patches at about 160 ms each. MinHook can queue: mark hooks to be
|
||||
// enabled or disabled, then apply every mark under one stop of the threads.
|
||||
//
|
||||
// WHAT THE QUEUE IS, AND THE TWO THINGS IT MAKES DANGEROUS (hook.c, MH_ApplyQueued). The queue is ONE table for the
|
||||
// process: applying it applies every hook whose mark differs from its state -- not the caller's marks, everybody's.
|
||||
// So:
|
||||
// 1. A mark may never be left standing. A hook marked "enable" that failed, left marked, would be enabled by the
|
||||
// next apply -- the stop's own, if that came next. And a hook marked "disable" for a target that a foreign overlay
|
||||
// has patched over would have OUR saved bytes written over THEIR jump by whoever applied next (§H7).
|
||||
// 2. Two threads may not interleave their marks and applies: the installer's apply would execute the stop's marks
|
||||
// and the other way round.
|
||||
// Hence the GATE (`BeginQueue` / `EndQueue` on the engine): mark, apply and commit happen inside it, and when it is
|
||||
// free no hook has a mark that differs from its state. The gate is held for one apply and never across anything that
|
||||
// can take the loader's lock (resolving a symbol is done before, by the caller).
|
||||
//
|
||||
// A draft of this marked EVERYTHING for disabling and then un-marked the targets it must not restore. It was refused
|
||||
// on review against hook.c: un-marking a hook that is already disabled marks it for ENABLING, and the stop's own apply
|
||||
// would have put a patch back in after the stop. Nothing here marks "all", and nothing un-marks by marking the
|
||||
// opposite except where the hook's state is known.
|
||||
//
|
||||
// THE ENGINE, beside Create: QueueEnable(target) / QueueDisable(target) -> bool (mark only); Apply() -> bool (every
|
||||
// mark, one stop of the threads; false when any failed -- it stops at the first failure and does not say which);
|
||||
// EnsureEnabled(target) / EnsureDisabled(target) -> bool (one hook, true when it is in that state afterwards);
|
||||
// BeginQueue() / EndQueue().
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// The stop's walk: every committed patch that is still OURS is restored, under one apply; a patch a foreign overlay
|
||||
// has patched over is left exactly as it is (17_HOOK_ENGINE §Unhooking, §H7). The caller has already cleared the
|
||||
// observing flag -- this is the read half of the pair described at the top of this file.
|
||||
//
|
||||
// `ours(target, detour)` -> bool: the bytes at the target are still the jump made for us (fl_patch_check.h).
|
||||
// `report(name, target, wasOurs, restored)` is called once per committed patch, after the gate is released.
|
||||
template <std::uint32_t Capacity, class Hooker, class Ours, class Report>
|
||||
void RestoreAll(const Registry<Capacity>& registry, Hooker&& hooker, Ours&& ours, Report&& report) noexcept {
|
||||
struct Entry {
|
||||
void* target;
|
||||
const char* name;
|
||||
bool wasOurs;
|
||||
bool marked;
|
||||
bool restored;
|
||||
};
|
||||
Entry entries[Capacity];
|
||||
std::uint32_t count = 0;
|
||||
bool anyMarked = false;
|
||||
|
||||
hooker.BeginQueue();
|
||||
registry.ForEachLive(
|
||||
[&entries, &count, &anyMarked, &hooker, &ours](void* target, void* detour, const char* name) noexcept {
|
||||
if (count >= Capacity) {
|
||||
return;
|
||||
}
|
||||
// Only a patch that is still ours is ever marked. One that is not is not touched -- not marked, and not
|
||||
// un-marked either: it has no mark to remove.
|
||||
const bool mine = ours(target, detour);
|
||||
const bool marked = mine && hooker.QueueDisable(target);
|
||||
anyMarked = anyMarked || marked;
|
||||
entries[count++] = Entry{target, name, mine, marked, false};
|
||||
});
|
||||
const bool applied = !anyMarked || hooker.Apply();
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
Entry& e = entries[i];
|
||||
if (!e.marked) {
|
||||
continue;
|
||||
}
|
||||
// The apply stops at the first hook it cannot restore: the ones after it are taken out one at a time, as
|
||||
// every patch was until 0.1.0-beta.46. One that will not come out at all has its mark removed -- it is
|
||||
// enabled, so marking it "enable" leaves nothing to apply.
|
||||
e.restored = applied || hooker.EnsureDisabled(e.target);
|
||||
if (!e.restored) {
|
||||
hooker.QueueEnable(e.target);
|
||||
}
|
||||
}
|
||||
hooker.EndQueue();
|
||||
|
||||
for (std::uint32_t i = 0; i < count; ++i) {
|
||||
report(entries[i].name, entries[i].target, entries[i].wasOurs, entries[i].restored);
|
||||
}
|
||||
}
|
||||
|
||||
// Several patches, registered before any can run, enabled under ONE stop of the threads, and none left in after a
|
||||
// stop -- the sequence of Install, for a group. One thread fills and commits a batch (the Overlay's watchdog).
|
||||
//
|
||||
// Add: claim a slot and create the hook; nothing is at the target yet and nothing is marked. Commit: enable them all.
|
||||
// After Commit every item carries its InstallResult, and the caller does what follows a patch (its log line, its
|
||||
// family bit) for the ones that read Installed, in the order they were added.
|
||||
template <std::uint32_t Capacity>
|
||||
class Batch {
|
||||
public:
|
||||
struct Item {
|
||||
void* target = nullptr;
|
||||
void* detour = nullptr;
|
||||
const char* name = nullptr;
|
||||
void* context = nullptr; // the caller's: what to do once the patch is in
|
||||
std::uint32_t word = 0; // the caller's
|
||||
int slot = -1;
|
||||
InstallResult result = InstallResult::NoTarget;
|
||||
};
|
||||
|
||||
// Pending: the hook is created and waits for Commit. Anything else is final and nothing was added.
|
||||
template <class Hooker>
|
||||
InstallResult Add(Registry<Capacity>& registry, const std::atomic<std::uint32_t>& observing, Hooker&& hooker,
|
||||
void* target, void* detour, void** original, const char* name, void* context,
|
||||
std::uint32_t word) noexcept {
|
||||
if (target == nullptr) {
|
||||
return InstallResult::NoTarget;
|
||||
}
|
||||
if (observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
return InstallResult::Stopped;
|
||||
}
|
||||
if (count_ >= Capacity) {
|
||||
return InstallResult::Full; // not reachable before the registry itself is full: one slot an item
|
||||
}
|
||||
const int slot = registry.Claim(target, detour, name);
|
||||
if (slot < 0) {
|
||||
return InstallResult::Full;
|
||||
}
|
||||
if (!hooker.Create(target, detour, original)) {
|
||||
registry.Release(slot);
|
||||
return InstallResult::CreateFailed;
|
||||
}
|
||||
items_[count_++] = Item{target, detour, name, context, word, slot, InstallResult::Pending};
|
||||
return InstallResult::Pending;
|
||||
}
|
||||
|
||||
template <class Hooker, class Ours>
|
||||
void Commit(Registry<Capacity>& registry, const std::atomic<std::uint32_t>& observing, Hooker&& hooker,
|
||||
Ours&& ours) noexcept {
|
||||
if (count_ == 0u) {
|
||||
return;
|
||||
}
|
||||
hooker.BeginQueue();
|
||||
if (observing.load(std::memory_order_seq_cst) == 0u) {
|
||||
// The stop ran between Add and here. Nothing was marked and nothing is at any target: the slots go back,
|
||||
// and the hooks stay created and disabled in the engine, as a hook that failed to enable always has.
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
registry.Release(items_[i].slot);
|
||||
items_[i].result = InstallResult::StoppedDuring;
|
||||
}
|
||||
hooker.EndQueue();
|
||||
return;
|
||||
}
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
if (!hooker.QueueEnable(items_[i].target)) {
|
||||
registry.Release(items_[i].slot);
|
||||
items_[i].result = InstallResult::EnableFailed;
|
||||
}
|
||||
}
|
||||
const bool applied = hooker.Apply();
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
Item& item = items_[i];
|
||||
if (item.result != InstallResult::Pending) {
|
||||
continue;
|
||||
}
|
||||
// The ENGINE says whether the hook is enabled, not the bytes at the target: a foreign overlay that
|
||||
// patched over us a moment after the apply would read as "not in", and taking that for a failure would
|
||||
// mark a restore nobody had compared (§H7). The apply stops at the first hook that fails, so the ones
|
||||
// after it are enabled one at a time -- one bad patch costs one patch, as it always has.
|
||||
if (applied || hooker.EnsureEnabled(item.target)) {
|
||||
registry.Commit(item.slot);
|
||||
item.result = InstallResult::Installed;
|
||||
} else {
|
||||
hooker.QueueDisable(item.target); // it is disabled: this removes the mark, and marks nothing
|
||||
registry.Release(item.slot);
|
||||
item.result = InstallResult::EnableFailed;
|
||||
}
|
||||
}
|
||||
hooker.EndQueue();
|
||||
|
||||
if (observing.load(std::memory_order_seq_cst) != 0u) {
|
||||
return;
|
||||
}
|
||||
// The stop ran while the batch went in -- the re-read of Install, for the group. Its walk either saw the
|
||||
// committed slots and restored the patches, and then they are no longer ours and nothing is marked, or it had
|
||||
// passed them, and this takes them out. Compared first, as the stop compares: a patch something else has
|
||||
// patched over in the meantime is left to it.
|
||||
bool takeOut[Capacity]{};
|
||||
bool anyMarked = false;
|
||||
hooker.BeginQueue();
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
const Item& item = items_[i];
|
||||
if (item.result == InstallResult::Installed) {
|
||||
takeOut[i] = ours(item.target, item.detour) && hooker.QueueDisable(item.target);
|
||||
anyMarked = anyMarked || takeOut[i];
|
||||
}
|
||||
}
|
||||
const bool out = !anyMarked || hooker.Apply();
|
||||
for (std::uint32_t i = 0; i < count_; ++i) {
|
||||
Item& item = items_[i];
|
||||
if (item.result != InstallResult::Installed) {
|
||||
continue;
|
||||
}
|
||||
if (takeOut[i] && !out && !hooker.EnsureDisabled(item.target)) {
|
||||
hooker.QueueEnable(item.target); // enabled and staying so: no mark may be left standing
|
||||
}
|
||||
registry.Retire(item.slot);
|
||||
item.result = InstallResult::StoppedDuring;
|
||||
}
|
||||
hooker.EndQueue();
|
||||
}
|
||||
|
||||
std::uint32_t Count() const noexcept { return count_; }
|
||||
const Item& At(std::uint32_t i) const noexcept { return items_[i]; }
|
||||
void Clear() noexcept { count_ = 0u; }
|
||||
|
||||
private:
|
||||
Item items_[Capacity]{};
|
||||
std::uint32_t count_ = 0u;
|
||||
};
|
||||
|
||||
} // namespace fl::patch
|
||||
|
||||
#endif // FRAMELEDGER_FL_PATCH_REGISTRY_H
|
||||
@@ -164,6 +164,7 @@ enum FlLogCode : uint32_t {
|
||||
kLogUpscaleRoute,
|
||||
kLogRuntimeCensus,
|
||||
kLogFfxConfigureType,
|
||||
kLogPatchBatch,
|
||||
};
|
||||
|
||||
const char* LogCodeName(uint32_t code) noexcept {
|
||||
@@ -204,6 +205,8 @@ const char* LogCodeName(uint32_t code) noexcept {
|
||||
return "RUNTIME_CENSUS";
|
||||
case kLogFfxConfigureType:
|
||||
return "FFX_CONFIGURE";
|
||||
case kLogPatchBatch:
|
||||
return "PATCH_BATCH";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
@@ -395,15 +398,77 @@ static_assert(fl::inventory::kRowCount + kPatchSitesOutsideTheInventory <= kMaxP
|
||||
"the patch registry cannot hold every patch this DLL may install -- raise kMaxPatches with the table");
|
||||
fl::patch::Registry<kMaxPatches> g_patches;
|
||||
|
||||
// MinHook, as the engine fl::patch::Install drives.
|
||||
// THE GATE around MinHook's queue (fl_patch_registry.h, BATCHES; 0.1.0-beta.46). MH_ApplyQueued applies every mark
|
||||
// in the process's one table, so the watchdog's "mark, apply, commit" and the stop's "mark, apply" must not
|
||||
// interleave. A slim reader/writer lock, taken exclusively: no allocation, no handle, nothing to initialise or tear
|
||||
// down. Held for one apply -- one stop of the threads -- and never across a symbol lookup (the loader's lock).
|
||||
//
|
||||
// NOT IN ANY HOOK BODY. The one path from a hook to here is the stop itself -- MayObserve reading the Agent's request,
|
||||
// or the third fault -- which already blocked for MinHook's own lock and a stop of the threads for every patch it
|
||||
// restored. It waits here for at most the watchdog's one apply, once in a process's life.
|
||||
//
|
||||
// RE-ENTERED BY ITS OWNER WITHOUT WAITING: a slim lock taken twice by one thread never returns. The only way there is
|
||||
// a stop that begins on the thread that is inside a batch -- a third fault in the LoadLibrary detour, if the engine
|
||||
// loaded a module under the gate. That stop then runs with the marks the batch has made; the batch's own re-read of
|
||||
// the flag takes out what it put in (fl_patch_registry.h, Batch::Commit).
|
||||
SRWLOCK g_patchGate = SRWLOCK_INIT;
|
||||
std::atomic<DWORD> g_patchGateOwner{0};
|
||||
uint32_t g_patchGateDepth = 0; // the owner's alone
|
||||
|
||||
// MinHook, as the engine fl::patch::Install, Batch and RestoreAll drive.
|
||||
struct MinHookEngine {
|
||||
static bool Create(void* target, void* detour, void** original) noexcept {
|
||||
return MH_CreateHook(target, detour, original) == MH_OK;
|
||||
}
|
||||
static bool Enable(void* target) noexcept { return MH_EnableHook(target) == MH_OK; }
|
||||
static void Disable(void* target) noexcept { MH_DisableHook(target); }
|
||||
|
||||
static bool QueueEnable(void* target) noexcept { return MH_QueueEnableHook(target) == MH_OK; }
|
||||
static bool QueueDisable(void* target) noexcept { return MH_QueueDisableHook(target) == MH_OK; }
|
||||
static bool Apply() noexcept { return MH_ApplyQueued() == MH_OK; }
|
||||
static bool EnsureEnabled(void* target) noexcept {
|
||||
const MH_STATUS status = MH_EnableHook(target);
|
||||
return status == MH_OK || status == MH_ERROR_ENABLED;
|
||||
}
|
||||
static bool EnsureDisabled(void* target) noexcept {
|
||||
const MH_STATUS status = MH_DisableHook(target);
|
||||
return status == MH_OK || status == MH_ERROR_DISABLED;
|
||||
}
|
||||
static void BeginQueue() noexcept {
|
||||
const DWORD self = GetCurrentThreadId();
|
||||
if (g_patchGateOwner.load(std::memory_order_acquire) == self) {
|
||||
++g_patchGateDepth;
|
||||
return;
|
||||
}
|
||||
AcquireSRWLockExclusive(&g_patchGate);
|
||||
g_patchGateOwner.store(self, std::memory_order_release);
|
||||
}
|
||||
static void EndQueue() noexcept {
|
||||
if (g_patchGateDepth != 0u) {
|
||||
--g_patchGateDepth;
|
||||
return;
|
||||
}
|
||||
g_patchGateOwner.store(0, std::memory_order_release);
|
||||
ReleaseSRWLockExclusive(&g_patchGate);
|
||||
}
|
||||
};
|
||||
|
||||
// The performance counter, as a number. QuadPart is named in the initialiser so that it is the member the union
|
||||
// holds when it is read back (SonarCloud's cpp:S6232 on a `{}` that initialises the other half).
|
||||
int64_t QpcNow() noexcept {
|
||||
LARGE_INTEGER now{.QuadPart = 0};
|
||||
QueryPerformanceCounter(&now);
|
||||
return now.QuadPart;
|
||||
}
|
||||
|
||||
// Microseconds since `fromTicks` (QpcNow), for a PATCH_BATCH line; saturating, because the line's field is 32 bits.
|
||||
uint32_t MicrosSince(int64_t fromTicks) noexcept {
|
||||
const int64_t now = QpcNow();
|
||||
const uint64_t ticks = now > fromTicks ? static_cast<uint64_t>(now - fromTicks) : 0u;
|
||||
const uint64_t micros = g_logQpcFreq != 0u ? ticks * 1000000ull / g_logQpcFreq : 0u;
|
||||
return micros > 0xFFFFFFFFull ? 0xFFFFFFFFu : static_cast<uint32_t>(micros);
|
||||
}
|
||||
|
||||
// A patch that did not go in, said ONCE per target and reason: the lazy installers retry every second, and a line a
|
||||
// second would push everything else out of a 256-event ring. Init and watchdog threads only, which never install at
|
||||
// the same time (the watchdog starts after the init thread's last install), so a plain table.
|
||||
@@ -919,7 +984,7 @@ void WakeWatchdog() noexcept;
|
||||
|
||||
void StopObserving(uint32_t reason) noexcept {
|
||||
// Compare-exchange, not a plain check-then-set: the watchdog and a game
|
||||
// thread inside a hook body can both arrive here, and MH_DisableHook must run
|
||||
// thread inside a hook body can both arrive here, and the restore must run
|
||||
// exactly once. The loser returns without touching status, so the FIRST
|
||||
// reason wins -- a self-disable already in flight is not overwritten by a
|
||||
// safety stop that arrives a millisecond later, or the record of WHY we
|
||||
@@ -939,14 +1004,27 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
// is restored only while the bytes at its target are still the jump MinHook
|
||||
// wrote for us; otherwise it is left in place and our detour stays in the
|
||||
// other overlay's chain doing nothing -- g_observing is 0, every body forwards.
|
||||
g_patches.ForEachLive([](void* target, void* detour, const char* name) noexcept {
|
||||
if (fl::patch::StillOurs(target, detour)) {
|
||||
const bool ok = MH_DisableHook(target) == MH_OK;
|
||||
LogNote(kLogUnhookRestored, name, ok ? 1u : 0u, reinterpret_cast<uint64_t>(target));
|
||||
} else {
|
||||
LogNote(kLogUnhookDeclined, name, 0u, reinterpret_cast<uint64_t>(target));
|
||||
}
|
||||
});
|
||||
//
|
||||
// ONE STOP OF THE GAME'S THREADS FOR ALL OF THEM (0.1.0-beta.46, owner decision D134). Each patch was restored by
|
||||
// its own MH_DisableHook -- a snapshot of the system's threads and a suspend of every one of this process's, per
|
||||
// patch: about 160 ms each, two to three seconds for a Streamline title, possibly on the thread that presents.
|
||||
// RestoreAll marks the patches that are still ours and applies the marks together (fl_patch_registry.h says what
|
||||
// may and may not be marked, and why). The lines below are written after the gate is released.
|
||||
const int64_t began = QpcNow();
|
||||
uint32_t restored = 0;
|
||||
fl::patch::RestoreAll(
|
||||
g_patches, MinHookEngine{},
|
||||
[](const void* target, const void* detour) noexcept { return fl::patch::StillOurs(target, detour); },
|
||||
[&restored](const char* name, void* target, bool wasOurs, bool ok) noexcept {
|
||||
if (wasOurs) {
|
||||
LogNote(kLogUnhookRestored, name, ok ? 1u : 0u, reinterpret_cast<uint64_t>(target));
|
||||
restored += ok ? 1u : 0u;
|
||||
} else {
|
||||
LogNote(kLogUnhookDeclined, name, 0u, reinterpret_cast<uint64_t>(target));
|
||||
}
|
||||
});
|
||||
// a = the microseconds the walk and its one apply took, b = how many patches it restored.
|
||||
LogNote(kLogPatchBatch, "restore", MicrosSince(began), restored);
|
||||
if (g_state != nullptr) {
|
||||
std::atomic_ref<uint32_t> status{g_state->status};
|
||||
status.store(reason, std::memory_order_release);
|
||||
@@ -986,6 +1064,63 @@ bool PatchTarget(void* target, void* detour, void** original, const char* name)
|
||||
return false;
|
||||
}
|
||||
|
||||
// SEVERAL PATCHES FOR ONE STOP OF THE GAME'S THREADS (0.1.0-beta.46, owner decision D134). The lazy installers put a
|
||||
// row's patch into the watchdog's batch instead of making it at once, and the batch goes in when the walk is done:
|
||||
// thirteen Streamline rows were thirteen stops of every thread of the game, 0.7 s to 2.8 s of its start in the
|
||||
// owner's logs of 2026-11-13. fl_patch_registry.h holds the sequence and what it must never do.
|
||||
//
|
||||
// WATCHDOG THREAD ONLY, and empty between two installers: each commits what it queued before it returns.
|
||||
fl::patch::Batch<kMaxPatches> g_batch;
|
||||
|
||||
// What PatchTarget does, deferred: the slot is claimed and the hook created now; the patch, its HOOK_INSTALLED line,
|
||||
// its family bit and its latch come at CommitPatchBatch -- in that order, and only if the patch went in. `family` is
|
||||
// 0 for a row whose family is published elsewhere, once every row of it is in; `latch` is the row's "patched" word.
|
||||
bool QueuePatch(void* target, void* detour, void** original, const char* name, uint32_t family,
|
||||
std::atomic<uint32_t>* latch) noexcept {
|
||||
const fl::patch::InstallResult result =
|
||||
g_batch.Add(g_patches, g_observing, MinHookEngine{}, target, detour, original, name, latch, family);
|
||||
if (result == fl::patch::InstallResult::Pending) {
|
||||
return true;
|
||||
}
|
||||
if (result != fl::patch::InstallResult::NoTarget) {
|
||||
NotePatchFailedOnce(target, result, name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CommitPatchBatch() noexcept {
|
||||
const uint32_t count = g_batch.Count();
|
||||
if (count == 0u) {
|
||||
return;
|
||||
}
|
||||
const int64_t began = QpcNow();
|
||||
g_batch.Commit(g_patches, g_observing, MinHookEngine{}, [](const void* target, const void* detour) noexcept {
|
||||
return fl::patch::StillOurs(target, detour);
|
||||
});
|
||||
const uint32_t micros = MicrosSince(began);
|
||||
uint32_t installed = 0;
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
const auto& item = g_batch.At(i);
|
||||
if (item.result != fl::patch::InstallResult::Installed) {
|
||||
NotePatchFailedOnce(item.target, item.result, item.name);
|
||||
continue;
|
||||
}
|
||||
LogNote(kLogHookInstalled, item.name, 0, reinterpret_cast<uint64_t>(item.target));
|
||||
// The family, then the latch: PublishHookFamily's order, for a row that has both.
|
||||
if (item.word != 0u && g_state != nullptr) {
|
||||
std::atomic_ref<uint32_t> hooks{g_state->hooksInstalledMask};
|
||||
hooks.fetch_or(item.word, std::memory_order_relaxed);
|
||||
}
|
||||
if (item.context != nullptr) {
|
||||
static_cast<std::atomic<uint32_t>*>(item.context)->store(1u, std::memory_order_release);
|
||||
}
|
||||
++installed;
|
||||
}
|
||||
// a = the microseconds the one apply took, b = how many patches it put in.
|
||||
LogNote(kLogPatchBatch, "install", micros, installed);
|
||||
g_batch.Clear();
|
||||
}
|
||||
|
||||
// Returns false when we must not record this present.
|
||||
//
|
||||
// The supervision deadline is NOT here any more -- it is the watchdog's, which
|
||||
@@ -2611,12 +2746,8 @@ bool InstallRow(const wchar_t* moduleName, const char* symbol, uint32_t family,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PatchTarget(target, detour, original, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PublishHookFamily(family, live);
|
||||
return true;
|
||||
// Queued, not patched: the family is published and the latch set when the batch commits (CommitPatchBatch).
|
||||
return QueuePatch(target, detour, original, name, family, &live);
|
||||
}
|
||||
|
||||
// Bind a row's family bit to the detour that implements it.
|
||||
@@ -2720,11 +2851,8 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak ffx-api
|
||||
}
|
||||
if (!PatchTarget(target, FfxConfigureDetour(slot), reinterpret_cast<void**>(&g_origFfxConfigure[slot]), name)) {
|
||||
return false;
|
||||
}
|
||||
g_ffxConfigurePatched[slot].store(1, std::memory_order_release);
|
||||
return true;
|
||||
return QueuePatch(target, FfxConfigureDetour(slot), reinterpret_cast<void**>(&g_origFfxConfigure[slot]), name,
|
||||
0u, &g_ffxConfigurePatched[slot]);
|
||||
}
|
||||
if (family == fl::inventory::kFamilyEvaluateFeature) {
|
||||
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlEvaluateFeature),
|
||||
@@ -2753,11 +2881,7 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
frameRow ? reinterpret_cast<void*>(&Hook_SlSetTagForFrame) : reinterpret_cast<void*>(&Hook_SlSetTag);
|
||||
void** original =
|
||||
frameRow ? reinterpret_cast<void**>(&g_origSlSetTagForFrame) : reinterpret_cast<void**>(&g_origSlSetTag);
|
||||
if (!PatchTarget(target, detour, original, name)) {
|
||||
return false;
|
||||
}
|
||||
patched.store(1, std::memory_order_release);
|
||||
return true;
|
||||
return QueuePatch(target, detour, original, name, 0u, &patched);
|
||||
}
|
||||
if (family == static_cast<uint32_t>(fl::FL_HOOK_FG_EVALUATIONS)) {
|
||||
return InstallRow(moduleName, symbol, family, reinterpret_cast<void*>(&Hook_SlGetNewFrameToken),
|
||||
@@ -2793,12 +2917,8 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak the 3.0 host ABI
|
||||
}
|
||||
if (!PatchTarget(target, reinterpret_cast<void*>(&Hook_FfxFsr3ContextDispatchUpscale),
|
||||
reinterpret_cast<void**>(&g_origFfxFsr3DispatchUpscale), name)) {
|
||||
return false;
|
||||
}
|
||||
g_fsr3HostPatched.store(1, std::memory_order_release);
|
||||
return true;
|
||||
return QueuePatch(target, reinterpret_cast<void*>(&Hook_FfxFsr3ContextDispatchUpscale),
|
||||
reinterpret_cast<void**>(&g_origFfxFsr3DispatchUpscale), name, 0u, &g_fsr3HostPatched);
|
||||
}
|
||||
const auto slot = static_cast<uint32_t>(leaf);
|
||||
if (g_ffxPatched[slot].load(std::memory_order_acquire) != 0) {
|
||||
@@ -2808,11 +2928,8 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak ffx-api
|
||||
}
|
||||
if (!PatchTarget(target, FfxDispatchDetour(slot), reinterpret_cast<void**>(&g_origFfxDispatch[slot]), name)) {
|
||||
return false;
|
||||
}
|
||||
g_ffxPatched[slot].store(1, std::memory_order_release);
|
||||
return true;
|
||||
return QueuePatch(target, FfxDispatchDetour(slot), reinterpret_cast<void**>(&g_origFfxDispatch[slot]), name, 0u,
|
||||
&g_ffxPatched[slot]);
|
||||
}
|
||||
if (family == fl::inventory::kFamilyFfxQuery) {
|
||||
// FOUR ROWS, ONE ARM, the dispatch arm's shape: the row's MODULE picks the trampoline and the latch slot.
|
||||
@@ -2829,11 +2946,8 @@ bool InstallByFamily(const wchar_t* moduleName, const char* symbol, uint32_t fam
|
||||
if (target == nullptr) {
|
||||
return false; // not loaded, or a module of the name that does not speak ffx-api
|
||||
}
|
||||
if (!PatchTarget(target, FfxQueryDetour(slot), reinterpret_cast<void**>(&g_origFfxQuery[slot]), name)) {
|
||||
return false;
|
||||
}
|
||||
g_ffxQueryPatched[slot].store(1, std::memory_order_release);
|
||||
return true;
|
||||
return QueuePatch(target, FfxQueryDetour(slot), reinterpret_cast<void**>(&g_origFfxQuery[slot]), name, 0u,
|
||||
&g_ffxQueryPatched[slot]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2957,6 +3071,9 @@ bool InstallUpscalerHooks() noexcept {
|
||||
}
|
||||
FL_HOOK_INVENTORY(FL_INSTALL_ROW)
|
||||
#undef FL_INSTALL_ROW
|
||||
// Every row this tick found something to patch for goes in now, together -- and before the families that are
|
||||
// published "when whole", which read the latches the commit sets.
|
||||
CommitPatchBatch();
|
||||
PublishParamsFamilyIfWhole();
|
||||
PublishFfxFamilyIfWhole();
|
||||
PublishFfxQueryFamilyIfWhole();
|
||||
@@ -3088,20 +3205,21 @@ bool InstallRtHooks() noexcept {
|
||||
const bool buildAgrees = directVtbl[fl::d3d12::kBuildRaytracingAccelerationStructureIndex] ==
|
||||
computeVtbl[fl::d3d12::kBuildRaytracingAccelerationStructureIndex];
|
||||
|
||||
// The two go in together (0.1.0-beta.46): one stop of the game's threads, not two.
|
||||
if (dispatchAgrees && g_rtDispatchLive.load(std::memory_order_acquire) == 0 &&
|
||||
PatchTarget(directVtbl[fl::d3d12::kDispatchRaysIndex], reinterpret_cast<void*>(&Hook_DispatchRays),
|
||||
reinterpret_cast<void**>(&g_origDispatchRays),
|
||||
"d3d12!ID3D12GraphicsCommandList4::DispatchRays")) {
|
||||
PublishHookFamily(static_cast<uint32_t>(fl::FL_HOOK_RT_DISPATCH), g_rtDispatchLive);
|
||||
QueuePatch(directVtbl[fl::d3d12::kDispatchRaysIndex], reinterpret_cast<void*>(&Hook_DispatchRays),
|
||||
reinterpret_cast<void**>(&g_origDispatchRays), "d3d12!ID3D12GraphicsCommandList4::DispatchRays",
|
||||
static_cast<uint32_t>(fl::FL_HOOK_RT_DISPATCH), &g_rtDispatchLive)) {
|
||||
installed = true;
|
||||
}
|
||||
if (buildAgrees && g_rtAsBuildLive.load(std::memory_order_acquire) == 0 &&
|
||||
PatchTarget(directVtbl[fl::d3d12::kBuildRaytracingAccelerationStructureIndex],
|
||||
reinterpret_cast<void*>(&Hook_BuildRtAs), reinterpret_cast<void**>(&g_origBuildRtAs),
|
||||
"d3d12!ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure")) {
|
||||
PublishHookFamily(static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD), g_rtAsBuildLive);
|
||||
QueuePatch(directVtbl[fl::d3d12::kBuildRaytracingAccelerationStructureIndex],
|
||||
reinterpret_cast<void*>(&Hook_BuildRtAs), reinterpret_cast<void**>(&g_origBuildRtAs),
|
||||
"d3d12!ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure",
|
||||
static_cast<uint32_t>(fl::FL_HOOK_RT_AS_BUILD), &g_rtAsBuildLive)) {
|
||||
installed = true;
|
||||
}
|
||||
CommitPatchBatch();
|
||||
}
|
||||
|
||||
// Closed before release: a command list left recording holds its allocator.
|
||||
@@ -3267,7 +3385,9 @@ DWORD WatchdogLoop() noexcept {
|
||||
// Twelve patches (the Streamline fixture until then) took 1.9 s and fitted; with three more rows the stop took 2.4 s,
|
||||
// the flush gave up first, and the log ended "the stop was still writing" with the last three UNHOOK_RESTORED lines
|
||||
// missing -- the patches were restored, the log did not say so. The wait ends the moment the stop is logged, so the
|
||||
// longer bound costs nothing where the stop is quick.
|
||||
// longer bound costs nothing where the stop is quick. Since 0.1.0-beta.46 the stop restores its patches under one
|
||||
// stop of the threads and is quick; the bound stays for the case it was sized for -- an apply that fails and falls
|
||||
// back to one restore a patch.
|
||||
constexpr ULONGLONG kStopLogWaitMs = 250ull * kMaxPatches;
|
||||
|
||||
DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -7416,6 +7417,7 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
|
||||
}
|
||||
|
||||
// ---- 2. ASKED: the patches go in on the tick that sees the request, and the next publications carry the groups.
|
||||
const ULONGLONG askedAt = GetTickCount64();
|
||||
SetAdvancedRequest(r, 1u);
|
||||
REQUIRE(WaitForHookFamily(r.st, slConstants));
|
||||
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FEATURE_VERSION)));
|
||||
@@ -7426,6 +7428,9 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
|
||||
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_ALLOCATE_RESOURCES)));
|
||||
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_FREE_RESOURCES)));
|
||||
REQUIRE(WaitForHookFamily(r.st, static_cast<uint32_t>(fl::FL_HOOK_SL_SHUTDOWN)));
|
||||
// Measured, not asserted: a tick's wait (up to a second) and then the nine patches. Printed so that a pull request
|
||||
// which changes how patches go in can say what it did to this (0.1.0-beta.46).
|
||||
WARN("asked -> the nine Advanced-only families published: " << (GetTickCount64() - askedAt) << " ms");
|
||||
REQUIRE(ReadTargetExportBytes(child.pi.dwProcessId, FL_STUB_SL_INTERPOSER, "slSetConstants", now));
|
||||
CHECK(std::memcmp(pristine, now, sizeof(now)) != 0); // patched now
|
||||
for (int i = 0; i < kFeatureExports; ++i) {
|
||||
@@ -7557,12 +7562,15 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
|
||||
// ---- 4. STOPPED: the export's first bytes are the file's again, and the log says which patch was restored.
|
||||
// The status is written after the last patch is restored, and a restore is some 160 ms: fifteen patches in this
|
||||
// target since 0.1.0-beta.45, so the wait is ten seconds where three were enough for twelve.
|
||||
const ULONGLONG stopAt = GetTickCount64();
|
||||
r.ctl->unhookRequested = 1;
|
||||
for (int i = 0; i < 200 && r.st->status != fl::FL_STATUS_UNHOOKED; ++i) {
|
||||
for (int i = 0; i < 1000 && r.st->status != fl::FL_STATUS_UNHOOKED; ++i) {
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(50);
|
||||
Sleep(10);
|
||||
}
|
||||
REQUIRE(r.st->status == fl::FL_STATUS_UNHOOKED);
|
||||
// Measured, not asserted: the request is read within a frame, then every patch is restored.
|
||||
WARN("unhook requested -> UNHOOKED: " << (GetTickCount64() - stopAt) << " ms");
|
||||
std::wstring log;
|
||||
std::string text;
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
@@ -7587,4 +7595,56 @@ TEST_CASE("region 5 carries what a Streamline title chains into its evaluation,
|
||||
}
|
||||
CHECK(text.find("UNHOOK_DECLINED") == std::string::npos);
|
||||
CHECK(text.find("PATCH_FAILED") == std::string::npos);
|
||||
|
||||
// 0.1.0-beta.46 (owner decision D134): the rows go in by the batch -- one stop of the target's threads for the rows
|
||||
// a tick found, not one a row -- and the stop takes every patch out under one. The log says so: a PATCH_BATCH line
|
||||
// an apply, `b` the number of patches it covered. Counted from the log, not written here as numbers: the rows
|
||||
// that install unasked go in on an earlier tick than the nine that wait for the request, so there are at least two
|
||||
// install lines, and every HOOK_INSTALLED that is not one of init's own (DXGI, the loader, OpenGL) is under one.
|
||||
const auto eachLine = [&text](const char* needle, const auto& visit) {
|
||||
std::size_t at = 0;
|
||||
while ((at = text.find(needle, at)) != std::string::npos) {
|
||||
const std::size_t end = text.find('\n', at);
|
||||
visit(text.substr(at, end == std::string::npos ? std::string::npos : end - at));
|
||||
at = end == std::string::npos ? text.size() : end;
|
||||
}
|
||||
};
|
||||
const auto field = [](const std::string& line, std::string_view key, int base) {
|
||||
const std::size_t at = line.find(key);
|
||||
return at == std::string::npos ? 0ull : std::strtoull(line.c_str() + at + key.size(), nullptr, base);
|
||||
};
|
||||
unsigned long long installBatches = 0;
|
||||
unsigned long long installedByBatch = 0;
|
||||
unsigned long long restoreBatches = 0;
|
||||
unsigned long long restoredByBatch = 0;
|
||||
unsigned long long restoreMicros = 0;
|
||||
unsigned long long installedLazily = 0;
|
||||
unsigned long long restoredLines = 0;
|
||||
eachLine("PATCH_BATCH install", [&](const std::string& line) {
|
||||
++installBatches;
|
||||
installedByBatch += field(line, " b=0x", 16);
|
||||
WARN("an install batch put " << field(line, " b=0x", 16) << " patches in, in " << field(line, " a=", 10)
|
||||
<< " us");
|
||||
});
|
||||
eachLine("PATCH_BATCH restore", [&](const std::string& line) {
|
||||
++restoreBatches;
|
||||
restoredByBatch += field(line, " b=0x", 16);
|
||||
restoreMicros += field(line, " a=", 10);
|
||||
});
|
||||
eachLine("HOOK_INSTALLED ", [&](const std::string& line) {
|
||||
if (line.find("dxgi!") == std::string::npos && line.find("kernelbase!") == std::string::npos &&
|
||||
line.find("opengl32!") == std::string::npos) {
|
||||
++installedLazily;
|
||||
}
|
||||
});
|
||||
eachLine("UNHOOK_RESTORED ", [&](const std::string&) { ++restoredLines; });
|
||||
CHECK(installBatches >= 2u);
|
||||
CHECK(installedByBatch == installedLazily);
|
||||
CHECK(installedLazily >= 10u); // slSetConstants and the eight feature exports among them
|
||||
CHECK(restoreBatches == 1u);
|
||||
CHECK(restoredByBatch == restoredLines);
|
||||
// One stop of the threads, not one a patch: restoring these one by one took 1.3 s to 1.5 s on the development PC
|
||||
// (0.1.0-beta.45, eighteen patches). A bound a slow runner still meets, and the old way did not.
|
||||
WARN("the stop's one apply restored " << restoredByBatch << " patches in " << restoreMicros << " us");
|
||||
CHECK(restoreMicros < 1000000ull);
|
||||
}
|
||||
@@ -367,3 +367,452 @@ TEST_CASE("a patch that failed gives its slot back, and a slot is not seen by th
|
||||
registry.Retire(-3);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
}
|
||||
|
||||
// --- batches (0.1.0-beta.46, owner decision D134) --------------------------------------------------------------------
|
||||
// Several patches for ONE stop of the process's threads, and every patch out the same way. Driven twice: against real
|
||||
// MinHook, for what is at the target, and against a MODEL of MinHook's table (hook.c: each hook has a state and a
|
||||
// mark, and an apply executes every hook whose two differ, stopping at the first that fails), for the things real
|
||||
// MinHook cannot be made to do on demand -- an apply that fails halfway, a stop that lands inside one.
|
||||
namespace {
|
||||
|
||||
// MinHook with its queue, as dllmain.cpp's MinHookEngine hands it to Batch and RestoreAll. The gate is the Overlay's;
|
||||
// one thread patches here.
|
||||
struct RealQueue {
|
||||
static bool Create(void* target, void* detour, void** original) noexcept {
|
||||
return MH_CreateHook(target, detour, original) == MH_OK;
|
||||
}
|
||||
static bool QueueEnable(void* target) noexcept { return MH_QueueEnableHook(target) == MH_OK; }
|
||||
static bool QueueDisable(void* target) noexcept { return MH_QueueDisableHook(target) == MH_OK; }
|
||||
static bool Apply() noexcept { return MH_ApplyQueued() == MH_OK; }
|
||||
static bool EnsureEnabled(void* target) noexcept {
|
||||
const MH_STATUS status = MH_EnableHook(target);
|
||||
return status == MH_OK || status == MH_ERROR_ENABLED;
|
||||
}
|
||||
static bool EnsureDisabled(void* target) noexcept {
|
||||
const MH_STATUS status = MH_DisableHook(target);
|
||||
return status == MH_OK || status == MH_ERROR_DISABLED;
|
||||
}
|
||||
static void BeginQueue() noexcept {}
|
||||
static void EndQueue() noexcept {}
|
||||
};
|
||||
|
||||
bool RealOurs(const void* target, const void* detour) noexcept {
|
||||
return fl::patch::StillOurs(target, detour);
|
||||
}
|
||||
|
||||
struct Model {
|
||||
static constexpr int kMax = 8;
|
||||
void* target[kMax]{};
|
||||
bool enabled[kMax]{};
|
||||
bool marked[kMax]{}; // MinHook's queueEnable: the state the next apply gives the hook
|
||||
bool foreign[kMax]{}; // somebody else patched over this one
|
||||
int count = 0;
|
||||
|
||||
void* neverEnables = nullptr; // the hook at this target cannot be enabled
|
||||
bool applyFails = false; // the apply does nothing and says so
|
||||
std::atomic<std::uint32_t>* stopsDuringApply = nullptr;
|
||||
|
||||
int applies = 0;
|
||||
int gate = 0;
|
||||
bool touchedOutsideTheGate = false;
|
||||
bool wroteOverAForeignPatch = false;
|
||||
|
||||
int Find(const void* t) const noexcept {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (target[i] == t) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
bool AMarkIsStanding() const noexcept {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (enabled[i] != marked[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool Enabled(const void* t) const noexcept {
|
||||
const int i = Find(t);
|
||||
return i >= 0 && enabled[i];
|
||||
}
|
||||
void Set(int i, bool on) noexcept {
|
||||
if (i < 0 || i >= count) {
|
||||
return;
|
||||
}
|
||||
if (!on && enabled[i] && foreign[i]) {
|
||||
wroteOverAForeignPatch = true; // our saved bytes over their jump: what §H7 forbids
|
||||
}
|
||||
enabled[i] = on;
|
||||
marked[i] = on;
|
||||
}
|
||||
// Somebody else patched over the hook at `t`.
|
||||
void PatchOver(const void* t) noexcept {
|
||||
const int i = Find(t);
|
||||
if (i >= 0) {
|
||||
foreign[i] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ModelEngine {
|
||||
Model* m;
|
||||
bool Create(void* target, void*, void**) const noexcept {
|
||||
if (m->Find(target) >= 0 || m->count == Model::kMax) {
|
||||
return false;
|
||||
}
|
||||
m->target[m->count++] = target;
|
||||
return true;
|
||||
}
|
||||
bool Mark(void* target, bool on) const noexcept {
|
||||
const int i = m->Find(target);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
m->touchedOutsideTheGate = m->touchedOutsideTheGate || m->gate == 0;
|
||||
m->marked[i] = on;
|
||||
return true;
|
||||
}
|
||||
bool QueueEnable(void* target) const noexcept { return Mark(target, true); }
|
||||
bool QueueDisable(void* target) const noexcept { return Mark(target, false); }
|
||||
bool Apply() const noexcept {
|
||||
++m->applies;
|
||||
m->touchedOutsideTheGate = m->touchedOutsideTheGate || m->gate == 0;
|
||||
if (m->stopsDuringApply != nullptr) {
|
||||
m->stopsDuringApply->store(0u);
|
||||
}
|
||||
if (m->applyFails) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < m->count; ++i) {
|
||||
if (m->enabled[i] == m->marked[i]) {
|
||||
continue;
|
||||
}
|
||||
if (m->marked[i] && m->target[i] == m->neverEnables) {
|
||||
return false; // hook.c: the first failure ends the apply, the rest keep their marks
|
||||
}
|
||||
m->Set(i, m->marked[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool EnsureEnabled(void* target) const noexcept {
|
||||
const int i = m->Find(target);
|
||||
if (i < 0 || target == m->neverEnables) {
|
||||
return false;
|
||||
}
|
||||
m->Set(i, true);
|
||||
return true;
|
||||
}
|
||||
bool EnsureDisabled(void* target) const noexcept {
|
||||
const int i = m->Find(target);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
m->Set(i, false);
|
||||
return true;
|
||||
}
|
||||
void BeginQueue() const noexcept { ++m->gate; }
|
||||
void EndQueue() const noexcept { --m->gate; }
|
||||
};
|
||||
|
||||
// "Still ours", for the model: in, and nobody patched over it.
|
||||
struct ModelOurs {
|
||||
const Model* m;
|
||||
bool operator()(const void* target, const void*) const noexcept {
|
||||
const int i = m->Find(target);
|
||||
return i >= 0 && m->enabled[i] && !m->foreign[i];
|
||||
}
|
||||
};
|
||||
|
||||
int g_a = 0;
|
||||
int g_b = 0;
|
||||
int g_c = 0;
|
||||
int g_detour = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("a batch puts three patches in under one apply, and the stop takes them out under one",
|
||||
"[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<3> registry;
|
||||
fl::patch::Batch<3> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
void* first = reinterpret_cast<void*>(&First);
|
||||
void* second = reinterpret_cast<void*>(&Second);
|
||||
void* third = reinterpret_cast<void*>(&Third);
|
||||
const int firstPlain = First(3);
|
||||
const int secondPlain = Second(3);
|
||||
const int thirdPlain = Third(3);
|
||||
|
||||
REQUIRE(MH_Initialize() == MH_OK);
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, first, reinterpret_cast<void*>(&DetourFirst),
|
||||
reinterpret_cast<void**>(&g_origFirst), "first", nullptr, 0u) == InstallResult::Pending);
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, second, reinterpret_cast<void*>(&DetourSecond),
|
||||
reinterpret_cast<void**>(&g_origSecond), "second", nullptr, 0u) == InstallResult::Pending);
|
||||
// The same target a second time: the engine refuses it, its slot goes back, and the others are not held up.
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, second, reinterpret_cast<void*>(&DetourSecond),
|
||||
reinterpret_cast<void**>(&g_origSecond), "second again", nullptr,
|
||||
0u) == InstallResult::CreateFailed);
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, third, reinterpret_cast<void*>(&DetourThird),
|
||||
reinterpret_cast<void**>(&g_origThird), "third", nullptr, 7u) == InstallResult::Pending);
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, nullptr, first, nullptr, "nothing", nullptr, 0u) ==
|
||||
InstallResult::NoTarget);
|
||||
REQUIRE(batch.Count() == 3u);
|
||||
|
||||
// Added is not patched: nothing is at any target, and the stop's walk has nothing to see.
|
||||
CHECK(First(3) == firstPlain);
|
||||
CHECK(Third(3) == thirdPlain);
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
|
||||
batch.Commit(registry, observing, RealQueue{}, RealOurs);
|
||||
for (std::uint32_t i = 0; i < batch.Count(); ++i) {
|
||||
CHECK(batch.At(i).result == InstallResult::Installed);
|
||||
}
|
||||
CHECK(batch.At(2).word == 7u); // what the caller attached comes back with the item
|
||||
CHECK(First(3) == firstPlain + 1000000);
|
||||
CHECK(Second(3) == secondPlain + 2000000);
|
||||
CHECK(Third(3) == thirdPlain + 3000000);
|
||||
CHECK(registry.LiveCount() == 3u);
|
||||
batch.Clear();
|
||||
CHECK(batch.Count() == 0u);
|
||||
|
||||
// The stop: one walk, one apply, every patch reported as ours and restored.
|
||||
observing.store(0u);
|
||||
int restored = 0;
|
||||
int declined = 0;
|
||||
fl::patch::RestoreAll(registry, RealQueue{}, RealOurs,
|
||||
[&restored, &declined](const char*, void*, bool wasOurs, bool ok) noexcept {
|
||||
restored += (wasOurs && ok) ? 1 : 0;
|
||||
declined += wasOurs ? 0 : 1;
|
||||
});
|
||||
CHECK(restored == 3);
|
||||
CHECK(declined == 0);
|
||||
CHECK(First(3) == firstPlain);
|
||||
CHECK(Second(3) == secondPlain);
|
||||
CHECK(Third(3) == thirdPlain);
|
||||
|
||||
// Stopping is one-way for a batch as for a single patch: nothing is created after it.
|
||||
CHECK(batch.Add(registry, observing, RealQueue{}, first, reinterpret_cast<void*>(&DetourFirst),
|
||||
reinterpret_cast<void**>(&g_origFirst), "first", nullptr, 0u) == InstallResult::Stopped);
|
||||
MH_Uninitialize();
|
||||
}
|
||||
|
||||
TEST_CASE("the stop's batch leaves a patch a foreign overlay patched over exactly as it is, and restores the others",
|
||||
"[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<2> registry;
|
||||
fl::patch::Batch<2> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
void* first = reinterpret_cast<void*>(&First);
|
||||
void* second = reinterpret_cast<void*>(&Second);
|
||||
const int secondPlain = Second(3);
|
||||
|
||||
REQUIRE(MH_Initialize() == MH_OK);
|
||||
REQUIRE(batch.Add(registry, observing, RealQueue{}, first, reinterpret_cast<void*>(&DetourFirst),
|
||||
reinterpret_cast<void**>(&g_origFirst), "first", nullptr, 0u) == InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, RealQueue{}, second, reinterpret_cast<void*>(&DetourSecond),
|
||||
reinterpret_cast<void**>(&g_origSecond), "second", nullptr, 0u) == InstallResult::Pending);
|
||||
batch.Commit(registry, observing, RealQueue{}, RealOurs);
|
||||
REQUIRE(registry.LiveCount() == 2u);
|
||||
|
||||
// A foreign overlay patches First after us.
|
||||
std::uint8_t* foreignRelay = MakeRelay(reinterpret_cast<void*>(&ForeignDetour), first);
|
||||
std::int32_t savedRel = 0;
|
||||
RepointJump(first, foreignRelay, &savedRel);
|
||||
std::uint8_t theirs[5]{};
|
||||
std::memcpy(theirs, first, sizeof(theirs));
|
||||
REQUIRE(First(5) == 4); // their hook is what runs
|
||||
|
||||
observing.store(0u);
|
||||
int restored = 0;
|
||||
int declined = 0;
|
||||
fl::patch::RestoreAll(registry, RealQueue{}, RealOurs,
|
||||
[&restored, &declined](const char*, void*, bool wasOurs, bool ok) noexcept {
|
||||
restored += (wasOurs && ok) ? 1 : 0;
|
||||
declined += wasOurs ? 0 : 1;
|
||||
});
|
||||
CHECK(restored == 1);
|
||||
CHECK(declined == 1);
|
||||
CHECK(std::memcmp(theirs, first, sizeof(theirs)) == 0); // not one byte of theirs was written
|
||||
CHECK(First(5) == 4);
|
||||
CHECK(Second(3) == secondPlain);
|
||||
|
||||
// ...and no mark was left on the declined one: an apply by anybody afterwards still does not touch it.
|
||||
CHECK(MH_ApplyQueued() == MH_OK);
|
||||
CHECK(std::memcmp(theirs, first, sizeof(theirs)) == 0);
|
||||
|
||||
RestoreJump(first, savedRel); // the foreign overlay goes away before MinHook is torn down
|
||||
MH_Uninitialize();
|
||||
VirtualFree(foreignRelay, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
TEST_CASE("an apply that fails halfway costs one patch, and leaves no mark for a later apply to act on",
|
||||
"[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<3> registry;
|
||||
fl::patch::Batch<3> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
Model model;
|
||||
model.neverEnables = &g_b;
|
||||
const ModelEngine engine{&model};
|
||||
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_a, &g_detour, nullptr, "a", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_c, &g_detour, nullptr, "c", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
CHECK_FALSE(model.AMarkIsStanding()); // adding marks nothing
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
|
||||
CHECK(batch.At(0).result == InstallResult::Installed);
|
||||
CHECK(batch.At(1).result == InstallResult::EnableFailed);
|
||||
CHECK(batch.At(2).result == InstallResult::Installed); // the apply stopped at b; c went in by itself
|
||||
CHECK(model.Enabled(&g_a));
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
CHECK(model.Enabled(&g_c));
|
||||
CHECK(registry.LiveCount() == 2u);
|
||||
CHECK(model.applies == 1);
|
||||
CHECK_FALSE(model.AMarkIsStanding());
|
||||
CHECK_FALSE(model.touchedOutsideTheGate);
|
||||
CHECK(model.gate == 0);
|
||||
|
||||
// The stop's apply -- anybody's apply -- must not be what puts b in.
|
||||
model.neverEnables = nullptr;
|
||||
CHECK(engine.Apply());
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
|
||||
// b's slot went back: the third slot can be claimed again.
|
||||
CHECK(registry.Claim(&g_b, &g_detour, "b again") >= 0);
|
||||
}
|
||||
|
||||
TEST_CASE("an apply that does nothing at all still gets every patch in, one at a time", "[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<2> registry;
|
||||
fl::patch::Batch<2> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
Model model;
|
||||
model.applyFails = true; // MinHook could not stop the threads: nothing applied, one status for all
|
||||
const ModelEngine engine{&model};
|
||||
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_a, &g_detour, nullptr, "a", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
CHECK(batch.At(0).result == InstallResult::Installed);
|
||||
CHECK(batch.At(1).result == InstallResult::Installed);
|
||||
CHECK(registry.LiveCount() == 2u);
|
||||
CHECK_FALSE(model.AMarkIsStanding());
|
||||
|
||||
// And the stop, with the same failing apply, still takes both out.
|
||||
observing.store(0u);
|
||||
int restored = 0;
|
||||
fl::patch::RestoreAll(
|
||||
registry, engine, ModelOurs{&model},
|
||||
[&restored](const char*, void*, bool wasOurs, bool ok) noexcept { restored += (wasOurs && ok) ? 1 : 0; });
|
||||
CHECK(restored == 2);
|
||||
CHECK_FALSE(model.Enabled(&g_a));
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
CHECK_FALSE(model.AMarkIsStanding());
|
||||
CHECK_FALSE(model.touchedOutsideTheGate);
|
||||
}
|
||||
|
||||
TEST_CASE("a stop before the batch commits enables nothing; a stop inside its apply is undone by the batch itself",
|
||||
"[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
Model model;
|
||||
const ModelEngine engine{&model};
|
||||
|
||||
SECTION("the stop ran between the adds and the commit") {
|
||||
fl::patch::Registry<2> registry;
|
||||
fl::patch::Batch<2> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_a, &g_detour, nullptr, "a", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
observing.store(0u);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
CHECK(batch.At(0).result == InstallResult::StoppedDuring);
|
||||
CHECK(batch.At(1).result == InstallResult::StoppedDuring);
|
||||
CHECK(model.applies == 0); // nothing was marked, nothing applied
|
||||
CHECK_FALSE(model.Enabled(&g_a));
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
CHECK(registry.Claim(&g_a, &g_detour, "free again") >= 0); // never live, so not retired
|
||||
}
|
||||
|
||||
SECTION("the stop ran while the apply was putting them in") {
|
||||
fl::patch::Registry<2> registry;
|
||||
fl::patch::Batch<2> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
model.stopsDuringApply = &observing;
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_a, &g_detour, nullptr, "a", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
CHECK(batch.At(0).result == InstallResult::StoppedDuring);
|
||||
CHECK(batch.At(1).result == InstallResult::StoppedDuring);
|
||||
CHECK_FALSE(model.Enabled(&g_a)); // put in, and taken out again by the installer
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
CHECK(model.applies == 2); // one in, one out
|
||||
CHECK(registry.LiveCount() == 0u);
|
||||
CHECK(registry.Claim(&g_a, &g_detour, "again") == -1); // they were live: the slots are never reused
|
||||
CHECK_FALSE(model.AMarkIsStanding());
|
||||
CHECK_FALSE(model.touchedOutsideTheGate);
|
||||
CHECK(model.gate == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("the stop marks only what is still ours: a foreign patch is not written, a restored patch is not put back",
|
||||
"[unhook][registry][batch]") {
|
||||
using fl::patch::InstallResult;
|
||||
fl::patch::Registry<3> registry;
|
||||
fl::patch::Batch<3> batch;
|
||||
std::atomic<std::uint32_t> observing{1u};
|
||||
Model model;
|
||||
const ModelEngine engine{&model};
|
||||
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_a, &g_detour, nullptr, "a", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_b, &g_detour, nullptr, "b", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
REQUIRE(batch.Add(registry, observing, engine, &g_c, &g_detour, nullptr, "c", nullptr, 0u) ==
|
||||
InstallResult::Pending);
|
||||
batch.Commit(registry, observing, engine, ModelOurs{&model});
|
||||
REQUIRE(registry.LiveCount() == 3u);
|
||||
|
||||
model.PatchOver(&g_a); // a: somebody patched over us
|
||||
// c: committed, and already taken out -- an installer between its own disable and its Retire. The draft that
|
||||
// marked everything and then un-marked what it must not restore marked THIS one for enabling, and the stop's own
|
||||
// apply put the patch back in after the stop.
|
||||
model.Set(model.Find(&g_c), false);
|
||||
model.applies = 0;
|
||||
|
||||
observing.store(0u);
|
||||
int ours = 0;
|
||||
int notOurs = 0;
|
||||
fl::patch::RestoreAll(registry, engine, ModelOurs{&model},
|
||||
[&ours, ¬Ours](const char*, void*, bool wasOurs, bool ok) noexcept {
|
||||
ours += (wasOurs && ok) ? 1 : 0;
|
||||
notOurs += wasOurs ? 0 : 1;
|
||||
});
|
||||
CHECK(ours == 1); // b
|
||||
CHECK(notOurs == 2); // a and c
|
||||
CHECK(model.applies == 1);
|
||||
CHECK(model.Enabled(&g_a)); // theirs: still in
|
||||
CHECK_FALSE(model.wroteOverAForeignPatch);
|
||||
CHECK_FALSE(model.Enabled(&g_b));
|
||||
CHECK_FALSE(model.Enabled(&g_c)); // stayed out
|
||||
CHECK_FALSE(model.AMarkIsStanding());
|
||||
CHECK_FALSE(model.touchedOutsideTheGate);
|
||||
CHECK(model.gate == 0);
|
||||
|
||||
// Nothing of ours left: a second stop's walk marks nothing and applies nothing.
|
||||
model.applies = 0;
|
||||
fl::patch::RestoreAll(registry, engine, ModelOurs{&model}, [](const char*, void*, bool, bool) noexcept {});
|
||||
CHECK(model.applies == 0);
|
||||
}
|
||||
@@ -8,4 +8,5 @@ add_subdirectory(fl-probe-processstats)
|
||||
add_subdirectory(fl-probe-signer)
|
||||
add_subdirectory(fl-probe-vklayer)
|
||||
add_subdirectory(vendor-stubs)
|
||||
add_subdirectory(fl-probe-reflex)
|
||||
add_subdirectory(hook-harness)
|
||||
@@ -0,0 +1,22 @@
|
||||
# fl-probe-reflex -- the instrument of docs/spike-notes §31 (Reflex route D, owner decision D132). A tool, NOT
|
||||
# SHIPPED, and it touches no game.
|
||||
#
|
||||
# BUILT WITH THE OVERLAY'S OWN FLAGS (fl_hostile_env_flags), as fl-probe-hookprofile is: fl_reflex_candidate.h is the
|
||||
# call sequence that would move into the Overlay if the owner says go, and a probe built otherwise would prove
|
||||
# nothing about it there.
|
||||
#
|
||||
# THE NVAPI HEADERS, NOT THE NVAPI LIBRARY. The include directory of the vendored MIT headers is taken by itself;
|
||||
# fl_nvapi -- which also links nvapi64.lib -- is deliberately not: the static library loads nvapi64.dll itself, from
|
||||
# a trusted location, with a signature check, and route D's shape is that the process already has the module.
|
||||
add_executable(fl-probe-reflex main.cpp)
|
||||
target_link_libraries(fl-probe-reflex PRIVATE fl_native_flags fl_hostile_env_flags d3d11 d3d12 dxgi)
|
||||
target_include_directories(fl-probe-reflex SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/third_party/nvapi")
|
||||
target_compile_definitions(fl-probe-reflex PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE)
|
||||
add_dependencies(fl-probe-reflex fl_stub_nvapi64)
|
||||
|
||||
# The half a build machine can run: the candidate against the stand-in module -- absent, without its getters, a
|
||||
# report of nothing, an error, sixty-four reports, both device kinds, a call that does not come back for a while.
|
||||
# Software devices; exit 77 where there is no Direct3D 11 at all. `--real` (the installed driver, an NVIDIA adapter)
|
||||
# is a measurement the note records, never a test.
|
||||
add_test(NAME fl_reflex_probe_stub COMMAND fl-probe-reflex --stub "$<TARGET_FILE:fl_stub_nvapi64>")
|
||||
set_tests_properties(fl_reflex_probe_stub PROPERTIES SKIP_RETURN_CODE 77)
|
||||
@@ -0,0 +1,128 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// The call sequence Reflex route D would put into the Overlay (docs/spike-notes §30, §31; owner decision D132) --
|
||||
// HERE, IN A PROBE, AND NOWHERE THAT SHIPS. Nothing loaded into a game includes this file. If the owner says go after
|
||||
// the spike, this is what moves; until then it exists to be measured.
|
||||
//
|
||||
// WHAT IT DOES: finds NVIDIA's nvapi64.dll in the process IF IT IS ALREADY LOADED -- it never loads it -- asks its one
|
||||
// export for the two getters by their interface ids, and calls them with a Direct3D device. Getters only: no marker,
|
||||
// no sleep mode, no sleep, nothing that changes what the driver does (rule 4's note of 2026-11-13).
|
||||
//
|
||||
// NOT LINKED AGAINST nvapi64.lib. The static library loads the DLL itself, from a trusted location and with a
|
||||
// signature check, on its first call; route D's whole shape is that the game brought the module and FrameLedger adds
|
||||
// nothing to the process. The ids are the vendored header's (nvapi_interface.h), the structs nvapi.h's.
|
||||
|
||||
#ifndef FRAMELEDGER_FL_REFLEX_CANDIDATE_H
|
||||
#define FRAMELEDGER_FL_REFLEX_CANDIDATE_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <nvapi.h>
|
||||
|
||||
namespace fl::reflex {
|
||||
|
||||
inline constexpr unsigned int kIdGetSleepStatus = 0xaef96ca1u; // nvapi_interface.h: NvAPI_D3D_GetSleepStatus
|
||||
inline constexpr unsigned int kIdGetLatency = 0x1a587f9cu; // nvapi_interface.h: NvAPI_D3D_GetLatency
|
||||
|
||||
using QueryInterfaceFn = void*(__cdecl*)(unsigned int);
|
||||
using GetLatencyFn = NvAPI_Status(__cdecl*)(IUnknown*, NV_LATENCY_RESULT_PARAMS*);
|
||||
using GetSleepStatusFn = NvAPI_Status(__cdecl*)(IUnknown*, NV_GET_SLEEP_STATUS_PARAMS*);
|
||||
|
||||
struct Api {
|
||||
GetLatencyFn getLatency = nullptr;
|
||||
GetSleepStatusFn getSleepStatus = nullptr;
|
||||
};
|
||||
|
||||
enum class Resolved : std::uint32_t {
|
||||
Ok = 0,
|
||||
NoModule = 1, // the process has not loaded nvapi64.dll: nothing was called and nothing was loaded
|
||||
NoQueryInterface = 2, // a module of that name without the export
|
||||
NoGetter = 3, // the module does not have one of the two getters
|
||||
};
|
||||
|
||||
// Finds the two getters in a module the process ALREADY holds. Takes a reference on it (as the Overlay's
|
||||
// ResolveScoped does on a module it patches) so the addresses stay valid; never loads a module.
|
||||
inline Resolved Resolve(Api& api) noexcept {
|
||||
api = Api{};
|
||||
HMODULE nvapi = nullptr;
|
||||
if (!GetModuleHandleExW(0, L"nvapi64.dll", &nvapi) || nvapi == nullptr) {
|
||||
return Resolved::NoModule;
|
||||
}
|
||||
const auto query = reinterpret_cast<QueryInterfaceFn>(GetProcAddress(nvapi, "nvapi_QueryInterface"));
|
||||
if (query == nullptr) {
|
||||
return Resolved::NoQueryInterface;
|
||||
}
|
||||
api.getLatency = reinterpret_cast<GetLatencyFn>(query(kIdGetLatency));
|
||||
api.getSleepStatus = reinterpret_cast<GetSleepStatusFn>(query(kIdGetSleepStatus));
|
||||
if (api.getLatency == nullptr || api.getSleepStatus == nullptr) {
|
||||
api = Api{};
|
||||
return Resolved::NoGetter;
|
||||
}
|
||||
return Resolved::Ok;
|
||||
}
|
||||
|
||||
// What a read returns when the driver's code faulted under it: not one of NVAPI's own codes.
|
||||
inline constexpr NvAPI_Status kFaulted = static_cast<NvAPI_Status>(-9999);
|
||||
|
||||
// One read of the driver's report. SEH-guarded as every call the Overlay makes into foreign code is; a guard does not
|
||||
// bound a call that never returns, which is why the probe measures that separately.
|
||||
inline NvAPI_Status ReadLatency(const Api& api, IUnknown* device, NV_LATENCY_RESULT_PARAMS& out) noexcept {
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
out.version = NV_LATENCY_RESULT_PARAMS_VER1;
|
||||
if (api.getLatency == nullptr || device == nullptr) {
|
||||
return NVAPI_INVALID_ARGUMENT;
|
||||
}
|
||||
__try {
|
||||
return api.getLatency(device, &out);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return kFaulted;
|
||||
}
|
||||
}
|
||||
|
||||
inline NvAPI_Status ReadSleepStatus(const Api& api, IUnknown* device, NV_GET_SLEEP_STATUS_PARAMS& out) noexcept {
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
out.version = NV_GET_SLEEP_STATUS_PARAMS_VER1;
|
||||
if (api.getSleepStatus == nullptr || device == nullptr) {
|
||||
return NVAPI_INVALID_ARGUMENT;
|
||||
}
|
||||
__try {
|
||||
return api.getSleepStatus(device, &out);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return kFaulted;
|
||||
}
|
||||
}
|
||||
|
||||
// What a report holds, in numbers: how many of its sixty-four frames carry anything, and the newest one's id and
|
||||
// two spans in the report's own unit -- simulation start to present end (the game's side) and to the end of GPU work.
|
||||
struct Digest {
|
||||
std::uint32_t valid = 0;
|
||||
std::uint64_t newestFrameId = 0;
|
||||
std::uint64_t newestSimToPresentEnd = 0;
|
||||
std::uint64_t newestSimToGpuEnd = 0;
|
||||
std::uint32_t newestGpuActiveUs = 0;
|
||||
};
|
||||
|
||||
inline Digest Summarise(const NV_LATENCY_RESULT_PARAMS& report) noexcept {
|
||||
Digest d{};
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
const auto& r = report.frameReport[i];
|
||||
if (r.frameID == 0u && r.simStartTime == 0u && r.gpuRenderEndTime == 0u) {
|
||||
continue;
|
||||
}
|
||||
++d.valid;
|
||||
d.newestFrameId = r.frameID;
|
||||
d.newestSimToPresentEnd = r.presentEndTime >= r.simStartTime ? r.presentEndTime - r.simStartTime : 0u;
|
||||
d.newestSimToGpuEnd = r.gpuRenderEndTime >= r.simStartTime ? r.gpuRenderEndTime - r.simStartTime : 0u;
|
||||
d.newestGpuActiveUs = r.gpuActiveRenderTimeUs;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
} // namespace fl::reflex
|
||||
|
||||
#endif // FRAMELEDGER_FL_REFLEX_CANDIDATE_H
|
||||
@@ -0,0 +1,708 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// fl-probe-reflex -- the instrument of docs/spike-notes §31 (Reflex route D, owner decision D132). NOT SHIPPED, and it
|
||||
// touches no game: it runs the call sequence of fl_reflex_candidate.h in its own process, against two things.
|
||||
//
|
||||
// --stub <path> a stand-in nvapi64.dll (tools/vendor-stubs/stub_nvapi64.cpp): the module absent, a getter absent,
|
||||
// a report of nothing, an error, sixty-four reports, both device kinds, and a call that does not come
|
||||
// back for seconds. ctest fl_reflex_probe_stub. Software devices are enough: the stub does not look.
|
||||
// --real the installed driver, on this PC's NVIDIA adapter, with the probe playing the game's part: it
|
||||
// loads nvapi64.dll itself, initialises it, and SETS LATENCY MARKERS ON ITS OWN DEVICE for a few
|
||||
// hundred frames -- a write, made here because a getter has nothing to return without it, in a
|
||||
// process that is nobody's game. Then it measures what route D would do: the two getters. A
|
||||
// measurement, not a test: exit 77 where there is no NVIDIA adapter.
|
||||
//
|
||||
// Built with the Overlay's own flags, because the candidate is the Overlay's code-to-be.
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_4.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "fl_reflex_candidate.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int g_failures = 0;
|
||||
|
||||
void Check(bool ok, const char* what) noexcept {
|
||||
std::printf("%s %s\n", ok ? "PASS" : "FAIL", what);
|
||||
if (!ok) {
|
||||
++g_failures;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ReleaseIf(T*& p) noexcept {
|
||||
if (p != nullptr) {
|
||||
p->Release();
|
||||
p = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
double QpcSeconds() noexcept {
|
||||
// QuadPart named in the initialiser, so the member read back is the one the union holds (cpp:S6232).
|
||||
LARGE_INTEGER f{.QuadPart = 0};
|
||||
LARGE_INTEGER c{.QuadPart = 0};
|
||||
QueryPerformanceFrequency(&f);
|
||||
QueryPerformanceCounter(&c);
|
||||
return static_cast<double>(c.QuadPart) / static_cast<double>(f.QuadPart);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Devices. `nvidia` picks this PC's NVIDIA adapter (vendor 0x10DE) or fails; otherwise the software adapter.
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
IDXGIAdapter1* FindAdapter(IDXGIFactory4* factory, bool nvidia) noexcept {
|
||||
if (!nvidia) {
|
||||
IDXGIAdapter1* warp = nullptr;
|
||||
factory->EnumWarpAdapter(__uuidof(IDXGIAdapter1), reinterpret_cast<void**>(&warp));
|
||||
return warp;
|
||||
}
|
||||
for (UINT i = 0;; ++i) {
|
||||
IDXGIAdapter1* adapter = nullptr;
|
||||
if (factory->EnumAdapters1(i, &adapter) != S_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
DXGI_ADAPTER_DESC1 desc{};
|
||||
if (SUCCEEDED(adapter->GetDesc1(&desc)) && desc.VendorId == 0x10DEu &&
|
||||
(desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0u) {
|
||||
return adapter;
|
||||
}
|
||||
adapter->Release();
|
||||
}
|
||||
}
|
||||
|
||||
struct Dx11 {
|
||||
ID3D11Device* device = nullptr;
|
||||
ID3D11DeviceContext* context = nullptr;
|
||||
IDXGISwapChain1* chain = nullptr;
|
||||
ID3D11RenderTargetView* target = nullptr;
|
||||
};
|
||||
|
||||
bool MakeDx11(IDXGIFactory4* factory, IDXGIAdapter1* adapter, Dx11& out) noexcept {
|
||||
if (FAILED(D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT, nullptr,
|
||||
0, D3D11_SDK_VERSION, &out.device, nullptr, &out.context))) {
|
||||
return false;
|
||||
}
|
||||
DXGI_SWAP_CHAIN_DESC1 desc{};
|
||||
desc.Width = 256;
|
||||
desc.Height = 256;
|
||||
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.BufferCount = 2;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED;
|
||||
if (FAILED(factory->CreateSwapChainForComposition(out.device, &desc, nullptr, &out.chain))) {
|
||||
return false;
|
||||
}
|
||||
ID3D11Texture2D* back = nullptr;
|
||||
if (FAILED(out.chain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&back)))) {
|
||||
return false;
|
||||
}
|
||||
const HRESULT hr = out.device->CreateRenderTargetView(back, nullptr, &out.target);
|
||||
back->Release();
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
void FreeDx11(Dx11& d) noexcept {
|
||||
ReleaseIf(d.target);
|
||||
ReleaseIf(d.chain);
|
||||
ReleaseIf(d.context);
|
||||
ReleaseIf(d.device);
|
||||
}
|
||||
|
||||
struct Dx12 {
|
||||
ID3D12Device* device = nullptr;
|
||||
ID3D12CommandQueue* queue = nullptr;
|
||||
IDXGISwapChain1* chain = nullptr;
|
||||
};
|
||||
|
||||
bool MakeDx12(IDXGIFactory4* factory, IDXGIAdapter1* adapter, Dx12& out) noexcept {
|
||||
if (FAILED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device),
|
||||
reinterpret_cast<void**>(&out.device)))) {
|
||||
return false;
|
||||
}
|
||||
D3D12_COMMAND_QUEUE_DESC q{};
|
||||
q.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
if (FAILED(
|
||||
out.device->CreateCommandQueue(&q, __uuidof(ID3D12CommandQueue), reinterpret_cast<void**>(&out.queue)))) {
|
||||
return false;
|
||||
}
|
||||
DXGI_SWAP_CHAIN_DESC1 desc{};
|
||||
desc.Width = 256;
|
||||
desc.Height = 256;
|
||||
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.BufferCount = 2;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED;
|
||||
return SUCCEEDED(factory->CreateSwapChainForComposition(out.queue, &desc, nullptr, &out.chain));
|
||||
}
|
||||
|
||||
void FreeDx12(Dx12& d) noexcept {
|
||||
ReleaseIf(d.chain);
|
||||
ReleaseIf(d.queue);
|
||||
ReleaseIf(d.device);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// --stub
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
using SetU32Fn = void(__cdecl*)(std::uint32_t);
|
||||
using GetU32Fn = std::uint32_t(__cdecl*)();
|
||||
using GetPtrFn = void*(__cdecl*)();
|
||||
|
||||
struct BlockedCall {
|
||||
fl::reflex::Api api;
|
||||
IUnknown* device;
|
||||
NvAPI_Status status;
|
||||
};
|
||||
|
||||
DWORD WINAPI BlockedCallThread(LPVOID p) noexcept {
|
||||
auto* call = static_cast<BlockedCall*>(p);
|
||||
static NV_LATENCY_RESULT_PARAMS report; // 15 KB: not on a new thread's stack for no reason
|
||||
call->status = fl::reflex::ReadLatency(call->api, call->device, report);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A stand-in for the Overlay's watchdog: a loop that ticks every 50 ms and, when told, makes the call ITSELF.
|
||||
struct Ticker {
|
||||
std::atomic<std::uint32_t> ticks{0};
|
||||
std::atomic<std::uint32_t> callNow{0};
|
||||
std::atomic<std::uint32_t> quit{0};
|
||||
fl::reflex::Api api;
|
||||
IUnknown* device = nullptr;
|
||||
};
|
||||
|
||||
DWORD WINAPI TickerThread(LPVOID p) noexcept {
|
||||
auto* t = static_cast<Ticker*>(p);
|
||||
static NV_LATENCY_RESULT_PARAMS report;
|
||||
while (t->quit.load(std::memory_order_acquire) == 0u) {
|
||||
if (t->callNow.exchange(0u, std::memory_order_acq_rel) != 0u) {
|
||||
fl::reflex::ReadLatency(t->api, t->device, report);
|
||||
}
|
||||
t->ticks.fetch_add(1u, std::memory_order_relaxed);
|
||||
Sleep(50);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RunStub(const wchar_t* stubPath) noexcept {
|
||||
using fl::reflex::Resolved;
|
||||
fl::reflex::Api api{};
|
||||
|
||||
// 1. The module is not in the process: nothing is called, and nothing gets loaded by asking.
|
||||
Check(GetModuleHandleW(L"nvapi64.dll") == nullptr, "before: no nvapi64.dll in this process");
|
||||
Check(fl::reflex::Resolve(api) == Resolved::NoModule, "module absent -> NoModule");
|
||||
Check(GetModuleHandleW(L"nvapi64.dll") == nullptr, "resolving loaded nothing");
|
||||
Check(api.getLatency == nullptr && api.getSleepStatus == nullptr, "no address was kept");
|
||||
|
||||
HMODULE stub = LoadLibraryExW(stubPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (stub == nullptr) {
|
||||
std::printf("FAIL the stub did not load (%lu)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
const auto setMode = reinterpret_cast<SetU32Fn>(GetProcAddress(stub, "FlStubNvSetMode"));
|
||||
const auto setBlock = reinterpret_cast<SetU32Fn>(GetProcAddress(stub, "FlStubNvSetBlockMs"));
|
||||
const auto hide = reinterpret_cast<SetU32Fn>(GetProcAddress(stub, "FlStubNvHideGetters"));
|
||||
const auto latencyCalls = reinterpret_cast<GetU32Fn>(GetProcAddress(stub, "FlStubNvLatencyCalls"));
|
||||
const auto lastDevice = reinterpret_cast<GetPtrFn>(GetProcAddress(stub, "FlStubNvLastDevice"));
|
||||
if (setMode == nullptr || setBlock == nullptr || hide == nullptr || latencyCalls == nullptr ||
|
||||
lastDevice == nullptr) {
|
||||
std::printf("FAIL the module at that path is not the stub\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 2. A module that does not have the getters.
|
||||
hide(1u);
|
||||
Check(fl::reflex::Resolve(api) == Resolved::NoGetter, "a getter the module does not have -> NoGetter");
|
||||
Check(api.getLatency == nullptr, "and nothing half-resolved is kept");
|
||||
hide(0u);
|
||||
Check(fl::reflex::Resolve(api) == Resolved::Ok, "both getters resolved by interface id");
|
||||
|
||||
IDXGIFactory4* factory = nullptr;
|
||||
if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory4), reinterpret_cast<void**>(&factory)))) {
|
||||
std::printf("SKIP no DXGI factory\n");
|
||||
return 77;
|
||||
}
|
||||
IDXGIAdapter1* adapter = FindAdapter(factory, false);
|
||||
Dx11 dx11{};
|
||||
Dx12 dx12{};
|
||||
const bool have11 = MakeDx11(factory, adapter, dx11);
|
||||
const bool have12 = MakeDx12(factory, adapter, dx12);
|
||||
if (!have11) {
|
||||
std::printf("SKIP no Direct3D 11 device here\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
static NV_LATENCY_RESULT_PARAMS report;
|
||||
NV_GET_SLEEP_STATUS_PARAMS sleep{};
|
||||
|
||||
// 3. Sixty-four reports, read as the header lays them out, with the device handed through untouched.
|
||||
setMode(0u);
|
||||
Check(fl::reflex::ReadLatency(api, dx11.device, report) == NVAPI_OK, "D3D11: the report is read");
|
||||
fl::reflex::Digest d = fl::reflex::Summarise(report);
|
||||
Check(d.valid == 64u && d.newestFrameId == 5063u, "sixty-four frames, the newest last");
|
||||
Check(d.newestSimToPresentEnd == 2200u && d.newestSimToGpuEnd == 7500u && d.newestGpuActiveUs == 3500u,
|
||||
"the spans are the ones the stub wrote");
|
||||
Check(lastDevice() == dx11.device, "the driver was handed the device, and only the device");
|
||||
if (have12) {
|
||||
Check(fl::reflex::ReadLatency(api, dx12.device, report) == NVAPI_OK && lastDevice() == dx12.device,
|
||||
"D3D12: the same call with the ID3D12Device the Overlay already holds");
|
||||
} else {
|
||||
std::printf("NOTE no Direct3D 12 device here; that half is not run\n");
|
||||
}
|
||||
Check(fl::reflex::ReadSleepStatus(api, dx11.device, sleep) == NVAPI_OK && sleep.bLowLatencyMode != 0 &&
|
||||
sleep.sleepIntervalUs == 4166u && sleep.fgMultiplier == 2,
|
||||
"the sleep status is read");
|
||||
|
||||
// 4. A game that set no marker (nvapi.h: every frame comes back zero), and a driver that says no.
|
||||
setMode(1u);
|
||||
Check(fl::reflex::ReadLatency(api, dx11.device, report) == NVAPI_OK && fl::reflex::Summarise(report).valid == 0u,
|
||||
"a report of nothing is zero frames, not sixty-four");
|
||||
setMode(2u);
|
||||
Check(fl::reflex::ReadLatency(api, dx11.device, report) == NVAPI_ERROR, "an error is returned as the error");
|
||||
Check(fl::reflex::ReadSleepStatus(api, dx11.device, sleep) == NVAPI_ERROR, "for the sleep status as well");
|
||||
Check(fl::reflex::ReadLatency(api, nullptr, report) == NVAPI_INVALID_ARGUMENT &&
|
||||
latencyCalls() == (have12 ? 4u : 3u),
|
||||
"no device, no call: the driver was not entered");
|
||||
setMode(0u);
|
||||
|
||||
// 5. A call that does not come back for a while. On a thread of its own, nothing else waits for it...
|
||||
setBlock(1500u);
|
||||
Ticker ticker{};
|
||||
ticker.api = api;
|
||||
ticker.device = dx11.device;
|
||||
HANDLE tick = CreateThread(nullptr, 0, &TickerThread, &ticker, 0, nullptr);
|
||||
Sleep(300);
|
||||
BlockedCall blocked{api, dx11.device, NVAPI_ERROR};
|
||||
const std::uint32_t before = ticker.ticks.load();
|
||||
const double began = QpcSeconds();
|
||||
HANDLE caller = CreateThread(nullptr, 0, &BlockedCallThread, &blocked, 0, nullptr);
|
||||
Sleep(1000);
|
||||
const std::uint32_t during = ticker.ticks.load() - before;
|
||||
Check(during >= 10u, "a call blocked on its own thread: the ticking thread went on (>= 10 ticks in the second)");
|
||||
WaitForSingleObject(caller, 5000);
|
||||
const double took = QpcSeconds() - began;
|
||||
Check(blocked.status == NVAPI_OK && took >= 1.4, "and the blocked call came back with its report");
|
||||
std::printf("NOTE the blocked call took %.2f s; the other thread ticked %u times in its first second\n", took,
|
||||
during);
|
||||
CloseHandle(caller);
|
||||
|
||||
// ...and made BY the ticking thread, that thread stands still for as long as the driver keeps it.
|
||||
const std::uint32_t before2 = ticker.ticks.load();
|
||||
ticker.callNow.store(1u);
|
||||
Sleep(1000);
|
||||
const std::uint32_t during2 = ticker.ticks.load() - before2;
|
||||
Check(during2 <= 3u, "the same call made by the ticking thread: it stopped ticking while the driver held it");
|
||||
std::printf("NOTE made by the ticking thread itself, it ticked %u times in that second\n", during2);
|
||||
Sleep(1000);
|
||||
ticker.quit.store(1u);
|
||||
WaitForSingleObject(tick, 3000);
|
||||
CloseHandle(tick);
|
||||
setBlock(0u);
|
||||
|
||||
FreeDx12(dx12);
|
||||
FreeDx11(dx11);
|
||||
ReleaseIf(adapter);
|
||||
ReleaseIf(factory);
|
||||
std::printf("%s: %d failure(s)\n", g_failures == 0 ? "STUB OK" : "STUB FAILED", g_failures);
|
||||
return g_failures == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// --real: the installed driver. The probe is the "game" here: it loads NVAPI, initialises it and sets markers.
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
constexpr unsigned int kIdInitialize = 0x0150e828u; // nvapi_interface.h: NvAPI_Initialize
|
||||
constexpr unsigned int kIdUnload = 0xd22bdd7eu; // NvAPI_Unload
|
||||
constexpr unsigned int kIdSetLatencyMarker = 0xd9984c05u; // NvAPI_D3D_SetLatencyMarker -- the game's call
|
||||
|
||||
using PlainFn = NvAPI_Status(__cdecl*)();
|
||||
using SetMarkerFn = NvAPI_Status(__cdecl*)(IUnknown*, NV_LATENCY_MARKER_PARAMS*);
|
||||
|
||||
struct Game {
|
||||
SetMarkerFn setMarker = nullptr;
|
||||
IUnknown* markerDevice = nullptr;
|
||||
std::uint64_t frame = 0;
|
||||
std::uint32_t markerErrors = 0;
|
||||
NvAPI_Status lastMarkerStatus = NVAPI_OK;
|
||||
};
|
||||
|
||||
void Mark(Game& g, NV_LATENCY_MARKER_TYPE type) noexcept {
|
||||
NV_LATENCY_MARKER_PARAMS p{};
|
||||
p.version = NV_LATENCY_MARKER_PARAMS_VER1;
|
||||
p.frameID = g.frame;
|
||||
p.markerType = type;
|
||||
const NvAPI_Status s = g.setMarker(g.markerDevice, &p);
|
||||
if (s != NVAPI_OK) {
|
||||
++g.markerErrors;
|
||||
g.lastMarkerStatus = s;
|
||||
}
|
||||
}
|
||||
|
||||
void Frame11(Game& g, Dx11& dx, bool markers) noexcept {
|
||||
++g.frame;
|
||||
if (markers) {
|
||||
Mark(g, SIMULATION_START);
|
||||
Mark(g, SIMULATION_END);
|
||||
Mark(g, RENDERSUBMIT_START);
|
||||
}
|
||||
const float colour[4] = {static_cast<float>(g.frame % 255u) / 255.0f, 0.2f, 0.4f, 1.0f};
|
||||
dx.context->OMSetRenderTargets(1, &dx.target, nullptr);
|
||||
dx.context->ClearRenderTargetView(dx.target, colour);
|
||||
if (markers) {
|
||||
Mark(g, RENDERSUBMIT_END);
|
||||
Mark(g, PRESENT_START);
|
||||
}
|
||||
dx.chain->Present(0, 0);
|
||||
if (markers) {
|
||||
Mark(g, PRESENT_END);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame12(Game& g, Dx12& dx) noexcept {
|
||||
++g.frame;
|
||||
Mark(g, SIMULATION_START);
|
||||
Mark(g, SIMULATION_END);
|
||||
Mark(g, RENDERSUBMIT_START);
|
||||
Mark(g, RENDERSUBMIT_END);
|
||||
Mark(g, PRESENT_START);
|
||||
dx.chain->Present(0, 0);
|
||||
Mark(g, PRESENT_END);
|
||||
}
|
||||
|
||||
void PrintDigest(const char* label, NvAPI_Status status, const NV_LATENCY_RESULT_PARAMS& report) noexcept {
|
||||
const fl::reflex::Digest d = fl::reflex::Summarise(report);
|
||||
std::printf("%-46s status %d, frames with anything %u, newest id %llu, sim->presentEnd %llu, sim->gpuEnd %llu, "
|
||||
"gpuActive %u us\n",
|
||||
label, static_cast<int>(status), d.valid, static_cast<unsigned long long>(d.newestFrameId),
|
||||
static_cast<unsigned long long>(d.newestSimToPresentEnd),
|
||||
static_cast<unsigned long long>(d.newestSimToGpuEnd), d.newestGpuActiveUs);
|
||||
}
|
||||
|
||||
struct Poller {
|
||||
fl::reflex::Api api;
|
||||
IUnknown* device = nullptr;
|
||||
std::atomic<std::uint32_t> quit{0};
|
||||
std::atomic<std::uint32_t> paused{0};
|
||||
std::atomic<std::uint32_t> intervalMs{250}; // 0: one read after another, as fast as the driver answers
|
||||
std::uint32_t calls = 0;
|
||||
std::uint32_t notOk = 0;
|
||||
std::uint32_t faults = 0;
|
||||
double worstSeconds = 0.0;
|
||||
std::uint32_t emptyReports = 0;
|
||||
};
|
||||
|
||||
DWORD WINAPI PollerThread(LPVOID p) noexcept {
|
||||
auto* poll = static_cast<Poller*>(p);
|
||||
static NV_LATENCY_RESULT_PARAMS report;
|
||||
NV_GET_SLEEP_STATUS_PARAMS sleep{};
|
||||
while (poll->quit.load(std::memory_order_acquire) == 0u) {
|
||||
if (poll->paused.load(std::memory_order_acquire) != 0u) {
|
||||
Sleep(50);
|
||||
continue;
|
||||
}
|
||||
const double t0 = QpcSeconds();
|
||||
const NvAPI_Status a = fl::reflex::ReadLatency(poll->api, poll->device, report);
|
||||
const NvAPI_Status b = fl::reflex::ReadSleepStatus(poll->api, poll->device, sleep);
|
||||
const double took = QpcSeconds() - t0;
|
||||
++poll->calls;
|
||||
poll->notOk += (a != NVAPI_OK || b != NVAPI_OK) ? 1u : 0u;
|
||||
poll->faults += (a == fl::reflex::kFaulted || b == fl::reflex::kFaulted) ? 1u : 0u;
|
||||
poll->emptyReports += (a == NVAPI_OK && fl::reflex::Summarise(report).valid == 0u) ? 1u : 0u;
|
||||
if (took > poll->worstSeconds) {
|
||||
poll->worstSeconds = took;
|
||||
}
|
||||
const std::uint32_t interval = poll->intervalMs.load(std::memory_order_relaxed);
|
||||
if (interval != 0u) {
|
||||
Sleep(interval);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Microseconds a call, over `n` calls: the mean, the median and the worst.
|
||||
struct Cost {
|
||||
double mean = 0.0;
|
||||
double median = 0.0;
|
||||
double worst = 0.0;
|
||||
};
|
||||
|
||||
template <class Call>
|
||||
Cost Measure(int n, const Call& call) noexcept {
|
||||
static double samples[4096];
|
||||
if (n <= 0) {
|
||||
return Cost{};
|
||||
}
|
||||
if (n > 4096) {
|
||||
n = 4096;
|
||||
}
|
||||
double sum = 0.0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const double t0 = QpcSeconds();
|
||||
call();
|
||||
samples[i] = (QpcSeconds() - t0) * 1e6;
|
||||
sum += samples[i];
|
||||
}
|
||||
for (int i = 1; i < n; ++i) { // insertion sort: a few thousand doubles, once
|
||||
const double v = samples[i];
|
||||
int j = i - 1;
|
||||
while (j >= 0 && samples[j] > v) {
|
||||
samples[j + 1] = samples[j];
|
||||
--j;
|
||||
}
|
||||
samples[j + 1] = v;
|
||||
}
|
||||
return Cost{sum / n, samples[n / 2], samples[n - 1]};
|
||||
}
|
||||
|
||||
double FramesPerSecond11(Game& g, Dx11& dx, double seconds) noexcept {
|
||||
const double t0 = QpcSeconds();
|
||||
std::uint32_t frames = 0;
|
||||
while (QpcSeconds() - t0 < seconds) {
|
||||
Frame11(g, dx, true);
|
||||
++frames;
|
||||
}
|
||||
return static_cast<double>(frames) / (QpcSeconds() - t0);
|
||||
}
|
||||
|
||||
int RunReal(int pollSeconds) noexcept {
|
||||
IDXGIFactory4* factory = nullptr;
|
||||
if (FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory4), reinterpret_cast<void**>(&factory)))) {
|
||||
std::printf("SKIP no DXGI factory\n");
|
||||
return 77;
|
||||
}
|
||||
IDXGIAdapter1* adapter = FindAdapter(factory, true);
|
||||
if (adapter == nullptr) {
|
||||
std::printf("SKIP no NVIDIA adapter on this PC\n");
|
||||
return 77;
|
||||
}
|
||||
DXGI_ADAPTER_DESC1 desc{};
|
||||
adapter->GetDesc1(&desc);
|
||||
std::printf("adapter: %ls\n", desc.Description);
|
||||
|
||||
// THE GAME'S PART: nvapi64.dll from the system directory, by full path, and NvAPI_Initialize.
|
||||
wchar_t path[MAX_PATH]{};
|
||||
const UINT n = GetSystemDirectoryW(path, MAX_PATH);
|
||||
if (n == 0 || n + 16 > MAX_PATH) {
|
||||
return 77;
|
||||
}
|
||||
wcscat_s(path, L"\\nvapi64.dll");
|
||||
fl::reflex::Api api{};
|
||||
std::printf("before the game loaded it: Resolve = %u (1 = NoModule)\n",
|
||||
static_cast<unsigned>(fl::reflex::Resolve(api)));
|
||||
HMODULE nvapi = LoadLibraryExW(path, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (nvapi == nullptr) {
|
||||
std::printf("SKIP %ls did not load (%lu)\n", path, GetLastError());
|
||||
return 77;
|
||||
}
|
||||
const auto query = reinterpret_cast<fl::reflex::QueryInterfaceFn>(GetProcAddress(nvapi, "nvapi_QueryInterface"));
|
||||
const auto initialize = query != nullptr ? reinterpret_cast<PlainFn>(query(kIdInitialize)) : nullptr;
|
||||
const auto unload = query != nullptr ? reinterpret_cast<PlainFn>(query(kIdUnload)) : nullptr;
|
||||
Game game{};
|
||||
game.setMarker = query != nullptr ? reinterpret_cast<SetMarkerFn>(query(kIdSetLatencyMarker)) : nullptr;
|
||||
if (initialize == nullptr || game.setMarker == nullptr) {
|
||||
std::printf("SKIP this nvapi64.dll does not answer the ids\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
Dx11 dx11{};
|
||||
if (!MakeDx11(factory, adapter, dx11)) {
|
||||
std::printf("SKIP no Direct3D 11 device on the NVIDIA adapter\n");
|
||||
return 77;
|
||||
}
|
||||
static NV_LATENCY_RESULT_PARAMS report;
|
||||
NV_GET_SLEEP_STATUS_PARAMS sleep{};
|
||||
|
||||
// R0. THE GETTERS BEFORE NvAPI_Initialize -- a game that has the module but has not initialised it.
|
||||
std::printf("Resolve with the module loaded: %u (0 = Ok)\n", static_cast<unsigned>(fl::reflex::Resolve(api)));
|
||||
PrintDigest("R0 before NvAPI_Initialize:", fl::reflex::ReadLatency(api, dx11.device, report), report);
|
||||
std::printf("NvAPI_Initialize: %d\n", static_cast<int>(initialize()));
|
||||
|
||||
// R1. Initialised, no marker ever set: what a game that does not use Reflex gives.
|
||||
for (int i = 0; i < 120; ++i) {
|
||||
Frame11(game, dx11, false);
|
||||
}
|
||||
PrintDigest("R1 D3D11, 120 frames, no marker:", fl::reflex::ReadLatency(api, dx11.device, report), report);
|
||||
const NvAPI_Status s1 = fl::reflex::ReadSleepStatus(api, dx11.device, sleep);
|
||||
std::printf(" sleep status %d: lowLatency %u, fsVrr %u, cplVsync %u, interval %u us, gameSleep %u, iFlip %u, "
|
||||
"fgMultiplier %u\n",
|
||||
static_cast<int>(s1), static_cast<unsigned>(sleep.bLowLatencyMode), static_cast<unsigned>(sleep.bFsVrr),
|
||||
static_cast<unsigned>(sleep.bCplVsyncOn), static_cast<unsigned>(sleep.sleepIntervalUs),
|
||||
static_cast<unsigned>(sleep.bUseGameSleep), static_cast<unsigned>(sleep.bFullscreenIFlip),
|
||||
static_cast<unsigned>(sleep.fgMultiplier));
|
||||
|
||||
// R2. The game sets markers: 300 frames.
|
||||
game.markerDevice = dx11.device;
|
||||
const double began = QpcSeconds();
|
||||
for (int i = 0; i < 300; ++i) {
|
||||
Frame11(game, dx11, true);
|
||||
}
|
||||
const double frameSeconds = (QpcSeconds() - began) / 300.0;
|
||||
std::printf("markers: %u error(s), last status %d; a frame took %.1f us by this probe's clock\n", game.markerErrors,
|
||||
static_cast<int>(game.lastMarkerStatus), frameSeconds * 1e6);
|
||||
PrintDigest("R2 D3D11, 300 frames with markers:", fl::reflex::ReadLatency(api, dx11.device, report), report);
|
||||
{
|
||||
// The unit of the report's times: the gap between two neighbouring frames' simStartTime against the probe's
|
||||
// own measured frame time.
|
||||
const auto& a = report.frameReport[62];
|
||||
const auto& b = report.frameReport[63];
|
||||
std::printf(" frames 62,63: id %llu,%llu simStart %llu,%llu (gap %llu) gpuFrameTimeUs %u\n",
|
||||
static_cast<unsigned long long>(a.frameID), static_cast<unsigned long long>(b.frameID),
|
||||
static_cast<unsigned long long>(a.simStartTime), static_cast<unsigned long long>(b.simStartTime),
|
||||
static_cast<unsigned long long>(b.simStartTime - a.simStartTime),
|
||||
static_cast<unsigned>(b.gpuFrameTimeUs));
|
||||
// Every time of the last four frames, as its distance from that frame's simStartTime ("-" where the driver
|
||||
// left the field zero): which fields a report fills in, and when a frame's report is complete.
|
||||
for (int i = 60; i < 64; ++i) {
|
||||
const auto& r = report.frameReport[i];
|
||||
const std::uint64_t fields[] = {r.inputSampleTime, r.simEndTime, r.renderSubmitStartTime,
|
||||
r.renderSubmitEndTime, r.presentStartTime, r.presentEndTime,
|
||||
r.driverStartTime, r.driverEndTime, r.osRenderQueueStartTime,
|
||||
r.osRenderQueueEndTime, r.gpuRenderStartTime, r.gpuRenderEndTime};
|
||||
static const char* const names[] = {"input", "simEnd", "subStart", "subEnd", "presStart", "presEnd",
|
||||
"drvStart", "drvEnd", "osqStart", "osqEnd", "gpuStart", "gpuEnd"};
|
||||
std::printf(" frame %d id %llu:", i, static_cast<unsigned long long>(r.frameID));
|
||||
for (int f = 0; f < 12; ++f) {
|
||||
if (fields[f] == 0u) {
|
||||
std::printf(" %s -", names[f]);
|
||||
} else {
|
||||
std::printf(" %s %lld", names[f],
|
||||
static_cast<long long>(fields[f]) - static_cast<long long>(r.simStartTime));
|
||||
}
|
||||
}
|
||||
std::printf(" | gpuActive %u gpuFrame %u\n", static_cast<unsigned>(r.gpuActiveRenderTimeUs),
|
||||
static_cast<unsigned>(r.gpuFrameTimeUs));
|
||||
}
|
||||
}
|
||||
|
||||
// R3. What a call costs, on the thread that presents, between two frames.
|
||||
const Cost latency = Measure(2000, [&]() noexcept { fl::reflex::ReadLatency(api, dx11.device, report); });
|
||||
const Cost status = Measure(2000, [&]() noexcept { fl::reflex::ReadSleepStatus(api, dx11.device, sleep); });
|
||||
std::printf("R3 GetLatency us a call: mean %.2f, median %.2f, worst %.2f (2000 calls)\n", latency.mean,
|
||||
latency.median, latency.worst);
|
||||
std::printf("R3 GetSleepStatus us a call: mean %.2f, median %.2f, worst %.2f (2000 calls)\n", status.mean,
|
||||
status.median, status.worst);
|
||||
|
||||
// R4. The getters on ANOTHER thread, four times a second, while this one presents and sets markers.
|
||||
// LEGS OF TEN SECONDS, ALTERNATING -- alone, beside the poller, alone, ... -- because one long leg against one
|
||||
// short one measures the drift of an uncapped loop over a minute, not the poller (the first run of this probe
|
||||
// compared 5 s alone with 60 s beside and read 1.3 % apart).
|
||||
Poller poll{};
|
||||
poll.api = api;
|
||||
poll.device = dx11.device;
|
||||
poll.paused.store(1u);
|
||||
HANDLE thread = CreateThread(nullptr, 0, &PollerThread, &poll, 0, nullptr);
|
||||
double aloneSum = 0.0;
|
||||
double besideSum = 0.0;
|
||||
const int legs = pollSeconds / 10 > 0 ? pollSeconds / 10 : 1;
|
||||
for (int leg = 0; leg < legs; ++leg) {
|
||||
poll.paused.store(1u);
|
||||
const double alone = FramesPerSecond11(game, dx11, 10.0);
|
||||
poll.paused.store(0u);
|
||||
const double beside = FramesPerSecond11(game, dx11, 10.0);
|
||||
aloneSum += alone;
|
||||
besideSum += beside;
|
||||
std::printf("R4 leg %d: frames a second %.0f alone, %.0f beside the poller (%+.2f %%)\n", leg + 1, alone,
|
||||
beside, (beside - alone) * 100.0 / alone);
|
||||
}
|
||||
const std::uint32_t slowCalls = poll.calls;
|
||||
const std::uint32_t slowNotOk = poll.notOk;
|
||||
const double slowWorst = poll.worstSeconds;
|
||||
|
||||
// THE SAME WITH THE POLLER READING WITHOUT A PAUSE -- hundreds of thousands of reads a second where route D would
|
||||
// make four. The legs above cannot tell half a percent from the loop's own drift; a dose this large can be seen,
|
||||
// and what four reads a second cost is that, scaled down by the ratio of the two rates.
|
||||
poll.intervalMs.store(0u);
|
||||
double aloneFast = 0.0;
|
||||
double besideFast = 0.0;
|
||||
std::uint32_t fastCallsBefore = poll.calls;
|
||||
for (int leg = 0; leg < 3; ++leg) {
|
||||
poll.paused.store(1u);
|
||||
const double alone = FramesPerSecond11(game, dx11, 10.0);
|
||||
poll.paused.store(0u);
|
||||
const double beside = FramesPerSecond11(game, dx11, 10.0);
|
||||
aloneFast += alone;
|
||||
besideFast += beside;
|
||||
std::printf("R4b leg %d: frames a second %.0f alone, %.0f beside a poller that never pauses (%+.2f %%)\n",
|
||||
leg + 1, alone, beside, (beside - alone) * 100.0 / alone);
|
||||
}
|
||||
poll.quit.store(1u);
|
||||
WaitForSingleObject(thread, 5000);
|
||||
CloseHandle(thread);
|
||||
std::printf("R4b 30 s beside a poller that never pauses: %u reads (%.0f a second), %u not OK, %u faulted, worst "
|
||||
"read %.1f us; frames a second %.0f alone, %.0f beside it (%+.2f %%); marker errors %u\n",
|
||||
poll.calls - fastCallsBefore, static_cast<double>(poll.calls - fastCallsBefore) / 30.0,
|
||||
poll.notOk - slowNotOk, poll.faults, poll.worstSeconds * 1e6, aloneFast / 3.0, besideFast / 3.0,
|
||||
(besideFast - aloneFast) * 100.0 / aloneFast, game.markerErrors);
|
||||
poll.calls = slowCalls;
|
||||
poll.notOk = slowNotOk;
|
||||
poll.worstSeconds = slowWorst;
|
||||
std::printf("R4 %d s beside a poller in %d legs: %u reads, %u not OK, %u faulted, %u empty, worst read %.1f us; "
|
||||
"frames a second %.0f alone, %.0f beside it (%+.2f %%); marker errors %u\n",
|
||||
legs * 10, legs, poll.calls, poll.notOk, poll.faults, poll.emptyReports, poll.worstSeconds * 1e6,
|
||||
aloneSum / legs, besideSum / legs, (besideSum - aloneSum) * 100.0 / aloneSum, game.markerErrors);
|
||||
|
||||
// R5. Direct3D 12: which object the driver wants -- the device (what the Overlay holds) or the queue.
|
||||
Dx12 dx12{};
|
||||
if (MakeDx12(factory, adapter, dx12)) {
|
||||
Game game12{};
|
||||
game12.setMarker = game.setMarker;
|
||||
game12.markerDevice = dx12.device;
|
||||
game12.frame = 100000;
|
||||
for (int i = 0; i < 300; ++i) {
|
||||
Frame12(game12, dx12);
|
||||
}
|
||||
std::printf("R5 D3D12, markers on the DEVICE: %u error(s), last status %d\n", game12.markerErrors,
|
||||
static_cast<int>(game12.lastMarkerStatus));
|
||||
PrintDigest("R5 D3D12, read with the device:", fl::reflex::ReadLatency(api, dx12.device, report), report);
|
||||
PrintDigest("R5 D3D12, read with the queue:", fl::reflex::ReadLatency(api, dx12.queue, report), report);
|
||||
const NvAPI_Status s12 = fl::reflex::ReadSleepStatus(api, dx12.device, sleep);
|
||||
std::printf(" sleep status with the device %d, with the queue %d\n", static_cast<int>(s12),
|
||||
static_cast<int>(fl::reflex::ReadSleepStatus(api, dx12.queue, sleep)));
|
||||
Game queue12{};
|
||||
queue12.setMarker = game.setMarker;
|
||||
queue12.markerDevice = dx12.queue;
|
||||
queue12.frame = 200000;
|
||||
for (int i = 0; i < 300; ++i) {
|
||||
Frame12(queue12, dx12);
|
||||
}
|
||||
std::printf("R5 D3D12, markers on the QUEUE: %u error(s), last status %d\n", queue12.markerErrors,
|
||||
static_cast<int>(queue12.lastMarkerStatus));
|
||||
PrintDigest("R5 D3D12, read with the device after that:", fl::reflex::ReadLatency(api, dx12.device, report),
|
||||
report);
|
||||
FreeDx12(dx12);
|
||||
} else {
|
||||
std::printf("R5 no Direct3D 12 device on the NVIDIA adapter\n");
|
||||
}
|
||||
|
||||
FreeDx11(dx11);
|
||||
if (unload != nullptr) {
|
||||
std::printf("NvAPI_Unload: %d\n", static_cast<int>(unload()));
|
||||
}
|
||||
ReleaseIf(adapter);
|
||||
ReleaseIf(factory);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int wmain(int argc, wchar_t** argv) {
|
||||
if (argc >= 3 && wcscmp(argv[1], L"--stub") == 0) {
|
||||
return RunStub(argv[2]);
|
||||
}
|
||||
if (argc >= 2 && wcscmp(argv[1], L"--real") == 0) {
|
||||
return RunReal(argc >= 3 ? _wtoi(argv[2]) : 60);
|
||||
}
|
||||
std::printf("usage: fl-probe-reflex --stub <path to the stub nvapi64.dll> | --real [seconds beside a poller]\n");
|
||||
return 2;
|
||||
}
|
||||
@@ -84,3 +84,20 @@ fl_add_vendor_stub(fl_stub_ffx_loader "amd_fidelityfx_loader_dx12" stub_amd_fide
|
||||
# is therefore hookinventory-check Pass C's SECOND positive control for the export
|
||||
# parser, beside the ffx-api leaf.
|
||||
fl_add_vendor_stub(fl_stub_ffx_fsr3_host "ffx_fsr3_x64" stub_ffx_fsr3_x64.cpp)
|
||||
|
||||
# --- NVIDIA NVAPI, for the spike of Reflex route D (docs/spike-notes §31, owner decision D132) ---
|
||||
#
|
||||
# A stand-in for nvapi64.dll: the real module's one way in (nvapi_QueryInterface) answering the two getters route D
|
||||
# would call, with knobs for what a driver cannot be made to do on demand -- a missing getter, a report of nothing,
|
||||
# an error, a call that does not return for seconds. Used by fl-probe-reflex only; the Overlay is not involved and
|
||||
# no inventory row names it, so it takes the vendored NVAPI headers (the include directory alone -- nvapi64.lib is
|
||||
# not linked) and nothing of the hook inventory.
|
||||
#
|
||||
# ITS OWN SUBDIRECTORY for its outputs: a file called nvapi64.lib beside the other stubs' import libraries would be
|
||||
# one careless link line away from being taken for the vendored one.
|
||||
fl_add_vendor_stub(fl_stub_nvapi64 "nvapi64" stub_nvapi64.cpp)
|
||||
target_include_directories(fl_stub_nvapi64 SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/third_party/nvapi")
|
||||
set_target_properties(fl_stub_nvapi64 PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/nvapi"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/nvapi"
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/nvapi")
|
||||
@@ -0,0 +1,151 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
// A stand-in for NVIDIA's nvapi64.dll, for the spike of Reflex route D (docs/spike-notes §31, owner decision D132).
|
||||
//
|
||||
// NOT A VENDOR LIBRARY AND NOT SHIPPED. It carries the one name the real module's callers resolve everything through
|
||||
// -- nvapi_QueryInterface -- and answers two interface ids, the two getters route D would call:
|
||||
// NvAPI_D3D_GetLatency and NvAPI_D3D_GetSleepStatus. The ids and the structs are the vendored MIT headers' own
|
||||
// (nvapi_interface.h, nvapi.h), so the probe and this stub cannot disagree about either.
|
||||
//
|
||||
// WHAT IT IS FOR: the things a real driver cannot be made to do on demand. A getter that is not there, a report of
|
||||
// nothing, an error, and a call that does not come back for seconds -- so that the probe can show each is harmless
|
||||
// before anything is tried against a driver, and long before anything is tried in a game.
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <nvapi.h>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr unsigned int kIdInitialize = 0x0150e828u;
|
||||
constexpr unsigned int kIdGetSleepStatus = 0xaef96ca1u;
|
||||
constexpr unsigned int kIdGetLatency = 0x1a587f9cu;
|
||||
|
||||
// 0: sixty-four reports. 1: a report of nothing (what the header says a game without markers gets). 2: an error.
|
||||
std::atomic<std::uint32_t> g_mode{0};
|
||||
std::atomic<std::uint32_t> g_blockMs{0};
|
||||
std::atomic<std::uint32_t> g_hideGetters{0};
|
||||
std::atomic<std::uint32_t> g_queries{0};
|
||||
std::atomic<std::uint32_t> g_latencyCalls{0};
|
||||
std::atomic<std::uint32_t> g_sleepStatusCalls{0};
|
||||
std::atomic<void*> g_lastDevice{nullptr};
|
||||
|
||||
NvAPI_Status __cdecl StubInitialize() {
|
||||
return NVAPI_OK;
|
||||
}
|
||||
|
||||
NvAPI_Status __cdecl StubGetLatency(IUnknown* device, NV_LATENCY_RESULT_PARAMS* out) {
|
||||
g_latencyCalls.fetch_add(1u, std::memory_order_relaxed);
|
||||
g_lastDevice.store(device, std::memory_order_relaxed);
|
||||
if (out == nullptr) {
|
||||
return NVAPI_INVALID_ARGUMENT;
|
||||
}
|
||||
if (out->version != NV_LATENCY_RESULT_PARAMS_VER1) {
|
||||
return NVAPI_INCOMPATIBLE_STRUCT_VERSION;
|
||||
}
|
||||
const std::uint32_t block = g_blockMs.load(std::memory_order_relaxed);
|
||||
if (block != 0u) {
|
||||
Sleep(block);
|
||||
}
|
||||
const std::uint32_t mode = g_mode.load(std::memory_order_relaxed);
|
||||
if (mode == 2u) {
|
||||
return NVAPI_ERROR;
|
||||
}
|
||||
if (mode == 1u) {
|
||||
return NVAPI_OK; // the caller's zeros are left as they are
|
||||
}
|
||||
// Sixty-four frames a little over four milliseconds apart, the newest last (nvapi.h: "element 63").
|
||||
for (std::uint32_t i = 0; i < 64u; ++i) {
|
||||
auto& r = out->frameReport[i];
|
||||
const std::uint64_t t = 1'000'000ull + static_cast<std::uint64_t>(i) * 4200ull;
|
||||
r.frameID = 5000ull + i;
|
||||
r.inputSampleTime = t;
|
||||
r.simStartTime = t + 100u;
|
||||
r.simEndTime = t + 900u;
|
||||
r.renderSubmitStartTime = t + 950u;
|
||||
r.renderSubmitEndTime = t + 2100u;
|
||||
r.presentStartTime = t + 2150u;
|
||||
r.presentEndTime = t + 2300u;
|
||||
r.driverStartTime = t + 2300u;
|
||||
r.driverEndTime = t + 2700u;
|
||||
r.osRenderQueueStartTime = t + 2700u;
|
||||
r.osRenderQueueEndTime = t + 3900u;
|
||||
r.gpuRenderStartTime = t + 3900u;
|
||||
r.gpuRenderEndTime = t + 7600u;
|
||||
r.gpuActiveRenderTimeUs = 3500u;
|
||||
r.gpuFrameTimeUs = 4200u;
|
||||
}
|
||||
return NVAPI_OK;
|
||||
}
|
||||
|
||||
NvAPI_Status __cdecl StubGetSleepStatus(IUnknown* device, NV_GET_SLEEP_STATUS_PARAMS* out) {
|
||||
g_sleepStatusCalls.fetch_add(1u, std::memory_order_relaxed);
|
||||
g_lastDevice.store(device, std::memory_order_relaxed);
|
||||
if (out == nullptr) {
|
||||
return NVAPI_INVALID_ARGUMENT;
|
||||
}
|
||||
if (out->version != NV_GET_SLEEP_STATUS_PARAMS_VER1) {
|
||||
return NVAPI_INCOMPATIBLE_STRUCT_VERSION;
|
||||
}
|
||||
if (g_mode.load(std::memory_order_relaxed) == 2u) {
|
||||
return NVAPI_ERROR;
|
||||
}
|
||||
out->bLowLatencyMode = 1;
|
||||
out->sleepIntervalUs = 4166u;
|
||||
out->bUseGameSleep = 1;
|
||||
out->fgMultiplier = 2;
|
||||
return NVAPI_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
// The real module's one way in: an address for an interface id, or null for one it does not have.
|
||||
__declspec(dllexport) void* __cdecl nvapi_QueryInterface(unsigned int id) {
|
||||
g_queries.fetch_add(1u, std::memory_order_relaxed);
|
||||
if (id == kIdInitialize) {
|
||||
return reinterpret_cast<void*>(&StubInitialize);
|
||||
}
|
||||
if (g_hideGetters.load(std::memory_order_relaxed) != 0u) {
|
||||
return nullptr;
|
||||
}
|
||||
if (id == kIdGetLatency) {
|
||||
return reinterpret_cast<void*>(&StubGetLatency);
|
||||
}
|
||||
if (id == kIdGetSleepStatus) {
|
||||
return reinterpret_cast<void*>(&StubGetSleepStatus);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The probe's knobs and counters. Names nobody else exports.
|
||||
__declspec(dllexport) void __cdecl FlStubNvSetMode(std::uint32_t mode) {
|
||||
g_mode.store(mode, std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) void __cdecl FlStubNvSetBlockMs(std::uint32_t milliseconds) {
|
||||
g_blockMs.store(milliseconds, std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) void __cdecl FlStubNvHideGetters(std::uint32_t hide) {
|
||||
g_hideGetters.store(hide, std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) std::uint32_t __cdecl FlStubNvQueries() {
|
||||
return g_queries.load(std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) std::uint32_t __cdecl FlStubNvLatencyCalls() {
|
||||
return g_latencyCalls.load(std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) std::uint32_t __cdecl FlStubNvSleepStatusCalls() {
|
||||
return g_sleepStatusCalls.load(std::memory_order_relaxed);
|
||||
}
|
||||
__declspec(dllexport) void* __cdecl FlStubNvLastDevice() {
|
||||
return g_lastDevice.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
Reference in new issue
Block a user