From 16b441166980246511faab157755007d73b9fa1e Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Tue, 25 Nov 2003 01:03:04 +0000
Subject: [PATCH] Removed MODULE_GetLoadOrderA.

---
 dlls/kernel/ne_module.c |  5 ++++-
 dlls/kernel/process.c   |  4 ++--
 dlls/ntdll/loader.c     |  2 +-
 dlls/ntdll/loadorder.c  | 45 +++++++++--------------------------------
 dlls/ntdll/ntdll.spec   |  3 +--
 include/module.h        |  4 +---
 6 files changed, 19 insertions(+), 44 deletions(-)

diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c
index 85634e9e18e..95a33c06694 100644
--- a/dlls/kernel/ne_module.c
+++ b/dlls/kernel/ne_module.c
@@ -1212,6 +1212,7 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
     }
     else
     {
+        UNICODE_STRING pathW;
         WCHAR buffer[MAX_PATH], *p;
 
         if (!GetModuleFileNameW( 0, buffer, MAX_PATH )) p = NULL;
@@ -1220,7 +1221,9 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
             if ((p = strrchrW( buffer, '\\' ))) p++;
             else p = buffer;
         }
-        MODULE_GetLoadOrderA(loadorder, p, basename, FALSE);
+        RtlCreateUnicodeStringFromAsciiz( &pathW, basename );
+        MODULE_GetLoadOrderW( loadorder, p, pathW.Buffer );
+        RtlFreeUnicodeString( &pathW );
     }
 
     for(i = 0; i < LOADORDER_NTYPES; i++)
diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index 06a124a2ca3..37d4be888e5 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -182,7 +182,7 @@ static HANDLE open_exe_file( const WCHAR *name )
         name = buffer;
     }
 
-    MODULE_GetLoadOrderW( loadorder, NULL, name, TRUE );
+    MODULE_GetLoadOrderW( loadorder, NULL, name );
 
     for(i = 0; i < LOADORDER_NTYPES; i++)
     {
@@ -245,7 +245,7 @@ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE
         return FALSE;
     }
 
-    MODULE_GetLoadOrderW( loadorder, NULL, buffer, TRUE );
+    MODULE_GetLoadOrderW( loadorder, NULL, buffer );
 
     for(i = 0; i < LOADORDER_NTYPES; i++)
     {
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 010274c8adb..dd8507e978f 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1442,7 +1442,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
     }
 
     main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
