Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(winecx): WineCX 11.17 (runtime 4.7.3) beside 11.15

raymondchinsb9db08a4fd65
diff --git a/app/Package.swift b/app/Package.swift
index b756b75..9c92f22 100644
--- a/app/Package.swift
+++ b/app/Package.swift
@@ -45,6 +45,11 @@ let package = Package(
.copy("Resources/detour32-winecx-11.15.bin"),
.copy("Resources/winemac-winecx-11.15.so"),
.copy("Resources/winebus-winecx-11.15.so"),
+ .copy("Resources/detour2-winecx-11.17.bin"),
+ .copy("Resources/detour32-winecx-11.17.bin"),
+ .copy("Resources/winemac-winecx-11.17.so"),
+ .copy("Resources/winebus-winecx-11.17.so"),
+ .copy("Resources/winebus-winecx-11.17.sys"),
.copy("Resources/libSDL2-2.0.0.dylib"),
],
swiftSettings: [.swiftLanguageMode(.v6)]
diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift
index faf657a..fe9460c 100644
--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift
+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift
@@ -1,6 +1,7 @@
// The second free engine: WineCX, CodeWeavers' LGPL CrossOver 26.3 Wine changes rebased
-// onto wine-11.15 by dappermint (github.com/dappermint/winecx, wine1115 branch) and built
-// into a Whisky runtime by dappermint/winecx-gptk's CI. Over the WineHQ engine it adds
+// onto upstream Wine by dappermint (github.com/dappermint/winecx) and built into a Whisky
+// runtime by dappermint/winecx-gptk's CI. The current release is Wine 11.17; the 11.15 one
+// stays installable and selectable beside it. Over the WineHQ engine it adds
// msync and the CrossOver hooks Apple's D3DMetal needs. DXMT (the same master build as the
// WineHQ engine, not the archive's 0.80) and DXVK are backends a game opts into; Wine's own
// Direct3D, or D3DMetal once a user's Game Porting Toolkit is linked, is the builtin.
@@ -54,17 +55,152 @@ struct WinecxRelease: Sendable {
// dlopens by leaf name, which dyld finds through winebus.so's @loader_path/../../
// rpath, i.e. in lib/.
let gamepad: [WinecxBundledFile]
+ // The runner build this release unpacks to, keyed by its pinned loader, and the ntdll
+ // detours for it (NtdllPatcher.byBuild).
+ let runner: RunnerBuild
+ let ntdllPatches: [NtdllPatch]
}
enum FreeEngineWinecx {
static let step = "Download free WineCX engine"
+ // What the WineCX row installs and what the notproton-winecx tool runs once it is
+ // installed. The 11.15 release stays a separate build with its own runner and tool.
+ static let current = v1117
+ static let previous = v1115
+ static let releases = [current, previous]
+
+ // The runner build of the current release.
+ static var runnerBuild: RunnerBuild { current.runner }
+ static var ntdllPatches: [NtdllPatch] { current.ntdllPatches }
+ static var runnerBuilds: [RunnerBuild] { releases.map(\.runner) }
+
+ static func release(build id: String) -> WinecxRelease? {
+ releases.first { $0.build == id }
+ }
+
+ // The release whose pinned loader a tree carries, which is what makes it that WineCX.
+ static func release(forRoot root: URL) -> WinecxRelease? {
+ let loader = Clean.copy(of: CrossOverSource.unixLoader(inRoot: root))
+ guard let hash = Digest.sha256IfPresent(loader) else { return nil }
+ return releases.first { $0.runner.loaderSHA256 == hash }
+ }
+
+ // DXVK-macOS 1.10.3 is the same repack in both runtimes. nvapi64 and nvngx are left out
+ // for the reason FreeEngine gives. The repack ships no dxgi, and its DLLs carry no
+ // builtin marker.
+ private static let dxvk: [WinecxBackendFile] = [
+ WinecxBackendFile(source: "DXVK/x64/d3d10core.dll", destination: "dxvk/x86_64-windows/d3d10core.dll",
+ sha256: "0fa08bba860c63e3abeeabfc96d0e7aa327411a975f8f23d2dc63594ef5f796e"),
+ WinecxBackendFile(source: "DXVK/x64/d3d11.dll", destination: "dxvk/x86_64-windows/d3d11.dll",
+ sha256: "0ff0b0835dde29556bd01dfce7b1ae348d7f229cb1e1a37cc71ea1a028beeca4"),
+ WinecxBackendFile(source: "DXVK/x32/d3d10core.dll", destination: "dxvk/i386-windows/d3d10core.dll",
+ sha256: "2277187a4e13fc2049fe28cb8dd05b34b48c68031c386c3597ba0e18b0c3d327"),
+ WinecxBackendFile(source: "DXVK/x32/d3d11.dll", destination: "dxvk/i386-windows/d3d11.dll",
+ sha256: "f79d417f675d00008375eb4ea2318af6fcd0b27971d604d3cf345a0dcfa998a0"),
+ ]
+
+ // SDL 2.32.8 (zlib license, NOTICE), the WineHQ engine runner's copy signed ad hoc,
+ // since a release build strips unsigned Mach-O resources and would break the pin.
+ private static let sdl = WinecxBundledFile(
+ resource: "libSDL2-2.0.0", ext: "dylib", path: "lib/libSDL2-2.0.0.dylib",
+ sha256: "605724f463875e945ca4a79a1db7bf35384d912fa5387f3042a27a42e878db19")
+
+ // runtime 4.7.3: winecx e0aa380 (Wine 11.17), built by winecx-gptk 0bf3eab, minos 26.0.
+ // Over 4.5.125 it carries the later msync fixes, kernelbase's FlsGetValue2 for Unity
+ // 6000.3, dxgi's CheckInterfaceSupport, the winemac client-view flush fix and the
+ // Wine 11.16 and 11.17 merges.
+ static let v1117 = WinecxRelease(
+ build: "winecx-11.17",
+ runtime: "4.7.3",
+ archive: "Libraries.tar.gz",
+ sha256: "a4b5d63493f80698cce5cad8e7212d9a51c8292037b00c478f4652636fcfd331",
+ bases: [
+ URL(string: "https://github.com/dappermint/winecx-gptk/releases/download/runtime-v4.7.3")!,
+ ],
+ bundleName: "WineCX 11.17.app",
+ wineTree: "Libraries/Wine",
+ backends: dxvk,
+ renderer: FreeEngine.dxmt,
+ d3dStock: [
+ "d3d10.dll": "9a9efe0cdaad2f41b0c5fe0f216c97720cdf82b21fbbb6e59f361112cdc4ccc3",
+ "d3d11.dll": "0a3d9e758a491c99d34dce1aa4ee744671d1faeef498c6dfc5d26eecb9dff7ec",
+ "d3d12.dll": "974e132bcafb150bb97f33fa63199346a3b942b3e09d6d06c0cbc1755f30afa5",
+ "dxgi.dll": "6f7cf2d60c991ad26b60316935bb9d3587b0c83cc01991bf55564bcfbfa47e09",
+ ],
+ macDriver: "aa192f846ad15d56de200fc92752eaf2d455700846ae2cf1ccc7b27b535f1c00",
+ // winebus.so: winecx e0aa380 built with SONAME_LIBSDL2. winebus.sys: the same tree's
+ // PE half with sdl_bus_load_mappings fixed (winebus-patch/), so a winebus "map" key
+ // no longer writes past the array and takes every pad down with it.
+ gamepad: [
+ WinecxBundledFile(resource: "winebus-winecx-11.17", ext: "so", path: "lib/wine/x86_64-unix/winebus.so",
+ sha256: "6223c035c824c90708abbc3e733f8d1d6ed6b8b4e9a3e1a5c813493ceba50473"),
+ WinecxBundledFile(resource: "winebus-winecx-11.17", ext: "sys",
+ path: "lib/wine/x86_64-windows/winebus.sys",
+ sha256: "da108d1c3788fa32807ef08c4d26d8a89812c230317ffa7ba5111e126bda607c"),
+ sdl,
+ ],
+ runner: RunnerBuild(
+ bundleVersion: "winecx-11.17",
+ releaseVersion: "WineCX 11.17",
+ flavor: nil,
+ loaderSHA256: "a680abba30b4888355adb39d8b62255e43546eb33d163897260627f7741ef648",
+ cleanNtdll: [
+ .x86_64Windows: "8b32c9f6f71b4f15fcaccb19b0f2adab9391ae73ad539cae9e136f8ee7d24128",
+ .i386Windows: "cc8a9035cea0e26c5d333ef220f1becefc27ae44d2cdcdaea3278e8739d26fd9",
+ ],
+ patchedNtdll: [
+ .x86_64Windows: "4573d521671a48212670e7543aa9ebf0921e383dada69477f677f435df2bef5a",
+ .i386Windows: "8ad83740df2da5e79ed435e4bc57e82b4b6a4b984fbec73e1160ca81dfce1b44",
+ ],
+ tools: [
+ CompatTool(name: "notproton-winecx", flavor: .rosetta, display: "WineCX 11.17 (msync, D3DMetal)"),
+ ],
+ isFree: true
+ ),
+ ntdllPatches: [
+ // From ntdll-patch/resolve.py on the archive's ntdlls, payloads from build.sh and
+ // build32.sh with the variant winecx-11.17. Both detours fit in .text padding.
+ NtdllPatch(
+ arch: .x86_64Windows,
+ payloadResource: "detour2-winecx-11.17",
+ payloadSHA256: "e1bbd185b19de3e23d627ae3a8bf25ed1b767bff5690102c5312a5ed3813e736",
+ caveRVA: 0x83360,
+ payloadRVA: 0x83360,
+ hooks: [
+ NtdllHook(rva: 0x52de3,
+ stolen: [0x48, 0x83, 0xbc, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x00]),
+ ],
+ caveSize: 3232,
+ cavePad: 0x00,
+ machine: 0x8664,
+ magic: 0x20b,
+ imageBase: 0x1_7000_0000
+ ),
+ NtdllPatch(
+ arch: .i386Windows,
+ payloadResource: "detour32-winecx-11.17",
+ payloadSHA256: "0676104e0bd56c4a1e8c473d9cbcd21fb2ba105fc7dc6cf5a70d37692c129e28",
+ caveRVA: 0x808a0,
+ payloadRVA: 0x808a0,
+ hooks: [
+ NtdllHook(rva: 0x4f880, stolen: [0xf6, 0x45, 0xb4, 0x02, 0x75, 0x29]),
+ ],
+ caveSize: 1888,
+ cavePad: 0x00,
+ machine: 0x14c,
+ magic: 0x10b,
+ imageBase: 0x7bc0_0000
+ ),
+ ]
+ )
+
// runtime 4.5.125 is the last wine1115 build (winecx 5b45f45, built from winecx-gptk
- // 7a0349b, minos 26.0). It is the 11.15 the bridge components are built against, and
- // the only 11.15 runtime with the msync spin fixes. The same bytes are mirrored on
- // dappermint/Whisky, which is what Whisky itself downloads.
- static let current = WinecxRelease(
+ // 7a0349b, minos 26.0). The same bytes are mirrored on dappermint/Whisky, which is what
+ // Whisky itself downloads. Its tool is notproton-winecx-11.15, and it answers to
+ // notproton-winecx while 11.17 is not installed (CompatTool.standsInFor).
+ static let v1115 = WinecxRelease(
build: "winecx-11.15",
runtime: "4.5.125",
archive: "Libraries.tar.gz",
@@ -75,18 +211,7 @@ enum FreeEngineWinecx {
],
bundleName: "WineCX 11.15.app",
wineTree: "Libraries/Wine",
- // nvapi64 and nvngx are left out for the reason FreeEngine gives. The DXVK-macOS
- // 1.10.3 repack ships no dxgi, and its DLLs carry no builtin marker.
- backends: [
- WinecxBackendFile(source: "DXVK/x64/d3d10core.dll", destination: "dxvk/x86_64-windows/d3d10core.dll",
- sha256: "0fa08bba860c63e3abeeabfc96d0e7aa327411a975f8f23d2dc63594ef5f796e"),
- WinecxBackendFile(source: "DXVK/x64/d3d11.dll", destination: "dxvk/x86_64-windows/d3d11.dll",
- sha256: "0ff0b0835dde29556bd01dfce7b1ae348d7f229cb1e1a37cc71ea1a028beeca4"),
- WinecxBackendFile(source: "DXVK/x32/d3d10core.dll", destination: "dxvk/i386-windows/d3d10core.dll",
- sha256: "2277187a4e13fc2049fe28cb8dd05b34b48c68031c386c3597ba0e18b0c3d327"),
- WinecxBackendFile(source: "DXVK/x32/d3d11.dll", destination: "dxvk/i386-windows/d3d11.dll",
- sha256: "f79d417f675d00008375eb4ea2318af6fcd0b27971d604d3cf345a0dcfa998a0"),
- ],
+ backends: dxvk,
// winecx's winemac.so already exports the macdrv_functions DXMT reads, and that
// table is unchanged between 0.80 and master, so DXMT needs no winemac-patch.
renderer: FreeEngine.dxmt,
@@ -97,76 +222,72 @@ enum FreeEngineWinecx {
"dxgi.dll": "f1f24da777c65a583b29f74475c6a9464da35068d75def6cee806268def9ecbb",
],
macDriver: "76d8f93839386f37e8badf0c82bb31b5ead22ac580f17896f9d2a729af0fc147",
- // winebus.so: winecx 5b45f45 built with SONAME_LIBSDL2 (docs/WINECX.md). libSDL2:
- // SDL 2.32.8 (zlib license, NOTICE), the WineHQ engine runner's copy signed ad hoc,
- // since a release build strips unsigned Mach-O resources and would break the pin.
+ // winebus.so: winecx 5b45f45 built with SONAME_LIBSDL2 (docs/WINECX.md).
gamepad: [
WinecxBundledFile(resource: "winebus-winecx-11.15", ext: "so", path: "lib/wine/x86_64-unix/winebus.so",
sha256: "1bc53184f5d026ab84a26cf6ef721348fc3b028c019ff969e69eb6cf9b9d1af9"),
- WinecxBundledFile(resource: "libSDL2-2.0.0", ext: "dylib", path: "lib/libSDL2-2.0.0.dylib",
- sha256: "605724f463875e945ca4a79a1db7bf35384d912fa5387f3042a27a42e878db19"),
- ]
- )
-
- // Appended to SupportedRunners.all. The hash-pinned loader is what makes it free, so a
- // CrossOver install can never be taken for it.
- static let runnerBuild = RunnerBuild(
- bundleVersion: "winecx-11.15",
- releaseVersion: "WineCX 11.15",
- flavor: nil,
- loaderSHA256: "a4b677428a6834f97f536a84d32c5da982c9a449e5d483c6be3d1c9b8f308998",
- cleanNtdll: [
- .x86_64Windows: "5710d16382c7a822ed8b1cba58d95fd86fe01905f039c296ca7224abff8f98e8",
- .i386Windows: "e1b208073c804a443e64ada577899d96a5c8eaee435813e4a30e0d143bca6e3c",
+ sdl,
],
- patchedNtdll: [
- .x86_64Windows: "4efd956e573726777827cddaa89ef3b7f72d6cfd7b8e2049e41f5f5bdf4a6306",
- .i386Windows: "23ee72664f172d38d76ecb8969d5c5af7e6828864dfe298338ed0e773910bc5d",
- ],
- tools: [
- CompatTool(name: "notproton-winecx", flavor: .rosetta, display: "WineCX 11.15 (msync, D3DMetal)"),
- ],
- isFree: true
- )
-
- // Appended to NtdllPatcher.byBuild. From ntdll-patch/resolve.py on the archive's ntdlls,
- // payloads from build.sh and build32.sh with the variant winecx-11.15. The x86_64 hook is
- // the CrossOver one (cmp [rsp+0xf0], 0), and its .text padding holds the detour; the
- // i386 padding does not, so that one gets the appended section.
- static let ntdllPatches: [NtdllPatch] = [
- NtdllPatch(
- arch: .x86_64Windows,
- payloadResource: "detour2-winecx-11.15",
- payloadSHA256: "fde56854b9a7a32da19babe2427d19ff6a6b83de1917fe8d32aaddd2991fc6b9",
- caveRVA: 0x82b20,
- payloadRVA: 0x82b20,
- hooks: [
- NtdllHook(rva: 0x52e43,
- stolen: [0x48, 0x83, 0xbc, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x00]),
+ // The hash-pinned loader is what makes it free, so a CrossOver install can never be
+ // taken for it.
+ runner: RunnerBuild(
+ bundleVersion: "winecx-11.15",
+ releaseVersion: "WineCX 11.15",
+ flavor: nil,
+ loaderSHA256: "a4b677428a6834f97f536a84d32c5da982c9a449e5d483c6be3d1c9b8f308998",
+ cleanNtdll: [
+ .x86_64Windows: "5710d16382c7a822ed8b1cba58d95fd86fe01905f039c296ca7224abff8f98e8",
+ .i386Windows: "e1b208073c804a443e64ada577899d96a5c8eaee435813e4a30e0d143bca6e3c",
],
- caveSize: 1248,
- cavePad: 0x00,
- machine: 0x8664,
- magic: 0x20b,
- imageBase: 0x1_7000_0000
- ),
- NtdllPatch(
- arch: .i386Windows,
- payloadResource: "detour32-winecx-11.15",
- payloadSHA256: "37daf5f795535df91bc8fcbd356f22f4fd1ab379ec4acc97ddff44037d265556",
- caveRVA: 0xb9000,
- payloadRVA: 0xb9000,
- hooks: [
- NtdllHook(rva: 0x4f7c0, stolen: [0xf6, 0x45, 0xb4, 0x02, 0x75, 0x29]),
+ patchedNtdll: [
+ .x86_64Windows: "4efd956e573726777827cddaa89ef3b7f72d6cfd7b8e2049e41f5f5bdf4a6306",
+ .i386Windows: "23ee72664f172d38d76ecb8969d5c5af7e6828864dfe298338ed0e773910bc5d",
],
- caveSize: 0x1000,
- cavePad: 0x00,
- machine: 0x14c,
- magic: 0x10b,
- imageBase: 0x7bc0_0000,
- placement: .section
+ tools: [
+ CompatTool(name: "notproton-winecx-11.15", flavor: .rosetta, display: "WineCX 11.15 (msync, D3DMetal)",
+ standsInFor: "notproton-winecx"),
+ ],
+ isFree: true
),
- ]
+ // From ntdll-patch/resolve.py on the archive's ntdlls, payloads from build.sh and
+ // build32.sh with the variant winecx-11.15. The x86_64 hook is the CrossOver one
+ // (cmp [rsp+0xf0], 0), and its .text padding holds the detour; the i386 padding does
+ // not, so that one gets the appended section.
+ ntdllPatches: [
+ NtdllPatch(
+ arch: .x86_64Windows,
+ payloadResource: "detour2-winecx-11.15",
+ payloadSHA256: "fde56854b9a7a32da19babe2427d19ff6a6b83de1917fe8d32aaddd2991fc6b9",
+ caveRVA: 0x82b20,
+ payloadRVA: 0x82b20,
+ hooks: [
+ NtdllHook(rva: 0x52e43,
+ stolen: [0x48, 0x83, 0xbc, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x00]),
+ ],
+ caveSize: 1248,
+ cavePad: 0x00,
+ machine: 0x8664,
+ magic: 0x20b,
+ imageBase: 0x1_7000_0000
+ ),
+ NtdllPatch(
+ arch: .i386Windows,
+ payloadResource: "detour32-winecx-11.15",
+ payloadSHA256: "37daf5f795535df91bc8fcbd356f22f4fd1ab379ec4acc97ddff44037d265556",
+ caveRVA: 0xb9000,
+ payloadRVA: 0xb9000,
+ hooks: [
+ NtdllHook(rva: 0x4f7c0, stolen: [0xf6, 0x45, 0xb4, 0x02, 0x75, 0x29]),
+ ],
+ caveSize: 0x1000,
+ cavePad: 0x00,
+ machine: 0x14c,
+ magic: 0x10b,
+ imageBase: 0x7bc0_0000,
+ placement: .section
+ ),
+ ]
+ )
// Runtime contract with compat_run.sh: the engine root says it can run msync, and the
// backends sit outside lib/wine, whose Direct3D builtins are Wine's own or, with
@@ -174,9 +295,9 @@ enum FreeEngineWinecx {
static let backendsPath = "lib/notproton-backends"
static let msyncMarkerPath = ".notproton-msync"
- static var downloads: URL {
+ static func downloads(for release: WinecxRelease = current) -> URL {
SupportPaths.home.appending(
- path: "Library/Caches/\(SupportPaths.supportDirName)/engines/winecx-\(current.runtime)",
+ path: "Library/Caches/\(SupportPaths.supportDirName)/engines/winecx-\(release.runtime)",
directoryHint: .isDirectory
)
}
@@ -247,7 +368,7 @@ enum FreeEngineWinecx {
) async throws -> CrossOverInstall {
let archive = try await PinnedDownload.obtain(
file: release.archive, sha256: release.sha256, bases: release.bases,
- into: downloads, step: step, source: "GitHub",
+ into: downloads(for: release), step: step, source: "GitHub",
report: { report(.downloading($0)) }
)
let renderer = try await PinnedDownload.obtain(
diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift
index fe9e405..e9324e9 100644
--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift
+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift
@@ -309,9 +309,10 @@ enum WinecxD3DMetal {
// its own D3DMetal and is never written to.
@discardableResult
static func refresh(
- root: URL, roots: [URL] = searchRoots(), stock: [String: String] = FreeEngineWinecx.current.d3dStock
+ root: URL, roots: [URL] = searchRoots(), stock: [String: String]? = nil
) -> Payload? {
- guard isWinecx(root: root) else { return nil }
+ guard let release = FreeEngineWinecx.release(forRoot: root) else { return nil }
+ let stock = stock ?? release.d3dStock
guard let payload = locate(in: roots) else {
unlink(root: root)
return nil
@@ -328,7 +329,6 @@ enum WinecxD3DMetal {
}
static func isWinecx(root: URL) -> Bool {
- let loader = Clean.copy(of: CrossOverSource.unixLoader(inRoot: root))
- return Digest.sha256IfPresent(loader) == FreeEngineWinecx.runnerBuild.loaderSHA256
+ FreeEngineWinecx.release(forRoot: root) != nil
}
}
diff --git a/app/Sources/NotProtonApp/Model/NtdllPatcher.swift b/app/Sources/NotProtonApp/Model/NtdllPatcher.swift
index c8c8713..7c9a7ef 100644
--- a/app/Sources/NotProtonApp/Model/NtdllPatcher.swift
+++ b/app/Sources/NotProtonApp/Model/NtdllPatcher.swift
@@ -285,8 +285,7 @@ enum NtdllPatcher {
imageBase: 0x7bc0_0000
),
],
- FreeEngineWinecx.runnerBuild.id: FreeEngineWinecx.ntdllPatches,
- ]
+ ].merging(FreeEngineWinecx.releases.map { ($0.runner.id, $0.ntdllPatches) }) { pinned, _ in pinned }
static func patches(for build: RunnerBuild) -> [NtdllPatch] {
byBuild[build.id] ?? []
diff --git a/app/Sources/NotProtonApp/Model/SupportedRunner.swift b/app/Sources/NotProtonApp/Model/SupportedRunner.swift
index 8651419..a43a122 100644
--- a/app/Sources/NotProtonApp/Model/SupportedRunner.swift
+++ b/app/Sources/NotProtonApp/Model/SupportedRunner.swift
@@ -73,6 +73,10 @@ struct CompatTool: Sendable, Hashable, Identifiable {
let flavor: Flavor
let display: String
+ // A tool name this one serves while no installed build serves it, so games mapped to it
+ // keep their tool when the build that now owns the name is not installed yet.
+ var standsInFor: String? = nil
+
var id: String { name }
var prefixArch: PrefixArch { flavor == .fex ? .arm64 : .x86_64 }
@@ -92,7 +96,8 @@ enum SupportedRunners {
// First entry is what windows-only games get when Steam has no mapping.
static let toolPreference = [
legacyToolName, "notproton-fex", "notproton-fex-rosetta", "notproton-preview",
- "notproton-fex-41069", "notproton-fex-rosetta-41069", "notproton-preview-41069", "notproton-26.3", "notproton-winecx", "notproton-winehq",
+ "notproton-fex-41069", "notproton-fex-rosetta-41069", "notproton-preview-41069", "notproton-26.3", "notproton-winecx",
+ "notproton-winecx-11.15", "notproton-winehq",
]
static let legacyToolName = "notproton"
@@ -111,9 +116,12 @@ enum SupportedRunners {
case .build(let id): id
case .nobody: nil
}
- let served = all.filter { installed.contains($0.id) }.flatMap { build in
+ let builds = all.filter { installed.contains($0.id) }
+ let owned = Set(builds.flatMap(\.tools).map(\.name))
+ let served = builds.flatMap { build in
build.tools.enumerated().map { index, tool in
- let name = build.id == holder && index == 0 ? legacyToolName : tool.name
+ var name = build.id == holder && index == 0 ? legacyToolName : tool.name
+ if let standIn = tool.standsInFor, !owned.contains(standIn) { name = standIn }
return InstalledTool(
tool: CompatTool(name: name, flavor: tool.flavor, display: tool.display), build: build.id
)
@@ -251,8 +259,7 @@ enum SupportedRunners {
],
isFree: true
),
- FreeEngineWinecx.runnerBuild,
- ]
+ ] + FreeEngineWinecx.runnerBuilds
static func build(loaderSHA256 hash: String) -> RunnerBuild? {
all.lazy.compactMap { $0.matching(loaderSHA256: hash) }.first
diff --git a/app/Sources/NotProtonApp/Resources/detour2-winecx-11.17.bin b/app/Sources/NotProtonApp/Resources/detour2-winecx-11.17.bin
new file mode 100644
index 0000000..710d511
Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/detour2-winecx-11.17.bin differ
diff --git a/app/Sources/NotProtonApp/Resources/detour32-winecx-11.17.bin b/app/Sources/NotProtonApp/Resources/detour32-winecx-11.17.bin
new file mode 100644
index 0000000..c1752de
Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/detour32-winecx-11.17.bin differ
diff --git a/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.so b/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.so
new file mode 100755
index 0000000..7f524c2
Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.so differ
diff --git a/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.sys b/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.sys
new file mode 100755
index 0000000..6c7f5c9
Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/winebus-winecx-11.17.sys differ
diff --git a/app/Sources/NotProtonApp/Resources/winemac-winecx-11.17.so b/app/Sources/NotProtonApp/Resources/winemac-winecx-11.17.so
new file mode 100755
index 0000000..8d9ae52
Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/winemac-winecx-11.17.so differ
diff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swift
index c0beec7..dae3c80 100644
--- a/app/Sources/NotProtonApp/SystemStatus.swift
+++ b/app/Sources/NotProtonApp/SystemStatus.swift
@@ -75,11 +75,12 @@ enum FreeEngineStatus {
// Each free engine is judged against its own pins.
static func isCurrent(_ install: CrossOverInstall) -> Bool {
- switch buildID(of: install) {
- case FreeEngine.current.build: FreeEngine.hasRenderer(root: install.crossOverRoot)
- case FreeEngineWinecx.current.build: FreeEngineWinecx.hasBackends(root: install.crossOverRoot)
- default: false
+ guard let id = buildID(of: install) else { return false }
+ if id == FreeEngine.current.build { return FreeEngine.hasRenderer(root: install.crossOverRoot) }
+ if let release = FreeEngineWinecx.release(build: id) {
+ return FreeEngineWinecx.hasBackends(root: install.crossOverRoot, release: release)
}
+ return false
}
static func capture(_ installs: [CrossOverInstall]) -> (current: Set<String>, gptkSource: String?) {
@@ -88,7 +89,7 @@ enum FreeEngineStatus {
for install in installs where install.isFree {
guard let id = buildID(of: install) else { continue }
if isCurrent(install) { current.insert(id) }
- if id == FreeEngineWinecx.current.build, gptk == nil {
+ if FreeEngineWinecx.release(build: id) != nil, gptk == nil {
gptk = WinecxD3DMetal.linkedSource(root: install.crossOverRoot)
}
}
@@ -471,10 +472,13 @@ final class SystemStatus {
runners: URL = SupportPaths.runners,
roots: [URL] = WinecxD3DMetal.searchRoots()
) -> String? {
- let engine = SupportPaths.crossOverRoot(inBundle: FreeEngineWinecx.bundle(engines: engines))
- let runner = SupportPaths.clonedRoot(forBuild: FreeEngineWinecx.current.build, runners: runners)
+ // Every WineCX release on disk, engine and runner, so each carries the same Direct3D.
+ let trees = FreeEngineWinecx.releases.flatMap { release in
+ [SupportPaths.crossOverRoot(inBundle: FreeEngineWinecx.bundle(for: release, engines: engines)),
+ SupportPaths.clonedRoot(forBuild: release.build, runners: runners)]
+ }
var linked: String?
- for root in [engine, runner] {
+ for root in trees {
if let payload = WinecxD3DMetal.refresh(root: root, roots: roots) {
linked = linked ?? payload.libRoot.standardizedFileURL.path(percentEncoded: false)
}
diff --git a/app/Sources/NotProtonApp/Views/StatusView.swift b/app/Sources/NotProtonApp/Views/StatusView.swift
index 7a0a632..0249779 100644
--- a/app/Sources/NotProtonApp/Views/StatusView.swift
+++ b/app/Sources/NotProtonApp/Views/StatusView.swift
@@ -560,7 +560,8 @@ struct StatusView: View {
let outdated = winecx == .outdated
StatusRow(
title: "WineCX Engine",
- value: "WineCX 11.15 with msync and D3DMetal, no CrossOver license needed.",
+ value: "\(FreeEngineWinecx.current.runner.releaseVersion) with msync and D3DMetal, "
+ + "no CrossOver license needed.",
tone: outdated ? .warning : .neutral,
action: StatusAction(
label: outdated ? "Update & Set Up" : "Download & Set Up",
diff --git a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift
index 6eacf6f..643dbc2 100644
--- a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift
+++ b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift
@@ -12,25 +12,53 @@ struct FreeEngineWinecxTests {
return url
}
- @Test("The pinned release names a free build NotProton knows how to patch")
- func releaseIsSupported() throws {
- let build = try #require(SupportedRunners.build(id: FreeEngineWinecx.current.build))
- #expect(build == FreeEngineWinecx.runnerBuild)
+ @Test("Each pinned release names a free build NotProton knows how to patch",
+ arguments: FreeEngineWinecx.releases.map(\.build))
+ func releaseIsSupported(id: String) throws {
+ let release = try #require(FreeEngineWinecx.release(build: id))
+ let build = try #require(SupportedRunners.build(id: id))
+ #expect(build == release.runner)
#expect(build.isFree)
#expect(Set(NtdllPatcher.patches(for: build).map(\.arch)) == [.x86_64Windows, .i386Windows])
+ #expect(NtdllPatcher.patches(for: build).map(\.payloadResource).allSatisfy { $0.hasSuffix(id) })
#expect(SupportedRunners.build(loaderSHA256: build.loaderSHA256)?.id == build.id)
- #expect(build.tools.map(\.name) == ["notproton-winecx"])
- #expect(build.tools.first?.display == "WineCX 11.15 (msync, D3DMetal)")
+ #expect(build.tools.count == 1)
+ #expect(build.tools.first?.display == "\(build.releaseVersion) (msync, D3DMetal)")
#expect(build.tools.first?.flavor == .rosetta)
+ #expect(release.bundleName == "\(build.releaseVersion).app")
+ }
+
+ @Test("11.17 is the current release and owns notproton-winecx; 11.15 stays selectable beside it")
+ func currentAndPrevious() throws {
+ #expect(FreeEngineWinecx.current.build == "winecx-11.17")
+ #expect(FreeEngineWinecx.previous.build == "winecx-11.15")
+ #expect(FreeEngineWinecx.runnerBuild == FreeEngineWinecx.current.runner)
+ #expect(FreeEngineWinecx.current.runner.tools.map(\.name) == ["notproton-winecx"])
+ #expect(FreeEngineWinecx.previous.runner.tools.map(\.name) == ["notproton-winecx-11.15"])
+ let current = FreeEngineWinecx.current.runner
+ let previous = FreeEngineWinecx.previous.runner
+
+ // Both installed: each serves its own tool, the current one first.
+ let both = SupportedRunners.tools(for: [previous, current])
+ #expect(both.map(\.name) == ["notproton-winecx", "notproton-winecx-11.15"])
+ #expect(both.map(\.build) == ["winecx-11.17", "winecx-11.15"])
+ // Only 11.15 installed: it keeps answering to notproton-winecx, so games mapped to
+ // that name keep their tool until 11.17 is set up.
+ let old = SupportedRunners.tools(for: [previous])
+ #expect(old.map(\.name) == ["notproton-winecx"])
+ #expect(old.map(\.build) == ["winecx-11.15"])
+ #expect(old.first?.display == "WineCX 11.15 (msync, D3DMetal)")
+ #expect(SupportedRunners.tools(for: [current]).map(\.name) == ["notproton-winecx"])
}
@Test("Both free engines stay separate builds with their own loaders and tools")
func coexistsWithWineHQ() throws {
let free = SupportedRunners.all.filter(\.isFree)
- #expect(Set(free.map(\.id)) == [FreeEngine.current.build, FreeEngineWinecx.current.build])
+ #expect(Set(free.map(\.id)) == Set([FreeEngine.current.build] + FreeEngineWinecx.releases.map(\.build)))
#expect(Set(free.map(\.loaderSHA256)).count == free.count)
#expect(Set(free.flatMap(\.tools).map(\.name)).count == free.flatMap(\.tools).count)
- #expect(FreeEngineWinecx.current.bundleName != FreeEngine.current.bundleName)
+ #expect(Set(FreeEngineWinecx.releases.map(\.bundleName) + [FreeEngine.current.bundleName]).count
+ == FreeEngineWinecx.releases.count + 1)
}
// The license gate keys on the loader hash alone: a CrossOver-shaped tree whose loader
@@ -40,16 +68,20 @@ struct FreeEngineWinecxTests {
let engines = try makeDirectory("engines")
defer { try? FileManager.default.removeItem(at: engines) }
- let root = FreeEngineWinecx.bundle(engines: engines).appending(path: "Contents/SharedSupport/CrossOver")
- let loader = CrossOverSource.unixLoader(inRoot: root)
- try FileManager.default.createDirectory(at: loader.deletingLastPathComponent(), withIntermediateDirectories: true)
- try Data("not winecx".utf8).write(to: loader)
- try Data("winecx-11.15\n".utf8).write(to: FreeEngineWinecx.msyncMarker(in: root))
-
- #expect(CrossOverLicense.freeBuild(at: root) == nil)
- #expect(!CrossOverLicense.check(crossOverRoot: root, searchDirs: []).licensed)
- #expect(!FreeEngineWinecx.isInstalled(engines: engines))
- #expect(!WinecxD3DMetal.isWinecx(root: root))
+ for release in FreeEngineWinecx.releases {
+ let root = FreeEngineWinecx.bundle(for: release, engines: engines)
+ .appending(path: "Contents/SharedSupport/CrossOver")
+ let loader = CrossOverSource.unixLoader(inRoot: root)
+ try FileManager.default.createDirectory(at: loader.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data("not winecx".utf8).write(to: loader)
+ try Data("\(release.build)\n".utf8).write(to: FreeEngineWinecx.msyncMarker(in: root))
+
+ #expect(CrossOverLicense.freeBuild(at: root) == nil)
+ #expect(!CrossOverLicense.check(crossOverRoot: root, searchDirs: []).licensed)
+ #expect(!FreeEngineWinecx.isInstalled(release, engines: engines))
+ #expect(!WinecxD3DMetal.isWinecx(root: root))
+ #expect(FreeEngineWinecx.release(forRoot: root) == nil)
+ }
}
@Test("Backends follow the compat_run.sh layout and never shadow lib/wine")
@@ -89,9 +121,10 @@ struct FreeEngineWinecxTests {
// winemac-patch/winecx-d3dmetal-retina.patch: an engine with winecx's own winemac.so is
// outdated, and the copy NotProton installs is the one it pins.
- @Test("The patched winemac.so ships with the app and replaces winecx's own")
- func patchedMacDriver() throws {
- let release = FreeEngineWinecx.current
+ @Test("The patched winemac.so ships with the app and replaces winecx's own",
+ arguments: FreeEngineWinecx.releases.map(\.build))
+ func patchedMacDriver(id: String) throws {
+ let release = try #require(FreeEngineWinecx.release(build: id))
let bundled = try #require(Bundle.module.url(forResource: "winemac-\(release.build)", withExtension: "so"))
#expect(Digest.sha256IfPresent(bundled) == release.macDriver)
@@ -100,12 +133,12 @@ struct FreeEngineWinecxTests {
let driver = root.appending(path: FreeEngine.macDriverPath)
try FileManager.default.createDirectory(at: driver.deletingLastPathComponent(), withIntermediateDirectories: true)
try Data("winecx's own winemac.so".utf8).write(to: driver)
- #expect(FreeEngineWinecx.layoutProblems(root: root).contains(FreeEngine.macDriverPath))
+ #expect(FreeEngineWinecx.layoutProblems(root: root, release: release).contains(FreeEngine.macDriverPath))
try FreeEngine.installMacDriver(root: root, build: release.build, sha256: release.macDriver,
step: FreeEngineWinecx.step)
#expect(Digest.sha256IfPresent(driver) == release.macDriver)
- #expect(!FreeEngineWinecx.layoutProblems(root: root).contains(FreeEngine.macDriverPath))
+ #expect(!FreeEngineWinecx.layoutProblems(root: root, release: release).contains(FreeEngine.macDriverPath))
#expect(throws: StepFailure.self) {
try FreeEngine.installMacDriver(root: root, build: release.build, sha256: String(repeating: "0", count: 64),
step: FreeEngineWinecx.step)
@@ -114,11 +147,16 @@ struct FreeEngineWinecxTests {
// docs/WINECX.md, Controllers: winebus.so with SDL2 in lib/wine, and the libSDL2 it
// dlopens by leaf name in lib/, where its @loader_path/../../ rpath points.
- @Test("The SDL2 winebus.so and its libSDL2 ship with the app and are laid into the engine")
- func gamepadSupport() throws {
- let files = FreeEngineWinecx.current.gamepad
- #expect(Set(files.map(\.path)) == ["lib/wine/x86_64-unix/winebus.so", "lib/libSDL2-2.0.0.dylib"])
- let table = FreeEngineWinecx.expectedFiles()
+ @Test("The SDL2 winebus.so and its libSDL2 ship with the app and are laid into the engine",
+ arguments: FreeEngineWinecx.releases.map(\.build))
+ func gamepadSupport(id: String) throws {
+ let release = try #require(FreeEngineWinecx.release(build: id))
+ let files = release.gamepad
+ var paths: Set<String> = ["lib/wine/x86_64-unix/winebus.so", "lib/libSDL2-2.0.0.dylib"]
+ // 11.17 also ships winebus.sys with sdl_bus_load_mappings fixed (winebus-patch/).
+ if release.build == "winecx-11.17" { paths.insert("lib/wine/x86_64-windows/winebus.sys") }
+ #expect(Set(files.map(\.path)) == paths)
+ let table = FreeEngineWinecx.expectedFiles(release)
for file in files {
let bundled = try #require(Bundle.module.url(forResource: file.resource, withExtension: file.ext))
#expect(Digest.sha256IfPresent(bundled) == file.sha256, "\(file.resource)")
@@ -130,11 +168,11 @@ struct FreeEngineWinecxTests {
let bus = root.appending(path: "lib/wine/x86_64-unix/winebus.so")
try FileManager.default.createDirectory(at: bus.deletingLastPathComponent(), withIntermediateDirectories: true)
try Data("winecx's own winebus.so, built without SDL2".utf8).write(to: bus)
- let before = FreeEngineWinecx.layoutProblems(root: root)
+ let before = FreeEngineWinecx.layoutProblems(root: root, release: release)
for file in files { #expect(before.contains(file.path), "\(file.path)") }
try FreeEngineWinecx.installBundled(files, root: root)
- let after = FreeEngineWinecx.layoutProblems(root: root)
+ let after = FreeEngineWinecx.layoutProblems(root: root, release: release)
for file in files {
#expect(Digest.sha256IfPresent(root.appending(path: file.path)) == file.sha256, "\(file.path)")
#expect(!after.contains(file.path), "\(file.path)")
@@ -151,7 +189,7 @@ struct FreeEngineWinecxTests {
let winecxBuild = try #require(SupportedRunners.build(id: FreeEngineWinecx.current.build))
let winehq = CrossOverInstall(bundle: URL(filePath: "/e/WineHQ 11.15.app"), releaseVersion: nil,
support: .supported(winehqBuild))
- let winecx = CrossOverInstall(bundle: URL(filePath: "/e/WineCX 11.15.app"), releaseVersion: nil,
+ let winecx = CrossOverInstall(bundle: URL(filePath: "/e/WineCX 11.17.app"), releaseVersion: nil,
support: .supported(winecxBuild))
let both = [winehq, winecx]
#expect(FreeEngineStatus.state(build: winehqBuild.id, installs: both, current: [winecxBuild.id]) == .outdated)
@@ -162,16 +200,25 @@ struct FreeEngineWinecxTests {
#expect(FreeEngineStatus.capture(both).current.isEmpty)
// Steam lists one tool per engine.
let tools = SupportedRunners.tools(for: [winehqBuild, winecxBuild]).map(\.display)
- #expect(Set(tools) == ["WineHQ 11.15 - Rosetta", "WineCX 11.15 (msync, D3DMetal)"])
+ #expect(Set(tools) == ["WineHQ 11.15 - Rosetta", "WineCX 11.17 (msync, D3DMetal)"])
+ // The 11.15 engine is judged by its own pins, not by 11.17's.
+ let previousBuild = try #require(SupportedRunners.build(id: FreeEngineWinecx.previous.build))
+ let previous = CrossOverInstall(bundle: URL(filePath: "/e/WineCX 11.15.app"), releaseVersion: nil,
+ support: .supported(previousBuild))
+ #expect(!FreeEngineStatus.isCurrent(previous))
+ #expect(FreeEngineStatus.state(build: previousBuild.id, installs: [previous], current: [previousBuild.id])
+ == .current)
}
@Test("Downloads come only from the pinned GitHub release mirrors")
func pinnedSources() {
- let release = FreeEngineWinecx.current
- #expect(release.sha256 == "6db83765d9bd9d9941cacf8e09d2b8a3014738305ca4672d2188f3e6e51fae87")
- #expect(release.bases.allSatisfy { $0.host() == "github.com" })
- #expect(release.bases.allSatisfy { $0.path().hasSuffix(release.runtime) })
- #expect(FreeEngineWinecx.downloads.lastPathComponent == "winecx-\(release.runtime)")
+ #expect(FreeEngineWinecx.current.sha256 == "a4b5d63493f80698cce5cad8e7212d9a51c8292037b00c478f4652636fcfd331")
+ #expect(FreeEngineWinecx.previous.sha256 == "6db83765d9bd9d9941cacf8e09d2b8a3014738305ca4672d2188f3e6e51fae87")
+ for release in FreeEngineWinecx.releases {
+ #expect(release.bases.allSatisfy { $0.host() == "github.com" })
+ #expect(release.bases.allSatisfy { $0.path().hasSuffix(release.runtime) })
+ #expect(FreeEngineWinecx.downloads(for: release).lastPathComponent == "winecx-\(release.runtime)")
+ }
}
// MARK: - D3DMetal linking
@@ -419,18 +466,20 @@ struct FreeEngineWinecxTests {
// MARK: - Against the real archive
- // Runs once the archive is in NotProton's cache, or at NOTPROTON_WINECX_ARCHIVE.
- private static var realArchive: URL? {
+ // Runs once a release's archive is in NotProton's cache, or at NOTPROTON_WINECX_ARCHIVE.
+ private static func realArchive(_ release: WinecxRelease) -> URL? {
let candidates = [
ProcessInfo.processInfo.environment["NOTPROTON_WINECX_ARCHIVE"].map { URL(filePath: $0) },
- FreeEngineWinecx.downloads.appending(path: FreeEngineWinecx.current.archive),
+ FreeEngineWinecx.downloads(for: release).appending(path: release.archive),
].compactMap { $0 }
- return candidates.first { Digest.sha256IfPresent($0) == FreeEngineWinecx.current.sha256 }
+ return candidates.first { Digest.sha256IfPresent($0) == release.sha256 }
}
- @Test("Unpacking the real archive yields a free, patchable engine with the runtime contract")
- func unpacksRealArchive() async throws {
- guard let archive = Self.realArchive else { return }
+ @Test("Unpacking the real archive yields a free, patchable engine with the runtime contract",
+ arguments: FreeEngineWinecx.releases.map(\.build))
+ func unpacksRealArchive(id: String) async throws {
+ let release = try #require(FreeEngineWinecx.release(build: id))
+ guard let archive = Self.realArchive(release) else { return }
// Fetched into the engine cache the way FreeEngineWinecx.install does, when missing.
let dxmt = FreeEngine.dxmt
let renderer = try await PinnedDownload.obtain(
@@ -444,17 +493,17 @@ struct FreeEngineWinecxTests {
let engines = base.appending(path: "engines")
let gptk = try makePayload(in: base.appending(path: "gptk"))
let install = try FreeEngineWinecx.unpack(
- archive, renderer: renderer, release: FreeEngineWinecx.current, engines: engines, gptkRoots: [gptk]
+ archive, renderer: renderer, release: release, engines: engines, gptkRoots: [gptk]
)
guard case .supported(let build) = install.support else {
Issue.record("unpacked engine is \(install.support)")
return
}
let root = install.crossOverRoot
- #expect(build.id == FreeEngineWinecx.current.build)
+ #expect(build.id == release.build)
#expect(install.isFree)
- #expect(FreeEngineWinecx.isInstalled(engines: engines))
- #expect(FreeEngineWinecx.hasBackends(root: root))
+ #expect(FreeEngineWinecx.isInstalled(release, engines: engines))
+ #expect(FreeEngineWinecx.hasBackends(root: root, release: release))
#expect(CrossOverLicense.check(crossOverRoot: root).licensed)
try RunnerInstaller.verifyClone(build: build, root: root)
@@ -466,19 +515,19 @@ struct FreeEngineWinecxTests {
#expect(Digest.sha256(of: patched) == build.patchedNtdll[patch.arch])
}
- #expect(FreeEngineWinecx.layoutProblems(root: root).isEmpty)
+ #expect(FreeEngineWinecx.layoutProblems(root: root, release: release).isEmpty)
// Master's winemetal replaced the archive's, and its DLLs are natives.
- for (path, hash) in FreeEngineWinecx.expectedFiles() {
+ for (path, hash) in FreeEngineWinecx.expectedFiles(release) {
#expect(Digest.sha256IfPresent(root.appending(path: path)) == hash, "\(path)")
}
#expect(!WinecxD3DMetal.isBuiltin(root.appending(path: "lib/notproton-backends/dxmt/x86_64-windows/d3d11.dll")))
#expect(WinecxD3DMetal.isBuiltin(root.appending(path: "lib/wine/x86_64-windows/winemetal.dll")))
- #expect(try String(contentsOf: FreeEngineWinecx.msyncMarker(in: root), encoding: .utf8) == "winecx-11.15\n")
+ #expect(try String(contentsOf: FreeEngineWinecx.msyncMarker(in: root), encoding: .utf8) == "\(release.build)\n")
// The fixture GPTK was linked as the builtins, with Wine's own set aside under their pins.
#expect(WinecxD3DMetal.isLinked(root: root))
#expect(fm.fileExists(atPath: root.appending(path: "lib/external/README").path(percentEncoded: false)))
- for (name, hash) in FreeEngineWinecx.current.d3dStock {
+ for (name, hash) in release.d3dStock {
#expect(Digest.sha256IfPresent(root.appending(path: "\(WinecxD3DMetal.stockPath)/\(name)")) == hash)
}
@@ -487,14 +536,14 @@ struct FreeEngineWinecxTests {
let cloned = try RunnerInstaller.clone(from: install, runners: runners)
let runnerRoot = SupportPaths.clonedRoot(forBuild: cloned.id, runners: runners)
#expect(WinecxD3DMetal.isLinked(root: runnerRoot))
- #expect(FreeEngineWinecx.layoutProblems(root: runnerRoot).isEmpty)
+ #expect(FreeEngineWinecx.layoutProblems(root: runnerRoot, release: release).isEmpty)
try fm.removeItem(at: gptk)
#expect(SystemStatus.relinkGameportingToolkit(engines: engines, runners: runners, roots: [gptk]) == nil)
for tree in [root, runnerRoot] {
#expect(!WinecxD3DMetal.isLinked(root: tree))
#expect(!fm.fileExists(atPath: WinecxD3DMetal.enabledMarker(in: tree).path(percentEncoded: false)))
- #expect(FreeEngineWinecx.layoutProblems(root: tree).isEmpty, "\(tree)")
- for (name, hash) in FreeEngineWinecx.current.d3dStock {
+ #expect(FreeEngineWinecx.layoutProblems(root: tree, release: release).isEmpty, "\(tree)")
+ for (name, hash) in release.d3dStock {
#expect(Digest.sha256IfPresent(tree.appending(path: "lib/wine/x86_64-windows/\(name)")) == hash)
}
}
diff --git a/docs/WINECX.md b/docs/WINECX.md
index e0c5229..671de5a 100644
--- a/docs/WINECX.md
+++ b/docs/WINECX.md
@@ -1,9 +1,29 @@
# WineCX engine
NotProton's second free engine. WineCX is CodeWeavers' open-source (LGPL) CrossOver 26.3
-Wine changes, rebased by dappermint onto upstream wine-11.15
-([dappermint/winecx](https://github.com/dappermint/winecx), branch `wine1115`). It is built in
-CI into a Whisky runtime by [dappermint/winecx-gptk](https://github.com/dappermint/winecx-gptk).
+Wine changes, rebased by dappermint onto upstream Wine
+([dappermint/winecx](https://github.com/dappermint/winecx)). It is built in CI into a Whisky
+runtime by [dappermint/winecx-gptk](https://github.com/dappermint/winecx-gptk).
+
+Two releases are pinned side by side (`FreeEngineWinecx.releases`):
+
+| Build | Runtime | winecx | Wine | Tool | Bundle |
+|---|---|---|---|---|---|
+| `winecx-11.17` (current) | 4.7.3 | `e0aa380` | 11.17 | `notproton-winecx` | `WineCX 11.17.app` |
+| `winecx-11.15` | 4.5.125 | `5b45f45` | 11.15 | `notproton-winecx-11.15` | `WineCX 11.15.app` |
+
+The WineCX row installs the current one. Each release is its own runner build with its own
+pins, ntdll detours and Steam tool, so the 11.15 engine stays installed and selectable. While
+11.17 is not installed, the 11.15 build answers to `notproton-winecx` (`CompatTool.standsInFor`),
+so games mapped to that name keep working until the update. A prefix claimed by one build is
+refused by the other (`refuse_other_build` in `compat_run.sh`): rebuild it in NotProton, or pick
+"WineCX 11.15" in the game's Compatibility settings.
+
+4.7.3 over 4.5.125: msync fixes (wake one waiter, skip wake syscalls nobody waits on, sleep
+instead of spinning while a wait registers, unregister on contention), kernelbase
+`FlsGetValue2` for Unity 6000.3, dxgi `CheckInterfaceSupport` for `IDXGIDevice`, winemac no
+longer hiding the client view on a window-surface flush, win32u reporting the adapter
+D3DMetal was told to use, and the Wine 11.16 and 11.17 merges.
Compared with the WineHQ 11.15 engine it adds:
@@ -16,13 +36,29 @@ Compared with the WineHQ 11.15 engine it adds:
`e94c312` build as the WineHQ engine ([DXMT.md](DXMT.md)), not the archive's 0.80. The
builtin Direct3D is Wine's own, or D3DMetal once a Game Porting Toolkit is linked.
-In NotProton it is build `winecx-11.15`, tool `notproton-winecx`, shown as "WineCX 11.15
-(msync, D3DMetal)". Like the WineHQ engine it needs no CrossOver license. The licence check
+In NotProton the current build is `winecx-11.17`, tool `notproton-winecx`, shown as "WineCX
+11.17 (msync, D3DMetal)". Like the WineHQ engine it needs no CrossOver license. The licence check
treats it as free only because the loader hash matches the pinned one, so a CrossOver install
can never pass as it.
## Artifact
+### 4.7.3 (current)
+
+| | |
+|---|---|
+| File | `Libraries.tar.gz`, 461,131,598 bytes |
+| URL | https://github.com/dappermint/winecx-gptk/releases/download/runtime-v4.7.3/Libraries.tar.gz |
+| sha256 | `a4b5d63493f80698cce5cad8e7212d9a51c8292037b00c478f4652636fcfd331` |
+| Source | winecx `e0aa380780b73e20fabcfe78fd42713b94929a53`, built by winecx-gptk `0bf3eabc2f0d95154282eb86b11205cbbaae6c65` |
+| Base | Wine 11.17 (`VERSION`) |
+| Arch, target | x86_64 only, minos 26.0, same layout as 4.5.125 |
+
+No Whisky mirror carries 4.7.3, so the only base is the winecx-gptk release. Its DXVK
+repack is byte-identical to 4.5.125's.
+
+### 4.5.125
+
| | |
|---|---|
| File | `Libraries.tar.gz`, 461,224,571 bytes |
@@ -49,8 +85,8 @@ stripped, which NotProton does not use. `Libraries/DXVK/{x64,x32}` holds DXVK. A
## What NotProton lays out
-The engine root (`…/WineCX 11.15.app/Contents/SharedSupport/CrossOver`, cloned into the runner
-`runners/crossover-winecx-11.15`) is the archive's `Libraries/Wine`, plus:
+The engine root (`…/WineCX 11.17.app/Contents/SharedSupport/CrossOver`, cloned into the runner
+`runners/crossover-winecx-11.17`; likewise for 11.15) is the archive's `Libraries/Wine`, plus:
```
.notproton-msync engine supports msync
@@ -60,6 +96,7 @@ lib/notproton-backends/dxmt/{x86_64,i386}-windows/{d3d11,d3d10core,dxgi}.dll D
lib/notproton-backends/dxvk/{x86_64,i386}-windows/{d3d11,d3d10core}.dll from the archive
lib/wine/x86_64-unix/winemac.so Retina fix, replacing the archive's (below)
lib/wine/x86_64-unix/winebus.so built with SDL2, replacing the archive's (Controllers)
+lib/wine/x86_64-windows/winebus.sys 11.17 only: map-key fix, replacing the archive's (Controllers)
lib/libSDL2-2.0.0.dylib SDL 2.32.8, x86_64, for winebus.so (Controllers)
```
@@ -82,9 +119,10 @@ swapchain from its view's frame in points, so with High Resolution (Retina) on,
half-size drawable and showed only the top-left quarter, and a `ResizeBuffers` from
`WM_SIZE` read the view's frame before it had followed the window, so the swapchain kept
its old size (Ravenswatch: 3024x1752 stretched over a 3024x1964 screen). NotProton installs
-`winemac-winecx-11.15.so`, built from winecx `5b45f45` with
-`winemac-patch/winecx-d3dmetal-retina.patch` (`winemac-patch/README.md`), pinned as
-`FreeEngineWinecx.current.macDriver`.
+`winemac-winecx-<build>.so`, built from winecx `e0aa380` with
+`winemac-patch/winecx-11.17-d3dmetal-retina.patch` (11.17) or from `5b45f45` with
+`winemac-patch/winecx-d3dmetal-retina.patch` (11.15), see `winemac-patch/README.md`, pinned as
+each release's `macDriver`.
## Controllers
@@ -94,7 +132,7 @@ macOS 26 SDK lacks. A gamepad then had no path into Wine: winebus ignores the IO
HID device for a gamepad unless that device has `Hidraw=1`, and with it the pad comes in as
`is_hidraw 1, is_gamepad 0`, which XInput never opens.
-NotProton installs `winebus-winecx-11.15.so`: winecx `5b45f45`'s own, built with
+NotProton installs `winebus-winecx-<build>.so`: that winecx tree's own, built with
`SONAME_LIBSDL2` = `libSDL2-2.0.0.dylib`, the name the WineHQ engine's `winebus.so` dlopens.
SDL's bus then presents the pad as a gamepad (`is_gamepad 1`), the device XInput opens.
dyld resolves the leaf name through the caller's `LC_RPATH`s, and `winebus.so` carries
@@ -123,8 +161,19 @@ changes), then link and sign the way the runtime's was:
Built this way without the define, the result matches the runtime's `winebus.so` in every
section and in all 171 symbols and their addresses, with the same load commands in the same
-order; only `__LINKEDIT`, the UUID and the linker's tool version differ. The pins are
-`FreeEngineWinecx.current.gamepad`.
+order; only `__LINKEDIT`, the UUID and the linker's tool version differ. For 11.17 the same
+recipe without the define reproduces the runtime's `winebus.so` in every section, symbol and
+load command. The pins are each release's `gamepad`.
+
+The PE half's `sdl_bus_load_mappings` (`dlls/winebus.sys/main.c`) stored each mapping at
+`mappings[count]` after `count++`, so it wrote one slot past the string it had just allocated,
+and terminated `mappings[len]` instead of the string. Any `map` value under the winebus key
+then corrupted the heap and took winebus, and every pad, down. Wine master still has it
+(checked 2026-10-10). 11.17 ships `winebus-winecx-11.17.sys`, built from `e0aa380` with
+`winebus-patch/winecx-sdl-mappings.patch` by the tree's own rule (mingw-w64 gcc, then
+`x86_64-w64-mingw32-strip --strip-debug` as the CI does). Built without the patch, the result
+is byte-identical to the runtime's `winebus.sys` except the PE timestamp, checksum and build
+id. 11.15 keeps the runtime's own `winebus.sys`, so the `map` key is still unsafe there.
## D3DMetal: the builtin model
@@ -257,11 +306,28 @@ folder.
tar -xzf Libraries.tar.gz
cd ntdll-patch
python3 resolve.py ../Libraries/Wine # self-tests against PINNED
-./build.sh ../Libraries/Wine/lib/wine/x86_64-windows/ntdll.dll winecx-11.15
-./build32.sh ../Libraries/Wine/lib/wine/i386-windows/ntdll.dll winecx-11.15
+./build.sh ../Libraries/Wine/lib/wine/x86_64-windows/ntdll.dll winecx-<11.17|11.15>
+./build32.sh ../Libraries/Wine/lib/wine/i386-windows/ntdll.dll winecx-<11.17|11.15>
python3 apply.py <ntdll.dll> <out> <detour bin> # patched hashes
```
+4.7.3 (`winecx-11.17`): both detours fit in `.text` padding.
+
+| Pin | sha256 |
+|---|---|
+| loader `lib/wine/x86_64-unix/wine` | `a680abba30b4888355adb39d8b62255e43546eb33d163897260627f7741ef648` |
+| clean x86_64 ntdll | `8b32c9f6f71b4f15fcaccb19b0f2adab9391ae73ad539cae9e136f8ee7d24128` |
+| patched x86_64 ntdll | `4573d521671a48212670e7543aa9ebf0921e383dada69477f677f435df2bef5a` |
+| clean i386 ntdll | `cc8a9035cea0e26c5d333ef220f1becefc27ae44d2cdcdaea3278e8739d26fd9` |
+| patched i386 ntdll | `8ad83740df2da5e79ed435e4bc57e82b4b6a4b984fbec73e1160ca81dfce1b44` |
+| `detour2-winecx-11.17.bin` | `e1bbd185b19de3e23d627ae3a8bf25ed1b767bff5690102c5312a5ed3813e736` |
+| `detour32-winecx-11.17.bin` | `0676104e0bd56c4a1e8c473d9cbcd21fb2ba105fc7dc6cf5a70d37692c129e28` |
+| `winemac-winecx-11.17.so` | `aa192f846ad15d56de200fc92752eaf2d455700846ae2cf1ccc7b27b535f1c00` |
+| `winebus-winecx-11.17.so` | `6223c035c824c90708abbc3e733f8d1d6ed6b8b4e9a3e1a5c813493ceba50473` |
+| `winebus-winecx-11.17.sys` | `da108d1c3788fa32807ef08c4d26d8a89812c230317ffa7ba5111e126bda607c` |
+
+4.5.125 (`winecx-11.15`):
+
| Pin | sha256 |
|---|---|
| loader `lib/wine/x86_64-unix/wine` | `a4b677428a6834f97f536a84d32c5da982c9a449e5d483c6be3d1c9b8f308998` |
@@ -272,6 +338,6 @@ python3 apply.py <ntdll.dll> <out> <detour bin> # patched hashes
| `detour2-winecx-11.15.bin` | `fde56854b9a7a32da19babe2427d19ff6a6b83de1917fe8d32aaddd2991fc6b9` |
| `detour32-winecx-11.15.bin` | `37daf5f795535df91bc8fcbd356f22f4fd1ab379ec4acc97ddff44037d265556` |
-The unpack test (`FreeEngineWinecxTests.unpacksRealArchive`) checks all of this against the
-real archive when `NOTPROTON_WINECX_ARCHIVE` points at it, or when it sits in NotProton's
-download cache.
+The unpack test (`FreeEngineWinecxTests.unpacksRealArchive`, once per release) checks all of
+this against the real archive when `NOTPROTON_WINECX_ARCHIVE` points at it, or when it sits in
+NotProton's download cache.
diff --git a/ntdll-patch/apply.py b/ntdll-patch/apply.py
index 0c5b7f4..8709dea 100644
--- a/ntdll-patch/apply.py
+++ b/ntdll-patch/apply.py
@@ -25,6 +25,8 @@ PAYLOAD_BY_CLEAN_SHA = {
"77ca83b2e1a3a1242f9d2d8868328262b2bcfc3f59bacf8b9389ea7e797ea852": "detour64-fex-41069.bin",
"5710d16382c7a822ed8b1cba58d95fd86fe01905f039c296ca7224abff8f98e8": "detour2-winecx-11.15.bin",
"e1b208073c804a443e64ada577899d96a5c8eaee435813e4a30e0d143bca6e3c": "detour32-winecx-11.15.bin",
+ "8b32c9f6f71b4f15fcaccb19b0f2adab9391ae73ad539cae9e136f8ee7d24128": "detour2-winecx-11.17.bin",
+ "cc8a9035cea0e26c5d333ef220f1becefc27ae44d2cdcdaea3278e8739d26fd9": "detour32-winecx-11.17.bin",
}
KNOWN_MACHINES = (0x8664, 0x14c, 0xaa64)
diff --git a/ntdll-patch/resolve.py b/ntdll-patch/resolve.py
index 017fceb..cb665e5 100755
--- a/ntdll-patch/resolve.py
+++ b/ntdll-patch/resolve.py
@@ -121,6 +121,21 @@ PINNED = {
'exports': {'LdrGetDllHandle': 0x7bc12a60, 'LdrLoadDll': 0x7bc13600,
'NtProtectVirtualMemory': 0x7bc0d764, 'NtOpenFile': 0x7bc0d594,
'NtReadFile': 0x7bc0d2c4, 'NtClose': 0x7bc0d354}},
+ # WineCX 11.17 (dappermint winecx-gptk runtime 4.7.3)
+ '8b32c9f6f71b4f15fcaccb19b0f2adab9391ae73ad539cae9e136f8ee7d24128':
+ {'hookRVA': 0x52de3, 'stolen': '4883bc24f000000000', 'caveRVA': 0x83360, 'caveSize': 3232,
+ 'resume': 0x52dec, 'wm': 'rbx', 'load_path': 0xd0,
+ 'payload': 'e1bbd185b19de3e23d627ae3a8bf25ed1b767bff5690102c5312a5ed3813e736',
+ 'exports': {'LdrGetDllHandle': 0x170017950, 'LdrLoadDll': 0x1700184c0,
+ 'NtProtectVirtualMemory': 0x17000f690, 'NtOpenFile': 0x17000f2f0,
+ 'NtReadFile': 0x17000ed50, 'NtClose': 0x17000ee70}},
+ 'cc8a9035cea0e26c5d333ef220f1becefc27ae44d2cdcdaea3278e8739d26fd9':
+ {'hookRVA': 0x4f880, 'stolen': 'f645b4027529', 'caveRVA': 0x808a0, 'caveSize': 1888,
+ 'resume': 0x4f886, 'wm': 'ebx', 'load_path': -0x5c,
+ 'payload': '0676104e0bd56c4a1e8c473d9cbcd21fb2ba105fc7dc6cf5a70d37692c129e28',
+ 'exports': {'LdrGetDllHandle': 0x7bc12aa0, 'LdrLoadDll': 0x7bc13640,
+ 'NtProtectVirtualMemory': 0x7bc0d7a4, 'NtOpenFile': 0x7bc0d5d4,
+ 'NtReadFile': 0x7bc0d304, 'NtClose': 0x7bc0d394}},
}
EXPORTS = ['LdrGetDllHandle', 'LdrLoadDll', 'NtProtectVirtualMemory',
'NtOpenFile', 'NtReadFile', 'NtClose']
diff --git a/winebus-patch/README.md b/winebus-patch/README.md
new file mode 100644
index 0000000..4bc7320
--- /dev/null
+++ b/winebus-patch/README.md
@@ -0,0 +1,7 @@
+# winebus-patch
+
+`winecx-sdl-mappings.patch` fixes `sdl_bus_load_mappings()` in `dlls/winebus.sys/main.c` (the
+PE half). It wrote each mapping to `mappings[count]` after `count++` and terminated
+`mappings[len]`, so any value under winebus's `map` key wrote past the array and crashed
+winebus with every pad on it. Against winecx `e0aa380`; the build and pin are in
+`docs/WINECX.md` (Controllers).
diff --git a/winebus-patch/winecx-sdl-mappings.patch b/winebus-patch/winecx-sdl-mappings.patch
new file mode 100644
index 0000000..6ac197e
--- /dev/null
+++ b/winebus-patch/winecx-sdl-mappings.patch
@@ -0,0 +1,30 @@
+diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
+index 88d21b47..5f501c72 100644
+--- a/dlls/winebus.sys/main.c
++++ b/dlls/winebus.sys/main.c
+@@ -1118,17 +1118,21 @@ static void sdl_bus_load_mappings(struct bus_options *options)
+ RtlUnicodeToMultiByteSize(&len, (WCHAR *)((char *)info + info->DataOffset), info_size - info->DataOffset);
+ if (!len) continue;
+
+- if (!(mappings[count++] = RtlAllocateHeap(GetProcessHeap(), 0, len + 1))) break;
+- if (count > capacity)
++ if (count == capacity)
+ {
++ char **grown;
++
+ capacity = capacity * 3 / 2;
+- if (!(mappings = RtlReAllocateHeap(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings))))
++ if (!(grown = RtlReAllocateHeap(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings))))
+ break;
++ mappings = grown;
+ }
++ if (!(mappings[count] = RtlAllocateHeap(GetProcessHeap(), 0, len + 1))) break;
+
+ RtlUnicodeToMultiByteN(mappings[count], len, NULL, (WCHAR *)((char *)info + info->DataOffset),
+ info_size - info->DataOffset);
+- if (mappings[len - 1]) mappings[len] = 0;
++ mappings[count][len] = 0;
++ count++;
+ }
+
+ if (mappings) while (count) RtlFreeHeap(GetProcessHeap(), 0, mappings[--count]);
diff --git a/winemac-patch/README.md b/winemac-patch/README.md
index 6dced40..6cc0cd8 100644
--- a/winemac-patch/README.md
+++ b/winemac-patch/README.md
@@ -63,3 +63,21 @@ Built this way without the patch, the result matches the runtime's `winemac.so`
section (`__text`, `__cstring`, `__const`, `__data`, objc) and in its 2147 symbols; only
`__LINKEDIT` and the SDK's framework versions differ. Then update `macDriver` in
`FreeEngineWinecx.swift` with the sha256.
+
+### 11.17: `winecx-11.17-d3dmetal-retina.patch`
+
+The same change re-derived against winecx `e0aa380` (runtime 4.7.3). 565f638 only adds the
+`raw` argument to `macdrv_CreateClientSurface`; the proxy and the d3dmetal.c hooks apply as
+they were. CW HACK 22435 had to change: Wine 11.17 no longer exports `client_surface_update`
+from win32u (only `client_surface_present`, `update_client_surfaces` and friends are in
+`gdi_driver.h`), so the 11.15 hunk fails to link. The 11.17 hunk calls
+`client_surface_present()` instead, which recomputes the rects and runs the driver's `update`
+exactly as `client_surface_update()` did, then `present`, which makes the surface the window's
+client view. To keep that a no-op it only touches the D3DMetal surface that already is
+`data->client_view` (the one D3DMetal last presented), not every surface in the list.
+
+Build as above from `e0aa380`, with two differences in the link: no `-framework CoreVideo`
+(11.17's `cocoa_window.m` dropped `WineDisplayLink`, and the Makefile rule with it), and the
+CI's `install_name_tool -add_rpath @loader_path/../../` before the final `codesign -fs -`.
+Built this way without the patch, the result matches the runtime 4.7.3 `winemac.so` in every
+section, all 2095 symbols and every load command.
diff --git a/winemac-patch/winecx-11.17-d3dmetal-retina.patch b/winemac-patch/winecx-11.17-d3dmetal-retina.patch
new file mode 100644
index 0000000..3c9ad41
--- /dev/null
+++ b/winemac-patch/winecx-11.17-d3dmetal-retina.patch
@@ -0,0 +1,203 @@
+diff --git a/dlls/winemac.drv/d3dmetal.c b/dlls/winemac.drv/d3dmetal.c
+index 7d5d9038..c90c6435 100644
+--- a/dlls/winemac.drv/d3dmetal.c
++++ b/dlls/winemac.drv/d3dmetal.c
+@@ -186,22 +186,29 @@ static void my_macdrv_release_metal_device(macdrv_metal_device d)
+ macdrv_release_metal_device(d);
+ }
+
++/* D3DMetal sizes a swapchain from the frame of the view it gets here, which is in
++ * points, while D3D sizes are Win32 pixels. The wrapper reports the frame in Win32
++ * pixels (d3dmetal_objc.m), so Retina mode gets a full-size backbuffer. */
+ static macdrv_metal_view my_macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d)
+ {
++ macdrv_metal_view view;
++
+ TRACE("macdrv_view_create_metal_view %p %p\n", v, d);
+- return macdrv_view_create_metal_view(v, d);
++ if (!(view = macdrv_view_create_metal_view(v, d))) return NULL;
++ return macdrv_d3dmetal_wrap_metal_view(view);
+ }
+
+ static macdrv_metal_layer my_macdrv_view_get_metal_layer(macdrv_metal_view v)
+ {
+ TRACE("macdrv_view_get_metal_layer %p\n", v);
+- return macdrv_view_get_metal_layer(v);
++ return macdrv_view_get_metal_layer(macdrv_d3dmetal_unwrap_metal_view(v));
+ }
+
+ static void my_macdrv_view_release_metal_view(macdrv_metal_view v)
+ {
+ TRACE("macdrv_view_release_metal_view %p\n", v);
+- return macdrv_view_release_metal_view(v);
++ macdrv_view_release_metal_view(macdrv_d3dmetal_unwrap_metal_view(v));
++ macdrv_d3dmetal_release_metal_view_wrapper(v);
+ }
+
+ static void my_OnMainThread(dispatch_block_t b)
+diff --git a/dlls/winemac.drv/d3dmetal_objc.m b/dlls/winemac.drv/d3dmetal_objc.m
+index 9b4a054f..37b04dfb 100644
+--- a/dlls/winemac.drv/d3dmetal_objc.m
++++ b/dlls/winemac.drv/d3dmetal_objc.m
+@@ -72,4 +72,104 @@ @implementation WineMetalLayer
+
+ @end
+
++
++/* D3DMetal (libd3dshared's WineSwapchainCallbacks::InitializeForHWND) sizes a window's
++ * backbuffer, and through it the CAMetalLayer drawable, from -frame of the view
++ * macdrv_view_create_metal_view() returns. A frame is in points, but D3D sizes are Win32
++ * pixels, which are backing pixels in Retina mode, so the backbuffer came out at half the
++ * window's Win32 size and a game rendering for its client rect showed only the top-left
++ * quarter. D3DMetal gets this proxy instead: -frame in Win32 pixels, the same conversion
++ * every other path makes with cgrect_win_from_mac(), and everything else forwarded. */
++@interface WineD3DMetalViewProxy : NSProxy
++{
++ NSView* view;
++}
++
++ - (instancetype) initWithView:(NSView*)aView;
++ - (NSView*) wineView;
++
++@end
++
++@implementation WineD3DMetalViewProxy
++
++ - (instancetype) initWithView:(NSView*)aView
++ {
++ view = [aView retain];
++ return self;
++ }
++
++ - (void) dealloc
++ {
++ [view release];
++ [super dealloc];
++ }
++
++ - (NSView*) wineView
++ {
++ return view;
++ }
++
++ /* Read on the main thread, behind the frame updates macdrv has already queued
++ * there: ResizeBuffers runs in the game's WM_SIZE handler, right after
++ * macdrv_WindowPosChanged() queued the view's new frame. */
++ - (NSRect) frame
++ {
++ __block NSRect frame;
++
++ if ([NSThread isMainThread])
++ frame = [view frame];
++ else
++ OnMainThread(^{ frame = [view frame]; });
++ return cgrect_win_from_mac(frame);
++ }
++
++ - (id) forwardingTargetForSelector:(SEL)selector
++ {
++ return view;
++ }
++
++ - (NSMethodSignature*) methodSignatureForSelector:(SEL)selector
++ {
++ return [view methodSignatureForSelector:selector];
++ }
++
++ - (void) forwardInvocation:(NSInvocation*)invocation
++ {
++ [invocation invokeWithTarget:view];
++ }
++
++ - (BOOL) respondsToSelector:(SEL)selector
++ {
++ return [view respondsToSelector:selector];
++ }
++
++ - (BOOL) isKindOfClass:(Class)aClass
++ {
++ return [view isKindOfClass:aClass];
++ }
++
++@end
++
++macdrv_metal_view macdrv_d3dmetal_wrap_metal_view(macdrv_metal_view v)
++{
++ return (macdrv_metal_view)[[WineD3DMetalViewProxy alloc] initWithView:(NSView*)v];
++}
++
++macdrv_metal_view macdrv_d3dmetal_unwrap_metal_view(macdrv_metal_view v)
++{
++ id object = (id)v;
++
++ if (object && object_getClass(object) == [WineD3DMetalViewProxy class])
++ return (macdrv_metal_view)[(WineD3DMetalViewProxy*)object wineView];
++ return v;
++}
++
++void macdrv_d3dmetal_release_metal_view_wrapper(macdrv_metal_view v)
++{
++ id object = (id)v;
++
++ if (object && object_getClass(object) == [WineD3DMetalViewProxy class])
++ [object release];
++}
++
+ #endif
+diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
+index c6552baa..2551ab11 100644
+--- a/dlls/winemac.drv/macdrv_cocoa.h
++++ b/dlls/winemac.drv/macdrv_cocoa.h
+@@ -560,6 +560,9 @@ extern void macdrv_order_cocoa_window(macdrv_window w, macdrv_window prev,
+ extern macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d);
+ extern macdrv_metal_layer macdrv_view_get_metal_layer(macdrv_metal_view v);
+ extern void macdrv_view_release_metal_view(macdrv_metal_view v);
++extern macdrv_metal_view macdrv_d3dmetal_wrap_metal_view(macdrv_metal_view v);
++extern macdrv_metal_view macdrv_d3dmetal_unwrap_metal_view(macdrv_metal_view v);
++extern void macdrv_d3dmetal_release_metal_view_wrapper(macdrv_metal_view v);
+ extern macdrv_metal_swapchain macdrv_create_view_swapchain(macdrv_view v);
+ extern macdrv_metal_swapchain macdrv_create_offscreen_swapchain(void* hwnd, void* client_hwnd, CGRect container, CGRect frame);
+ extern void macdrv_swapchain_set_frame(macdrv_metal_swapchain swapchain, CGRect container, CGRect frame);
+diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
+index d31cd24d..fe575d61 100644
+--- a/dlls/winemac.drv/window.c
++++ b/dlls/winemac.drv/window.c
+@@ -1909,7 +1909,37 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT
+ }
+
+ done:
+- release_win_data(data);
++ /* CW HACK 22435: D3DMetal's client surfaces are not on win32u's list, so
++ * update_client_surfaces() skips them and their views only caught up with the
++ * window on the next present. A game that answers WM_SIZE with ResizeBuffers
++ * then had D3DMetal read the old view frame and keep the old backbuffer size
++ * (Ravenswatch: maximized 3024x1752 kept after going 3024x1964 borderless).
++ * Queue the shown surface's view frame now, before WM_SIZE. Wine 11.17 no longer
++ * exports client_surface_update(), so this goes through client_surface_present(),
++ * which updates the same way and then shows the surface; limiting it to the
++ * surface that is already the window's client view keeps that a no-op. win32u
++ * locks the surfaces before the window data, so it runs after release_win_data(). */
++ {
++ struct client_surface *shown = NULL;
++ CFIndex i, count = data->d3dmetal_client_surfaces ? CFArrayGetCount(data->d3dmetal_client_surfaces) : 0;
++
++ for (i = 0; i < count && data->client_view; i++)
++ {
++ struct macdrv_client_surface *surface =
++ (struct macdrv_client_surface *)CFArrayGetValueAtIndex(data->d3dmetal_client_surfaces, i);
++ if (surface->cocoa_view != data->client_view) continue;
++ shown = &surface->client;
++ client_surface_add_ref(shown);
++ break;
++ }
++ release_win_data(data);
++
++ if (shown)
++ {
++ client_surface_present(shown);
++ client_surface_release(shown);
++ }
++ }
+ }
+
+