28 typedef struct _ES_TRIGGER_DATA
44 typedef struct _ES_TRIGGER_INFO
53 typedef struct _ES_TRIGGER_CONTEXT
59 ULONG InitialNumberOfTriggers;
64 ULONG LastSelectedType;
71 typedef struct _TYPE_ENTRY
77 typedef struct _SUBTYPE_ENTRY
84 typedef struct _ETW_PUBLISHER_ENTRY
104 static GUID NetworkManagerFirstIpAddressArrivalGuid = { 0x4f27f2de, 0x14e2, 0x430b, { 0xa5, 0x49, 0x7c, 0xd4, 0x8c, 0xbc, 0x82, 0x45 } };
105 static GUID NetworkManagerLastIpAddressRemovalGuid = { 0xcc4ba62a, 0x162e, 0x4648, { 0x84, 0x7a, 0xb6, 0xbd, 0xf9, 0x93, 0xe3, 0x35 } };
106 static GUID DomainJoinGuid = { 0x1ce20aba, 0x9851, 0x4421, { 0x94, 0x30, 0x1d, 0xde, 0xb7, 0x66, 0xe8, 0x09 } };
107 static GUID DomainLeaveGuid = { 0xddaf516e, 0x58c2, 0x4866, { 0x95, 0x74, 0xc3, 0xb6, 0x15, 0xd4, 0x2e, 0xa1 } };
108 static GUID FirewallPortOpenGuid = { 0xb7569e07, 0x8421, 0x4ee0, { 0xad, 0x10, 0x86, 0x91, 0x5a, 0xfd, 0xad, 0x09 } };
109 static GUID FirewallPortCloseGuid = { 0xa144ed38, 0x8e12, 0x4de4, { 0x9d, 0x96, 0xe6, 0x47, 0x40, 0xb1, 0xa5, 0x24 } };
110 static GUID MachinePolicyPresentGuid = { 0x659fcae6, 0x5bdb, 0x4da9, { 0xb1, 0xff, 0xca, 0x2a, 0x17, 0x8d, 0x46, 0xe0 } };
111 static GUID UserPolicyPresentGuid = { 0x54fb46c8, 0xf089, 0x464c, { 0xb1, 0xfd, 0x59, 0xd1, 0xb6, 0x2c, 0x3b, 0x50 } };
112 static GUID RpcInterfaceEventGuid = { 0xbc90d167, 0x9470, 0x4139, { 0xa9, 0xba, 0xbe, 0x0b, 0xbb, 0xf5, 0xb7, 0x4d } };
113 static GUID NamedPipeEventGuid = { 0x1f81d131, 0x3fac, 0x4537, { 0x9e, 0x0c, 0x7e, 0x7b, 0x0c, 0x2f, 0x4b, 0x55 } };
114 static GUID SubTypeUnknownGuid;
118 { SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL, L
"Device interface arrival" },
119 { SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY, L
"IP address availability" },
120 { SERVICE_TRIGGER_TYPE_DOMAIN_JOIN, L
"Domain join" },
121 { SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT, L
"Firewall port event" },
122 { SERVICE_TRIGGER_TYPE_GROUP_POLICY, L
"Group policy" },
123 { SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT, L
"Network endpoint" },
124 { SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE, L
"Custom system state change" },
125 { SERVICE_TRIGGER_TYPE_CUSTOM, L
"Custom" }
130 { SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY, NULL, L
"IP address" },
131 { SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY, &NetworkManagerFirstIpAddressArrivalGuid, L
"IP address: First arrival" },
132 { SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY, &NetworkManagerLastIpAddressRemovalGuid, L
"IP address: Last removal" },
133 { SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY, &SubTypeUnknownGuid, L
"IP address: Unknown" },
134 { SERVICE_TRIGGER_TYPE_DOMAIN_JOIN, NULL, L
"Domain" },
135 { SERVICE_TRIGGER_TYPE_DOMAIN_JOIN, &DomainJoinGuid, L
"Domain: Join" },
136 { SERVICE_TRIGGER_TYPE_DOMAIN_JOIN, &DomainLeaveGuid, L
"Domain: Leave" },
137 { SERVICE_TRIGGER_TYPE_DOMAIN_JOIN, &SubTypeUnknownGuid, L
"Domain: Unknown" },
138 { SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT, NULL, L
"Firewall port" },
139 { SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT, &FirewallPortOpenGuid, L
"Firewall port: Open" },
140 { SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT, &FirewallPortCloseGuid, L
"Firewall port: Close" },
141 { SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT, &SubTypeUnknownGuid, L
"Firewall port: Unknown" },
142 { SERVICE_TRIGGER_TYPE_GROUP_POLICY, NULL, L
"Group policy change" },
143 { SERVICE_TRIGGER_TYPE_GROUP_POLICY, &MachinePolicyPresentGuid, L
"Group policy change: Machine" },
144 { SERVICE_TRIGGER_TYPE_GROUP_POLICY, &UserPolicyPresentGuid, L
"Group policy change: User" },
145 { SERVICE_TRIGGER_TYPE_GROUP_POLICY, &SubTypeUnknownGuid, L
"Group policy change: Unknown" },
146 { SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT, NULL, L
"Network endpoint" },
147 { SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT, &RpcInterfaceEventGuid, L
"Network endpoint: RPC interface" },
148 { SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT, &NamedPipeEventGuid, L
"Network endpoint: Named pipe" },
149 { SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT, &SubTypeUnknownGuid, L
"Network endpoint: Unknown" }
155 _In_opt_ PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM DataItem
165 data->Type = DataItem->dwDataType;
167 if (data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING)
169 if (DataItem->pData && DataItem->cbData >= 2)
170 data->String =
PhCreateStringEx((PWSTR)DataItem->pData, DataItem->cbData - 2);
174 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_BINARY)
176 data->BinaryLength = DataItem->cbData;
179 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL)
181 if (DataItem->cbData ==
sizeof(UCHAR))
182 data->Byte = *(PUCHAR)DataItem->pData;
184 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY || data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL)
186 if (DataItem->cbData ==
sizeof(ULONG64))
187 data->UInt64 = *(PULONG64)DataItem->pData;
202 if (newData->Type == SERVICE_TRIGGER_DATA_TYPE_STRING)
207 else if (newData->Type == SERVICE_TRIGGER_DATA_TYPE_BINARY)
210 newData->Binary =
PhAllocateCopy(newData->Binary, newData->BinaryLength);
220 if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING)
225 else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_BINARY)
235 _In_opt_ PSERVICE_TRIGGER Trigger
245 info->Type = Trigger->dwTriggerType;
247 if (Trigger->pTriggerSubtype)
249 info->SubtypeBuffer = *Trigger->pTriggerSubtype;
250 info->Subtype = &info->SubtypeBuffer;
253 info->Action = Trigger->dwAction;
256 info->Type == SERVICE_TRIGGER_TYPE_CUSTOM ||
257 info->Type == SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL ||
258 info->Type == SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT ||
259 info->Type == SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT
266 for (i = 0; i < Trigger->cDataItems; i++)
284 if (newInfo->Subtype == &Info->SubtypeBuffer)
285 newInfo->Subtype = &newInfo->SubtypeBuffer;
287 if (newInfo->DataList)
291 newInfo->DataList =
PhCreateList(Info->DataList->AllocatedCount);
292 newInfo->DataList->Count = Info->DataList->Count;
294 for (i = 0; i < Info->DataList->Count; i++)
309 for (i = 0; i < Info->DataList->Count; i++)
326 for (i = 0; i < List->Count; i++)
336 _In_ HWND WindowHandle,
344 context->ServiceItem = ServiceItem;
345 context->WindowHandle = WindowHandle;
346 context->TriggersLv = TriggersLv;
362 _In_
struct _ES_TRIGGER_CONTEXT *Context
367 for (i = 0; i < Context->InfoList->Count; i++)
401 if (publisherName && publisherName->
Length == 0)
404 publisherName = NULL;
415 return publisherName;
425 _Out_ PULONG NumberOfEntries
429 HANDLE publishersKeyHandle;
434 ULONG numberOfEntries;
435 ULONG allocatedEntries;
438 &publishersKeyHandle,
449 allocatedEntries = 256;
454 buffer = PhAllocate(0x100);
475 nameUs.Buffer = buffer->
Name;
495 if (publisherName->
Length != 0)
499 if (numberOfEntries == allocatedEntries)
501 allocatedEntries *= 2;
505 entry = &entries[numberOfEntries++];
506 entry->PublisherName = publisherName;
521 else if (status == STATUS_NO_MORE_ENTRIES)
525 else if (status == STATUS_BUFFER_OVERFLOW || status == STATUS_BUFFER_TOO_SMALL)
528 buffer = PhAllocate(bufferSize);
537 NtClose(publishersKeyHandle);
540 *NumberOfEntries = numberOfEntries;
552 ULONG numberOfEntries;
560 for (i = 0; i < numberOfEntries; i++)
564 *Guid = entries[i].Guid;
578 _Out_ PWSTR *TriggerString,
579 _Out_ PWSTR *ActionString,
584 PWSTR triggerString = NULL;
588 BOOLEAN subTypeFound;
592 case SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL:
598 triggerString = L
"Device interface arrival";
604 triggerString = stringUsed->
Buffer;
608 case SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE:
614 triggerString = L
"Custom system state change";
620 triggerString = stringUsed->
Buffer;
624 case SERVICE_TRIGGER_TYPE_CUSTOM:
634 triggerString = stringUsed->
Buffer;
638 triggerString = L
"Custom";
645 subTypeFound =
FALSE;
647 for (i = 0; i <
sizeof(SubTypeEntries) /
sizeof(
SUBTYPE_ENTRY); i++)
649 if (SubTypeEntries[i].Type == Info->Type)
653 if (!Info->Subtype && !SubTypeEntries[i].Guid)
656 triggerString = SubTypeEntries[i].Name;
659 else if (Info->Subtype && SubTypeEntries[i].Guid && memcmp(Info->Subtype, SubTypeEntries[i].Guid,
sizeof(GUID)) == 0)
662 triggerString = SubTypeEntries[i].Name;
665 else if (!subTypeFound && SubTypeEntries[i].Guid == &SubTypeUnknownGuid)
667 triggerString = SubTypeEntries[i].Name;
675 triggerString = L
"Unknown";
681 switch (Info->Action)
683 case SERVICE_TRIGGER_ACTION_SERVICE_START:
684 actionString = L
"Start";
686 case SERVICE_TRIGGER_ACTION_SERVICE_STOP:
687 actionString = L
"Stop";
690 actionString = L
"Unknown";
694 *TriggerString = triggerString;
695 *ActionString = actionString;
696 *StringUsed = stringUsed;
700 _In_
struct _ES_TRIGGER_CONTEXT *Context,
701 _In_ SC_HANDLE ServiceHandle
704 PSERVICE_TRIGGER_INFO triggerInfo;
711 for (i = 0; i < triggerInfo->cTriggers; i++)
713 PSERVICE_TRIGGER trigger = &triggerInfo->pTriggers[i];
725 lvItemIndex =
PhAddListViewItem(Context->TriggersLv, MAXINT, triggerString, info);
732 Context->InitialNumberOfTriggers = triggerInfo->cTriggers;
741 _In_
struct _ES_TRIGGER_CONTEXT *Context,
742 _Out_ PULONG Win32Result
745 BOOLEAN result =
TRUE;
747 SC_HANDLE serviceHandle;
748 SERVICE_TRIGGER_INFO triggerInfo;
757 if (Context->InitialNumberOfTriggers == 0 && Context->InfoList->Count == 0)
762 memset(&triggerInfo, 0,
sizeof(SERVICE_TRIGGER_INFO));
763 triggerInfo.cTriggers = Context->InfoList->Count;
766 if (Context->InfoList->Count != 0)
769 memset(triggerInfo.pTriggers, 0, Context->InfoList->Count *
sizeof(SERVICE_TRIGGER));
771 for (i = 0; i < Context->InfoList->Count; i++)
773 PSERVICE_TRIGGER trigger = &triggerInfo.pTriggers[i];
776 trigger->dwTriggerType = info->Type;
777 trigger->dwAction = info->Action;
778 trigger->pTriggerSubtype = info->Subtype;
780 if (info->DataList && info->DataList->Count != 0)
782 trigger->cDataItems = info->DataList->Count;
785 for (j = 0; j < info->DataList->Count; j++)
787 PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM dataItem = &trigger->pDataItems[j];
790 dataItem->dwDataType = data->Type;
792 if (data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING)
794 dataItem->cbData = (ULONG)data->String->Length + 2;
795 dataItem->pData = (PBYTE)data->String->Buffer;
797 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_BINARY)
799 dataItem->cbData = data->BinaryLength;
800 dataItem->pData = data->Binary;
802 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL)
804 dataItem->cbData =
sizeof(UCHAR);
805 dataItem->pData = (PBYTE)&data->Byte;
807 else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY || data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL)
809 dataItem->cbData =
sizeof(ULONG64);
810 dataItem->pData = (PBYTE)&data->UInt64;
817 if (serviceHandle =
PhOpenService(Context->ServiceItem->Name->Buffer, SERVICE_CHANGE_CONFIG))
819 if (!ChangeServiceConfig2(serviceHandle, SERVICE_CONFIG_TRIGGER_INFO, &triggerInfo))
822 *Win32Result = GetLastError();
825 CloseServiceHandle(serviceHandle);
830 *Win32Result = GetLastError();
832 if (*Win32Result == ERROR_ACCESS_DENIED && !
PhElevated)
842 SERVICE_CONFIG_TRIGGER_INFO, &triggerInfo)))
853 *Win32Result = ERROR_CANCELLED;
864 _In_ HWND ListViewHandle,
871 item.mask = LVIF_PARAM;
874 item.lParam = (LPARAM)Param;
876 return ListView_SetItem(ListViewHandle, &item);
880 _In_
struct _ES_TRIGGER_CONTEXT *Context,
889 Context->EditingInfo->Type = SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY;
890 Context->EditingInfo->SubtypeBuffer = NetworkManagerFirstIpAddressArrivalGuid;
891 Context->EditingInfo->Subtype = &Context->EditingInfo->SubtypeBuffer;
892 Context->EditingInfo->Action = SERVICE_TRIGGER_ACTION_SERVICE_START;
897 Context->WindowHandle,
907 Context->Dirty =
TRUE;
912 lvItemIndex =
PhAddListViewItem(Context->TriggersLv, MAXINT, triggerString, Context->EditingInfo);
923 Context->EditingInfo = NULL;
932 lvItemIndex = ListView_GetNextItem(Context->TriggersLv, -1, LVNI_SELECTED);
936 index = PhFindItemList(Context->InfoList, info);
945 Context->WindowHandle,
954 Context->Dirty =
TRUE;
956 Context->InfoList->Items[index] = Context->EditingInfo;
972 Context->EditingInfo = NULL;
983 lvItemIndex = ListView_GetNextItem(Context->TriggersLv, -1, LVNI_SELECTED);
987 index = PhFindItemList(Context->InfoList, info);
997 Context->Dirty =
TRUE;
1002 ULONG selectedCount;
1004 selectedCount = ListView_GetSelectedCount(Context->TriggersLv);
1006 EnableWindow(GetDlgItem(Context->WindowHandle,
IDC_EDIT), selectedCount == 1);
1007 EnableWindow(GetDlgItem(Context->WindowHandle,
IDC_DELETE), selectedCount == 1);
1013 static ULONG EspTriggerTypeStringToInteger(
1019 for (i = 0; i <
sizeof(TypeEntries) /
sizeof(
TYPE_ENTRY); i++)
1022 return TypeEntries[i].Type;
1028 static int __cdecl EtwPublisherByNameCompareFunction(
1029 _In_
const void *elem1,
1030 _In_
const void *elem2
1039 static VOID EspFixServiceTriggerControls(
1045 HWND subTypeComboBox;
1051 typeComboBox = GetDlgItem(hwndDlg,
IDC_TYPE);
1052 subTypeComboBox = GetDlgItem(hwndDlg,
IDC_SUBTYPE);
1055 type = EspTriggerTypeStringToInteger(selectedTypeString->
Buffer);
1058 if (Context->LastSelectedType != type)
1062 ComboBox_ResetContent(subTypeComboBox);
1066 case SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL:
1068 ComboBox_AddString(subTypeComboBox, L
"Custom");
1071 case SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE:
1073 ComboBox_AddString(subTypeComboBox, L
"Custom");
1076 case SERVICE_TRIGGER_TYPE_CUSTOM:
1079 ULONG numberOfEntries;
1082 ComboBox_AddString(subTypeComboBox, L
"Custom");
1088 qsort(entries, numberOfEntries,
sizeof(
ETW_PUBLISHER_ENTRY), EtwPublisherByNameCompareFunction);
1090 for (i = 0; i < numberOfEntries; i++)
1092 ComboBox_AddString(subTypeComboBox, entries[i].PublisherName->Buffer);
1101 for (i = 0; i <
sizeof(SubTypeEntries) /
sizeof(
SUBTYPE_ENTRY); i++)
1103 if (SubTypeEntries[i].Type == type && SubTypeEntries[i].Guid && SubTypeEntries[i].Guid != &SubTypeUnknownGuid)
1105 ComboBox_AddString(subTypeComboBox, SubTypeEntries[i].Name);
1111 ComboBox_SetCurSel(subTypeComboBox, 0);
1113 Context->LastSelectedType = type;
1145 for (i = 0; i < (ULONG)String->Length / 2; i++)
1147 if (String->Buffer[i] == 0)
1171 for (i = 0; i < String->Length / 2; i++)
1174 if (String->Buffer[i] ==
'\r')
1179 if (String->Buffer[i] ==
'\n')
1181 text->
Buffer[count++] = 0;
1185 text->
Buffer[count++] = String->Buffer[i];
1191 if (text->
Buffer[count - 1] != 0)
1192 text->
Buffer[count++] = 0;
1195 text->
Length = count * 2;
1209 for (j = 0; j < text->
Length / 2; j++)
1211 if (text->
Buffer[j] == 0)
1223 if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING)
1226 if (Data->String->Length != 0)
1236 else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_BINARY)
1240 else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL)
1244 else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY)
1248 else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL)
1267 if (uMsg == WM_INITDIALOG)
1270 SetProp(hwndDlg, L
"Context", (HANDLE)context);
1276 if (uMsg == WM_DESTROY)
1277 RemoveProp(hwndDlg, L
"Context");
1288 HWND actionComboBox;
1292 context->LastSelectedType = 0;
1294 if (context->EditingInfo->Subtype)
1295 context->LastCustomSubType =
PhFormatGuid(context->EditingInfo->Subtype);
1299 typeComboBox = GetDlgItem(hwndDlg,
IDC_TYPE);
1300 actionComboBox = GetDlgItem(hwndDlg,
IDC_ACTION);
1302 for (i = 0; i <
sizeof(TypeEntries) /
sizeof(
TYPE_ENTRY); i++)
1304 ComboBox_AddString(typeComboBox, TypeEntries[i].Name);
1306 if (TypeEntries[i].Type == context->EditingInfo->Type)
1312 ComboBox_AddString(actionComboBox, L
"Start");
1313 ComboBox_AddString(actionComboBox, L
"Stop");
1314 ComboBox_SetCurSel(actionComboBox, context->EditingInfo->Action == SERVICE_TRIGGER_ACTION_SERVICE_START ? 0 : 1);
1316 EspFixServiceTriggerControls(hwndDlg, context);
1318 if (context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_CUSTOM)
1320 for (i = 0; i <
sizeof(SubTypeEntries) /
sizeof(
SUBTYPE_ENTRY); i++)
1323 SubTypeEntries[i].Type == context->EditingInfo->Type &&
1324 SubTypeEntries[i].Guid &&
1325 context->EditingInfo->Subtype &&
1326 memcmp(SubTypeEntries[i].Guid, context->EditingInfo->Subtype,
sizeof(GUID)) == 0
1336 if (context->EditingInfo->Subtype)
1348 EspFixServiceTriggerControls(hwndDlg, context);
1350 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
1355 if (context->EditingInfo->DataList)
1357 for (i = 0; i < context->EditingInfo->DataList->Count; i++)
1363 data = context->EditingInfo->DataList->Items[i];
1382 switch (LOWORD(wParam))
1385 if (HIWORD(wParam) == CBN_SELCHANGE)
1387 EspFixServiceTriggerControls(hwndDlg, context);
1391 if (HIWORD(wParam) == CBN_SELCHANGE)
1393 EspFixServiceTriggerControls(hwndDlg, context);
1400 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
1416 data->Type = SERVICE_TRIGGER_DATA_TYPE_STRING;
1419 if (!context->EditingInfo->DataList)
1439 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
1440 lvItemIndex = ListView_GetNextItem(lvHandle, -1, LVNI_SELECTED);
1444 data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING
1447 index = PhFindItemList(context->EditingInfo->DataList, data);
1482 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
1483 lvItemIndex = ListView_GetNextItem(lvHandle, -1, LVNI_SELECTED);
1487 index = PhFindItemList(context->EditingInfo->DataList, data);
1499 EndDialog(hwndDlg, IDCANCEL);
1517 for (i = 0; i <
sizeof(TypeEntries) /
sizeof(
TYPE_ENTRY); i++)
1521 context->EditingInfo->Type = TypeEntries[i].Type;
1528 if (context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_CUSTOM)
1530 for (i = 0; i <
sizeof(SubTypeEntries) /
sizeof(
SUBTYPE_ENTRY); i++)
1533 SubTypeEntries[i].Type == context->EditingInfo->Type &&
1537 context->EditingInfo->SubtypeBuffer = *SubTypeEntries[i].Guid;
1538 context->EditingInfo->Subtype = &context->EditingInfo->SubtypeBuffer;
1547 PhShowError(hwndDlg, L
"Unable to find the ETW publisher GUID.");
1551 context->EditingInfo->Subtype = &context->EditingInfo->SubtypeBuffer;
1562 while (guidString.
Length != 0 && *guidString.Buffer ==
' ')
1564 guidString.Buffer++;
1568 while (guidString.
Length != 0 && guidString.Buffer[guidString.
Length / 2 - 1] ==
' ')
1575 context->EditingInfo->Subtype = &context->EditingInfo->SubtypeBuffer;
1579 PhShowError(hwndDlg, L
"The custom subtype is invalid. Please ensure that the string is a valid GUID: \"{x-x-x-x-x}\".");
1585 context->EditingInfo->Action = SERVICE_TRIGGER_ACTION_SERVICE_START;
1587 context->EditingInfo->Action = SERVICE_TRIGGER_ACTION_SERVICE_STOP;
1590 context->EditingInfo->DataList &&
1591 context->EditingInfo->DataList->Count != 0 &&
1592 context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL &&
1593 context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT &&
1594 context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT &&
1595 context->EditingInfo->Type != SERVICE_TRIGGER_TYPE_CUSTOM
1601 MB_OKCANCEL | MB_ICONWARNING,
1602 L
"The trigger type \"%s\" does not allow data items to be configured. "
1603 L
"If you continue, they will be removed.",
1610 for (i = 0; i < context->EditingInfo->DataList->Count; i++)
1618 EndDialog(hwndDlg, IDOK);
1629 LPNMHDR header = (LPNMHDR)lParam;
1632 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
1634 switch (header->code)
1636 case LVN_ITEMCHANGED:
1638 if (header->hwndFrom == lvHandle)
1640 if (ListView_GetSelectedCount(lvHandle) == 1)
1645 EnableWindow(GetDlgItem(hwndDlg,
IDC_EDIT), data && data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING);
1658 if (header->hwndFrom == lvHandle)
1660 SendMessage(hwndDlg, WM_COMMAND,
IDC_EDIT, 0);
1681 if (uMsg == WM_INITDIALOG)
1684 SetProp(hwndDlg, L
"Context", (HANDLE)context);
1690 if (uMsg == WM_DESTROY)
1691 RemoveProp(hwndDlg, L
"Context");
1701 SetDlgItemText(hwndDlg,
IDC_VALUES, context->EditingValue->Buffer);
1703 Edit_SetSel(GetDlgItem(hwndDlg,
IDC_VALUES), 0, -1);
1708 switch (LOWORD(wParam))
1711 EndDialog(hwndDlg, IDCANCEL);
1715 EndDialog(hwndDlg, IDOK);