[PATCH] ntdll: Fix error code when querying too large memory address.

Zebediah Figura z.figura12 at gmail.com
Tue Feb 27 17:31:23 CST 2018


From: Michael Müller <michael at fds-team.de>

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
Process Hacker calls this function in a loop to determine the working set
limit, and expects it to return STATUS_INVALID_PARAMETER if the given address
is too high. This patch allows Process Hacker to enumerate a process's virtual
mappings.

Test simplified from staging version.

 dlls/ntdll/tests/info.c | 4 ++++
 dlls/ntdll/virtual.c    | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index b62e035..1f1c675 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1868,6 +1868,10 @@ static void test_queryvirtualmemory(void)
             "mbi.Protect is 0x%x\n", mbi.Protect);
     }
     else skip( "bss is outside of module\n" );  /* this can happen on Mac OS */
+
+    /* check error code when addr is higher than working set limit */
+    status = pNtQueryVirtualMemory(NtCurrentProcess(), (void *)~0, MemoryBasicInformation, &mbi, sizeof(mbi), &readcount);
+    ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
 }
 
 static void test_affinity(void)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 106dab2..befb59c 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2845,7 +2845,7 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
 
     base = ROUND_ADDR( addr, page_mask );
 
-    if (is_beyond_limit( base, 1, working_set_limit )) return STATUS_WORKING_SET_LIMIT_RANGE;
+    if (is_beyond_limit( base, 1, working_set_limit )) return STATUS_INVALID_PARAMETER;
 
     /* Find the view containing the address */
 
-- 
2.7.4




More information about the wine-devel mailing list