00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
#include "cmp.h"
00037
#include <stdio.h>
00038
#include <stdlib.h>
00039
#include <string.h>
00040
00041 #define WORK_SIZE 1024
00042
00043
void __cdecl
main(
int,
char **);
00044
void processargs();
00045
00046 ULONG
failure = 0;
00047
00048 UNICODE_STRING
KeyPath;
00049
00050 UCHAR
TestData[] =
00051
"This is some test data, it is short. But long enough for most of our tests.";
00052
00053 UNICODE_STRING
WorkName;
00054 WCHAR
workbuffer[2 *
CM_MAX_STASH];
00055
00056 LONG
testvector0[] = { 0, 3, 4, 5, -1 };
00057
00058 LONG
testvector1[] = { 0, 0, 3, 0, 4, 0, 5, 0, 3, 3, 4, 3, 5, 3,
00059 4, 4, 5, 4, 5, 5, -1 };
00060
00061 LONG
testvector2[] = { 8, 6, 8, 32,
00062
PAGE_SIZE,
PAGE_SIZE-1,
PAGE_SIZE,
PAGE_SIZE+1,
00063 -1 };
00064
00065 LONG
testvector3[] = {
CM_MAX_STASH,
CM_MAX_STASH-1,
CM_MAX_STASH,
00066
CM_MAX_STASH+1, -1 };
00067
00068 PLONG
supervector[] = { &(
testvector1[0]), &(
testvector2[1]),
00069 &(
testvector3[0]),
NULL };
00070
00071
00072
void
00073 __cdecl
main(
00074
int argc,
00075
char **argv
00076 )
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
00098
00099
processargs(argc, argv);
00100
00101
00102
00103
00104
00105 printf(
"rtsetopt: starting\n");
00106
00107
WorkName.MaximumLength =
WORK_SIZE;
00108
WorkName.Length = 0
L;
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
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
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
00276
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 }
00330
00331
00332
void
00333 processargs(
00334
int argc,
00335
char *argv[]
00336 )
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 }