Advertisement
waliedassar

Detect VirtualBox (WNetGetProviderName)

Sep 11th, 2012
2,553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. //http://waleedassar.blogspot.com/   (@waleedassar)
  2. //Using the "WNetGetProviderName" function to detect VirtualBox.
  3. //Thanks @deesse_k for the idea
  4.  
  5. #include "stdafx.h"
  6. #include "windows.h"
  7. #include "Winnetwk.h"
  8.  
  9. #pragma comment(lib,"MPR")
  10.  
  11. int main(void)
  12. {
  13.        //method 9
  14.        unsigned long pnsize=0x1000;
  15.        char* provider=(char*)LocalAlloc(LMEM_ZEROINIT,pnsize);
  16.        int retv=WNetGetProviderName(WNNC_NET_RDR2SAMPLE,provider,&pnsize);
  17.        if(retv==NO_ERROR)
  18.        {
  19.                 if(lstrcmpi(provider,"VirtualBox Shared Folders")==0)
  20.                 {
  21.                         MessageBox(0,"VirtualBox detected","waliedassar",0);
  22.                         ExitProcess(9);
  23.                 }
  24.        }
  25.        return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement