ReactOS 0.4.16-dev-106-g10b08aa
NtQuerySystemEnvironmentValue.c File Reference
#include "precomp.h"
Include dependency graph for NtQuerySystemEnvironmentValue.c:

Go to the source code of this file.

Classes

struct  _TEST_CASE
 

Macros

#define MIN_BUFFER_LENGTH   4L
 
#define MAX_BUFFER_LENGTH   2048L
 
#define COUNT_OF(x)   (sizeof((x))/sizeof((x)[0]))
 

Typedefs

typedef struct _TEST_CASE TEST_CASE
 
typedef struct _TEST_CASEPTEST_CASE
 

Functions

static void Test_API (IN ULONG TestNumber, IN PTEST_CASE TestCase)
 
 START_TEST (NtQuerySystemEnvironmentValue)
 

Variables

static TEST_CASE TestCases []
 

Macro Definition Documentation

◆ COUNT_OF

#define COUNT_OF (   x)    (sizeof((x))/sizeof((x)[0]))

Definition at line 14 of file NtQuerySystemEnvironmentValue.c.

◆ MAX_BUFFER_LENGTH

#define MAX_BUFFER_LENGTH   2048L

Definition at line 12 of file NtQuerySystemEnvironmentValue.c.

◆ MIN_BUFFER_LENGTH

#define MIN_BUFFER_LENGTH   4L

Definition at line 11 of file NtQuerySystemEnvironmentValue.c.

Typedef Documentation

◆ PTEST_CASE

◆ TEST_CASE

Function Documentation

◆ START_TEST()

Definition at line 103 of file NtQuerySystemEnvironmentValue.c.

104{
105 ULONG i;
106
107 for (i = 0 ; i < COUNT_OF(TestCases) ; ++i)
108 {
109 Test_API(i, &TestCases[i]);
110 }
111}
static TEST_CASE TestCases[]
static void Test_API(IN ULONG TestNumber, IN PTEST_CASE TestCase)
#define COUNT_OF(x)
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
uint32_t ULONG
Definition: typedefs.h:59

◆ Test_API()

static void Test_API ( IN ULONG  TestNumber,
IN PTEST_CASE  TestCase 
)
static

Definition at line 49 of file NtQuerySystemEnvironmentValue.c.

51{
53 BOOLEAN WasEnabled = FALSE;
54 WCHAR ValueBuffer[MAX_BUFFER_LENGTH / sizeof(WCHAR)];
56
57 //
58 // Adjust the privileges if asked for (we need to
59 // have already administrator privileges to do so).
60 //
61 if (TestCase->AdjustPrivileges)
62 {
64 TRUE,
65 FALSE,
66 &WasEnabled);
67 ok(NT_SUCCESS(Status), "RtlAdjustPrivilege(%lu) failed : 0x%08lx\n", TestNumber, Status);
68 }
69
70 //
71 // Get the system environment value and set the privilege back.
72 //
74 ValueBuffer,
75 TestCase->ValueBufferLength,
77
78 if (TestCase->AdjustPrivileges)
79 {
81 WasEnabled,
82 FALSE,
83 &WasEnabled);
84 }
85
86 //
87 // Now check the results.
88 //
89 ok(Status == TestCase->Result,
90 "NtQuerySystemEnvironmentValue(%lu) failed : returned 0x%08lx, expected 0x%08lx\n",
91 TestNumber,
92 Status,
93 TestCase->Result);
94
95 ok( ((TestCase->MinimalExpectedReturnedLength <= ReturnedLength) && (ReturnedLength <= TestCase->MaximalExpectedReturnedLength)),
96 "NtQuerySystemEnvironmentValue(%lu) failed : returned length %lu, expected between %lu and %lu\n",
97 TestNumber,
99 TestCase->MinimalExpectedReturnedLength,
100 TestCase->MaximalExpectedReturnedLength);
101}
#define MAX_BUFFER_LENGTH
unsigned char BOOLEAN
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE
Definition: security.c:676
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSTATUS NTAPI NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName, OUT PWSTR ValueBuffer, IN ULONG ValueBufferLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: sysinfo.c:385
#define STATUS_SUCCESS
Definition: shellext.h:65
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

Variable Documentation

◆ TestCases

TEST_CASE TestCases[]
static
Initial value:
=
{
{STATUS_UNSUCCESSFUL , RTL_CONSTANT_STRING(L"NonExistent"), TRUE , 0, 0, 0},
{STATUS_PRIVILEGE_NOT_HELD, RTL_CONSTANT_STRING(L"LastKnownGood"), FALSE, 0, 0, 0},
}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define MIN_BUFFER_LENGTH
#define L(x)
Definition: ntvdm.h:50
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Definition at line 26 of file NtQuerySystemEnvironmentValue.c.

Referenced by START_TEST().