39#define WIN32_LEAN_AND_MEAN
59#define REG_VAL_BUF_SIZE 4096
62#define QUERY_VALUE_MAX_ARGS 1
66#define REG_FILE_HEX_LINE_LEN 76
75 _T(
"HKEY_LOCAL_MACHINE"),
77 _T(
"HKEY_CLASSES_ROOT"),
78 _T(
"HKEY_CURRENT_CONFIG"),
79 _T(
"HKEY_CURRENT_USER")
82#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
90#define NOT_ENOUGH_MEMORY 1
97#define CHECK_ENOUGH_MEMORY(p) \
100 _tprintf(_T("file %S, line %d: Not enough memory"), __FILE__, __LINE__); \
102 exit(NOT_ENOUGH_MEMORY); \
105#define CHECK_ENOUGH_MEMORY(p) \
108 _tprintf(_T("file %s, line %d: Not enough memory"), __FILE__, __LINE__); \
110 exit(NOT_ENOUGH_MEMORY); \
135 while (**
str!=
'\0') {
162 CHAR *
s = *command_line;
172 while (
s[0] !=
'"') {
174 _tprintf(
_T(
"Unexpected end of file name!\n"));
202 (*command_line) +=
pos;
237 xbuf[88 *
sizeof(
TCHAR)] =
'\0';
240 return sizeof(
DWORD);
277 if (bufLen !=
sizeof(
DWORD))
return NULL;
303 _tprintf(
_T(
"WARNING converting CSV hex stream with no comma, ") \
304 _T(
"input data seems invalid.\n"));
306 if (strLen > 3*bufLen) {
307 _tprintf(
_T(
"ERROR converting CSV hex stream. Too long\n"));
309 while (strPos < strLen) {
316 *
b++ = (
unsigned char)wc;
335 static const struct data_type data_types[] =
347 const struct data_type *
ptr;
350 for (
ptr = data_types;
ptr->tag;
ptr++) {
357 *lpValue +=
ptr->len;
362 if (**lpValue ==
_T(
'\0') || *
end !=
_T(
')') || *(
end+1) !=
_T(
':')) {
401 for (str_idx = 0; str_idx <
len; str_idx++, val_idx++) {
402 if (
str[str_idx] ==
_T(
'\\')) {
404 switch (
str[str_idx]) {
406 str[val_idx] =
_T(
'\n');
410 str[val_idx] =
str[str_idx];
413 _tprintf(
_T(
"Warning! Unrecognized escape sequence: \\%c'\n"),
str[str_idx]);
414 str[val_idx] =
str[str_idx];
418 str[val_idx] =
str[str_idx];
421 str[val_idx] =
_T(
'\0');
435 DWORD dwDataType, dwParseType;
438 BYTE *bBigBuffer = 0;
441 if ((val_name ==
NULL) || (val_data ==
NULL))
451 if (dwParseType ==
REG_SZ) {
453 if (dwLen > 0 && val_data[dwLen-1] ==
_T(
'"')) {
455 val_data[dwLen] =
_T(
'\0');
458 dwLen *=
sizeof(
TCHAR);
465 int b_len =
_tcslen(val_data)+2/3;
468 if (bBigBuffer ==
NULL) {
473 lpbData = bBigBuffer;
480 0, dwDataType, lpbData, dwLen);
482 _tprintf(
_T(
" Value: %s, Data: %s\n"), val_name, lpbData);
500 if (stdInput ==
NULL)
545 keyNameBeg =
_tcschr(lpLineCopy,
_T(
'\\'));
550 keyNameEnd =
_tcschr(lpLineCopy,
_T(
']'));
552 *keyNameEnd =
_T(
'\0');
555 keyNameBeg = lpLineCopy +
_tcslen(lpLineCopy);
580 classNameEnd =
_tcschr(lpClassCopy,
_T(
'\\'));
582 classNameEnd = lpClassCopy +
_tcslen(lpClassCopy);
583 if (classNameEnd[-1] ==
_T(
']')) {
587 *classNameEnd =
_T(
'\0');
588 if (lpClassCopy[0] ==
_T(
'[')) {
589 classNameBeg = lpClassCopy + 1;
591 classNameBeg = lpClassCopy;
625 if (stdInput ==
NULL) {
631 if (stdInput[0] ==
_T(
'[')) {
636 _tprintf(
_T(
"doSetValue failed to open key %s\n"), stdInput);
639 ((stdInput[0] ==
_T(
'@')) ||
640 (stdInput[0] ==
_T(
'\"')))) {
658 if (stdInput ==
NULL) {
664 if (stdInput[0] ==
_T(
'[')) {
668 _tprintf(
_T(
"doQueryValue failed to open key %s\n"), stdInput);
672 ((stdInput[0] ==
_T(
'@')) ||
673 (stdInput[0] ==
_T(
'\"')))) {
687 _tprintf(
_T(
"deleteValue not yet implemented\n"));
696 _tprintf(
_T(
"deleteKey not yet implemented\n"));
705 _tprintf(
_T(
"createKey not yet implemented\n"));
725 if (
line[line_idx] ==
_T(
'@') &&
line[line_idx + 1] ==
_T(
'=')) {
726 line[line_idx] =
_T(
'\0');
729 }
else if (
line[line_idx] ==
_T(
'\"')) {
731 val_name =
line + line_idx;
733 if (
line[line_idx] ==
_T(
'\\')) {
736 if (
line[line_idx] ==
_T(
'\"')) {
737 line[line_idx] =
_T(
'\0');
745 if (
line[line_idx] !=
_T(
'=')) {
746 line[line_idx] =
_T(
'\"');
755 val_data =
line + line_idx;
760 hRes =
setValue(val_name, val_data);
772 _tprintf(
_T(
"ERROR!!! - temporary disabled"));
778 ULONG argCounter = 0;
802 if ((keyValue[0] ==
'@') && (
_tcslen(keyValue) == 1)) {
815 strncpy(lpsRes, lpsData, lLen);
846 strncpy(lpsRes, lpbData, dwLen);
847 lpsRes[dwLen-1] =
'\0';
899 size_t size_remaining;
905 size_remaining = lineSize - (
s-
line);
906 if (size_remaining < 2) {
915 s =
line + lineSize - size_remaining;
917 size_remaining = lineSize - (
s-
line);
929 size_to_get = (size_remaining > lineSize ? lineSize : size_remaining);
934 perror (
"While reading input");
949 if (!
feof (
in) && !s_eol) {
956 if (
line [0] ==
_T(
'#')) {
964 if (s_eol >
line && *(s_eol-1) ==
_T(
'\r'))
970 if (s_eol >
line && *(s_eol-1) ==
_T(
'\\')) {
979 _tprintf(
_T(
"ERROR - invalid continuation.\n"));
1000 if (stdInput ==
NULL)
return;
1006 if (lpfnDLLRegProc) {
1007 retVal = (*lpfnDLLRegProc)();
1009 _tprintf(
_T(
"Couldn't find DllRegisterServer proc in '%s'.\n"), stdInput);
1011 if (retVal !=
S_OK) {
1012 _tprintf(
_T(
"Couldn't find DllRegisterServer proc in '%s'.\n"), stdInput);
1016 _tprintf(
_T(
"Could not load DLL '%s'.\n"), stdInput);
1030 if (stdInput ==
NULL)
return;
1036 if (lpfnDLLRegProc) {
1037 retVal = (*lpfnDLLRegProc)();
1039 _tprintf(
_T(
"Couldn't find DllUnregisterServer proc in '%s'.\n"), stdInput);
1041 if (retVal !=
S_OK) {
1042 _tprintf(
_T(
"DLLUnregisterServer error 0x%x in '%s'.\n"), retVal, stdInput);
1046 _tprintf(
_T(
"Could not load DLL '%s'.\n"), stdInput);
1088 if (required_len > *
len) {
1089 *
len = required_len;
1104 for (
i = 0;
i <
len;
i++) {
1132 TCHAR **reg_key_name_buf,
DWORD *reg_key_name_len,
1136 DWORD max_sub_key_len;
1137 DWORD max_val_name_len;
1149 curr_len =
_tcslen(*reg_key_name_buf);
1152 if (max_val_size > *val_size) {
1153 *val_size = max_val_size;
1166 DWORD val_name_len1 = *val_name_len;
1167 DWORD val_size1 = *val_size;
1176 if ((*val_name_buf)[0]) {
1183 switch (value_type) {
1212 hex_prefix =
_T(
"hex:");
1222 for (i1 = 0; i1 < val_size1; i1++) {
1224 if (i1 + 1 < val_size1) {
1242 (*reg_key_name_buf)[curr_len] =
_T(
'\\');
1244 DWORD buf_len = *reg_key_name_len - curr_len;
1256 export_hkey(
file, subkey, reg_key_name_buf, reg_key_name_len, val_name_buf, val_name_len, val_buf, val_size);
1263 (*reg_key_name_buf)[curr_len] =
_T(
'\0');
1314 TCHAR *reg_key_name_buf;
1315 TCHAR *val_name_buf;
1329 if (reg_key_name && reg_key_name[0]) {
1335 _tcscpy(reg_key_name_buf, reg_key_name);
1340 _tprintf(
_T(
"Incorrect registry class specification in '%s\n"), reg_key_name);
1346 if (!branch_name[0]) {
1350 ®_key_name_buf, ®_key_name_len,
1351 &val_name_buf, &val_name_len,
1352 &val_buf, &val_size);
1356 ®_key_name_buf, ®_key_name_len,
1357 &val_name_buf, &val_name_len,
1358 &val_buf, &val_size);
1361 _tprintf(
_T(
"Can't export. Registry key '%s does not exist!\n"), reg_key_name);
1377 ®_key_name_buf, ®_key_name_len,
1378 &val_name_buf, &val_name_len,
1379 &val_buf, &val_size);
1413 DWORD max_sub_key_len;
1431 curr_len =
_tcslen(*reg_key_name_buf);
1434 (*reg_key_name_buf)[curr_len] =
'\\';
1435 for (
i = subkeys - 1;
i >= 0;
i--) {
1436 DWORD buf_len = *reg_key_name_len - curr_len;
1446 (*reg_key_name_buf)[curr_len] =
'\0';
1462 DWORD branch_name_len;
1466 if (!reg_key_name || !reg_key_name[0]) {
1472 _tprintf(
_T(
"Incorrect registry class specification in '%s'\n"), reg_key_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);
1487 delete_branch(reg_key_class, &branch_name, &branch_name_len);
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
BOOL import_registry_file(FILE *reg_file)
static HKEY reg_class_keys[]
static BOOL REGPROC_unescape_string(WCHAR *str, WCHAR **unparsed)
static FILE * REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
BOOL export_registry_key(WCHAR *file_name, WCHAR *path, DWORD format)
void delete_registry_key(WCHAR *reg_key_name)
#define RegCloseKey(hKey)
int puts(const char *string)
#define ERROR_INVALID_PARAMETER
#define GetProcAddress(x, y)
#define ERROR_NO_MORE_ITEMS
#define HeapFree(x, y, z)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLuint GLsizei GLenum type
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
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
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
HLOCAL NTAPI LocalFree(HLOCAL hMem)
_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)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
REFIID LPVOID DWORD_PTR dw
#define memcpy(s1, s2, n)
struct task_struct * current
void doRegisterDLL(LPTSTR stdInput)
static TCHAR * reg_class_names[]
LPTSTR getRegKeyName(LPTSTR lpLine)
TCHAR * convertHexToDWORDStr(BYTE *buf, ULONG bufLen)
void processQueryValue(LPTSTR cmdline)
void doSetValue(LPTSTR stdInput)
static HKEY currentKeyHandle
void processSetValue(LPTSTR line)
void REGPROC_export_string(FILE *file, TCHAR *str)
HRESULT openKey(LPTSTR stdInput)
BOOL delete_branch(HKEY key, TCHAR **reg_key_name_buf, DWORD *reg_key_name_len)
#define REG_FILE_HEX_LINE_LEN
static HKEY currentKeyClass
static BOOL bTheKeyIsOpen
HRESULT setValue(LPTSTR val_name, LPTSTR val_data)
DWORD getDataType(LPTSTR *lpValue, DWORD *parse_type)
#define QUERY_VALUE_MAX_ARGS
void REGPROC_resize_char_buffer(TCHAR **buffer, DWORD *len, DWORD required_len)
static LPTSTR currentKeyName
void REGPROC_print_error(VOID)
void doDeleteValue(LPTSTR line)
void doQueryValue(LPTSTR stdInput)
TCHAR * convertHexToHexCSV(BYTE *buf, ULONG bufLen)
DWORD convertHexToDWord(TCHAR *str, BYTE *buf)
void doDeleteKey(LPTSTR line)
void doUnregisterDLL(LPTSTR stdInput)
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)
DWORD convertHexCSVToHex(TCHAR *str, BYTE *buf, ULONG bufLen)
HKEY getRegClass(LPTSTR lpClass)
void get_file_nameA(CHAR **command_line, CHAR *file_name, int max_filename)
#define CHECK_ENOUGH_MEMORY(p)
LPTSTR getArg(LPTSTR arg)
void processRegLines(FILE *in, CommandAPI command)
void doCreateKey(LPTSTR line)
void get_file_nameW(CHAR **command_line, WCHAR *filename, int max_filename)
static CHAR filenameA[MAX_PATH]
#define REG_OPTION_NON_VOLATILE
void(* CommandAPI)(LPTSTR lpsLine)
char * getToken(char **str, const char *delims)
int parse_type(Type t, const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
DWORD WINAPI GetLastError(void)
#define FORMAT_MESSAGE_FROM_SYSTEM
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
#define ERROR_REGISTRY_IO_FAILED
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_CONFIG
#define HKEY_CURRENT_USER
#define HKEY_CLASSES_ROOT
BOOL WINAPI OemToCharBuffW(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPWSTR lpszDst, _In_ DWORD cchDstLength)