summaryrefslogtreecommitdiffstats
path: root/src/detection/physicalmemory/physicalmemory.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/physicalmemory/physicalmemory.c
Add the files
Diffstat (limited to 'src/detection/physicalmemory/physicalmemory.c')
-rw-r--r--src/detection/physicalmemory/physicalmemory.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/detection/physicalmemory/physicalmemory.c b/src/detection/physicalmemory/physicalmemory.c
new file mode 100644
index 0000000..0188e05
--- /dev/null
+++ b/src/detection/physicalmemory/physicalmemory.c
@@ -0,0 +1,73 @@
+#include "physicalmemory.h"
+
+static inline const char* getVendorString(unsigned vendorId) {
+ switch (vendorId) {
+ case 0x017A:
+ return "Apacer";
+ case 0x0198:
+ return "Kingston";
+ case 0x029E:
+ return "Corsair";
+ case 0x04CB:
+ return "A-DATA";
+ case 0x04CD:
+ return "G-Skill";
+ case 0x059B:
+ case 0x859B:
+ return "Crucial";
+ case 0x00CE:
+ case 0x80CE:
+ case 0xCE00:
+ return "Samsung";
+ case 0x014F:
+ return "Transcend";
+ case 0x2C00:
+ case 0x802C:
+ return "Micron";
+ case 0xAD00:
+ case 0x80AD:
+ return "SK Hynix";
+ case 0x5105:
+ case 0x8551:
+ return "Qimonda";
+ case 0x02FE:
+ return "Elpida";
+ case 0x0467:
+ return "Ramaxel";
+ default:
+ return NULL;
+ }
+}
+
+void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device) {
+ if (device->vendor.length == 0) {
+ return;
+ }
+ if (ffStrbufEqualS(&device->vendor, "Unknown")) {
+ ffStrbufClear(&device->vendor);
+ return;
+ }
+
+ char vendorIdStr[5];
+ if (ffStrbufStartsWithS(&device->vendor, "0x")) {
+ if (device->vendor.length < 6) {
+ return;
+ }
+ memcpy(vendorIdStr, device->vendor.chars + 2, 4);
+ } else {
+ if (device->vendor.length < 4) {
+ return;
+ }
+ memcpy(vendorIdStr, device->vendor.chars, 4);
+ }
+ vendorIdStr[4] = '\0';
+ char* pEnd = NULL;
+ uint32_t vendorId = (uint32_t) strtoul(vendorIdStr, &pEnd, 16);
+ if (*pEnd != '\0') {
+ return;
+ }
+ const char* vendorStr = getVendorString(vendorId);
+ if (vendorStr) {
+ ffStrbufSetStatic(&device->vendor, vendorStr);
+ }
+}