vmware is an excellent program that allows you to run multiple operating systems on the same computer concurrently. sometimes it's useful to know if you're running under a real os or in this 'emulated' operating system state, and there is a test you can use to determine this. however, if the test fails (if vmware isn't there), the test will crash your program, but that little problem is easily overcome with a structured exception handler, and i've used a modified version of florent heyworth's excellent <a href="http://"http://g]http://www.powerbasic.com/support/forums/smile.gif[/img]
------------------
the powerbasic crypto archives - my email - protection scheme testing - what's mine is yours...
[this message has been edited by wayne diamond (edited september 05, 2003).]
Code:
#compile exe #register none #include "win32api.inc" type seh dwprevlink as dword dwcurrenthandler as dword dwsafeoffset as dword dwprevesp as dword dwprevebp as dword end type function seh_handler cdecl( ptexcept as exception_record ptr, ptframe as seh ptr, ptcontext as context ptr, byval pdwdispatch as dword) as long @ptcontext.regeip = @ptcontext.regeip + 13 '// set eip to a known safe offset end function function vmwaredetect() as long #register none function = 0 local lebp as long, lesp as long, tseh as seh '// setup the seh. ! push dword fs:[0] tseh.dwcurrenthandler = codeptr(seh_handler) tseh.dwsafeoffset = codeptr(except) ! lea esi, tseh ! mov fs:[0], esi ! mov lesp, esp ! mov lebp, ebp tseh.dwprevesp = lesp tseh.dwprevebp = lebp '// call the vmware backdoor to see if its there. '// if its not there, our seh will save us from crashing. ! mov ecx, &h0a ! mov eax, "vmxh" ! mov dx, "vx" ! in eax, dx ! cmp ebx, "vmxh" ! je vmwarefound ! jmp except vmwarefound: function = 1 except: ! pop dword fs:[0] end function function pbmain() as long if vmwaredetect = 1 then '// vmware detected else '// not detected end if end function
------------------
the powerbasic crypto archives - my email - protection scheme testing - what's mine is yours...
[this message has been edited by wayne diamond (edited september 05, 2003).]
Comment