内存拷贝,实现程序自身代码复制。

#include #include #include using namespace std; #define BUFFER_SIZE 4096 void *MemAddr = NULL; int _tmain(int argc, _TCHAR* argv[]) { copyself(); getchar(); return 0; }

void copyself( ) { MemAddr = VirtualAlloc(NULL, BUFFER_SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); memcpy(MemAddr, (void *)_tmain, BUFFER_SIZE); }



    推荐阅读