ReactOS  0.4.14-dev-49-gfb4591c
encode.c
Go to the documentation of this file.
1 /*
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>)
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include <rtl.h>
13 
14 #define NDEBUG
15 #include <debug.h>
16 
17 /* FUNCTIONS ***************************************************************/
18 
19 VOID NTAPI
22 {
23  PUCHAR ptr;
24  USHORT i;
25 
26  ptr = (PUCHAR)String->Buffer;
27  if (String->Length > 1)
28  {
29  for (i = String->Length; i > 1; i--)
30  {
31  ptr[i - 1] ^= ptr[i - 2] ^ Hash;
32  }
33  }
34 
35  if (String->Length >= 1)
36  {
37  ptr[0] ^= Hash | (UCHAR)0x43;
38  }
39 }
40 
41 
42 VOID NTAPI
45 {
46  LARGE_INTEGER CurrentTime;
47  PUCHAR ptr;
48  USHORT i;
50 
51  ptr = (PUCHAR) String->Buffer;
52  if (*Hash == 0)
53  {
54  Status = NtQuerySystemTime (&CurrentTime);
55  if (NT_SUCCESS(Status))
56  {
57  for (i = 1; i < sizeof(LARGE_INTEGER) && (*Hash == 0); i++)
58  *Hash |= *(PUCHAR)(((PUCHAR)&CurrentTime) + i);
59  }
60 
61  if (*Hash == 0)
62  *Hash = 1;
63  }
64 
65  if (String->Length >= 1)
66  {
67  ptr[0] ^= (*Hash) | (UCHAR)0x43;
68  if (String->Length > 1)
69  {
70  for (i = 1; i < String->Length; i++)
71  {
72  ptr[i] ^= ptr[i - 1] ^ (*Hash);
73  }
74  }
75  }
76 }
77 
78 /* EOF */
static int Hash(const char *)
Definition: reader.c:2257
#define IN
Definition: typedefs.h:38
VOID NTAPI RtlRunDecodeUnicodeString(IN UCHAR Hash, IN OUT PUNICODE_STRING String)
Definition: encode.c:20
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static PVOID ptr
Definition: dispmode.c:27
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned char UCHAR
Definition: xmlstorage.h:181
union _LARGE_INTEGER LARGE_INTEGER
Status
Definition: gdiplustypes.h:24
VOID NTAPI RtlRunEncodeUnicodeString(IN OUT PUCHAR Hash, IN OUT PUNICODE_STRING String)
Definition: encode.c:43
unsigned short USHORT
Definition: pedump.c:61
#define OUT
Definition: typedefs.h:39
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:417