From a45de8303af278615ab03306041554150f8c842c Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:24:45 -0500 Subject: [PATCH] Uninstaller "Collect logs": model data it cannot check is "not verified here", not invalid A game's uninstall.exe is built without the converter map, so its Collect logs report called valid model data invalid. It now reports the model file's presence and size and says the data is not verified there; the launcher's own report is unchanged. The bundle also lists WrongGPU's files and has no empty version fields. Tests: launcher-core covers the uninstall.exe case; the installer suite runs Collect logs through uninstall.exe in every build configuration. Fixes #24 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/installer/src/wg_core/logs.cpp | 35 +++++++++- clean/installer/src/wg_core/logs.h | 5 ++ clean/installer/tests/launcher_core_tests.cpp | 30 ++++++++ clean/installer/tests/run_installer_tests.py | 69 ++++++++++++++++++- 4 files changed, 137 insertions(+), 2 deletions(-) diff --git a/clean/installer/src/wg_core/logs.cpp b/clean/installer/src/wg_core/logs.cpp index 9fb62c8a..2efe402a 100644 --- a/clean/installer/src/wg_core/logs.cpp +++ b/clean/installer/src/wg_core/logs.cpp @@ -221,6 +221,27 @@ string SupportAdapters() { } factory->Release(); return out + "]"; } +// 0.6.1: what a process without the converter data or the payload table (uninstall.exe, the restorer: wg_core without them) +// can say truthfully; WrongGPU.exe, which embeds both, keeps its own lines byte for byte. +bool HasConverterData(Context& ctx, bool k) { return ctx.data && MapResourceId(ctx, k) != 0; } +wstring ModelDataUnverified(const wstring& file) { + if (!IsFile(file)) return IsDir(file) ? L"present but unreadable (a folder, not a file)" : L"missing"; + HANDLE h = CreateFileW(file.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + if (h == INVALID_HANDLE_VALUE) return L"present but unreadable (" + ErrText(GetLastError()) + L")"; + LARGE_INTEGER size{}; + char first = 0; + DWORD got = 0; + const bool sized = GetFileSizeEx(h, &size) != 0; + const DWORD sizeError = sized ? 0 : GetLastError(); + const bool read = sized && ReadFile(h, &first, 1, &got, nullptr) != 0; + const DWORD readError = read ? 0 : GetLastError(); + CloseHandle(h); + if (!sized) return L"present but unreadable (" + ErrText(sizeError) + L")"; + if (!read) return L"present but unreadable (" + ErrText(readError) + L")"; + return L"present, " + std::to_wstring(size.QuadPart) + L" bytes, not verified here (uninstall.exe has no converter data; use Collect logs in the WrongGPU " + L"launcher to verify)"; +} + // Collects from the install folder (and the exe folder and game root, where some games write logs). Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, const SystemInfo& sys) { if (dirIn.empty() || !IsDir(dirIn)) Fail(L"Choose the game first: logs are collected from its folder.", EXIT_REFUSED); @@ -280,7 +301,10 @@ Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, co // System information. wstring s = L"WrongGPU - log bundle (attach this file to your game report)\r\n"; - s += L"Created: " + NowStamp(false) + L"\r\nInstaller version: " + wstring(ctx.data->version) + L" (build " + ctx.data->buildId + L", payload " + ctx.data->payloadName + L")\r\n"; + if (*ctx.data->buildId) + s += L"Created: " + NowStamp(false) + L"\r\nInstaller version: " + wstring(ctx.data->version) + L" (build " + ctx.data->buildId + L", payload " + ctx.data->payloadName + L")\r\n"; + else // uninstall.exe: its own version; it carries no build name or payload (0.6.1: no empty fields) + s += L"Created: " + NowStamp(false) + L"\r\nInstaller version: " + wstring(ctx.data->version) + L" (uninstall.exe of this version; build and payload not known here)\r\n"; s += L"Install folder: " + dir + L"\r\n"; if (!exe.empty()) s += L"Game executable: " + exe + L" (file version " + FileVersion(exe) + L")\r\n"; s += L"Game status: " + wstring(t.validated ? L"Validated" : L"Experimental (not validated yet)") + L"\r\n"; @@ -297,6 +321,10 @@ Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, co wstring why; // Collection must use the installed preset, independent of the wizard's default M choice. // Keep a private map so a concurrent conversion worker's map is never changed. + // 0.6.1: a process without the converter data (uninstall.exe) never claims the map is invalid: it says what it can see + if (!HasConverterData(ctx, reportK)) { + s += L"Model data: " + ModelDataUnverified(reportModelFile) + L"\r\n"; + } else { DWORD reportMapSize = 0; const void* reportMapBytes = ResourceData(MapResourceId(ctx, reportK), reportMapSize); wgc::LoadedMap reportMap; @@ -306,6 +334,7 @@ Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, co if (modelMatches) modelMatches = wgc::verify_model_file(*reportMap.map, std::filesystem::path(reportModelFile), reportWhy); else reportWhy = "the embedded converter map is invalid"; s += L"Model data: " + (modelMatches ? L"present and matching (" + reportModelFile + L")" : L"not usable (" + FromUtf8(reportWhy) + L")") + L"\r\n"; + } // (WrongGPU.exe's lines above: unchanged, kept at their indentation so the diff shows it) #if WRONGGPU_PRESET_K s += L"Installed startup preset: " + wstring(reportK ? L"K" : L"M") + L"\r\n"; #endif @@ -336,6 +365,10 @@ Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, co std::vector names{L"dxgi.dll", L"d3d12.dll", L"version.dll", L"winmm.dll", L"OptiScaler.ini", L"OptiScaler.dll", L"wronggpu_ffx_dx12.dll", kOptiSlotFrontEnd, L"wronggpu-amd-compare.dll", L"amd_fidelityfx_upscaler_dx12.dll"}; for (auto& sl : kSlots) { names.push_back(sl.name); names.push_back(sl.original); } for (auto& f : *ctx.data) names.push_back(f.rel); + // 0.6.1: uninstall.exe has no payload table: the install record's files instead, so the list is not silently missing + // WrongGPU's runtime, plugins and text files (WrongGPU.exe's list: unchanged) + if (!ctx.data->count && installed) + for (auto& e : m.e) if (e.action == L"copy") names.push_back(e.rel); std::set listed; string inventory = "["; bool firstInventory = true; for (auto& n : names) { diff --git a/clean/installer/src/wg_core/logs.h b/clean/installer/src/wg_core/logs.h index 9210c794..d1410df4 100644 --- a/clean/installer/src/wg_core/logs.h +++ b/clean/installer/src/wg_core/logs.h @@ -15,6 +15,11 @@ bool SupportReadTail(const wstring& path, string& out, uint64_t limit, uint64_t& string SupportDriverRegistry(); string SupportAdapters(); Bundle CollectLogs(Context& ctx, const wstring& dirIn, const wstring& outZip, const SystemInfo& sys); +// 0.6.1: whether this process carries the converter map (WrongGPU.exe does; uninstall.exe, the restorer, does not), and the +// Model data line of a process without it: "missing", "present but unreadable ()", or "present, bytes, not +// verified here (uninstall.exe has no converter data; use Collect logs in the WrongGPU launcher to verify)". +bool HasConverterData(Context& ctx, bool k); +wstring ModelDataUnverified(const wstring& file); wstring DefaultBundlePath(const wstring& dir); wstring BundleMessage(const Bundle& b); } // namespace wg diff --git a/clean/installer/tests/launcher_core_tests.cpp b/clean/installer/tests/launcher_core_tests.cpp index 2e647fde..1d553dab 100644 --- a/clean/installer/tests/launcher_core_tests.cpp +++ b/clean/installer/tests/launcher_core_tests.cpp @@ -14,6 +14,7 @@ #include "wg_core/detect.h" #include "wg_core/gamerules.h" #include "wg_core/launcher.h" +#include "wg_core/logs.h" #include "wg_core/logtail.h" #include "wg_core/optiedition.h" #include "wg_core/pe.h" @@ -44,6 +45,35 @@ string OptionsOf(const string& ini) { string v, s; IniGetFrontEnd(ini, "runtime_ int main() { try { + // ---- 0.6.1: Collect logs in uninstall.exe (no converter data) never claims the map is invalid ---------------- + { + const wstring cl = TempFolder() + L"-collect"; + RemoveTree(cl); + EnsureDir(cl); + const wstring model = Join(cl, L"model.wgcm"); + const wstring tail = L" bytes, not verified here (uninstall.exe has no converter data; use Collect logs in the WrongGPU launcher to verify)"; + require(ModelDataUnverified(model) == L"missing", "uninstall.exe's Model data: missing"); + const string bytes(1234, 'm'); + WriteFileAtomic(model, bytes.data(), bytes.size()); + require(ModelDataUnverified(model) == L"present, 1234" + tail, "uninstall.exe's Model data: present, its size, not verified here"); + HANDLE lock = CreateFileW(model.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); // no sharing: unreadable + const wstring locked = ModelDataUnverified(model); + if (lock != INVALID_HANDLE_VALUE) CloseHandle(lock); + require(lock != INVALID_HANDLE_VALUE && locked.rfind(L"present but unreadable (", 0) == 0 && locked.back() == L')' && locked.size() > 26, + "uninstall.exe's Model data: present but unreadable (the reason)"); + DeleteFileW(model.c_str()); + EnsureDir(model); + require(ModelDataUnverified(model) == L"present but unreadable (a folder, not a file)", "uninstall.exe's Model data: a folder in its place"); + // which process says what: uninstall.exe's table (as restore_main.cpp makes it) has no converter data; WrongGPU.exe's + // has (its lines are the 0.6.0 code, unchanged: the suite's collect comparison checks them byte for byte) + static const EmbeddedData restorer{nullptr, 0, 0, L"", 0, L"", 0, L"0.6.1"}; + static const EmbeddedData launcherLike{nullptr, 0, 901, L"00", 902, L"00", 0, L"0.6.1", L"0.6.1", L"0.6.1"}; + Context rc, lc; + rc.data = &restorer; + lc.data = &launcherLike; + require(!HasConverterData(rc, false) && !HasConverterData(rc, true) && HasConverterData(lc, false), "the converter data: uninstall.exe none, WrongGPU.exe its map"); + RemoveTree(cl); + } // ---- validation ----------------------------------------------------------------------------------------- string n; wstring why; const SettingDef* exec = FindSetting("executor"); diff --git a/clean/installer/tests/run_installer_tests.py b/clean/installer/tests/run_installer_tests.py index cb933071..6550ac94 100644 --- a/clean/installer/tests/run_installer_tests.py +++ b/clean/installer/tests/run_installer_tests.py @@ -398,8 +398,12 @@ def run_all(t, payload_dir): t.check("bundle: system info, logs, record, model source, events", all(n in names for n in ( "system-info.txt", "windows-events.txt", "wronggpu-fsr.log", "wronggpu-fsr.ini", "wronggpu-runtime.log", "wronggpu-report.json", "crash/wronggpu-crash-20261005-1.txt", "install/install.record", "install/model-source.txt", "game-root/wronggpu-root.log")), str(names)) + # 0.6.1: uninstall.exe has no converter data: it says the file is there and its size, never that the map is invalid + # (WrongGPU.exe's own /COLLECT verifies it: test_collect_logs, run by every build) + mbytes = os.path.getsize(t.model_file()) if os.path.isfile(t.model_file()) else -1 t.check("system info: status, FSR DLL, model, GPU", "Game status: Validated" in info and "amd_fidelityfx_dx12.dll: WrongGPU" in info and "ffx_fsr3upscaler_x64.wronggpu-original.dll: the game's" in info and - "Model data: present and matching" in info and "GPU:" in info, info[:1500]) + ("Model data: present, %d bytes, not verified here (uninstall.exe has no converter data; use Collect logs in the WrongGPU launcher to verify)" % mbytes) in info and + "GPU:" in info, info[:1500]) t.check("structured diagnostics and support manifest included", "wronggpu-diagnostics.jsonl" in names and "support-manifest.json" in names, str(names)) if "support-manifest.json" in names: support = json.loads(z.read("support-manifest.json")) @@ -1478,6 +1482,68 @@ def optiscaler_package(t, name): return opti +def test_collect_logs(t): + """0.6.1, run by every build (with or without the direct route: the release builds have none, and the case above that + collects through uninstall.exe is one of the direct route's): Collect logs through the game's uninstall.exe, which has + no converter data, says what it can see of the model file (present with its size, missing, unreadable), never that the + map is invalid; its version line has no empty fields and its file list has WrongGPU's runtime (the install record's + files). WrongGPU.exe's own /COLLECT still verifies the file (present and matching).""" + print("\n[collect logs] uninstall.exe and WrongGPU.exe: the Model data line, in every build") + t.clear_model() + root, b = cyberpunk(t, "collect-restorer", model=t.model.file) + rc = t.run("/DIR=" + root, "/FORCE", "/NOSCAN", *t.route) + t.check("collect logs: installed", rc == 0, "exit %d; %s" % (rc, t.logtext()[-400:])) + un = os.path.join(b, "wronggpu-setup", "uninstall.exe") + model = t.model_file() + tail = " bytes, not verified here (uninstall.exe has no converter data; use Collect logs in the WrongGPU launcher to verify)\r\n" + + def info_of(exe, name): + z = os.path.join(t.work, name) + if os.path.exists(z): + os.remove(z) + code = t.run("/COLLECT", "/DIR=" + b, "/OUT=" + z, exe=exe) + text = zipfile.ZipFile(z).read("system-info.txt").decode("utf-8", "replace") if os.path.isfile(z) else "" + return code, text + + def model_line(text): + at = text.find("Model data: ") + return text[at:text.find("\r\n", at) + 2] if at >= 0 else "" + + rc, info = info_of(un, "collect-un.zip") + size = os.path.getsize(model) if os.path.isfile(model) else -1 + t.check("uninstall.exe /COLLECT: \"Model data: present, bytes, not verified here (...)\", never \"the embedded converter map is invalid\"", + rc == 0 and model_line(info) == "Model data: present, %d%s" % (size, tail) and "converter map is invalid" not in info, (rc, model_line(info))) + t.check("uninstall.exe /COLLECT: no empty build/payload fields; the files list has WrongGPU's runtime", + "(build , payload )" not in info and "(uninstall.exe of this version; build and payload not known here)" in info and + "\r\n wronggpu_runtime.dll " in info, info[:900]) + rc, info2 = info_of(None, "collect-launcher.zip") + t.check("WrongGPU.exe /COLLECT: the model is verified (present and matching), as before", rc == 0 and model_line(info2).startswith("Model data: present and matching ("), + (rc, model_line(info2))) + if t.env.native: # the model file open elsewhere without sharing: unreadable + import ctypes + k32 = ctypes.WinDLL("kernel32", use_last_error=True) + k32.CreateFileW.restype = ctypes.c_void_p + k32.CreateFileW.argtypes = [ctypes.c_wchar_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_void_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_void_p] + k32.CloseHandle.argtypes = [ctypes.c_void_p] + handle = k32.CreateFileW(model, 0x80000000, 0, None, 3, 0, None) # GENERIC_READ, no sharing, OPEN_EXISTING + try: + rc, info = info_of(un, "collect-un-locked.zip") + finally: + k32.CloseHandle(handle) + t.check("uninstall.exe /COLLECT, the model file locked: \"Model data: present but unreadable ()\"", + rc == 0 and model_line(info).startswith("Model data: present but unreadable (") and model_line(info).endswith(")\r\n"), (rc, model_line(info))) + else: + print(" (skipped: the locked model file needs native Windows)") + saved = read(model) + os.remove(model) + rc, info = info_of(un, "collect-un-missing.zip") + t.check("uninstall.exe /COLLECT, no model file: \"Model data: missing\"", rc == 0 and model_line(info) == "Model data: missing\r\n", (rc, model_line(info))) + write(model, saved) + rc = t.uninstall(b) + t.check("collect logs: uninstalled", rc == 0, "exit %d" % rc) + t.clear_model() + + def test_amd_provider(t): """0.4.5.1: the hosted front end lists AMD's FSR versions after WrongGPU's only when it can load an AMD DLL past OptiScaler's redirection (0.4.5 player report: FSR 4 gone from OptiScaler's list and the game's menu). The install @@ -2083,6 +2149,7 @@ def main(): test_game_exe(t) test_anticheat_scope(t) test_amd_provider(t) + test_collect_logs(t) # (0.6.1: every build; the release builds have no direct route) test_asi_plugin(t, os.path.join(prep, "payload")) test_filter_group(t) if direct: