Hey,
I'm the developer of [Voltron](https://github/snare/voltron) and I'm currently adding support for WinDbg/CDB using PyKD as discussed on twitter. I'm having an issue where if I load the Voltron entry point script as a file, PyKD raises an exception, but if I `!py` and enter the same code via the REPL, it works fine.
For example:
```
$ cdb -c '.load C:\pykd.pyd' calc
Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64
...
<snip>
...
0:000> !py C:\Users\admin\e.py
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width
warnings.warn(_MSG_NOSUPPORT)
Voltron loaded.
c0000005 Exception in C:\pykd.pyd.py debugger extension.
PC: 00000000`6ff497bc VA: 00000000`00000058 R/W: 0 Parameter: 00000000`00000000
```
As you can see there, Voltron has loaded successfully but PyKD has thrown an exception after the code finished running. Ignore the `terminal.py` warning.
After this, the CDB/WinDbg prompt disappears, but the debugger still responds to commands. If I try to execute more Python, it just hangs:
```
r
rax=0000000000000000 rbx=0000000000000000 rcx=000000007774010a
rdx=0000000000000000 rsi=00000000777f52f8 rdi=0000000077823650
rip=00000000777a1220 rsp=00000000001fef90 rbp=000007fffffd4000
r8=00000000001fef88 r9=000007fffffd4000 r10=0000000000000000
r11=0000000000000246 r12=0000000000000000 r13=0000000077823520
r14=00000000001ff590 r15=000000000000ffff
iopl=0 nv up ei pl zr na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000246
ntdll!CsrSetPriorityClass+0x40:
00000000`777a1220 cc int 3
!py
<hang>
```
If I run the same code in the REPL, it works fine:
```
$ cat e.py
import voltron.entry
$ cdb -c '.load C:\pykd.pyd' calc
Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64
...
<snip>
...
0:000> !py
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import voltron.entry
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width
warnings.warn(_MSG_NOSUPPORT)
Voltron loaded.
>>> exit()
0:000>
```
This has executed successfully and the Voltron server is running in a background thread:
```
$ curl http://localhost:5555/api/version 2>/dev/null
{"status": "success", "data": {"api_version": 1.1, "capabilities": ["async"], "host_version": "Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64, pykd 0.3.0.38"}, "type": "response"}
$ curl http://localhost:5555/api/registers 2>/dev/null
{"status": "success", "data": {"registers": {"gs": 43, "rip": 2004488736, "rdx": 0, "r15": 65535, "cs": 51, "es": 43, "r13": 2005021984, "rcx": 2004091146, "rax": 0, "rflags": 582, "r14": 849072, "fs": 83, "r12": 0, "rsi": 2004833016, "r10": 0, "r11": 582, "rsp": 847536, "ds": 43, "rbx": 0, "ss": 43, "r8": 847528, "r9": 8796092874752, "rbp": 8796092874752, "rdi": 2005022288}}, "type": "response"}
```
Any idea what's going on here? I'm running on Windows 7 x64 as it's all I have handy, with Windows SDK for .NET 3.5, Python 2.7.11, and PyKD 0.3.0.38.
I'm the developer of [Voltron](https://github/snare/voltron) and I'm currently adding support for WinDbg/CDB using PyKD as discussed on twitter. I'm having an issue where if I load the Voltron entry point script as a file, PyKD raises an exception, but if I `!py` and enter the same code via the REPL, it works fine.
For example:
```
$ cdb -c '.load C:\pykd.pyd' calc
Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64
...
<snip>
...
0:000> !py C:\Users\admin\e.py
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width
warnings.warn(_MSG_NOSUPPORT)
Voltron loaded.
c0000005 Exception in C:\pykd.pyd.py debugger extension.
PC: 00000000`6ff497bc VA: 00000000`00000058 R/W: 0 Parameter: 00000000`00000000
```
As you can see there, Voltron has loaded successfully but PyKD has thrown an exception after the code finished running. Ignore the `terminal.py` warning.
After this, the CDB/WinDbg prompt disappears, but the debugger still responds to commands. If I try to execute more Python, it just hangs:
```
r
rax=0000000000000000 rbx=0000000000000000 rcx=000000007774010a
rdx=0000000000000000 rsi=00000000777f52f8 rdi=0000000077823650
rip=00000000777a1220 rsp=00000000001fef90 rbp=000007fffffd4000
r8=00000000001fef88 r9=000007fffffd4000 r10=0000000000000000
r11=0000000000000246 r12=0000000000000000 r13=0000000077823520
r14=00000000001ff590 r15=000000000000ffff
iopl=0 nv up ei pl zr na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000246
ntdll!CsrSetPriorityClass+0x40:
00000000`777a1220 cc int 3
!py
<hang>
```
If I run the same code in the REPL, it works fine:
```
$ cat e.py
import voltron.entry
$ cdb -c '.load C:\pykd.pyd' calc
Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64
...
<snip>
...
0:000> !py
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import voltron.entry
C:\Python27\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width
warnings.warn(_MSG_NOSUPPORT)
Voltron loaded.
>>> exit()
0:000>
```
This has executed successfully and the Voltron server is running in a background thread:
```
$ curl http://localhost:5555/api/version 2>/dev/null
{"status": "success", "data": {"api_version": 1.1, "capabilities": ["async"], "host_version": "Microsoft (R) Windows Debugger Version 6.11.0001.404 AMD64, pykd 0.3.0.38"}, "type": "response"}
$ curl http://localhost:5555/api/registers 2>/dev/null
{"status": "success", "data": {"registers": {"gs": 43, "rip": 2004488736, "rdx": 0, "r15": 65535, "cs": 51, "es": 43, "r13": 2005021984, "rcx": 2004091146, "rax": 0, "rflags": 582, "r14": 849072, "fs": 83, "r12": 0, "rsi": 2004833016, "r10": 0, "r11": 582, "rsp": 847536, "ds": 43, "rbx": 0, "ss": 43, "r8": 847528, "r9": 8796092874752, "rbp": 8796092874752, "rdi": 2005022288}}, "type": "response"}
```
Any idea what's going on here? I'm running on Windows 7 x64 as it's all I have handy, with Windows SDK for .NET 3.5, Python 2.7.11, and PyKD 0.3.0.38.