Alexandre Julliard : kernel32: Set environment variables for the various Wine paths.

Alexandre Julliard julliard at winehq.org
Fri Jul 5 14:49:17 CDT 2019


Module: wine
Branch: master
Commit: d5400af7825581b7cf174f65d951b527154e2987
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d5400af7825581b7cf174f65d951b527154e2987

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jul  4 15:40:11 2019 +0200

kernel32: Set environment variables for the various Wine paths.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/process.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 3e33fa7..7c40c34 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -676,6 +676,23 @@ static WCHAR *get_reg_value( HKEY hkey, const WCHAR *name )
     return ret;
 }
 
+/* set an environment variable for one of the wine path variables */
+static void set_wine_path_variable( const WCHAR *name, const char *unix_path )
+{
+    UNICODE_STRING nt_name, var_name;
+    ANSI_STRING unix_name;
+
+    RtlInitUnicodeString( &var_name, name );
+    if (unix_path)
+    {
+        RtlInitAnsiString( &unix_name, unix_path );
+        if (wine_unix_to_nt_file_name( &unix_name, &nt_name )) return;
+        RtlSetEnvironmentVariable( NULL, &var_name, &nt_name );
+        RtlFreeUnicodeString( &nt_name );
+    }
+    else RtlSetEnvironmentVariable( NULL, &var_name, NULL );
+}
+
 
 /***********************************************************************
  *           set_additional_environment
@@ -697,12 +714,31 @@ static void set_additional_environment(void)
     static const WCHAR allusersW[] = {'A','L','L','U','S','E','R','S','P','R','O','F','I','L','E',0};
     static const WCHAR programdataW[] = {'P','r','o','g','r','a','m','D','a','t','a',0};
     static const WCHAR publicW[] = {'P','U','B','L','I','C',0};
+    static const WCHAR winedlldirW[] = {'W','I','N','E','D','L','L','D','I','R','%','u',0};
+    static const WCHAR winehomedirW[] = {'W','I','N','E','H','O','M','E','D','I','R',0};
+    static const WCHAR winedatadirW[] = {'W','I','N','E','D','A','T','A','D','I','R',0};
+    static const WCHAR winebuilddirW[] = {'W','I','N','E','B','U','I','L','D','D','I','R',0};
+    static const WCHAR wineconfigdirW[] = {'W','I','N','E','C','O','N','F','I','G','D','I','R',0};
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING nameW;
+    const char *path;
     WCHAR *profile_dir = NULL, *program_data_dir = NULL, *public_dir = NULL;
-    WCHAR buf[MAX_COMPUTERNAME_LENGTH+1];
+    WCHAR buf[32];
     HANDLE hkey;
-    DWORD len;
+    DWORD len, i;
+
+    /* wine paths */
+    set_wine_path_variable( winedatadirW, wine_get_data_dir() );
+    set_wine_path_variable( winehomedirW, getenv("HOME") );
+    set_wine_path_variable( winebuilddirW, wine_get_build_dir() );
+    set_wine_path_variable( wineconfigdirW, wine_get_config_dir() );
+    for (i = 0; (path = wine_dll_enum_load_path( i )); i++)
+    {
+        sprintfW( buf, winedlldirW, i );
+        set_wine_path_variable( buf, path );
+    }
+    sprintfW( buf, winedlldirW, i );
+    set_wine_path_variable( buf, NULL );
 
     /* ComputerName */
     len = ARRAY_SIZE( buf );




More information about the wine-cvs mailing list