[v3 2/5] kernel32: Support for LIBRARY_SEARCH_SYSTEM32 when loading dlls

Carlos Palminha CARLOS.PALMINHA at synopsys.com
Fri Aug 11 05:39:33 CDT 2017


If LIBRARY_SEARCH_SYSTEM32 flag is used when loading a dll,
%windows%\system32 is used to search.

Standard search path directories are not used and it cannot be
combined with ALTERED_SEARCH_PATH.

Signed-off-by: Carlos Palminha <palminha at synopsys.com>
---
 v3:
  - no changes

 v2:
  - no changes

 dlls/kernel32/module.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index c6696d84918..21de9db503f 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -778,6 +778,9 @@ static inline const WCHAR *get_module_path_end(const WCHAR *module)
  */
 
 WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
+    int len = 0;
+    WCHAR *ret = NULL, *p = NULL;
+
     if (flags & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) {
         FIXME("unsupported flag used LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR (flags: 0x%08x)\n", flags);
     }
@@ -791,9 +794,31 @@ WCHAR *MODULE_get_dll_load_path_flags( DWORD flags ) {
     }
 
     if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32 || flags & LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) {
-        FIXME("unsupported flag used LOAD_LIBRARY_SEARCH_SYSTEM32 (flags: 0x%08x)\n", flags);
+        WCHAR szWinDir[MAX_PATH];
+        int retStrSize;
+
+        retStrSize = GetWindowsDirectoryW(szWinDir,MAX_PATH);
+        if (retStrSize) {
+            WCHAR strSys32[] = {'\\','s','y','s','t','e','m','3','2',0};
+
+            len += ( strlenW(szWinDir) + strlenW(strSys32) + 1 );
+            if (ret)
+                ret = HeapReAlloc( GetProcessHeap(), 0, ret, len * sizeof(WCHAR) );
+            else
+                p = ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+
+            strcpyW (p, szWinDir);
+            p += strlenW(p);
+            strcpyW (p, strSys32);
+            p += strlenW(strSys32);
+            *p++ = ';';
+        }
     }
-    return NULL;
+
+    if(p)
+        *p++ = '\0';
+
+    return ret;
 }
 
 /******************************************************************
-- 
2.11.0




More information about the wine-patches mailing list