mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Implemented RtlImpersonateSelf().
svn path=/trunk/; revision=2388
This commit is contained in:
parent
d1d89cd409
commit
396df5ce12
5 changed files with 78 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.31 2001/06/24 17:58:13 phreak Exp $
|
/* $Id: rtl.h,v 1.32 2001/11/21 22:27:26 ekohl Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -465,6 +465,12 @@ RtlIsValidIndexHandle (
|
||||||
IN ULONG Index
|
IN ULONG Index
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
RtlImpersonateSelf (
|
||||||
|
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
|
||||||
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlpNtCreateKey (
|
RtlpNtCreateKey (
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.def,v 1.80 2001/11/03 16:48:06 chorns Exp $
|
; $Id: ntdll.def,v 1.81 2001/11/21 22:31:18 ekohl Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -434,7 +434,7 @@ RtlImageDirectoryEntryToData@16
|
||||||
RtlImageNtHeader@4
|
RtlImageNtHeader@4
|
||||||
RtlImageRvaToSection@12
|
RtlImageRvaToSection@12
|
||||||
RtlImageRvaToVa@16
|
RtlImageRvaToVa@16
|
||||||
;RtlImpersonateSelf
|
RtlImpersonateSelf@4
|
||||||
RtlInitAnsiString@8
|
RtlInitAnsiString@8
|
||||||
;RtlInitCodePageTable
|
;RtlInitCodePageTable
|
||||||
;RtlInitNlsTables
|
;RtlInitNlsTables
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.edf,v 1.69 2001/11/03 16:48:06 chorns Exp $
|
; $Id: ntdll.edf,v 1.70 2001/11/21 22:31:18 ekohl Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -433,7 +433,7 @@ RtlImageDirectoryEntryToData=RtlImageDirectoryEntryToData@16
|
||||||
RtlImageNtHeader=RtlImageNtHeader@4
|
RtlImageNtHeader=RtlImageNtHeader@4
|
||||||
RtlImageRvaToSection=RtlImageRvaToSection@12
|
RtlImageRvaToSection=RtlImageRvaToSection@12
|
||||||
RtlImageRvaToVa=RtlImageRvaToVa@16
|
RtlImageRvaToVa=RtlImageRvaToVa@16
|
||||||
;RtlImpersonateSelf
|
RtlImpersonateSelf=RtlImpersonateSelf@4
|
||||||
RtlInitAnsiString=RtlInitAnsiString@8
|
RtlInitAnsiString=RtlInitAnsiString@8
|
||||||
;RtlInitCodePageTable
|
;RtlInitCodePageTable
|
||||||
;RtlInitNlsTables
|
;RtlInitNlsTables
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.67 2001/11/03 16:48:05 chorns Exp $
|
# $Id: makefile,v 1.68 2001/11/21 22:30:57 ekohl Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
|
||||||
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
|
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
|
||||||
rtl/registry.o rtl/exception.o rtl/intrlck.o rtl/resource.o \
|
rtl/registry.o rtl/exception.o rtl/intrlck.o rtl/resource.o \
|
||||||
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o \
|
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o \
|
||||||
rtl/propvar.o
|
rtl/propvar.o rtl/security.o
|
||||||
|
|
||||||
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
|
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
|
||||||
|
|
||||||
|
|
65
reactos/lib/ntdll/rtl/security.c
Normal file
65
reactos/lib/ntdll/rtl/security.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/* $Id: security.c,v 1.4 2001/11/21 22:30:45 ekohl Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: lib/ntdll/rtl/security.c
|
||||||
|
* PURPOSE: Miscellaneous securitiy related functions
|
||||||
|
* PROGRAMMER: Eric Kohl
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* 21/11/2001 Created
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
SECURITY_QUALITY_OF_SERVICE SecQos;
|
||||||
|
HANDLE ProcessToken;
|
||||||
|
HANDLE ImpersonationToken;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtOpenProcessToken(NtCurrentProcess(),
|
||||||
|
TOKEN_DUPLICATE,
|
||||||
|
&ProcessToken);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return(Status);
|
||||||
|
|
||||||
|
SecQos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
|
||||||
|
SecQos.ImpersonationLevel = ImpersonationLevel;
|
||||||
|
SecQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
|
||||||
|
SecQos.EffectiveOnly = FALSE;
|
||||||
|
|
||||||
|
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
ObjectAttributes.RootDirectory = 0;
|
||||||
|
ObjectAttributes.ObjectName = NULL;
|
||||||
|
ObjectAttributes.Attributes = 0;
|
||||||
|
ObjectAttributes.SecurityDescriptor = NULL;
|
||||||
|
ObjectAttributes.SecurityQualityOfService = &SecQos;
|
||||||
|
|
||||||
|
Status = NtDuplicateToken(ProcessToken,
|
||||||
|
TOKEN_IMPERSONATE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
NULL,
|
||||||
|
TokenImpersonation,
|
||||||
|
&ImpersonationToken);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
NtClose(ProcessToken);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtSetInformationThread(NtCurrentThread(),
|
||||||
|
ThreadImpersonationToken,
|
||||||
|
&ImpersonationToken,
|
||||||
|
sizeof(HANDLE));
|
||||||
|
NtClose(ImpersonationToken);
|
||||||
|
NtClose(ProcessToken);
|
||||||
|
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
Loading…
Reference in a new issue