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
33 changes: 33 additions & 0 deletions clean/installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,39 @@ Windows (the Wine run was not repeated for them):
not a HIP runtime; `LLVM_PATH` removed for the child (the mock fails when it sees it); the newest ROCm folder
(7.10 before 7.2) tried first.

**The tests never read the PC's own game libraries** (#243). Every read of a store's metadata goes through one place
(`util.h` `LibraryAccess` / `LibraryRegistryAccess`). That covers Steam's library list and app manifests (also Play's Steam
app id and the display name), Epic's manifests (also Play's Epic app name), the GOG registry, Steam's art cache, and every
walk of a library game's folder (`FindFilesNamed`).
- A `WRONGGPU_TESTING` build with `WRONGGPU_TEST_LIBRARIES` set takes its store libraries from that folder only (each
sub-folder a game; set but empty: none). It reads nothing outside the folder that holds it, the test run's own folder, and
no store registry key. The check is on the real path too: a path whose resolved form differs (a junction or link on the
way), a reparse point, a file with a second name (a hard link) and a test folder that itself resolves elsewhere are
refused.
- Such a build logs "library access: <path>" (or "... refused: <path> (<why>)") to `WRONGGPU_TEST_ACCESS_LOG` before every
read: each walked folder and each file it opens. A read whose line cannot be written is refused (fail closed). A new log
starts with "run <WRONGGPU_TEST_RUN_ID>", and every start of the launcher or the restorer writes a "process" line.
Release builds read none of these variables.
- `--noscan` (CLI, every verb; `apply --noscan` for the job too), `/NOSCAN` and the window's no-scan keep every library search
away from the store libraries, the AMD FSR 4 search and the other-model search included. An operation's own noscan (a
job's) holds for that operation only, never for the next job of a batch.
- `/S /NOSCAN /FSR4` and `/S /NOSCAN /LIST` search no library; the report says "libraries not searched (/NOSCAN)".

Every runner (launcher, coexistence, Model L / K, convert-ignore, installer) sets these variables to its work folder and a
new run id; it never creates the access log itself (native installer runs need a `WRONGGPU_TESTING` build). Each
runs the guard's self-test (`tests/launcher_isolation.py` `self_test`) before any program call, and stops the run if the
guard is broken. Every launcher and installer call, raw ones and elevated jobs included, is checked by `check_isolation`.
The run stops, loudly, on:
- a read outside the work folder (also its `\\?\` and UNC forms);
- a store registry read;
- a missing or unreadable access log, one that does not start with this run's id, or a call that added no line to it;
- no access at all where a call was meant to scan (the guard's sensitivity);
- a search line of the main log that names a path outside the work folder.

The `[isolation-verbs]` section runs install, repair, update, uninstall, the window's refresh, a batch (a noscan job, then a
normal one) and `/FSR4` / `/LIST`, with and without no-scan, against a non-empty test library. The 0.5.1 baseline installer
predates all this and runs only with `--run-old-baseline`, in a fully redirected sandbox.

On Windows: `python tests\run_installer_tests.py --prepare-only` writes the mock payload and the synthetic map; build
the installer from them with CMake (`-DWRONGGPU_PAYLOAD_DIR=... -DWRONGGPU_MAP=...`) and run
`python tests\run_installer_tests.py --setup <WrongGPU-Setup.exe>`. Natively it points `LOCALAPPDATA` and
Expand Down
2 changes: 2 additions & 0 deletions clean/installer/src/app/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ static void IgnoreJson(Output& o, const IgnoreReport& r) {
int Verb(const wstring& verb, const Args& a, Output& o) {
if (IgnoreArgsMisplaced(verb, a, o)) return o.code;
const bool noScan = a.has(L"noscan");
if (noScan) { g.ctx.noScanAlways = true; g.ctx.noLibraryScan = true; } // every verb: no store library search (the AMD FSR 4 search too)
GlobalSettings& gs = gl.global;
GlobalSettings scan = gs; // --library=<folder>: scanned this time only, never saved
for (auto& lib : a.libraries) scan.extraFolders.push_back(FullPath(lib));
Expand Down Expand Up @@ -758,6 +759,7 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
g.ctx.perGameEntry = perEntry >= 0 ? perEntry == 1 : !LauncherInstalled();
Ui ui; ui.step = [](int, int, const wstring&) {}; ui.log = [](const wstring& s) { LogLine(g.ctx, s); };
LogLine(g.ctx, wstring(L"elevated worker: ") + OpName(r.op) + L" " + (r.dir.empty() ? r.exe : r.dir) + (IsElevated() ? L" (elevated)" : L" (not elevated)"));
r.noScan = r.noScan || g.ctx.noScanAlways; // apply --noscan: the job's own searches too (#243)
res = RunOp(g.ctx, r, ui);
}
if (!result.empty()) { const string rt = ResultText(res); try { WriteFileAtomic(result, rt.data(), rt.size()); } catch (const SetupError&) {} }
Expand Down
19 changes: 13 additions & 6 deletions clean/installer/src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,27 @@ int RunSilent() {
LogLine(g.ctx, L"HIP check: " + (h.ok ? L"OK - " + h.device + L" (" + h.arch + L") with " + h.dll : h.text));
return h.ok ? EXIT_OK : EXIT_REFUSED;
}
// /NOSCAN with /FSR4 or /LIST (#243): no store library is searched; the report says so
auto storeLibraries = [](const wchar_t* what) {
if (!g.ctx.noLibraryScan) return ScanLibraries();
LogLine(g.ctx, wstring(what) + L": libraries not searched (/NOSCAN)");
return std::vector<StoreGame>{};
};
if (g.fsr4) { // read-only: the AMD FSR 4 DLL an install would record for the comparison key
const CompareDll fc = FindCompareDll(g.ctx, ScanLibraries());
LogLine(g.ctx, fc.path.empty() ? wstring(L"FSR 4 for the comparison key: none found (Home compares with the game's own AMD FSR)")
const CompareDll fc = FindCompareDll(g.ctx, storeLibraries(L"FSR 4 for the comparison key"));
if (!g.ctx.noLibraryScan) LogLine(g.ctx, fc.path.empty() ? wstring(L"FSR 4 for the comparison key: none found (Home compares with the game's own AMD FSR)")
: L"FSR 4 for the comparison key: " + fc.path + L" (" + fc.version + L", " + fc.game + L")");
return EXIT_OK;
}
if (g.list) { // read-only: what the wizard would show, with the checks for each game
for (auto& f : DetectGames(ScanLibraries())) {
for (auto& f : DetectGames(storeLibraries(L"games"))) {
GameTarget t = InspectGame(g.ctx, f.exe, f.name);
Checks c = RunChecks(g.ctx, t, g.sys, nullptr, g.force);
LogLine(g.ctx, L"game " + f.name + L" [" + f.source + L"] " + (f.validated ? L"VALIDATED" : L"experimental") + L" -> " + f.exe + L" | install folder " + t.dir);
for (int i = 0; i < L_COUNT; ++i) LogLine(g.ctx, wstring(c.st[i] == CK_OK ? L" ok " : c.st[i] == CK_WARN ? L" warn " : c.st[i] == CK_NA ? L" n/a " : L" FAIL ") + c.text[i]);
}
const CompareDll fc = FindCompareDll(g.ctx, ScanLibraries()); // what an install would record (nothing written here)
LogLine(g.ctx, fc.path.empty() ? wstring(L"FSR 4 for the comparison key: none found (Home compares with the game's own AMD FSR)")
const CompareDll fc = FindCompareDll(g.ctx, storeLibraries(L"FSR 4 for the comparison key")); // what an install would record (nothing written here)
if (!g.ctx.noLibraryScan) LogLine(g.ctx, fc.path.empty() ? wstring(L"FSR 4 for the comparison key: none found (Home compares with the game's own AMD FSR)")
: L"FSR 4 for the comparison key: " + fc.path + L" (" + fc.version + L", " + fc.game + L")");
return EXIT_OK;
}
Expand Down Expand Up @@ -202,6 +208,7 @@ using namespace wg;
using namespace wg::app;

int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, PWSTR, int) {
TestAccessStart(L"WrongGPU"); // (#243: a test build run by the tests leaves a line for every run)
{ // release 0.6.0: the Ray Reconstruction helper (rrprep.h): this program copied under a game's program name, started by
// the launcher with --rr-prepare <runtime> <passes>; nothing else of the launcher runs in it
int hc = 0; LPWSTR* hv = CommandLineToArgvW(GetCommandLineW(), &hc);
Expand Down Expand Up @@ -243,7 +250,7 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, PWSTR, int) {
else if (la == L"/preset=m") {}
#endif
else if (kDirectRoute && la == L"/directfsr") g.route = wg_wizard::Route::DirectFsr;
else if (la == L"/noscan") g.noScan = g.ctx.noLibraryScan = true;
else if (la == L"/noscan") { g.noScan = g.ctx.noScanAlways = true; g.ctx.noLibraryScan = true; }
else if (la == L"/force") g.force = true;
else if (la == L"/experimental") g.experimentalOk = true;
else if (la == L"/movemods") g.moveMods = true;
Expand Down
1 change: 1 addition & 0 deletions clean/installer/src/app/restore_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ wstring PlainError(const SetupError& e) {
} // namespace

int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) {
TestAccessStart(L"restorer"); // (#243: a test build run by the tests leaves a line for every run)
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
static const EmbeddedData data{nullptr, 0, 0, L"", 0, L"", 0, WRONGGPU_VERSION_STR};
Context ctx;
Expand Down
11 changes: 8 additions & 3 deletions clean/installer/src/app/ui_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ struct ArtState {
} st;

wstring LibraryCache() {
wstring steam = RegString(HKEY_CURRENT_USER, L"Software\\Valve\\Steam", L"SteamPath");
// (util.h: the store access; a test build never reads the PC's own Steam)
wstring steam = LibraryRegistryAccess(L"Steam SteamPath (art cache)") ? RegString(HKEY_CURRENT_USER, L"Software\\Valve\\Steam", L"SteamPath") : wstring();
for (auto& c : steam) if (c == L'/') c = L'\\';
return steam.empty() ? wstring() : Join(steam, L"appcache\\librarycache");
const wstring cache = steam.empty() ? wstring() : Join(steam, L"appcache\\librarycache");
return cache.empty() || !LibraryAccess(cache) ? wstring() : cache;
}

// <cache>\<appid>\<name>, or one folder deeper (Steam keeps hashed sub-folders); the newest when there are several.
Expand All @@ -66,10 +68,13 @@ wstring FindArt(const wstring& dir, const wchar_t* name) {
auto consider = [&](const wstring& p) {
WIN32_FILE_ATTRIBUTE_DATA a{};
if (!GetFileAttributesExW(p.c_str(), GetFileExInfoStandard, &a) || (a.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) return;
if (!LibraryAccess(p)) return; // (util.h: each art file is asked before it can be opened)
if (best.empty() || CompareFileTime(&a.ftLastWriteTime, &bestTime) > 0) { best = p; bestTime = a.ftLastWriteTime; }
};
if (!LibraryAccess(dir)) return best; // (util.h: every folder listed is asked first)
consider(Join(dir, name));
for (auto& sub : ListDirs(dir)) consider(Join(sub, name));
for (auto& sub : ListDirs(dir))
if (LibraryAccess(sub)) consider(Join(sub, name));
return best;
}

Expand Down
1 change: 1 addition & 0 deletions clean/installer/src/app/ui_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ using namespace win;
// no network, no HIP probe or model conversion. Development and the launcher tests.
int RunLauncherUiDump(const wstring& outFile, const wstring& shotDir, bool noScan, const wstring& apply) {
g.noScan = noScan;
if (noScan) { g.ctx.noScanAlways = true; g.ctx.noLibraryScan = true; } // (the AMD FSR 4 search too)
CreateLauncherWindow(false);
RefreshModelNow();
SetGpu(DetectGpu());
Expand Down
7 changes: 6 additions & 1 deletion clean/installer/src/wg_core/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// g_presetK, g_map, g_opti, g_noLibraryScan and the embedded payload table), the Ui callbacks of a long operation, the
// log file and the model data folder. Written for this project.
#pragma once
#include <atomic>
#include <functional>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -84,7 +85,11 @@ struct Context {
wgc::LoadedMap fMap;
wstring fMapError;
OptiPackage opti; // the player's OptiScaler package (/OPTISCALER=, the wizard's choice)
bool noLibraryScan = false; // /NOSCAN: the store libraries are not searched
// No search of the store libraries (#243). noScanAlways: this process was asked (--noscan, /NOSCAN, the window's); set once
// at start. noLibraryScan: what the searches read now (the AMD FSR 4 search, the other model); RunOp sets it per operation
// (noScanAlways or the operation's own noscan) and puts it back after, so a job's noscan never reaches the next job.
bool noScanAlways = false;
std::atomic<bool> noLibraryScan{false};
// The launcher (build/launcher-design.md): one Apps & features entry for all games instead of one per game; the
// HIP runtime is optional (D3D12 is the default executor on RX 9000; a missing HIP runtime is a warning); the
// uninstaller written into each game is the small restorer the launcher embeds (WrongGPU-Restore.exe).
Expand Down
Loading
Loading