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
a6063f83
Commit
a6063f83
authored
Jul 07, 2022
by
Hugh McMaster
Committed by
Alexandre Julliard
Jul 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Replace heap_x*() functions with malloc(), realloc() and free().
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
parent
de0794a1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
163 additions
and
203 deletions
+163
-203
childwnd.c
programs/regedit/childwnd.c
+14
-15
edit.c
programs/regedit/edit.c
+17
-19
framewnd.c
programs/regedit/framewnd.c
+22
-24
hexedit.c
programs/regedit/hexedit.c
+12
-13
listview.c
programs/regedit/listview.c
+14
-16
main.c
programs/regedit/main.c
+0
-1
main.h
programs/regedit/main.h
+1
-2
regedit.c
programs/regedit/regedit.c
+7
-7
regproc.c
programs/regedit/regproc.c
+50
-78
treeview.c
programs/regedit/treeview.c
+26
-28
No files found.
programs/regedit/childwnd.c
View file @
a6063f83
...
...
@@ -25,7 +25,6 @@
#include "main.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
regedit
);
...
...
@@ -99,7 +98,7 @@ static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) {
len
+=
lstrlenW
(
pPaths
[
i
])
+
1
;
}
}
combined
=
heap_x
alloc
(
len
*
sizeof
(
WCHAR
));
combined
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
*
combined
=
'\0'
;
for
(
i
=
0
,
pos
=
0
;
i
<
nPaths
;
i
++
)
{
if
(
pPaths
[
i
]
&&
*
pPaths
[
i
])
{
...
...
@@ -122,7 +121,7 @@ static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
HKEY
hRootKey
=
NULL
;
if
(
!
hItem
)
hItem
=
(
HTREEITEM
)
SendMessageW
(
hwndTV
,
TVM_GETNEXTITEM
,
TVGN_CARET
,
0
);
heap_
free
(
GetItemPath
(
hwndTV
,
hItem
,
&
hRootKey
));
free
(
GetItemPath
(
hwndTV
,
hItem
,
&
hRootKey
));
if
(
!
bFull
&&
!
hRootKey
)
return
NULL
;
if
(
hRootKey
)
...
...
@@ -143,8 +142,8 @@ LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
parts
[
0
]
=
GetPathRoot
(
hwndTV
,
hItem
,
bFull
);
parts
[
1
]
=
GetItemPath
(
hwndTV
,
hItem
,
&
hRootKey
);
ret
=
CombinePaths
((
LPCWSTR
*
)
parts
,
2
);
heap_
free
(
parts
[
0
]);
heap_
free
(
parts
[
1
]);
free
(
parts
[
0
]);
free
(
parts
[
1
]);
return
ret
;
}
...
...
@@ -165,7 +164,7 @@ static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BO
keyPath
=
GetItemPath
(
hwndTV
,
hItem
,
&
hRootKey
);
RefreshListView
(
hwndLV
,
hRootKey
,
keyPath
,
NULL
);
heap_
free
(
keyPath
);
free
(
keyPath
);
}
UpdateStatusBar
();
}
...
...
@@ -272,7 +271,7 @@ static void set_last_key(HWND hwndTV)
value
=
GetItemFullPath
(
g_pChildWnd
->
hTreeWnd
,
selection
,
FALSE
);
RegSetValueExW
(
hkey
,
wszLastKey
,
0
,
REG_SZ
,
(
LPBYTE
)
value
,
(
lstrlenW
(
value
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
selection
!=
root
)
heap_
free
(
value
);
free
(
value
);
RegCloseKey
(
hkey
);
}
}
...
...
@@ -304,7 +303,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
WCHAR
*
path
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hRootKey
);
BOOL
res
=
RenameKey
(
hWnd
,
hRootKey
,
path
,
dispInfo
->
item
.
pszText
);
heap_
free
(
path
);
free
(
path
);
if
(
res
)
{
...
...
@@ -317,7 +316,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
path
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hRootKey
);
update_listview_path
(
path
);
heap_
free
(
path
);
free
(
path
);
UpdateStatusBar
();
}
...
...
@@ -391,9 +390,9 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
NMLISTVIEW
*
nmlv
=
(
NMLISTVIEW
*
)
lParam
;
LINE_INFO
*
info
=
(
LINE_INFO
*
)
nmlv
->
lParam
;
heap_
free
(
info
->
name
);
heap_
free
(
info
->
val
);
heap_
free
(
info
);
free
(
info
->
name
);
free
(
info
->
val
);
free
(
info
);
break
;
}
case
LVN_ENDLABELEDITW
:
...
...
@@ -412,7 +411,7 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
dispInfo
->
item
.
iItem
,
(
LPARAM
)
&
dispInfo
->
item
);
}
heap_
free
(
oldName
);
free
(
oldName
);
return
0
;
}
case
LVN_GETDISPINFOW
:
...
...
@@ -440,7 +439,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
switch
(
message
)
{
case
WM_CREATE
:
g_pChildWnd
=
heap_x
alloc
(
sizeof
(
ChildWnd
));
g_pChildWnd
=
m
alloc
(
sizeof
(
ChildWnd
));
if
(
!
g_pChildWnd
)
return
0
;
LoadStringW
(
hInst
,
IDS_REGISTRY_ROOT_NAME
,
g_pChildWnd
->
szPath
,
MAX_PATH
);
g_pChildWnd
->
nSplitPos
=
250
;
...
...
@@ -472,7 +471,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
goto
def
;
case
WM_DESTROY
:
set_last_key
(
g_pChildWnd
->
hTreeWnd
);
heap_
free
(
g_pChildWnd
);
free
(
g_pChildWnd
);
g_pChildWnd
=
NULL
;
PostQuitMessage
(
0
);
break
;
...
...
programs/regedit/edit.c
View file @
a6063f83
...
...
@@ -24,11 +24,9 @@
#include <commctrl.h>
#include <commdlg.h>
#include <cderr.h>
#include <stdlib.h>
#include <shellapi.h>
#include <shlwapi.h>
#include "wine/heap.h"
#include "main.h"
static
const
WCHAR
*
editValueName
;
...
...
@@ -120,7 +118,7 @@ static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case
IDOK
:
if
((
hwndValue
=
GetDlgItem
(
hwndDlg
,
IDC_VALUE_DATA
)))
{
len
=
GetWindowTextLengthW
(
hwndValue
);
stringValueData
=
heap_x
realloc
(
stringValueData
,
(
len
+
1
)
*
sizeof
(
WCHAR
));
stringValueData
=
realloc
(
stringValueData
,
(
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
GetWindowTextW
(
hwndValue
,
stringValueData
,
len
+
1
))
*
stringValueData
=
0
;
}
...
...
@@ -156,11 +154,11 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
case
IDOK
:
params
=
(
struct
edit_params
*
)
GetWindowLongPtrW
(
hwndDlg
,
DWLP_USER
);
size
=
SendDlgItemMessageW
(
hwndDlg
,
IDC_VALUE_DATA
,
HEM_GETDATA
,
0
,
0
);
data
=
heap_x
alloc
(
size
);
data
=
m
alloc
(
size
);
SendDlgItemMessageW
(
hwndDlg
,
IDC_VALUE_DATA
,
HEM_GETDATA
,
(
WPARAM
)
size
,
(
LPARAM
)
data
);
lRet
=
RegSetValueExW
(
params
->
hkey
,
params
->
value_name
,
0
,
params
->
type
,
data
,
size
);
heap_
free
(
data
);
free
(
data
);
if
(
lRet
==
ERROR_SUCCESS
)
EndDialog
(
hwndDlg
,
1
);
...
...
@@ -189,7 +187,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
if
(
lRet
==
ERROR_FILE_NOT_FOUND
&&
!
valueName
)
{
/* no default value here, make it up */
if
(
len
)
*
len
=
1
;
if
(
lpType
)
*
lpType
=
REG_SZ
;
buffer
=
heap_x
alloc
(
sizeof
(
WCHAR
));
buffer
=
m
alloc
(
sizeof
(
WCHAR
));
*
buffer
=
'\0'
;
return
buffer
;
}
...
...
@@ -197,7 +195,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
goto
done
;
}
buffer
=
heap_x
alloc
(
valueDataLen
+
sizeof
(
WCHAR
));
buffer
=
m
alloc
(
valueDataLen
+
sizeof
(
WCHAR
));
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
0
,
0
,
(
LPBYTE
)
buffer
,
&
valueDataLen
);
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
...
...
@@ -209,7 +207,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
return
buffer
;
done:
heap_
free
(
buffer
);
free
(
buffer
);
return
NULL
;
}
...
...
@@ -277,7 +275,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
}
}
else
if
(
type
==
REG_DWORD
)
{
DWORD
value
=
*
((
DWORD
*
)
stringValueData
);
stringValueData
=
heap_x
realloc
(
stringValueData
,
64
);
stringValueData
=
realloc
(
stringValueData
,
64
);
wsprintfW
(
stringValueData
,
L"%x"
,
value
);
if
(
DialogBoxW
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_DWORD
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
...
...
@@ -291,7 +289,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
}
}
else
if
(
type
==
REG_QWORD
)
{
UINT64
value
=
*
((
UINT64
*
)
stringValueData
);
stringValueData
=
heap_x
realloc
(
stringValueData
,
64
);
stringValueData
=
realloc
(
stringValueData
,
64
);
swprintf
(
stringValueData
,
64
,
L"%I64x"
,
value
);
if
(
DialogBoxParamW
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_DWORD
),
hwnd
,
modify_dlgproc
,
type
)
==
IDOK
)
{
...
...
@@ -310,7 +308,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
for
(
i
=
0
,
count
=
0
;
i
<
len
/
sizeof
(
WCHAR
);
i
++
)
if
(
!
stringValueData
[
i
]
&&
stringValueData
[
i
+
1
]
)
count
++
;
tmpValueData
=
heap_x
alloc
(
len
+
(
count
*
sizeof
(
WCHAR
)));
tmpValueData
=
m
alloc
(
len
+
(
count
*
sizeof
(
WCHAR
)));
for
(
i
=
0
,
j
=
0
;
i
<
len
/
sizeof
(
WCHAR
);
i
++
)
{
...
...
@@ -323,14 +321,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData
[
j
++
]
=
stringValueData
[
i
];
}
heap_
free
(
stringValueData
);
free
(
stringValueData
);
stringValueData
=
tmpValueData
;
tmpValueData
=
NULL
;
if
(
DialogBoxW
(
0
,
MAKEINTRESOURCEW
(
IDD_EDIT_MULTI_STRING
),
hwnd
,
modify_dlgproc
)
==
IDOK
)
{
len
=
lstrlenW
(
stringValueData
);
tmpValueData
=
heap_x
alloc
((
len
+
2
)
*
sizeof
(
WCHAR
));
tmpValueData
=
m
alloc
((
len
+
2
)
*
sizeof
(
WCHAR
));
for
(
i
=
0
,
j
=
0
;
i
<
len
;
i
++
)
{
...
...
@@ -346,7 +344,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData
[
j
++
]
=
0
;
tmpValueData
[
j
++
]
=
0
;
heap_
free
(
stringValueData
);
free
(
stringValueData
);
stringValueData
=
tmpValueData
;
lRet
=
RegSetValueExW
(
hKey
,
valueName
,
0
,
type
,
(
LPBYTE
)
stringValueData
,
j
*
sizeof
(
WCHAR
));
...
...
@@ -372,13 +370,13 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
{
int
index
=
SendMessageW
(
g_pChildWnd
->
hListWnd
,
LVM_GETNEXTITEM
,
-
1
,
MAKELPARAM
(
LVNI_FOCUSED
|
LVNI_SELECTED
,
0
));
heap_
free
(
stringValueData
);
free
(
stringValueData
);
stringValueData
=
read_value
(
hwnd
,
hKey
,
valueName
,
&
type
,
&
len
);
format_value_data
(
g_pChildWnd
->
hListWnd
,
index
,
type
,
stringValueData
,
len
);
}
done:
heap_
free
(
stringValueData
);
free
(
stringValueData
);
stringValueData
=
NULL
;
RegCloseKey
(
hKey
);
return
result
;
...
...
@@ -538,7 +536,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
result
=
TRUE
;
done:
heap_
free
(
value
);
free
(
value
);
RegCloseKey
(
hKey
);
return
result
;
}
...
...
@@ -562,7 +560,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
}
else
{
LPWSTR
srcSubKey_copy
;
parentPath
=
heap_x
alloc
((
lstrlenW
(
keyPath
)
+
1
)
*
sizeof
(
WCHAR
));
parentPath
=
m
alloc
((
lstrlenW
(
keyPath
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
parentPath
,
keyPath
);
srcSubKey_copy
=
wcsrchr
(
parentPath
,
'\\'
);
*
srcSubKey_copy
=
0
;
...
...
@@ -607,7 +605,7 @@ done:
RegCloseKey
(
destKey
);
if
(
parentKey
)
{
RegCloseKey
(
parentKey
);
heap_
free
(
parentPath
);
free
(
parentPath
);
}
return
result
;
}
programs/regedit/framewnd.c
View file @
a6063f83
...
...
@@ -24,12 +24,10 @@
#include <commctrl.h>
#include <commdlg.h>
#include <cderr.h>
#include <stdlib.h>
#include <shellapi.h>
#include "main.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
regedit
);
...
...
@@ -188,7 +186,7 @@ static void UpdateMenuItems(HMENU hMenu) {
EnableMenuItem
(
hMenu
,
ID_FAVORITES_REMOVEFAVORITE
,
(
GetMenuItemCount
(
hMenu
)
>
2
?
MF_ENABLED
:
MF_GRAYED
)
|
MF_BYCOMMAND
);
heap_
free
(
keyName
);
free
(
keyName
);
}
static
void
add_remove_modify_menu_items
(
HMENU
hMenu
)
...
...
@@ -227,7 +225,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
if
(
!
num_values
)
goto
exit
;
max_value_len
++
;
value_name
=
heap_x
alloc
(
max_value_len
*
sizeof
(
WCHAR
));
value_name
=
m
alloc
(
max_value_len
*
sizeof
(
WCHAR
));
if
(
hMenu
)
AppendMenuW
(
hMenu
,
MF_SEPARATOR
,
0
,
0
);
...
...
@@ -244,7 +242,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
}
}
heap_
free
(
value_name
);
free
(
value_name
);
exit:
RegCloseKey
(
hkey
);
return
i
;
...
...
@@ -303,7 +301,7 @@ void UpdateStatusBar(void)
{
LPWSTR
fullPath
=
GetItemFullPath
(
g_pChildWnd
->
hTreeWnd
,
NULL
,
TRUE
);
SendMessageW
(
hStatusBar
,
SB_SETTEXTW
,
0
,
(
LPARAM
)
fullPath
);
heap_
free
(
fullPath
);
free
(
fullPath
);
}
static
void
toggle_child
(
HWND
hWnd
,
UINT
cmd
,
HWND
hchild
)
...
...
@@ -361,12 +359,12 @@ static void ExportRegistryFile_StoreSelection(HWND hdlg, OPENFILENAMEW *pOpenFil
if
(
IsDlgButtonChecked
(
hdlg
,
IDC_EXPORT_SELECTED
))
{
INT
len
=
SendDlgItemMessageW
(
hdlg
,
IDC_EXPORT_PATH
,
WM_GETTEXTLENGTH
,
0
,
0
);
pOpenFileName
->
lCustData
=
(
LPARAM
)
heap_x
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
pOpenFileName
->
lCustData
=
(
LPARAM
)
m
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
SendDlgItemMessageW
(
hdlg
,
IDC_EXPORT_PATH
,
WM_GETTEXT
,
len
+
1
,
pOpenFileName
->
lCustData
);
}
else
{
pOpenFileName
->
lCustData
=
(
LPARAM
)
heap_x
alloc
(
sizeof
(
WCHAR
));
pOpenFileName
->
lCustData
=
(
LPARAM
)
m
alloc
(
sizeof
(
WCHAR
));
*
(
WCHAR
*
)
pOpenFileName
->
lCustData
=
0
;
}
}
...
...
@@ -395,7 +393,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
SendDlgItemMessageW
(
hdlg
,
IDC_EXPORT_PATH
,
WM_SETTEXT
,
0
,
(
LPARAM
)
path
);
if
(
path
&&
path
[
0
])
export_branch
=
TRUE
;
heap_
free
(
path
);
free
(
path
);
CheckRadioButton
(
hdlg
,
IDC_EXPORT_ALL
,
IDC_EXPORT_SELECTED
,
export_branch
?
IDC_EXPORT_SELECTED
:
IDC_EXPORT_ALL
);
break
;
}
...
...
@@ -481,7 +479,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
key_path
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
root_key
);
RefreshListView
(
g_pChildWnd
->
hListWnd
,
root_key
,
key_path
,
NULL
);
heap_
free
(
key_path
);
free
(
key_path
);
return
TRUE
;
}
...
...
@@ -724,13 +722,13 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
int
pos
=
SendMessageW
(
hwndList
,
LB_GETCURSEL
,
0
,
0
);
int
len
=
SendMessageW
(
hwndList
,
LB_GETTEXTLEN
,
pos
,
0
);
if
(
len
>
0
)
{
WCHAR
*
lpName
=
heap_x
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
WCHAR
*
lpName
=
m
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
SendMessageW
(
hwndList
,
LB_GETTEXT
,
pos
,
(
LPARAM
)
lpName
);
if
(
len
>
127
)
lpName
[
127
]
=
'\0'
;
lstrcpyW
(
favoriteName
,
lpName
);
EndDialog
(
hwndDlg
,
IDOK
);
heap_
free
(
lpName
);
free
(
lpName
);
}
return
TRUE
;
}
...
...
@@ -795,7 +793,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
else
if
(
DeleteKey
(
hWnd
,
hKeyRoot
,
keyPath
))
{
DeleteNode
(
g_pChildWnd
->
hTreeWnd
,
0
);
}
heap_
free
(
keyPath
);
free
(
keyPath
);
}
else
if
(
hWndDelete
==
g_pChildWnd
->
hListWnd
)
{
unsigned
int
num_selected
,
index
,
focus_idx
;
WCHAR
*
keyPath
;
...
...
@@ -822,10 +820,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR
*
valueName
=
GetItemText
(
g_pChildWnd
->
hListWnd
,
index
);
if
(
!
DeleteValue
(
hWnd
,
hKeyRoot
,
keyPath
,
valueName
))
{
heap_
free
(
valueName
);
free
(
valueName
);
break
;
}
heap_
free
(
valueName
);
free
(
valueName
);
SendMessageW
(
g_pChildWnd
->
hListWnd
,
LVM_DELETEITEM
,
index
,
0L
);
/* the default value item is always visible, so add it back in */
if
(
!
index
)
...
...
@@ -840,7 +838,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
index
=
SendMessageW
(
g_pChildWnd
->
hListWnd
,
LVM_GETNEXTITEM
,
-
1
,
MAKELPARAM
(
LVNI_SELECTED
,
0
));
}
heap_
free
(
keyPath
);
free
(
keyPath
);
}
else
if
(
IsChild
(
g_pChildWnd
->
hTreeWnd
,
hWndDelete
)
||
IsChild
(
g_pChildWnd
->
hListWnd
,
hWndDelete
))
{
SendMessageW
(
hWndDelete
,
WM_KEYDOWN
,
VK_DELETE
,
0
);
...
...
@@ -853,8 +851,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR
*
valueName
=
GetValueName
(
g_pChildWnd
->
hListWnd
);
WCHAR
*
keyPath
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
ModifyValue
(
hWnd
,
hKeyRoot
,
keyPath
,
valueName
);
heap_
free
(
keyPath
);
heap_
free
(
valueName
);
free
(
keyPath
);
free
(
valueName
);
break
;
}
case
ID_EDIT_FIND
:
...
...
@@ -901,7 +899,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LPWSTR
fullPath
=
GetItemFullPath
(
g_pChildWnd
->
hTreeWnd
,
NULL
,
FALSE
);
if
(
fullPath
)
{
CopyKeyName
(
hWnd
,
fullPath
);
heap_
free
(
fullPath
);
free
(
fullPath
);
}
break
;
}
...
...
@@ -913,7 +911,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if
(
InsertNode
(
g_pChildWnd
->
hTreeWnd
,
0
,
newKeyW
))
StartKeyRename
(
g_pChildWnd
->
hTreeWnd
);
}
heap_
free
(
keyPath
);
free
(
keyPath
);
}
break
;
case
ID_EDIT_NEW_STRINGVALUE
:
...
...
@@ -940,7 +938,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR
newKey
[
MAX_NEW_KEY_LEN
];
if
(
CreateValue
(
hWnd
,
hKeyRoot
,
keyPath
,
valueType
,
newKey
))
StartValueRename
(
g_pChildWnd
->
hListWnd
);
heap_
free
(
keyPath
);
free
(
keyPath
);
}
break
;
case
ID_EDIT_RENAME
:
...
...
@@ -954,7 +952,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
else
if
(
GetFocus
()
==
g_pChildWnd
->
hListWnd
)
{
StartValueRename
(
g_pChildWnd
->
hListWnd
);
}
heap_
free
(
keyPath
);
free
(
keyPath
);
break
;
}
case
ID_TREE_EXPAND_COLLAPSE
:
...
...
@@ -987,7 +985,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RegCloseKey
(
hKey
);
}
}
heap_
free
(
lpKeyPath
);
free
(
lpKeyPath
);
}
break
;
}
...
...
@@ -1008,7 +1006,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR
*
keyPath
=
GetItemPath
(
g_pChildWnd
->
hTreeWnd
,
0
,
&
hKeyRoot
);
RefreshTreeView
(
g_pChildWnd
->
hTreeWnd
);
RefreshListView
(
g_pChildWnd
->
hListWnd
,
hKeyRoot
,
keyPath
,
NULL
);
heap_
free
(
keyPath
);
free
(
keyPath
);
}
break
;
/*case ID_OPTIONS_TOOLBAR:*/
...
...
programs/regedit/hexedit.c
View file @
a6063f83
...
...
@@ -34,7 +34,6 @@
#include "winnls.h"
#include "commctrl.h"
#include "wine/heap.h"
#include "main.h"
/* spaces dividing hex and ASCII */
...
...
@@ -71,7 +70,7 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
static
LPWSTR
HexEdit_GetLineText
(
int
offset
,
BYTE
*
pData
,
LONG
cbData
,
LONG
pad
)
{
WCHAR
*
lpszLine
=
heap_x
alloc
((
6
+
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
WCHAR
));
WCHAR
*
lpszLine
=
m
alloc
((
6
+
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
WCHAR
));
LONG
i
;
wsprintfW
(
lpszLine
,
L"%04X "
,
offset
);
...
...
@@ -133,7 +132,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
TextOutW
(
hdc
,
nXStart
,
nYStart
,
lpszLine
,
lstrlenW
(
lpszLine
));
nYStart
+=
infoPtr
->
nHeight
;
heap_
free
(
lpszLine
);
free
(
lpszLine
);
}
SelectObject
(
hdc
,
hOldFont
);
...
...
@@ -172,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
if
(
!
nLineLen
)
size
.
cx
=
0
;
heap_
free
(
lpszLine
);
free
(
lpszLine
);
SetCaretPos
(
GetSystemMetrics
(
SM_CXBORDER
)
+
size
.
cx
,
...
...
@@ -224,10 +223,10 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
static
LRESULT
HexEdit_SetData
(
HEXEDIT_INFO
*
infoPtr
,
INT
cbData
,
const
BYTE
*
pData
)
{
heap_
free
(
infoPtr
->
pData
);
free
(
infoPtr
->
pData
);
infoPtr
->
cbData
=
0
;
infoPtr
->
pData
=
heap_x
alloc
(
cbData
);
infoPtr
->
pData
=
m
alloc
(
cbData
);
memcpy
(
infoPtr
->
pData
,
pData
,
cbData
);
infoPtr
->
cbData
=
cbData
;
...
...
@@ -286,7 +285,7 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
{
/* make room for another byte */
infoPtr
->
cbData
++
;
infoPtr
->
pData
=
heap_x
realloc
(
infoPtr
->
pData
,
infoPtr
->
cbData
+
1
);
infoPtr
->
pData
=
realloc
(
infoPtr
->
pData
,
infoPtr
->
cbData
+
1
);
/* move everything after caret up one byte */
memmove
(
infoPtr
->
pData
+
nCaretBytePos
+
1
,
...
...
@@ -328,9 +327,9 @@ static inline LRESULT
HexEdit_Destroy
(
HEXEDIT_INFO
*
infoPtr
)
{
HWND
hwnd
=
infoPtr
->
hwndSelf
;
heap_
free
(
infoPtr
->
pData
);
free
(
infoPtr
->
pData
);
/* free info data */
heap_
free
(
infoPtr
);
free
(
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
return
0
;
}
...
...
@@ -430,7 +429,7 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
lpcs
->
dwExStyle
|
WS_EX_CLIENTEDGE
);
/* allocate memory for info structure */
infoPtr
=
heap_x
alloc
(
sizeof
(
HEXEDIT_INFO
));
infoPtr
=
m
alloc
(
sizeof
(
HEXEDIT_INFO
));
memset
(
infoPtr
,
0
,
sizeof
(
HEXEDIT_INFO
));
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
...
...
@@ -479,15 +478,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
for
(
i
=
0
;
;
i
++
)
{
BYTE
*
pData
=
heap_x
alloc
(
i
);
BYTE
*
pData
=
m
alloc
(
i
);
WCHAR
*
lpszLine
;
SIZE
size
;
memset
(
pData
,
0
,
i
);
lpszLine
=
HexEdit_GetLineText
(
0
,
pData
,
i
,
0
);
GetTextExtentPoint32W
(
hdc
,
lpszLine
,
lstrlenW
(
lpszLine
),
&
size
);
heap_
free
(
lpszLine
);
heap_
free
(
pData
);
free
(
lpszLine
);
free
(
pData
);
if
(
size
.
cx
>
(
rcClient
.
right
-
rcClient
.
left
))
{
infoPtr
->
nBytesPerLine
=
i
-
1
;
...
...
programs/regedit/listview.c
View file @
a6063f83
...
...
@@ -22,10 +22,8 @@
#include <windows.h>
#include <winternl.h>
#include <commctrl.h>
#include <stdlib.h>
#include "main.h"
#include "wine/heap.h"
static
INT
Image_String
;
static
INT
Image_Binary
;
...
...
@@ -50,14 +48,14 @@ LPWSTR GetItemText(HWND hwndLV, UINT item)
unsigned
int
maxLen
=
128
;
if
(
item
==
0
)
return
NULL
;
/* first item is ALWAYS a default */
curStr
=
heap_x
alloc
(
maxLen
*
sizeof
(
WCHAR
));
curStr
=
m
alloc
(
maxLen
*
sizeof
(
WCHAR
));
do
{
ListView_GetItemTextW
(
hwndLV
,
item
,
0
,
curStr
,
maxLen
);
if
(
lstrlenW
(
curStr
)
<
maxLen
-
1
)
return
curStr
;
maxLen
*=
2
;
curStr
=
heap_x
realloc
(
curStr
,
maxLen
*
sizeof
(
WCHAR
));
curStr
=
realloc
(
curStr
,
maxLen
*
sizeof
(
WCHAR
));
}
while
(
TRUE
);
heap_
free
(
curStr
);
free
(
curStr
);
return
NULL
;
}
...
...
@@ -73,9 +71,9 @@ WCHAR *GetValueName(HWND hwndLV)
BOOL
update_listview_path
(
const
WCHAR
*
path
)
{
heap_
free
(
g_currentPath
);
free
(
g_currentPath
);
g_currentPath
=
heap_x
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
g_currentPath
=
m
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
g_currentPath
,
path
);
return
TRUE
;
...
...
@@ -136,12 +134,12 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz
{
unsigned
int
i
;
BYTE
*
pData
=
data
;
WCHAR
*
strBinary
=
heap_x
alloc
(
size
*
sizeof
(
WCHAR
)
*
3
+
sizeof
(
WCHAR
));
WCHAR
*
strBinary
=
m
alloc
(
size
*
sizeof
(
WCHAR
)
*
3
+
sizeof
(
WCHAR
));
for
(
i
=
0
;
i
<
size
;
i
++
)
wsprintfW
(
strBinary
+
i
*
3
,
L"%02X "
,
pData
[
i
]
);
strBinary
[
size
*
3
]
=
0
;
ListView_SetItemTextW
(
hwndLV
,
index
,
2
,
strBinary
);
heap_
free
(
strBinary
);
free
(
strBinary
);
break
;
}
}
...
...
@@ -153,20 +151,20 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR
LVITEMW
item
=
{
0
};
int
index
;
linfo
=
heap_x
alloc
(
sizeof
(
LINE_INFO
));
linfo
=
m
alloc
(
sizeof
(
LINE_INFO
));
linfo
->
dwValType
=
dwValType
;
linfo
->
val_len
=
dwCount
;
if
(
Name
)
{
linfo
->
name
=
heap_x
alloc
((
lstrlenW
(
Name
)
+
1
)
*
sizeof
(
WCHAR
));
linfo
->
name
=
m
alloc
((
lstrlenW
(
Name
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
linfo
->
name
,
Name
);
}
else
linfo
->
name
=
NULL
;
if
(
ValBuf
&&
dwCount
)
{
linfo
->
val
=
heap_x
alloc
(
dwCount
);
linfo
->
val
=
m
alloc
(
dwCount
);
memcpy
(
linfo
->
val
,
ValBuf
,
dwCount
);
}
else
linfo
->
val
=
NULL
;
...
...
@@ -411,8 +409,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
max_val_name_len
++
;
max_val_size
++
;
valName
=
heap_x
alloc
(
max_val_name_len
*
sizeof
(
WCHAR
));
valBuf
=
heap_x
alloc
(
max_val_size
);
valName
=
m
alloc
(
max_val_name_len
*
sizeof
(
WCHAR
));
valBuf
=
m
alloc
(
max_val_size
);
valSize
=
max_val_size
;
if
(
RegQueryValueExW
(
hKey
,
NULL
,
NULL
,
&
valType
,
valBuf
,
&
valSize
)
==
ERROR_FILE_NOT_FOUND
)
{
...
...
@@ -444,8 +442,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
result
=
TRUE
;
done:
heap_
free
(
valBuf
);
heap_
free
(
valName
);
free
(
valBuf
);
free
(
valName
);
SendMessageW
(
hwndLV
,
WM_SETREDRAW
,
TRUE
,
0
);
if
(
hKey
)
RegCloseKey
(
hKey
);
...
...
programs/regedit/main.c
View file @
a6063f83
...
...
@@ -21,7 +21,6 @@
#define WIN32_LEAN_AND_MEAN
/* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <fcntl.h>
#include "wine/debug.h"
...
...
programs/regedit/main.h
View file @
a6063f83
...
...
@@ -22,6 +22,7 @@
#define __MAIN_H__
#include <stdio.h>
#include <stdlib.h>
#include "resource.h"
#define STATUS_WINDOW 2001
...
...
@@ -156,8 +157,6 @@ void WINAPIV output_message(unsigned int id, ...);
void
WINAPIV
error_exit
(
unsigned
int
id
,
...);
/* regproc.c */
void
*
heap_xalloc
(
size_t
size
);
void
*
heap_xrealloc
(
void
*
buf
,
size_t
size
);
char
*
GetMultiByteString
(
const
WCHAR
*
strW
);
BOOL
import_registry_file
(
FILE
*
reg_file
);
void
delete_registry_key
(
WCHAR
*
reg_key_name
);
...
...
programs/regedit/regedit.c
View file @
a6063f83
...
...
@@ -22,8 +22,8 @@
#include <windows.h>
#include <commctrl.h>
#include <shellapi.h>
#include "wine/debug.h"
#include "wine/heap.h"
#include "main.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
regedit
);
...
...
@@ -41,12 +41,12 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
* we should call WriteFile() with OEM code page.
*/
len
=
WideCharToMultiByte
(
GetOEMCP
(),
0
,
str
,
wlen
,
NULL
,
0
,
NULL
,
NULL
);
msgA
=
heap_x
alloc
(
len
);
msgA
=
m
alloc
(
len
);
if
(
!
msgA
)
return
;
WideCharToMultiByte
(
GetOEMCP
(),
0
,
str
,
wlen
,
msgA
,
len
,
NULL
,
NULL
);
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
msgA
,
len
,
&
count
,
FALSE
);
heap_
free
(
msgA
);
free
(
msgA
);
}
}
...
...
@@ -119,13 +119,13 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
size
=
SearchPathW
(
NULL
,
filename
,
NULL
,
0
,
NULL
,
NULL
);
if
(
size
>
0
)
{
realname
=
heap_x
alloc
(
size
*
sizeof
(
WCHAR
));
realname
=
m
alloc
(
size
*
sizeof
(
WCHAR
));
size
=
SearchPathW
(
NULL
,
filename
,
NULL
,
size
,
realname
,
NULL
);
}
if
(
size
==
0
)
{
output_message
(
STRING_FILE_NOT_FOUND
,
filename
);
heap_
free
(
realname
);
free
(
realname
);
return
;
}
reg_file
=
_wfopen
(
realname
,
L"rb"
);
...
...
@@ -133,14 +133,14 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
{
_wperror
(
L"regedit"
);
output_message
(
STRING_CANNOT_OPEN_FILE
,
filename
);
heap_
free
(
realname
);
free
(
realname
);
return
;
}
}
import_registry_file
(
reg_file
);
if
(
realname
)
{
heap_
free
(
realname
);
free
(
realname
);
fclose
(
reg_file
);
}
break
;
...
...
programs/regedit/regproc.c
View file @
a6063f83
...
...
@@ -22,16 +22,12 @@
*/
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <commctrl.h>
#include <wine/debug.h>
#include <wine/heap.h>
#include "main.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
regedit
);
#include "main.h"
#define REG_VAL_BUF_SIZE 4096
...
...
@@ -40,30 +36,6 @@ static HKEY reg_class_keys[] = {
HKEY_CURRENT_CONFIG
,
HKEY_CURRENT_USER
,
HKEY_DYN_DATA
};
void
*
heap_xalloc
(
size_t
size
)
{
void
*
buf
=
heap_alloc
(
size
);
if
(
!
buf
)
{
ERR
(
"Out of memory!
\n
"
);
exit
(
1
);
}
return
buf
;
}
void
*
heap_xrealloc
(
void
*
buf
,
size_t
size
)
{
void
*
new_buf
=
heap_realloc
(
buf
,
size
);
if
(
!
new_buf
)
{
ERR
(
"Out of memory!
\n
"
);
exit
(
1
);
}
return
new_buf
;
}
/******************************************************************************
* Allocates memory and converts input from multibyte to wide chars
* Returned string must be freed by the caller
...
...
@@ -75,7 +47,7 @@ static WCHAR* GetWideString(const char* strA)
WCHAR
*
strW
;
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
strA
,
-
1
,
NULL
,
0
);
strW
=
heap_x
alloc
(
len
*
sizeof
(
WCHAR
));
strW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
strA
,
-
1
,
strW
,
len
);
return
strW
;
}
...
...
@@ -93,7 +65,7 @@ static WCHAR* GetWideStringN(const char* strA, int chars, DWORD *len)
WCHAR
*
strW
;
*
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
strA
,
chars
,
NULL
,
0
);
strW
=
heap_x
alloc
(
*
len
*
sizeof
(
WCHAR
));
strW
=
m
alloc
(
*
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
strA
,
chars
,
strW
,
*
len
);
return
strW
;
}
...
...
@@ -112,7 +84,7 @@ char* GetMultiByteString(const WCHAR* strW)
char
*
strA
;
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
strA
=
heap_x
alloc
(
len
);
strA
=
m
alloc
(
len
);
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
-
1
,
strA
,
len
,
NULL
,
NULL
);
return
strA
;
}
...
...
@@ -130,7 +102,7 @@ static char* GetMultiByteStringN(const WCHAR* strW, int chars, DWORD* len)
char
*
strA
;
*
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
chars
,
NULL
,
0
,
NULL
,
NULL
);
strA
=
heap_x
alloc
(
*
len
);
strA
=
m
alloc
(
*
len
);
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
chars
,
strA
,
*
len
,
NULL
,
NULL
);
return
strA
;
}
...
...
@@ -277,7 +249,7 @@ static BOOL convert_hex_csv_to_hex(struct parser *parser, WCHAR **str)
/* The worst case is 1 digit + 1 comma per byte */
size
=
((
lstrlenW
(
*
str
)
+
1
)
/
2
)
+
parser
->
data_size
;
parser
->
data
=
heap_x
realloc
(
parser
->
data
,
size
);
parser
->
data
=
realloc
(
parser
->
data
,
size
);
s
=
*
str
;
d
=
(
BYTE
*
)
parser
->
data
+
parser
->
data_size
;
...
...
@@ -447,7 +419,7 @@ static void close_key(struct parser *parser)
{
if
(
parser
->
hkey
)
{
heap_
free
(
parser
->
key_name
);
free
(
parser
->
key_name
);
parser
->
key_name
=
NULL
;
RegCloseKey
(
parser
->
hkey
);
...
...
@@ -476,7 +448,7 @@ static LONG open_key(struct parser *parser, WCHAR *path)
if
(
res
==
ERROR_SUCCESS
)
{
parser
->
key_name
=
heap_x
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
parser
->
key_name
=
m
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
parser
->
key_name
,
path
);
}
else
...
...
@@ -488,7 +460,7 @@ static LONG open_key(struct parser *parser, WCHAR *path)
static
void
free_parser_data
(
struct
parser
*
parser
)
{
if
(
parser
->
parse_type
==
REG_DWORD
||
parser
->
parse_type
==
REG_BINARY
)
heap_
free
(
parser
->
data
);
free
(
parser
->
data
);
parser
->
data
=
NULL
;
parser
->
data_size
=
0
;
...
...
@@ -522,7 +494,7 @@ static void prepare_hex_string_data(struct parser *parser)
parser
->
data
=
GetWideStringN
(
parser
->
data
,
parser
->
data_size
,
&
parser
->
data_size
);
parser
->
data_size
*=
sizeof
(
WCHAR
);
heap_
free
(
data
);
free
(
data
);
}
}
}
...
...
@@ -571,12 +543,12 @@ static WCHAR *header_state(struct parser *parser, WCHAR *pos)
if
(
!
parser
->
is_unicode
)
{
header
=
heap_x
alloc
((
lstrlenW
(
line
)
+
3
)
*
sizeof
(
WCHAR
));
header
=
m
alloc
((
lstrlenW
(
line
)
+
3
)
*
sizeof
(
WCHAR
));
header
[
0
]
=
parser
->
two_wchars
[
0
];
header
[
1
]
=
parser
->
two_wchars
[
1
];
lstrcpyW
(
header
+
2
,
line
);
parser
->
reg_version
=
parse_file_header
(
header
);
heap_
free
(
header
);
free
(
header
);
}
else
parser
->
reg_version
=
parse_file_header
(
line
);
...
...
@@ -708,7 +680,7 @@ static WCHAR *delete_key_state(struct parser *parser, WCHAR *pos)
/* handler for parser DEFAULT_VALUE_NAME state */
static
WCHAR
*
default_value_name_state
(
struct
parser
*
parser
,
WCHAR
*
pos
)
{
heap_
free
(
parser
->
value_name
);
free
(
parser
->
value_name
);
parser
->
value_name
=
NULL
;
set_state
(
parser
,
DATA_START
);
...
...
@@ -720,14 +692,14 @@ static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos)
{
WCHAR
*
val_name
=
pos
,
*
p
;
heap_
free
(
parser
->
value_name
);
free
(
parser
->
value_name
);
parser
->
value_name
=
NULL
;
if
(
!
REGPROC_unescape_string
(
val_name
,
&
p
))
goto
invalid
;
/* copy the value name in case we need to parse multiple lines and the buffer is overwritten */
parser
->
value_name
=
heap_x
alloc
((
lstrlenW
(
val_name
)
+
1
)
*
sizeof
(
WCHAR
));
parser
->
value_name
=
m
alloc
((
lstrlenW
(
val_name
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
parser
->
value_name
,
val_name
);
set_state
(
parser
,
DATA_START
);
...
...
@@ -838,7 +810,7 @@ static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos)
{
WCHAR
*
line
=
pos
;
parser
->
data
=
heap_x
alloc
(
sizeof
(
DWORD
));
parser
->
data
=
m
alloc
(
sizeof
(
DWORD
));
if
(
!
convert_hex_to_dword
(
line
,
parser
->
data
))
goto
invalid
;
...
...
@@ -958,14 +930,14 @@ static WCHAR *get_lineA(FILE *fp)
static
char
*
buf
,
*
next
;
char
*
line
;
heap_
free
(
lineW
);
free
(
lineW
);
if
(
!
fp
)
goto
cleanup
;
if
(
!
size
)
{
size
=
REG_VAL_BUF_SIZE
;
buf
=
heap_x
alloc
(
size
);
buf
=
m
alloc
(
size
);
*
buf
=
0
;
next
=
buf
;
}
...
...
@@ -982,7 +954,7 @@ static WCHAR *get_lineA(FILE *fp)
if
(
size
-
len
<
3
)
{
size
*=
2
;
buf
=
heap_x
realloc
(
buf
,
size
);
buf
=
realloc
(
buf
,
size
);
}
if
(
!
(
count
=
fread
(
buf
+
len
,
1
,
size
-
len
-
1
,
fp
)))
{
...
...
@@ -1004,7 +976,7 @@ static WCHAR *get_lineA(FILE *fp)
cleanup:
lineW
=
NULL
;
if
(
size
)
heap_
free
(
buf
);
if
(
size
)
free
(
buf
);
size
=
0
;
return
NULL
;
}
...
...
@@ -1020,7 +992,7 @@ static WCHAR *get_lineW(FILE *fp)
if
(
!
size
)
{
size
=
REG_VAL_BUF_SIZE
;
buf
=
heap_x
alloc
(
size
*
sizeof
(
WCHAR
));
buf
=
m
alloc
(
size
*
sizeof
(
WCHAR
));
*
buf
=
0
;
next
=
buf
;
}
...
...
@@ -1037,7 +1009,7 @@ static WCHAR *get_lineW(FILE *fp)
if
(
size
-
len
<
3
)
{
size
*=
2
;
buf
=
heap_x
realloc
(
buf
,
size
*
sizeof
(
WCHAR
));
buf
=
realloc
(
buf
,
size
*
sizeof
(
WCHAR
));
}
if
(
!
(
count
=
fread
(
buf
+
len
,
sizeof
(
WCHAR
),
size
-
len
-
1
,
fp
)))
{
...
...
@@ -1056,7 +1028,7 @@ static WCHAR *get_lineW(FILE *fp)
}
cleanup:
if
(
size
)
heap_
free
(
buf
);
if
(
size
)
free
(
buf
);
size
=
0
;
return
NULL
;
}
...
...
@@ -1099,7 +1071,7 @@ BOOL import_registry_file(FILE *reg_file)
if
(
parser
.
reg_version
==
REG_VERSION_FUZZY
||
parser
.
reg_version
==
REG_VERSION_INVALID
)
return
parser
.
reg_version
==
REG_VERSION_FUZZY
;
heap_
free
(
parser
.
value_name
);
free
(
parser
.
value_name
);
close_key
(
&
parser
);
return
TRUE
;
...
...
@@ -1140,7 +1112,7 @@ static void REGPROC_write_line(FILE *fp, const WCHAR *str, BOOL unicode)
{
char
*
strA
=
GetMultiByteString
(
str
);
fputs
(
strA
,
fp
);
heap_
free
(
strA
);
free
(
strA
);
}
}
...
...
@@ -1159,7 +1131,7 @@ static WCHAR *REGPROC_escape_string(WCHAR *str, size_t str_len, size_t *line_len
escape_count
++
;
}
buf
=
heap_x
alloc
((
str_len
+
escape_count
+
1
)
*
sizeof
(
WCHAR
));
buf
=
m
alloc
((
str_len
+
escape_count
+
1
)
*
sizeof
(
WCHAR
));
for
(
i
=
0
,
pos
=
0
;
i
<
str_len
;
i
++
,
pos
++
)
{
...
...
@@ -1203,11 +1175,11 @@ static size_t export_value_name(FILE *fp, WCHAR *name, size_t len, BOOL unicode)
if
(
name
&&
*
name
)
{
WCHAR
*
str
=
REGPROC_escape_string
(
name
,
len
,
&
line_len
);
WCHAR
*
buf
=
heap_x
alloc
((
line_len
+
4
)
*
sizeof
(
WCHAR
));
WCHAR
*
buf
=
m
alloc
((
line_len
+
4
)
*
sizeof
(
WCHAR
));
line_len
=
swprintf
(
buf
,
line_len
+
4
,
L"
\"
%s
\"
="
,
str
);
REGPROC_write_line
(
fp
,
buf
,
unicode
);
heap_
free
(
buf
);
heap_
free
(
str
);
free
(
buf
);
free
(
str
);
}
else
{
...
...
@@ -1226,14 +1198,14 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size)
if
(
size
)
len
=
size
/
sizeof
(
WCHAR
)
-
1
;
str
=
REGPROC_escape_string
(
data
,
len
,
&
line_len
);
*
buf
=
heap_x
alloc
((
line_len
+
3
)
*
sizeof
(
WCHAR
));
*
buf
=
m
alloc
((
line_len
+
3
)
*
sizeof
(
WCHAR
));
swprintf
(
*
buf
,
line_len
+
3
,
L"
\"
%s
\"
"
,
str
);
heap_
free
(
str
);
free
(
str
);
}
static
void
export_dword_data
(
WCHAR
**
buf
,
DWORD
*
data
)
{
*
buf
=
heap_x
alloc
(
15
*
sizeof
(
WCHAR
));
*
buf
=
m
alloc
(
15
*
sizeof
(
WCHAR
));
swprintf
(
*
buf
,
15
,
L"dword:%08x"
,
*
data
);
}
...
...
@@ -1249,10 +1221,10 @@ static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode)
}
else
{
WCHAR
*
buf
=
heap_x
alloc
(
15
*
sizeof
(
WCHAR
));
WCHAR
*
buf
=
m
alloc
(
15
*
sizeof
(
WCHAR
));
line_len
=
swprintf
(
buf
,
15
,
L"hex(%x):"
,
type
);
REGPROC_write_line
(
fp
,
buf
,
unicode
);
heap_
free
(
buf
);
free
(
buf
);
}
return
line_len
;
...
...
@@ -1273,7 +1245,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len,
data
=
GetMultiByteStringN
(
data
,
size
/
sizeof
(
WCHAR
),
&
size
);
num_commas
=
size
-
1
;
*
buf
=
heap_x
alloc
(
size
*
3
*
sizeof
(
WCHAR
));
*
buf
=
m
alloc
(
size
*
3
*
sizeof
(
WCHAR
));
for
(
i
=
0
,
pos
=
0
;
i
<
size
;
i
++
)
{
...
...
@@ -1328,7 +1300,7 @@ static void export_data(FILE *fp, WCHAR *value_name, DWORD value_len, DWORD type
if
(
size
||
type
==
REG_SZ
)
{
REGPROC_write_line
(
fp
,
buf
,
unicode
);
heap_
free
(
buf
);
free
(
buf
);
}
export_newline
(
fp
,
unicode
);
...
...
@@ -1338,7 +1310,7 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name,
{
WCHAR
*
subkey_path
;
subkey_path
=
heap_x
alloc
((
path_len
+
subkey_len
+
2
)
*
sizeof
(
WCHAR
));
subkey_path
=
m
alloc
((
path_len
+
subkey_len
+
2
)
*
sizeof
(
WCHAR
));
swprintf
(
subkey_path
,
path_len
+
subkey_len
+
2
,
L"%s
\\
%s"
,
path
,
subkey_name
);
return
subkey_path
;
...
...
@@ -1348,10 +1320,10 @@ static void export_key_name(FILE *fp, WCHAR *name, BOOL unicode)
{
WCHAR
*
buf
;
buf
=
heap_x
alloc
((
lstrlenW
(
name
)
+
7
)
*
sizeof
(
WCHAR
));
buf
=
m
alloc
((
lstrlenW
(
name
)
+
7
)
*
sizeof
(
WCHAR
));
swprintf
(
buf
,
lstrlenW
(
name
)
+
7
,
L"
\r\n
[%s]
\r\n
"
,
name
);
REGPROC_write_line
(
fp
,
buf
,
unicode
);
heap_
free
(
buf
);
free
(
buf
);
}
#define MAX_SUBKEY_LEN 257
...
...
@@ -1369,8 +1341,8 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
export_key_name
(
fp
,
path
,
unicode
);
value_name
=
heap_x
alloc
(
max_value_len
*
sizeof
(
WCHAR
));
data
=
heap_x
alloc
(
max_data_bytes
);
value_name
=
m
alloc
(
max_value_len
*
sizeof
(
WCHAR
));
data
=
m
alloc
(
max_data_bytes
);
i
=
0
;
for
(;;)
...
...
@@ -1388,21 +1360,21 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
if
(
data_size
>
max_data_bytes
)
{
max_data_bytes
=
data_size
;
data
=
heap_x
realloc
(
data
,
max_data_bytes
);
data
=
realloc
(
data
,
max_data_bytes
);
}
else
{
max_value_len
*=
2
;
value_name
=
heap_x
realloc
(
value_name
,
max_value_len
*
sizeof
(
WCHAR
));
value_name
=
realloc
(
value_name
,
max_value_len
*
sizeof
(
WCHAR
));
}
}
else
break
;
}
heap_
free
(
data
);
heap_
free
(
value_name
);
free
(
data
);
free
(
value_name
);
subkey_name
=
heap_x
alloc
(
MAX_SUBKEY_LEN
*
sizeof
(
WCHAR
));
subkey_name
=
m
alloc
(
MAX_SUBKEY_LEN
*
sizeof
(
WCHAR
));
path_len
=
lstrlenW
(
path
);
...
...
@@ -1419,13 +1391,13 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
export_registry_data
(
fp
,
subkey
,
subkey_path
,
unicode
);
RegCloseKey
(
subkey
);
}
heap_
free
(
subkey_path
);
free
(
subkey_path
);
i
++
;
}
else
break
;
}
heap_
free
(
subkey_name
);
free
(
subkey_name
);
return
0
;
}
...
...
@@ -1516,12 +1488,12 @@ static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL unicode)
return
FALSE
;
}
class_name
=
heap_x
alloc
((
lstrlenW
(
reg_class_namesW
[
i
])
+
1
)
*
sizeof
(
WCHAR
));
class_name
=
m
alloc
((
lstrlenW
(
reg_class_namesW
[
i
])
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
class_name
,
reg_class_namesW
[
i
]);
export_registry_data
(
fp
,
classes
[
i
],
class_name
,
unicode
);
heap_
free
(
class_name
);
free
(
class_name
);
RegCloseKey
(
key
);
}
...
...
programs/regedit/treeview.c
View file @
a6063f83
...
...
@@ -25,12 +25,10 @@
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <wine/debug.h>
#include <shlwapi.h>
#include "wine/heap.h"
#include "main.h"
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL
(
regedit
);
...
...
@@ -82,7 +80,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKe
}
*
pMaxChars
*=
2
;
*
pKeyPath
=
heap_x
realloc
(
*
pKeyPath
,
*
pMaxChars
);
*
pKeyPath
=
realloc
(
*
pKeyPath
,
*
pMaxChars
);
}
while
(
TRUE
);
return
TRUE
;
...
...
@@ -98,7 +96,7 @@ LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
if
(
!
hItem
)
return
NULL
;
}
pathBuffer
=
heap_x
alloc
(
maxLen
*
sizeof
(
WCHAR
));
pathBuffer
=
m
alloc
(
maxLen
*
sizeof
(
WCHAR
));
if
(
!
pathBuffer
)
return
NULL
;
*
pathBuffer
=
0
;
if
(
!
get_item_path
(
hwndTV
,
hItem
,
phRootKey
,
&
pathBuffer
,
&
pathLen
,
&
maxLen
))
return
NULL
;
...
...
@@ -117,7 +115,7 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
return
NULL
;
len
=
lpPos
+
1
-
(
*
lplpKeyName
);
lpResult
=
heap_x
alloc
(
len
*
sizeof
(
WCHAR
));
lpResult
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
lstrcpynW
(
lpResult
,
*
lplpKeyName
,
len
);
*
lplpKeyName
=
*
lpPos
?
lpPos
+
1
:
NULL
;
...
...
@@ -152,7 +150,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
SendMessageW
(
hwndTV
,
TVM_EXPAND
,
TVE_EXPAND
,
(
LPARAM
)
hItem
);
if
(
!
lpKeyName
)
{
heap_
free
(
lpItemName
);
free
(
lpItemName
);
return
hItem
;
}
hOldItem
=
hItem
;
...
...
@@ -161,7 +159,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
}
hItem
=
(
HTREEITEM
)
SendMessageW
(
hwndTV
,
TVM_GETNEXTITEM
,
TVGN_NEXT
,
(
LPARAM
)
hItem
);
}
heap_
free
(
lpItemName
);
free
(
lpItemName
);
if
(
!
hItem
)
return
valid_path
?
hOldItem
:
hRoot
;
}
...
...
@@ -236,17 +234,17 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
return
FALSE
;
if
(
RegOpenKeyExW
(
hRoot
,
KeyPath
,
0
,
KEY_READ
,
&
hKey
)
!=
ERROR_SUCCESS
)
{
heap_
free
(
KeyPath
);
free
(
KeyPath
);
return
FALSE
;
}
heap_
free
(
KeyPath
);
free
(
KeyPath
);
if
(
ERROR_SUCCESS
!=
RegQueryInfoKeyW
(
hKey
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
&
lenNameMax
,
&
lenValueMax
,
NULL
,
NULL
))
return
FALSE
;
lenName
=
++
lenNameMax
;
valName
=
heap_x
alloc
(
lenName
*
sizeof
(
WCHAR
));
valName
=
m
alloc
(
lenName
*
sizeof
(
WCHAR
));
adjust
=
0
;
...
...
@@ -267,8 +265,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
if
(
mode
&
SEARCH_VALUES
)
{
if
(
match_string
(
valName
,
sstring
,
mode
))
{
heap_
free
(
valName
);
heap_
free
(
buffer
);
free
(
valName
);
free
(
buffer
);
RegCloseKey
(
hKey
);
*
row
=
i
+
adjust
;
return
TRUE
;
...
...
@@ -277,15 +275,15 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
if
((
mode
&
SEARCH_CONTENT
)
&&
(
type
==
REG_EXPAND_SZ
||
type
==
REG_SZ
))
{
if
(
!
buffer
)
buffer
=
heap_x
alloc
(
lenValueMax
);
buffer
=
m
alloc
(
lenValueMax
);
lenName
=
lenNameMax
;
lenValue
=
lenValueMax
;
if
(
ERROR_SUCCESS
!=
RegEnumValueW
(
hKey
,
i
,
valName
,
&
lenName
,
NULL
,
&
type
,
(
LPBYTE
)
buffer
,
&
lenValue
))
break
;
if
(
match_string
(
buffer
,
sstring
,
mode
))
{
heap_
free
(
valName
);
heap_
free
(
buffer
);
free
(
valName
);
free
(
buffer
);
RegCloseKey
(
hKey
);
*
row
=
i
+
adjust
;
return
TRUE
;
...
...
@@ -294,8 +292,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
i
++
;
}
heap_
free
(
valName
);
heap_
free
(
buffer
);
free
(
valName
);
free
(
buffer
);
RegCloseKey
(
hKey
);
}
return
FALSE
;
...
...
@@ -371,7 +369,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
}
else
{
hKey
=
hRoot
;
}
heap_
free
(
KeyPath
);
free
(
KeyPath
);
if
(
RegQueryInfoKeyW
(
hKey
,
0
,
0
,
0
,
&
dwCount
,
&
dwMaxSubKeyLen
,
0
,
0
,
0
,
0
,
0
,
0
)
!=
ERROR_SUCCESS
)
{
return
FALSE
;
...
...
@@ -392,10 +390,10 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
}
dwMaxSubKeyLen
++
;
/* account for the \0 terminator */
Name
=
heap_x
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
Name
=
m
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
tvItem
.
cchTextMax
=
dwMaxSubKeyLen
;
tvItem
.
pszText
=
heap_x
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
tvItem
.
pszText
=
m
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
/* Now go through all the children in the registry, and check if any have to be added. */
for
(
dwIndex
=
0
;
dwIndex
<
dwCount
;
dwIndex
++
)
{
...
...
@@ -422,8 +420,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
tvItem
.
mask
=
TVIF_TEXT
;
tvItem
.
hItem
=
childItem
;
if
(
!
TreeView_GetItemW
(
hwndTV
,
&
tvItem
))
{
heap_
free
(
Name
);
heap_
free
(
tvItem
.
pszText
);
free
(
Name
);
free
(
tvItem
.
pszText
);
return
FALSE
;
}
...
...
@@ -438,8 +436,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
AddEntryToTree
(
hwndTV
,
hItem
,
Name
,
NULL
,
dwSubCount
);
}
}
heap_
free
(
Name
);
heap_
free
(
tvItem
.
pszText
);
free
(
Name
);
free
(
tvItem
.
pszText
);
RegCloseKey
(
hKey
);
/* Now go through all the children in the tree, and check if any have to be removed. */
...
...
@@ -647,7 +645,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
errCode
=
RegQueryInfoKeyW
(
hNewKey
,
0
,
0
,
0
,
&
dwCount
,
&
dwMaxSubKeyLen
,
0
,
0
,
0
,
0
,
0
,
0
);
if
(
errCode
!=
ERROR_SUCCESS
)
goto
done
;
dwMaxSubKeyLen
++
;
/* account for the \0 terminator */
Name
=
heap_x
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
Name
=
m
alloc
(
dwMaxSubKeyLen
*
sizeof
(
WCHAR
));
for
(
dwIndex
=
0
;
dwIndex
<
dwCount
;
dwIndex
++
)
{
DWORD
cName
=
dwMaxSubKeyLen
,
dwSubCount
;
...
...
@@ -663,7 +661,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
AddEntryToTree
(
hwndTV
,
hItem
,
Name
,
NULL
,
dwSubCount
);
}
RegCloseKey
(
hNewKey
);
heap_
free
(
Name
);
free
(
Name
);
done:
item
.
mask
=
TVIF_STATE
;
...
...
@@ -674,7 +672,7 @@ done:
SendMessageW
(
hwndTV
,
WM_SETREDRAW
,
TRUE
,
0
);
SetCursor
(
hcursorOld
);
expanding
=
FALSE
;
heap_
free
(
keyPath
);
free
(
keyPath
);
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