Skip to content

Commit 7abda41

Browse files
authored
Merge pull request #77 from hakril/improve_testing
Small improvments
2 parents 8932682 + 3489a56 commit 7abda41

7 files changed

Lines changed: 14 additions & 6 deletions

File tree

tests/test_alpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def generated_test():
1515
time.sleep(0.5)
1616
client_function()
1717
th.join()
18-
return True
18+
return
1919
return generated_test
2020

2121
PORT_NAME = r"\RPC Control\PythonForWindowsTestPort"

tests/test_crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def test_crypt_obj():
227227
# TODO: Need some better ideas
228228

229229
def test_certificate_from_store():
230-
return windows.crypto.CertificateStore.from_system_store("Root")
230+
assert windows.crypto.CertificateStore.from_system_store("Root")
231231

232232

233233
def test_sign_verify(rawcert, rawpfx):

tests/test_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_current_process_ppid(self):
2525
assert myself.ppid == windows.current_process.ppid
2626

2727
def test_get_current_process_peb(self):
28-
return windows.current_process.peb
28+
assert windows.current_process.peb
2929

3030
def test_get_current_process_modules(self):
3131
# Use module filename because this executable can be:

windows/debug/symbols.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ def _get_type_info(self, typeinfo, ires=None):
177177
windows.winproxy.LocalFree(res)
178178
return newres
179179

180+
@property
181+
def module(self):
182+
return self.resolver.get_module(self.modbase)
183+
180184
@property
181185
def name(self):
182186
return self._get_type_info(gdef.TI_GET_SYMNAME)

windows/syswow64.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def get_current_process_syswow_peb():
169169

170170
class CurrentProcessReadSyswow(process.Process):
171171
bitness = 64
172+
172173
def _get_handle(self):
174+
# GetCurrentProcess() is not accepted for NtWow64ReadVirtualMemory64 :(
173175
return winproxy.OpenProcess(dwProcessId=windows.current_process.pid)
174176

175177
def read_memory(self, addr, size):

windows/winobject/event_log.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ class ImprovedEVT_VARIANT(gdef.EVT_VARIANT):
377377
gdef.EvtVarTypeUInt16 + gdef.EVT_VARIANT_TYPE_ARRAY : "UInt16Arr",
378378
gdef.EvtVarTypeUInt32 + gdef.EVT_VARIANT_TYPE_ARRAY : "UInt32Arr",
379379
gdef.EvtVarTypeUInt64 + gdef.EVT_VARIANT_TYPE_ARRAY : "UInt64Arr",
380+
gdef.EvtVarTypeHexInt64 + gdef.EVT_VARIANT_TYPE_ARRAY : "UInt64Arr",
380381
}
381382
NoneValue = None
382383

windows/winobject/process.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,12 @@ def handles(self):
520520
return [h for h in windows.system.handles if h.dwProcessId == pid]
521521

522522
def __del__(self):
523-
super(Process, self).__del__()
524-
# Same logic that AutoHandle.__del__ for Process.limited_handle
525-
# Assert that Process inherit AutoHandle
526523
# sys.path is not None -> check if python shutdown
527524
if sys.path is not None and hasattr(self, "_limited_handle") and self._limited_handle:
525+
# Same logic that AutoHandle.__del__ for Process.limited_handle
526+
# Assert that Process inherit AutoHandle
527+
# Call super after check as Process could be None during destruction
528+
super(Process, self).__del__()
528529
# Prevent some bug where dbgprint might be None when __del__ is called in a closing process
529530
# This line is bad -> it reopens a handle closed by 'super(Process, self).__del__()' ._.
530531
dbgprint("Closing limited handle {0} for {1}".format(hex(self._limited_handle), self), "HANDLE") if dbgprint is not None else None

0 commit comments

Comments
 (0)