Skip to content

Commit e6f6884

Browse files
authored
Merge branch 'dev' into dev
2 parents 7f9cb57 + 0dd487e commit e6f6884

4 files changed

Lines changed: 33 additions & 70 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ sudo make install
112112
cmake -S . -B build/ -G "Visual Studio 16 2019"
113113
```
114114

115+
Optionally, you can create a debug build by appending `-DCMAKE_BUILD_TYPE=Debug` to the cmake arguments.
116+
115117
<br>
116118

117119

docs/documentation.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ VMAware provides a convenient way to not only check for VMs, but also have the f
539539
| `VM::AUDIO` | Check if no waveform-audio output devices are present in the system | 🪟 | 25% | | | | | [link](https://github.com/kernelwernel/VMAware/blob/8cb2491b1c7d2cb7300d1d698b7c64c953b4ae75/src/vmaware.hpp#L9980) |
540540
| `VM::UNKNOWN_MANUFACTURER` | Check if the CPU manufacturer is not known | 🐧🪟🍏 | 50% | | | | | [link](https://github.com/kernelwernel/VMAware/blob/8cb2491b1c7d2cb7300d1d698b7c64c953b4ae75/src/vmaware.hpp#L10016) |
541541
| `VM::NSJAIL_PID` | Check if process status matches with nsjail patterns with PID anomalies | 🐧 | 75% | | | | Disabled by default | [link](https://github.com/kernelwernel/VMAware/blob/8cb2491b1c7d2cb7300d1d698b7c64c953b4ae75/src/vmaware.hpp#L10083) |
542-
| `VM::PCI_VM` | Check for PCIe bridge names for known VM keywords and brands | 🐧 | 100% | | | | Disabled by default | [link](https://github.com/kernelwernel/VMAware/blob/8cb2491b1c7d2cb7300d1d698b7c64c953b4ae75/src/vmaware.hpp#L10142) |
543542
| `VM::TPM` | Check if the system has a physical TPM by matching the TPM manufacturer against known physical TPM chip vendors | 🪟 | 50% | | | | | [link](https://github.com/kernelwernel/VMAware/blob/fb66db9fdd7894edebe5eeade4b0148a08bd5514/src/vmaware.hpp#L10011)|
544543
| `VM::PCI_VM_DEVICE_ID` | Check for PCI vendor and device IDs that are VM-specific | 🐧 | 90% | | | | | |
545544
| `VM::QEMU_PASSTHROUGH` | Check for QEMU's hot-plug signature | 🪟 | 100% | | | | | |

src/cli.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ bool is_unsupported(VM::enum_flags flag) {
393393
case VM::FILE_ACCESS_HISTORY:
394394
case VM::UNKNOWN_MANUFACTURER:
395395
case VM::NSJAIL_PID:
396-
case VM::PCI_VM:
397396
case VM::PCI_VM_DEVICE_ID:
398397
// ADD LINUX FLAG
399398
return false;
@@ -971,7 +970,6 @@ void general() {
971970
checker(VM::FILE_ACCESS_HISTORY, "low file access count");
972971
checker(VM::UNKNOWN_MANUFACTURER, "unknown manufacturer ids");
973972
checker(VM::NSJAIL_PID, "nsjail PID");
974-
checker(VM::PCI_VM, "PCIe bridge ports");
975973
checker(VM::TPM, "TPM manufacturer");
976974
checker(VM::PCI_VM_DEVICE_ID, "PCI vendor/device ID");
977975
checker(VM::QEMU_PASSTHROUGH, "QEMU passthrough");

src/vmaware.hpp

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ struct VM {
656656
AUDIO,
657657
UNKNOWN_MANUFACTURER,
658658
NSJAIL_PID,
659-
PCI_VM,
660659
TPM,
661660
PCI_VM_DEVICE_ID,
662661
QEMU_PASSTHROUGH,
@@ -908,8 +907,7 @@ struct VM {
908907
constexpr std::size_t buffer_size = sizeof(i32) * buffer.size();
909908
std::array<char, 64> charbuffer{};
910909

911-
std::string brand = "";
912-
brand.reserve(48); // 3 leafs 16 each
910+
std::string brand(48, '\0'); // 3 leafs 16 each
913911

914912
constexpr std::array<u32, 3> ids = { { cpu::leaf::brand1, cpu::leaf::brand2, cpu::leaf::brand3 } };
915913
for (const u32& id : ids) {
@@ -9665,52 +9663,6 @@ struct VM {
96659663
}
96669664

96679665

9668-
/**
9669-
* @brief Check for PCIe bridge names for known VM keywords and brands
9670-
* @category Linux
9671-
* @implements VM::PCI_VM
9672-
*/
9673-
[[nodiscard]] static bool lspci() {
9674-
#if (!LINUX)
9675-
return false;
9676-
#else
9677-
if (!(
9678-
(util::exists("/usr/bin/lspci")) ||
9679-
(util::exists("/bin/lspci")) ||
9680-
(util::exists("/usr/sbin/lspci"))
9681-
)) {
9682-
debug("PCI_VM: ", "binary doesn't exist");
9683-
return false;
9684-
}
9685-
9686-
const std::unique_ptr<std::string> result = util::sys_result("lspci 2>&1");
9687-
9688-
if (result == nullptr) {
9689-
debug("PCI_VM: ", "invalid stdout output from lspci");
9690-
return false;
9691-
}
9692-
9693-
const std::string full_command = *result;
9694-
9695-
auto pci_finder = [&](const char* str) -> bool {
9696-
if (util::find(full_command, str)) {
9697-
debug("PCI_VM: found ", str);
9698-
return true;
9699-
} else {
9700-
return false;
9701-
}
9702-
};
9703-
9704-
if (pci_finder("QEMU PCIe Root port")) { return core::add(brands::QEMU); }
9705-
if (pci_finder("QEMU XHCI Host Controller")) { return core::add(brands::QEMU); }
9706-
if (pci_finder("QXL paravirtual graphic card")) { return core::add(brands::QEMU); }
9707-
if (pci_finder("Virtio")) { return true; } // could be used by a lot of brands, who knows
9708-
9709-
return false;
9710-
#endif
9711-
}
9712-
9713-
97149666
/**
97159667
* @brief Check if the system has a physical TPM by matching the TPM manufacturer against known physical TPM chip vendors
97169668
* @category Windows
@@ -9857,6 +9809,16 @@ struct VM {
98579809
);
98589810
}
98599811
#endif
9812+
9813+
auto found = [](const std::string &b) -> bool {
9814+
debug(
9815+
"PCI_VM_DEVICE_ID: found ", b, ", vendor ID = ",
9816+
"0x", std::setw(4), std::setfill('0'), std::hex, dev.vendor_id,
9817+
" device ID = 0x", std::setw(4), std::setfill('0'), std::hex, dev.device_id
9818+
);
9819+
9820+
return true;
9821+
};
98609822

98619823
for (const auto& dev : devices) {
98629824
const u32 id = ((dev.vendor_id << 16) | dev.device_id);
@@ -9882,6 +9844,7 @@ struct VM {
98829844
case 0x1af41053: // Virtio socket
98839845
case 0x1af4105a: // Virtio file system
98849846
case 0x1af41110: // Inter-VM shared memory
9847+
return true;
98859848

98869849
// VMware
98879850
case 0x15ad0405: // SVGA II Adapter
@@ -9913,6 +9876,7 @@ struct VM {
99139876
case 0x0e0f8002: // Root Hub
99149877
case 0x0e0f8003: // Root Hub
99159878
case 0x0e0ff80a: // Smoker FX2
9879+
return found(brands::VMWARE);
99169880

99179881
// Red Hat + QEMU
99189882
case 0x1b360001: // Red Hat, Inc. QEMU PCI-PCI bridge
@@ -9928,34 +9892,33 @@ struct VM {
99289892
case 0x1b360010: // Red Hat, Inc. QEMU NVM Express Controller
99299893
case 0x1b360011: // Red Hat, Inc. QEMU PVPanic device
99309894
case 0x1b360013: // Red Hat, Inc. QEMU UFS Host Controller
9895+
case 0x1b360100: // Red Hat, Inc. QXL paravirtual graphic card
99319896

99329897
// QEMU
9933-
case 0x6270001: // Adomax Technology Co., Ltd QEMU Tablet
9898+
case 0x06270001: // Adomax Technology Co., Ltd QEMU Tablet
99349899
case 0x1d1d1f1f: // CNEX Labs QEMU NVM Express LightNVM Controller
99359900
case 0x80865845: // Intel Corporation QEMU NVM Express Controller
99369901
case 0x1d6b0200: // Linux Foundation Qemu Audio Device
9937-
9902+
return found(brands::QEMU);
9903+
99389904
// vGPUs (mostly NVIDIA)
99399905
case 0x10de0fe7: // GK107GL [GRID K100 vGPU]
99409906
case 0x10de0ff7: // GK107GL [GRID K140Q vGPU]
99419907
case 0x10de118d: // GK104GL [GRID K200 vGPU]
99429908
case 0x10de11b0: // GK104GL [GRID K240Q\K260Q vGPU]
99439909
case 0x1ec6020f: // Vastai Technologies SG100 vGPU
9910+
return true;
99449911

99459912
// VirtualBox
99469913
case 0x80ee0021: // USB Tablet
99479914
case 0x80ee0022: // multitouch tablet
9915+
return found(brands::VBOX);
99489916

9949-
// misc
9950-
case 0x29556e61: // Connectix (VirtualPC) OHCI USB 1.1 controller
9951-
case 0x1ab84000: // Parallels, Inc. Virtual Machine Communication Interface
9952-
debug(
9953-
"PCI_VM_DEVICE_ID: found vendor ID = ",
9954-
"0x", std::setw(4), std::setfill('0'), std::hex, dev.vendor_id,
9955-
" device ID = 0x", std::setw(4), std::setfill('0'), std::hex, dev.device_id
9956-
);
9957-
9958-
return true;
9917+
// Connectix (VirtualPC) OHCI USB 1.1 controller
9918+
case 0x29556e61: return found(brands::VPC);
9919+
9920+
// Parallels, Inc. Virtual Machine Communication Interface
9921+
case 0x1ab84000: return found(brands::PARALLELS);
99599922
}
99609923

99619924
// TODO: EXTRAS TO ADD (64 instead of 32 bits for device_id field)
@@ -10398,7 +10361,6 @@ struct VM {
1039810361
flags.flip(PORT_CONNECTORS);
1039910362
flags.flip(TEMPERATURE);
1040010363
flags.flip(LSHW_QEMU);
10401-
flags.flip(PCI_VM);
1040210364

1040310365
// disable all the settings flags
1040410366
flags.flip(NO_MEMO);
@@ -11329,7 +11291,6 @@ struct VM {
1132911291
case AUDIO: return "AUDIO";
1133011292
case UNKNOWN_MANUFACTURER: return "UNKNOWN_MANUFACTURER";
1133111293
case NSJAIL_PID: return "NSJAIL_PID";
11332-
case PCI_VM: return "PCI_VM";
1133311294
case TPM: return "TPM";
1133411295
case PCI_VM_DEVICE_ID: return "PCI_VM_DEVICE_ID";
1133511296
case QEMU_PASSTHROUGH: return "QEMU_PASSTHROUGH";
@@ -11562,12 +11523,16 @@ struct VM {
1156211523
const std::string inside_vm = "Running inside";
1156311524
#endif
1156411525

11565-
auto make_conclusion = [&](std::string_view category) -> std::string {
11526+
#if (CPP >= 17)
11527+
auto make_conclusion = [&](const std::string_view category) -> std::string {
11528+
#else
11529+
auto make_conclusion = [&](const std::string &category) -> std::string {
11530+
#endif
1156611531
// this basically just fixes the grammatical syntax
1156711532
// by either having "a" or "an" before the VM brand
11568-
// name, like it would look weird if the conclusion
11533+
// name. Like it would look weird if the conclusion
1156911534
// message was "an VirtualBox" or "a Anubis", so this
11570-
// section fixes that issue.
11535+
// lambda fixes that issue.
1157111536
std::string article = "";
1157211537

1157311538
if (
@@ -11892,7 +11857,6 @@ std::pair<VM::enum_flags, VM::core::technique> VM::core::technique_list[] = {
1189211857
std::make_pair(VM::AUDIO, VM::core::technique(25, VM::check_audio)),
1189311858
std::make_pair(VM::UNKNOWN_MANUFACTURER, VM::core::technique(50, VM::unknown_manufacturer)),
1189411859
std::make_pair(VM::NSJAIL_PID, VM::core::technique(75, VM::nsjail_proc_id)),
11895-
std::make_pair(VM::PCI_VM, VM::core::technique(100, VM::lspci)),
1189611860
std::make_pair(VM::TPM, VM::core::technique(50, VM::tpm)),
1189711861
std::make_pair(VM::PCI_VM_DEVICE_ID, VM::core::technique(90, VM::pci_vm_device_id)),
1189811862
std::make_pair(VM::QEMU_PASSTHROUGH, VM::core::technique(90, VM::qemu_passthrough)),

0 commit comments

Comments
 (0)