70 static ULONG TargetingMode = 0;
71 static BOOLEAN TargetingWindow =
FALSE;
72 static BOOLEAN TargetingCurrentWindowDraw =
FALSE;
73 static BOOLEAN TargetingCompleted =
FALSE;
74 static HWND TargetingCurrentWindow = NULL;
93 _In_opt_ PVOID Parameter,
94 _In_opt_ PVOID Context
104 _In_opt_ PVOID Parameter,
105 _In_opt_ PVOID Context
113 _In_ PWSTR BannerText
137 tabInfoCopy = *entry;
159 HWND treeNewHandle = NULL;
184 return treeNewHandle;
187 static VOID NTAPI TabPageUpdatedCallback(
188 _In_opt_ PVOID Parameter,
189 _In_opt_ PVOID Context
192 INT tabIndex = (INT)Parameter;
228 static VOID NTAPI LayoutPaddingCallback(
229 _In_opt_ PVOID Parameter,
230 _In_opt_ PVOID Context
244 data->
Padding.top += rebarRect.bottom;
287 data->
Padding.bottom += statusBarRect.bottom;
291 static BOOLEAN NTAPI MessageLoopFilter(
308 static VOID DrawWindowBorderForTargeting(
315 GetWindowRect(hWnd, &rect);
316 hdc = GetWindowDC(hWnd);
320 ULONG penWidth = GetSystemMetrics(SM_CXBORDER) * 3;
328 SetROP2(hdc, R2_NOT);
330 pen = CreatePen(PS_INSIDEFRAME, penWidth, RGB(0x00, 0x00, 0x00));
331 SelectObject(hdc, pen);
333 brush = GetStockObject(NULL_BRUSH);
334 SelectObject(hdc, brush);
337 Rectangle(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
342 RestoreDC(hdc, oldDc);
343 ReleaseDC(hWnd, hdc);
347 static LRESULT CALLBACK MainWndSubclassProc(
352 _In_ UINT_PTR uIdSubclass,
353 _In_ ULONG_PTR dwRefData
360 switch (GET_WM_COMMAND_CMD(wParam, lParam))
388 if (SearchboxText->
Length == 0)
397 switch (GET_WM_COMMAND_ID(wParam, lParam))
399 case PHAPP_ID_ESC_EXIT:
405 TargetingWindow =
FALSE;
435 case PHAPP_ID_VIEW_ALWAYSONTOP:
438 DefSubclassProc(hWnd, uMsg, wParam, lParam);
444 SendMessage(
ToolBarHandle, TB_PRESSBUTTON, (WPARAM)PHAPP_ID_VIEW_ALWAYSONTOP, (LPARAM)(MAKELONG(isAlwaysOnTopEnabled, 0)));
454 LPNMHDR hdr = (LPNMHDR)lParam;
460 case RBN_HEIGHTCHANGE:
466 case RBN_CHEVRONPUSHED:
468 LPNMREBARCHEVRON rebar;
470 ULONG buttonCount = 0;
475 rebar = (LPNMREBARCHEVRON)lParam;
480 buttonCount = (ULONG)SendMessage(
ToolBarHandle, TB_BUTTONCOUNT, 0, 0);
482 for (index = 0; index < buttonCount; index++)
485 TBBUTTONINFO button = {
sizeof(TBBUTTONINFO) };
486 button.dwMask = TBIF_BYINDEX | TBIF_STYLE | TBIF_COMMAND | TBIF_IMAGE;
489 if (SendMessage(
ToolBarHandle, TB_GETITEMRECT, index, (LPARAM)&buttonRect) == -1)
492 if (buttonRect.right <= toolbarRect.right)
496 if (SendMessage(
ToolBarHandle, TB_GETBUTTONINFO, index, (LPARAM)&button) == -1)
499 if (button.fsStyle == BTNS_SEP)
515 DestroyIcon(menuIcon);
517 if (button.idCommand == PHAPP_ID_VIEW_ALWAYSONTOP)
536 MapWindowPoints(
RebarHandle, NULL, (LPPOINT)&rebar->rc, 2);
547 if (selectedItem && selectedItem->
Id != -1)
565 LPNMTOOLBAR toolbar = (LPNMTOOLBAR)hdr;
568 id = (ULONG)toolbar->iItem;
576 SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
578 TargetingWindow =
TRUE;
579 TargetingCurrentWindow = NULL;
580 TargetingCurrentWindowDraw =
FALSE;
581 TargetingCompleted =
FALSE;
584 SendMessage(hWnd, WM_MOUSEMOVE, 0, 0);
588 case TBN_INITCUSTOMIZE:
594 } *initcustomize = (PVOID)lParam;
596 return TBNRF_HIDEHELP;
597 case TBN_QUERYINSERT:
598 case TBN_QUERYDELETE:
600 case TBN_GETBUTTONINFO:
602 LPTBNOTIFY tbNotify = (LPTBNOTIFY)lParam;
635 return TBNRF_ENDCUSTOMIZE;
648 GetCursorPos(&cursorPos);
664 HWND windowOverMouse;
668 GetCursorPos(&cursorPos);
669 windowOverMouse = WindowFromPoint(cursorPos);
671 if (TargetingCurrentWindow != windowOverMouse)
673 if (TargetingCurrentWindow && TargetingCurrentWindowDraw)
676 DrawWindowBorderForTargeting(TargetingCurrentWindow);
681 threadId = GetWindowThreadProcessId(windowOverMouse, &processId);
684 if (UlongToHandle(processId) != NtCurrentProcessId())
686 DrawWindowBorderForTargeting(windowOverMouse);
687 TargetingCurrentWindowDraw =
TRUE;
691 TargetingCurrentWindowDraw =
FALSE;
695 TargetingCurrentWindow = windowOverMouse;
711 TargetingCompleted =
TRUE;
715 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
717 TargetingWindow =
FALSE;
720 if (TargetingCurrentWindow)
722 if (TargetingCurrentWindowDraw)
725 DrawWindowBorderForTargeting(TargetingCurrentWindow);
732 static HWND (WINAPI *HungWindowFromGhostWindow_I)(
736 if (!HungWindowFromGhostWindow_I)
739 if (HungWindowFromGhostWindow_I)
741 HWND hungWindow = HungWindowFromGhostWindow_I(TargetingCurrentWindow);
746 TargetingCurrentWindow = hungWindow;
750 threadId = GetWindowThreadProcessId(TargetingCurrentWindow, &processId);
752 if (threadId && processId && UlongToHandle(processId) != NtCurrentProcessId())
764 switch (TargetingMode)
784 PhShowError(hWnd, L
"The process (PID %lu) does not exist.", processId);
799 PhShowError(hWnd, L
"The process (PID %lu) does not exist.", processId);
811 case WM_CAPTURECHANGED:
813 if (!TargetingCompleted)
818 if (TargetingCurrentWindow)
820 if (TargetingCurrentWindowDraw)
823 DrawWindowBorderForTargeting(TargetingCurrentWindow);
828 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
830 TargetingCompleted =
TRUE;
838 case WM_SETTINGCHANGE:
844 return DefSubclassProc(hWnd, uMsg, wParam, lParam);
847 return DefWindowProc(hWnd, uMsg, wParam, lParam);
851 _In_opt_ PVOID Parameter,
852 _In_opt_ PVOID Context
858 LayoutPaddingCallback,
860 &LayoutPaddingCallbackRegistration
868 _In_opt_ PVOID Parameter,
869 _In_opt_ PVOID Context
882 _In_opt_ PVOID Parameter,
883 _In_opt_ PVOID Context
895 _In_ HINSTANCE Instance,
897 _Reserved_ PVOID Reserved
902 case DLL_PROCESS_ATTACH:
922 info->
Author = L
"dmex, wj32";
923 info->
Description = L
"Adds a toolbar and a status bar.";
924 info->
Url = L
"http://processhacker.sf.net/forums/viewtopic.php?t=1119";
932 &PluginLoadCallbackRegistration
938 &PluginShowOptionsCallbackRegistration
944 &MainWindowShowingCallbackRegistration
950 &ProcessesUpdatedCallbackRegistration
954 TabPageUpdatedCallback,
956 &TabPageCallbackRegistration
962 &ProcessTreeNewInitializingCallbackRegistration
968 &ServiceTreeNewInitializingCallbackRegistration
974 &NetworkTreeNewInitializingCallbackRegistration