Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://waleedassar.blogspot.com - (@waleedassar)
- //Code to show how to use the "PAGE_GUARD" anti-dumping trick.
- #include "stdafx.h"
- #include "windows.h"
- #pragma data_seg("walied4")
- int x=1;
- #pragma data_seg()
- int __stdcall watch()
- {
- while(1)
- {
- MEMORY_BASIC_INFORMATION MBI={0};
- VirtualQuery(&x,&MBI,sizeof(MBI));
- if(!((MBI.Protect)&PAGE_GUARD)) ExitProcess(0);
- }
- }
- int main(int argc, char* argv[])
- {
- unsigned long fake_base=(unsigned long)(&x); //the page is initially PAGE_WRITECOPY
- *(unsigned long*)fake_base=0xCECECECE; //Now it is PAGE_READWRITE
- unsigned long old;
- VirtualProtect((void*)fake_base,0x1000,PAGE_READWRITE|PAGE_GUARD,&old);
- unsigned long tid;
- CreateThread(0,0x1000,(LPTHREAD_START_ROUTINE)&watch,0,0,&tid);
- //---------------Useless stuff--------------
- MessageBox(0,"Try to dump me","waliedassar",0);
- ExitProcess(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement