2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/advapi32/sec/sec.c
5 * PURPOSE: Registry functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
11 #define NTOS_MODE_USER
18 GetSecurityDescriptorControl (
19 PSECURITY_DESCRIPTOR pSecurityDescriptor,
20 PSECURITY_DESCRIPTOR_CONTROL pControl,
26 Status = RtlGetControlSecurityDescriptor (pSecurityDescriptor,
28 (PULONG)lpdwRevision);
29 if (!NT_SUCCESS(Status))
31 SetLastError (RtlNtStatusToDosError (Status));
41 GetSecurityDescriptorDacl (
42 PSECURITY_DESCRIPTOR pSecurityDescriptor,
43 LPBOOL lpbDaclPresent,
45 LPBOOL lpbDaclDefaulted
49 BOOLEAN DaclDefaulted;
52 Status = RtlGetDaclSecurityDescriptor (pSecurityDescriptor,
56 *lpbDaclPresent = (BOOL)DaclPresent;
57 *lpbDaclDefaulted = (BOOL)DaclDefaulted;
59 if (!NT_SUCCESS(Status))
61 SetLastError (RtlNtStatusToDosError (Status));
71 GetSecurityDescriptorGroup (
72 PSECURITY_DESCRIPTOR pSecurityDescriptor,
74 LPBOOL lpbGroupDefaulted
77 BOOLEAN GroupDefaulted;
80 Status = RtlGetGroupSecurityDescriptor (pSecurityDescriptor,
83 *lpbGroupDefaulted = (BOOL)GroupDefaulted;
85 if (!NT_SUCCESS(Status))
87 SetLastError (RtlNtStatusToDosError (Status));
97 GetSecurityDescriptorLength (
98 PSECURITY_DESCRIPTOR pSecurityDescriptor
101 return RtlLengthSecurityDescriptor(pSecurityDescriptor);
107 GetSecurityDescriptorOwner (
108 PSECURITY_DESCRIPTOR pSecurityDescriptor,
110 LPBOOL lpbOwnerDefaulted
113 BOOLEAN OwnerDefaulted;
116 Status = RtlGetOwnerSecurityDescriptor (pSecurityDescriptor,
119 *lpbOwnerDefaulted = (BOOL)OwnerDefaulted;
121 if (!NT_SUCCESS(Status))
123 SetLastError (RtlNtStatusToDosError (Status));
133 GetSecurityDescriptorSacl (
134 PSECURITY_DESCRIPTOR pSecurityDescriptor,
135 LPBOOL lpbSaclPresent,
137 LPBOOL lpbSaclDefaulted
141 BOOLEAN SaclDefaulted;
144 Status = RtlGetSaclSecurityDescriptor (pSecurityDescriptor,
148 *lpbSaclPresent = (BOOL)SaclPresent;
149 *lpbSaclDefaulted = (BOOL)SaclDefaulted;
151 if (!NT_SUCCESS(Status))
153 SetLastError (RtlNtStatusToDosError (Status));
163 InitializeSecurityDescriptor (
164 PSECURITY_DESCRIPTOR pSecurityDescriptor,
170 Status = RtlCreateSecurityDescriptor (pSecurityDescriptor,
172 if (!NT_SUCCESS(Status))
174 SetLastError (RtlNtStatusToDosError (Status));
183 IsValidSecurityDescriptor (
184 PSECURITY_DESCRIPTOR pSecurityDescriptor
189 Result = RtlValidSecurityDescriptor (pSecurityDescriptor);
191 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR));
200 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
201 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
202 LPDWORD lpdwAbsoluteSecurityDescriptorSize,
204 LPDWORD lpdwDaclSize,
206 LPDWORD lpdwSaclSize,
208 LPDWORD lpdwOwnerSize,
210 LPDWORD lpdwPrimaryGroupSize
215 Status = RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor,
216 pAbsoluteSecurityDescriptor,
217 lpdwAbsoluteSecurityDescriptorSize,
225 lpdwPrimaryGroupSize);
226 if (!NT_SUCCESS(Status))
228 SetLastError (RtlNtStatusToDosError (Status));
239 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
240 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
241 LPDWORD lpdwBufferLength
246 Status = RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor,
247 pSelfRelativeSecurityDescriptor,
248 (PULONG)lpdwBufferLength);
249 if (!NT_SUCCESS(Status))
251 SetLastError (RtlNtStatusToDosError (Status));
261 SetSecurityDescriptorDacl (
262 PSECURITY_DESCRIPTOR pSecurityDescriptor,
270 Status = RtlSetDaclSecurityDescriptor (pSecurityDescriptor,
274 if (!NT_SUCCESS(Status))
276 SetLastError (RtlNtStatusToDosError (Status));
286 SetSecurityDescriptorGroup (
287 PSECURITY_DESCRIPTOR pSecurityDescriptor,
294 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
297 if (!NT_SUCCESS(Status))
299 SetLastError (RtlNtStatusToDosError (Status));
309 SetSecurityDescriptorOwner (
310 PSECURITY_DESCRIPTOR pSecurityDescriptor,
317 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
320 if (!NT_SUCCESS(Status))
322 SetLastError (RtlNtStatusToDosError (Status));
332 SetSecurityDescriptorSacl (
333 PSECURITY_DESCRIPTOR pSecurityDescriptor,
341 Status = RtlSetSaclSecurityDescriptor (pSecurityDescriptor,
345 if (!NT_SUCCESS(Status))
347 SetLastError (RtlNtStatusToDosError (Status));
355 GetUserNameA(LPSTR lpBuffer, LPDWORD nSize)
361 GetUserNameW(LPWSTR lpBuffer, LPDWORD nSize)