AddResourceAttributeAce
関数ACLにリソース属性ACEを追加する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pAcl | ACL* | inout | アクセス制御リスト (ACL) へのポインターです。この関数はこの ACL に ACE を追加します。このパラメーターの値を NULL にすることはできません。ACE は SYSTEM_RESOURCE_ATTRIBUTE_ACE 構造体の形式です。 | ||||||||||||
| dwAceRevision | ACE_REVISION | in | 変更する ACL のリビジョンレベルを指定します。この値には ACL_REVISION または ACL_REVISION_DS を指定できます。ACL にオブジェクト固有の ACE が含まれる場合は ACL_REVISION_DS を使用してください。 | ||||||||||||
| AceFlags | ACE_FLAGS | in | ACE の継承を制御するビットフラグの集合です。この関数は新しい ACE の ACE_HEADER 構造体の AceFlags メンバーにこれらのフラグを設定します。 Windows 8 の詳細なファイルアクセス許可 UI との整合性のため、アプリケーションは AceFlags パラメーターに CONTAINER_INHERIT_ACE および OBJECT_INHERIT_ACE フラグを指定する必要があります。 このパラメーターには次の値の組み合わせを指定できます。
| ||||||||||||
| AccessMask | DWORD | in | Windows 8 および Windows Server 2012 では 0 でなければなりません。 | ||||||||||||
| pSid | PSID | in | Windows 8 および Windows Server 2012 では Everyone SID (S-1-1-0) でなければなりません。 | ||||||||||||
| pAttributeInfo | CLAIM_SECURITY_ATTRIBUTES_INFORMATION* | in | ACE 内の SID の後に付加される属性情報を指定します。 | ||||||||||||
| pReturnLength | DWORD* | out | 実際に使用された ACL バッファーのサイズ (バイト単位) です。pAcl パラメーターで指定されたバッファーが十分な大きさでない場合、このパラメーターの値は ACL バッファーに必要な合計サイズになります。 |
戻り値の型: BOOL
公式ドキュメント
SYSTEM_RESOURCE_ATTRIBUTE_ACE アクセス制御エントリ (ACE) をシステムアクセス制御リスト (SACL) の末尾に追加します。
戻り値
関数が成功した場合は TRUE を返します。
関数が失敗した場合は FALSE を返します。拡張エラー情報を取得するには GetLastError を呼び出してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global AddResourceAttributeAce "AddResourceAttributeAce" sptr, int, int, int, sptr, sptr, sptr ; res = AddResourceAttributeAce(varptr(pAcl), dwAceRevision, AceFlags, AccessMask, pSid, varptr(pAttributeInfo), varptr(pReturnLength)) ; pAcl : ACL* in/out -> "sptr" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "sptr" ; pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "sptr" ; pReturnLength : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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" intptr, int, int, int, intptr, intptr, intptr ; res = AddResourceAttributeAce(varptr(pAcl), dwAceRevision, AceFlags, AccessMask, pSid, varptr(pAttributeInfo), varptr(pReturnLength)) ; pAcl : ACL* in/out -> "intptr" ; dwAceRevision : ACE_REVISION -> "int" ; AceFlags : ACE_FLAGS -> "int" ; AccessMask : DWORD -> "int" ; pSid : PSID -> "intptr" ; pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "intptr" ; pReturnLength : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "kernel32" fn AddResourceAttributeAce(
pAcl: [*c]ACL, // ACL* in/out
dwAceRevision: u32, // ACE_REVISION
AceFlags: u32, // ACE_FLAGS
AccessMask: u32, // DWORD
pSid: ?*anyopaque, // PSID
pAttributeInfo: [*c]CLAIM_SECURITY_ATTRIBUTES_INFORMATION, // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
pReturnLength: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc AddResourceAttributeAce(
pAcl: ptr ACL, # ACL* in/out
dwAceRevision: uint32, # ACE_REVISION
AceFlags: uint32, # ACE_FLAGS
AccessMask: uint32, # DWORD
pSid: pointer, # PSID
pAttributeInfo: ptr CLAIM_SECURITY_ATTRIBUTES_INFORMATION, # CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
pReturnLength: ptr uint32 # DWORD* out
): int32 {.importc: "AddResourceAttributeAce", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int AddResourceAttributeAce(
ACL* pAcl, // ACL* in/out
uint dwAceRevision, // ACE_REVISION
uint AceFlags, // ACE_FLAGS
uint AccessMask, // DWORD
void* pSid, // PSID
CLAIM_SECURITY_ATTRIBUTES_INFORMATION* pAttributeInfo, // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
uint* pReturnLength // DWORD* out
);ccall((:AddResourceAttributeAce, "KERNEL32.dll"), stdcall, Int32,
(Ptr{ACL}, UInt32, UInt32, UInt32, Ptr{Cvoid}, Ptr{CLAIM_SECURITY_ATTRIBUTES_INFORMATION}, Ptr{UInt32}),
pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
# pAcl : ACL* in/out -> Ptr{ACL}
# dwAceRevision : ACE_REVISION -> UInt32
# AceFlags : ACE_FLAGS -> UInt32
# AccessMask : DWORD -> UInt32
# pSid : PSID -> Ptr{Cvoid}
# pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> Ptr{CLAIM_SECURITY_ATTRIBUTES_INFORMATION}
# pReturnLength : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t AddResourceAttributeAce(
void* pAcl,
uint32_t dwAceRevision,
uint32_t AceFlags,
uint32_t AccessMask,
void* pSid,
void* pAttributeInfo,
uint32_t* pReturnLength);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
-- pAcl : ACL* in/out
-- dwAceRevision : ACE_REVISION
-- AceFlags : ACE_FLAGS
-- AccessMask : DWORD
-- pSid : PSID
-- pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
-- pReturnLength : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const AddResourceAttributeAce = lib.func('__stdcall', 'AddResourceAttributeAce', 'int32_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t', 'void *', 'void *', 'uint32_t *']);
// AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
// pAcl : ACL* in/out -> 'void *'
// dwAceRevision : ACE_REVISION -> 'uint32_t'
// AceFlags : ACE_FLAGS -> 'uint32_t'
// AccessMask : DWORD -> 'uint32_t'
// pSid : PSID -> 'void *'
// pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> 'void *'
// pReturnLength : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
AddResourceAttributeAce: { parameters: ["pointer", "u32", "u32", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength)
// pAcl : ACL* in/out -> "pointer"
// dwAceRevision : ACE_REVISION -> "u32"
// AceFlags : ACE_FLAGS -> "u32"
// AccessMask : DWORD -> "u32"
// pSid : PSID -> "pointer"
// pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> "pointer"
// pReturnLength : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t AddResourceAttributeAce(
void* pAcl,
uint32_t dwAceRevision,
uint32_t AceFlags,
uint32_t AccessMask,
void* pSid,
void* pAttributeInfo,
uint32_t* pReturnLength);
C, "KERNEL32.dll");
// $ffi->AddResourceAttributeAce(pAcl, dwAceRevision, AceFlags, AccessMask, pSid, pAttributeInfo, pReturnLength);
// pAcl : ACL* in/out
// dwAceRevision : ACE_REVISION
// AceFlags : ACE_FLAGS
// AccessMask : DWORD
// pSid : PSID
// pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
// pReturnLength : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
boolean AddResourceAttributeAce(
Pointer pAcl, // ACL* in/out
int dwAceRevision, // ACE_REVISION
int AceFlags, // ACE_FLAGS
int AccessMask, // DWORD
Pointer pSid, // PSID
Pointer pAttributeInfo, // CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
IntByReference pReturnLength // DWORD* out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun AddResourceAttributeAce = AddResourceAttributeAce(
pAcl : ACL*, # ACL* in/out
dwAceRevision : UInt32, # ACE_REVISION
AceFlags : UInt32, # ACE_FLAGS
AccessMask : UInt32, # DWORD
pSid : Void*, # PSID
pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION*, # CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
pReturnLength : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef AddResourceAttributeAceNative = Int32 Function(Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef AddResourceAttributeAceDart = int Function(Pointer<Void>, int, int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final AddResourceAttributeAce = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<AddResourceAttributeAceNative, AddResourceAttributeAceDart>('AddResourceAttributeAce');
// pAcl : ACL* in/out -> Pointer<Void>
// dwAceRevision : ACE_REVISION -> Uint32
// AceFlags : ACE_FLAGS -> Uint32
// AccessMask : DWORD -> Uint32
// pSid : PSID -> Pointer<Void>
// pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> Pointer<Void>
// pReturnLength : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "AddResourceAttributeAce"
c_AddResourceAttributeAce :: Ptr () -> Word32 -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr Word32 -> IO CInt
-- pAcl : ACL* in/out -> Ptr ()
-- dwAceRevision : ACE_REVISION -> Word32
-- AceFlags : ACE_FLAGS -> Word32
-- AccessMask : DWORD -> Word32
-- pSid : PSID -> Ptr ()
-- pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> Ptr ()
-- pReturnLength : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let addresourceattributeace =
foreign "AddResourceAttributeAce"
((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* pAcl : ACL* in/out -> (ptr void) *)
(* dwAceRevision : ACE_REVISION -> uint32_t *)
(* AceFlags : ACE_FLAGS -> uint32_t *)
(* AccessMask : DWORD -> uint32_t *)
(* pSid : PSID -> (ptr void) *)
(* pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> (ptr void) *)
(* pReturnLength : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("AddResourceAttributeAce" add-resource-attribute-ace :convention :stdcall) :int32
(p-acl :pointer) ; ACL* in/out
(dw-ace-revision :uint32) ; ACE_REVISION
(ace-flags :uint32) ; ACE_FLAGS
(access-mask :uint32) ; DWORD
(p-sid :pointer) ; PSID
(p-attribute-info :pointer) ; CLAIM_SECURITY_ATTRIBUTES_INFORMATION*
(p-return-length :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $AddResourceAttributeAce = Win32::API::More->new('KERNEL32',
'BOOL AddResourceAttributeAce(LPVOID pAcl, DWORD dwAceRevision, DWORD AceFlags, DWORD AccessMask, HANDLE pSid, LPVOID pAttributeInfo, LPVOID pReturnLength)');
# my $ret = $AddResourceAttributeAce->Call($pAcl, $dwAceRevision, $AceFlags, $AccessMask, $pSid, $pAttributeInfo, $pReturnLength);
# pAcl : ACL* in/out -> LPVOID
# dwAceRevision : ACE_REVISION -> DWORD
# AceFlags : ACE_FLAGS -> DWORD
# AccessMask : DWORD -> DWORD
# pSid : PSID -> HANDLE
# pAttributeInfo : CLAIM_SECURITY_ATTRIBUTES_INFORMATION* -> LPVOID
# pReturnLength : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。