Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

rtsetopt.c File Reference

#include "cmp.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Defines

#define WORK_SIZE   1024

Functions

void __cdecl main (int, char **)
void processargs ()
void processargs (int argc, char *argv[])

Variables

ULONG failure = 0
UNICODE_STRING KeyPath
UCHAR TestData []
UNICODE_STRING WorkName
WCHAR workbuffer [2 *CM_MAX_STASH]
LONG testvector0 [] = { 0, 3, 4, 5, -1 }
LONG testvector1 []
LONG testvector2 []
LONG testvector3 []
PLONG supervector []


Define Documentation

#define WORK_SIZE   1024
 

Definition at line 41 of file rtsetopt.c.


Function Documentation

void __cdecl main int  ,
char ** 
 

Definition at line 73 of file rtsetopt.c.

References CM_MAX_STASH, exit, failure, KeyPath, L, NT_SUCCESS, NtDeleteValueKey(), NtOpenKey(), NtQueryValueKey(), NtSetValueKey(), NTSTATUS(), NULL, ObjectAttributes, processargs(), RtlCopyString(), RtlInitUnicodeString(), supervector, TestData, testvector0, ValueName, WORK_SIZE, workbuffer, and WorkName.

00077 { 00078 NTSTATUS status; 00079 OBJECT_ATTRIBUTES ObjectAttributes; 00080 HANDLE BaseHandle; 00081 UNICODE_STRING ValueName; 00082 ULONG ResultLength; 00083 PKEY_VALUE_FULL_INFORMATION pvaluefull; 00084 PKEY_VALUE_PARTIAL_INFORMATION pvaluepart; 00085 ULONG i; 00086 ULONG index; 00087 LONG testsize; 00088 PUCHAR p; 00089 PLONG activevector; 00090 00091 00092 for (i = 0; i < 2 * CM_MAX_STASH; i++) { 00093 workbuffer[i] = 'e'; 00094 } 00095 00096 // 00097 // Process args 00098 // 00099 processargs(argc, argv); 00100 00101 00102 // 00103 // Open the specified keypath, punt on failure 00104 // 00105 printf("rtsetopt: starting\n"); 00106 00107 WorkName.MaximumLength = WORK_SIZE; 00108 WorkName.Length = 0L; 00109 WorkName.Buffer = &(workbuffer[0]); 00110 00111 RtlCopyString((PSTRING)&WorkName, (PSTRING)&KeyPath); 00112 00113 InitializeObjectAttributes( 00114 &ObjectAttributes, 00115 &WorkName, 00116 0, 00117 (HANDLE)NULL, 00118 NULL 00119 ); 00120 ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE; 00121 00122 status = NtOpenKey( 00123 &BaseHandle, 00124 MAXIMUM_ALLOWED, 00125 &ObjectAttributes 00126 ); 00127 if (!NT_SUCCESS(status)) { 00128 printf("line_%4d: abort %08lx\n", __LINE__, status); 00129 failure++; 00130 goto punt; 00131 } 00132 00133 00134 // 00135 // Perform new value entry tests, with an empty list. 00136 // 00137 RtlInitUnicodeString( 00138 &ValueName, 00139 L"NewValueTest1" 00140 ); 00141 00142 for (index = 0; testvector0[index] != -1; index++) { 00143 00144 testsize = testvector0[index]; 00145 00146 printf("AT line_%4d: %d\n", __LINE__, testsize); 00147 00148 status = NtSetValueKey( 00149 BaseHandle, 00150 &ValueName, 00151 1, 00152 REG_BINARY, 00153 &(TestData[0]), 00154 testsize 00155 ); 00156 if (!NT_SUCCESS(status)) { 00157 printf("line_%4d: %08lx\n", __LINE__, status); 00158 failure++; 00159 } 00160 00161 printf("AT line_%4d: %d\n", __LINE__, testsize); 00162 for (i = 0; i < WORK_SIZE; i++) workbuffer[i] = '?'; 00163 status = NtQueryValueKey( 00164 BaseHandle, 00165 &ValueName, 00166 KeyValueFullInformation, 00167 &(workbuffer[0]), 00168 WORK_SIZE, 00169 &ResultLength 00170 ); 00171 if (!NT_SUCCESS(status)) { 00172 printf("line_%4d: %08lx\n", __LINE__, status); 00173 failure++; 00174 } 00175 00176 pvaluefull = (PKEY_VALUE_FULL_INFORMATION)(&(workbuffer[0])); 00177 if (pvaluefull->DataLength != testsize) { 00178 printf("line_%4d: %08lx\n", __LINE__, 9999); 00179 failure++; 00180 } 00181 00182 00183 if (testsize > 0) { 00184 p = (PUCHAR)pvaluefull; 00185 p = p+pvaluefull->DataOffset; 00186 if (p[2] != 'i') { 00187 printf("line_%4d: %08lx\n", __LINE__, 9999); 00188 failure++; 00189 } 00190 } 00191 00192 printf("AT line_%4d: %d\n", __LINE__, testsize); 00193 if (testvector0[index+1] != -1) { 00194 status = NtDeleteValueKey( 00195 BaseHandle, 00196 &ValueName 00197 ); 00198 if (!NT_SUCCESS(status)) { 00199 printf("line_%4d: abort %08lx\n", __LINE__, status); 00200 failure++; 00201 goto punt; 00202 } 00203 } 00204 } 00205 00206 // 00207 // Perform new value entry tests, with a non empty list. 00208 // 00209 RtlInitUnicodeString( 00210 &ValueName, 00211 L"NewValueTest2" 00212 ); 00213 00214 for (index = 0; testvector0[index] != -1; index++) { 00215 00216 testsize = testvector0[index]; 00217 00218 printf("AT line_%4d: %d\n", __LINE__, testsize); 00219 status = NtSetValueKey( 00220 BaseHandle, 00221 &ValueName, 00222 1, 00223 REG_BINARY, 00224 &(TestData[0]), 00225 testsize 00226 ); 00227 if (!NT_SUCCESS(status)) { 00228 printf("line_%4d: %08lx\n", __LINE__, status); 00229 failure++; 00230 } 00231 00232 printf("AT line_%4d: %d\n", __LINE__, testsize); 00233 for (i = 0; i < WORK_SIZE; i++) workbuffer[i] = '?'; 00234 status = NtQueryValueKey( 00235 BaseHandle, 00236 &ValueName, 00237 KeyValuePartialInformation, 00238 &(workbuffer[0]), 00239 WORK_SIZE, 00240 &ResultLength 00241 ); 00242 if (!NT_SUCCESS(status)) { 00243 printf("line_%4d: %08lx\n", __LINE__, status); 00244 failure++; 00245 } 00246 00247 pvaluepart = (PKEY_VALUE_PARTIAL_INFORMATION)(&(workbuffer[0])); 00248 if (pvaluepart->DataLength != testsize) { 00249 printf("line_%4d: %08lx\n", __LINE__, 9999); 00250 failure++; 00251 } 00252 00253 00254 if (testsize > 0) { 00255 if (pvaluepart->Data[2] != 'i') { 00256 printf("line_%4d: %08lx\n", __LINE__, 9999); 00257 failure++; 00258 } 00259 } 00260 00261 printf("AT line_%4d: %d\n", __LINE__, testsize); 00262 status = NtDeleteValueKey( 00263 BaseHandle, 00264 &ValueName 00265 ); 00266 if (!NT_SUCCESS(status)) { 00267 printf("line_%4d: abort %08lx\n", __LINE__, status); 00268 failure++; 00269 goto punt; 00270 } 00271 } 00272 00273 00274 // 00275 // Perform existing value entry tests, with all the relevent 00276 // size transitions. 00277 // 00278 RtlInitUnicodeString( 00279 &ValueName, 00280 L"NewValueTest3" 00281 ); 00282 00283 for (i = 0; i < 2 * CM_MAX_STASH; i++) { 00284 workbuffer[i] = 'e'; 00285 } 00286 00287 for (i = 0; supervector[i] != NULL; i++) { 00288 00289 activevector = supervector[i]; 00290 00291 for (index = 0; activevector[index] != -1; index++) { 00292 00293 testsize = activevector[index]; 00294 00295 printf("AT line_%4d: %d\n", __LINE__, testsize); 00296 status = NtSetValueKey( 00297 BaseHandle, 00298 &ValueName, 00299 1, 00300 REG_BINARY, 00301 &(workbuffer[0]), 00302 testsize 00303 ); 00304 if (!NT_SUCCESS(status)) { 00305 printf("line_%4d: %08lx\n", __LINE__, status); 00306 failure++; 00307 } 00308 00309 printf("AT line_%4d: %d\n", __LINE__, testsize); 00310 status = NtQueryValueKey( 00311 BaseHandle, 00312 &ValueName, 00313 KeyValuePartialInformation, 00314 &(workbuffer[0]), 00315 2 * CM_MAX_STASH, 00316 &ResultLength 00317 ); 00318 if (!NT_SUCCESS(status)) { 00319 printf("line_%4d: %08lx\n", __LINE__, status); 00320 failure++; 00321 } 00322 } 00323 } 00324 00325 00326 punt: 00327 printf("rtsetopt: %d failures\n", failure); 00328 exit(failure); 00329 }

void processargs int  argc,
char *  argv[]
 

Definition at line 333 of file rtsetopt.c.

References exit, KeyPath, RtlAnsiStringToUnicodeString(), RtlInitAnsiString(), and TRUE.

00337 { 00338 ANSI_STRING temp; 00339 00340 if (argc != 2) 00341 { 00342 printf("Usage: %s <KeyPath>\n", argv[0]); 00343 exit(1); 00344 } 00345 00346 RtlInitAnsiString( 00347 &temp, 00348 argv[1] 00349 ); 00350 00351 RtlAnsiStringToUnicodeString( 00352 &KeyPath, 00353 &temp, 00354 TRUE 00355 ); 00356 00357 return; 00358 }

void processargs  ) 
 


