53 _In_opt_ PVOID Parameter1,
54 _In_opt_ PVOID Parameter2,
55 _In_opt_ PVOID Context
58 static HWND ServiceTreeListHandle;
59 static ULONG ServiceTreeListSortColumn;
68 static HICON ServiceApplicationIcon;
69 static HICON ServiceApplicationGoIcon;
70 static HICON ServiceCogIcon;
71 static HICON ServiceCogGoIcon;
116 ServiceTreeListHandle = hwnd;
118 SendMessage(
TreeNew_GetTooltips(ServiceTreeListHandle), TTM_SETDELAYTIME, TTDT_AUTOPOP, MAXSHORT);
148 treeNewInfo.
CmData = &ServiceTreeListCm;
176 settings =
PhCmSaveSettingsEx(ServiceTreeListHandle, &ServiceTreeListCm, 0, &sortSettings);
187 return &FilterSupport;
206 &ServiceNodeStateList,
244 ServiceNodeHashtable,
245 &lookupServiceNodePtr
265 &ServiceNode->ShState,
266 &ServiceNodeStateList,
269 ServiceTreeListHandle
288 if ((index = PhFindItemList(ServiceNodeList, ServiceNode)) != -1)
311 ServiceNode->ValidMask = 0;
330 static VOID PhpUpdateServiceNodeConfig(
336 SC_HANDLE serviceHandle;
337 LPQUERY_SERVICE_CONFIG serviceConfig;
339 if (serviceHandle =
PhOpenService(ServiceNode->ServiceItem->Name->Buffer, SERVICE_QUERY_CONFIG))
343 if (serviceConfig->lpBinaryPathName)
345 if (serviceConfig->lpLoadOrderGroup)
351 CloseServiceHandle(serviceHandle);
358 static VOID PhpUpdateServiceNodeDescription(
364 SC_HANDLE serviceHandle;
366 if (serviceHandle =
PhOpenService(ServiceNode->ServiceItem->Name->Buffer, SERVICE_QUERY_CONFIG))
370 CloseServiceHandle(serviceHandle);
377 #define SORT_FUNCTION(Column) PhpServiceTreeNewCompare##Column
379 #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpServiceTreeNewCompare##Column( \
380 _In_ const void *_elem1, \
381 _In_ const void *_elem2 \
384 PPH_SERVICE_NODE node1 = *(PPH_SERVICE_NODE *)_elem1; \
385 PPH_SERVICE_NODE node2 = *(PPH_SERVICE_NODE *)_elem2; \
386 PPH_SERVICE_ITEM serviceItem1 = node1->ServiceItem; \
387 PPH_SERVICE_ITEM serviceItem2 = node2->ServiceItem; \
390 #define END_SORT_FUNCTION \
394 return PhModifySort(sortResult, ServiceTreeListSortOrder); \
421 sortResult =
intcmp(serviceItem1->Type, serviceItem2->Type);
427 sortResult =
intcmp(serviceItem1->State, serviceItem2->State);
433 sortResult =
intcmp(serviceItem1->StartType, serviceItem2->StartType);
436 sortResult =
intcmp(serviceItem1->DelayedStart, serviceItem2->DelayedStart);
438 sortResult =
intcmp(serviceItem1->HasTriggers, serviceItem2->HasTriggers);
444 sortResult =
uintptrcmp((ULONG_PTR)serviceItem1->ProcessId, (ULONG_PTR)serviceItem2->ProcessId);
450 PhpUpdateServiceNodeConfig(node1);
451 PhpUpdateServiceNodeConfig(node2);
458 sortResult =
intcmp(serviceItem1->ErrorControl, serviceItem2->ErrorControl);
464 PhpUpdateServiceNodeConfig(node1);
465 PhpUpdateServiceNodeConfig(node2);
472 PhpUpdateServiceNodeDescription(node1);
473 PhpUpdateServiceNodeDescription(node2);
481 _In_opt_ PVOID Parameter1,
482 _In_opt_ PVOID Parameter2,
483 _In_opt_ PVOID Context
497 if (!getChildren->
Node)
499 static PVOID sortFunctions[] =
512 int (__cdecl *sortFunction)(
const void *,
const void *);
516 ServiceNodeList->
Count,
517 ServiceTreeListSortColumn,
518 ServiceTreeListSortOrder,
523 sortFunction = sortFunctions[ServiceTreeListSortColumn];
529 qsort(ServiceNodeList->
Items, ServiceNodeList->
Count,
sizeof(PVOID), sortFunction);
553 switch (getCellText->
Id)
570 PWSTR additional = NULL;
576 additional = L
" (Delayed, Trigger)";
578 additional = L
" (Delayed)";
580 additional = L
" (Trigger)";
589 getCellText->
Text.
Length = returnLength -
sizeof(WCHAR);
597 PhpUpdateServiceNodeConfig(node);
604 PhpUpdateServiceNodeConfig(node);
608 PhpUpdateServiceNodeDescription(node);
627 getNodeIcon->
Icon = ServiceCogGoIcon;
629 getNodeIcon->
Icon = ServiceCogIcon;
634 getNodeIcon->
Icon = ServiceApplicationGoIcon;
636 getNodeIcon->
Icon = ServiceApplicationIcon;
648 if (getCellTooltip->
Column->
Id != 0)
668 TreeNew_GetSort(hwnd, &ServiceTreeListSortColumn, &ServiceTreeListSortOrder);
680 if (GetKeyState(VK_CONTROL) < 0)
684 if (GetKeyState(VK_CONTROL) < 0)
691 if (GetKeyState(VK_CONTROL) >= 0)
739 for (i = 0; i < ServiceNodeList->
Count; i++)
755 _Out_ PULONG NumberOfServices
763 for (i = 0; i < ServiceNodeList->
Count; i++)
774 *NumberOfServices = list->
Count;
792 if (!ServiceNode->Node.Visible)
797 TreeNew_SelectRange(ServiceTreeListHandle, ServiceNode->Node.Index, ServiceNode->Node.Index);
822 for (i = 0; i < lines->
Count; i++)
826 line = lines->
Items[i];