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
62d3309a
Commit
62d3309a
authored
Dec 28, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Make RegOpenCurrentUser() return real key handles for current SID.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8fe18a16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
registry.c
dlls/advapi32/registry.c
+47
-1
registry.c
dlls/advapi32/tests/registry.c
+13
-0
No files found.
dlls/advapi32/registry.c
View file @
62d3309a
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "winerror.h"
#include "winerror.h"
#include "winternl.h"
#include "winternl.h"
#include "winuser.h"
#include "winuser.h"
#include "sddl.h"
#include "advapi32_misc.h"
#include "advapi32_misc.h"
#include "wine/unicode.h"
#include "wine/unicode.h"
...
@@ -648,6 +649,21 @@ LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
...
@@ -648,6 +649,21 @@ LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
return
RegOpenKeyExA
(
hkey
,
name
,
0
,
MAXIMUM_ALLOWED
,
retkey
);
return
RegOpenKeyExA
(
hkey
,
name
,
0
,
MAXIMUM_ALLOWED
,
retkey
);
}
}
static
WCHAR
*
get_thread_token_user_sid
(
HANDLE
token
)
{
WCHAR
*
sidstring
=
NULL
;
TOKEN_USER
*
info
;
DWORD
len
=
0
;
GetTokenInformation
(
token
,
TokenUser
,
NULL
,
0
,
&
len
);
info
=
heap_alloc
(
len
);
if
(
GetTokenInformation
(
token
,
TokenUser
,
info
,
len
,
&
len
))
ConvertSidToStringSidW
(
info
->
User
.
Sid
,
&
sidstring
);
heap_free
(
info
);
return
sidstring
;
}
/******************************************************************************
/******************************************************************************
* RegOpenCurrentUser [ADVAPI32.@]
* RegOpenCurrentUser [ADVAPI32.@]
...
@@ -671,7 +687,37 @@ LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
...
@@ -671,7 +687,37 @@ LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
*/
*/
LSTATUS
WINAPI
RegOpenCurrentUser
(
REGSAM
access
,
PHKEY
retkey
)
LSTATUS
WINAPI
RegOpenCurrentUser
(
REGSAM
access
,
PHKEY
retkey
)
{
{
return
RegOpenKeyExA
(
HKEY_CURRENT_USER
,
""
,
0
,
access
,
retkey
);
WCHAR
*
sidstring
=
NULL
;
HANDLE
threadtoken
;
LSTATUS
ret
;
/* get current user SID */
if
(
OpenThreadToken
(
GetCurrentThread
(),
TOKEN_QUERY
,
FALSE
,
&
threadtoken
))
{
sidstring
=
get_thread_token_user_sid
(
threadtoken
);
CloseHandle
(
threadtoken
);
}
if
(
!
sidstring
)
{
ImpersonateSelf
(
SecurityIdentification
);
if
(
OpenThreadToken
(
GetCurrentThread
(),
TOKEN_QUERY
,
FALSE
,
&
threadtoken
))
{
sidstring
=
get_thread_token_user_sid
(
threadtoken
);
CloseHandle
(
threadtoken
);
}
RevertToSelf
();
}
if
(
sidstring
)
{
ret
=
RegOpenKeyExW
(
HKEY_USERS
,
sidstring
,
0
,
access
,
retkey
);
LocalFree
(
sidstring
);
}
else
ret
=
RegOpenKeyExA
(
HKEY_CURRENT_USER
,
""
,
0
,
access
,
retkey
);
return
ret
;
}
}
...
...
dlls/advapi32/tests/registry.c
View file @
62d3309a
...
@@ -3278,6 +3278,18 @@ static void test_delete_key_value(void)
...
@@ -3278,6 +3278,18 @@ static void test_delete_key_value(void)
RegCloseKey
(
subkey
);
RegCloseKey
(
subkey
);
}
}
static
void
test_RegOpenCurrentUser
(
void
)
{
HKEY
key
;
LONG
ret
;
key
=
HKEY_CURRENT_USER
;
ret
=
RegOpenCurrentUser
(
KEY_READ
,
&
key
);
ok
(
!
ret
,
"got %d, error %d
\n
"
,
ret
,
GetLastError
());
ok
(
key
!=
HKEY_CURRENT_USER
,
"got %p
\n
"
,
key
);
RegCloseKey
(
key
);
}
START_TEST
(
registry
)
START_TEST
(
registry
)
{
{
/* Load pointers for functions that are not available in all Windows versions */
/* Load pointers for functions that are not available in all Windows versions */
...
@@ -3310,6 +3322,7 @@ START_TEST(registry)
...
@@ -3310,6 +3322,7 @@ START_TEST(registry)
test_deleted_key
();
test_deleted_key
();
test_delete_value
();
test_delete_value
();
test_delete_key_value
();
test_delete_key_value
();
test_RegOpenCurrentUser
();
/* cleanup */
/* cleanup */
delete_key
(
hkey_main
);
delete_key
(
hkey_main
);
...
...
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