2

I just want to known how to get BIO information in C++. I tried following option but each one has its drawback.

  1. From Registry: But I found some system where HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS is missing may be it is virtual machine.
  2. Using WMI: But It is not necessary that WMI will run on all the systems, because in certain cases either the service is disabled or the WMI object is missing!!

I need one permanent solution that gives me BIO information in c++.

Ajay
  • 18,086
  • 12
  • 59
  • 105
  • 1
    What information are you trying to read from the BIOS? There is very little that you actually need to go all the way to the BIOS to read that you can't get from somewhere else. – Salgar Jul 09 '13 at 09:56
  • On a virtual machine, almost anything in the BIOS would be "virtual" information (and typically kept to the minimum necessary to make the system function correctly). What exactly are you looking to do? – Mats Petersson Jul 09 '13 at 09:59
  • @Salgar i am looking for "SystemProductName" from BIO. –  Jul 09 '13 at 10:00
  • @MatsPetersson i just want to know about system is virtual or not!! –  Jul 09 '13 at 10:01
  • @Sankaganak Is this generic for ALL VM's, or for a particular manufacturer? – Mats Petersson Jul 09 '13 at 10:10
  • @MatsPetersson for ALL VM's from hypervisor to vmware.. –  Jul 09 '13 at 10:12
  • "My last question is still unresolved!" - because this is up to the programmers you describe as "this guys are software gient they doesnt bother about...". We cannot solve the problems with wrong COM interface created by someone else. – SChepurin Jul 09 '13 at 10:19

2 Answers2

1

Trying to detect if you are in a virtual OS is done in various ways and depends on the virtualization software being used.

There are many different questions about this already on stackoverflow.

In no particular order, here are some articles, they cover a variety of the different virtualization pieces used:

Detect virtualized OS from an application?

detect if application running on virtual box

64-bit windows VMware detection

How to identify that you're running under a VM?

http://www.codeproject.com/Articles/9823/Detect-if-your-program-is-running-inside-a-Virtual

Community
  • 1
  • 1
Salgar
  • 7,687
  • 1
  • 25
  • 39
1

Whilst Salgar beat me to it, one of the more "safe" methods is to use the CPUID instruction, which generally works on modern VM's. I know that KVM, Microsoft and Xen uses a CPUID leaf around 0x40000000 that gives back "You are in a virtual machine". Not 100% sure if VMWare also supports the same one - on a "real" machine, these are reserved and not used.

Here's a page that discusses several options besides CPUID: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/detecting-x86-virtual-machines.html and there are several links for further reading.

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227