GetSecurityDescriptorSacl
関数セキュリティ記述子からSACLを取得する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL GetSecurityDescriptorSacl(
PSECURITY_DESCRIPTOR pSecurityDescriptor,
BOOL* lpbSaclPresent,
ACL** pSacl,
BOOL* lpbSaclDefaulted
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pSecurityDescriptor | PSECURITY_DESCRIPTOR | in |
| lpbSaclPresent | BOOL* | out |
| pSacl | ACL** | out |
| lpbSaclDefaulted | BOOL* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL GetSecurityDescriptorSacl(
PSECURITY_DESCRIPTOR pSecurityDescriptor,
BOOL* lpbSaclPresent,
ACL** pSacl,
BOOL* lpbSaclDefaulted
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetSecurityDescriptorSacl(
IntPtr pSecurityDescriptor, // PSECURITY_DESCRIPTOR
out int lpbSaclPresent, // BOOL* out
IntPtr pSacl, // ACL** out
out int lpbSaclDefaulted // BOOL* out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetSecurityDescriptorSacl(
pSecurityDescriptor As IntPtr, ' PSECURITY_DESCRIPTOR
<Out> ByRef lpbSaclPresent As Integer, ' BOOL* out
pSacl As IntPtr, ' ACL** out
<Out> ByRef lpbSaclDefaulted As Integer ' BOOL* out
) As Boolean
End Function' pSecurityDescriptor : PSECURITY_DESCRIPTOR
' lpbSaclPresent : BOOL* out
' pSacl : ACL** out
' lpbSaclDefaulted : BOOL* out
Declare PtrSafe Function GetSecurityDescriptorSacl Lib "advapi32" ( _
ByVal pSecurityDescriptor As LongPtr, _
ByRef lpbSaclPresent As Long, _
ByVal pSacl As LongPtr, _
ByRef lpbSaclDefaulted As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSecurityDescriptorSacl = ctypes.windll.advapi32.GetSecurityDescriptorSacl
GetSecurityDescriptorSacl.restype = wintypes.BOOL
GetSecurityDescriptorSacl.argtypes = [
wintypes.HANDLE, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
ctypes.c_void_p, # lpbSaclPresent : BOOL* out
ctypes.c_void_p, # pSacl : ACL** out
ctypes.c_void_p, # lpbSaclDefaulted : BOOL* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
GetSecurityDescriptorSacl = Fiddle::Function.new(
lib['GetSecurityDescriptorSacl'],
[
Fiddle::TYPE_VOIDP, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
Fiddle::TYPE_VOIDP, # lpbSaclPresent : BOOL* out
Fiddle::TYPE_VOIDP, # pSacl : ACL** out
Fiddle::TYPE_VOIDP, # lpbSaclDefaulted : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn GetSecurityDescriptorSacl(
pSecurityDescriptor: *mut core::ffi::c_void, // PSECURITY_DESCRIPTOR
lpbSaclPresent: *mut i32, // BOOL* out
pSacl: *mut *mut ACL, // ACL** out
lpbSaclDefaulted: *mut i32 // BOOL* 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 GetSecurityDescriptorSacl(IntPtr pSecurityDescriptor, out int lpbSaclPresent, IntPtr pSacl, out int lpbSaclDefaulted);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetSecurityDescriptorSacl' -Namespace Win32 -PassThru
# $api::GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted)#uselib "ADVAPI32.dll"
#func global GetSecurityDescriptorSacl "GetSecurityDescriptorSacl" sptr, sptr, sptr, sptr
; GetSecurityDescriptorSacl pSecurityDescriptor, lpbSaclPresent, varptr(pSacl), lpbSaclDefaulted ; 戻り値は stat
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"
; lpbSaclPresent : BOOL* out -> "sptr"
; pSacl : ACL** out -> "sptr"
; lpbSaclDefaulted : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorSacl "GetSecurityDescriptorSacl" sptr, int, var, int ; res = GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr" ; lpbSaclPresent : BOOL* out -> "int" ; pSacl : ACL** out -> "var" ; lpbSaclDefaulted : BOOL* out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorSacl "GetSecurityDescriptorSacl" sptr, int, sptr, int ; res = GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, varptr(pSacl), lpbSaclDefaulted) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr" ; lpbSaclPresent : BOOL* out -> "int" ; pSacl : ACL** out -> "sptr" ; lpbSaclDefaulted : BOOL* out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL* lpbSaclPresent, ACL** pSacl, BOOL* lpbSaclDefaulted) #uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorSacl "GetSecurityDescriptorSacl" intptr, int, var, int ; res = GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr" ; lpbSaclPresent : BOOL* out -> "int" ; pSacl : ACL** out -> "var" ; lpbSaclDefaulted : BOOL* out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL* lpbSaclPresent, ACL** pSacl, BOOL* lpbSaclDefaulted) #uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorSacl "GetSecurityDescriptorSacl" intptr, int, intptr, int ; res = GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, varptr(pSacl), lpbSaclDefaulted) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr" ; lpbSaclPresent : BOOL* out -> "int" ; pSacl : ACL** out -> "intptr" ; lpbSaclDefaulted : BOOL* out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procGetSecurityDescriptorSacl = advapi32.NewProc("GetSecurityDescriptorSacl")
)
// pSecurityDescriptor (PSECURITY_DESCRIPTOR), lpbSaclPresent (BOOL* out), pSacl (ACL** out), lpbSaclDefaulted (BOOL* out)
r1, _, err := procGetSecurityDescriptorSacl.Call(
uintptr(pSecurityDescriptor),
uintptr(lpbSaclPresent),
uintptr(pSacl),
uintptr(lpbSaclDefaulted),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetSecurityDescriptorSacl(
pSecurityDescriptor: THandle; // PSECURITY_DESCRIPTOR
lpbSaclPresent: Pointer; // BOOL* out
pSacl: Pointer; // ACL** out
lpbSaclDefaulted: Pointer // BOOL* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetSecurityDescriptorSacl';result := DllCall("ADVAPI32\GetSecurityDescriptorSacl"
, "Ptr", pSecurityDescriptor ; PSECURITY_DESCRIPTOR
, "Ptr", lpbSaclPresent ; BOOL* out
, "Ptr", pSacl ; ACL** out
, "Ptr", lpbSaclDefaulted ; BOOL* out
, "Int") ; return: BOOL●GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted) = DLL("ADVAPI32.dll", "bool GetSecurityDescriptorSacl(void*, void*, void*, void*)")
# 呼び出し: GetSecurityDescriptorSacl(pSecurityDescriptor, lpbSaclPresent, pSacl, lpbSaclDefaulted)
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "void*"
# lpbSaclPresent : BOOL* out -> "void*"
# pSacl : ACL** out -> "void*"
# lpbSaclDefaulted : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。