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