mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Fixed a bug in NtQueryVirtualMemory()
svn path=/trunk/; revision=982
This commit is contained in:
parent
5f71c29e2c
commit
ca7bca8f84
1 changed files with 29 additions and 25 deletions
|
@ -323,9 +323,9 @@ NTSTATUS STDCALL NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID MmChangeAreaProtection(PEPROCESS Process,
|
VOID MmChangeAreaProtection(PEPROCESS Process,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG Protect)
|
ULONG Protect)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
@ -393,24 +393,27 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryVirtualMemory(IN HANDLE ProcessHandle,
|
NTSTATUS
|
||||||
IN PVOID Address,
|
STDCALL
|
||||||
IN CINT VirtualMemoryInformationClass,
|
NtQueryVirtualMemory (
|
||||||
OUT PVOID VirtualMemoryInformation,
|
IN HANDLE ProcessHandle,
|
||||||
IN ULONG Length,
|
IN PVOID Address,
|
||||||
OUT PULONG ResultLength)
|
IN CINT VirtualMemoryInformationClass,
|
||||||
|
OUT PVOID VirtualMemoryInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
|
if (ResultLength)
|
||||||
|
{
|
||||||
|
*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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue