Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created August 5, 2017 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/b311654133ef070a69f07d978203692d to your computer and use it in GitHub Desktop.
Save blaquee/b311654133ef070a69f07d978203692d to your computer and use it in GitHub Desktop.
Misc Unicode helpers
BOOL RtlEndsWithUnicodeString(PUNICODE_STRING Source, PUNICODE_STRING Find)
{
if (Source->Length == Find->Length ||
(Find->Length > Source->Length))
{
//do a regular RtlEqualUnicodeString?
return FALSE;
}
USHORT bytesDif = Source->Length - Find->Length;
USHORT strLen = bytesDif / sizeof(WCHAR);
const UNICODE_STRING endStr =
{
Source->Length - bytesDif,
Source->MaximumLength - bytesDif,
Source->Buffer + strLen
};
return RtlEqualUnicodeString_(&endStr, Find, TRUE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment