pykd:带有回调的setBp给出类型错误

pykd: setBp with callback gives typeerror

我正在尝试使用 windbg 和 pykd 编写堆跟踪器,但在尝试设置回调时出现类型错误。

部分代码如下:


def enter_call_back(bp):
    print "RtlAllocateHeap called"
    return False

def return_call_back(bp):
    print "RtlAllocateHeap returned"
    return False



add = get_address("ntdll!RtlAllocateHeap")
bp_init = pykd.setBp(int(add, 16), enter_call_back)
bp_end = None

当我尝试 运行 时,出现以下错误:

0:000> !py C:\Users\tobbe\Documents\Projects\HeapTrace\heap_trace.py
hej


TypeError: enter_call_back() takes exactly 1 argument (0 given)

我正在使用 python 2.7 版;

0:000> !py
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

和 pykd 版本 2.0.0.22

0:000> !pykd.info

pykd bootstrapper version: 2.0.0.22

Installed python:

Version:        Status:     Image:
------------------------------------------------------------------------------
* 2.7 x86-32    Unloaded    C:\WINDOWS\SYSTEM32\python27.dll
  3.7 x86-32    Unloaded    C:\Users\Tobias.Lorek\AppData\Local\Programs\Python\Python37-32\python37.dll

我最初尝试按照以下教程进行操作,但遇到了类似的错误,https://labs.f-secure.com/archive/heap-tracing-with-windbg-and-python/

如有任何帮助,我们将不胜感激。

此致,

enter_call_back 应该没有参数。

查看来自 pykd 测试的示例: https://githomelab.ru/pykd/pykd/blob/0.3.2/test/scripts/breakpoint.py#L67

 def stopOnBreak():
     return pykd.eventResult.Break

 def testBreakCallback(self):
      breakCount = callCounter(stopOnBreak)
      bp = pykd.setBp( self.targetModule.CdeclFunc, breakCount )
      self.assertEqual( pykd.executionStatus.Break, pykd.go() )
      self.assertEqual( 1, breakCount.count )