Alexandre Julliard : ntdll: Initialize filesystem redirects before kernel32 is loaded.

Alexandre Julliard julliard at winehq.org
Tue Jul 2 15:32:02 CDT 2019


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jul  2 12:36:05 2019 +0200

ntdll: Initialize filesystem redirects before kernel32 is loaded.

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

---

 dlls/ntdll/directory.c | 78 ++++++--------------------------------------------
 dlls/ntdll/rtlstr.c    |  1 -
 dlls/ntdll/thread.c    |  1 +
 3 files changed, 10 insertions(+), 70 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index dd0062d..b50d41b 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2191,83 +2191,30 @@ static const WCHAR driversetcW[] = {'s','y','s','t','e','m','3','2','\\','d','r'
 static const WCHAR logfilesW[] = {'s','y','s','t','e','m','3','2','\\','l','o','g','f','i','l','e','s',0};
 static const WCHAR spoolW[] = {'s','y','s','t','e','m','3','2','\\','s','p','o','o','l',0};
 static const WCHAR system32W[] = {'s','y','s','t','e','m','3','2',0};
-static const WCHAR syswow64W[] = {'s','y','s','w','o','w','6','4',0};
 static const WCHAR sysnativeW[] = {'s','y','s','n','a','t','i','v','e',0};
 static const WCHAR regeditW[] = {'r','e','g','e','d','i','t','.','e','x','e',0};
-static const WCHAR wow_regeditW[] = {'s','y','s','w','o','w','6','4','\\','r','e','g','e','d','i','t','.','e','x','e',0};
 
 static struct
 {
     const WCHAR *source;
-    const WCHAR *dos_target;
     const char *unix_target;
 } redirects[] =
 {
-    { catrootW, NULL, NULL },
-    { catroot2W, NULL, NULL },
-    { driversstoreW, NULL, NULL },
-    { driversetcW, NULL, NULL },
-    { logfilesW, NULL, NULL },
-    { spoolW, NULL, NULL },
-    { system32W, syswow64W, NULL },
-    { sysnativeW, system32W, NULL },
-    { regeditW, wow_regeditW, NULL }
+    { catrootW, NULL },
+    { catroot2W, NULL },
+    { driversstoreW, NULL },
+    { driversetcW, NULL },
+    { logfilesW, NULL },
+    { spoolW, NULL },
+    { system32W, "syswow64" },
+    { sysnativeW, "system32" },
+    { regeditW, "syswow64/regedit.exe" }
 };
 
 static unsigned int nb_redirects;
 
 
 /***********************************************************************
- *           get_redirect_target
- *
- * Find the target unix name for a redirected dir.
- */
-static const char *get_redirect_target( const char *windows_dir, const WCHAR *name )
-{
-    int used_default, len, pos, win_len = strlen( windows_dir );
-    char *unix_name, *unix_target = NULL;
-    NTSTATUS status;
-
-    if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, win_len + MAX_DIR_ENTRY_LEN + 2 )))
-        return NULL;
-    memcpy( unix_name, windows_dir, win_len );
-    pos = win_len;
-
-    while (*name)
-    {
-        const WCHAR *end, *next;
-
-        for (end = name; *end; end++) if (IS_SEPARATOR(*end)) break;
-        for (next = end; *next; next++) if (!IS_SEPARATOR(*next)) break;
-
-        status = find_file_in_dir( unix_name, pos, name, end - name, FALSE, NULL );
-        if (status == STATUS_OBJECT_PATH_NOT_FOUND && !*next)  /* not finding last element is ok */
-        {
-            len = ntdll_wcstoumbs( 0, name, end - name, unix_name + pos + 1,
-                                   MAX_DIR_ENTRY_LEN - (pos - win_len), NULL, &used_default );
-            if (len > 0 && !used_default)
-            {
-                unix_name[pos] = '/';
-                pos += len + 1;
-                unix_name[pos] = 0;
-                break;
-            }
-        }
-        if (status) goto done;
-        pos += strlen( unix_name + pos );
-        name = next;
-    }
-
-    if ((unix_target = RtlAllocateHeap( GetProcessHeap(), 0, pos - win_len )))
-        memcpy( unix_target, unix_name + win_len + 1, pos - win_len );
-
-done:
-    RtlFreeHeap( GetProcessHeap(), 0, unix_name );
-    return unix_target;
-}
-
-
-/***********************************************************************
  *           init_redirects
  */
 static void init_redirects(void)
@@ -2276,7 +2223,6 @@ static void init_redirects(void)
     const char *config_dir = wine_get_config_dir();
     char *dir;
     struct stat st;
-    unsigned int i;
 
     if (!(dir = RtlAllocateHeap( GetProcessHeap(), 0, strlen(config_dir) + sizeof(windows_dir) ))) return;
     strcpy( dir, config_dir );
@@ -2286,12 +2232,6 @@ static void init_redirects(void)
         windir.dev = st.st_dev;
         windir.ino = st.st_ino;
         nb_redirects = ARRAY_SIZE( redirects );
-        for (i = 0; i < nb_redirects; i++)
-        {
-            if (!redirects[i].dos_target) continue;
-            redirects[i].unix_target = get_redirect_target( dir, redirects[i].dos_target );
-            TRACE( "%s -> %s\n", debugstr_w(redirects[i].source), redirects[i].unix_target );
-        }
     }
     else ERR( "%s: %s\n", dir, strerror(errno) );
     RtlFreeHeap( GetProcessHeap(), 0, dir );
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index e834ad2..6b60d36 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -63,7 +63,6 @@ void CDECL __wine_init_codepages( const union cptable *ansi, const union cptable
     oem_table = oem;
     unix_table = ucp;
     NlsAnsiCodePage = ansi->info.codepage;
-    init_directories();
 }
 
 int ntdll_umbstowcs(DWORD flags, const char* src, int srclen, WCHAR* dst, int dstlen)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index f837062..126bf76 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -245,6 +245,7 @@ void thread_init(void)
         exit(1);
     }
 
+    init_directories();
     init_user_process_params( info_size );
 
     /* initialize time values in user_shared_data */




More information about the wine-cvs mailing list