Skip to content

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

feat(gamefixes): HIDE_WINE_EXPORTS hides Wine's version from games

raymondchins4a691ffb02f5
diff --git a/NOTICE b/NOTICE
index 407a766..c800140 100644
--- a/NOTICE
+++ b/NOTICE
@@ -56,6 +56,8 @@ sha256 pins are in docs/WINECX.md and each patch directory's README.
d3dx11_42-winecx-11.17-i386.dll (same patch)
crypt32-winecx-11.17.dll ngx-signer-patch/winecx-ngx-signer.patch
wintrust-winecx-11.17.dll ngx-signer-patch/winecx-ngx-signer.patch
+ kernel32-winecx-11.17.dll hide-wine-exports-patch/winecx-hide-wine-exports.patch
+ kernelbase-winecx-11.17.dll hide-wine-exports-patch/winecx-hide-wine-exports.patch
WineCX 11.15 (winecx 5b45f4564c4f87fa9c0f958733a5e9bb3918a058, runtime 4.5.125):
winemac-winecx-11.15.so winemac-patch/winecx-d3dmetal-retina.patch
diff --git a/app/Package.swift b/app/Package.swift
index d62d806..282e7e3 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/kernel32-winecx-11.17.dll"),
+ .copy("Resources/kernelbase-winecx-11.17.dll"),
.copy("Resources/crypt32-winecx-11.17.dll"),
.copy("Resources/wintrust-winecx-11.17.dll"),
.copy("Resources/nvapi64-shim.dll"),
diff --git a/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift b/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
index 6917544..9239e08 100644
--- a/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
+++ b/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
@@ -72,6 +72,10 @@ struct WinecxRelease: Sendable {
// Persona 4 Golden import and Wine leaves as a stub (d3dx11-patch/). Empty where the
// runtime's own are kept.
let d3dx: [WinecxBundledFile]
+ // kernel32 and kernelbase rebuilt so GetProcAddress can hide ntdll's wine_* exports from
+ // games that turn features off under Wine (hide-wine-exports-patch/,
+ // NOTPROTON_HIDE_WINE_EXPORTS). Empty where the runtime's own are kept.
+ let loader: [WinecxBundledFile]
// The runner build this release unpacks to, keyed by its pinned loader, and the ntdll
// detours for it (NtdllPatcher.byBuild).
let runner: RunnerBuild
@@ -214,6 +218,16 @@ enum FreeEngineWinecx {
path: "lib/wine/i386-windows/d3dx11_42.dll",
sha256: "85075f8b4f30f1a993238a0d6ab772a3a3df6c031e87ee9401c4367a527cd57c"),
],
+ // kernel32.dll, kernelbase.dll: winecx e0aa380's PE halves with
+ // hide-wine-exports-patch/winecx-hide-wine-exports.patch.
+ loader: [
+ WinecxBundledFile(resource: "kernel32-winecx-11.17", ext: "dll",
+ path: "lib/wine/x86_64-windows/kernel32.dll",
+ sha256: "9cffe153abd3f91f7157f936377baac47c5aef9fa807e263a0f9e051c6010af3"),
+ WinecxBundledFile(resource: "kernelbase-winecx-11.17", ext: "dll",
+ path: "lib/wine/x86_64-windows/kernelbase.dll",
+ sha256: "4d55600b204724046567688ca96132e49e53af1baac7a362f3e2bf285f669a8a"),
+ ],
runner: RunnerBuild(
bundleVersion: "winecx-11.17",
releaseVersion: "WineCX 11.17",
@@ -304,6 +318,7 @@ enum FreeEngineWinecx {
nvidia: [],
audio: [],
d3dx: [],
+ loader: [],
// The hash-pinned loader is what makes it free, so a CrossOver install can never be
// taken for it.
runner: RunnerBuild(
@@ -396,7 +411,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 + release.nvidia + release.audio + release.d3dx { table[file.path] = file.sha256 }
+ for file in release.gamepad + release.network + release.nvidia + release.audio + release.d3dx + release.loader { 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)
@@ -485,7 +500,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 + release.nvidia + release.audio + release.d3dx, root: root)
+ try installBundled(release.gamepad + release.network + release.nvidia + release.audio + release.d3dx + release.loader, root: root)
let libraries = wine.deletingLastPathComponent()
for file in release.backends {
diff --git a/app/Sources/BridgeplayApp/Resources/kernel32-winecx-11.17.dll b/app/Sources/BridgeplayApp/Resources/kernel32-winecx-11.17.dll
new file mode 100755
index 0000000..0feacdb
Binary files /dev/null and b/app/Sources/BridgeplayApp/Resources/kernel32-winecx-11.17.dll differ
diff --git a/app/Sources/BridgeplayApp/Resources/kernelbase-winecx-11.17.dll b/app/Sources/BridgeplayApp/Resources/kernelbase-winecx-11.17.dll
new file mode 100755
index 0000000..0b5d13a
Binary files /dev/null and b/app/Sources/BridgeplayApp/Resources/kernelbase-winecx-11.17.dll differ
diff --git a/app/Tests/BridgeplayAppTests/FreeEngineWinecxTests.swift b/app/Tests/BridgeplayAppTests/FreeEngineWinecxTests.swift
index 8023aae..48d6be0 100644
--- a/app/Tests/BridgeplayAppTests/FreeEngineWinecxTests.swift
+++ b/app/Tests/BridgeplayAppTests/FreeEngineWinecxTests.swift
@@ -228,6 +228,23 @@ struct FreeEngineWinecxTests {
}
}
+ // hide-wine-exports-patch: 11.17 ships kernel32 and kernelbase that can hide ntdll's
+ // wine_* exports; 11.15 keeps the runtime's.
+ @Test("The hide-Wine-exports kernel32 and kernelbase ship with the app and are pinned for 11.17",
+ arguments: FreeEngineWinecx.releases.map(\.build))
+ func hideWineExports(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/kernel32.dll", "lib/wine/x86_64-windows/kernelbase.dll"] : []
+ #expect(Set(release.loader.map(\.path)) == expected)
+ let table = FreeEngineWinecx.expectedFiles(release)
+ for file in release.loader {
+ 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)")
+ }
+ }
+
// winecoreaudio-patch: 11.17 ships a winecoreaudio.so with half-period output pulls.
@Test("The patched winecoreaudio ships with the app and is pinned for 11.17",
arguments: FreeEngineWinecx.releases.map(\.build))
diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.md
index b870901..8c0c495 100644
--- a/docs/GAMEFIXES.md
+++ b/docs/GAMEFIXES.md
@@ -38,6 +38,7 @@ logged, when:
| `DLSS_FG` | `0`, `1` | With `NVAPI=1` on `d3dmetal`, `1` sets `CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal` so WineCX reports hardware GPU scheduling, which DLSS frame generation requires. Off by default: [frankea/Whisky#231](https://github.com/frankea/Whisky/pull/231) saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer |
| `STDOUT_NULL` | `0`, `1` | `1` starts the game without a stdout handle, as Steam on Windows does. Source 2 treats any stdout as a console build (`Plat_IsConsoleApplication`) and then skips NGX, so Deadlock offers no DLSS |
| `VSYNC` | `0`, `1` | `1` makes the game's Metal layer wait for the display even when the game turns vsync off, like forcing vsync in the NVIDIA control panel. For games that lock vsync off with frame generation on (Resident Evil Requiem) and tear above the refresh rate |
+| `HIDE_WINE_EXPORTS` | `0`, `1` | `1` makes `GetProcAddress` fail for ntdll's `wine_*` exports on the WineCX 11.17 engine (`hide-wine-exports-patch/`), like Wine Staging's `HideWineExports`. For games that turn features off under Wine: The Witcher 3 5.0 skips NVIDIA Streamline, so no DLSS |
| `DXMT_*`, `DXVK_*`, `MVK_*`, `VKD3D_*`, `D3DM_*`, `STAGING_*` | any | Exported as is |
| `MTL_HUD_ENABLED`, `WINEDEBUG`, `WINE_LARGE_ADDRESS_AWARE`, `WINE_CPU_TOPOLOGY` | any | Exported as is |
| `CX_FWD_COMPAT_GL_CTX` | any | Exported as is: WineCX's switch for forward-compatible OpenGL contexts, for testing OpenGL (`wined3d`) games |
diff --git a/docs/WINECX.md b/docs/WINECX.md
index 5ea7f2d..afa0816 100644
--- a/docs/WINECX.md
+++ b/docs/WINECX.md
@@ -98,6 +98,7 @@ lib/wine/x86_64-unix/winemac.so Retina fix, replacing the arch
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/wine/x86_64-windows/ws2_32.dll 11.17 only: own host name without loopback, replacing the archive's (Own host name)
+lib/wine/x86_64-windows/kernel{32,base}.dll 11.17 only: GetProcAddress can hide ntdll's wine_* exports, replacing the archive's (Hidden Wine exports)
lib/wine/{x86_64,i386}-windows/d3dx11_4{2,3}.dll 11.17 only: D3DX11CreateThreadPump stub, replacing the archive's (D3DX11 thread pump)
lib/libSDL2-2.0.0.dylib SDL 2.32.10, x86_64, for winebus.so (Controllers)
```
@@ -205,6 +206,22 @@ is byte-identical to the runtime's `ws2_32.dll`; only the PE timestamp, checksum
differ, and the runtime's `.eh_frame` section name is cut to `.eh_fram` (10 bytes of string
table). 11.15 keeps the runtime's own `ws2_32.dll`, so it still answers loopback first.
+## Hidden Wine exports
+
+Some games turn features off once `GetProcAddress(ntdll, "wine_get_version")` answers. The
+Witcher 3 5.0 then never calls `slInit`: Streamline logs only `SL not initialized or no plugins
+found` and the game offers FSR and XeSS but no DLSS. Wine Staging's `HideWineExports` covers
+this; WineCX has no equivalent.
+
+11.17 ships `kernel32-winecx-11.17.dll` and `kernelbase-winecx-11.17.dll` as
+`lib/wine/x86_64-windows/kernel32.dll` and `kernelbase.dll`: winecx `e0aa380`'s PE halves with
+`hide-wine-exports-patch/winecx-hide-wine-exports.patch`. With `NOTPROTON_HIDE_WINE_EXPORTS`
+set (gamefix key `HIDE_WINE_EXPORTS=1`), both `GetProcAddress` copies fail a lookup by name of
+an ntdll export starting with `wine_`. `__wine_*` stays, since every builtin's
+`__wine_init_unix_call` needs it. Without the variable they behave as the runtime's.
+Built and pinned as in `hide-wine-exports-patch/README.md`; the pins are the release's
+`loader`. 11.15 keeps the runtime's own.
+
## D3DX11 thread pump
Wine's `d3dx11_43` and `d3dx11_42` declare `D3DX11CreateThreadPump` as a spec stub, so a game
@@ -381,6 +398,8 @@ python3 apply.py <ntdll.dll> <out> <detour bin> # patched hashes
| `winebus-winecx-11.17.so` | `6223c035c824c90708abbc3e733f8d1d6ed6b8b4e9a3e1a5c813493ceba50473` |
| `winebus-winecx-11.17.sys` | `da108d1c3788fa32807ef08c4d26d8a89812c230317ffa7ba5111e126bda607c` |
| `ws2_32-winecx-11.17.dll` | `cb0a5670ce6dbf949ed25cca54e9f1c4930cd4c2ade895836d518d3d9073079c` |
+| `kernel32-winecx-11.17.dll` | `9cffe153abd3f91f7157f936377baac47c5aef9fa807e263a0f9e051c6010af3` |
+| `kernelbase-winecx-11.17.dll` | `4d55600b204724046567688ca96132e49e53af1baac7a362f3e2bf285f669a8a` |
| `d3dx11_43-winecx-11.17.dll` | `7d23cdfacc922f67dfa2eba98df277ae2ae351ad3646c3191a84966b55dbbfd3` |
| `d3dx11_43-winecx-11.17-i386.dll` | `dd4dd351f2a5880c9848d5ccf4944a0b5e7622bb7fb196544115b1f9c92d749c` |
| `d3dx11_42-winecx-11.17.dll` | `3d97e1de9000a78e27eb5c90d0ab9b36d54fd350760063da27226d22c90c8e1b` |
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index 8571552..e31f310 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -432,7 +432,7 @@ gamefix_reason() {
case "$1" in
BACKEND)
case "$2" in dxmt|dxvk|wined3d|d3dmetal) ;; *) echo "not dxmt, dxvk, wined3d or d3dmetal" ;; esac ;;
- MSYNC|RETINA|NVAPI|DLSS_FG|STDOUT_NULL|VSYNC|FRAMEGEN_UI|FRAMEGEN_FALLBACK|STEAMDECK)
+ MSYNC|RETINA|NVAPI|DLSS_FG|STDOUT_NULL|VSYNC|HIDE_WINE_EXPORTS|FRAMEGEN_UI|FRAMEGEN_FALLBACK|STEAMDECK)
case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;
FRAMEGEN)
# 1 is the 2x of the first release.
@@ -523,6 +523,7 @@ load_gamefixes() {
DLSS_FG) gamefix_dlss_fg=$value; gamefix_log "DLSS_FG=$value from the $from conf" ;;
STDOUT_NULL) gamefix_apply_env NOTPROTON_STDOUT_NULL "$value" "$from" ;;
VSYNC) gamefix_apply_env NOTPROTON_VSYNC "$value" "$from" ;;
+ HIDE_WINE_EXPORTS) gamefix_apply_env NOTPROTON_HIDE_WINE_EXPORTS "$value" "$from" ;;
ARGS)
if [ "$verb" = waitforexitandrun ]; then
gamefix_args=$value
@@ -2805,7 +2806,7 @@ else
echo "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || true
fi
set -- --args "$shim_exe" "$@"
-for name in $(env | LC_ALL=C sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|CX_FWD_COMPAT_GL_CTX|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|FEX_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?|NOTPROTON_NGX_SIGNER|NOTPROTON_NVAPI_DRIVER|NOTPROTON_DRIVER_VERSION|NOTPROTON_STDOUT_NULL|NOTPROTON_VSYNC|CX_ACTIVE_GRAPHICS_BACKEND)=.*/\1/p'); do
+for name in $(env | LC_ALL=C sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|CX_FWD_COMPAT_GL_CTX|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|FEX_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?|NOTPROTON_NGX_SIGNER|NOTPROTON_NVAPI_DRIVER|NOTPROTON_DRIVER_VERSION|NOTPROTON_STDOUT_NULL|NOTPROTON_VSYNC|NOTPROTON_HIDE_WINE_EXPORTS|CX_ACTIVE_GRAPHICS_BACKEND)=.*/\1/p'); do
eval "value=\$$name"
# shellcheck disable=SC2154 # eval assigns value on the line above
set -- --env "$name=$value" "$@"
diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.sh
index b5871e0..13ccd87 100644
--- a/dylib/tests/gamefixescheck.sh
+++ b/dylib/tests/gamefixescheck.sh
@@ -116,7 +116,7 @@ launch() {
eval "$bridge_line"
for v in backend WINEDLLOVERRIDES WINEMSYNC msync_from NOTPROTON_RETINA NOTPROTON_FRAMEGEN \
NOTPROTON_FRAMEGEN_QUALITY NOTPROTON_FRAMEGEN_UI NOTPROTON_FRAMEGEN_FALLBACK NOTPROTON_FRAMEGEN_ENGINE CX_GRAPHICS_BACKEND \
- DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED D3DM_VENDOR_ID D3DM_DEVICE_ID D3DM_DEVICE_DESCRIPTION NOTPROTON_NGX_SIGNER NOTPROTON_DRIVER_VERSION CX_ACTIVE_GRAPHICS_BACKEND NOTPROTON_VSYNC CX_FWD_COMPAT_GL_CTX gamefix_args; do
+ DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED D3DM_VENDOR_ID D3DM_DEVICE_ID D3DM_DEVICE_DESCRIPTION NOTPROTON_NGX_SIGNER NOTPROTON_DRIVER_VERSION CX_ACTIVE_GRAPHICS_BACKEND NOTPROTON_VSYNC NOTPROTON_HIDE_WINE_EXPORTS CX_FWD_COMPAT_GL_CTX gamefix_args; do
eval "printf \"%s=%s\\n\" \$v \"\${$v-<unset>}\""
done
' launch "$target" > "$case_dir/out" 2>&1 || echo "launch exited $?" >> "$case_dir/out"
@@ -398,6 +398,9 @@ is "DLSS_FG=1 reports hardware scheduling for DLSS frame generation" "d3dmetal"
user_conf 'VSYNC=1'
launch waitforexitandrun "$case_dir/game/game.exe"
is "VSYNC=1 asks the overlay shim to keep the layer on display sync" "1" "$(got NOTPROTON_VSYNC)"
+user_conf 'HIDE_WINE_EXPORTS=1'
+launch waitforexitandrun "$case_dir/game/game.exe"
+is "HIDE_WINE_EXPORTS=1 hides ntdll's wine_* exports from GetProcAddress" "1" "$(got NOTPROTON_HIDE_WINE_EXPORTS)"
user_conf 'NVAPI=1' 'BACKEND=dxmt'
launch waitforexitandrun "$case_dir/game/game.exe"
is "but not for dxmt" "d3d10core,d3d11,dxgi=n,b;d3d10,d3d12=b;nvapi64,nvngx=d;$trio" "$(got WINEDLLOVERRIDES)"
diff --git a/hide-wine-exports-patch/README.md b/hide-wine-exports-patch/README.md
new file mode 100644
index 0000000..64eb05c
--- /dev/null
+++ b/hide-wine-exports-patch/README.md
@@ -0,0 +1,28 @@
+# hide-wine-exports-patch
+
+Some games look up `wine_get_version` in ntdll and turn features off when it answers. The
+Witcher 3 5.0 (`witcher3.exe`, `GetProcAddress(ntdll, "wine_get_version")`) then never calls
+`slInit`, so NVIDIA Streamline loads no plugins and the game offers no DLSS, only FSR and XeSS.
+Wine Staging hides these exports with `HideWineExports`; WineCX has no such switch.
+
+`winecx-hide-wine-exports.patch` (against winecx `e0aa380`) adds a check to
+`get_proc_address` in `dlls/kernel32/module.c` and `dlls/kernelbase/loader.c`: with
+`NOTPROTON_HIDE_WINE_EXPORTS` set, a lookup by name of an ntdll export starting with `wine_`
+(`wine_get_version`, `wine_get_build_id`, `wine_get_host_version`, `wine_server_call`, ...) fails
+with `ERROR_PROC_NOT_FOUND`. `__wine_*` stays visible: winecrt0's `__wine_init_unix_call` looks
+those up in every builtin, and hiding them stops D3DMetal's `dxgi.dll` from initializing. Other
+modules are untouched (gdi32 and user32 look up `wine_` names in display drivers and imm32), and
+so are lookups by ordinal,
+`LdrGetProcedureAddress` and static imports. `compat_run.sh` sets the variable for the
+`HIDE_WINE_EXPORTS=1` gamefix key.
+
+Build in the tree from `winemac-patch/README.md` (mingw-w64 gcc 16.2,
+`DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer`):
+`make dlls/kernel32/x86_64-windows/kernel32.dll dlls/kernelbase/x86_64-windows/kernelbase.dll`,
+with each DLL's `.res` files made by the `make -n` lines with `--po-dir` pointed at an empty
+folder (the runtime carries English resources only; with the tree's `po/` kernelbase grows by
+1.6 MB), then `x86_64-w64-mingw32-strip --strip-debug`. `.rsrc` then matches the runtime's
+byte for byte. Built without the patch, kernelbase's `.text` differs from the runtime's in 12
+bytes only: offsets to the critical-section names, which carry the source path
+(`../winecx-1117/` here, `../winecx/` in the CI). Pins: `FreeEngineWinecx.v1117.loader` and
+`docs/WINECX.md`.
diff --git a/hide-wine-exports-patch/winecx-hide-wine-exports.patch b/hide-wine-exports-patch/winecx-hide-wine-exports.patch
new file mode 100644
index 0000000..90b6a3a
--- /dev/null
+++ b/hide-wine-exports-patch/winecx-hide-wine-exports.patch
@@ -0,0 +1,84 @@
+--- a/dlls/kernel32/module.c
++++ b/dlls/kernel32/module.c
+@@ -259,6 +259,27 @@
+ &app_nameA, FALSE )))
+ return FALSE;
+ return GetBinaryTypeW(NtCurrentTeb()->StaticUnicodeString.Buffer, lpBinaryType);
++}
++
++/* NotProton: some games turn features off once ntdll answers wine_get_version (The Witcher 3
++ * 5.0 then never starts NVIDIA Streamline, so it offers no DLSS). With
++ * NOTPROTON_HIDE_WINE_EXPORTS set, a lookup of ntdll's wine_* exports by name fails as on
++ * Windows. __wine_* stays: winecrt0's __wine_init_unix_call in every builtin looks those up.
++ * Other modules are untouched: gdi32 and user32 look up wine_ names in display drivers and
++ * imm32. kernel32 and kernelbase each carry this copy. */
++static BOOL notproton_hidden_export( HMODULE module, const char *name )
++{
++ static int hide = -1;
++ static HMODULE ntdll;
++
++ if (hide == -1)
++ {
++ ntdll = GetModuleHandleW( L"ntdll.dll" );
++ hide = GetEnvironmentVariableW( L"NOTPROTON_HIDE_WINE_EXPORTS", NULL, 0 ) != 0;
++ }
++ if (!hide || module != ntdll || strncmp( name, "wine_", 5 )) return FALSE;
++ TRACE( "NotProton: hiding ntdll.%s\n", debugstr_a(name) );
++ return TRUE;
+ }
+
+ /***********************************************************************
+@@ -284,6 +305,11 @@
+ {
+ ANSI_STRING str;
+
++ if (notproton_hidden_export( hModule, function ))
++ {
++ SetLastError( ERROR_PROC_NOT_FOUND );
++ return NULL;
++ }
+ RtlInitAnsiString( &str, function );
+ if (!set_ntstatus( LdrGetProcedureAddress( hModule, &str, 0, (void**)&fp ))) return NULL;
+ }
+--- a/dlls/kernelbase/loader.c
++++ b/dlls/kernelbase/loader.c
+@@ -59,6 +59,27 @@
+ * Modules
+ ***********************************************************************/
+
++
++/* NotProton: some games turn features off once ntdll answers wine_get_version (The Witcher 3
++ * 5.0 then never starts NVIDIA Streamline, so it offers no DLSS). With
++ * NOTPROTON_HIDE_WINE_EXPORTS set, a lookup of ntdll's wine_* exports by name fails as on
++ * Windows. __wine_* stays: winecrt0's __wine_init_unix_call in every builtin looks those up.
++ * Other modules are untouched: gdi32 and user32 look up wine_ names in display drivers and
++ * imm32. kernel32 and kernelbase each carry this copy. */
++static BOOL notproton_hidden_export( HMODULE module, const char *name )
++{
++ static int hide = -1;
++ static HMODULE ntdll;
++
++ if (hide == -1)
++ {
++ ntdll = GetModuleHandleW( L"ntdll.dll" );
++ hide = GetEnvironmentVariableW( L"NOTPROTON_HIDE_WINE_EXPORTS", NULL, 0 ) != 0;
++ }
++ if (!hide || module != ntdll || strncmp( name, "wine_", 5 )) return FALSE;
++ TRACE( "NotProton: hiding ntdll.%s\n", debugstr_a(name) );
++ return TRUE;
++}
+
+ /******************************************************************
+ * get_proc_address
+@@ -72,6 +93,11 @@
+
+ if ((ULONG_PTR)function >> 16)
+ {
++ if (notproton_hidden_export( module, function ))
++ {
++ SetLastError( ERROR_PROC_NOT_FOUND );
++ return NULL;
++ }
+ RtlInitAnsiString( &str, function );
+ if (!set_ntstatus( LdrGetProcedureAddress( module, &str, 0, (void**)&proc ))) return NULL;
+ }