ReactOS 0.4.16-dev-258-g81860b4
regproc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KEY_MAX_LEN   1024
 
#define SUCCESS   0
 
#define KEY_VALUE_ALREADY_SET   2
 
#define get_file_name   get_file_nameA
 

Typedefs

typedef void(* CommandAPI) (LPTSTR lpsLine)
 

Functions

void doSetValue (LPTSTR lpsLine)
 
void doDeleteValue (LPTSTR lpsLine)
 
void doCreateKey (LPTSTR lpsLine)
 
void doDeleteKey (LPTSTR lpsLine)
 
void doQueryValue (LPTSTR lpsLine)
 
void doRegisterDLL (LPTSTR lpsLine)
 
void doUnregisterDLL (LPTSTR lpsLine)
 
BOOL export_registry_key (TCHAR *file_name, TCHAR *reg_key_name)
 
BOOL import_registry_file (LPTSTR filename)
 
void delete_registry_key (TCHAR *reg_key_name)
 
void processRegLines (FILE *in, CommandAPI command)
 
chargetToken (char **str, const char *delims)
 
void get_file_nameA (CHAR **command_line, CHAR *filename, int max_filename)
 
void get_file_nameW (CHAR **command_line, WCHAR *filename, int max_filename)
 
DWORD convertHexToDWord (TCHAR *str, BYTE *buf)
 
DWORD convertHexCSVToHex (TCHAR *str, BYTE *buf, ULONG bufLen)
 
LPTSTR convertHexToHexCSV (BYTE *buf, ULONG len)
 
LPTSTR convertHexToDWORDStr (BYTE *buf, ULONG len)
 
LPTSTR getRegKeyName (LPTSTR lpLine)
 
HKEY getRegClass (LPTSTR lpLine)
 
DWORD getDataType (LPTSTR *lpValue, DWORD *parse_type)
 
LPTSTR getArg (LPTSTR arg)
 
HRESULT openKey (LPTSTR stdInput)
 
void closeKey (VOID)
 
void processSetValue (LPTSTR cmdline)
 
HRESULT setValue (LPTSTR val_name, LPTSTR val_data)
 
void processQueryValue (LPTSTR cmdline)
 
