Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
c33bd1b7
Commit
c33bd1b7
authored
Jul 11, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an SID instead of the user name for the path of the
HKEY_CURRENT_USER key (based on an old patch by Juan Lang).
parent
13621056
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
17 deletions
+57
-17
reg.c
dlls/ntdll/reg.c
+38
-11
sec.c
dlls/ntdll/sec.c
+19
-6
No files found.
dlls/ntdll/reg.c
View file @
c33bd1b7
...
...
@@ -790,21 +790,48 @@ NTSTATUS WINAPI NtUnloadKey(IN HANDLE KeyHandle)
/******************************************************************************
* RtlFormatCurrentUserKeyPath [NTDLL.@]
*
* NOTE: under NT the user name part of the path is an SID.
*/
NTSTATUS
WINAPI
RtlFormatCurrentUserKeyPath
(
IN
OUT
PUNICODE_STRING
KeyPath
)
{
static
const
WCHAR
pathW
[]
=
{
'\\'
,
'R'
,
'e'
,
'g'
,
'i'
,
's'
,
't'
,
'r'
,
'y'
,
'\\'
,
'U'
,
's'
,
'e'
,
'r'
,
'\\'
};
const
char
*
user
=
wine_get_user_name
()
;
int
len
=
ntdll_umbstowcs
(
0
,
user
,
strlen
(
user
)
+
1
,
NULL
,
0
)
;
HANDLE
token
;
NTSTATUS
status
;
KeyPath
->
MaximumLength
=
sizeof
(
pathW
)
+
len
*
sizeof
(
WCHAR
);
KeyPath
->
Length
=
KeyPath
->
MaximumLength
-
sizeof
(
WCHAR
);
if
(
!
(
KeyPath
->
Buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
KeyPath
->
MaximumLength
)))
return
STATUS_NO_MEMORY
;
memcpy
(
KeyPath
->
Buffer
,
pathW
,
sizeof
(
pathW
)
);
ntdll_umbstowcs
(
0
,
user
,
strlen
(
user
)
+
1
,
KeyPath
->
Buffer
+
sizeof
(
pathW
)
/
sizeof
(
WCHAR
),
len
);
return
STATUS_SUCCESS
;
status
=
NtOpenThreadToken
(
GetCurrentThread
(),
TOKEN_READ
,
TRUE
,
&
token
);
if
(
status
==
STATUS_NO_TOKEN
)
status
=
NtOpenProcessToken
(
GetCurrentProcess
(),
TOKEN_READ
,
&
token
);
if
(
status
==
STATUS_SUCCESS
)
{
char
buffer
[
sizeof
(
TOKEN_USER
)
+
sizeof
(
SID
)
+
sizeof
(
DWORD
)
*
SID_MAX_SUB_AUTHORITIES
];
DWORD
len
=
sizeof
(
buffer
);
status
=
NtQueryInformationToken
(
token
,
TokenUser
,
buffer
,
len
,
&
len
);
if
(
status
==
STATUS_SUCCESS
)
{
KeyPath
->
MaximumLength
=
0
;
status
=
RtlConvertSidToUnicodeString
(
KeyPath
,
((
TOKEN_USER
*
)
buffer
)
->
User
.
Sid
,
FALSE
);
if
(
status
==
STATUS_BUFFER_OVERFLOW
)
{
PWCHAR
buf
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
pathW
)
+
KeyPath
->
Length
+
sizeof
(
WCHAR
));
if
(
buf
)
{
memcpy
(
buf
,
pathW
,
sizeof
(
pathW
));
KeyPath
->
MaximumLength
=
KeyPath
->
Length
+
sizeof
(
WCHAR
);
KeyPath
->
Buffer
=
(
PWCHAR
)((
LPBYTE
)
buf
+
sizeof
(
pathW
));
status
=
RtlConvertSidToUnicodeString
(
KeyPath
,
((
TOKEN_USER
*
)
buffer
)
->
User
.
Sid
,
FALSE
);
KeyPath
->
Buffer
=
(
PWCHAR
)
buf
;
KeyPath
->
Length
+=
sizeof
(
pathW
);
KeyPath
->
MaximumLength
+=
sizeof
(
pathW
);
}
else
status
=
STATUS_NO_MEMORY
;
}
}
NtClose
(
token
);
}
return
status
;
}
/******************************************************************************
...
...
@@ -822,7 +849,7 @@ DWORD WINAPI RtlOpenCurrentUser(
UNICODE_STRING
ObjectName
;
NTSTATUS
ret
;
TRACE
(
"(0x%08lx, %p)
stub
\n
"
,
DesiredAccess
,
KeyHandle
);
TRACE
(
"(0x%08lx, %p)
\n
"
,
DesiredAccess
,
KeyHandle
);
RtlFormatCurrentUserKeyPath
(
&
ObjectName
);
InitializeObjectAttributes
(
&
ObjectAttributes
,
&
ObjectName
,
OBJ_CASE_INSENSITIVE
,
0
,
NULL
);
...
...
dlls/ntdll/sec.c
View file @
c33bd1b7
...
...
@@ -37,6 +37,7 @@
#include "ntdll_misc.h"
#include "excpt.h"
#include "wine/library.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
ntdll
);
...
...
@@ -1558,13 +1559,25 @@ NtSetSecurityObject(
*/
NTSTATUS
WINAPI
RtlConvertSidToUnicodeString
(
PUNICODE_STRING
String
,
PSID
Sid
,
PSID
p
Sid
,
BOOLEAN
AllocateString
)
{
const
char
*
user
=
wine_get_user_name
();
int
len
=
ntdll_umbstowcs
(
0
,
user
,
strlen
(
user
)
+
1
,
NULL
,
0
)
*
sizeof
(
WCHAR
);
FIXME
(
"(%p %p %u)
\n
"
,
String
,
Sid
,
AllocateString
);
static
const
WCHAR
formatW
[]
=
{
'-'
,
'%'
,
'u'
,
0
};
WCHAR
buffer
[
2
+
10
+
10
+
10
*
SID_MAX_SUB_AUTHORITIES
];
WCHAR
*
p
=
buffer
;
const
SID
*
sid
=
(
const
SID
*
)
pSid
;
DWORD
i
,
len
;
*
p
++
=
'S'
;
p
+=
sprintfW
(
p
,
formatW
,
sid
->
Revision
);
p
+=
sprintfW
(
p
,
formatW
,
MAKELONG
(
MAKEWORD
(
sid
->
IdentifierAuthority
.
Value
[
5
],
sid
->
IdentifierAuthority
.
Value
[
4
]
),
MAKEWORD
(
sid
->
IdentifierAuthority
.
Value
[
3
],
sid
->
IdentifierAuthority
.
Value
[
2
]
)));
for
(
i
=
0
;
i
<
sid
->
SubAuthorityCount
;
i
++
)
p
+=
sprintfW
(
p
,
formatW
,
sid
->
SubAuthority
[
i
]
);
len
=
(
p
+
1
-
buffer
)
*
sizeof
(
WCHAR
);
String
->
Length
=
len
-
sizeof
(
WCHAR
);
if
(
AllocateString
)
...
...
@@ -1575,7 +1588,7 @@ NTSTATUS WINAPI RtlConvertSidToUnicodeString(
}
else
if
(
len
>
String
->
MaximumLength
)
return
STATUS_BUFFER_OVERFLOW
;
ntdll_umbstowcs
(
0
,
user
,
strlen
(
user
)
+
1
,
String
->
Buffer
,
len
/
sizeof
(
WCHAR
)
);
memcpy
(
String
->
Buffer
,
buffer
,
len
);
return
STATUS_SUCCESS
;
}
...
...
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