* docs(spike-notes): §25 - the Xbox/GDK titles' layout, read-only, and the launch probe's decision table, written before the run (D77) (beta.33 PR-1) The owner's 11 GDK packages under C:\XboxGames and D:\xbox, read without launching anything: the .GamingRoot files, MicrosoftGame.config / appxmanifest.xml, the WindowsApps junction chain, and the executables refusing FILE_READ_DATA and FILE_EXECUTE to every process outside their package. Then the probe's method and the table that decides what each outcome changes - committed before the probe runs, as the house rule asks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(spike-notes): §25's run - six GDK titles activated through their packages; the image paths, the chains, the tokens, the mitigations, and what a start by path really does (D77, D80) (beta.33 PR-1) The image path and the loader's main-module path are both the Content spelling on every process of every chain; no chain member the guard's rights cannot open; no fuzzy-fragment module; full trust, not an AppContainer, medium integrity; none of the four mitigations. And CreateProcess by path is not error 5, as assumed: the package's launch executable is replaced by an unpackaged gamelaunchhelper.exe that activates the package (the game is never the caller's process nor its descendant), and an Unreal shipping executable runs outside its package. D80 stands on those two measured grounds; the read-only claim is struck and dated in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: games from the Xbox app and the Microsoft Store - the GDK library, a package root as an install-root boundary for the guard and detection, the xbox platform rule (root_file, rules 2026.11.1), the game's own art; Privacy 2.13 (D77-D81) (beta.33 PR-1) The import gains a fifth store, `xbox`: each ready drive's .GamingRoot names the games folders, each <Game>\Content\ holding MicrosoftGame.config beside appxmanifest.xml is a GDK package (read with DTDs prohibited), and Windows' appmodel calls (PackageFamilyNameFromId, GetPackagesByPackageFamily) say whether it is installed for this user. The record: the family name as the store id, Content as the install folder (the spelling the game's own process reports, spike-notes section 25), the AUMID as the launch key; ExecutableLocator picks the process that draws, never gamelaunchhelper.exe. Safety: no install-root boundary matched the Xbox layout, so check 4 walked only an Unreal title's Binaries\WinGDK. A GDK package root is now a boundary for InstallRoot and the native ResolveInstallRoot alike, asked only where no store boundary matched (it can only widen the walk); GamesInstalled joins the native list; one case list, tests/fixtures/install-roots/cases.txt, is read by Catch2 and xUnit both. Detection: an `xbox` platform first in the array (a GDK FINAL FANTASY ships steam_api64.dll), decided by a new root_file signal from the install root's own listing, so a deep walk that ran short cannot make it Unknown. Art: the square logo and the splash image the package names, from inside the package root only. games.platform's vocabulary gains xbox; the importer's fake repository now validates as the real one does. Privacy Policy 2.13 with the wording approved with the plan; TRADEMARKS, 02_SPEC, 15_ROADMAP, 05/06/08/19/20, README, LIMITATIONS and the guide follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
205 lines
8.5 KiB
C#
205 lines
8.5 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FrameLedger.Application.Persistence;
|
|
using FrameLedger.Application.TriState;
|
|
using FrameLedger.Domain.Consent;
|
|
using FrameLedger.Domain.Metrics;
|
|
|
|
namespace FrameLedger.Application.Tests.Recording;
|
|
|
|
internal sealed class FakeGameRepository : IGameRepository
|
|
{
|
|
private long _nextId = 1;
|
|
|
|
public Dictionary<string, GameRow> Rows { get; } = new(StringComparer.OrdinalIgnoreCase);
|
|
|
|
public List<(long GameId, string Reason, DateTimeOffset At)> Disabled { get; } = [];
|
|
|
|
public List<(long GameId, DateTimeOffset At)> Injections { get; } = [];
|
|
|
|
public int CrashCount { get; set; }
|
|
|
|
public ValueTask<GameRow> EnsureAsync(ExecutableFingerprint fingerprint, string name, CancellationToken ct = default)
|
|
{
|
|
if (!Rows.TryGetValue(fingerprint.ExePath, out GameRow? row))
|
|
{
|
|
row = new GameRow
|
|
{
|
|
Id = _nextId++,
|
|
Name = name,
|
|
Fingerprint = fingerprint,
|
|
HookEnabled = false,
|
|
HookCrashCount = 0,
|
|
AddedAt = DateTimeOffset.UnixEpoch,
|
|
UpdatedAt = DateTimeOffset.UnixEpoch,
|
|
};
|
|
Rows[fingerprint.ExePath] = row;
|
|
}
|
|
|
|
return ValueTask.FromResult(row);
|
|
}
|
|
|
|
public ValueTask<GameRow?> FindAsync(string normalisedExePath, CancellationToken ct = default) =>
|
|
ValueTask.FromResult(Rows.GetValueOrDefault(normalisedExePath));
|
|
|
|
public ValueTask<IReadOnlyList<GameRow>> ListAsync(CancellationToken ct = default) =>
|
|
ValueTask.FromResult<IReadOnlyList<GameRow>>([.. Rows.Values]);
|
|
|
|
public ValueTask<bool> AutoDisableHookAsync(long gameId, string reason, DateTimeOffset at, CancellationToken ct = default)
|
|
{
|
|
Disabled.Add((gameId, reason, at));
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
public List<(long GameId, ExecutableFingerprint Changed)> Changes { get; } = [];
|
|
|
|
/// <summary>
|
|
/// The adapter's rule (2026-09-23, kept here so the relocator's D27 tests see it): a downgrade by construction — the new
|
|
/// bytes, hooking off, consent cleared, the pre-scan not run, the block kept — refused for a removed row and for a
|
|
/// path another row holds.
|
|
/// </summary>
|
|
public ValueTask<bool> ChangeExecutableAsync(long gameId, ExecutableFingerprint fingerprint, DateTimeOffset at, CancellationToken ct = default)
|
|
{
|
|
foreach ((string key, GameRow row) in Rows)
|
|
{
|
|
if (row.Id != gameId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!row.InLibrary || (Rows.TryGetValue(fingerprint.ExePath, out GameRow? holder) && holder.Id != gameId))
|
|
{
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
Rows.Remove(key);
|
|
Rows[fingerprint.ExePath] = row with { Fingerprint = fingerprint, HookEnabled = false, HookConsentAt = null, HookPrescanState = "not_run", UpdatedAt = at };
|
|
Changes.Add((gameId, fingerprint));
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
public List<(long GameId, ExecutableFingerprint Moved)> Relocations { get; } = [];
|
|
|
|
/// <summary>The adapter's rule, kept here so the sweep and the watcher tests see it: same size and mtime, or nothing moves.</summary>
|
|
public ValueTask<bool> RelocateExecutableAsync(long gameId, ExecutableFingerprint moved, DateTimeOffset at, CancellationToken ct = default)
|
|
{
|
|
foreach ((string key, GameRow row) in Rows)
|
|
{
|
|
if (row.Id != gameId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (row.Fingerprint.SizeBytes != moved.SizeBytes || row.Fingerprint.MtimeUnixMs != moved.MtimeUnixMs || Rows.ContainsKey(moved.ExePath))
|
|
{
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
Rows.Remove(key);
|
|
Rows[moved.ExePath] = row with { Fingerprint = moved, UpdatedAt = at };
|
|
Relocations.Add((gameId, moved));
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
public ValueTask<int> RecordCrashAsync(long gameId, CancellationToken ct = default) => ValueTask.FromResult(++CrashCount);
|
|
|
|
public ValueTask<bool> RecordInjectionAsync(long gameId, DateTimeOffset at, CancellationToken ct = default)
|
|
{
|
|
Injections.Add((gameId, at));
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
public ValueTask<GameRow?> FindByIdAsync(long gameId, CancellationToken ct = default) =>
|
|
ValueTask.FromResult(Rows.Values.FirstOrDefault(r => r.Id == gameId));
|
|
|
|
// The UI's half (P3 PR-3) — no recorder test reaches these; the SQLite adapter has its own tests.
|
|
public ValueTask<bool> UpdateMetadataAsync(long gameId, GameMetadata metadata, CancellationToken ct = default) => throw new NotSupportedException();
|
|
|
|
public ValueTask<bool> SetTriStateDefaultAsync(long gameId, TriStateKind kind, Tri value, CancellationToken ct = default) => throw new NotSupportedException();
|
|
|
|
public ValueTask<bool> RemoveAsync(long gameId, bool keepSessions, CancellationToken ct = default) => throw new NotSupportedException();
|
|
|
|
/// <summary>The UI's recording switch (2026-09-23), applied to the row so the watcher tests see it.</summary>
|
|
public ValueTask<bool> SetRecordingAsync(long gameId, bool record, CancellationToken ct = default)
|
|
{
|
|
foreach ((string key, GameRow row) in Rows)
|
|
{
|
|
if (row.Id == gameId)
|
|
{
|
|
Rows[key] = row with { RecordSessions = record };
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
}
|
|
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
/// <summary>Every store write, in order (P4 PR-4); the row takes the store's platform, id and version whole (the SQLite adapter's provenance rule has its own tests).</summary>
|
|
public List<(long GameId, StoreMetadata Store)> Stores { get; } = [];
|
|
|
|
public ValueTask<bool> ApplyStoreMetadataAsync(long gameId, StoreMetadata store, CancellationToken ct = default)
|
|
{
|
|
// The real repository's contract (beta.33): a store id that is not in games.platform's vocabulary throws there, so it
|
|
// throws here too — an importer test must not pass with a platform the ledger would refuse.
|
|
ArgumentNullException.ThrowIfNull(store);
|
|
if (!GameMetadata.Platforms.Contains(store.Platform, StringComparer.Ordinal) || string.Equals(store.Platform, "none", StringComparison.Ordinal))
|
|
{
|
|
throw new ArgumentException($"'{store.Platform}' is not a store", nameof(store));
|
|
}
|
|
|
|
Stores.Add((gameId, store));
|
|
foreach ((string key, GameRow row) in Rows)
|
|
{
|
|
if (row.Id != gameId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
Rows[key] = row with { Platform = store.Platform, StoreId = store.StoreId ?? row.StoreId, GameVersion = store.GameVersion ?? row.GameVersion };
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
|
|
/// <summary>Every detection write, in order (P4 PR-1); the row gains the cache key and the flags so a second sweep sees it as current.</summary>
|
|
public List<(long GameId, DetectionWrite Write)> Detections { get; } = [];
|
|
|
|
public ValueTask<bool> ApplyDetectionAsync(long gameId, DetectionWrite detection, CancellationToken ct = default)
|
|
{
|
|
Detections.Add((gameId, detection));
|
|
foreach ((string key, GameRow row) in Rows)
|
|
{
|
|
if (row.Id != gameId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
Rows[key] = row with
|
|
{
|
|
Engine = detection.EngineId ?? row.Engine,
|
|
EngineVersion = detection.EngineVersion ?? row.EngineVersion,
|
|
Platform = detection.PlatformId ?? row.Platform,
|
|
CapabilityFlagsJson = "[" + string.Join(",", detection.CapabilityIds.Select(static c => "\"" + c + "\"")) + "]",
|
|
DetectionRulesVersion = detection.RulesVersion,
|
|
DetectionExeSizeBytes = detection.ExeSizeBytes,
|
|
DetectionExeMtimeMs = detection.ExeMtimeMs,
|
|
ExeMachine = detection.ExeArchitecture,
|
|
ExeFileVersion = detection.ExeFileVersion,
|
|
ExeProductVersion = detection.ExeProductVersion,
|
|
Libraries = detection.Libraries,
|
|
};
|
|
return ValueTask.FromResult(true);
|
|
}
|
|
|
|
return ValueTask.FromResult(false);
|
|
}
|
|
}
|