2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * PURPOSE: Security descriptor functions
5 * FILE: lib/rtl/encode.c
6 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
7 * (code contributed by crazylord <crazyl0rd@minithins.net>)
10 /* INCLUDES *****************************************************************/
17 /* FUNCTIONS ***************************************************************/
20 RtlRunDecodeUnicodeString (IN UCHAR Hash
,
21 IN OUT PUNICODE_STRING String
)
26 ptr
= (PUCHAR
)String
->Buffer
;
27 if (String
->Length
> 1)
29 for (i
= String
->Length
; i
> 1; i
--)
31 ptr
[i
- 1] ^= ptr
[i
- 2] ^ Hash
;
35 if (String
->Length
>= 1)
37 ptr
[0] ^= Hash
| (UCHAR
)0x43;
43 RtlRunEncodeUnicodeString (IN OUT PUCHAR Hash
,
44 IN OUT PUNICODE_STRING String
)
46 LARGE_INTEGER CurrentTime
;
51 ptr
= (PUCHAR
) String
->Buffer
;
54 Status
= NtQuerySystemTime (&CurrentTime
);
55 if (NT_SUCCESS(Status
))
57 for (i
= 1; i
< sizeof(LARGE_INTEGER
) && (*Hash
== 0); i
++)
58 *Hash
|= *(PUCHAR
)(((PUCHAR
)&CurrentTime
) + i
);
65 if (String
->Length
>= 1)
67 ptr
[0] ^= (*Hash
) | (UCHAR
)0x43;
68 if (String
->Length
> 1)
70 for (i
= 1; i
< String
->Length
; i
++)
72 ptr
[i
] ^= ptr
[i
- 1] ^ (*Hash
);