Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6346d488e7 |
No files matched your search
@@ -19,6 +19,19 @@ GitHub release body, so a missing section will mean an empty release note.
|
||||
|
||||
### Added
|
||||
|
||||
- **P1 item 1 — the `LoadLibrary` detour, both jobs (2026-09-06).** The Overlay patches
|
||||
`kernelbase.dll!LoadLibraryExW` after its present hooks (`17_HOOK_ENGINE` §DLL entry step 3): a module
|
||||
the hook inventory or runtime census names **wakes the watchdog** through an auto-reset event, so the
|
||||
lazy installers run within milliseconds of the module instead of on the next 1 Hz tick (94 ms measured
|
||||
against a 500 ms bound); a module matching the compiled anti-cheat floor's MODULE families **stops the
|
||||
Overlay from inside** with the new `FL_STATUS_STOPPED_BLOCKLISTED`, on the next present or watchdog
|
||||
iteration — `20_OPEN_QUESTIONS` §S6 ✅, `19_SAFETY` §During a session's in-process half (exact names
|
||||
only; fragment and signer stay the host's 30 s scan, so the Disclaimer's window is unchanged). The
|
||||
detour installs nothing inline (§H2), calls the original first, and skips data-file / resource loads.
|
||||
Two `FlWriterState` words from `reserved[]` (`loaderSignals` @56, `earlyStopFamily` @58; no layout
|
||||
bump), `hook-harness --load-after-ms N PATH`, two real-Overlay ctest cases (`[loader]`, `[S6]`), and
|
||||
the CaptureHost's `loader detour:` / `EARLY STOP` report lines, `SessionEndReason.WriterStoppedBlocklisted`
|
||||
(exit 5) with the family named from the staged rules file.
|
||||
- **P0 closed — the closing sweep (owner: "theo bảng", 2026-09-06).** Exit criterion 1 is met with
|
||||
the quality preset amended to an honest `N/A` by measurement; criterion 2 is met with §S24 counting
|
||||
zero S-items against it. Three items closed by a gate each: **§S19(c)** — `rules-validate` gains a
|
||||
|
||||
@@ -284,6 +284,13 @@ Findings written to `docs/spike-notes.md`. Nothing in P1 starts until the exit c
|
||||
## P1 — Native core (1.5 weeks)
|
||||
`FrameLedger.Overlay` proper: hook installation for D3D11/12/9/OGL, feature hooks, ring writer, fault policy, unhook path, native logging. `FrameLedger.Injector` with launch + attach modes. Struct mirror + Catch2 tests. Vulkan layer to parity — `vkQueuePresentKHR` plus the in-layer supervision check §S2 gates on it.
|
||||
|
||||
> **P1 item 1 landed 2026-09-06: the `LoadLibrary` detour** (`kernelbase!LoadLibraryExW`; wake for lazily
|
||||
> loaded runtimes + §S6's in-process anti-cheat stop, `FL_STATUS_STOPPED_BLOCKLISTED`), measured in
|
||||
> ctest `fl_guard` `[loader]` / `[S6]`. Order for the rest, as proposed and accepted: **2** the Injector's
|
||||
> launch mode (§S13(c), §S1's deferred input); **3** the Vulkan layer to `vkQueuePresentKHR` with §S2's
|
||||
> in-layer supervision and a harness Vulkan mode (reopens §S29(d)'s CI leg); **4** the unhook path,
|
||||
> native logging, D3D9 / OpenGL.
|
||||
|
||||
> **The guard already shipped, in P0.** This line used to read "the guard,
|
||||
> complete and fully tested — it ships before the first real injection, not
|
||||
> after", which was the correct ordering stated in the wrong phase: P0 items 1
|
||||
|
||||
@@ -32,6 +32,31 @@ The injected DLL. Its whole job: install hooks, write 64-byte records into a rin
|
||||
1. Open/create shared memory `Local\FrameLedger.Ring.<pid>`; write the handshake header (layout version, build id, pid, api=unknown).
|
||||
2. `MH_Initialize()`.
|
||||
3. Resolve which graphics APIs are present (`GetModuleHandleW` on `d3d11.dll`, `d3d12.dll`, `dxgi.dll`, `opengl32.dll`) — and register a `LoadLibrary` hook so APIs loaded **later** still get hooked (many games load D3D12 lazily). **The `LoadLibrary` hook must not install hooks inline:** it runs under the loader lock, and MinHook suspends all threads to patch, which deadlocks against any thread waiting on that lock. It enqueues the request and signals the init thread, which installs outside the lock (`20_OPEN_QUESTIONS` §H2).
|
||||
|
||||
> **Built 2026-09-06 (P1 item 1), with two differences from the sentence above.** The detour is on
|
||||
> `kernelbase.dll!LoadLibraryExW` — the one body every `LoadLibrary*` variant of `kernel32` reaches —
|
||||
> and it is installed **after** the present hooks, from `InitThread`, outside any loader lock. It
|
||||
> **enqueues nothing**: the module's real file name (`GetModuleFileNameW` on the handle the original
|
||||
> returned, into a stack buffer — never the caller's string, which may be relative or an API set) is
|
||||
> compared against two fixed tables and the detour then does one of two things, both a single store
|
||||
> plus `SetEvent` on the watchdog's auto-reset wake event. **(a)** A name that is in `FL_HOOK_INVENTORY`
|
||||
> or `FL_RUNTIME_CENSUS` bumps a saturating 15-bit wake count and wakes the watchdog, whose next
|
||||
> iteration runs the same lazy installers it always ran — so the install happens on the watchdog
|
||||
> thread, as before, but **within milliseconds of the module rather than on the next 1 Hz tick**
|
||||
> (measured in ctest `fl_guard` `[loader]`: 94 ms from the module appearing to the hook family being
|
||||
> published, against a 500 ms bound that discriminates the wake from the tick). **(b)** A name that
|
||||
> matches a MODULE family of the compiled anti-cheat floor (`fl_ac_floor.generated.h`, the same table
|
||||
> the guard carries — prefix, case-insensitive, allocation-free) records the family's 1-based index in
|
||||
> `earlyStopFamily` and wakes the watchdog; the **present path** stops the Overlay on its next
|
||||
> `MayObserve` and the **watchdog** stops it on its next iteration, whichever comes first, with the new
|
||||
> status `FL_STATUS_STOPPED_BLOCKLISTED` (= 4) — `19_SAFETY` §During a session, the in-process half;
|
||||
> `20_OPEN_QUESTIONS` §S6. The words are `FlWriterState.loaderSignals` @56 (bit 15 = installed, bits
|
||||
> 0..14 = wake count) and `earlyStopFamily` @58, both carved from `reserved[]` so the layout version did
|
||||
> not move. The original is always called first and its result returned untouched, and
|
||||
> `LOAD_LIBRARY_AS_DATAFILE` / `_EXCLUSIVE` / `AS_IMAGE_RESOURCE` loads are skipped — no code runs from
|
||||
> them and the loader does not list them. Body under `FL_HOOK_GUARD`, no allocation, no lock, no
|
||||
> logging (rule 5). Exercised by `hook-harness --load-after-ms N PATH` (up to four), against the real
|
||||
> Overlay in a real target, both jobs.
|
||||
4. Install present hooks for what exists (below).
|
||||
5. Install feature hooks (upscaler / RT / PSO) lazily — the first time their module appears.
|
||||
6. Publish `status = ready` in the handshake block.
|
||||
@@ -126,6 +151,12 @@ Every hook must be listed here with a purpose. Anything not on this list is not
|
||||
> so a shipped hook missing from here is invisible to every gate. Flip the row **and this
|
||||
> banner** in the same PR that builds a hook.
|
||||
|
||||
### The one system-module detour — a hook, and the asymmetry stated
|
||||
|
||||
| Hook | Purpose |
|
||||
|---|---|
|
||||
| ✅ `kernelbase.dll!LoadLibraryExW` (2026-09-06, P1 item 1) | The wake for lazily loaded runtimes and the in-process anti-cheat stop — §DLL entry step 3 above carries the mechanism. **Rule 4:** it reads one argument the API was given (`flags`) and one property of a handle the loader just returned to *its own caller* (the module file name); nothing of the game's. **It is the only hook on a system module, and it is deliberately not in `FL_HOOK_INVENTORY`:** that table is *vendor* symbols resolved by name and gated by `hookinventory-check` against `vendor-exports.json`, and `LoadLibraryExW` is neither vendor nor uncertain. It is listed here instead so the table above and this row together are the whole inventory. It **never** installs, uninstalls or patches anything itself (§H2) |
|
||||
|
||||
### Watchdog observations — not hooks, and listed here so nobody mistakes them for one
|
||||
|
||||
| Observation | Mechanism | Rule 4 | Why |
|
||||
|
||||
@@ -578,6 +578,20 @@ injected or layered**.
|
||||
|
||||
**Be honest about the window.** A 30 s poll means anti-cheat can be loaded for up to 30 s before we react — the unhook is immediate *once detected*, not immediate in absolute terms. Consent and disclaimer wording must say "within 30 seconds", never "immediately" (`legal/DISCLAIMER.md` §2). Whether to shrink the window, or to detect the load directly via the `LoadLibrary` hook `17_HOOK_ENGINE` §DLL entry **specifies** for lazily-loaded graphics DLLs, is `20_OPEN_QUESTIONS` §S6.
|
||||
|
||||
> **The in-process half exists since 2026-09-06 (P1 item 1), and the sentence above stays true because
|
||||
> of what it does NOT cover.** The Overlay's `LoadLibrary` detour compares every module the loader maps
|
||||
> mid-session against the **compiled floor's MODULE families — the exact prefix names, and nothing
|
||||
> else** — and stops the Overlay from inside on a match (`FL_STATUS_STOPPED_BLOCKLISTED`; `17_HOOK_ENGINE`
|
||||
> §DLL entry step 3), within one present or one watchdog iteration. That is the same set the Agent's
|
||||
> guard matches by name. **The fragment tier and the signer tier are not in the detour**, on purpose: a
|
||||
> substring scan is not allocation-free in a hook body under the loader lock, and `WinVerifyTrust` from
|
||||
> inside a game process is out of the question — so a module the floor knows only by a fragment, or only
|
||||
> by its signer, is still caught by **this host's 30 s scan and by nothing sooner**. The disclosure
|
||||
> therefore does not change: "within 30 seconds" remains the promise; the exact-name case is now usually
|
||||
> much faster, and the report says which happened (`EARLY STOP` naming the family, or the host's own
|
||||
> stop). Modules loaded **before** the Overlay attached are the pre-injection scan's, as always. The
|
||||
> detour supplements the poll; it replaces nothing (§S6's own ruling).
|
||||
|
||||
> **This sentence used to say the hook "already exists and is currently unused", which was false.** Corrected 2026-08-04: the Overlay installs no hooks at all — `dllmain.cpp` exports one function and nothing in the tree calls `MH_CreateHook` outside a probe. §S6 is therefore downstream of the whole P1 hook layer, not "the cheapest available improvement to the most important behavior in the product". A reader planning work off this paragraph was being told a mechanism was sitting there ready.
|
||||
|
||||
### Elevated / protected targets
|
||||
|
||||
@@ -81,7 +81,7 @@ or it becomes the next stale status claim this file exists to record.
|
||||
| **S23-4** | ✅ **resolved 2026-08-05** | `19_SAFETY` §During a session said "the module scan and the driver scan"; `EvaluateImpl` runs four. Reworded to "every pre-injection check" so it cannot go stale when a check is added, with the two omissions named — `services` is the only tier measured firing on real anti-cheat, and the pre-scan is the only one touching the filesystem |
|
||||
| **S2 part three** | 🅓 **deferred to P1, rationale written 2026-09-06** | In-layer supervision lands with `vkQueuePresentKHR` (P1). Building it sooner would be a predicate whose wrong answer changes nothing observable; the layer intercepts nothing, so nothing a user sees waits on it |
|
||||
| **S4 signing** | 🅓 **deferred to P4, rationale written 2026-09-06** | Signing is a property of the feed and there is no feed (§S20); every rules file today shipped inside a release whose checksum attests it. The P4 decision (compiled-in key, detached signature, fail-closed) is written in the entry |
|
||||
| **S6** | 🅓 **deferred to P1, rationale written 2026-09-06** | The `LoadLibrary` hook that would raise the stop flag on a blocklisted load needs the P1 detour lazily loaded graphics DLLs need; building it twice is the cost of doing it in P0. The 30 s window stays disclosed |
|
||||
| **S6** | ✅ **built 2026-09-06 (P1 item 1)** | The detour on `kernelbase!LoadLibraryExW` stops the Overlay from inside on an exact-floor MODULE match, within one present or one watchdog iteration, and wakes the lazy installers within milliseconds for an inventoried module; measured against the real Overlay in ctest `fl_guard` `[loader]`/`[S6]`. Exact names only — fragment and signer stay the host's 30 s scan, so the disclosure does not change |
|
||||
| **S19(a)** | ✅ **resolved 2026-08-05** | `gameguard` could never fire — `guard` subsumed it. Removed; `rules-validate` now fails when any fragment contains another, so the class cannot return. Zero coverage lost: nProtect has its own named module family |
|
||||
| **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 |
|
||||
@@ -3137,9 +3137,32 @@ Two decisions, both the owner's:
|
||||
Until both are answered the inertness is recorded in the data's own `$comment`
|
||||
and beside check 3, rather than being inferable only from two empty arrays.
|
||||
|
||||
### S6 · The 30 s scan window is the weakest part of the most important behavior
|
||||
### S6 ✅ · The 30 s scan window is the weakest part of the most important behavior — **the in-process half built 2026-09-06 (P1 item 1)**
|
||||
|
||||
Now disclosed honestly in the Disclaimer and README. The open question is whether
|
||||
> **Built, as the deferral below said it would be: one detour, both jobs.** `kernelbase.dll!LoadLibraryExW`
|
||||
> is patched from `InitThread` after the present hooks; the body calls the original first, skips
|
||||
> data-file / resource mappings, reads the mapped module's own file name into a stack buffer and compares
|
||||
> its base name (a) against `FL_HOOK_INVENTORY` + `FL_RUNTIME_CENSUS` — a match bumps a 15-bit wake count
|
||||
> and signals the watchdog's auto-reset event, so the lazy installers run **within milliseconds** rather
|
||||
> than on the next 1 Hz tick — and (b) against the compiled floor's MODULE families (prefix, case-
|
||||
> insensitive, the generated table the guard itself carries; zero allocation) — a match CASes the family's
|
||||
> 1-based index into `earlyStopFamily`, and the present path (`MayObserve`) or the watchdog, whichever is
|
||||
> first, calls `StopObserving(FL_STATUS_STOPPED_BLOCKLISTED)`. It supplements the poll and replaces
|
||||
> nothing; it installs nothing inline (§H2). **Measured**, real Overlay in a real target (ctest `fl_guard`):
|
||||
> a late `sl.interposer.dll` hooked **94 ms** after it appeared (bound 500 ms, which the tick alone cannot
|
||||
> meet more than half the time); a decoy copied to `EasyAntiCheat_fl_fixture.dll` and loaded 2.5 s in
|
||||
> stopped the Overlay with `earlyStopFamily` equal to the index the test computed from the same generated
|
||||
> table, `unhookRequested` still 0, and `writeIndex` frozen thereafter. The CaptureHost reads both words
|
||||
> (`Consume/EarlyStop.cs`), ends the session as `WriterStoppedBlocklisted` (exit 5, the safety-stop code)
|
||||
> and names the family from the staged rules file.
|
||||
>
|
||||
> **What it does not do, stated so the disclosure stays honest:** the fragment tier and the signer tier
|
||||
> are not in the detour, so a module the floor knows only that way waits for the host's 30 s scan; the
|
||||
> Disclaimer's "within 30 seconds" is unchanged. **Owed:** the real-game leg of §H2 — a title that loads
|
||||
> D3D12 or Streamline lazily, hooked through the wake rather than the tick — which the next captures
|
||||
> report via the `loader detour:` line (`woke the watchdog N time(s)`).
|
||||
|
||||
Now disclosed honestly in the Disclaimer and README. The open question ~~is~~ was whether
|
||||
to shrink it.
|
||||
|
||||
> **"Already installs" was false, and it changed how this item read.** Corrected
|
||||
@@ -3308,6 +3331,14 @@ lazily, which is the case the hook exists for. Until then, keep the rule and do
|
||||
not let anyone "simplify" it back to an inline install on the grounds that the
|
||||
probe never showed a deadlock.
|
||||
|
||||
> **The deferred path is built and exercised in a fixture (2026-09-06, P1 item 1 — §S6).** The detour
|
||||
> signals an auto-reset event the watchdog waits on with its 1 s timeout; it never calls MinHook.
|
||||
> ctest `fl_guard` `[loader]` loads `sl.interposer.dll` into a presenting harness 2.3 s after start and
|
||||
> sees the hook family within 94 ms, wake count ≥ 1, no fault, no stop. **Still owed, unchanged:** the
|
||||
> 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.
|
||||
|
||||
### H5 ✅ · Proxy swapchains defeat the dummy-vtable assumption — **the DLSS / DLSS-G question closed 2026-09-06 (owner)**
|
||||
|
||||
> **CLOSED 2026-09-06, 12:17, on Cronos: The New Dawn demo with frame generation ON (`spike-notes` §9).**
|
||||
|
||||
+4
-2
@@ -38,7 +38,8 @@ outside any PR). **What comes next is P1** (`15_ROADMAP` §P1): the Overlay prop
|
||||
hook installation for D3D11/12/9/OGL, the `LoadLibrary` detour that §S6's early stop
|
||||
and lazily loaded runtimes both hang on, unhook path, native logging; the Injector's
|
||||
launch mode (§S13(c), §S1's deferred input); the Vulkan layer to `vkQueuePresentKHR`
|
||||
with §S2's in-layer supervision. The three P1-deferred S-items (S6, S2 part three, and
|
||||
with §S2's in-layer supervision. **P1 item 1 — the `LoadLibrary` detour — landed 2026-09-06
|
||||
(§S6 ✅); next is item 2, the Injector's launch mode.** The ~~three~~ two P1-deferred S-items (~~S6~~, S2 part three, and
|
||||
the hand-run blast-radius script behind S29(d)) are the reminders. The text below is
|
||||
P0's history and stays as it stood.
|
||||
|
||||
@@ -208,7 +209,8 @@ own PR with its own rule-4 justification.
|
||||
watchdog thread runs once a second. No `LoadLibrary` hook is needed for P0 — which
|
||||
keeps §S6 genuinely separable. The Overlay has **no** module-resolution machinery
|
||||
today (`GetProcAddress`/`GetModuleHandle` appear nowhere), so that helper is part of
|
||||
the real cost.
|
||||
the real cost. *(2026-09-06: the detour exists now — P1 item 1 — and it still only
|
||||
WAKES that thread; the installers did not move. `17_HOOK_ENGINE` §DLL entry step 3.)*
|
||||
- `tools/hookinventory-check.ps1`: every symbol the Overlay resolves by name must
|
||||
appear in `vendor-exports.json`. **No drift exists today** — a refuter resolved every
|
||||
inventory symbol against all 34 measured modules — so write it as prevention and do
|
||||
|
||||
@@ -56,6 +56,7 @@ internal static class SessionEndClassifier
|
||||
{
|
||||
FlStatus.Unhooked => weLatchedTheUnhook ? SessionEndReason.SafetyUnhook : SessionEndReason.SupervisionLost,
|
||||
FlStatus.SelfDisabled => SessionEndReason.WriterSelfDisabled,
|
||||
FlStatus.StoppedBlocklisted => SessionEndReason.WriterStoppedBlocklisted,
|
||||
FlStatus.Init when attachSettled => SessionEndReason.WriterNeverInstalledHooks,
|
||||
_ => SessionEndReason.Running,
|
||||
};
|
||||
|
||||
@@ -32,6 +32,14 @@ internal enum SessionEndReason
|
||||
/// <summary>Three hook faults; the Overlay went dormant on its own.</summary>
|
||||
WriterSelfDisabled,
|
||||
|
||||
/// <summary>
|
||||
/// The Overlay's <c>LoadLibrary</c> detour saw a module the compiled anti-cheat floor
|
||||
/// names arrive mid-session and stopped the Overlay from inside, before this host's
|
||||
/// 30 s scan could (<c>19_SAFETY</c> §During a session, the in-process half; §S6).
|
||||
/// <c>FlWriterState.EarlyStopFamily</c> names which family.
|
||||
/// </summary>
|
||||
WriterStoppedBlocklisted,
|
||||
|
||||
/// <summary>
|
||||
/// The handshake was published and <c>status</c> never left <c>INIT</c>, which
|
||||
/// means MinHook failed: the ring will never move.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using FrameLedger.Shared;
|
||||
|
||||
namespace FrameLedger.CaptureHost.Consume;
|
||||
|
||||
/// <summary>
|
||||
/// The Overlay's <c>LoadLibrary</c> detour, as the report reads it: whether the detour is in, how often it woke
|
||||
/// the watchdog for a module the inventory or census names, and — when the Overlay stopped itself — which
|
||||
/// anti-cheat family the module that arrived matched (<c>fl_shm.h</c> §loaderSignals / earlyStopFamily,
|
||||
/// <c>19_SAFETY</c> §During a session, the in-process half; §S6).
|
||||
/// </summary>
|
||||
internal static class EarlyStop
|
||||
{
|
||||
private const ushort _installedBit = 0x8000;
|
||||
|
||||
private const ushort _countMask = 0x7FFF;
|
||||
|
||||
/// <summary>The seed rules file staged beside this host (<c>FrameLedger.Rules.targets</c>).</summary>
|
||||
public static string StagedRulesPath => Path.Combine(AppContext.BaseDirectory, "rules", "detection-rules.json");
|
||||
|
||||
/// <summary>
|
||||
/// The family name behind a 1-based index into <c>anticheat.modules</c> of the rules file — the same order
|
||||
/// <c>gen-ac-floor.ps1</c> emits the compiled floor's MODULE families in, which is what the Overlay indexes.
|
||||
/// Null when the file cannot be read or the index is outside it; never a guess.
|
||||
/// </summary>
|
||||
public static string? FamilyName(int index, string rulesPath)
|
||||
{
|
||||
if (index <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using JsonDocument doc = JsonDocument.Parse(File.ReadAllBytes(rulesPath));
|
||||
if (!doc.RootElement.TryGetProperty("anticheat", out JsonElement anticheat)
|
||||
|| !anticheat.TryGetProperty("modules", out JsonElement modules)
|
||||
|| modules.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (JsonElement family in modules.EnumerateArray())
|
||||
{
|
||||
if (++i == index)
|
||||
{
|
||||
return family.TryGetProperty("family", out JsonElement name) ? name.GetString() : null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) when (e is IOException or UnauthorizedAccessException or JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The report's two lines: the detour's state always, the stop only when it happened.</summary>
|
||||
public static IEnumerable<string> Describe(FlWriterState writer, string rulesPath)
|
||||
{
|
||||
bool installed = (writer.LoaderSignals & _installedBit) != 0;
|
||||
int wakes = writer.LoaderSignals & _countMask;
|
||||
yield return installed
|
||||
? $" loader detour: installed (kernelbase!LoadLibraryExW); woke the watchdog {wakes.ToString(CultureInfo.InvariantCulture)} time(s) for a module the inventory or census names"
|
||||
: " loader detour: NOT installed - late vendor modules wait for the 1 Hz tick, and the in-process anti-cheat stop is absent; the host's 30 s scan is the only stop";
|
||||
|
||||
if (writer.EarlyStopFamily == 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
string? name = FamilyName(writer.EarlyStopFamily, rulesPath);
|
||||
yield return " EARLY STOP: the Overlay stopped ITSELF - a module matching anti-cheat family #"
|
||||
+ writer.EarlyStopFamily.ToString(CultureInfo.InvariantCulture)
|
||||
+ (name is null ? " (name not resolvable from the staged rules file)" : $" ({name})")
|
||||
+ " loaded mid-session (19_SAFETY §During a session, the in-process half); status="
|
||||
+ ((FlStatus)writer.Status).ToString()
|
||||
+ ". This is the exact-name floor only; the fragment-and-signer tier is the host's scan";
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ internal static class Program
|
||||
or SessionEndReason.TargetCannotBePinned => _exitTargetNotResolved,
|
||||
SessionEndReason.AttachRefused => _exitAttachRefused,
|
||||
SessionEndReason.SafetyUnhook or SessionEndReason.SupervisionLost
|
||||
or SessionEndReason.SupervisionFaulted => _exitStoppedForSafety,
|
||||
or SessionEndReason.SupervisionFaulted or SessionEndReason.WriterStoppedBlocklisted => _exitStoppedForSafety,
|
||||
_ => _exitRefused,
|
||||
};
|
||||
}
|
||||
@@ -210,7 +210,7 @@ internal static class Program
|
||||
$" apiMask=0x{result.WriterState.ApiMask:X} rtTier={result.WriterState.RtTier}");
|
||||
PrintCensus(result, markers);
|
||||
|
||||
HostConsole.Line(WriterNote(result));
|
||||
PrintWriterAndLoader(result);
|
||||
HostConsole.Line($" records carrying Upscaler={withUpscaler}/{dominant.Count} " +
|
||||
$"UpscalerParams={withParams}/{dominant.Count} " +
|
||||
$"(a value below the total means the hook came up mid-session, not that it never did)");
|
||||
@@ -388,6 +388,16 @@ internal static class Program
|
||||
return " cause: the record is present, enabled and matching — so the refusal came from elsewhere";
|
||||
}
|
||||
|
||||
/// <summary>The writer's own line, then the LoadLibrary detour's (installed / woke / EARLY STOP).</summary>
|
||||
private static void PrintWriterAndLoader(CaptureResult result)
|
||||
{
|
||||
HostConsole.Line(WriterNote(result));
|
||||
foreach (string line in EarlyStop.Describe(result.WriterState, EarlyStop.StagedRulesPath))
|
||||
{
|
||||
HostConsole.Line(line);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The two numbers that separate "nothing happened" from "something went wrong".
|
||||
/// </summary>
|
||||
|
||||
@@ -76,6 +76,13 @@ public enum FlStatus : uint
|
||||
/// <summary>Three hook faults; see <c>17_HOOK_ENGINE</c> §Fault policy.</summary>
|
||||
SelfDisabled = 2,
|
||||
Unhooked = 3,
|
||||
|
||||
/// <summary>
|
||||
/// A module matching the anti-cheat floor compiled into the Overlay loaded mid-session and the Overlay
|
||||
/// stopped itself (<c>19_SAFETY</c> §During a session, the in-process half; §S6). Which family:
|
||||
/// <see cref="FlWriterState.EarlyStopFamily"/>.
|
||||
/// </summary>
|
||||
StoppedBlocklisted = 4,
|
||||
}
|
||||
|
||||
/// <summary>Bits in <see cref="FlWriterState.ApiMask"/>, and the value of <see cref="FlFrameRecord.Api"/>.</summary>
|
||||
@@ -564,8 +571,20 @@ public unsafe struct FlWriterState
|
||||
/// <summary>Hooked presents on which the DXGI counter was read. Took <c>reserved[1]</c> on 2026-09-05.</summary>
|
||||
public uint DxgiPresentSamples;
|
||||
|
||||
/// <summary>
|
||||
/// The <c>LoadLibrary</c> detour's word: bit 15 = installed; bits 0..14 = how many times a module the hook
|
||||
/// inventory or the runtime census names was loaded and the watchdog woken for it.
|
||||
/// </summary>
|
||||
public ushort LoaderSignals;
|
||||
|
||||
/// <summary>
|
||||
/// 0 = none; else the 1-based index, among the compiled floor's MODULE families in rules order, of the
|
||||
/// family whose value matched a module loaded mid-session. Paired with <see cref="FlStatus.StoppedBlocklisted"/>.
|
||||
/// </summary>
|
||||
public ushort EarlyStopFamily;
|
||||
|
||||
/// <summary>Must be zero; room for additive fields.</summary>
|
||||
public fixed uint Reserved[2];
|
||||
public fixed uint Reserved[1];
|
||||
|
||||
// WHY THE COUNTERS ARE PUBLISHED AT 1 Hz AND NOT ACCUMULATED HERE PER FRAME: this struct is
|
||||
// region 2, which the Overlay writes on the present path, and the regions are separate cache lines
|
||||
|
||||
@@ -25,6 +25,13 @@ add_library(FrameLedger.Overlay SHARED src/dllmain.cpp)
|
||||
# and third_party/fidelityfx/README.md: an Overlay that imports a vendor module
|
||||
# fails to load in every game that ships no such module, in the loader, silently.
|
||||
# hookinventory-check Pass C reads the built DLL's import AND export tables.
|
||||
# fl_ac_floor: the anti-cheat MODULE families compiled into the guard, now also into
|
||||
# the Overlay for the LoadLibrary detour's early stop (§S6). Types only from
|
||||
# fl_ac_rules.h -- nothing of fl_ac_rules.cpp is compiled here, and the Overlay
|
||||
# links neither wintrust nor the rules parser.
|
||||
target_include_directories(FrameLedger.Overlay PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../FrameLedger.Injector/include")
|
||||
add_dependencies(FrameLedger.Overlay fl_ac_floor_gen)
|
||||
target_link_libraries(FrameLedger.Overlay PRIVATE fl_ac_floor)
|
||||
target_link_libraries(FrameLedger.Overlay PRIVATE FrameLedger.Shm fl_dxgi_vtable fl_native_flags fl_hostile_env_flags minhook
|
||||
fl_streamline_headers fl_fidelityfx_headers fl_fsr3_host_headers
|
||||
Advapi32 d3d11 d3d12 dxgi)
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fl_ac_rules.h>
|
||||
#include <fl_d3d12_vtable.h>
|
||||
#include <fl_dxgi_vtable.h>
|
||||
#include <fl_hook_inventory.h>
|
||||
@@ -53,6 +54,12 @@
|
||||
#include <MinHook.h>
|
||||
#include <sddl.h>
|
||||
|
||||
// Its own block, below the sorted one, because it needs Family/Group/MatchKind
|
||||
// from fl_ac_rules.h and clang-format sorts each block independently. Types plus
|
||||
// the generated floor table only -- for the LoadLibrary detour's early stop; nothing
|
||||
// of the rules parser is compiled into the Overlay.
|
||||
#include <fl_ac_floor.generated.h>
|
||||
|
||||
// Vendored MIT headers, for TYPES ONLY -- never linked, and no vendor function's
|
||||
// address is ever taken in evaluated code. See
|
||||
// third_party/streamline/README.md: linking one would make sl.interposer.dll a
|
||||
@@ -615,6 +622,12 @@ void StopObserving(uint32_t reason) noexcept {
|
||||
// is the whole point of having one. What stays is the safety stop, because
|
||||
// 07_IPC requires it within one frame and a one-second watchdog cannot promise
|
||||
// that, and the pause check, which is inherently per-frame.
|
||||
// The LoadLibrary detour's early stop (defined with the detour below; the present
|
||||
// path reads it first): 0 = none; else 1-based index among the floor's MODULE
|
||||
// families in rules order.
|
||||
std::atomic<uint32_t> g_earlyStopFamily{0};
|
||||
void PublishLoaderWords() noexcept;
|
||||
|
||||
bool MayObserve() noexcept {
|
||||
if (g_observing.load(std::memory_order_acquire) == 0) {
|
||||
return false;
|
||||
@@ -631,6 +644,15 @@ bool MayObserve() noexcept {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The IN-PROCESS stop, same path and same polarity: the LoadLibrary detour saw
|
||||
// a module matching the compiled anti-cheat floor load. Published before the
|
||||
// unhook so the reason is on the mapping whichever thread gets here first.
|
||||
if (g_earlyStopFamily.load(std::memory_order_acquire) != 0u) {
|
||||
PublishLoaderWords();
|
||||
StopObserving(FL_STATUS_STOPPED_BLOCKLISTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pausing is not stopping: the Agent asked us to hold, and the supervision
|
||||
// clock keeps running (in the watchdog), so a paused session still stops if
|
||||
// the guard dies.
|
||||
@@ -937,6 +959,180 @@ std::atomic<uint32_t> g_dxgiSamples{0};
|
||||
// it: they do not move the counter (#35), so there is nothing to invalidate.
|
||||
std::atomic<uint32_t> g_dxgiEpoch{0};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// THE LoadLibrary DETOUR (17_HOOK_ENGINE §DLL entry step 3; §H2; §S6). P1 item 1,
|
||||
// 2026-09-06. Two jobs, one rule.
|
||||
//
|
||||
// The jobs: (a) a module the hook inventory or the runtime census names loaded
|
||||
// AFTER init -- the watchdog is woken now instead of on its next 1 Hz tick, so
|
||||
// the window in which a late vendor module's calls go unobserved shrinks from up
|
||||
// to a second to milliseconds; (b) a module whose base name matches the
|
||||
// anti-cheat floor compiled into this binary loaded mid-session -- the Overlay
|
||||
// stops ITSELF on the next present or watchdog wake, the in-process half of
|
||||
// 19_SAFETY §During a session, where the host's 30 s scan was the only half.
|
||||
//
|
||||
// The rule: the detour INSTALLS NOTHING AND UNHOOKS NOTHING INLINE. MinHook
|
||||
// suspends every other thread to patch, and a LoadLibrary caller may hold the
|
||||
// loader lock (a DllMain calling LoadLibrary is legal); suspending a thread that
|
||||
// holds it, from a thread that then waits on it, is the deadlock §H2 names. So
|
||||
// the detour reads a base name off the module the ORIGINAL returned, compares it
|
||||
// against two fixed tables without allocating, stores two atomics, and signals an
|
||||
// event. Everything that patches runs on the watchdog thread, outside the lock.
|
||||
//
|
||||
// kernelbase!LoadLibraryExW is the target because it is the funnel: LoadLibraryA,
|
||||
// LoadLibraryW and LoadLibraryExA all reach it inside KernelBase, so one detour
|
||||
// covers the four documented entry points. What it does NOT cover, stated:
|
||||
// LdrLoadDll called directly (no measured title does), and delay-load thunks
|
||||
// resolved before we attached (they went through it before we existed). The 1 Hz
|
||||
// watchdog and the host's 30 s scan remain the backstops for both jobs.
|
||||
//
|
||||
// NOT an FL_HOOK_INVENTORY row: that table is (vendor module, exported symbol)
|
||||
// and Pass A checks each row against measured vendor exports. This is a system
|
||||
// module, and 17_HOOK_ENGINE §Hook inventory records the asymmetry beside the
|
||||
// ray-tracing vtable slots, which are outside the table for the same reason.
|
||||
// ---------------------------------------------------------------------------
|
||||
using PFN_LoadLibraryExW = HMODULE(WINAPI*)(LPCWSTR, HANDLE, DWORD);
|
||||
PFN_LoadLibraryExW g_origLoadLibraryExW = nullptr;
|
||||
|
||||
// Bit 15 = installed; bits 0..14 = wake-ups for inventoried modules (saturating).
|
||||
constexpr uint32_t kLoaderInstalledBit = 0x8000u;
|
||||
constexpr uint32_t kLoaderCountMask = 0x7FFFu;
|
||||
std::atomic<uint32_t> g_loaderSignals{0};
|
||||
// Auto-reset; the watchdog waits on it with its 1 s timeout, so a signal ends the
|
||||
// wait early and a missing event (creation failed) degrades to the plain sleep.
|
||||
HANDLE g_watchdogWake = nullptr;
|
||||
|
||||
const wchar_t* BaseNameOf(const wchar_t* path) noexcept {
|
||||
const wchar_t* base = path;
|
||||
for (const wchar_t* p = path; *p != L'\0'; ++p) {
|
||||
if (*p == L'\\' || *p == L'/') {
|
||||
base = p + 1;
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
wchar_t AsciiLower(wchar_t c) noexcept {
|
||||
return (c >= L'A' && c <= L'Z') ? static_cast<wchar_t>(c + (L'a' - L'A')) : c;
|
||||
}
|
||||
|
||||
// Case-insensitive ASCII compare of a wide base name against a narrow rule value:
|
||||
// exact, or the value as a prefix. The rules are ASCII by schema, so a wide
|
||||
// character outside ASCII simply never matches.
|
||||
bool NameMatches(const wchar_t* base, const char* value, bool prefix) noexcept {
|
||||
size_t i = 0;
|
||||
for (; value[i] != '\0'; ++i) {
|
||||
const wchar_t b = base[i];
|
||||
if (b == L'\0' || AsciiLower(b) != AsciiLower(static_cast<wchar_t>(static_cast<unsigned char>(value[i])))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return prefix || base[i] == L'\0';
|
||||
}
|
||||
|
||||
// The compiled floor's MODULE families, in order: the 1-based index of the first
|
||||
// whose value matches, else 0. The same prefix/exact semantics the guard's
|
||||
// MatchName applies to a base name, on the same generated table.
|
||||
uint32_t MatchesFloorModule(const wchar_t* base) noexcept {
|
||||
uint32_t index = 0;
|
||||
for (const fl::guard::Family& f : fl::guard::generated::kFloorFamilies) {
|
||||
if (f.group != fl::guard::Group::kModules) {
|
||||
continue;
|
||||
}
|
||||
++index;
|
||||
for (std::size_t v = 0; v < f.valueCount; ++v) {
|
||||
if (NameMatches(base, f.values[v], f.match == fl::guard::MatchKind::kPrefix)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Does the inventory or the census name this module? A load of one of these is
|
||||
// what the watchdog installs or counts on its next tick, so it is what wakes it.
|
||||
bool ModuleIsInventoried(const wchar_t* base) noexcept {
|
||||
#define FL_LOADER_NAME(mod, ...) \
|
||||
if (_wcsicmp(base, mod) == 0) { \
|
||||
return true; \
|
||||
}
|
||||
FL_HOOK_INVENTORY(FL_LOADER_NAME)
|
||||
FL_RUNTIME_CENSUS(FL_LOADER_NAME)
|
||||
#undef FL_LOADER_NAME
|
||||
return false;
|
||||
}
|
||||
|
||||
void WakeWatchdog() noexcept {
|
||||
if (g_watchdogWake != nullptr) {
|
||||
SetEvent(g_watchdogWake);
|
||||
}
|
||||
}
|
||||
|
||||
HMODULE WINAPI Hook_LoadLibraryExW(LPCWSTR name, HANDLE file, DWORD flags) noexcept {
|
||||
// The original FIRST, always, and its result is returned untouched: this
|
||||
// detour must be invisible to the loader's caller whatever happens below.
|
||||
const HMODULE h = g_origLoadLibraryExW(name, file, flags);
|
||||
FL_HOOK_GUARD({
|
||||
// A data-file or resource mapping is not a module: no code runs from it
|
||||
// and the loader does not list it, so neither job applies.
|
||||
constexpr DWORD kNotAModule =
|
||||
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_IMAGE_RESOURCE;
|
||||
if (h != nullptr && (flags & kNotAModule) == 0u && g_observing.load(std::memory_order_acquire) != 0) {
|
||||
// The module's real file name, not the caller's string: a relative or
|
||||
// API-set name resolves to whatever the loader mapped, and that is the
|
||||
// name the guard would see.
|
||||
wchar_t path[MAX_PATH]{};
|
||||
if (GetModuleFileNameW(h, path, MAX_PATH) != 0) {
|
||||
const wchar_t* base = BaseNameOf(path);
|
||||
const uint32_t family = MatchesFloorModule(base);
|
||||
if (family != 0u) {
|
||||
uint32_t none = 0;
|
||||
g_earlyStopFamily.compare_exchange_strong(none, family, std::memory_order_acq_rel);
|
||||
WakeWatchdog();
|
||||
} else if (ModuleIsInventoried(base)) {
|
||||
uint32_t cur = g_loaderSignals.load(std::memory_order_relaxed);
|
||||
while ((cur & kLoaderCountMask) < kLoaderCountMask &&
|
||||
!g_loaderSignals.compare_exchange_weak(cur, cur + 1u, std::memory_order_relaxed)) {
|
||||
}
|
||||
WakeWatchdog();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return h;
|
||||
}
|
||||
|
||||
// Installed AFTER the present hooks, from InitThread, outside any loader lock.
|
||||
// Failure is not fatal and is visible: bit 15 stays clear, so the report can say
|
||||
// the detour is absent and the two backstops are all there is.
|
||||
bool InstallLoaderHook() noexcept {
|
||||
const HMODULE kb = GetModuleHandleW(L"kernelbase.dll");
|
||||
if (kb == nullptr) {
|
||||
return false;
|
||||
}
|
||||
void* target = reinterpret_cast<void*>(GetProcAddress(kb, "LoadLibraryExW"));
|
||||
if (target == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (MH_CreateHook(target, reinterpret_cast<void*>(&Hook_LoadLibraryExW),
|
||||
reinterpret_cast<void**>(&g_origLoadLibraryExW)) != MH_OK ||
|
||||
MH_EnableHook(target) != MH_OK) {
|
||||
return false;
|
||||
}
|
||||
g_loaderSignals.fetch_or(kLoaderInstalledBit, std::memory_order_release);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PublishLoaderWords() noexcept {
|
||||
if (g_state == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::atomic_ref<uint16_t> signals{g_state->loaderSignals};
|
||||
std::atomic_ref<uint16_t> family{g_state->earlyStopFamily};
|
||||
signals.store(static_cast<uint16_t>(g_loaderSignals.load(std::memory_order_relaxed)), std::memory_order_relaxed);
|
||||
family.store(static_cast<uint16_t>(g_earlyStopFamily.load(std::memory_order_relaxed)), std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void NoteTagTypes(uint32_t typeBits, uint32_t routeShift) noexcept {
|
||||
if (typeBits == 0u) {
|
||||
return;
|
||||
@@ -1845,7 +2041,13 @@ bool InstallRtHooks() noexcept {
|
||||
// Overlay and was not in the Vulkan layer.
|
||||
DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
for (;;) {
|
||||
Sleep(kWatchdogIntervalMs);
|
||||
// The 1 s tick, OR the LoadLibrary detour's wake -- whichever comes first.
|
||||
// An event that failed to create degrades to the plain sleep.
|
||||
if (g_watchdogWake != nullptr) {
|
||||
WaitForSingleObject(g_watchdogWake, kWatchdogIntervalMs);
|
||||
} else {
|
||||
Sleep(kWatchdogIntervalMs);
|
||||
}
|
||||
|
||||
if (g_observing.load(std::memory_order_acquire) == 0) {
|
||||
return 0; // stopped by us or by a hook body; nothing left to decide
|
||||
@@ -1860,18 +2062,32 @@ DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The in-process stop, for a title that is NOT presenting (menu, hung,
|
||||
// alt-tabbed) -- the case the present path cannot reach. Same order as the
|
||||
// Agent's stop: before any install.
|
||||
if (g_earlyStopFamily.load(std::memory_order_acquire) != 0u) {
|
||||
PublishLoaderWords();
|
||||
StopObserving(FL_STATUS_STOPPED_BLOCKLISTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The detour's words BEFORE the installers: a reader that sees the hook
|
||||
// family appear must already be able to see the wake that caused it.
|
||||
PublishLoaderWords();
|
||||
|
||||
// Lazy feature-hook installation. AFTER the two stops, never before: a
|
||||
// tick that is going to unhook must not install anything first.
|
||||
//
|
||||
// THIS IS THE VEHICLE, AND IT IS WHY NO LoadLibrary HOOK IS NEEDED FOR
|
||||
// P0. 17_HOOK_ENGINE §DLL entry step 5 installs feature hooks "the first
|
||||
// time their module appears", and a game that loads Streamline lazily --
|
||||
// most of them, since sl.interposer is pulled in at device creation --
|
||||
// would be missed by a one-shot check at init. A LoadLibrary hook would
|
||||
// catch it too, but it runs under the loader lock while MinHook suspends
|
||||
// every thread to patch (§H2), so it must defer the work to a thread
|
||||
// anyway. This thread already exists and already wakes once a second, so
|
||||
// §S6 stays genuinely separable rather than becoming a prerequisite.
|
||||
// THIS IS THE VEHICLE. 17_HOOK_ENGINE §DLL entry step 5 installs feature
|
||||
// hooks "the first time their module appears", and a game that loads
|
||||
// Streamline lazily -- most of them, since sl.interposer is pulled in at
|
||||
// device creation -- would be missed by a one-shot check at init. The
|
||||
// LoadLibrary detour (step 3, P1 item 1) does NOT install anything itself:
|
||||
// it runs under the loader lock while MinHook suspends every thread to
|
||||
// patch (§H2), so it only signals g_watchdogWake and the install still
|
||||
// happens HERE, on this thread -- within milliseconds of the module rather
|
||||
// than on the next tick. Through P0 the tick alone was the vehicle, which
|
||||
// is why §S6 stayed separable rather than becoming a prerequisite.
|
||||
//
|
||||
// It RETRIES until it succeeds and latches only on SUCCESS. An
|
||||
// install-attempted flag would give the module exactly one chance, at a
|
||||
@@ -1889,6 +2105,7 @@ DWORD WINAPI WatchdogThread(LPVOID) noexcept {
|
||||
PublishRuntimeCensus();
|
||||
PublishSlTagCensus();
|
||||
PublishDxgiPresentCounters();
|
||||
PublishLoaderWords();
|
||||
|
||||
// Supervision loss. guardTicks counts COMPLETED guard evaluations, not
|
||||
// seconds, so a stalled guard loop stops it advancing even while the
|
||||
@@ -2552,6 +2769,13 @@ DWORD WINAPI InitThread(LPVOID) noexcept {
|
||||
std::atomic_ref<uint32_t> hooks{g_state->hooksInstalledMask};
|
||||
hooks.fetch_or(static_cast<uint32_t>(FL_HOOK_PRESENT), std::memory_order_relaxed);
|
||||
|
||||
// The watchdog's wake, created BEFORE the loader hook that signals it and before
|
||||
// the thread that waits on it. Then the LoadLibrary detour -- non-fatal: without
|
||||
// it the 1 Hz tick and the host's scan are the backstops, and bit 15 says so.
|
||||
g_watchdogWake = CreateEventW(nullptr, FALSE, FALSE, nullptr);
|
||||
InstallLoaderHook();
|
||||
PublishLoaderWords();
|
||||
|
||||
status.store(FL_STATUS_READY, std::memory_order_release);
|
||||
|
||||
// AFTER the hooks, deliberately. The watchdog's only job is to take them out
|
||||
|
||||
@@ -89,6 +89,12 @@ enum FlStatus : uint32_t {
|
||||
FL_STATUS_READY = 1,
|
||||
FL_STATUS_SELF_DISABLED = 2, // 3 hook faults; see 17_HOOK_ENGINE §Fault policy
|
||||
FL_STATUS_UNHOOKED = 3,
|
||||
// A module whose base name matches the anti-cheat floor compiled into the
|
||||
// Overlay was loaded mid-session, and the Overlay stopped ITSELF -- the
|
||||
// in-process half of 19_SAFETY §During a session (§S6, built 2026-09-06 as
|
||||
// P1 item 1). FlWriterState::earlyStopFamily says which family. The host's
|
||||
// 30 s scan remains the backstop and the only half that runs the signer tier.
|
||||
FL_STATUS_STOPPED_BLOCKLISTED = 4,
|
||||
};
|
||||
|
||||
// bits in FlWriterState::apiMask and FlFrameRecord::api
|
||||
@@ -708,7 +714,24 @@ struct alignas(64) FlWriterState {
|
||||
uint32_t dxgiPresentsUnseen; // @48 presents DXGI counted between two hooked presents, beyond the one seen
|
||||
uint32_t dxgiPresentSamples; // @52 hooked presents on which the counter was read
|
||||
|
||||
uint32_t reserved[2]; // @56..63 must be zero; room for additive fields
|
||||
// THE LoadLibrary DETOUR'S TWO WORDS (2026-09-06, P1 item 1; 17_HOOK_ENGINE §DLL
|
||||
// entry step 3). The Overlay detours kernelbase!LoadLibraryExW -- the funnel every
|
||||
// LoadLibrary* variant reaches -- and, never inline (§H2: MinHook suspends threads
|
||||
// to patch, and the caller may hold the loader lock), only records what loaded and
|
||||
// wakes the watchdog. Took reserved[0]; additive, no layout bump.
|
||||
//
|
||||
// loaderSignals: bit 15 = the detour is installed; bits 0..14 = how many times a
|
||||
// module the hook inventory or the runtime census names was loaded and the
|
||||
// watchdog was woken for it (saturating). A count of 0 with bit 15 set is a title
|
||||
// that loaded every vendor module before we attached, which is the common case.
|
||||
uint16_t loaderSignals; // @56
|
||||
// earlyStopFamily: 0 = none; else the 1-based index, among the compiled floor's
|
||||
// MODULE families in rules order, of the family whose value matched a module
|
||||
// loaded mid-session. Set once (the first match wins) and status goes to
|
||||
// FL_STATUS_STOPPED_BLOCKLISTED on the next present or watchdog wake.
|
||||
uint16_t earlyStopFamily; // @58
|
||||
|
||||
uint32_t reserved[1]; // @60..63 must be zero; room for additive fields
|
||||
|
||||
// NOTE: there is deliberately no droppedRecords here. The writer has no
|
||||
// reader index and cannot know whether the slot it overwrites was ever
|
||||
@@ -916,7 +939,9 @@ static_assert(offsetof(FlWriterState, runtimeCensus) == 40);
|
||||
static_assert(offsetof(FlWriterState, slTagCensus) == 44);
|
||||
static_assert(offsetof(FlWriterState, dxgiPresentsUnseen) == 48);
|
||||
static_assert(offsetof(FlWriterState, dxgiPresentSamples) == 52);
|
||||
static_assert(offsetof(FlWriterState, reserved) == 56);
|
||||
static_assert(offsetof(FlWriterState, loaderSignals) == 56);
|
||||
static_assert(offsetof(FlWriterState, earlyStopFamily) == 58);
|
||||
static_assert(offsetof(FlWriterState, reserved) == 60);
|
||||
|
||||
static_assert(offsetof(FlControlBlock, pauseRequested) == 0);
|
||||
static_assert(offsetof(FlControlBlock, unhookRequested) == 4);
|
||||
|
||||
@@ -26,6 +26,7 @@ target_include_directories(fl_guard_test PRIVATE "${CMAKE_SOURCE_DIR}/FrameLedge
|
||||
target_link_libraries(fl_guard_test PRIVATE FrameLedger.Shm fl_native_flags fl_jsmn Catch2::Catch2WithMain
|
||||
Shell32 Ole32 fl_ac_floor)
|
||||
add_dependencies(fl_guard_test fl_ac_floor_gen)
|
||||
add_dependencies(fl_guard_test fl_stub_sl_common fl_stub_sl_interposer)
|
||||
|
||||
# /EHsc on the TEST BINARY only. Catch2 reports failures by throwing, and the
|
||||
# top-level CMakeLists strips the compiler's default /EHsc so every target has
|
||||
@@ -94,6 +95,12 @@ target_compile_definitions(fl_guard_test PRIVATE
|
||||
FL_DXR_DISPATCH_W=${FL_DXR_DISPATCH_W}
|
||||
FL_DXR_DISPATCH_H=${FL_DXR_DISPATCH_H}
|
||||
FL_DXR_DISPATCH_D=${FL_DXR_DISPATCH_D}
|
||||
# The Streamline stubs, for the LoadLibrary detour's late-load fixture (P1 item
|
||||
# 1): sl.common is an inert decoy exporting nothing (also copied under an
|
||||
# anti-cheat name for the early-stop case), sl.interposer is the module whose
|
||||
# late arrival must be hooked within milliseconds rather than on the next tick.
|
||||
FL_STUB_SL_COMMON=L"$<TARGET_FILE:fl_stub_sl_common>"
|
||||
FL_STUB_SL_INTERPOSER=L"$<TARGET_FILE:fl_stub_sl_interposer>"
|
||||
FL_OVERLAY_DLL=L"${FL_STAGED_OVERLAY}"
|
||||
# The un-staged original, so a test can prove the check discriminates on
|
||||
# DIRECTORY rather than on filename: same bytes, same name, wrong place.
|
||||
|
||||
@@ -1289,6 +1289,9 @@ TEST_CASE(
|
||||
// to, which is the only part of this suite that has a live Overlay to inspect.
|
||||
#include <fl_ring.h>
|
||||
#include <fl_shm.h>
|
||||
// The compiled floor, so the early-stop case computes the family index the Overlay
|
||||
// publishes from the same table rather than asserting a literal.
|
||||
#include <fl_ac_floor.generated.h>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
@@ -1831,6 +1834,204 @@ TEST_CASE("the Agent's safety stop halts recording within a frame", "[guard][inj
|
||||
CloseHandle(mapping);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// P1 item 1 -- the LoadLibrary detour (17_HOOK_ENGINE §DLL entry step 3, §H2, §S6).
|
||||
// Both jobs, against the real Overlay in a real target: a vendor module that
|
||||
// arrives LATE is hooked within milliseconds of its arrival, and an anti-cheat-
|
||||
// named module that arrives late stops the Overlay by itself.
|
||||
// ===========================================================================
|
||||
namespace {
|
||||
|
||||
struct MappedRing {
|
||||
HANDLE mapping = nullptr;
|
||||
void* base = nullptr;
|
||||
fl::FlWriterState* st = nullptr;
|
||||
fl::FlControlBlock* ctl = nullptr;
|
||||
~MappedRing() {
|
||||
if (base != nullptr) {
|
||||
UnmapViewOfFile(base);
|
||||
}
|
||||
if (mapping != nullptr) {
|
||||
CloseHandle(mapping);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool OpenRingFor(DWORD pid, MappedRing& r) {
|
||||
wchar_t name[128]{};
|
||||
if (_snwprintf_s(name, _TRUNCATE, L"Local\\FrameLedger.Ring.%lu", pid) <= 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < 100 && r.mapping == nullptr; ++i) {
|
||||
r.mapping = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, name);
|
||||
if (r.mapping == nullptr) {
|
||||
Sleep(50);
|
||||
}
|
||||
}
|
||||
if (r.mapping == nullptr) {
|
||||
return false;
|
||||
}
|
||||
r.base = MapViewOfFile(r.mapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
|
||||
if (r.base == nullptr) {
|
||||
return false;
|
||||
}
|
||||
r.st = reinterpret_cast<fl::FlWriterState*>(static_cast<unsigned char*>(r.base) + FL_SHM_WRITER_OFFSET);
|
||||
r.ctl = reinterpret_cast<fl::FlControlBlock*>(static_cast<unsigned char*>(r.base) + FL_SHM_CONTROL_OFFSET);
|
||||
for (int i = 0; i < 100 && r.st->status != fl::FL_STATUS_READY; ++i) {
|
||||
Sleep(50);
|
||||
}
|
||||
return r.st->status == fl::FL_STATUS_READY;
|
||||
}
|
||||
|
||||
bool StartHarness(Child& child, const std::wstring& args) {
|
||||
std::wstring cmd = std::wstring(L"\"") + FL_HARNESS_EXE + L"\" " + args;
|
||||
STARTUPINFOW si{};
|
||||
si.cb = sizeof(si);
|
||||
if (!CreateProcessW(FL_HARNESS_EXE, cmd.data(), nullptr, nullptr, FALSE, CREATE_NO_WINDOW, nullptr, nullptr, &si,
|
||||
&child.pi)) {
|
||||
return false;
|
||||
}
|
||||
Sleep(800);
|
||||
return WaitForSingleObject(child.pi.hProcess, 0) == WAIT_TIMEOUT;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("the LoadLibrary detour hooks a vendor module that arrives LATE within milliseconds, not on the next tick",
|
||||
"[guard][inject][shm][loader]") {
|
||||
// The harness presents with no vendor module, then loads sl.common (an inert
|
||||
// decoy) and sl.interposer 2.0 / 2.3 s in. Before: no upscaler hook. After: the
|
||||
// hook family appears within 500 ms of the module -- the detour woke the
|
||||
// watchdog. The 1 Hz tick alone would land anywhere in the next second, so a
|
||||
// latency bound under half of that is what discriminates the wake from the tick.
|
||||
Child child;
|
||||
std::wstring args = L"--real --hold-presenting 14 --load-after-ms 2000 \"" + std::wstring(FL_STUB_SL_COMMON) +
|
||||
L"\" --load-after-ms 2300 \"" + std::wstring(FL_STUB_SL_INTERPOSER) + L"\"";
|
||||
REQUIRE(StartHarness(child, args));
|
||||
|
||||
ResetFake();
|
||||
g.modules = {"kernel32.dll"};
|
||||
g.scanSet = {child.pi.dwProcessId};
|
||||
REQUIRE(GuardedInjectWithSources(child.pi.dwProcessId, FL_OVERLAY_DLL, FakeSources()).Allowed());
|
||||
|
||||
MappedRing r;
|
||||
REQUIRE(OpenRingFor(child.pi.dwProcessId, r));
|
||||
CHECK((r.st->loaderSignals & 0x8000u) != 0u); // the detour installed
|
||||
|
||||
// Nothing vendor-shaped yet: the identity family is absent and stays absent.
|
||||
Sleep(300);
|
||||
++r.ctl->guardTicks;
|
||||
REQUIRE((r.st->hooksInstalledMask & fl::FL_HOOK_UPSCALER_IDENTITY) == 0u);
|
||||
|
||||
// Wait for the interposer to appear in the target, then time the family.
|
||||
ULONGLONG appeared = 0;
|
||||
for (int i = 0; i < 400 && appeared == 0; ++i) {
|
||||
if (TargetHasModule(child.pi.dwProcessId, L"sl.interposer.dll")) {
|
||||
appeared = GetTickCount64();
|
||||
break;
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
REQUIRE(appeared != 0);
|
||||
ULONGLONG hooked = 0;
|
||||
for (int i = 0; i < 300 && hooked == 0; ++i) {
|
||||
if ((r.st->hooksInstalledMask & fl::FL_HOOK_UPSCALER_IDENTITY) != 0u) {
|
||||
hooked = GetTickCount64();
|
||||
break;
|
||||
}
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(10);
|
||||
}
|
||||
REQUIRE(hooked != 0);
|
||||
const ULONGLONG latencyMs = hooked - appeared;
|
||||
INFO("late-load hook latency " << latencyMs << " ms, loaderSignals=0x" << std::hex << r.st->loaderSignals);
|
||||
CHECK(latencyMs < 500);
|
||||
// The wake count is published by the watchdog, on its own iteration; give it
|
||||
// the iteration rather than racing the install that the wake caused.
|
||||
for (int i = 0; i < 200 && (r.st->loaderSignals & 0x7FFFu) == 0u; ++i) {
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(10);
|
||||
}
|
||||
CHECK((r.st->loaderSignals & 0x7FFFu) >= 1u); // the detour saw an inventoried module and woke the watchdog
|
||||
CHECK(r.st->earlyStopFamily == 0u);
|
||||
CHECK(r.st->status == fl::FL_STATUS_READY);
|
||||
}
|
||||
|
||||
TEST_CASE("the LoadLibrary detour stops the Overlay by itself when an anti-cheat-named module arrives",
|
||||
"[guard][inject][shm][loader][S6]") {
|
||||
// The in-process half of 19_SAFETY §During a session. A decoy DLL copied under a
|
||||
// name the compiled floor's first module family matches by prefix is loaded 2.5 s
|
||||
// in; the Overlay must stop within a frame, name the family, and stay stopped.
|
||||
wchar_t temp[MAX_PATH]{};
|
||||
REQUIRE(GetTempPathW(MAX_PATH, temp) != 0);
|
||||
const std::wstring copy = std::wstring(temp) + L"EasyAntiCheat_fl_fixture.dll";
|
||||
REQUIRE(CopyFileW(FL_STUB_SL_COMMON, copy.c_str(), FALSE));
|
||||
|
||||
// The expected index, computed from the same generated table the Overlay
|
||||
// compiled in -- never a literal 1, so a reordered rules file moves both sides.
|
||||
uint32_t expected = 0;
|
||||
{
|
||||
uint32_t index = 0;
|
||||
for (const fl::guard::Family& f : fl::guard::generated::kFloorFamilies) {
|
||||
if (f.group != fl::guard::Group::kModules) {
|
||||
continue;
|
||||
}
|
||||
++index;
|
||||
for (std::size_t v = 0; v < f.valueCount && expected == 0; ++v) {
|
||||
if (f.match == fl::guard::MatchKind::kPrefix &&
|
||||
_strnicmp("EasyAntiCheat_fl_fixture.dll", f.values[v], std::strlen(f.values[v])) == 0) {
|
||||
expected = index;
|
||||
}
|
||||
}
|
||||
if (expected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUIRE(expected != 0);
|
||||
|
||||
{
|
||||
Child child;
|
||||
std::wstring args = L"--real --hold-presenting 14 --load-after-ms 2500 \"" + copy + L"\"";
|
||||
REQUIRE(StartHarness(child, args));
|
||||
|
||||
ResetFake();
|
||||
g.modules = {"kernel32.dll"};
|
||||
g.scanSet = {child.pi.dwProcessId};
|
||||
REQUIRE(GuardedInjectWithSources(child.pi.dwProcessId, FL_OVERLAY_DLL, FakeSources()).Allowed());
|
||||
|
||||
MappedRing r;
|
||||
REQUIRE(OpenRingFor(child.pi.dwProcessId, r));
|
||||
|
||||
// It really was recording, with the supervision clock kept alive.
|
||||
std::uint64_t before = 0;
|
||||
for (int i = 0; i < 40 && before < 5; ++i) {
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(100);
|
||||
before = r.st->writeIndex;
|
||||
}
|
||||
REQUIRE(before > 5);
|
||||
|
||||
// THE STOP, from inside: no unhookRequested from this side, ever.
|
||||
for (int i = 0; i < 100 && r.st->status != fl::FL_STATUS_STOPPED_BLOCKLISTED; ++i) {
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(50);
|
||||
}
|
||||
CHECK(r.st->status == fl::FL_STATUS_STOPPED_BLOCKLISTED);
|
||||
CHECK(r.st->earlyStopFamily == expected);
|
||||
CHECK(r.ctl->unhookRequested == 0u);
|
||||
|
||||
// And it stays stopped while the harness keeps presenting and the ticks keep coming.
|
||||
const std::uint64_t atStop = r.st->writeIndex;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
++r.ctl->guardTicks;
|
||||
Sleep(100);
|
||||
}
|
||||
CHECK(r.st->writeIndex == atStop);
|
||||
} // the child is gone before its module file is deleted
|
||||
DeleteFileW(copy.c_str());
|
||||
}
|
||||
|
||||
TEST_CASE("the injected Overlay records real presents into the ring", "[guard][inject][shm]") {
|
||||
// The end-to-end claim the whole hook layer exists for, against a target that
|
||||
// is PRESENTING WHILE WE INJECT. --hold cannot be used here: it presents 240
|
||||
|
||||
@@ -66,7 +66,9 @@ int main() {
|
||||
Field("slTagCensus", offsetof(FlWriterState, slTagCensus), sizeof(uint32_t));
|
||||
Field("dxgiPresentsUnseen", offsetof(FlWriterState, dxgiPresentsUnseen), sizeof(uint32_t));
|
||||
Field("dxgiPresentSamples", offsetof(FlWriterState, dxgiPresentSamples), sizeof(uint32_t));
|
||||
Field("reserved", offsetof(FlWriterState, reserved), sizeof(uint32_t) * 2, true);
|
||||
Field("loaderSignals", offsetof(FlWriterState, loaderSignals), sizeof(uint16_t));
|
||||
Field("earlyStopFamily", offsetof(FlWriterState, earlyStopFamily), sizeof(uint16_t));
|
||||
Field("reserved", offsetof(FlWriterState, reserved), sizeof(uint32_t) * 1, true);
|
||||
std::printf(" ] },\n");
|
||||
|
||||
std::printf(" \"FlControlBlock\": { \"size\": %zu, \"fields\": [\n", sizeof(FlControlBlock));
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
// guard's signer half (§S19(b)): a fragment-matching
|
||||
// module in the TARGET, signed or not, is what the guard
|
||||
// must judge
|
||||
// --load-after-ms N PATH
|
||||
// LoadLibrary PATH from a worker thread N ms after startup,
|
||||
// while the hold mode presents. Fixture for the Overlay's
|
||||
// LoadLibrary detour (17_HOOK_ENGINE §DLL entry, §S6): a
|
||||
// vendor module that appears LATE, or an anti-cheat-named
|
||||
// one, is what the detour must react to. Up to 4
|
||||
// --hold-presenting-overflow N
|
||||
// fill the Overlay's fixed 16-slot swapchain table, then
|
||||
// present for N seconds on one that cannot get a slot. The
|
||||
@@ -590,6 +596,27 @@ bool ProbeCost_PerPresent(Gfx& g) {
|
||||
// a tight Present(0, DXGI_PRESENT_TEST) loop, which is what an alt-tabbed game
|
||||
// runs, and the Overlay has to be measured against it deliberately rather than
|
||||
// by accident.
|
||||
// --load-after-ms: a module that appears while the harness presents. The worker
|
||||
// sleeps, loads by absolute path, and prints; the process keeps the module for
|
||||
// its life so the Overlay's scan and the guard's both see it.
|
||||
struct LateLoad {
|
||||
DWORD delayMs = 0;
|
||||
wchar_t path[MAX_PATH * 2]{};
|
||||
};
|
||||
constexpr int kMaxLateLoads = 4;
|
||||
LateLoad g_lateLoads[kMaxLateLoads];
|
||||
int g_lateLoadCount = 0;
|
||||
|
||||
DWORD WINAPI LateLoadThread(LPVOID arg) {
|
||||
auto* l = static_cast<LateLoad*>(arg);
|
||||
Sleep(l->delayMs);
|
||||
const HMODULE h = LoadLibraryW(l->path);
|
||||
std::printf(" --load-after-ms %lu %ls -> %s\n", static_cast<unsigned long>(l->delayMs), l->path,
|
||||
h != nullptr ? "loaded" : "FAILED");
|
||||
std::fflush(stdout);
|
||||
return h != nullptr ? 0u : 1u;
|
||||
}
|
||||
|
||||
int PresentLoop(Gfx& g, int frames, bool real) {
|
||||
const UINT flags = real ? 0u : DXGI_PRESENT_TEST;
|
||||
for (int i = 0; i < frames; ++i) {
|
||||
@@ -2834,6 +2861,20 @@ int main(int argc, char** argv) {
|
||||
slTagWholeResource = true;
|
||||
} else if (std::strcmp(argv[i], "--sl-tag-dlssg-inputs") == 0) {
|
||||
slTagDlssgInputs = true;
|
||||
} else if (std::strcmp(argv[i], "--load-after-ms") == 0 && i + 2 < argc) {
|
||||
if (g_lateLoadCount < kMaxLateLoads) {
|
||||
LateLoad& l = g_lateLoads[g_lateLoadCount];
|
||||
l.delayMs = static_cast<DWORD>(std::atoi(argv[++i]));
|
||||
const char* path = argv[++i];
|
||||
MultiByteToWideChar(CP_ACP, 0, path, -1, l.path, static_cast<int>(sizeof(l.path) / sizeof(l.path[0])));
|
||||
HANDLE t = CreateThread(nullptr, 0, &LateLoadThread, &l, 0, nullptr);
|
||||
if (t != nullptr) {
|
||||
CloseHandle(t);
|
||||
}
|
||||
++g_lateLoadCount;
|
||||
} else {
|
||||
i += 2;
|
||||
}
|
||||
} else if (std::strcmp(argv[i], "--load") == 0 && i + 1 < argc) {
|
||||
// The fixture for the guard's signer half: put a named module into
|
||||
// THIS process before the guard looks. Loaded, not injected, and it
|
||||
@@ -2855,12 +2896,16 @@ int main(int argc, char** argv) {
|
||||
std::strcmp(argv[i], "--present-interval-ms") == 0 || std::strcmp(argv[i], "--presents-per-eval") == 0 ||
|
||||
std::strcmp(argv[i], "--ffx-topology") == 0 || std::strcmp(argv[i], "--ffx-no-prepare") == 0 ||
|
||||
std::strcmp(argv[i], "--sl-tag-for-frame") == 0 || std::strcmp(argv[i], "--sl-tag-whole-resource") == 0 ||
|
||||
std::strcmp(argv[i], "--sl-tag-dlssg-inputs") == 0 || std::strcmp(argv[i], "--load") == 0) {
|
||||
std::strcmp(argv[i], "--sl-tag-dlssg-inputs") == 0 || std::strcmp(argv[i], "--load") == 0 ||
|
||||
std::strcmp(argv[i], "--load-after-ms") == 0) {
|
||||
if (std::strcmp(argv[i], "--plus-ui") == 0 || std::strcmp(argv[i], "--present-interval-ms") == 0 ||
|
||||
std::strcmp(argv[i], "--presents-per-eval") == 0 || std::strcmp(argv[i], "--ffx-topology") == 0 ||
|
||||
std::strcmp(argv[i], "--load") == 0) {
|
||||
++i;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--load-after-ms") == 0) {
|
||||
i += 2;
|
||||
}
|
||||
continue; // consumed above
|
||||
} else if (std::strcmp(argv[i], "--probe-frames") == 0) {
|
||||
ok = ProbeFrameIdentity(g) && ok;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.CaptureHost.Capture;
|
||||
using FrameLedger.CaptureHost.Consume;
|
||||
using FrameLedger.Shared;
|
||||
|
||||
namespace FrameLedger.CaptureHost.Tests.Consume;
|
||||
|
||||
/// <summary>The loader detour's two words as the report reads them, and the family index against a rules file.</summary>
|
||||
public sealed class EarlyStopTests : IDisposable
|
||||
{
|
||||
private readonly string _rules = Path.Combine(Path.GetTempPath(), "fl-rules-" + Guid.NewGuid().ToString("N") + ".json");
|
||||
|
||||
public EarlyStopTests() => File.WriteAllText(_rules,
|
||||
"""{"anticheat":{"modules":[{"family":"Easy Anti-Cheat","match":"prefix","values":["EasyAntiCheat"]},{"family":"BattlEye","match":"prefix","values":["BEClient"]}]}}""");
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(_rules);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheFamilyIndexIsOneBasedInRulesOrderAndNeverAGuess()
|
||||
{
|
||||
EarlyStop.FamilyName(1, _rules).Should().Be("Easy Anti-Cheat");
|
||||
EarlyStop.FamilyName(2, _rules).Should().Be("BattlEye");
|
||||
EarlyStop.FamilyName(3, _rules).Should().BeNull("outside the file");
|
||||
EarlyStop.FamilyName(0, _rules).Should().BeNull();
|
||||
EarlyStop.FamilyName(1, Path.Combine(Path.GetTempPath(), "nope.json")).Should().BeNull("unreadable is null, not a throw");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnInstalledDetourWithNoStopIsOneLine()
|
||||
{
|
||||
var writer = new FlWriterState { LoaderSignals = 0x8003, Status = (uint)FlStatus.Ready };
|
||||
|
||||
List<string> lines = [.. EarlyStop.Describe(writer, _rules)];
|
||||
|
||||
lines.Should().ContainSingle().Which.Should().Contain("installed").And.Contain("woke the watchdog 3 time(s)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AMissingDetourSaysWhatIsLost()
|
||||
{
|
||||
List<string> lines = [.. EarlyStop.Describe(new FlWriterState { LoaderSignals = 0 }, _rules)];
|
||||
|
||||
lines.Should().ContainSingle().Which.Should().Contain("NOT installed").And.Contain("host's 30 s scan is the only stop");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AStopNamesTheFamilyAndTheStatus()
|
||||
{
|
||||
var writer = new FlWriterState { LoaderSignals = 0x8000, EarlyStopFamily = 2, Status = (uint)FlStatus.StoppedBlocklisted };
|
||||
|
||||
List<string> lines = [.. EarlyStop.Describe(writer, _rules)];
|
||||
|
||||
lines.Should().HaveCount(2);
|
||||
lines[1].Should().Contain("EARLY STOP").And.Contain("family #2 (BattlEye)").And.Contain("status=StoppedBlocklisted")
|
||||
.And.Contain("fragment-and-signer tier is the host's scan");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheClassifierMapsTheNewStatusToItsOwnReasonAndAnExitedTargetStillWins()
|
||||
{
|
||||
SessionEndClassifier.Classify(targetExited: false, (uint)FlStatus.StoppedBlocklisted, weLatchedTheUnhook: false, attachSettled: true)
|
||||
.Should().Be(SessionEndReason.WriterStoppedBlocklisted);
|
||||
SessionEndClassifier.Classify(targetExited: true, (uint)FlStatus.StoppedBlocklisted, weLatchedTheUnhook: false, attachSettled: true)
|
||||
.Should().Be(SessionEndReason.TargetExited);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user