35 if (Buffer == NULL || Length < headerSize || (Length - headerSize) %
sizeof(WCHAR) != 0) {
36 return STATUS_INVALID_PARAMETER;
40 ULONG count = request->
Count;
42 return STATUS_INVALID_PARAMETER;
47 const WCHAR* names = request->
Names;
48 ULONG remaining = (Length - headerSize) /
sizeof(WCHAR);
50 for (ULONG i = 0; i < count; i++) {
52 while (position + nameLength < remaining && names[position + nameLength] != L
'\0') {
55 if (position + nameLength >= remaining || nameLength == 0 ||
57 return STATUS_INVALID_PARAMETER;
59 position += nameLength + 1;
61 if (position != remaining) {
62 return STATUS_INVALID_PARAMETER;
68 SIZE_T namesOffset = FIELD_OFFSET(
INJECT_EXCLUSION_LIST, Names) + (SIZE_T)count *
sizeof(UNICODE_STRING);
70 if (newList == NULL) {
71 return STATUS_INSUFFICIENT_RESOURCES;
74 PWCHAR characters = (PWCHAR)((PUCHAR)newList + namesOffset);
75 RtlCopyMemory(characters, names, (SIZE_T)position *
sizeof(WCHAR));
77 newList->
Count = count;
78 PWCHAR name = characters;
79 for (ULONG i = 0; i < count; i++) {
81 USHORT nameLength = (USHORT)wcslen(name);
84 for (USHORT c = 0; c < nameLength; c++) {
85 name[c] = RtlUpcaseUnicodeChar(name[c]);
87 newList->
Names[i].Buffer = name;
88 newList->
Names[i].Length = nameLength *
sizeof(WCHAR);
89 newList->
Names[i].MaximumLength = newList->
Names[i].Length +
sizeof(WCHAR);
90 name += nameLength + 1;
91 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL,
"[+] Panoptes: Do not inject: %wZ\n", &newList->
Names[i]);
95 KeEnterCriticalRegion();
96 ExAcquirePushLockExclusive(&g_ListLock);
99 ExReleasePushLockExclusive(&g_ListLock);
100 KeLeaveCriticalRegion();
102 if (oldList != NULL) {
106 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL,
"[+] Panoptes: Injection exclusion list set (%lu names)\n", count);
107 return STATUS_SUCCESS;
124 if (ProcessImagePath == NULL || ProcessImagePath->Buffer == NULL || ProcessImagePath->Length == 0) {
129 USHORT totalChars = ProcessImagePath->Length /
sizeof(WCHAR);
130 USHORT start = totalChars;
131 while (start > 0 && ProcessImagePath->Buffer[start - 1] != L
'\\') {
135 UNICODE_STRING fileName;
136 fileName.Buffer = ProcessImagePath->Buffer + start;
137 fileName.Length = (totalChars - start) *
sizeof(WCHAR);
138 fileName.MaximumLength = fileName.Length;
139 if (fileName.Length == 0) {
143 BOOLEAN excluded = FALSE;
144 KeEnterCriticalRegion();
145 ExAcquirePushLockShared(&g_ListLock);
146 if (g_List != NULL) {
147 for (ULONG i = 0; i < g_List->Count; i++) {
150 PCUNICODE_STRING entry = &g_List->Names[i];
151 PCUNICODE_STRING candidate = (entry->Buffer[0] == L
'\\') ? ProcessImagePath : &fileName;
155 BOOLEAN matched = HasWildcard(entry) ?
156 FsRtlIsNameInExpression((PUNICODE_STRING)entry, (PUNICODE_STRING)candidate, TRUE, NULL) :
157 RtlEqualUnicodeString(candidate, entry, TRUE);
164 ExReleasePushLockShared(&g_ListLock);
165 KeLeaveCriticalRegion();