LPVOID RegHeapAlloc (HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
 
LPVOID RegHeapReAlloc (HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes)
 
BOOL RegHeapFree (HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
 

Macro Definition Documentation

◆ get_file_name

#define get_file_name   get_file_nameA

Definition at line 51 of file regproc.h.

◆ KEY_MAX_LEN

#define KEY_MAX_LEN   1024

Definition at line 23 of file regproc.h.

◆ KEY_VALUE_ALREADY_SET

#define KEY_VALUE_ALREADY_SET   2

Definition at line 27 of file regproc.h.

◆ SUCCESS

#define SUCCESS   0

Definition at line 26 of file regproc.h.

Typedef Documentation

◆ CommandAPI

typedef void(* CommandAPI) (LPTSTR lpsLine)

Definition at line 29 of file regproc.h.

Function Documentation

◆ closeKey()

void closeKey ( VOID  )

Definition at line 604 of file regproc.c.

605{
607 HeapFree(GetProcessHeap(), 0, currentKeyName); /* Allocated by getKeyName */
610 currentKeyClass = 0;
612}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
static HKEY currentKeyHandle
Definition: regproc.c:71
static HKEY currentKeyClass
Definition: regproc.c:70
static BOOL bTheKeyIsOpen
Definition: regproc.c:72
static LPTSTR currentKeyName
Definition: regproc.c:69

Referenced by doQueryValue(), and doSetValue().

◆ convertHexCSVToHex()

DWORD convertHexCSVToHex ( TCHAR str,
BYTE buf,
ULONG  bufLen 
)

Definition at line 289 of file regproc.c.

290{
291 TCHAR* s = str; /* Pointer to current */
292 CHAR* b = buf; /* Pointer to result */
293 ULONG strLen = _tcslen(str);
294 ULONG strPos = 0;
295 DWORD byteCount = 0;
296
297 memset(buf, 0, bufLen);
298 /*
299 * warn the user if we are here with a string longer than 2 bytes that does
300 * not contains ",". It is more likely because the data is invalid.
301 */
302 if ((strLen > 2) && (_tcschr(str, _T(',')) == NULL)) {
303 _tprintf(_T("WARNING converting CSV hex stream with no comma, ") \
304 _T("input data seems invalid.\n"));
305 }
306 if (strLen > 3*bufLen) {
307 _tprintf(_T("ERROR converting CSV hex stream. Too long\n"));
308 }
309 while (strPos < strLen) {
310 TCHAR xbuf[3];
311 TCHAR wc;
312 memcpy(xbuf, s, 2);
313 xbuf[2] = _T('\0');
314 _stscanf(xbuf, _T("%02x"), (UINT*)&wc);
315 if (byteCount < bufLen)
316 *b++ = (unsigned char)wc;
317 s += 3;
318 strPos += 3;
319 ++byteCount;
320 }
321 return byteCount;
322}
unsigned char
Definition: typeof.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _stscanf
Definition: tchar.h:557
#define _tprintf
Definition: tchar.h:506
#define _tcschr
Definition: tchar.h:1406
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int UINT
Definition: ndis.h:50
const WCHAR * str
UCHAR byteCount
Definition: scsi.h:3709
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define _T(x)
Definition: vfdio.h:22
char TCHAR
Definition: xmlstorage.h:189
#define _tcslen
Definition: xmlstorage.h:198
char CHAR
Definition: xmlstorage.h:175

Referenced by setValue().

◆ convertHexToDWord()

DWORD convertHexToDWord ( TCHAR str,
BYTE buf 
)

Definition at line 231 of file regproc.c.

232{
233 DWORD dw;
234 TCHAR xbuf[9];
235
236 memcpy(xbuf, str, 8 * sizeof(TCHAR));
237 xbuf[88 * sizeof(TCHAR)] = '\0';
238 _stscanf(xbuf, _T("%08lx"), &dw);
239 memcpy(buf, &dw, sizeof(DWORD));
240 return sizeof(DWORD);
241}
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define DWORD
Definition: nt_native.h:44

Referenced by setValue().

◆ convertHexToDWORDStr()

LPTSTR convertHexToDWORDStr ( BYTE buf,
ULONG  len 
)

Definition at line 272 of file regproc.c.

273{
274 TCHAR* str;
275 DWORD dw;
276
277 if (bufLen != sizeof(DWORD)) return NULL;
278 str = HeapAlloc(GetProcessHeap(), 0, ((bufLen*2)+1)*sizeof(TCHAR));
279 memcpy(&dw, buf, sizeof(DWORD));
280 _stprintf(str, _T("%08lx"), dw);
281 /* Get rid of the last comma */
282 return str;
283}
#define HeapAlloc
Definition: compat.h:733
#define _stprintf
Definition: utility.h:124

Referenced by processQueryValue().

◆ convertHexToHexCSV()

LPTSTR convertHexToHexCSV ( BYTE buf,
ULONG  len 
)

Definition at line 246 of file regproc.c.

247{
248 TCHAR* str;
249 TCHAR* ptrStr;
250 BYTE* ptrBuf;
251
252 ULONG current = 0;
253 str = HeapAlloc(GetProcessHeap(), 0, (bufLen+1)*2*sizeof(TCHAR));
254 memset(str, 0, (bufLen+1)*2);
255 ptrStr = str; /* Pointer to result */
256 ptrBuf = buf; /* Pointer to current */
257 while (current < bufLen) {
258 BYTE bCur = ptrBuf[current++];
259 TCHAR res[3];
260 _stprintf(res, _T("%02x"), (unsigned int)*&bCur);
261 _tcscat(str, res);
262 _tcscat(str, _T(","));
263 }
264 /* Get rid of the last comma */
265 str[_tcslen(str)-1] = _T('\0');
266 return str;
267}
GLuint res
Definition: glext.h:9613
#define _tcscat
Definition: tchar.h:622
struct task_struct * current
Definition: linux.c:32
unsigned char BYTE
Definition: xxhash.c:193

Referenced by processQueryValue().

◆ delete_registry_key()

void delete_registry_key ( TCHAR reg_key_name)

Definition at line 1459 of file regproc.c.

1460{
1461 TCHAR* branch_name;
1462 DWORD branch_name_len;
1463 HKEY reg_key_class;
1464 HKEY branch_key;
1465
1466 if (!reg_key_name || !reg_key_name[0]) {
1467 return;
1468 }
1469 /* open the specified key */
1470 reg_key_class = getRegClass(reg_key_name);
1471 if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
1472 _tprintf(_T("Incorrect registry class specification in '%s'\n"), reg_key_name);
1473 //exit(1);
1474 return;
1475 }
1476 branch_name = getRegKeyName(reg_key_name);
1477 CHECK_ENOUGH_MEMORY(branch_name);
1478 branch_name_len = _tcslen(branch_name);
1479 if (!branch_name[0]) {
1480 _tprintf(_T("Can't delete registry class '%s'\n"), reg_key_name);
1481 //exit(1);
1482 return;
1483 }
1484 if (RegOpenKey(reg_key_class, branch_name, &branch_key) == ERROR_SUCCESS) {
1485 /* check whether the key exists */
1486 RegCloseKey(branch_key);
1487 delete_branch(reg_key_class, &branch_name, &branch_name_len);
1488 }
1489 HeapFree(GetProcessHeap(), 0, branch_name);
1490}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LPTSTR getRegKeyName(LPTSTR lpLine)
Definition: regproc.c:536
BOOL delete_branch(HKEY key, TCHAR **reg_key_name_buf, DWORD *reg_key_name_len)
Definition: regproc.c:1410
HKEY getRegClass(LPTSTR lpClass)
Definition: regproc.c:567
#define CHECK_ENOUGH_MEMORY(p)
Definition: regproc.c:105
#define RegOpenKey
Definition: winreg.h:519

◆ doCreateKey()

void doCreateKey ( LPTSTR  lpsLine)

Definition at line 704 of file regproc.c.

704 {
705 _tprintf(_T("createKey not yet implemented\n"));
706}

◆ doDeleteKey()

void doDeleteKey ( LPTSTR  lpsLine)

Definition at line 695 of file regproc.c.

695 {
696 _tprintf(_T("deleteKey not yet implemented\n"));
697}

◆ doDeleteValue()

void doDeleteValue ( LPTSTR  lpsLine)

Definition at line 686 of file regproc.c.

686 {
687 _tprintf(_T("deleteValue not yet implemented\n"));
688}

◆ doQueryValue()

void doQueryValue ( LPTSTR  lpsLine)

Definition at line 653 of file regproc.c.

653 {
654 /*
655 * We encoutered the end of the file, make sure we
656 * close the opened key and exit
657 */
658 if (stdInput == NULL) {
659 if (bTheKeyIsOpen != FALSE)
660 closeKey();
661 return;
662 }
663
664 if (stdInput[0] == _T('[')) { /* We are reading a new key */
665 if (bTheKeyIsOpen != FALSE)
666 closeKey(); /* Close the previous key before */
667 if (openKey(stdInput) != ERROR_SUCCESS ) {
668 _tprintf(_T("doQueryValue failed to open key %s\n"), stdInput);
669 }
670 }
671 else if( (bTheKeyIsOpen) &&
672 ((stdInput[0] == _T('@')) || /* reading a default @=data pair */
673 (stdInput[0] == _T('\"')))) { /* reading a new value=data pair */
674 processQueryValue(stdInput);
675 } else { /* since we are assuming that the file format is */
676 if (bTheKeyIsOpen) /* valid we must be reading a blank line which */
677 closeKey(); /* indicate end of this key processing */
678 }
679}
void closeKey(VOID)
Definition: regproc.c:604
void processQueryValue(LPTSTR cmdline)
Definition: regproc.c:770
HRESULT openKey(LPTSTR stdInput)
Definition: regproc.c:494

◆ doRegisterDLL()

void doRegisterDLL ( LPTSTR  lpsLine)

Definition at line 994 of file regproc.c.

995{
996 HMODULE theLib = 0;
997 UINT retVal = 0;
998
999 /* Check for valid input */
1000 if (stdInput == NULL) return;
1001
1002 /* Load and register the library, then free it */
1003 theLib = LoadLibrary(stdInput);
1004 if (theLib) {
1005 FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer");
1006 if (lpfnDLLRegProc) {
1007 retVal = (*lpfnDLLRegProc)();
1008 } else {
1009 _tprintf(_T("Couldn't find DllRegisterServer proc in '%s'.\n"), stdInput);
1010 }
1011 if (retVal != S_OK) {
1012 _tprintf(_T("Couldn't find DllRegisterServer proc in '%s'.\n"), stdInput);
1013 }
1014 FreeLibrary(theLib);
1015 } else {
1016 _tprintf(_T("Could not load DLL '%s'.\n"), stdInput);
1017 }
1018}
int(* FARPROC)()
Definition: compat.h:36
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define S_OK
Definition: intsafe.h:52
#define LoadLibrary
Definition: winbase.h:3887

◆ doSetValue()

void doSetValue ( LPTSTR  lpsLine)

Definition at line 619 of file regproc.c.

620{
621 /*
622 * We encountered the end of the file, make sure we
623 * close the opened key and exit
624 */
625 if (stdInput == NULL) {
626 if (bTheKeyIsOpen != FALSE)
627 closeKey();
628 return;
629 }
630
631 if (stdInput[0] == _T('[')) { /* We are reading a new key */
632 if (bTheKeyIsOpen != FALSE) {
633 closeKey(); /* Close the previous key before */
634 }
635 if (openKey(stdInput) != ERROR_SUCCESS) {
636 _tprintf(_T("doSetValue failed to open key %s\n"), stdInput);
637 }
638 } else if ((bTheKeyIsOpen) &&
639 ((stdInput[0] == _T('@')) || /* reading a default @=data pair */
640 (stdInput[0] == _T('\"')))) { /* reading a new value=data pair */
641 processSetValue(stdInput);
642 } else { /* since we are assuming that the file format is */
643 if (bTheKeyIsOpen) /* valid we must be reading a blank line which */
644 closeKey(); /* indicate end of this key processing */
645 }
646}
void processSetValue(LPTSTR line)
Definition: regproc.c:716

Referenced by import_registry_file().

◆ doUnregisterDLL()

void doUnregisterDLL ( LPTSTR  lpsLine)

Definition at line 1024 of file regproc.c.

1025{
1026 HMODULE theLib = 0;
1027 UINT retVal = 0;
1028
1029 /* Check for valid input */
1030 if (stdInput == NULL) return;
1031
1032 /* Load and unregister the library, then free it */
1033 theLib = LoadLibrary(stdInput);
1034 if (theLib) {
1035 FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer");
1036 if (lpfnDLLRegProc) {
1037 retVal = (*lpfnDLLRegProc)();
1038 } else {
1039 _tprintf(_T("Couldn't find DllUnregisterServer proc in '%s'.\n"), stdInput);
1040 }
1041 if (retVal != S_OK) {
1042 _tprintf(_T("DLLUnregisterServer error 0x%x in '%s'.\n"), retVal, stdInput);
1043 }
1044 FreeLibrary(theLib);
1045 } else {
1046 _tprintf(_T("Could not load DLL '%s'.\n"), stdInput);
1047 }
1048}

◆ export_registry_key()

BOOL export_registry_key ( TCHAR file_name,
TCHAR reg_key_name 
)

Definition at line 1310 of file regproc.c.

1311{
1312 HKEY reg_key_class;
1313
1314 TCHAR *reg_key_name_buf;
1315 TCHAR *val_name_buf;
1316 BYTE *val_buf;
1317 DWORD reg_key_name_len = KEY_MAX_LEN;
1318 DWORD val_name_len = KEY_MAX_LEN;
1319 DWORD val_size = REG_VAL_BUF_SIZE;
1320 FILE *file = NULL;
1321
1322 //_tprintf(_T("export_registry_key(%s, %s)\n"), reg_key_name, file_name);
1323
1324 reg_key_name_buf = HeapAlloc(GetProcessHeap(), 0, reg_key_name_len * sizeof(*reg_key_name_buf));
1325 val_name_buf = HeapAlloc(GetProcessHeap(), 0, val_name_len * sizeof(*val_name_buf));
1326 val_buf = HeapAlloc(GetProcessHeap(), 0, val_size);
1327 CHECK_ENOUGH_MEMORY(reg_key_name_buf && val_name_buf && val_buf);
1328
1329 if (reg_key_name && reg_key_name[0]) {
1330 TCHAR *branch_name;
1331 HKEY key;
1332
1333 REGPROC_resize_char_buffer(&reg_key_name_buf, &reg_key_name_len,
1334 _tcslen(reg_key_name));
1335 _tcscpy(reg_key_name_buf, reg_key_name);
1336
1337 /* open the specified key */
1338 reg_key_class = getRegClass(reg_key_name);
1339 if (reg_key_class == (HKEY)ERROR_INVALID_PARAMETER) {
1340 _tprintf(_T("Incorrect registry class specification in '%s\n"), reg_key_name);
1341 //exit(1);
1342 return FALSE;
1343 }
1344 branch_name = getRegKeyName(reg_key_name);
1345 CHECK_ENOUGH_MEMORY(branch_name);
1346 if (!branch_name[0]) {
1347 /* no branch - registry class is specified */
1349 export_hkey(file, reg_key_class,
1350 &reg_key_name_buf, &reg_key_name_len,
1351 &val_name_buf, &val_name_len,
1352 &val_buf, &val_size);
1353 } else if (RegOpenKey(reg_key_class, branch_name, &key) == ERROR_SUCCESS) {
1356 &reg_key_name_buf, &reg_key_name_len,
1357 &val_name_buf, &val_name_len,
1358 &val_buf, &val_size);
1360 } else {
1361 _tprintf(_T("Can't export. Registry key '%s does not exist!\n"), reg_key_name);
1363 }
1364 HeapFree(GetProcessHeap(), 0, branch_name);
1365 } else {
1366 int i;
1367
1368 /* export all registry classes */
1370 for (i = 0; i < REG_CLASS_NUMBER; i++) {
1371 /* do not export HKEY_CLASSES_ROOT */
1375 _tcscpy(reg_key_name_buf, reg_class_names[i]);
1377 &reg_key_name_buf, &reg_key_name_len,
1378 &val_name_buf, &val_name_len,
1379 &val_buf, &val_size);
1380 }
1381 }
1382 }
1383 if (file) {
1384 fclose(file);
1385 }
1386// HeapFree(GetProcessHeap(), 0, reg_key_name);
1387 HeapFree(GetProcessHeap(), 0, val_buf);
1388 HeapFree(GetProcessHeap(), 0, val_name_buf);
1389 HeapFree(GetProcessHeap(), 0, reg_key_name_buf);
1390 return TRUE;
1391}
#define KEY_MAX_LEN
Definition: main.h:29
#define REG_VAL_BUF_SIZE
Definition: regproc.c:25
static HKEY reg_class_keys[]
Definition: regproc.c:27
static FILE * REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
Definition: regproc.c:1452
#define TRUE
Definition: types.h:120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define _tcscpy
Definition: tchar.h:623
static TCHAR * reg_class_names[]
Definition: regproc.c:74
void REGPROC_resize_char_buffer(TCHAR **buffer, DWORD *len, DWORD required_len)
Definition: regproc.c:1085
void REGPROC_print_error(VOID)
Definition: regproc.c:1056
void export_hkey(FILE *file, HKEY key, TCHAR **reg_key_name_buf, DWORD *reg_key_name_len, TCHAR **val_name_buf, DWORD *val_name_len, BYTE **val_buf, DWORD *val_size)
Definition: regproc.c:1131
#define REG_CLASS_NUMBER
Definition: regproc.c:82
static LPCWSTR file_name
Definition: protocol.c:147
Definition: fci.c:127
Definition: copy.c:22
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

◆ get_file_nameA()

void get_file_nameA ( CHAR **  command_line,
CHAR filename,
int  max_filename 
)

Definition at line 160 of file regproc.c.

161{
162 CHAR *s = *command_line;
163 int pos = 0; /* position of pointer "s" in *command_line */
164 file_name[0] = 0;
165
166 if (!s[0]) {
167 return;
168 }
169 if (s[0] == '"') {
170 s++;
171 (*command_line)++;
172 while (s[0] != '"') {
173 if (!s[0]) {
174 _tprintf(_T("Unexpected end of file name!\n"));
175 assert(0);
176 //exit(1);
177 }
178 s++;
179 pos++;
180 }
181 } else {
182 while (s[0] && !isspace(s[0])) {
183 s++;
184 pos++;
185 }
186 }
187 memcpy(file_name, *command_line, pos * sizeof((*command_line)[0]));
188 /* remove the last backslash */
189 if (file_name[pos - 1] == '\\') {
190 file_name[pos - 1] = '\0';
191 } else {
192 file_name[pos] = '\0';
193 }
194 if (s[0]) {
195 s++;
196 pos++;
197 }
198 while (s[0] && isspace(s[0])) {
199 s++;
200 pos++;
201 }
202 (*command_line) += pos;
203}
#define isspace(c)
Definition: acclib.h:69
#define assert(x)
Definition: debug.h:53

