VMware Communities
yemre3330
Contributor
Contributor
Jump to solution

Inside virtual machine determine whether it is ESX or Workstation

Hi,

Is it programmatically possible inside of a virtual machine whether it is running from WMWare Workstation or ESX?

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

I'm not really familiar with Visual Studio, and I understand that only the 32-bit Windows C compiler supports inline assembly.  If you're using the 64-bit Windows C compiler, you may have to resort to a stand-alone assembler.  The basic idea is:

load register %eax with 0x564D5868

load register %ecx with 10

load register %edx with 0x5658

execute the instruction "in %dx, %eax"

Then look at register %ecx.  A value of 2 indicates ESX, and a value of 4 indicates Workstation.

View solution in original post

0 Kudos
10 Replies
weinstein5
Immortal
Immortal
Jump to solution

Welcome to the Community - The only possible would be to look at the version of VMware tools installed - as Workstation and ESXi install different versions. WHich of course means if VMware tools is not installed it will not help you at all.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
admin
Immortal
Immortal
Jump to solution

Assuming that the isolation controls allow the version to be queried, the attached C program ought to do it.  This can be compiled with gcc.  Note that outside of a VMware VM, this program will crash with a segmentation fault.

yemre3330
Contributor
Contributor
Jump to solution

Thank you very much JMATTSON,

All our virtual machines are Windows and we are using visual studio 2010 in our project. Could you please provide code for this environement that we can compile and run in visual studio?

0 Kudos
admin
Immortal
Immortal
Jump to solution

I'm not really familiar with Visual Studio, and I understand that only the 32-bit Windows C compiler supports inline assembly.  If you're using the 64-bit Windows C compiler, you may have to resort to a stand-alone assembler.  The basic idea is:

load register %eax with 0x564D5868

load register %ecx with 10

load register %edx with 0x5658

execute the instruction "in %dx, %eax"

Then look at register %ecx.  A value of 2 indicates ESX, and a value of 4 indicates Workstation.

0 Kudos
simonre
Hot Shot
Hot Shot
Jump to solution

jmattson -- thanks for the platform.c  program.  This is just what I have been looking for.  I used the mingw complier:

http://www.mingw.org/Welcome_to_MinGW_org

and that was fine.

Can I ask -- in an earlier post you say: "Assuming that the isolation controls allow the version to be queried..."?  Where could this be allowed or disallowed?

0 Kudos
admin
Immortal
Immortal
Jump to solution

The following option restricts the backdoor port to CPL <= IOPL, so the query would typically fail in user mode, though it would work in supervisory mode:

monitor_control.restrict_backdoor = TRUE

Moreover, I believe that the following option can be used to disable this specific query:

isolation.tools.getVersion.disable = TRUE

0 Kudos
simonre
Hot Shot
Hot Shot
Jump to solution

Thanks for the info.

A more generic question -- is it always possible to prevent a guest OS from finding out if it is running inside a VM?  Or is there always some way for a guest OS to know if it is running inside a VM whatever the VM config settings.

0 Kudos
admin
Immortal
Immortal
Jump to solution

There's always some way to know, particularly from supervisory mode.

0 Kudos
simonre
Hot Shot
Hot Shot
Jump to solution

Thanks again for the info.

0 Kudos
yemre3330
Contributor
Contributor
Jump to solution

Hi Again,

I have a new problem. Is there a way to read uuid.location information inside virtual machine?

Thanks in advance

0 Kudos