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 }