security.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef BOOST_WINAPI_SECURITY_HPP_INCLUDED_
  9. #define BOOST_WINAPI_SECURITY_HPP_INCLUDED_
  10. #include <boost/winapi/basic_types.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. #pragma once
  13. #endif
  14. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  15. #include <boost/winapi/detail/header.hpp>
  16. #if !defined( BOOST_USE_WINDOWS_H )
  17. extern "C" {
  18. struct _ACL;
  19. struct _SECURITY_DESCRIPTOR;
  20. #if defined( BOOST_WINAPI_IS_MINGW )
  21. typedef _SECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR;
  22. #else
  23. typedef boost::winapi::PVOID_ PSECURITY_DESCRIPTOR;
  24. #endif
  25. BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  26. InitializeSecurityDescriptor(
  27. PSECURITY_DESCRIPTOR pSecurityDescriptor,
  28. boost::winapi::DWORD_ dwRevision);
  29. BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  30. SetSecurityDescriptorDacl(
  31. PSECURITY_DESCRIPTOR pSecurityDescriptor,
  32. boost::winapi::BOOL_ bDaclPresent,
  33. ::_ACL* pDacl,
  34. boost::winapi::BOOL_ bDaclDefaulted);
  35. }
  36. #endif
  37. namespace boost {
  38. namespace winapi {
  39. typedef PVOID_ PSID_;
  40. typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_;
  41. typedef struct BOOST_MAY_ALIAS _ACL {
  42. BYTE_ AclRevision;
  43. BYTE_ Sbz1;
  44. WORD_ AclSize;
  45. WORD_ AceCount;
  46. WORD_ Sbz2;
  47. } ACL_, *PACL_;
  48. typedef struct BOOST_MAY_ALIAS _SECURITY_DESCRIPTOR {
  49. BYTE_ Revision;
  50. BYTE_ Sbz1;
  51. SECURITY_DESCRIPTOR_CONTROL_ Control;
  52. PSID_ Owner;
  53. PSID_ Group;
  54. PACL_ Sacl;
  55. PACL_ Dacl;
  56. } SECURITY_DESCRIPTOR_, *PISECURITY_DESCRIPTOR_;
  57. // To abstract away the different ::PSECURITY_DESCRIPTOR on MinGW, we use PVOID_ universally here
  58. // and cast the pointers to ::PSECURITY_DESCRIPTOR in wrapper functions.
  59. typedef PVOID_ PSECURITY_DESCRIPTOR_;
  60. BOOST_FORCEINLINE BOOL_ InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, DWORD_ dwRevision)
  61. {
  62. return ::InitializeSecurityDescriptor(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), dwRevision);
  63. }
  64. BOOST_FORCEINLINE BOOL_ SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, BOOL_ bDaclPresent, PACL_ pDacl, BOOL_ bDaclDefaulted)
  65. {
  66. return ::SetSecurityDescriptorDacl(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), bDaclPresent, reinterpret_cast< ::_ACL* >(pDacl), bDaclDefaulted);
  67. }
  68. }
  69. }
  70. #include <boost/winapi/detail/footer.hpp>
  71. #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
  72. #endif // BOOST_WINAPI_SECURITY_HPP_INCLUDED_