Skip to content

Commit a52b793

Browse files
author
Requiem
committed
feat: added checks for virtual boot loaders
1 parent 8b14b09 commit a52b793

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/vmaware.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9368,6 +9368,31 @@ struct VM {
93689368
return true; // we cant return a brand here since its used in VMWare, QEMU with OVMF, VirtualBox, etc
93699369
}
93709370

9371+
if (nameView == L"Boot0000") { // should be Windows Boot Manager
9372+
BYTE* bootBuf = nullptr; SIZE_T bootLen = 0;
9373+
if (read_var_to_buf(nameView, varName->VendorGuid, bootBuf, bootLen)) {
9374+
bool anomaly = (bootLen < 6);
9375+
if (!anomaly) {
9376+
unsigned short fplLen = 0;
9377+
memcpy(&fplLen, bootBuf + 4, sizeof(fplLen));
9378+
// we could also check if loadOptionsLength is 136
9379+
if (fplLen != 116) anomaly = true;
9380+
}
9381+
9382+
if (bootBuf && bootBuf != stackBuf) {
9383+
PVOID b = bootBuf; SIZE_T z = 0;
9384+
pNtFreeVirtualMemory(hCurrentProcess, &b, &z, 0x8000);
9385+
}
9386+
9387+
if (anomaly) {
9388+
debug("NVRAM: Environment was loaded using a virtual boot loader"); // "virtual" here -> non genuine
9389+
SIZE_T z = 0; pNtFreeVirtualMemory(hCurrentProcess, &enumBase, &z, 0x8000);
9390+
cleanup();
9391+
return true;
9392+
}
9393+
}
9394+
}
9395+
93719396
if (varName->NextEntryOffset == 0) break;
93729397
const SIZE_T ne = static_cast<SIZE_T>(varName->NextEntryOffset);
93739398
const size_t nextOffset = offset + ne;

0 commit comments

Comments
 (0)