[PATCH] ntdll: Report system information SystemPerformanceInformation info class. (v3)

Vijay Kiran Kamuju infyquest at gmail.com
Tue Apr 16 04:27:16 CDT 2019


Based on patch from Michael Müller <michael at fds-team.de>
parse /proc/meminfo for all the information instead of calling sysinfo

From: Vijay Kiran Kamuju <infyquest at gmail.com>
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
 dlls/ntdll/nt.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index f429349698..c8794e5108 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2319,6 +2319,37 @@ NTSTATUS WINAPI NtQuerySystemInformation(
                 spi.IdleTime.QuadPart = ++idle;
             }
 
+            if ((fp = fopen("/proc/meminfo", "r")))
+            {
+                ULONG64 totalram, freeram, totalswap, freeswap;
+                char line[64];
+                while (fgets(line, sizeof(line), fp))
+                {
+                   if(sscanf(line, "MemTotal: %llu kB", &totalram) == 1)
+                   {
+                       totalram *= 1024;
+                   }
+                   else if(sscanf(line, "MemFree: %llu kB", &freeram) == 1)
+                   {
+                       freeram *= 1024;
+                   }
+                   else if(sscanf(line, "SwapTotal: %llu kB", &totalswap) == 1)
+                   {
+                       totalswap *= 1024;
+                   }
+                   else if(sscanf(line, "SwapFree: %llu kB", &freeswap) == 1)
+                   {
+                       freeswap *= 1024;
+                       break;
+                   }
+                }
+                fclose(fp);
+
+                spi.AvailablePages      = freeram / page_size;
+                spi.TotalCommittedPages = (totalram + totalswap - freeram - freeswap) / page_size;
+                spi.TotalCommitLimit    = (totalram + totalswap) / page_size;
+            }
+
             if (Length >= len)
             {
                 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
-- 
2.21.0




More information about the wine-devel mailing list