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
97f10736
Commit
97f10736
authored
Jul 21, 2022
by
Hugh McMaster
Committed by
Alexandre Julliard
Jul 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Use 'struct edit_params' with read_value().
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
parent
becf1108
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
69 deletions
+67
-69
edit.c
programs/regedit/edit.c
+67
-69
No files found.
programs/regedit/edit.c
View file @
97f10736
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include "main.h"
#include "main.h"
static
const
WCHAR
*
editValueName
;
static
const
WCHAR
*
editValueName
;
static
WCHAR
*
stringValueData
;
static
BOOL
isDecimal
;
static
BOOL
isDecimal
;
struct
edit_params
struct
edit_params
...
@@ -267,39 +266,42 @@ static INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wP
...
@@ -267,39 +266,42 @@ static INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wP
return
FALSE
;
return
FALSE
;
}
}
static
LPWSTR
read_value
(
HWND
hwnd
,
HKEY
hKey
,
LPCWSTR
valueName
,
DWORD
*
lpType
,
LONG
*
len
)
static
BOOL
read_value
(
HWND
hwnd
,
struct
edit_params
*
params
)
{
{
DWORD
valueDataLen
;
LONG
ret
;
LPWSTR
buffer
=
NULL
;
WCHAR
*
buf
=
NULL
;
LONG
lRet
;
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
NULL
,
lpType
,
NULL
,
&
valueDataLen
);
if
((
ret
=
RegQueryValueExW
(
params
->
hkey
,
params
->
value_name
,
NULL
,
&
params
->
type
,
NULL
,
&
params
->
size
)))
if
(
lRet
)
{
{
if
(
lRet
==
ERROR_FILE_NOT_FOUND
&&
!
valueName
)
{
/* no default value here, make it up */
if
(
ret
==
ERROR_FILE_NOT_FOUND
&&
!
params
->
value_name
)
if
(
len
)
*
len
=
1
;
{
if
(
lpType
)
*
lpType
=
REG_SZ
;
params
->
type
=
REG_SZ
;
buffer
=
malloc
(
sizeof
(
WCHAR
));
params
->
size
=
sizeof
(
WCHAR
);
*
buffer
=
'\0'
;
params
->
data
=
malloc
(
params
->
size
);
return
buffer
;
*
(
WCHAR
*
)
params
->
data
=
0
;
return
TRUE
;
}
}
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
goto
done
;
}
buffer
=
malloc
(
valueDataLen
+
sizeof
(
WCHAR
));
goto
error
;
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
0
,
0
,
(
LPBYTE
)
buffer
,
&
valueDataLen
);
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
goto
done
;
}
}
if
((
valueDataLen
%
sizeof
(
WCHAR
))
==
0
)
buffer
[
valueDataLen
/
sizeof
(
WCHAR
)]
=
0
;
if
(
len
)
*
len
=
valueDataLen
;
return
buffer
;
done:
buf
=
malloc
(
params
->
size
+
sizeof
(
WCHAR
));
free
(
buffer
);
return
NULL
;
if
(
RegQueryValueExW
(
params
->
hkey
,
params
->
value_name
,
NULL
,
&
params
->
type
,
(
BYTE
*
)
buf
,
&
params
->
size
))
goto
error
;
if
(
params
->
size
%
sizeof
(
WCHAR
)
==
0
)
buf
[
params
->
size
/
sizeof
(
WCHAR
)]
=
0
;
params
->
data
=
buf
;
return
TRUE
;
error:
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
params
->
value_name
);
free
(
buf
);
params
->
data
=
NULL
;
return
FALSE
;
}
}
BOOL
CreateKey
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPWSTR
keyName
)
BOOL
CreateKey
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPWSTR
keyName
)
...
@@ -383,27 +385,24 @@ static void format_dlgproc_string(struct edit_params *params)
...
@@ -383,27 +385,24 @@ static void format_dlgproc_string(struct edit_params *params)
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPCWSTR
valueName
)
BOOL
ModifyValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPCWSTR
valueName
)
{
{
HKEY
hKey
;
DWORD
type
;
LONG
lRet
;
LONG
len
;
struct
edit_params
params
;
struct
edit_params
params
;
BOOL
result
=
FALSE
;
BOOL
result
=
FALSE
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
editValueName
=
valueName
?
valueName
:
g_pszDefaultValueName
;
if
(
lRet
)
{
if
(
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
params
.
hkey
))
{
error_code_messagebox
(
hwnd
,
IDS_SET_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_SET_VALUE_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
editValueName
=
valueName
?
valueName
:
g_pszDefaultValueName
;
if
(
!
(
stringValueData
=
read_value
(
hwnd
,
hKey
,
valueName
,
&
type
,
&
len
)))
goto
done
;
params
.
hkey
=
hKey
;
params
.
value_name
=
valueName
;
params
.
value_name
=
valueName
;
params
.
type
=
type
;
params
.
data
=
stringValueData
;
if
(
!
read_value
(
hwnd
,
&
params
))
params
.
size
=
len
;
{
RegCloseKey
(
params
.
hkey
);
return
FALSE
;
}
switch
(
params
.
type
)
switch
(
params
.
type
)
{
{
...
@@ -433,15 +432,13 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
...
@@ -433,15 +432,13 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
{
{
int
index
=
SendMessageW
(
g_pChildWnd
->
hListWnd
,
LVM_GETNEXTITEM
,
-
1
,
int
index
=
SendMessageW
(
g_pChildWnd
->
hListWnd
,
LVM_GETNEXTITEM
,
-
1
,
MAKELPARAM
(
LVNI_FOCUSED
|
LVNI_SELECTED
,
0
));
MAKELPARAM
(
LVNI_FOCUSED
|
LVNI_SELECTED
,
0
));
free
(
stringValueData
);
stringValueData
=
read_value
(
hwnd
,
hKey
,
valueName
,
&
type
,
&
len
);
read_value
(
hwnd
,
&
params
);
format_value_data
(
g_pChildWnd
->
hListWnd
,
index
,
type
,
stringValueData
,
len
);
format_value_data
(
g_pChildWnd
->
hListWnd
,
index
,
params
.
type
,
params
.
data
,
params
.
size
);
}
}
done:
free
(
params
.
data
);
free
(
stringValueData
);
RegCloseKey
(
params
.
hkey
);
stringValueData
=
NULL
;
RegCloseKey
(
hKey
);
return
result
;
return
result
;
}
}
...
@@ -564,47 +561,48 @@ done:
...
@@ -564,47 +561,48 @@ done:
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPCWSTR
oldName
,
LPCWSTR
newName
)
BOOL
RenameValue
(
HWND
hwnd
,
HKEY
hKeyRoot
,
LPCWSTR
keyPath
,
LPCWSTR
oldName
,
LPCWSTR
newName
)
{
{
LPWSTR
value
=
NULL
;
struct
edit_params
params
;
DWORD
type
;
LONG
len
,
lRet
;
BOOL
result
=
FALSE
;
BOOL
result
=
FALSE
;
HKEY
hKey
;
if
(
!
oldName
)
return
FALSE
;
if
(
!
oldName
)
return
FALSE
;
if
(
!
newName
)
return
FALSE
;
if
(
!
newName
)
return
FALSE
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
params
.
hkey
))
if
(
lRet
)
{
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
if
(
!
RegQueryValueExW
(
hKey
,
newName
,
NULL
,
NULL
,
NULL
,
NULL
))
{
if
(
!
RegQueryValueExW
(
params
.
hkey
,
newName
,
NULL
,
NULL
,
NULL
,
NULL
))
{
error_code_messagebox
(
hwnd
,
IDS_VALUE_EXISTS
,
oldName
);
error_code_messagebox
(
hwnd
,
IDS_VALUE_EXISTS
,
oldName
);
goto
done
;
goto
done
;
}
}
value
=
read_value
(
hwnd
,
hKey
,
oldName
,
&
type
,
&
len
);
if
(
!
value
)
goto
done
;
params
.
value_name
=
oldName
;
lRet
=
RegSetValueExW
(
hKey
,
newName
,
0
,
type
,
(
BYTE
*
)
value
,
len
);
if
(
!
read_value
(
hwnd
,
&
params
))
goto
done
;
if
(
lRet
)
{
if
(
RegSetValueExW
(
params
.
hkey
,
newName
,
0
,
params
.
type
,
(
BYTE
*
)
params
.
data
,
params
.
size
))
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
goto
done
;
goto
done
;
}
}
lRet
=
RegDeleteValueW
(
hKey
,
oldName
);
if
(
lRet
)
{
if
(
RegDeleteValueW
(
params
.
hkey
,
oldName
))
RegDeleteValueW
(
hKey
,
newName
);
{
RegDeleteValueW
(
params
.
hkey
,
newName
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
goto
done
;
goto
done
;
}
}
result
=
TRUE
;
result
=
TRUE
;
done:
done:
free
(
value
);
free
(
params
.
data
);
RegCloseKey
(
hK
ey
);
RegCloseKey
(
params
.
hk
ey
);
return
result
;
return
result
;
}
}
BOOL
RenameKey
(
HWND
hwnd
,
HKEY
hRootKey
,
LPCWSTR
keyPath
,
LPCWSTR
newName
)
BOOL
RenameKey
(
HWND
hwnd
,
HKEY
hRootKey
,
LPCWSTR
keyPath
,
LPCWSTR
newName
)
{
{
LPWSTR
parentPath
=
0
;
LPWSTR
parentPath
=
0
;
...
...
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