当前位置: 首页>>代码示例>>Python>>正文


Python win32process.CreateProcess方法代码示例

本文整理汇总了Python中win32process.CreateProcess方法的典型用法代码示例。如果您正苦于以下问题:Python win32process.CreateProcess方法的具体用法?Python win32process.CreateProcess怎么用?Python win32process.CreateProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32process的用法示例。


在下文中一共展示了win32process.CreateProcess方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def main():
    if sys.argv[1] == 'child':
        if sys.argv[2] == 'windows':
            import win32api as api, win32process as proc
            info = proc.STARTUPINFO()
            info.hStdInput = api.GetStdHandle(api.STD_INPUT_HANDLE)
            info.hStdOutput = api.GetStdHandle(api.STD_OUTPUT_HANDLE)
            info.hStdError = api.GetStdHandle(api.STD_ERROR_HANDLE)
            python = sys.executable
            scriptDir = os.path.dirname(__file__)
            scriptName = os.path.basename(__file__)
            proc.CreateProcess(
                None, " ".join((python, scriptName, "grandchild")), None,
                None, 1, 0, os.environ, scriptDir, info)
        else:
            if os.fork() == 0:
                grandchild()
    else:
        grandchild() 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:21,代码来源:process_helper.py

示例2: create_desktop

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def create_desktop(desktop_name, start_explorer=1):
    """ Creates a new desktop and spawns a thread running on it
        Will also start a new icon thread on an existing desktop
    """
    sa=pywintypes.SECURITY_ATTRIBUTES()
    sa.bInheritHandle=1

    try:
        hdesk=win32service.CreateDesktop(desktop_name, 0, win32con.MAXIMUM_ALLOWED, sa)
    except win32service.error:
        traceback.print_exc()
        errbuf=cStringIO.StringIO()
        traceback.print_exc(None,errbuf)
        win32api.MessageBox(0, errbuf.getvalue(), 'Desktop creation failed')
        return
    if start_explorer:
        s=win32process.STARTUPINFO()
        s.lpDesktop=desktop_name
        prc_info=win32process.CreateProcess(None, "Explorer.exe",None,None,True,win32con.CREATE_NEW_CONSOLE,None,'c:\\',s)

    th=thread.start_new_thread(new_icon,(hdesk,desktop_name))
    hdesk.SwitchDesktop() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:desktopmanager.py

示例3: LaunchWin32Process

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def LaunchWin32Process(self, command):
        try:
            StartupInfo = win32process.STARTUPINFO()
            StartupInfo.dwFlags = win32process.STARTF_USESHOWWINDOW
            StartupInfo.wShowWindow = win32con.SW_NORMAL
            win32process.CreateProcess(
                None,
                command,
                None,
                None,
                0,
                win32process.NORMAL_PRIORITY_CLASS,
                None,
                None,
                StartupInfo)
        except Exception as e:
            print(sys.exc_info())
            print("Exception in LaunchWin32Process")
            pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:21,代码来源:agent.py

示例4: call

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def call(self, method, args):
            """
            Launch program to consume file

            @type	method: string
            @param	method: Command to execute
            @type	args: array of objects
            @param	args: Arguments to pass
            """

            hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess(
                None, self.commandLine, None, None, 0,
                win32con.NORMAL_PRIORITY_CLASS, None, None, None)

            while win32process.GetExitCodeProcess(hProcess) == win32con.STILL_ACTIVE:
                time.sleep(0.25)

            self.closeApp(hProcess, self._windowName) 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:20,代码来源:process.py

示例5: StartYardServer

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def StartYardServer(self):
        try:
            rkey = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Webers\\Y.A.R.D")
            path = RegQueryValueEx(rkey, "program")[0]
            if not os.path.exists(path):
                raise Exception
        except:
            raise self.Exception(
                "Please start Yards.exe first and configure it."
            )
        try:
            hProcess = CreateProcess(
                None,
                path,
                None,
                None,
                0,
                CREATE_NEW_CONSOLE,
                None,
                None,
                STARTUPINFO()
            )[0]
        except Exception, exc:
            raise eg.Exception(FormatError(exc[0])) 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:26,代码来源:__init__.py

示例6: start

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def start(self):
        procHandle, threadHandle, procId, threadId  = win32process.CreateProcess(
            None, # appName
            'python.exe "%s" /run_test_process %s %s' % (this_file,
                                                         self.BucketCount,
                                                         self.threadCount),
            None, # process security
            None, # thread security
            0, # inherit handles
            win32process.NORMAL_PRIORITY_CLASS,
            None, # new environment
            None, # Current directory
            win32process.STARTUPINFO(), # startup info
            )
        self.processHandle = procHandle 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_win32trace.py

示例7: _invalidWin32App

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def _invalidWin32App(pywinerr):
    """
    Determine if a pywintypes.error is telling us that the given process is
    'not a valid win32 application', i.e. not a PE format executable.

    @param pywinerr: a pywintypes.error instance raised by CreateProcess

    @return: a boolean
    """

    # Let's do this better in the future, but I have no idea what this error
    # is; MSDN doesn't mention it, and there is no symbolic constant in
    # win32process module that represents 193.

    return pywinerr.args[0] == 193 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:_dumbwin32proc.py

