ホーム › Security.Authorization › BuildTrusteeWithObjectsAndNameW
BuildTrusteeWithObjectsAndNameW
関数オブジェクトと名前を指定してTRUSTEE構造体を初期化する。
シグネチャ
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
void BuildTrusteeWithObjectsAndNameW(
TRUSTEE_W* pTrustee,
OBJECTS_AND_NAME_W* pObjName, // optional
SE_OBJECT_TYPE ObjectType, // optional
LPWSTR ObjectTypeName, // optional
LPWSTR InheritedObjectTypeName, // optional
LPWSTR Name // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pTrustee | TRUSTEE_W* | inout |
| pObjName | OBJECTS_AND_NAME_W* | inoptional |
| ObjectType | SE_OBJECT_TYPE | inoptional |
| ObjectTypeName | LPWSTR | inoptional |
| InheritedObjectTypeName | LPWSTR | inoptional |
| Name | LPWSTR | inoptional |
戻り値の型: void
各言語での呼び出し定義
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
void BuildTrusteeWithObjectsAndNameW(
TRUSTEE_W* pTrustee,
OBJECTS_AND_NAME_W* pObjName, // optional
SE_OBJECT_TYPE ObjectType, // optional
LPWSTR ObjectTypeName, // optional
LPWSTR InheritedObjectTypeName, // optional
LPWSTR Name // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void BuildTrusteeWithObjectsAndNameW(
IntPtr pTrustee, // TRUSTEE_W* in/out
IntPtr pObjName, // OBJECTS_AND_NAME_W* optional
int ObjectType, // SE_OBJECT_TYPE optional
[MarshalAs(UnmanagedType.LPWStr)] string ObjectTypeName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string InheritedObjectTypeName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string Name // LPWSTR optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub BuildTrusteeWithObjectsAndNameW(
pTrustee As IntPtr, ' TRUSTEE_W* in/out
pObjName As IntPtr, ' OBJECTS_AND_NAME_W* optional
ObjectType As Integer, ' SE_OBJECT_TYPE optional
<MarshalAs(UnmanagedType.LPWStr)> ObjectTypeName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> InheritedObjectTypeName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> Name As String ' LPWSTR optional
)
End Sub' pTrustee : TRUSTEE_W* in/out
' pObjName : OBJECTS_AND_NAME_W* optional
' ObjectType : SE_OBJECT_TYPE optional
' ObjectTypeName : LPWSTR optional
' InheritedObjectTypeName : LPWSTR optional
' Name : LPWSTR optional
Declare PtrSafe Sub BuildTrusteeWithObjectsAndNameW Lib "advapi32" ( _
ByVal pTrustee As LongPtr, _
ByVal pObjName As LongPtr, _
ByVal ObjectType As Long, _
ByVal ObjectTypeName As LongPtr, _
ByVal InheritedObjectTypeName As LongPtr, _
ByVal Name As LongPtr)
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BuildTrusteeWithObjectsAndNameW = ctypes.windll.advapi32.BuildTrusteeWithObjectsAndNameW
BuildTrusteeWithObjectsAndNameW.restype = None
BuildTrusteeWithObjectsAndNameW.argtypes = [
ctypes.c_void_p, # pTrustee : TRUSTEE_W* in/out
ctypes.c_void_p, # pObjName : OBJECTS_AND_NAME_W* optional
ctypes.c_int, # ObjectType : SE_OBJECT_TYPE optional
wintypes.LPCWSTR, # ObjectTypeName : LPWSTR optional
wintypes.LPCWSTR, # InheritedObjectTypeName : LPWSTR optional
wintypes.LPCWSTR, # Name : LPWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
BuildTrusteeWithObjectsAndNameW = Fiddle::Function.new(
lib['BuildTrusteeWithObjectsAndNameW'],
[
Fiddle::TYPE_VOIDP, # pTrustee : TRUSTEE_W* in/out
Fiddle::TYPE_VOIDP, # pObjName : OBJECTS_AND_NAME_W* optional
Fiddle::TYPE_INT, # ObjectType : SE_OBJECT_TYPE optional
Fiddle::TYPE_VOIDP, # ObjectTypeName : LPWSTR optional
Fiddle::TYPE_VOIDP, # InheritedObjectTypeName : LPWSTR optional
Fiddle::TYPE_VOIDP, # Name : LPWSTR optional
],
Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advapi32")]
extern "system" {
fn BuildTrusteeWithObjectsAndNameW(
pTrustee: *mut TRUSTEE_W, // TRUSTEE_W* in/out
pObjName: *mut OBJECTS_AND_NAME_W, // OBJECTS_AND_NAME_W* optional
ObjectType: i32, // SE_OBJECT_TYPE optional
ObjectTypeName: *mut u16, // LPWSTR optional
InheritedObjectTypeName: *mut u16, // LPWSTR optional
Name: *mut u16 // LPWSTR optional
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode)]
public static extern void BuildTrusteeWithObjectsAndNameW(IntPtr pTrustee, IntPtr pObjName, int ObjectType, [MarshalAs(UnmanagedType.LPWStr)] string ObjectTypeName, [MarshalAs(UnmanagedType.LPWStr)] string InheritedObjectTypeName, [MarshalAs(UnmanagedType.LPWStr)] string Name);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildTrusteeWithObjectsAndNameW' -Namespace Win32 -PassThru
# $api::BuildTrusteeWithObjectsAndNameW(pTrustee, pObjName, ObjectType, ObjectTypeName, InheritedObjectTypeName, Name)#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithObjectsAndNameW "BuildTrusteeWithObjectsAndNameW" wptr, wptr, wptr, wptr, wptr, wptr
; BuildTrusteeWithObjectsAndNameW varptr(pTrustee), varptr(pObjName), ObjectType, ObjectTypeName, InheritedObjectTypeName, Name
; pTrustee : TRUSTEE_W* in/out -> "wptr"
; pObjName : OBJECTS_AND_NAME_W* optional -> "wptr"
; ObjectType : SE_OBJECT_TYPE optional -> "wptr"
; ObjectTypeName : LPWSTR optional -> "wptr"
; InheritedObjectTypeName : LPWSTR optional -> "wptr"
; Name : LPWSTR optional -> "wptr"出力引数:
#uselib "ADVAPI32.dll" #func global BuildTrusteeWithObjectsAndNameW "BuildTrusteeWithObjectsAndNameW" var, var, int, wstr, wstr, wstr ; BuildTrusteeWithObjectsAndNameW pTrustee, pObjName, ObjectType, ObjectTypeName, InheritedObjectTypeName, Name ; pTrustee : TRUSTEE_W* in/out -> "var" ; pObjName : OBJECTS_AND_NAME_W* optional -> "var" ; ObjectType : SE_OBJECT_TYPE optional -> "int" ; ObjectTypeName : LPWSTR optional -> "wstr" ; InheritedObjectTypeName : LPWSTR optional -> "wstr" ; Name : LPWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #func global BuildTrusteeWithObjectsAndNameW "BuildTrusteeWithObjectsAndNameW" sptr, sptr, int, wstr, wstr, wstr ; BuildTrusteeWithObjectsAndNameW varptr(pTrustee), varptr(pObjName), ObjectType, ObjectTypeName, InheritedObjectTypeName, Name ; pTrustee : TRUSTEE_W* in/out -> "sptr" ; pObjName : OBJECTS_AND_NAME_W* optional -> "sptr" ; ObjectType : SE_OBJECT_TYPE optional -> "int" ; ObjectTypeName : LPWSTR optional -> "wstr" ; InheritedObjectTypeName : LPWSTR optional -> "wstr" ; Name : LPWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void BuildTrusteeWithObjectsAndNameW(TRUSTEE_W* pTrustee, OBJECTS_AND_NAME_W* pObjName, SE_OBJECT_TYPE ObjectType, LPWSTR ObjectTypeName, LPWSTR InheritedObjectTypeName, LPWSTR Name) #uselib "ADVAPI32.dll" #func global BuildTrusteeWithObjectsAndNameW "BuildTrusteeWithObjectsAndNameW" var, var, int, wstr, wstr, wstr ; BuildTrusteeWithObjectsAndNameW pTrustee, pObjName, ObjectType, ObjectTypeName, InheritedObjectTypeName, Name ; pTrustee : TRUSTEE_W* in/out -> "var" ; pObjName : OBJECTS_AND_NAME_W* optional -> "var" ; ObjectType : SE_OBJECT_TYPE optional -> "int" ; ObjectTypeName : LPWSTR optional -> "wstr" ; InheritedObjectTypeName : LPWSTR optional -> "wstr" ; Name : LPWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void BuildTrusteeWithObjectsAndNameW(TRUSTEE_W* pTrustee, OBJECTS_AND_NAME_W* pObjName, SE_OBJECT_TYPE ObjectType, LPWSTR ObjectTypeName, LPWSTR InheritedObjectTypeName, LPWSTR Name) #uselib "ADVAPI32.dll" #func global BuildTrusteeWithObjectsAndNameW "BuildTrusteeWithObjectsAndNameW" intptr, intptr, int, wstr, wstr, wstr ; BuildTrusteeWithObjectsAndNameW varptr(pTrustee), varptr(pObjName), ObjectType, ObjectTypeName, InheritedObjectTypeName, Name ; pTrustee : TRUSTEE_W* in/out -> "intptr" ; pObjName : OBJECTS_AND_NAME_W* optional -> "intptr" ; ObjectType : SE_OBJECT_TYPE optional -> "int" ; ObjectTypeName : LPWSTR optional -> "wstr" ; InheritedObjectTypeName : LPWSTR optional -> "wstr" ; Name : LPWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procBuildTrusteeWithObjectsAndNameW = advapi32.NewProc("BuildTrusteeWithObjectsAndNameW")
)
// pTrustee (TRUSTEE_W* in/out), pObjName (OBJECTS_AND_NAME_W* optional), ObjectType (SE_OBJECT_TYPE optional), ObjectTypeName (LPWSTR optional), InheritedObjectTypeName (LPWSTR optional), Name (LPWSTR optional)
r1, _, err := procBuildTrusteeWithObjectsAndNameW.Call(
uintptr(pTrustee),
uintptr(pObjName),
uintptr(ObjectType),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ObjectTypeName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(InheritedObjectTypeName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Name))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure BuildTrusteeWithObjectsAndNameW(
pTrustee: Pointer; // TRUSTEE_W* in/out
pObjName: Pointer; // OBJECTS_AND_NAME_W* optional
ObjectType: Integer; // SE_OBJECT_TYPE optional
ObjectTypeName: PWideChar; // LPWSTR optional
InheritedObjectTypeName: PWideChar; // LPWSTR optional
Name: PWideChar // LPWSTR optional
); stdcall;
external 'ADVAPI32.dll' name 'BuildTrusteeWithObjectsAndNameW';result := DllCall("ADVAPI32\BuildTrusteeWithObjectsAndNameW"
, "Ptr", pTrustee ; TRUSTEE_W* in/out
, "Ptr", pObjName ; OBJECTS_AND_NAME_W* optional
, "Int", ObjectType ; SE_OBJECT_TYPE optional
, "WStr", ObjectTypeName ; LPWSTR optional
, "WStr", InheritedObjectTypeName ; LPWSTR optional
, "WStr", Name ; LPWSTR optional
, "Int") ; return: void●BuildTrusteeWithObjectsAndNameW(pTrustee, pObjName, ObjectType, ObjectTypeName, InheritedObjectTypeName, Name) = DLL("ADVAPI32.dll", "int BuildTrusteeWithObjectsAndNameW(void*, void*, int, char*, char*, char*)")
# 呼び出し: BuildTrusteeWithObjectsAndNameW(pTrustee, pObjName, ObjectType, ObjectTypeName, InheritedObjectTypeName, Name)
# pTrustee : TRUSTEE_W* in/out -> "void*"
# pObjName : OBJECTS_AND_NAME_W* optional -> "void*"
# ObjectType : SE_OBJECT_TYPE optional -> "int"
# ObjectTypeName : LPWSTR optional -> "char*"
# InheritedObjectTypeName : LPWSTR optional -> "char*"
# Name : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。