@@ -73,14 +73,35 @@ def create_console():
7373 sys .stderr = console_stderr
7474
7575
76- def create_process (path , args = None , dwCreationFlags = 0 , show_windows = True ):
77- """A convenient wrapper arround :func:`windows.winproxy.CreateProcessW`"""
76+ def create_process (path , args = None , dwCreationFlags = 0 , show_windows = True , machine = None ):
77+ """A convenient wrapper arround :func:`windows.winproxy.CreateProcessW`
78+ ..note:
79+ The machine param only works starting at vista and should be used on arm64 computer
80+ """
7881 proc_info = PROCESS_INFORMATION ()
82+ StartupInfo = None
7983 lpStartupInfo = None
84+
85+ if machine is not None :
86+ buffer = ctypes .create_string_buffer (0x100 )
87+ size = gdef .DWORD64 (len (buffer ))
88+ machine = gdef .WORD (machine )
89+ windows .winproxy .InitializeProcThreadAttributeList (buffer , 1 , 0 , size )
90+ windows .winproxy .UpdateProcThreadAttribute (buffer , 0 , gdef .PROC_THREAD_ATTRIBUTE_MACHINE_TYPE , ctypes .addressof (machine ), ctypes .sizeof (machine ), None , None )
91+
92+ startup_infoex = gdef .STARTUPINFOEXW ()
93+ startup_infoex .StartupInfo .cb = ctypes .sizeof (gdef .STARTUPINFOEXW )
94+ startup_infoex .lpAttributeList = ctypes .cast (buffer , gdef .PVOID )
95+ StartupInfo = startup_infoex .StartupInfo
96+
97+ dwCreationFlags |= gdef .EXTENDED_STARTUPINFO_PRESENT
98+
8099 if show_windows :
81- StartupInfo = STARTUPINFOW ()
82- StartupInfo .cb = ctypes .sizeof (StartupInfo )
100+ if StartupInfo is None :
101+ StartupInfo = STARTUPINFOW ()
102+ StartupInfo .cb = ctypes .sizeof (StartupInfo )
83103 StartupInfo .dwFlags = 0
104+ if StartupInfo :
84105 lpStartupInfo = ctypes .byref (StartupInfo )
85106 lpCommandLine = None
86107 if isinstance (path , bytes ):
@@ -97,6 +118,8 @@ def create_process(path, args=None, dwCreationFlags=0, show_windows=True):
97118 dbgprint ("CreateProcessW new thread handle {:#x}" .format (proc_info .hThread ), "HANDLE" )
98119 dbgprint ("Automatic close of thread handle {:#x}" .format (proc_info .hThread ), "HANDLE" )
99120 windows .winproxy .CloseHandle (proc_info .hThread ) # Give access to a WinThread in addition of the WinProcess ?
121+ if machine :
122+ windows .winproxy .DeleteProcThreadAttributeList (buffer )
100123 return windows .winobject .process .WinProcess (pid = proc_info .dwProcessId , handle = proc_info .hProcess )
101124
102125
0 commit comments