mirror of
https://github.com/reactos/reactos.git
synced 2024-11-07 15:10:53 +00:00
c2d0d784c7
- Create a branch to do a proper merge of USB work from a trunk base instead of from cmake-bringup - In the future, DO NOT under any circumstances branch another branch. This leads to merge problems! svn path=/branches/usb-bringup-trunk/; revision=55018
77 lines
1.7 KiB
C
77 lines
1.7 KiB
C
/* 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>)
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include <rtl.h>
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
VOID NTAPI
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
VOID NTAPI
|
|
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 */
|