mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 18:43:41 +00:00
Lightweight sync with WINE regedit; imported obvious changes such as const correctness, TCHAR string usage etc
svn path=/trunk/; revision=18056
This commit is contained in:
parent
b59af67517
commit
4f9b4be8fb
6 changed files with 65 additions and 69 deletions
|
@ -42,6 +42,7 @@ static LPCTSTR get_root_key_name(HKEY hRootKey)
|
||||||
if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
|
if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
|
||||||
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
|
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
|
||||||
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
|
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
|
||||||
|
if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
|
||||||
return _T("UKNOWN HKEY, PLEASE REPORT");
|
return _T("UKNOWN HKEY, PLEASE REPORT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +170,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
* WM_DESTROY - post a quit message and return
|
* WM_DESTROY - post a quit message and return
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
static short last_split;
|
static short last_split;
|
||||||
BOOL Result;
|
BOOL Result;
|
||||||
|
|
|
@ -61,7 +61,7 @@ static void resize_frame_rect(HWND hWnd, PRECT prect)
|
||||||
MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
|
MoveWindow(g_pChildWnd->hWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize_frame_client(HWND hWnd)
|
static void resize_frame_client(HWND hWnd)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ static BOOL CheckCommDlgError(HWND hWnd)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
|
static UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
OPENFILENAME* pOpenFileName;
|
OPENFILENAME* pOpenFileName;
|
||||||
OFNOTIFY* pOfNotify;
|
OFNOTIFY* pOfNotify;
|
||||||
|
@ -375,7 +375,7 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||||
pd.nToPage = 0xFFFF;
|
pd.nToPage = 0xFFFF;
|
||||||
pd.nMinPage = 1;
|
pd.nMinPage = 1;
|
||||||
pd.nMaxPage = 0xFFFF;
|
pd.nMaxPage = 0xFFFF;
|
||||||
if (PrintDlg(&pd) == TRUE) {
|
if (PrintDlg(&pd)) {
|
||||||
/* GDI calls to render output. */
|
/* GDI calls to render output. */
|
||||||
DeleteDC(pd.hDC); /* Delete DC when done.*/
|
DeleteDC(pd.hDC); /* Delete DC when done.*/
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ BOOL PrintRegistryHive(HWND hWnd, LPTSTR path)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CopyKeyName(HWND hWnd, LPTSTR keyName)
|
static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
|
||||||
{
|
{
|
||||||
BOOL result;
|
BOOL result;
|
||||||
|
|
||||||
|
@ -717,8 +717,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
|
@ -730,6 +729,10 @@ FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if (!_CmdWndProc(hWnd, message, wParam, lParam))
|
if (!_CmdWndProc(hWnd, message, wParam, lParam))
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
break;
|
break;
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
if (LOWORD(hWnd))
|
||||||
|
SetFocus(g_pChildWnd->hWnd);
|
||||||
|
break;
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
resize_frame_client(hWnd);
|
resize_frame_client(hWnd);
|
||||||
break;
|
break;
|
||||||
|
@ -744,10 +747,6 @@ FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_MENUSELECT:
|
case WM_MENUSELECT:
|
||||||
OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
||||||
break;
|
break;
|
||||||
case WM_ACTIVATE:
|
|
||||||
if (LOWORD(hWnd))
|
|
||||||
SetFocus(g_pChildWnd->hWnd);
|
|
||||||
break;
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
|
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "regproc.h"
|
#include "regproc.h"
|
||||||
|
|
||||||
static char *usage =
|
static const char *usage =
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
" regedit filename\n"
|
" regedit filename\n"
|
||||||
" regedit /E filename [regpath]\n"
|
" regedit /E filename [regpath]\n"
|
||||||
|
@ -52,8 +52,7 @@ static char *usage =
|
||||||
"\n"
|
"\n"
|
||||||
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
|
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
|
||||||
"This program is command-line compatible with Microsoft Windows\n"
|
"This program is command-line compatible with Microsoft Windows\n"
|
||||||
"regedit. The difference with Windows regedit - this application has\n"
|
"regedit.\n";
|
||||||
"command-line interface only.\n";
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||||
|
@ -68,7 +67,7 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s);
|
||||||
* chu - the switch character in upper-case.
|
* chu - the switch character in upper-case.
|
||||||
* s - the command line string where s points to the switch character.
|
* s - the command line string where s points to the switch character.
|
||||||
*/
|
*/
|
||||||
void error_unknown_switch(char chu, char *s)
|
static void error_unknown_switch(char chu, char *s)
|
||||||
{
|
{
|
||||||
if (isalpha(chu)) {
|
if (isalpha(chu)) {
|
||||||
fprintf(stderr,"%s: Undefined switch /%c!\n", getAppName(), chu);
|
fprintf(stderr,"%s: Undefined switch /%c!\n", getAppName(), chu);
|
||||||
|
|
|
@ -46,18 +46,18 @@ static HKEY currentKeyClass = 0;
|
||||||
static HKEY currentKeyHandle = 0;
|
static HKEY currentKeyHandle = 0;
|
||||||
static BOOL bTheKeyIsOpen = FALSE;
|
static BOOL bTheKeyIsOpen = FALSE;
|
||||||
|
|
||||||
static CHAR *app_name = "UNKNOWN";
|
static const CHAR *app_name = "UNKNOWN";
|
||||||
|
|
||||||
static CHAR *reg_class_names[] = {
|
static const CHAR *reg_class_names[] = {
|
||||||
"HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT",
|
"HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CLASSES_ROOT",
|
||||||
"HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER"
|
"HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
|
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
|
||||||
|
|
||||||
static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
|
static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
|
||||||
HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT,
|
HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT,
|
||||||
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER
|
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
|
||||||
};
|
};
|
||||||
|
|
||||||
/* return values */
|
/* return values */
|
||||||
|
@ -234,7 +234,7 @@ char* convertHexToDWORDStr(BYTE *buf, ULONG bufLen)
|
||||||
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen)
|
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen)
|
||||||
{
|
{
|
||||||
char *s = str; /* Pointer to current */
|
char *s = str; /* Pointer to current */
|
||||||
char *b = (char*)buf; /* Pointer to result */
|
char *b = (char*) buf; /* Pointer to result */
|
||||||
|
|
||||||
ULONG strLen = strlen(str);
|
ULONG strLen = strlen(str);
|
||||||
ULONG strPos = 0;
|
ULONG strPos = 0;
|
||||||
|
@ -346,7 +346,7 @@ LPSTR getArg( LPSTR arg)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Replaces escape sequences with the characters.
|
* Replaces escape sequences with the characters.
|
||||||
*/
|
*/
|
||||||
void REGPROC_unescape_string(LPSTR str)
|
static void REGPROC_unescape_string(LPSTR str)
|
||||||
{
|
{
|
||||||
int str_idx = 0; /* current character under analysis */
|
int str_idx = 0; /* current character under analysis */
|
||||||
int val_idx = 0; /* the last character of the unescaped string */
|
int val_idx = 0; /* the last character of the unescaped string */
|
||||||
|
@ -427,7 +427,7 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hRes = RegSetValueExA(
|
hRes = RegSetValueEx(
|
||||||
currentKeyHandle,
|
currentKeyHandle,
|
||||||
val_name,
|
val_name,
|
||||||
0, /* Reserved */
|
0, /* Reserved */
|
||||||
|
@ -522,14 +522,14 @@ HKEY getRegClass(LPSTR lpClass)
|
||||||
{
|
{
|
||||||
LPSTR classNameEnd;
|
LPSTR classNameEnd;
|
||||||
LPSTR classNameBeg;
|
LPSTR classNameBeg;
|
||||||
UINT i;
|
unsigned int i;
|
||||||
|
|
||||||
char lpClassCopy[KEY_MAX_LEN];
|
char lpClassCopy[KEY_MAX_LEN];
|
||||||
|
|
||||||
if (lpClass == NULL)
|
if (lpClass == NULL)
|
||||||
return (HKEY)ERROR_INVALID_PARAMETER;
|
return (HKEY)ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
strncpy(lpClassCopy, lpClass, KEY_MAX_LEN);
|
lstrcpynA(lpClassCopy, lpClass, KEY_MAX_LEN);
|
||||||
|
|
||||||
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */
|
classNameEnd = strchr(lpClassCopy, '\\'); /* The class name ends by '\' */
|
||||||
if (!classNameEnd) /* or the whole string */
|
if (!classNameEnd) /* or the whole string */
|
||||||
|
@ -558,7 +558,7 @@ HKEY getRegClass(LPSTR lpClass)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Close the currently opened key.
|
* Close the currently opened key.
|
||||||
*/
|
*/
|
||||||
void closeKey()
|
void closeKey(void)
|
||||||
{
|
{
|
||||||
RegCloseKey(currentKeyHandle);
|
RegCloseKey(currentKeyHandle);
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ void closeKey()
|
||||||
void doSetValue(LPSTR stdInput)
|
void doSetValue(LPSTR stdInput)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We encoutered the end of the file, make sure we
|
* We encountered the end of the file, make sure we
|
||||||
* close the opened key and exit
|
* close the opened key and exit
|
||||||
*/
|
*/
|
||||||
if (stdInput == NULL) {
|
if (stdInput == NULL) {
|
||||||
|
@ -610,14 +610,14 @@ void doSetValue(LPSTR stdInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the queryValue type of action. It
|
* This function is the main entry point to the queryValue type of action. It
|
||||||
* receives the currently read line and dispatch the work depending on the
|
* receives the currently read line and dispatch the work depending on the
|
||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
void doQueryValue(LPSTR stdInput)
|
void doQueryValue(LPSTR stdInput)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We encoutered the end of the file, make sure we
|
* We encountered the end of the file, make sure we
|
||||||
* close the opened key and exit
|
* close the opened key and exit
|
||||||
*/
|
*/
|
||||||
if (stdInput == NULL) {
|
if (stdInput == NULL) {
|
||||||
|
@ -648,7 +648,7 @@ void doQueryValue(LPSTR stdInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the deletetValue type of action. It
|
* This function is the main entry point to the deleteValue type of action. It
|
||||||
* receives the currently read line and dispatch the work depending on the
|
* receives the currently read line and dispatch the work depending on the
|
||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
|
@ -658,7 +658,7 @@ void doDeleteValue(LPSTR line)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the deleteKey type of action. It
|
* This function is the main entry point to the deleteKey type of action. It
|
||||||
* receives the currently read line and dispatch the work depending on the
|
* receives the currently read line and dispatch the work depending on the
|
||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
|
@ -668,7 +668,7 @@ void doDeleteKey(LPSTR line)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the createKey type of action. It
|
* This function is the main entry point to the createKey type of action. It
|
||||||
* receives the currently read line and dispatch the work depending on the
|
* receives the currently read line and dispatch the work depending on the
|
||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
|
@ -793,8 +793,7 @@ void processQueryValue(LPSTR cmdline)
|
||||||
|
|
||||||
if (hRes == ERROR_SUCCESS) {
|
if (hRes == ERROR_SUCCESS) {
|
||||||
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
|
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
|
||||||
strncpy(lpsRes, lpsData, lLen);
|
lstrcpynA(lpsRes, lpsData, lLen);
|
||||||
lpsRes[lLen-1]='\0';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DWORD dwLen = KEY_MAX_LEN;
|
DWORD dwLen = KEY_MAX_LEN;
|
||||||
|
@ -824,8 +823,7 @@ void processQueryValue(LPSTR cmdline)
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
case REG_EXPAND_SZ: {
|
case REG_EXPAND_SZ: {
|
||||||
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
|
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
|
||||||
strncpy(lpsRes, lpbData, dwLen);
|
lstrcpynA(lpsRes, lpbData, dwLen);
|
||||||
lpsRes[dwLen-1]='\0';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_DWORD: {
|
case REG_DWORD: {
|
||||||
|
@ -976,7 +974,7 @@ void processRegLines(FILE *in, CommandAPI command)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the registerDLL action. It
|
* This function is the main entry point to the registerDLL action. It
|
||||||
* receives the currently read line, then loads and registers the requested DLLs
|
* receives the currently read line, then loads and registers the requested DLLs
|
||||||
*/
|
*/
|
||||||
void doRegisterDLL(LPSTR stdInput)
|
void doRegisterDLL(LPSTR stdInput)
|
||||||
|
@ -989,7 +987,7 @@ void doRegisterDLL(LPSTR stdInput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Load and register the library, then free it */
|
/* Load and register the library, then free it */
|
||||||
theLib = LoadLibraryA(stdInput);
|
theLib = LoadLibrary(stdInput);
|
||||||
if (theLib) {
|
if (theLib) {
|
||||||
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer");
|
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllRegisterServer");
|
||||||
if (lpfnDLLRegProc)
|
if (lpfnDLLRegProc)
|
||||||
|
@ -1009,7 +1007,7 @@ void doRegisterDLL(LPSTR stdInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* This funtion is the main entry point to the unregisterDLL action. It
|
* This function is the main entry point to the unregisterDLL action. It
|
||||||
* receives the currently read line, then loads and unregisters the requested DLLs
|
* receives the currently read line, then loads and unregisters the requested DLLs
|
||||||
*/
|
*/
|
||||||
void doUnregisterDLL(LPSTR stdInput)
|
void doUnregisterDLL(LPSTR stdInput)
|
||||||
|
@ -1022,7 +1020,7 @@ void doUnregisterDLL(LPSTR stdInput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Load and unregister the library, then free it */
|
/* Load and unregister the library, then free it */
|
||||||
theLib = LoadLibraryA(stdInput);
|
theLib = LoadLibrary(stdInput);
|
||||||
if (theLib) {
|
if (theLib) {
|
||||||
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer");
|
FARPROC lpfnDLLRegProc = GetProcAddress(theLib, "DllUnregisterServer");
|
||||||
if (lpfnDLLRegProc)
|
if (lpfnDLLRegProc)
|
||||||
|
@ -1047,7 +1045,7 @@ void doUnregisterDLL(LPSTR stdInput)
|
||||||
* Print the message for GetLastError
|
* Print the message for GetLastError
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void REGPROC_print_error()
|
static void REGPROC_print_error(void)
|
||||||
{
|
{
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
DWORD error_code;
|
DWORD error_code;
|
||||||
|
@ -1076,7 +1074,7 @@ void REGPROC_print_error()
|
||||||
* required_len - length of the string to place to the buffer in characters.
|
* required_len - length of the string to place to the buffer in characters.
|
||||||
* The length does not include the terminating null character.
|
* The length does not include the terminating null character.
|
||||||
*/
|
*/
|
||||||
void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD required_len)
|
static void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD required_len)
|
||||||
{
|
{
|
||||||
required_len++;
|
required_len++;
|
||||||
if (required_len > *len) {
|
if (required_len > *len) {
|
||||||
|
@ -1092,7 +1090,7 @@ void REGPROC_resize_char_buffer(CHAR **buffer, DWORD *len, DWORD required_len)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Prints string str to file
|
* Prints string str to file
|
||||||
*/
|
*/
|
||||||
void REGPROC_export_string(FILE *file, CHAR *str)
|
static void REGPROC_export_string(FILE *file, CHAR *str)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -1133,7 +1131,7 @@ void REGPROC_export_string(FILE *file, CHAR *str)
|
||||||
* Is resized if necessary.
|
* Is resized if necessary.
|
||||||
* val_size - size of the buffer for storing values in bytes.
|
* val_size - size of the buffer for storing values in bytes.
|
||||||
*/
|
*/
|
||||||
void export_hkey(FILE *file, HKEY key,
|
static void export_hkey(FILE *file, HKEY key,
|
||||||
CHAR **reg_key_name_buf, DWORD *reg_key_name_len,
|
CHAR **reg_key_name_buf, DWORD *reg_key_name_len,
|
||||||
CHAR **val_name_buf, DWORD *val_name_len,
|
CHAR **val_name_buf, DWORD *val_name_len,
|
||||||
BYTE **val_buf, DWORD *val_size)
|
BYTE **val_buf, DWORD *val_size)
|
||||||
|
@ -1176,8 +1174,8 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
DWORD value_type;
|
DWORD value_type;
|
||||||
DWORD val_name_len1 = *val_name_len;
|
DWORD val_name_len1 = *val_name_len;
|
||||||
DWORD val_size1 = *val_size;
|
DWORD val_size1 = *val_size;
|
||||||
ret = RegEnumValueA(key, i, *val_name_buf, &val_name_len1, NULL,
|
ret = RegEnumValue(key, i, *val_name_buf, &val_name_len1, NULL,
|
||||||
&value_type, *val_buf, &val_size1);
|
&value_type, *val_buf, &val_size1);
|
||||||
if (ret != ERROR_SUCCESS) {
|
if (ret != ERROR_SUCCESS) {
|
||||||
more_data = FALSE;
|
more_data = FALSE;
|
||||||
if (ret != ERROR_NO_MORE_ITEMS) {
|
if (ret != ERROR_NO_MORE_ITEMS) {
|
||||||
|
@ -1198,7 +1196,7 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
fputs("\"", file);
|
fputs("\"", file);
|
||||||
REGPROC_export_string(file, (CHAR*)*val_buf);
|
REGPROC_export_string(file, (char*) *val_buf);
|
||||||
fputs("\"\n", file);
|
fputs("\"\n", file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1217,7 +1215,7 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case REG_BINARY: {
|
case REG_BINARY: {
|
||||||
DWORD i1;
|
DWORD i1;
|
||||||
CHAR *hex_prefix;
|
const CHAR *hex_prefix;
|
||||||
CHAR buf[20];
|
CHAR buf[20];
|
||||||
int cur_pos;
|
int cur_pos;
|
||||||
|
|
||||||
|
@ -1260,8 +1258,8 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
while(more_data) {
|
while(more_data) {
|
||||||
DWORD buf_len = *reg_key_name_len - curr_len;
|
DWORD buf_len = *reg_key_name_len - curr_len;
|
||||||
|
|
||||||
ret = RegEnumKeyExA(key, i, *reg_key_name_buf + curr_len + 1, &buf_len,
|
ret = RegEnumKeyEx(key, i, *reg_key_name_buf + curr_len + 1, &buf_len,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) {
|
if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) {
|
||||||
more_data = FALSE;
|
more_data = FALSE;
|
||||||
if (ret != ERROR_NO_MORE_ITEMS) {
|
if (ret != ERROR_NO_MORE_ITEMS) {
|
||||||
|
@ -1271,8 +1269,8 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
HKEY subkey;
|
HKEY subkey;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (RegOpenKeyA(key, *reg_key_name_buf + curr_len + 1,
|
if (RegOpenKey(key, *reg_key_name_buf + curr_len + 1,
|
||||||
&subkey) == ERROR_SUCCESS) {
|
&subkey) == ERROR_SUCCESS) {
|
||||||
export_hkey(file, subkey, reg_key_name_buf, reg_key_name_len,
|
export_hkey(file, subkey, reg_key_name_buf, reg_key_name_len,
|
||||||
val_name_buf, val_name_len, val_buf, val_size);
|
val_name_buf, val_name_len, val_buf, val_size);
|
||||||
RegCloseKey(subkey);
|
RegCloseKey(subkey);
|
||||||
|
@ -1287,7 +1285,7 @@ void export_hkey(FILE *file, HKEY key,
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Open file for export.
|
* Open file for export.
|
||||||
*/
|
*/
|
||||||
FILE *REGPROC_open_export_file(CHAR *file_name)
|
static FILE *REGPROC_open_export_file(CHAR *file_name)
|
||||||
{
|
{
|
||||||
FILE *file = fopen(file_name, "w");
|
FILE *file = fopen(file_name, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
@ -1350,7 +1348,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
|
||||||
®_key_name_buf, ®_key_name_len,
|
®_key_name_buf, ®_key_name_len,
|
||||||
&val_name_buf, &val_name_len,
|
&val_name_buf, &val_name_len,
|
||||||
&val_buf, &val_size);
|
&val_buf, &val_size);
|
||||||
} else if (RegOpenKeyA(reg_key_class, branch_name, &key) == ERROR_SUCCESS) {
|
} else if (RegOpenKey(reg_key_class, branch_name, &key) == ERROR_SUCCESS) {
|
||||||
file = REGPROC_open_export_file(file_name);
|
file = REGPROC_open_export_file(file_name);
|
||||||
export_hkey(file, key,
|
export_hkey(file, key,
|
||||||
®_key_name_buf, ®_key_name_len,
|
®_key_name_buf, ®_key_name_len,
|
||||||
|
@ -1372,7 +1370,8 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
|
||||||
/* do not export HKEY_CLASSES_ROOT */
|
/* do not export HKEY_CLASSES_ROOT */
|
||||||
if (reg_class_keys[i] != HKEY_CLASSES_ROOT &&
|
if (reg_class_keys[i] != HKEY_CLASSES_ROOT &&
|
||||||
reg_class_keys[i] != HKEY_CURRENT_USER &&
|
reg_class_keys[i] != HKEY_CURRENT_USER &&
|
||||||
reg_class_keys[i] != HKEY_CURRENT_CONFIG) {
|
reg_class_keys[i] != HKEY_CURRENT_CONFIG &&
|
||||||
|
reg_class_keys[i] != HKEY_DYN_DATA) {
|
||||||
strcpy(reg_key_name_buf, reg_class_names[i]);
|
strcpy(reg_key_name_buf, reg_class_names[i]);
|
||||||
export_hkey(file, reg_class_keys[i],
|
export_hkey(file, reg_class_keys[i],
|
||||||
®_key_name_buf, ®_key_name_len,
|
®_key_name_buf, ®_key_name_len,
|
||||||
|
@ -1393,7 +1392,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Reads contents of the specified file into the registry.
|
* Reads contents of the specified file into the registry.
|
||||||
*/
|
*/
|
||||||
BOOL import_registry_file(LPSTR filename)
|
BOOL import_registry_file(LPTSTR filename)
|
||||||
{
|
{
|
||||||
FILE* reg_file = fopen(filename, "r");
|
FILE* reg_file = fopen(filename, "r");
|
||||||
|
|
||||||
|
@ -1407,7 +1406,7 @@ BOOL import_registry_file(LPSTR filename)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Recursive function which removes the registry key with all subkeys.
|
* Recursive function which removes the registry key with all subkeys.
|
||||||
*/
|
*/
|
||||||
void delete_branch(HKEY key,
|
static void delete_branch(HKEY key,
|
||||||
CHAR **reg_key_name_buf, DWORD *reg_key_name_len)
|
CHAR **reg_key_name_buf, DWORD *reg_key_name_len)
|
||||||
{
|
{
|
||||||
HKEY branch_key;
|
HKEY branch_key;
|
||||||
|
@ -1417,7 +1416,7 @@ void delete_branch(HKEY key,
|
||||||
LONG ret;
|
LONG ret;
|
||||||
long int i;
|
long int i;
|
||||||
|
|
||||||
if (RegOpenKeyA(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) {
|
if (RegOpenKey(key, *reg_key_name_buf, &branch_key) != ERROR_SUCCESS) {
|
||||||
REGPROC_print_error();
|
REGPROC_print_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,8 +1435,8 @@ void delete_branch(HKEY key,
|
||||||
for (i = subkeys - 1; i >= 0; i--) {
|
for (i = subkeys - 1; i >= 0; i--) {
|
||||||
DWORD buf_len = *reg_key_name_len - curr_len;
|
DWORD buf_len = *reg_key_name_len - curr_len;
|
||||||
|
|
||||||
ret = RegEnumKeyExA(branch_key, i, *reg_key_name_buf + curr_len + 1,
|
ret = RegEnumKeyEx(branch_key, i, *reg_key_name_buf + curr_len + 1,
|
||||||
&buf_len, NULL, NULL, NULL, NULL);
|
&buf_len, NULL, NULL, NULL, NULL);
|
||||||
if (ret != ERROR_SUCCESS &&
|
if (ret != ERROR_SUCCESS &&
|
||||||
ret != ERROR_MORE_DATA &&
|
ret != ERROR_MORE_DATA &&
|
||||||
ret != ERROR_NO_MORE_ITEMS) {
|
ret != ERROR_NO_MORE_ITEMS) {
|
||||||
|
@ -1448,7 +1447,7 @@ void delete_branch(HKEY key,
|
||||||
}
|
}
|
||||||
(*reg_key_name_buf)[curr_len] = '\0';
|
(*reg_key_name_buf)[curr_len] = '\0';
|
||||||
RegCloseKey(branch_key);
|
RegCloseKey(branch_key);
|
||||||
RegDeleteKeyA(key, *reg_key_name_buf);
|
RegDeleteKey(key, *reg_key_name_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -1482,7 +1481,7 @@ void delete_registry_key(CHAR *reg_key_name)
|
||||||
getAppName(), reg_key_name);
|
getAppName(), reg_key_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (RegOpenKeyA(reg_key_class, branch_name, &branch_key) == ERROR_SUCCESS) {
|
if (RegOpenKey(reg_key_class, branch_name, &branch_key) == ERROR_SUCCESS) {
|
||||||
/* check whether the key exists */
|
/* check whether the key exists */
|
||||||
RegCloseKey(branch_key);
|
RegCloseKey(branch_key);
|
||||||
delete_branch(reg_key_class, &branch_name, &branch_name_len);
|
delete_branch(reg_key_class, &branch_name, &branch_name_len);
|
||||||
|
@ -1494,12 +1493,12 @@ void delete_registry_key(CHAR *reg_key_name)
|
||||||
* Sets the application name. Then application name is used in the error
|
* Sets the application name. Then application name is used in the error
|
||||||
* reporting.
|
* reporting.
|
||||||
*/
|
*/
|
||||||
void setAppName(CHAR *name)
|
void setAppName(const CHAR *name)
|
||||||
{
|
{
|
||||||
app_name = name;
|
app_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR *getAppName()
|
const CHAR *getAppName(void)
|
||||||
{
|
{
|
||||||
return app_name;
|
return app_name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,11 @@ void doRegisterDLL(LPSTR lpsLine);
|
||||||
void doUnregisterDLL(LPSTR lpsLine);
|
void doUnregisterDLL(LPSTR lpsLine);
|
||||||
|
|
||||||
BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name);
|
BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name);
|
||||||
BOOL import_registry_file(LPSTR filename);
|
BOOL import_registry_file(LPTSTR filename);
|
||||||
void delete_registry_key(CHAR *reg_key_name);
|
void delete_registry_key(CHAR *reg_key_name);
|
||||||
|
|
||||||
void setAppName(CHAR *name);
|
void setAppName(const CHAR *name);
|
||||||
CHAR *getAppName();
|
const CHAR *getAppName(void);
|
||||||
|
|
||||||
void processRegLines(FILE *in, CommandAPI command);
|
void processRegLines(FILE *in, CommandAPI command);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ HKEY getRegClass(LPSTR lpLine);
|
||||||
DWORD getDataType(LPSTR *lpValue, DWORD* parse_type);
|
DWORD getDataType(LPSTR *lpValue, DWORD* parse_type);
|
||||||
LPSTR getArg(LPSTR arg);
|
LPSTR getArg(LPSTR arg);
|
||||||
HRESULT openKey(LPSTR stdInput);
|
HRESULT openKey(LPSTR stdInput);
|
||||||
void closeKey();
|
void closeKey(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* api setValue prototypes
|
* api setValue prototypes
|
||||||
|
|
|
@ -100,7 +100,6 @@ LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
||||||
if (!hItem) return NULL;
|
if (!hItem) return NULL;
|
||||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
|
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
|
||||||
/*printf("hRoot=%p, keyPath='%s'\n", *phRootKey, pathBuffer);*/
|
|
||||||
return pathBuffer;
|
return pathBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue