// File name: Memcheck.h // Author: moonwell // msn: Archonzhao@hotmail.com// In the case of detecting the internal deputy community, the memory offline appears in the process of the #include "memcheck.h" // Access code will appear interrupt #1ndef _mem_check_h # define _mem_check_hvoid * operator new (size_t size) {// created page number INT Page = (int) (size / 4096 1); // Offset size_t offset = Page_num * 4096 - size; // Create an additional protection page after the memory block, and set the properties of the page to the non-readable void * p = Virtualalloc (null, Page_Num * 4096 1, MEM_COMMIT, PAGE_EXECUTE_READWRITE); / / Positioning the last protection page address void * pChecker = (char *) P Page_num * 4096; // Set the last page to not read DWORD OLD_VALUE; VirtualProtect (PChecker, 4096, Page_noAccess, & Old_Value); return (char * P offset;} Void Operator delete (Void * p) {// Find the start address P = (char *) P - (size_t) p% 4096; VirtualFree (p, 0, mem_release);} # Endif / / There are no one to do a few lines of code. For example, use: #include
Note: Each time the new operation, at least the memory is more than 4K, which is more than 4K.