def __init__(self, pid): ph = win32api.OpenProcess( win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, 0, pid) token = win32security.OpenProcessToken(ph, win32con.TOKEN_QUERY) sid, attr = win32security.GetTokenInformation(token, ntsecuritycon.TokenUser) (username, proc_domain, proc_type) = win32security.LookupAccountSid(None, sid) exes = [] modules = [] for module in win32process.EnumProcessModules(ph): fn = win32process.GetModuleFileNameEx(ph, module) if win_exec_re.search(fn): exes.append(fn) else: modules.append(fn) # gross but...eh if not exes: nondll = [] for mod in modules: if not win_dll_re.search(mod): nondll.append(mod) if nondll: exes.append(nondll[0]) super(WindowsProcess, self).__init__(pid, string.join(exes, ' '), username)
def __init__(self, pid): ph = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_VM_READ,0,pid) token = win32security.OpenProcessToken(ph, win32con.TOKEN_QUERY) sid,attr = win32security.GetTokenInformation(token, ntsecuritycon.TokenUser) (username, proc_domain, proc_type) = win32security.LookupAccountSid(None, sid) exes = [] modules = [] for module in win32process.EnumProcessModules(ph): fn = win32process.GetModuleFileNameEx(ph, module) if win_exec_re.search(fn): exes.append(fn) else: modules.append(fn) # gross but...eh if not exes: nondll = [] for mod in modules: if not win_dll_re.search(mod): nondll.append(mod) if nondll: exes.append(nondll[0]) super(WindowsProcess, self).__init__(pid, string.join(exes, ' '), username)
def _do_get_xaccess(self): super(Win32File, self)._do_get_xaccess() self.xaccess = self.xaccess and win_exec_re.search(self.path)