From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/info.c | 20 +++++++------------- dlls/ntdll/unix/process.c | 12 ++++++------ include/winternl.h | 26 ++++++++++++++++++++------ 3 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 7475fcf56ee..35e4b834c42 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -342,7 +342,7 @@ static void test_query_process(void) ULONG HandleCount; DWORD dwUnknown3; DWORD dwUnknown4; - VM_COUNTERS vmCounters; + VM_COUNTERS_EX vmCounters; IO_COUNTERS ioCounters; SYSTEM_THREAD_INFORMATION ti[1]; } SYSTEM_PROCESS_INFORMATION_PRIVATE; @@ -1399,7 +1399,7 @@ static void test_query_process_basic(void) ok( pbi.UniqueProcessId > 0, "Expected a ProcessID > 0, got 0\n"); }
-static void dump_vm_counters(const char *header, const VM_COUNTERS *pvi) +static void dump_vm_counters(const char *header, const VM_COUNTERS_EX *pvi) { trace("%s:\n", header); trace("PeakVirtualSize : %lu\n", pvi->PeakVirtualSize); @@ -1419,8 +1419,7 @@ static void test_query_process_vm(void) { NTSTATUS status; ULONG ReturnLength; - VM_COUNTERS pvi; - ULONG old_size = FIELD_OFFSET(VM_COUNTERS,PrivatePageCount); + VM_COUNTERS_EX pvi; HANDLE process; SIZE_T prev_size; const SIZE_T alloc_size = 16 * 1024 * 1024; @@ -1430,24 +1429,19 @@ static void test_query_process_vm(void) ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE, "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
- status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, old_size, NULL); + status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, sizeof(VM_COUNTERS), NULL); ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
- /* Windows XP and W2K3 will report success for a size of 44 AND 48 ! - Windows W2K will only report success for 44. - For now we only care for 44, which is FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) - */ - status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 24, &ReturnLength); ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
- status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, old_size, &ReturnLength); + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(VM_COUNTERS), &ReturnLength); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); - ok( old_size == ReturnLength, "Inconsistent length %d\n", ReturnLength); + ok( ReturnLength == sizeof(VM_COUNTERS), "Inconsistent length %d\n", ReturnLength);
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 46, &ReturnLength); ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); - ok( ReturnLength == old_size || ReturnLength == sizeof(pvi), "Inconsistent length %d\n", ReturnLength); + ok( ReturnLength == sizeof(VM_COUNTERS) || ReturnLength == sizeof(pvi), "Inconsistent length %d\n", ReturnLength);
/* Check if we have some return values */ dump_vm_counters("VM counters for GetCurrentProcess", &pvi); diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 578c79bf89a..c39d8fb23a4 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1170,13 +1170,13 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class { VM_COUNTERS pvmi;
- /* older Windows versions don't have the PrivatePageCount field */ - if (size >= FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) + /* older Windows versions don't have the PrivateUsage field */ + if (size >= sizeof(VM_COUNTERS)) { if (!info) ret = STATUS_ACCESS_VIOLATION; else { - memset(&pvmi, 0 , sizeof(VM_COUNTERS)); + memset(&pvmi, 0, sizeof(pvmi)); if (handle == GetCurrentProcess()) fill_VM_COUNTERS(&pvmi); else { @@ -1197,10 +1197,10 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class if (ret) break; } len = size; - if (len != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) len = sizeof(VM_COUNTERS); - memcpy(info, &pvmi, min(size,sizeof(VM_COUNTERS))); + if (len != sizeof(VM_COUNTERS)) len = sizeof(VM_COUNTERS_EX); + memcpy(info, &pvmi, min(size, sizeof(pvmi))); } - if (size != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount) && size != sizeof(VM_COUNTERS)) + if (size != sizeof(VM_COUNTERS) && size != sizeof(VM_COUNTERS_EX)) ret = STATUS_INFO_LENGTH_MISMATCH; } else diff --git a/include/winternl.h b/include/winternl.h index 9a70a2014f1..5b5a5f32c6f 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1584,12 +1584,11 @@ typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION { BOOLEAN DebuggerNotPresent; } SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
-/* System Information Class 0x05 */ - -typedef struct _VM_COUNTERS_ { +typedef struct _VM_COUNTERS +{ SIZE_T PeakVirtualSize; SIZE_T VirtualSize; - ULONG PageFaultCount; + ULONG PageFaultCount; SIZE_T PeakWorkingSetSize; SIZE_T WorkingSetSize; SIZE_T QuotaPeakPagedPoolUsage; @@ -1598,9 +1597,24 @@ typedef struct _VM_COUNTERS_ { SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; - SIZE_T PrivatePageCount; } VM_COUNTERS, *PVM_COUNTERS;
+typedef struct _VM_COUNTERS_EX +{ + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; + typedef struct _SYSTEM_PROCESS_INFORMATION { #ifdef __WINESRC__ /* win32/win64 */ ULONG NextEntryOffset; /* 00/00 */ @@ -1616,7 +1630,7 @@ typedef struct _SYSTEM_PROCESS_INFORMATION { ULONG HandleCount; /* 4c/60 */ ULONG SessionId; /* 50/64 */ DWORD dwUnknown4; /* 54/68 */ - VM_COUNTERS vmCounters; /* 58/70 */ + VM_COUNTERS_EX vmCounters; /* 58/70 */ IO_COUNTERS ioCounters; /* 88/d0 */ SYSTEM_THREAD_INFORMATION ti[1]; /* b8/100 */ #else