Page 1 of 1
How to detect if a PB program is running inside a VM
Posted: Sat Jan 03, 2015 12:22 am
by glomph
Happy new year to all.
It is possible to detect if a PB program is running inside a Virtual Machine.
Saw same stuff here:
http://www.codeproject.com/Articles/982 ... -a-Virtual
Unfortunately I'm not able to translate that code into PB.
Maybe someone has tried something like this and could help.
Glomph
Re: How to detect if a PB program is running inside a VM
Posted: Sat Jan 03, 2015 5:05 am
by idle
you should be able to use cpuid info with the flag #hypervisor but you may still need to do additional checks.
see here
http://www.purebasic.fr/english/viewtop ... 12&t=61060
and use IsCPU(#hypervisor)
Re: How to detect if a PB program is running inside a VM
Posted: Sat Jan 03, 2015 5:18 am
by glomph
Thank you very much Idle
That's a start!
Glomph
Re: How to detect if a PB program is running inside a VM
Posted: Sat Jan 03, 2015 5:28 am
by glomph
....and even more fine:
It works on MAC too.

Re: How to detect if a PB program is running inside a VM
Posted: Sun Jan 04, 2015 2:27 am
by jassing
I worked on a project that had to refuse to run on a VM. we found using the ID of the NIC a good way; ultimately we used a NIC database and a CPU check as backup/secondary -- sometimes the CPU check was passed to the host OS, so you didn't get the right value...
Re: How to detect if a PB program is running inside a VM
Posted: Sun Jan 04, 2015 3:01 pm
by glomph
@ jassing,
thanks you for your advice.
Surely you point the right direction.
Never before I had to look a NIC,
so I nead a little more help,
to get through.
Have all a nice day
Glomph
Re: How to detect if a PB program is running inside a VM
Posted: Tue Jan 06, 2015 2:19 pm
by jassing
Getting the NIC information should be trivial -- and I'm sure there are code samples/examples on these forums.
Now the list of NIC info... that's a different story... It wasn't an exhaustive list, but we did sample all the "free" VM's, VMWare, Microsofts, and a few other that had trials...
I no longer work on that project, but I will see if I have the list in my personal archives....
We had to do multiple checks as each VM seemed to offer it's own unique issues that would fail some "generic" test...