From 133e634c0d3b2ad9bc01558c5cdb2eeea64a960e Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:15:05 -0500 Subject: [PATCH 1/5] Launcher: the RR plugin's own rr_mode save keeps WrongGPU\wronggpu.ini WrongGPU's The RR plugin saves the mode picked in OptiScaler's menu into WrongGPU\wronggpu.ini (rr_panel.cpp: the [wronggpu] rr_mode line becomes "rr_mode=", CRLF). That changed the file's bytes away from the record's hash, so the next repair took the file for the player's and backed it up, and the uninstall then ended "partly" and kept that generation in WrongGPU-originals. WhatIsThere now treats the file as WrongGPU's when its only change since the launcher last wrote it is that line in the plugin's exact form (rr.h RrSettingsPluginEdit: the recorded bytes with the line set back to one of the three modes). Any other change (another key or line, spaces around "=", other line ends) is still the player's. The "left in place" warning no longer calls that file another setup's OptiScaler (the header WrongGPU writes in it names OptiScaler's menu). Tests: launcher-core checks of both directions (RrSettingsPluginEdit and WhatIsThere); test_rr's in-game switch writes what the plugin writes; launcher_rr_owner_cases.py (called from test_rr) covers plugin save + repair + uninstall (removed, nothing kept) and a hand edit with and without a repair (the player's bytes stay or come back). Refs #219 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/installer/README.md | 13 ++- clean/installer/src/wg_core/record.cpp | 7 +- clean/installer/src/wg_core/record.h | 4 +- clean/installer/src/wg_core/rr.cpp | 33 ++++++ clean/installer/src/wg_core/rr.h | 9 +- clean/installer/tests/launcher_core_tests.cpp | 33 ++++++ .../tests/launcher_rr_owner_cases.py | 110 ++++++++++++++++++ clean/installer/tests/run_launcher_tests.py | 5 +- 8 files changed, 205 insertions(+), 9 deletions(-) create mode 100644 clean/installer/tests/launcher_rr_owner_cases.py diff --git a/clean/installer/README.md b/clean/installer/README.md index e00533cf..91e69fe7 100644 --- a/clean/installer/README.md +++ b/clean/installer/README.md @@ -249,13 +249,18 @@ With the defaults nothing of this section changes the installer. hash). Nothing else proves it: not the file's name, not a file next to it, not an ini key, not "it is a log", not "the install created that path". A file that is not in the record is not touched, whatever its name (`wronggpu-*`, `OptiScaler.log`, `fakenvapi.log`, ...). - - **Two policies, stated here on purpose.** Files in WrongGPU's FSR slot that identify as WrongGPU (the version + - **Three policies, stated here on purpose.** Files in WrongGPU's FSR slot that identify as WrongGPU (the version resource's `ProductName` is WrongGPU: the game may update that DLL, and a newer WrongGPU build placed by hand counts), or that are byte-identical to a WrongGPU release (`known_releases.h`, size and SHA-256) or to the embedded payload, are treated as WrongGPU's. This is a recognition by identity, not proof of ownership: a player's own build or copy with - that product name, or a copy of a release file, is treated the same way. Nothing else is treated as WrongGPU's by - its content. - - Any other file at a recorded path (edited by hand, saved by OptiScaler's menu or by WrongGPU's own plugin, replaced + that product name, or a copy of a release file, is treated the same way. And the RR plugin's settings file + `WrongGPU\wronggpu.ini` whose only change since the launcher last wrote it is the `[wronggpu] rr_mode` line WrongGPU's + RR plugin saves when the player switches the mode in OptiScaler's menu (exactly `rr_mode=exact|accurate|fast`, CRLF + line ends: the recorded bytes with that line set back to one of the three modes) is still WrongGPU's, so an uninstall + removes it and a repair or update replaces it (#219; `rr.h` `RrSettingsPluginEdit`). Any other change to it (another + key or line, spaces around `=`) is the player's. Nothing else is treated as WrongGPU's by its content. + - Any other file at a recorded path (edited by hand, saved by OptiScaler's menu or by WrongGPU's own plugins beyond the + rr_mode save above, replaced by another setup or a game update, a settings file the install created and a program rewrote since) stays where it is, untouched, with a warning. - **Hard links.** A file that has another name (a hard link) is never written through, because the other name would change diff --git a/clean/installer/src/wg_core/record.cpp b/clean/installer/src/wg_core/record.cpp index 2bf865a3..9dd4836b 100644 --- a/clean/installer/src/wg_core/record.cpp +++ b/clean/installer/src/wg_core/record.cpp @@ -556,6 +556,10 @@ Holds WhatIsThere(Context& ctx, const wstring& dir, const Entry& e, const wstrin if (!e.inst.empty() && IEq(h, e.inst)) return Holds::Ours; if (e.existed && !e.orig.empty() && IEq(h, e.orig)) return Holds::Original; const wstring t = Target(dir, e.rel); + if (IEq(e.rel, kRrSettings) && !e.inst.empty()) { // #219: only WrongGPU's RR plugin saved its mode there since (rr.h) + string text; + if (ReadAll(t, text) && IEq(Sha256Bytes(text.data(), text.size()), h) && RrSettingsPluginEdit(text, e.inst)) return Holds::Ours; + } wstring info; if (const FfxSlot* sl = SlotOf(e)) return ClassifySlot(*sl, t, nullptr, info) == FFX_OURS ? Holds::Ours : Holds::Other; // the slot exception if (!EndsWithI(e.rel, L".ini") && KnownReleaseFile(ctx, t)) return Holds::Ours; // a WrongGPU release's file (size and SHA-256) @@ -609,7 +613,8 @@ std::vector DoRestore(Context& ctx, const wstring& dir, Ui& ui, bool fa struct Plan { Do what = Do::Nothing; wstring now, source; bool keep = false; }; // now: the hash the decision was made on std::vector plan(m.e.size()); auto leaveWarning = [&](const Entry& e, const wstring& t, const wstring& keptAt, bool linked = false) { - const Fingerprint fp = e.action == L"copy" && !IsSlotName(e.rel) ? IdentifyFile(t) : Fingerprint(); + // (not the RR settings files: the header WrongGPU writes in WrongGPU\wronggpu.ini names OptiScaler's menu) + const Fingerprint fp = e.action == L"copy" && !IsSlotName(e.rel) && !IsRrSettingsFile(e.rel) ? IdentifyFile(t) : Fingerprint(); wstring w; if (linked) w = L"Left in place (the file has another name, a hard link; writing through it would change that name too): " + e.rel; else if (e.action == L"copy" && IsSlotName(e.rel)) w = L"The game replaced " + e.rel + L" (probably an update); its new file was kept."; diff --git a/clean/installer/src/wg_core/record.h b/clean/installer/src/wg_core/record.h index b8bff4da..c871f958 100644 --- a/clean/installer/src/wg_core/record.h +++ b/clean/installer/src/wg_core/record.h @@ -127,7 +127,9 @@ bool HostedRecord(const Record& m); // install created whose bytes changed since is preserved too). EXPLICIT POLICY (README "file-ownership rule"): files in the // game's FSR slots that identify as WrongGPU (ClassifySlot: the version resource's ProductName, because the game may update // that DLL), and files byte-identical to a WrongGPU release or to the embedded payload (KnownReleaseFile), are treated as -// WrongGPU's; that is recognition by identity, not proof of ownership, and nothing else is treated as WrongGPU's by content. +// WrongGPU's; that is recognition by identity, not proof of ownership. The RR plugin's settings file whose only change is the +// rr_mode line WrongGPU's RR plugin saves (rr.h RrSettingsPluginEdit, #219) is WrongGPU's too. Nothing else is treated as +// WrongGPU's by content. // Anything else at a recorded path stays as it is; a player's original that cannot be put back because of it is kept in // \WrongGPU-originals\