Skip to content

Commit

Permalink
Merge pull request #16 from NotRequiem/main
Browse files Browse the repository at this point in the history
Fixed every MSVC warning
  • Loading branch information
kernelwernel authored Dec 21, 2023
2 parents ff09967 + 3ec43c4 commit 8cd212c
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions src/vmaware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* A C++ VM detection library
*
* - Made by: @kernelwernel (https://github.com/kernelwernel)
* - Contributed by @Requirem (https://github.com/NotRequiem)
* - Contributed by @Requiem (https://github.com/NotRequiem)
* - Repository: https://github.com/kernelwernel/VMAware
* - Docs: https://github.com/kernelwernel/VMAware/docs/documentation.md
* - Full credits: https://github.com/kernelwernel/VMAware#credits
Expand Down Expand Up @@ -2984,22 +2984,34 @@ struct VM {
iBuffSize = sizeof(szBuff);
nRes = RegQueryValueEx(hOpen, "ProductId", NULL, NULL, (unsigned char*)szBuff, reinterpret_cast<LPDWORD>(&iBuffSize));
if (nRes == ERROR_SUCCESS) {
if (strcmp(szBuff, "55274-640-2673064-23950") == 0) { // joebox
free(szBuff);
return add(JOEBOX);
} else if (strcmp(szBuff, "76487-644-3177037-23510") == 0) {
free(szBuff);
return add(CWSANDBOX); // CW Sandbox
} else if (strcmp(szBuff, "76487-337-8429955-22614") == 0) { // anubis
free(szBuff);
return add(ANUBIS);
} else {
free(szBuff);
// Check if szBuff is not NULL before using strcmp
if (szBuff != NULL) {
if (strcmp(szBuff, "55274-640-2673064-23950") == 0) { // joebox
free(szBuff);
return add(JOEBOX);
}
else if (strcmp(szBuff, "76487-644-3177037-23510") == 0) {
free(szBuff);
return add(CWSANDBOX); // CW Sandbox
}
else if (strcmp(szBuff, "76487-337-8429955-22614") == 0) { // anubis
free(szBuff);
return add(ANUBIS);
}
else {
free(szBuff);
return false;
}
}
else {
// Handle the case when szBuff is NULL
RegCloseKey(hOpen);
return false;
}
}
RegCloseKey(hOpen);
}
// Set szBuff to NULL after freeing to avoid double free issues
free(szBuff);
return false;
#endif
Expand Down Expand Up @@ -3340,13 +3352,13 @@ struct VM {

hDll = GetModuleHandle(dll);

if (hDll != NULL) {
if (strcmp(dll, "sbiedll.dll") == 0) { return add(SANDBOXIE); }
if (strcmp(dll, "pstorec.dll") == 0) { return add(SUNBELT); }
if (strcmp(dll, "vmcheck.dll") == 0) { return add(VPC); }
if (strcmp(dll, "cmdvrt64.dll") == 0) { return add(COMODO); }
if (strcmp(dll, "cmdvrt32.dll") == 0) { return add(COMODO); }
return true;
if (hDll != NULL && dll != NULL) {
if (strcmp(dll, "sbiedll.dll") == 0) { return add(SANDBOXIE); }
if (strcmp(dll, "pstorec.dll") == 0) { return add(SUNBELT); }
if (strcmp(dll, "vmcheck.dll") == 0) { return add(VPC); }
if (strcmp(dll, "cmdvrt64.dll") == 0) { return add(COMODO); }
if (strcmp(dll, "cmdvrt32.dll") == 0) { return add(COMODO); }
return true;
}
}

Expand Down Expand Up @@ -3554,6 +3566,7 @@ struct VM {
}

VARIANT vtProp;
VariantInit(&vtProp);
hr = pclsObj->Get(L"Manufacturer", 0, &vtProp, 0, 0);

if (SUCCEEDED(hr)) {
Expand Down Expand Up @@ -3902,4 +3915,4 @@ const std::map<VM::u64, VM::technique> VM::table = {
// __TABLE_LABEL, add your technique above
// { VM::YOUR_FUNCTION, { POINTS, FUNCTION POINTER }}
// ^ template
};
};

0 comments on commit 8cd212c

Please sign in to comment.