1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS system libraries
3 * PURPOSE: Security descriptor functions
4 * FILE: lib/rtl/encode.c
5 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
6 * (code contributed by crazylord <crazyl0rd@minithins.net>)
9 /* INCLUDES *****************************************************************/
16 /* FUNCTIONS ***************************************************************/
19 RtlRunDecodeUnicodeString (IN UCHAR Hash
,
20 IN OUT PUNICODE_STRING String
)
25 ptr
= (PUCHAR
)String
->Buffer
;
26 if (String
->Length
> 1)
28 for (i
= String
->Length
; i
> 1; i
--)
30 ptr
[i
- 1] ^= ptr
[i
- 2] ^ Hash
;
34 if (String
->Length
>= 1)
36 ptr
[0] ^= Hash
| (UCHAR
)0x43;
42 RtlRunEncodeUnicodeString (IN OUT PUCHAR Hash
,
43 IN OUT PUNICODE_STRING String
)
45 LARGE_INTEGER CurrentTime
;
50 ptr
= (PUCHAR
) String
->Buffer
;
53 Status
= NtQuerySystemTime (&CurrentTime
);
54 if (NT_SUCCESS(Status
))
56 for (i
= 1; i
< sizeof(LARGE_INTEGER
) && (*Hash
== 0); i
++)
57 *Hash
|= *(PUCHAR
)(((PUCHAR
)&CurrentTime
) + i
);
64 if (String
->Length
>= 1)
66 ptr
[0] ^= (*Hash
) | (UCHAR
)0x43;
67 if (String
->Length
> 1)
69 for (i
= 1; i
< String
->Length
; i
++)
71 ptr
[i
] ^= ptr
[i
- 1] ^ (*Hash
);