1. /*Code By Pnig0s1992*/ 
  2. #include <Windows.h> 
  3. #include <stdio.h> 
  4. #include <tchar.h> 
  5.  
  6. #define MEM_BLOCK_SIZE 32 
  7.  
  8. BOOL ShowMemContent(LPVOID lpMem,SIZE_T dwSize); 
  9.  
  10. int main(void){ 
  11.     HANDLE hHeap = GetProcessHeap(); 
  12.     LPVOID lpSrc; 
  13.     LPVOID lpDis; 
  14.     if(hHeap == NULL){ 
  15.         printf("获取当前进程中的堆错误:%d\n",GetLastError()); 
  16.         return 1; 
  17.     } 
  18.     lpSrc = HeapAlloc(hHeap,0,MEM_BLOCK_SIZE); 
  19.     lpDis = HeapAlloc(hHeap,0,MEM_BLOCK_SIZE); 
  20.  
  21.     printf("未清零的内存:\n"); 
  22.  
  23.     ShowMemContent(lpSrc,MEM_BLOCK_SIZE); 
  24.     ShowMemContent(lpDis,MEM_BLOCK_SIZE); 
  25.  
  26.     ZeroMemory(lpSrc,MEM_BLOCK_SIZE); 
  27.     ZeroMemory(lpDis,MEM_BLOCK_SIZE); 
  28.  
  29.     printf("清零后的内存:\n"); 
  30.  
  31.     ShowMemContent(lpSrc,MEM_BLOCK_SIZE); 
  32.     ShowMemContent(lpDis,MEM_BLOCK_SIZE); 
  33.  
  34.     FillMemory(lpSrc,MEM_BLOCK_SIZE,0xBB); 
  35.     FillMemory(lpSrc,MEM_BLOCK_SIZE/2,0xAA); 
  36.  
  37.     CopyMemory(lpDis,lpSrc,MEM_BLOCK_SIZE); 
  38.  
  39.     printf("填充复制后的内存:\n"); 
  40.     ShowMemContent(lpDis,MEM_BLOCK_SIZE); 
  41.  
  42.     system("pause"); 
  43.     return 0; 
  44.  
  45. BOOL ShowMemContent(LPVOID lpMem,SIZE_T dwSize){ 
  46.     BYTE lpShow[MEM_BLOCK_SIZE]; 
  47.     INT i=0; 
  48.     if(dwSize>MEM_BLOCK_SIZE){ 
  49.         printf("over flow."); 
  50.         return FALSE; 
  51.     } 
  52.     CopyMemory(lpShow,lpMem,MEM_BLOCK_SIZE); 
  53.     for(i=0;i<dwSize;i++){ 
  54.         printf("%.2X",lpShow[i]); 
  55.         if(!((i+1)%16)){ 
  56.             printf("\n"); 
  57.         } 
  58.     } 
  59.     printf("\n"); 
  60.     return TRUE;