Referenced by get_file_nameW().

◆ get_file_nameW()

void get_file_nameW ( CHAR **  command_line,
WCHAR filename,
int  max_filename 
)

Definition at line 205 of file regproc.c.

206{
208 int len;
209
210 get_file_nameA(command_line, filenameA, _MAX_PATH);
212 OemToCharBuffW(filenameA, filename, max_filename);
213 filename[len] = _T('\0');
214/*
215 UNICODE_STRING UnicodeString;
216 ANSI_STRING AnsiString;
217 CHAR filenameA[_MAX_PATH];
218
219 get_file_nameA(command_line, filenameA, _MAX_PATH);
220
221 //RtlInitAnsiString(&AnsiString, filenameA);
222 UnicodeString.Buffer = filename;
223 UnicodeString.MaximumLength = max_filename;//MAX_PATH;
224 RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, FALSE);
225 */
226}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLsizei len
Definition: glext.h:6722
const char * filename
Definition: ioapi.h:137
#define _MAX_PATH
Definition: utility.h:77
void get_file_nameA(CHAR **command_line, CHAR *file_name, int max_filename)
Definition: regproc.c:160
static CHAR filenameA[MAX_PATH]
Definition: storage32.c:42
BOOL WINAPI OemToCharBuffW(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPWSTR lpszDst, _In_ DWORD cchDstLength)

