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