summaryrefslogtreecommitdiffstats
path: root/src/detection/memory/memory_windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/detection/memory/memory_windows.c')
-rw-r--r--src/detection/memory/memory_windows.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/detection/memory/memory_windows.c b/src/detection/memory/memory_windows.c
new file mode 100644
index 0000000..779425d
--- /dev/null
+++ b/src/detection/memory/memory_windows.c
@@ -0,0 +1,19 @@
+#include "memory.h"
+
+#include <windows.h>
+
+const char* ffDetectMemory(FFMemoryResult* ram) {
+ MEMORYSTATUSEX statex = {
+ .dwLength = sizeof(statex),
+ };
+ // GlobalMemoryStatusEx() internally uses
+ // NtQuerySystemInformation(SystemBasicPerformanceInformation) in Win 7, and
+ // NtQuerySystemInformation(SystemMemoryUsageInformation) in Win 10
+ if (!GlobalMemoryStatusEx(&statex)) {
+ return "GlobalMemoryStatusEx() failed";
+ }
+
+ ram->bytesTotal = statex.ullTotalPhys;
+ ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;
+ return NULL;
+}