Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
feat(dlss): let Streamline load Apple's NGX bridge
raymondchins5a9f96df7f1c
diff --git a/app/Package.swift b/app/Package.swiftindex 0e81a82..820bd81 100644--- a/app/Package.swift+++ b/app/Package.swift@@ -53,6 +53,8 @@ let package = Package(.copy("Resources/winebus-winecx-11.17.so"),.copy("Resources/winebus-winecx-11.17.sys"),.copy("Resources/ws2_32-winecx-11.17.dll"),+ .copy("Resources/crypt32-winecx-11.17.dll"),+ .copy("Resources/wintrust-winecx-11.17.dll"),.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.swiftindex f170315..d19b94e 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift@@ -59,6 +59,11 @@ struct WinecxRelease: Sendable {// link-local addresses macOS lists first, as Windows never returns them// (ws2_32-patch/). Empty where the runtime's own ws2_32 is kept.let network: [WinecxBundledFile]+ // crypt32 and wintrust rebuilt so, with NOTPROTON_NGX_SIGNER set, a signature check of+ // the system32 NGX core (Apple's unsigned MetalFX bridge) is answered from an+ // NVIDIA-signed Streamline module next to the game, which lets Streamline load it+ // (ngx-signer-patch/). Empty where the runtime's own are kept.+ let signer: [WinecxBundledFile]// The runner build this release unpacks to, keyed by its pinned loader, and the ntdll// detours for it (NtdllPatcher.byBuild).let runner: RunnerBuild@@ -153,6 +158,16 @@ enum FreeEngineWinecx {path: "lib/wine/x86_64-windows/ws2_32.dll",sha256: "cb0a5670ce6dbf949ed25cca54e9f1c4930cd4c2ade895836d518d3d9073079c"),],+ // crypt32.dll, wintrust.dll: winecx e0aa380's PE halves with+ // ngx-signer-patch/winecx-ngx-signer.patch.+ signer: [+ WinecxBundledFile(resource: "crypt32-winecx-11.17", ext: "dll",+ path: "lib/wine/x86_64-windows/crypt32.dll",+ sha256: "19330827fc085603c2a73b859b801980f494a942ae470398634fbb6e1d62ada9"),+ WinecxBundledFile(resource: "wintrust-winecx-11.17", ext: "dll",+ path: "lib/wine/x86_64-windows/wintrust.dll",+ sha256: "6ae3a8723bae11e5ff9ad6e23d1f1325740b1892d01b78abdeb1b77ac8bb6da8"),+ ],runner: RunnerBuild(bundleVersion: "winecx-11.17",releaseVersion: "WineCX 11.17",@@ -240,6 +255,7 @@ enum FreeEngineWinecx {sdl,],network: [],+ signer: [],// The hash-pinned loader is what makes it free, so a CrossOver install can never be// taken for it.runner: RunnerBuild(@@ -332,7 +348,7 @@ enum FreeEngineWinecx {// checks them, since they are either Wine's own or links into a Game Porting Toolkit.static func expectedFiles(_ release: WinecxRelease = current) -> [String: String] {var table: [String: String] = [FreeEngine.macDriverPath: release.macDriver]- for file in release.gamepad + release.network { table[file.path] = file.sha256 }+ for file in release.gamepad + release.network + release.signer { table[file.path] = file.sha256 }for file in release.backends { table["\(backendsPath)/\(file.destination)"] = file.sha256 }for path in release.renderer.files.keys {table[release.renderer.installPath(of: path)] = release.renderer.installedHash(of: path)@@ -421,7 +437,7 @@ enum FreeEngineWinecx {try fm.createDirectory(at: root.deletingLastPathComponent(), withIntermediateDirectories: true)try fm.moveItem(at: wine, to: root)try FreeEngine.installMacDriver(root: root, build: release.build, sha256: release.macDriver, step: step)- try installBundled(release.gamepad + release.network, root: root)+ try installBundled(release.gamepad + release.network + release.signer, root: root)let libraries = wine.deletingLastPathComponent()for file in release.backends {diff --git a/app/Sources/NotProtonApp/Resources/crypt32-winecx-11.17.dll b/app/Sources/NotProtonApp/Resources/crypt32-winecx-11.17.dllnew file mode 100755index 0000000..1ff6d52Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/crypt32-winecx-11.17.dll differdiff --git a/app/Sources/NotProtonApp/Resources/wintrust-winecx-11.17.dll b/app/Sources/NotProtonApp/Resources/wintrust-winecx-11.17.dllnew file mode 100755index 0000000..5b0575bBinary files /dev/null and b/app/Sources/NotProtonApp/Resources/wintrust-winecx-11.17.dll differdiff --git a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swiftindex 4679d71..065a400 100644--- a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift@@ -209,6 +209,23 @@ struct FreeEngineWinecxTests {#expect(!FreeEngineWinecx.layoutProblems(root: root, release: release).contains(files[0].path))}+ // ngx-signer-patch: 11.17 ships crypt32 and wintrust that let Streamline accept Apple's+ // NGX bridge; 11.15 keeps the runtime's.+ @Test("The NGX signer crypt32 and wintrust ship with the app and are pinned for 11.17",+ arguments: FreeEngineWinecx.releases.map(\.build))+ func ngxSigner(id: String) throws {+ let release = try #require(FreeEngineWinecx.release(build: id))+ let expected: Set<String> = release.build == "winecx-11.17"+ ? ["lib/wine/x86_64-windows/crypt32.dll", "lib/wine/x86_64-windows/wintrust.dll"] : []+ #expect(Set(release.signer.map(\.path)) == expected)+ let table = FreeEngineWinecx.expectedFiles(release)+ for file in release.signer {+ let bundled = try #require(Bundle.module.url(forResource: file.resource, withExtension: file.ext))+ #expect(Digest.sha256IfPresent(bundled) == file.sha256, "\(file.resource)")+ #expect(table[file.path] == file.sha256, "\(file.path)")+ }+ }+@Test("Each free engine is current, outdated or missing on its own pins")func perEngineState() throws {let winehqBuild = try #require(SupportedRunners.build(id: FreeEngine.current.build))diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 22014b5..a15e3fb 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -696,6 +696,9 @@ activate_backend() {# NVIDIA one. A D3DM_* value from a conf or the launch options wins.export D3DM_VENDOR_ID="${D3DM_VENDOR_ID:-0x10de}" D3DM_DEVICE_ID="${D3DM_DEVICE_ID:-0x2684}"export D3DM_DEVICE_DESCRIPTION="${D3DM_DEVICE_DESCRIPTION:-NVIDIA GeForce RTX 4090}"+ # Streamline loads an NGX core only when it is NVIDIA-signed; the engine's crypt32 and+ # wintrust answer for Apple's bridge from a signed Streamline module (ngx-signer-patch/).+ export NOTPROTON_NGX_SIGNER=1graphics_log "NVAPI=1: $nv_dlls on, adapter $D3DM_VENDOR_ID:$D3DM_DEVICE_ID ($D3DM_DEVICE_DESCRIPTION)"else[ "$gamefix_nvapi" != 1 ] || graphics_log "NVAPI=1 not applied, $backend is not d3dmetal"@@ -2135,7 +2138,7 @@ elseecho "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || truefiset -- --args "$shim_exe" "$@"-for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?)=.*/\1/p'); do+for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?|NOTPROTON_NGX_SIGNER)=.*/\1/p'); doeval "value=\$$name"# shellcheck disable=SC2154 # eval assigns value on the line aboveset -- --env "$name=$value" "$@"diff --git a/dylib/version.h b/dylib/version.hindex b92e379..47daf5f 100644--- a/dylib/version.h+++ b/dylib/version.h@@ -2,6 +2,6 @@#ifndef NOTPROTON_VERSION_H#define NOTPROTON_VERSION_H-#define NOTPROTON_VERSION "1.1.7-winehq.1-ray.20"+#define NOTPROTON_VERSION "1.1.7-winehq.1-ray.21"#endif // NOTPROTON_VERSION_Hdiff --git a/ngx-signer-patch/README.md b/ngx-signer-patch/README.mdnew file mode 100644index 0000000..7d4fec9--- /dev/null+++ b/ngx-signer-patch/README.md@@ -0,0 +1,21 @@+# NGX signer patch (WineCX 11.17)++NVIDIA Streamline loads an NGX core only when it carries an NVIDIA Authenticode signature+(`sl_security.h`: `CryptQueryObject` + `WinVerifyTrust` by path). Apple's MetalFX DLSS bridge,+`nvngx-on-metalfx`, linked as `system32\nvngx.dll`, is unsigned, so Streamline games+(Resident Evil Requiem, 007 First Light) logged `failed to load NGXCore: -2146885623` and+never offered DLSS. Games calling NGX directly (Death Stranding) were unaffected.++`winecx-ngx-signer.patch` (against winecx `e0aa380`) wraps `CryptQueryObject` (crypt32) and+`WinVerifyTrust` (wintrust): with `NOTPROTON_NGX_SIGNER` set, a check of+`...\system32\nvngx.dll` or `_nvngx.dll` by path is answered from an NVIDIA-signed Streamline+module next to the game executable (`sl.interposer.dll`, `sl.common.dll` or `nvngx_dlss.dll`).+Every other path is untouched. `compat_run.sh` sets the variable only with `NVAPI=1` on D3DMetal.++Verified 2026-10-12: RE Requiem lists NVIDIA DLSS; 007 First Light logs+`Loaded NGXCore from path (C:\windows\system32\nvngx.dll)`.++Build in a tree configured as in `winemac-patch/README.md` (with+`DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer` so the x86_64 clang runs):+`make dlls/crypt32/x86_64-windows/crypt32.dll dlls/wintrust/x86_64-windows/wintrust.dll`, then+`x86_64-w64-mingw32-strip --strip-debug`. Pins: `FreeEngineWinecx.v1117.signer`.diff --git a/ngx-signer-patch/winecx-ngx-signer.patch b/ngx-signer-patch/winecx-ngx-signer.patchnew file mode 100644index 0000000..1d93e29--- /dev/null+++ b/ngx-signer-patch/winecx-ngx-signer.patch@@ -0,0 +1,142 @@+diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c+index 8a4a161b..fc88b3fa 100644+--- a/dlls/crypt32/object.c++++ b/dlls/crypt32/object.c+@@ -767,7 +767,7 @@ static BOOL CRYPT_QueryPFXObject(DWORD dwObjectType, const void *pvObject,+ return ret;+ }++-BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject,++static BOOL crypt_query_object(DWORD dwObjectType, const void *pvObject,+ DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags,+ DWORD dwFlags, DWORD *pdwMsgAndCertEncodingType, DWORD *pdwContentType,+ DWORD *pdwFormatType, HCERTSTORE *phCertStore, HCRYPTMSG *phMsg,+@@ -863,6 +863,54 @@ BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject,+ return ret;+ }+++/* NotProton: Apple's MetalFX DLSS bridge (nvngx-on-metalfx, linked as system32 nvngx.dll)++ * carries no NVIDIA signature, and the NGX loader inside NVIDIA Streamline refuses an++ * unsigned NGX core, so Streamline games never offer DLSS. When the run script sets++ * NOTPROTON_NGX_SIGNER (NVAPI=1 on D3DMetal), a signature check of that one file, by++ * path, is answered from an NVIDIA-signed Streamline module that ships with the game. */++static const WCHAR *notproton_ngx_signer( const WCHAR *path, WCHAR *buf, DWORD len )++{++ static const WCHAR * const signed_modules[] = { L"sl.interposer.dll", L"sl.common.dll", L"nvngx_dlss.dll" };++ const WCHAR *base;++ WCHAR *slash;++ DWORD i;++++ if (!path || !GetEnvironmentVariableW( L"NOTPROTON_NGX_SIGNER", NULL, 0 )) return path;++ base = wcsrchr( path, '\\' );++ if (!base) return path;++ base++;++ if (wcsicmp( base, L"nvngx.dll" ) && wcsicmp( base, L"_nvngx.dll" )) return path;++ if (base - path < 10 || wcsnicmp( base - 10, L"\\system32\\", 10 )) return path;++ if (!GetModuleFileNameW( NULL, buf, len ) || !(slash = wcsrchr( buf, '\\' ))) return path;++ for (i = 0; i < ARRAY_SIZE(signed_modules); i++)++ {++ if (wcslen( signed_modules[i] ) + 1 > len - (DWORD)(slash + 1 - buf)) continue;++ wcscpy( slash + 1, signed_modules[i] );++ if (GetFileAttributesW( buf ) == INVALID_FILE_ATTRIBUTES) continue;++ FIXME( "NotProton: checking the signature of %s against %s\n", debugstr_w(path), debugstr_w(buf) );++ return buf;++ }++ return path;++}++++/***********************************************************************++ * CryptQueryObject (CRYPT32.@)++ */++BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject,++ DWORD dwExpectedContentTypeFlags, DWORD dwExpectedFormatTypeFlags,++ DWORD dwFlags, DWORD *pdwMsgAndCertEncodingType, DWORD *pdwContentType,++ DWORD *pdwFormatType, HCERTSTORE *phCertStore, HCRYPTMSG *phMsg,++ const void **ppvContext)++{++ WCHAR ngx_signer[MAX_PATH];++++ if (dwObjectType == CERT_QUERY_OBJECT_FILE)++ pvObject = notproton_ngx_signer(pvObject, ngx_signer, ARRAY_SIZE(ngx_signer));++ return crypt_query_object(dwObjectType, pvObject, dwExpectedContentTypeFlags,++ dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType,++ pdwFormatType, phCertStore, phMsg, ppvContext);++}+++ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,+ DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct,+ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat,+diff --git a/dlls/wintrust/wintrust_main.c b/dlls/wintrust/wintrust_main.c+index a9b1587e..b72094ea 100644+--- a/dlls/wintrust/wintrust_main.c++++ b/dlls/wintrust/wintrust_main.c+@@ -655,6 +655,39 @@ static void dump_wintrust_data(WINTRUST_DATA *data)+ * Trust providers can be found at:+ * HKLM\SOFTWARE\Microsoft\Cryptography\Providers\Trust\+ */++/* NotProton: Apple's MetalFX DLSS bridge (nvngx-on-metalfx, linked as system32 nvngx.dll)++ * carries no NVIDIA signature, and the NGX loader inside NVIDIA Streamline refuses an++ * unsigned NGX core, so Streamline games never offer DLSS. When the run script sets++ * NOTPROTON_NGX_SIGNER (NVAPI=1 on D3DMetal), a signature check of that one file, by++ * path, is answered from an NVIDIA-signed Streamline module that ships with the game. */++static const WCHAR *notproton_ngx_signer( const WCHAR *path, WCHAR *buf, DWORD len )++{++ static const WCHAR * const signed_modules[] = { L"sl.interposer.dll", L"sl.common.dll", L"nvngx_dlss.dll" };++ const WCHAR *base;++ WCHAR *slash;++ DWORD i;++++ if (!path || !GetEnvironmentVariableW( L"NOTPROTON_NGX_SIGNER", NULL, 0 )) return path;++ base = wcsrchr( path, '\\' );++ if (!base) return path;++ base++;++ if (wcsicmp( base, L"nvngx.dll" ) && wcsicmp( base, L"_nvngx.dll" )) return path;++ if (base - path < 10 || wcsnicmp( base - 10, L"\\system32\\", 10 )) return path;++ if (!GetModuleFileNameW( NULL, buf, len ) || !(slash = wcsrchr( buf, '\\' ))) return path;++ for (i = 0; i < ARRAY_SIZE(signed_modules); i++)++ {++ if (wcslen( signed_modules[i] ) + 1 > len - (DWORD)(slash + 1 - buf)) continue;++ wcscpy( slash + 1, signed_modules[i] );++ if (GetFileAttributesW( buf ) == INVALID_FILE_ATTRIBUTES) continue;++ FIXME( "NotProton: checking the signature of %s against %s\n", debugstr_w(path), debugstr_w(buf) );++ return buf;++ }++ return path;++}++++/***********************************************************************++ * WinVerifyTrust (WINTRUST.@) with the NotProton NGX signer redirect++ */+ LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )+ {+ static const GUID unknown = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,+@@ -667,9 +700,21 @@ LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )+ LONG err = ERROR_SUCCESS;+ WINTRUST_DATA *actionData = ActionData;+++ WINTRUST_FILE_INFO *ngx_file = NULL;++ LPCWSTR ngx_path = NULL;++ WCHAR ngx_signer[MAX_PATH];+++ TRACE("(%p, %s, %p)\n", hwnd, debugstr_guid(ActionID), ActionData);+ dump_wintrust_data(ActionData);+++ if (actionData && actionData->dwUnionChoice == WTD_CHOICE_FILE && actionData->pFile &&++ !actionData->pFile->hFile)++ {++ ngx_file = actionData->pFile;++ ngx_path = ngx_file->pcwszFilePath;++ ngx_file->pcwszFilePath = notproton_ngx_signer( ngx_path, ngx_signer, ARRAY_SIZE(ngx_signer) );++ }+++ /* Support for known old-style callers: */+ if (IsEqualGUID(ActionID, &published_software))+ err = WINTRUST_PublishedSoftware(hwnd, ActionID, ActionData);+@@ -709,6 +754,7 @@ LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )+ }+ }+++ if (ngx_file) ngx_file->pcwszFilePath = ngx_path;+ if (err) SetLastError(err);+ TRACE("returning %08lx\n", err);+ return err;