58     _In_opt_ PVOID Context
 
   63     _In_opt_ PVOID Context
 
   73 static RECT MinimumSize;
 
   76 static PPH_LIST ProcessesList = NULL;
 
   77 static ULONG NumberOfHiddenProcesses;
 
   78 static ULONG NumberOfTerminatedProcesses;
 
   88             L
"Hidden process detection cannot function properly without KProcessHacker. " 
   89             L
"Make sure Process Hacker is running with administrative privileges." 
  143             MinimumSize.left = 0;
 
  145             MinimumSize.right = 330;
 
  146             MinimumSize.bottom = 140;
 
  147             MapDialogRect(hwndDlg, &MinimumSize);
 
  164             ComboBox_AddString(GetDlgItem(hwndDlg, 
IDC_METHOD), L
"Brute Force");
 
  165             ComboBox_AddString(GetDlgItem(hwndDlg, 
IDC_METHOD), L
"CSR Handles");
 
  180             ShowWindow(hwndDlg, SW_HIDE);
 
  181             SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 0);
 
  186             switch (LOWORD(wParam))
 
  191                     SendMessage(hwndDlg, WM_CLOSE, 0, 0);
 
  206                         for (i = 0; i < ProcessesList->
Count; i++)
 
  227                     NumberOfHiddenProcesses = 0;
 
  228                     NumberOfTerminatedProcesses = 0;
 
  243                             NumberOfHiddenProcesses, NumberOfTerminatedProcesses)->Buffer
 
  249                         PhShowStatus(hwndDlg, L
"Unable to perform the scan", status, 0);
 
  256                     ULONG numberOfEntries;
 
  261                     if (numberOfEntries != 0)
 
  267                             L
"the selected process(es)",
 
  268                             L
"Terminating a hidden process may cause the system to become unstable " 
  274                             HANDLE processHandle;
 
  279                             for (i = 0; i < numberOfEntries; i++)
 
  301                                     NtClose(processHandle);
 
  308                                     PhShowStatus(hwndDlg, L
"Unable to terminate the process", status, 0);
 
  314                                 LARGE_INTEGER interval;
 
  319                                 NtDelayExecution(
FALSE, &interval);
 
  320                                 SendMessage(hwndDlg, WM_COMMAND, 
IDC_SCAN, 0);
 
  332                         { L
"Text files (*.txt)", L
"*.txt" },
 
  333                         { L
"All files (*.*)", L
"*.*" }
 
  367                                 L
"Hidden: %u\r\nTerminated: %u\r\n\r\n",
 
  368                                 NumberOfHiddenProcesses,
 
  369                                 NumberOfTerminatedProcesses
 
  376                                 for (i = 0; i < ProcessesList->
Count; i++)
 
  400                             PhShowStatus(hwndDlg, L
"Unable to create the file", status, 0);
 
  411             LPNMHDR header = (LPNMHDR)lParam;
 
  415             switch (header->code)
 
  417             case LVN_ITEMCHANGED:
 
  447                                 PhShowError(hwndDlg, L
"Unable to create a process structure for the selected process.");
 
  466     case WM_CTLCOLORSTATIC:
 
  470                 if (NumberOfHiddenProcesses != 0)
 
  472                     SetTextColor((HDC)wParam, RGB(0xff, 0x00, 0x00));
 
  475                 SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE));
 
  477                 return (INT_PTR)GetSysColorBrush(COLOR_3DFACE);
 
  491     _In_opt_ PVOID Context
 
  500         return RGB(0xff, 0x00, 0x00);
 
  502         return RGB(0x77, 0x77, 0x77);
 
  505     return GetSysColor(COLOR_WINDOW);
 
  510     _In_opt_ PVOID Context
 
  530         NumberOfHiddenProcesses++;
 
  532         NumberOfTerminatedProcesses++;
 
  544     HANDLE processHandle;
 
  545     PROCESS_BASIC_INFORMATION basicInfo;
 
  546     KERNEL_USER_TIMES times;
 
  549     HANDLE processHandle2;
 
  628             processItem->
UserTime = times.UserTime;
 
  635             ProcessPriorityClass,
 
  705         BOOLEAN isPosix = 
FALSE;
 
  710         processItem->
IsPosix = isPosix;
 
  721                 for (i = 0; i < (ULONG)commandLine->
Length / 2; i++)
 
  723                     if (commandLine->
Buffer[i] == 0)
 
  724                         commandLine->
Buffer[i] = 
' ';
 
  739         NtClose(processHandle2);
 
  751     _In_opt_ PVOID Context
 
  759     BOOLEAN stop = 
FALSE;
 
  775     for (pid = 8; pid <= 65536; pid += 4)
 
  778         HANDLE processHandle;
 
  780         KERNEL_USER_TIMES times;
 
  805                 if (times.ExitTime.QuadPart != 0)
 
  807                 else if (PhFindItemList(pids, (HANDLE)pid) != -1)
 
  812                 if (!Callback(&entry, Context))
 
  818             NtClose(processHandle);
 
  830                 if (PhFindItemList(pids, (HANDLE)pid) != -1)
 
  835                 if (!Callback(&entry, Context))
 
  842         if (status2 == STATUS_INVALID_CID || status2 == STATUS_INVALID_PARAMETER)
 
  843             status2 = STATUS_SUCCESS;
 
  851             if (!Callback(&entry, Context))
 
  864 typedef struct _CSR_HANDLES_CONTEXT
 
  871 static BOOLEAN NTAPI PhpCsrProcessHandlesCallback(
 
  873     _In_opt_ PVOID Context
 
  879     HANDLE processHandle;
 
  880     KERNEL_USER_TIMES times;
 
  904             if (times.ExitTime.QuadPart != 0)
 
  906             else if (PhFindItemList(context->Pids, Handle->ProcessId) != -1)
 
  911             if (!context->Callback(&entry, context->Context))
 
  917         NtClose(processHandle);
 
  925         if (!context->Callback(&entry, context->Context))
 
  934     _In_opt_ PVOID Context
 
  957     context.Callback = Callback;
 
  958     context.Context = Context;
 
  971     _In_opt_ PVOID Context
 
  991     _Out_ PHANDLE *ProcessHandles,
 
  992     _Out_ PULONG NumberOfProcessHandles
 
 1009         HANDLE processHandle;
 
 1028                 NtClose(processHandle);
 
 1036     *NumberOfProcessHandles = processHandleList->
Count;
 
 1048     PROCESS_BASIC_INFORMATION processBasicInfo;
 
 1051     Handle->IsThreadHandle = 
FALSE;
 
 1052     Handle->ProcessId = NULL;
 
 1058         Handle->CsrProcessHandle,
 
 1062         sizeof(PROCESS_BASIC_INFORMATION),
 
 1068         Handle->ProcessId = processBasicInfo.UniqueProcessId;
 
 1076             Handle->CsrProcessHandle,
 
 1087             Handle->IsThreadHandle = 
TRUE;
 
 1096     _In_opt_ PVOID Context
 
 1100     PHANDLE csrProcessHandles;
 
 1101     ULONG numberOfCsrProcessHandles;
 
 1103     BOOLEAN stop = 
FALSE;
 
 1108         &numberOfCsrProcessHandles
 
 1114     for (i = 0; i < numberOfCsrProcessHandles; i++)
 
 1138                 if (PhFindItemList(pids, handle.
ProcessId) != -1)
 
 1143                 if (!Callback(&handle, Context))
 
 1156     for (i = 0; i < numberOfCsrProcessHandles; i++)
 
 1157         NtClose(csrProcessHandles[i]);
 
 1159     PhFree(csrProcessHandles);
 
 1165     _Out_ PHANDLE ProcessHandle,
 
 1166     _In_ ACCESS_MASK DesiredAccess,
 
 1172     if (!Handle->IsThreadHandle)
 
 1175             Handle->CsrProcessHandle,
 
 1186         HANDLE threadHandle;
 
 1189             Handle->CsrProcessHandle,
 
 1204         NtClose(threadHandle);
 
 1210 typedef struct _OPEN_PROCESS_BY_CSR_CONTEXT
 
 1213     PHANDLE ProcessHandle;
 
 1214     ACCESS_MASK DesiredAccess;
 
 1218 static BOOLEAN NTAPI PhpOpenProcessByCsrHandlesCallback(
 
 1220     _In_opt_ PVOID Context
 
 1223     POPEN_PROCESS_BY_CSR_CONTEXT context = Context;
 
 1225     if (Handle->ProcessId == context->ProcessId)
 
 1228             context->ProcessHandle,
 
 1229             context->DesiredAccess,
 
 1240     _Out_ PHANDLE ProcessHandle,
 
 1241     _In_ ACCESS_MASK DesiredAccess,
 
 1248     context.Status = STATUS_INVALID_CID;
 
 1249     context.ProcessHandle = ProcessHandle;
 
 1250     context.DesiredAccess = DesiredAccess;
 
 1254         PhpOpenProcessByCsrHandlesCallback,
 
 1259     return context.Status;