ReactOS 0.4.15-dev-7842-g558ab78
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
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
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 */
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static int Hash(const char *)
Definition: reader.c:2257
Status
Definition: gdiplustypes.h:25
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
if(dx< 0)
Definition: linetemp.h:194
static PVOID ptr
Definition: dispmode.c:27
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:483
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI RtlRunEncodeUnicodeString(IN OUT PUCHAR Hash, IN OUT PUNICODE_STRING String)
Definition: encode.c:43
VOID NTAPI RtlRunDecodeUnicodeString(IN UCHAR Hash, IN OUT PUNICODE_STRING String)
Definition: encode.c:20
#define NTAPI
Definition: typedefs.h:36
union _LARGE_INTEGER LARGE_INTEGER
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
unsigned char UCHAR
Definition: xmlstorage.h:181