[PATCH 0/2] MR11007: wbemprox: Win32_OperatingSystem.FreeVirtualMemory and TotalVirtualMemorySize improvements
Fixes expectations about returned memory size in native .NET (crash when the result doesn't fit into 32-bit value). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11007
From: Piotr Caban <piotr@codeweavers.com> --- dlls/wbemprox/builtin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 59f5e89d8c8..15ba55779fe 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -1929,7 +1929,7 @@ static UINT64 get_total_virtual_memory(void) status.dwLength = sizeof(status); if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024; - return status.ullTotalVirtual; + return status.ullTotalPageFile; } static UINT64 get_available_virtual_memory(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11007
From: Piotr Caban <piotr@codeweavers.com> --- dlls/wbemprox/builtin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 15ba55779fe..9e1036cdc26 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -1938,7 +1938,7 @@ static UINT64 get_available_virtual_memory(void) status.dwLength = sizeof(status); if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024; - return status.ullAvailVirtual; + return status.ullAvailPageFile; } static WCHAR *get_computername(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11007
Hans Leidekker (@hans) commented about dlls/wbemprox/builtin.c:
status.dwLength = sizeof(status); if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024; - return status.ullTotalVirtual; + return status.ullTotalPageFile;
ullTotalVirtual is supposed to be 2 or 3GB for 32-bit processes. How does this cause overflow? If we're switching to ullTotalPageFile, shouldn't we add the amount of physical memory (ullTotalPhys)? That's how MSDN defines TotalVirtualMemorySize. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11007#note_141414
On Wed May 27 10:46:03 2026 +0000, Hans Leidekker wrote:
ullTotalVirtual is supposed to be 2 or 3GB for 32-bit processes. How does this cause overflow? If we're switching to ullTotalPageFile, shouldn't we add the amount of physical memory (ullTotalPhys)? That's how MSDN defines TotalVirtualMemorySize. .NET expects the value to fit into 32 bits in 64-bit application.
`TotalVirtualMemorySize` can be computed as `TotalVisibleMemorySize + SizeStoredInPagingFiles`. We don't implement `SizeStoredInPagingFiles` but when we do we will need to implement it as (`status.ullTotalPageFile - status.ullTotalPhys) / 1024` due to how `GlobalMemoryStatusEx` works. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11007#note_141415
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11007
participants (3)
-
Hans Leidekker (@hans) -
Piotr Caban -
Piotr Caban (@piotr)