Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
113 additions
and
125 deletions
+113
-125
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
+0
-0
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
This diff is collapsed.
Click to expand it.
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