TreeResetNamedSecurityInfoA
関数シグネチャ
// 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 | 更新されたセキュリティ情報を受け取るオブジェクトのルートノードオブジェクト名を指定する、null で終わる文字列へのポインターです。サポートされるオブジェクトはレジストリキーとファイルオブジェクトです。各オブジェクト種別の文字列形式の説明については、 SE_OBJECT_TYPE を参照してください。 |
| ObjectType | SE_OBJECT_TYPE | in | pObjectName パラメーターで指定されたオブジェクトの種類を示す、SE_OBJECT_TYPE 列挙体の値です。サポートされる値は、レジストリキーを表す SE_REGISTRY_KEY と、ファイルオブジェクトを表す SE_FILE_OBJECT です。 |
| SecurityInfo | OBJECT_SECURITY_INFORMATION | in | リセットするセキュリティ情報の種類を示す ビットフラグのセットです。このパラメーターには、 SECURITY_INFORMATION ビットフラグの組み合わせを指定できます。 |
| pOwner | PSID | inoptional | オブジェクトの所有者を識別する SID 構造体へのポインターです。この SID は、セキュリティ記述子の所有者 SID として割り当て可能なものでなければなりません。SecurityInfo パラメーターには OWNER_SECURITY_INFORMATION フラグを含める必要があります。所有者を設定するには、呼び出し元はルートオブジェクトを含む各オブジェクトに対して WRITE_OWNER アクセス権を持っている必要があります。所有者 SID を設定しない場合、このパラメーターは NULL にできます。 |
| pGroup | PSID | inoptional | オブジェクトのプライマリグループを識別する SID 構造体へのポインターです。SecurityInfo パラメーターには GROUP_SECURITY_INFORMATION フラグを含める必要があります。グループを設定するには、呼び出し元はルートオブジェクトを含む各オブジェクトに対して WRITE_OWNER アクセス権を持っている必要があります。プライマリグループ SID を設定しない場合、このパラメーターは NULL にできます。 |
| pDacl | ACL* | inoptional | リセット対象のオブジェクトの新しい DACL を表す アクセス制御リスト (ACL) 構造体へのポインターです。SecurityInfo パラメーターには DACL_SECURITY_INFORMATION フラグを含める必要があります。呼び出し元はルートオブジェクトを含む各オブジェクトに対して READ_CONTROL および WRITE_DAC アクセス権を持っている必要があります。DACL を設定しない場合、このパラメーターは NULL にできます。 |
| pSacl | ACL* | inoptional | リセット対象のオブジェクトの新しい SACL を表す ACL 構造体へのポインターです。SecurityInfo パラメーターには、SACL_SECURITY_INFORMATION、LABEL_SECURITY_INFORMATION、ATTRIBUTE_SECURITY_INFORMATION、SCOPE_SECURITY_INFORMATION、BACKUP_SECURITY_INFORMATION のいずれかのフラグを含める必要があります。SACL_SECURITY_INFORMATION または SCOPE_SECURITY_INFORMATION を設定する場合、呼び出し元は SE_SECURITY_NAME 特権を有効にしている必要があります。SACL を設定しない場合、このパラメーターは NULL にできます。 |
| KeepExplicit | BOOL | in | サブツリーに対して明示的に定義された ACE を保持するか削除するかを定義するブール値です。KeepExplicit が TRUE の場合、各サブツリーの DACL と SACL について明示的に定義された ACE は保持され、継承された ACE は pDacl と pSacl からの継承 ACE で置き換えられます。KeepExplicit が FALSE の場合、各サブツリーの DACL と SACL について明示的に定義された ACE は削除されてから、継承された ACE が pDacl と pSacl からの継承 ACE で置き換えられます。 |
| fnProgress | FN_PROGRESS | inoptional | TreeResetNamedSecurityInfo 関数の進行状況を追跡するために使用される関数へのポインターです。進行状況関数のプロトタイプは次のとおりです。
進行状況関数は、ノードが処理される際に呼び出し元へ進行状況とエラー情報を提供します。呼び出し元は fnProgress に進行状況関数を指定し、ツリー操作中に TreeResetNamedSecurityInfo は最後に処理されたオブジェクト名、その操作のエラー状態、および現在の PROG_INVOKE_SETTING 値を渡します。呼び出し元は pInvokeSetting を使用して PROG_INVOKE_SETTING 値を変更できます。 進行状況関数を使用しない場合は、このパラメーターを NULL に設定します。 |
| ProgressInvokeSetting | PROG_INVOKE_SETTING | in | 進行状況関数の初期設定を指定する PROG_INVOKE_SETTING 列挙体の値です。 |
| Args | void* | inoptional | 呼び出し元が指定する進行状況関数の引数となる VOID へのポインターです。 |
戻り値の型: WIN32_ERROR
公式ドキュメント
指定したオブジェクトツリーのセキュリティ記述子内の、指定したセキュリティ情報をリセットします。(ANSI)
戻り値
関数が成功した場合、ERROR_SUCCESS を返します。
関数が失敗した場合、WinError.h で定義されているエラーコードを返します。
解説(Remarks)
この関数では、所有者、グループ、DACL、SACL に NULL を設定することはサポートされていません。
呼び出し元が、要求された所有者、グループ、DACL、SACL の更新をサポートする適切な特権と権限を持っていない場合、いずれの更新も実行されません。
この関数は TreeSetNamedSecurityInfo 関数に似ています。
- TreeResetNamedSecurityInfo の KeepExplicit パラメーターが TRUE に設定されている場合、この関数は dwAction パラメーターを TREE_SEC_INFO_RESET_KEEP_EXPLICIT に設定した TreeSetNamedSecurityInfo と同等です。
- TreeResetNamedSecurityInfo の KeepExplicit パラメーターが FALSE に設定されている場合、この関数は dwAction パラメーターを TREE_SEC_INFO_RESET に設定した TreeSetNamedSecurityInfo と同等です。
aclapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして TreeResetNamedSecurityInfo を定義しています。エンコーディング中立なエイリアスの使用と、エンコーディング中立でないコードを混在させると、コンパイルエラーや実行時エラーを引き起こす不整合につながる可能性があります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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)。const std = @import("std");
extern "advapi32" fn TreeResetNamedSecurityInfoA(
pObjectName: [*c]const u8, // LPSTR
ObjectType: i32, // SE_OBJECT_TYPE
SecurityInfo: u32, // OBJECT_SECURITY_INFORMATION
pOwner: ?*anyopaque, // PSID optional
pGroup: ?*anyopaque, // PSID optional
pDacl: [*c]ACL, // ACL* optional
pSacl: [*c]ACL, // ACL* optional
KeepExplicit: i32, // BOOL
fnProgress: ?*anyopaque, // FN_PROGRESS optional
ProgressInvokeSetting: i32, // PROG_INVOKE_SETTING
Args: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;proc TreeResetNamedSecurityInfoA(
pObjectName: cstring, # LPSTR
ObjectType: int32, # SE_OBJECT_TYPE
SecurityInfo: uint32, # OBJECT_SECURITY_INFORMATION
pOwner: pointer, # PSID optional
pGroup: pointer, # PSID optional
pDacl: ptr ACL, # ACL* optional
pSacl: ptr ACL, # ACL* optional
KeepExplicit: int32, # BOOL
fnProgress: pointer, # FN_PROGRESS optional
ProgressInvokeSetting: int32, # PROG_INVOKE_SETTING
Args: pointer # void* optional
): uint32 {.importc: "TreeResetNamedSecurityInfoA", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
uint TreeResetNamedSecurityInfoA(
const(char)* pObjectName, // LPSTR
int ObjectType, // SE_OBJECT_TYPE
uint SecurityInfo, // OBJECT_SECURITY_INFORMATION
void* pOwner, // PSID optional
void* pGroup, // PSID optional
ACL* pDacl, // ACL* optional
ACL* pSacl, // ACL* optional
int KeepExplicit, // BOOL
void* fnProgress, // FN_PROGRESS optional
int ProgressInvokeSetting, // PROG_INVOKE_SETTING
void* Args // void* optional
);ccall((:TreeResetNamedSecurityInfoA, "ADVAPI32.dll"), stdcall, UInt32,
(Cstring, Int32, UInt32, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{ACL}, Ptr{ACL}, Int32, Ptr{Cvoid}, Int32, Ptr{Cvoid}),
pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)
# pObjectName : LPSTR -> Cstring
# ObjectType : SE_OBJECT_TYPE -> Int32
# SecurityInfo : OBJECT_SECURITY_INFORMATION -> UInt32
# pOwner : PSID optional -> Ptr{Cvoid}
# pGroup : PSID optional -> Ptr{Cvoid}
# pDacl : ACL* optional -> Ptr{ACL}
# pSacl : ACL* optional -> Ptr{ACL}
# KeepExplicit : BOOL -> Int32
# fnProgress : FN_PROGRESS optional -> Ptr{Cvoid}
# ProgressInvokeSetting : PROG_INVOKE_SETTING -> Int32
# Args : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t TreeResetNamedSecurityInfoA(
const char* pObjectName,
int32_t ObjectType,
uint32_t SecurityInfo,
void* pOwner,
void* pGroup,
void* pDacl,
void* pSacl,
int32_t KeepExplicit,
void* fnProgress,
int32_t ProgressInvokeSetting,
void* Args);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)
-- 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
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const TreeResetNamedSecurityInfoA = lib.func('__stdcall', 'TreeResetNamedSecurityInfoA', 'uint32_t', ['str', 'int32_t', 'uint32_t', 'void *', 'void *', 'void *', 'void *', 'int32_t', 'void *', 'int32_t', 'void *']);
// TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)
// pObjectName : LPSTR -> 'str'
// ObjectType : SE_OBJECT_TYPE -> 'int32_t'
// SecurityInfo : OBJECT_SECURITY_INFORMATION -> 'uint32_t'
// pOwner : PSID optional -> 'void *'
// pGroup : PSID optional -> 'void *'
// pDacl : ACL* optional -> 'void *'
// pSacl : ACL* optional -> 'void *'
// KeepExplicit : BOOL -> 'int32_t'
// fnProgress : FN_PROGRESS optional -> 'void *'
// ProgressInvokeSetting : PROG_INVOKE_SETTING -> 'int32_t'
// Args : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("ADVAPI32.dll", {
TreeResetNamedSecurityInfoA: { parameters: ["buffer", "i32", "u32", "pointer", "pointer", "pointer", "pointer", "i32", "pointer", "i32", "pointer"], result: "u32" },
});
// lib.symbols.TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args)
// pObjectName : LPSTR -> "buffer"
// ObjectType : SE_OBJECT_TYPE -> "i32"
// SecurityInfo : OBJECT_SECURITY_INFORMATION -> "u32"
// pOwner : PSID optional -> "pointer"
// pGroup : PSID optional -> "pointer"
// pDacl : ACL* optional -> "pointer"
// pSacl : ACL* optional -> "pointer"
// KeepExplicit : BOOL -> "i32"
// fnProgress : FN_PROGRESS optional -> "pointer"
// ProgressInvokeSetting : PROG_INVOKE_SETTING -> "i32"
// Args : void* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t TreeResetNamedSecurityInfoA(
const char* pObjectName,
int32_t ObjectType,
uint32_t SecurityInfo,
void* pOwner,
void* pGroup,
void* pDacl,
void* pSacl,
int32_t KeepExplicit,
void* fnProgress,
int32_t ProgressInvokeSetting,
void* Args);
C, "ADVAPI32.dll");
// $ffi->TreeResetNamedSecurityInfoA(pObjectName, ObjectType, SecurityInfo, pOwner, pGroup, pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args);
// 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
// 構造体/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 Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class, W32APIOptions.ASCII_OPTIONS);
int TreeResetNamedSecurityInfoA(
String pObjectName, // LPSTR
int ObjectType, // SE_OBJECT_TYPE
int SecurityInfo, // OBJECT_SECURITY_INFORMATION
Pointer pOwner, // PSID optional
Pointer pGroup, // PSID optional
Pointer pDacl, // ACL* optional
Pointer pSacl, // ACL* optional
boolean KeepExplicit, // BOOL
Callback fnProgress, // FN_PROGRESS optional
int ProgressInvokeSetting, // PROG_INVOKE_SETTING
Pointer Args // void* optional
);
}@[Link("advapi32")]
lib LibADVAPI32
fun TreeResetNamedSecurityInfoA = TreeResetNamedSecurityInfoA(
pObjectName : UInt8*, # LPSTR
ObjectType : Int32, # SE_OBJECT_TYPE
SecurityInfo : UInt32, # OBJECT_SECURITY_INFORMATION
pOwner : Void*, # PSID optional
pGroup : Void*, # PSID optional
pDacl : ACL*, # ACL* optional
pSacl : ACL*, # ACL* optional
KeepExplicit : Int32, # BOOL
fnProgress : Void*, # FN_PROGRESS optional
ProgressInvokeSetting : Int32, # PROG_INVOKE_SETTING
Args : Void* # void* optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TreeResetNamedSecurityInfoANative = Uint32 Function(Pointer<Utf8>, Int32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Int32, Pointer<Void>, Int32, Pointer<Void>);
typedef TreeResetNamedSecurityInfoADart = int Function(Pointer<Utf8>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>);
final TreeResetNamedSecurityInfoA = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<TreeResetNamedSecurityInfoANative, TreeResetNamedSecurityInfoADart>('TreeResetNamedSecurityInfoA');
// pObjectName : LPSTR -> Pointer<Utf8>
// ObjectType : SE_OBJECT_TYPE -> Int32
// SecurityInfo : OBJECT_SECURITY_INFORMATION -> Uint32
// pOwner : PSID optional -> Pointer<Void>
// pGroup : PSID optional -> Pointer<Void>
// pDacl : ACL* optional -> Pointer<Void>
// pSacl : ACL* optional -> Pointer<Void>
// KeepExplicit : BOOL -> Int32
// fnProgress : FN_PROGRESS optional -> Pointer<Void>
// ProgressInvokeSetting : PROG_INVOKE_SETTING -> Int32
// Args : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TreeResetNamedSecurityInfoA"
c_TreeResetNamedSecurityInfoA :: CString -> Int32 -> Word32 -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> CInt -> Ptr () -> Int32 -> Ptr () -> IO Word32
-- pObjectName : LPSTR -> CString
-- ObjectType : SE_OBJECT_TYPE -> Int32
-- SecurityInfo : OBJECT_SECURITY_INFORMATION -> Word32
-- pOwner : PSID optional -> Ptr ()
-- pGroup : PSID optional -> Ptr ()
-- pDacl : ACL* optional -> Ptr ()
-- pSacl : ACL* optional -> Ptr ()
-- KeepExplicit : BOOL -> CInt
-- fnProgress : FN_PROGRESS optional -> Ptr ()
-- ProgressInvokeSetting : PROG_INVOKE_SETTING -> Int32
-- Args : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let treeresetnamedsecurityinfoa =
foreign "TreeResetNamedSecurityInfoA"
(string @-> int32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> int32_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> returning uint32_t)
(* pObjectName : LPSTR -> string *)
(* ObjectType : SE_OBJECT_TYPE -> int32_t *)
(* SecurityInfo : OBJECT_SECURITY_INFORMATION -> uint32_t *)
(* pOwner : PSID optional -> (ptr void) *)
(* pGroup : PSID optional -> (ptr void) *)
(* pDacl : ACL* optional -> (ptr void) *)
(* pSacl : ACL* optional -> (ptr void) *)
(* KeepExplicit : BOOL -> int32_t *)
(* fnProgress : FN_PROGRESS optional -> (ptr void) *)
(* ProgressInvokeSetting : PROG_INVOKE_SETTING -> int32_t *)
(* Args : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("TreeResetNamedSecurityInfoA" tree-reset-named-security-info-a :convention :stdcall) :uint32
(p-object-name :string) ; LPSTR
(object-type :int32) ; SE_OBJECT_TYPE
(security-info :uint32) ; OBJECT_SECURITY_INFORMATION
(p-owner :pointer) ; PSID optional
(p-group :pointer) ; PSID optional
(p-dacl :pointer) ; ACL* optional
(p-sacl :pointer) ; ACL* optional
(keep-explicit :int32) ; BOOL
(fn-progress :pointer) ; FN_PROGRESS optional
(progress-invoke-setting :int32) ; PROG_INVOKE_SETTING
(args :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TreeResetNamedSecurityInfoA = Win32::API::More->new('ADVAPI32',
'DWORD TreeResetNamedSecurityInfoA(LPCSTR pObjectName, int ObjectType, DWORD SecurityInfo, HANDLE pOwner, HANDLE pGroup, LPVOID pDacl, LPVOID pSacl, BOOL KeepExplicit, LPVOID fnProgress, int ProgressInvokeSetting, LPVOID Args)');
# my $ret = $TreeResetNamedSecurityInfoA->Call($pObjectName, $ObjectType, $SecurityInfo, $pOwner, $pGroup, $pDacl, $pSacl, $KeepExplicit, $fnProgress, $ProgressInvokeSetting, $Args);
# pObjectName : LPSTR -> LPCSTR
# ObjectType : SE_OBJECT_TYPE -> int
# SecurityInfo : OBJECT_SECURITY_INFORMATION -> DWORD
# pOwner : PSID optional -> HANDLE
# pGroup : PSID optional -> HANDLE
# pDacl : ACL* optional -> LPVOID
# pSacl : ACL* optional -> LPVOID
# KeepExplicit : BOOL -> BOOL
# fnProgress : FN_PROGRESS optional -> LPVOID
# ProgressInvokeSetting : PROG_INVOKE_SETTING -> int
# Args : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
- f TreeResetNamedSecurityInfoW (Unicode版) — オブジェクトツリーのセキュリティ情報を再設定する(Unicode版)。