From fa63ad2beed5aad8c6cf541bda983e02ea20fd34 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sun, 11 Dec 2005 17:02:07 +0000 Subject: [PATCH] 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. svn path=/trunk/; revision=20067 --- reactos/ntoskrnl/ldr/loader.c | 39 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 8866fdafdf7..0f47e691a71 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -394,6 +394,9 @@ LdrpQueryModuleInformation ( ANSI_STRING AnsiName; PCHAR p; KIRQL Irql; + PUNICODE_STRING UnicodeName; + ULONG tmpBufferSize = 0; + PWCHAR tmpNameBuffer; KeAcquireSpinLock(&ModuleListLock,&Irql); @@ -402,6 +405,8 @@ LdrpQueryModuleInformation ( 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 @@ LdrpQueryModuleInformation ( 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 @@ LdrpQueryModuleInformation ( 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], ¤t->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, - ¤t->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 @@ LdrpQueryModuleInformation ( p++; Smi->Module[ModuleCount].PathLength = p - AnsiName.Buffer; } - - ModuleCount++; - current_entry = current_entry->Flink; } - KeReleaseSpinLock(&ModuleListLock, Irql); + ExFreePool(UnicodeName); return(STATUS_SUCCESS); } -- 2.17.1