- Merge from trunk up to r45543
[reactos.git] / dll / win32 / advapi32 / sec / audit.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/sec/audit.c
6 * PURPOSE: Audit functions
7 * PROGRAMMER: Eric Kohl
8 * UPDATE HISTORY:
9 * Created 07/19/2003
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <advapi32.h>
15 #include <wine/debug.h>
16
17 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
18
19 /* FUNCTIONS ****************************************************************/
20
21 /*
22 * @implemented
23 */
24 BOOL WINAPI
25 AccessCheckAndAuditAlarmA(LPCSTR SubsystemName,
26 LPVOID HandleId,
27 LPSTR ObjectTypeName,
28 LPSTR ObjectName,
29 PSECURITY_DESCRIPTOR SecurityDescriptor,
30 DWORD DesiredAccess,
31 PGENERIC_MAPPING GenericMapping,
32 BOOL ObjectCreation,
33 LPDWORD GrantedAccess,
34 LPBOOL AccessStatus,
35 LPBOOL pfGenerateOnClose)
36 {
37 UNICODE_STRING SubsystemNameU;
38 UNICODE_STRING ObjectTypeNameU;
39 UNICODE_STRING ObjectNameU;
40 NTSTATUS LocalAccessStatus;
41 BOOLEAN GenerateOnClose;
42 NTSTATUS Status;
43
44 RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU,
45 (PCHAR)SubsystemName);
46 RtlCreateUnicodeStringFromAsciiz(&ObjectTypeNameU,
47 (PCHAR)ObjectTypeName);
48 RtlCreateUnicodeStringFromAsciiz(&ObjectNameU,
49 (PCHAR)ObjectName);
50
51 Status = NtAccessCheckAndAuditAlarm(&SubsystemNameU,
52 HandleId,
53 &ObjectTypeNameU,
54 &ObjectNameU,
55 SecurityDescriptor,
56 DesiredAccess,
57 GenericMapping,
58 ObjectCreation,
59 GrantedAccess,
60 &LocalAccessStatus,
61 &GenerateOnClose);
62 RtlFreeUnicodeString(&SubsystemNameU);
63 RtlFreeUnicodeString(&ObjectTypeNameU);
64 RtlFreeUnicodeString(&ObjectNameU);
65
66 *pfGenerateOnClose = (BOOL)GenerateOnClose;
67
68 if (!NT_SUCCESS(Status))
69 {
70 SetLastError(RtlNtStatusToDosError(Status));
71 return FALSE;
72 }
73
74 if (!NT_SUCCESS (LocalAccessStatus))
75 {
76 *AccessStatus = FALSE;
77 SetLastError(RtlNtStatusToDosError(Status));
78 return FALSE;
79 }
80
81 *AccessStatus = TRUE;
82
83 return TRUE;
84 }
85
86
87 /*
88 * @implemented
89 */
90 BOOL WINAPI
91 AccessCheckAndAuditAlarmW(LPCWSTR SubsystemName,
92 LPVOID HandleId,
93 LPWSTR ObjectTypeName,
94 LPWSTR ObjectName,
95 PSECURITY_DESCRIPTOR SecurityDescriptor,
96 DWORD DesiredAccess,
97 PGENERIC_MAPPING GenericMapping,
98 BOOL ObjectCreation,
99 LPDWORD GrantedAccess,
100 LPBOOL AccessStatus,
101 LPBOOL pfGenerateOnClose)
102 {
103 UNICODE_STRING SubsystemNameU;
104 UNICODE_STRING ObjectTypeNameU;
105 UNICODE_STRING ObjectNameU;
106 NTSTATUS LocalAccessStatus;
107 BOOLEAN GenerateOnClose;
108 NTSTATUS Status;
109
110 RtlInitUnicodeString(&SubsystemNameU,
111 (PWSTR)SubsystemName);
112 RtlInitUnicodeString(&ObjectTypeNameU,
113 (PWSTR)ObjectTypeName);
114 RtlInitUnicodeString(&ObjectNameU,
115 (PWSTR)ObjectName);
116
117 Status = NtAccessCheckAndAuditAlarm(&SubsystemNameU,
118 HandleId,
119 &ObjectTypeNameU,
120 &ObjectNameU,
121 SecurityDescriptor,
122 DesiredAccess,
123 GenericMapping,
124 ObjectCreation,
125 GrantedAccess,
126 &LocalAccessStatus,
127 &GenerateOnClose);
128
129 *pfGenerateOnClose = (BOOL)GenerateOnClose;
130
131 if (!NT_SUCCESS(Status))
132 {
133 SetLastError(RtlNtStatusToDosError(Status));
134 return FALSE;
135 }
136
137 if (!NT_SUCCESS(LocalAccessStatus))
138 {
139 *AccessStatus = FALSE;
140 SetLastError(RtlNtStatusToDosError(Status));
141 return FALSE;
142 }
143
144 *AccessStatus = TRUE;
145
146 return TRUE;
147 }
148
149
150 /*
151 * @implemented
152 */
153 BOOL WINAPI
154 ObjectCloseAuditAlarmA(LPCSTR SubsystemName,
155 LPVOID HandleId,
156 BOOL GenerateOnClose)
157 {
158 UNICODE_STRING Name;
159 NTSTATUS Status;
160
161 Status = RtlCreateUnicodeStringFromAsciiz(&Name,
162 (PCHAR)SubsystemName);
163 if (!NT_SUCCESS(Status))
164 {
165 SetLastError(RtlNtStatusToDosError(Status));
166 return FALSE;
167 }
168
169 Status = NtCloseObjectAuditAlarm(&Name,
170 HandleId,
171 GenerateOnClose);
172 RtlFreeUnicodeString(&Name);
173 if (!NT_SUCCESS (Status))
174 {
175 SetLastError(RtlNtStatusToDosError(Status));
176 return FALSE;
177 }
178
179 return TRUE;
180 }
181
182
183 /*
184 * @implemented
185 */
186 BOOL WINAPI
187 ObjectCloseAuditAlarmW(LPCWSTR SubsystemName,
188 LPVOID HandleId,
189 BOOL GenerateOnClose)
190 {
191 UNICODE_STRING Name;
192 NTSTATUS Status;
193
194 RtlInitUnicodeString(&Name,
195 (PWSTR)SubsystemName);
196
197 Status = NtCloseObjectAuditAlarm(&Name,
198 HandleId,
199 GenerateOnClose);
200 if (!NT_SUCCESS(Status))
201 {
202 SetLastError(RtlNtStatusToDosError(Status));
203 return FALSE;
204 }
205
206 return TRUE;
207 }
208
209
210 /*
211 * @implemented
212 */
213 BOOL WINAPI
214 ObjectDeleteAuditAlarmA(LPCSTR SubsystemName,
215 LPVOID HandleId,
216 BOOL GenerateOnClose)
217 {
218 UNICODE_STRING Name;
219 NTSTATUS Status;
220
221 Status = RtlCreateUnicodeStringFromAsciiz(&Name,
222 (PCHAR)SubsystemName);
223 if (!NT_SUCCESS(Status))
224 {
225 SetLastError(RtlNtStatusToDosError(Status));
226 return FALSE;
227 }
228
229 Status = NtDeleteObjectAuditAlarm(&Name,
230 HandleId,
231 GenerateOnClose);
232 RtlFreeUnicodeString(&Name);
233 if (!NT_SUCCESS(Status))
234 {
235 SetLastError(RtlNtStatusToDosError(Status));
236 return FALSE;
237 }
238
239 return TRUE;
240 }
241
242
243 /*
244 * @implemented
245 */
246 BOOL WINAPI
247 ObjectDeleteAuditAlarmW(LPCWSTR SubsystemName,
248 LPVOID HandleId,
249 BOOL GenerateOnClose)
250 {
251 UNICODE_STRING Name;
252 NTSTATUS Status;
253
254 RtlInitUnicodeString(&Name,
255 (PWSTR)SubsystemName);
256
257 Status = NtDeleteObjectAuditAlarm(&Name,
258 HandleId,
259 GenerateOnClose);
260 if (!NT_SUCCESS(Status))
261 {
262 SetLastError(RtlNtStatusToDosError(Status));
263 return FALSE;
264 }
265
266 return TRUE;
267 }
268
269
270 /*
271 * @implemented
272 */
273 BOOL WINAPI
274 ObjectOpenAuditAlarmA(LPCSTR SubsystemName,
275 LPVOID HandleId,
276 LPSTR ObjectTypeName,
277 LPSTR ObjectName,
278 PSECURITY_DESCRIPTOR pSecurityDescriptor,
279 HANDLE ClientToken,
280 DWORD DesiredAccess,
281 DWORD GrantedAccess,
282 PPRIVILEGE_SET Privileges,
283 BOOL ObjectCreation,
284 BOOL AccessGranted,
285 LPBOOL GenerateOnClose)
286 {
287 UNICODE_STRING SubsystemNameU;
288 UNICODE_STRING ObjectTypeNameU;
289 UNICODE_STRING ObjectNameU;
290 NTSTATUS Status;
291
292 RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU,
293 (PCHAR)SubsystemName);
294 RtlCreateUnicodeStringFromAsciiz(&ObjectTypeNameU,
295 (PCHAR)ObjectTypeName);
296 RtlCreateUnicodeStringFromAsciiz(&ObjectNameU,
297 (PCHAR)ObjectName);
298
299 Status = NtOpenObjectAuditAlarm(&SubsystemNameU,
300 HandleId,
301 &ObjectTypeNameU,
302 &ObjectNameU,
303 pSecurityDescriptor,
304 ClientToken,
305 DesiredAccess,
306 GrantedAccess,
307 Privileges,
308 ObjectCreation,
309 AccessGranted,
310 (PBOOLEAN)GenerateOnClose);
311 RtlFreeUnicodeString(&SubsystemNameU);
312 RtlFreeUnicodeString(&ObjectTypeNameU);
313 RtlFreeUnicodeString(&ObjectNameU);
314 if (!NT_SUCCESS(Status))
315 {
316 SetLastError(RtlNtStatusToDosError(Status));
317 return FALSE;
318 }
319
320 return TRUE;
321 }
322
323
324 /*
325 * @implemented
326 */
327 BOOL WINAPI
328 ObjectOpenAuditAlarmW(LPCWSTR SubsystemName,
329 LPVOID HandleId,
330 LPWSTR ObjectTypeName,
331 LPWSTR ObjectName,
332 PSECURITY_DESCRIPTOR pSecurityDescriptor,
333 HANDLE ClientToken,
334 DWORD DesiredAccess,
335 DWORD GrantedAccess,
336 PPRIVILEGE_SET Privileges,
337 BOOL ObjectCreation,
338 BOOL AccessGranted,
339 LPBOOL GenerateOnClose)
340 {
341 UNICODE_STRING SubsystemNameU;
342 UNICODE_STRING ObjectTypeNameU;
343 UNICODE_STRING ObjectNameU;
344 NTSTATUS Status;
345
346 RtlInitUnicodeString(&SubsystemNameU,
347 (PWSTR)SubsystemName);
348 RtlInitUnicodeString(&ObjectTypeNameU,
349 (PWSTR)ObjectTypeName);
350 RtlInitUnicodeString(&ObjectNameU,
351 (PWSTR)ObjectName);
352
353 Status = NtOpenObjectAuditAlarm(&SubsystemNameU,
354 HandleId,
355 &ObjectTypeNameU,
356 &ObjectNameU,
357 pSecurityDescriptor,
358 ClientToken,
359 DesiredAccess,
360 GrantedAccess,
361 Privileges,
362 ObjectCreation,
363 AccessGranted,
364 (PBOOLEAN)GenerateOnClose);
365 if (!NT_SUCCESS(Status))
366 {
367 SetLastError(RtlNtStatusToDosError(Status));
368 return FALSE;
369 }
370
371 return TRUE;
372 }
373
374
375 /*
376 * @implemented
377 */
378 BOOL WINAPI
379 ObjectPrivilegeAuditAlarmA(LPCSTR SubsystemName,
380 LPVOID HandleId,
381 HANDLE ClientToken,
382 DWORD DesiredAccess,
383 PPRIVILEGE_SET Privileges,
384 BOOL AccessGranted)
385 {
386 UNICODE_STRING SubsystemNameU;
387 NTSTATUS Status;
388
389 RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU,
390 (PCHAR)SubsystemName);
391
392 Status = NtPrivilegeObjectAuditAlarm(&SubsystemNameU,
393 HandleId,
394 ClientToken,
395 DesiredAccess,
396 Privileges,
397 AccessGranted);
398 RtlFreeUnicodeString (&SubsystemNameU);
399 if (!NT_SUCCESS(Status))
400 {
401 SetLastError(RtlNtStatusToDosError(Status));
402 return FALSE;
403 }
404
405 return TRUE;
406 }
407
408
409 /*
410 * @implemented
411 */
412 BOOL WINAPI
413 ObjectPrivilegeAuditAlarmW(LPCWSTR SubsystemName,
414 LPVOID HandleId,
415 HANDLE ClientToken,
416 DWORD DesiredAccess,
417 PPRIVILEGE_SET Privileges,
418 BOOL AccessGranted)
419 {
420 UNICODE_STRING SubsystemNameU;
421 NTSTATUS Status;
422
423 RtlInitUnicodeString(&SubsystemNameU,
424 (PWSTR)SubsystemName);
425
426 Status = NtPrivilegeObjectAuditAlarm(&SubsystemNameU,
427 HandleId,
428 ClientToken,
429 DesiredAccess,
430 Privileges,
431 AccessGranted);
432 if (!NT_SUCCESS(Status))
433 {
434 SetLastError(RtlNtStatusToDosError(Status));
435 return FALSE;
436 }
437
438 return TRUE;
439 }
440
441
442 /*
443 * @implemented
444 */
445 BOOL WINAPI
446 PrivilegedServiceAuditAlarmA(LPCSTR SubsystemName,
447 LPCSTR ServiceName,
448 HANDLE ClientToken,
449 PPRIVILEGE_SET Privileges,
450 BOOL AccessGranted)
451 {
452 UNICODE_STRING SubsystemNameU;
453 UNICODE_STRING ServiceNameU;
454 NTSTATUS Status;
455
456 RtlCreateUnicodeStringFromAsciiz(&SubsystemNameU,
457 (PCHAR)SubsystemName);
458 RtlCreateUnicodeStringFromAsciiz(&ServiceNameU,
459 (PCHAR)ServiceName);
460
461 Status = NtPrivilegedServiceAuditAlarm(&SubsystemNameU,
462 &ServiceNameU,
463 ClientToken,
464 Privileges,
465 AccessGranted);
466 RtlFreeUnicodeString(&SubsystemNameU);
467 RtlFreeUnicodeString(&ServiceNameU);
468 if (!NT_SUCCESS(Status))
469 {
470 SetLastError(RtlNtStatusToDosError(Status));
471 return FALSE;
472 }
473
474 return TRUE;
475 }
476
477
478 /*
479 * @implemented
480 */
481 BOOL WINAPI
482 PrivilegedServiceAuditAlarmW(LPCWSTR SubsystemName,
483 LPCWSTR ServiceName,
484 HANDLE ClientToken,
485 PPRIVILEGE_SET Privileges,
486 BOOL AccessGranted)
487 {
488 UNICODE_STRING SubsystemNameU;
489 UNICODE_STRING ServiceNameU;
490 NTSTATUS Status;
491
492 RtlInitUnicodeString(&SubsystemNameU,
493 (PWSTR)SubsystemName);
494 RtlInitUnicodeString(&ServiceNameU,
495 (PWSTR)ServiceName);
496
497 Status = NtPrivilegedServiceAuditAlarm(&SubsystemNameU,
498 &ServiceNameU,
499 ClientToken,
500 Privileges,
501 AccessGranted);
502 if (!NT_SUCCESS(Status))
503 {
504 SetLastError(RtlNtStatusToDosError(Status));
505 return FALSE;
506 }
507
508 return TRUE;
509 }
510
511
512 /*
513 * @unimplemented
514 */
515 BOOL WINAPI
516 AccessCheckByTypeResultListAndAuditAlarmByHandleW(IN LPCWSTR SubsystemName,
517 IN LPVOID HandleId,
518 IN HANDLE ClientToken,
519 IN LPCWSTR ObjectTypeName,
520 IN LPCWSTR ObjectName,
521 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
522 IN PSID PrincipalSelfSid,
523 IN DWORD DesiredAccess,
524 IN AUDIT_EVENT_TYPE AuditType,
525 IN DWORD Flags,
526 IN POBJECT_TYPE_LIST ObjectTypeList,
527 IN DWORD ObjectTypeListLength,
528 IN PGENERIC_MAPPING GenericMapping,
529 IN BOOL ObjectCreation,
530 OUT LPDWORD GrantedAccess,
531 OUT LPDWORD AccessStatusList,
532 OUT LPBOOL pfGenerateOnClose)
533 {
534 FIXME("%s() not implemented!\n", __FUNCTION__);
535 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
536 return FALSE;
537 }
538
539
540 /*
541 * @unimplemented
542 */
543 BOOL WINAPI
544 AccessCheckByTypeResultListAndAuditAlarmByHandleA(IN LPCSTR SubsystemName,
545 IN LPVOID HandleId,
546 IN HANDLE ClientToken,
547 IN LPCSTR ObjectTypeName,
548 IN LPCSTR ObjectName,
549 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
550 IN PSID PrincipalSelfSid,
551 IN DWORD DesiredAccess,
552 IN AUDIT_EVENT_TYPE AuditType,
553 IN DWORD Flags,
554 IN POBJECT_TYPE_LIST ObjectTypeList,
555 IN DWORD ObjectTypeListLength,
556 IN PGENERIC_MAPPING GenericMapping,
557 IN BOOL ObjectCreation,
558 OUT LPDWORD GrantedAccess,
559 OUT LPDWORD AccessStatusList,
560 OUT LPBOOL pfGenerateOnClose)
561 {
562 FIXME("%s() not implemented!\n", __FUNCTION__);
563 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
564 return FALSE;
565 }
566
567
568 /*
569 * @unimplemented
570 */
571 BOOL WINAPI
572 AccessCheckByTypeResultListAndAuditAlarmW(IN LPCWSTR SubsystemName,
573 IN LPVOID HandleId,
574 IN LPCWSTR ObjectTypeName,
575 IN LPCWSTR ObjectName,
576 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
577 IN PSID PrincipalSelfSid,
578 IN DWORD DesiredAccess,
579 IN AUDIT_EVENT_TYPE AuditType,
580 IN DWORD Flags,
581 IN POBJECT_TYPE_LIST ObjectTypeList,
582 IN DWORD ObjectTypeListLength,
583 IN PGENERIC_MAPPING GenericMapping,
584 IN BOOL ObjectCreation,
585 OUT LPDWORD GrantedAccess,
586 OUT LPDWORD AccessStatusList,
587 OUT LPBOOL pfGenerateOnClose)
588 {
589 FIXME("%s() not implemented!\n", __FUNCTION__);
590 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
591 return FALSE;
592 }
593
594
595 /*
596 * @unimplemented
597 */
598 BOOL WINAPI
599 AccessCheckByTypeResultListAndAuditAlarmA(IN LPCSTR SubsystemName,
600 IN LPVOID HandleId,
601 IN LPCSTR ObjectTypeName,
602 IN LPCSTR ObjectName,
603 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
604 IN PSID PrincipalSelfSid,
605 IN DWORD DesiredAccess,
606 IN AUDIT_EVENT_TYPE AuditType,
607 IN DWORD Flags,
608 IN POBJECT_TYPE_LIST ObjectTypeList,
609 IN DWORD ObjectTypeListLength,
610 IN PGENERIC_MAPPING GenericMapping,
611 IN BOOL ObjectCreation,
612 OUT LPDWORD GrantedAccess,
613 OUT LPDWORD AccessStatusList,
614 OUT LPBOOL pfGenerateOnClose)
615 {
616 FIXME("%s() not implemented!\n", __FUNCTION__);
617 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
618 return FALSE;
619 }
620
621
622 /*
623 * @unimplemented
624 */
625 BOOL WINAPI
626 AccessCheckByTypeAndAuditAlarmW(IN LPCWSTR SubsystemName,
627 IN LPVOID HandleId,
628 IN LPCWSTR ObjectTypeName,
629 IN LPCWSTR ObjectName,
630 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
631 IN PSID PrincipalSelfSid,
632 IN DWORD DesiredAccess,
633 IN AUDIT_EVENT_TYPE AuditType,
634 IN DWORD Flags,
635 IN POBJECT_TYPE_LIST ObjectTypeList,
636 IN DWORD ObjectTypeListLength,
637 IN PGENERIC_MAPPING GenericMapping,
638 IN BOOL ObjectCreation,
639 OUT LPDWORD GrantedAccess,
640 OUT LPBOOL AccessStatus,
641 OUT LPBOOL pfGenerateOnClose)
642 {
643 FIXME("%s() not implemented!\n", __FUNCTION__);
644 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
645 return FALSE;
646 }
647
648
649 /*
650 * @unimplemented
651 */
652 BOOL WINAPI
653 AccessCheckByTypeAndAuditAlarmA(IN LPCSTR SubsystemName,
654 IN LPVOID HandleId,
655 IN LPCSTR ObjectTypeName,
656 IN LPCSTR ObjectName,
657 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
658 IN PSID PrincipalSelfSid,
659 IN DWORD DesiredAccess,
660 IN AUDIT_EVENT_TYPE AuditType,
661 IN DWORD Flags,
662 IN POBJECT_TYPE_LIST ObjectTypeList,
663 IN DWORD ObjectTypeListLength,
664 IN PGENERIC_MAPPING GenericMapping,
665 IN BOOL ObjectCreation,
666 OUT LPDWORD GrantedAccess,
667 OUT LPBOOL AccessStatus,
668 OUT LPBOOL pfGenerateOnClose)
669 {
670 FIXME("%s() not implemented!\n", __FUNCTION__);
671 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
672 return FALSE;
673 }
674
675 /* EOF */