Better message / WindowsError raised when process die during safe_execute_python

This commit is contained in:
Clement Rouault
2016-07-18 14:04:37 +02:00
parent 19205f73a1
commit 9ebb25017b
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -21,6 +21,9 @@ TODO:
- test !
- Injection
- death of process in execute_python raise a WindowsError with explicit message (change sample in readme)
Documentation
* verif samples
* COMImplementation (example in LKD)
+3
View File
@@ -8,6 +8,7 @@ import windows.utils as utils
from .native_exec import simple_x86 as x86
from .native_exec import simple_x64 as x64
from windows.generated_def import STATUS_THREAD_IS_TERMINATING
from windows.native_exec.nativeutils import GetProcAddress64, GetProcAddress32
from windows.dbgprint import dbgprint
@@ -315,6 +316,8 @@ def safe_execute_python(process, code):
t.wait() # Wait terminaison of the thread
if t.exit_code == 0:
return True
if t.exit_code == STATUS_THREAD_IS_TERMINATING:
raise WindowsError("{0} died during execution of python command".format(process))
if t.exit_code != 0xffffffff:
raise ValueError("Unknown exit code {0}".format(hex(t.exit_code)))
data = retrieve_last_exception_data(process)