From 0327f84a2f9e70b416146ee97fdccb1827fe38b4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 4 Sep 2008 21:57:13 +0200 Subject: [PATCH] ntdll: Implemented NtOpenProcessTokenEx and NtOpenThreadTokenEx. --- dlls/ntdll/nt.c | 44 ++++++++++++++++++++++++++++++------------- dlls/ntdll/ntdll.spec | 16 ++++++++-------- include/winternl.h | 2 ++ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index 18b83091a5d..3ca17555dbf 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -95,22 +95,31 @@ NTSTATUS WINAPI NtOpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess, HANDLE *TokenHandle) +{ + return NtOpenProcessTokenEx( ProcessHandle, DesiredAccess, 0, TokenHandle ); +} + +/****************************************************************************** + * NtOpenProcessTokenEx [NTDLL.@] + * ZwOpenProcessTokenEx [NTDLL.@] + */ +NTSTATUS WINAPI NtOpenProcessTokenEx( HANDLE process, DWORD access, DWORD attributes, + HANDLE *handle ) { NTSTATUS ret; - TRACE("(%p,0x%08x,%p)\n", ProcessHandle,DesiredAccess, TokenHandle); + TRACE("(%p,0x%08x,0x%08x,%p)\n", process, access, attributes, handle); SERVER_START_REQ( open_token ) { - req->handle = ProcessHandle; - req->access = DesiredAccess; - req->attributes = 0; + req->handle = process; + req->access = access; + req->attributes = attributes; req->flags = 0; ret = wine_server_call( req ); - if (!ret) *TokenHandle = reply->token; + if (!ret) *handle = reply->token; } SERVER_END_REQ; - return ret; } @@ -123,21 +132,30 @@ NTSTATUS WINAPI NtOpenThreadToken( DWORD DesiredAccess, BOOLEAN OpenAsSelf, HANDLE *TokenHandle) +{ + return NtOpenThreadTokenEx( ThreadHandle, DesiredAccess, OpenAsSelf, 0, TokenHandle ); +} + +/****************************************************************************** + * NtOpenThreadTokenEx [NTDLL.@] + * ZwOpenThreadTokenEx [NTDLL.@] + */ +NTSTATUS WINAPI NtOpenThreadTokenEx( HANDLE thread, DWORD access, BOOLEAN as_self, DWORD attributes, + HANDLE *handle ) { NTSTATUS ret; - TRACE("(%p,0x%08x,0x%08x,%p)\n", - ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle); + TRACE("(%p,0x%08x,%u,0x%08x,%p)\n", thread, access, as_self, attributes, handle ); SERVER_START_REQ( open_token ) { - req->handle = ThreadHandle; - req->access = DesiredAccess; - req->attributes = 0; + req->handle = thread; + req->access = access; + req->attributes = attributes; req->flags = OPEN_TOKEN_THREAD; - if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF; + if (as_self) req->flags |= OPEN_TOKEN_AS_SELF; ret = wine_server_call( req ); - if (!ret) *TokenHandle = reply->token; + if (!ret) *handle = reply->token; } SERVER_END_REQ; diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index e18f3a37ff5..696124ed642 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -214,14 +214,14 @@ @ stdcall NtOpenMutant(ptr long ptr) @ stub NtOpenObjectAuditAlarm @ stdcall NtOpenProcess(ptr long ptr ptr) -@ stdcall NtOpenProcessToken(long long long) -# @ stub NtOpenProcessTokenEx +@ stdcall NtOpenProcessToken(long long ptr) +@ stdcall NtOpenProcessTokenEx(long long long ptr) @ stdcall NtOpenSection(ptr long ptr) @ stdcall NtOpenSemaphore(long long ptr) @ stdcall NtOpenSymbolicLinkObject (ptr long ptr) @ stdcall NtOpenThread(ptr long ptr ptr) -@ stdcall NtOpenThreadToken(long long long long) -# @ stub NtOpenThreadTokenEx +@ stdcall NtOpenThreadToken(long long long ptr) +@ stdcall NtOpenThreadTokenEx(long long long long ptr) @ stdcall NtOpenTimer(ptr long ptr) @ stub NtPlugPlayControl @ stdcall NtPowerInformation(long ptr long ptr long) @@ -1058,14 +1058,14 @@ @ stdcall ZwOpenMutant(ptr long ptr) NtOpenMutant @ stub ZwOpenObjectAuditAlarm @ stdcall ZwOpenProcess(ptr long ptr ptr) NtOpenProcess -@ stdcall ZwOpenProcessToken(long long long) NtOpenProcessToken -# @ stub ZwOpenProcessTokenEx +@ stdcall ZwOpenProcessToken(long long ptr) NtOpenProcessToken +@ stdcall ZwOpenProcessTokenEx(long long long ptr) NtOpenProcessTokenEx @ stdcall ZwOpenSection(ptr long ptr) NtOpenSection @ stdcall ZwOpenSemaphore(long long ptr) NtOpenSemaphore @ stdcall ZwOpenSymbolicLinkObject (ptr long ptr) NtOpenSymbolicLinkObject @ stdcall ZwOpenThread(ptr long ptr ptr) NtOpenThread -@ stdcall ZwOpenThreadToken(long long long long) NtOpenThreadToken -# @ stub ZwOpenThreadTokenEx +@ stdcall ZwOpenThreadToken(long long long ptr) NtOpenThreadToken +@ stdcall ZwOpenThreadTokenEx(long long long long ptr) NtOpenThreadTokenEx @ stdcall ZwOpenTimer(ptr long ptr) NtOpenTimer @ stub ZwPlugPlayControl @ stdcall ZwPowerInformation(long ptr long ptr long) NtPowerInformation diff --git a/include/winternl.h b/include/winternl.h index 71169fa236d..f254da5696e 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1942,11 +1942,13 @@ NTSYSAPI NTSTATUS WINAPI NtOpenMutant(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUT NTSYSAPI NTSTATUS WINAPI NtOpenObjectAuditAlarm(PUNICODE_STRING,PHANDLE,PUNICODE_STRING,PUNICODE_STRING,PSECURITY_DESCRIPTOR,HANDLE,ACCESS_MASK,ACCESS_MASK,PPRIVILEGE_SET,BOOLEAN,BOOLEAN,PBOOLEAN); NTSYSAPI NTSTATUS WINAPI NtOpenProcess(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*); NTSYSAPI NTSTATUS WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *); +NTSYSAPI NTSTATUS WINAPI NtOpenProcessTokenEx(HANDLE,DWORD,DWORD,HANDLE *); NTSYSAPI NTSTATUS WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtOpenSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES); NTSYSAPI NTSTATUS WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*); NTSYSAPI NTSTATUS WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *); +NTSYSAPI NTSTATUS WINAPI NtOpenThreadTokenEx(HANDLE,DWORD,BOOLEAN,DWORD,HANDLE *); NTSYSAPI NTSTATUS WINAPI NtOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*); NTSYSAPI NTSTATUS WINAPI NtPowerInformation(POWER_INFORMATION_LEVEL,PVOID,ULONG,PVOID,ULONG); NTSYSAPI NTSTATUS WINAPI NtPrivilegeCheck(HANDLE,PPRIVILEGE_SET,PBOOLEAN);