◆ getArg()

LPTSTR getArg ( LPTSTR  arg)

Definition at line 377 of file regproc.c.

378{
379 LPTSTR tmp = NULL;
380 ULONG len;
381
382 if (arg == NULL) return NULL;
383
384 // Get rid of surrounding quotes
385 len = _tcslen(arg);
386 if (arg[len-1] == _T('\"')) arg[len-1] = _T('\0');
387 if (arg[0] == _T('\"')) arg++;
388 tmp = HeapAlloc(GetProcessHeap(), 0, (_tcslen(arg)+1) * sizeof(TCHAR));
389 _tcscpy(tmp, arg);
390 return tmp;
391}
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by processQueryValue().

◆ getDataType()

DWORD getDataType ( LPTSTR lpValue,
DWORD parse_type 
)

Definition at line 331 of file regproc.c.

332{
333 struct data_type { const TCHAR *tag; int len; int type; int parse_type; };
334
335 static const struct data_type data_types[] =
336 { /* actual type */ /* type to assume for parsing */
337 { _T("\""), 1, REG_SZ, REG_SZ },
338 { _T("str:\""), 5, REG_SZ, REG_SZ },
339// { _T("str(2):\""), 8, REG_EXPAND_SZ, REG_SZ },
340 { _T("expand:\""), 8, REG_EXPAND_SZ, REG_EXPAND_SZ },
341 { _T("hex:"), 4, REG_BINARY, REG_BINARY },
342 { _T("dword:"), 6, REG_DWORD, REG_DWORD },
343 { _T("hex("), 4, -1, REG_BINARY },
344 { NULL, 0, 0, 0 }
345 };
346
347 const struct data_type *ptr;
348 int type;
349
350 for (ptr = data_types; ptr->tag; ptr++) {
351 if (memcmp(ptr->tag, *lpValue, ptr->len))
352 continue;
353
354 /* Found! */
355 *parse_type = ptr->parse_type;
356 type = ptr->type;
357 *lpValue += ptr->len;
358 if (type == -1) {
359 TCHAR* end;
360 /* "hex(xx):" is special */
361 type = (int)_tcstoul(*lpValue , &end, 16);
362 if (**lpValue == _T('\0') || *end != _T(')') || *(end+1) != _T(':')) {
363 type = REG_NONE;
364 } else {
365 *lpValue = end + 2;
366 }
367 }
368 return type;
369 }
370 return (**lpValue == _T('\0') ? REG_SZ : REG_NONE);
371}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
#define _tcstoul
Definition: tchar.h:595
#define REG_SZ
Definition: layer.c:22
static PVOID ptr
Definition: dispmode.c:27
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_DWORD
Definition: sdbapi.c:596
int parse_type(Type t, const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
Definition: sdkparse.cpp:653
Definition: ecma_167.h:138

Referenced by setValue().

◆ getRegClass()

HKEY getRegClass ( LPTSTR  lpLine)

Definition at line 567 of file regproc.c.

568{
569 LPTSTR classNameEnd;
570 LPTSTR classNameBeg;
571 int i;
572
573 TCHAR lpClassCopy[KEY_MAX_LEN];
574
575 if (lpClass == NULL)
577
578 _tcsncpy(lpClassCopy, lpClass, KEY_MAX_LEN);
579
580 classNameEnd = _tcschr(lpClassCopy, _T('\\')); /* The class name ends by '\' */
581 if (!classNameEnd) { /* or the whole string */
582 classNameEnd = lpClassCopy + _tcslen(lpClassCopy);
583 if (classNameEnd[-1] == _T(']')) {
584 classNameEnd--;
585 }
586 }
587 *classNameEnd = _T('\0'); /* Isolate the class name */
588 if (lpClassCopy[0] == _T('[')) {
589 classNameBeg = lpClassCopy + 1;
590 } else {
591 classNameBeg = lpClassCopy;
592 }
593 for (i = 0; i < REG_CLASS_NUMBER; i++) {
594 if (!_tcscmp(classNameBeg, reg_class_names[i])) {
595 return reg_class_keys[i];
596 }
597 }
599}
#define _tcscmp
Definition: tchar.h:1424
#define _tcsncpy
Definition: tchar.h:1410

Referenced by delete_registry_key(), export_registry_key(), and openKey().

◆ getRegKeyName()

LPTSTR getRegKeyName ( LPTSTR  lpLine)

Definition at line 536 of file regproc.c.

537{
538 LPTSTR keyNameBeg;
539 TCHAR lpLineCopy[KEY_MAX_LEN];
540
541 if (lpLine == NULL)
542 return NULL;
543
544 _tcscpy(lpLineCopy, lpLine);
545 keyNameBeg = _tcschr(lpLineCopy, _T('\\')); /* The key name start by '\' */
546 if (keyNameBeg) {
547 LPTSTR keyNameEnd;
548
549 keyNameBeg++; /* is not part of the name */
550 keyNameEnd = _tcschr(lpLineCopy, _T(']'));
551 if (keyNameEnd) {
552 *keyNameEnd = _T('\0'); /* remove ']' from the key name */
553 }
554 } else {
555 keyNameBeg = lpLineCopy + _tcslen(lpLineCopy); /* branch - empty string */
556 }
557 currentKeyName = HeapAlloc(GetProcessHeap(), 0, (_tcslen(keyNameBeg)+1)*sizeof(TCHAR));
559 _tcscpy(currentKeyName, keyNameBeg);
560 return currentKeyName;
561}

Referenced by delete_registry_key(), export_registry_key(), and openKey().

◆ getToken()

char * getToken ( char **  str,
const char delims 
)

Referenced by processQueryValue().

◆ import_registry_file()

BOOL import_registry_file ( LPTSTR  filename)

Definition at line 1396 of file regproc.c.

1397{
1398 FILE* reg_file = _tfopen(filename, _T("r"));
1399
1400 if (reg_file) {
1401 processRegLines(reg_file, doSetValue);
1402 return TRUE;
1403 }
1404 return FALSE;
1405}
void doSetValue(LPTSTR stdInput)
Definition: regproc.c:619
void processRegLines(FILE *in, CommandAPI command)
Definition: regproc.c:887
#define _tfopen
Definition: xmlstorage.h:196

◆ openKey()

HRESULT openKey ( LPTSTR  stdInput)

Definition at line 494 of file regproc.c.

495{
496 DWORD dwDisp;
497 HRESULT hRes;
498
499 /* Sanity checks */
500 if (stdInput == NULL)
502
503 /* Get the registry class */
504 currentKeyClass = getRegClass(stdInput); /* Sets global variable */
507
508 /* Get the key name */
509 currentKeyName = getRegKeyName(stdInput); /* Sets global variable */
510 if (currentKeyName == NULL)
512
513 hRes = RegCreateKeyEx(
514 currentKeyClass, /* Class */
515 currentKeyName, /* Sub Key */
516 0, /* MUST BE 0 */
517 NULL, /* object type */
518 REG_OPTION_NON_VOLATILE, /* option, REG_OPTION_NON_VOLATILE ... */
519 KEY_ALL_ACCESS, /* access mask, KEY_ALL_ACCESS */
520 NULL, /* security attribute */
521 &currentKeyHandle, /* result */
522 &dwDisp); /* disposition, REG_CREATED_NEW_KEY or
523 REG_OPENED_EXISTING_KEY */
524
525 if (hRes == ERROR_SUCCESS)
527
528 return hRes;
529
530}
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by doQueryValue(), and doSetValue().

◆ processQueryValue()

void processQueryValue ( LPTSTR  cmdline)

Definition at line 770 of file regproc.c.

771{
772 _tprintf(_T("ERROR!!! - temporary disabled"));
773 //exit(1);
774 return;
775#if 0
776 LPSTR argv[QUERY_VALUE_MAX_ARGS];/* args storage */
777 LPSTR token = NULL; /* current token analized */
778 ULONG argCounter = 0; /* counter of args */
779 INT counter;
780 HRESULT hRes = 0;
781 LPSTR keyValue = NULL;
782 LPSTR lpsRes = NULL;
783
784 /*
785 * Init storage and parse the line
786 */
788 argv[counter] = NULL;
789
790 while ((token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL) {
791 argv[argCounter++] = getArg(token);
792 if (argCounter == QUERY_VALUE_MAX_ARGS)
793 break; /* Stop processing args no matter what */
794 }
795
796 /* The value we look for is the first token on the line */
797 if (argv[0] == NULL)
798 return; /* SHOULD NOT HAPPEN */
799 else
800 keyValue = argv[0];
801
802 if ((keyValue[0] == '@') && (_tcslen(keyValue) == 1)) {
803 LONG lLen = KEY_MAX_LEN;
805 /*
806 * We need to query the key default value
807 */
808 hRes = RegQueryValue(currentKeyHandle, currentKeyName, (LPBYTE)lpsData, &lLen);
809 if (hRes == ERROR_MORE_DATA) {
810 lpsData = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpsData, lLen);
811 hRes = RegQueryValue(currentKeyHandle, currentKeyName, (LPBYTE)lpsData, &lLen);
812 }
813 if (hRes == ERROR_SUCCESS) {
814 lpsRes = HeapAlloc(GetProcessHeap(), 0, lLen);
815 strncpy(lpsRes, lpsData, lLen);
816 lpsRes[lLen-1]='\0';
817 }
818 } else {
819 DWORD dwLen = KEY_MAX_LEN;
821 DWORD dwType;
822 /*
823 * We need to query a specific value for the key
824 */
825 hRes = RegQueryValueEx(
827 keyValue,
828 0,
829 &dwType,
830 (LPBYTE)lpbData,
831 &dwLen);
832
833 if (hRes == ERROR_MORE_DATA) {
834 lpbData = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpbData, dwLen * sizeof(TCHAR));
835 hRes = RegQueryValueEx(currentKeyHandle, keyValue, NULL, &dwType, (LPBYTE)lpbData, &dwLen);
836 }
837
838 if (hRes == ERROR_SUCCESS) {
839 /*
840 * Convert the returned data to a displayable format
841 */
842 switch (dwType) {
843 case REG_SZ:
844 case REG_EXPAND_SZ:
845 lpsRes = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(TCHAR));
846 strncpy(lpsRes, lpbData, dwLen);
847 lpsRes[dwLen-1] = '\0';
848 break;
849 case REG_DWORD:
850 lpsRes = convertHexToDWORDStr(lpbData, dwLen);
851 break;
852 default:
853 lpsRes = convertHexToHexCSV(lpbData, dwLen);
854 break;
855 }
856 }
857
858 HeapFree(GetProcessHeap(), 0, lpbData);
859 }
860 if (hRes == ERROR_SUCCESS) {
861 _tprintf(_T("Value \"%s\" = \"%s\" in key [%s]\n"), keyValue, lpsRes, currentKeyName);
862
863 } else {
864 _tprintf(_T("ERROR Value \"%s\" not found. for key \"%s\"\n"), keyValue, currentKeyName);
865 }
866
867 /*
868 * Do some cleanup
869 */
870 for (counter=0; counter<argCounter; counter++)
871 if (argv[counter] != NULL)
873
874 if (lpsRes != NULL)
875 HeapFree(GetProcessHeap(), 0, lpsRes);
876#endif
877}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
TCHAR * convertHexToDWORDStr(BYTE *buf, ULONG bufLen)
Definition: regproc.c:272
#define QUERY_VALUE_MAX_ARGS
Definition: regproc.c:62
TCHAR * convertHexToHexCSV(BYTE *buf, ULONG bufLen)
Definition: regproc.c:246
LPTSTR getArg(LPTSTR arg)
Definition: regproc.c:377
#define argv
Definition: mplay32.c:18
long LONG
Definition: pedump.c:60
char * getToken(char **str, const char *delims)
TCHAR * cmdline
Definition: stretchblt.cpp:32
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define RegQueryValueEx
Definition: winreg.h:524
#define RegQueryValue
Definition: winreg.h:523
char * LPSTR
Definition: xmlstorage.h:182

Referenced by doQueryValue().

◆ processRegLines()

void processRegLines ( FILE in,
CommandAPI  command 
)

Definition at line 887 of file regproc.c.

888{
889 LPTSTR line = NULL; /* line read from input stream */
890 ULONG lineSize = REG_VAL_BUF_SIZE;
891
892 line = HeapAlloc(GetProcessHeap(), 0, lineSize * sizeof(TCHAR));
894
895 while (!feof(in)) {
896 LPTSTR s; /* The pointer into line for where the current fgets should read */
897 s = line;
898 for (;;) {
899 size_t size_remaining;
900 int size_to_get;
901 TCHAR *s_eol; /* various local uses */
902
903 /* Do we need to expand the buffer ? */
904 assert (s >= line && s <= line + lineSize);
905 size_remaining = lineSize - (s-line);
906 if (size_remaining < 2) { /* room for 1 character and the \0 */
907 TCHAR *new_buffer;
908 size_t new_size = lineSize + REG_VAL_BUF_SIZE;
909 if (new_size > lineSize) /* no arithmetic overflow */
910 new_buffer = HeapReAlloc (GetProcessHeap(), 0, line, new_size * sizeof(TCHAR));
911 else
912 new_buffer = NULL;
913 CHECK_ENOUGH_MEMORY(new_buffer);
914 line = new_buffer;
915 s = line + lineSize - size_remaining;
916 lineSize = new_size;
917 size_remaining = lineSize - (s-line);
918 }
919
920 /* Get as much as possible into the buffer, terminated either by
921 * eof, error, eol or getting the maximum amount. Abort on error.
922 */
923//
924// This line is surely foobar, don't want to read INT_MAX in buffer at s, it's never going to be that big...
925// size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining);
926//
927// Looks as if 'lineSize' contains the number of characters of buffer size
928//
929 size_to_get = (size_remaining > lineSize ? lineSize : size_remaining);
930
931 if (NULL == _fgetts(s, size_to_get, in)) {
932 if (ferror(in)) {
933 //_tperror(_T("While reading input"));
934 perror ("While reading input");
935 //exit(IO_ERROR);
936 return;
937 } else {
938 assert (feof(in));
939 *s = _T('\0');
940 /* It is not clear to me from the definition that the
941 * contents of the buffer are well defined on detecting
942 * an eof without managing to read anything.
943 */
944 }
945 }
946
947 /* If we didn't read the eol nor the eof go around for the rest */
948 s_eol = _tcschr (s, _T('\n'));
949 if (!feof (in) && !s_eol) {
950 s = _tcschr (s, _T('\0'));
951 /* It should be s + size_to_get - 1 but this is safer */
952 continue;
953 }
954
955 /* If it is a comment line then discard it and go around again */
956 if (line [0] == _T('#')) {
957 s = line;
958 continue;
959 }
960
961 /* Remove any line feed. Leave s_eol on the \0 */
962 if (s_eol) {
963 *s_eol = _T('\0');
964 if (s_eol > line && *(s_eol-1) == _T('\r'))
965 *--s_eol = _T('\0');
966 } else {
967 s_eol = _tcschr (s, _T('\0'));
968 }
969 /* If there is a concatenating \\ then go around again */
970 if (s_eol > line && *(s_eol-1) == _T('\\')) {
971 int c;
972 s = s_eol-1;
973 /* The following error protection could be made more self-
974 * correcting but I thought it not worth trying.
975 */
976
977 if ((c = _fgettc(in)) == _TEOF || c != _T(' ') ||
978 (c = _fgettc(in)) == _TEOF || c != _T(' '))
979 _tprintf(_T("ERROR - invalid continuation.\n"));
980 continue;
981 }
982 break; /* That is the full virtual line */
983 }
984 command(line);
985 }
986 command(NULL);
988}
const GLubyte * c
Definition: glext.h:8905
GLuint in
Definition: glext.h:9616
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
#define _fgettc
Definition: tchar.h:562
#define _fgetts
Definition: tchar.h:565
#define c
Definition: ke_i.h:80
#define _TEOF
Definition: regproc.c:117
Definition: parser.c:49

Referenced by import_registry_file().

◆ processSetValue()

void processSetValue ( LPTSTR  cmdline)

Definition at line 716 of file regproc.c.

717{
718 LPTSTR val_name; /* registry value name */
719 LPTSTR val_data; /* registry value data */
720
721 int line_idx = 0; /* current character under analysis */
722 HRESULT hRes = 0;
723
724 /* get value name */
725 if (line[line_idx] == _T('@') && line[line_idx + 1] == _T('=')) {
726 line[line_idx] = _T('\0');
727 val_name = line;
728 line_idx++;
729 } else if (line[line_idx] == _T('\"')) {
730 line_idx++;
731 val_name = line + line_idx;
732 while (TRUE) {
733 if (line[line_idx] == _T('\\')) { /* skip escaped character */
734 line_idx += 2;
735 } else {
736 if (line[line_idx] == _T('\"')) {
737 line[line_idx] = _T('\0');
738 line_idx++;
739 break;
740 } else {
741 line_idx++;
742 }
743 }
744 }
745 if (line[line_idx] != _T('=')) {
746 line[line_idx] = _T('\"');
747 _tprintf(_T("Warning! uncrecognized line:\n%s\n"), line);
748 return;
749 }
750 } else {
751 _tprintf(_T("Warning! unrecognized line:\n%s\n"), line);
752 return;
753 }
754 line_idx++; /* skip the '=' character */
755 val_data = line + line_idx;
756 REGPROC_unescape_string(val_name);
757
758 _tprintf(_T("Key: %s, Value: %s, Data: %s\n"), currentKeyName, val_name, val_data);
759
760 hRes = setValue(val_name, val_data);
761 if (hRes != ERROR_SUCCESS) {
762 _tprintf(_T("ERROR Key %s not created. Value: %s, Data: %s\n"), currentKeyName, val_name, val_data);
763 }
764}
static BOOL REGPROC_unescape_string(WCHAR *str, WCHAR **unparsed)
Definition: regproc.c:352
HRESULT setValue(LPTSTR val_name, LPTSTR val_data)
Definition: regproc.c:432

