Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/heap.c | 4 ---- dlls/kernelbase/memory.c | 13 ++++++++----- dlls/ntdll/unix/system.c | 4 ++++ 3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index c36d9331bef..6efe4da4634 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -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 );
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index 29e1999fe6b..42ffd1bcdd9 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -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; diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 4052d28f644..65c49b6ccd1 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -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;