static VOID NcAreaInitializeImageList( _Inout_ PEDIT_CONTEXT Context ) { HBITMAP bitmapActive = NULL; HBITMAP bitmapInactive = NULL; Context->ImageWidth = 23; Context->ImageHeight = 20; Context->ImageList = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0); ImageList_SetBkColor(Context->ImageList, Context->BackgroundColorRef); ImageList_SetImageCount(Context->ImageList, 2); // Add the images to the imagelist if (bitmapActive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) { ImageList_Replace(Context->ImageList, 0, bitmapActive, NULL); DeleteObject(bitmapActive); } else { PhSetImageListBitmap(Context->ImageList, 0, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); } if (bitmapInactive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) { ImageList_Replace(Context->ImageList, 1, bitmapInactive, NULL); DeleteObject(bitmapInactive); } else { PhSetImageListBitmap(Context->ImageList, 1, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); } }
VOID NcAreaInitializeImageList( _Inout_ PEDIT_CONTEXT Context ) { HBITMAP bitmapActive = NULL; HBITMAP bitmapInactive = NULL; Context->ImageWidth = GetSystemMetrics(SM_CXSMICON) + 4; Context->ImageHeight = GetSystemMetrics(SM_CYSMICON) + 4; Context->ImageList = ImageList_Create(32, 32, ILC_COLOR32, 2, 2); ImageList_SetImageCount(Context->ImageList, 2); // Add the images to the imagelist if (bitmapActive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) { ImageList_Replace(Context->ImageList, 0, bitmapActive, NULL); DeleteObject(bitmapActive); } else { PhSetImageListBitmap(Context->ImageList, 0, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); } if (bitmapInactive = LoadImageFromResources(Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) { ImageList_Replace(Context->ImageList, 1, bitmapInactive, NULL); DeleteObject(bitmapInactive); } else { PhSetImageListBitmap(Context->ImageList, 1, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); } }
static INT_PTR CALLBACK PhpProcessTerminatorDlgProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { PPH_PROCESS_ITEM processItem = (PPH_PROCESS_ITEM)lParam; PPH_STRING title; HWND lvHandle; HIMAGELIST imageList; ULONG i; PhCenterWindow(hwndDlg, GetParent(hwndDlg)); title = PhFormatString( L"Terminator - %s (%u)", processItem->ProcessName->Buffer, (ULONG)processItem->ProcessId ); SetWindowText(hwndDlg, title->Buffer); PhDereferenceObject(title); SetProp(hwndDlg, L"ProcessItem", (HANDLE)processItem); lvHandle = GetDlgItem(hwndDlg, IDC_TERMINATOR_LIST); PhAddListViewColumn(lvHandle, 0, 0, 0, LVCFMT_LEFT, 70, L"ID"); PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 280, L"Description"); ListView_SetExtendedListViewStyleEx(lvHandle, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES, -1); PhSetControlTheme(lvHandle, L"explorer"); imageList = ImageList_Create(16, 16, ILC_COLOR32, 0, 0); ImageList_SetImageCount(imageList, 2); PhSetImageListBitmap(imageList, CROSS_INDEX, PhInstanceHandle, MAKEINTRESOURCE(IDB_CROSS)); PhSetImageListBitmap(imageList, TICK_INDEX, PhInstanceHandle, MAKEINTRESOURCE(IDB_TICK)); for (i = 0; i < sizeof(PhTerminatorTests) / sizeof(TEST_ITEM); i++) { INT itemIndex; BOOLEAN check; itemIndex = PhAddListViewItem( lvHandle, MAXINT, PhTerminatorTests[i].Id, &PhTerminatorTests[i] ); PhSetListViewSubItem(lvHandle, itemIndex, 1, PhTerminatorTests[i].Description); PhSetListViewItemImageIndex(lvHandle, itemIndex, -1); check = TRUE; if (WSTR_EQUAL(PhTerminatorTests[i].Id, L"TT4") || WSTR_EQUAL(PhTerminatorTests[i].Id, L"M1")) check = FALSE; ListView_SetCheckState(lvHandle, itemIndex, check); } ListView_SetImageList(lvHandle, imageList, LVSIL_SMALL); SetDlgItemText( hwndDlg, IDC_TERMINATOR_TEXT, L"Double-click a termination method or click Run Selected." ); } break; case WM_DESTROY: { RemoveProp(hwndDlg, L"ProcessItem"); } break; case WM_COMMAND: { INT id = LOWORD(wParam); switch (id) { case IDCANCEL: // Esc and X button to close case IDOK: EndDialog(hwndDlg, IDOK); break; case IDC_RUNSELECTED: { if (PhShowConfirmMessage(hwndDlg, L"run", L"the selected terminator tests", NULL, FALSE)) { HWND lvHandle; ULONG i; lvHandle = GetDlgItem(hwndDlg, IDC_TERMINATOR_LIST); for (i = 0; i < sizeof(PhTerminatorTests) / sizeof(TEST_ITEM); i++) { if (ListView_GetCheckState(lvHandle, i)) { if (PhpRunTerminatorTest( hwndDlg, i )) break; } } } } break; } } break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; if (header->hwndFrom == GetDlgItem(hwndDlg, IDC_TERMINATOR_LIST)) { if (header->code == NM_DBLCLK) { LPNMITEMACTIVATE itemActivate = (LPNMITEMACTIVATE)header; if (itemActivate->iItem != -1) { if (PhShowConfirmMessage(hwndDlg, L"run", L"the selected test", NULL, FALSE)) { PhpRunTerminatorTest( hwndDlg, itemActivate->iItem ); } } } else if (header->code == LVN_ITEMCHANGED) { ULONG i; BOOLEAN oneSelected; oneSelected = FALSE; for (i = 0; i < sizeof(PhTerminatorTests) / sizeof(TEST_ITEM); i++) { if (ListView_GetCheckState(header->hwndFrom, i)) { oneSelected = TRUE; break; } } EnableWindow(GetDlgItem(hwndDlg, IDC_RUNSELECTED), oneSelected); } } } break; } return FALSE; }
static LRESULT CALLBACK MainWndSubclassProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ UINT_PTR uIdSubclass, _In_ ULONG_PTR dwRefData ) { if (uMsg == TaskbarButtonCreatedMsgId) { if (!TaskbarButtonsCreated) { BlackIcon = PhGetBlackIcon(); ButtonsImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0); ImageList_SetImageCount(ButtonsImageList, 4); PhSetImageListBitmap(ButtonsImageList, 0, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_CHART_LINE_BMP)); PhSetImageListBitmap(ButtonsImageList, 1, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_FIND_BMP)); PhSetImageListBitmap(ButtonsImageList, 2, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_BMP)); PhSetImageListBitmap(ButtonsImageList, 3, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_GO_BMP)); ButtonsArray[0].dwMask = THB_FLAGS | THB_BITMAP | THB_TOOLTIP; ButtonsArray[0].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK; ButtonsArray[0].iId = PHAPP_ID_VIEW_SYSTEMINFORMATION; ButtonsArray[0].iBitmap = 0; wcsncpy_s(ButtonsArray[0].szTip, ARRAYSIZE(ButtonsArray[0].szTip), L"System Information", _TRUNCATE); ButtonsArray[1].dwMask = THB_FLAGS | THB_BITMAP | THB_TOOLTIP; ButtonsArray[1].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK; ButtonsArray[1].iId = PHAPP_ID_HACKER_FINDHANDLESORDLLS; ButtonsArray[1].iBitmap = 1; wcsncpy_s(ButtonsArray[1].szTip, ARRAYSIZE(ButtonsArray[1].szTip), L"Find Handles or DLLs", _TRUNCATE); ButtonsArray[2].dwMask = THB_FLAGS | THB_BITMAP | THB_TOOLTIP; ButtonsArray[2].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK; ButtonsArray[2].iId = PHAPP_ID_HELP_LOG; ButtonsArray[2].iBitmap = 2; wcsncpy_s(ButtonsArray[2].szTip, ARRAYSIZE(ButtonsArray[2].szTip), L"Application Log", _TRUNCATE); ButtonsArray[3].dwMask = THB_FLAGS | THB_BITMAP | THB_TOOLTIP; ButtonsArray[3].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK; ButtonsArray[3].iId = PHAPP_ID_TOOLS_INSPECTEXECUTABLEFILE; ButtonsArray[3].iBitmap = 3; wcsncpy_s(ButtonsArray[3].szTip, ARRAYSIZE(ButtonsArray[3].szTip), L"Inspect Executable File", _TRUNCATE); TaskbarButtonsCreated = TRUE; } if (TaskbarListClass) { // Set the ThumbBar image list ITaskbarList3_ThumbBarSetImageList(TaskbarListClass, PhMainWndHandle, ButtonsImageList); // Set the ThumbBar buttons array ITaskbarList3_ThumbBarAddButtons(TaskbarListClass, PhMainWndHandle, ARRAYSIZE(ButtonsArray), ButtonsArray); if (TaskbarIconType != TASKBAR_ICON_NONE) { // Set the initial ThumbBar icon ITaskbarList3_SetOverlayIcon(TaskbarListClass, PhMainWndHandle, BlackIcon, NULL); } } } return DefSubclassProc(hWnd, uMsg, wParam, lParam); }
static VOID RebarLoadSettings( VOID ) { // Initialize the Toolbar Imagelist. if (EnableToolBar && !ToolBarImageList) { HBITMAP iconBitmap = NULL; // Create the toolbar imagelist ToolBarImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0); // Set the number of images ImageList_SetImageCount(ToolBarImageList, 8); // Add the images to the imagelist if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_ARROW_REFRESH))) { ImageList_Replace(ToolBarImageList, 0, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 0, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_ARROW_REFRESH_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_COG_EDIT))) { ImageList_Replace(ToolBarImageList, 1, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 1, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_COG_EDIT_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_FIND))) { ImageList_Replace(ToolBarImageList, 2, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 2, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_FIND_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CHART_LINE))) { ImageList_Replace(ToolBarImageList, 3, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 3, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_CHART_LINE_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION))) { ImageList_Replace(ToolBarImageList, 4, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 4, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION_GO))) { ImageList_Replace(ToolBarImageList, 5, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 5, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_GO_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CROSS))) { ImageList_Replace(ToolBarImageList, 6, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 6, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_CROSS_BMP)); } if (iconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION_GET))) { ImageList_Replace(ToolBarImageList, 7, iconBitmap, NULL); DeleteObject(iconBitmap); } else { PhSetImageListBitmap(ToolBarImageList, 7, PluginInstance->DllBase, MAKEINTRESOURCE(IDB_APPLICATION_GET_BMP)); } } // Initialize the Rebar and Toolbar controls. if (EnableToolBar && !RebarHandle) { REBARINFO rebarInfo = { sizeof(REBARINFO) }; ULONG toolbarButtonSize; // Create the ReBar window. RebarHandle = CreateWindowEx( WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT | RBS_AUTOSIZE, // CCS_NOPARENTALIGN | RBS_FIXEDORDER CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); // Set the toolbar info with no imagelist. SendMessage(RebarHandle, RB_SETBARINFO, 0, (LPARAM)&rebarInfo); // Create the ToolBar window. ToolBarHandle = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | CCS_ADJUSTABLE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE, // TBSTYLE_ALTDRAG CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, RebarHandle, NULL, NULL, NULL ); // Manually add button strings via TB_ADDSTRING. // NOTE: The Toolbar will sometimes decide to free strings hard-coded via (INT_PTR)L"String" // in the ToolbarButtons array causing random crashes unless we manually add the strings // into the Toolbar string pool (this bug only affects 64bit Windows)... WTF??? ToolbarButtons[0].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Refresh"); ToolbarButtons[1].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Options"); ToolbarButtons[3].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Handles or DLLs"); ToolbarButtons[4].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"System Information"); ToolbarButtons[6].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window"); ToolbarButtons[7].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window and Thread"); ToolbarButtons[8].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Find Window and Kill"); ToolbarButtons[9].iString = SendMessage(ToolBarHandle, TB_ADDSTRING, 0, (LPARAM)L"Always on Top"); // Set the toolbar struct size. SendMessage(ToolBarHandle, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); // Set the toolbar extended toolbar styles. SendMessage(ToolBarHandle, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_HIDECLIPPEDBUTTONS); // Configure the toolbar imagelist. SendMessage(ToolBarHandle, TB_SETIMAGELIST, 0, (LPARAM)ToolBarImageList); // Add the buttons to the toolbar (also specifying the default number of items to display). SendMessage(ToolBarHandle, TB_ADDBUTTONS, MAX_DEFAULT_TOOLBAR_ITEMS, (LPARAM)ToolbarButtons); // Restore the toolbar settings (Note: This will invoke the TBN_ENDADJUST notification). SendMessage(ToolBarHandle, TB_SAVERESTORE, FALSE, (LPARAM)&ToolbarSaveParams); // Query the toolbar button width/height. toolbarButtonSize = (ULONG)SendMessage(ToolBarHandle, TB_GETBUTTONSIZE, 0, 0); // Enable theming: //SendMessage(RebarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help //SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Media"); //Media/Communications/BrowserTabBar/Help // Inset the toolbar into the rebar control. RebarBandInsert(BandID_ToolBar, ToolBarHandle, HIWORD(toolbarButtonSize), LOWORD(toolbarButtonSize)); ToolbarInitialized = TRUE; } // Initialize the Searchbox and TreeNewFilters. if (EnableSearchBox && !SearchboxHandle) { SearchboxText = PhReferenceEmptyString(); ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, NULL); ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), (PPH_TN_FILTER_FUNCTION)ServiceTreeFilterCallback, NULL); NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), (PPH_TN_FILTER_FUNCTION)NetworkTreeFilterCallback, NULL); // Create the Searchbox control. SearchboxHandle = CreateSearchControl(ID_SEARCH_CLEAR); } // Initialize the Statusbar control. if (EnableStatusBar && !StatusBarHandle) { // Create the StatusBar window. StatusBarHandle = CreateWindowEx( 0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP | SBARS_TOOLTIPS, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); } // Hide or show controls (Note: don't unload or remove at runtime). if (EnableToolBar) { if (RebarHandle && !IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_SHOW); } else { if (RebarHandle && IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_HIDE); } if (EnableSearchBox) { // Add the Searchbox band into the rebar control. if (!RebarBandExists(BandID_SearchBox)) RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180); if (SearchboxHandle && !IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_SHOW); } else { // Remove the Searchbox band from the rebar control. if (RebarBandExists(BandID_SearchBox)) RebarBandRemove(BandID_SearchBox); if (SearchboxHandle) { // Clear search text and reset search filters. SetFocus(SearchboxHandle); Static_SetText(SearchboxHandle, L""); if (IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_HIDE); } } // TODO: Fix above code... if (SearchBoxDisplayMode == SearchBoxDisplayHideInactive) { if (RebarBandExists(BandID_SearchBox)) RebarBandRemove(BandID_SearchBox); } else { if (!RebarBandExists(BandID_SearchBox)) RebarBandInsert(BandID_SearchBox, SearchboxHandle, 20, 180); } if (EnableStatusBar) { if (StatusBarHandle && !IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_SHOW); } else { if (StatusBarHandle && IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_HIDE); } }