2

I went thrrough some links in stackoverflow. But code given here doesnt work for virtual box. I have also tried redpill but thats not working too. my application will run on both linux and windows(preferably).
Please let me know if anyone has any solution.

Edit: Preet Sangha's link not working as well

Community
  • 1
  • 1
ashmish2
  • 2,885
  • 8
  • 40
  • 54
  • 1
    No. The general purpose of virtualization is to run multiple OSes simultaneously on the same hardware by being "close enough" - not necessarily indistinguishable. – nobody Sep 21 '11 at 16:00

2 Answers2

2

VBox 1.0 uses a different method. Check http://spth.virii.lu/eof2/articles/WarGame/vboxdetect.html

Yogurt
  • 21
  • 2
1

from http://www.gedzac.com/rrlf.dr.eof.eZine/articles/WarGame/vboxdetect.html

Check if the pseudo-device \\.\VBoxMiniRdrDN exists in the system (you need CreateFile())

#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    if(CreateFile("\\\\.\\VBoxMiniRdrDN",GENERIC_READ,FILE_SHARE_READ,
        NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL) != INVALID_HANDLE_VALUE)
    {
        MessageBox(NULL,"VBox detected!","Warning",MB_OK|MB_ICONWARNING);
    }

    else
    {
        MessageBox(NULL,"Not inside VBox","Info",MB_OK|MB_ICONINFORMATION);
    }
}
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216