Commit 9cb94b27 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Implement RtlImpersonateSelf, RevertToSelf and MapGenericMask.

parent 433f72f8
......@@ -1770,23 +1770,40 @@ NotifyBootConfigStatus( DWORD x1 )
/******************************************************************************
* RevertToSelf [ADVAPI32.@]
*
* Ends the impersonation of a user.
*
* PARAMS
* void []
*
* RETURNS
* Success: TRUE.
* Failure: FALSE.
*/
BOOL WINAPI
RevertToSelf( void )
{
FIXME("(), stub\n");
return TRUE;
HANDLE Token = NULL;
return set_ntstatus( NtSetInformationThread( GetCurrentThread(),
ThreadImpersonationToken, &Token, sizeof(Token) ) );
}
/******************************************************************************
* ImpersonateSelf [ADVAPI32.@]
*
* Makes an impersonation token that represents the process user and assigns
* to the current thread.
*
* PARAMS
* ImpersonationLevel [I] Level at which to impersonate.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE.
*/
BOOL WINAPI
ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
{
return RtlImpersonateSelf(ImpersonationLevel);
return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel ) );
}
/******************************************************************************
......@@ -1844,14 +1861,22 @@ BOOL WINAPI AccessCheckByType(
return !*AccessStatus;
}
/******************************************************************************
* MapGenericMask [ADVAPI32.@]
*
* Maps generic access rights into specific access rights according to the
* supplied mapping.
*
* PARAMS
* AccessMask [I/O] Access rights.
* GenericMapping [I] The mapping between generic and specific rights.
*
* RETURNS
* Nothing.
*/
VOID WINAPI MapGenericMask( PDWORD AccessMask, PGENERIC_MAPPING GenericMapping )
{
FIXME("%p %p - stub\n", AccessMask, GenericMapping);
*AccessMask |= GenericMapping->GenericRead;
*AccessMask |= GenericMapping->GenericWrite;
*AccessMask |= GenericMapping->GenericExecute;
*AccessMask |= GenericMapping->GenericAll;
RtlMapGenericMask( AccessMask, GenericMapping );
}
/*************************************************************************
......
......@@ -1365,12 +1365,55 @@ RtlAdjustPrivilege(ULONG Privilege,
/******************************************************************************
* RtlImpersonateSelf [NTDLL.@]
*
* Makes an impersonation token that represents the process user and assigns
* to the current thread.
*
* PARAMS
* ImpersonationLevel [I] Level at which to impersonate.
*
* RETURNS
* Success: STATUS_SUCCESS.
* Failure: NTSTATUS code.
*/
BOOL WINAPI
NTSTATUS WINAPI
RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
{
FIXME("(%08x), stub\n", ImpersonationLevel);
return TRUE;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE ProcessToken;
HANDLE ImpersonationToken;
TRACE("(%08x)\n", ImpersonationLevel);
Status = NtOpenProcessToken( NtCurrentProcess(), TOKEN_DUPLICATE,
&ProcessToken);
if (Status != STATUS_SUCCESS)
return Status;
InitializeObjectAttributes( &ObjectAttributes, NULL, 0, NULL, NULL );
Status = NtDuplicateToken( ProcessToken,
TOKEN_IMPERSONATE,
&ObjectAttributes,
ImpersonationLevel,
TokenImpersonation,
&ImpersonationToken );
if (Status != STATUS_SUCCESS)
{
NtClose( ProcessToken );
return Status;
}
Status = NtSetInformationThread( GetCurrentThread(),
ThreadImpersonationToken,
&ImpersonationToken,
sizeof(ImpersonationToken) );
NtClose( ImpersonationToken );
NtClose( ProcessToken );
return Status;
}
/******************************************************************************
......
......@@ -1890,7 +1890,7 @@ PVOID WINAPI RtlImageDirectoryEntryToData(HMODULE,BOOL,WORD,ULONG *);
PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE);
PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection(const IMAGE_NT_HEADERS *,HMODULE,DWORD);
PVOID WINAPI RtlImageRvaToVa(const IMAGE_NT_HEADERS *,HMODULE,DWORD,IMAGE_SECTION_HEADER **);
BOOL WINAPI RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
NTSTATUS WINAPI RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
void WINAPI RtlInitString(PSTRING,PCSZ);
void WINAPI RtlInitAnsiString(PANSI_STRING,PCSZ);
void WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment