Skip to content

Commit 89c39b1

Browse files
authored
Merge pull request #154 from utoshu/gpu_chiptype
add gpu_chiptype detection method
2 parents 2acf36d + c49aa8c commit 89c39b1

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ And if you found this project useful, a star would be appreciated :)
216216
- Eric Parker's discord community
217217
- [ShellCode33](https://github.com/ShellCode33)
218218
- [Georgii Gennadev (D00Movenok)](https://github.com/D00Movenok)
219+
- [utoshu](https://github.com/utoshu)
219220

220221
<br>
221222

src/cli.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ void general() {
514514
checker(VM::WSL_PROC, "WSL string in /proc");
515515
checker(VM::ANYRUN_DRIVER, "ANY.RUN driver");
516516
checker(VM::ANYRUN_DIRECTORY, "ANY.RUN directory");
517+
checker(VM::GPU_CHIPTYPE, "GPU Chiptype");
517518

518519
std::printf("\n");
519520

src/vmaware.hpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*
99
* C++ VM detection library
1010
*
11-
* - Made by: @kernelwernel (https://github.com/kernelwernel)
11+
* - Made by: kernelwernel (https://github.com/kernelwernel)
1212
* - Contributed by:
1313
* - Requiem (https://github.com/NotRequiem)
1414
* - Alex (https://github.com/greenozon)
1515
* - Marek Knápek (https://github.com/MarekKnapek)
1616
* - Vladyslav Miachkov (https://github.com/fameowner99)
1717
* - Alan Tse (https://github.com/alandtse)
1818
* - Georgii Gennadev (https://github.com/D00Movenok)
19+
* - utoshu (https://github.com/utoshu)
1920
* - Repository: https://github.com/kernelwernel/VMAware
2021
* - Docs: https://github.com/kernelwernel/VMAware/docs/documentation.md
2122
* - Full credits: https://github.com/kernelwernel/VMAware#credits-and-contributors-%EF%B8%8F
@@ -439,6 +440,7 @@ struct VM {
439440
WSL_PROC,
440441
ANYRUN_DRIVER,
441442
ANYRUN_DIRECTORY,
443+
GPU_CHIPTYPE,
442444

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

91309132

9133+
/**
9134+
* @brief Use wmic to get the GPU/videocontrollers chip type.
9135+
* @category Windows
9136+
* @author utoshu
9137+
*/
9138+
[[nodiscard]] static bool gpu_chiptype() try {
9139+
#if (!MSVC)
9140+
return false;
9141+
#else
9142+
std::string command = "wmic path win32_videocontroller get videoprocessor";
9143+
std::string result = "";
9144+
9145+
FILE* pipe = _popen(command.c_str(), "r");
9146+
if (!pipe) {
9147+
debug("GPU_CHIPTYPE: failed to run wmic command");
9148+
return false;
9149+
}
9150+
9151+
char buffer[128];
9152+
while (!feof(pipe)) {
9153+
if (fgets(buffer, 128, pipe) != NULL)
9154+
result += buffer;
9155+
}
9156+
_pclose(pipe);
9157+
9158+
std::transform(result.begin(), result.end(), result.begin(), ::tolower);
9159+
9160+
if (util::find(result, "vmware")) {
9161+
return core::add(VMWARE);
9162+
}
9163+
9164+
if (util::find(result, "virtualbox")) {
9165+
return core::add(VBOX);
9166+
}
9167+
9168+
if (util::find(result, "hyper-v")) {
9169+
return core::add(HYPERV);
9170+
}
9171+
9172+
return false;
9173+
#endif
9174+
}
9175+
catch (...) {
9176+
debug("GPU_CHIPTYPE: caught error, returned false");
9177+
return false;
9178+
}
9179+
9180+
91319181
/**
91329182
* @brief Check for any.run driver presence
91339183
* @category Windows
@@ -10708,5 +10758,6 @@ const std::map<VM::enum_flags, VM::core::technique> VM::core::technique_table =
1070810758
{ VM::PODMAN_FILE, { 15, VM::podman_file, true } },
1070910759
{ VM::WSL_PROC, { 30, VM::wsl_proc_subdir, false } },
1071010760
{ VM::ANYRUN_DRIVER, { 65, VM::anyrun_driver, false } },
10711-
{ VM::ANYRUN_DIRECTORY, { 35, VM::anyrun_directory, false } }
10761+
{ VM::ANYRUN_DIRECTORY, { 35, VM::anyrun_directory, false } },
10762+
{ VM::GPU_CHIPTYPE, { 100, VM::gpu_chiptype, false }}
1071210763
};

0 commit comments

Comments
 (0)