1 /*
2 * Copyright 2010 Vicente J. Botet Escriba
3 * Copyright 2015 Andrey Semashev
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * See http://www.boost.org/LICENSE_1_0.txt
7 */
8
9 #ifndef BOOST_WINAPI_SECURITY_HPP_INCLUDED_
10 #define BOOST_WINAPI_SECURITY_HPP_INCLUDED_
11
12 #include <boost/winapi/basic_types.hpp>
13
14 #ifdef BOOST_HAS_PRAGMA_ONCE
15 #pragma once
16 #endif
17
18 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
19
20 #include <boost/winapi/detail/header.hpp>
21
22 #if !defined( BOOST_USE_WINDOWS_H )
23 extern "C" {
24 struct _ACL;
25 struct _SECURITY_DESCRIPTOR;
26 #if defined( BOOST_WINAPI_IS_MINGW )
27 typedef _SECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR;
28 #else
29 typedef boost::winapi::PVOID_ PSECURITY_DESCRIPTOR;
30 #endif
31
32 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
33 InitializeSecurityDescriptor(
34 PSECURITY_DESCRIPTOR pSecurityDescriptor,
35 boost::winapi::DWORD_ dwRevision);
36 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
37 SetSecurityDescriptorDacl(
38 PSECURITY_DESCRIPTOR pSecurityDescriptor,
39 boost::winapi::BOOL_ bDaclPresent,
40 ::_ACL* pDacl,
41 boost::winapi::BOOL_ bDaclDefaulted);
42 }
43 #endif
44
45 namespace boost {
46 namespace winapi {
47
48 typedef PVOID_ PSID_;
49 typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_;
50
51 typedef struct BOOST_MAY_ALIAS _ACL {
52 BYTE_ AclRevision;
53 BYTE_ Sbz1;
54 WORD_ AclSize;
55 WORD_ AceCount;
56 WORD_ Sbz2;
57 } ACL_, *PACL_;
58
59 typedef struct BOOST_MAY_ALIAS _SECURITY_DESCRIPTOR {
60 BYTE_ Revision;
61 BYTE_ Sbz1;
62 SECURITY_DESCRIPTOR_CONTROL_ Control;
63 PSID_ Owner;
64 PSID_ Group;
65 PACL_ Sacl;
66 PACL_ Dacl;
67 } SECURITY_DESCRIPTOR_, *PISECURITY_DESCRIPTOR_;
68
69 // To abstract away the different ::PSECURITY_DESCRIPTOR on MinGW, we use PVOID_ universally here
70 // and cast the pointers to ::PSECURITY_DESCRIPTOR in wrapper functions.
71 typedef PVOID_ PSECURITY_DESCRIPTOR_;
72
InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR_ pSecurityDescriptor,DWORD_ dwRevision)73 BOOST_FORCEINLINE BOOL_ InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, DWORD_ dwRevision)
74 {
75 return ::InitializeSecurityDescriptor(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), dwRevision);
76 }
77
SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor,BOOL_ bDaclPresent,PACL_ pDacl,BOOL_ bDaclDefaulted)78 BOOST_FORCEINLINE BOOL_ SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, BOOL_ bDaclPresent, PACL_ pDacl, BOOL_ bDaclDefaulted)
79 {
80 return ::SetSecurityDescriptorDacl(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), bDaclPresent, reinterpret_cast< ::_ACL* >(pDacl), bDaclDefaulted);
81 }
82
83 }
84 }
85
86 #include <boost/winapi/detail/footer.hpp>
87
88 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
89 #endif // BOOST_WINAPI_SECURITY_HPP_INCLUDED_
90