Allocate a tem buffer for the module names in LdrpQueryModuleInformation, because it isn't possible to call RtlUnicodeStringToAnsiString if the irql is raised to DPC_LEVEL.
Modified: trunk/reactos/ntoskrnl/ldr/loader.c

Modified: trunk/reactos/ntoskrnl/ldr/loader.c
--- trunk/reactos/ntoskrnl/ldr/loader.c	2005-12-11 16:46:40 UTC (rev 20066)
+++ trunk/reactos/ntoskrnl/ldr/loader.c	2005-12-11 17:02:07 UTC (rev 20067)
@@ -394,6 +394,9 @@
     ANSI_STRING AnsiName;
     PCHAR p;
     KIRQL Irql;
+    PUNICODE_STRING UnicodeName;
+    ULONG tmpBufferSize = 0;
+    PWCHAR tmpNameBuffer;
 
     KeAcquireSpinLock(&ModuleListLock,&Irql);
 
@@ -402,6 +405,8 @@
     while (current_entry != (&ModuleListHead))
     {
         ModuleCount++;
+        current = CONTAINING_RECORD(current_entry,LDR_DATA_TABLE_ENTRY,InLoadOrderModuleList);
+        tmpBufferSize += current->FullDllName.Length + sizeof(WCHAR) + sizeof(UNICODE_STRING);
         current_entry = current_entry->Flink;
     }
 
@@ -414,6 +419,15 @@
         return(STATUS_INFO_LENGTH_MISMATCH);
     }
 
+    /* allocate a temp buffer to store the module names */
+    UnicodeName = ExAllocatePool(NonPagedPool, tmpBufferSize);
+    if (UnicodeName == NULL)
+    {
+        KeReleaseSpinLock(&ModuleListLock, Irql);
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+    tmpNameBuffer = (PWCHAR)((ULONG_PTR)UnicodeName + ModuleCount * sizeof(UNICODE_STRING));
+
     /* fill the buffer */
     memset(Buffer, '=', Size);
 
@@ -434,13 +448,25 @@
         Smi->Module[ModuleCount].Index = (USHORT)ModuleCount;
         Smi->Module[ModuleCount].NameLength = 0;
         Smi->Module[ModuleCount].LoadCount = 0; /* FIXME */
+        UnicodeName[ModuleCount].Buffer = tmpNameBuffer;
+        UnicodeName[ModuleCount].MaximumLength = current->FullDllName.Length + sizeof(WCHAR);
+        tmpNameBuffer += UnicodeName[ModuleCount].MaximumLength / sizeof(WCHAR);
+        RtlCopyUnicodeString(&UnicodeName[ModuleCount], &current->FullDllName);
 
+        ModuleCount++;
+        current_entry = current_entry->Flink;
+    }
+
+    KeReleaseSpinLock(&ModuleListLock, Irql);
+
+    for (ModuleCount = 0; ModuleCount < Smi->Count; ModuleCount++)
+    {
         AnsiName.Length = 0;
-        AnsiName.MaximumLength = 256;
+        AnsiName.MaximumLength = 255;
         AnsiName.Buffer = Smi->Module[ModuleCount].ImageName;
-        RtlUnicodeStringToAnsiString(&AnsiName,
-            &current->FullDllName,
-            FALSE);
+        RtlUnicodeStringToAnsiString(&AnsiName, &UnicodeName[ModuleCount], FALSE);
+        AnsiName.Buffer[AnsiName.Length] = 0;
+        Smi->Module[ModuleCount].NameLength = AnsiName.Length;
 
         p = strrchr(AnsiName.Buffer, '\\');
         if (p == NULL)
@@ -452,12 +478,9 @@
             p++;
             Smi->Module[ModuleCount].PathLength = p - AnsiName.Buffer;
         }
-
-        ModuleCount++;
-        current_entry = current_entry->Flink;
     }
 
-    KeReleaseSpinLock(&ModuleListLock, Irql);
+    ExFreePool(UnicodeName);
 
     return(STATUS_SUCCESS);
 }