xref: /reactos/sdk/lib/rtl/access.c (revision c2c66aff)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS system libraries
4  * FILE:            lib/rtl/access.c
5  * PURPOSE:         Access rights handling functions
6  * PROGRAMMERS:     Eric Kohl
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <rtl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* FUNCTIONS ***************************************************************/
16 
17 /*
18  * @implemented
19  */
20 BOOLEAN
21 NTAPI
RtlAreAllAccessesGranted(IN ACCESS_MASK GrantedAccess,IN ACCESS_MASK DesiredAccess)22 RtlAreAllAccessesGranted(IN ACCESS_MASK GrantedAccess,
23                          IN ACCESS_MASK DesiredAccess)
24 {
25     PAGED_CODE_RTL();
26 
27     /* Return if there's no leftover bits after granting all of them */
28     return !(~GrantedAccess & DesiredAccess);
29 }
30 
31 /*
32  * @implemented
33  */
34 BOOLEAN
35 NTAPI
RtlAreAnyAccessesGranted(IN ACCESS_MASK GrantedAccess,IN ACCESS_MASK DesiredAccess)36 RtlAreAnyAccessesGranted(IN ACCESS_MASK GrantedAccess,
37                          IN ACCESS_MASK DesiredAccess)
38 {
39     PAGED_CODE_RTL();
40 
41     /* Return if there's any leftover bits after granting all of them */
42     return ((GrantedAccess & DesiredAccess) != 0);
43 }
44 
45 /*
46  * @implemented
47  */
48 VOID
49 NTAPI
RtlMapGenericMask(IN OUT PACCESS_MASK AccessMask,IN PGENERIC_MAPPING GenericMapping)50 RtlMapGenericMask(IN OUT PACCESS_MASK AccessMask,
51                   IN PGENERIC_MAPPING GenericMapping)
52 {
53     PAGED_CODE_RTL();
54 
55     /* Convert mappings */
56     if (*AccessMask & GENERIC_READ) *AccessMask |= GenericMapping->GenericRead;
57     if (*AccessMask & GENERIC_WRITE) *AccessMask |= GenericMapping->GenericWrite;
58     if (*AccessMask & GENERIC_EXECUTE) *AccessMask |= GenericMapping->GenericExecute;
59     if (*AccessMask & GENERIC_ALL) *AccessMask |= GenericMapping->GenericAll;
60 
61     /* Clear generic flags */
62     *AccessMask &= ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
63 }
64 
65 /* EOF */
66