Skip to content

Commit d479d7a

Browse files
Merge branch 'qilingframework:dev' into dev
2 parents d939f0a + bae4eec commit d479d7a

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

qiling/os/windows/dlls/ntdll.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _QueryInformationProcess(ql: Qiling, address: int, params):
9393
def hook_ZwQueryInformationProcess(ql: Qiling, address: int, params):
9494
# TODO have no idea if is cdecl or stdcall
9595

96-
_QueryInformationProcess(ql, address, params)
96+
return _QueryInformationProcess(ql, address, params)
9797

9898
# __kernel_entry NTSTATUS NtQueryInformationProcess(
9999
# IN HANDLE ProcessHandle,
@@ -112,7 +112,7 @@ def hook_ZwQueryInformationProcess(ql: Qiling, address: int, params):
112112
def hook_NtQueryInformationProcess(ql: Qiling, address: int, params):
113113
# TODO have no idea if is cdecl or stdcall
114114

115-
_QueryInformationProcess(ql, address, params)
115+
return _QueryInformationProcess(ql, address, params)
116116

117117
def _QuerySystemInformation(ql: Qiling, address: int, params):
118118
siClass = params["SystemInformationClass"]

qiling/os/windows/thread.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,17 @@ def create(self, func_addr, func_params, status):
8484
stack_size = 1024
8585
new_stack = self.ql.os.heap.alloc(stack_size) + stack_size
8686

87+
self.saved_context = self.ql.reg.save()
88+
89+
# set return address, parameters
8790
if self.ql.archtype == QL_ARCH.X86:
8891
self.ql.mem.write(new_stack - 4, self.ql.pack32(self.ql.os.thread_manager.THREAD_RET_ADDR))
8992
self.ql.mem.write(new_stack, self.ql.pack32(func_params))
9093
elif self.ql.archtype == QL_ARCH.X8664:
9194
self.ql.mem.write(new_stack - 8, self.ql.pack64(self.ql.os.thread_manager.THREAD_RET_ADDR))
92-
self.ql.mem.write(new_stack, self.ql.pack64(func_params))
93-
94-
# set eip, ebp, esp
95-
self.saved_context = self.ql.reg.save()
95+
self.saved_context["rcx"] = func_params
9696

97+
# set eip/rip, ebp/rbp, esp/rsp
9798
if self.ql.archtype == QL_ARCH.X86:
9899
self.saved_context["eip"] = func_addr
99100
self.saved_context["ebp"] = new_stack - 4

tests/test_pe.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
from qiling.os.windows.fncc import *
1717
from qiling.os.windows.utils import *
1818
from qiling.os.mapper import QlFsMappedObject
19+
# This is intended.
20+
# See https://stackoverflow.com/questions/8804830/python-multiprocessing-picklingerror-cant-pickle-type-function
1921
import multiprocess as mb
22+
import traceback
2023

2124
# On Windows, the CPython GC is too conservative and may hold too
2225
# many Unicorn objects (nearly 16GB) until free-ing them which may
@@ -33,7 +36,8 @@ def _run_test(self, results):
3336
try:
3437
results['result'] = self._test()
3538
except Exception as e:
36-
results['exception'] = e
39+
tb = traceback.format_exc()
40+
results['exception'] = tb
3741
results['result'] = False
3842

3943
def run(self):
@@ -45,7 +49,7 @@ def run(self):
4549
if "exception" not in results:
4650
return results['result']
4751
else:
48-
raise results['exception']
52+
raise RuntimeError(f"\n\nGot an exception during subprocess:\n\n{results['exception']}")
4953

5054

5155
class TestOut:

0 commit comments

Comments
 (0)