[Wine-patches] [eterhack 22/23] kernel32: Prevent second loading of a library with specified path.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:22 MSD 2009


---
 dlls/kernel32/module.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index 5a50d1e..3df42cc 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -921,6 +921,8 @@ HMODULE WINAPI LoadLibraryExW(LPCWSTR libnameW, HANDLE hfile, DWORD flags)
 {
     UNICODE_STRING      wstr;
     HMODULE             res;
+    WCHAR              *pathnameW;
+    DWORD               len;
 
     if (hfile)
     {
@@ -933,6 +935,22 @@ HMODULE WINAPI LoadLibraryExW(LPCWSTR libnameW, HANDLE hfile, DWORD flags)
         SetLastError(ERROR_INVALID_PARAMETER);
         return 0;
     }
+
+    /* Prevent second loading of a library with specified path */
+    if (strchrW( libnameW, '\\' ) && (len = GetLongPathNameW( libnameW, NULL, 0 )))
+    {
+        if (!(pathnameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
+        {
+            SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+            return 0;
+        }
+        GetLongPathNameW( libnameW, pathnameW, len );
+        RtlInitUnicodeString( &wstr, pathnameW );
+        res = load_library( &wstr, flags );
+        HeapFree( GetProcessHeap(), 0, pathnameW );
+        return res;
+    }
+
     RtlInitUnicodeString( &wstr, libnameW );
     if (wstr.Buffer[wstr.Length/sizeof(WCHAR) - 1] != ' ')
         return load_library( &wstr, flags );
-- 
1.6.3.1



Подробная информация о списке рассылки Wine-patches