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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
#include "cmp.h"
00047
#include <stdio.h>
00048
#include <stdlib.h>
00049
#include <string.h>
00050
00051 #define WORK_SIZE 1024
00052
00053
void __cdecl
main(
int,
char *);
00054
void processargs();
00055
00056 ULONG
failure = 0;
00057
00058 UNICODE_STRING
KeyPath;
00059 UNICODE_STRING
KeyName;
00060 ULONG
NumberChildren;
00061 ULONG
NumberValues;
00062 UCHAR
BaseName[
WORK_SIZE];
00063 UCHAR
formatbuffer[
WORK_SIZE];
00064 STRING
format;
00065
00066 UNICODE_STRING
WorkName;
00067 WCHAR
workbuffer[
WORK_SIZE];
00068
00069
void
00070 __cdecl
main(
00071
int argc,
00072
char *argv[]
00073 )
00074 {
00075
NTSTATUS status;
00076 OBJECT_ATTRIBUTES
ObjectAttributes;
00077 HANDLE BaseHandle;
00078 HANDLE WorkHandle;
00079 ULONG Disposition;
00080 UNICODE_STRING ClassName;
00081 ULONG i;
00082 ULONG j;
00083 PUCHAR p;
00084
00085
00086
00087
00088
00089
processargs(argc, argv);
00090
00091
00092
00093
00094
00095
00096 printf(
"rtvbatcr: starting\n");
00097
00098
WorkName.MaximumLength =
WORK_SIZE;
00099
WorkName.Length = 0
L;
00100
WorkName.Buffer = &(
workbuffer[0]);
00101
00102
RtlCopyString((PSTRING)&
WorkName, (PSTRING)&
KeyPath);
00103
00104 p =
WorkName.Buffer;
00105 p +=
WorkName.Length;
00106 *p =
'\\';
00107 p++;
00108 *p =
'\0';
00109
WorkName.Length += 2;
00110
00111
RtlAppendStringToString((PSTRING)&
WorkName, (PSTRING)&
KeyName);
00112
00113
RtlInitUnicodeString(
00114 &ClassName,
00115
L"Test Class Name"
00116 );
00117
00118 InitializeObjectAttributes(
00119 &
ObjectAttributes,
00120 &
WorkName,
00121 0,
00122 (HANDLE)
NULL,
00123
NULL
00124 );
00125
ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
00126
00127 status =
NtCreateKey(
00128 &BaseHandle,
00129 MAXIMUM_ALLOWED,
00130 &
ObjectAttributes,
00131 0,
00132 &ClassName,
00133 REG_OPTION_VOLATILE,
00134 &Disposition
00135 );
00136
if (!
NT_SUCCESS(status)) {
00137 printf(
"rtvbatcr: t0: %08lx\n", status);
00138
failure++;
00139
goto punt;
00140 }
00141
00142
00143
00144
00145
00146
00147
for (i = 0; i <
NumberChildren; i++) {
00148
00149
sprintf(
formatbuffer,
"%s%d",
BaseName, i);
00150
RtlInitString(&
format,
formatbuffer);
00151
RtlAnsiStringToUnicodeString(&
WorkName, &
format,
FALSE);
00152
00153
00154 InitializeObjectAttributes(
00155 &
ObjectAttributes,
00156 &
WorkName,
00157 0,
00158 BaseHandle,
00159
NULL
00160 );
00161
ObjectAttributes.Attributes |= OBJ_CASE_INSENSITIVE;
00162
00163 status =
NtCreateKey(
00164 &WorkHandle,
00165 MAXIMUM_ALLOWED,
00166 &
ObjectAttributes,
00167 0,
00168 &ClassName,
00169 REG_OPTION_VOLATILE,
00170 &Disposition
00171 );
00172
if (!
NT_SUCCESS(status)) {
00173 printf(
"rtvbatcr: t1: status = %08lx i = %d\n", status, i);
00174
failure++;
00175 }
00176
00177
00178
00179
00180
00181
for (j = 0; j <
NumberValues; j++) {
00182
00183
sprintf(
formatbuffer,
"%s%d",
BaseName, j);
00184
RtlInitString(&
format,
formatbuffer);
00185
RtlAnsiStringToUnicodeString(&
WorkName, &
format,
FALSE);
00186
00187
sprintf(
00188
formatbuffer,
"This is a rtvbatcr value for %s%d",
BaseName, j
00189 );
00190
00191 status =
NtSetValueKey(
00192 WorkHandle,
00193 &
WorkName,
00194 j,
00195 j,
00196
formatbuffer,
00197
strlen(
formatbuffer)+1
00198 );
00199
if (!
NT_SUCCESS(status)) {
00200 printf(
"rtvbatcr: t2: status = %08lx j = %d\n", status, j);
00201
failure++;
00202 }
00203 }
00204
NtClose(WorkHandle);
00205 }
00206
00207 punt:
00208 printf(
"rtvbatcr: %d failures\n",
failure);
00209
exit(
failure);
00210 }
00211
00212
00213
void
00214 processargs(
00215
int argc,
00216
char *argv[]
00217 )
00218 {
00219 ANSI_STRING temp;
00220
00221
if ( (argc != 3) && (argc != 6) )
00222 {
00223 printf(
"Usage: %s <KeyPath> <KeyName> [<basename> <#children> <#values>]\n",
00224 argv[0]);
00225
exit(1);
00226 }
00227
00228
RtlInitAnsiString(
00229 &temp,
00230 argv[1]
00231 );
00232
00233
RtlAnsiStringToUnicodeString(
00234 &
KeyPath,
00235 &temp,
00236
TRUE
00237 );
00238
00239
RtlInitAnsiString(
00240 &temp,
00241 argv[2]
00242 );
00243
00244
RtlAnsiStringToUnicodeString(
00245 &
KeyName,
00246 &temp,
00247
TRUE
00248 );
00249
00250
if (argc < 6) {
00251
00252
NumberChildren = 0;
00253
NumberValues = 0;
00254
00255 }
else {
00256
00257 strcpy(
BaseName, argv[3]);
00258
NumberChildren = atoi(argv[4]);
00259
NumberValues = atoi(argv[5]);
00260
00261 }
00262
return;
00263 }