问题
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
回答1:
VBox 1.0 uses a different method. Check http://spth.virii.lu/eof2/articles/WarGame/vboxdetect.html
回答2:
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);
}
}
来源:https://stackoverflow.com/questions/7499985/detect-if-application-running-on-virtual-box