2005-09-08 00:09:32 +00:00
|
|
|
/* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* PURPOSE: Security descriptor functions
|
|
|
|
* FILE: lib/rtl/encode.c
|
|
|
|
* PROGRAMMER: KJK::Hyperion <noog@libero.it>
|
|
|
|
* (code contributed by crazylord <crazyl0rd@minithins.net>)
|
2004-06-20 23:27:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2005-07-26 08:39:07 +00:00
|
|
|
#include <rtl.h>
|
2004-06-20 23:27:21 +00:00
|
|
|
|
2005-05-08 05:14:46 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2004-06-20 23:27:21 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
|
2005-10-19 17:03:38 +00:00
|
|
|
VOID NTAPI
|
2004-06-20 23:27:21 +00:00
|
|
|
RtlRunDecodeUnicodeString (IN UCHAR Hash,
|
|
|
|
IN OUT PUNICODE_STRING String)
|
|
|
|
{
|
|
|
|
PUCHAR ptr;
|
|
|
|
USHORT i;
|
|
|
|
|
|
|
|
ptr = (PUCHAR)String->Buffer;
|
|
|
|
if (String->Length > 1)
|
|
|
|
{
|
|
|
|
for (i = String->Length; i > 1; i--)
|
|
|
|
{
|
|
|
|
ptr[i - 1] ^= ptr[i - 2] ^ Hash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String->Length >= 1)
|
|
|
|
{
|
|
|
|
ptr[0] ^= Hash | (UCHAR)0x43;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-19 17:03:38 +00:00
|
|
|
VOID NTAPI
|
2004-06-20 23:27:21 +00:00
|
|
|
RtlRunEncodeUnicodeString (IN OUT PUCHAR Hash,
|
|
|
|
IN OUT PUNICODE_STRING String)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER CurrentTime;
|
|
|
|
PUCHAR ptr;
|
|
|
|
USHORT i;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
ptr = (PUCHAR) String->Buffer;
|
|
|
|
if (*Hash == 0)
|
|
|
|
{
|
|
|
|
Status = NtQuerySystemTime (&CurrentTime);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
for (i = 1; i < sizeof(LARGE_INTEGER) && (*Hash == 0); i++)
|
|
|
|
*Hash |= *(PUCHAR)(((PUCHAR)&CurrentTime) + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*Hash == 0)
|
|
|
|
*Hash = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String->Length >= 1)
|
|
|
|
{
|
|
|
|
ptr[0] ^= (*Hash) | (UCHAR)0x43;
|
|
|
|
if (String->Length > 1)
|
|
|
|
{
|
|
|
|
for (i = 1; i < String->Length; i++)
|
|
|
|
{
|
|
|
|
ptr[i] ^= ptr[i - 1] ^ (*Hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|