程序的自我复制


#include <windows.h>
#include <iostream>
#include <stdio.h>
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); 
} 

 

posted @ 2014-03-13 22:25  RookieRoy  阅读(360)  评论(0编辑  收藏  举报