Advertisement
waliedassar

VirtualBox HardDiskInfo Trick

Nov 5th, 2012
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.80 KB | None | 0 0
  1. //http://waleedassar.blogspot.com
  2. //http://www.twitter.com/waleedassar
  3. #include "stdafx.h"
  4. #include "windows.h"
  5. #include "stdio.h"
  6. #include "winioctl.h"
  7.  
  8. #define IOCTL_STORAGE_QUERY_PROPERTY \
  9.   CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
  10.  
  11. void AllToUpper(unsigned char* str,unsigned long len)
  12. {
  13.         for(unsigned long c=0;c<len;c++)
  14.         {
  15.                 if(str[c]>='a' && str[c]<='z')
  16.                 {
  17.                         str[c]-=32;
  18.                 }
  19.         }
  20. }
  21. unsigned char* ScanDataForString(unsigned char* data,unsigned long data_length,unsigned char* string2)
  22. {
  23.         unsigned long string_length=(unsigned long)strlen((char*)string2);
  24.         for(unsigned long i=0;i<=(data_length-string_length);i++)
  25.         {
  26.                 if(strncmp((char*)(&data[i]),(char*)string2,string_length)==0) return &data[i];
  27.         }
  28.         return 0;
  29. }
  30. void main()
  31. {
  32.     HANDLE hF=0;
  33.     unsigned char name[0x100];
  34.     for(unsigned long i=0;i<0xA;i++)
  35.     {
  36.         unsigned char x[0x2]={0};
  37.         memset((void*)name,0,0x100);
  38.         strcpy((char*)name,"\\\\.\\PhysicalDrive");
  39.         x[0]=i+48;
  40.         strcat((char*)name,(char*)(&x[0]));
  41.         hF=CreateFile((char*)name,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
  42.         if(hF!=INVALID_HANDLE_VALUE)
  43.         {
  44.             unsigned char inbuf[0xC]={0};
  45.             unsigned char* outbuf=(unsigned char*)LocalAlloc(LMEM_ZEROINIT,0x3000);
  46.             unsigned long ret=0;
  47.             if(DeviceIoControl(hF,IOCTL_STORAGE_QUERY_PROPERTY,&inbuf[0],0xC,outbuf,0x3000,&ret,0))
  48.             {
  49.                 AllToUpper(outbuf,0x3000);
  50.                 if(ScanDataForString(outbuf,0x3000,(unsigned char*)"VBOX") ||
  51.                     ScanDataForString(outbuf,0x3000,(unsigned char*)"VIRTUALBOX") )
  52.                 {
  53.                     MessageBox(0,"VirtualBox detected!","waliedassar",0);
  54.                     ExitProcess(0);
  55.                 }
  56.             }
  57.             LocalFree(outbuf);
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement