MCPcopy Create free account
hub / github.com/Atarity/Lightpack / getDxProcessesIDs

Function getDxProcessesIDs

Software/grab/WinUtils.cpp:70–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70QList<DWORD> * getDxProcessesIDs(QList<DWORD> * processes, LPCWSTR wstrSystemRootPath) {
71
72 DWORD aProcesses[1024];
73 HMODULE hMods[1024];
74 DWORD cbNeeded;
75 DWORD cProcesses;
76 char debug_buf[255];
77 WCHAR executableName[MAX_PATH];
78 unsigned int i;
79
80 // Get the list of process identifiers.
81 processes->clear();
82
83 if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
84 return NULL;
85
86 // Calculate how many process identifiers were returned.
87
88 cProcesses = cbNeeded / sizeof(DWORD);
89
90 // Print the names of the modules for each process.
91
92 for ( i = 0; i < cProcesses; i++ )
93 {
94 if (aProcesses[i] != GetCurrentProcessId()) {
95 HANDLE hProcess;
96 hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
97 PROCESS_VM_READ,
98 FALSE, aProcesses[i] );
99 if (NULL == hProcess)
100 goto nextProcess;
101
102 GetModuleFileNameExW(hProcess, 0, executableName, sizeof (executableName));
103
104 if (wcsstr(executableName, wstrSystemRootPath) != NULL) {
105 goto nextProcess;
106 }
107
108 PathStripPathW(executableName);
109
110 ::WideCharToMultiByte(CP_ACP, 0, executableName, -1, debug_buf, 255, NULL, NULL);
111 DEBUG_MID_LEVEL << Q_FUNC_INFO << debug_buf;
112
113 for (unsigned k=0; k < SIZEOF_ARRAY(pwstrExcludeProcesses); k++) {
114 if (wcsicmp(executableName, pwstrExcludeProcesses[k])== 0) {
115 DEBUG_MID_LEVEL << Q_FUNC_INFO << "skipping " << pwstrExcludeProcesses;
116 goto nextProcess;
117 }
118 }
119
120 // Get a list of all the modules in this process.
121
122 if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
123 {
124 bool isDXPresent = false;
125 for ( DWORD j = 0; j < (cbNeeded / sizeof(HMODULE)); j++ )
126 {
127 WCHAR szModName[MAX_PATH];

Callers 1

Calls 2

clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected