ntdll/kernel32: #10

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- implemented LdrQueryProcessModuleInformation
- rewrote VERSION_GetLinkedDllVersion() with this new function instead of accessing directly the modref list


A+
--
Eric Pouech
Common subdirectories: dlls/ntdll9/CVS and dlls/ntdll/CVS
diff -u -x '*~' -x '.#*' dlls/ntdll9/loader.c dlls/ntdll/loader.c
--- dlls/ntdll9/loader.c	2003-03-20 20:28:09.000000000 +0100
+++ dlls/ntdll/loader.c	2003-03-20 20:40:44.000000000 +0100
@@ -759,6 +759,55 @@
 }
 
 /******************************************************************
+ *		LdrQueryProcessModuleInformation
+ *
+ */
+NTSTATUS WINAPI LdrQueryProcessModuleInformation(PSYSTEM_MODULE_INFORMATION smi, 
+                                                 ULONG buf_size, ULONG* req_size)
+{
+    SYSTEM_MODULE*      sm = &smi->Modules[0];
+    ULONG               size = sizeof(ULONG);
+    NTSTATUS            nts = STATUS_SUCCESS;
+    ANSI_STRING         str;
+    char*               ptr;
+    WINE_MODREF*        wm;
+
+    smi->ModulesCount = 0;
+
+    RtlEnterCriticalSection( &loader_section );
+    for ( wm = MODULE_modref_list; wm; wm = wm->next )
+    {
+        size += sizeof(*sm);
+        if (size <= buf_size)
+        {
+            sm->Reserved1 = 0; /* FIXME */
+            sm->Reserved2 = 0; /* FIXME */
+            sm->ImageBaseAddress = wm->ldr.BaseAddress;
+            sm->ImageSize = wm->ldr.SizeOfImage;
+            sm->Flags = wm->ldr.Flags;
+            sm->Id = 0; /* FIXME */
+            sm->Rank = 0; /* FIXME */
+            sm->Unknown = 0; /* FIXME */
+            str.Length = 0;
+            str.MaximumLength = MAXIMUM_FILENAME_LENGTH;
+            str.Buffer = sm->Name;
+            RtlUnicodeStringToAnsiString(&str, &wm->ldr.FullDllName, FALSE);
+            ptr = strrchr(sm->Name, '\\');
+            sm->NameOffset = (ptr != NULL) ? (ptr - (char*)sm->Name + 1) : 0;
+
+            smi->ModulesCount++;
+            sm++;
+        }
+        else nts = STATUS_INFO_LENGTH_MISMATCH;
+    }
+    RtlLeaveCriticalSection( &loader_section );
+
+    if (req_size) *req_size = size;
+
+    return nts;
+}
+
+/******************************************************************
  *		LdrShutdownProcess (NTDLL.@)
  *
  */
diff -u -x '*~' -x '.#*' dlls/ntdll9/ntdll.spec dlls/ntdll/ntdll.spec
--- dlls/ntdll9/ntdll.spec	2003-03-20 19:33:47.000000000 +0100
+++ dlls/ntdll/ntdll.spec	2003-03-20 20:42:28.000000000 +0100
@@ -46,7 +46,7 @@
 @ stdcall LdrLockLoaderLock(long ptr ptr)
 @ stub LdrProcessRelocationBlock
 @ stub LdrQueryImageFileExecutionOptions
-@ stub LdrQueryProcessModuleInformation
+@ stdcall LdrQueryProcessModuleInformation(ptr long ptr)
 @ stdcall LdrShutdownProcess()
 @ stdcall LdrShutdownThread()
 @ stdcall LdrUnloadDll(ptr)
Common subdirectories: dlls/ntdll9/tests and dlls/ntdll/tests
Common subdirectories: include9/bitmaps and include/bitmaps
Common subdirectories: include9/CVS and include/CVS
Common subdirectories: include9/msvcrt and include/msvcrt
Common subdirectories: include9/wine and include/wine
diff -u -x '*~' -x '.#*' include9/winternl.h include/winternl.h
--- include9/winternl.h	2003-03-20 20:28:09.000000000 +0100
+++ include/winternl.h	2003-03-20 20:44:00.000000000 +0100
@@ -1227,6 +1227,7 @@
 NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, PANSI_STRING, ULONG, void**);
 NTSTATUS WINAPI LdrLoadDll(LPCWSTR, DWORD, PUNICODE_STRING, HMODULE*);
 NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
+NTSTATUS WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULONG, ULONG*);
 NTSTATUS WINAPI LdrShutdownProcess(void);
 NTSTATUS WINAPI LdrShutdownThread(void);
 NTSTATUS WINAPI LdrUnloadDll(HMODULE);
