120{
122
125
131 DWORD dwValueSize = 0;
134
137 {
139 }
141 {
143 goto CheckValueArgument;
144 }
145
147 {
148CheckValueArgument:
149 blnBadParameter =
FALSE;
150 if (((*pszParameter ==
_T(
'/'))||(*pszParameter ==
_T(
'-')))
151 &&(*(pszParameter+1) ==
_T(
'?')))
152 {
154 }
156 {
158 {
160 }
161 else if (
_tcsicmp(pszParameter,
_T(
"dw")) == 0)
162 {
164 }
165 else if (
_tcsicmp(pszParameter,
_T(
"dwle")) == 0)
166 {
168 }
169 else if (
_tcsicmp(pszParameter,
_T(
"dwbe")) == 0)
170 {
172 }
173 else if (
_tcsicmp(pszParameter,
_T(
"sz")) == 0)
174 {
176 }
177 else if (
_tcsicmp(pszParameter,
_T(
"esz")) == 0)
178 {
180 }
181 else
182 {
183 blnBadParameter =
TRUE;
184 }
185 }
186 else if (pszValueData ==
NULL)
187 {
188 pszValueData = pszParameter;
189 }
190 else if (!pszValueFull)
191 {
192 pszValueFull = pszParameter;
193 }
194 else
195 {
196 blnBadParameter =
TRUE;
197 }
198 if (blnBadParameter)
199 {
200 rConsole.
Write(
_T(
"Bad parameter: "));
201 rConsole.
Write(pszParameter);
203 }
204 }
205
206 if (!pszValueData)
208
211 const TCHAR *pszEmpty =
_T(
"");
212 const TCHAR *pszPath;
213
214 if (blnHelp)
215 {
217
218 if (pDataBuffer)
219 delete pDataBuffer;
220
221 return 0;
222 }
223
224 if (pszValueFull)
225 {
227 goto CommandNAonRoot;
228
230 pszValueName = pchSep?(pchSep+1):(pszValueFull);
231 pszPath = pchSep?pszValueFull:
_T(
".");
232
233
234
235
236
237
238
239 if (pchSep)
240 *pchSep = 0;
241 }
242 else
243 {
244 pszValueName = (
TCHAR*)pszEmpty;
246 }
247
249 {
251 goto SkipCommand;
252 }
253
255 goto CommandNAonRoot;
256
257 switch (dwType)
258 {
260 {
265 {
266 rConsole.
Write(
_T(
"Cannot open file "));
267 rConsole.
Write(pszValueData);
269 goto SkipCommand;
270 }
272 if (dwValueSize == (
DWORD)-1)
273
274
275 {
276 rConsole.
Write(
_T(
"Cannot get size of file "));
277 rConsole.
Write(pszValueData);
280 goto SkipCommand;
281 }
282 pDataBuffer =
new BYTE [dwValueSize];
283 if (!pDataBuffer)
284 {
285 rConsole.
Write(
_T(
"Cannot load file into memory. Out of memory.\n"));
287 goto SkipCommand;
288 }
290 {
291 rConsole.
Write(
_T(
"Cannot load file into memory. Error reading file.\n"));
293 goto SkipCommand;
294 }
295
297 ASSERT(dwBytesReaded == dwValueSize);
298 }
299 break;
302 dwValueSize = 4;
303 pDataBuffer = (
BYTE *)
new BYTE [dwValueSize];
305 {
306 rConsole.
Write(
_T(
"Cannot convert "));
307 rConsole.
Write(pszValueData);
308 rConsole.
Write(
_T(
" to DWORD \n"));
309 goto SkipCommand;
310 }
312 {
313 unsigned char nByte;
314 nByte = *pDataBuffer;
315 *pDataBuffer = *(pDataBuffer+3);
316 *(pDataBuffer+3) = nByte;
317 nByte = *(pDataBuffer+1);
318 *(pDataBuffer+1) = *(pDataBuffer+2);
319 *(pDataBuffer+2) = nByte;
320 }
321 break;
324 dwValueSize =
_tcslen(pszValueData)+1;
325 if (*pszValueData ==
_T(
'\"'))
326 {
327 dwValueSize -= 2;
328 *(pszValueData+dwValueSize) = 0;
329 pszValueData++;
330 }
331 dwValueSize *=
sizeof(
TCHAR);
332 pDataBuffer = (
BYTE *)
new BYTE [dwValueSize];
333
334 {
335 const TCHAR *pchSrc = pszValueData;
337 while(*pchSrc)
338 {
339 if (pchSrc[0] ==
_T(
'^'))
340 {
341 if (pchSrc[1] ==
_T(
'a'))
343 else if (pchSrc[1] ==
_T(
'b'))
345 else if (pchSrc[1] ==
_T(
'f'))
347 else if (pchSrc[1] ==
_T(
'n'))
349 else if (pchSrc[1] ==
_T(
'r'))
351 else if (pchSrc[1] ==
_T(
't'))
353 else
354 *pchDest = pchSrc[1];
355
356 pchSrc +=2;
357 pchDest++;
358 dwValueSize--;
359 }
360 else
361 {
362 *pchDest = *pchSrc;
363 pchSrc++;
364 pchDest++;
365 }
366 }
368 }
369 break;
370 default:
372 }
373
374 {
376 if (
s && (pszValueName[0] ==
_T(
'\"'))&&(pszValueName[
s-1] ==
_T(
'\"')))
377 {
378 pszValueName[
s-1] = 0;
379 pszValueName++;
380 }
381 }
382
383 nError =
Key.SetValue(pszValueName,dwType,pDataBuffer,dwValueSize);
385 {
389 }
390 else
391 {
393 }
394
395SkipCommand:
396 if (pDataBuffer)
397 delete[] pDataBuffer;
398 return 0;
399
400CommandNAonRoot:
402 return 0;
403}
void InvalidateCompletion()
#define COMMAND_NA_ON_ROOT
BOOL StringToDWORD(DWORD &rdwOut, const TCHAR *pszIn)
#define SET_VALUE_CMD_LENGTH
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetLastErrorDescription()
virtual const TCHAR * GetHelpString()
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
#define REG_DWORD_LITTLE_ENDIAN
#define REG_DWORD_BIG_ENDIAN