When executing pykd.dbgCommand('th') from a breakpoint handler in the kernel I get an HRESULT E_FAIL 0x80004005 error. PyKD version 0.3.1.9, debugger and debuggee are both Windows 7 SP1 x64. If the breakpoint handler simply returns pykd.eventResult.Break and I run pykd.dbgCommand('th') manually it works as expected.
Example execution showing the basic breakpoint handler failing and then the manual execution succeeding.
```
0: kd> !py
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> def handler():
... pykd.dprintln('tracing...')
... pykd.dbgCommand('th')
... return pykd.eventResult.Proceed
...
>>> bp = pykd.setBp(0xfffff88002dc05b4, callback=handler)
>>> exit()
0: kd> g
tracing...
Traceback (most recent call last):
File "<console>", line 3, in handler
DbgException: Call IDebugControl::WaitForEvent failed
HRESULT 0x80004005
vmmemctl+0x15b4:
fffff880`02dc05b4 48895c2408 mov qword ptr [rsp+8],rbx
1: kd> !py
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> pykd.dbgCommand('th')
```
Example execution showing the basic breakpoint handler failing and then the manual execution succeeding.
```
0: kd> !py
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> def handler():
... pykd.dprintln('tracing...')
... pykd.dbgCommand('th')
... return pykd.eventResult.Proceed
...
>>> bp = pykd.setBp(0xfffff88002dc05b4, callback=handler)
>>> exit()
0: kd> g
tracing...
Traceback (most recent call last):
File "<console>", line 3, in handler
DbgException: Call IDebugControl::WaitForEvent failed
HRESULT 0x80004005
vmmemctl+0x15b4:
fffff880`02dc05b4 48895c2408 mov qword ptr [rsp+8],rbx
1: kd> !py
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> pykd.dbgCommand('th')
```