https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d00d883a21c9308fa9c963...
commit d00d883a21c9308fa9c96300e7e182c13f444da9 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Sat Aug 12 17:47:38 2023 +0300 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Sat Aug 19 23:52:21 2023 +0300
[RTL][NTDLL] Implement and export RtlCompareUnicodeStrings --- dll/ntdll/def/ntdll.spec | 2 +- sdk/lib/rtl/unicode.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/dll/ntdll/def/ntdll.spec b/dll/ntdll/def/ntdll.spec index 99fcbc96ed3..ee2598f8040 100644 --- a/dll/ntdll/def/ntdll.spec +++ b/dll/ntdll/def/ntdll.spec @@ -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) diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c index c29dfa4f3b8..6cd70dda1e7 100644 --- a/sdk/lib/rtl/unicode.c +++ b/sdk/lib/rtl/unicode.c @@ -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 */