From 95f94568158caaf4fefe2e14f21bb3f0701577c9 Mon Sep 17 00:00:00 2001 From: Vijay Kiran Kamuju Date: Tue, 16 Apr 2019 11:27:16 +0200 Subject: [PATCH] ntdll: Report system information SystemPerformanceInformation info class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on patch from Michael Müller. Signed-off-by: Vijay Kiran Kamuju Signed-off-by: Alexandre Julliard (cherry picked from commit 99ba65a1ea2c1546a61c3ed40996cbfee9d25f69) Signed-off-by: Michael Stefaniuc --- dlls/ntdll/nt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index dcf9123409f..12f1ab58ab7 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -2312,6 +2312,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;