Referenced by doSetValue().

◆ RegHeapAlloc()

LPVOID RegHeapAlloc ( HANDLE  hHeap,
DWORD  dwFlags,
SIZE_T  dwBytes 
)

◆ RegHeapFree()

BOOL RegHeapFree ( HANDLE  hHeap,
DWORD  dwFlags,
LPVOID  lpMem 
)

◆ RegHeapReAlloc()

LPVOID RegHeapReAlloc ( HANDLE  hHeap,
DWORD  dwFlags,
LPVOID  lpMem,
SIZE_T  dwBytes 
)

◆ setValue()

HRESULT setValue ( LPTSTR  val_name,
LPTSTR  val_data 
)

Definition at line 432 of file regproc.c.

433{
434 HRESULT hRes;
435 DWORD dwDataType, dwParseType;
436 LPBYTE lpbData;
438 BYTE *bBigBuffer = 0;
439 DWORD dwLen;
440
441 if ((val_name == NULL) || (val_data == NULL))
443
444 /* Get the data type stored into the value field */
445 dwDataType = getDataType(&val_data, &dwParseType);
446
447// if (dwParseType == REG_EXPAND_SZ) {
448// }
449// if (dwParseType == REG_SZ || dwParseType == REG_EXPAND_SZ) { /* no conversion for string */
450
451 if (dwParseType == REG_SZ) { /* no conversion for string */
452 dwLen = _tcslen(val_data);
453 if (dwLen > 0 && val_data[dwLen-1] == _T('"')) {
454 dwLen--;
455 val_data[dwLen] = _T('\0');
456 }
457 dwLen++;
458 dwLen *= sizeof(TCHAR);
459 REGPROC_unescape_string(val_data);
460 lpbData = val_data;
461 } else if (dwParseType == REG_DWORD) { /* Convert the dword types */
462 dwLen = convertHexToDWord(val_data, convert);
463 lpbData = convert;
464 } else { /* Convert the hexadecimal types */
465 int b_len = _tcslen(val_data)+2/3;
466 if (b_len > KEY_MAX_LEN) {
467 bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len * sizeof(TCHAR));
468 if (bBigBuffer == NULL) {
470 }
471 CHECK_ENOUGH_MEMORY(bBigBuffer);
472 dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len);
473 lpbData = bBigBuffer;
474 } else {
475 dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN);
476 lpbData = convert;
477 }
478 }
479 hRes = RegSetValueEx(currentKeyHandle, val_name,
480 0, /* Reserved */dwDataType, lpbData, dwLen);
481
482 _tprintf(_T(" Value: %s, Data: %s\n"), val_name, lpbData);
483
484
485 if (bBigBuffer)
486 HeapFree(GetProcessHeap(), 0, bBigBuffer);
487 return hRes;
488}
DWORD getDataType(LPTSTR *lpValue, DWORD *parse_type)
Definition: regproc.c:331
DWORD convertHexToDWord(TCHAR *str, BYTE *buf)
Definition: regproc.c:231
DWORD convertHexCSVToHex(TCHAR *str, BYTE *buf, ULONG bufLen)
Definition: regproc.c:289
int convert
Definition: msacm.c:1374
#define ERROR_REGISTRY_IO_FAILED
Definition: winerror.h:595
#define RegSetValueEx
Definition: winreg.h:533

Referenced by processSetValue().