Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 75 additions & 11 deletions clean/installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ AMD's upscaler; on any other build the plugin changes nothing and WrongGPU stays
`Dx12Upscaler=fsr31`, `FfxDx12SRPath` and `UpscalerIndex=0` stay as before. Uninstall removes the plugin, its folder
when the install made it, and its files (`wronggpu-asi.log`, `wronggpu-asi.ini` in the OptiScaler folder), and puts the
player's OptiScaler.ini back. Tests: `test_asi_plugin`.
Other setups' plugins (0.6.1, `ForeignPlugins`): `.asi` files in `plugins\`, `OptiScaler\plugins\` or `wronggpu-plugins\` that
the install record doesn't name with that hash. In a Ray Reconstruction game WrongGPU's RR stays out by default (they may
hook RR too; the result says so); with the player's OK (the window's question, `--switch-plugins`) they are moved aside
(backed up, put back on uninstall) and WrongGPU's RR goes in: exactly the plugins the question listed (`--switch-plugins`:
those there at the time); one that is not listed keeps RR out. Repair and Update keep them aside on that OK (the earlier
install's restore brings them back; byte for byte those go aside again), and RR stays out when the exe folder is outside
the install folder (nothing to move them with). Elsewhere they stay beside WrongGPU's plugin.
WrongGPU RR from another package at exactly `plugins\WrongGPU-RR.asi` is overwritten by the install's RR plugin (backed up by its copy entry, put back on uninstall); under any other name it stays.

For 007 First Light (`007FirstLight.exe`) the installer also sets OptiScaler's `[Spoofing] DxgiFactoryWrapping=true`:
with OptiScaler 0.9.5.4 the game does not start otherwise when WrongGPU is OptiScaler's FSR library (the list is
Expand Down Expand Up @@ -224,17 +232,73 @@ With the defaults nothing of this section changes the installer.
setup, or its uninstaller, can be run again. The logs that the OptiScaler of WrongGPU's own earlier hosted install
wrote (`OptiScaler.log`) belong to that install: no `/MOVEMODS`, no warning. An OptiScaler that is not in the
install record is another mod, as before.
- **Uninstall.** Restores every original byte for byte (hash-verified), removes everything added, including
`wronggpu-*` files WrongGPU wrote while the game ran and the player's `wronggpu.ini` (a re-install keeps it), removes
the entry, and `%LOCALAPPDATA%\WrongGPU` (model and logs) when no other game uses it. Nothing of WrongGPU is left. If a game update replaced one of the FSR DLLs, the game's new file is
kept and the old renamed copy is removed; the other DLLs are restored as usual.
- **Files that changed since the install** (uninstall and update alike). A file that is WrongGPU's own all the same is
removed like the one the record names, and the game's original comes back: an FSR DLL with WrongGPU's version
resource (a newer build the player placed by hand), or another payload file named `wronggpu*`, such as
`wronggpu_runtime.dll` (not the settings file). Any other changed FSR DLL follows the rule for game updates above;
any other changed file is left in place. The game's original of an FSR DLL is never removed while WrongGPU's DLL is
under the game's name: it comes back from the backup, or from its `*.wronggpu-original.dll` copy when the backup
is missing or damaged, checked against the hash in the record.
- **Uninstall.** Restores every original byte for byte (hash-verified) and removes what WrongGPU added in the game's folders
(by the rule below), and the entry. **WrongGPU's own folder `%LOCALAPPDATA%\WrongGPU` is deleted with everything in it** when
the last game that uses it is uninstalled (model, shared data, logs, jobs; the way an uninstaller removes its own application
folder; it is not a place for your files). The one thing kept is a shared ignore list (`ignore-files.txt`), which is put
back, never deleted. The launcher's uninstall question for the last game says so: "WrongGPU's own folder
%LOCALAPPDATA%\WrongGPU is deleted with everything in it." In the game's folders the `wronggpu-*` logs and reports that
WrongGPU's own programs wrote while the game ran are not in the record, so nothing proves them WrongGPU's (a player's
`wronggpu-notes.txt` carries the same prefix): they are not deleted. They stay in their folders, each is in the setup
log, and the result lists them ("left in place").
- **What the launcher removes or overwrites: the file-ownership rule** (0.6.1; the restore, uninstall, repair, update, move
out of a wrong folder and the state-folder cleanup; `src/wg_core/record.h`). In the game's folders, a file
is deleted or overwritten only when its current bytes are WrongGPU's: the hash the install record says WrongGPU last
wrote there (every write of the launcher to `wronggpu.ini`, `OptiScaler.ini` and the RR plugin's settings updates that
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
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
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
too: when its original has to go back, the file stays, the original is kept in `WrongGPU-originals`, and the result
says so. A recorded hard-linked file with nothing to put back loses only the recorded name.
- **REFramework's mirror.** A mirror copy of a root DLL (`_storage_`) is deleted only when the record lists it. An
unrecorded copy, even byte for byte the file the install wrote, stays and the result says so.
- **The state folder** (`wronggpu-setup`, in the game's folder) keeps the rule: a file goes only when it is WrongGPU's and,
where a hash is known, its bytes are those. The backups the record lists go while they match the entry's hash; the
previous version's files that `previous.txt` lists go while they match the hashes it states (a changed one stays and
is listed); `owned-files.json` goes while it is byte for byte what WrongGPU makes of the record. The record,
`previous.txt`, `uninstall.exe`, `setup.log` and `profile.ini` carry no recorded hash and go by their fixed names (the one
place the rule is by name). The player's Engine.ini copy (`rr-config`) goes only through the Engine.ini revert. Any other
file stays, the folder stays with it, and the result lists what was left. The same applies when an install is moved
out of a wrong folder. The shared folder `%LOCALAPPDATA%\WrongGPU` is not in a game's folder; see Uninstall.
- **A settings file in a build without Preset K.** The plugin's `wronggpu-asi.ini` is rewritten (its `selection=wronggpu-k`
line changed) only when an earlier record lists it and its bytes still match. Otherwise it stays as it is and the
result tells the player how to change it.
- **The replace race, as far as it is closed.** In the restore, a file is checked and changed through one handle: it is
opened once with read and delete access and without sharing for writing, renaming or deleting, hashed through that
handle, and then deleted (`FileDispositionInfoEx`) or overwritten through it. The file that was hashed is the file
that goes; a file that another program swaps in after the plan was made is found by the hash and left. Where nothing was
at a path when the plan was made, the original is created only if the path is still free. Not covered, and said here:
the folders above a file are resolved by name when it is opened (a program that can rename a folder of the game's path
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).
- When the original from before WrongGPU cannot go back because of such a file, it is kept in
`<install folder>\WrongGPU-originals\<time>\` (a folder no operation removes), checked byte for byte; a second
generation goes into a folder of its own, neither is overwritten. The result then says "partly" and names each file
and where its original is.
- Before anything changes, every recorded file is checked: one that cannot be read or replaced (another program holds
it, such as the running game) or a missing or damaged backup stops the operation ("Nothing was changed"). Each file
is checked again right before it is changed. The record is removed before the backup, so a stop at any point leaves
either the record and backup for a second run, which finishes, or every original at its path or in
`WrongGPU-originals`.
- The game's original of an FSR DLL comes back from the backup, or from its `*.wronggpu-original.dll` copy when the
backup is missing or damaged, checked against the hash in the record; when neither is there, the uninstall refuses
("Nothing was changed"). An uninstall that leaves an OptiScaler.ini naming WrongGPU's files warns that its setup may
need them.
- Moving another setup's files aside needs the player's OK for those exact bytes: the switch and plugin questions
record each listed file with its SHA-256, and a file that changed since the question is not moved
(`--switch` / `--switch-plugins`: the files as they are when the install starts).
- **Collect logs** (button, `/COLLECT`, or "Modify" in Apps & features): one .zip with WrongGPU's logs and crash
notes, the install record, setup log, model source, system information (Windows, GPU, driver, HIP runtime, FSR DLL
state, model state, where the output filter comes from, file hashes) and recent Windows crash / GPU-reset events.
Expand Down
8 changes: 7 additions & 1 deletion clean/installer/src/app/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
// status [game] one game or all: status, versions, last run, problems
// install | repair | update <game> (--opti=<OptiScaler download>, --model=<nvngx_dlss.dll>, --experimental,
// --switch: replace the player's own OptiScaler / other upscaler mod (backed up),
// --switch-plugins: other setups' OptiScaler plugins aside (backed up) so WrongGPU's
// Ray Reconstruction goes in (without it an RR game installs without WrongGPU's RR),
// --removeold: remove an older WrongGPU install first, --force: no GPU/HIP block,
// --rr-config-fix=on|off: Borderlands 4 / Hogwarts Legacy's Engine.ini question answered)
// uninstall | rollback | adopt <game> (adopt --all: every 0.5.x install the scan finds)
// clean-leftovers | adopt-leftovers <game> WrongGPU files without a record (hash-matched to our releases only)
// clean-leftovers | adopt-leftovers <game> WrongGPU files without a record (hash-matched to our releases only);
// --confirm-other-setup: also when another mod's setup uses them (refused without it)
// set <game> key=value ... per-game settings (written to the game at once); set --global key=value ...
// set <game> opti.<Section>.<Key>=value: an editable key of the game's OptiScaler.ini
// get <game> [key] | get --global
Expand Down Expand Up @@ -445,6 +448,7 @@ void EntryJson(Json& j, const GameEntry& e) {
FindingsJson(j, e.coexist);
j.Key("proxy_plan").Obj().S("name", e.proxyPlan.name).S("reason", e.proxyPlan.reason).B("untested", e.proxyPlan.untested).End();
if (!e.leftovers.empty()) {
if (e.leftoversOtherSetup) j.B("leftovers_other_setup", true); // 0.6.1: used by another mod's setup (left alone)
j.Key("leftovers").Arr();
for (auto& l : e.leftovers) j.Obj().S("path", l.rel).S("sha256", l.sha).S("version", l.version).End();
j.End();
Expand Down Expand Up @@ -675,6 +679,7 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
if (!Game(a, o, exe, dir)) return o.code;
if (NeedsElevation(dir)) { o.j.S("error", L"administrator permission is needed for " + dir); return EXIT_REFUSED; }
OpRequest r; ParseOp(verb, r.op); r.exe = exe; r.dir = dir;
r.otherSetupOk = a.has(L"confirm-other-setup"); // 0.6.1: files another mod's setup uses are left alone unless confirmed
OpLogBegin();
Ui ui; ui.step = [](int, int, const wstring&) {}; ui.log = [](const wstring& s) { LogLine(g.ctx, s); };
const OpResult res = RunOp(g.ctx, r, ui);
Expand Down Expand Up @@ -711,6 +716,7 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
r.optiPackage = op == Op::Install || op == Op::Update || op == Op::Repair ? OptiFor(a, gs) : (!a.get(L"opti").empty() ? a.get(L"opti") : gs.optiPackage);
r.modelDll = a.get(L"model");
r.moveMods = a.has(L"switch") || a.has(L"movemods");
r.movePlugins = a.has(L"switch-plugins") || a.has(L"moveplugins"); // 0.6.1: other setups' OptiScaler plugins aside (WrongGPU's RR then goes in)
r.removeOld = a.has(L"removeold") || a.has(L"clean-leftovers");
r.experimental = a.has(L"experimental");
r.force = a.has(L"force");
Expand Down
19 changes: 16 additions & 3 deletions clean/installer/src/app/launcher_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,22 @@ bool PrepareOp(const GameEntry& e, Op op, OpRequest& r, bool* failed, bool* gone
r.experimental = true;
if (t.conflicts.modsFound()) {
wstring list; for (auto& m : t.conflicts.mods) list += (list.empty() ? L"" : L", ") + m;
if (!Confirm(L"Switch to WrongGPU's OptiScaler setup?\n\nThis game already has " + list + L". Your files are backed up and put back exactly as they were if you uninstall WrongGPU.",
0, L"Switch", L"Cancel"))
// (0.6.1: Cancel is the default: the files may be another setup's OptiScaler over WrongGPU's own)
if (RunDialog(0, L"Switch to WrongGPU's OptiScaler setup?\n\nThis game already has " + list + L". Your files are backed up and put back exactly as they were if you uninstall WrongGPU.",
{{L"Switch", 1, false, false}, {L"Cancel", 0, true, false}}, 0) != 1)
return false;
r.moveMods = true;
// the OK is for these files with these bytes (the install moves none that changed since)
for (auto& f : t.conflicts.modFiles) r.moveModsList.push_back({f, Sha256File(Join(t.dir, f))});
}
if (t.coexist.foreignPluginsBlockRr) { // 0.6.1: other setups' plugins may hook RR too; keeping them leaves WrongGPU's RR out
wstring list; for (auto& p : t.coexist.foreignPlugins) list += (list.empty() ? L"" : L", ") + p;
r.movePlugins = RunDialog(0, L"Move the other OptiScaler plugins aside?\n\n" + t.name + L" has other OptiScaler plugins (" + list + L"). They may hook "
L"Ray Reconstruction as WrongGPU's does, so WrongGPU's Ray Reconstruction goes in only if they are moved aside. They are backed "
L"up and put back when you uninstall WrongGPU. If you keep them, WrongGPU installs without its Ray Reconstruction.",
{{L"Move them aside", 1, false, false}, {L"Keep them", 0, true, false}}, 0) == 1;
if (r.movePlugins) // exactly the plugins the question listed, with the bytes they had then
for (auto& p : t.coexist.foreignPlugins) r.movePluginsList.push_back({p, Sha256File(Join(t.exeDir, p))});
}
if (t.conflicts.oldFound()) {
if (!Confirm(L"Remove the older WrongGPU install first?\n\nAn older WrongGPU (DLSS 4.5 AMD) install is in this game. The game's original files are put back exactly as they were.", 0,
Expand Down Expand Up @@ -859,12 +871,13 @@ void OnLeftovers(const GameEntry& e, bool clean) {
wstring names;
for (auto& f : e.leftovers) names += (names.empty() ? L"" : L"\n") + f.rel + L" (WrongGPU " + f.version + L")";
for (;;) { // Show details: the files' names, then the question again
const int a = RunDialog(0, LeftoversText(e.name, e.leftovers, clean), LeftoversButtons(clean), 0);
const int a = RunDialog(0, LeftoversText(e.name, e.leftovers, clean, e.leftoversOtherSetup), LeftoversButtons(clean, e.leftoversOtherSetup), 0);
if (a == 1) break;
if (a != 2 || !v.live) return;
Inform(L"Details\n\n" + names, 2);
}
OpRequest r; r.op = clean ? Op::CleanLeftovers : Op::AdoptLeftovers; r.exe = e.exe; r.dir = e.dir;
r.otherSetupOk = e.leftoversOtherSetup; // (0.6.1: the player chose "anyway" for another mod's setup's files)
StartOp(r);
}
// An install the launcher does not manage yet (WrongGPU setup 0.5, no profile.ini, its own uninstall entry): adopted,
Expand Down
5 changes: 3 additions & 2 deletions clean/installer/src/app/launcher_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ void HandOverToInstalled(HANDLE& one, const wstring& installedExe, const wchar_t
bool AnswerReplaceOffer(HANDLE& one, const wstring& installedExe, const wstring& have, const LauncherStartDecision& start); // ui_words.cpp: "Update WrongGPU to X?"; true: Not now, this copy runs (rc5)
void RemoveDataAsked(); // ui_words.cpp: a portable copy's Settings > Remove data... (RemoveSharedData)
void StartHealth(bool gpu); // the model data, the RR data and the graphics card read again (the status line, Settings)
wstring LeftoversText(const wstring& name, const std::vector<Leftover>& files, bool clean); // Clean up / Adopt's question
std::vector<lui::DialogButton> LeftoversButtons(bool clean);
// Clean up / Adopt's question; otherSetup (0.6.1): the files are used by another mod's setup (said, Cancel the default)
wstring LeftoversText(const wstring& name, const std::vector<Leftover>& files, bool clean, bool otherSetup = false);
std::vector<lui::DialogButton> LeftoversButtons(bool clean, bool otherSetup = false);
// ui_dump.cpp ("WrongGPU.exe ui-dump") drives the window offscreen with these
const float kDefaultW = 1180, kDefaultH = 724; // the window's first size (DIPs)
extern bool firstRunBusy, focusFirstStop; // the first run's checks still running; the Library's first stop takes the focus next
Expand Down
Loading
Loading