{-# LINE1"System\\Win32\\Security.hsc"#-}{-# OPTIONS_GHC -w #-}-- The above warning supression flag is a temporary kludge.-- While working on this module you are encouraged to remove it and fix-- any warnings in the module. See-- https://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings-- for details{-# LANGUAGE Trustworthy #-}------------------------------------------------------------------------------- |-- Module : System.Win32.Security-- Copyright : (c) Simon Marlow 2007-- License : BSD-style (see the file LICENSE)---- Maintainer : Simon Marlow-- Stability : provisional-- Portability : portable---- FFI-bindings to interact with Win32 Security-------------------------------------------------------------------------------moduleSystem.Win32.Security(-- * TypesSID,PSID,ACL,PACL,SECURITY_DESCRIPTOR,SECURITY_DESCRIPTOR_CONTROL,se_OWNER_DEFAULTED,se_GROUP_DEFAULTED,se_DACL_PRESENT,se_DACL_DEFAULTED,se_SACL_PRESENT,se_SACL_DEFAULTED,se_DACL_AUTO_INHERIT_REQ,se_SACL_AUTO_INHERIT_REQ,se_DACL_AUTO_INHERITED,se_SACL_AUTO_INHERITED,se_DACL_PROTECTED,se_SACL_PROTECTED,se_SELF_RELATIVE,SECURITY_INFORMATION,oWNER_SECURITY_INFORMATION,gROUP_SECURITY_INFORMATION,dACL_SECURITY_INFORMATION,sACL_SECURITY_INFORMATION,-- * FunctionsgetFileSecurity,)whereimportForeign-- import Foreign.CimportSystem.Win32.Types#include "windows_cconv.h" -- ---------------------------------------------------------------------------- Security DescriptorsnewtypeSECURITY_DESCRIPTOR=SECURITY_DESCRIPTORSECURITY_DESCRIPTORtypePSECURITY_DESCRIPTOR=PtrSECURITY_DESCRIPTORnewtypeSecurityDescriptor=SecurityDescriptor(ForeignPtrSECURITY_DESCRIPTOR)typeSECURITY_DESCRIPTOR_CONTROL=WORDse_OWNER_DEFAULTED::SECURITY_DESCRIPTOR_CONTROLse_OWNER_DEFAULTED=1se_GROUP_DEFAULTED::SECURITY_DESCRIPTOR_CONTROLse_GROUP_DEFAULTED=2se_DACL_PRESENT::SECURITY_DESCRIPTOR_CONTROLse_DACL_PRESENT=4se_DACL_DEFAULTED::SECURITY_DESCRIPTOR_CONTROLse_DACL_DEFAULTED=8se_SACL_PRESENT::SECURITY_DESCRIPTOR_CONTROLse_SACL_PRESENT=16se_SACL_DEFAULTED::SECURITY_DESCRIPTOR_CONTROLse_SACL_DEFAULTED=32se_DACL_AUTO_INHERIT_REQ::SECURITY_DESCRIPTOR_CONTROLse_DACL_AUTO_INHERIT_REQ=256se_SACL_AUTO_INHERIT_REQ::SECURITY_DESCRIPTOR_CONTROLse_SACL_AUTO_INHERIT_REQ=512se_DACL_AUTO_INHERITED::SECURITY_DESCRIPTOR_CONTROLse_DACL_AUTO_INHERITED=1024se_SACL_AUTO_INHERITED::SECURITY_DESCRIPTOR_CONTROLse_SACL_AUTO_INHERITED=2048se_DACL_PROTECTED::SECURITY_DESCRIPTOR_CONTROLse_DACL_PROTECTED=4096se_SACL_PROTECTED::SECURITY_DESCRIPTOR_CONTROLse_SACL_PROTECTED=8192se_SELF_RELATIVE::SECURITY_DESCRIPTOR_CONTROLse_SELF_RELATIVE=32768{-# LINE85"System\\Win32\\Security.hsc"#-}newtypeACL=ACLACL-- abstracttypePACL=PtrACLnewtypeSID=SIDSIDtypePSID=PtrSIDforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorControl"c_getSecurityDescriptorControl::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->PtrSECURITY_DESCRIPTOR_CONTROL-- pControl->LPDWORD-- lpdwRevision->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorDacl"c_getSecurityDescriptorDacl::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->LPBOOL-- lpbDaclPresent->PtrPACL-- pDacl->LPBOOL-- lpbDaclDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorGroup"c_getSecurityDescriptorGroup::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->PtrPSID-- pGroup->LPBOOL-- lpbGroupDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorLength"c_getSecurityDescriptorLength::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->IODWORDforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorOwner"c_getSecurityDescriptorOwner::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->PtrPSID-- pOwner->LPBOOL-- lpbOwnerDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h GetSecurityDescriptorSacl"c_getSecurityDescriptorSacl::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->LPBOOL-- lpbSaclPresent->PtrPACL-- pSacl->LPBOOL-- lpbSaclDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h InitializeSecurityDescriptor"c_initializeSecurityDescriptor::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->DWORD-- dwRevision->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h IsValidSecurityDescriptor"c_isValidSecurityDescriptor::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h SetSecurityDescriptorDacl"c_setSecurityDescriptorDacl::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->BOOL-- bDaclPresent->PACL-- pDacl->BOOL-- bDaclDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h SetSecurityDescriptorGroup"c_setSecurityDescriptorGroup::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->PSID-- pGroup->BOOL-- bGroupDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h SetSecurityDescriptorOwner"c_setSecurityDescriptorOwner::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->PSID-- pOwner->BOOL-- bOwnerDefaulted->IOBOOLforeignimportWINDOWS_CCONVunsafe"windows.h SetSecurityDescriptorSacl"c_setSecurityDescriptorSacl::PSECURITY_DESCRIPTOR-- pSecurityDescriptor->BOOL-- bSaclPresent->PACL-- pSacl->BOOL-- bSaclDefaulted->IOBOOL-- ----------------------------------------------------------------------------- PGENERIC_MAPPING-- PPRIVILEGE_SETtypeSECURITY_INFORMATION=DWORDoWNER_SECURITY_INFORMATION::SECURITY_INFORMATIONoWNER_SECURITY_INFORMATION=1gROUP_SECURITY_INFORMATION::SECURITY_INFORMATIONgROUP_SECURITY_INFORMATION=2dACL_SECURITY_INFORMATION::SECURITY_INFORMATIONdACL_SECURITY_INFORMATION=4sACL_SECURITY_INFORMATION::SECURITY_INFORMATIONsACL_SECURITY_INFORMATION=8{-# LINE188"System\\Win32\\Security.hsc"#-}-- , pROTECTED_DACL_SECURITY_INFORMATION = PROTECTED_DACL_SECURITY_INFORMATION-- , pROTECTED_SACL_SECURITY_INFORMATION = PROTECTED_SACL_SECURITY_INFORMATION-- , uNPROTECTED_DACL_SECURITY_INFORMATION = UNPROTECTED_DACL_SECURITY_INFORMATION-- , uNPROTECTED_SACL_SECURITY_INFORMATION = UNPROTECTED_SACL_SECURITY_INFORMATIONgetFileSecurity::String->SECURITY_INFORMATION->IOSecurityDescriptorgetFileSecurityfilenamesi=withTStringfilename$\lpFileName->with0$\lpnLengthNeeded->doc_GetFileSecuritylpFileNamesinullPtr0lpnLengthNeededneeded<-peeklpnLengthNeededfpSd<-mallocForeignPtrBytes(fromIntegralneeded)withForeignPtrfpSd$\pSd->dofailIfFalse_"getFileSecurity"$c_GetFileSecuritylpFileNamesipSdneededlpnLengthNeededreturn(SecurityDescriptorfpSd)foreignimportWINDOWS_CCONVunsafe"windows.h GetFileSecurityW"c_GetFileSecurity::LPCWSTR-- lpFileName->SECURITY_INFORMATION-- RequestedInformation->PSECURITY_DESCRIPTOR-- pSecurityDescriptor->DWORD-- nLength->LPDWORD-- lpnLengthNeeded->IOBOOL--foreign import WINDOWS_CCONV unsafe "windows.h AccessCheck"-- c_AccessCheck-- :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor-- -> HANDLE -- ClientToken-- -> DWORD -- DesiredAccess-- -> PGENERIC_MAPPING -- GenericMapping-- -> PPRIVILEGE_SET -- PrivilegeSet-- -> LPDWORD -- PrivilegeSetLength-- -> LPDWORD -- GrantedAccess-- -> LPBOOL -- AccessStatus-- -> IO BOOL-- foreign import WINDOWS_CCONV unsafe "windows.h OpenThreadToken"-- OpenThreadToken-- :: HANDLE -- ThreadHandle-- -> DWORD -- DesiredAccess-- -> BOOL -- OpenAsSelf-- -> PHANDLE -- TokenHandle-- -> IO BOOL