@@ -5609,10 +5609,7 @@ struct VM {
5609
5609
#pragma pack(pop)
5610
5610
5611
5611
constexpr DWORD ACPI_SIG = ' ACPI' ;
5612
- constexpr DWORD ssdtSig = ' TDSS' ;
5613
5612
constexpr DWORD dsdtSig = ' TDSD' ;
5614
- constexpr DWORD FIRM_SIG = ' FIRM' ;
5615
- constexpr DWORD RSMB_SIG = ' RSMB' ;
5616
5613
5617
5614
// "WAET" is also present as a string inside the WAET table, so there's no need to check for its table signature
5618
5615
constexpr std::array<const char *, 24 > targets = { {
@@ -5670,7 +5667,7 @@ struct VM {
5670
5667
return true ;
5671
5668
}
5672
5669
5673
- // 4) VM‐ specific firmware signatures
5670
+ // 4) VM- specific firmware signatures
5674
5671
for (size_t ti = 0 ; ti < targets.size (); ++ti) {
5675
5672
const char * pat = targets[ti];
5676
5673
const size_t plen = strlen (pat);
@@ -5734,12 +5731,6 @@ struct VM {
5734
5731
debug (" FIRMWARE: Not enough ACPI tables for a real system" );
5735
5732
return true ;
5736
5733
}
5737
- int ssdt_ct = 0 ;
5738
- for (auto tbl : tables) if (tbl == ssdtSig && ++ssdt_ct >= 2 ) break ;
5739
- if (ssdt_ct < 2 ) {
5740
- debug (" FIRMWARE: Not enough SSDT tables for a real system" );
5741
- return true ;
5742
- }
5743
5734
5744
5735
// helper to fetch one table into a malloc'd buffer
5745
5736
constexpr size_t MAX_FW_TABLE = static_cast <size_t >(16 * 1024 ) * 1024 ;
@@ -5760,6 +5751,7 @@ struct VM {
5760
5751
for (auto tbl : tables) {
5761
5752
BYTE* buf = nullptr ; size_t len = 0 ;
5762
5753
if (fetch (ACPI_SIG, tbl, buf, len)) {
5754
+
5763
5755
if (scan_table (buf, len)) {
5764
5756
free (buf);
5765
5757
return true ;
@@ -5768,7 +5760,7 @@ struct VM {
5768
5760
}
5769
5761
}
5770
5762
5771
- // 4) DSDT + _OSI check
5763
+ // 4) DSDT check
5772
5764
const UINT dsdtSz = GetSystemFirmwareTable (ACPI_SIG, dsdtSig, nullptr , 0 );
5773
5765
if (dsdtSz == 0 || dsdtSz > MAX_FW_TABLE)
5774
5766
return false ;
@@ -5801,28 +5793,33 @@ struct VM {
5801
5793
}
5802
5794
5803
5795
// 5) SMBIOS (RSMB) / FIRM tables
5804
- const DWORD smbios[] = { FIRM_SIG, RSMB_SIG };
5805
- for (DWORD provider : smbios) {
5806
- const UINT enumSMB = EnumSystemFirmwareTables (provider, nullptr , 0 );
5807
- if (enumSMB == 0 ) continue ;
5808
- if (enumSMB % sizeof (DWORD) != 0 ) continue ;
5809
-
5810
- std::vector<BYTE> ids (enumSMB);
5811
- if (EnumSystemFirmwareTables (provider, ids.data (), enumSMB) != enumSMB)
5812
- continue ;
5796
+ constexpr DWORD smbProviders[] = { ' FIRM' , ' RSMB' };
5797
+ for (DWORD prov : smbProviders) {
5798
+ UINT e = EnumSystemFirmwareTables (prov, nullptr , 0 );
5799
+ if (!e) continue ;
5800
+ std::vector<BYTE> bufIDs (e);
5801
+ if (EnumSystemFirmwareTables (prov, bufIDs.data (), e) != e) continue ;
5802
+ DWORD cnt = e / sizeof (DWORD);
5803
+ auto otherIDs = reinterpret_cast <DWORD*>(bufIDs.data ());
5804
+
5805
+ char provStr[5 ] = { 0 }; memcpy (provStr, &prov, 4 );
5806
+
5807
+ for (DWORD i = 0 ; i < cnt; ++i) {
5808
+ DWORD tblID = otherIDs[i];
5809
+
5810
+ UINT sz = GetSystemFirmwareTable (prov, tblID, nullptr , 0 );
5811
+ if (!sz) continue ;
5812
+ BYTE* buf = (BYTE*)malloc (sz);
5813
+ if (!buf) continue ;
5814
+ if (GetSystemFirmwareTable (prov, tblID, buf, sz) != sz) {
5815
+ free (buf); continue ;
5816
+ }
5813
5817
5814
- const DWORD cntOther = enumSMB / sizeof (DWORD);
5815
- for (DWORD i = 0 ; i < cntOther; ++i) {
5816
- DWORD tblID;
5817
- memcpy (&tblID, ids.data () + i * sizeof (DWORD), sizeof (tblID));
5818
- BYTE* buf = nullptr ; size_t len = 0 ;
5819
- if (fetch (provider, tblID, buf, len)) {
5820
- if (scan_table (buf, len)) {
5821
- free (buf);
5822
- return true ;
5823
- }
5818
+ if (scan_table (buf, sz)) {
5824
5819
free (buf);
5820
+ return true ;
5825
5821
}
5822
+ free (buf);
5826
5823
}
5827
5824
}
5828
5825
@@ -8087,6 +8084,7 @@ struct VM {
8087
8084
case 0x54584E00u : // "TXN\0"
8088
8085
case 0x524F4343u : // "ROCC"
8089
8086
case 0x4C454E00u : // "LEN\0"
8087
+ case 0x4D534654u : // "MSFT" -> Microsoft Surface Pro Devices
8090
8088
return false ;
8091
8089
default :
8092
8090
return true ;
0 commit comments