MCPcopy Create free account
hub / github.com/dobin/RedEdr / IsSubstringInUnicodeString

Function IsSubstringInUnicodeString

RedEdrDriver/utils.c:29–47  ·  view source on GitHub ↗

TODO SLOW

Source from the content-addressed store, hash-verified

27
28// TODO SLOW
29int IsSubstringInUnicodeString(PUNICODE_STRING pDestString, PCWSTR pSubString) {
30 if (pDestString->Length == 0 || pDestString->Buffer == NULL || pSubString == NULL) {
31 return FALSE;
32 }
33 size_t lengthInWchars = pDestString->Length / sizeof(WCHAR);
34 WCHAR tempBuffer[PATH_LEN];
35
36 // Ensure we don't overflow the temp buffer
37 if (lengthInWchars >= sizeof(tempBuffer) / sizeof(WCHAR)) {
38 return FALSE;
39 }
40
41 // Safely copy and null-terminate
42 RtlCopyMemory(tempBuffer, pDestString->Buffer, pDestString->Length);
43 tempBuffer[lengthInWchars] = L'\0';
44
45 int result = wcsstr(tempBuffer, pSubString) != NULL;
46 return result;
47}
48
49
50void Unicodestring2wcharAlloc(const UNICODE_STRING* ustr, wchar_t* dest, size_t destSize)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected