From 4c2ace98eec1dcb2a01230b99451e594512d9831 Mon Sep 17 00:00:00 2001 From: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:37:04 -0800 Subject: [PATCH 1/2] Launcher: PathForGamePrefix tries the drive root when the first folder does not convert The walk that converts the deepest existing folder to a Z: path stopped at the first folder below the drive (cut < 3) and returned the path unchanged, so C:\\F\model.wgcm with only C:\ convertible never tried C:\. The install then warned and wrote the prefix-local path. The walk now keeps the separator on the root ("C:\") and tries it before giving up, and drops the root's trailing '/' so the tail's own separator does not double. Only the UnderWine() branch changes; outside Wine the function still returns the path as it is. Test: wg_core_tests converts C:\con\F\model.wgcm under Wine. Wine converts a single missing folder but not a DOS device name like CON, so the first folder fails while C:\ exists. Before the fix: FAILED: PathForGamePrefix under Wine: a Z: path when only the drive's root exists (wg-core-tests, after 81 checks). After: wg-core-tests 92 checks passed (main: 91). Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- clean/installer/src/wg_core/util.cpp | 9 ++++++--- clean/installer/tests/wg_core_tests.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/clean/installer/src/wg_core/util.cpp b/clean/installer/src/wg_core/util.cpp index 0a20f887..cc7ae773 100644 --- a/clean/installer/src/wg_core/util.cpp +++ b/clean/installer/src/wg_core/util.cpp @@ -257,12 +257,15 @@ wstring PathForGamePrefix(const wstring& path) { wstring head = path, tail; char* u = nullptr; while (!(u = unixName(head.c_str()))) { + if (head.size() <= 3) return path; const size_t cut = head.find_last_of(L"\\/"); - if (cut == wstring::npos || cut < 3) return path; + if (cut == wstring::npos || cut < 2) return path; tail = head.substr(cut) + tail; - head.resize(cut); + head.resize(cut == 2 ? 3 : cut); // keep the separator on a drive root: "C:\" converts, "C:" alone is not tried } - wstring z = L"Z:" + FromUtf8(u) + tail; + string unixPath = u; + if (!tail.empty() && unixPath.size() > 1 && unixPath.back() == '/') unixPath.pop_back(); // a root's Unix name ends in '/'; the tail brings its own separator + wstring z = L"Z:" + FromUtf8(unixPath.c_str()) + tail; HeapFree(GetProcessHeap(), 0, u); for (wchar_t& c : z) if (c == L'/') c = L'\\'; diff --git a/clean/installer/tests/wg_core_tests.cpp b/clean/installer/tests/wg_core_tests.cpp index dc16690f..e4429e16 100644 --- a/clean/installer/tests/wg_core_tests.cpp +++ b/clean/installer/tests/wg_core_tests.cpp @@ -321,6 +321,13 @@ int main() { if (UnderWine()) require(StartsWithI(deep, L"Z:\\") && deep.size() > deepTail.size() && deep.compare(deep.size() - deepTail.size(), deepTail.size(), deepTail) == 0, "PathForGamePrefix under Wine: a Z: path for missing folders too"); + // only the drive's root converts (Wine cannot make a Unix name for a DOS device name like CON, so the first folder fails too): + // the walk still reaches the root, so the path is converted + const wstring rootTail = L"\\con\\F\\model.wgcm", atRoot = PathForGamePrefix(L"C:" + rootTail); + if (UnderWine()) + require(StartsWithI(atRoot, L"Z:\\") && atRoot.size() > rootTail.size() && atRoot.compare(atRoot.size() - rootTail.size(), rootTail.size(), rootTail) == 0 && + atRoot.find(L"\\\\") == wstring::npos, + "PathForGamePrefix under Wine: a Z: path when only the drive's root exists"); require(PathForGamePrefix(L"").empty(), "PathForGamePrefix of an empty path"); // a drive the prefix doesn't map: no Z: path can be made, the path comes back as it is (the install then // reports it, install.cpp ModelPathForGame) From 0dbd2c1be34480b377eb13bf908232ec7144f197 Mon Sep 17 00:00:00 2001 From: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:38:24 -0800 Subject: [PATCH 2/2] Launcher tests: the Wine DetectGpu check follows LinuxRdna4Name instead of probing cards itself The under-Wine part of wg_core_tests.cpp probed card0 to card15 on its own to decide whether Linux reports an RDNA 4 card, and compared that with LinuxRdna4Name(). LinuxRdna4Name looks at every card in the folder, so the two disagreed when the only RDNA 4 card is card16 or later. The duplicate probe is dropped rather than made to enumerate the same way: a second enumerator in the test would only repeat the code under test. Which cards LinuxRdna4Name looks at is already checked on the made-up folder (card20 and card17 in the same file). The under-Wine block now only checks that DetectGpu follows LinuxRdna4Name: when it names a card, DetectGpu reports an RDNA 4 AMD card. The made-up folder's card20 check was seen to fail with DrmCards limited to card15 (FAILED: LinuxRdna4Name: a card numbered 20, reported as not confirmed), so card16 and later stay covered; the change was reverted. The probe's check is gone, so wg-core-tests counts one less: 91 on main, 90 with this commit alone, 91 on top of the drive-root commit (92 -> 91). Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- clean/installer/tests/wg_core_tests.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/clean/installer/tests/wg_core_tests.cpp b/clean/installer/tests/wg_core_tests.cpp index e4429e16..d0663270 100644 --- a/clean/installer/tests/wg_core_tests.cpp +++ b/clean/installer/tests/wg_core_tests.cpp @@ -227,24 +227,13 @@ int main() { card(L"card17", "0x1002\n", "0x7550 \n"); // two RDNA 4 cards: the lower number first require(Contains(LinuxRdna4Name(drm), L"7550"), "LinuxRdna4Name: cards in number order"); } - // under Wine an RDNA 4 card that Linux reports is found even when Wine's own DXGI names an old Radeon + // under Wine an RDNA 4 card that Linux reports is found even when Wine's own DXGI names an old Radeon. Which cards + // LinuxRdna4Name looks at is checked above on the made-up folder (card20 and card17 included); here DetectGpu must follow it. if (UnderWine()) { - auto sysfs = [](const wstring& p) { // the C runtime reads to the end of file (sysfs reports 4096 bytes) - string s; - if (FILE* f = _wfopen(p.c_str(), L"rb")) { char b[64]; size_t n; while ((n = fread(b, 1, sizeof b, f)) > 0) s.append(b, n); fclose(f); } - return s; - }; - bool linuxRdna4 = false; - for (int i = 0; i < 16 && !linuxRdna4; ++i) { - const wstring dev = L"Z:\\sys\\class\\drm\\card" + std::to_wstring(i) + L"\\device\\"; - const unsigned long v = strtoul(sysfs(dev + L"vendor").c_str(), nullptr, 16), id = strtoul(sysfs(dev + L"device").c_str(), nullptr, 16); - linuxRdna4 = v == 0x1002 && (id == 0x7550 || id == 0x7551 || id == 0x7590 || id == 0x7591); - } const wstring fromLinux = LinuxRdna4Name(); const GpuInfo gpu = DetectGpu(); - std::wcout << L"under Wine: Linux reports RDNA 4: " << linuxRdna4 << L"; LinuxRdna4Name: \"" << fromLinux << L"\"; DetectGpu: " << gpu.name << L" (rdna4 " << gpu.rdna4 << L")\n"; - require(fromLinux.empty() != linuxRdna4, "LinuxRdna4Name: the RDNA 4 card Linux reports, and only then"); - if (linuxRdna4) require(gpu.amd && gpu.rdna4, "DetectGpu under Wine: the RDNA 4 card Linux reports"); + std::wcout << L"under Wine: LinuxRdna4Name: \"" << fromLinux << L"\"; DetectGpu: " << gpu.name << L" (rdna4 " << gpu.rdna4 << L")\n"; + if (!fromLinux.empty()) require(gpu.amd && gpu.rdna4, "DetectGpu under Wine: the RDNA 4 card Linux reports"); } // a store's launch exe is a hint only: a launcher stub (REDprelauncher.exe) gives way to the exe discovery