Search code examples
python64-bitwindbgpykd

Using Pykd with SOS


I wanted to do the following in PyKd: execute a command of another extension and process its output.

First of all, it seems I have to load SOS in PyKd, not in WinDbg. I did this with

>>> print(loadExt("C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll"))
59323328

Next I wanted to perform a call on the extension like this:

>>> print(callExt(59323328, "!dumpheap -stat", ""))

(The third paramter is not documented in API.)

However, it gives me the error

The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework64\2.0.50727\sos.dll) failed
Win32 error 0n126
"The module could not be found."
Please check your debugger configuration and/or network access.

I'm doing all this within a !pycmd command prompt.

How can I call SOS commands from PyKd and process the output?

Versions:

WinDbg 9.2.9200.16384 x64
debugging a 64 bit application
Pykd 0.2.0.26 64 bit
Python 2.7.3


Solution

  • You can use a python sugar:

    loadExt(r"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll")

    About output length see the pykd issue tracker, I've posted a comment.