Skip to content

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

3.2 KB
Raw Blame
--- 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;
     }