Fixed a bug in NtQueryVirtualMemory()

svn path=/trunk/; revision=982
This commit is contained in:
Eric Kohl 2000-02-06 15:52:04 +00:00
parent 5f71c29e2c
commit ca7bca8f84

View file

@ -393,24 +393,27 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS
STDCALL
NtQueryVirtualMemory (
IN HANDLE ProcessHandle,
IN PVOID Address, IN PVOID Address,
IN CINT VirtualMemoryInformationClass, IN CINT VirtualMemoryInformationClass,
OUT PVOID VirtualMemoryInformation, OUT PVOID VirtualMemoryInformation,
IN ULONG Length, IN ULONG Length,
OUT PULONG ResultLength) OUT PULONG ResultLength
)
{ {
NTSTATUS Status; NTSTATUS Status;
PEPROCESS Process; PEPROCESS Process;
MEMORY_AREA* MemoryArea; MEMORY_AREA* MemoryArea;
#if 0 DPRINT("NtQueryVirtualMemory(ProcessHandle %x, Address %x, "
DbgPrint("NtReadVirtualMemory(ProcessHandle %x, Address %x, "
"VirtualMemoryInformationClass %d, VirtualMemoryInformation %x, " "VirtualMemoryInformationClass %d, VirtualMemoryInformation %x, "
"Length %lu ResultLength %x)\n",ProcessHandle,Address, "Length %lu ResultLength %x)\n",ProcessHandle,Address,
VirtualMemoryInformationClass,VirtualMemoryInformation, VirtualMemoryInformationClass,VirtualMemoryInformation,
Length,ResultLength); Length,ResultLength);
#endif
switch(VirtualMemoryInformationClass) switch(VirtualMemoryInformationClass)
{ {
case MemoryBasicInformation: case MemoryBasicInformation:
@ -421,11 +424,13 @@ NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle,
if (Length < sizeof(MEMORY_BASIC_INFORMATION)) if (Length < sizeof(MEMORY_BASIC_INFORMATION))
{ {
ObDereferenceObject(Process); ObDereferenceObject(Process);
return(STATUS_INFO_LENGTH_MISMATCH); return STATUS_INFO_LENGTH_MISMATCH;
} }
if (ResultLength)
{
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION); *ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
}
Status = ObReferenceObjectByHandle(ProcessHandle, Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_QUERY_INFORMATION, PROCESS_QUERY_INFORMATION,
@ -436,7 +441,7 @@ NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
// DbdPrint("NtQueryVirtualMemory() = %x\n",Status); DPRINT("NtQueryVirtualMemory() = %x\n",Status);
return(Status); return(Status);
} }
@ -446,7 +451,7 @@ NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle,
if (MemoryArea == NULL) if (MemoryArea == NULL)
{ {
Info->State = MEM_FREE; Info->State = MEM_FREE;
DbgPrint("Virtual memory at %p is free.\n", Address); DPRINT("Virtual memory at %p is free.\n", Address);
ObDereferenceObject(Process); ObDereferenceObject(Process);
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
} }
@ -463,17 +468,16 @@ NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle,
Info->BaseAddress = MemoryArea->BaseAddress; Info->BaseAddress = MemoryArea->BaseAddress;
Info->RegionSize = MemoryArea->Length; Info->RegionSize = MemoryArea->Length;
DbgPrint("BaseAddress %p, Length %x\n", DPRINT("BaseAddress %p, RegionSize %x State %x\n",
Info->BaseAddress, Info->RegionSize); Info->BaseAddress, Info->RegionSize, Info->State);
ObDereferenceObject(Process); ObDereferenceObject(Process);
return (STATUS_SUCCESS); return STATUS_SUCCESS;
} }
break; break;
} }
return(STATUS_INVALID_INFO_CLASS); return STATUS_INVALID_INFO_CLASS;
} }