mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-06 13:14:21 +01:00
Memory / Swap (Windows): simplify implementation
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
#include "memory.h"
|
||||
|
||||
#include <winternl.h>
|
||||
#include <ntstatus.h>
|
||||
#include <windows.h>
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
{
|
||||
MEMORYSTATUSEX statex = {
|
||||
.dwLength = sizeof(statex),
|
||||
};
|
||||
if (!GlobalMemoryStatusEx(&statex))
|
||||
return "GlobalMemoryStatusEx() failed";
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetNativeSystemInfo(&sysInfo);
|
||||
|
||||
SYSTEM_PERFORMANCE_INFORMATION info;
|
||||
if (!NT_SUCCESS(NtQuerySystemInformation(SystemPerformanceInformation, &info, sizeof(info), NULL)))
|
||||
return "NtQuerySystemInformation(SystemPerformanceInformation) failed";
|
||||
ram->bytesUsed = (uint64_t)(info.TotalCommitLimit - info.AvailablePages) * sysInfo.dwPageSize;
|
||||
ram->bytesTotal = (uint64_t)info.TotalCommitLimit * sysInfo.dwPageSize;
|
||||
|
||||
ram->bytesTotal = statex.ullTotalPhys;
|
||||
ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user