Solved How to detect (inside) if my Qt app is running on a virtual machine
-
I developed a software on Qt Creator with c++ and i would want to write a code in c++ to detect if it is executed on virtual machine for security reason.
-
Hi,
Can you show the code matching your query ?
-
@SGaist
i don't have a code yet, i am searching, that can be a function who check if my app is executing on virtual machine. -
hi @Lemat and welcome
that is not an easy task, and as far as I know, you would have to code that specific for all the different VM's
you can take a look here
https://www.codeproject.com/Articles/9823/Detect-if-your-program-is-running-inside-a-Virtualfor an example for VMWare detection
-
@J-Hilk thanks for you reply. okay i understand and i will continue searching.
-
@Lemat If you virtual machine is a Windows system, you can read the manufacturer and model and look if it contains VMware or VirtualBox:
wmic computersystem manufacturer,name
-
@KroMignon
interesting!!!, using wmic. i can detect HyperV also with this command? -
@Lemat said in How to detect (inside) if my Qt app is running on a virtual machine:
using wmic. i can detect HyperV also with this command?
I don't have access to HyperV... but just try it out, open a cmd.exe and look at the result of
wmic computersystem manufacturer,name
-
@KroMignon thanks, i will run it through QProcess.
-
@Lemat said in How to detect (inside) if my Qt app is running on a virtual machine:
thanks, i will run it through QProcess.
Yes something like this should do the job:QProcess wmic; wmic.setProcessChannelMode(QProcess::MergedChannels); wmic.start("wmic", QStringList() << "computersystem" << "get" << "manufacturer,name"); if(wmic.waitForFinished(10000)) { QString text(wmic.readAll()); bool isVM = text.contains("VMware") || text.contains("VirtualBox") || text.contains("Virtual Machine"); qDebug() << text; }
-
@KroMignon , Yes. thanks a lot for you help.
-
@KroMignon said in How to detect (inside) if my Qt app is running on a virtual machine:
@Lemat If you virtual machine is a Windows system, you can read the manufacturer and model and look if it contains VMware or VirtualBox:
wmic computersystem get manufacturer,name