mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
update registry test program.
svn path=/trunk/; revision=3784
This commit is contained in:
parent
11e87876dc
commit
5110b764c2
7 changed files with 2135 additions and 131 deletions
27
reactos/apps/tests/regdump/main.c
Normal file
27
reactos/apps/tests/regdump/main.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
// main.c :
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "regdump.h"
|
||||
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
|
||||
DWORD GetInput(char* Buffer, int buflen)
|
||||
{
|
||||
DWORD Result;
|
||||
|
||||
ReadConsoleA(InputHandle, Buffer, buflen, &Result, NULL);
|
||||
return Result;
|
||||
}
|
||||
|
||||
int __cdecl main(int argc, char* argv[])
|
||||
{
|
||||
//AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
//return regmain(argc, argv);
|
||||
return regdump(argc, argv);
|
||||
}
|
|
@ -11,9 +11,12 @@ TARGET_APPTYPE = console
|
|||
|
||||
TARGET_NAME = regdump
|
||||
|
||||
#TARGET_CFLAGS = -DWIN32_REGDBG -DUNICODE -D_UNICODE
|
||||
TARGET_CFLAGS = -DWIN32_REGDBG
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o regcmds.o regproc.o main.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
221
reactos/apps/tests/regdump/regcmds.c
Normal file
221
reactos/apps/tests/regdump/regcmds.c
Normal file
|
@ -0,0 +1,221 @@
|
|||
/* $Id: regcmds.c,v 1.1 2002/11/24 19:13:40 robd Exp $
|
||||
*
|
||||
* ReactOS regedit
|
||||
*
|
||||
* regcmds.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* Original Work Copyright 2002 Andriy Palamarchuk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WIN32_REGDBG
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "regproc.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Global Variables:
|
||||
//
|
||||
|
||||
static char *usage =
|
||||
"Usage:\n"
|
||||
" regedit filename\n"
|
||||
" regedit /E filename [regpath]\n"
|
||||
" regedit /D regpath\n"
|
||||
"\n"
|
||||
"filename - registry file name\n"
|
||||
"regpath - name of the registry key\n"
|
||||
"\n"
|
||||
"When is called without any switches adds contents of the specified\n"
|
||||
"registry file to the registry\n"
|
||||
"\n"
|
||||
"Switches:\n"
|
||||
" /E - exports contents of the specified registry key to the specified\n"
|
||||
" file. Exports the whole registry if no key is specified.\n"
|
||||
" /D - deletes specified registry key\n"
|
||||
" /S - silent execution, can be used with any other switch.\n"
|
||||
" The only existing mode, exists for compatibility with Windows regedit.\n"
|
||||
" /V - advanced mode, can be used with any other switch.\n"
|
||||
" Ignored, exists for compatibility with Windows regedit.\n"
|
||||
" /L - location of system.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /R - location of user.dat file. Can be used with any other switch.\n"
|
||||
" Ignored. Exists for compatibility with Windows regedit.\n"
|
||||
" /? - print this help. Any other switches are ignored.\n"
|
||||
" /C - create registry from. Not implemented.\n"
|
||||
"\n"
|
||||
"The switches are case-insensitive, can be prefixed either by '-' or '/'.\n"
|
||||
"This program is command-line compatible with Microsoft Windows\n"
|
||||
"regedit. The difference with Windows regedit - this application has\n"
|
||||
"command-line interface only.\n";
|
||||
|
||||
typedef enum {
|
||||
ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE
|
||||
} REGEDIT_ACTION;
|
||||
|
||||
/**
|
||||
* Process unknown switch.
|
||||
*
|
||||
* Params:
|
||||
* chu - the switch character in upper-case.
|
||||
* s - the command line string where s points to the switch character.
|
||||
*/
|
||||
void error_unknown_switch(char chu, char *s)
|
||||
{
|
||||
if (isalpha(chu)) {
|
||||
printf("Undefined switch /%c!\n", chu);
|
||||
} else {
|
||||
printf("Alphabetic character is expected after '%c' "
|
||||
"in switch specification\n", *(s - 1));
|
||||
}
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
|
||||
{
|
||||
TCHAR filename[MAX_PATH];
|
||||
TCHAR reg_key_name[KEY_MAX_LEN];
|
||||
|
||||
switch (action) {
|
||||
case ACTION_ADD:
|
||||
get_file_name(&s, filename, MAX_PATH);
|
||||
if (!filename[0]) {
|
||||
printf("No file name is specified\n%s", usage);
|
||||
return FALSE;
|
||||
//exit(1);
|
||||
}
|
||||
while (filename[0]) {
|
||||
if (!import_registry_file(filename)) {
|
||||
perror("");
|
||||
printf("Can't open file \"%s\"\n", filename);
|
||||
return FALSE;
|
||||
//exit(1);
|
||||
}
|
||||
get_file_name(&s, filename, MAX_PATH);
|
||||
}
|
||||
break;
|
||||
case ACTION_DELETE:
|
||||
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
|
||||
if (!reg_key_name[0]) {
|
||||
printf("No registry key is specified for removal\n%s", usage);
|
||||
return FALSE;
|
||||
//exit(1);
|
||||
}
|
||||
delete_registry_key(reg_key_name);
|
||||
break;
|
||||
case ACTION_EXPORT:
|
||||
filename[0] = '\0';
|
||||
get_file_name(&s, filename, MAX_PATH);
|
||||
if (!filename[0]) {
|
||||
printf("No file name is specified\n%s", usage);
|
||||
return FALSE;
|
||||
//exit(1);
|
||||
}
|
||||
if (s[0]) {
|
||||
get_file_name(&s, reg_key_name, KEY_MAX_LEN);
|
||||
export_registry_key(filename, reg_key_name);
|
||||
} else {
|
||||
export_registry_key(filename, NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Unhandled action!\n");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine)
|
||||
{
|
||||
REGEDIT_ACTION action = ACTION_UNDEF;
|
||||
LPSTR s = lpCmdLine; /* command line pointer */
|
||||
CHAR ch = *s; /* current character */
|
||||
|
||||
while (ch && ((ch == '-') || (ch == '/'))) {
|
||||
char chu;
|
||||
char ch2;
|
||||
|
||||
s++;
|
||||
ch = *s;
|
||||
ch2 = *(s+1);
|
||||
chu = toupper(ch);
|
||||
if (!ch2 || isspace(ch2)) {
|
||||
if (chu == 'S' || chu == 'V') {
|
||||
/* ignore these switches */
|
||||
} else {
|
||||
switch (chu) {
|
||||
case 'D':
|
||||
action = ACTION_DELETE;
|
||||
break;
|
||||
case 'E':
|
||||
action = ACTION_EXPORT;
|
||||
break;
|
||||
case '?':
|
||||
printf(usage);
|
||||
return FALSE;
|
||||
//exit(0);
|
||||
break;
|
||||
default:
|
||||
error_unknown_switch(chu, s);
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s++;
|
||||
} else {
|
||||
if (ch2 == ':') {
|
||||
switch (chu) {
|
||||
case 'L':
|
||||
/* fall through */
|
||||
case 'R':
|
||||
s += 2;
|
||||
while (*s && !isspace(*s)) {
|
||||
s++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_unknown_switch(chu, s);
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* this is a file name, starting from '/' */
|
||||
s--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* skip spaces to the next parameter */
|
||||
ch = *s;
|
||||
while (ch && isspace(ch)) {
|
||||
s++;
|
||||
ch = *s;
|
||||
}
|
||||
}
|
||||
if (action == ACTION_UNDEF) {
|
||||
action = ACTION_ADD;
|
||||
}
|
||||
return PerformRegAction(action, s);
|
||||
}
|
|
@ -1,123 +1,192 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
/* $Id: regdump.c,v 1.2 2002/11/24 19:13:40 robd Exp $
|
||||
*
|
||||
* ReactOS regedit
|
||||
*
|
||||
* regdump.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <stdio.h>
|
||||
#include "regdump.h"
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
#define MAX_REGKEY_NAME_LEN 500
|
||||
#define MAX_REG_DATA_SIZE 500
|
||||
#define REG_FILE_HEX_LINE_LEN 76
|
||||
|
||||
#ifdef UNICODE
|
||||
//#define dprintf _tprintf
|
||||
#define dprintf printf
|
||||
#else
|
||||
#define dprintf printf
|
||||
#endif
|
||||
|
||||
/*
|
||||
char dprintf_buffer[1024];
|
||||
|
||||
void dprintf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
int msg_len;
|
||||
va_list args;
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
va_start(args, fmt);
|
||||
vsprintf(dprintf_buffer, fmt, args);
|
||||
//_vstprintf(dprintf_buffer, fmt, args);
|
||||
msg_len = strlen(dprintf_buffer)
|
||||
WriteConsoleA(OutputHandle, dprintf_buffer, msg_len, NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
#define MAX_NAME_LEN 500
|
||||
/*
|
||||
BOOL DumpRegKey(TCHAR* KeyPath, HKEY hKey)
|
||||
{
|
||||
TCHAR keyPath[1000];
|
||||
int keyPathLen = 0;
|
||||
|
||||
keyPath[0] = _T('\0');
|
||||
|
||||
dprintf("\n[%s]\n", KeyPath);
|
||||
|
||||
if (hKey != NULL) {
|
||||
HKEY hNewKey;
|
||||
LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR Name[MAX_NAME_LEN];
|
||||
DWORD cName = MAX_NAME_LEN;
|
||||
FILETIME LastWriteTime;
|
||||
DWORD dwIndex = 0L;
|
||||
while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
|
||||
HKEY hSubKey;
|
||||
DWORD dwCount = 0L;
|
||||
|
||||
dprintf("\n[%s\\%s]\n", KeyPath, Name);
|
||||
|
||||
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR SubName[MAX_NAME_LEN];
|
||||
DWORD cSubName = MAX_NAME_LEN;
|
||||
// if (RegEnumKeyEx(hSubKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
||||
while (RegEnumKeyEx(hSubKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
||||
dprintf("\t%s (%d)\n", SubName, dwCount);
|
||||
cSubName = MAX_NAME_LEN;
|
||||
++dwCount;
|
||||
}
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
|
||||
//AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
|
||||
cName = MAX_NAME_LEN;
|
||||
++dwIndex;
|
||||
}
|
||||
RegCloseKey(hNewKey);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
dprintf("\n");
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
BOOL _DumpRegKey(TCHAR* KeyPath, HKEY hKey)
|
||||
{
|
||||
if (hKey != NULL) {
|
||||
HKEY hNewKey;
|
||||
LONG errCode = RegOpenKeyEx(hKey, NULL, 0, KEY_READ, &hNewKey);
|
||||
LONG errCode;
|
||||
|
||||
//_tprintf(_T("_DumpRegKey() - Calling RegOpenKeyEx(%x)\n"), hKey);
|
||||
//
|
||||
// TODO: this is freezing ROS in bochs hard
|
||||
errCode = RegOpenKeyEx(hKey, NULL, 0, KEY_READ, &hNewKey);
|
||||
//
|
||||
//errCode = RegOpenKeyExA(hKey, NULL, 0, KEY_READ, &hNewKey);
|
||||
|
||||
//_tprintf(_T("RegOpenKeyEx returned %x\n"), errCode);
|
||||
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR Name[MAX_NAME_LEN];
|
||||
DWORD cName = MAX_NAME_LEN;
|
||||
TCHAR Name[MAX_REGKEY_NAME_LEN];
|
||||
DWORD cName = MAX_REGKEY_NAME_LEN;
|
||||
FILETIME LastWriteTime;
|
||||
DWORD dwIndex = 0L;
|
||||
TCHAR* pKeyName = &KeyPath[_tcslen(KeyPath)];
|
||||
|
||||
//_tprintf(_T("Calling RegEnumKeyEx(%x)\n"), hNewKey);
|
||||
|
||||
while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
|
||||
HKEY hSubKey;
|
||||
DWORD dwCount = 0L;
|
||||
//int len;
|
||||
_tcscat(KeyPath, _T("\\"));
|
||||
_tcscat(KeyPath, Name);
|
||||
dprintf("\n[%s]\n", KeyPath);
|
||||
_tprintf(_T("[%s]\n"), KeyPath);
|
||||
#if 1
|
||||
//_tprintf(_T("Calling RegOpenKeyEx\n"));
|
||||
|
||||
errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
#if 1
|
||||
_DumpRegKey(KeyPath, hSubKey);
|
||||
#else
|
||||
TCHAR SubName[MAX_NAME_LEN];
|
||||
DWORD cSubName = MAX_NAME_LEN;
|
||||
// if (RegEnumKeyEx(hSubKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
||||
while (RegEnumKeyEx(hSubKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
||||
dprintf("\t%s (%d)\n", SubName, dwCount);
|
||||
cSubName = MAX_NAME_LEN;
|
||||
BYTE Data[MAX_REG_DATA_SIZE];
|
||||
DWORD cbData = MAX_REG_DATA_SIZE;
|
||||
TCHAR ValueName[MAX_REGKEY_NAME_LEN];
|
||||
DWORD cValueName = MAX_REGKEY_NAME_LEN;
|
||||
DWORD Type;
|
||||
|
||||
//_tprintf(_T("Calling RegEnumValue\n"));
|
||||
|
||||
while (RegEnumValue(hSubKey, dwCount, ValueName, &cValueName, NULL, &Type, Data, &cbData) == ERROR_SUCCESS) {
|
||||
//dprintf("\t%S (%d) %d data bytes\n", ValueName, Type, cbData);
|
||||
_tprintf(_T("\t%s = "), ValueName);
|
||||
////
|
||||
switch (Type) {
|
||||
case REG_EXPAND_SZ:
|
||||
_tprintf(_T("expand:"));
|
||||
case REG_SZ:
|
||||
_tprintf(_T("\"%s\"\n"), Data);
|
||||
break;
|
||||
case REG_DWORD:
|
||||
_tprintf(_T("dword:%08lx\n"), *((DWORD *)Data));
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("warning - unsupported registry format '%ld', ") \
|
||||
_T("treat as binary\n"), Type);
|
||||
_tprintf(_T("key name: \"%s\"\n"), Name);
|
||||
_tprintf(_T("value name:\"%s\"\n\n"), ValueName);
|
||||
/* falls through */
|
||||
case REG_MULTI_SZ:
|
||||
/* falls through */
|
||||
case REG_BINARY:
|
||||
{
|
||||
DWORD i1;
|
||||
TCHAR *hex_prefix;
|
||||
TCHAR buf[20];
|
||||
int cur_pos;
|
||||
|
||||
if (Type == REG_BINARY) {
|
||||
hex_prefix = _T("hex:");
|
||||
} else {
|
||||
hex_prefix = buf;
|
||||
_stprintf(buf, _T("hex(%ld):"), Type);
|
||||
}
|
||||
|
||||
/* position of where the next character will be printed */
|
||||
/* NOTE: yes, _tcslen("hex:") is used even for hex(x): */
|
||||
cur_pos = _tcslen(_T("\"\"=")) + _tcslen(_T("hex:")) + _tcslen(ValueName);
|
||||
|
||||
//dprintf(hex_prefix);
|
||||
//_tprintf(hex_prefix);
|
||||
|
||||
for (i1 = 0; i1 < cbData; i1++) {
|
||||
_tprintf(_T("%02x"), (unsigned int)(Data)[i1]);
|
||||
if (i1 + 1 < cbData) {
|
||||
_tprintf(_T(","));
|
||||
}
|
||||
cur_pos += 3;
|
||||
/* wrap the line */
|
||||
if (cur_pos > REG_FILE_HEX_LINE_LEN) {
|
||||
_tprintf(_T("\\\n "));
|
||||
cur_pos = 2;
|
||||
}
|
||||
}
|
||||
_tprintf(_T("\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
////
|
||||
cValueName = MAX_REGKEY_NAME_LEN;
|
||||
cbData = MAX_REG_DATA_SIZE;
|
||||
++dwCount;
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
_DumpRegKey(KeyPath, hSubKey);
|
||||
#endif
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
cName = MAX_NAME_LEN;
|
||||
#endif
|
||||
cName = MAX_REGKEY_NAME_LEN;
|
||||
*pKeyName = _T('\0');
|
||||
++dwIndex;
|
||||
}
|
||||
RegCloseKey(hNewKey);
|
||||
} else {
|
||||
_tprintf(_T("_DumpRegKey(...) RegOpenKeyEx() failed.\n\n"));
|
||||
}
|
||||
} else {
|
||||
_tprintf(_T("_DumpRegKey(...) - NULL key parameter passed.\n\n"));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL DumpRegKey(TCHAR* KeyPath, HKEY hKey)
|
||||
{
|
||||
dprintf("\n[%s]\n", KeyPath);
|
||||
_tprintf(_T("\n[%s]\n"), KeyPath);
|
||||
//_tprintf(_T("Calling _DumpRegKey(..., %x))\n", hKey);
|
||||
return _DumpRegKey(KeyPath, hKey);
|
||||
}
|
||||
|
||||
|
@ -127,23 +196,23 @@ void RegKeyPrint(int which)
|
|||
|
||||
switch (which) {
|
||||
case '1':
|
||||
strcpy(szKeyPath, _T("HKEY_CLASSES_ROOT"));
|
||||
_tcscpy(szKeyPath, _T("HKEY_CLASSES_ROOT"));
|
||||
DumpRegKey(szKeyPath, HKEY_CLASSES_ROOT);
|
||||
break;
|
||||
case '2':
|
||||
strcpy(szKeyPath, _T("HKEY_CURRENT_USER"));
|
||||
_tcscpy(szKeyPath, _T("HKEY_CURRENT_USER"));
|
||||
DumpRegKey(szKeyPath, HKEY_CURRENT_USER);
|
||||
break;
|
||||
case '3':
|
||||
strcpy(szKeyPath, _T("HKEY_LOCAL_MACHINE"));
|
||||
_tcscpy(szKeyPath, _T("HKEY_LOCAL_MACHINE"));
|
||||
DumpRegKey(szKeyPath, HKEY_LOCAL_MACHINE);
|
||||
break;
|
||||
case '4':
|
||||
strcpy(szKeyPath, _T("HKEY_USERS"));
|
||||
_tcscpy(szKeyPath, _T("HKEY_USERS"));
|
||||
DumpRegKey(szKeyPath, HKEY_USERS);
|
||||
break;
|
||||
case '5':
|
||||
strcpy(szKeyPath, _T("HKEY_CURRENT_CONFIG"));
|
||||
_tcscpy(szKeyPath, _T("HKEY_CURRENT_CONFIG"));
|
||||
DumpRegKey(szKeyPath, HKEY_CURRENT_CONFIG);
|
||||
break;
|
||||
case '6':
|
||||
|
@ -152,55 +221,83 @@ void RegKeyPrint(int which)
|
|||
// DumpRegKey(szKeyPath, HKEY_LOCAL_MACHINE);
|
||||
// DumpRegKey(szKeyPath, HKEY_USERS);
|
||||
// DumpRegKey(szKeyPath, HKEY_CURRENT_CONFIG);
|
||||
dprintf("unimplemented...\n");
|
||||
_tprintf(_T("unimplemented...\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char Buffer[10];
|
||||
TCHAR szKeyPath[1000];
|
||||
DWORD Result;
|
||||
const char* default_cmd_line1 = "/E HKLM_EXPORT.TXT HKEY_LOCAL_MACHINE";
|
||||
const char* default_cmd_line2 = "TEST_IMPORT.TXT";
|
||||
const char* default_cmd_line3 = "/D HKEY_LOCAL_MACHINE\\SYSTEM";
|
||||
const char* default_cmd_line4 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
|
||||
const char* default_cmd_line5 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
|
||||
const char* default_cmd_line6 = "/E HKCR_EXPORT.TXT HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes";
|
||||
const char* default_cmd_line7 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
|
||||
const char* default_cmd_line8 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
|
||||
const char* default_cmd_line9 = "/D HKEY_LOCAL_MACHINE\\SOFTWARE";
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
void show_menu(void)
|
||||
{
|
||||
_tprintf(_T("\nchoose test :\n"));
|
||||
_tprintf(_T(" 0 = Exit\n"));
|
||||
_tprintf(_T(" 1 = HKEY_CLASSES_ROOT\n"));
|
||||
_tprintf(_T(" 2 = HKEY_CURRENT_USER\n"));
|
||||
_tprintf(_T(" 3 = HKEY_LOCAL_MACHINE\n"));
|
||||
_tprintf(_T(" 4 = HKEY_USERS\n"));
|
||||
_tprintf(_T(" 5 = HKEY_CURRENT_CONFIG\n"));
|
||||
_tprintf(_T(" 6 = REGISTRY ROOT\n"));
|
||||
printf(" 7 = %s\n", default_cmd_line1);
|
||||
printf(" 8 = %s\n", default_cmd_line2);
|
||||
printf(" 9 = %s\n", default_cmd_line3);
|
||||
printf(" A = %s\n", default_cmd_line4);
|
||||
printf(" B = %s\n", default_cmd_line5);
|
||||
printf(" C = %s\n", default_cmd_line6);
|
||||
printf(" D = %s\n", default_cmd_line7);
|
||||
printf(" E = %s\n", default_cmd_line8);
|
||||
printf(" F = %s\n", default_cmd_line9);
|
||||
/*
|
||||
_tprintf(_T(" 7 = %s\n"), default_cmd_line1);
|
||||
_tprintf(_T(" 8 = %s\n"), default_cmd_line2);
|
||||
_tprintf(_T(" 9 = %s\n"), default_cmd_line3);
|
||||
_tprintf(_T(" A = %s\n"), default_cmd_line4);
|
||||
_tprintf(_T(" B = %s\n"), default_cmd_line5);
|
||||
_tprintf(_T(" C = %s\n"), default_cmd_line6);
|
||||
_tprintf(_T(" D = %s\n"), default_cmd_line7);
|
||||
_tprintf(_T(" E = %s\n"), default_cmd_line8);
|
||||
_tprintf(_T(" F = %s\n"), default_cmd_line9);
|
||||
*/
|
||||
}
|
||||
|
||||
int regdump(int argc, char* argv[])
|
||||
{
|
||||
char Buffer[500];
|
||||
|
||||
if (argc > 1) {
|
||||
|
||||
// if (0 == _tcsstr(argv[1], _T("HKLM"))) {
|
||||
if (strstr(argv[1], "help")) {
|
||||
|
||||
if (strstr(argv[1], _T("help"))) {
|
||||
|
||||
} else if (strstr(argv[1], _T("HKCR"))) {
|
||||
} else if (strstr(argv[1], "HKCR")) {
|
||||
RegKeyPrint('1');
|
||||
} else if (strstr(argv[1], _T("HKCU"))) {
|
||||
} else if (strstr(argv[1], "HKCU")) {
|
||||
RegKeyPrint('2');
|
||||
} else if (strstr(argv[1], _T("HKLM"))) {
|
||||
} else if (strstr(argv[1], "HKLM")) {
|
||||
RegKeyPrint('3');
|
||||
} else if (strstr(argv[1], _T("HKU"))) {
|
||||
} else if (strstr(argv[1], "HKU")) {
|
||||
RegKeyPrint('4');
|
||||
} else if (strstr(argv[1], _T("HKCC"))) {
|
||||
} else if (strstr(argv[1], "HKCC")) {
|
||||
RegKeyPrint('5');
|
||||
} else if (strstr(argv[1], _T("HKRR"))) {
|
||||
} else if (strstr(argv[1], "HKRR")) {
|
||||
RegKeyPrint('6');
|
||||
} else {
|
||||
dprintf("started with argc = %d, argv[1] = %s (unknown?)\n", argc, argv[1]);
|
||||
}
|
||||
|
||||
} else while (1) {
|
||||
dprintf("choose test :\n");
|
||||
dprintf(" 0 = Exit\n");
|
||||
dprintf(" 1 = HKEY_CLASSES_ROOT\n");
|
||||
dprintf(" 2 = HKEY_CURRENT_USER\n");
|
||||
dprintf(" 3 = HKEY_LOCAL_MACHINE\n");
|
||||
dprintf(" 4 = HKEY_USERS\n");
|
||||
dprintf(" 5 = HKEY_CURRENT_CONFIG\n");
|
||||
dprintf(" 6 = REGISTRY ROOT\n");
|
||||
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
||||
switch (Buffer[0]) {
|
||||
return 0;
|
||||
}
|
||||
show_menu();
|
||||
while (1) {
|
||||
GetInput(Buffer, sizeof(Buffer));
|
||||
switch (toupper(Buffer[0])) {
|
||||
case '0':
|
||||
return(0);
|
||||
case '1':
|
||||
|
@ -211,24 +308,42 @@ int main(int argc, char* argv[])
|
|||
case '6':
|
||||
RegKeyPrint(Buffer[0]/* - '0'*/);
|
||||
break;
|
||||
default:
|
||||
dprintf("invalid input.\n");
|
||||
case '7':
|
||||
strcpy(Buffer, default_cmd_line1);
|
||||
goto doit;
|
||||
case '8':
|
||||
strcpy(Buffer, default_cmd_line2);
|
||||
goto doit;
|
||||
case '9':
|
||||
strcpy(Buffer, default_cmd_line3);
|
||||
goto doit;
|
||||
case 'A':
|
||||
strcpy(Buffer, default_cmd_line4);
|
||||
goto doit;
|
||||
case 'B':
|
||||
strcpy(Buffer, default_cmd_line5);
|
||||
goto doit;
|
||||
case 'C':
|
||||
strcpy(Buffer, default_cmd_line6);
|
||||
goto doit;
|
||||
case 'D':
|
||||
strcpy(Buffer, default_cmd_line7);
|
||||
goto doit;
|
||||
case 'E':
|
||||
strcpy(Buffer, default_cmd_line8);
|
||||
goto doit;
|
||||
case 'F':
|
||||
strcpy(Buffer, default_cmd_line9);
|
||||
goto doit;
|
||||
default: doit:
|
||||
if (!ProcessCmdLine(Buffer)) {
|
||||
dprintf("invalid input.\n");
|
||||
show_menu();
|
||||
} else {
|
||||
dprintf("done.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
[HKEY_LOCAL_MACHINE]
|
||||
|
||||
[HKEY_LOCAL_MACHINE\HARDWARE]
|
||||
|
||||
[HKEY_LOCAL_MACHINE\HARDWARE\ACPI]
|
||||
|
||||
[HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT]
|
||||
|
||||
[HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT\VIA694]
|
||||
|
||||
[HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT\VIA694\AWRDACPI]
|
||||
|
||||
*/
|
44
reactos/apps/tests/regdump/regdump.h
Normal file
44
reactos/apps/tests/regdump/regdump.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* ReactOS
|
||||
*
|
||||
* regdump.h
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __REGDUMP_H__
|
||||
#define __REGDUMP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern HANDLE OutputHandle;
|
||||
extern HANDLE InputHandle;
|
||||
|
||||
DWORD GetInput(char* Buffer, int buflen);
|
||||
//void dprintf(char* fmt, ...);
|
||||
int regdump(int argc, char* argv[]);
|
||||
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // __REGDUMP_H__
|
1484
reactos/apps/tests/regdump/regproc.c
Normal file
1484
reactos/apps/tests/regdump/regproc.c
Normal file
File diff suppressed because it is too large
Load diff
110
reactos/apps/tests/regdump/regproc.h
Normal file
110
reactos/apps/tests/regdump/regproc.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright 1999 Sylvain St-Germain
|
||||
* Copyright 2002 Andriy Palamarchuk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Defines and consts
|
||||
*/
|
||||
#define KEY_MAX_LEN 1024
|
||||
|
||||
/* Return values */
|
||||
#define SUCCESS 0
|
||||
#define KEY_VALUE_ALREADY_SET 2
|
||||
|
||||
typedef void (*CommandAPI)(LPTSTR lpsLine);
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
* Generic prototypes
|
||||
*/
|
||||
#ifdef _UNICODE
|
||||
#define get_file_name get_file_nameW
|
||||
#else
|
||||
#define get_file_name get_file_nameA
|
||||
#endif
|
||||
|
||||
char* getToken(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);
|
||||
|
||||
/*
|
||||
* api setValue prototypes
|
||||
*/
|
||||
void processSetValue(LPTSTR cmdline);
|
||||
HRESULT setValue(LPTSTR val_name, LPTSTR val_data);
|
||||
|
||||
/*
|
||||
* api queryValue prototypes
|
||||
*/
|
||||
void processQueryValue(LPTSTR cmdline);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef WIN32_REGDBG
|
||||
//typedef UINT_PTR SIZE_T, *PSIZE_T;
|
||||
//#define _MAX_PATH 260 /* max. length of full pathname */
|
||||
#endif /*WIN32_REGDBG*/
|
||||
|
||||
#ifdef UNICODE
|
||||
#define _tfopen _wfopen
|
||||
#else
|
||||
#define _tfopen fopen
|
||||
#endif
|
||||
|
||||
#endif /*__GNUC__*/
|
||||
|
||||
LPVOID RegHeapAlloc(
|
||||
HANDLE hHeap, // handle to private heap block
|
||||
DWORD dwFlags, // heap allocation control
|
||||
SIZE_T dwBytes // number of bytes to allocate
|
||||
);
|
||||
|
||||
LPVOID RegHeapReAlloc(
|
||||
HANDLE hHeap, // handle to heap block
|
||||
DWORD dwFlags, // heap reallocation options
|
||||
LPVOID lpMem, // pointer to memory to reallocate
|
||||
SIZE_T dwBytes // number of bytes to reallocate
|
||||
);
|
||||
|
||||
BOOL RegHeapFree(
|
||||
HANDLE hHeap, // handle to heap
|
||||
DWORD dwFlags, // heap free options
|
||||
LPVOID lpMem // pointer to memory
|
||||
);
|
Loading…
Reference in a new issue