1 | /*
|
---|
2 | * dlls/advapi32/security.c
|
---|
3 | * FIXME: for all functions thunking down to Rtl* functions: implement SetLastError()
|
---|
4 | */
|
---|
5 | #include <string.h>
|
---|
6 |
|
---|
7 | #include "windef.h"
|
---|
8 | #include "winerror.h"
|
---|
9 | #include "heap.h"
|
---|
10 | #include "ntddk.h"
|
---|
11 | #include "ntsecapi.h"
|
---|
12 | #include "debugtools.h"
|
---|
13 |
|
---|
14 | #ifdef __WIN32OS2__
|
---|
15 | #include <heapstring.h>
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | DEFAULT_DEBUG_CHANNEL(advapi);
|
---|
19 |
|
---|
20 | #define CallWin32ToNt(func) \
|
---|
21 | { NTSTATUS ret; \
|
---|
22 | ret = (func); \
|
---|
23 | if (ret !=STATUS_SUCCESS) \
|
---|
24 | { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
|
---|
25 | return TRUE; \
|
---|
26 | }
|
---|
27 |
|
---|
28 | static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
|
---|
29 | {
|
---|
30 | if (oa)
|
---|
31 | {
|
---|
32 | TRACE("\n\tlength=%lu, rootdir=0x%08x, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
|
---|
33 | oa->Length, oa->RootDirectory,
|
---|
34 | oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
|
---|
35 | oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | /* ##############################
|
---|
40 | ###### TOKEN FUNCTIONS ######
|
---|
41 | ##############################
|
---|
42 | */
|
---|
43 |
|
---|
44 | /******************************************************************************
|
---|
45 | * OpenProcessToken [ADVAPI32.@]
|
---|
46 | * Opens the access token associated with a process
|
---|
47 | *
|
---|
48 | * PARAMS
|
---|
49 | * ProcessHandle [I] Handle to process
|
---|
50 | * DesiredAccess [I] Desired access to process
|
---|
51 | * TokenHandle [O] Pointer to handle of open access token
|
---|
52 | *
|
---|
53 | * RETURNS STD
|
---|
54 | */
|
---|
55 | BOOL WINAPI
|
---|
56 | OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
|
---|
57 | HANDLE *TokenHandle )
|
---|
58 | {
|
---|
59 | CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
|
---|
60 | }
|
---|
61 |
|
---|
62 | /******************************************************************************
|
---|
63 | * OpenThreadToken [ADVAPI32.@]
|
---|
64 | *
|
---|
65 | * PARAMS
|
---|
66 | * thread []
|
---|
67 | * desiredaccess []
|
---|
68 | * openasself []
|
---|
69 | * thandle []
|
---|
70 | */
|
---|
71 | BOOL WINAPI
|
---|
72 | OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
|
---|
73 | BOOL OpenAsSelf, HANDLE *TokenHandle)
|
---|
74 | {
|
---|
75 | CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
|
---|
76 | }
|
---|
77 |
|
---|
78 | /******************************************************************************
|
---|
79 | * AdjustTokenPrivileges [ADVAPI32.@]
|
---|
80 | *
|
---|
81 | * PARAMS
|
---|
82 | * TokenHandle []
|
---|
83 | * DisableAllPrivileges []
|
---|
84 | * NewState []
|
---|
85 | * BufferLength []
|
---|
86 | * PreviousState []
|
---|
87 | * ReturnLength []
|
---|
88 | */
|
---|
89 | BOOL WINAPI
|
---|
90 | AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
---|
91 | LPVOID NewState, DWORD BufferLength,
|
---|
92 | LPVOID PreviousState, LPDWORD ReturnLength )
|
---|
93 | {
|
---|
94 | CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
|
---|
95 | }
|
---|
96 |
|
---|
97 | /******************************************************************************
|
---|
98 | * CheckTokenMembership [ADVAPI32.@]
|
---|
99 | *
|
---|
100 | * PARAMS
|
---|
101 | * TokenHandle []
|
---|
102 | * SidToCheck []
|
---|
103 | * IsMember []
|
---|
104 | */
|
---|
105 | BOOL WINAPI
|
---|
106 | CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
|
---|
107 | PBOOL IsMember )
|
---|
108 | {
|
---|
109 | FIXME("(0x%08x %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
|
---|
110 |
|
---|
111 | *IsMember = TRUE;
|
---|
112 | return(TRUE);
|
---|
113 | }
|
---|
114 |
|
---|
115 | /******************************************************************************
|
---|
116 | * GetTokenInformation [ADVAPI32.@]
|
---|
117 | *
|
---|
118 | * PARAMS
|
---|
119 | * token []
|
---|
120 | * tokeninfoclass []
|
---|
121 | * tokeninfo []
|
---|
122 | * tokeninfolength []
|
---|
123 | * retlen []
|
---|
124 | *
|
---|
125 | */
|
---|
126 | BOOL WINAPI
|
---|
127 | GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
|
---|
128 | LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
|
---|
129 | {
|
---|
130 | CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
|
---|
131 | }
|
---|
132 |
|
---|
133 | /*************************************************************************
|
---|
134 | * SetThreadToken [ADVAPI32.@]
|
---|
135 | *
|
---|
136 | * Assigns an "impersonation token" to a thread so it can assume the
|
---|
137 | * security privledges of another thread or process. Can also remove
|
---|
138 | * a previously assigned token. Only supported on NT - it's a stub
|
---|
139 | * exactly like this one on Win9X.
|
---|
140 | *
|
---|
141 | */
|
---|
142 |
|
---|
143 | BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
|
---|
144 | {
|
---|
145 | #ifdef __WIN32OS2__
|
---|
146 |
|
---|
147 | dprintf(("SetThreadToken %x %x NOT IMPLEMENTED (FAKED)", thread, token));
|
---|
148 | return TRUE; //pretend it succeeded
|
---|
149 | #else
|
---|
150 | FIXME("(%p, %x): stub (NT impl. only)\n", thread, token);
|
---|
151 |
|
---|
152 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
---|
153 |
|
---|
154 | return FALSE;
|
---|
155 | #endif
|
---|
156 | }
|
---|
157 |
|
---|
158 | /* ##############################
|
---|
159 | ###### SID FUNCTIONS ######
|
---|
160 | ##############################
|
---|
161 | */
|
---|
162 |
|
---|
163 | /******************************************************************************
|
---|
164 | * AllocateAndInitializeSid [ADVAPI32.@]
|
---|
165 | *
|
---|
166 | * PARAMS
|
---|
167 | * pIdentifierAuthority []
|
---|
168 | * nSubAuthorityCount []
|
---|
169 | * nSubAuthority0 []
|
---|
170 | * nSubAuthority1 []
|
---|
171 | * nSubAuthority2 []
|
---|
172 | * nSubAuthority3 []
|
---|
173 | * nSubAuthority4 []
|
---|
174 | * nSubAuthority5 []
|
---|
175 | * nSubAuthority6 []
|
---|
176 | * nSubAuthority7 []
|
---|
177 | * pSid []
|
---|
178 | */
|
---|
179 | BOOL WINAPI
|
---|
180 | AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
---|
181 | BYTE nSubAuthorityCount,
|
---|
182 | DWORD nSubAuthority0, DWORD nSubAuthority1,
|
---|
183 | DWORD nSubAuthority2, DWORD nSubAuthority3,
|
---|
184 | DWORD nSubAuthority4, DWORD nSubAuthority5,
|
---|
185 | DWORD nSubAuthority6, DWORD nSubAuthority7,
|
---|
186 | PSID *pSid )
|
---|
187 | {
|
---|
188 | return RtlAllocateAndInitializeSid(
|
---|
189 | pIdentifierAuthority, nSubAuthorityCount,
|
---|
190 | nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
|
---|
191 | nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
|
---|
192 | pSid );
|
---|
193 | }
|
---|
194 |
|
---|
195 | /******************************************************************************
|
---|
196 | * FreeSid [ADVAPI32.@]
|
---|
197 | *
|
---|
198 | * PARAMS
|
---|
199 | * pSid []
|
---|
200 | */
|
---|
201 | PVOID WINAPI
|
---|
202 | FreeSid( PSID pSid )
|
---|
203 | {
|
---|
204 | RtlFreeSid(pSid);
|
---|
205 | return NULL; /* is documented like this */
|
---|
206 | }
|
---|
207 |
|
---|
208 | /******************************************************************************
|
---|
209 | * CopySid [ADVAPI32.@]
|
---|
210 | *
|
---|
211 | * PARAMS
|
---|
212 | * nDestinationSidLength []
|
---|
213 | * pDestinationSid []
|
---|
214 | * pSourceSid []
|
---|
215 | */
|
---|
216 | BOOL WINAPI
|
---|
217 | CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
|
---|
218 | {
|
---|
219 | return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
|
---|
220 | }
|
---|
221 |
|
---|
222 | /******************************************************************************
|
---|
223 | * IsValidSid [ADVAPI32.@]
|
---|
224 | *
|
---|
225 | * PARAMS
|
---|
226 | * pSid []
|
---|
227 | */
|
---|
228 | BOOL WINAPI
|
---|
229 | IsValidSid( PSID pSid )
|
---|
230 | {
|
---|
231 | return RtlValidSid( pSid );
|
---|
232 | }
|
---|
233 |
|
---|
234 | /******************************************************************************
|
---|
235 | * EqualSid [ADVAPI32.@]
|
---|
236 | *
|
---|
237 | * PARAMS
|
---|
238 | * pSid1 []
|
---|
239 | * pSid2 []
|
---|
240 | */
|
---|
241 | BOOL WINAPI
|
---|
242 | EqualSid( PSID pSid1, PSID pSid2 )
|
---|
243 | {
|
---|
244 | return RtlEqualSid( pSid1, pSid2 );
|
---|
245 | }
|
---|
246 |
|
---|
247 | /******************************************************************************
|
---|
248 | * EqualPrefixSid [ADVAPI32.@]
|
---|
249 | */
|
---|
250 | BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
|
---|
251 | {
|
---|
252 | return RtlEqualPrefixSid(pSid1, pSid2);
|
---|
253 | }
|
---|
254 |
|
---|
255 | /******************************************************************************
|
---|
256 | * GetSidLengthRequired [ADVAPI32.@]
|
---|
257 | *
|
---|
258 | * PARAMS
|
---|
259 | * nSubAuthorityCount []
|
---|
260 | */
|
---|
261 | DWORD WINAPI
|
---|
262 | GetSidLengthRequired( BYTE nSubAuthorityCount )
|
---|
263 | {
|
---|
264 | return RtlLengthRequiredSid(nSubAuthorityCount);
|
---|
265 | }
|
---|
266 |
|
---|
267 | /******************************************************************************
|
---|
268 | * InitializeSid [ADVAPI32.@]
|
---|
269 | *
|
---|
270 | * PARAMS
|
---|
271 | * pIdentifierAuthority []
|
---|
272 | */
|
---|
273 | BOOL WINAPI
|
---|
274 | InitializeSid (
|
---|
275 | PSID pSid,
|
---|
276 | PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
---|
277 | BYTE nSubAuthorityCount)
|
---|
278 | {
|
---|
279 | return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
|
---|
280 | }
|
---|
281 |
|
---|
282 | /******************************************************************************
|
---|
283 | * GetSidIdentifierAuthority [ADVAPI32.@]
|
---|
284 | *
|
---|
285 | * PARAMS
|
---|
286 | * pSid []
|
---|
287 | */
|
---|
288 | PSID_IDENTIFIER_AUTHORITY WINAPI
|
---|
289 | GetSidIdentifierAuthority( PSID pSid )
|
---|
290 | {
|
---|
291 | return RtlIdentifierAuthoritySid(pSid);
|
---|
292 | }
|
---|
293 |
|
---|
294 | /******************************************************************************
|
---|
295 | * GetSidSubAuthority [ADVAPI32.@]
|
---|
296 | *
|
---|
297 | * PARAMS
|
---|
298 | * pSid []
|
---|
299 | * nSubAuthority []
|
---|
300 | */
|
---|
301 | PDWORD WINAPI
|
---|
302 | GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
---|
303 | {
|
---|
304 | return RtlSubAuthoritySid(pSid, nSubAuthority);
|
---|
305 | }
|
---|
306 |
|
---|
307 | /******************************************************************************
|
---|
308 | * GetSidSubAuthorityCount [ADVAPI32.@]
|
---|
309 | *
|
---|
310 | * PARAMS
|
---|
311 | * pSid []
|
---|
312 | */
|
---|
313 | PUCHAR WINAPI
|
---|
314 | GetSidSubAuthorityCount (PSID pSid)
|
---|
315 | {
|
---|
316 | return RtlSubAuthorityCountSid(pSid);
|
---|
317 | }
|
---|
318 |
|
---|
319 | /******************************************************************************
|
---|
320 | * GetLengthSid [ADVAPI32.@]
|
---|
321 | *
|
---|
322 | * PARAMS
|
---|
323 | * pSid []
|
---|
324 | */
|
---|
325 | DWORD WINAPI
|
---|
326 | GetLengthSid (PSID pSid)
|
---|
327 | {
|
---|
328 | if(!IsValidSid(pSid)) return 0;
|
---|
329 |
|
---|
330 | return RtlLengthSid(pSid);
|
---|
331 | }
|
---|
332 |
|
---|
333 | /* ##############################################
|
---|
334 | ###### SECURITY DESCRIPTOR FUNCTIONS ######
|
---|
335 | ##############################################
|
---|
336 | */
|
---|
337 |
|
---|
338 | /******************************************************************************
|
---|
339 | * InitializeSecurityDescriptor [ADVAPI32.@]
|
---|
340 | *
|
---|
341 | * PARAMS
|
---|
342 | * pDescr []
|
---|
343 | * revision []
|
---|
344 | */
|
---|
345 | BOOL WINAPI
|
---|
346 | InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
|
---|
347 | {
|
---|
348 | CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
|
---|
349 | }
|
---|
350 |
|
---|
351 | /******************************************************************************
|
---|
352 | * GetSecurityDescriptorLength [ADVAPI32.@]
|
---|
353 | */
|
---|
354 | DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
|
---|
355 | {
|
---|
356 | return (RtlLengthSecurityDescriptor(pDescr));
|
---|
357 | }
|
---|
358 |
|
---|
359 | /******************************************************************************
|
---|
360 | * GetSecurityDescriptorOwner [ADVAPI32.@]
|
---|
361 | *
|
---|
362 | * PARAMS
|
---|
363 | * pOwner []
|
---|
364 | * lpbOwnerDefaulted []
|
---|
365 | */
|
---|
366 | BOOL WINAPI
|
---|
367 | GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
|
---|
368 | LPBOOL lpbOwnerDefaulted )
|
---|
369 | {
|
---|
370 | CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
|
---|
371 | }
|
---|
372 |
|
---|
373 | /******************************************************************************
|
---|
374 | * SetSecurityDescriptorOwner [ADVAPI32.@]
|
---|
375 | *
|
---|
376 | * PARAMS
|
---|
377 | */
|
---|
378 | BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
379 | PSID pOwner, BOOL bOwnerDefaulted)
|
---|
380 | {
|
---|
381 | CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
|
---|
382 | }
|
---|
383 | /******************************************************************************
|
---|
384 | * GetSecurityDescriptorGroup [ADVAPI32.@]
|
---|
385 | */
|
---|
386 | BOOL WINAPI GetSecurityDescriptorGroup(
|
---|
387 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
388 | PSID *Group,
|
---|
389 | LPBOOL GroupDefaulted)
|
---|
390 | {
|
---|
391 | CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
|
---|
392 | }
|
---|
393 | /******************************************************************************
|
---|
394 | * SetSecurityDescriptorGroup [ADVAPI32.@]
|
---|
395 | */
|
---|
396 | BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
397 | PSID Group, BOOL GroupDefaulted)
|
---|
398 | {
|
---|
399 | CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
|
---|
400 | }
|
---|
401 |
|
---|
402 | /******************************************************************************
|
---|
403 | * IsValidSecurityDescriptor [ADVAPI32.@]
|
---|
404 | *
|
---|
405 | * PARAMS
|
---|
406 | * lpsecdesc []
|
---|
407 | */
|
---|
408 | BOOL WINAPI
|
---|
409 | IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
|
---|
410 | {
|
---|
411 | CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
|
---|
412 | }
|
---|
413 |
|
---|
414 | /******************************************************************************
|
---|
415 | * GetSecurityDescriptorDacl [ADVAPI32.@]
|
---|
416 | */
|
---|
417 | BOOL WINAPI GetSecurityDescriptorDacl(
|
---|
418 | IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
419 | OUT LPBOOL lpbDaclPresent,
|
---|
420 | OUT PACL *pDacl,
|
---|
421 | OUT LPBOOL lpbDaclDefaulted)
|
---|
422 | {
|
---|
423 | CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
|
---|
424 | pDacl, (PBOOLEAN)lpbDaclDefaulted));
|
---|
425 | }
|
---|
426 |
|
---|
427 | /******************************************************************************
|
---|
428 | * SetSecurityDescriptorDacl [ADVAPI32.@]
|
---|
429 | */
|
---|
430 | BOOL WINAPI
|
---|
431 | SetSecurityDescriptorDacl (
|
---|
432 | PSECURITY_DESCRIPTOR lpsd,
|
---|
433 | BOOL daclpresent,
|
---|
434 | PACL dacl,
|
---|
435 | BOOL dacldefaulted )
|
---|
436 | {
|
---|
437 | CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
|
---|
438 | }
|
---|
439 | /******************************************************************************
|
---|
440 | * GetSecurityDescriptorSacl [ADVAPI32.@]
|
---|
441 | */
|
---|
442 | BOOL WINAPI GetSecurityDescriptorSacl(
|
---|
443 | IN PSECURITY_DESCRIPTOR lpsd,
|
---|
444 | OUT LPBOOL lpbSaclPresent,
|
---|
445 | OUT PACL *pSacl,
|
---|
446 | OUT LPBOOL lpbSaclDefaulted)
|
---|
447 | {
|
---|
448 | CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd,
|
---|
449 | (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted));
|
---|
450 | }
|
---|
451 |
|
---|
452 | /**************************************************************************
|
---|
453 | * SetSecurityDescriptorSacl [ADVAPI32.@]
|
---|
454 | */
|
---|
455 | BOOL WINAPI SetSecurityDescriptorSacl (
|
---|
456 | PSECURITY_DESCRIPTOR lpsd,
|
---|
457 | BOOL saclpresent,
|
---|
458 | PACL lpsacl,
|
---|
459 | BOOL sacldefaulted)
|
---|
460 | {
|
---|
461 | CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
|
---|
462 | }
|
---|
463 | /******************************************************************************
|
---|
464 | * MakeSelfRelativeSD [ADVAPI32.@]
|
---|
465 | *
|
---|
466 | * PARAMS
|
---|
467 | * lpabssecdesc []
|
---|
468 | * lpselfsecdesc []
|
---|
469 | * lpbuflen []
|
---|
470 | */
|
---|
471 | BOOL WINAPI
|
---|
472 | MakeSelfRelativeSD(
|
---|
473 | IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
|
---|
474 | IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
|
---|
475 | IN OUT LPDWORD lpdwBufferLength)
|
---|
476 | {
|
---|
477 | CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
|
---|
478 | }
|
---|
479 |
|
---|
480 | /******************************************************************************
|
---|
481 | * GetSecurityDescriptorControl [ADVAPI32.@]
|
---|
482 | */
|
---|
483 |
|
---|
484 | BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
485 | PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
|
---|
486 | {
|
---|
487 | CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
|
---|
488 | }
|
---|
489 |
|
---|
490 | /* ##############################
|
---|
491 | ###### ACL FUNCTIONS ######
|
---|
492 | ##############################
|
---|
493 | */
|
---|
494 |
|
---|
495 | /*************************************************************************
|
---|
496 | * InitializeAcl [ADVAPI32.@]
|
---|
497 | */
|
---|
498 | DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
|
---|
499 | {
|
---|
500 | CallWin32ToNt (RtlCreateAcl(acl, size, rev));
|
---|
501 | }
|
---|
502 |
|
---|
503 | /* ##############################
|
---|
504 | ###### MISC FUNCTIONS ######
|
---|
505 | ##############################
|
---|
506 | */
|
---|
507 |
|
---|
508 | /******************************************************************************
|
---|
509 | * LookupPrivilegeValueW [ADVAPI32.@]
|
---|
510 | * Retrieves LUID used on a system to represent the privilege name.
|
---|
511 | *
|
---|
512 | * NOTES
|
---|
513 | * lpLuid should be PLUID
|
---|
514 | *
|
---|
515 | * PARAMS
|
---|
516 | * lpSystemName [I] Address of string specifying the system
|
---|
517 | * lpName [I] Address of string specifying the privilege
|
---|
518 | * lpLuid [I] Address of locally unique identifier
|
---|
519 | *
|
---|
520 | * RETURNS STD
|
---|
521 | */
|
---|
522 | BOOL WINAPI
|
---|
523 | LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
|
---|
524 | {
|
---|
525 | FIXME("(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
|
---|
526 | debugstr_w(lpName), lpLuid);
|
---|
527 | return TRUE;
|
---|
528 | }
|
---|
529 |
|
---|
530 | /******************************************************************************
|
---|
531 | * LookupPrivilegeValueA [ADVAPI32.@]
|
---|
532 | */
|
---|
533 | BOOL WINAPI
|
---|
534 | LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, LPVOID lpLuid )
|
---|
535 | {
|
---|
536 | LPWSTR lpSystemNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSystemName);
|
---|
537 | LPWSTR lpNameW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpName);
|
---|
538 | BOOL ret;
|
---|
539 |
|
---|
540 | ret = LookupPrivilegeValueW( lpSystemNameW, lpNameW, lpLuid);
|
---|
541 | HeapFree(GetProcessHeap(), 0, lpNameW);
|
---|
542 | HeapFree(GetProcessHeap(), 0, lpSystemNameW);
|
---|
543 | return ret;
|
---|
544 | }
|
---|
545 |
|
---|
546 | /******************************************************************************
|
---|
547 | * GetFileSecurityA [ADVAPI32.@]
|
---|
548 | *
|
---|
549 | * Obtains Specified information about the security of a file or directory
|
---|
550 | * The information obtained is constrained by the callers access rights and
|
---|
551 | * privileges
|
---|
552 | */
|
---|
553 | BOOL WINAPI
|
---|
554 | GetFileSecurityA( LPCSTR lpFileName,
|
---|
555 | SECURITY_INFORMATION RequestedInformation,
|
---|
556 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
557 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
---|
558 | {
|
---|
559 | FIXME("(%s) : stub\n", debugstr_a(lpFileName));
|
---|
560 | return TRUE;
|
---|
561 | }
|
---|
562 |
|
---|
563 | /******************************************************************************
|
---|
564 | * GetFileSecurityW [ADVAPI32.@]
|
---|
565 | *
|
---|
566 | * Obtains Specified information about the security of a file or directory
|
---|
567 | * The information obtained is constrained by the callers access rights and
|
---|
568 | * privileges
|
---|
569 | *
|
---|
570 | * PARAMS
|
---|
571 | * lpFileName []
|
---|
572 | * RequestedInformation []
|
---|
573 | * pSecurityDescriptor []
|
---|
574 | * nLength []
|
---|
575 | * lpnLengthNeeded []
|
---|
576 | */
|
---|
577 | BOOL WINAPI
|
---|
578 | GetFileSecurityW( LPCWSTR lpFileName,
|
---|
579 | SECURITY_INFORMATION RequestedInformation,
|
---|
580 | PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
---|
581 | DWORD nLength, LPDWORD lpnLengthNeeded )
|
---|
582 | {
|
---|
583 | FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
|
---|
584 | return TRUE;
|
---|
585 | }
|
---|
586 |
|
---|
587 |
|
---|
588 | /******************************************************************************
|
---|
589 | * LookupAccountSidA [ADVAPI32.@]
|
---|
590 | */
|
---|
591 | BOOL WINAPI
|
---|
592 | LookupAccountSidA(
|
---|
593 | IN LPCSTR system,
|
---|
594 | IN PSID sid,
|
---|
595 | OUT LPSTR account,
|
---|
596 | IN OUT LPDWORD accountSize,
|
---|
597 | OUT LPSTR domain,
|
---|
598 | IN OUT LPDWORD domainSize,
|
---|
599 | OUT PSID_NAME_USE name_use )
|
---|
600 | {
|
---|
601 | static const char ac[] = "Administrator";
|
---|
602 | static const char dm[] = "DOMAIN";
|
---|
603 | FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
|
---|
604 | debugstr_a(system),sid,
|
---|
605 | account,accountSize,accountSize?*accountSize:0,
|
---|
606 | domain,domainSize,domainSize?*domainSize:0,
|
---|
607 | name_use);
|
---|
608 |
|
---|
609 | if (accountSize) *accountSize = strlen(ac)+1;
|
---|
610 | if (account && (*accountSize > strlen(ac)))
|
---|
611 | strcpy(account, ac);
|
---|
612 |
|
---|
613 | if (domainSize) *domainSize = strlen(dm)+1;
|
---|
614 | if (domain && (*domainSize > strlen(dm)))
|
---|
615 | strcpy(domain,dm);
|
---|
616 |
|
---|
617 | if (name_use) *name_use = SidTypeUser;
|
---|
618 | return TRUE;
|
---|
619 | }
|
---|
620 |
|
---|
621 | /******************************************************************************
|
---|
622 | * LookupAccountSidW [ADVAPI32.@]
|
---|
623 | *
|
---|
624 | * PARAMS
|
---|
625 | * system []
|
---|
626 | * sid []
|
---|
627 | * account []
|
---|
628 | * accountSize []
|
---|
629 | * domain []
|
---|
630 | * domainSize []
|
---|
631 | * name_use []
|
---|
632 | */
|
---|
633 | BOOL WINAPI
|
---|
634 | LookupAccountSidW(
|
---|
635 | IN LPCWSTR system,
|
---|
636 | IN PSID sid,
|
---|
637 | OUT LPWSTR account,
|
---|
638 | IN OUT LPDWORD accountSize,
|
---|
639 | OUT LPWSTR domain,
|
---|
640 | IN OUT LPDWORD domainSize,
|
---|
641 | OUT PSID_NAME_USE name_use )
|
---|
642 | {
|
---|
643 | static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
|
---|
644 | static const WCHAR dm[] = {'D','O','M','A','I','N',0};
|
---|
645 | FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
|
---|
646 | debugstr_w(system),sid,
|
---|
647 | account,accountSize,accountSize?*accountSize:0,
|
---|
648 | domain,domainSize,domainSize?*domainSize:0,
|
---|
649 | name_use);
|
---|
650 |
|
---|
651 | if (accountSize) *accountSize = strlenW(ac)+1;
|
---|
652 | if (account && (*accountSize > strlenW(ac)))
|
---|
653 | strcpyW(account, ac);
|
---|
654 |
|
---|
655 | if (domainSize) *domainSize = strlenW(dm)+1;
|
---|
656 | if (domain && (*domainSize > strlenW(dm)))
|
---|
657 | strcpyW(domain,dm);
|
---|
658 |
|
---|
659 | if (name_use) *name_use = SidTypeUser;
|
---|
660 | return TRUE;
|
---|
661 | }
|
---|
662 |
|
---|
663 | /******************************************************************************
|
---|
664 | * SetFileSecurityA [ADVAPI32.@]
|
---|
665 | * Sets the security of a file or directory
|
---|
666 | */
|
---|
667 | BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
|
---|
668 | SECURITY_INFORMATION RequestedInformation,
|
---|
669 | PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
---|
670 | {
|
---|
671 | FIXME("(%s) : stub\n", debugstr_a(lpFileName));
|
---|
672 | return TRUE;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /******************************************************************************
|
---|
676 | * SetFileSecurityW [ADVAPI32.@]
|
---|
677 | * Sets the security of a file or directory
|
---|
678 | *
|
---|
679 | * PARAMS
|
---|
680 | * lpFileName []
|
---|
681 | * RequestedInformation []
|
---|
682 | * pSecurityDescriptor []
|
---|
683 | */
|
---|
684 | BOOL WINAPI
|
---|
685 | SetFileSecurityW( LPCWSTR lpFileName,
|
---|
686 | SECURITY_INFORMATION RequestedInformation,
|
---|
687 | PSECURITY_DESCRIPTOR pSecurityDescriptor )
|
---|
688 | {
|
---|
689 | FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
|
---|
690 | return TRUE;
|
---|
691 | }
|
---|
692 |
|
---|
693 | /******************************************************************************
|
---|
694 | * QueryWindows31FilesMigration [ADVAPI32.@]
|
---|
695 | *
|
---|
696 | * PARAMS
|
---|
697 | * x1 []
|
---|
698 | */
|
---|
699 | BOOL WINAPI
|
---|
700 | QueryWindows31FilesMigration( DWORD x1 )
|
---|
701 | {
|
---|
702 | FIXME("(%ld):stub\n",x1);
|
---|
703 | return TRUE;
|
---|
704 | }
|
---|
705 |
|
---|
706 | /******************************************************************************
|
---|
707 | * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
|
---|
708 | *
|
---|
709 | * PARAMS
|
---|
710 | * x1 []
|
---|
711 | * x2 []
|
---|
712 | * x3 []
|
---|
713 | * x4 []
|
---|
714 | */
|
---|
715 | BOOL WINAPI
|
---|
716 | SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
|
---|
717 | DWORD x4 )
|
---|
718 | {
|
---|
719 | FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
|
---|
720 | return TRUE;
|
---|
721 | }
|
---|
722 |
|
---|
723 | /******************************************************************************
|
---|
724 | * LsaOpenPolicy [ADVAPI32.@]
|
---|
725 | *
|
---|
726 | * PARAMS
|
---|
727 | * x1 []
|
---|
728 | * x2 []
|
---|
729 | * x3 []
|
---|
730 | * x4 []
|
---|
731 | */
|
---|
732 | NTSTATUS WINAPI
|
---|
733 | LsaOpenPolicy(
|
---|
734 | IN PLSA_UNICODE_STRING SystemName,
|
---|
735 | IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
|
---|
736 | IN ACCESS_MASK DesiredAccess,
|
---|
737 | IN OUT PLSA_HANDLE PolicyHandle)
|
---|
738 | {
|
---|
739 | FIXME("(%s,%p,0x%08lx,%p):stub\n",
|
---|
740 | SystemName?debugstr_w(SystemName->Buffer):"null",
|
---|
741 | ObjectAttributes, DesiredAccess, PolicyHandle);
|
---|
742 | dumpLsaAttributes(ObjectAttributes);
|
---|
743 | if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
|
---|
744 | return TRUE;
|
---|
745 | }
|
---|
746 |
|
---|
747 | /******************************************************************************
|
---|
748 | * LsaQueryInformationPolicy [ADVAPI32.@]
|
---|
749 | */
|
---|
750 | NTSTATUS WINAPI
|
---|
751 | LsaQueryInformationPolicy(
|
---|
752 | IN LSA_HANDLE PolicyHandle,
|
---|
753 | IN POLICY_INFORMATION_CLASS InformationClass,
|
---|
754 | OUT PVOID *Buffer)
|
---|
755 | {
|
---|
756 | FIXME("(%p,0x%08x,%p):stub\n",
|
---|
757 | PolicyHandle, InformationClass, Buffer);
|
---|
758 |
|
---|
759 | if(!Buffer) return FALSE;
|
---|
760 | switch (InformationClass)
|
---|
761 | {
|
---|
762 | case PolicyAuditEventsInformation: /* 2 */
|
---|
763 | {
|
---|
764 | PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
|
---|
765 | p->AuditingMode = FALSE; /* no auditing */
|
---|
766 | *Buffer = p;
|
---|
767 | }
|
---|
768 | break;
|
---|
769 | case PolicyPrimaryDomainInformation: /* 3 */
|
---|
770 | case PolicyAccountDomainInformation: /* 5 */
|
---|
771 | {
|
---|
772 | struct di
|
---|
773 | { POLICY_PRIMARY_DOMAIN_INFO ppdi;
|
---|
774 | SID sid;
|
---|
775 | };
|
---|
776 | SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
|
---|
777 |
|
---|
778 | struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
|
---|
779 | RtlInitUnicodeString(&(xdi->ppdi.Name), HEAP_strdupAtoW(GetProcessHeap(),0,"DOMAIN"));
|
---|
780 | xdi->ppdi.Sid = &(xdi->sid);
|
---|
781 | xdi->sid.Revision = SID_REVISION;
|
---|
782 | xdi->sid.SubAuthorityCount = 1;
|
---|
783 | xdi->sid.IdentifierAuthority = localSidAuthority;
|
---|
784 | xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
|
---|
785 | *Buffer = xdi;
|
---|
786 | }
|
---|
787 | break;
|
---|
788 | case PolicyAuditLogInformation:
|
---|
789 | case PolicyPdAccountInformation:
|
---|
790 | case PolicyLsaServerRoleInformation:
|
---|
791 | case PolicyReplicaSourceInformation:
|
---|
792 | case PolicyDefaultQuotaInformation:
|
---|
793 | case PolicyModificationInformation:
|
---|
794 | case PolicyAuditFullSetInformation:
|
---|
795 | case PolicyAuditFullQueryInformation:
|
---|
796 | case PolicyDnsDomainInformation:
|
---|
797 | {
|
---|
798 | FIXME("category not implemented\n");
|
---|
799 | return FALSE;
|
---|
800 | }
|
---|
801 | }
|
---|
802 | return TRUE;
|
---|
803 | }
|
---|
804 |
|
---|
805 | /******************************************************************************
|
---|
806 | * LsaLookupSids [ADVAPI32.@]
|
---|
807 | */
|
---|
808 | typedef struct
|
---|
809 | {
|
---|
810 | SID_NAME_USE Use;
|
---|
811 | LSA_UNICODE_STRING Name;
|
---|
812 | LONG DomainIndex;
|
---|
813 | } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
|
---|
814 |
|
---|
815 | typedef struct
|
---|
816 | {
|
---|
817 | LSA_UNICODE_STRING Name;
|
---|
818 | PSID Sid;
|
---|
819 | } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
|
---|
820 |
|
---|
821 | typedef struct
|
---|
822 | {
|
---|
823 | ULONG Entries;
|
---|
824 | PLSA_TRUST_INFORMATION Domains;
|
---|
825 | } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
|
---|
826 |
|
---|
827 | NTSTATUS WINAPI
|
---|
828 | LsaLookupSids(
|
---|
829 | IN LSA_HANDLE PolicyHandle,
|
---|
830 | IN ULONG Count,
|
---|
831 | IN PSID *Sids,
|
---|
832 | OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
|
---|
833 | OUT PLSA_TRANSLATED_NAME *Names )
|
---|
834 | {
|
---|
835 | FIXME("%p %lu %p %p %p\n",
|
---|
836 | PolicyHandle, Count, Sids, ReferencedDomains, Names);
|
---|
837 | return FALSE;
|
---|
838 | }
|
---|
839 |
|
---|
840 | /******************************************************************************
|
---|
841 | * LsaFreeMemory [ADVAPI32.@]
|
---|
842 | */
|
---|
843 | NTSTATUS WINAPI
|
---|
844 | LsaFreeMemory(IN PVOID Buffer)
|
---|
845 | {
|
---|
846 | TRACE("(%p)\n",Buffer);
|
---|
847 | return HeapFree(GetProcessHeap(), 0, Buffer);
|
---|
848 | }
|
---|
849 | /******************************************************************************
|
---|
850 | * LsaClose [ADVAPI32.@]
|
---|
851 | */
|
---|
852 | NTSTATUS WINAPI
|
---|
853 | LsaClose(IN LSA_HANDLE ObjectHandle)
|
---|
854 | {
|
---|
855 | FIXME("(%p):stub\n",ObjectHandle);
|
---|
856 | return 0xc0000000;
|
---|
857 | }
|
---|
858 | /******************************************************************************
|
---|
859 | * NotifyBootConfigStatus [ADVAPI32.@]
|
---|
860 | *
|
---|
861 | * PARAMS
|
---|
862 | * x1 []
|
---|
863 | */
|
---|
864 | BOOL WINAPI
|
---|
865 | NotifyBootConfigStatus( DWORD x1 )
|
---|
866 | {
|
---|
867 | FIXME("(0x%08lx):stub\n",x1);
|
---|
868 | return 1;
|
---|
869 | }
|
---|
870 |
|
---|
871 | /******************************************************************************
|
---|
872 | * RevertToSelf [ADVAPI32.@]
|
---|
873 | *
|
---|
874 | * PARAMS
|
---|
875 | * void []
|
---|
876 | */
|
---|
877 | BOOL WINAPI
|
---|
878 | RevertToSelf( void )
|
---|
879 | {
|
---|
880 | FIXME("(), stub\n");
|
---|
881 | return TRUE;
|
---|
882 | }
|
---|
883 |
|
---|
884 | /******************************************************************************
|
---|
885 | * ImpersonateSelf [ADVAPI32.@]
|
---|
886 | */
|
---|
887 | BOOL WINAPI
|
---|
888 | ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
---|
889 | {
|
---|
890 | return RtlImpersonateSelf(ImpersonationLevel);
|
---|
891 | }
|
---|
892 |
|
---|
893 | /******************************************************************************
|
---|
894 | * AccessCheck [ADVAPI32.@]
|
---|
895 | *
|
---|
896 | * FIXME check cast LPBOOL to PBOOLEAN
|
---|
897 | */
|
---|
898 | BOOL WINAPI
|
---|
899 | AccessCheck(
|
---|
900 | PSECURITY_DESCRIPTOR SecurityDescriptor,
|
---|
901 | HANDLE ClientToken,
|
---|
902 | DWORD DesiredAccess,
|
---|
903 | PGENERIC_MAPPING GenericMapping,
|
---|
904 | PPRIVILEGE_SET PrivilegeSet,
|
---|
905 | LPDWORD PrivilegeSetLength,
|
---|
906 | LPDWORD GrantedAccess,
|
---|
907 | LPBOOL AccessStatus)
|
---|
908 | {
|
---|
909 | CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
|
---|
910 | GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
|
---|
911 | }
|
---|
912 |
|
---|
913 | /*************************************************************************
|
---|
914 | * SetKernelObjectSecurity [ADVAPI32.@]
|
---|
915 | */
|
---|
916 | BOOL WINAPI SetKernelObjectSecurity (
|
---|
917 | IN HANDLE Handle,
|
---|
918 | IN SECURITY_INFORMATION SecurityInformation,
|
---|
919 | IN PSECURITY_DESCRIPTOR SecurityDescriptor )
|
---|
920 | {
|
---|
921 | CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
|
---|
922 | }
|
---|
923 |
|
---|
924 | /******************************************************************************
|
---|
925 | * AddAccessAllowedAce [ADVAPI32.@]
|
---|
926 | */
|
---|
927 | BOOL WINAPI AddAccessAllowedAce(
|
---|
928 | IN OUT PACL pAcl,
|
---|
929 | IN DWORD dwAceRevision,
|
---|
930 | IN DWORD AccessMask,
|
---|
931 | IN PSID pSid)
|
---|
932 | {
|
---|
933 | return RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid);
|
---|
934 | }
|
---|
935 |
|
---|
936 | /******************************************************************************
|
---|
937 | * LookupAccountNameA [ADVAPI32.@]
|
---|
938 | */
|
---|
939 | BOOL WINAPI
|
---|
940 | LookupAccountNameA(
|
---|
941 | IN LPCSTR system,
|
---|
942 | IN LPCSTR account,
|
---|
943 | OUT PSID sid,
|
---|
944 | OUT LPDWORD cbSid,
|
---|
945 | LPSTR ReferencedDomainName,
|
---|
946 | IN OUT LPDWORD cbReferencedDomainName,
|
---|
947 | OUT PSID_NAME_USE name_use )
|
---|
948 | {
|
---|
949 | FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
|
---|
950 | return FALSE;
|
---|
951 | }
|
---|
952 |
|
---|
953 | /******************************************************************************
|
---|
954 | * GetAce [ADVAPI32.@]
|
---|
955 | */
|
---|
956 | BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
|
---|
957 | {
|
---|
958 | CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce));
|
---|
959 | }
|
---|