-    MODULE_GetLoadOrderW( loadorder, main_exe->ldr.BaseDllName.Buffer, filename, TRUE);
+    MODULE_GetLoadOrderW( loadorder, main_exe->ldr.BaseDllName.Buffer, filename );
 
     nts = STATUS_DLL_NOT_FOUND;
     for (i = 0; i < LOADORDER_NTYPES; i++)
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index 155ac278827..c5a88efcd1f 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -510,7 +510,7 @@ BOOL MODULE_GetSystemDirectory( UNICODE_STRING *sysdir )
  * the specific dll. Otherwise the default load order is returned.
  */
 void MODULE_GetLoadOrderW( enum loadorder_type loadorder[], const WCHAR *app_name,
-                          const WCHAR *path, BOOL win32 )
+                          const WCHAR *path )
 {
     static const WCHAR DllOverridesW[] = {'M','a','c','h','i','n','e','\\',
                                           'S','o','f','t','w','a','r','e','\\',
@@ -520,8 +520,11 @@ void MODULE_GetLoadOrderW( enum loadorder_type loadorder[], const WCHAR *app_nam
                                           'D','l','l','O','v','e','r','r','i','d','e','s',0};
 
     static HKEY std_key = (HKEY)-1;  /* key to standard section, cached */
+    static UNICODE_STRING sysdir;
+
     HKEY app_key = 0;
     WCHAR *module, *basename;
+    UNICODE_STRING path_str;
     int len;
 
     if (!init_done) init_load_order();
@@ -531,21 +534,14 @@ void MODULE_GetLoadOrderW( enum loadorder_type loadorder[], const WCHAR *app_nam
     loadorder[0] = LOADORDER_INVALID;  /* in case something bad happens below */
 
     /* Strip path information if the module resides in the system directory
-     * (path is already stripped by caller for 16-bit modules)
      */
-    if (win32)
+    if (!sysdir.Buffer && !MODULE_GetSystemDirectory( &sysdir )) return;
+    RtlInitUnicodeString( &path_str, path );
+    if (RtlPrefixUnicodeString( &sysdir, &path_str, TRUE ))
     {
-        UNICODE_STRING path_str, sysdir;
-
-        if (!MODULE_GetSystemDirectory( &sysdir )) return;
-        RtlInitUnicodeString( &path_str, path );
-        if (RtlPrefixUnicodeString( &sysdir, &path_str, TRUE ))
-        {
-            const WCHAR *p = path + sysdir.Length / sizeof(WCHAR);
-            while (*p == '\\' || *p == '/') p++;
-            if (!strchrW( p, '\\' ) && !strchrW( p, '/' )) path = p;
-        }
-        RtlFreeUnicodeString( &sysdir );
+        const WCHAR *p = path + sysdir.Length / sizeof(WCHAR);
+        while (*p == '\\' || *p == '/') p++;
+        if (!strchrW( p, '\\' ) && !strchrW( p, '/' )) path = p;
     }
 
     if (!(len = strlenW(path))) return;
@@ -660,24 +656,3 @@ void MODULE_GetLoadOrderW( enum loadorder_type loadorder[], const WCHAR *app_nam
     if (app_key) NtClose( app_key );
     RtlFreeHeap( GetProcessHeap(), 0, module );
 }
-
-
-/***************************************************************************
- *	MODULE_GetLoadOrderA	(internal)
- *
- * Locate the loadorder of a module.
- * Any path is stripped from the path-argument and so are the extension
- * '.dll' and '.exe'. A lookup in the table can yield an override for
- * the specific dll. Otherwise the default load order is returned.
- *
- * FIXME: should be removed, everything should be Unicode.
- */
-void MODULE_GetLoadOrderA( enum loadorder_type loadorder[], const WCHAR *app_name,
-                           const char *path, BOOL win32 )
-{
-    UNICODE_STRING pathW;
-
-    RtlCreateUnicodeStringFromAsciiz( &pathW, path );
-    MODULE_GetLoadOrderW( loadorder, app_name, pathW.Buffer, win32 );
-    RtlFreeUnicodeString( &pathW );
-}
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 3b79ea0d08f..803f9e9ea65 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1080,7 +1080,6 @@
 #
 @ cdecl CDROM_InitRegistry(long long str)
 @ cdecl MODULE_DllThreadAttach(ptr)
-@ cdecl MODULE_GetLoadOrderA(ptr str str long)
-@ cdecl MODULE_GetLoadOrderW(ptr wstr wstr long)
+@ cdecl MODULE_GetLoadOrderW(ptr wstr wstr)
 @ cdecl VERSION_Init(wstr)
 @ cdecl VIRTUAL_SetFaultHandler(ptr ptr ptr)
diff --git a/include/module.h b/include/module.h
index 520b695582b..eea76fb1e1a 100644
--- a/include/module.h
+++ b/include/module.h
@@ -184,8 +184,6 @@ extern void TASK_InstallTHHook( THHOOK *pNewThook );
 
 /* loadorder.c */
 extern void MODULE_GetLoadOrderW( enum loadorder_type plo[], const WCHAR *app_name,
-                                  const WCHAR *path, BOOL win32 );
-extern void MODULE_GetLoadOrderA( enum loadorder_type plo[], const WCHAR *app_name,
-                                  const char *path, BOOL win32 );
+                                  const WCHAR *path );
 
 #endif  /* __WINE_MODULE_H */
-- 
GitLab