From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.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
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v3: fix a compiler warning...
dlls/ntdll/tests/info.c | 6 ++++++ dlls/ntdll/unix/process.c | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 35e4b834c42..e399757b85d 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -1462,6 +1462,7 @@ static void test_query_process_vm(void) process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId()); status = pNtQueryInformationProcess(process, ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage );
/* Check if we have some return values */ dump_vm_counters("VM counters for GetCurrentProcessId", &pvi); @@ -1473,6 +1474,7 @@ static void test_query_process_vm(void) /* Check if we have real counters */ status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage ); prev_size = pvi.VirtualSize; if (winetest_debug > 1) dump_vm_counters("VM counters before VirtualAlloc", &pvi); @@ -1480,6 +1482,7 @@ static void test_query_process_vm(void) ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError()); status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage ); if (winetest_debug > 1) dump_vm_counters("VM counters after VirtualAlloc", &pvi); todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size, @@ -1488,6 +1491,7 @@ static void test_query_process_vm(void)
status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage ); prev_size = pvi.VirtualSize; if (winetest_debug > 1) dump_vm_counters("VM counters before VirtualAlloc", &pvi); @@ -1495,6 +1499,7 @@ static void test_query_process_vm(void) ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError()); status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage ); if (winetest_debug > 1) dump_vm_counters("VM counters after VirtualAlloc(MEM_RESERVE)", &pvi); todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size, @@ -1505,6 +1510,7 @@ static void test_query_process_vm(void) ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError()); status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok( pvi.PrivateUsage == pvi.PagefileUsage, "wrong value %lu/%lu\n", pvi.PrivateUsage, pvi.PagefileUsage ); if (winetest_debug > 1) dump_vm_counters("VM counters after VirtualAlloc(MEM_COMMIT)", &pvi); ok( pvi.VirtualSize == prev_size, diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index c39d8fb23a4..33bee03c19a 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -1008,7 +1008,7 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
#if defined(HAVE_MACH_MACH_H)
-static void fill_VM_COUNTERS(VM_COUNTERS* pvmi) +static void fill_VM_COUNTERS( VM_COUNTERS_EX *pvmi ) { #if defined(MACH_TASK_BASIC_INFO) struct mach_task_basic_info info; @@ -1025,7 +1025,7 @@ static void fill_VM_COUNTERS(VM_COUNTERS* pvmi)
#elif defined(linux)
-static void fill_VM_COUNTERS(VM_COUNTERS* pvmi) +static void fill_VM_COUNTERS( VM_COUNTERS_EX *pvmi ) { FILE *f; char line[256]; @@ -1056,7 +1056,7 @@ static void fill_VM_COUNTERS(VM_COUNTERS* pvmi)
#else
-static void fill_VM_COUNTERS(VM_COUNTERS* pvmi) +static void fill_VM_COUNTERS( VM_COUNTERS_EX *pvmi ) { /* FIXME : real data */ } @@ -1168,7 +1168,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
case ProcessVmCounters: { - VM_COUNTERS pvmi; + VM_COUNTERS_EX pvmi;
/* older Windows versions don't have the PrivateUsage field */ if (size >= sizeof(VM_COUNTERS)) @@ -1196,6 +1196,8 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class SERVER_END_REQ; if (ret) break; } + if (size >= sizeof(VM_COUNTERS_EX)) + pvmi.PrivateUsage = pvmi.PagefileUsage; len = size; if (len != sizeof(VM_COUNTERS)) len = sizeof(VM_COUNTERS_EX); memcpy(info, &pvmi, min(size, sizeof(pvmi)));