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
a0dc4d7c
Commit
a0dc4d7c
authored
May 03, 2021
by
Hugh McMaster
Committed by
Alexandre Julliard
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Add or modify the (Default) registry value if [/v] is not specified.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
df9c11ff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
27 deletions
+24
-27
add.c
programs/reg/add.c
+9
-12
add.c
programs/reg/tests/add.c
+15
-15
No files found.
programs/reg/add.c
View file @
a0dc4d7c
...
...
@@ -154,6 +154,8 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
WCHAR
*
type
,
WCHAR
separator
,
WCHAR
*
data
,
BOOL
force
)
{
HKEY
hkey
;
DWORD
data_type
,
data_size
;
BYTE
*
reg_data
=
NULL
;
if
(
RegCreateKeyExW
(
root
,
path
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_READ
|
KEY_WRITE
,
NULL
,
&
hkey
,
NULL
))
...
...
@@ -162,12 +164,6 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
return
1
;
}
if
(
value_name
||
value_empty
||
data
)
{
DWORD
reg_type
;
DWORD
data_size
=
0
;
BYTE
*
reg_data
=
NULL
;
if
(
!
force
)
{
if
(
RegQueryValueExW
(
hkey
,
value_name
,
NULL
,
NULL
,
NULL
,
NULL
)
==
ERROR_SUCCESS
)
...
...
@@ -181,29 +177,30 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
}
}
reg_type
=
wchar_get_type
(
type
);
if
(
reg_type
==
~
0u
)
data_type
=
wchar_get_type
(
type
);
if
(
data_type
==
~
0u
)
{
RegCloseKey
(
hkey
);
output_message
(
STRING_UNSUPPORTED_TYPE
,
type
);
return
1
;
}
if
((
reg_type
==
REG_DWORD
||
reg_type
==
REG_DWORD_BIG_ENDIAN
)
&&
!
data
)
if
((
data_type
==
REG_DWORD
||
data_type
==
REG_DWORD_BIG_ENDIAN
)
&&
!
data
)
{
RegCloseKey
(
hkey
);
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
}
if
(
!
(
reg_data
=
get_regdata
(
data
,
reg
_type
,
separator
,
&
data_size
)))
if
(
!
(
reg_data
=
get_regdata
(
data
,
data
_type
,
separator
,
&
data_size
)))
{
RegCloseKey
(
hkey
);
return
1
;
}
RegSetValueExW
(
hkey
,
value_name
,
0
,
reg
_type
,
reg_data
,
data_size
);
RegSetValueExW
(
hkey
,
value_name
,
0
,
data
_type
,
reg_data
,
data_size
);
free
(
reg_data
);
}
RegCloseKey
(
hkey
);
output_message
(
STRING_SUCCESS
);
...
...
programs/reg/tests/add.c
View file @
a0dc4d7c
...
...
@@ -330,8 +330,8 @@ static void test_add(void)
open_key
(
HKEY_CURRENT_USER
,
KEY_BASE
,
KEY_WRITE
,
&
hkey
);
/* The Default value is initialized if no parameters are specified */
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
delete_value
(
hkey
,
NULL
);
/* This also occurs when specifying a registry type and passing data */
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_DWORD /d 0x5 /f"
,
&
r
);
...
...
@@ -342,7 +342,7 @@ static void test_add(void)
/* The Default value can also be overwritten as an empty string */
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
TODO_REG_TYPE
|
TODO_REG_SIZE
|
TODO_REG_DATA
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
close_key
(
hkey
);
delete_key
(
HKEY_CURRENT_USER
,
KEY_BASE
);
...
...
@@ -366,8 +366,8 @@ static void test_add(void)
/* ... but we can add it without passing [/f] to reg.exe */
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
delete_value
(
hkey
,
NULL
);
/* Test whether overwriting a registry key modifies existing keys and values */
add_key
(
hkey
,
"Subkey"
,
NULL
);
...
...
@@ -382,7 +382,7 @@ static void test_add(void)
verify_key
(
hkey
,
"Subkey"
);
verify_reg
(
hkey
,
"Test1"
,
REG_SZ
,
"Value1"
,
7
,
0
);
verify_reg
(
hkey
,
"Test2"
,
REG_DWORD
,
&
dword
,
sizeof
(
dword
),
0
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_NONE /d Test /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
...
...
@@ -406,9 +406,9 @@ static void test_reg_none(void)
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_NONE /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %d, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_NONE
,
"
\0
"
,
2
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_NONE
,
"
\0
"
,
2
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
delete_value
(
hkey
,
NULL
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /ve /t REG_NONE /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
...
...
@@ -435,7 +435,7 @@ static void test_reg_sz(void)
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_SZ /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_SZ
,
""
,
1
,
0
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /d WineTest /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
||
broken
(
r
==
REG_EXIT_FAILURE
/* WinXP */
),
...
...
@@ -513,9 +513,9 @@ static void test_reg_expand_sz(void)
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_EXPAND_SZ /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_EXPAND_SZ
,
""
,
1
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_EXPAND_SZ
,
""
,
1
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
delete_value
(
hkey
,
NULL
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /ve /t REG_EXPAND_SZ /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
...
...
@@ -556,9 +556,9 @@ static void test_reg_binary(void)
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_BINARY /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_BINARY
,
buffer
,
0
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_BINARY
,
buffer
,
0
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
delete_value
(
hkey
,
NULL
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /ve /t REG_BINARY /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
...
...
@@ -754,9 +754,9 @@ static void test_reg_multi_sz(void)
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_MULTI_SZ /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
todo_wine
verify_reg
(
hkey
,
NULL
,
REG_MULTI_SZ
,
""
,
1
,
0
);
verify_reg
(
hkey
,
NULL
,
REG_MULTI_SZ
,
""
,
1
,
0
);
todo_wine
delete_value
(
hkey
,
NULL
);
delete_value
(
hkey
,
NULL
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /ve /t REG_MULTI_SZ /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u, expected 0
\n
"
,
r
);
...
...
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