Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect (inside) if my Qt app is running on a virtual machine

How to detect (inside) if my Qt app is running on a virtual machine

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Can you show the code matching your query ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    LematL 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Can you show the code matching your query ?

      LematL Offline
      LematL Offline
      Lemat
      wrote on last edited by Lemat
      #3

      @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.

      Time to elevate.

      1 Reply Last reply
      0
      • LematL Lemat

        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.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #4

        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-Virtual

        for an example for VMWare detection


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        LematL 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          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-Virtual

          for an example for VMWare detection

          LematL Offline
          LematL Offline
          Lemat
          wrote on last edited by
          #5

          @J-Hilk thanks for you reply. okay i understand and i will continue searching.

          Time to elevate.

          KroMignonK 1 Reply Last reply
          0
          • LematL Lemat

            @J-Hilk thanks for you reply. okay i understand and i will continue searching.

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #6

            @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
            

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            LematL 2 Replies Last reply
            2
            • KroMignonK KroMignon

              @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
              
              LematL Offline
              LematL Offline
              Lemat
              wrote on last edited by
              #7

              @KroMignon
              interesting!!!, using wmic. i can detect HyperV also with this command?

              Time to elevate.

              KroMignonK 1 Reply Last reply
              0
              • LematL Lemat

                @KroMignon
                interesting!!!, using wmic. i can detect HyperV also with this command?

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by
                #8

                @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

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                LematL 1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @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

                  LematL Offline
                  LematL Offline
                  Lemat
                  wrote on last edited by Lemat
                  #9

                  @KroMignon thanks, i will run it through QProcess.

                  Time to elevate.

                  KroMignonK 1 Reply Last reply
                  0
                  • LematL Lemat

                    @KroMignon thanks, i will run it through QProcess.

                    KroMignonK Offline
                    KroMignonK Offline
                    KroMignon
                    wrote on last edited by KroMignon
                    #10

                    @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;
                    }
                    

                    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                    LematL 1 Reply Last reply
                    0
                    • KroMignonK KroMignon

                      @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;
                      }
                      
                      LematL Offline
                      LematL Offline
                      Lemat
                      wrote on last edited by Lemat
                      #11

                      @KroMignon , Yes. thanks a lot for you help.

                      Time to elevate.

                      1 Reply Last reply
                      0
                      • KroMignonK KroMignon

                        @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
                        
                        LematL Offline
                        LematL Offline
                        Lemat
                        wrote on last edited by
                        #12

                        @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
                        

                        Time to elevate.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved