A convenient wrapper arround :func:`windows.winproxy.CreateProcessA`
(path, args=None, dwCreationFlags=0, show_windows=True)
| 87 | |
| 88 | |
| 89 | def 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 | |
| 116 | def device_io_control(handle, iocode, buffer): |