[PATCH 7/7] wbemprox: Add FreeVirtualMemory property to Win32_Operatingsystem.

Louis Lenders xerox.xerox2000x at gmail.com
Tue Apr 26 01:41:29 CDT 2022


Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=52887
Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
---
 dlls/wbemprox/builtin.c     | 12 ++++++++++++
 dlls/wbemprox/tests/query.c |  1 +
 2 files changed, 13 insertions(+)

diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index cab598be5c6..7075e4909db 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -239,6 +239,7 @@ static const struct column col_operatingsystem[] =
     { L"CSName",                  CIM_STRING|COL_FLAG_DYNAMIC },
     { L"CurrentTimeZone",         CIM_SINT16 },
     { L"FreePhysicalMemory",      CIM_UINT64 },
+    { L"FreeVirtualMemory",       CIM_UINT64 },
     { L"InstallDate",             CIM_DATETIME },
     { L"LastBootUpTime",          CIM_DATETIME|COL_FLAG_DYNAMIC },
     { L"LocalDateTime",           CIM_DATETIME|COL_FLAG_DYNAMIC },
@@ -672,6 +673,7 @@ struct record_operatingsystem
     const WCHAR *csname;
     INT16        currenttimezone;
     UINT64       freephysicalmemory;
+    UINT64       freevirtualmemory;
     const WCHAR *installdate;
     const WCHAR *lastbootuptime;
     const WCHAR *localdatetime;
@@ -1560,6 +1562,15 @@ static UINT64 get_available_physical_memory(void)
     return status.ullAvailPhys;
 }
 
+static UINT64 get_available_virtual_memory(void)
+{
+    MEMORYSTATUSEX status;
+
+    status.dwLength = sizeof(status);
+    if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
+    return status.ullAvailVirtual;
+}
+
 static WCHAR *get_computername(void)
 {
     WCHAR *ret;
@@ -3683,6 +3694,7 @@ static enum fill_status fill_operatingsystem( struct table *table, const struct
     rec->csname                 = get_computername();
     rec->currenttimezone        = get_currenttimezone();
     rec->freephysicalmemory     = get_available_physical_memory() / 1024;
+    rec->freevirtualmemory      = get_available_virtual_memory() / 1024;
     rec->installdate            = L"20140101000000.000000+000";
     rec->lastbootuptime         = get_lastbootuptime();
     rec->localdatetime          = get_localdatetime();
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index aa6dc132ac6..641535fa213 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -1404,6 +1404,7 @@ static void test_Win32_OperatingSystem( IWbemServices *services )
     VariantClear( &val );
 
     check_property( obj, L"FreePhysicalMemory", VT_BSTR, CIM_UINT64 );
+    check_property( obj, L"FreeVirtualMemory", VT_BSTR, CIM_UINT64 );
     check_property( obj, L"Name", VT_BSTR, CIM_STRING );
 
     type = 0xdeadbeef;
-- 
2.36.0




More information about the wine-devel mailing list