Skip to content

Commit

Permalink
[RTL][NTDLL] Implement and export RtlCompareUnicodeStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
tkreuzer committed Aug 19, 2023
1 parent c332b91 commit d00d883
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dll/ntdll/def/ntdll.spec
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@
@ stdcall RtlCompareMemoryUlong(ptr long long)
@ stdcall RtlCompareString(ptr ptr long)
@ stdcall RtlCompareUnicodeString (ptr ptr long)
@ stub -version=0x600+ RtlCompareUnicodeStrings
@ stdcall -version=0x600+ RtlCompareUnicodeStrings(wstr long wstr long long)
@ stub -version=0x600+ -arch=x86_64 RtlCompleteProcessCloning
@ stdcall RtlCompressBuffer(long ptr long ptr long long ptr ptr)
@ stdcall RtlComputeCrc32(long ptr long)
Expand Down
47 changes: 47 additions & 0 deletions sdk/lib/rtl/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,53 @@ RtlCompareUnicodeString(
return ret;
}

/*
* @implemented
*/
_IRQL_requires_max_(PASSIVE_LEVEL)
_Must_inspect_result_
NTSYSAPI
LONG
NTAPI
RtlCompareUnicodeStrings(
_In_reads_(String1Length) PCWCH String1,
_In_ SIZE_T String1Length,
_In_reads_(String2Length) PCWCH String2,
_In_ SIZE_T String2Length,
_In_ BOOLEAN CaseInSensitive)
{
LONG Result = 0;
SIZE_T MinStringLength = min(String1Length, String2Length);
SIZE_T Index;

if (CaseInSensitive)
{
for (Index = 0; Index < MinStringLength; Index++)
{
WCHAR Char1 = RtlpUpcaseUnicodeChar(String1[Index]);
WCHAR Char2 = RtlpUpcaseUnicodeChar(String2[Index]);
Result = Char1 - Char2;
if (Result != 0)
{
return Result;
}
}
}
else
{
for (Index = 0; Index < MinStringLength; Index++)
{
Result = String1[Index] - String2[Index];
if (Result != 0)
{
return Result;
}
}
}

return String1Length - String2Length;
}

/*
* @implemented
*/
Expand Down

0 comments on commit d00d883

Please sign in to comment.