Skip to content

Surface Pro 11 fix revision #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions src/vmaware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
#elif VMA_CPLUSPLUS >= 202002L
# define CPP 20
# ifdef __VMAWARE_DEBUG__
# pragma message("using C++20")

Check warning on line 255 in src/vmaware.hpp

View workflow job for this annotation

GitHub Actions / Analyze (cpp, gcc-14, Ninja Multi-Config, Debug, ON)

using C++20 [-W#pragma-messages]
# endif

#elif VMA_CPLUSPLUS >= 201703L
Expand Down Expand Up @@ -5609,10 +5609,7 @@
#pragma pack(pop)

constexpr DWORD ACPI_SIG = 'ACPI';
constexpr DWORD ssdtSig = 'TDSS';
constexpr DWORD dsdtSig = 'TDSD';
constexpr DWORD FIRM_SIG = 'FIRM';
constexpr DWORD RSMB_SIG = 'RSMB';

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

// 4) VMspecific firmware signatures
// 4) VM-specific firmware signatures
for (size_t ti = 0; ti < targets.size(); ++ti) {
const char* pat = targets[ti];
const size_t plen = strlen(pat);
Expand Down Expand Up @@ -5734,12 +5731,6 @@
debug("FIRMWARE: Not enough ACPI tables for a real system");
return true;
}
int ssdt_ct = 0;
for (auto tbl : tables) if (tbl == ssdtSig && ++ssdt_ct >= 2) break;
if (ssdt_ct < 2) {
debug("FIRMWARE: Not enough SSDT tables for a real system");
return true;
}

// helper to fetch one table into a malloc'd buffer
constexpr size_t MAX_FW_TABLE = static_cast<size_t>(16 * 1024) * 1024;
Expand All @@ -5760,6 +5751,7 @@
for (auto tbl : tables) {
BYTE* buf = nullptr; size_t len = 0;
if (fetch(ACPI_SIG, tbl, buf, len)) {

if (scan_table(buf, len)) {
free(buf);
return true;
Expand All @@ -5768,7 +5760,7 @@
}
}

// 4) DSDT + _OSI check
// 4) DSDT check
const UINT dsdtSz = GetSystemFirmwareTable(ACPI_SIG, dsdtSig, nullptr, 0);
if (dsdtSz == 0 || dsdtSz > MAX_FW_TABLE)
return false;
Expand Down Expand Up @@ -5801,28 +5793,33 @@
}

// 5) SMBIOS (RSMB) / FIRM tables
const DWORD smbios[] = { FIRM_SIG, RSMB_SIG };
for (DWORD provider : smbios) {
const UINT enumSMB = EnumSystemFirmwareTables(provider, nullptr, 0);
if (enumSMB == 0) continue;
if (enumSMB % sizeof(DWORD) != 0) continue;

std::vector<BYTE> ids(enumSMB);
if (EnumSystemFirmwareTables(provider, ids.data(), enumSMB) != enumSMB)
continue;
constexpr DWORD smbProviders[] = { 'FIRM', 'RSMB' };
for (DWORD prov : smbProviders) {
UINT e = EnumSystemFirmwareTables(prov, nullptr, 0);
if (!e) continue;
std::vector<BYTE> bufIDs(e);
if (EnumSystemFirmwareTables(prov, bufIDs.data(), e) != e) continue;
DWORD cnt = e / sizeof(DWORD);
auto otherIDs = reinterpret_cast<DWORD*>(bufIDs.data());

char provStr[5] = { 0 }; memcpy(provStr, &prov, 4);

for (DWORD i = 0; i < cnt; ++i) {
DWORD tblID = otherIDs[i];

UINT sz = GetSystemFirmwareTable(prov, tblID, nullptr, 0);
if (!sz) continue;
BYTE* buf = (BYTE*)malloc(sz);
if (!buf) continue;
if (GetSystemFirmwareTable(prov, tblID, buf, sz) != sz) {
free(buf); continue;
}

const DWORD cntOther = enumSMB / sizeof(DWORD);
for (DWORD i = 0; i < cntOther; ++i) {
DWORD tblID;
memcpy(&tblID, ids.data() + i * sizeof(DWORD), sizeof(tblID));
BYTE* buf = nullptr; size_t len = 0;
if (fetch(provider, tblID, buf, len)) {
if (scan_table(buf, len)) {
free(buf);
return true;
}
if (scan_table(buf, sz)) {
free(buf);
return true;
}
free(buf);
}
}

Expand Down Expand Up @@ -8087,6 +8084,7 @@
case 0x54584E00u: // "TXN\0"
case 0x524F4343u: // "ROCC"
case 0x4C454E00u: // "LEN\0"
case 0x4D534654u: // "MSFT" -> Microsoft Surface Pro Devices
return false;
default:
return true;
Expand Down