Variable Documentation

ULONG failure = 0
 

Definition at line 46 of file rtsetopt.c.

UNICODE_STRING KeyPath
 

Definition at line 48 of file rtsetopt.c.

PLONG supervector[]
 

Initial value:

{ &(testvector1[0]), &(testvector2[1]), &(testvector3[0]), NULL }

Definition at line 68 of file rtsetopt.c.

Referenced by main().

UCHAR TestData[]
 

Initial value:

"This is some test data, it is short. But long enough for most of our tests."

Definition at line 50 of file rtsetopt.c.

Referenced by main().

LONG testvector0[] = { 0, 3, 4, 5, -1 }
 

Definition at line 56 of file rtsetopt.c.

Referenced by main().

LONG testvector1[]
 

Initial value:

{ 0, 0, 3, 0, 4, 0, 5, 0, 3, 3, 4, 3, 5, 3, 4, 4, 5, 4, 5, 5, -1 }

Definition at line 58 of file rtsetopt.c.

LONG testvector2[]
 

Initial value:

{ 8, 6, 8, 32, PAGE_SIZE, PAGE_SIZE-1, PAGE_SIZE, PAGE_SIZE+1, -1 }

Definition at line 61 of file rtsetopt.c.

LONG testvector3[]
 

Initial value:

Definition at line 65 of file rtsetopt.c.

WCHAR workbuffer[2 *CM_MAX_STASH]
 

Definition at line 54 of file rtsetopt.c.

UNICODE_STRING WorkName
 

Definition at line 53 of file rtsetopt.c.


Generated on Sat May 15 19:45:30 2004 for test by doxygen 1.3.7