Skip to content

Commit

Permalink
Merge pull request #154 from utoshu/gpu_chiptype
Browse files Browse the repository at this point in the history
add gpu_chiptype detection method
  • Loading branch information
kernelwernel authored Oct 13, 2024
2 parents 2acf36d + c49aa8c commit 89c39b1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ And if you found this project useful, a star would be appreciated :)
- Eric Parker's discord community
- [ShellCode33](https://github.com/ShellCode33)
- [Georgii Gennadev (D00Movenok)](https://github.com/D00Movenok)
- [utoshu](https://github.com/utoshu)

<br>

Expand Down
1 change: 1 addition & 0 deletions src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ void general() {
checker(VM::WSL_PROC, "WSL string in /proc");
checker(VM::ANYRUN_DRIVER, "ANY.RUN driver");
checker(VM::ANYRUN_DIRECTORY, "ANY.RUN directory");
checker(VM::GPU_CHIPTYPE, "GPU Chiptype");

std::printf("\n");

Expand Down
55 changes: 53 additions & 2 deletions src/vmaware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
*
* C++ VM detection library
*
* - Made by: @kernelwernel (https://github.com/kernelwernel)
* - Made by: kernelwernel (https://github.com/kernelwernel)
* - Contributed by:
* - Requiem (https://github.com/NotRequiem)
* - Alex (https://github.com/greenozon)
* - Marek Knápek (https://github.com/MarekKnapek)
* - Vladyslav Miachkov (https://github.com/fameowner99)
* - Alan Tse (https://github.com/alandtse)
* - Georgii Gennadev (https://github.com/D00Movenok)
* - utoshu (https://github.com/utoshu)
* - Repository: https://github.com/kernelwernel/VMAware
* - Docs: https://github.com/kernelwernel/VMAware/docs/documentation.md
* - Full credits: https://github.com/kernelwernel/VMAware#credits-and-contributors-%EF%B8%8F
Expand Down Expand Up @@ -439,6 +440,7 @@ struct VM {
WSL_PROC,
ANYRUN_DRIVER,
ANYRUN_DIRECTORY,
GPU_CHIPTYPE,

// start of settings technique flags (THE ORDERING IS VERY SPECIFIC HERE AND MIGHT BREAK SOMETHING IF RE-ORDERED)
NO_MEMO,
Expand Down Expand Up @@ -9128,6 +9130,54 @@ struct VM {
}


/**
* @brief Use wmic to get the GPU/videocontrollers chip type.
* @category Windows
* @author utoshu
*/
[[nodiscard]] static bool gpu_chiptype() try {
#if (!MSVC)
return false;
#else
std::string command = "wmic path win32_videocontroller get videoprocessor";
std::string result = "";

FILE* pipe = _popen(command.c_str(), "r");
if (!pipe) {
debug("GPU_CHIPTYPE: failed to run wmic command");
return false;
}

char buffer[128];
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
_pclose(pipe);

std::transform(result.begin(), result.end(), result.begin(), ::tolower);

if (util::find(result, "vmware")) {
return core::add(VMWARE);
}

if (util::find(result, "virtualbox")) {
return core::add(VBOX);
}

if (util::find(result, "hyper-v")) {
return core::add(HYPERV);
}

return false;
#endif
}
catch (...) {
debug("GPU_CHIPTYPE: caught error, returned false");
return false;
}


/**
* @brief Check for any.run driver presence
* @category Windows
Expand Down Expand Up @@ -10708,5 +10758,6 @@ const std::map<VM::enum_flags, VM::core::technique> VM::core::technique_table =
{ VM::PODMAN_FILE, { 15, VM::podman_file, true } },
{ VM::WSL_PROC, { 30, VM::wsl_proc_subdir, false } },
{ VM::ANYRUN_DRIVER, { 65, VM::anyrun_driver, false } },
{ VM::ANYRUN_DIRECTORY, { 35, VM::anyrun_directory, false } }
{ VM::ANYRUN_DIRECTORY, { 35, VM::anyrun_directory, false } },
{ VM::GPU_CHIPTYPE, { 100, VM::gpu_chiptype, false }}
};

0 comments on commit 89c39b1

Please sign in to comment.