MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / create_process

Function create_process

windows/utils/winutils.py:89–113  ·  view source on GitHub ↗

A convenient wrapper arround :func:`windows.winproxy.CreateProcessA`

(path, args=None, dwCreationFlags=0, show_windows=True)

Source from the content-addressed store, hash-verified

87
88
89def create_process(path, args=None, dwCreationFlags=0, show_windows=True):
90 """A convenient wrapper arround :func:`windows.winproxy.CreateProcessA`"""
91 proc_info = PROCESS_INFORMATION()
92 lpStartupInfo = None
93 if show_windows:
94 StartupInfo = STARTUPINFOW()
95 StartupInfo.cb = ctypes.sizeof(StartupInfo)
96 StartupInfo.dwFlags = 0
97 lpStartupInfo = ctypes.byref(StartupInfo)
98 lpCommandLine = None
99 if isinstance(path, bytes):
100 path = path.decode()
101 if args:
102 unicode_args = []
103 for arg in args:
104 if isinstance(arg, bytes):
105 arg = arg.decode()
106 unicode_args.append(arg)
107 lpCommandLine = (" ".join(unicode_args))
108 windows.winproxy.CreateProcessW(path, lpCommandLine=lpCommandLine, dwCreationFlags=dwCreationFlags, lpProcessInformation=ctypes.byref(proc_info), lpStartupInfo=lpStartupInfo)
109 dbgprint("CreateProcessW new process handle {:#x}".format(proc_info.hProcess), "HANDLE")
110 dbgprint("CreateProcessW new thread handle {:#x}".format(proc_info.hThread), "HANDLE")
111 dbgprint("Automatic close of thread handle {:#x}".format(proc_info.hThread), "HANDLE")
112 windows.winproxy.CloseHandle(proc_info.hThread) # Give access to a WinThread in addition of the WinProcess ?
113 return windows.winobject.process.WinProcess(pid=proc_info.dwProcessId, handle=proc_info.hProcess)
114
115
116def device_io_control(handle, iocode, buffer):

Callers 2

pop_proc_32Function · 0.90
pop_proc_64Function · 0.90

Calls 2

decodeMethod · 0.80
sizeofMethod · 0.45

Tested by 2

pop_proc_32Function · 0.72
pop_proc_64Function · 0.72