summaryrefslogtreecommitdiffstats
path: root/src/detection/memory/memory_bsd.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/memory/memory_bsd.c
Add the files
Diffstat (limited to 'src/detection/memory/memory_bsd.c')
-rw-r--r--src/detection/memory/memory_bsd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/detection/memory/memory_bsd.c b/src/detection/memory/memory_bsd.c
new file mode 100644
index 0000000..f76f6b8
--- /dev/null
+++ b/src/detection/memory/memory_bsd.c
@@ -0,0 +1,16 @@
+#include "memory.h"
+#include "common/sysctl.h"
+
+const char* ffDetectMemory(FFMemoryResult* ram) {
+ size_t length = sizeof(ram->bytesTotal);
+ if (sysctl((int[]) { CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0)) {
+ return "Failed to read hw.physmem";
+ }
+
+ // vm.stats.vm.* are int values
+ int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0) + ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0) + ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
+
+ ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.sysinfo.pageSize;
+
+ return NULL;
+}