Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Apr : How to detect VirtualPC on the MAC and PC
| Subject: | How to detect VirtualPC on the MAC and PC |
| Posted by: | "Darryl Strickland" (dstrickla..@carolina.rr.com) |
| Date: | Mon, 11 Apr 2005 16:57:40 |
I have a client that's trying to run my application in the Mac's version of
VirtualPC and the security system I have integrated is failing. Therefore,
I would like to check when the application starts to see if it is running in
VirtualPC. I have googled over and over again and found some code below but
it gets an error when runing in the IDE on XP. So I do not know whether it
works or not.
Thanks
Darryl
function running_inside_vpc: boolean; assembler;
asm
push ebp
mov ecx, offset @@exception_handler
mov ebp, esp
push ebx
push ecx
push dword ptr fs:[0]
mov dword ptr fs:[0], esp
mov ebx, 0 // flag
mov eax, 1 // VPC function number
// call VPC
db 00Fh, 03Fh, 007h, 00Bh <=============== Causes a AV on this
line.
mov eax, dword ptr ss:[esp]
mov dword ptr fs:[0], eax
add esp, 8
test ebx, ebx
setz al
lea esp, dword ptr ss:[ebp-4]
mov ebx, dword ptr ss:[esp]
mov ebp, dword ptr ss:[esp+4]
add esp, 8
jmp @@ret
@@exception_handler:
mov ecx, [esp+0Ch]
mov dword ptr [ecx+0A4h], -1 // EBX = -1 -> not running, ebx = 0 ->
running
add dword ptr [ecx+0B8h], 4 // -> skip past the detection code
xor eax, eax // exception is handled
ret
@@ret:
end;