update for HEAD-2003021201
[reactos.git] / lib / advapi32 / sec / misc.c
1 /*
2  */
3
4 #define NTOS_MODE_USER
5 #include <ntos.h>
6 #include <windows.h>
7
8
9 WINBOOL STDCALL
10 AreAllAccessesGranted(DWORD GrantedAccess,
11                       DWORD DesiredAccess)
12 {
13   return((BOOL)RtlAreAllAccessesGranted(GrantedAccess,
14                                         DesiredAccess));
15 }
16
17
18 WINBOOL STDCALL
19 AreAnyAccessesGranted(DWORD GrantedAccess,
20                       DWORD DesiredAccess)
21 {
22   return((BOOL)RtlAreAnyAccessesGranted(GrantedAccess,
23                                         DesiredAccess));
24 }
25
26
27 WINBOOL STDCALL
28 GetKernelObjectSecurity(HANDLE Handle,
29                         SECURITY_INFORMATION RequestedInformation,
30                         PSECURITY_DESCRIPTOR pSecurityDescriptor,
31                         DWORD nLength,
32                         LPDWORD lpnLengthNeeded)
33 {
34   NTSTATUS Status;
35
36   Status = NtQuerySecurityObject(Handle,
37                                  RequestedInformation,
38                                  pSecurityDescriptor,
39                                  nLength,
40                                  lpnLengthNeeded);
41   if (!NT_SUCCESS(Status))
42     {
43       SetLastError(RtlNtStatusToDosError(Status));
44       return(FALSE);
45     }
46   return(TRUE);
47 }
48
49
50 BOOL STDCALL
51 SetKernelObjectSecurity(HANDLE Handle,
52                         SECURITY_INFORMATION SecurityInformation,
53                         PSECURITY_DESCRIPTOR SecurityDescriptor)
54 {
55   NTSTATUS Status;
56
57   Status = NtSetSecurityObject(Handle,
58                                SecurityInformation,
59                                SecurityDescriptor);
60   if (!NT_SUCCESS(Status))
61     {
62       SetLastError(RtlNtStatusToDosError(Status));
63       return(FALSE);
64     }
65   return(TRUE);
66 }
67
68
69 VOID STDCALL
70 MapGenericMask(PDWORD AccessMask,
71                PGENERIC_MAPPING GenericMapping)
72 {
73   RtlMapGenericMask(AccessMask,
74                     GenericMapping);
75 }
76
77
78 WINBOOL
79 STDCALL
80 ImpersonateLoggedOnUser(HANDLE hToken)
81 {
82     return FALSE;
83 }
84
85 BOOL STDCALL
86 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
87 {
88   NTSTATUS Status;
89
90   Status = RtlImpersonateSelf(ImpersonationLevel);
91   if (!NT_SUCCESS(Status))
92     {
93       SetLastError(RtlNtStatusToDosError(Status));
94       return(FALSE);
95     }
96   return(TRUE);
97 }
98
99
100 BOOL STDCALL
101 RevertToSelf(VOID)
102 {
103   NTSTATUS Status;
104   HANDLE Token = NULL;
105
106   Status = NtSetInformationThread(NtCurrentThread(),
107                                   ThreadImpersonationToken,
108                                   &Token,
109                                   sizeof(HANDLE));
110   if (!NT_SUCCESS(Status))
111     {
112       SetLastError(RtlNtStatusToDosError(Status));
113       return(FALSE);
114     }
115   return(TRUE);
116 }
117
118 /* EOF */
119