[PATCH] kernel32: Do not impose 32 bit limits on Win64 in GlobalMemoryStatus().
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> --- Fixes computer configuration detection in Forza Horizon 4 (avoids the complain about the system falling below minimum requirements). dlls/kernel32/heap.c | 7 ++++--- dlls/kernel32/tests/heap.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c index b7bd6f5f91d..c8ae9f5a943 100644 --- a/dlls/kernel32/heap.c +++ b/dlls/kernel32/heap.c @@ -44,6 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(globalmem); static HANDLE systemHeap; /* globally shared heap */ +static BOOL is_win64 = sizeof(void *) == 8; /*********************************************************************** * HEAP_CreateSystemHeap @@ -561,7 +562,7 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer ) osver.dwOSVersionInfoSize = sizeof(osver); GetVersionExW(&osver); - if ( osver.dwMajorVersion >= 5 || osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) + if ( !is_win64 && (osver.dwMajorVersion >= 5 || osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) ) { lpBuffer->dwTotalPhys = min( memstatus.ullTotalPhys, MAXDWORD ); lpBuffer->dwAvailPhys = min( memstatus.ullAvailPhys, MAXDWORD ); @@ -572,7 +573,7 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer ) lpBuffer->dwAvailVirtual = min( memstatus.ullAvailVirtual, MAXDWORD ); } - else /* duplicate NT bug */ + else /* 64 bit case, or duplicate NT bug */ { lpBuffer->dwTotalPhys = memstatus.ullTotalPhys; lpBuffer->dwAvailPhys = memstatus.ullAvailPhys; @@ -593,7 +594,7 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer ) } /* work around for broken photoshop 4 installer */ - if ( lpBuffer->dwAvailPhys + lpBuffer->dwAvailPageFile >= 2U*1024*1024*1024) + if ( !is_win64 && lpBuffer->dwAvailPhys + lpBuffer->dwAvailPageFile >= 2U*1024*1024*1024 ) lpBuffer->dwAvailPageFile = 2U*1024*1024*1024 - lpBuffer->dwAvailPhys - 1; /* limit page file size for really old binaries */ diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index fa372b14e21..85579535084 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -1213,6 +1213,39 @@ static void test_GetPhysicallyInstalledSystemMemory(void) "expected total_memory >= memstatus.ullTotalPhys / 1024\n"); } +static void test_GlobalMemoryStatus(void) +{ + MEMORYSTATUSEX memex; + MEMORYSTATUS mem; + SIZE_T size; + + mem.dwLength = sizeof(mem); + GlobalMemoryStatus(&mem); + memex.dwLength = sizeof(memex); + GlobalMemoryStatusEx(&memex); + + size = min(memex.ullTotalPhys, ~(SIZE_T)0 >> 1); + ok(mem.dwTotalPhys == size, "Got unexpected dwTotalPhys %s, size %s.\n", + wine_dbgstr_longlong(mem.dwTotalPhys), wine_dbgstr_longlong(size)); + size = min(memex.ullAvailPhys, ~(SIZE_T)0 >> 1); + ok(mem.dwAvailPhys == size, "Got unexpected dwAvailPhys %s, size %s.\n", + wine_dbgstr_longlong(mem.dwAvailPhys), wine_dbgstr_longlong(size)); + + size = min(memex.ullTotalPageFile, ~(SIZE_T)0); + ok(mem.dwTotalPageFile == size + || mem.dwTotalPageFile == size - 512 * 1024 /* Workaround for Sacrifice demo in Wine */, + "Got unexpected dwTotalPageFile %s, size %s.\n", + wine_dbgstr_longlong(mem.dwTotalPageFile), wine_dbgstr_longlong(size)); + size = min(memex.ullAvailPageFile, ~(SIZE_T)0); + ok(mem.dwAvailPageFile == size, "Got unexpected dwAvailPageFile %s, size %s.\n", + wine_dbgstr_longlong(mem.dwAvailPageFile), wine_dbgstr_longlong(size)); + + ok(mem.dwTotalVirtual == memex.ullTotalVirtual, "Got unexpected dwTotalVirtual %s, ullTotalVirtual %s.\n", + wine_dbgstr_longlong(mem.dwTotalVirtual), wine_dbgstr_longlong(memex.ullTotalVirtual)); + ok(mem.dwAvailVirtual == memex.ullAvailVirtual, "Got unexpected dwAvailVirtual %s, ullAvailVirtual %s.\n", + wine_dbgstr_longlong(mem.dwAvailVirtual), wine_dbgstr_longlong(memex.ullAvailVirtual)); +} + START_TEST(heap) { int argc; @@ -1246,6 +1279,7 @@ START_TEST(heap) test_HeapQueryInformation(); test_GetPhysicallyInstalledSystemMemory(); + test_GlobalMemoryStatus(); if (pRtlGetNtGlobalFlags) { -- 2.30.2
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89148 Your paranoid android. === w7u_el (32 bit report) === kernel32: heap.c:1231: Test failed: Got unexpected dwAvailPhys 67c43000, size 67c3e000. === w1064v1507 (64 bit report) === kernel32: heap.c:1231: Test failed: Got unexpected dwAvailPhys 809c9000, size 809c6000. === debiant2 (32 bit report) === kernel32: comm.c:728: Test failed: Still pending 2070003979 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue === debiant2 (32 bit WoW report) === kernel32: comm.c:728: Test failed: Still pending 2070003979 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue comm.c:728: Test failed: Still pending 5676975 characters in OutQueue === debiant2 (64 bit WoW report) === kernel32: comm.c:727: Test failed: Unexpected 2070004009 chars in InQueue comm.c:996: Test failed: Unexpected 13335381 chars in OutQueue comm.c:997: Test failed: ClearCommErrors: Unexpected error 0x0057ad0f comm.c:729: Test failed: Unexpected errors 0x00cb7b55 comm.c:2011: Test failed: expected 0, got 13335381 bytes in OutQueue comm.c:2012: Test failed: expected errors 0, got 0x57ad0f comm.c:727: Test failed: Unexpected 5515760 chars in InQueue comm.c:729: Test failed: Unexpected errors 0x0053fa37
participants (2)
-
Marvin -
Paul Gofman