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
dd5da0ae
Commit
dd5da0ae
authored
Apr 26, 2016
by
Hugh McMaster
Committed by
Alexandre Julliard
Apr 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Support recursion when querying a registry value.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
959b9d1c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
14 deletions
+39
-14
reg.c
programs/reg/reg.c
+39
-14
No files found.
programs/reg/reg.c
View file @
dd5da0ae
...
...
@@ -655,16 +655,19 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name,
return
subkey_path
;
}
static
int
query_value
(
HKEY
key
,
WCHAR
*
value_name
,
WCHAR
*
path
)
static
int
query_value
(
HKEY
key
,
WCHAR
*
value_name
,
WCHAR
*
path
,
BOOL
recurse
)
{
LONG
rc
;
DWORD
num_subkeys
,
max_subkey_len
,
subkey_len
;
DWORD
max_data_bytes
,
data_size
;
DWORD
type
;
DWORD
type
,
path_len
,
i
;
BYTE
*
data
;
WCHAR
fmt
[]
=
{
'%'
,
'1'
,
'\n'
,
0
};
WCHAR
newlineW
[]
=
{
'\n'
,
0
};
WCHAR
*
subkey_name
,
*
subkey_path
;
HKEY
subkey
;
rc
=
RegQueryInfoKeyW
(
key
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
rc
=
RegQueryInfoKeyW
(
key
,
NULL
,
NULL
,
NULL
,
&
num_subkeys
,
&
max_subkey_len
,
NULL
,
NULL
,
NULL
,
&
max_data_bytes
,
NULL
,
NULL
);
if
(
rc
)
{
...
...
@@ -690,12 +693,44 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path)
HeapFree
(
GetProcessHeap
(),
0
,
data
);
if
(
!
recurse
)
{
if
(
rc
==
ERROR_FILE_NOT_FOUND
)
{
output_message
(
STRING_CANNOT_FIND
);
return
1
;
}
return
0
;
}
max_subkey_len
++
;
subkey_name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max_subkey_len
*
sizeof
(
WCHAR
));
if
(
!
subkey_name
)
{
ERR
(
"Failed to allocate memory for subkey_name
\n
"
);
return
1
;
}
path_len
=
strlenW
(
path
);
for
(
i
=
0
;
i
<
num_subkeys
;
i
++
)
{
subkey_len
=
max_subkey_len
;
rc
=
RegEnumKeyExW
(
key
,
i
,
subkey_name
,
&
subkey_len
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
rc
==
ERROR_SUCCESS
)
{
subkey_path
=
build_subkey_path
(
path
,
path_len
,
subkey_name
,
subkey_len
);
if
(
!
RegOpenKeyExW
(
key
,
subkey_name
,
0
,
KEY_READ
,
&
subkey
))
{
query_value
(
subkey
,
value_name
,
subkey_path
,
recurse
);
RegCloseKey
(
subkey
);
}
HeapFree
(
GetProcessHeap
(),
0
,
subkey_path
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
subkey_name
);
return
0
;
}
static
int
query_all
(
HKEY
key
,
WCHAR
*
path
,
BOOL
recurse
)
...
...
@@ -795,8 +830,6 @@ static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL
{
WCHAR
*
p
;
HKEY
root
,
key
;
static
const
WCHAR
stubW
[]
=
{
'S'
,
'T'
,
'U'
,
'B'
,
' '
,
'Q'
,
'U'
,
'E'
,
'R'
,
'Y'
,
' '
,
'-'
,
' '
,
'%'
,
'1'
,
' '
,
'%'
,
'2'
,
' '
,
'%'
,
'3'
,
'!'
,
'd'
,
'!'
,
' '
,
'%'
,
'4'
,
'!'
,
'd'
,
'!'
,
'\n'
,
0
};
int
ret
;
if
(
!
sane_path
(
key_name
))
...
...
@@ -825,15 +858,7 @@ static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL
}
if
(
value_name
||
value_empty
)
{
if
(
recurse
)
{
RegCloseKey
(
key
);
output_string
(
stubW
,
key_name
,
value_name
,
value_empty
,
recurse
);
return
1
;
}
ret
=
query_value
(
key
,
value_name
,
key_name
);
}
ret
=
query_value
(
key
,
value_name
,
key_name
,
recurse
);
else
ret
=
query_all
(
key
,
key_name
,
recurse
);
...
...
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