码迷,mamicode.com
首页 > Windows程序 > 详细

浅析Windows环境下堆表的空闲双向链表结构

时间:2017-04-12 23:40:54      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:链表   soft   mem   microsoft   clu   cal   操作   pack   alt   

  • 实验环境:
    • 操作系统: Windows 2000 Service Pack 4
    • 集成开发环境: Microsoft Visual C++ 6.0 SP6
  • 实验代码如下:
  •  1 #include <windows.h>
     2 #include <stdio.h>
     3 
     4 int main(int argc, char **argv)
     5 {
     6     HLOCAL h1, h2, h3, h4, h5, h6;
     7     HANDLE hp;
     8     hp = HeapCreate(0, 0x1000, 0x10000);
     9     
    10     // 为了方便显示堆的地址,这里把它打印出来
    11     printf("Heap address: %p\n", hp);
    12 
    13     // 为了避免程序监测出调试器而是使用调试堆管理策略
    14     __asm int 3
    15 
    16     h1 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 3);
    17     printf("h1: %p\n", h1);
    18     h2 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 5);
    19     printf("h2: %p\n", h2);
    20     h3 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 6);
    21     printf("h3: %p\n", h3);
    22     h4 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 8);
    23     printf("h4: %p\n", h4);
    24     h5 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 19);
    25     printf("h5: %p\n", h5);
    26     h6 = HeapAlloc(hp, HEAP_ZERO_MEMORY, 24);
    27     printf("h6: %p\n", h6);
    28 
    29     HeapFree(hp,0, h1);
    30     HeapFree(hp,0, h3);
    31     HeapFree(hp,0, h5);
    32 
    33     HeapFree(hp, 0, h4);
    34 
    35     return 0;
    36 }

     

  • 根据技术分享
  • 技术分享

浅析Windows环境下堆表的空闲双向链表结构

标签:链表   soft   mem   microsoft   clu   cal   操作   pack   alt   

原文地址:http://www.cnblogs.com/fishbool/p/6700724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!