Skip to content

kernel32.CreateRemoteThread() may return None #86

@HMaker

Description

@HMaker

When the process exits while CreateRemoteThread is called, the return type is None, but pymem is not checking that below:

Pymem/pymem/__init__.py

Lines 168 to 183 in 0ca7f66

params = params or 0
NULL_SECURITY_ATTRIBUTES = ctypes.cast(0, pymem.ressources.structure.LPSECURITY_ATTRIBUTES)
thread_h = pymem.ressources.kernel32.CreateRemoteThread(
self.process_handle,
NULL_SECURITY_ATTRIBUTES,
0,
address,
params,
0,
ctypes.byref(ctypes.c_ulong(0))
)
last_error = ctypes.windll.kernel32.GetLastError()
if last_error:
pymem.logger.warning('Got an error in start thread, code: %s' % last_error)
pymem.ressources.kernel32.WaitForSingleObject(thread_h, -1)
pymem.logger.debug('New thread_id: 0x%08x' % thread_h)

GetLastError() returned code 5 and I got logging error TypeError: %x format: an integer is required, not NoneType at line 183.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions