Skip to content

Commit

Permalink
hyperv_fucker prototype 7
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwernel committed Aug 9, 2024
1 parent 880a6dd commit d6a175b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/vmaware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,11 +1627,11 @@ struct VM {
core_debug("HYPERV_FUCKER: eax = ", eax);

if (eax == 12) {
const char* p = SMBIOS_string();
std::string p = SMBIOS_string();

core_debug("HYPERV_FUCKER: SMBIOS string = ", p);

if (std::strcmp(p, "VIRTUAL MACHINE") == 0) {
if (p == "VIRTUAL MACHINE") {
return add(false);
}

Expand Down Expand Up @@ -1954,10 +1954,11 @@ struct VM {
}


[[nodiscard]] static char* SMBIOS_string() {
[[nodiscard]] static std::string SMBIOS_string() {
HKEY hk = 0;
int ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\mssmbios\\data", 0, KEY_ALL_ACCESS, &hk);
if (ret != ERROR_SUCCESS) {
debug("SMBIOS_string(): ret = error");
return nullptr;
}

Expand All @@ -1968,18 +1969,21 @@ struct VM {

if (ret != ERROR_SUCCESS) {
RegCloseKey(hk);
debug("SMBIOS_string(): ret = error 2");
return nullptr;
}

if (length == 0) {
RegCloseKey(hk);
debug("SMBIOS_string(): length = 0");
return nullptr;
}

char* p = static_cast<char*>(LocalAlloc(LMEM_ZEROINIT, length));

if (p == nullptr) {
RegCloseKey(hk);
debug("SMBIOS_string(): p = nullptr");
return nullptr;
}

Expand All @@ -1988,11 +1992,13 @@ struct VM {
if (ret != ERROR_SUCCESS) {
LocalFree(p);
RegCloseKey(hk);
debug("SMBIOS_string(): ret = error 3");
return nullptr;
}

RegCloseKey(hk);
return p;
std::string tmp(p);
return tmp;
}

[[nodiscard]] static bool motherboard_string(const wchar_t* vm_string) {
Expand Down Expand Up @@ -4519,11 +4525,16 @@ struct VM {
#else
const char* p = util::SMBIOS_string();


if (p == nullptr) {
debug("MSSMBIOS: nullptr detected, returned false");
return false;
}

#ifdef __VMAWARE_DEBUG__
debug("VBOX_MSSMBIOS: string = ", p);
#endif

bool is_vm = false;

const bool x1 = (std::strcmp(p, "INNOTEK GMBH") == 0);
Expand All @@ -4534,13 +4545,6 @@ struct VM {

if (x1 || x2 || x3 || x4 || x5) {
is_vm = true;
#ifdef __VMAWARE_DEBUG__
if (x1) { debug("VBOX_MSSMBIOS: x1 = ", p); }
if (x2) { debug("VBOX_MSSMBIOS: x2 = ", p); }
if (x3) { debug("VBOX_MSSMBIOS: x3 = ", p); }
if (x4) { debug("VBOX_MSSMBIOS: x4 = ", p); }
if (x5) { debug("VBOX_MSSMBIOS: x5 = ", p); }
#endif
}

if (is_vm) {
Expand Down

0 comments on commit d6a175b

Please sign in to comment.