ohmu
·
2026-10-15
1#include "physicalmemory.h"
2
3static inline const char* getVendorString(unsigned vendorId) {
4 switch (vendorId) {
5 case 0x017A:
6 return "Apacer";
7 case 0x0198:
8 return "Kingston";
9 case 0x029E:
10 return "Corsair";
11 case 0x04CB:
12 return "A-DATA";
13 case 0x04CD:
14 return "G-Skill";
15 case 0x059B:
16 case 0x859B:
17 return "Crucial";
18 case 0x00CE:
19 case 0x80CE:
20 case 0xCE00:
21 return "Samsung";
22 case 0x014F:
23 return "Transcend";
24 case 0x2C00:
25 case 0x802C:
26 return "Micron";
27 case 0xAD00:
28 case 0x80AD:
29 return "SK Hynix";
30 case 0x5105:
31 case 0x8551:
32 return "Qimonda";
33 case 0x02FE:
34 return "Elpida";
35 case 0x0467:
36 return "Ramaxel";
37 default:
38 return nullptr;
39 }
40}
41
42void FFPhysicalMemoryUpdateVendorString(FFPhysicalMemoryResult* device) {
43 if (device->vendor.length == 0) {
44 return;
45 }
46 if (ffStrbufEqualS(&device->vendor, "Unknown")) {
47 ffStrbufClear(&device->vendor);
48 return;
49 }
50
51 char vendorIdStr[5];
52 if (ffStrbufStartsWithS(&device->vendor, "0x")) {
53 if (device->vendor.length < 6) {
54 return;
55 }
56 memcpy(vendorIdStr, device->vendor.chars + 2, 4);
57 } else {
58 if (device->vendor.length < 4) {
59 return;
60 }
61 memcpy(vendorIdStr, device->vendor.chars, 4);
62 }
63 vendorIdStr[4] = '\0';
64 char* pEnd = nullptr;
65 uint32_t vendorId = (uint32_t) strtoul(vendorIdStr, &pEnd, 16);
66 if (*pEnd != '\0') {
67 return;
68 }
69 const char* vendorStr = getVendorString(vendorId);
70 if (vendorStr) {
71 ffStrbufSetStatic(&device->vendor, vendorStr);
72 }
73}