Common subdirectories: loader9/CVS and loader/CVS
Common subdirectories: loader9/ne and loader/ne
Common subdirectories: misc9/CVS and misc/CVS
diff -u -x '*~' -x '.#*' misc9/version.c misc/version.c
--- misc9/version.c	2003-03-20 20:28:09.000000000 +0100
+++ misc/version.c	2003-03-20 20:40:44.000000000 +0100
@@ -37,6 +37,7 @@
 #include "module.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
+#include "ntdll_misc.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ver);
 
@@ -444,51 +445,64 @@
  */
 static DWORD VERSION_GetLinkedDllVersion(void)
 {
-	WINE_MODREF *wm;
 	DWORD WinVersion = NB_WINDOWS_VERSIONS;
 	PIMAGE_OPTIONAL_HEADER ophd;
         IMAGE_NT_HEADERS *nt;
+        ULONG       count, required;
+        SYSTEM_MODULE_INFORMATION*  smi;
 
 	/* First check the native dlls provided. These have to be
 	from one windows version */
-	for ( wm = MODULE_modref_list; wm; wm=wm->next )
-	{
-          nt = RtlImageNtHeader(wm->ldr.BaseAddress);
-          ophd = &nt->OptionalHeader;
-
-	  TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
-	    wm->modname,
-	    ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
-	    ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
-	    ophd->MajorImageVersion, ophd->MinorImageVersion,
-	    ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
-
-	  /* test if it is an external (native) dll */
-	  if (!(wm->ldr.Flags & LDR_WINE_INTERNAL))
-	  {
-	    int i;
-	    for (i = 0; special_dlls[i]; i++)
-	    {
-	      /* test if it is a special dll */
-	      if (!strcasecmp(wm->modname, special_dlls[i]))
-	      {
-	        DWORD DllVersion = VERSION_GetSystemDLLVersion(wm->ldr.BaseAddress);
-	        if (WinVersion == NB_WINDOWS_VERSIONS)
-	          WinVersion = DllVersion;
-	        else {
-	          if (WinVersion != DllVersion) {
-	            ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
-			wm->modname,
-			VersionData[WinVersion].getVersionEx.szCSDVersion,
-			VersionData[DllVersion].getVersionEx.szCSDVersion);
-	            return WIN20; /* this may let the exe exiting */
-	          }
-	        }
-	        break;
-	      }
-	    }
-	  }
-	}
+        smi = (SYSTEM_MODULE_INFORMATION*)&count;
+        LdrQueryProcessModuleInformation(smi, sizeof(count), &required);
+        smi = RtlAllocateHeap(ntdll_get_process_heap(), 0, required);
+        if (smi)
+        {
+            if (LdrQueryProcessModuleInformation(smi, required, NULL) == STATUS_SUCCESS)
+            {
+                int k;
+                for (k = 0; k < smi->ModulesCount; k++)
+                {
+                    nt = RtlImageNtHeader(smi->Modules[k].ImageBaseAddress);
+                    ophd = &nt->OptionalHeader;
+                    
+                    TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
+                          &smi->Modules[k].Name[smi->Modules[k].NameOffset],
+                          ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
+                          ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
+                          ophd->MajorImageVersion, ophd->MinorImageVersion,
+                          ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
+                }
+
+                /* test if it is an external (native) dll */
+                if (!(smi->Modules[k].Flags & LDR_WINE_INTERNAL))
+                {
+                    int i;
+                    for (i = 0; special_dlls[i]; i++)
+                    {
+                        /* test if it is a special dll */
+                        if (!strcasecmp(&smi->Modules[k].Name[smi->Modules[k].NameOffset], special_dlls[i]))
+                        {
+                            DWORD DllVersion = VERSION_GetSystemDLLVersion(smi->Modules[k].ImageBaseAddress);
+                            if (WinVersion == NB_WINDOWS_VERSIONS)
+                                WinVersion = DllVersion;
+                            else 
+                            {
+                                if (WinVersion != DllVersion) {
+                                    ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
+                                        &smi->Modules[k].Name[smi->Modules[k].NameOffset],
+                                        VersionData[WinVersion].getVersionEx.szCSDVersion,
+                                        VersionData[DllVersion].getVersionEx.szCSDVersion);
+                                    return WIN20; /* this may let the exe exiting */
+                                }
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+            RtlFreeHeap(ntdll_get_process_heap(), 0, smi);
+        }
 
 	if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
 
Common subdirectories: relay329/CVS and relay32/CVS
Common subdirectories: scheduler9/CVS and scheduler/CVS

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux