当前位置:网站首页>win32:堆破壞的dump文件分析
win32:堆破壞的dump文件分析
2022-07-03 17:52:00 【修的什麼真】
- win32堆結構
在解决實際問題以前,先來了解一下相關概念
1. 堆結構
堆->段->塊
堆是由段,段是由塊組成的,塊就是用戶最終向系統申請的虛擬內存的數據結構。(目前我們用戶態程序只需要理解塊就可以了)
2. _HEAP_ENTRY結構
每個堆,每個段,每個塊都會有相應的_HEAP_ENTRY結構,裏面描述了該區域內容的信息。比如塊的_HEAP_ENTRY結構就存放了所屬的堆,段,前項大小和當前大小等信息。
- windbg堆的相關命令
- 查看所有堆的概覽信息:!heap -s
- 某個堆所有的段和塊信息:!heap -a 0xXXXXXXXX
- 查看某個內存地址所在的_HEAP_ENTRY信息:!heap -x 0xXXXXXXXX
- 統計某個堆的概覽信息:!heap -stat -h 0xXXXXXXXX
- 列出所有大小為X的塊地址:!heap -flt s X
- 查看堆的調試支持:!gflag
- 查看內存塊的內容 dc 0xXXXXXXXX
- 堆破壞的調試
1. 什麼叫做堆破壞
堆破壞其實就是塊破壞,由於對超出地址所在分配的空間讀寫,導致破壞了_HEAP_ENTRY結構(如果是CRT堆,就是破壞了CRT堆的末尾檢查結構,甚至破壞了下一個塊的結構)
2. 一個堆破壞的例子

這裏故意寫了一個越界的操作,編譯成release版本,用windbg掛上去

查看一下ptr的值

查看一下ptr所在的_HEAP_ENTRY結構,發現屬於00b30000這個堆,在00b34420這個塊裏面


我們看到上述塊後續的塊都已經被破壞,所以堆破壞的特征基本就長這樣。但是該例程並不會導致崩潰。
3. 總結一下分析思路
a) 找到該崩潰的塊所在的堆(可以根據地址範圍判斷)。
b) 查看該堆所有塊信息。
c) 從最後一個尚未被破壞的塊找到相應的信息。(如果業務邏輯是從小往大地址寫,就會破壞往後塊,否則就是相反)
边栏推荐
- The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
- PHP MySQL inserts data
- Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
- Interviewer: why is the value nil not equal to nil?
- How to read the source code [debug and observe the source code]
- Loop through JSON object list
- Comparison of kotlin collaboration + retro build network request schemes
- QT学习日记9——对话框
- 基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
- STM32实现74HC595控制
猜你喜欢

(8) HS corner detection

国内如何购买Google Colab会员

Talk about the design and implementation logic of payment process

问题随记 —— 在 edge 上看视频会绿屏

面试官:值为 nil 为什么不等于 nil ?

Leetcode Valentine's Day Special - looking for a single dog

互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼

Embedded-c language-7

(9) Opencv Canny edge detection

STM32 realizes 74HC595 control
随机推荐
Talk about the design and implementation logic of payment process
Kotlin's collaboration: Context
Enterprise custom form engine solution (XI) -- form rule engine 1
Detailed explanation of common network attacks
AcWing 271. 杨老师的照相排列【多维DP】
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
The difference between i++ and ++i: tell their differences easily
1146_ SiCp learning notes_ exponentiation
Graduation summary
[set theory] order relation: summary (partial order relation | partial order set | comparable | strictly less than | covering | hasto | total order relation | quasi order relation | partial order rela
Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
Qt调节Win屏幕亮度和声音大小
IntelliJ 2021.3 short command line when running applications
vs2013已阻止安装程序,需安装IE10
微服务组件Sentinel控制台调用
Leetcode 669 pruning binary search tree -- recursive method and iterative method
Distributed task distribution framework gearman
WEB-UI自动化测试-最全元素定位方法
问题随记 —— 在 edge 上看视频会绿屏
PHP returns 500 errors but no error log - PHP return 500 error but no error log