Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 8985e8134f fix: a refusal for a driver or service says "on this PC", the unhook notice promises nothing untrue, the GPU sensors follow the game's adapter, and the language-changing tests run alone (beta.13 PR-1)
The four follow-ups the beta.12 documentation audit left as chips; three of
them here, the fourth (Velopack deltas) rides the release PR.

S23-3. The guard's checks 2 and 2b are machine-wide: while Easy Anti-Cheat's
service runs for another title, every game refuses with BlockedService, and
the notice read "Easy Anti-Cheat was detected in this game". CaptureRefused
and SafetyUnhook gain an optional guardReason (additive; reason stays the
session's end reason), and BlockedService / BlockedDriver read
Safety_Refused_MachineWide_Format, Safety_Unhooked_MachineWide_Format and
Summary_Tier2_Why_MachineWide_Format (en/vi; ja as an English copy awaiting
the human safety review, like its siblings). Safety_Unhooked_Format loses
"will not inject into this game again until you enable it again", untrue both
ways since 2026-09-22. Formats.NamedRefusal is the one place a named refusal
is worded; SafetyNotices and HookingConsentResult both use it.

L1's adapter. SelectAdapter had no caller, and fixing that alone would have
changed little: the composite merges L3 > L2 > L1 per field, and L2 and L3
read their own first GPU. CaptureProgress carries the handshake's AdapterLuid;
the recorder hands it to the poller once (noted in the .partial);
CompositeTelemetrySource.SelectAdapter points L1 at it (IGpuAdapterSelector)
and tells the other layers its vendor (IGpuVendorFollower): L2 maps that
vendor's LHM node, L3 contributes nothing for a non-NVIDIA adapter. What stays
first-found is written in 18_GPU_VENDOR_APIS and LIMITATIONS.

Culture races. The strings-culture collection serialized its own members but
ran beside every other class; it now has a definition with
DisableParallelization, and StringsTests asserts xUnit bound it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 08:24:49 +07:00
42 changed files with 603 additions and 42 deletions

No files matched your search

+19
View File
@@ -28,6 +28,25 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Fixed
- **A refusal because of a driver or service said the anti-cheat "was detected in this game".** The guard's checks for
drivers and services are machine-wide: while Easy Anti-Cheat's service runs for another title, every game is refused,
and the notice named a game the user may not even own. It now says the anti-cheat is running on this PC — a driver or
service that may belong to another game or program — and the session summary says the same; a finding in the game
itself still says "in this game" (`20_OPEN_QUESTIONS` §S23-3, closed). The Agent's refusal and unhook events carry the
guard's own reason for this (`guardReason`, additive).
- **The notice for a mid-session stop promised "FrameLedger will not inject into this game again until you enable it
again"**, untrue both ways since beta.5: a driver or service that starts on the PC turns no hooking off, and a finding
in the game turns it off for good. It says where the finding was, and whether hooking was turned off.
- **On a PC with more than one graphics card, the GPU sensors could describe a card the game was not using.** The
adapter the game draws on is now followed once it has shown its first frame: the DXGI layer switches to it,
LibreHardwareMonitor reads that brand's GPU rather than the first one it lists (often a laptop's integrated GPU), and
NVAPI says nothing when the game runs on an AMD or Intel card — N/A rather than another card's temperature.
`LIMITATIONS.md` says what still describes the first card.
- **Tests that change the App's language ran beside tests that read its text**, so the second kind could read the
wrong language once in many runs; the language-changing tests now run on their own.
## [0.1.0-beta.12] - 2026-10-04
**The twelfth pre-release: how much memory each game itself uses, documents you can read, and a user guide.** The same
+5
View File
@@ -103,6 +103,11 @@ shown is recorded too, from outside the game. ([Capture](docs/04_CAPTURE.md))
- GPU temperature, load, power and memory are best supported on **NVIDIA** GPUs. **AMD and Intel GPUs have
not been tested** on real hardware yet.
- **On a PC with more than one graphics card**, the GPU figures follow the card the game draws on once a Direct3D game
has shown its first frame; before that, in an unmeasured session, and for OpenGL or Vulkan games they describe the
first card Windows lists, and with two cards of one brand the temperature and load come from that brand's first card.
The session's hardware details always name the first card. None of this has been tested on a machine with two cards.
([Telemetry](docs/18_GPU_VENDOR_APIS.md))
- **CPU temperature** needs *Run the agent as administrator* and the separately installed PawnIO driver, and
has not been verified on real hardware yet. CPU load is the time the processor was busy — not Task
Manager's "utility" figure, which can exceed 100%. ([Telemetry](docs/18_GPU_VENDOR_APIS.md))
+2 -2
View File
@@ -406,9 +406,9 @@ Unchanged in spirit from v1, bumped to `v2` for the new message set.
| `SessionHeld` | A→UI | **Added 2026-09-23.** 1 Hz while a client listens, for a session held unhooked only: `{ sessionGuid, elapsedS, gpuTempC?, cpuTempC?, gpuLoadPct?, cpuLoadPct?, gameVramDedicatedMb?, gameRamPrivateMb? }` — how long it has run and the machine's sensors (and since beta.12 the game process's own memory, read from outside it — optional, an older client ignores them). **Never `SessionProgress`**: its `presents5s`, `presentedQualifier` and `fgMode` are required, and zeros there would put measured-looking numbers on the wire for a session that measures nothing (rule 6 has nothing to show and shows nothing) |
| `SessionProgress` | A→UI | 1 Hz: `{ sessionGuid, elapsedS, presents5s, presentedFps5s?, presentedQualifier, nativeFps5s?, displayedFps5s?, fgFactor?, fgMode, upscaler?, upscalerQuality?, upscalerDriverReported?, renderW/H?, outputW/H?, rtActive?, gpuTempC?, cpuTempC?, cpuLoadPct?, vramProcMb?, latencyUs?, fgRefusal?, fgRuntimeCensus?, gameVramDedicatedMb?, gameRamPrivateMb? }` (the last two added 2026-10-03, beta.12, optional: the game process's dedicated GPU memory and private working set, MiB, from the newest telemetry tick; `vramProcMb` stays reserved for the in-process figure and has no producer) — a 5 s rolling window over the ring through the SAME Domain calculators the row uses (`SessionProgressCalculator`, D13). **`upscalerDriverReported` added 2026-09-21, optional:** `dlss` when the NVIDIA driver reports an NGX super-resolution feature created and evaluated in the target (`03_METRICS` §The driver-reported rung), so the live card says `DLSS (driver-reported)` where no hook can name the upscaler; identity only. **`cpuLoadPct` added 2026-09-21, optional** (CPU time busy over the last telemetry tick, 0–100; `cpuTempC` has a producer from the same date, present only when the Agent is elevated with PawnIO). **Two fields added 2026-09-14, both optional (an older client ignores them, §C):** `fgRefusal` is the row's `fg_refusal` (schema 0003) — present when `fgMode` names a technology and `fgFactor` is absent, so the live card can say "DLSS-G active — factor not counted" rather than N/A; `fgRuntimeCensus` is the raw census so the `fg_runtime_loaded` chip can name the module. **Rule 6 at the wire (2026-09-13):** `nativeFps5s` / `displayedFps5s` / `fgFactor` are present only when frame generation was measured in the window; otherwise `presentedFps5s` stands alone with `presentedQualifier` (`census_not_run` · `no_fg_runtime` · `fg_runtime_loaded` · `none_withheld`, the row's `presented_qualifier` from the same function). Every unmeasured field is absent, never 0. Suppressed when no client is connected |
| `SessionCompleted` | A→UI | `{ sessionGuid, sessionId?, exitStatus, tier, finalize, reason, gameId?, gameName? }` — UI loads the full row from SQLite; `sessionId` is null and `finalize` is `discarded` when the row was not stored (under the minimum length), or `game_removed` when its entry was removed with its sessions while it ran (2026-09-23), or **`faulted` when the session's task threw before it could finalize** (2026-09-23: it follows the `CaptureError SessionFaulted`, with `exitStatus` `interrupted` and `reason` `SessionFaulted`, so the live card and the tray let go of a session that no longer runs; the `.partial` stays for recovery); `exitStatus` is the row's vocabulary (`normal` · `crashed` · `unhooked_safety` · `degraded`); `reason` is the loop's `SessionEndReason`. **`gameId` / `gameName` added 2026-09-23, optional:** the entry the session was stored under — the finalizer's owner when it re-keyed a session whose entry was removed, else the one it started under — so the notice names the session that completed, not whatever the live card last showed |
| `CaptureRefused` | A→UI | `{ gameId, gameName, reason, family?, signal?, hookingTurnedOff }` — **guard fired**; `hookingTurnedOff` (2026-09-22) is true when the finding turned the game's hooking off (`19_SAFETY` §What a finding does to the game); UI shows the plain-language explanation — ~~and the Tier-2 offer~~; there is no alternative measurement to offer, only the option to record the session unmeasured (`08_UI` §Safety events). *(Built: for `RefusedByGuard`, `RefusedPreviouslyBlocked`, `RefusedKillSwitch`, `PreScanCouldNotVerify` and, since 2026-09-21 (beta.4), `TargetUnreadable` — a protected process the Agent could not open (added 2026-10-04) — `PreScanCouldNotVerify` with no family, because "could not verify" is neither a hit nor a pass; `family`/`signal` are the verdict's. A game merely not enabled or not consented raises nothing: that is an ordinary Tier-2 row, not a refusal to explain.)* |
| `CaptureRefused` | A→UI | `{ gameId, gameName, reason, family?, signal?, hookingTurnedOff, guardReason? }` — **`guardReason` (beta.13, optional)** is the guard's own reason when it named a family; `BlockedService` / `BlockedDriver` is a finding on the PC, not in the game, and the notice says so (§S23-3); `reason` stays the session's end reason — **guard fired**; `hookingTurnedOff` (2026-09-22) is true when the finding turned the game's hooking off (`19_SAFETY` §What a finding does to the game); UI shows the plain-language explanation — ~~and the Tier-2 offer~~; there is no alternative measurement to offer, only the option to record the session unmeasured (`08_UI` §Safety events). *(Built: for `RefusedByGuard`, `RefusedPreviouslyBlocked`, `RefusedKillSwitch`, `PreScanCouldNotVerify` and, since 2026-09-21 (beta.4), `TargetUnreadable` — a protected process the Agent could not open (added 2026-10-04) — `PreScanCouldNotVerify` with no family, because "could not verify" is neither a hit nor a pass; `family`/`signal` are the verdict's. A game merely not enabled or not consented raises nothing: that is an ordinary Tier-2 row, not a refusal to explain.)* |
| `CaptureDegraded` | A→UI | `{ sessionGuid, from: 1, to: 2, reason }` — Tier 1 → Tier 2 mid-flight, or overlay self-disabled. **Under a two-rung ladder this means measurement STOPPED**, not that it continued at lower fidelity, and the notice must say so. *(Built: `SupervisionLost`, `WriterSelfDisabled`, `WriterStoppedBlocklisted`, `WriterNeverInstalledHooks`, `SupervisionFaulted`, `KillSwitchEngaged` — `RecordedSessionEvents.Classify` is the table.)* |
| `SafetyUnhook` | A→UI | `{ sessionGuid, family?, signal?, hookingTurnedOff }` — anti-cheat appeared mid-session; prominent UI notice; `hookingTurnedOff` as on `CaptureRefused`. *(Built: the verdict that FIRED, not the pass that started the session — `CaptureOutcome.Verdict` carries the supervisor's last verdict on this reason since 2026-09-13.)* |
| `SafetyUnhook` | A→UI | `{ sessionGuid, family?, signal?, hookingTurnedOff, guardReason? }` — `guardReason` as on `CaptureRefused` (beta.13) — anti-cheat appeared mid-session; prominent UI notice; `hookingTurnedOff` as on `CaptureRefused`. *(Built: the verdict that FIRED, not the pass that started the session — `CaptureOutcome.Verdict` carries the supervisor's last verdict on this reason since 2026-09-13.)* |
| `HookingTurnedOff` | A→UI | `{ gameId, gameName?, reason, family?, signal? }` — **since 2026-09-25 (beta.8):** the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) found anti-cheat in a game whose hooking the user had turned on, and turned it off. Not a session event — no session is running — so the UI's notice carries no "record without measuring" action, only Dismiss (`SafetyNoticeKind.HookingOff`). A finding on a game whose hooking was already off sends nothing: its page and its library card change, nothing the user switched on did. Additive: a client that does not know the type ignores it (§Versioning). |
| `CaptureError` | A→UI | `{ sessionGuid?, code, message }` — `InjectFailed`, `RingVersionMismatch`, `AttachRefused`, ~~`EtwAccessDenied`~~ (struck 2026-09-13 with the tier), ~~`PresentMonMissing`~~ (retired with the tool, 2026-08-27 — a code naming an implementation nobody chose), `TelemetryUnavailable`, `DbWriteFailed`, `SessionFaulted` (the session's task threw before finalize; the `.partial` stays for recovery, and ~~no `SessionCompleted` follows~~ a `SessionCompleted` with `finalize: faulted` follows since 2026-09-23). *(Built: `RingVersionMismatch` for a layout / record-size / build-id refusal — the "restart the game after an update" case — `AttachRefused` for the rest of the ring's refusals, `InjectFailed` for a target that could not be started, pinned, read or singled out.)* |
| `Ping`/`Pong` | ~~both~~ UI→A | 15 s keepalive, **client-driven** (built 2026-09-13): the client pings, the Agent answers; the Agent initiates nothing on an idle connection |
+12
View File
@@ -138,6 +138,18 @@ The Menu sits in its own row **below** the TitleBar (never inside the drag regio
> `SafetyNoticesTests` (the three kinds, the sentence per refusal reason, the strip for errors, nothing for a
> session event, dismiss only by the user).
>
> **On this PC, not in this game — beta.13 (§S23-3).** A driver or a service is found machine-wide: while Easy
> Anti-Cheat's service runs for another title, every game refuses with `BlockedService`, and the notice said the
> family "was detected in this game". The events carry the guard's own reason (`guardReason`, `07_IPC`), and a
> `BlockedService` / `BlockedDriver` refusal reads `Safety_Refused_MachineWide_Format` ("… is running on this PC (…): a
> driver or service, which may belong to another game or program …"), an unhook `Safety_Unhooked_MachineWide_Format`,
> and the summary's Tier-2 reason `Summary_Tier2_Why_MachineWide_Format`; a module, a title list or a file in the game
> still reads "in this game". `Safety_Unhooked_Format` lost "will not inject into this game again until you enable it
> again", untrue both ways since 2026-09-22 (a machine-wide finding turns no hooking off; a finding about the game turns
> it off for good, which `Safety_HookingTurnedOff` then says). Without a `guardReason` — an older Agent — the notice
> reads as before. Tests: `SafetyNoticesTests.AServiceOrDriverIsOnThisPcAndAModuleIsInThisGame`,
> `…AnUnhookSaysWhereTheFindingWasAndPromisesNoReEnable`, `Tier2ReasonTests`.
>
> **Corrected 2026-09-14, after the owner saw a red bar with no way out.** WPF UI 4.3.0's `InfoBar` template has
> **no `ContentPresenter`**, so the action button above — placed as the InfoBar's Content, the only dismissal once
> `IsClosable="False"` removed the X — was never rendered. The view model was right and the screen was wrong.
+9 -1
View File
@@ -57,7 +57,15 @@ Implementations compose rather than compete:
> nothing calls `SelectAdapter` outside tests. L1 stays on the first hardware adapter in DXGI's high-performance order,
> as `HardwareSnapshotSource` does, and the handshake's `adapterLuid` is read by no managed code — so on a
> multi-adapter machine L1 can describe an adapter the game did not present on. The game's own memory, D43, is
> summed over every adapter and is not affected.)* Every
> summed over every adapter and is not affected.)* **Built in beta.13:** the recorder hands the handshake's
> `adapterLuid` to the poller at the first tick that carries one (`CaptureProgress.AdapterLuid`, noted in the
> `.partial`), and `CompositeTelemetrySource.SelectAdapter` points L1 at it (`IGpuAdapterSelector`) and tells the layers
> that read their own GPU its vendor (`IGpuVendorFollower`): L2 maps that vendor's GPU node instead of the first one
> LibreHardwareMonitor lists (on a laptop often the integrated GPU), and L3 contributes nothing when the game's adapter
> is not NVIDIA's — N/A rather than another card's temperature. **What stays first-found:** a session before the game's
> first present, a Tier-2 session (no handshake), a game presenting through OpenGL or Vulkan (they publish no LUID), two
> GPUs of one vendor (L2 and L3 take that vendor's first), and the session's hardware snapshot
> (`HardwareSnapshotSource`, taken before the first present). Every
> poller sample is stamped with QPC (`TelemetrySample.QpcTicks`), the ring's clock, and
> `QpcClockTests` pins `Stopwatch` / `TimeProvider.GetTimestamp` to the real counter.
+3 -3
View File
@@ -116,7 +116,7 @@ or it becomes the next stale status claim this file exists to record.
| **S19(c)** | ✅ **resolved 2026-09-06** | The fields are constants the schema pins and the guard never reads, because the policy is code by CLAUDE.md rule 2 and `19_SAFETY`; `rules-validate` now proves the schema rejects `action: "allow"` and `signerField: "CN"` (canary 3), so the data cannot say otherwise |
| **S19(d) residual** | ✅ **resolved 2026-08-05** | A second canary, **derived from the shipped document** rather than hand-written, carries `nameFragments: []` and must be rejected. The entry's stated consequence was overstated and is corrected in place: the generated floor would not have disappeared, `gen-ac-floor.ps1` hard-errors and the native build fails — what was unguarded is the *schema* half |
| **S20 feed half** | 🅓 **deferred ~~to P4~~, unscheduled — P4 closed without it (corrected 2026-10-04); rationale written 2026-09-06** | **FR-7.3 stays unmet and written as unmet**: the fetch needs a shipped Agent, §S4's signing and the privacy policy's rows, all P4; until then a rules edit ships with the next release, checksum-attested |
| **S23-3** | ~~🅓 **deferred to P3, rationale written 2026-09-06**~~ 🔴 **open: P3 shipped the refusal UI without it** *(corrected 2026-10-04: a machine-wide `BlockedService` / `BlockedDriver` notice still reads "… was detected in this game", `SafetyNotices.RefusalText`)* | `08_UI`'s refusal notice is wrong in the commonest case; the requirement reaches `08_UI` and the `Safety_*` keys in the PR that creates the first refusal UI — a string with no view would read as done |
| **S23-3** | ~~🅓 **deferred to P3, rationale written 2026-09-06**~~ ~~🔴 **open: P3 shipped the refusal UI without it**~~ ✅ **closed in beta.13** — the events carry the guard's own reason and a `BlockedService` / `BlockedDriver` notice says the family is running on this PC (`08_UI` §Safety events) *(it was 🔴 from 2026-10-04: a machine-wide notice still read "… was detected in this game")* | `08_UI`'s refusal notice is wrong in the commonest case; the requirement reaches `08_UI` and the `Safety_*` keys in the PR that creates the first refusal UI — a string with no view would read as done |
| **S23-5** | ✅ **resolved 2026-08-05** | Closed the way §S23-4 closed the same class — by **removing** the restatement, not correcting it — and `rules-validate` now fails when any `$comment` enumerates checks again. The rule's own first version was scoped to the wrong object and could not fire; it now walks every `$comment` and fails if it finds none |
| **S23-6** | ✅ **closed 2026-09-06** | `license-check` binds `THIRD_PARTY_NOTICES` bidirectionally, and the accuracy blocks are now ONE text — `legal/ACCURACY.md`, embedded verbatim in `README.md` and `DISCLAIMER.md` §4, gated by `tools/accuracy-check.ps1` (self-tested both directions). Truth stays a human's job; drift between copies no longer is |
| **S23-2** | 🚫 **owner only — no PR can close it** | `Rules / validate` is **not** a required status check on `main`. **Re-verified against the live branch protection 2026-08-05**, not repeated from the entry: `required_status_checks.contexts` is exactly `["check", "analyze (csharp, none)", "analyze (cpp, manual)"]` (`strict: true`, `enforce_admins: true`, `required_linear_history: true`). The `validate` job is path-filtered and `pull_request`-only, so a red removal check does not block the merge button. **The gate that exists to make the anti-cheat blocklist un-removable is advisory.** This is a branch-protection setting |
@@ -137,7 +137,7 @@ either work or a rationale written down:
correction. **S30 closed 2026-08-15 and S31 opened 2026-08-20**, and this bullet went on
naming S30 until 2026-08-27 — so the total below stayed right by coincidence rather than
by count.)*
- **three ⏳** — S2 part three, S4 signing, S23-3
- **three ⏳** — S2 part three, S4 signing, S23-3 *(S2 part three built 2026-09-06 and S23-3 closed in beta.13 — noted 2026-10-04; S4 signing stays deferred)*
- ~~two ◐~~ ~~**three ◐**~~ **two ◐ (2026-09-04)** — S14, S23-6. ~~**S31**~~ *(moved out of ❓ on 2026-08-27 when its test landed on row P2; **resolved 2026-09-04** when the token count landed on row P1 with `tokens/batch = 1.00` — the question answered by a second count rather than by an oracle)*
- **one 🔴** — S29, added by the audit that produced this recount; **five of its seven
findings are now closed**, and the residue is (a) the ungated managed drain and (d) the
@@ -3083,7 +3083,7 @@ required contexts are exactly `check`, `analyze (csharp, none)` and
the gate that exists to make the anti-cheat blocklist un-removable is advisory.
Fixing it is a branch-protection change, i.e. the owner's, not a code change.
**3. ~~🅓 Deferred to P3, rationale written 2026-09-06~~ 🔴 Open — P3 built the refusal UI without it (corrected 2026-10-04: `SafetyNotices.RefusalText` formats every named refusal as "… was detected in this game", so the measured case below still reads wrong) — `08_UI` describes a refusal notice that is wrong in the commonest case.** *(The requirement below must reach `08_UI` and the `Safety_*` keys in the PR that creates the first refusal UI, and not before: there is no UI to be wrong in yet, and a `.resx` string with no view is the kind of fix that reads as done. The spike log carries the measurement; this line is the reminder.)* It
**3. ~~🅓 Deferred to P3, rationale written 2026-09-06~~ ~~🔴 Open~~ ✅ Closed in beta.13 (`08_UI` §Safety events: a driver or service is said as running on this PC) — P3 built the refusal UI without it (corrected 2026-10-04: `SafetyNotices.RefusalText` formats every named refusal as "… was detected in this game", so the measured case below still reads wrong) — `08_UI` describes a refusal notice that is wrong in the commonest case.** *(The requirement below must reach `08_UI` and the `Safety_*` keys in the PR that creates the first refusal UI, and not before: there is no UI to be wrong in yet, and a `.resx` string with no view is the kind of fix that reads as done. The spike log carries the measurement; this line is the reminder.)* It
promises "the specific signal named in plain language". Measured (`spike-notes`
§13): while any Easy Anti-Cheat title is running, **every** target — including a
freshly spawned, unrelated process — refuses with `BlockedService` naming
+16 -1
View File
@@ -305,7 +305,10 @@ public static class Formats
case "RefusedHookNotEnabled":
return Strings.Summary_Tier2_Why_HookOff;
case "RefusedByGuard" or "SafetyUnhook" when n.GuardFamily is { Length: > 0 } family:
return string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_Guard_Format, family, n.GuardSignal ?? Strings.Common_NotAvailable);
// A driver or service is on the PC, not in the game (beta.13, §S23-3).
return string.Format(CultureInfo.CurrentCulture,
IsMachineWide(n.GuardReason) ? Strings.Summary_Tier2_Why_MachineWide_Format : Strings.Summary_Tier2_Why_Guard_Format,
family, n.GuardSignal ?? Strings.Common_NotAvailable);
case "RefusedByGuard" when n.GuardReason is { Length: > 0 } reason:
// A refusal no family names (beta.8): the guard could not look, the game is 32-bit… — said as what it is,
// never "… was detected in this game", which read as a finding.
@@ -364,6 +367,18 @@ public static class Formats
public static string GuardSentence(string reason) =>
string.Format(CultureInfo.CurrentCulture, Strings.Guard_Refused_Format, GuardReasonText(reason));
/// <summary>
/// §S23-3 (beta.13): a driver or a service is found on the PC, not in the game. The guard's checks 2 and 2b are
/// machine-wide, so while one runs every game refuses — the measured case is Easy Anti-Cheat's service, running for
/// another title — and a notice must not say it was detected "in this game".
/// </summary>
public static bool IsMachineWide(string? guardReason) => guardReason is "BlockedDriver" or "BlockedService";
/// <summary>A refusal the guard named a family for, as a sentence: found on this PC, or found in this game.</summary>
public static string NamedRefusal(string? guardReason, string family, string signal) =>
string.Format(CultureInfo.CurrentCulture,
IsMachineWide(guardReason) ? Shared.Strings.Safety_Refused_MachineWide_Format : Shared.Strings.Safety_Refused_Named_Format, family, signal);
/// <summary>What a familyless guard reason means, as a clause.</summary>
public static string GuardReasonText(string reason) => reason switch
{
@@ -36,6 +36,7 @@ public sealed record HookingConsentResult(HookingConsentOutcome Outcome, string?
return string.IsNullOrEmpty(Refusal.Reason) ? Shared.Strings.Safety_Refused_Unnamed : Formats.GuardSentence(Refusal.Reason);
}
return string.Format(System.Globalization.CultureInfo.CurrentCulture, Shared.Strings.Safety_Refused_Named_Format, Refusal.Family, Refusal.Signal ?? Refusal.Reason);
// The pre-scan's reason is the guard's own: a driver or service would be on the PC, not in the game (beta.13, §S23-3).
return Formats.NamedRefusal(Refusal.Reason, Refusal.Family, Refusal.Signal ?? Refusal.Reason);
}
}
+16 -6
View File
@@ -50,16 +50,15 @@ public sealed class SafetyNotices : IDisposable
string.Format(CultureInfo.CurrentCulture, Strings.Notice_Refused_Title_Format, refused.GameName ?? Strings.Common_NotAvailable),
// "The session is still recorded" is true for every refusal since 2026-09-22: the loop holds a refused session
// open, unhooked, until the game exits (it was untrue for a process that could not be opened, 2026-09-21).
TurnedOff(RefusalText(refused.Reason, refused.Family, refused.Signal) + " " + Strings.Notice_Refused_Recording, refused.HookingTurnedOff), now);
TurnedOff(RefusalText(refused.Reason, refused.GuardReason, refused.Family, refused.Signal) + " " + Strings.Notice_Refused_Recording, refused.HookingTurnedOff), now);
case IpcMessageType.SafetyUnhook when IpcCodec.Payload<SafetyUnhookEvent>(envelope) is { } unhooked:
return new SafetyNotice(SafetyNoticeKind.Unhooked, Strings.Notice_Unhooked_Title,
TurnedOff(string.Format(CultureInfo.CurrentCulture, Shared.Strings.Safety_Unhooked_Format, unhooked.Family ?? unhooked.Signal ?? Strings.Common_NotAvailable), unhooked.HookingTurnedOff), now);
return new SafetyNotice(SafetyNoticeKind.Unhooked, Strings.Notice_Unhooked_Title, TurnedOff(UnhookText(unhooked), unhooked.HookingTurnedOff), now);
// The Agent's pre-scan of the library turned hooking off for a game the user had turned it on for (2026-09-25):
// not a session event, so none of a refusal's "this run is still recorded" — no run is going on.
case IpcMessageType.HookingTurnedOff when IpcCodec.Payload<HookingTurnedOffEvent>(envelope) is { } off:
return new SafetyNotice(SafetyNoticeKind.HookingOff,
string.Format(CultureInfo.CurrentCulture, Strings.Notice_HookingOff_Title_Format, off.GameName ?? Strings.Common_NotAvailable),
TurnedOff(RefusalText(off.Reason, off.Family, off.Signal), turnedOff: true), now);
TurnedOff(RefusalText(off.Reason, off.Reason, off.Family, off.Signal), turnedOff: true), now);
case IpcMessageType.CaptureDegraded when IpcCodec.Payload<CaptureDegradedEvent>(envelope) is { } degraded:
return new SafetyNotice(SafetyNoticeKind.Degraded, Strings.Notice_Degraded_Title,
string.Format(CultureInfo.CurrentCulture, Strings.Notice_Degraded_Body_Format, degraded.Reason), now);
@@ -71,7 +70,18 @@ public sealed class SafetyNotices : IDisposable
/// <summary>The finding turned the game's hooking off (2026-09-22): the notice says so, because the page will.</summary>
private static string TurnedOff(string text, bool turnedOff) => turnedOff ? text + " " + Shared.Strings.Safety_HookingTurnedOff : text;
private static string RefusalText(string reason, string? family, string? signal)
/// <summary>
/// A driver or service that started on the PC mid-session is said as that (beta.13, §S23-3) — not "detected while the
/// game was running … until you enable it again", which was untrue twice: such a finding turns no hooking off, and a
/// finding about the game turns it off for good (the turned-off sentence follows).
/// </summary>
private static string UnhookText(SafetyUnhookEvent unhooked) =>
Formats.IsMachineWide(unhooked.GuardReason) && unhooked.Family is { } family
? string.Format(CultureInfo.CurrentCulture, Shared.Strings.Safety_Unhooked_MachineWide_Format, family, unhooked.Signal ?? Strings.Common_NotAvailable)
: string.Format(CultureInfo.CurrentCulture, Shared.Strings.Safety_Unhooked_Format, unhooked.Family ?? unhooked.Signal ?? Strings.Common_NotAvailable);
/// <summary><paramref name="reason"/> is the session's end reason; <paramref name="guardReason"/> the guard's own, when it named a family.</summary>
private static string RefusalText(string reason, string? guardReason, string? family, string? signal)
{
if (string.Equals(reason, "PreScanCouldNotVerify", StringComparison.Ordinal))
{
@@ -90,7 +100,7 @@ public sealed class SafetyNotices : IDisposable
return string.IsNullOrEmpty(reason) ? Shared.Strings.Safety_Refused_Unnamed : Formats.GuardSentence(reason);
}
return string.Format(CultureInfo.CurrentCulture, Shared.Strings.Safety_Refused_Named_Format, family, signal ?? reason);
return Formats.NamedRefusal(guardReason, family, signal ?? reason);
}
private void OnEvent(object? sender, AgentEventArgs e)
+3
View File
@@ -873,6 +873,7 @@ public static class Strings
nameof(Summary_Tier2_Why_ConsentChanged),
nameof(Summary_Tier2_Why_Guard_Format),
nameof(Summary_Tier2_Why_HookOff),
nameof(Summary_Tier2_Why_MachineWide_Format),
nameof(Summary_Tier2_Why_Other_Format),
nameof(Summary_Tier2_Why_Unreadable),
nameof(Summary_Title_Format),
@@ -2670,6 +2671,8 @@ public static class Strings
public static string Summary_Tier2_Why_HookOff => ResourceManager.GetString(nameof(Summary_Tier2_Why_HookOff), Culture) ?? nameof(Summary_Tier2_Why_HookOff);
public static string Summary_Tier2_Why_MachineWide_Format => ResourceManager.GetString(nameof(Summary_Tier2_Why_MachineWide_Format), Culture) ?? nameof(Summary_Tier2_Why_MachineWide_Format);
public static string Summary_Tier2_Why_Other_Format => ResourceManager.GetString(nameof(Summary_Tier2_Why_Other_Format), Culture) ?? nameof(Summary_Tier2_Why_Other_Format);
public static string Summary_Tier2_Why_Unreadable => ResourceManager.GetString(nameof(Summary_Tier2_Why_Unreadable), Culture) ?? nameof(Summary_Tier2_Why_Unreadable);
+4
View File
@@ -1457,6 +1457,10 @@
<value>理由: ガードが拒否しました — {0}({1})。</value>
<comment>review</comment>
</data>
<data name="Summary_Tier2_Why_MachineWide_Format" xml:space="preserve">
<value>理由: このPCで {0} が動作していました({1})— ドライバーまたはサービスです。これが動作している間、FrameLedger はどのゲームにも注入しません。</value>
<comment>review</comment>
</data>
<data name="Summary_Tier2_Why_HookOff" xml:space="preserve">
<value>理由: このゲームのフックはオフだったため、何も読み込まれていません。</value>
<comment>review</comment>
+3
View File
@@ -1098,6 +1098,9 @@
<data name="Summary_Tier2_Why_Guard_Format" xml:space="preserve">
<value>Why: the guard refused — {0} ({1}).</value>
</data>
<data name="Summary_Tier2_Why_MachineWide_Format" xml:space="preserve">
<value>Why: {0} was running on this PC ({1}) — a driver or service — and FrameLedger injects into no game while it runs.</value>
</data>
<data name="Summary_Tier2_Why_HookOff" xml:space="preserve">
<value>Why: hooking was off for this game, so nothing was injected.</value>
</data>
+3
View File
@@ -1093,6 +1093,9 @@
<data name="Summary_Tier2_Why_Guard_Format" xml:space="preserve">
<value>Lý do: guard đã từ chối — {0} ({1}).</value>
</data>
<data name="Summary_Tier2_Why_MachineWide_Format" xml:space="preserve">
<value>Lý do: {0} đang chạy trên máy này ({1}) — một driver hoặc service — và FrameLedger không inject vào game nào khi nó còn chạy.</value>
</data>
<data name="Summary_Tier2_Why_HookOff" xml:space="preserve">
<value>Lý do: hooking đang tắt cho game này, nên không có gì được inject.</value>
</data>
@@ -31,6 +31,12 @@ public sealed record CaptureProgress
public required NgxDriverState NgxDriver { get; init; }
/// <summary>
/// The adapter the game presents on, as the Overlay published it in the handshake at its first present (beta.13); 0
/// before that, on every Tier-2 tick, and for a game that presents through OpenGL or Vulkan, which publish none.
/// </summary>
public ulong AdapterLuid { get; init; }
/// <summary>
/// On a held session's tick (2026-09-23): the refusal it is held under — its reason, and the guard's verdict when the
/// guard spoke — so the pipe can say, while the game runs, why nothing is measured. Null on every hooked tick.
@@ -725,6 +725,7 @@ public sealed class CaptureSession(
TouchQpc = Loaded.TouchQpc,
RuntimeModules = Loaded.Set,
NgxDriver = Loaded.Ngx,
AdapterLuid = sink.Handshake.AdapterLuid,
};
}
@@ -3,6 +3,7 @@
using FrameLedger.Application.Capture;
using FrameLedger.Application.Recording;
using FrameLedger.Domain.AntiCheat;
using FrameLedger.Shared;
using FrameLedger.Shared.Ipc;
@@ -106,10 +107,12 @@ public static class RecordedSessionEvents
{
case Kind.Refused:
pipe.Publish(IpcMessageType.CaptureRefused,
new CaptureRefusedEvent(info.GameId, info.GameName, o.Reason.ToString(), NullIfEmpty(o.Verdict.Family), NullIfEmpty(o.Verdict.Signal), o.HookingTurnedOff));
new CaptureRefusedEvent(info.GameId, info.GameName, o.Reason.ToString(), NullIfEmpty(o.Verdict.Family), NullIfEmpty(o.Verdict.Signal), o.HookingTurnedOff,
GuardReasonOf(o.Verdict)));
break;
case Kind.SafetyUnhook:
pipe.Publish(IpcMessageType.SafetyUnhook, new SafetyUnhookEvent(sessionGuid, NullIfEmpty(o.Verdict.Family), NullIfEmpty(o.Verdict.Signal), o.HookingTurnedOff));
pipe.Publish(IpcMessageType.SafetyUnhook,
new SafetyUnhookEvent(sessionGuid, NullIfEmpty(o.Verdict.Family), NullIfEmpty(o.Verdict.Signal), o.HookingTurnedOff, GuardReasonOf(o.Verdict)));
break;
case Kind.Degraded:
pipe.Publish(IpcMessageType.CaptureDegraded, new CaptureDegradedEvent(sessionGuid, From: 1, To: 2, o.Reason.ToString()));
@@ -156,4 +159,10 @@ public static class RecordedSessionEvents
};
private static string? NullIfEmpty(string? value) => string.IsNullOrEmpty(value) ? null : value;
/// <summary>
/// The guard's own reason when it named a family (beta.13, §S23-3): the App says a <c>BlockedService</c> or
/// <c>BlockedDriver</c> was found on the PC, not in the game. Null when the guard named nothing.
/// </summary>
private static string? GuardReasonOf(AntiCheatVerdict verdict) => string.IsNullOrEmpty(verdict.Family) ? null : verdict.Reason.ToString();
}
@@ -323,6 +323,7 @@ public sealed class SessionRecorder : ISessionRecorder
{
private readonly List<TelemetrySample> _drained = [];
private CaptureProgress? _last;
private ulong _adapter;
public DateTimeOffset? AttachedAt { get; private set; }
@@ -350,11 +351,29 @@ public sealed class SessionRecorder : ISessionRecorder
public void Tick(CaptureProgress progress)
{
_last = progress;
FollowAdapter(progress.AdapterLuid);
DrainTelemetry();
writer.OnTick(progress);
observer?.Tick(guid, progress, _drained);
}
/// <summary>
/// The adapter the game presents on (beta.13): the Overlay publishes its LUID at the first present, the telemetry thread
/// is told once, and the <c>.partial</c> says whether its layers could follow — until then, and where they could not,
/// they describe the adapter they found first (<c>18_GPU_VENDOR_APIS</c> §L1).
/// </summary>
private void FollowAdapter(ulong luid)
{
if (luid == 0 || luid == _adapter)
{
return;
}
_adapter = luid;
bool followed = poller?.FollowAdapter(luid) ?? false;
writer.Note(string.Create(CultureInfo.InvariantCulture, $"adapter: luid=0x{luid:x} {(followed ? "followed" : "not followed")}"));
}
public void FinalFlush()
{
DrainTelemetry();
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Application.Telemetry;
/// <summary>
/// A telemetry layer that can be pointed at one graphics adapter (beta.13): L1 reads DXGI's identity and the adapter-wide
/// memory counter for the adapter it is told, by the LUID the Overlay publishes in the handshake at the game's first
/// present. Until then it describes the first hardware adapter in DXGI's high-performance order.
/// </summary>
public interface IGpuAdapterSelector
{
/// <summary>The adapter being described; null before one is known.</summary>
GpuAdapterIdentity? Selected { get; }
/// <summary>Switch to the adapter with this LUID. False — and no change — for 0, or for a LUID it did not list.</summary>
bool SelectAdapter(ulong luid);
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.Application.Telemetry;
/// <summary>
/// A telemetry layer that reads its own GPU rather than one named by LUID (beta.13) — LibreHardwareMonitor's GPU node,
/// NVAPI's physical GPU — told the PCI vendor of the adapter the game presents on, so it describes that vendor's GPU or
/// nothing. A layer whose GPU is not the game's contributes no field: a confident figure from the wrong card is worse
/// than N/A (<c>FlShmHandshake.AdapterLuid</c>'s own rule).
/// </summary>
public interface IGpuVendorFollower
{
/// <summary>The game's adapter is this PCI vendor's (<c>0x10DE</c> NVIDIA, <c>0x1002</c> AMD, <c>0x8086</c> Intel, or another).</summary>
void FollowVendor(uint vendorId);
}
@@ -41,4 +41,10 @@ public interface ITelemetryPoller : IDisposable
/// what may be opened (<see cref="GameProcess"/>). A poller with no game source ignores it.
/// </summary>
void Follow(GameProcess target) { }
/// <summary>
/// The adapter the game presents on, by the LUID the Overlay publishes at its first present (beta.13): the layers follow
/// it. False when the source cannot follow adapters or did not list this one — a poller without layers says false.
/// </summary>
bool FollowAdapter(ulong luid) => false;
}
@@ -36,7 +36,7 @@ namespace FrameLedger.Infrastructure.Telemetry;
/// answer (N/A, layer healthy), not a fault.
/// </para>
/// </remarks>
public sealed class BaselineTelemetrySource : IGpuTelemetrySource
public sealed class BaselineTelemetrySource : IGpuTelemetrySource, IGpuAdapterSelector
{
/// <summary>Faults tolerated before the layer is disabled. The second one disables.</summary>
public const int MaxFaults = 2;
@@ -30,7 +30,7 @@ namespace FrameLedger.Infrastructure.Telemetry;
/// Owns its layers: disposing the composite disposes them.
/// </para>
/// </remarks>
public sealed class CompositeTelemetrySource : IGpuTelemetrySource
public sealed class CompositeTelemetrySource : IGpuTelemetrySource, IGpuAdapterSelector
{
/// <summary>Throws tolerated from one layer's <c>TryRead</c> before it is excluded. The second one excludes.</summary>
public const int MaxFaults = 2;
@@ -42,6 +42,7 @@ public sealed class CompositeTelemetrySource : IGpuTelemetrySource
private readonly string?[] _lastFault;
private readonly TelemetryLayer[] _fieldLayers = new TelemetryLayer[_fieldBits];
private readonly Lock _lock = new();
private GpuAdapterIdentity? _selected;
private bool _disposed;
public CompositeTelemetrySource(IEnumerable<IGpuTelemetrySource> layers)
@@ -89,6 +90,55 @@ public sealed class CompositeTelemetrySource : IGpuTelemetrySource
public string Descriptor =>
TelemetryLayerNames.Describe(Enumerable.Range(0, _layers.Length).Where(IsStanding).Select(i => _layers[i].Layer));
/// <summary>The adapter <see cref="SelectAdapter"/> last chose; null before the game's first present named one.</summary>
public GpuAdapterIdentity? Selected
{
get
{
lock (_lock)
{
return _selected;
}
}
}
/// <summary>
/// The adapter the game presents on (beta.13). The layer that names adapters by LUID (L1) switches to it, and every layer
/// that reads its own GPU is told the adapter's vendor (<see cref="IGpuVendorFollower"/>), so a merged sample describes the
/// game's card and not the first one each layer happened to find. False — nothing told — when no layer listed the LUID.
/// Under the merge lock, so no sample mixes the old adapter with the new one.
/// </summary>
public bool SelectAdapter(ulong luid)
{
lock (_lock)
{
GpuAdapterIdentity? chosen = null;
for (int i = 0; i < _layers.Length; i++)
{
if (IsStanding(i) && _layers[i] is IGpuAdapterSelector selector && selector.SelectAdapter(luid))
{
chosen ??= selector.Selected;
}
}
if (chosen is null)
{
return false;
}
_selected = chosen;
for (int i = 0; i < _layers.Length; i++)
{
if (IsStanding(i) && _layers[i] is IGpuVendorFollower follower)
{
follower.FollowVendor(chosen.VendorId);
}
}
return true;
}
}
/// <summary>What a layer's last throw said, for the report. Null if it never threw.</summary>
public string? LastFaultOf(TelemetryLayer layer)
{
@@ -42,7 +42,7 @@ namespace FrameLedger.Infrastructure.Telemetry;
/// never reports sets nothing. <see cref="GpuSample.PresentFields"/> is the only input.
/// </para>
/// </remarks>
public sealed class LhmTelemetrySource : IGpuTelemetrySource
public sealed class LhmTelemetrySource : IGpuTelemetrySource, IGpuVendorFollower
{
/// <summary>Faults tolerated before the layer is disabled. The second one disables.</summary>
public const int MaxFaults = 2;
@@ -61,6 +61,9 @@ public sealed class LhmTelemetrySource : IGpuTelemetrySource
private int _polling;
private int _hangCounted;
private long _pollStartedUtcTicks;
/// <summary>The game adapter's PCI vendor id once known (beta.13); 0 maps the first GPU node, as before.</summary>
private int _vendor;
private bool _opened;
private bool _disposed;
private string? _lastFault;
@@ -126,8 +129,15 @@ public sealed class LhmTelemetrySource : IGpuTelemetrySource
}
/// <summary>
/// One poll: refresh the tree, map the first GPU node, publish. Public so a probe or a
/// test can drive it without the thread; the thread calls exactly this.
/// The game presents on this vendor's adapter (beta.13): the next polls map that vendor's GPU node rather than the first
/// one LibreHardwareMonitor lists — on a laptop that is often the integrated GPU while the game runs on the discrete one —
/// and publish nothing when the tree has no node of that vendor.
/// </summary>
public void FollowVendor(uint vendorId) => Volatile.Write(ref _vendor, unchecked((int)vendorId));
/// <summary>
/// One poll: refresh the tree, map the first GPU node — of the game adapter's vendor once that is known (beta.13) —
/// publish. Public so a probe or a test can drive it without the thread; the thread calls exactly this.
/// </summary>
public void PollOnce()
{
@@ -143,10 +153,11 @@ public sealed class LhmTelemetrySource : IGpuTelemetrySource
{
_computer.Update();
uint vendor = unchecked((uint)Volatile.Read(ref _vendor));
IHardware? gpu = null;
foreach (IHardware hardware in _computer.Hardware)
{
if (SensorMap.IsGpu(hardware))
if (SensorMap.IsGpu(hardware) && (vendor == 0 || SensorMap.IsVendor(hardware, vendor)))
{
gpu = hardware;
break;
@@ -24,11 +24,17 @@ namespace FrameLedger.Infrastructure.Telemetry;
/// this source never calls <c>NvAPI_D3D_GetLatency</c>.
/// </para>
/// </remarks>
public sealed class NvapiTelemetrySource : IGpuTelemetrySource
public sealed class NvapiTelemetrySource : IGpuTelemetrySource, IGpuVendorFollower
{
/// <summary>Faults tolerated before the layer is disabled. The second one disables.</summary>
public const int MaxFaults = 2;
/// <summary>NVIDIA's PCI vendor id: the only vendor NVAPI describes.</summary>
private const uint _nvidiaVendorId = 0x10DE;
/// <summary>1 once the game's adapter is known to be another vendor's (beta.13): this layer then reads nothing.</summary>
private int _otherVendor;
private readonly INvapiBridge _bridge;
private readonly TimeProvider _clock;
private readonly Lock _lock = new();
@@ -109,10 +115,18 @@ public sealed class NvapiTelemetrySource : IGpuTelemetrySource
}
}
/// <summary>
/// The game presents on this vendor's adapter (beta.13). NVAPI reads NVIDIA's first physical GPU, which is not the
/// game's when the game's adapter is AMD's or Intel's — so for any other vendor the layer contributes nothing from now
/// on, rather than a temperature from a card the game is not using. Not a fault and not disabled: the layer is still
/// healthy, it just has nothing true to say about this session.
/// </summary>
public void FollowVendor(uint vendorId) => Volatile.Write(ref _otherVendor, vendorId == _nvidiaVendorId ? 0 : 1);
public bool TryRead([NotNullWhen(true)] out GpuSample? sample)
{
sample = null;
if (IsDisabled)
if (IsDisabled || Volatile.Read(ref _otherVendor) != 0)
{
return false;
}
@@ -39,6 +39,22 @@ public static class SensorMap
return hardware.HardwareType is HardwareType.GpuNvidia or HardwareType.GpuAmd or HardwareType.GpuIntel;
}
/// <summary>
/// Whether a GPU node is this PCI vendor's (beta.13): NVIDIA <c>0x10DE</c>, AMD <c>0x1002</c>, Intel <c>0x8086</c>. Any
/// other vendor has no node LibreHardwareMonitor understands.
/// </summary>
public static bool IsVendor(IHardware hardware, uint vendorId)
{
ArgumentNullException.ThrowIfNull(hardware);
return vendorId switch
{
0x10DE => hardware.HardwareType == HardwareType.GpuNvidia,
0x1002 => hardware.HardwareType == HardwareType.GpuAmd,
0x8086 => hardware.HardwareType == HardwareType.GpuIntel,
_ => false,
};
}
/// <summary>Every sensor under a node, including its sub-hardware, in tree order.</summary>
public static IEnumerable<ISensor> AllSensors(IHardware hardware)
{
@@ -131,6 +131,9 @@ public sealed class TelemetryPoller : ITelemetryPoller
}
}
/// <summary>The adapter the game presents on (beta.13): handed to the source, which points its layers at it.</summary>
public bool FollowAdapter(ulong luid) => _source is IGpuAdapterSelector selector && selector.SelectAdapter(luid);
/// <summary>The game process whose memory the next ticks read (beta.12, D43); ignored without a game source.</summary>
public void Follow(GameProcess target)
{
+11 -4
View File
@@ -292,14 +292,21 @@ public sealed record SessionProgressEvent
/// </summary>
public sealed record SessionCompletedEvent(Guid SessionGuid, long? SessionId, string ExitStatus, int Tier, string Finalize, string Reason, long? GameId = null, string? GameName = null);
/// <summary>The gate or the guard said no before anything was injected (<c>08_UI</c> §Safety events: never a toast).</summary>
public sealed record CaptureRefusedEvent(long GameId, string? GameName, string Reason, string? Family, string? Signal, bool HookingTurnedOff = false);
/// <summary>
/// The gate or the guard said no before anything was injected (<c>08_UI</c> §Safety events: never a toast).
/// <see cref="Reason"/> is the session's end reason; <see cref="GuardReason"/> (beta.13, optional) is the guard's own, sent
/// when it named a family — <c>BlockedService</c> or <c>BlockedDriver</c> is a finding on the PC, not in the game (§S23-3).
/// </summary>
public sealed record CaptureRefusedEvent(long GameId, string? GameName, string Reason, string? Family, string? Signal, bool HookingTurnedOff = false, string? GuardReason = null);
/// <summary>Measurement STOPPED mid-session (two-rung ladder: there is no lower fidelity to continue at).</summary>
public sealed record CaptureDegradedEvent(Guid SessionGuid, int From, int To, string Reason);
/// <summary>Anti-cheat appeared mid-session and our own guard published the stop.</summary>
public sealed record SafetyUnhookEvent(Guid SessionGuid, string? Family, string? Signal, bool HookingTurnedOff = false);
/// <summary>
/// Anti-cheat appeared mid-session and our own guard published the stop. <see cref="GuardReason"/> as on
/// <see cref="CaptureRefusedEvent"/> (beta.13): a driver or service that started on the PC is not a finding in the game.
/// </summary>
public sealed record SafetyUnhookEvent(Guid SessionGuid, string? Family, string? Signal, bool HookingTurnedOff = false, string? GuardReason = null);
public sealed record CaptureErrorEvent(Guid? SessionGuid, string Code, string Message);
+6
View File
@@ -70,10 +70,12 @@ public static class Strings
nameof(Safety_HookingTurnedOff),
nameof(Safety_RecordWithoutMeasuring),
nameof(Safety_Refused_CouldNotVerify),
nameof(Safety_Refused_MachineWide_Format),
nameof(Safety_Refused_Named_Format),
nameof(Safety_Refused_TargetUnreadable),
nameof(Safety_Refused_Unnamed),
nameof(Safety_Unhooked_Format),
nameof(Safety_Unhooked_MachineWide_Format),
];
public static string Safety_AdminMode_Accept => ResourceManager.GetString(nameof(Safety_AdminMode_Accept), Culture) ?? nameof(Safety_AdminMode_Accept);
@@ -158,6 +160,8 @@ public static class Strings
public static string Safety_Refused_CouldNotVerify => ResourceManager.GetString(nameof(Safety_Refused_CouldNotVerify), Culture) ?? nameof(Safety_Refused_CouldNotVerify);
public static string Safety_Refused_MachineWide_Format => ResourceManager.GetString(nameof(Safety_Refused_MachineWide_Format), Culture) ?? nameof(Safety_Refused_MachineWide_Format);
public static string Safety_Refused_Named_Format => ResourceManager.GetString(nameof(Safety_Refused_Named_Format), Culture) ?? nameof(Safety_Refused_Named_Format);
public static string Safety_Refused_TargetUnreadable => ResourceManager.GetString(nameof(Safety_Refused_TargetUnreadable), Culture) ?? nameof(Safety_Refused_TargetUnreadable);
@@ -165,4 +169,6 @@ public static class Strings
public static string Safety_Refused_Unnamed => ResourceManager.GetString(nameof(Safety_Refused_Unnamed), Culture) ?? nameof(Safety_Refused_Unnamed);
public static string Safety_Unhooked_Format => ResourceManager.GetString(nameof(Safety_Unhooked_Format), Culture) ?? nameof(Safety_Unhooked_Format);
public static string Safety_Unhooked_MachineWide_Format => ResourceManager.GetString(nameof(Safety_Unhooked_MachineWide_Format), Culture) ?? nameof(Safety_Unhooked_MachineWide_Format);
}
+3 -1
View File
@@ -28,9 +28,11 @@
<data name="Safety_RecordWithoutMeasuring" xml:space="preserve"><value>Record this session without measuring it</value><comment>safety: human review required</comment></data>
<data name="Safety_Refused_CouldNotVerify" xml:space="preserve"><value>FrameLedger could not verify this game's files for anti-cheat, so hooking stays off. It will check again when the game's files or the detection rules change.</value><comment>safety: human review required</comment></data>
<data name="Safety_Refused_Named_Format" xml:space="preserve"><value>{0} was detected in this game ({1}). FrameLedger will not inject into it, and nothing overrides that.</value><comment>safety: human review required</comment></data>
<data name="Safety_Refused_MachineWide_Format" xml:space="preserve"><value>{0} is running on this PC ({1}): a driver or service, which may belong to another game or program rather than this one. While it runs, FrameLedger injects into no game, and nothing overrides that.</value><comment>safety: human review required</comment></data>
<data name="Safety_Refused_Unnamed" xml:space="preserve"><value>An anti-cheat or anti-tamper module was detected in this game. FrameLedger will not inject into it, and nothing overrides that.</value><comment>safety: human review required</comment></data>
<data name="Safety_HookingTurnedOff" xml:space="preserve"><value>Hooking has been turned off for this game; its page says what was found.</value><comment>safety: human review required</comment></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Capture stopped: {0} was detected while the game was running. FrameLedger unhooked and will not inject into this game again until you enable it again.</value><comment>safety: human review required</comment></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Capture stopped: {0} was detected while the game was running, and FrameLedger unhooked.</value><comment>safety: human review required</comment></data>
<data name="Safety_Unhooked_MachineWide_Format" xml:space="preserve"><value>Capture stopped: {0} started on this PC while the game was running ({1}) — a driver or service, which may belong to another game or program — and FrameLedger unhooked. The game's next session is measured again once it is no longer running.</value><comment>safety: human review required</comment></data>
<data name="Safety_Refused_TargetUnreadable" xml:space="preserve"><value>The game is running, but Windows would not let FrameLedger open its process: it is protected by an anti-cheat driver, or it runs as administrator while FrameLedger does not. Nothing was injected and this run was not measured. FrameLedger will not work around another product's protection. If the game itself runs as administrator, the agent's admin mode in Settings lets FrameLedger open it; a protected process stays closed.</value><comment>safety: human review required</comment></data>
<data name="Safety_Exception_Title_Format" xml:space="preserve"><value>Make a user-mode exception for {0}?</value><comment>safety: human review required</comment></data>
<data name="Safety_Exception_Intro_Format" xml:space="preserve"><value>FrameLedger found {0} in this game ({1}) and turned its hooking off. This dialog asks whether to make an exception for this game only. It recommends neither choice.</value><comment>safety: human review required</comment></data>
+3 -1
View File
@@ -33,9 +33,11 @@
<data name="Safety_RecordWithoutMeasuring" xml:space="preserve"><value>Record this session without measuring it</value></data>
<data name="Safety_Refused_CouldNotVerify" xml:space="preserve"><value>FrameLedger could not verify this game's files for anti-cheat, so hooking stays off. It will check again when the game's files or the detection rules change.</value></data>
<data name="Safety_Refused_Named_Format" xml:space="preserve"><value>{0} was detected in this game ({1}). FrameLedger will not inject into it, and nothing overrides that.</value></data>
<data name="Safety_Refused_MachineWide_Format" xml:space="preserve"><value>{0} is running on this PC ({1}): a driver or service, which may belong to another game or program rather than this one. While it runs, FrameLedger injects into no game, and nothing overrides that.</value></data>
<data name="Safety_Refused_Unnamed" xml:space="preserve"><value>An anti-cheat or anti-tamper module was detected in this game. FrameLedger will not inject into it, and nothing overrides that.</value></data>
<data name="Safety_HookingTurnedOff" xml:space="preserve"><value>Hooking has been turned off for this game; its page says what was found.</value></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Capture stopped: {0} was detected while the game was running. FrameLedger unhooked and will not inject into this game again until you enable it again.</value></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Capture stopped: {0} was detected while the game was running, and FrameLedger unhooked.</value></data>
<data name="Safety_Unhooked_MachineWide_Format" xml:space="preserve"><value>Capture stopped: {0} started on this PC while the game was running ({1}) — a driver or service, which may belong to another game or program — and FrameLedger unhooked. The game's next session is measured again once it is no longer running.</value></data>
<data name="Safety_Refused_TargetUnreadable" xml:space="preserve"><value>The game is running, but Windows would not let FrameLedger open its process: it is protected by an anti-cheat driver, or it runs as administrator while FrameLedger does not. Nothing was injected and this run was not measured. FrameLedger will not work around another product's protection. If the game itself runs as administrator, the agent's admin mode in Settings lets FrameLedger open it; a protected process stays closed.</value></data>
<data name="Safety_Exception_Title_Format" xml:space="preserve"><value>Make a user-mode exception for {0}?</value></data>
<data name="Safety_Exception_Intro_Format" xml:space="preserve"><value>FrameLedger found {0} in this game ({1}) and turned its hooking off. This dialog asks whether to make an exception for this game only. It recommends neither choice.</value></data>
+3 -1
View File
@@ -27,9 +27,11 @@
<data name="Safety_RecordWithoutMeasuring" xml:space="preserve"><value>Ghi phiên này mà không đo</value></data>
<data name="Safety_Refused_CouldNotVerify" xml:space="preserve"><value>FrameLedger không thể kiểm tra các tệp của game này về anti-cheat, nên hooking vẫn tắt. Nó sẽ kiểm tra lại khi tệp của game hoặc bộ quy tắc phát hiện thay đổi.</value></data>
<data name="Safety_Refused_Named_Format" xml:space="preserve"><value>Đã phát hiện {0} trong game này ({1}). FrameLedger sẽ không inject vào game này, và không có cách nào vượt qua điều đó.</value></data>
<data name="Safety_Refused_MachineWide_Format" xml:space="preserve"><value>{0} đang chạy trên máy này ({1}): một driver hoặc service, có thể thuộc về game hay chương trình khác chứ không phải game này. Khi nó còn chạy, FrameLedger không inject vào bất kỳ game nào, và không có cách nào vượt qua điều đó.</value></data>
<data name="Safety_Refused_Unnamed" xml:space="preserve"><value>Đã phát hiện một mô-đun anti-cheat hoặc anti-tamper trong game này. FrameLedger sẽ không inject vào game này, và không có cách nào vượt qua điều đó.</value></data>
<data name="Safety_HookingTurnedOff" xml:space="preserve"><value>Hooking đã được tắt cho game này; trang của game ghi rõ đã phát hiện gì.</value></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Đã dừng thu thập: phát hiện {0} khi game đang chạy. FrameLedger đã gỡ hook và sẽ không inject vào game này nữa cho đến khi bạn bật lại.</value></data>
<data name="Safety_Unhooked_Format" xml:space="preserve"><value>Đã dừng thu thập: phát hiện {0} khi game đang chạy, và FrameLedger đã gỡ hook.</value></data>
<data name="Safety_Unhooked_MachineWide_Format" xml:space="preserve"><value>Đã dừng thu thập: {0} khởi động trên máy này khi game đang chạy ({1}) — một driver hoặc service, có thể thuộc về game hay chương trình khác — và FrameLedger đã gỡ hook. Phiên sau của game sẽ được đo lại khi nó không còn chạy.</value></data>
<data name="Safety_Refused_TargetUnreadable" xml:space="preserve"><value>Game đang chạy, nhưng Windows không cho FrameLedger mở tiến trình của nó: tiến trình được driver anti-cheat bảo vệ, hoặc game chạy với quyền quản trị còn FrameLedger thì không. Không có gì được inject và lần chạy này không được đo. FrameLedger sẽ không tìm cách vượt qua cơ chế bảo vệ của sản phẩm khác. Nếu chính game chạy với quyền quản trị, chế độ quản trị của agent trong Cài đặt cho phép FrameLedger mở nó; tiến trình được bảo vệ vẫn đóng.</value></data>
<data name="Safety_Exception_Title_Format" xml:space="preserve"><value>Tạo ngoại lệ user-mode cho {0}?</value></data>
<data name="Safety_Exception_Intro_Format" xml:space="preserve"><value>FrameLedger đã phát hiện {0} trong game này ({1}) và đã tắt hooking cho nó. Hộp thoại này hỏi bạn có muốn tạo ngoại lệ cho riêng game này không. Nó không khuyến nghị lựa chọn nào.</value></data>
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.Shared.Ipc;
@@ -12,6 +13,7 @@ namespace FrameLedger.App.Tests;
/// persistent notices with the signal named and the acknowledge action; a capture error is the strip's; a
/// session event is nobody's; a notice leaves only when the user dismisses it.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the expected texts are resources that follow the UI culture")]
public sealed class SafetyNoticesTests
{
[Fact]
@@ -55,6 +57,48 @@ public sealed class SafetyNoticesTests
strip.Shown.Should().BeEmpty("never a toast");
}
/// <summary>
/// §S23-3 (beta.13): while Easy Anti-Cheat's service runs for another title, EVERY game refuses with
/// <c>BlockedService</c> (spike-notes §13), and the notice said it was detected "in this game" — a game the user may not
/// even own. A driver or a service is said as running on this PC; a module in the game still says "in this game".
/// </summary>
[Fact]
public void AServiceOrDriverIsOnThisPcAndAModuleIsInThisGame()
{
var link = new FakeAgentLink();
using var notices = new SafetyNotices(link, new RecordingStrip());
link.Raise(IpcMessageType.CaptureRefused, new CaptureRefusedEvent(7, "Title", "RefusedByGuard", "Easy Anti-Cheat", "EasyAntiCheat_EOS", GuardReason: "BlockedService"));
link.Raise(IpcMessageType.CaptureRefused, new CaptureRefusedEvent(7, "Title", "RefusedByGuard", "Riot Vanguard", "vgk.sys", GuardReason: "BlockedDriver"));
link.Raise(IpcMessageType.CaptureRefused, new CaptureRefusedEvent(7, "Title", "RefusedByGuard", "BattlEye", "BEClient_x64.dll", GuardReason: "BlockedModule"));
link.Raise(IpcMessageType.CaptureRefused, new CaptureRefusedEvent(7, "Title", "RefusedByGuard", "BattlEye", "BEClient_x64.dll"));
string[] bodies = [.. notices.Items.Reverse().Select(static n => n.Body)];
bodies[0].Should().StartWith(Format(Shared.Strings.Safety_Refused_MachineWide_Format, "Easy Anti-Cheat", "EasyAntiCheat_EOS"));
bodies[1].Should().StartWith(Format(Shared.Strings.Safety_Refused_MachineWide_Format, "Riot Vanguard", "vgk.sys"));
bodies[2].Should().StartWith(Format(Shared.Strings.Safety_Refused_Named_Format, "BattlEye", "BEClient_x64.dll"));
bodies[3].Should().StartWith(Format(Shared.Strings.Safety_Refused_Named_Format, "BattlEye", "BEClient_x64.dll"), "an older Agent sends no guard reason");
}
/// <summary>
/// The unhook notice promised "will not inject into this game again until you enable it again", untrue both ways since
/// 2026-09-22: a service that starts on the PC turns no hooking off, and a finding about the game turns it off for good —
/// which the turned-off sentence then says (beta.13).
/// </summary>
[Fact]
public void AnUnhookSaysWhereTheFindingWasAndPromisesNoReEnable()
{
var link = new FakeAgentLink();
using var notices = new SafetyNotices(link, new RecordingStrip());
link.Raise(IpcMessageType.SafetyUnhook, new SafetyUnhookEvent(Guid.NewGuid(), "Easy Anti-Cheat", "EasyAntiCheat_EOS", GuardReason: "BlockedService"));
link.Raise(IpcMessageType.SafetyUnhook, new SafetyUnhookEvent(Guid.NewGuid(), "BattlEye", "BEClient_x64.dll", HookingTurnedOff: true, GuardReason: "BlockedModule"));
string[] bodies = [.. notices.Items.Reverse().Select(static n => n.Body)];
bodies[0].Should().Be(Format(Shared.Strings.Safety_Unhooked_MachineWide_Format, "Easy Anti-Cheat", "EasyAntiCheat_EOS"));
bodies[1].Should().Be(Format(Shared.Strings.Safety_Unhooked_Format, "BattlEye") + " " + Shared.Strings.Safety_HookingTurnedOff);
}
[Fact]
public void ACouldNotVerifyRefusalUsesItsOwnSentence()
{
@@ -150,4 +194,8 @@ public sealed class SafetyNoticesTests
notices.Items.Should().BeEmpty();
}
private static string Format(string format, string first) => string.Format(CultureInfo.CurrentCulture, format, first);
private static string Format(string format, string first, string second) => string.Format(CultureInfo.CurrentCulture, format, first, second);
}
@@ -16,3 +16,4 @@ internal static class StringsCultureCollection
{
public const string Name = "strings-culture";
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.App.Tests;
/// <summary>
/// Since beta.13 <see cref="StringsCultureCollection"/> runs ALONE (<see cref="CollectionDefinitionAttribute.DisableParallelization"/>:
/// after every parallel collection, and beside none). A collection only serializes its own members; every other class still
/// ran next to them, and a class that READS resource or FPS text read the wrong language while one of these had flipped the
/// culture — <c>GamesViewModelTests</c> on 2026-10-03, beside <c>GameMemoryTextTests</c>' many flips. Moving each reader in
/// found the races one red run at a time; taking the writers out of the parallel phase ends them as a class.
/// <see cref="StringsTests"/> proves the definition is the one bound.
/// </summary>
[CollectionDefinition(StringsCultureCollection.Name, DisableParallelization = true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1515:Consider making public types internal", Justification = "xUnit requires a collection definition to be public (xUnit1027)")]
public sealed class StringsCultureDefinition;
@@ -50,6 +50,16 @@ public sealed class StringsTests
Strings.Keys.Should().BeEquivalentTo(keys, "Strings.Designer.cs is generated from Strings.resx and committed; tools/resx-audit.ps1 fails on drift");
}
/// <summary>
/// beta.13: the culture collection's definition is the one bound — it is what takes these classes out of the parallel
/// phase — so a definition xUnit did not find would fail here rather than bring the races back silently.
/// </summary>
[Fact]
public void TheCultureCollectionIsBoundToTheDefinitionThatRunsItAlone()
{
TestContext.Current.TestCollection!.TestCollectionClassName.Should().Be(typeof(StringsCultureDefinition).FullName);
}
[Fact]
public void TheCulturePropertyOverridesTheThread()
{
@@ -19,8 +19,13 @@ public sealed class Tier2ReasonTests
.Should().Be(Strings.Summary_Tier2_Why_HookOff);
Formats.Tier2Reason("end=RefusedHookNotEnabled; tier2: attach=NotEvaluated; guard=PreviouslyBlocked/previously blocked/BlockedModule: Easy Anti-Cheat EasyAntiCheat_EOS.dll")
.Should().Be(string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_Blocked_Format, "BlockedModule: Easy Anti-Cheat EasyAntiCheat_EOS.dll"));
// A driver or service is on the PC, not in the game (beta.13, §S23-3); a module is the guard's finding in the game.
Formats.Tier2Reason("end=RefusedByGuard; tier2: attach=NotEvaluated; guard=BlockedDriver/Riot Vanguard/vgk.sys")
.Should().Be(string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_Guard_Format, "Riot Vanguard", "vgk.sys"));
.Should().Be(string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_MachineWide_Format, "Riot Vanguard", "vgk.sys"));
Formats.Tier2Reason("end=RefusedByGuard; tier2: attach=NotEvaluated; guard=BlockedService/Easy Anti-Cheat/EasyAntiCheat_EOS")
.Should().Be(string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_MachineWide_Format, "Easy Anti-Cheat", "EasyAntiCheat_EOS"));
Formats.Tier2Reason("end=RefusedByGuard; tier2: attach=NotEvaluated; guard=BlockedModule/BattlEye/BEClient_x64.dll")
.Should().Be(string.Format(CultureInfo.CurrentCulture, Strings.Summary_Tier2_Why_Guard_Format, "BattlEye", "BEClient_x64.dll"));
Formats.Tier2Reason("end=TargetUnreadable; tier2: attach=NotEvaluated").Should().Be(Strings.Summary_Tier2_Why_Unreadable);
Formats.Tier2Reason("end=AttachRefused; tier2: attach=BuildIdMismatch").Should().Be(Strings.End_AttachRefused, "every end reason has its own words since beta.8");
Formats.Tier2Reason("end=SomethingLater; tier2: attach=NotEvaluated")
@@ -161,6 +161,29 @@ public sealed class RecordedSessionEventsTests
pipe.Of<SafetyUnhookEvent>().Single().HookingTurnedOff.Should().BeTrue();
}
/// <summary>
/// §S23-3 (beta.13): the events carry the guard's own reason when it named a family, so the App can say a service or a
/// driver was found on the PC — and nothing when the guard named nothing (the kill switch, a block already on the row).
/// </summary>
[Fact]
public void BothSafetyEventsCarryTheGuardsReasonWhenItNamedAFamily()
{
var pipe = new RecordingPublisher();
RecordedSession service = Session(SessionEndReason.RefusedByGuard, ExitStatus.Normal, new FinalizeOutcome(FinalizeStatus.Discarded, null, 0),
verdict: AntiCheatVerdict.Refused(AntiCheatRefusalReason.BlockedService, "Easy Anti-Cheat", "EasyAntiCheat_EOS"), tier: CaptureTier.NotHooked);
RecordedSession driver = Session(SessionEndReason.SafetyUnhook, ExitStatus.UnhookedSafety, new FinalizeOutcome(FinalizeStatus.Saved, 9, 0),
verdict: AntiCheatVerdict.Refused(AntiCheatRefusalReason.BlockedDriver, "Riot Vanguard", "vgk.sys"));
RecordedSession killSwitch = Session(SessionEndReason.RefusedKillSwitch, ExitStatus.Normal, new FinalizeOutcome(FinalizeStatus.Discarded, null, 0),
tier: CaptureTier.NotHooked);
RecordedSessionEvents.PublishAll(pipe, service, _info);
RecordedSessionEvents.PublishAll(pipe, driver, _info);
RecordedSessionEvents.PublishAll(pipe, killSwitch, _info);
pipe.Of<CaptureRefusedEvent>().Select(static e => e.GuardReason).Should().Equal("BlockedService", null);
pipe.Of<SafetyUnhookEvent>().Single().GuardReason.Should().Be("BlockedDriver");
}
[Fact]
public void ASafetyUnhookCarriesTheVerdictThatFired()
{
@@ -93,13 +93,13 @@ public sealed class SessionRecorderTests : IAsyncDisposable
ValueTask.FromResult(AntiCheatVerdict.Allowed());
}
private sealed class FakeSink(SteppingClock clock, int recordsToServe) : ICaptureSink
private sealed class FakeSink(SteppingClock clock, int recordsToServe, ulong adapterLuid = 0) : ICaptureSink
{
private int _served;
public FlWriterState WriterState => new() { Status = (uint)FlStatus.Ready, HooksInstalledMask = 1, RuntimeCensus = 0x8000_0000 };
public FlShmHandshake Handshake => default;
public FlShmHandshake Handshake => new() { AdapterLuid = adapterLuid };
public FlDisplayState? DisplayState => null;
@@ -174,8 +174,16 @@ public sealed class SessionRecorderTests : IAsyncDisposable
{
private int _served;
public List<ulong> Adapters { get; } = [];
public string Descriptor => "l1+lhm";
public bool FollowAdapter(ulong luid)
{
Adapters.Add(luid);
return true;
}
public long Dropped => 0;
public void Start()
@@ -212,12 +220,12 @@ public sealed class SessionRecorderTests : IAsyncDisposable
}
private sealed class Factory(IGameConsentStore store, FakeGuard guard, SteppingClock clock, int records, FakeLiveness liveness,
IUserModeExceptionSwitch? exceptions = null, IDisplayProbe? display = null) : ICaptureSessionFactory
IUserModeExceptionSwitch? exceptions = null, IDisplayProbe? display = null, ulong adapterLuid = 0) : ICaptureSessionFactory
{
public CaptureSession Create(ICaptureObserver observer) => new(
store, new HookedCaptureGate(guard), guard, new FixedResolver(),
new DelegateLivenessSource(_ => liveness),
new DelegateRingAttacher(_ => (new FakeSink(clock, records), ShmAttachRefusal.Ok)),
new DelegateRingAttacher(_ => (new FakeSink(clock, records, adapterLuid), ShmAttachRefusal.Ok)),
new CaptureOptions
{
DrainInterval = TimeSpan.FromMilliseconds(1),
@@ -263,6 +271,8 @@ public sealed class SessionRecorderTests : IAsyncDisposable
public required SteppingClock Clock { get; init; }
public required SqliteGameConsentStore Store { get; init; }
public FakePoller? Poller { get; init; }
}
/// <summary>What the driver-profile source answers (beta.8); a throwing one proves a failed read costs the column, not the session.</summary>
@@ -278,7 +288,7 @@ public sealed class SessionRecorderTests : IAsyncDisposable
}
private async Task<Harness> MakeAsync(bool consented = true, AntiCheatVerdict? verdict = null, int records = 3_000, FakeLiveness? liveness = null, bool poller = true,
bool clockStepsOnDrain = false, IDriverProfileSource? profiles = null, bool excepted = false, IDisplayProbe? display = null)
bool clockStepsOnDrain = false, IDriverProfileSource? profiles = null, bool excepted = false, IDisplayProbe? display = null, ulong adapterLuid = 0)
{
_db ??= await LedgerDatabase.OpenAsync(Path.Combine(_dir, LedgerPaths.DatabaseFileName), ct: TestContext.Current.CancellationToken).ConfigureAwait(false);
var store = new SqliteGameConsentStore(_db);
@@ -302,14 +312,15 @@ public sealed class SessionRecorderTests : IAsyncDisposable
var games = new FakeGameRepository();
var sessions = new FakeSessionRepository();
var partials = new FakePartialSessionStore();
FakePoller? fakePoller = poller ? new FakePoller(clockStepsOnDrain ? clock : null) : null;
var recorder = new SessionRecorder(
new Factory(store, guard, clock, records, liveness ?? _alive, excepted ? new FakeExceptionSwitch(on: true) : null, display),
new Factory(store, guard, clock, records, liveness ?? _alive, excepted ? new FakeExceptionSwitch(on: true) : null, display, adapterLuid),
games, new FakeSnapshots(), new FixedHardware(), partials,
new SessionFinalizer(sessions, new RawSeriesCodec()), new NoCrashEvents(),
_ => poller ? new FakePoller(clockStepsOnDrain ? clock : null) : null, clock,
_ => fakePoller, clock,
new RecorderOptions { PartialFlushInterval = TimeSpan.FromSeconds(10), MinimumSessionLength = SteppingClock.Step }, profiles: profiles,
exceptionLapse: new UserModeExceptionLapsePolicy(store, sessions));
return new Harness { Recorder = recorder, Games = games, Sessions = sessions, Partials = partials, Clock = clock, Store = store };
return new Harness { Recorder = recorder, Games = games, Sessions = sessions, Partials = partials, Clock = clock, Store = store, Poller = fakePoller };
}
/// <summary>D33: block the consented row for NetEase Yidun, grant its exception on these bytes, and turn hooking on again.</summary>
@@ -405,6 +416,22 @@ public sealed class SessionRecorderTests : IAsyncDisposable
after.AcException.TrialFailed.Should().Be(ends);
}
/// <summary>
/// beta.13: the adapter the Overlay names in the handshake reaches the telemetry thread once, however many ticks carry it;
/// a session whose handshake names none (0, before the first present or through OpenGL) tells it nothing.
/// </summary>
[Fact]
public async Task TheGamesAdapterIsHandedToTheTelemetryThreadOnce()
{
Harness named = await MakeAsync(adapterLuid: 0x0000_0001_0000_0042);
await named.Recorder.RecordAsync(Request(), TestContext.Current.CancellationToken);
named.Poller!.Adapters.Should().Equal(0x0000_0001_0000_0042UL);
Harness unnamed = await MakeAsync();
await unnamed.Recorder.RecordAsync(Request(), TestContext.Current.CancellationToken);
unnamed.Poller!.Adapters.Should().BeEmpty();
}
[Fact]
public async Task AHookedSessionIsRecordedEndToEnd()
{
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Diagnostics.CodeAnalysis;
using FluentAssertions;
using FrameLedger.Application.Telemetry;
using FrameLedger.Infrastructure.Telemetry;
@@ -144,6 +145,26 @@ public sealed class CompositeTelemetrySourceTests
l2.Disposed.Should().BeTrue();
}
/// <summary>
/// beta.13: the game's adapter, by the LUID the Overlay published — L1 switches to it and the layers that read their own
/// GPU are told its vendor; a LUID no layer listed changes nothing and tells nobody.
/// </summary>
[Fact]
public void AnAdapterTheGamePresentsOnIsSelectedInL1AndItsVendorReachesTheOtherLayers()
{
using var l1 = new AdapterLayer(listedLuid: 0x0000_0001_0000_0042, vendor: 0x1002);
using var l3 = new VendorLayer(TelemetryLayer.Nvapi);
using var composite = new CompositeTelemetrySource([l1, l3]);
composite.SelectAdapter(0x99).Should().BeFalse("no layer listed it");
l3.Vendors.Should().BeEmpty();
composite.Selected.Should().BeNull();
composite.SelectAdapter(0x0000_0001_0000_0042).Should().BeTrue();
composite.Selected!.VendorId.Should().Be(0x1002u);
l3.Vendors.Should().Equal(0x1002u);
}
[Fact]
public void TheNamesAreTheOnesTheSchemaExampleUses()
{
@@ -152,4 +173,72 @@ public sealed class CompositeTelemetrySourceTests
Action none = () => TelemetryLayerNames.Of(TelemetryLayer.None);
none.Should().Throw<ArgumentOutOfRangeException>();
}
/// <summary>L1 as the composite sees it: one adapter, by LUID.</summary>
private sealed class AdapterLayer(ulong listedLuid, uint vendor) : IGpuTelemetrySource, IGpuAdapterSelector
{
public TelemetryLayer Layer => TelemetryLayer.Baseline;
public GpuCapabilities Capabilities => GpuCapabilities.None;
public bool IsDisabled => false;
public GpuAdapterIdentity? Selected { get; private set; }
public bool SelectAdapter(ulong luid)
{
if (luid != listedLuid)
{
return false;
}
Selected = new GpuAdapterIdentity
{
Name = "fake",
Luid = luid,
VendorId = vendor,
DeviceId = 1,
SubSysId = 0,
Revision = 0,
DedicatedVideoMemoryMb = 8192,
SharedSystemMemoryMb = 16384,
IsSoftware = false,
};
return true;
}
public bool TryRead([NotNullWhen(true)] out GpuSample? sample)
{
sample = null;
return false;
}
public void Dispose()
{
}
}
/// <summary>A layer that reads its own GPU and is told the vendor.</summary>
private sealed class VendorLayer(TelemetryLayer layer) : IGpuTelemetrySource, IGpuVendorFollower
{
public List<uint> Vendors { get; } = [];
public TelemetryLayer Layer => layer;
public GpuCapabilities Capabilities => GpuCapabilities.None;
public bool IsDisabled => false;
public void FollowVendor(uint vendorId) => Vendors.Add(vendorId);
public bool TryRead([NotNullWhen(true)] out GpuSample? sample)
{
sample = null;
return false;
}
public void Dispose()
{
}
}
}
@@ -37,10 +37,12 @@ public sealed class LhmTelemetrySourceTests
return s;
}
private static IHardware Gpu(params ISensor[] sensors)
private static IHardware Gpu(params ISensor[] sensors) => Gpu(HardwareType.GpuNvidia, sensors);
private static IHardware Gpu(HardwareType type, params ISensor[] sensors)
{
IHardware h = Substitute.For<IHardware>();
h.HardwareType.Returns(HardwareType.GpuNvidia);
h.HardwareType.Returns(type);
h.Name.Returns("fake");
h.Sensors.Returns(sensors);
h.SubHardware.Returns([]);
@@ -57,6 +59,34 @@ public sealed class LhmTelemetrySourceTests
private static LhmTelemetrySource Source(ILhmComputer computer, ManualTimeProvider? clock = null) =>
new(computer, new LhmTelemetryOptions(), clock ?? new ManualTimeProvider());
/// <summary>
/// beta.13: a laptop's tree lists the integrated GPU first while the game runs on the discrete one. Told the game
/// adapter's vendor, the layer maps that vendor's node; with no node of that vendor it publishes nothing.
/// </summary>
[Fact]
public void ToldTheGamesVendorThePollMapsThatVendorsNodeOrNothing()
{
ILhmComputer computer = Computer(
Gpu(HardwareType.GpuIntel, Sensor(SensorType.Temperature, "GPU Core", 48f)),
Gpu(HardwareType.GpuNvidia, Sensor(SensorType.Temperature, "GPU Core", 66f)));
using LhmTelemetrySource source = Source(computer);
source.PollOnce();
source.TryRead(out GpuSample? first).Should().BeTrue();
first!.TempCoreC.Should().Be(48, "before the game's adapter is known, the first node, as before");
source.FollowVendor(0x10DE);
source.PollOnce();
source.TryRead(out GpuSample? nvidia).Should().BeTrue();
nvidia!.TempCoreC.Should().Be(66);
source.FollowVendor(0x1002);
source.PollOnce();
source.TryRead(out GpuSample? amd).Should().BeFalse("the tree has no AMD node: N/A, not another card's figure");
amd.Should().BeNull();
source.IsDisabled.Should().BeFalse();
}
[Fact]
public void APollMapsTheFirstGpuAndPublishesItsFieldsAsCapabilities()
{
@@ -41,6 +41,26 @@ public sealed class NvapiTelemetrySourceTests
bridge.Inits.Should().Be(1);
}
/// <summary>
/// beta.13: NVAPI reads NVIDIA's first GPU, so when the game presents on AMD's or Intel's the layer says nothing rather
/// than another card's temperature — without a fault, and back when the game's adapter is NVIDIA's.
/// </summary>
[Fact]
public void AGameOnAnotherVendorsAdapterGetsNothingFromNvapi()
{
using var bridge = new FakeNvapiBridge { Sample = FakeNvapiBridge.Full };
using var source = new NvapiTelemetrySource(bridge, new ManualTimeProvider());
source.FollowVendor(0x1002);
source.TryRead(out GpuSample? amd).Should().BeFalse();
amd.Should().BeNull();
source.IsDisabled.Should().BeFalse("nothing went wrong; it just is not the game's card");
source.FollowVendor(0x10DE);
source.TryRead(out GpuSample? nvidia).Should().BeTrue();
nvidia!.TempCoreC.Should().Be(62);
}
[Theory]
[InlineData(NativeNvapiBridge.Unavailable)]
[InlineData(-6)]
@@ -24,6 +24,27 @@ public sealed class TelemetryPollerTests
public override long GetTimestamp() => Ticks;
}
/// <summary>
/// beta.13: the adapter the game presents on reaches the source — the real L1 switches to a LUID DXGI listed — and a source
/// that cannot follow adapters answers false rather than pretending.
/// </summary>
[Fact]
public void TheGamesAdapterReachesALayerThatCanFollowIt()
{
using var memory = new FakeMemoryCounter(_ => () => 1024);
using var l1 = new BaselineTelemetrySource(new FakeDxgi(FakeDxgi.Identity("first", 0x10), FakeDxgi.Identity("second", 0x20)), memory, new ManualTimeProvider());
using var composite = new CompositeTelemetrySource([l1]);
using var poller = new TelemetryPoller(composite, new TelemetryPollerOptions(), new ManualTimeProvider());
poller.FollowAdapter(0x20).Should().BeTrue();
l1.Selected!.Name.Should().Be("second");
poller.FollowAdapter(0xDEAD).Should().BeFalse("DXGI never listed it");
using var layer = new FakeLayer(TelemetryLayer.Lhm);
using var plain = new TelemetryPoller(layer, new TelemetryPollerOptions(), new ManualTimeProvider());
plain.FollowAdapter(0x20).Should().BeFalse("a layer that reads its own GPU is told a vendor by the composite, not a LUID");
}
[Fact]
public void ATickStampsTheLayersSampleWithTheCallersTimestampClock()
{