Skip to content

Launcher: coexist with other OptiScaler setups - #47

Merged
phantoslayer21 merged 14 commits into
mainfrom
23-coexist
Nov 14, 2026
Merged

phantoslayer21 merged 14 commits into
mainfrom
23-coexist

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

When a game folder already contains an OptiScaler setup from another source, the launcher must not take it over or
delete its files. This PR gives the restore, uninstall, repair and update paths one file-ownership rule for the game's folders
(src/wg_core/record.h, installer README "What the launcher removes or overwrites").

What it guarantees, and no more.

  • Game folders and the state folder in them (wronggpu-setup): a file is deleted or overwritten only when the install record
    lists it and its bytes are the recorded ones. The state folder is the one place with files that carry no recorded hash
    (uninstall.exe, setup.log, profile.ini, previous.txt, the record itself): they go by their fixed names. Backups,
    the previous version's files and owned-files.json are checked against their hashes first.
  • Two recognition policies: files in WrongGPU's FSR slot that identify as WrongGPU (version resource ProductName), and files
    byte-identical to a WrongGPU release or to the embedded payload, are treated as WrongGPU's (identity, not proof of ownership).
  • %LOCALAPPDATA%\WrongGPU is WrongGPU's own application folder: when the last game is uninstalled, it is deleted with everything
    in it (the shared ignore list is put back, not deleted). The uninstall question says so. Nothing is promised there for files a
    player keeps in it.

