mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-30 04:13:33 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user