Commit 4e2e176c authored by Andriy Palamarchuk's avatar Andriy Palamarchuk Committed by Alexandre Julliard

Created regedit replacement. Fixed some bugs.

parent 65a7a108
......@@ -12586,7 +12586,7 @@ MAKE_DLL_RULES=dlls/Makedll.rules
MAKE_PROG_RULES=programs/Makeprog.rules
ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msg711/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msg711/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
cat >confcache <<\_ACEOF
......@@ -13182,6 +13182,7 @@ do
"programs/osversioncheck/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/osversioncheck/Makefile" ;;
"programs/progman/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/progman/Makefile" ;;
"programs/regapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regapi/Makefile" ;;
"programs/regedit/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regedit/Makefile" ;;
"programs/regtest/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regtest/Makefile" ;;
"programs/uninstaller/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/uninstaller/Makefile" ;;
"programs/view/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/view/Makefile" ;;
......
......@@ -1399,6 +1399,7 @@ programs/notepad/Makefile
programs/osversioncheck/Makefile
programs/progman/Makefile
programs/regapi/Makefile
programs/regedit/Makefile
programs/regtest/Makefile
programs/uninstaller/Makefile
programs/view/Makefile
......
......@@ -13,6 +13,7 @@ SUBDIRS = \
osversioncheck \
progman \
regapi \
regedit \
regtest \
uninstaller \
view \
......
......@@ -31,9 +31,9 @@ LINE: while(<>) {
if( /^\[/ ) {
${prefix} = ${_}; # assign the prefix for the forthcomming section
print "${prefix}\n";
next LINE;
}
s/\\\\/\\/g; # Still some more substitutions... To fix paths...
print "${prefix}$_\n";
}
......
......@@ -5,6 +5,7 @@
# in the "REGEDIT4" format.
#
# 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
......@@ -21,45 +22,46 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
${newkey} = "";
${key} = "";
${data} = "";
use strict;
use diagnostics;
# I do not validate the integrity of the file, I am assuming that
# the input file comes from the output of regFixer.pl, therefore things
# should be ok, if they are not, investigate and send me an email...
# should be ok, if they are not, submit a bug
print "REGEDIT4\n";
LINE: while(<>) {
chomp; # get rid of new line
next LINE if(/^$/); # This is an empty line
my $curr_key = "";
my $key;
my $value;
my $rest;
my $s;
(${key}, ${data}, ${rest})= split /]/,$_ ; # Extract the values from the line
print "REGEDIT4\n";
${key} = "${key}]"; # put the ']' back there...
LINE: while($s = <>) {
chomp($s); # get rid of new line
if (${rest} ne "") # concat we had more than 1 ']'
{ # on the line
${data} = "${data}]${rest}";
}
next LINE if($s =~ /^$/); # this is an empty line
if (${key} eq ${newkey})
if ($s =~ /\]$/) # only key name on the line
{
print "${data}\n";
($key) = ($s =~ /^\[(.*)\]$/);
unless ($key)
{
die "Unrecognized string $s";
}
if ($key ne $curr_key)
{
$curr_key = $key;
print "\n[$key]\n";
}
}
else
{
print "\n";
print "$key\n";
my $s = $data;
$s =~ s/^\s+//;
$s =~ s/\s+$//;
if ($s ne "")
{
$newkey = $key; # assign it
print "$data\n";
}
($key, $value) = ($s =~ /^\[(.*?)\](.+)$/);
if (!defined($key) || ($key ne $curr_key))
{
die "Unrecognized string $s";
}
print "$value\n"
}
}
......@@ -3,3 +3,5 @@ Test data:
after.reg - registry file with the change, exported from regedit
before.reg - registry file without the change, exported from regedit
orig.reg - registry file ot the test change, exported from regedit
Note, orig.reg must me in Unix format, after.reg and before.reg - in Dos format.
......@@ -24,8 +24,7 @@ REGEDIT4
[HKEY_CURRENT_USER\Volatile Environment]
"NWUSERNAME"="APalamar"
"LOGONSERVER"="\\\\CE08N270"
"NWLANGUAGE"="English"
"LOGONSERVER"="\\\\BX08N200"
"=M:"="M:\\"
"=O:"="O:\\"
"=P:"="P:\\"
......@@ -36,7 +35,7 @@ REGEDIT4
"=N:"="N:\\"
"=Q:"="Q:\\"
"=S:"="S:\\"
"=X:"="X:\\"
"NWLANGUAGE"="English"
"=T:"="T:\\"
"WINDOWS_LOGIN"="0"
Makefile
regedit.spec.c
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = regedit
C_SRCS = \
regedit.c \
regproc.c
@MAKE_PROG_RULES@
### Dependencies:
/*
* Windows regedit.exe registry editor implementation.
*
* 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
*/
#include <ctype.h>
#include <stdio.h>
#include <windows.h>
#include "regproc.h"
static char *usage =
"Usage:
regedit filename
regedit /E filename [regpath]
regedit /D regpath
filename - registry file name
regpath - name of the registry key
When is called without any switches adds contents of the specified
registry file to the registry
Switches:
/E - exports contents of the specified registry key to the specified
file. Exports the whole registry if no key is specified.
/D - deletes specified registry key
/S - silent execution, can be used with any other switch.
The only existing mode, exists for compatibility with Windows regedit.
/V - advanced mode, can be used with any other switch.
Ignored, exists for compatibility with Windows regedit.
/L - location of system.dat file. Can be used with any other switch.
Ignored. Exists for compatibility with Windows regedit.
/R - location of user.dat file. Can be used with any other switch.
Ignored. Exists for compatibility with Windows regedit.
/? - print this help. Any other switches are ignored.
/C - create registry from. Not implemented.
The switches are case-insensitive, can be prefixed either by '-' or '/'.
This program is command-line compatible with Microsoft Windows
regedit. The difference with Windows regedit - this application has
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("%s: Undefined switch /%c!\n", getAppName(), chu);
} else {
printf("%s: Alphabetic character is expected after '%c' "
"in switch specification\n", getAppName(), *(s - 1));
}
exit(1);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
REGEDIT_ACTION action = ACTION_UNDEF;
LPSTR s = lpCmdLine; /* command line pointer */
CHAR ch = *s; /* current character */
setAppName("regedit");
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);
exit(0);
break;
default:
error_unknown_switch(chu, s);
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);
break;
}
} else {
printf("%s: Incorrect switch format, switch '%c'\n%s",
getAppName(), chu, usage);
exit(1);
break;
}
}
/* skip spaces to the next parameter */
ch = *s;
while (ch && isspace(ch))
{
s++;
ch = *s;
}
}
if (action == ACTION_UNDEF)
{
action = ACTION_ADD;
}
switch (action)
{
case ACTION_ADD:
{
CHAR filename[MAX_PATH];
FILE *reg_file;
get_file_name(&s, filename);
if (!filename[0])
{
printf("%s: No file name is specified\n%s", getAppName(), usage);
exit(1);
}
while(filename[0])
{
reg_file = fopen(filename, "r");
if (reg_file)
{
processRegLines(reg_file, doSetValue);
} else {
perror("");
printf("%s: Can't open file \"%s\"\n", getAppName(), filename);
}
get_file_name(&s, filename);
}
break;
}
case ACTION_DELETE:
{
CHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name);
if (!reg_key_name[0])
{
printf("%s: No registry key is specified for removal\n%s",
getAppName(), usage);
exit(1);
}
delete_registry_key(reg_key_name);
break;
}
case ACTION_EXPORT:
{
CHAR filename[MAX_PATH];
filename[0] = '\0';
get_file_name(&s, filename);
if (!filename[0])
{
printf("%s: No file name is specified\n%s", getAppName(), usage);
exit(1);
}
if (s[0])
{
CHAR reg_key_name[KEY_MAX_LEN];
get_file_name(&s, reg_key_name);
export_registry_key(filename, reg_key_name);
} else {
export_registry_key(filename, NULL);
}
break;
}
default:
printf("%s: Unhandled action!\n", getAppName());
exit(1);
break;
}
return 0;
}
name regedit
type win32
mode guiexe
init WinMain
import msvcrt.dll
import advapi32.dll
import kernel32.dll
import ntdll.dll
/*
* 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)(LPSTR lpsLine);
void doSetValue(LPSTR lpsLine);
void doDeleteValue(LPSTR lpsLine);
void doCreateKey(LPSTR lpsLine);
void doDeleteKey(LPSTR lpsLine);
void doQueryValue(LPSTR lpsLine);
void doRegisterDLL(LPSTR lpsLine);
void doUnregisterDLL(LPSTR lpsLine);
void export_registry_key(CHAR *file_name, CHAR *reg_key_name);
void delete_registry_key(CHAR *reg_key_name);
void setAppName(CHAR *name);
CHAR *getAppName();
void processRegLines(FILE *in, CommandAPI command);
/*
* Generic prototypes
*/
char* getToken(char** str, const char* delims);
void get_file_name(CHAR **command_line, CHAR *filename);
DWORD convertHexToDWord(char *str, BYTE *buf);
DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen);
LPSTR convertHexToHexCSV( BYTE *buf, ULONG len);
LPSTR convertHexToDWORDStr( BYTE *buf, ULONG len);
LPSTR getRegKeyName(LPSTR lpLine);
HKEY getRegClass(LPSTR lpLine);
DWORD getDataType(LPSTR *lpValue, DWORD* parse_type);
LPSTR getArg(LPSTR arg);
HRESULT openKey(LPSTR stdInput);
void closeKey();
/*
* api setValue prototypes
*/
void processSetValue(LPSTR cmdline);
HRESULT setValue(LPSTR val_name, LPSTR val_data);
/*
* api queryValue prototypes
*/
void processQueryValue(LPSTR cmdline);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment