ホーム › Security.Authorization › TreeResetNamedSecurityInfoA
TreeResetNamedSecurityInfoA
関数オブジェクトツリーのセキュリティ情報を再設定する(ANSI版)。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR TreeResetNamedSecurityInfoA(
LPSTR pObjectName,
SE_OBJECT_TYPE ObjectType,
OBJECT_SECURITY_INFORMATION SecurityInfo,
PSID pOwner, // optional
PSID pGroup, // optional
ACL* pDacl, // optional
ACL* pSacl, // optional
BOOL KeepExplicit,
FN_PROGRESS fnProgress, // optional
PROG_INVOKE_SETTING ProgressInvokeSetting,
void* Args // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pObjectName | LPSTR | in |
| ObjectType | SE_OBJECT_TYPE | in |
| SecurityInfo | OBJECT_SECURITY_INFORMATION | in |
| pOwner | PSID | inoptional |
| pGroup | PSID | inoptional |
| pDacl | ACL* | inoptional |
| pSacl | ACL* | inoptional |
| KeepExplicit | BOOL | in |
| fnProgress | FN_PROGRESS | inoptional |
| ProgressInvokeSetting | PROG_INVOKE_SETTING | in |
| Args | void* | inoptional |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR TreeResetNamedSecurityInfoA(
LPSTR pObjectName,
SE_OBJECT_TYPE ObjectType,
OBJECT_SECURITY_INFORMATION SecurityInfo,
PSID pOwner, // optional
PSID pGroup, // optional
ACL* pDacl, // optional
ACL* pSacl, // optional
BOOL KeepExplicit,
FN_PROGRESS fnProgress, // optional
PROG_INVOKE_SETTING ProgressInvokeSetting,
void* Args // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint TreeResetNamedSecurityInfoA(
[MarshalAs(UnmanagedType.LPStr)] string pObjectName, // LPSTR
int ObjectType, // SE_OBJECT_TYPE
uint SecurityInfo, // OBJECT_SECURITY_INFORMATION
IntPtr pOwner, // PSID optional
IntPtr pGroup, // PSID optional
IntPtr pDacl, // ACL* optional
IntPtr pSacl, // ACL* optional
bool KeepExplicit, // BOOL
IntPtr fnProgress, // FN_PROGRESS optional
int ProgressInvokeSetting, // PROG_INVOKE_SETTING
IntPtr Args // void* optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function TreeResetNamedSecurityInfoA(
<MarshalAs(UnmanagedType.LPStr)> pObjectName As String, ' LPSTR
ObjectType As Integer, ' SE_OBJECT_TYPE
SecurityInfo As UInteger, ' OBJECT_SECURITY_INFORMATION
pOwner As IntPtr, ' PSID optional
pGroup As IntPtr, ' PSID optional
pDacl As IntPtr, ' ACL* optional
pSacl As IntPtr, ' ACL* optional
KeepExplicit As Boolean, ' BOOL
fnProgress As IntPtr, ' FN_PROGRESS optional
ProgressInvokeSetting As Integer, ' PROG_INVOKE_SETTING
Args As IntPtr ' void* optional
) As UInteger
End Function' pObjectName : LPSTR
' ObjectType : SE_OBJECT_TYPE
' SecurityInfo : OBJECT_SECURITY_INFORMATION
' pOwner : PSID optional
' pGroup : PSID optional
' pDacl : ACL* optional
' pSacl : ACL* optional
' KeepExplicit : BOOL
' fnProgress : FN_PROGRESS optional
' ProgressInvokeSetting : PROG_INVOKE_SETTING
' Args : void* optional
Declare PtrSafe Function TreeResetNamedSecurityInfoA Lib "advapi32" ( _
ByVal pObjectName As String, _
ByVal ObjectType As Long, _
ByVal SecurityInfo As Long, _
ByVal pOwner As LongPtr, _
ByVal pGroup As LongPtr, _
ByVal pDacl As LongPtr, _
ByVal pSacl As LongPtr, _
ByVal KeepExplicit As Long, _
ByVal fnProgress As LongPtr, _
ByVal ProgressInvokeSetting As Long, _
ByVal Args As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TreeResetNamedSecurityInfoA = ctypes.windll.advapi32.TreeResetNamedSecurityInfoA
TreeResetNamedSecurityInfoA.restype = wintypes.DWORD
TreeResetNamedSecurityInfoA.argtypes = [
wintypes.LPCSTR, # pObjectName : LPSTR
ctypes.c_int, # ObjectType : SE_OBJECT_TYPE
wintypes.DWORD, # SecurityInfo : OBJECT_SECURITY_INFORMATION
wintypes.HANDLE, # pOwner : PSID optional
wintypes.HANDLE, # pGroup : PSID optional
ctypes.c_void_p, # pDacl : ACL* optional
ctypes.c_void_p, # pSacl : ACL* optional
wintypes.BOOL, # KeepExplicit : BOOL
ctypes.c_void_p, # fnProgress : FN_PROGRESS optional
ctypes.c_int, # ProgressInvokeSetting : PROG_INVOKE_SETTING
ctypes.POINTER(None), # Args : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
TreeResetNamedSecurityInfoA = Fiddle::Function.new(
lib['TreeResetNamedSecurityInfoA'],
[
Fiddle::TYPE_VOIDP, # pObjectName : LPSTR
Fiddle::TYPE_INT, # ObjectType : SE_OBJECT_TYPE
-Fiddle::TYPE_INT, # SecurityInfo : OBJECT_SECURITY_INFORMATION
Fiddle::TYPE_VOIDP, # pOwner : PSID optional
Fiddle::TYPE_VOIDP, # pGroup : PSID optional
Fiddle::TYPE_VOIDP, # pDacl : ACL* optional
Fiddle::TYPE_VOIDP, # pSacl : ACL* optional
Fiddle::TYPE_INT, # KeepExplicit : BOOL
Fiddle::TYPE_VOIDP, # fnProgress : FN_PROGRESS optional
Fiddle::TYPE_INT, # ProgressInvokeSetting : PROG_INVOKE_SETTING
Fiddle::TYPE_VOIDP, # Args : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn TreeResetNamedSecurityInfoA(
pObjectName: *mut u8, // LPSTR
ObjectType: i32, // SE_OBJECT_TYPE
SecurityInfo: u32, // OBJECT_SECURITY_INFORMATION
pOwner: *mut core::ffi::c_void, // PSID optional
pGroup: *mut core::ffi::c_void, // PSID optional
pDacl: *mut ACL, // ACL* optional
pSacl: *mut ACL, // ACL* optional
KeepExplicit: i32, // BOOL
fnProgress: *const core::ffi::c_void, // FN_PROGRESS optional
ProgressInvokeSetting: i32, // PROG_INVOKE_SETTING
Args: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint TreeResetNamedSecurityInfoA([MarshalAs(UnmanagedType.LPStr)] string pObjectName, int ObjectType, uint SecurityInfo, IntPtr pOwner, IntPtr pGroup, IntPtr pDacl, IntPtr pSacl, bool KeepExplicit, IntPtr fnProgress, int ProgressInvokeSetting, IntPtr Args);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_TreeResetNamedSecurityInfoA' -Namespace Win32 -PassThru
# $api::TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)#uselib "ADVAPI32.dll"
#func global TreeResetNamedSecurityInfoA "TreeResetNamedSecurityInfoA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; TreeResetNamedSecurityInfoA pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, varptr(pDacl), varptr(pSacl), KeepExplicit, fnProgress, ProgressInvokeSetting, Args ; 戻り値は stat
; pObjectName : LPSTR -> "sptr"
; ObjectType : SE_OBJECT_TYPE -> "sptr"
; SecurityInfo : OBJECT_SECURITY_INFORMATION -> "sptr"
; pOwner : PSID optional -> "sptr"
; pGroup : PSID optional -> "sptr"
; pDacl : ACL* optional -> "sptr"
; pSacl : ACL* optional -> "sptr"
; KeepExplicit : BOOL -> "sptr"
; fnProgress : FN_PROGRESS optional -> "sptr"
; ProgressInvokeSetting : PROG_INVOKE_SETTING -> "sptr"
; Args : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global TreeResetNamedSecurityInfoA "TreeResetNamedSecurityInfoA" str, int, int, sptr, sptr, var, var, int, sptr, int, sptr ; res = TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args) ; pObjectName : LPSTR -> "str" ; ObjectType : SE_OBJECT_TYPE -> "int" ; SecurityInfo : OBJECT_SECURITY_INFORMATION -> "int" ; pOwner : PSID optional -> "sptr" ; pGroup : PSID optional -> "sptr" ; pDacl : ACL* optional -> "var" ; pSacl : ACL* optional -> "var" ; KeepExplicit : BOOL -> "int" ; fnProgress : FN_PROGRESS optional -> "sptr" ; ProgressInvokeSetting : PROG_INVOKE_SETTING -> "int" ; Args : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global TreeResetNamedSecurityInfoA "TreeResetNamedSecurityInfoA" str, int, int, sptr, sptr, sptr, sptr, int, sptr, int, sptr ; res = TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, varptr(pDacl), varptr(pSacl), KeepExplicit, fnProgress, ProgressInvokeSetting, Args) ; pObjectName : LPSTR -> "str" ; ObjectType : SE_OBJECT_TYPE -> "int" ; SecurityInfo : OBJECT_SECURITY_INFORMATION -> "int" ; pOwner : PSID optional -> "sptr" ; pGroup : PSID optional -> "sptr" ; pDacl : ACL* optional -> "sptr" ; pSacl : ACL* optional -> "sptr" ; KeepExplicit : BOOL -> "int" ; fnProgress : FN_PROGRESS optional -> "sptr" ; ProgressInvokeSetting : PROG_INVOKE_SETTING -> "int" ; Args : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR TreeResetNamedSecurityInfoA(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, OBJECT_SECURITY_INFORMATION SecurityInfo, PSID pOwner, PSID pGroup, ACL* pDacl, ACL* pSacl, BOOL KeepExplicit, FN_PROGRESS fnProgress, PROG_INVOKE_SETTING ProgressInvokeSetting, void* Args) #uselib "ADVAPI32.dll" #cfunc global TreeResetNamedSecurityInfoA "TreeResetNamedSecurityInfoA" str, int, int, intptr, intptr, var, var, int, intptr, int, intptr ; res = TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args) ; pObjectName : LPSTR -> "str" ; ObjectType : SE_OBJECT_TYPE -> "int" ; SecurityInfo : OBJECT_SECURITY_INFORMATION -> "int" ; pOwner : PSID optional -> "intptr" ; pGroup : PSID optional -> "intptr" ; pDacl : ACL* optional -> "var" ; pSacl : ACL* optional -> "var" ; KeepExplicit : BOOL -> "int" ; fnProgress : FN_PROGRESS optional -> "intptr" ; ProgressInvokeSetting : PROG_INVOKE_SETTING -> "int" ; Args : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR TreeResetNamedSecurityInfoA(LPSTR pObjectName, SE_OBJECT_TYPE ObjectType, OBJECT_SECURITY_INFORMATION SecurityInfo, PSID pOwner, PSID pGroup, ACL* pDacl, ACL* pSacl, BOOL KeepExplicit, FN_PROGRESS fnProgress, PROG_INVOKE_SETTING ProgressInvokeSetting, void* Args) #uselib "ADVAPI32.dll" #cfunc global TreeResetNamedSecurityInfoA "TreeResetNamedSecurityInfoA" str, int, int, intptr, intptr, intptr, intptr, int, intptr, int, intptr ; res = TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, varptr(pDacl), varptr(pSacl), KeepExplicit, fnProgress, ProgressInvokeSetting, Args) ; pObjectName : LPSTR -> "str" ; ObjectType : SE_OBJECT_TYPE -> "int" ; SecurityInfo : OBJECT_SECURITY_INFORMATION -> "int" ; pOwner : PSID optional -> "intptr" ; pGroup : PSID optional -> "intptr" ; pDacl : ACL* optional -> "intptr" ; pSacl : ACL* optional -> "intptr" ; KeepExplicit : BOOL -> "int" ; fnProgress : FN_PROGRESS optional -> "intptr" ; ProgressInvokeSetting : PROG_INVOKE_SETTING -> "int" ; Args : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procTreeResetNamedSecurityInfoA = advapi32.NewProc("TreeResetNamedSecurityInfoA")
)
// pObjectName (LPSTR), ObjectType (SE_OBJECT_TYPE), SecurityInfo (OBJECT_SECURITY_INFORMATION), pOwner (PSID optional), pGroup (PSID optional), pDacl (ACL* optional), pSacl (ACL* optional), KeepExplicit (BOOL), fnProgress (FN_PROGRESS optional), ProgressInvokeSetting (PROG_INVOKE_SETTING), Args (void* optional)
r1, _, err := procTreeResetNamedSecurityInfoA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pObjectName))),
uintptr(ObjectType),
uintptr(SecurityInfo),
uintptr(pOwner),
uintptr(pGroup),
uintptr(pDacl),
uintptr(pSacl),
uintptr(KeepExplicit),
uintptr(fnProgress),
uintptr(ProgressInvokeSetting),
uintptr(Args),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction TreeResetNamedSecurityInfoA(
pObjectName: PAnsiChar; // LPSTR
ObjectType: Integer; // SE_OBJECT_TYPE
SecurityInfo: DWORD; // OBJECT_SECURITY_INFORMATION
pOwner: THandle; // PSID optional
pGroup: THandle; // PSID optional
pDacl: Pointer; // ACL* optional
pSacl: Pointer; // ACL* optional
KeepExplicit: BOOL; // BOOL
fnProgress: Pointer; // FN_PROGRESS optional
ProgressInvokeSetting: Integer; // PROG_INVOKE_SETTING
Args: Pointer // void* optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'TreeResetNamedSecurityInfoA';result := DllCall("ADVAPI32\TreeResetNamedSecurityInfoA"
, "AStr", pObjectName ; LPSTR
, "Int", ObjectType ; SE_OBJECT_TYPE
, "UInt", SecurityInfo ; OBJECT_SECURITY_INFORMATION
, "Ptr", pOwner ; PSID optional
, "Ptr", pGroup ; PSID optional
, "Ptr", pDacl ; ACL* optional
, "Ptr", pSacl ; ACL* optional
, "Int", KeepExplicit ; BOOL
, "Ptr", fnProgress ; FN_PROGRESS optional
, "Int", ProgressInvokeSetting ; PROG_INVOKE_SETTING
, "Ptr", Args ; void* optional
, "UInt") ; return: WIN32_ERROR●TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args) = DLL("ADVAPI32.dll", "dword TreeResetNamedSecurityInfoA(char*, int, dword, void*, void*, void*, void*, bool, void*, int, void*)")
# 呼び出し: TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)
# pObjectName : LPSTR -> "char*"
# ObjectType : SE_OBJECT_TYPE -> "int"
# SecurityInfo : OBJECT_SECURITY_INFORMATION -> "dword"
# pOwner : PSID optional -> "void*"
# pGroup : PSID optional -> "void*"
# pDacl : ACL* optional -> "void*"
# pSacl : ACL* optional -> "void*"
# KeepExplicit : BOOL -> "bool"
# fnProgress : FN_PROGRESS optional -> "void*"
# ProgressInvokeSetting : PROG_INVOKE_SETTING -> "int"
# Args : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。