INNER CODE UNIT · Python
PROCESSENTRY32
Qwejay/Qflow · main.py:261
class PROCESSENTRY32(ctypes.Structure):
_fields_ = [("dwSize", ctypes.c_ulong), ("cntUsage", ctypes.c_ulong), ("th32ProcessID", ctypes.c_ulong), ("th32DefaultHeapID", ctypes.c_ulong), ("th32ModuleID", ctypes.c_ulong), ("cntThreads", ctypes.c_ulong), ("th32ParentProcessID", ctypes.c_ulong), ("pcPriClassBase", ctypes.c_long), ("dwFlags", ctypes.c_ulong), ("szExeFile", ctypes.c_char * 260)]
@staticmethod
def _get_process_map():
pid_map = {}
hSnap = ctypes.windll.kernel32.CreateToolhelp32Snapshot(WindowEngine.TH32CS_SNAPPROCESS, 0)
if hSnap == -1: return pid_map
try:
pe32 = WindowEngine.PROCESSENTRY32()
pe32.dwSize = ctypes.sizeof(WindowEngine.PROCESSENTRY32)
if ctypes.windll.kernel32.Process32First(hSnap, ctypes.byref(pe32)):
while True:
try: exe_name = pe32.szExeFile.decode('gbk', 'ignore')
except: exe_name = pe32.szExeFile.decode('utf-8', 'ignore')
pid_map[pe32.th32ProcessID] = exe_name
if not ctypes.windll.kernel32.Process32Next(hSnap, ctypes.byref(pe32)): break
finally: