23 #define PH_MAINWND_PRIVATE
43 #define RUNAS_MODE_ADMIN 1
44 #define RUNAS_MODE_LIMITED 2
57 static BOOLEAN NeedsMaximize =
FALSE;
58 static ULONG NeedsSelectPid = 0;
59 static BOOLEAN AlwaysOnTop =
FALSE;
61 static BOOLEAN DelayedLoadCompleted =
FALSE;
62 static ULONG NotifyIconNotifyMask;
65 static RECT LayoutPadding = { 0, 0, 0, 0 };
66 static BOOLEAN LayoutPaddingValid =
TRUE;
67 static HWND TabControlHandle;
68 static INT ProcessesTabIndex;
69 static INT ServicesTabIndex;
70 static INT NetworkTabIndex;
71 static INT MaxTabIndex;
72 static INT OldTabIndex;
73 static PPH_LIST AdditionalTabPageList = NULL;
74 static HWND ProcessTreeListHandle;
75 static HWND ServiceTreeListHandle;
76 static HWND NetworkTreeListHandle;
77 static HFONT CurrentCustomFont;
79 static BOOLEAN NetworkFirstTime =
TRUE;
80 static BOOLEAN ServiceTreeListLoaded =
FALSE;
81 static BOOLEAN NetworkTreeListLoaded =
FALSE;
82 static HMENU SubMenuHandles[5];
84 static PPH_LIST LegacyAddMenuItemList;
85 static BOOLEAN UsersMenuInitialized =
FALSE;
86 static BOOLEAN UpdateAutomatically =
TRUE;
95 static BOOLEAN ProcessesNeedsRedraw =
FALSE;
104 static BOOLEAN ServicesNeedsRedraw =
FALSE;
111 static BOOLEAN NetworkNeedsRedraw =
FALSE;
113 static ULONG SelectedRunAsMode;
114 static HWND SelectedProcessWindowHandle;
115 static BOOLEAN SelectedProcessVirtualizationEnabled;
116 static ULONG SelectedUserSessionId;
124 static ULONG LastNotificationType;
129 } LastNotificationDetails;
187 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
188 windowRectangle.
Left,
190 windowRectangle.
Width,
241 ShowCommand = SW_HIDE;
243 ShowCommand = SW_SHOW;
247 if (ShowCommand != SW_HIDE)
249 ShowCommand = SW_MAXIMIZE;
254 NeedsMaximize =
TRUE;
271 if (ShowCommand != SW_HIDE)
299 case WM_SETTINGCHANGE:
316 if (
PhMwpOnSysCommand((ULONG)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
325 case WM_INITMENUPOPUP:
358 case WM_WTSSESSION_CHANGE:
370 return DefWindowProc(hWnd, uMsg, wParam, lParam);
379 memset(&wcex, 0,
sizeof(WNDCLASSEX));
380 wcex.cbSize =
sizeof(WNDCLASSEX);
387 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
393 if (!RegisterClassEx(&wcex))
442 TabControlHandle = CreateWindow(
445 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TCS_MULTILINE,
456 BringWindowToTop(TabControlHandle);
460 MaxTabIndex = NetworkTabIndex;
464 ProcessTreeListHandle = CreateWindow(
477 BringWindowToTop(ProcessTreeListHandle);
479 ServiceTreeListHandle = CreateWindow(
492 BringWindowToTop(ServiceTreeListHandle);
494 NetworkTreeListHandle = CreateWindow(
507 BringWindowToTop(NetworkTreeListHandle);
522 &ProcessAddedRegistration
528 &ProcessModifiedRegistration
534 &ProcessRemovedRegistration
540 &ProcessesUpdatedRegistration
547 &ServiceAddedRegistration
553 &ServiceModifiedRegistration
559 &ServiceRemovedRegistration
565 &ServicesUpdatedRegistration
572 &NetworkItemAddedRegistration
578 &NetworkItemModifiedRegistration
584 &NetworkItemRemovedRegistration
590 &NetworkItemsUpdatedRegistration
604 SetProcessShutdownParameters(0x100, 0);
606 DelayedLoadCompleted =
TRUE;
609 return STATUS_SUCCESS;
623 { CSIDL_PROGRAM_FILESX86, L
"\\Windows Kits\\10\\Debuggers\\x64\\dbghelp.dll" },
624 { CSIDL_PROGRAM_FILESX86, L
"\\Windows Kits\\8.1\\Debuggers\\x64\\dbghelp.dll" },
625 { CSIDL_PROGRAM_FILESX86, L
"\\Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" },
626 { CSIDL_PROGRAM_FILES, L
"\\Debugging Tools for Windows (x64)\\dbghelp.dll" }
628 { CSIDL_PROGRAM_FILES, L
"\\Windows Kits\\10\\Debuggers\\x86\\dbghelp.dll" },
629 { CSIDL_PROGRAM_FILES, L
"\\Windows Kits\\8.1\\Debuggers\\x86\\dbghelp.dll" },
630 { CSIDL_PROGRAM_FILES, L
"\\Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" },
631 { CSIDL_PROGRAM_FILES, L
"\\Debugging Tools for Windows (x86)\\dbghelp.dll" }
638 for (i = 0; i <
sizeof(locations) /
sizeof(locations[0]); i++)
713 SelectedRunAsMode = 0;
728 L
"Type the name of a program that will be opened under alternate credentials.",
744 L
"Type the name of a program that will be opened under standard user privileges.",
781 { L
"Text files (*.txt;*.log)", L
"*.txt;*.log" },
782 { L
"Comma-separated values (*.csv)", L
"*.csv" },
783 { L
"All files (*.*)", L
"*.*" }
786 ULONG selectedTab = TabCtrl_GetCurSel(TabControlHandle);
787 PWSTR tabText = L
"Output";
790 if (selectedTab == ProcessesTabIndex)
792 tabText = L
"Processes";
794 else if (selectedTab == ServicesTabIndex)
796 tabText = L
"Services";
798 else if (selectedTab == NetworkTabIndex)
800 tabText = L
"Network";
802 else if (AdditionalTabPageList)
806 for (i = 0; i < AdditionalTabPageList->
Count; i++)
810 if (tabPage->
Index == selectedTab)
812 selectedTabPage = tabPage;
813 tabText = selectedTabPage->
Text;
844 if (filterIndex == 2)
852 if (selectedTab == ProcessesTabIndex)
856 else if (selectedTab == ServicesTabIndex)
860 else if (selectedTab == NetworkTabIndex)
864 else if (selectedTabPage)
945 if (!CurrentUserFilterEntry)
952 CurrentUserFilterEntry = NULL;
962 if (!SignedFilterEntry)
968 L
"This filter cannot function because digital signature checking is not enabled. "
969 L
"Enable it in Options > Advanced and restart Process Hacker."
978 SignedFilterEntry = NULL;
999 if (!DriverFilterEntry)
1006 DriverFilterEntry = NULL;
1016 AlwaysOnTop = !AlwaysOnTop;
1017 SetWindowPos(
PhMainWndHandle, AlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
1018 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1079 UpdateAutomatically = !UpdateAutomatically;
1084 if (TabCtrl_GetCurSel(TabControlHandle) == NetworkTabIndex)
1102 { L
"Executable files (*.exe;*.dll;*.ocx;*.sys;*.scr;*.cpl)", L
"*.exe;*.dll;*.ocx;*.sys;*.scr;*.cpl" },
1103 { L
"All files (*.*)", L
"*.*" }
1116 L
"ProgramInspectExecutables",
1119 L
"Make sure the PE Viewer executable file is present."
1210 ULONG numberOfProcesses;
1240 ULONG numberOfProcesses;
1252 ULONG numberOfProcesses;
1310 !SelectedProcessVirtualizationEnabled
1404 ULONG numberOfProcesses;
1417 if (processItem && processItem->
FileName)
1456 ULONG numberOfProcesses;
1471 ULONG numberOfProcesses;
1482 if (IsWindow(SelectedProcessWindowHandle))
1484 WINDOWPLACEMENT placement = {
sizeof(placement) };
1486 GetWindowPlacement(SelectedProcessWindowHandle, &placement);
1488 if (placement.showCmd == SW_MINIMIZE)
1489 ShowWindowAsync(SelectedProcessWindowHandle, SW_RESTORE);
1491 SetForegroundWindow(SelectedProcessWindowHandle);
1497 if (IsWindow(SelectedProcessWindowHandle))
1499 ShowWindowAsync(SelectedProcessWindowHandle, SW_RESTORE);
1505 if (IsWindow(SelectedProcessWindowHandle))
1507 ShowWindowAsync(SelectedProcessWindowHandle, SW_MINIMIZE);
1513 if (IsWindow(SelectedProcessWindowHandle))
1515 ShowWindowAsync(SelectedProcessWindowHandle, SW_MAXIMIZE);
1521 if (IsWindow(SelectedProcessWindowHandle))
1523 PostMessage(SelectedProcessWindowHandle, WM_CLOSE, 0, 0);
1531 if (processItem && processItem->
FileName)
1575 SetFocus(ProcessTreeListHandle);
1660 &serviceKeyName->
sr,
1680 SC_HANDLE serviceHandle;
1692 CloseServiceHandle(serviceHandle);
1725 SetFocus(ProcessTreeListHandle);
1736 if (networkItem && networkItem->
OwnerName)
1741 SetFocus(ServiceTreeListHandle);
1764 ULONG numberOfNetworkItems;
1783 ULONG selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
1785 if (selectedIndex != MaxTabIndex)
1795 ULONG selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
1797 if (selectedIndex != 0)
1800 selectedIndex = MaxTabIndex;
1809 _In_ BOOLEAN Showing,
1816 NeedsMaximize =
FALSE;
1822 _In_
LONG CursorScreenX,
1823 _In_
LONG CursorScreenY
1860 MENUITEMINFO menuItemInfo;
1862 menuItemInfo.cbSize =
sizeof(MENUITEMINFO);
1863 menuItemInfo.fMask = MIIM_ID | MIIM_DATA;
1865 if (GetMenuItemInfo(Menu, Index,
TRUE, &menuItemInfo))
1874 _In_ BOOLEAN IsWindowMenu
1884 for (i = 0; i <
sizeof(SubMenuHandles) /
sizeof(HWND); i++)
1886 if (Menu == SubMenuHandles[i])
1899 if (!UsersMenuInitialized)
1902 UsersMenuInitialized =
TRUE;
1909 while (DeleteMenu(Menu, 0, MF_BYPOSITION)) ;
1912 if (SubMenuObjects[Index])
1916 memset(&menuInfo, 0,
sizeof(MENUINFO));
1917 menuInfo.cbSize =
sizeof(MENUINFO);
1918 menuInfo.fMask = MIM_STYLE;
1919 menuInfo.dwStyle = MNS_CHECKORBMP;
1920 SetMenuInfo(Menu, &menuInfo);
1932 menuInfo.
u.
MainMenu.SubMenuIndex = Index;
1937 SubMenuObjects[Index] = menu;
1948 deferHandle = BeginDeferWindowPos(2);
1950 EndDeferWindowPos(deferHandle);
1956 _In_ PRECT DragRectangle
1966 INT selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
1968 if (selectedIndex == ProcessesTabIndex)
1969 SetFocus(ProcessTreeListHandle);
1970 else if (selectedIndex == ServicesTabIndex)
1971 SetFocus(ServiceTreeListHandle);
1972 else if (selectedIndex == NetworkTabIndex)
1973 SetFocus(NetworkTreeListHandle);
1982 static ULONG state = 1;
2020 _Out_ LRESULT *Result
2023 if (Header->hwndFrom == TabControlHandle)
2066 HANDLE newTokenHandle;
2070 TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_QUERY | TOKEN_ADJUST_GROUPS |
2071 TOKEN_ADJUST_DEFAULT | READ_CONTROL | WRITE_DAC,
2091 NtClose(newTokenHandle);
2094 NtClose(tokenHandle);
2116 _In_ ULONG SessionId
2119 if (Reason == WTS_SESSION_LOGON || Reason == WTS_SESSION_LOGOFF)
2121 if (UsersMenuInitialized)
2130 _In_ ULONG_PTR WParam,
2131 _In_ ULONG_PTR LParam
2217 showMemoryEditor->
Title,
2218 showMemoryEditor->
Flags
2221 PhFree(showMemoryEditor);
2237 PhFree(showMemoryResults);
2242 ULONG index = (ULONG)WParam;
2246 if (index == ProcessesTabIndex)
2247 SetFocus(ProcessTreeListHandle);
2248 else if (index == ServicesTabIndex)
2249 SetFocus(ServiceTreeListHandle);
2250 else if (index == NetworkTabIndex)
2251 SetFocus(NetworkTreeListHandle);
2256 return (ULONG_PTR)&LayoutPaddingCallback;
2261 LayoutPaddingValid =
FALSE;
2303 fontHexString->
Length / 2 / 2 ==
sizeof(LOGFONT) &&
2309 newFont = CreateFontIndirect(&font);
2313 if (CurrentCustomFont)
2314 DeleteObject(CurrentCustomFont);
2316 CurrentCustomFont = newFont;
2318 SendMessage(ProcessTreeListHandle, WM_SETFONT, (WPARAM)newFont,
TRUE);
2319 SendMessage(ServiceTreeListHandle, WM_SETFONT, (WPARAM)newFont,
TRUE);
2320 SendMessage(NetworkTreeListHandle, WM_SETFONT, (WPARAM)newFont,
TRUE);
2322 if (AdditionalTabPageList)
2326 for (i = 0; i < AdditionalTabPageList->
Count; i++)
2343 return SendMessage(ProcessTreeListHandle, WM_GETFONT, 0, 0);
2346 VOID (NTAPI *
function)(PVOID);
2348 function = (PVOID)LParam;
2349 function((PVOID)WParam);
2371 return UpdateAutomatically;
2376 if (!!WParam != UpdateAutomatically)
2389 ULONG runId = (ULONG)WParam;
2412 ULONG runId = (ULONG)WParam;
2423 PhFree(serviceModifiedData);
2438 ULONG runId = (ULONG)WParam;
2465 _In_opt_ PVOID Parameter,
2466 _In_opt_ PVOID Context
2483 _In_opt_ PVOID Parameter,
2484 _In_opt_ PVOID Context
2493 _In_opt_ PVOID Parameter,
2494 _In_opt_ PVOID Context
2505 _In_opt_ PVOID Parameter,
2506 _In_opt_ PVOID Context
2513 _In_opt_ PVOID Parameter,
2514 _In_opt_ PVOID Context
2529 _In_opt_ PVOID Parameter,
2530 _In_opt_ PVOID Context
2542 _In_opt_ PVOID Parameter,
2543 _In_opt_ PVOID Context
2552 _In_opt_ PVOID Parameter,
2553 _In_opt_ PVOID Context
2560 _In_opt_ PVOID Parameter,
2561 _In_opt_ PVOID Context
2576 _In_opt_ PVOID Parameter,
2577 _In_opt_ PVOID Context
2586 _In_opt_ PVOID Parameter,
2587 _In_opt_ PVOID Context
2596 _In_opt_ PVOID Parameter,
2597 _In_opt_ PVOID Context
2614 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE);
2645 if (customFont->
Length / 2 / 2 ==
sizeof(LOGFONT))
2659 if (ServiceTreeListLoaded)
2661 if (NetworkTreeListLoaded)
2680 WINDOWPLACEMENT placement = {
sizeof(placement) };
2684 if (placement.showCmd == SW_NORMAL)
2686 else if (placement.showCmd == SW_MAXIMIZE)
2691 _In_ PWSTR DbgHelpPath
2694 HMODULE dbghelpModule;
2696 if (dbghelpModule = LoadLibrary(DbgHelpPath))
2699 ULONG indexOfFileName;
2705 if (fullDbghelpPath)
2707 if (indexOfFileName != 0)
2712 dbghelpFolder.
Length = indexOfFileName *
sizeof(WCHAR);
2715 LoadLibrary(symsrvPath->Buffer);
2724 dbghelpModule = LoadLibrary(L
"dbghelp.dll");
2731 _In_opt_ PVOID Parameter,
2732 _In_opt_ PVOID Context
2759 Rect->left += Padding->left;
2760 Rect->top += Padding->top;
2761 Rect->right -= Padding->right;
2762 Rect->bottom -= Padding->bottom;
2766 _Inout_ HDWP *DeferHandle
2774 if (!LayoutPaddingValid)
2777 LayoutPaddingValid =
TRUE;
2783 SetWindowPos(TabControlHandle, NULL,
2784 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
2785 SWP_NOACTIVATE | SWP_NOZORDER);
2786 UpdateWindow(TabControlHandle);
2871 menuInfo.cbSize =
sizeof(MENUINFO);
2872 menuInfo.fMask = MIM_STYLE;
2873 menuInfo.dwStyle = MNS_NOTIFYBYPOS;
2874 SetMenuInfo(Menu, &menuInfo);
2876 for (i = 0; i <
sizeof(SubMenuHandles) /
sizeof(HMENU); i++)
2883 _In_ HMENU MenuHandle,
2884 _In_ ULONG ItemIndex,
2886 _In_ ULONG_PTR ItemData
2931 SelectedUserSessionId = (ULONG)ItemData;
2946 if (!LegacyAddMenuItemList)
2954 pluginMenuItem->
Plugin = AddMenuItem->Plugin;
2955 pluginMenuItem->
Id = AddMenuItem->Id;
2956 pluginMenuItem->
Context = AddMenuItem->Context;
2958 addMenuItem->
Context = pluginMenuItem;
2967 static HBITMAP shieldBitmap = NULL;
2972 HICON shieldIcon = NULL;
2981 if (SUCCEEDED(loadIconMetric(NULL, IDI_SHIELD, LIM_SMALL, &shieldIcon)))
2984 DestroyIcon(shieldIcon);
2989 return shieldBitmap;
3011 HBITMAP shieldBitmap;
3016 menuItem->
Bitmap = shieldBitmap;
3023 else if (Index == 1)
3029 ULONG placeholderIndex;
3033 if (trayIconsMenuItem)
3043 for (;
id != maximum;
id <<= 1)
3053 for (i = 0; i < trayIconsMenuItem->
Items->
Count; i++)
3055 menuItem = trayIconsMenuItem->
Items->
Items[i];
3060 switch (menuItem->
Id)
3142 else if (Index == 2)
3152 HBITMAP shieldBitmap;
3157 menuItem->
Bitmap = shieldBitmap;
3162 if (LegacyAddMenuItemList)
3167 for (i = 0; i < LegacyAddMenuItemList->
Count; i++)
3169 addMenuItem = LegacyAddMenuItemList->
Items[i];
3171 if (addMenuItem->
Location == Index)
3177 for (insertIndex = 0; insertIndex < Menu->Items->Count; insertIndex++)
3198 if (addMenuItem->
Text[0] ==
'-' && addMenuItem->
Text[1] == 0)
3214 for (i = 0; i < Menu->Items->Count; i++)
3227 _In_ ULONG StartIndex
3233 selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
3235 if (selectedIndex == ProcessesTabIndex)
3262 else if (selectedIndex == ServicesTabIndex)
3269 else if (selectedIndex == NetworkTabIndex)
3284 else if (AdditionalTabPageList)
3288 for (i = 0; i < AdditionalTabPageList->
Count; i++)
3292 if (selectedIndex == tabPage->
Index)
3311 _Inout_ HDWP *DeferHandle
3317 if (!LayoutPaddingValid)
3320 LayoutPaddingValid =
TRUE;
3325 TabCtrl_AdjustRect(TabControlHandle,
FALSE, &rect);
3327 selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
3329 if (selectedIndex == ProcessesTabIndex)
3331 *DeferHandle = DeferWindowPos(*DeferHandle, ProcessTreeListHandle, NULL,
3332 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
3333 SWP_NOACTIVATE | SWP_NOZORDER);
3335 else if (selectedIndex == ServicesTabIndex)
3337 *DeferHandle = DeferWindowPos(*DeferHandle, ServiceTreeListHandle, NULL,
3338 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
3339 SWP_NOACTIVATE | SWP_NOZORDER);
3341 else if (selectedIndex == NetworkTabIndex)
3343 *DeferHandle = DeferWindowPos(*DeferHandle, NetworkTreeListHandle, NULL,
3344 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
3345 SWP_NOACTIVATE | SWP_NOZORDER);
3347 else if (AdditionalTabPageList)
3351 for (i = 0; i < AdditionalTabPageList->
Count; i++)
3355 if (selectedIndex == tabPage->
Index)
3369 *DeferHandle = DeferWindowPos(*DeferHandle, tabPage->
WindowHandle, NULL,
3370 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
3371 SWP_NOACTIVATE | SWP_NOZORDER);
3384 if (Header->code == TCN_SELCHANGING)
3386 OldTabIndex = TabCtrl_GetCurSel(TabControlHandle);
3388 else if (Header->code == TCN_SELCHANGE)
3401 selectedIndex = TabCtrl_GetCurSel(TabControlHandle);
3403 deferHandle = BeginDeferWindowPos(1);
3405 EndDeferWindowPos(deferHandle);
3409 if (selectedIndex == ServicesTabIndex)
3412 if (selectedIndex == NetworkTabIndex)
3418 if (UpdateAutomatically || NetworkFirstTime)
3421 NetworkFirstTime =
FALSE;
3429 ShowWindow(ProcessTreeListHandle, selectedIndex == ProcessesTabIndex ? SW_SHOW : SW_HIDE);
3430 ShowWindow(ServiceTreeListHandle, selectedIndex == ServicesTabIndex ? SW_SHOW : SW_HIDE);
3431 ShowWindow(NetworkTreeListHandle, selectedIndex == NetworkTabIndex ? SW_SHOW : SW_HIDE);
3435 if (AdditionalTabPageList)
3439 for (i = 0; i < AdditionalTabPageList->
Count; i++)
3445 if (tabPage->
Index == OldIndex)
3449 else if (tabPage->
Index == selectedIndex)
3455 ShowWindow(tabPage->
WindowHandle, selectedIndex == tabPage->
Index ? SW_SHOW : SW_HIDE);
3470 if (!AdditionalTabPageList)
3477 MaxTabIndex = newTabPage->
Index;
3483 deferHandle = BeginDeferWindowPos(1);
3485 EndDeferWindowPos(deferHandle);
3496 oldIndex = TabCtrl_GetCurSel(TabControlHandle);
3497 TabCtrl_SetCurSel(TabControlHandle, Index);
3507 return ProcessesTabIndex;
3511 return ServicesTabIndex;
3515 return NetworkTabIndex;
3517 else if (AdditionalTabPageList)
3521 for (i = 0; i < AdditionalTabPageList->
Count; i++)
3526 return tabPage->
Index;
3533 static int __cdecl IconProcessesCpuUsageCompare(
3534 _In_
const void *elem1,
3535 _In_
const void *elem2
3544 static int __cdecl IconProcessesNameCompare(
3545 _In_
const void *elem1,
3546 _In_
const void *elem2
3563 BOOLEAN isSuspended =
FALSE;
3564 BOOLEAN isPartiallySuspended =
TRUE;
3602 if (isPartiallySuspended)
3619 switch (MenuItem->Id)
3626 HANDLE processId = MenuItem->Context;
3631 switch (MenuItem->Id)
3662 HANDLE processId = MenuItem->Context;
3681 HANDLE processId = MenuItem->Context;
3702 _In_ ULONG NumberOfProcesses
3707 ULONG numberOfProcessItems;
3716 for (i = 0; i < processList->
Count; i++)
3718 processItem = processList->
Items[i];
3728 for (i = 0; i < processList->
Count && processList->
Count > NumberOfProcesses; i++)
3730 processItem = processList->
Items[i];
3744 qsort(processList->
Items, processList->
Count,
sizeof(PVOID), IconProcessesCpuUsageCompare);
3746 if (processList->
Count > NumberOfProcesses)
3752 qsort(processList->
Items, processList->
Count,
sizeof(PVOID), IconProcessesNameCompare);
3759 for (i = 0; i < processList->
Count; i++)
3767 processItem = processList->
Items[i];
3799 subMenu->
Bitmap = iconBitmap;
3818 ULONG numberOfProcesses;
3834 if (NotifyIconNotifyMask & i)
3893 BOOLEAN handled =
FALSE;
3951 NotifyIconNotifyMask ^= bit;
3977 switch (LastNotificationType)
3997 if (LastNotificationDetails.ServiceName &&
4015 if (LastNotificationType &
4021 LastNotificationType = 0;
4022 memset(&LastNotificationDetails, 0,
sizeof(LastNotificationDetails));
4027 _In_ PVOID Parameter
4032 notifyEvent.
Type = Type;
4061 _In_opt_ PVOID Context
4080 _In_opt_ PVOID Context
4094 _In_ ULONG NumberOfProcesses
4097 ULONG priorityClass;
4131 _In_ ULONG NumberOfProcesses
4162 _In_ BOOLEAN SetPriority,
4163 _In_ BOOLEAN SetIoPriority,
4164 _In_ BOOLEAN SetPagePriority
4167 HANDLE processHandle;
4169 ULONG ioPriority = -1;
4170 ULONG pagePriority = -1;
4181 NtQueryInformationProcess(processHandle, ProcessPriorityClass, &priorityClass,
sizeof(
PROCESS_PRIORITY_CLASS), NULL);
4206 NtClose(processHandle);
4241 if (SetIoPriority && ioPriority != -1)
4269 if (SetPagePriority && pagePriority != -1)
4273 switch (pagePriority)
4304 _In_ ULONG NumberOfProcesses
4309 if (NumberOfProcesses == 0)
4313 else if (NumberOfProcesses == 1)
4328 ULONG menuItemsMultiEnabled[] =
4357 for (i = 0; i <
sizeof(menuItemsMultiEnabled) /
sizeof(ULONG); i++)
4375 if (NumberOfProcesses == 1)
4377 if (Processes[0]->IsSuspended)
4383 if (!Processes[0]->IsPartiallySuspended)
4391 if (NumberOfProcesses == 1)
4393 HANDLE processHandle;
4395 BOOLEAN allowed =
FALSE;
4396 BOOLEAN enabled =
FALSE;
4412 SelectedProcessVirtualizationEnabled = enabled;
4414 NtClose(tokenHandle);
4417 NtClose(processHandle);
4427 if (NumberOfProcesses == 1)
4437 if (NumberOfProcesses == 1)
4439 WINDOWPLACEMENT placement = {
sizeof(placement) };
4444 if (!SelectedProcessWindowHandle)
4447 GetWindowPlacement(SelectedProcessWindowHandle, &placement);
4449 if (placement.showCmd == SW_MINIMIZE)
4451 else if (placement.showCmd == SW_MAXIMIZE)
4453 else if (placement.showCmd == SW_NORMAL)
4476 ULONG numberOfProcesses;
4480 if (numberOfProcesses != 0)
4495 menuInfo.
u.
Process.Processes = processes;
4496 menuInfo.
u.
Process.NumberOfProcesses = numberOfProcesses;
4506 ContextMenu->Location.x,
4507 ContextMenu->Location.y
4512 BOOLEAN handled =
FALSE;
4536 if (!ProcessesNeedsRedraw)
4539 ProcessesNeedsRedraw =
TRUE;
4547 HANDLE parentProcessId = NULL;
4556 parentProcessId = parentProcess->
ProcessId;
4574 LastNotificationDetails.ProcessId = ProcessItem->
ProcessId;
4577 L
"The process %s (%u) was created by %s (%u)",
4590 ProcessToScrollTo = processNode;
4594 if (NeedsSelectPid != 0)
4596 if (processNode->
ProcessId == UlongToHandle(NeedsSelectPid))
4597 ProcessToScrollTo = processNode;
4611 if (SignedFilterEntry)
4621 if (!ProcessesNeedsRedraw)
4624 ProcessesNeedsRedraw =
TRUE;
4635 LastNotificationDetails.ProcessId = ProcessItem->ProcessId;
4638 L
"The process %s (%u) was terminated.",
4639 ProcessItem->ProcessName->Buffer,
4640 (ULONG)ProcessItem->ProcessId
4648 if (ProcessToScrollTo == processNode)
4649 ProcessToScrollTo = NULL;
4665 if (ProcessesNeedsRedraw)
4668 ProcessesNeedsRedraw =
FALSE;
4671 if (NeedsSelectPid != 0)
4673 if (ProcessToScrollTo)
4676 ProcessToScrollTo = NULL;
4682 if (ProcessToScrollTo)
4685 ProcessToScrollTo = NULL;
4693 if (!ServiceTreeListLoaded)
4695 ServiceTreeListLoaded =
TRUE;
4704 if (ServicesPendingList)
4707 ULONG enumerationKey = 0;
4709 while (
PhEnumPointerList(ServicesPendingList, &enumerationKey, (PVOID *)&serviceItem))
4724 _In_opt_ PVOID Context
4738 _In_ ULONG NumberOfServices
4741 if (NumberOfServices == 0)
4745 else if (NumberOfServices == 1)
4756 if (NumberOfServices == 1)
4758 switch (Services[0]->State)
4760 case SERVICE_RUNNING:
4765 Services[0]->ControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE);
4767 Services[0]->ControlsAccepted & SERVICE_ACCEPT_STOP);
4770 case SERVICE_PAUSED:
4774 Services[0]->ControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE);
4777 Services[0]->ControlsAccepted & SERVICE_ACCEPT_STOP);
4780 case SERVICE_STOPPED:
4787 case SERVICE_START_PENDING:
4788 case SERVICE_CONTINUE_PENDING:
4789 case SERVICE_PAUSE_PENDING:
4790 case SERVICE_STOP_PENDING:
4800 if (!(Services[0]->ControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE))
4818 ULONG numberOfServices;
4822 if (numberOfServices != 0)
4837 menuInfo.
u.
Service.Services = services;
4838 menuInfo.
u.
Service.NumberOfServices = numberOfServices;
4848 ContextMenu->Location.x,
4849 ContextMenu->Location.y
4854 BOOLEAN handled =
FALSE;
4878 if (ServiceTreeListLoaded)
4880 if (!ServicesNeedsRedraw)
4883 ServicesNeedsRedraw =
TRUE;
4891 if (!ServicesPendingList)
4910 L
"The service %s (%s) has been created.",
4918 if (ServiceTreeListLoaded)
4929 if (ServiceTreeListLoaded)
4939 if (DriverFilterEntry)
4945 switch (serviceChange)
4964 if (logEntryType != 0)
4965 PhLogServiceEntry(logEntryType, ServiceModifiedData->Service->Name, ServiceModifiedData->Service->DisplayName);
4971 serviceItem = ServiceModifiedData->Service;
4982 L
"The service %s (%s) has been started.",
4997 L
"The service %s (%s) has been stopped.",
5010 if (ServiceTreeListLoaded)
5012 if (!ServicesNeedsRedraw)
5015 ServicesNeedsRedraw =
TRUE;
5027 PhSwapReference(&LastNotificationDetails.ServiceName, ServiceItem->Name);
5030 L
"The service %s (%s) has been deleted.",
5031 ServiceItem->Name->Buffer,
5032 ServiceItem->DisplayName->Buffer
5037 if (ServiceTreeListLoaded)
5043 if (ServicesPendingList)
5045 HANDLE pointerHandle;
5062 if (ServiceTreeListLoaded)
5066 if (ServicesNeedsRedraw)
5069 ServicesNeedsRedraw =
FALSE;
5078 if (!NetworkTreeListLoaded)
5080 NetworkTreeListLoaded =
TRUE;
5088 _In_opt_ PVOID Context
5104 _In_opt_ PVOID Context
5121 _In_ ULONG NumberOfNetworkItems
5127 if (NumberOfNetworkItems == 0)
5131 else if (NumberOfNetworkItems == 1)
5150 if (NumberOfNetworkItems != 1 || !NetworkItems[0]->OwnerName)
5157 if (NumberOfNetworkItems != 0)
5159 BOOLEAN closeOk =
TRUE;
5161 for (i = 0; i < NumberOfNetworkItems; i++)
5165 NetworkItems[i]->State != MIB_TCP_STATE_ESTAB
5184 ULONG numberOfNetworkItems;
5188 if (numberOfNetworkItems != 0)
5203 menuInfo.
u.
Network.NetworkItems = networkItems;
5204 menuInfo.
u.
Network.NumberOfNetworkItems = numberOfNetworkItems;
5214 ContextMenu->Location.x,
5215 ContextMenu->Location.y
5220 BOOLEAN handled =
FALSE;
5244 if (!NetworkNeedsRedraw)
5247 NetworkNeedsRedraw =
TRUE;
5265 if (!NetworkNeedsRedraw)
5268 NetworkNeedsRedraw =
TRUE;
5280 if (NetworkNeedsRedraw)
5283 NetworkNeedsRedraw =
FALSE;
5293 ULONG numberOfSessions;
5296 MENUITEMINFO menuItemInfo = {
sizeof(MENUITEMINFO) };
5298 menu = SubMenuHandles[3];
5301 while (DeleteMenu(menu, 0, MF_BYPOSITION)) ;
5305 for (i = 0; i < numberOfSessions; i++)
5312 ULONG numberOfItems;
5316 sessions[i].SessionId,
5323 winStationInfo.
Domain[0] = 0;
5327 if (winStationInfo.
Domain[0] == 0 || winStationInfo.
UserName[0] == 0)
5335 sessions[i].SessionId,
5345 MF_STRING | MF_POPUP,
5352 menuItemInfo.fMask = MIIM_DATA;
5353 menuItemInfo.dwItemData = sessions[i].
SessionId;
5355 numberOfItems = GetMenuItemCount(userMenu);
5357 if (numberOfItems != -1)
5359 for (j = 0; j < numberOfItems; j++)
5360 SetMenuItemInfo(userMenu, j,
TRUE, &menuItemInfo);