Re: vmWare, virtualPC, dedect , ... IN/OUT

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Mauricio Lange (mlange_at_cett.conae.gov.ar)
Date: 07/27/04


Date: Tue, 27 Jul 2004 14:48:23 -0300

Yo can try using a try..except construct. That should catch any exception,
but I am not absolutely sure.

Regards,
Mauricio

"Mario Semo" <mario_semo@Xhotmail.com> wrote in message
news:uSdDH2$cEHA.3560@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> yes, it appears so. but how can i catch the privileged instruction
exception
> in Win* ?
> I compiled the sample with VC++ and when it runs in vmWare, i get the
output
> "running inside vmWare",
> when i run it outside vmWare (in W2K or XP) i get an "unexpected software
> exception - privileged instruction" popup and the program terminates.
>
> this LINUX method with signal(SIGSEGV,...) does not work on W2K.
>
> --
> mit freundlichen Grüßen/best regards
> mario semo
>
> "Mauricio Lange" <mlange@cett.conae.gov.ar> schrieb im Newsbeitrag
> news:u5KJv69cEHA.2812@tk2msftngp13.phx.gbl...
> > AFAIK, Linux don't allow privileged instructions in user mode, either.
And
> > if you look at the code, there is a fault handler that catches the
> > protection fault when the program is NOT running on VMware (and that
> handler
> > tells you that you are not in VMware). Maybe the VMware emulator
> unprotects
> > that I/O address (via the IO permission bitmap in the TSS register), so,
> an
> > "in" instruction wont cause an exception.
> >
> > Mauricio
> >
> > "Mario Semo" <mario_semo@Xhotmail.com> wrote in message
> > news:ORXhAS9cEHA.2452@TK2MSFTNGP10.phx.gbl...
> > > Hello
> > >
> > > how can i dedect, if my program runs in a vmWare session or in
VirtualPC
> > > session or alike?
> > > From a C/C++ program?
> > >
> > > We found a vmWare chk program, but this was written for Linux, and it
> uses
> > > IN / OUT commands (--> privileged instructions!)
> > > How can i use IN/OUT from my W2K C program?
> > >
> > > /*
> > > * 4tphi-vmchk.c
> > > * Detects if you are in a VMWare virtual machine.
> > > *
> > > * Written by Andrew Hintz <http://guh.nu>
> > > * and AAron Walters
> > > * Fortify Research Laboratories <http://4tphi.net>
> > > *
> > > * "Oft at the hives of his tame bees
> > > * They would their sugary thirst appease."
> > > *
> > > * This program is based on info and code from:
> > > * http://chitchat.tripod.co.jp/vmware/
> > > * by chitchat@lycos.jp
> > > *
> > > * Notes:
> > > * The program can be run as a normal user.
> > > * We tested the program only in x86 Linux.
> > > * The m4dn3ss lives on!
> > > */
> > >
> > > #include <stdio.h>
> > > #include <signal.h>
> > > #include <stdlib.h>
> > >
> > > #if __INTSIZE == 2 /* 16 bit environment */
> > > typedef unsigned int uint16;
> > > typedef unsigned long uint32;
> > > #else /* 32 bit environment */
> > > typedef unsigned short uint16;
> > > typedef unsigned int uint32;
> > > #endif /* __INTSIZE */
> > >
> > > void _cdecl segfault(int dummy){
> > > printf("Not running inside VMware.\n");
> > > exit(1);
> > > }
> > >
> > > int main(){
> > > uint32 verMajor, verMinor, magic, dout;
> > >
> > > signal(SIGSEGV, segfault);
> > >
> > > _asm {
> > > mov eax,0x564D5868 /* magic number */
> > > mov ebx,0x3c6cf712 /* random number */
> > > mov ecx,0x0000000A /* specifies command */
> > > mov edx,0x5658 /* VMware I/O port */
> > >
> > > in eax,dx
> > >
> > > mov verMajor,eax
> > > mov magic,ebx
> > > mov verMinor,ecx
> > > mov dout,edx
> > > }
> > >
> > > if (magic == 0x564D5868) {
> > > printf("Running inside VMware. ");
> > > printf("(Version %lu,%lu)\n", verMajor, verMinor);
> > > /* I'm not really sure what the versions mean. */
> > > }
> > >
> > > return 0;
> > >
> > > }/* end main */
> > >
> > > /* end of file */
> > >
> > >
> > >
> > > --
> > > mit freundlichen Grüßen/best regards
> > > mario semo
> > >
> > >
> >
> >
>
>
>



Relevant Pages

  • Re: Probelm with Process and shortcut
    ... works with Process method. ... just first time is slow in ... my case because of the exception throwing. ... > |> Regards. ...
    (microsoft.public.dotnet.framework)
  • Re: Video hangs while its running under Windows CE
    ... S. Pradeep Kumar ... exception when you are running a DEBUG OS with that debugger. ... Exception in device.exe, gwes.exe & filesys.exe. ...
    (microsoft.public.windowsce.embedded)
  • Re: Starting default mail program
    ... mapi32.dll is usually installed with Outlook with MS Office or Microsoft ... Exchange tools. ... Catch ex As Exception ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Get Function & Class Name
    ... compiler can't the macro definition which I understand is because I am ... >>location in my code as to where an exception occurs and for that reason I ... > to illustrate the detailed concerns and code context of your need? ... > Best regards, ...
    (microsoft.public.vc.mfc)
  • Re: Simple webmethod call
    ... if client derive public WS classed from Microsoft.Web.Services2.WebServicesClientProtocol I must throw exception)? ... with best regards ... I have a web app that offer some webmethods. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)