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
3f5457ac
Commit
3f5457ac
authored
Feb 26, 2016
by
Sebastian Lackner
Committed by
Alexandre Julliard
Feb 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Simplify and clean up RegDeleteTree implementation.
Signed-off-by:
Sebastian Lackner
<
sebastian@fds-team.de
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
6b7c576b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
47 deletions
+46
-47
registry.c
dlls/advapi32/registry.c
+46
-47
No files found.
dlls/advapi32/registry.c
View file @
3f5457ac
...
...
@@ -3016,91 +3016,90 @@ LSTATUS WINAPI RegDisablePredefinedCache(void)
return
ERROR_SUCCESS
;
}
/******************************************************************************
* RegDeleteTreeW [ADVAPI32.@]
*
*/
LSTATUS
WINAPI
RegDeleteTreeW
(
HKEY
hKey
,
LPCWSTR
lpszSubKey
)
LSTATUS
WINAPI
RegDeleteTreeW
(
HKEY
hkey
,
const
WCHAR
*
subkey
)
{
static
const
WCHAR
emptyW
[]
=
{
0
};
DWORD
name_size
,
max_name
,
max_subkey
;
WCHAR
*
name_buf
=
NULL
;
LONG
ret
;
DWORD
dwMaxSubkeyLen
,
dwMaxValueLen
;
DWORD
dwMaxLen
,
dwSize
;
WCHAR
szNameBuf
[
MAX_PATH
],
*
lpszName
=
szNameBuf
;
HKEY
hSubKey
=
hKey
;
TRACE
(
"(hkey=%p,%p %s)
\n
"
,
hKey
,
lpszSubKey
,
debugstr_w
(
lpszSubKey
)
);
TRACE
(
"(%p, %s)
\n
"
,
hkey
,
debugstr_w
(
subkey
)
);
if
(
lpszSubK
ey
)
if
(
subk
ey
)
{
ret
=
RegOpenKeyExW
(
hKey
,
lpszSubKey
,
0
,
KEY_READ
,
&
hSubKey
);
ret
=
RegOpenKeyExW
(
hkey
,
subkey
,
0
,
KEY_READ
,
&
hkey
);
if
(
ret
)
return
ret
;
}
/* Get highest length for keys, values */
ret
=
RegQueryInfoKeyW
(
hSubKey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
dwMaxSubkeyLen
,
NULL
,
NULL
,
&
dwMaxValueLen
,
NULL
,
NULL
,
NULL
);
if
(
ret
)
goto
cleanup
;
ret
=
RegQueryInfoKeyW
(
hkey
,
NULL
,
NULL
,
NULL
,
NULL
,
&
max_subkey
,
NULL
,
NULL
,
&
max_name
,
NULL
,
NULL
,
NULL
);
if
(
ret
)
goto
cleanup
;
dwMaxSubkeyLen
++
;
dwMaxValueLen
++
;
dwMaxLen
=
max
(
dwMaxSubkeyLen
,
dwMaxValueLen
);
if
(
dwMaxLen
>
sizeof
(
szNameBuf
)
/
sizeof
(
WCHAR
))
{
/* Name too big: alloc a buffer for it */
if
(
!
(
lpszName
=
heap_alloc
(
dwMaxLen
*
sizeof
(
WCHAR
))))
max_name
=
max
(
max_subkey
,
max_name
)
+
1
;
if
(
!
(
name_buf
=
heap_alloc
(
max_name
*
sizeof
(
WCHAR
)
)))
{
ret
=
ERROR_NOT_ENOUGH_MEMORY
;
goto
cleanup
;
}
}
/* Recursively delete
all the
subkeys */
while
(
TRUE
)
/* Recursively delete subkeys */
for
(;;
)
{
dwSize
=
dwMaxLen
;
if
(
RegEnumKeyExW
(
hSubKey
,
0
,
lpszName
,
&
dwSize
,
NULL
,
NULL
,
NULL
,
NULL
)
)
break
;
ret
=
RegDeleteTreeW
(
hSubKey
,
lpszName
);
name_size
=
max_name
;
ret
=
RegEnumKeyExW
(
hkey
,
0
,
name_buf
,
&
name_size
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
==
ERROR_NO_MORE_ITEMS
)
break
;
if
(
ret
)
goto
cleanup
;
ret
=
RegDeleteTreeW
(
hkey
,
name_buf
);
if
(
ret
)
goto
cleanup
;
}
if
(
lpszSubKey
)
ret
=
RegDeleteKeyW
(
hKey
,
lpszSubKey
);
else
while
(
TRUE
)
/* Delete the key itself */
if
(
subkey
)
{
dwSize
=
dwMaxLen
;
if
(
RegEnumValueW
(
hKey
,
0
,
lpszName
,
&
dwSize
,
NULL
,
NULL
,
NULL
,
NULL
))
break
;
ret
=
RegDeleteKeyW
(
hkey
,
emptyW
)
;
goto
cleanup
;
}
ret
=
RegDeleteValueW
(
hKey
,
lpszName
);
/* Delete values */
for
(;;)
{
name_size
=
max_name
;
ret
=
RegEnumValueW
(
hkey
,
0
,
name_buf
,
&
name_size
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
==
ERROR_NO_MORE_ITEMS
)
break
;
if
(
ret
)
goto
cleanup
;
ret
=
RegDeleteValueW
(
hkey
,
name_buf
);
if
(
ret
)
goto
cleanup
;
}
ret
=
ERROR_SUCCESS
;
cleanup:
/* Free buffer if allocated */
if
(
lpszName
!=
szNameBuf
)
heap_free
(
lpszName
);
if
(
lpszSubKey
)
RegCloseKey
(
hSubKey
);
heap_free
(
name_buf
);
if
(
subkey
)
RegCloseKey
(
hkey
);
return
ret
;
}
/******************************************************************************
* RegDeleteTreeA [ADVAPI32.@]
*
*/
LSTATUS
WINAPI
RegDeleteTreeA
(
HKEY
hKey
,
LPCSTR
lpszSubKey
)
LSTATUS
WINAPI
RegDeleteTreeA
(
HKEY
hkey
,
const
char
*
subkey
)
{
UNICODE_STRING
subkeyW
;
LONG
ret
;
UNICODE_STRING
lpszSubKeyW
;
if
(
lpszSubKey
)
RtlCreateUnicodeStringFromAsciiz
(
&
lpszSubKeyW
,
lpszSubKey
);
else
lpszSubK
eyW
.
Buffer
=
NULL
;
ret
=
RegDeleteTreeW
(
h
Key
,
lpszSubKeyW
.
Buffer
);
RtlFreeUnicodeString
(
&
lpszSubK
eyW
);
if
(
subkey
)
RtlCreateUnicodeStringFromAsciiz
(
&
subkeyW
,
subkey
);
else
subk
eyW
.
Buffer
=
NULL
;
ret
=
RegDeleteTreeW
(
h
key
,
subkeyW
.
Buffer
);
RtlFreeUnicodeString
(
&
subk
eyW
);
return
ret
;
}
...
...
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