在this question中,我想用API调用代替DbgCommand("dt ..."),而PYKD命令typedVar()来拯救它。
因此,我的heap_stat脚本(用m_nSize和m_nCount信息扩展)现在运行速度快了三倍。
关于您的信息,我已经完成了计算STL集合中成员数量的替换操作:
Replace: collection_Size = dbgCommand(("dt 0x" + pointer_format + " %s m_nSize") % (ptr,type_name)).split(' : ').[-1].split('\n')[0]
By: collection_Size = typedVar(type_name, ptr).m_nSize由于这一成功,我想用API调用替换其他DbgCommand请求。
对于dbgCommand('!heap -h 0')来说,这似乎不是那么简单(一些例子):
>>> for t in targetHeapIterator():
... print t
...
Traceback (most recent call last):
File "<console>", line 1, in <module>
RuntimeError: This class cannot be instantiated from Python
>>> for t in targetHeap().entries:
... print t
...
Traceback (most recent call last):
File "<console>", line 1, in <module>
RuntimeError: This class cannot be instantiated from Python
>>> for t in targetProcess().getManagedHeap().entries:
... print t
...
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'instancemethod' object is not iterable我如何在我的进程堆上迭代(替换!heap -h 0)?
即使targetHeap()不能作为!heap -h 0的替代品,我仍然想知道如何使用它来进行调查。
发布于 2018-11-22 08:26:51
targetHeapIterator() -只适用于托管堆,不能直接创建它,只能通过特殊类创建。
for entry in targetProcess.getManagedHeap().entries():
pass # enumerate managed heap要枚举本机堆,需要编写自己的脚本。
也许它会对你有用:https://githomelab.ru/pykd/pykdwin
这个包有堆驱动程序,但有限制:
来自医生的样本:
from pykdwin.heap import *
for heap in get_heaps():
for entry in heap.entries():
print( hex(entry.address), entry.size )https://stackoverflow.com/questions/53393285
复制相似问题