Debian Codegraph @

ProcessListWindows.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/ProcessListWindows.cpp`/include "ProcessListWindows.h"cxx . . $ `<file>/ProcessListWindows.h`/
2
3
4 #if defined(Q_OS_WIN)
5 typedef LONG (WINAPI *PROCNTQSIP)(HANDLE,UINT,PVOID,ULONG,PULONG);
6
7 PROCNTQSIP NtQueryInformationProcess;
8 #endif
9
10
11 #if defined(Q_OS_WIN)
12 BOOL ProcessListWindows::GetProcessCmdLine(DWORD dwId,LPWSTR wBuf,DWORD dwBufLen)
13 {
14 LONG status;
15 HANDLE hProcess;
16 PROCESS_BASIC_INFORMATION pbi;
17 PEB Peb;
18 PROCESS_PARAMETERS ProcParam;
19 SIZE_T dwDummy;
20 DWORD dwSize;
21 LPVOID lpAddress;
22 BOOL bRet = FALSE;
23
24 // Get process handle
25 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,dwId);
26 if (!hProcess)
27 return FALSE;
28
29 // Retrieve information
30 status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, (PVOID)&pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL);
31
32
33 if (status)
34 goto cleanup;
35
36 if ( !ReadProcessMemory(hProcess, pbi.PebBaseAddress, &Peb, sizeof(PEB), &dwDummy) )
37 goto cleanup;
38
39 if ( !ReadProcessMemory(hProcess, Peb.ProcessParameters, &ProcParam, sizeof(PROCESS_PARAMETERS), &dwDummy) )
40 goto cleanup;
41
42 lpAddress = ProcParam.CommandLine.Buffer;
43 dwSize = ProcParam.CommandLine.Length;
44
45 if (dwBufLen<dwSize)
46 goto cleanup;
47
48 if ( !ReadProcessMemory(hProcess, lpAddress, wBuf, dwSize, &dwDummy) )
49 goto cleanup;
50
51 bRet = TRUE;
52
53 cleanup:
54 CloseHandle (hProcess);
55
56 return bRet;
57 }
58
59 #endif
60
61 ProcessListWindowscxx . . $ ProcessListWindows#::ProcessListWindowscxx . . $ ProcessListWindows#ProcessListWindows(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent){
62
63 }
64
65 int ProcessListWindowscxx . . $ ProcessListWindows#::initProccessListcxx . . $ ProcessListWindows#initProccessList(b126dc7c1de90089).(){
66 return 1;
67 }
68
69 QStringcxx . . $ QString# ProcessListWindowscxx . . $ ProcessListWindows#::getProgramcxx . . $ ProcessListWindows#getProgram(f7f320d754b8fd09).(QStringcxx . . $ QString# pid){
70
71 int iPID = pid.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
72
73 #if defined(Q_OS_WIN)
74 HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, iPID);
75 if (hProcess==NULL) return "-";
76
77 WCHAR szFilePath[MAX_PATH] = {0};
78 GetModuleFileNameEx(hProcess, NULL, szFilePath, MAX_PATH);
79 CloseHandle(hProcess);
80 return QString::fromWCharArray(szFilePath);
81
82 #endif
83
84 return ""cxx . . $ QString#QString(85c52e162fed56f9).;
85
86 }
87
88
89 QStringcxx . . $ QString# ProcessListWindowscxx . . $ ProcessListWindows#::getCmdlinecxx . . $ ProcessListWindows#getCmdline(f7f320d754b8fd09).(QStringcxx . . $ QString# pid){
90 #if defined(Q_OS_WIN)
91 NtQueryInformationProcess = (PROCNTQSIP)GetProcAddress( GetModuleHandle((const WCHAR*)"NTDLL"), "NtQueryInformationProcess" );
92
93 if (!NtQueryInformationProcess) return "";
94
95 DWORD dwId;
96 sscanf(pid.toStdString().c_str(),"%lu",&dwId);
97
98 WCHAR wstr[255];
99
100 if (GetProcessCmdLine(dwId,wstr,sizeof(wstr))){
101 //wprintf(L"Command line for process %lu is:\n%s\n",dwId,wstr);
102 return QString::fromWCharArray(wstr);
103 }
104 //wprintf(L"Could not get command line!");
105 #endif
106
107 return ""cxx . . $ QString#QString(85c52e162fed56f9).;
108 }
109
110 QStringListcxx . . $ QStringList# ProcessListWindowscxx . . $ ProcessListWindows#::getSocketscxx . . $ ProcessListWindows#getSockets(327870d3b2cb3fa6).(QStringcxx . . $ QString# pid){
111 return QStringListcxx . . $ QStringList#QStringList(ced63f7c635d850d).();
112 }
113
114 sProccesscxx . . $ sProccess# ProcessListWindowscxx . . $ ProcessListWindows#::getProccxx . . $ ProcessListWindows#getProc(a30611555c524a2e).(QStringcxx . . $ QString# pid){
115 sProccesscxx . . $ sProccess# proc;
116 proc.pidcxx . . $ sProccess#pid.=cxx . . $ QString#`operator=`(b79fde0b0ce9b948).pid;
117 //proc.sockets=getSockets(pid);
118 proc.programcxx . . $ sProccess#program.=cxx . . $ QString#`operator=`(4f35bf974e7f8568).getProgramcxx . . $ ProcessListWindows#getProgram(f7f320d754b8fd09).(pidcxx . . $ QString#QString(132dd6869045752b).);
119 proc.cmdlinecxx . . $ sProccess#cmdline.=cxx . . $ QString#`operator=`(4f35bf974e7f8568).getCmdlinecxx . . $ ProcessListWindows#getCmdline(f7f320d754b8fd09).(pidcxx . . $ QString#QString(132dd6869045752b).);
120
121 return proc;
122 }