<s> from ctypes import c_void_p , POINTER , sizeof , Structure , windll , WinError , WINFUNCTYPE <EOL> from ctypes . wintypes import BOOL , BYTE , DWORD , HANDLE , LPCWSTR , LPWSTR , UINT , WORD <EOL> LPVOID = c_void_p <EOL> LPBYTE = POINTER ( BYTE ) <EOL> LPDWORD = POINTER ( DWORD ) <EOL> def ErrCheckBool ( result , func , args ) : <EOL> """<STR_LIT>""" <EOL> if not result : <EOL> raise WinError ( ) <EOL> return args <EOL> CloseHandleProto = WINFUNCTYPE ( BOOL , HANDLE ) <EOL> CloseHandle = CloseHandleProto ( ( "<STR_LIT>" , windll . kernel32 ) ) <EOL> CloseHandle . errcheck = ErrCheckBool <EOL> class AutoHANDLE ( HANDLE ) : <EOL> """<STR_LIT>""" <EOL> def Close ( self ) : <EOL> if self . value : <EOL> CloseHandle ( self ) <EOL> self . value = <NUM_LIT:0> <EOL> def __del__ ( self ) : <EOL> self . Close ( ) <EOL> def __int__ ( self ) : <EOL> return self . value <EOL> def ErrCheckHandle ( result , func , args ) : <EOL> """<STR_LIT>""" <EOL> if not result : <EOL> raise WinError ( ) <EOL> return AutoHANDLE ( result ) <EOL> class PROCESS_INFORMATION ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT>" , HANDLE ) , <EOL> ( "<STR_LIT>" , HANDLE ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) ] <EOL> def __init__ ( self ) : <EOL> Structure . __init__ ( self ) <EOL> self . cb = sizeof ( self ) <EOL> LPPROCESS_INFORMATION = POINTER ( PROCESS_INFORMATION ) <EOL> class STARTUPINFO ( Structure ) : <EOL> _fields_ = [ ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , LPWSTR ) , <EOL> ( "<STR_LIT>" , LPWSTR ) , <EOL> ( "<STR_LIT>" , LPWSTR ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , DWORD ) , <EOL> ( "<STR_LIT>" , WORD ) , <EOL> ( "<STR_LIT>" , WORD ) , <EOL> ( "<STR_LIT>" , LPBYTE ) , <EOL> ( "<STR_LIT>" , HANDLE ) , <EOL> ( "<STR_LIT>" , HANDLE ) , <EOL> ( "<STR_LIT>" , HANDLE ) <EOL> ] <EOL> LPSTARTUPINFO = POINTER ( STARTUPINFO ) <EOL> STARTF_USESHOWWINDOW = <NUM_LIT> <EOL> STARTF_USESIZE = <NUM_LIT> <EOL> STARTF_USEPOSITION = <NUM_LIT> <EOL> STARTF_USECOUNTCHARS = <NUM_LIT> <EOL> STARTF_USEFILLATTRIBUTE = <NUM_LIT> <EOL> STARTF_RUNFULLSCREEN = <NUM_LIT> <EOL> STARTF_FORCEONFEEDBACK = <NUM_LIT> <EOL> STARTF_FORCEOFFFEEDBACK = <NUM_LIT> <EOL> STARTF_USESTDHANDLES = <NUM_LIT> <EOL> class EnvironmentBlock : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , dict ) : <EOL> if not dict : <EOL> self . _as_parameter_ = None <EOL> else : <EOL> values = [ "<STR_LIT>" % ( key , value ) <EOL> for ( key , value ) in dict . items ( ) ] <EOL> values . append ( "<STR_LIT>" ) <EOL> self . _as_parameter_ = LPCWSTR ( "<STR_LIT>" . join ( values ) ) <EOL> CreateProcessProto = WINFUNCTYPE ( BOOL , <EOL> LPCWSTR , <EOL> LPWSTR , <EOL> LPVOID , <EOL> LPVOID , <EOL> BOOL , <EOL> DWORD , <EOL> LPVOID , <EOL> LPCWSTR , <EOL> LPSTARTUPINFO , <EOL> LPPROCESS_INFORMATION <EOL> ) <EOL> CreateProcessFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , True ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:2> , "<STR_LIT>" ) ) <EOL> def ErrCheckCreateProcess ( result , func , args ) : <EOL> ErrCheckBool ( result , func , args ) <EOL> pi = args [ <NUM_LIT:9> ] <EOL> return AutoHANDLE ( pi . hProcess ) , AutoHANDLE ( pi . hThread ) , pi . dwProcessID , pi . dwThreadID <EOL> CreateProcess = CreateProcessProto ( ( "<STR_LIT>" , windll . kernel32 ) , <EOL> CreateProcessFlags ) <EOL> CreateProcess . errcheck = ErrCheckCreateProcess <EOL> CREATE_BREAKAWAY_FROM_JOB = <NUM_LIT> <EOL> CREATE_DEFAULT_ERROR_MODE = <NUM_LIT> <EOL> CREATE_NEW_CONSOLE = <NUM_LIT> <EOL> CREATE_NEW_PROCESS_GROUP = <NUM_LIT> <EOL> CREATE_NO_WINDOW = <NUM_LIT> <EOL> CREATE_SUSPENDED = <NUM_LIT> <EOL> CREATE_UNICODE_ENVIRONMENT = <NUM_LIT> <EOL> DEBUG_ONLY_THIS_PROCESS = <NUM_LIT> <EOL> DEBUG_PROCESS = <NUM_LIT> <EOL> DETACHED_PROCESS = <NUM_LIT> <EOL> CreateJobObjectProto = WINFUNCTYPE ( HANDLE , <EOL> LPVOID , <EOL> LPCWSTR <EOL> ) <EOL> CreateJobObjectFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" , None ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , None ) ) <EOL> CreateJobObject = CreateJobObjectProto ( ( "<STR_LIT>" , windll . kernel32 ) , <EOL> CreateJobObjectFlags ) <EOL> CreateJobObject . errcheck = ErrCheckHandle <EOL> AssignProcessToJobObjectProto = WINFUNCTYPE ( BOOL , <EOL> HANDLE , <EOL> HANDLE <EOL> ) <EOL> AssignProcessToJobObjectFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" ) ) <EOL> AssignProcessToJobObject = AssignProcessToJobObjectProto ( <EOL> ( "<STR_LIT>" , windll . kernel32 ) , <EOL> AssignProcessToJobObjectFlags ) <EOL> AssignProcessToJobObject . errcheck = ErrCheckBool <EOL> def ErrCheckResumeThread ( result , func , args ) : <EOL> if result == - <NUM_LIT:1> : <EOL> raise WinError ( ) <EOL> return args <EOL> ResumeThreadProto = WINFUNCTYPE ( DWORD , <EOL> HANDLE <EOL> ) <EOL> ResumeThreadFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" ) , ) <EOL> ResumeThread = ResumeThreadProto ( ( "<STR_LIT>" , windll . kernel32 ) , <EOL> ResumeThreadFlags ) <EOL> ResumeThread . errcheck = ErrCheckResumeThread <EOL> TerminateJobObjectProto = WINFUNCTYPE ( BOOL , <EOL> HANDLE , <EOL> UINT <EOL> ) <EOL> TerminateJobObjectFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , <NUM_LIT> ) ) <EOL> TerminateJobObject = TerminateJobObjectProto ( <EOL> ( "<STR_LIT>" , windll . kernel32 ) , <EOL> TerminateJobObjectFlags ) <EOL> TerminateJobObject . errcheck = ErrCheckBool <EOL> WaitForSingleObjectProto = WINFUNCTYPE ( DWORD , <EOL> HANDLE , <EOL> DWORD , <EOL> ) <EOL> WaitForSingleObjectFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:1> , "<STR_LIT>" , - <NUM_LIT:1> ) ) <EOL> WaitForSingleObject = WaitForSingleObjectProto ( <EOL> ( "<STR_LIT>" , windll . kernel32 ) , <EOL> WaitForSingleObjectFlags ) <EOL> INFINITE = - <NUM_LIT:1> <EOL> WAIT_TIMEOUT = <NUM_LIT> <EOL> WAIT_OBJECT_0 = <NUM_LIT> <EOL> WAIT_ABANDONED = <NUM_LIT> <EOL> GetExitCodeProcessProto = WINFUNCTYPE ( BOOL , <EOL> HANDLE , <EOL> LPDWORD , <EOL> ) <EOL> GetExitCodeProcessFlags = ( ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:2> , "<STR_LIT>" ) ) <EOL> GetExitCodeProcess = GetExitCodeProcessProto ( <EOL> ( "<STR_LIT>" , windll . kernel32 ) , <EOL> GetExitCodeProcessFlags ) <EOL> GetExitCodeProcess . errcheck = ErrCheckBool </s>
