@@ -5824,31 +5824,40 @@ struct VM {
5824
5824
}
5825
5825
}
5826
5826
5827
- // 4) SMBIOS (RSMB) / FIRM tables
5828
- const DWORD smbios[] = { FIRM_SIG, RSMB_SIG };
5829
- for (DWORD provider : smbios) {
5830
- const UINT enumSMB = EnumSystemFirmwareTables (provider, nullptr , 0 );
5831
- if (enumSMB == 0 ) continue ;
5832
- if (enumSMB % sizeof (DWORD) != 0 ) continue ;
5833
-
5834
- std::vector<BYTE> ids (enumSMB);
5835
- if (EnumSystemFirmwareTables (provider, ids.data (), enumSMB) != enumSMB)
5836
- continue ;
5827
+ // 4) SMBIOS (RSMB) / FIRM tables
5828
+ constexpr DWORD smbProviders[] = { ' FIRM' , ' RSMB' };
5837
5829
5838
- const DWORD cntOther = enumSMB / sizeof (DWORD);
5839
- for (DWORD i = 0 ; i < cntOther; ++i) {
5840
- DWORD tblID;
5841
- memcpy (&tblID, ids.data () + i * sizeof (DWORD), sizeof (tblID));
5842
- BYTE* buf = nullptr ; size_t len = 0 ;
5843
- if (fetch (provider, tblID, buf, len)) {
5844
- if (scan_table (buf, len)) {
5845
- free (buf);
5846
- return true ;
5847
- }
5848
- free (buf);
5849
- }
5830
+ for (DWORD prov : smbProviders) {
5831
+ UINT e = EnumSystemFirmwareTables (prov, nullptr , 0 );
5832
+
5833
+ if (!e) continue ;
5834
+
5835
+ std::vector<BYTE> bufIDs (e);
5836
+
5837
+ if (EnumSystemFirmwareTables (prov, bufIDs.data (), e) != e) continue ;
5838
+
5839
+ DWORD cnt = e / sizeof (DWORD);
5840
+ auto otherIDs = reinterpret_cast <DWORD*>(bufIDs.data ());
5841
+ char provStr[5 ] = { 0 }; memcpy (provStr, &prov, 4 );
5842
+
5843
+ for (DWORD i = 0 ; i < cnt; ++i) {
5844
+ DWORD tblID = otherIDs[i];
5845
+ UINT sz = GetSystemFirmwareTable (prov, tblID, nullptr , 0 );Add commentMore actions
5846
+ if (!sz) continue ;
5847
+ BYTE* buf = (BYTE*)malloc (sz);
5848
+ if (!buf) continue ;
5849
+ if (GetSystemFirmwareTable (prov, tblID, buf, sz) != sz) {
5850
+ free (buf); continue ;
5851
+ }
5852
+
5853
+ if (scan_table (buf, sz)) {
5854
+ free (buf);
5855
+ return true ;
5850
5856
}
5857
+
5858
+ free (buf);
5851
5859
}
5860
+ }
5852
5861
5853
5862
return false ;
5854
5863
#elif (LINUX)
0 commit comments