資源簡介
windows內存讀寫監視
windows內存讀寫監視
代碼片段和文件信息
#include
#include
#include“memexcept.h“
int?CALLBACK?cb(void*addrBOOL?wUINT_PTR*Tag)
{
int*p=(int*)addr;
printf(“address:%pwrite:%dvalue:%d\n“pwCanRead(&p)?*p:0);
return?0;//return?1?to?disable?watcher
}
int?main()
{
int(*p)[4];
p=(int(*)[4])VirtualAlloc(0sizeof(*p)MEM_COMMITPAGE_READWRITE);
(*p)[0]=0;
(*p)[1]=1;
(*p)[2]=2;
StartupMemExcept();//initialize
RegisterMemoryWatcher(psizeof(*p)cbFALSETRUE0);
printf(“v:%d\n“(*p)[0]);
printf(“v:%d\n“(*p)[1]);
puts(“dd“);
__try
{
printf(“v:%d\n“(*p)[2]);
(*p)[3]=6;
*(volatile?char*)0;//not?watched
}__except(EXCEPTION_EXECUTE_HANDLER)
{
puts(“except“);
}
CleanupMemExcept();//cleanup
return?0;
}
評論
共有 條評論