[ros-diffs] [weiden] 16226: implemented RtlHashUnicodeString and export it in ntdll

weiden at svn.reactos.com weiden at svn.reactos.com
Wed Jun 22 23:01:19 CEST 2005


implemented RtlHashUnicodeString and export it in ntdll
Modified: trunk/reactos/include/ndk/umtypes.h
Modified: trunk/reactos/lib/ntdll/def/ntdll.def
Modified: trunk/reactos/lib/rtl/unicode.c
  _____  

Modified: trunk/reactos/include/ndk/umtypes.h
--- trunk/reactos/include/ndk/umtypes.h	2005-06-22 20:51:22 UTC (rev
16225)
+++ trunk/reactos/include/ndk/umtypes.h	2005-06-22 21:01:13 UTC (rev
16226)
@@ -184,6 +184,11 @@

 #define VER_CONDITION_MASK              7
 #define VER_NUM_BITS_PER_CONDITION_MASK 3
 
+/* RTL String Hash Algorithms */
+#define HASH_STRING_ALGORITHM_DEFAULT   0
+#define HASH_STRING_ALGORITHM_X65599    1
+#define HASH_STRING_ALGORITHM_INVALID   0xffffffff
+
 /* List Macros */
 static __inline 
 VOID
  _____  

Modified: trunk/reactos/lib/ntdll/def/ntdll.def
--- trunk/reactos/lib/ntdll/def/ntdll.def	2005-06-22 20:51:22 UTC
(rev 16225)
+++ trunk/reactos/lib/ntdll/def/ntdll.def	2005-06-22 21:01:13 UTC
(rev 16226)
@@ -475,6 +475,7 @@

 RtlGetSecurityDescriptorRMControl at 8
 ;RtlGetUserInfoHeap
 RtlGetVersion at 4
+RtlHashUnicodeString at 16
 RtlIdentifierAuthoritySid at 4
 RtlImageDirectoryEntryToData at 16
 RtlImageNtHeader at 4
  _____  

Modified: trunk/reactos/lib/rtl/unicode.c
--- trunk/reactos/lib/rtl/unicode.c	2005-06-22 20:51:22 UTC (rev
16225)
+++ trunk/reactos/lib/rtl/unicode.c	2005-06-22 21:01:13 UTC (rev
16226)
@@ -1603,19 +1603,55 @@

 }
 
 /*
-* @unimplemented
+* @implemented
 */
 NTSTATUS
 STDCALL
 RtlHashUnicodeString(
-	IN const UNICODE_STRING *String,
-	IN BOOLEAN CaseInSensitive,
-	IN ULONG HashAlgorithm,
-	OUT PULONG HashValue
-	)
+  IN CONST UNICODE_STRING *String,
+  IN BOOLEAN CaseInSensitive,
+  IN ULONG HashAlgorithm,
+  OUT PULONG HashValue)
 {
-	UNIMPLEMENTED;
-	return STATUS_NOT_IMPLEMENTED;
+    if (String != NULL && HashValue != NULL)
+    {
+        switch (HashAlgorithm)
+        {
+            case HASH_STRING_ALGORITHM_DEFAULT:
+            case HASH_STRING_ALGORITHM_X65599:
+            {
+                WCHAR *c, *end;
+
+                *HashValue = 0;
+                end = String->Buffer + (String->Length /
sizeof(WCHAR));
+
+                if (CaseInSensitive)
+                {
+                    for (c = String->Buffer;
+                         c != end;
+                         c++)
+                    {
+                        /* only uppercase characters if they are 'a'
... 'z'! */
+                        *HashValue = ((65599 * (*HashValue)) +
+                                      (ULONG)(((*c) >= L'a' && (*c) <=
L'z') ?
+                                              (*c) - L'a' + L'A' :
(*c)));
+                    }
+                }
+                else
+                {
+                    for (c = String->Buffer;
+                         c != end;
+                         c++)
+                    {
+                        *HashValue = ((65599 * (*HashValue)) +
(ULONG)(*c));
+                    }
+                }
+                return STATUS_SUCCESS;
+            }
+        }
+    }
+
+    return STATUS_INVALID_PARAMETER;
 }
 
 /*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20050622/ae77c643/attachment.html


More information about the Ros-diffs mailing list