AddConditionalAce
関数ACLに条件式付きのアクセス制御エントリを追加する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL AddConditionalAce(
ACL* pAcl,
ACE_REVISION dwAceRevision,
ACE_FLAGS AceFlags,
BYTE AceType,
DWORD AccessMask,
PSID pSid,
LPWSTR ConditionStr,
DWORD* ReturnLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pAcl | ACL* | inout |
| dwAceRevision | ACE_REVISION | in |
| AceFlags | ACE_FLAGS | in |
| AceType | BYTE | in |
| AccessMask | DWORD | in |
| pSid | PSID | in |
| ConditionStr | LPWSTR | in |
| ReturnLength | DWORD* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL AddConditionalAce(
ACL* pAcl,
ACE_REVISION dwAceRevision,
ACE_FLAGS AceFlags,
BYTE AceType,
DWORD AccessMask,
PSID pSid,
LPWSTR ConditionStr,
DWORD* ReturnLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AddConditionalAce(
IntPtr pAcl, // ACL* in/out
uint dwAceRevision, // ACE_REVISION
uint AceFlags, // ACE_FLAGS
byte AceType, // BYTE
uint AccessMask, // DWORD
IntPtr pSid, // PSID
[MarshalAs(UnmanagedType.LPWStr)] string ConditionStr, // LPWSTR
out uint ReturnLength // DWORD* out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AddConditionalAce(
pAcl As IntPtr, ' ACL* in/out
dwAceRevision As UInteger, ' ACE_REVISION
AceFlags As UInteger, ' ACE_FLAGS
AceType As Byte, ' BYTE
AccessMask As UInteger, ' DWORD
pSid As IntPtr, ' PSID
<MarshalAs(UnmanagedType.LPWStr)> ConditionStr As String, ' LPWSTR
<Out> ByRef ReturnLength As UInteger ' DWORD* out
) As Boolean
End Function' pAcl : ACL* in/out
' dwAceRevision : ACE_REVISION
' AceFlags : ACE_FLAGS
' AceType : BYTE
' AccessMask : DWORD
' pSid : PSID
' ConditionStr : LPWSTR
' ReturnLength : DWORD* out
Declare PtrSafe Function AddConditionalAce Lib "advapi32" ( _
ByVal pAcl As LongPtr, _
ByVal dwAceRevision As Long, _
ByVal AceFlags As Long, _
ByVal AceType As Byte, _
ByVal AccessMask As Long, _
ByVal pSid As LongPtr, _
ByVal ConditionStr As LongPtr, _
ByRef ReturnLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AddConditionalAce = ctypes.windll.advapi32.AddConditionalAce
AddConditionalAce.restype = wintypes.BOOL
AddConditionalAce.argtypes = [
ctypes.c_void_p, # pAcl : ACL* in/out
wintypes.DWORD, # dwAceRevision : ACE_REVISION
wintypes.DWORD, # AceFlags : ACE_FLAGS
ctypes.c_ubyte, # AceType : BYTE
wintypes.DWORD, # AccessMask : DWORD
wintypes.HANDLE, # pSid : PSID
wintypes.LPCWSTR, # ConditionStr : LPWSTR
ctypes.POINTER(wintypes.DWORD), # ReturnLength : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
AddConditionalAce = Fiddle::Function.new(
lib['AddConditionalAce'],
[
Fiddle::TYPE_VOIDP, # pAcl : ACL* in/out
-Fiddle::TYPE_INT, # dwAceRevision : ACE_REVISION
-Fiddle::TYPE_INT, # AceFlags : ACE_FLAGS
-Fiddle::TYPE_CHAR, # AceType : BYTE
-Fiddle::TYPE_INT, # AccessMask : DWORD
Fiddle::TYPE_VOIDP, # pSid : PSID
Fiddle::TYPE_VOIDP, # ConditionStr : LPWSTR
Fiddle::TYPE_VOIDP, # ReturnLength : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn AddConditionalAce(
pAcl: *mut ACL, // ACL* in/out
dwAceRevision: u32, // ACE_REVISION
AceFlags: u32, // ACE_FLAGS
AceType: u8, // BYTE
AccessMask: u32, // DWORD
pSid: *mut core::ffi::c_void, // PSID
ConditionStr: *mut u16, // LPWSTR
ReturnLength: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool AddConditionalAce(IntPtr pAcl, uint dwAceRevision, uint AceFlags, byte AceType, uint AccessMask, IntPtr pSid, [MarshalAs(UnmanagedType.LPWStr)] string ConditionStr, out uint ReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_AddConditionalAce' -Namespace Win32 -PassThru
# $api::AddConditionalAce(pAcl, dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, ReturnLength)#uselib "ADVAPI32.dll"
#func global AddConditionalAce "AddConditionalAce" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; AddConditionalAce varptr(pAcl), dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, varptr(ReturnLength) ; 戻り値は stat
; pAcl : ACL* in/out -> "sptr"
; dwAceRevision : ACE_REVISION -> "sptr"
; AceFlags : ACE_FLAGS -> "sptr"
; AceType : BYTE -> "sptr"
; AccessMask : DWORD -> "sptr"
; pSid : PSID -> "sptr"
; ConditionStr : LPWSTR -> "sptr"
; ReturnLength : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global AddConditionalAce "AddConditionalAce" var, int, int, int, int, sptr, wstr, var ; res = AddConditionalAce(pAcl, dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, ReturnLength) ; pAcl : ACL* in/out -> "var" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AceType : BYTE -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "sptr" ; ConditionStr : LPWSTR -> "wstr" ; ReturnLength : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global AddConditionalAce "AddConditionalAce" sptr, int, int, int, int, sptr, wstr, sptr ; res = AddConditionalAce(varptr(pAcl), dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, varptr(ReturnLength)) ; pAcl : ACL* in/out -> "sptr" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AceType : BYTE -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "sptr" ; ConditionStr : LPWSTR -> "wstr" ; ReturnLength : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL AddConditionalAce(ACL* pAcl, ACE_REVISION dwAceRevision, ACE_FLAGS AceFlags, BYTE AceType, DWORD AccessMask, PSID pSid, LPWSTR ConditionStr, DWORD* ReturnLength) #uselib "ADVAPI32.dll" #cfunc global AddConditionalAce "AddConditionalAce" var, int, int, int, int, intptr, wstr, var ; res = AddConditionalAce(pAcl, dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, ReturnLength) ; pAcl : ACL* in/out -> "var" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AceType : BYTE -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "intptr" ; ConditionStr : LPWSTR -> "wstr" ; ReturnLength : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL AddConditionalAce(ACL* pAcl, ACE_REVISION dwAceRevision, ACE_FLAGS AceFlags, BYTE AceType, DWORD AccessMask, PSID pSid, LPWSTR ConditionStr, DWORD* ReturnLength) #uselib "ADVAPI32.dll" #cfunc global AddConditionalAce "AddConditionalAce" intptr, int, int, int, int, intptr, wstr, intptr ; res = AddConditionalAce(varptr(pAcl), dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, varptr(ReturnLength)) ; pAcl : ACL* in/out -> "intptr" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AceType : BYTE -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "intptr" ; ConditionStr : LPWSTR -> "wstr" ; ReturnLength : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procAddConditionalAce = advapi32.NewProc("AddConditionalAce")
)
// pAcl (ACL* in/out), dwAceRevision (ACE_REVISION), AceFlags (ACE_FLAGS), AceType (BYTE), AccessMask (DWORD), pSid (PSID), ConditionStr (LPWSTR), ReturnLength (DWORD* out)
r1, _, err := procAddConditionalAce.Call(
uintptr(pAcl),
uintptr(dwAceRevision),
uintptr(AceFlags),
uintptr(AceType),
uintptr(AccessMask),
uintptr(pSid),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ConditionStr))),
uintptr(ReturnLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction AddConditionalAce(
pAcl: Pointer; // ACL* in/out
dwAceRevision: DWORD; // ACE_REVISION
AceFlags: DWORD; // ACE_FLAGS
AceType: Byte; // BYTE
AccessMask: DWORD; // DWORD
pSid: THandle; // PSID
ConditionStr: PWideChar; // LPWSTR
ReturnLength: Pointer // DWORD* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'AddConditionalAce';result := DllCall("ADVAPI32\AddConditionalAce"
, "Ptr", pAcl ; ACL* in/out
, "UInt", dwAceRevision ; ACE_REVISION
, "UInt", AceFlags ; ACE_FLAGS
, "UChar", AceType ; BYTE
, "UInt", AccessMask ; DWORD
, "Ptr", pSid ; PSID
, "WStr", ConditionStr ; LPWSTR
, "Ptr", ReturnLength ; DWORD* out
, "Int") ; return: BOOL●AddConditionalAce(pAcl, dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, ReturnLength) = DLL("ADVAPI32.dll", "bool AddConditionalAce(void*, dword, dword, byte, dword, void*, char*, void*)")
# 呼び出し: AddConditionalAce(pAcl, dwAceRevision, AceFlags, AceType, AccessMask, pSid, ConditionStr, ReturnLength)
# pAcl : ACL* in/out -> "void*"
# dwAceRevision : ACE_REVISION -> "dword"
# AceFlags : ACE_FLAGS -> "dword"
# AceType : BYTE -> "byte"
# AccessMask : DWORD -> "dword"
# pSid : PSID -> "void*"
# ConditionStr : LPWSTR -> "char*"
# ReturnLength : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。