Nikolay Sivov : ntdll: Implement RtlHashUnicodeString().

Alexandre Julliard julliard at winehq.org
Wed Jul 24 14:55:27 CDT 2013


Module: wine
Branch: master
Commit: 9e5097187ed85289162227e11306baadda548ec8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9e5097187ed85289162227e11306baadda548ec8

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Jul 20 09:15:34 2013 +0400

ntdll: Implement RtlHashUnicodeString().

---

 dlls/ntdll/ntdll.spec               |    2 +-
 dlls/ntdll/ntdll_misc.h             |    4 ++++
 dlls/ntdll/rtlstr.c                 |   25 +++++++++++++++++++++++++
 dlls/ntdll/tests/rtlstr.c           |    2 +-
 dlls/ntoskrnl.exe/ntoskrnl.exe.spec |    2 +-
 5 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 0d4d62d..910ded5 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -651,7 +651,7 @@
 @ stub RtlGetUserInfoHeap
 @ stdcall RtlGetVersion(ptr)
 @ stub RtlGuidToPropertySetName
-# @ stub RtlHashUnicodeString
+@ stdcall RtlHashUnicodeString(ptr long long ptr)
 @ stdcall RtlIdentifierAuthoritySid(ptr)
 @ stdcall RtlImageDirectoryEntryToData(long long long ptr)
 @ stdcall RtlImageNtHeader(long)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 146ce50..d2d0764 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -257,4 +257,8 @@ extern mode_t FILE_umask DECLSPEC_HIDDEN;
                        "ret $(4*" #args ")" ) /* fake ret to make copy protections happy */
 #endif
 
+#define HASH_STRING_ALGORITHM_DEFAULT  0
+#define HASH_STRING_ALGORITHM_X65599   1
+#define HASH_STRING_ALGORITHM_INVALID  0xffffffff
+
 #endif
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index 4e9614c..b092772 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -2138,3 +2138,28 @@ NTSTATUS WINAPI RtlStringFromGUID(const GUID* guid, UNICODE_STRING *str)
 
   return STATUS_SUCCESS;
 }
+
+/******************************************************************************
+ * RtlHashUnicodeString [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING string, BOOLEAN case_insensitive, ULONG alg, ULONG *hash)
+{
+    unsigned int i;
+
+    if (!string || !hash) return STATUS_INVALID_PARAMETER;
+
+    switch (alg)
+    {
+    case HASH_STRING_ALGORITHM_DEFAULT:
+    case HASH_STRING_ALGORITHM_X65599:
+        break;
+    default:
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    *hash = 0;
+    for (i = 0; i < string->Length/sizeof(WCHAR); i++)
+        *hash = *hash*65599 + (case_insensitive ? toupperW(string->Buffer[i]) : string->Buffer[i]);
+
+    return STATUS_SUCCESS;
+}
diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c
index e8524da..240fe61 100644
--- a/dlls/ntdll/tests/rtlstr.c
+++ b/dlls/ntdll/tests/rtlstr.c
@@ -1935,7 +1935,7 @@ static void test_RtlHashUnicodeString(void)
 
     if (!pRtlHashUnicodeString)
     {
-        skip("RtlHashUnicodeString is not available\n");
+        win_skip("RtlHashUnicodeString is not available\n");
         return;
     }
 
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 10ff0ab..2d221ef 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -1046,7 +1046,7 @@
 @ stdcall RtlGetSaclSecurityDescriptor(ptr ptr ptr ptr) ntdll.RtlGetSaclSecurityDescriptor
 @ stub RtlGetSetBootStatusData
 @ stdcall RtlGetVersion(ptr) ntdll.RtlGetVersion
-@ stub RtlHashUnicodeString
+@ stdcall RtlHashUnicodeString(ptr long long ptr) ntdll.RtlHashUnicodeString
 @ stdcall RtlImageDirectoryEntryToData(long long long ptr) ntdll.RtlImageDirectoryEntryToData
 @ stdcall RtlImageNtHeader(long) ntdll.RtlImageNtHeader
 @ stdcall RtlInitAnsiString(ptr str) ntdll.RtlInitAnsiString




More information about the wine-cvs mailing list