ntdll: Simplify RtlFormatCurrentUserKeyPath using GetCurrentThreadEffectiveToken.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2016-09-01 23:52:27 +02:00 committed by Alexandre Julliard
parent b0534c12c0
commit be74d3a5d5
1 changed files with 19 additions and 28 deletions

View File

@ -911,18 +911,11 @@ NTSTATUS WINAPI NtUnloadKey(IN POBJECT_ATTRIBUTES attr)
NTSTATUS WINAPI RtlFormatCurrentUserKeyPath( IN OUT PUNICODE_STRING KeyPath) NTSTATUS WINAPI RtlFormatCurrentUserKeyPath( IN OUT PUNICODE_STRING KeyPath)
{ {
static const WCHAR pathW[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\'}; static const WCHAR pathW[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\'};
HANDLE token;
NTSTATUS status;
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]; char buffer[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD)*SID_MAX_SUB_AUTHORITIES];
DWORD len = sizeof(buffer); DWORD len = sizeof(buffer);
NTSTATUS status;
status = NtQueryInformationToken(token, TokenUser, buffer, len, &len); status = NtQueryInformationToken(GetCurrentThreadEffectiveToken(), TokenUser, buffer, len, &len);
if (status == STATUS_SUCCESS) if (status == STATUS_SUCCESS)
{ {
KeyPath->MaximumLength = 0; KeyPath->MaximumLength = 0;
@ -946,8 +939,6 @@ NTSTATUS WINAPI RtlFormatCurrentUserKeyPath( IN OUT PUNICODE_STRING KeyPath)
status = STATUS_NO_MEMORY; status = STATUS_NO_MEMORY;
} }
} }
NtClose(token);
}
return status; return status;
} }