Alexandre Julliard : ntdll: Make the windows directory a global variable.

Alexandre Julliard julliard at winehq.org
Thu May 21 15:41:20 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu May 21 12:40:08 2020 +0200

ntdll: Make the windows directory a global variable.

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

---

 dlls/ntdll/actctx.c     | 6 +++---
 dlls/ntdll/env.c        | 2 --
 dlls/ntdll/loader.c     | 6 ++++--
 dlls/ntdll/ntdll_misc.h | 1 +
 dlls/ntdll/thread.c     | 3 +--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index 6ae34cb416..af9499c404 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -3189,11 +3189,11 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit
     if (!ai->arch || !ai->name || !ai->public_key) return STATUS_NO_SUCH_FILE;
 
     if (!(path = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(manifest_dirW) +
-                                  wcslen(user_shared_data->NtSystemRoot) * sizeof(WCHAR) )))
+                                  wcslen(windows_dir) * sizeof(WCHAR) )))
         return STATUS_NO_MEMORY;
 
-    wcscpy( path, user_shared_data->NtSystemRoot );
-    memcpy( path + wcslen(path), manifest_dirW, sizeof(manifest_dirW) );
+    wcscpy( path, windows_dir );
+    wcscat( path, manifest_dirW );
 
     if (!RtlDosPathNameToNtPathName_U( path, &path_us, NULL, NULL ))
     {
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index f81f500bcb..f8b243154b 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -50,8 +50,6 @@ static const UNICODE_STRING null_str = { 0, 0, NULL };
 
 static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
 
-static const WCHAR windows_dir[] = {'C',':','\\','w','i','n','d','o','w','s',0};
-
 static BOOL first_prefix_start;  /* first ever process start in this prefix? */
 
 static inline SIZE_T get_env_length( const WCHAR *env )
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 6e41b37ad8..3c05c524af 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -69,6 +69,8 @@ typedef void  (CALLBACK *LDRENUMPROC)(LDR_DATA_TABLE_ENTRY *, void *, BOOLEAN *)
 
 const struct unix_funcs *unix_funcs = NULL;
 
+/* windows directory */
+const WCHAR windows_dir[] = {'C',':','\\','w','i','n','d','o','w','s',0};
 /* system directory with trailing backslash */
 const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
                             's','y','s','t','e','m','3','2','\\',0};
@@ -2870,7 +2872,7 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname )
         goto done;
     }
 
-    needed = (wcslen(user_shared_data->NtSystemRoot) * sizeof(WCHAR) +
+    needed = (wcslen(windows_dir) * sizeof(WCHAR) +
               sizeof(winsxsW) + info->ulAssemblyDirectoryNameLength + nameW.Length + 2*sizeof(WCHAR));
 
     if (!(*fullname = p = RtlAllocateHeap( GetProcessHeap(), 0, needed )))
@@ -2878,7 +2880,7 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname )
         status = STATUS_NO_MEMORY;
         goto done;
     }
-    wcscpy( p, user_shared_data->NtSystemRoot );
+    wcscpy( p, windows_dir );
     p += wcslen(p);
     memcpy( p, winsxsW, sizeof(winsxsW) );
     p += ARRAY_SIZE( winsxsW );
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 4321347e72..9e1f6e20fc 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -144,6 +144,7 @@ extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY
                                      FARPROC origfun, DWORD ordinal, const WCHAR *user ) DECLSPEC_HIDDEN;
 extern void RELAY_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
 extern void SNOOP_SetupDLL( HMODULE hmod ) DECLSPEC_HIDDEN;
+extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
 extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
 extern const WCHAR syswow64_dir[] DECLSPEC_HIDDEN;
 
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 238a63aad0..3345a9c515 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -54,7 +54,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread);
 
 struct _KUSER_SHARED_DATA *user_shared_data = NULL;
 static size_t user_shared_data_size;
-static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0};
 
 void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL;
 
@@ -275,7 +274,7 @@ TEB *thread_init(void)
     }
     user_shared_data = addr;
     user_shared_data_size = size;
-    memcpy( user_shared_data->NtSystemRoot, default_windirW, sizeof(default_windirW) );
+    wcscpy( user_shared_data->NtSystemRoot, windows_dir );
 
     /* allocate and initialize the PEB and initial TEB */
 




More information about the wine-cvs mailing list