示例8: CreateProcess

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def CreateProcess(appName,
                  cmdline,
                  procSecurity,
                  threadSecurity,
                  inheritHandles,
                  newEnvironment,
                  env,
                  workingDir,
                  startupInfo):
    """
    This function mocks the generated pid aspect of the win32.CreateProcess
    function.
      - the true win32process.CreateProcess is called
      - return values are harvested in a tuple.
      - all return values from createProcess are passed back to the calling
        function except for the pid, the returned pid is hardcoded to 42
    """

    hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(
                      appName,
                      cmdline,
                      procSecurity,
                      threadSecurity,
                      inheritHandles,
                      newEnvironment,
                      env,
                      workingDir,
                      startupInfo)
    dwPid = 42
    return (hProcess, hThread, dwPid, dwTid) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:32,代码来源:mock_win32process.py

示例9: start

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def start(self, cmd):
        sAttr = win32security.SECURITY_ATTRIBUTES()
        sAttr.bInheritHandle = True

        stdout_r, stdout_w = win32pipe.CreatePipe(sAttr,0)
        stdin_r, stdin_w = win32pipe.CreatePipe(sAttr,0)
        self.read_handle=stdout_r
        self.write_handle=stdout_w
        self.stdin_write=stdin_w

        si = win32process.STARTUPINFO()
        si.dwFlags = win32process.STARTF_USESHOWWINDOW | win32process.STARTF_USESTDHANDLES
        si.wShowWindow = win32con.SW_HIDE
        si.hStdInput = stdin_r            # file descriptor of origin stdin
        si.hStdOutput = stdout_w
        si.hStdError = stdout_w
        hProcess, hThread, dwProcessID, dwThreadID = win32process.CreateProcess(None,"cmd", None, None, True, win32process.CREATE_NEW_CONSOLE, None, None, si)
        self.dwProcessID=dwProcessID
        self.hProcess=hProcess
        sleep(0.5)
        if self.hProcess == 0:
            DebugOutput("Start Process Fail:{:d}".format(win32api.GetLastError()))
        DebugOutput('[*] pid: {:x}'.format(self.dwProcessID))
        self.Console_hwnd = get_hwnds_for_pid(self.dwProcessID)
        if len(self.Console_hwnd)==0:
            raise Exception("Fail to run,No Process!")
        DebugOutput('[*] hwnd:{:x}'.format(self.Console_hwnd[0])) 
开发者ID:turingsec,项目名称:marsnake,代码行数:29,代码来源:winpty.py

示例10: launch_chrome

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def launch_chrome():
    global chrome
    if os.path.exists(chrome_path):
        command="\"{}\"--remote-debugging-port={}".format(chrome_path, port_chrome)
        print(u"如果Chrome白屏,请使用CMD手动运行以下命令:\n{}".format(command))
        chrome = win32process.CreateProcess(None, "{} --remote-debugging-port={}".format(chrome_path, port_chrome),None, None, 0, 0, None, None, win32process.STARTUPINFO())
    else:
        print(u"未找到Chrome安装目录")
        exit(-1) 
开发者ID:LiuChangFreeman,项目名称:perfect_video_downloader,代码行数:11,代码来源:main.py

示例11: jitInject

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import CreateProcess [as 别名]
def jitInject(path, shellcode):
	info = win32process.CreateProcess(None, path, None, None, False, 0x04, None, None, win32process.STARTUPINFO())  
	page_rwx_value = 0x40
	process_all = 0x1F0FFF
	memcommit = 0x00001000

	shellcode_length = len(shellcode)
	process_handle = info[0].handle # phandle

	VirtualAllocEx = windll.kernel32.VirtualAllocEx
	VirtualAllocEx.restype = LPVOID
	VirtualAllocEx.argtypes = (HANDLE, LPVOID, DWORD, DWORD, DWORD)

	WriteProcessMemory = ctypes.windll.kernel32.WriteProcessMemory
	WriteProcessMemory.restype = BOOL
	WriteProcessMemory.argtypes = (HANDLE, LPVOID, LPCVOID, DWORD, DWORD)

	CreateRemoteThread = ctypes.windll.kernel32.CreateRemoteThread
	CreateRemoteThread.restype = HANDLE
	CreateRemoteThread.argtypes = (HANDLE, LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, LPVOID, DWORD, DWORD)

	lpBuffer = VirtualAllocEx(process_handle, 0, shellcode_length, memcommit, page_rwx_value)
	print(hex(lpBuffer))
	WriteProcessMemory(process_handle, lpBuffer, shellcode, shellcode_length, 0)
	CreateRemoteThread(process_handle, None, 0, lpBuffer, 0, 0, 0)
	print('JIT Injection, done.')
# -------------------------------------------------- # 
开发者ID:aaaddress1,项目名称:shellDev.py,代码行数:29,代码来源:shellDev.py


注:本文中的win32process.CreateProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。