Skip to content

Commit f883294

Browse files
committed
misc changes
1 parent 7beb4b3 commit f883294

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

src/vmaware.hpp

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5824,31 +5824,40 @@ struct VM {
58245824
}
58255825
}
58265826

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' };
58375829

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;
58505856
}
5857+
5858+
free(buf);
58515859
}
5860+
}
58525861

58535862
return false;
58545863
#elif (LINUX)

0 commit comments

Comments
 (0)