Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
58c185ec
Commit
58c185ec
authored
Dec 08, 2003
by
Dimitrie O. Paun
Committed by
Alexandre Julliard
Dec 08, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat regedit in a consistent manner.
parent
8aef340c
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
218 additions
and
338 deletions
+218
-338
childwnd.c
programs/regedit/childwnd.c
+5
-5
edit.c
programs/regedit/edit.c
+0
-0
framewnd.c
programs/regedit/framewnd.c
+25
-25
listview.c
programs/regedit/listview.c
+24
-30
main.c
programs/regedit/main.c
+1
-1
main.h
programs/regedit/main.h
+0
-0
regedit.c
programs/regedit/regedit.c
+49
-68
regproc.c
programs/regedit/regproc.c
+112
-206
regproc.h
programs/regedit/regproc.h
+0
-0
treeview.c
programs/regedit/treeview.c
+2
-3
No files found.
programs/regedit/childwnd.c
View file @
58c185ec
...
...
@@ -127,7 +127,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT
CALLBACK
ChildWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
static
int
last_split
;
/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */
/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */
switch
(
message
)
{
case
WM_CREATE
:
...
...
@@ -168,7 +168,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
draw_splitbar
(
hWnd
,
last_split
);
SetCapture
(
hWnd
);
}
break
;}
break
;
}
case
WM_LBUTTONUP
:
if
(
GetCapture
()
==
hWnd
)
{
...
...
@@ -232,8 +233,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
switch
(((
LPNMHDR
)
lParam
)
->
code
)
{
case
TVN_ITEMEXPANDING
:
return
!
OnTreeExpanding
(
pChildWnd
->
hTreeWnd
,
(
NMTREEVIEW
*
)
lParam
);
case
TVN_SELCHANGED
:
{
case
TVN_SELCHANGED
:
{
HKEY
hKey
;
TCHAR
keyPath
[
1000
];
int
keyPathLen
=
0
;
...
...
@@ -263,7 +263,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
ResizeWnd
(
pChildWnd
,
LOWORD
(
lParam
),
HIWORD
(
lParam
));
}
/* fall through */
default:
def:
default:
def:
return
DefWindowProc
(
hWnd
,
message
,
wParam
,
lParam
);
}
return
0
;
...
...
programs/regedit/edit.c
View file @
58c185ec
programs/regedit/framewnd.c
View file @
58c185ec
...
...
@@ -47,7 +47,7 @@ static HWND hChildWnd;
static
void
resize_frame_rect
(
HWND
hWnd
,
PRECT
prect
)
{
RECT
rt
;
/*
/*
if (IsWindowVisible(hToolBar)) {
SendMessage(hToolBar, WM_SIZE, 0, 0);
GetClientRect(hToolBar, &rt);
...
...
@@ -119,7 +119,7 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
int
nParts
;
GetClientRect
(
hWnd
,
&
rc
);
nParts
=
rc
.
right
;
/* nParts = -1;*/
/* nParts = -1;*/
if
(
bResize
)
SendMessage
(
hStatusBar
,
WM_SIZE
,
0
,
0
);
SendMessage
(
hStatusBar
,
SB_SETPARTS
,
1
,
(
LPARAM
)
&
nParts
);
...
...
@@ -196,8 +196,7 @@ UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM w
break
;
case
WM_NOTIFY
:
pOfNotify
=
(
OFNOTIFY
*
)
lParam
;
if
(
pOfNotify
->
hdr
.
code
==
CDN_INITDONE
)
{
}
if
(
pOfNotify
->
hdr
.
code
==
CDN_INITDONE
)
{}
break
;
default:
break
;
...
...
@@ -225,18 +224,18 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
pofn
->
nMaxFile
=
_MAX_PATH
;
pofn
->
lpstrFileTitle
=
FileTitleBuffer
;
pofn
->
nMaxFileTitle
=
_MAX_PATH
;
/* pofn->lpstrInitialDir = _T("");*/
/* pofn->lpstrTitle = _T("Import Registry File");*/
/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
/* pofn->lpstrInitialDir = _T("");*/
/* pofn->lpstrTitle = _T("Import Registry File");*/
/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/
pofn
->
Flags
=
OFN_HIDEREADONLY
;
/* pofn->nFileOffset = ;*/
/* pofn->nFileExtension = ;*/
/* pofn->lpstrDefExt = _T("");*/
/* pofn->lCustData = ;*/
/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
/* pofn->FlagsEx = ;*/
/* pofn->nFileOffset = ;*/
/* pofn->nFileExtension = ;*/
/* pofn->lpstrDefExt = _T("");*/
/* pofn->lCustData = ;*/
/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/
/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/
/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/
/* pofn->FlagsEx = ;*/
return
TRUE
;
}
...
...
@@ -246,7 +245,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
InitOpenFileName
(
hWnd
,
&
ofn
);
ofn
.
lpstrTitle
=
_T
(
"Import Registry File"
);
/* ofn.lCustData = ;*/
/* ofn.lCustData = ;*/
if
(
GetOpenFileName
(
&
ofn
))
{
if
(
!
import_registry_file
(
ofn
.
lpstrFile
))
{
/*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/
...
...
@@ -269,6 +268,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
get_file_name(&s, filename, MAX_PATH);
}
#endif
}
else
{
CheckCommDlgError
(
hWnd
);
}
...
...
@@ -284,7 +284,7 @@ static BOOL ExportRegistryFile(HWND hWnd)
ExportKeyPath
[
0
]
=
_T
(
'\0'
);
InitOpenFileName
(
hWnd
,
&
ofn
);
ofn
.
lpstrTitle
=
_T
(
"Export Registry File"
);
/* ofn.lCustData = ;*/
/* ofn.lCustData = ;*/
ofn
.
Flags
=
OFN_ENABLETEMPLATE
+
OFN_EXPLORER
;
ofn
.
lpfnHook
=
ImportRegistryFile_OFNHookProc
;
ofn
.
lpTemplateName
=
MAKEINTRESOURCE
(
IDD_DIALOG1
);
...
...
@@ -314,6 +314,7 @@ static BOOL ExportRegistryFile(HWND hWnd)
export_registry_key(filename, NULL);
}
#endif
}
else
{
CheckCommDlgError
(
hWnd
);
}
...
...
@@ -485,19 +486,19 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case
ID_VIEW_REFRESH
:
RefreshView
(
hWnd
);
break
;
/* case ID_OPTIONS_TOOLBAR:*/
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
/* break;*/
/* case ID_OPTIONS_TOOLBAR:*/
/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
/* break;*/
case
ID_VIEW_STATUSBAR
:
toggle_child
(
hWnd
,
LOWORD
(
wParam
),
hStatusBar
);
break
;
case
ID_HELP_HELPTOPICS
:
/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/
/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/
WinHelp
(
hWnd
,
_T
(
"regedit"
),
HELP_FINDER
,
0
);
break
;
case
ID_HELP_ABOUT
:
#ifdef WINSHELLAPI
/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/
/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/
#else
ShowAboutBox
(
hWnd
);
#endif
...
...
@@ -526,12 +527,11 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
static
ChildWnd
*
pChildWnd
=
NULL
;
switch
(
message
)
{
case
WM_CREATE
:
{
case
WM_CREATE
:
{
pChildWnd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
ChildWnd
));
_tcsncpy
(
pChildWnd
->
szPath
,
_T
(
"My Computer"
),
MAX_PATH
);
hChildWnd
=
CreateWindowEx
(
0
,
szChildClass
,
_T
(
"regedit child window"
),
/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/
/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/
WS_CHILD
|
WS_VISIBLE
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
hWnd
,
(
HMENU
)
0
,
hInst
,
pChildWnd
);
...
...
programs/regedit/listview.c
View file @
58c185ec
...
...
@@ -61,30 +61,28 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
item
.
pszText
=
LPSTR_TEXTCALLBACK
;
item
.
iImage
=
0
;
item
.
lParam
=
(
LPARAM
)
dwValType
;
/* item.lParam = (LPARAM)ValBuf; */
/* item.lParam = (LPARAM)ValBuf; */
#if (_WIN32_IE >= 0x0300)
item
.
iIndent
=
0
;
#endif
index
=
ListView_InsertItem
(
hwndLV
,
&
item
);
if
(
index
!=
-
1
)
{
/* LPTSTR pszText = NULL; */
/* LPTSTR pszText = NULL; */
LPTSTR
pszText
=
_T
(
"value"
);
switch
(
dwValType
)
{
case
REG_SZ
:
case
REG_EXPAND_SZ
:
ListView_SetItemText
(
hwndLV
,
index
,
2
,
ValBuf
);
break
;
case
REG_DWORD
:
{
case
REG_DWORD
:
{
TCHAR
buf
[
64
];
wsprintf
(
buf
,
_T
(
"0x%08X (%d)"
),
*
(
DWORD
*
)
ValBuf
,
*
(
DWORD
*
)
ValBuf
);
ListView_SetItemText
(
hwndLV
,
index
,
2
,
buf
);
}
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
break
;
case
REG_BINARY
:
{
case
REG_BINARY
:
{
unsigned
int
i
;
LPBYTE
pData
=
(
LPBYTE
)
ValBuf
;
LPTSTR
strBinary
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwCount
*
sizeof
(
TCHAR
)
*
3
+
1
);
...
...
@@ -96,7 +94,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
}
break
;
default:
/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */
/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */
ListView_SetItemText
(
hwndLV
,
index
,
2
,
pszText
);
break
;
}
...
...
@@ -153,9 +151,9 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
case
REG_DWORD
:
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD"
);
break
;
/* case REG_DWORD_LITTLE_ENDIAN: */
/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */
/* break; */
/* case REG_DWORD_LITTLE_ENDIAN: */
/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */
/* break; */
case
REG_DWORD_BIG_ENDIAN
:
plvdi
->
item
.
pszText
=
_T
(
"REG_DWORD_BIG_ENDIAN"
);
break
;
...
...
@@ -199,14 +197,13 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
#endif
static
void
ListViewPopUpMenu
(
HWND
hWnd
,
POINT
pt
)
{
}
{}
static
BOOL
_CmdWndProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
switch
(
LOWORD
(
wParam
))
{
/* case ID_FILE_OPEN: */
/* break; */
/* case ID_FILE_OPEN: */
/* break; */
default:
return
FALSE
;
}
...
...
@@ -226,14 +223,13 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
case
LVN_GETDISPINFO
:
OnGetDispInfo
((
NMLVDISPINFO
*
)
lParam
);
break
;
case
NM_DBLCLK
:
{
case
NM_DBLCLK
:
{
NMITEMACTIVATE
*
nmitem
=
(
LPNMITEMACTIVATE
)
lParam
;
LVHITTESTINFO
info
;
if
(
nmitem
->
hdr
.
hwndFrom
!=
hWnd
)
break
;
/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */
/* if (nmitem->hdr.code != ???) break; */
/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */
/* if (nmitem->hdr.code != ???) break; */
#ifdef _MSC_VER
switch
(
nmitem
->
uKeyFlags
)
{
case
LVKF_ALT
:
/* The ALT key is pressed. */
...
...
@@ -252,14 +248,12 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
LVITEM
item
;
item
.
mask
=
LVIF_PARAM
;
item
.
iItem
=
info
.
iItem
;
if
(
ListView_GetItem
(
hWnd
,
&
item
))
{
}
if
(
ListView_GetItem
(
hWnd
,
&
item
))
{}
}
}
break
;
case
NM_RCLICK
:
{
case
NM_RCLICK
:
{
int
idx
;
LV_HITTESTINFO
lvH
;
NM_LISTVIEW
*
pNm
=
(
NM_LISTVIEW
*
)
lParam
;
...
...
@@ -307,7 +301,7 @@ HWND CreateListView(HWND hwndParent, int id)
ListView_SetExtendedListViewStyle
(
hwndLV
,
LVS_EX_FULLROWSELECT
);
/* Initialize the image list, and add items to the control. */
/*
/*
if (!InitListViewImageLists(hwndLV) ||
!InitListViewItems(hwndLV, szName)) {
DestroyWindow(hwndLV);
...
...
@@ -338,7 +332,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
errCode
=
RegQueryInfoKey
(
hNewKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_sub_key_len
,
NULL
,
&
val_count
,
&
max_val_name_len
,
&
max_val_size
,
NULL
,
NULL
);
#define BUF_HEAD_SPACE 2
/* TODO: check why this is required with ROS ??? */
#define BUF_HEAD_SPACE 2
/* TODO: check why this is required with ROS ??? */
if
(
errCode
==
ERROR_SUCCESS
)
{
TCHAR
*
ValName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
++
max_val_name_len
*
sizeof
(
TCHAR
)
+
BUF_HEAD_SPACE
);
...
...
@@ -347,10 +341,10 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
DWORD
dwValSize
=
max_val_size
;
DWORD
dwIndex
=
0L
;
DWORD
dwValType
;
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
/* } */
/* dwValSize = max_val_size; */
/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */
/* } */
/* dwValSize = max_val_size; */
while
(
RegEnumValue
(
hNewKey
,
dwIndex
,
ValName
,
&
dwValNameLen
,
NULL
,
&
dwValType
,
ValBuf
,
&
dwValSize
)
==
ERROR_SUCCESS
)
{
ValBuf
[
dwValSize
]
=
0
;
AddEntryToList
(
hwndLV
,
ValName
,
dwValType
,
ValBuf
,
dwValSize
);
...
...
@@ -363,7 +357,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath)
HeapFree
(
GetProcessHeap
(),
0
,
ValName
);
}
/*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */
/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */
/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */
ShowWindow
(
hwndLV
,
SW_SHOW
);
RegCloseKey
(
hNewKey
);
}
...
...
programs/regedit/main.c
View file @
58c185ec
...
...
@@ -148,7 +148,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
{
MSG
msg
;
HACCEL
hAccel
;
/*
/*
int hCrt;
FILE *hf;
AllocConsole();
...
...
programs/regedit/main.h
View file @
58c185ec
programs/regedit/regedit.c
View file @
58c185ec
...
...
@@ -24,36 +24,36 @@
#include "regproc.h"
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
"
;
"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
...
...
@@ -70,8 +70,7 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s);
*/
void
error_unknown_switch
(
char
chu
,
char
*
s
)
{
if
(
isalpha
(
chu
))
{
if
(
isalpha
(
chu
))
{
fprintf
(
stderr
,
"%s: Undefined switch /%c!
\n
"
,
getAppName
(),
chu
);
}
else
{
fprintf
(
stderr
,
"%s: Alphabetic character is expected after '%c' "
...
...
@@ -87,8 +86,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
CHAR
ch
=
*
s
;
/* current character */
setAppName
(
"regedit"
);
while
(
ch
&&
((
ch
==
'-'
)
||
(
ch
==
'/'
)))
{
while
(
ch
&&
((
ch
==
'-'
)
||
(
ch
==
'/'
)))
{
char
chu
;
char
ch2
;
...
...
@@ -96,14 +94,11 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
ch
=
*
s
;
ch2
=
*
(
s
+
1
);
chu
=
toupper
(
ch
);
if
(
!
ch2
||
isspace
(
ch2
))
{
if
(
chu
==
'S'
||
chu
==
'V'
)
{
if
(
!
ch2
||
isspace
(
ch2
))
{
if
(
chu
==
'S'
||
chu
==
'V'
)
{
/* ignore these switches */
}
else
{
switch
(
chu
)
{
switch
(
chu
)
{
case
'D'
:
action
=
ACTION_DELETE
;
break
;
...
...
@@ -121,16 +116,13 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
}
s
++
;
}
else
{
if
(
ch2
==
':'
)
{
switch
(
chu
)
{
if
(
ch2
==
':'
)
{
switch
(
chu
)
{
case
'L'
:
/* fall through */
case
'R'
:
s
+=
2
;
while
(
*
s
&&
!
isspace
(
*
s
))
{
while
(
*
s
&&
!
isspace
(
*
s
))
{
s
++
;
}
break
;
...
...
@@ -146,8 +138,7 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
}
/* skip spaces to the next parameter */
ch
=
*
s
;
while
(
ch
&&
isspace
(
ch
))
{
while
(
ch
&&
isspace
(
ch
))
{
s
++
;
ch
=
*
s
;
}
...
...
@@ -164,26 +155,21 @@ BOOL ProcessCmdLine(LPSTR lpCmdLine)
BOOL
PerformRegAction
(
REGEDIT_ACTION
action
,
LPSTR
s
)
{
switch
(
action
)
{
case
ACTION_ADD
:
{
switch
(
action
)
{
case
ACTION_ADD
:
{
CHAR
filename
[
MAX_PATH
];
FILE
*
reg_file
;
get_file_name
(
&
s
,
filename
);
if
(
!
filename
[
0
])
{
if
(
!
filename
[
0
])
{
fprintf
(
stderr
,
"%s: No file name is specified
\n
"
,
getAppName
());
fprintf
(
stderr
,
usage
);
exit
(
1
);
}
while
(
filename
[
0
])
{
while
(
filename
[
0
])
{
reg_file
=
fopen
(
filename
,
"r"
);
if
(
reg_file
)
{
if
(
reg_file
)
{
processRegLines
(
reg_file
,
doSetValue
);
}
else
{
perror
(
""
);
...
...
@@ -194,13 +180,11 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
}
break
;
}
case
ACTION_DELETE
:
{
case
ACTION_DELETE
:
{
CHAR
reg_key_name
[
KEY_MAX_LEN
];
get_file_name
(
&
s
,
reg_key_name
);
if
(
!
reg_key_name
[
0
])
{
if
(
!
reg_key_name
[
0
])
{
fprintf
(
stderr
,
"%s: No registry key is specified for removal
\n
"
,
getAppName
());
fprintf
(
stderr
,
usage
);
...
...
@@ -209,21 +193,18 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s)
delete_registry_key
(
reg_key_name
);
break
;
}
case
ACTION_EXPORT
:
{
case
ACTION_EXPORT
:
{
CHAR
filename
[
MAX_PATH
];
filename
[
0
]
=
'\0'
;
get_file_name
(
&
s
,
filename
);
if
(
!
filename
[
0
])
{
if
(
!
filename
[
0
])
{
fprintf
(
stderr
,
"%s: No file name is specified
\n
"
,
getAppName
());
fprintf
(
stderr
,
usage
);
exit
(
1
);
}
if
(
s
[
0
])
{
if
(
s
[
0
])
{
CHAR
reg_key_name
[
KEY_MAX_LEN
];
get_file_name
(
&
s
,
reg_key_name
);
...
...
programs/regedit/regproc.c
View file @
58c185ec
...
...
@@ -48,14 +48,14 @@ static CHAR *app_name = "UNKNOWN";
static
CHAR
*
reg_class_names
[]
=
{
"HKEY_LOCAL_MACHINE"
,
"HKEY_USERS"
,
"HKEY_CLASSES_ROOT"
,
"HKEY_CURRENT_CONFIG"
,
"HKEY_CURRENT_USER"
};
};
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
static
HKEY
reg_class_keys
[
REG_CLASS_NUMBER
]
=
{
HKEY_LOCAL_MACHINE
,
HKEY_USERS
,
HKEY_CLASSES_ROOT
,
HKEY_CURRENT_CONFIG
,
HKEY_CURRENT_USER
};
};
/* return values */
#define NOT_ENOUGH_MEMORY 1
...
...
@@ -65,12 +65,12 @@ static HKEY reg_class_keys[REG_CLASS_NUMBER] = {
/* common check of memory allocation results */
#define CHECK_ENOUGH_MEMORY(p) \
if (!(p)) \
{ \
if (!(p)) \
{ \
fprintf(stderr,"%s: file %s, line %d: Not enough memory", \
getAppName(), __FILE__, __LINE__); \
exit(NOT_ENOUGH_MEMORY); \
}
}
/******************************************************************************
* This is a replacement for strsep which is not portable (missing on Solaris).
...
...
@@ -118,19 +118,15 @@ void get_file_name(CHAR **command_line, CHAR *file_name)
int
pos
=
0
;
/* position of pointer "s" in *command_line */
file_name
[
0
]
=
0
;
if
(
!
s
[
0
])
{
if
(
!
s
[
0
])
{
return
;
}
if
(
s
[
0
]
==
'"'
)
{
if
(
s
[
0
]
==
'"'
)
{
s
++
;
(
*
command_line
)
++
;
while
(
s
[
0
]
!=
'"'
)
{
if
(
!
s
[
0
])
{
while
(
s
[
0
]
!=
'"'
)
{
if
(
!
s
[
0
])
{
fprintf
(
stderr
,
"%s: Unexpected end of file name!
\n
"
,
getAppName
());
exit
(
1
);
...
...
@@ -139,28 +135,24 @@ void get_file_name(CHAR **command_line, CHAR *file_name)
pos
++
;
}
}
else
{
while
(
s
[
0
]
&&
!
isspace
(
s
[
0
]))
{
while
(
s
[
0
]
&&
!
isspace
(
s
[
0
]))
{
s
++
;
pos
++
;
}
}
memcpy
(
file_name
,
*
command_line
,
pos
*
sizeof
((
*
command_line
)[
0
]));
/* remove the last backslash */
if
(
file_name
[
pos
-
1
]
==
'\\'
)
{
if
(
file_name
[
pos
-
1
]
==
'\\'
)
{
file_name
[
pos
-
1
]
=
'\0'
;
}
else
{
file_name
[
pos
]
=
'\0'
;
}
if
(
s
[
0
])
{
if
(
s
[
0
])
{
s
++
;
pos
++
;
}
while
(
s
[
0
]
&&
isspace
(
s
[
0
]))
{
while
(
s
[
0
]
&&
isspace
(
s
[
0
]))
{
s
++
;
pos
++
;
}
...
...
@@ -199,8 +191,7 @@ char* convertHexToHexCSV(BYTE *buf, ULONG bufLen)
ptrStr
=
str
;
/* Pointer to result */
ptrBuf
=
buf
;
/* Pointer to current */
while
(
current
<
bufLen
)
{
while
(
current
<
bufLen
)
{
BYTE
bCur
=
ptrBuf
[
current
++
];
char
res
[
3
];
...
...
@@ -259,8 +250,7 @@ DWORD convertHexCSVToHex(char *str, BYTE *buf, ULONG bufLen)
fprintf
(
stderr
,
"%s: ERROR converting CSV hex stream. Too long
\n
"
,
getAppName
());
while
(
strPos
<
strLen
)
{
while
(
strPos
<
strLen
)
{
char
xbuf
[
3
];
UINT
wc
;
...
...
@@ -288,8 +278,7 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type)
{
struct
data_type
{
const
char
*
tag
;
int
len
;
int
type
;
int
parse_type
;
};
static
const
struct
data_type
data_types
[]
=
{
/* actual type */
/* type to assume for parsing */
static
const
struct
data_type
data_types
[]
=
{
/* actual type */
/* type to assume for parsing */
{
"
\"
"
,
1
,
REG_SZ
,
REG_SZ
},
{
"str:
\"
"
,
5
,
REG_SZ
,
REG_SZ
},
{
"str(2):
\"
"
,
8
,
REG_EXPAND_SZ
,
REG_SZ
},
...
...
@@ -302,8 +291,7 @@ DWORD getDataType(LPSTR *lpValue, DWORD* parse_type)
const
struct
data_type
*
ptr
;
int
type
;
for
(
ptr
=
data_types
;
ptr
->
tag
;
ptr
++
)
{
for
(
ptr
=
data_types
;
ptr
->
tag
;
ptr
++
)
{
if
(
memcmp
(
ptr
->
tag
,
*
lpValue
,
ptr
->
len
))
continue
;
...
...
@@ -360,13 +348,10 @@ void REGPROC_unescape_string(LPSTR str)
int
str_idx
=
0
;
/* current character under analysis */
int
val_idx
=
0
;
/* the last character of the unescaped string */
int
len
=
strlen
(
str
);
for
(
str_idx
=
0
;
str_idx
<
len
;
str_idx
++
,
val_idx
++
)
{
if
(
str
[
str_idx
]
==
'\\'
)
{
for
(
str_idx
=
0
;
str_idx
<
len
;
str_idx
++
,
val_idx
++
)
{
if
(
str
[
str_idx
]
==
'\\'
)
{
str_idx
++
;
switch
(
str
[
str_idx
])
{
switch
(
str
[
str_idx
])
{
case
'n'
:
str
[
val_idx
]
=
'\n'
;
break
;
...
...
@@ -421,24 +406,19 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data)
dwLen
++
;
REGPROC_unescape_string
(
val_data
);
lpbData
=
val_data
;
}
else
if
(
dwParseType
==
REG_DWORD
)
/* Convert the dword types */
}
else
if
(
dwParseType
==
REG_DWORD
)
/* Convert the dword types */
{
dwLen
=
convertHexToDWord
(
val_data
,
convert
);
lpbData
=
convert
;
}
else
/* Convert the hexadecimal types */
}
else
/* Convert the hexadecimal types */
{
int
b_len
=
strlen
(
val_data
)
+
2
/
3
;
if
(
b_len
>
KEY_MAX_LEN
)
{
if
(
b_len
>
KEY_MAX_LEN
)
{
bBigBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
b_len
);
CHECK_ENOUGH_MEMORY
(
bBigBuffer
);
dwLen
=
convertHexCSVToHex
(
val_data
,
bBigBuffer
,
b_len
);
lpbData
=
bBigBuffer
;
}
else
{
}
else
{
dwLen
=
convertHexCSVToHex
(
val_data
,
convert
,
KEY_MAX_LEN
);
lpbData
=
convert
;
}
...
...
@@ -514,14 +494,12 @@ LPSTR getRegKeyName(LPSTR lpLine)
strcpy
(
lpLineCopy
,
lpLine
);
keyNameBeg
=
strchr
(
lpLineCopy
,
'\\'
);
/* The key name start by '\' */
if
(
keyNameBeg
)
{
if
(
keyNameBeg
)
{
LPSTR
keyNameEnd
;
keyNameBeg
++
;
/* is not part of the name */
keyNameEnd
=
strchr
(
lpLineCopy
,
']'
);
if
(
keyNameEnd
)
{
if
(
keyNameEnd
)
{
*
keyNameEnd
=
'\0'
;
/* remove ']' from the key name */
}
}
else
{
...
...
@@ -560,17 +538,14 @@ HKEY getRegClass(LPSTR lpClass)
}
}
*
classNameEnd
=
'\0'
;
/* Isolate the class name */
if
(
lpClassCopy
[
0
]
==
'['
)
{
if
(
lpClassCopy
[
0
]
==
'['
)
{
classNameBeg
=
lpClassCopy
+
1
;
}
else
{
classNameBeg
=
lpClassCopy
;
}
for
(
i
=
0
;
i
<
REG_CLASS_NUMBER
;
i
++
)
{
if
(
!
strcmp
(
classNameBeg
,
reg_class_names
[
i
]))
{
for
(
i
=
0
;
i
<
REG_CLASS_NUMBER
;
i
++
)
{
if
(
!
strcmp
(
classNameBeg
,
reg_class_names
[
i
]))
{
return
reg_class_keys
[
i
];
}
}
...
...
@@ -604,8 +579,7 @@ void doSetValue(LPSTR stdInput)
* We encoutered the end of the file, make sure we
* close the opened key and exit
*/
if
(
stdInput
==
NULL
)
{
if
(
stdInput
==
NULL
)
{
if
(
bTheKeyIsOpen
!=
FALSE
)
closeKey
();
...
...
@@ -620,14 +594,12 @@ void doSetValue(LPSTR stdInput)
if
(
openKey
(
stdInput
)
!=
ERROR_SUCCESS
)
fprintf
(
stderr
,
"%s: setValue failed to open key %s
\n
"
,
getAppName
(),
stdInput
);
}
else
if
(
(
bTheKeyIsOpen
)
&&
}
else
if
(
(
bTheKeyIsOpen
)
&&
((
stdInput
[
0
]
==
'@'
)
||
/* reading a default @=data pair */
(
stdInput
[
0
]
==
'\"'
)))
/* reading a new value=data pair */
{
processSetValue
(
stdInput
);
}
else
/* since we are assuming that the */
}
else
/* since we are assuming that the */
{
/* file format is valid we must */
if
(
bTheKeyIsOpen
)
/* be reading a blank line which */
closeKey
();
/* indicate end of this key processing */
...
...
@@ -639,13 +611,13 @@ void doSetValue(LPSTR stdInput)
* receives the currently read line and dispatch the work depending on the
* context.
*/
void
doQueryValue
(
LPSTR
stdInput
)
{
void
doQueryValue
(
LPSTR
stdInput
)
{
/*
* We encoutered the end of the file, make sure we
* close the opened key and exit
*/
if
(
stdInput
==
NULL
)
{
if
(
stdInput
==
NULL
)
{
if
(
bTheKeyIsOpen
!=
FALSE
)
closeKey
();
...
...
@@ -660,14 +632,12 @@ void doQueryValue(LPSTR stdInput) {
if
(
openKey
(
stdInput
)
!=
ERROR_SUCCESS
)
fprintf
(
stderr
,
"%s: queryValue failed to open key %s
\n
"
,
getAppName
(),
stdInput
);
}
else
if
(
(
bTheKeyIsOpen
)
&&
}
else
if
(
(
bTheKeyIsOpen
)
&&
((
stdInput
[
0
]
==
'@'
)
||
/* reading a default @=data pair */
(
stdInput
[
0
]
==
'\"'
)))
/* reading a new value=data pair */
{
processQueryValue
(
stdInput
);
}
else
/* since we are assuming that the */
}
else
/* since we are assuming that the */
{
/* file format is valid we must */
if
(
bTheKeyIsOpen
)
/* be reading a blank line which */
closeKey
();
/* indicate end of this key processing */
...
...
@@ -679,7 +649,8 @@ void doQueryValue(LPSTR stdInput) {
* receives the currently read line and dispatch the work depending on the
* context.
*/
void
doDeleteValue
(
LPSTR
line
)
{
void
doDeleteValue
(
LPSTR
line
)
{
fprintf
(
stderr
,
"%s: deleteValue not yet implemented
\n
"
,
getAppName
());
}
...
...
@@ -688,7 +659,8 @@ void doDeleteValue(LPSTR line) {
* receives the currently read line and dispatch the work depending on the
* context.
*/
void
doDeleteKey
(
LPSTR
line
)
{
void
doDeleteKey
(
LPSTR
line
)
{
fprintf
(
stderr
,
"%s: deleteKey not yet implemented
\n
"
,
getAppName
());
}
...
...
@@ -697,7 +669,8 @@ void doDeleteKey(LPSTR line) {
* receives the currently read line and dispatch the work depending on the
* context.
*/
void
doCreateKey
(
LPSTR
line
)
{
void
doCreateKey
(
LPSTR
line
)
{
fprintf
(
stderr
,
"%s: createKey not yet implemented
\n
"
,
getAppName
());
}
...
...
@@ -718,24 +691,19 @@ void processSetValue(LPSTR line)
HRESULT
hRes
=
0
;
/* get value name */
if
(
line
[
line_idx
]
==
'@'
&&
line
[
line_idx
+
1
]
==
'='
)
{
if
(
line
[
line_idx
]
==
'@'
&&
line
[
line_idx
+
1
]
==
'='
)
{
line
[
line_idx
]
=
'\0'
;
val_name
=
line
;
line_idx
++
;
}
else
if
(
line
[
line_idx
]
==
'\"'
)
{
}
else
if
(
line
[
line_idx
]
==
'\"'
)
{
line_idx
++
;
val_name
=
line
+
line_idx
;
while
(
TRUE
)
{
while
(
TRUE
)
{
if
(
line
[
line_idx
]
==
'\\'
)
/* skip escaped character */
{
line_idx
+=
2
;
}
else
{
if
(
line
[
line_idx
]
==
'\"'
)
{
if
(
line
[
line_idx
]
==
'\"'
)
{
line
[
line_idx
]
=
'\0'
;
line_idx
++
;
break
;
...
...
@@ -744,16 +712,13 @@ void processSetValue(LPSTR line)
}
}
}
if
(
line
[
line_idx
]
!=
'='
)
{
if
(
line
[
line_idx
]
!=
'='
)
{
line
[
line_idx
]
=
'\"'
;
fprintf
(
stderr
,
"Warning! unrecognized line:
\n
%s
\n
"
,
line
);
return
;
}
}
else
{
}
else
{
fprintf
(
stderr
,
"Warning! unrecognized line:
\n
%s
\n
"
,
line
);
return
;
}
...
...
@@ -793,8 +758,7 @@ void processQueryValue(LPSTR cmdline)
for (counter=0; counter<QUERY_VALUE_MAX_ARGS; counter++)
argv[counter]=NULL;
while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL )
{
while( (token = getToken(&cmdline, queryValueDelim[argCounter])) != NULL ) {
argv[argCounter++] = getArg(token);
if (argCounter == QUERY_VALUE_MAX_ARGS)
...
...
@@ -807,8 +771,7 @@ void processQueryValue(LPSTR cmdline)
else
keyValue = argv[0];
if( (keyValue[0] == '@') && (strlen(keyValue) == 1) )
{
if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) {
LONG lLen = KEY_MAX_LEN;
CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
/*
...
...
@@ -825,15 +788,12 @@ void processQueryValue(LPSTR cmdline)
hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen);
}
if (hRes == ERROR_SUCCESS)
{
if (hRes == ERROR_SUCCESS) {
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
strncpy(lpsRes, lpsData, lLen);
lpsRes[lLen-1]='\0';
}
}
else
{
} else {
DWORD dwLen = KEY_MAX_LEN;
BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
DWORD dwType;
...
...
@@ -853,28 +813,23 @@ void processQueryValue(LPSTR cmdline)
hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen);
}
if (hRes == ERROR_SUCCESS)
{
if (hRes == ERROR_SUCCESS) {
/*
* Convert the returned data to a displayable format
*/
switch ( dwType )
{
switch ( dwType ) {
case REG_SZ:
case REG_EXPAND_SZ:
{
case REG_EXPAND_SZ: {
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
strncpy(lpsRes, lpbData, dwLen);
lpsRes[dwLen-1]='\0';
break;
}
case REG_DWORD:
{
case REG_DWORD: {
lpsRes = convertHexToDWORDStr(lpbData, dwLen);
break;
}
default:
{
default: {
lpsRes = convertHexToHexCSV(lpbData, dwLen);
break;
}
...
...
@@ -927,12 +882,10 @@ void processRegLines(FILE *in, CommandAPI command)
line
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lineSize
);
CHECK_ENOUGH_MEMORY
(
line
);
while
(
!
feof
(
in
))
{
while
(
!
feof
(
in
))
{
LPSTR
s
;
/* The pointer into line for where the current fgets should read */
s
=
line
;
for
(;;)
{
for
(;;)
{
size_t
size_remaining
;
int
size_to_get
;
char
*
s_eol
;
/* various local uses */
...
...
@@ -959,15 +912,11 @@ void processRegLines(FILE *in, CommandAPI command)
* eof, error, eol or getting the maximum amount. Abort on error.
*/
size_to_get
=
(
size_remaining
>
INT_MAX
?
INT_MAX
:
size_remaining
);
if
(
NULL
==
fgets
(
s
,
size_to_get
,
in
))
{
if
(
ferror
(
in
))
{
if
(
NULL
==
fgets
(
s
,
size_to_get
,
in
))
{
if
(
ferror
(
in
))
{
perror
(
"While reading input"
);
exit
(
IO_ERROR
);
}
else
{
}
else
{
assert
(
feof
(
in
));
*
s
=
'\0'
;
/* It is not clear to me from the definition that the
...
...
@@ -979,33 +928,28 @@ void processRegLines(FILE *in, CommandAPI command)
/* If we didn't read the eol nor the eof go around for the rest */
s_eol
=
strchr
(
s
,
'\n'
);
if
(
!
feof
(
in
)
&&
!
s_eol
)
{
if
(
!
feof
(
in
)
&&
!
s_eol
)
{
s
=
strchr
(
s
,
'\0'
);
/* It should be s + size_to_get - 1 but this is safer */
continue
;
}
/* If it is a comment line then discard it and go around again */
if
(
line
[
0
]
==
'#'
)
{
if
(
line
[
0
]
==
'#'
)
{
s
=
line
;
continue
;
}
/* Remove any line feed. Leave s_eol on the \0 */
if
(
s_eol
)
{
if
(
s_eol
)
{
*
s_eol
=
'\0'
;
if
(
s_eol
>
line
&&
*
(
s_eol
-
1
)
==
'\r'
)
*--
s_eol
=
'\0'
;
}
else
}
else
s_eol
=
strchr
(
s
,
'\0'
);
/* If there is a concatenating \\ then go around again */
if
(
s_eol
>
line
&&
*
(
s_eol
-
1
)
==
'\\'
)
{
if
(
s_eol
>
line
&&
*
(
s_eol
-
1
)
==
'\\'
)
{
int
c
;
s
=
s_eol
-
1
;
/* The following error protection could be made more self-
...
...
@@ -1032,7 +976,8 @@ void processRegLines(FILE *in, CommandAPI command)
* This funtion is the main entry point to the registerDLL action. It
* receives the currently read line, then loads and registers the requested DLLs
*/
void
doRegisterDLL
(
LPSTR
stdInput
)
{
void
doRegisterDLL
(
LPSTR
stdInput
)
{
HMODULE
theLib
=
0
;
UINT
retVal
=
0
;
...
...
@@ -1042,8 +987,7 @@ void doRegisterDLL(LPSTR stdInput) {
/* Load and register the library, then free it */
theLib
=
LoadLibrary
(
stdInput
);
if
(
theLib
)
{
if
(
theLib
)
{
FARPROC
lpfnDLLRegProc
=
GetProcAddress
(
theLib
,
"DllRegisterServer"
);
if
(
lpfnDLLRegProc
)
retVal
=
(
*
lpfnDLLRegProc
)();
...
...
@@ -1056,9 +1000,7 @@ void doRegisterDLL(LPSTR stdInput) {
getAppName
(),
retVal
,
stdInput
);
FreeLibrary
(
theLib
);
}
else
{
}
else
{
fprintf
(
stderr
,
"%s: Could not load DLL '%s'.
\n
"
,
getAppName
(),
stdInput
);
}
}
...
...
@@ -1067,7 +1009,8 @@ void doRegisterDLL(LPSTR stdInput) {
* This funtion is the main entry point to the unregisterDLL action. It
* receives the currently read line, then loads and unregisters the requested DLLs
*/
void
doUnregisterDLL
(
LPSTR
stdInput
)
{
void
doUnregisterDLL
(
LPSTR
stdInput
)
{
HMODULE
theLib
=
0
;
UINT
retVal
=
0
;
...
...
@@ -1077,8 +1020,7 @@ void doUnregisterDLL(LPSTR stdInput) {
/* Load and unregister the library, then free it */
theLib
=
LoadLibrary
(
stdInput
);
if
(
theLib
)
{
if
(
theLib
)
{
FARPROC
lpfnDLLRegProc
=
GetProcAddress
(
theLib
,
"DllUnregisterServer"
);
if
(
lpfnDLLRegProc
)
retVal
=
(
*
lpfnDLLRegProc
)();
...
...
@@ -1091,9 +1033,7 @@ void doUnregisterDLL(LPSTR stdInput) {
getAppName
(),
retVal
,
stdInput
);
FreeLibrary
(
theLib
);
}
else
{
}
else
{
fprintf
(
stderr
,
"%s: Could not load DLL '%s'.
\n
"
,
getAppName
(),
stdInput
);
}
}
...
...
@@ -1104,7 +1044,8 @@ void doUnregisterDLL(LPSTR stdInput) {
* Print the message for GetLastError
*/
void
REGPROC_print_error
()
{
void
REGPROC_print_error
()
{
LPVOID
lpMsgBuf
;
DWORD
error_code
;
int
status
;
...
...
@@ -1135,8 +1076,7 @@ void REGPROC_print_error() {
void
REGPROC_resize_char_buffer
(
CHAR
**
buffer
,
DWORD
*
len
,
DWORD
required_len
)
{
required_len
++
;
if
(
required_len
>
*
len
)
{
if
(
required_len
>
*
len
)
{
*
len
=
required_len
;
if
(
!*
buffer
)
*
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
len
*
sizeof
(
**
buffer
));
...
...
@@ -1155,11 +1095,9 @@ void REGPROC_export_string(FILE *file, CHAR *str)
size_t
i
;
/* escaping characters */
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
CHAR
c
=
str
[
i
];
switch
(
c
)
{
switch
(
c
)
{
case
'\\'
:
fputs
(
"
\\\\
"
,
file
);
break
;
...
...
@@ -1209,8 +1147,7 @@ void export_hkey(FILE *file, HKEY key,
if
(
RegQueryInfoKey
(
key
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_sub_key_len
,
NULL
,
NULL
,
&
max_val_name_len
,
&
max_val_size
,
NULL
,
NULL
)
!=
ERROR_SUCCESS
)
{
)
!=
ERROR_SUCCESS
)
{
REGPROC_print_error
();
}
curr_len
=
strlen
(
*
reg_key_name_buf
);
...
...
@@ -1218,8 +1155,7 @@ void export_hkey(FILE *file, HKEY key,
max_sub_key_len
+
curr_len
+
1
);
REGPROC_resize_char_buffer
(
val_name_buf
,
val_name_len
,
max_val_name_len
);
if
(
max_val_size
>
*
val_size
)
{
if
(
max_val_size
>
*
val_size
)
{
*
val_size
=
max_val_size
;
if
(
!*
val_buf
)
*
val_buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
val_size
);
else
*
val_buf
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
val_buf
,
*
val_size
);
...
...
@@ -1233,25 +1169,21 @@ void export_hkey(FILE *file, HKEY key,
/* print all the values */
i
=
0
;
more_data
=
TRUE
;
while
(
more_data
)
{
while
(
more_data
)
{
DWORD
value_type
;
DWORD
val_name_len1
=
*
val_name_len
;
DWORD
val_size1
=
*
val_size
;
ret
=
RegEnumValue
(
key
,
i
,
*
val_name_buf
,
&
val_name_len1
,
NULL
,
&
value_type
,
*
val_buf
,
&
val_size1
);
if
(
ret
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SUCCESS
)
{
more_data
=
FALSE
;
if
(
ret
!=
ERROR_NO_MORE_ITEMS
)
{
if
(
ret
!=
ERROR_NO_MORE_ITEMS
)
{
REGPROC_print_error
();
}
}
else
{
i
++
;
if
((
*
val_name_buf
)[
0
])
{
if
((
*
val_name_buf
)[
0
])
{
fputs
(
"
\"
"
,
file
);
REGPROC_export_string
(
file
,
*
val_name_buf
);
fputs
(
"
\"
="
,
file
);
...
...
@@ -1259,8 +1191,7 @@ void export_hkey(FILE *file, HKEY key,
fputs
(
"@="
,
file
);
}
switch
(
value_type
)
{
switch
(
value_type
)
{
case
REG_SZ
:
case
REG_EXPAND_SZ
:
fputs
(
"
\"
"
,
file
);
...
...
@@ -1281,15 +1212,13 @@ void export_hkey(FILE *file, HKEY key,
/* falls through */
case
REG_MULTI_SZ
:
/* falls through */
case
REG_BINARY
:
{
case
REG_BINARY
:
{
DWORD
i1
;
CHAR
*
hex_prefix
;
CHAR
buf
[
20
];
int
cur_pos
;
if
(
value_type
==
REG_BINARY
)
{
if
(
value_type
==
REG_BINARY
)
{
hex_prefix
=
"hex:"
;
}
else
{
hex_prefix
=
buf
;
...
...
@@ -1302,18 +1231,15 @@ void export_hkey(FILE *file, HKEY key,
strlen
(
*
val_name_buf
);
fputs
(
hex_prefix
,
file
);
for
(
i1
=
0
;
i1
<
val_size1
;
i1
++
)
{
for
(
i1
=
0
;
i1
<
val_size1
;
i1
++
)
{
fprintf
(
file
,
"%02x"
,
(
unsigned
int
)(
*
val_buf
)[
i1
]);
if
(
i1
+
1
<
val_size1
)
{
if
(
i1
+
1
<
val_size1
)
{
fputs
(
","
,
file
);
}
cur_pos
+=
3
;
/* wrap the line */
if
(
cur_pos
>
REG_FILE_HEX_LINE_LEN
)
{
if
(
cur_pos
>
REG_FILE_HEX_LINE_LEN
)
{
fputs
(
"
\\\n
"
,
file
);
cur_pos
=
2
;
}
...
...
@@ -1328,17 +1254,14 @@ void export_hkey(FILE *file, HKEY key,
i
=
0
;
more_data
=
TRUE
;
(
*
reg_key_name_buf
)[
curr_len
]
=
'\\'
;
while
(
more_data
)
{
while
(
more_data
)
{
DWORD
buf_len
=
*
reg_key_name_len
-
curr_len
;
ret
=
RegEnumKeyEx
(
key
,
i
,
*
reg_key_name_buf
+
curr_len
+
1
,
&
buf_len
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
!=
ERROR_SUCCESS
&&
ret
!=
ERROR_MORE_DATA
)
{
if
(
ret
!=
ERROR_SUCCESS
&&
ret
!=
ERROR_MORE_DATA
)
{
more_data
=
FALSE
;
if
(
ret
!=
ERROR_NO_MORE_ITEMS
)
{
if
(
ret
!=
ERROR_NO_MORE_ITEMS
)
{
REGPROC_print_error
();
}
}
else
{
...
...
@@ -1346,8 +1269,7 @@ void export_hkey(FILE *file, HKEY key,
i
++
;
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
,
val_name_buf
,
val_name_len
,
val_buf
,
val_size
);
RegCloseKey
(
subkey
);
...
...
@@ -1365,8 +1287,7 @@ void export_hkey(FILE *file, HKEY key,
FILE
*
REGPROC_open_export_file
(
CHAR
*
file_name
)
{
FILE
*
file
=
fopen
(
file_name
,
"w"
);
if
(
!
file
)
{
if
(
!
file
)
{
perror
(
""
);
fprintf
(
stderr
,
"%s: Can't open file
\"
%s
\"\n
"
,
getAppName
(),
file_name
);
exit
(
1
);
...
...
@@ -1402,8 +1323,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
val_buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
val_size
);
CHECK_ENOUGH_MEMORY
(
reg_key_name_buf
&&
val_name_buf
&&
val_buf
);
if
(
reg_key_name
&&
reg_key_name
[
0
])
{
if
(
reg_key_name
&&
reg_key_name
[
0
])
{
CHAR
*
branch_name
;
HKEY
key
;
...
...
@@ -1413,25 +1333,21 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
/* open the specified key */
reg_key_class
=
getRegClass
(
reg_key_name
);
if
(
reg_key_class
==
(
HKEY
)
ERROR_INVALID_PARAMETER
)
{
if
(
reg_key_class
==
(
HKEY
)
ERROR_INVALID_PARAMETER
)
{
fprintf
(
stderr
,
"%s: Incorrect registry class specification in '%s'
\n
"
,
getAppName
(),
reg_key_name
);
exit
(
1
);
}
branch_name
=
getRegKeyName
(
reg_key_name
);
CHECK_ENOUGH_MEMORY
(
branch_name
);
if
(
!
branch_name
[
0
])
{
if
(
!
branch_name
[
0
])
{
/* no branch - registry class is specified */
file
=
REGPROC_open_export_file
(
file_name
);
export_hkey
(
file
,
reg_key_class
,
&
reg_key_name_buf
,
&
reg_key_name_len
,
&
val_name_buf
,
&
val_name_len
,
&
val_buf
,
&
val_size
);
}
else
if
(
RegOpenKey
(
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
);
export_hkey
(
file
,
key
,
&
reg_key_name_buf
,
&
reg_key_name_len
,
...
...
@@ -1449,13 +1365,11 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
/* export all registry classes */
file
=
REGPROC_open_export_file
(
file_name
);
for
(
i
=
0
;
i
<
REG_CLASS_NUMBER
;
i
++
)
{
for
(
i
=
0
;
i
<
REG_CLASS_NUMBER
;
i
++
)
{
/* do not export HKEY_CLASSES_ROOT */
if
(
reg_class_keys
[
i
]
!=
HKEY_CLASSES_ROOT
&&
reg_class_keys
[
i
]
!=
HKEY_CURRENT_USER
&&
reg_class_keys
[
i
]
!=
HKEY_CURRENT_CONFIG
)
{
reg_class_keys
[
i
]
!=
HKEY_CURRENT_CONFIG
)
{
strcpy
(
reg_key_name_buf
,
reg_class_names
[
i
]);
export_hkey
(
file
,
reg_class_keys
[
i
],
&
reg_key_name_buf
,
&
reg_key_name_len
,
...
...
@@ -1465,8 +1379,7 @@ BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name)
}
}
if
(
file
)
{
if
(
file
)
{
fclose
(
file
);
}
HeapFree
(
GetProcessHeap
(),
0
,
reg_key_name
);
...
...
@@ -1501,8 +1414,7 @@ void delete_branch(HKEY key,
LONG
ret
;
long
int
i
;
if
(
RegOpenKey
(
key
,
*
reg_key_name_buf
,
&
branch_key
)
!=
ERROR_SUCCESS
)
{
if
(
RegOpenKey
(
key
,
*
reg_key_name_buf
,
&
branch_key
)
!=
ERROR_SUCCESS
)
{
REGPROC_print_error
();
}
...
...
@@ -1510,8 +1422,7 @@ void delete_branch(HKEY key,
if
(
RegQueryInfoKey
(
branch_key
,
NULL
,
NULL
,
NULL
,
&
subkeys
,
&
max_sub_key_len
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
)
!=
ERROR_SUCCESS
)
{
)
!=
ERROR_SUCCESS
)
{
REGPROC_print_error
();
}
curr_len
=
strlen
(
*
reg_key_name_buf
);
...
...
@@ -1519,16 +1430,14 @@ void delete_branch(HKEY key,
max_sub_key_len
+
curr_len
+
1
);
(
*
reg_key_name_buf
)[
curr_len
]
=
'\\'
;
for
(
i
=
subkeys
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
subkeys
-
1
;
i
>=
0
;
i
--
)
{
DWORD
buf_len
=
*
reg_key_name_len
-
curr_len
;
ret
=
RegEnumKeyEx
(
branch_key
,
i
,
*
reg_key_name_buf
+
curr_len
+
1
,
&
buf_len
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
!=
ERROR_SUCCESS
&&
ret
!=
ERROR_MORE_DATA
&&
ret
!=
ERROR_NO_MORE_ITEMS
)
{
ret
!=
ERROR_NO_MORE_ITEMS
)
{
REGPROC_print_error
();
}
else
{
delete_branch
(
key
,
reg_key_name_buf
,
reg_key_name_len
);
...
...
@@ -1557,8 +1466,7 @@ void delete_registry_key(CHAR *reg_key_name)
return
;
/* open the specified key */
reg_key_class
=
getRegClass
(
reg_key_name
);
if
(
reg_key_class
==
(
HKEY
)
ERROR_INVALID_PARAMETER
)
{
if
(
reg_key_class
==
(
HKEY
)
ERROR_INVALID_PARAMETER
)
{
fprintf
(
stderr
,
"%s: Incorrect registry class specification in '%s'
\n
"
,
getAppName
(),
reg_key_name
);
exit
(
1
);
...
...
@@ -1566,14 +1474,12 @@ void delete_registry_key(CHAR *reg_key_name)
branch_name
=
getRegKeyName
(
reg_key_name
);
CHECK_ENOUGH_MEMORY
(
branch_name
);
branch_name_len
=
strlen
(
branch_name
);
if
(
!
branch_name
[
0
])
{
if
(
!
branch_name
[
0
])
{
fprintf
(
stderr
,
"%s: Can't delete registry class '%s'
\n
"
,
getAppName
(),
reg_key_name
);
exit
(
1
);
}
if
(
RegOpenKey
(
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 */
RegCloseKey
(
branch_key
);
delete_branch
(
reg_key_class
,
&
branch_name
,
&
branch_name_len
);
...
...
programs/regedit/regproc.h
View file @
58c185ec
programs/regedit/treeview.c
View file @
58c185ec
...
...
@@ -72,7 +72,7 @@ HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, in
hKey
=
(
HKEY
)
item
.
lParam
;
item
.
mask
=
TVIF_TEXT
;
item
.
hItem
=
hItem
;
/* item.pszText = &keyPath[*pPathLen]; */
/* item.pszText = &keyPath[*pPathLen]; */
item
.
pszText
=
keyPath
;
item
.
cchTextMax
=
max
;
if
(
TreeView_GetItem
(
hwndTV
,
&
item
))
{
...
...
@@ -213,7 +213,7 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
if
(
errCode
==
ERROR_SUCCESS
)
{
TCHAR
SubName
[
MAX_NAME_LEN
];
DWORD
cSubName
=
MAX_NAME_LEN
;
/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */
/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */
while
(
RegEnumKeyEx
(
hKey
,
dwCount
,
SubName
,
&
cSubName
,
NULL
,
NULL
,
NULL
,
NULL
)
==
ERROR_SUCCESS
)
{
++
dwCount
;
}
...
...
@@ -226,7 +226,6 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
/*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */
RegCloseKey
(
hNewKey
);
}
}
else
{
}
expanding
=
FALSE
;
return
TRUE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment