90 lines
2.6 KiB
C++
90 lines
2.6 KiB
C++
/*
|
|
* Copyright 2010 Vicente J. Botet Escriba
|
|
* Copyright 2015 Andrey Semashev
|
|
*
|
|
* Distributed under the Boost Software License, Version 1.0.
|
|
* See http://www.boost.org/LICENSE_1_0.txt
|
|
*/
|
|
|
|
#ifndef ACTIV_BOOST_WINAPI_SECURITY_HPP_INCLUDED_
|
|
#define ACTIV_BOOST_WINAPI_SECURITY_HPP_INCLUDED_
|
|
|
|
#include <ActivBoost/winapi/basic_types.hpp>
|
|
|
|
#ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE
|
|
#pragma once
|
|
#endif
|
|
|
|
#if ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM
|
|
|
|
#include <ActivBoost/winapi/detail/header.hpp>
|
|
|
|
#if !defined( ACTIV_BOOST_USE_WINDOWS_H )
|
|
extern "C" {
|
|
struct _ACL;
|
|
struct _SECURITY_DESCRIPTOR;
|
|
#if defined( ACTIV_BOOST_WINAPI_IS_MINGW )
|
|
typedef _SECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR;
|
|
#else
|
|
typedef Boost::winapi::PVOID_ PSECURITY_DESCRIPTOR;
|
|
#endif
|
|
|
|
ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC
|
|
InitializeSecurityDescriptor(
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
Boost::winapi::DWORD_ dwRevision);
|
|
ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC
|
|
SetSecurityDescriptorDacl(
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
Boost::winapi::BOOL_ bDaclPresent,
|
|
::_ACL* pDacl,
|
|
Boost::winapi::BOOL_ bDaclDefaulted);
|
|
}
|
|
#endif
|
|
|
|
namespace Boost {
|
|
namespace winapi {
|
|
|
|
typedef PVOID_ PSID_;
|
|
typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_;
|
|
|
|
typedef struct ACTIV_BOOST_MAY_ALIAS _ACL {
|
|
BYTE_ AclRevision;
|
|
BYTE_ Sbz1;
|
|
WORD_ AclSize;
|
|
WORD_ AceCount;
|
|
WORD_ Sbz2;
|
|
} ACL_, *PACL_;
|
|
|
|
typedef struct ACTIV_BOOST_MAY_ALIAS _SECURITY_DESCRIPTOR {
|
|
BYTE_ Revision;
|
|
BYTE_ Sbz1;
|
|
SECURITY_DESCRIPTOR_CONTROL_ Control;
|
|
PSID_ Owner;
|
|
PSID_ Group;
|
|
PACL_ Sacl;
|
|
PACL_ Dacl;
|
|
} SECURITY_DESCRIPTOR_, *PISECURITY_DESCRIPTOR_;
|
|
|
|
// To abstract away the different ::PSECURITY_DESCRIPTOR on MinGW, we use PVOID_ universally here
|
|
// and cast the pointers to ::PSECURITY_DESCRIPTOR in wrapper functions.
|
|
typedef PVOID_ PSECURITY_DESCRIPTOR_;
|
|
|
|
ACTIV_BOOST_FORCEINLINE BOOL_ InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, DWORD_ dwRevision)
|
|
{
|
|
return ::InitializeSecurityDescriptor(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), dwRevision);
|
|
}
|
|
|
|
ACTIV_BOOST_FORCEINLINE BOOL_ SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, BOOL_ bDaclPresent, PACL_ pDacl, BOOL_ bDaclDefaulted)
|
|
{
|
|
return ::SetSecurityDescriptorDacl(reinterpret_cast< ::PSECURITY_DESCRIPTOR >(pSecurityDescriptor), bDaclPresent, reinterpret_cast< ::_ACL* >(pDacl), bDaclDefaulted);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#include <ActivBoost/winapi/detail/footer.hpp>
|
|
|
|
#endif // ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM
|
|
#endif // ACTIV_BOOST_WINAPI_SECURITY_HPP_INCLUDED_
|