TODO SLOW
| 27 | |
| 28 | // TODO SLOW |
| 29 | int 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 | |
| 50 | void Unicodestring2wcharAlloc(const UNICODE_STRING* ustr, wchar_t* dest, size_t destSize) |
no outgoing calls
no test coverage detected