From e6eb5d8fedb654cff79f47d50b5a967fe89e4e0b Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:06:09 -0500 Subject: [PATCH 1/4] Launcher: roll back and the Engine.ini revert change only WrongGPU's bytes, through one handle Roll back (#184): every payload file is held (PinnedFile: one handle, no write, rename or delete sharing), hashed through that handle and compared with the hash the record says WrongGPU installed. The current files are copied out for a later update and the earlier ones written through the same held handles. A file with other bytes, a hard-linked file, a link, or a file that appears where a payload file was missing stops the roll back before anything changes; the result names it and the file stays. A missing payload file is created only where nothing is (CREATE_NEW, held). Engine.ini revert (#186): Engine.ini is opened once, read, compared and then rewritten or deleted through that same handle. A missing file is created only with CREATE_NEW; a file another program created meanwhile stays, the player's copy is kept in wronggpu-setup\rr-config and the result says where. Hard-linked or linked files are not written. New PinnedFile primitives (Create, ReadBytes, CopyOut, SetReadOnly) and WriteFileNew; RestoreStep is shared so the tests can act at the new steps. launcher-core gains 13 checks: player-changed, hard-linked, held, missing and appeared payload files at roll back; Engine.ini replaced or written while held, replaced before the open, created before the absent-file restore (on disk and in-memory copy), restored when gone, hard-linked. Fixes #184 Fixes #186 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/installer/README.md | 16 +- clean/installer/src/wg_core/launcher.cpp | 94 +++++++- clean/installer/src/wg_core/record.cpp | 2 +- clean/installer/src/wg_core/record.h | 7 +- clean/installer/src/wg_core/rrconfig.cpp | 67 ++++-- clean/installer/src/wg_core/util.cpp | 60 +++++ clean/installer/src/wg_core/util.h | 15 ++ clean/installer/tests/launcher_core_tests.cpp | 205 ++++++++++++++++++ 8 files changed, 435 insertions(+), 31 deletions(-) diff --git a/clean/installer/README.md b/clean/installer/README.md index d942f926..73dde33f 100644 --- a/clean/installer/README.md +++ b/clean/installer/README.md @@ -282,7 +282,18 @@ With the defaults nothing of this section changes the installer. between the plan and the open can make the open reach another file, which is then compared with the plan's hash like any file); the game's FSR DLL, in the one step where WrongGPU's DLL is deleted and the game's file takes its name, is held until deleted and the move that follows creates the name only if free; the install, repair and update steps - that write into the game folder, the Engine.ini edit and the rollback are not covered by this (tracked separately). + that write into the game folder and the Engine.ini edit that adds the line are not covered by this (tracked separately). + - **Roll back** holds every payload file it changes through one handle (as above), compares its bytes with the hash the + record says WrongGPU installed, keeps the current files for a later update by copying them out through those handles, + and then overwrites through them. A payload file with other bytes (the player's or another program's), a hard-linked + one, a link, or a file that appears where a payload file was missing stops the roll back before anything changes, and + the result names it; the file stays as it is. A missing payload file is created only where nothing is. + - **The Engine.ini revert** (=off, uninstall) reads the player's `Engine.ini` through one handle and writes its + corrected bytes (or deletes the file WrongGPU created) through that same handle, so a replacement by another program can + land only before the read (that file is then the one corrected) or after the write. When the file is gone, the + player's copy is created only where nothing is: a file another program created meanwhile stays, the copy is kept in + `wronggpu-setup\rr-config`, and the result says where. A hard-linked or linked `Engine.ini` is not written; the result + says to take the line out by hand. The in-place write is not atomic against a stop or a power cut. - When the original from before WrongGPU cannot go back because of such a file, it is kept in `\WrongGPU-originals\