예제 #1
0
    def process(self):
        """The process possessing the handle

        :type: :class:`WinProcess <windows.winobject.process.WinProcess>`"""
        # "TODO: something smart ? :D"
        # return [p for p in windows.system.processes if p.pid == self.dwProcessId][0]
        return windows.WinProcess(pid=self.dwProcessId)
예제 #2
0
    def process(self):
        """The process running the service (if any)

        :type: :class:`WinProcess <windows.winobject.process.WinProcess>` or ``None``
        """
        pid = self.ServiceStatusProcess.dwProcessId
        if not pid:
            return None
        l = windows.WinProcess(pid=pid)
        return l
예제 #3
0
def test_exec_method_Win32_Process_create(cmdline):
    namespace = wmimanager["root\\cimv2"]
    win32_process_cls = namespace.get_object("Win32_Process")
    inparam = win32_process_cls.get_method("Create").inparam.spawn_instance()
    inparam["CommandLine"] = cmdline
    result = namespace.exec_method(win32_process_cls, "Create", inparam)
    assert result
    assert not result["ReturnValue"]
    assert result["ProcessId"]
    proc = windows.WinProcess(pid=result["ProcessId"])
    assert proc.peb.commandline.str == cmdline
    proc.exit(0)
예제 #4
0
import windows

wmispace = windows.system.wmi["root\\cimv2"]
print("WMI namespace is <{0}>".format(wmispace))
proc_class = wmispace.get_object("Win32_process")
print("Process class is {0}".format(proc_class))

inparam_cls = proc_class.get_method("Create").inparam
print("Method Create InParams is <{0}>".format(inparam_cls))
print("Method Create InParams properties are <{0}>".format(
    inparam_cls.properties))
print("Creating instance of inparam")

inparam = inparam_cls()
print("InParam instance is <{0}>".format(inparam))
print("Setting <CommandLine>")
inparam["CommandLine"] = r"c:\windows\system32\notepad.exe"

print("Executing method")
# This API may change for something that better wraps cls/object/Parameters handling
outparam = wmispace.exec_method(proc_class, "Create", inparam)

print("OutParams is {0}".format(outparam))
print("Out params values are: {0}".format(outparam.properties))
target = windows.WinProcess(pid=int(outparam["ProcessId"]))
print("Created process is {0}".format(target))
print("Waiting 1s")
time.sleep(1)
print("Killing the process")
target.exit(0)
예제 #5
0
 def description_Process(self):
     proc = windows.WinProcess(handle=self.wValue)
     res = str(proc)
     del proc._handle
     return res