Skip to content

Commit 654c0e6

Browse files
authored
Merge pull request #449 from NotRequiem/dev
Surface Pro 11 fix revision
2 parents ce21d5a + 543fe67 commit 654c0e6

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

src/vmaware.hpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5609,10 +5609,7 @@ struct VM {
56095609
#pragma pack(pop)
56105610

56115611
constexpr DWORD ACPI_SIG = 'ACPI';
5612-
constexpr DWORD ssdtSig = 'TDSS';
56135612
constexpr DWORD dsdtSig = 'TDSD';
5614-
constexpr DWORD FIRM_SIG = 'FIRM';
5615-
constexpr DWORD RSMB_SIG = 'RSMB';
56165613

56175614
// "WAET" is also present as a string inside the WAET table, so there's no need to check for its table signature
56185615
constexpr std::array<const char*, 24> targets = { {
@@ -5670,7 +5667,7 @@ struct VM {
56705667
return true;
56715668
}
56725669

5673-
// 4) VMspecific firmware signatures
5670+
// 4) VM-specific firmware signatures
56745671
for (size_t ti = 0; ti < targets.size(); ++ti) {
56755672
const char* pat = targets[ti];
56765673
const size_t plen = strlen(pat);
@@ -5734,12 +5731,6 @@ struct VM {
57345731
debug("FIRMWARE: Not enough ACPI tables for a real system");
57355732
return true;
57365733
}
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-
}
57435734

57445735
// helper to fetch one table into a malloc'd buffer
57455736
constexpr size_t MAX_FW_TABLE = static_cast<size_t>(16 * 1024) * 1024;
@@ -5760,6 +5751,7 @@ struct VM {
57605751
for (auto tbl : tables) {
57615752
BYTE* buf = nullptr; size_t len = 0;
57625753
if (fetch(ACPI_SIG, tbl, buf, len)) {
5754+
57635755
if (scan_table(buf, len)) {
57645756
free(buf);
57655757
return true;
@@ -5768,7 +5760,7 @@ struct VM {
57685760
}
57695761
}
57705762

5771-
// 4) DSDT + _OSI check
5763+
// 4) DSDT check
57725764
const UINT dsdtSz = GetSystemFirmwareTable(ACPI_SIG, dsdtSig, nullptr, 0);
57735765
if (dsdtSz == 0 || dsdtSz > MAX_FW_TABLE)
57745766
return false;
@@ -5801,28 +5793,33 @@ struct VM {
58015793
}
58025794

58035795
// 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+
}
58135817

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)) {
58245819
free(buf);
5820+
return true;
58255821
}
5822+
free(buf);
58265823
}
58275824
}
58285825

@@ -8087,6 +8084,7 @@ struct VM {
80878084
case 0x54584E00u: // "TXN\0"
80888085
case 0x524F4343u: // "ROCC"
80898086
case 0x4C454E00u: // "LEN\0"
8087+
case 0x4D534654u: // "MSFT" -> Microsoft Surface Pro Devices
80908088
return false;
80918089
default:
80928090
return true;

0 commit comments

Comments
 (0)