ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

encode.c
Go to the documentation of this file.
00001 /* COPYRIGHT:       See COPYING in the top level directory
00002  * PROJECT:         ReactOS system libraries
00003  * PURPOSE:         Security descriptor functions
00004  * FILE:            lib/rtl/encode.c
00005  * PROGRAMMER:      KJK::Hyperion <noog@libero.it>
00006  *                  (code contributed by crazylord <crazyl0rd@minithins.net>)
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #include <rtl.h>
00012 
00013 #define NDEBUG
00014 #include <debug.h>
00015 
00016 /* FUNCTIONS ***************************************************************/
00017 
00018 VOID NTAPI
00019 RtlRunDecodeUnicodeString (IN UCHAR Hash,
00020                            IN OUT PUNICODE_STRING String)
00021 {
00022    PUCHAR ptr;
00023    USHORT i;
00024 
00025    ptr = (PUCHAR)String->Buffer;
00026    if (String->Length > 1)
00027    {
00028       for (i = String->Length; i > 1; i--)
00029       {
00030          ptr[i - 1] ^= ptr[i - 2] ^ Hash;
00031       }
00032    }
00033 
00034    if (String->Length >= 1)
00035    {
00036       ptr[0] ^= Hash | (UCHAR)0x43;
00037    }
00038 }
00039 
00040 
00041 VOID NTAPI
00042 RtlRunEncodeUnicodeString (IN OUT PUCHAR Hash,
00043                            IN OUT PUNICODE_STRING String)
00044 {
00045    LARGE_INTEGER CurrentTime;
00046    PUCHAR ptr;
00047    USHORT i;
00048    NTSTATUS Status;
00049 
00050    ptr = (PUCHAR) String->Buffer;
00051    if (*Hash == 0)
00052    {
00053       Status = NtQuerySystemTime (&CurrentTime);
00054       if (NT_SUCCESS(Status))
00055       {
00056          for (i = 1; i < sizeof(LARGE_INTEGER) && (*Hash == 0); i++)
00057             *Hash |= *(PUCHAR)(((PUCHAR)&CurrentTime) + i);
00058       }
00059 
00060       if (*Hash == 0)
00061          *Hash = 1;
00062    }
00063 
00064    if (String->Length >= 1)
00065    {
00066       ptr[0] ^= (*Hash) | (UCHAR)0x43;
00067       if (String->Length > 1)
00068       {
00069          for (i = 1; i < String->Length; i++)
00070          {
00071             ptr[i] ^= ptr[i - 1] ^ (*Hash);
00072          }
00073       }
00074    }
00075 }
00076 
00077 /* EOF */

Generated on Sun May 27 2012 04:23:14 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.