ReactOS 0.4.15-dev-7931-gfd331f1
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)
void TestEncrypt(ULONG OptionFlags)
void TestCrossProcessEncrypt(ULONG OptionFlags)
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2003
Status
Definition: gdiplustypes.h:25
#define RTL_ENCRYPT_OPTION_SAME_LOGON
Definition: ksecdd.h:27
#define RTL_ENCRYPT_OPTION_SAME_PROCESS
Definition: ksecdd.h:25
#define RTL_ENCRYPT_OPTION_CROSS_PROCESS
Definition: ksecdd.h:26
#define RtlEncryptMemory
Definition: ntsecapi.h:692
char * PSTR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175

◆ 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
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}
#define ok_int(expression, result)
Definition: atltest.h:134
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define RtlEqualMemory(a, b, c)
Definition: kdvm.h:18
unsigned int UINT
Definition: ndis.h:50
#define RtlDecryptMemory
Definition: ntsecapi.h:693
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: xmlstorage.h:181

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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MAX_PATH
Definition: compat.h:34
static const WCHAR CmdLine[]
Definition: install.c:48
GLuint64EXT * result
Definition: glext.h:11304
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int __cdecl system(_In_opt_z_ const char *_Command)
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by START_TEST().

◆ TestEncrypt()

void TestEncrypt ( ULONG  OptionFlags)

Definition at line 14 of file RtlEncryptMemory.c.

15{
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}
#define ok(value,...)
Definition: atltest.h:57
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
#define DECLSPEC_ALIGN(x)
Definition: ntbasedef.h:251
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

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.