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
0badf072
Commit
0badf072
authored
Nov 08, 2022
by
Sven Baars
Committed by
Alexandre Julliard
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Factor opening a subkey out of open_key().
parent
31ee0b30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
49 deletions
+74
-49
registry.c
dlls/kernelbase/registry.c
+74
-49
No files found.
dlls/kernelbase/registry.c
View file @
0badf072
...
...
@@ -221,79 +221,104 @@ static NTSTATUS create_key( HKEY *retkey, HKEY root, UNICODE_STRING name, ULONG
return
status
;
}
/* wrapper for NtOpenKeyEx to handle Wow6432 nodes */
static
NTSTATUS
open_key
(
HKEY
*
retkey
,
HKEY
root
,
UNICODE_STRING
name
,
DWORD
options
,
ACCESS_MASK
access
)
static
NTSTATUS
open_subkey
(
HKEY
*
subkey
,
HKEY
root
,
UNICODE_STRING
*
name
,
DWORD
options
,
ACCESS_MASK
access
)
{
DWORD
i
=
0
,
len
=
name
->
Length
/
sizeof
(
WCHAR
);
WCHAR
*
buffer
=
name
->
Buffer
;
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
HANDLE
subkey
;
WCHAR
*
buffer
=
name
.
Buffer
;
DWORD
i
,
len
=
name
.
Length
/
sizeof
(
WCHAR
);
*
retkey
=
NULL
;
UNICODE_STRING
str
;
NTSTATUS
status
=
0
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
root
;
attr
.
ObjectName
=
&
name
;
attr
.
ObjectName
=
&
str
;
attr
.
Attributes
=
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
!
(
is_win64
&&
(
access
&
KEY_WOW64_32KEY
)))
if
(
buffer
[
0
]
==
'\\'
)
return
STATUS_OBJECT_PATH_INVALID
;
while
(
i
<
len
&&
buffer
[
i
]
!=
'\\'
)
i
++
;
str
.
Buffer
=
name
->
Buffer
;
str
.
Length
=
i
*
sizeof
(
WCHAR
);
if
(
i
==
len
)
{
if
(
options
&
REG_OPTION_OPEN_LINK
)
attr
.
Attributes
|=
OBJ_OPENLINK
;
status
=
NtOpenKeyEx
(
(
HANDLE
*
)
retkey
,
access
,
&
attr
,
options
);
if
(
status
==
STATUS_PREDEFINED_HANDLE
)
{
*
retkey
=
get_perflib_key
(
*
retkey
);
status
=
STATUS_SUCCESS
;
}
return
status
;
}
while
(
len
)
else
{
i
=
0
;
if
(
buffer
[
0
]
==
'\\'
)
return
STATUS_OBJECT_PATH_INVALID
;
while
(
i
<
len
&&
buffer
[
i
]
!=
'\\'
)
i
++
;
i
f
(
!
(
options
&
REG_OPTION_OPEN_LINK
))
attr
.
Attributes
&=
~
OBJ_OPENLINK
;
options
&=
~
REG_OPTION_OPEN_LINK
;
}
name
.
Buffer
=
buffer
;
name
.
Length
=
i
*
sizeof
(
WCHAR
);
status
=
NtOpenKeyEx
(
(
HANDLE
*
)
subkey
,
access
,
&
attr
,
options
);
if
(
status
==
STATUS_PREDEFINED_HANDLE
)
{
*
subkey
=
get_perflib_key
(
*
subkey
);
status
=
STATUS_SUCCESS
;
}
if
(
i
==
len
)
{
if
(
options
&
REG_OPTION_OPEN_LINK
)
attr
.
Attributes
|=
OBJ_OPENLINK
;
status
=
NtOpenKeyEx
(
&
subkey
,
access
,
&
attr
,
options
);
}
else
{
if
(
!
(
options
&
REG_OPTION_OPEN_LINK
))
attr
.
Attributes
&=
~
OBJ_OPENLINK
;
status
=
NtOpenKeyEx
(
&
subkey
,
access
,
&
attr
,
options
&
~
REG_OPTION_OPEN_LINK
);
}
if
(
attr
.
RootDirectory
!=
root
)
NtClose
(
attr
.
RootDirectory
);
if
(
status
)
return
status
;
attr
.
RootDirectory
=
subkey
;
if
(
!
status
)
{
while
(
i
<
len
&&
buffer
[
i
]
==
'\\'
)
i
++
;
buffer
+=
i
;
len
-=
i
;
name
.
Buffer
=
buffer
;
name
.
Length
=
len
*
sizeof
(
WCHAR
);
if
(
!
is_wow6432node
(
&
name
))
name
->
Buffer
+=
i
;
name
->
Length
-=
i
*
sizeof
(
WCHAR
);
if
(
!
is_wow6432node
(
name
))
{
if
((
subkey
=
open_wow6432node
(
attr
.
RootDirectory
)))
HKEY
wow6432node
=
open_wow6432node
(
*
subkey
);
if
(
wow6432node
)
{
NtClose
(
attr
.
RootDirector
y
);
attr
.
RootDirectory
=
subkey
;
NtClose
(
*
subke
y
);
*
subkey
=
wow6432node
;
}
}
}
if
(
status
==
STATUS_PREDEFINED_HANDLE
)
return
status
;
}
/* wrapper for NtOpenKeyEx to handle Wow6432 nodes */
static
NTSTATUS
open_key
(
HKEY
*
retkey
,
HKEY
root
,
UNICODE_STRING
name
,
DWORD
options
,
ACCESS_MASK
access
)
{
HKEY
subkey
,
subkey_root
=
root
;
NTSTATUS
status
=
0
;
*
retkey
=
NULL
;
if
(
!
(
is_win64
&&
(
access
&
KEY_WOW64_32KEY
)))
{
attr
.
RootDirectory
=
get_perflib_key
(
attr
.
RootDirectory
);
status
=
STATUS_SUCCESS
;
OBJECT_ATTRIBUTES
attr
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
root
;
attr
.
ObjectName
=
&
name
;
attr
.
Attributes
=
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
options
&
REG_OPTION_OPEN_LINK
)
attr
.
Attributes
|=
OBJ_OPENLINK
;
status
=
NtOpenKeyEx
(
(
HANDLE
*
)
retkey
,
access
,
&
attr
,
options
);
if
(
status
==
STATUS_PREDEFINED_HANDLE
)
{
*
retkey
=
get_perflib_key
(
*
retkey
);
status
=
STATUS_SUCCESS
;
}
return
status
;
}
*
retkey
=
attr
.
RootDirectory
;
while
(
!
status
&&
name
.
Length
)
{
status
=
open_subkey
(
&
subkey
,
subkey_root
,
&
name
,
options
,
access
);
if
(
subkey_root
&&
subkey_root
!=
root
)
NtClose
(
subkey_root
);
subkey_root
=
subkey
;
}
if
(
!
status
)
*
retkey
=
subkey_root
;
return
status
;
}
...
...
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