Author: mjmartin Date: Wed Oct 29 14:50:55 2008 New Revision: 37073
URL: http://svn.reactos.org/svn/reactos?rev=37073&view=rev Log: - Implement VirtualMemoryInformationClass of MemorySectionName for NtQueryVirtualMemory.
Modified: trunk/reactos/ntoskrnl/mm/virtual.c
Modified: trunk/reactos/ntoskrnl/mm/virtual.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/virtual.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/virtual.c [iso-8859-1] Wed Oct 29 14:50:55 2008 @@ -947,6 +947,9 @@ NTSTATUS Status = STATUS_SUCCESS; SIZE_T ResultLength = 0; KPROCESSOR_MODE PreviousMode; + WCHAR ModuleFileNameBuffer[MAX_PATH] = {0}; + UNICODE_STRING ModuleFileName; + PMEMORY_SECTION_NAME SectionName = NULL; union { MEMORY_BASIC_INFORMATION BasicInfo; @@ -985,13 +988,58 @@ return STATUS_INVALID_PARAMETER; }
- Status = MiQueryVirtualMemory(ProcessHandle, - Address, - VirtualMemoryInformationClass, - &VirtualMemoryInfo, - Length, - &ResultLength ); - + /* FIXME: Move this inside MiQueryVirtualMemory */ + if (VirtualMemoryInformationClass == MemorySectionName) + { + RtlInitEmptyUnicodeString(&ModuleFileName, ModuleFileNameBuffer, sizeof(ModuleFileNameBuffer)); + Status = MmGetFileNameForAddress(Address, &ModuleFileName); + + if (NT_SUCCESS(Status)) + { + SectionName = VirtualMemoryInformation; + if (PreviousMode != KernelMode) + { + _SEH_TRY + { + RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); + SectionName->SectionFileName.MaximumLength = Length; + RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); + + if (UnsafeResultLength != NULL) + { + *UnsafeResultLength = ModuleFileName.Length; + } + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } + else + { + RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); + SectionName->SectionFileName.MaximumLength = Length; + RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); + + if (UnsafeResultLength != NULL) + { + *UnsafeResultLength = ModuleFileName.Length; + } + } + } + return Status; + } + else + { + Status = MiQueryVirtualMemory(ProcessHandle, + Address, + VirtualMemoryInformationClass, + &VirtualMemoryInfo, + Length, + &ResultLength); + } + if (NT_SUCCESS(Status)) { if (PreviousMode != KernelMode)