如何在给定块地址 WinDbg 的情况下查看堆块的内容

How to view contents of a heap block given the block address WinDbg

我最近在浏览这篇论文(https://www.usenix.org/legacy/event/sec09/tech/full_papers/ratanaworabhan.pdf),其中软件“扫描堆对象 识别有效的 x86 代码序列。”在过去的几周里,我一直在努力让它发挥作用。

到目前为止,我已经取得足够的进展,可以打印 rtlallocateheap 参数并打印其 return 值。 RTLAllocateheap returns 已分配堆块的指针。但是,使用这个指针如何识别这个位置的块是否是有效的 x86 代码序列?

我附上了一张 WinDbg 的图片来展示我目前所拥有的

使用u <address>反汇编:

Allocated 1000 bytes starting at 001a0000
0:003> u 001a0000
001a0000 90              nop
001a0001 90              nop
001a0002 90              nop
001a0003 90              nop
001a0004 31c0            xor     eax,eax
001a0006 90              nop
001a0007 90              nop
001a0008 90              nop

不幸的是,许多字节将导致有效的操作码。对我来说,问题更多:你如何判断这些操作码是无害的还是有害的。

只有当您看到像这里这样的问号时,您才可以判断这是无效代码。

0:003> u 5d0000
005d0000 32e3            xor     ah,bl
005d0002 388895280001    cmp     byte ptr [eax+1002895h],cl
005d0008 ee              out     dx,al
005d0009 ff              ???
005d000a ee              out     dx,al
005d000b ff02            inc     dword ptr [edx]