Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://waleedassar.blogspot.com (@waleedassar)
- // Code to test whether VirtualBox (With VTX/AMD-V turned off) supports hardware breakpoints
- #include "stdafx.h"
- #include <stdio.h>
- #include <windows.h>
- #define CONTEXT_ALL 0x1003F;
- unsigned char probe=0x100;
- int __cdecl Handler(EXCEPTION_RECORD* pRec,void* est,unsigned char* pContext,void* disp)
- {
- if(pRec->ExceptionCode==0xC0000005)
- {
- *(unsigned long*)pContext=CONTEXT_ALL;
- //Set debug registers here
- *(unsigned long*)(pContext+0x4)=(unsigned long)(&probe);
- *(unsigned long*)(pContext+0x18)=0x032101;
- (*(unsigned long*)(pContext+0xB8))+=0x6;
- return ExceptionContinueExecution;
- }
- if(pRec->ExceptionCode==EXCEPTION_SINGLE_STEP)
- {
- MessageBox(0,"Expected behavior","waliedassar",0);
- ExitProcess(0);
- }
- return ExceptionContinueSearch;
- }
- int main()
- {
- __asm
- {
- push offset Handler
- push dword ptr fs:[0x0]
- mov dword ptr fs:[0x0],esp
- xor eax,eax
- mov dword ptr[eax],0x1 ;;triggers an AV
- nop
- nop
- nop
- nop
- nop
- }
- unsigned char x=probe;
- MessageBox(0,"VirtualBox(Intel-VTX/AMD-V Turned off) detected","waliedassar",0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement