--- 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
--- 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@8
;RtlGetUserInfoHeap
RtlGetVersion@4
+RtlHashUnicodeString@16
RtlIdentifierAuthoritySid@4
RtlImageDirectoryEntryToData@16
RtlImageNtHeader@4
--- 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;
}
/*