ReactOS  0.4.15-dev-3719-g41b8715
RtlEncryptMemory.c File Reference
#include "precomp.h"
#include <ntsecapi.h>
Include dependency graph for RtlEncryptMemory.c:

Go to the source code of this file.

Functions

void TestEncrypt (ULONG OptionFlags)
 
void TestCrossProcessDecrypt (PSTR Param)
 
void TestCrossProcessEncrypt (ULONG OptionFlags)
 
 START_TEST (RtlEncryptMemory)
 

Variables

static const CHAR TestData [32] = "This is some test Message!!!"
 

Function Documentation

◆ START_TEST()

START_TEST ( RtlEncryptMemory  )

Definition at line 96 of file RtlEncryptMemory.c.

97 {
98  CHAR Buffer[8] = { 0 };
99  PSTR CommandLine, Param;
101 
102  /* Check recursive call */
103  CommandLine = GetCommandLineA();
104  Param = strstr(CommandLine, "-cp");
105  if (Param != NULL)
106  {
108  return;
109  }
110 
114 
115  Status = RtlEncryptMemory(Buffer, sizeof(Buffer), 4);
117 
120 }
void TestCrossProcessDecrypt(PSTR Param)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS
Definition: ksecdd.h:26
void TestCrossProcessEncrypt(ULONG OptionFlags)
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
void TestEncrypt(ULONG OptionFlags)
#define RTL_ENCRYPT_OPTION_SAME_PROCESS
Definition: ksecdd.h:25
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2004
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
signed char * PSTR
Definition: retypes.h:7
#define NULL
Definition: types.h:112
NTSTATUS WINAPI RtlEncryptMemory(PVOID Memory, ULONG MemorySize, ULONG OptionFlags)
#define ok_ntstatus(status, expected)
Definition: atltest.h:135

◆ TestCrossProcessDecrypt()

void TestCrossProcessDecrypt ( PSTR  Param)

Definition at line 43 of file RtlEncryptMemory.c.

44 {
45  UCHAR Buffer[32] = { 0 };
46  ULONG OptionFlags;
47  PSTR StrData;
48  ULONG i;
50 
51  OptionFlags = Param[3] == '1' ? RTL_ENCRYPT_OPTION_CROSS_PROCESS : RTL_ENCRYPT_OPTION_SAME_LOGON;
52 
53  /* Convert the HEX string to binary ('-cp<1|2>:<data>') */
54  StrData = Param + 5;
55  for (i = 0; i < sizeof(Buffer); i++)
56  {
57  UINT x;
58  sscanf(&StrData[2 * i], "%02X", &x);
59  Buffer[i] = (UCHAR)x;
60  }
61 
62  /* Decrypt the data */
63  Status = RtlDecryptMemory(Buffer, sizeof(Buffer), OptionFlags);
66 }
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
LONG NTSTATUS
Definition: precomp.h:26
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS
Definition: ksecdd.h:26
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define ok_int(expression, result)
Definition: atltest.h:134
Definition: bufpool.h:45
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
NTSTATUS WINAPI RtlDecryptMemory(PVOID Memory, ULONG MemorySize, ULONG OptionFlags)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
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
signed char * PSTR
Definition: retypes.h:7
unsigned int UINT
Definition: ndis.h:50
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by START_TEST().

◆ TestCrossProcessEncrypt()

void TestCrossProcessEncrypt ( ULONG  OptionFlags)

Definition at line 68 of file RtlEncryptMemory.c.

69 {
70  UCHAR Buffer[32];
72  PSTR StrBuffer;
74  ULONG i;
75  INT result;
76 
77  /* Encrypt the test string */
79  Status = RtlEncryptMemory(Buffer, sizeof(Buffer), OptionFlags);
81 
82  /* Start building a command line */
83  sprintf(CmdLine, "advapi32_apitest.exe RtlEncryptMemory -cp%lu:", OptionFlags);
84  StrBuffer = CmdLine + strlen(CmdLine);
85 
86  /* Convert encrypted data into a hex string */
87  for (i = 0; i < sizeof(Buffer); i++)
88  {
89  sprintf(&StrBuffer[2 * i], "%02X", Buffer[i]);
90  }
91 
93  ok_int(result, 0);
94 }
GLuint64EXT * result
Definition: glext.h:11304
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
int32_t INT
Definition: typedefs.h:58
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static const WCHAR CmdLine[]
Definition: install.c:48
#define ok_int(expression, result)
Definition: atltest.h:134
Definition: bufpool.h:45
int __cdecl system(_In_opt_z_ const char *_Command)
Status
Definition: gdiplustypes.h:24
#define MAX_PATH
Definition: compat.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
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
signed char * PSTR
Definition: retypes.h:7
NTSTATUS WINAPI RtlEncryptMemory(PVOID Memory, ULONG MemorySize, ULONG OptionFlags)
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by START_TEST().

◆ TestEncrypt()

void TestEncrypt ( ULONG  OptionFlags)

Definition at line 14 of file RtlEncryptMemory.c.

15 {
16  CHAR DECLSPEC_ALIGN(8) Buffer[32];
18 
19  /* Size must be aligned to 8 bytes (aka RTL_ENCRYPT_MEMORY_SIZE) */
21  Status = RtlEncryptMemory(Buffer, 7, OptionFlags);
23 
24  /* Buffer can be unaligned */
26  Status = RtlEncryptMemory(&Buffer[1], 8, OptionFlags);
28  Status = RtlDecryptMemory(&Buffer[1], 8, OptionFlags);
31  "OptionFlags=%lu, Buffer='%s', TestData='%s'\n",
32  OptionFlags, Buffer, TestData);
33 
35  Status = RtlEncryptMemory(Buffer, sizeof(Buffer), OptionFlags);
38  Status = RtlDecryptMemory(Buffer, sizeof(Buffer), OptionFlags);
41 }
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
GLdouble n
Definition: glext.h:7729
#define DECLSPEC_ALIGN(x)
Definition: ntbasedef.h:251
#define ok_int(expression, result)
Definition: atltest.h:134
Definition: bufpool.h:45
NTSTATUS WINAPI RtlDecryptMemory(PVOID Memory, ULONG MemorySize, ULONG OptionFlags)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
GLdouble s
Definition: gl.h:2039
#define ok(value,...)
Definition: atltest.h:57
NTSTATUS WINAPI RtlEncryptMemory(PVOID Memory, ULONG MemorySize, ULONG OptionFlags)
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by START_TEST().

Variable Documentation

◆ TestData

const CHAR TestData[32] = "This is some test Message!!!"
static

Definition at line 12 of file RtlEncryptMemory.c.