Win32 API 日本語リファレンス
ホームSecurity › AddResourceAttributeAce

AddResourceAttributeAce

関数
ACLにリソース属性ACEを追加する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL AddResourceAttributeAce(
    ACL* pAcl,
    ACE_REVISION dwAceRevision,
    ACE_FLAGS AceFlags,
    DWORD AccessMask,
    PSID pSid,
    CLAIM_SECURITY_ATTRIBUTES_INFORMATION* pAttributeInfo,
    DWORD* pReturnLength
);

パラメーター

名前方向
pAclACL*inout
dwAceRevisionACE_REVISIONin
AceFlagsACE_FLAGSin
AccessMaskDWORDin
pSidPSIDin
pAttributeInfoCLAIM_SECURITY_ATTRIBUTES_INFORMATION*in
pReturnLengthDWORD*out

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL AddResourceAttributeAce(
    ACL* pAcl,
    ACE_REVISION dwAceRevision,
    ACE_FLAGS AceFlags,
    DWORD AccessMask,
    PSID pSid,
    CLAIM_SECURITY_ATTRIBUTES_INFORMATION* pAttributeInfo,
    DWORD* pReturnLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AddResourceAttributeAce(
    IntPtr pAcl,   // ACL* in/out
    uint dwAceRevision,   // ACE_REVISION
    uint AceFlags,   // ACE_FLAGS
    uint AccessMask,   // DWORD
    IntPtr pSid,   // PSID
    IntPtr pAttributeInfo,   // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
    out uint pReturnLength   // DWORD* out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AddResourceAttributeAce(
    pAcl As IntPtr,   ' ACL* in/out
    dwAceRevision As UInteger,   ' ACE_REVISION
    AceFlags As UInteger,   ' ACE_FLAGS
    AccessMask As UInteger,   ' DWORD
    pSid As IntPtr,   ' PSID
    pAttributeInfo As IntPtr,   ' CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
    <Out> ByRef pReturnLength As UInteger   ' DWORD* out
) As Boolean
End Function
' pAcl : ACL* in/out
' dwAceRevision : ACE_REVISION
' AceFlags : ACE_FLAGS
' AccessMask : DWORD
' pSid : PSID
' pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
' pReturnLength : DWORD* out
Declare PtrSafe Function AddResourceAttributeAce Lib "kernel32" ( _
    ByVal pAcl As LongPtr, _
    ByVal dwAceRevision As Long, _
    ByVal AceFlags As Long, _
    ByVal AccessMask As Long, _
    ByVal pSid As LongPtr, _
    ByVal pAttributeInfo As LongPtr, _
    ByRef pReturnLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AddResourceAttributeAce = ctypes.windll.kernel32.AddResourceAttributeAce
AddResourceAttributeAce.restype = wintypes.BOOL
AddResourceAttributeAce.argtypes = [
    ctypes.c_void_p,  # pAcl : ACL* in/out
    wintypes.DWORD,  # dwAceRevision : ACE_REVISION
    wintypes.DWORD,  # AceFlags : ACE_FLAGS
    wintypes.DWORD,  # AccessMask : DWORD
    wintypes.HANDLE,  # pSid : PSID
    ctypes.c_void_p,  # pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
    ctypes.POINTER(wintypes.DWORD),  # pReturnLength : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
AddResourceAttributeAce = Fiddle::Function.new(
  lib['AddResourceAttributeAce'],
  [
    Fiddle::TYPE_VOIDP,  # pAcl : ACL* in/out
    -Fiddle::TYPE_INT,  # dwAceRevision : ACE_REVISION
    -Fiddle::TYPE_INT,  # AceFlags : ACE_FLAGS
    -Fiddle::TYPE_INT,  # AccessMask : DWORD
    Fiddle::TYPE_VOIDP,  # pSid : PSID
    Fiddle::TYPE_VOIDP,  # pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
    Fiddle::TYPE_VOIDP,  # pReturnLength : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn AddResourceAttributeAce(
        pAcl: *mut ACL,  // ACL* in/out
        dwAceRevision: u32,  // ACE_REVISION
        AceFlags: u32,  // ACE_FLAGS
        AccessMask: u32,  // DWORD
        pSid: *mut core::ffi::c_void,  // PSID
        pAttributeInfo: *mut CLAIM_SECURITY_ATTRIBUTES_INFORMATION,  // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
        pReturnLength: *mut u32  // DWORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool AddResourceAttributeAce(IntPtr pAcl, uint dwAceRevision, uint AceFlags, uint AccessMask, IntPtr pSid, IntPtr pAttributeInfo, out uint pReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_AddResourceAttributeAce' -Namespace Win32 -PassThru
# $api::AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
#uselib "KERNEL32.dll"
#func global AddResourceAttributeAce "AddResourceAttributeAce" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; AddResourceAttributeAce varptr(pAcl), dwAceRevision, AceFlags, AccessMask, pSid, varptr(pAttributeInfo), varptr(pReturnLength)   ; 戻り値は stat
; pAcl : ACL* in/out -> "sptr"
; dwAceRevision : ACE_REVISION -> "sptr"
; AceFlags : ACE_FLAGS -> "sptr"
; AccessMask : DWORD -> "sptr"
; pSid : PSID -> "sptr"
; pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "sptr"
; pReturnLength : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global AddResourceAttributeAce "AddResourceAttributeAce" var, int, int, int, sptr, var, var
; res = AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
; pAcl : ACL* in/out -> "var"
; dwAceRevision : ACE_REVISION -> "int"
; AceFlags : ACE_FLAGS -> "int"
; AccessMask : DWORD -> "int"
; pSid : PSID -> "sptr"
; pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "var"
; pReturnLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL AddResourceAttributeAce(ACL* pAcl, ACE_REVISION dwAceRevision, ACE_FLAGS AceFlags, DWORD AccessMask, PSID pSid, CLAIM_SECURITY_ATTRIBUTES_INFORMATION* pAttributeInfo, DWORD* pReturnLength)
#uselib "KERNEL32.dll"
#cfunc global AddResourceAttributeAce "AddResourceAttributeAce" var, int, int, int, intptr, var, var
; res = AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
; pAcl : ACL* in/out -> "var"
; dwAceRevision : ACE_REVISION -> "int"
; AceFlags : ACE_FLAGS -> "int"
; AccessMask : DWORD -> "int"
; pSid : PSID -> "intptr"
; pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "var"
; pReturnLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procAddResourceAttributeAce = kernel32.NewProc("AddResourceAttributeAce")
)

// pAcl (ACL* in/out), dwAceRevision (ACE_REVISION), AceFlags (ACE_FLAGS), AccessMask (DWORD), pSid (PSID), pAttributeInfo (CLAIM_SECURITY_ATTRIBUTES_INFORMATION*), pReturnLength (DWORD* out)
r1, _, err := procAddResourceAttributeAce.Call(
	uintptr(pAcl),
	uintptr(dwAceRevision),
	uintptr(AceFlags),
	uintptr(AccessMask),
	uintptr(pSid),
	uintptr(pAttributeInfo),
	uintptr(pReturnLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AddResourceAttributeAce(
  pAcl: Pointer;   // ACL* in/out
  dwAceRevision: DWORD;   // ACE_REVISION
  AceFlags: DWORD;   // ACE_FLAGS
  AccessMask: DWORD;   // DWORD
  pSid: THandle;   // PSID
  pAttributeInfo: Pointer;   // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
  pReturnLength: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'AddResourceAttributeAce';
result := DllCall("KERNEL32\AddResourceAttributeAce"
    , "Ptr", pAcl   ; ACL* in/out
    , "UInt", dwAceRevision   ; ACE_REVISION
    , "UInt", AceFlags   ; ACE_FLAGS
    , "UInt", AccessMask   ; DWORD
    , "Ptr", pSid   ; PSID
    , "Ptr", pAttributeInfo   ; CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
    , "Ptr", pReturnLength   ; DWORD* out
    , "Int")   ; return: BOOL
●AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength) = DLL("KERNEL32.dll", "bool AddResourceAttributeAce(void*, dword, dword, dword, void*, void*, void*)")
# 呼び出し: AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
# pAcl : ACL* in/out -> "void*"
# dwAceRevision : ACE_REVISION -> "dword"
# AceFlags : ACE_FLAGS -> "dword"
# AccessMask : DWORD -> "dword"
# pSid : PSID -> "void*"
# pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "void*"
# pReturnLength : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。