Commit bb175832 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

kernelbase: Fix GlobalMemoryStatusEx counters.

parent cabfefb0
......@@ -1266,17 +1266,13 @@ static void test_GlobalMemoryStatus(void)
expect.ullAvailExtendedVirtual = 0;
ok( memex.dwMemoryLoad == expect.dwMemoryLoad, "got dwMemoryLoad %lu\n", memex.dwMemoryLoad );
todo_wine
ok( memex.ullTotalPhys == expect.ullTotalPhys, "got ullTotalPhys %#I64x\n", memex.ullTotalPhys );
ok( memex.ullAvailPhys == expect.ullAvailPhys, "got ullAvailPhys %#I64x\n", memex.ullAvailPhys );
todo_wine
ok( memex.ullTotalPageFile == expect.ullTotalPageFile, "got ullTotalPageFile %#I64x\n", memex.ullTotalPageFile );
/* allow some variability, page file is not always in sync on Windows */
ok( memex.ullAvailPageFile - expect.ullAvailPageFile + 32 * basic_info.PageSize <= 64 * basic_info.PageSize,
"got ullAvailPageFile %#I64x\n", memex.ullAvailPageFile );
todo_wine
ok( memex.ullTotalVirtual == expect.ullTotalVirtual, "got ullTotalVirtual %#I64x\n", memex.ullTotalVirtual );
todo_wine
ok( memex.ullAvailVirtual <= expect.ullAvailVirtual, "got ullAvailVirtual %#I64x\n", memex.ullAvailVirtual );
ok( memex.ullAvailExtendedVirtual == 0, "got ullAvailExtendedVirtual %#I64x\n", memex.ullAvailExtendedVirtual );
......
......@@ -1043,6 +1043,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GlobalMemoryStatusEx( MEMORYSTATUSEX *status )
static DWORD last_check;
SYSTEM_BASIC_INFORMATION basic_info;
SYSTEM_PERFORMANCE_INFORMATION perf_info;
VM_COUNTERS_EX vmc;
if (status->dwLength != sizeof(*status))
{
......@@ -1059,16 +1060,18 @@ BOOL WINAPI DECLSPEC_HOTPATCH GlobalMemoryStatusEx( MEMORYSTATUSEX *status )
if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation,
&basic_info, sizeof(basic_info), NULL )) ||
!set_ntstatus( NtQuerySystemInformation( SystemPerformanceInformation,
&perf_info, sizeof(perf_info), NULL)))
&perf_info, sizeof(perf_info), NULL)) ||
!set_ntstatus( NtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters,
&vmc, sizeof(vmc), NULL )))
return FALSE;
status->dwMemoryLoad = 0;
status->ullTotalPhys = perf_info.TotalCommitLimit;
status->ullTotalPhys = basic_info.MmNumberOfPhysicalPages;
status->ullAvailPhys = perf_info.AvailablePages;
status->ullTotalPageFile = perf_info.TotalCommitLimit + 1; /* Titan Quest refuses to run if TotalPageFile <= TotalPhys */
status->ullTotalPageFile = perf_info.TotalCommitLimit;
status->ullAvailPageFile = status->ullTotalPageFile - perf_info.TotalCommittedPages;
status->ullTotalVirtual = (ULONG_PTR)basic_info.HighestUserAddress - (ULONG_PTR)basic_info.LowestUserAddress;
status->ullAvailVirtual = status->ullTotalVirtual - 64 * 1024; /* FIXME */
status->ullTotalVirtual = (ULONG_PTR)basic_info.HighestUserAddress - (ULONG_PTR)basic_info.LowestUserAddress + 1;
status->ullAvailVirtual = status->ullTotalVirtual - (ULONGLONG)vmc.WorkingSetSize /* approximate */;
status->ullAvailExtendedVirtual = 0;
status->ullTotalPhys *= basic_info.PageSize;
......
......@@ -2008,6 +2008,10 @@ static void get_performance_info( SYSTEM_PERFORMANCE_INFORMATION *info )
#endif
}
#endif
/* Titan Quest refuses to run if TotalPageFile <= TotalPhys */
if (!totalswap) totalswap = page_size;
info->AvailablePages = freeram / page_size;
info->TotalCommittedPages = (totalram + totalswap - freeram - freeswap) / page_size;
info->TotalCommitLimit = (totalram + totalswap) / page_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment