3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Security descriptor functions
6 * FILE: lib/ntdll/rtl/encode.c
7 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * 02/04/2003: created (code contributed by crazylord
10 * <crazyl0rd@minithins.net>)
13 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
17 #include <ntdll/ntdll.h>
19 /* FUNCTIONS ***************************************************************/
23 RtlRunDecodeUnicodeString(
25 IN OUT PUNICODE_STRING uString
31 ptr = (UCHAR *) uString->Buffer;
32 if (uString->Length > 1) {
33 for (i=uString->Length; i>1; i--) {
34 ptr[i-1] ^= ptr[i-2] ^ hash;
38 if (uString->Length >= 1) {
39 ptr[0] ^= hash | (UCHAR) 0x43;
45 RtlRunEncodeUnicodeString(
47 IN OUT PUNICODE_STRING uString
55 ptr = (UCHAR *) uString->Buffer;
57 ntS = NtQuerySystemTime((PLARGE_INTEGER)&CurrentTime);
58 if (NT_SUCCESS(ntS)) {
59 for (i=1; i<sizeof(TIME) && (*hash == 0); i++)
60 *hash |= *(PUCHAR) (((PUCHAR) &CurrentTime)+i);
67 if (uString->Length >= 1) {
68 ptr[0] ^= (*hash) | (UCHAR) 0x43;
69 if (uString->Length > 1) {
70 for (i=1; i<uString->Length; i++) {
71 ptr[i] ^= ptr[i-1] ^ (*hash);