It does not cover the install, repair and update steps that write into the game folder (issue #185), the Engine.ini restore (#186)
or the rollback (#184), nor the residual races named below. It is tested on Windows CPU runs and not in a game.

The rule

  1. A file is deleted or overwritten only when its current bytes are WrongGPU's: the hash the install record says
    WrongGPU last wrote there, or a WrongGPU release's (known_releases.h, size and SHA-256) or the embedded payload's.
    Nothing else proves it: not the file's name, a neighbouring file, an ini key or "it is a log".
  2. Any other file at a recorded path (edited by hand, saved by OptiScaler's menu, replaced by another setup or a game
    update) stays where it is, untouched.
  3. When the player's original cannot go back because of such a file, the original is kept, checked byte for byte, in
    <install folder>\WrongGPU-originals\<time>\. No operation removes this folder. A second generation goes into a
    folder of its own, so neither is overwritten.
  4. Settings files: every launcher write to wronggpu.ini, OptiScaler.ini and the RR plugin's settings updates the
    record's hash, so a hand edit or a menu save is no longer WrongGPU's. MigrateSettings only rewrites a file that is
    WrongGPU's.
  5. In the game's folders no file is deleted for its name: a file that is not in the record is not touched, whatever its name
    (wronggpu-*, OptiScaler.log, fakenvapi.log, ...). The restore finds the unrecorded wronggpu-* files in the folders the
    record's runtime lines name, logs each, and an uninstall lists them ("left in place"). The state folder (wronggpu-setup)
    follows the same rule with the exceptions stated above; anything else in it stays, with the folder, and is listed. A recorded
    file the install created and whose bytes changed since is preserved too. %LOCALAPPDATA%\WrongGPU is outside this rule (see
    "What it guarantees").
  6. Two recognition policies, stated on purpose. Files in WrongGPU's FSR slot that identify as WrongGPU (the version
    resource's ProductName is WrongGPU), or that are byte-identical to a WrongGPU release or to the embedded payload, are
    treated as WrongGPU's. This is recognition by identity, not proof of ownership: a player's own build 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.
  7. The result says "done" only when everything went back. Otherwise it says "partly" and names each file and where its
    original is kept (launcher, CLI and the small restorer).

Order of a restore: every recorded file is checked first. An unreadable file, a file that another program holds without
delete sharing, or a missing or damaged backup stops the operation with "Nothing was changed". Then originals that cannot
go back are kept, and the files are restored, each checked again right before it changes. Last, the record is removed,
then the backup. A stop at any point either leaves the record and backup for a second run, which finishes, or leaves
every original at its path or in WrongGPU-originals.

Consent is bound to bytes. The switch and plugin questions record each listed file with its SHA-256; the elevated job
carries them as movemod.N / moveplugin.N = path|sha256. A file that changed since the question is not moved.
--switch / --switch-plugins bind to the files as they are when the install starts.

Fixes #23, fixes #70, fixes #73

Behaviour changes (from the reviewed head c47d623)

  • Repair and Update no longer refuse over a changed file at a recorded path. They keep the original in
    WrongGPU-originals, go on, and report "partly".
  • Another setup's OptiScaler over WrongGPU's proxy, while the player's own OptiScaler sits in the backup: Repair now
    restores first, then stops with "two OptiScaler copies" (exit 6). Nothing is lost. Before, it refused before any
    change.
  • After an uninstall, a menu-saved or hand-edited OptiScaler.ini and wronggpu.ini stay, and so do shared logs.
    The player's earlier file is kept in WrongGPU-originals when one was there. A leftover OptiScaler.ini then makes
    the game page show "your own OptiScaler".
  • A game update's FSR DLL is never deleted. When WrongGPU's DLL was replaced by the game's newer one, the old original
    goes to WrongGPU-originals.
  • An earlier direct install moved to the hosted route never loses its wronggpu.ini by name. When the exe folder
    already has one, the earlier file stays in place with a warning.
  • Records from before this change have no runtime lines: nothing is listed for them, and their wronggpu-* logs stay.
  • The game root above the install folder (the folder Collect logs reads as game-root) has a runtime line of its own
    (<game-root>, resolved from the record's exe). The uninstall looks there for unrecorded wronggpu-* files too, lists
    them and leaves them.
  • An uninstall leaves the wronggpu-* logs and reports that WrongGPU's programs wrote while the game ran (they are not in
    the record), and the plugin's wronggpu-asi.ini, and says so in its result. The folders that hold them stay. An update's
    or repair's restore leaves them too, without a warning. The RR plugin's wronggpu-rr.ini and WrongGPU\wronggpu.ini, which
    the install creates and the plugin rewrites while the game runs, stay after an uninstall as well (their bytes are no longer
    the recorded ones); an unchanged copy still goes.
  • A failed install's rollback of a recorded file follows the same rule: a file whose bytes are not the installed ones (another program's, or a
    copy cut off halfway) stays and is logged.
  • A build without Preset K changes selection=wronggpu-k in an earlier install's wronggpu-asi.ini to selection=wronggpu
    (the file now survives the restore; every other line stays).
  • An update or setup over an earlier install starts the new wronggpu.ini from the earlier one when that was WrongGPU's
    (its recorded bytes). It is read before the restore, so the player's choices carry over while the restore puts an
    original from before WrongGPU back (the new install then backs it up again).
  • A recorded file that another program holds without delete sharing now refuses a setup over an earlier install before
    anything changes (exit 2, "Nothing was changed"). Before, it failed half-way (exit 1) with the record and backup kept.

Second review: finding by finding

Finding Status
M1: a wronggpu.ini that existed before the install is discarded (Repair after an edit; on uninstall the restored original is then deleted by name) Fixed in record.cpp (WhatIsThere: settings are WrongGPU's only by the recorded hash; no deletion by name; the restore keeps the original when the live file is the player's) and install.cpp (MigrateOurSettings only on a file that is WrongGPU's, and the record hash follows every write; RemoveEarlierDirect never deletes a wronggpu.ini). Tests: launcher-core "ownership: wronggpu.ini ..."; coexist_061_tests.py test_ownership_matrix (wronggpu.ini through uninstall, repair, update, relocation), test_settings_file.
M2: a live OptiScaler.log / fakenvapi.log that differs from the backed-up one is deleted because of its name Fixed in record.cpp: UnrecordedRuntimeFiles finds the wronggpu-* files in the folders the record's runtime lines name, and the restore leaves them (no file is deleted by its name) (SetRuntimeLines in install.cpp, leftovers.cpp); a disable entry whose path now holds other content leaves that file and keeps the moved-aside original. In install.cpp, a .log the player did not agree to move is left in place. Tests: launcher-core "ownership: OptiScaler.log ..."; test_ownership_matrix (OptiScaler.log).
M3: a replaced OptiScaler.ini is overwritten or deleted because the proxy DLL next to it still matches Fixed in record.cpp (WhatIsThere, OptiIniWrittenByUs: the ini is WrongGPU's only by its own recorded hash, never because of the DLL next to it or its keys). detect.cpp / coexist.cpp keep the proxy-DLL check (OptiSetupIsOurs) only to decide what the scan asks about. Tests: launcher-core "ownership: OptiScaler.ini, menu save" and "... full replacement beside the untouched OptiScaler DLL"; test_ownership_matrix, test_opti_ini_ownership, test_players_ini_edited_in_menu.
Consent not bound to the files' bytes Fixed in install.h / install.cpp (AgreedFiles, checked before moving and again after the restore), coexist.cpp (PlanPluginsAside matches name and current hash), launcher.cpp (job keys `path
A success message after a partial restore Fixed in launcher.cpp (PartlyText, Uninstall and Install results), restore_main.cpp, ui_words.cpp. Tests: the "result says partly and where" checks in test_ownership_matrix and launcher-core.
Interrupted operations Fixed in record.cpp: everything is checked before any change (Replaceable opens each file for delete access); each file is checked again before it changes; the record is removed before the backup. Test builds can stop the process at a named step (WRONGGPU_TEST_STOP_AT: kept, restored, record-removed). Tests: launcher-core "stopped after/before the record's removal", "held with read sharing only"; test_interrupted_restore (stop at record-removed, then a second run finishes; stop at restored; a file held with read sharing only).
README: the FSR DLL slot exception Fixed in clean/installer/README.md: the rule section states the slot exception (version resource) and drops the "never by a version resource" wording.

The first review's rows (B1-B3, should-fix 1-9, #70, #73) stand as described at c47d623, with these changes:

Re-review of #47 (head df9a5c8): item by item (scope split: install/repair/update race, Engine.ini and rollback are tracked in #185, #186, #184)

# Item Status
1 State and shared cleanup deleted unrecorded files (record.cpp state/model/shared cleanup, install.cpp and launcher.cpp relocation, util.cpp RemoveTree) State folder: fixed. util.cpp RemoveOwned deletes below a root only what a test accepts (each file through the handle it was checked through; links and held files stay) and removes only folders left empty. record.cpp StateOwned: see the final review below for what it accepts. Used by the uninstall, the update/repair backup removal and both relocations (install.cpp, launcher.cpp). What stays is listed in the result and the log. The shared folder: see the final review below (policy).
2 Settings migration rewrote an unrecorded wronggpu-asi.ini by name (install.cpp) Fixed. MigrateAsiSelection rewrites the selection=wronggpu-k line only when an earlier record lists the file and its bytes match: hashed through the handle that then writes (PinnedFile::OverwriteBytes), so it is a conditional write. Otherwise the file stays and the result tells the player what to do. Tests: not recorded, recorded with other bytes, recorded and matching, nothing to change, held by another program. The end-to-end update test now expects the file to stay and the warning.
3 Hard links: an in-place restore changed other names Fixed. PinnedFile::Open refuses a file with more than one name for writing (ERROR_TOO_MANY_LINKS, checked on a probe and again on the held handle). The restore leaves the file, keeps the original in WrongGPU-originals and says why ("partly"). A recorded hard-linked file with nothing to put back is deleted (only its name goes). Tests: refusal, restore with a linked recorded file (both names keep the bytes, the original is kept), a linked file with nothing to put back.
4 Mirror cleanup deleted an unrecorded copy for matching the installed hash Fixed in record.cpp: a mirror copy goes only when the record lists it; an unrecorded copy stays and is said. Tests: unrecorded matching copy stays, recorded copy goes.
5 Read-only attribute cleared by path before checking the file Fixed in util.cpp PinnedFile::Open: a probe handle (attribute access only, never follows a link) shows what the file is first; the bit is cleared through the probe only for a file that is a plain file with one name, put back if the open fails, if it is another file, or if the caller leaves the file (Close); Delete's fallback also puts it back on failure. Tests: failed open leaves the bit, close without writing puts it back, a changed read-only file the restore leaves keeps its bit, a link is refused before any attribute change (when the account may make one).
6 FSR ProductName and release-hash exceptions Kept as explicit policy, in item 6 above, in the installer README (uninstall section) and in record.h: "files in WrongGPU's FSR slot that identify as WrongGPU, or are byte-identical to a WrongGPU release, are treated as WrongGPU's".
7 Wording Narrowed (opening paragraph, "What it guarantees"); the README and record.h say what is covered and what is not.

Final review of #47 (head f258b36): policy and item by item (scope: the install/repair/update race #185, the Engine.ini restore #186 and the rollback #184 are not here)

# Item Status
3 %LOCALAPPDATA%\WrongGPU and everything under it Policy: it is WrongGPU's own application folder. The last game's uninstall removes it completely, including the delayed recursive cleanup (StartCleanup moves it aside and the hidden cleanup deletes the moved folder). The in-place "foreign file" mode, SharedOwned, ModelOwned and the model-data name filter are gone. The ignore list (ignore-files.txt) is still put back by its own rule (PutIgnoreListBack, unchanged). Written in the installer README (Uninstall) and in the launcher's last-game uninstall question: "WrongGPU's own folder %LOCALAPPDATA%\WrongGPU is deleted with everything in it." (ui_words.cpp UninstallGameText, which also says the ignore list is kept). Test (launcher-core): a folder with a model file, a foreign file in model\, in logs\ and at the top is removed whole by the cleanup.
4 Game folders and the state folder: own-files-only Kept for the game's folders (recorded files whose bytes match; everything else stays). The state folder: the backups the record lists go only while they match the entry's hash, owned-files.json only while it is byte for byte what WrongGPU makes of the record, the previous version's files per item 5; the record, previous.txt, uninstall.exe, setup.log and profile.ini have no recorded hash and go by their fixed names (the one by-name case, stated in the README). Anything else stays, with the folder, and is listed. Tests: a foreign file saved in the state folder, unlisted files in backup\ and previous\, an owned-files.json with other bytes, and the player's Engine.ini copy all stay; relocation's RemoveStateFolder with and without foreign files.
5 previous.txt hashes Fixed. StateOwned reads the hash each `file=
6 Wording The opening, "What it guarantees", rule items 5 and 6, the README and record.h are narrowed to items 3 to 5 and the two FSR recognition policies.

Batch review of #47 (head e96ebcb): finding by finding

Finding Status
Major: unrecorded player files are deleted solely by a prefix Fixed in record.cpp (UnrecordedRuntimeFiles replaces RemoveRuntimeFiles; unrecorded files are logged and listed, none deleted; a created file whose bytes changed stays).
Major: rechecking does not close the replacement race Fixed in the restore paths where Win32 allows (PinnedFile, DeleteIfSha, CopyNew in util.cpp); narrow races remain, named below.

Known narrow race (what is still path based)

  • The folders above a file are resolved by name when the file is opened. A program that can rename or replace a folder of
    the game's path (or put a junction there) between the plan and the open can make the open reach another file. That file
    is then hashed and compared with the hash the plan was made on, so it is changed only if its bytes equal the recorded
    ones (a copy of WrongGPU's own file). A link at the file itself is refused (the test for that runs only where the account may create a symbolic link). The parent-folder swap itself is not tested.
  • The plan hashes by path. A swap between the plan and the open is found by the hash (tested); a swap to a file with the same
    bytes is harmless.
  • The slot DLL step (WrongGPU's DLL under a game FSR name, the game's file moved back): WrongGPU's DLL is held while it is
    recognised (its version resource is read by path from the held file) and deleted through the handle. The game's file then
    takes the name by a move that does not replace anything: in the instant between the delete and the move another program
    can create a file at that name, and the move then fails; the game's file stays beside it, is kept in WrongGPU-originals and
    reported. A stop between the two leaves the name free, and a second run puts the game's file back.
  • The renamed original of an FSR DLL is checked and then moved by path: a swap of that source between the check and the move
    moves different bytes (the destination is created without replacing anything). Not tested.
  • An in-place overwrite keeps the destination file's security descriptor and other streams; it does not restore all of the
    backup's metadata.
  • "Nothing was changed" is a property of the preflight, not a transaction: a program that takes a conflicting handle on a file after
    the preflight makes the action fail at the held open, possibly after earlier entries changed.
  • The preflight (Replaceable) is advice ("Nothing was changed" before anything changes); the action decides.
  • An overwrite in place is not atomic against a stop: the record and backup stay until the restore is complete, and a second
    run finds a file that is neither the installed nor the original bytes, leaves it and keeps the original.
  • Not changed by this PR (tracked: install, repair and update writes Launcher: install, repair and update can delete or overwrite a file replaced after the backup #185; Engine.ini restore Launcher: Engine.ini selective restore can lose a replacement made after it was read #186; rollback Launcher: rollback can overwrite a player's changed file with the old payload #184): the install's own
    disable and rename-aside steps and its payload writes, the Engine.ini restore, and the rollback's overwrite. Also not changed:
    the launcher's own uninstall of its files by name and its "Remove data" (RemoveSharedData).

Tested

All runs are on Windows, CPU only, with 1 compile job, on the pushed head (this branch with main at 1b37c67 merged in). The CPU
test targets are built in the CI's launcher configuration (-DWRONGGPU_PRESET_K=OFF -DWRONGGPU_DIRECT_ROUTE=OFF). The end-to-end
launchers are WRONGGPU_TESTING builds (-DWRONGGPU_PRESET_K=OFF, direct route on) from the payload and map that
run_installer_tests.py --prepare-only writes. The baseline is the same suites on a build of e96ebcb (this PR before the fixes).

Run Result
CI launcher step (ctest: wg-core 87 checks, launcher-core 348, coexist-core 212, convert-ignore 219, model-choice 22, source-size, wording) 7/7 passed
run_coexist_tests.py (with coexist_061_tests.py) 229 passed, 0 failed; baseline 229 passed, 0 failed
run_launcher_tests.py (whole suite) 103 passed, 5 failed; baseline 103 passed, the same 5 failed
run_launcher_tests.py --only sm2_settings rr_config_fix players_optiscaler experimental_and_shared_model orphan rc6_hunt launcher_uninstall edition_download 133 passed, 0 failed; baseline the same
run_installer_tests.py --setup (hosted, Preset K off) 236 passed, 11 failed; baseline 236 passed, the same 11 failed
run_convert_ignore_tests.py 129 passed, 0 failed; baseline the same
Mutation check (this head): the hard-link refusal removed from PinnedFile::Open launcher-core fails at "hard link: a file with two names is refused for writing"
  • The 5 launcher failures are the same checks at e96ebcb ("uninstall.exe is the small restorer, not the launcher" (sizes of this
    local build), "an older record: update available installed", "a game without RR: installed without any RR file or record line",
    and the two rr-prepare checks, which need a prepared RR runtime). The suite stops in that case, so the later groups (rr,
    re9, direct_rr) do not run locally. The 11 installer failures are the same checks at e96ebcb.
  • The end-to-end suites had expected an uninstall to delete the wronggpu-* files they write to stand for a game run; they expect
    those files to stay (kept_runtime, unrecorded_wronggpu_files in run_installer_tests.py). One installer-suite check now expects
    the backup of an unlisted file and the then stale owned-files.json (a record with an entry removed by hand) to stay and be
    listed.

Not tested

  • The rr, re9 and direct_rr groups of run_launcher_tests.py, whose byte-for-byte uninstall checks were edited for the new rule
    (they cannot run here: the RR helper case and a synthetic file outside the repository). Also not run: launcher_ignore_cases, the
    adopt / self-install group (needs the 0.5.1 installer), ui_dump, run_model_l_tests.py, and the installer suite's Preset K and
    direct-route-only builds (one expectation edited for the Preset K build is in a branch that only such a build runs).
  • Relocation of an install out of a wrong folder end to end (RemoveEarlierDirect and the launcher's wrong-folder move): the shared
    RemoveStateFolder is tested, the callers are not run.
  • The last-game uninstall question with its new sentence in the window (UninstallGameText; the window's dialog dump ui_dump was not run).
  • Any elevated (UAC) run: nobody was at the PC to answer a prompt, so none was started; the hashed consent through the elevated job
    is not exercised.
  • In a game (needs the maintainer's game test). Dialog-level checks. A full disk. The folder-above-the-file race named above.

When a game folder already holds an OptiScaler setup from another source, the
launcher no longer takes it over or deletes its files:

- An OptiScaler that names WrongGPU is still another setup's; a file is
  WrongGPU's only by the install record's name and hash.
- Repair and Update ask before switching another setup's OptiScaler that sits
  over WrongGPU's proxy; the OK covers exactly the files moved aside.
- OptiScaler.ini is WrongGPU's only while its keys point at WrongGPU's files.
- The uninstall removes a changed file only by a WrongGPU release's hash; the
  game's own FSR DLL is never taken away without its original.
- Other setups' OptiScaler plugins keep WrongGPU's RR out of an RR game unless
  the player agrees to move them aside (backed up, put back on uninstall).
- WrongGPU's files beside another mod's OptiScaler are left to that setup;
  leftovers recognise WrongGPU's RR plugin and the 0.6.0 release's hashes.
- The game page reads clearly for a game with another upscaler mod, gives one
  finding per file, and Last run shows the RR plugin's "stays off" lines.
- Test programs can refuse to start with a temp folder outside a configured
  root (WRONGGPU_TEST_TEMP_ROOT, empty by default: no check).

Tests: coexist-core, launcher-core and wg-core cases; coexist_061_tests.py
drives the launcher on made-up folder layouts.

Fixes #23

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@j0nsh1n

j0nsh1n commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Since this reworks coexist.cpp: #50 suggests one Wine-only change to the DXVK / vkd3d-proton rule. Under Proton, vkd3d-proton next to the game exe is the game's own D3D12, and today it's how Linux players get dxil-spirv #362. So under Wine it could be a note instead of a refusal, with Windows unchanged and DXVK still refused. The issue has the few lines of code it takes and how I tested them. If it fits your rework of this file, it may be easiest to fold in here. Otherwise it can wait for its own change.

- OptiScaler.ini is the install's while the OptiScaler DLL the record
  installed is still in place (OptiScaler's menu may point the ini
  elsewhere), or while its keys point at WrongGPU's files.
- A file left in place whose original is in the backup never loses that
  backup: the uninstall keeps the backup folder; Repair and Update refuse
  before anything changes, also when a file moved aside is back with other
  content. An unreadable recorded file stops the uninstall before anything
  changes.
- Other setups' plugins: decided before the earlier install's restore and
  again after it; only the plugins the player's question listed are moved;
  plugins an earlier install moved aside go aside again (byte for byte);
  paths relative to the install folder, RR stays out when the exe folder
  is outside it.
- The switch question defaults to Cancel; Clean up / Adopt of files another
  mod's setup uses take --confirm-other-setup instead of --force.
- The consent check after the restore is gone (checked before anything
  changes); a game FSR DLL without its original makes the uninstall refuse
  again ("Nothing was changed").
- Leftovers: WrongGPU's own setup without its record is recognised by its
  menu plugin's hash, not by file names or the licence text.
- Split out for a follow-up: the test builds' temp-folder guard, the RR
  guard lines in Last run and the library cache's 24th field.
- Backups (#70): Update and Repair keep the player's moved-aside
  OptiScaler.log (the log WrongGPU's OptiScaler wrote there goes, the
  player's comes back and goes aside again); the move out of a wrong
  folder refuses like Repair instead of dropping a kept backup. The settings file (#73): wronggpu.ini
  changed since the install stays through Update and Repair, and the
  uninstall removes it and says so instead of "left in place".
- Comments and test texts describe the behaviour; new tests for these
  cases and for interrupted operations.

Fixes #70
Fixes #73

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 21:36
@phantoslayer21
phantoslayer21 marked this pull request as draft November 14, 2026 00:06
Every restore, uninstall, repair, update, move out of a wrong folder and
cleanup now follows one rule (record.h, README "What the launcher removes
or overwrites"):

- A file is deleted or overwritten only when its current bytes are
  WrongGPU's: the hash the record says WrongGPU last wrote there, or a
  WrongGPU release's or the embedded payload's. Not by name, a
  neighbouring file, an ini key or because it is a log. The two
  exceptions: the game's FSR DLL slots (WrongGPU's DLL by its version
  resource) and settings/log/text files with WrongGPU's own unique names
  that the record lists as created by WrongGPU.
- Anything else at a recorded path stays as it is. A player's original
  that cannot go back because of it is kept, byte for byte, in
  <install folder>\WrongGPU-originals\<time>\ (never removed; a second
  generation in a folder of its own), and the result says "partly" and
  names each file and where its original is.
- wronggpu.ini, OptiScaler.ini and the RR settings: the record's hash
  follows every write of the launcher (MigrateSettings too, only on a file
  that is WrongGPU's). OptiScaler.ini is no longer WrongGPU's because of
  the OptiScaler DLL next to it or its keys (the scan still uses that,
  only to decide what it asks about).
- OptiScaler.log, fakenvapi.log and other shared names are never deleted
  by name. The install lists the folders its own programs write
  wronggpu-* files to (new record line "runtime"); only those go by name.
- Before anything changes every recorded file is checked (unreadable,
  held by another program without delete sharing, missing backup:
  refused, "Nothing was changed"); each file is checked again right
  before it changes. The record is removed before the backup, so a stop
  at any point is finished by a second run or leaves every original at
  its path or kept. Repair and Update no longer refuse over a changed
  file: they keep its original and go on.
- The player's OK to move other setups' files aside is bound to their
  bytes: the switch and plugin questions carry each listed file with its
  SHA-256 (also through the elevated job, movemod.N / moveplugin.N =
  path|sha256); --switch / --switch-plugins bind to the files as the
  install starts. A file that changed since is not moved.
- The relocation of an earlier direct install never deletes its
  wronggpu.ini by name (left in place when the exe folder has one).

Tests: launcher-core (each case asserts bytes): wronggpu.ini,
OptiScaler.ini (menu save, full replacement beside the untouched
OptiScaler DLL) and OptiScaler.log, A before / B after, through uninstall
and an update or repair's restore: A and B both survive; two generations;
runtime names; a file changed between check and change; a stop after the
record's removal and before it; a file held with read sharing only.
coexist-core: consent bound to bytes. The coexist suite: the same four
cases end to end through repair, update, uninstall and the move out of a
wrong folder, the stop points (test builds stop the process at a named
step) and a held file; existing tests follow the rule. The installer and
launcher suites follow it (hand-edited settings files are put back, the
game's replaced FSR DLL is kept).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Conflicts in record.h / record.cpp with the ignore-list change (#46):
StartCleanup now returns the line about a kept ignore-files.txt, and the
restore reports it. The restore keeps this branch's order: the record is
removed before the backup, and there is no kept-backup path (originals
that cannot go back are kept in WrongGPU-originals).

Found by the installer suite's direct-route cases ([1] to [11], [14]),
run with a direct-route build:
- An update or setup over an earlier install starts the new wronggpu.ini
  from the earlier one when that was WrongGPU's (its recorded bytes),
  read before the restore; the restore deals with the path by the rule,
  so the player's choices stay and an original from before WrongGPU is
  backed up again. The move of an earlier direct install from another
  folder carries that file to the exe folder the same way.
- The game root above the install folder (where the game's working
  folder is and Collect logs looks) gets a runtime line of its own
  ("<game-root>", resolved from the record's exe): WrongGPU's wronggpu-*
  logs there go with the uninstall; other files there stay.
- Suite expectations follow the rule: a hand-written wronggpu.ini stays
  after the uninstall; a game update's FSR DLL stays and the earlier one
  is kept in WrongGPU-originals (two generations both kept); a file held
  without delete sharing refuses the setup before anything changes
  (exit 2); OptiScaler's shared logs stay; an older version's record
  carries the hash of the wronggpu.ini it wrote.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ndle-based delete and overwrite

Uninstall no longer deletes files by their wronggpu- name prefix: unrecorded files are kept and listed in the result. A
recorded file the install created is deleted only while its bytes are still the recorded ones, like any other recorded
file. The check and the delete or overwrite go through one handle opened without sharing for writing, renaming or
deleting; an original goes back only where the path is still free (CopyNew). Tests cover files created after install,
recorded files replaced after install, created-then-changed files, and swaps between check and action.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…o-end suites expect unrecorded wronggpu-* files to stay

A build without Preset K changes an earlier install's selection=wronggpu-k line in wronggpu-asi.ini to selection=wronggpu
(that file now survives the restore, it is not in the record). The end-to-end suites compare the folder after an uninstall
with the folder before, plus the unrecorded wronggpu-* files the tests wrote (kept_runtime, unrecorded_wronggpu_files).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
… links, mirror, settings migration and read-only handling

The state folder, the shared data folder, the model data and a relocated install's state folder are cleaned by what WrongGPU
wrote (its fixed names, the recorded backups, the previous version's listed files, the model files); anything else stays
with the folder and is listed in the result. A hard-linked file is never written through. A mirror copy is deleted only when
the record lists it. The plugin's wronggpu-asi.ini is rewritten only when recorded and its bytes match, through the held
handle. A read-only bit is changed only after a probe shows what the file is, and put back when the file is not written.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…game; the state folder checks the bytes

The shared data folder is WrongGPU's own application folder: the last game's uninstall removes it with everything in it (the
ignore list is still put back), and the uninstall question says so. The state folder in the game's folder keeps the
own-files-only rule: backups, previous-version files and owned-files.json are deleted only while their bytes match the
recorded hashes (previous.txt's hashes are checked now); a changed file stays and is listed.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
j0nsh1n added a commit to j0nsh1n/wronggpu that referenced this pull request Nov 15, 2026
Brings the launcher branch up to upstream main (217 commits: phantoslayer21#47, phantoslayer21#105,
phantoslayer21#196, phantoslayer21#197, phantoslayer21#209, Model K/L, frame generation, ...). Changes beyond
resolving the three conflicts (CMakeLists.txt project(), util.h's includes,
the restorer test):

- POSIX layer: the Win32 calls main's handle-based restore uses
  (SetFileInformationByHandle with FileBasicInfo, FileDispositionInfo and
  FileDispositionInfoEx's POSIX delete, GetFileInformationByHandleEx
  FileBasicInfo, SetEndOfFile, ExitProcess, GetProcessHeap/HeapFree, CDECL,
  ERROR_TOO_MANY_LINKS/FILE_CORRUPT/READ_FAULT), with posix-layer tests.
- run_launcher_tests.py stays below the 256 KB source limit: the edition
  section moves unchanged to launcher_edition_cases.py and the Linux run's
  plumbing to native_linux.NativeT.
- launcher-native runs only in a -DWRONGGPU_PRESET_K=OFF build (like CI's
  launcher build: the suite expects no seeded wronggpu-asi.ini); its two
  checks that fail on main's own launcher too (phantoslayer21#219) are skipped while
  they fail (native_linux.KNOWN_ON_MAIN).

Verified: fresh build, ctest 22/22 (launcher-native 365 passed, 0 failed,
6 skipped: 4 Windows-only sections, the 2 phantoslayer21#219 checks); reuse lint passes.

Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants