ホーム › Security.Authorization › BuildImpersonateTrusteeA
BuildImpersonateTrusteeA
関数代理トラスティを設定してTRUSTEE構造体を初期化する。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
void BuildImpersonateTrusteeA(
TRUSTEE_A* pTrustee,
TRUSTEE_A* pImpersonateTrustee // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pTrustee | TRUSTEE_A* | inout | 代理情報を設定する対象のTRUSTEE_A構造体へのポインタ。 |
| pImpersonateTrustee | TRUSTEE_A* | inoptional | 偽装に使用する受託者を表すTRUSTEE_A構造体へのポインタ。 |
戻り値の型: void
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
void BuildImpersonateTrusteeA(
TRUSTEE_A* pTrustee,
TRUSTEE_A* pImpersonateTrustee // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern void BuildImpersonateTrusteeA(
IntPtr pTrustee, // TRUSTEE_A* in/out
IntPtr pImpersonateTrustee // TRUSTEE_A* optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Sub BuildImpersonateTrusteeA(
pTrustee As IntPtr, ' TRUSTEE_A* in/out
pImpersonateTrustee As IntPtr ' TRUSTEE_A* optional
)
End Sub' pTrustee : TRUSTEE_A* in/out
' pImpersonateTrustee : TRUSTEE_A* optional
Declare PtrSafe Sub BuildImpersonateTrusteeA Lib "advapi32" ( _
ByVal pTrustee As LongPtr, _
ByVal pImpersonateTrustee As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BuildImpersonateTrusteeA = ctypes.windll.advapi32.BuildImpersonateTrusteeA
BuildImpersonateTrusteeA.restype = None
BuildImpersonateTrusteeA.argtypes = [
ctypes.c_void_p, # pTrustee : TRUSTEE_A* in/out
ctypes.c_void_p, # pImpersonateTrustee : TRUSTEE_A* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
BuildImpersonateTrusteeA = Fiddle::Function.new(
lib['BuildImpersonateTrusteeA'],
[
Fiddle::TYPE_VOIDP, # pTrustee : TRUSTEE_A* in/out
Fiddle::TYPE_VOIDP, # pImpersonateTrustee : TRUSTEE_A* optional
],
Fiddle::TYPE_VOID)#[link(name = "advapi32")]
extern "system" {
fn BuildImpersonateTrusteeA(
pTrustee: *mut TRUSTEE_A, // TRUSTEE_A* in/out
pImpersonateTrustee: *mut TRUSTEE_A // TRUSTEE_A* optional
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern void BuildImpersonateTrusteeA(IntPtr pTrustee, IntPtr pImpersonateTrustee);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildImpersonateTrusteeA' -Namespace Win32 -PassThru
# $api::BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee)#uselib "ADVAPI32.dll"
#func global BuildImpersonateTrusteeA "BuildImpersonateTrusteeA" sptr, sptr
; BuildImpersonateTrusteeA varptr(pTrustee), varptr(pImpersonateTrustee)
; pTrustee : TRUSTEE_A* in/out -> "sptr"
; pImpersonateTrustee : TRUSTEE_A* optional -> "sptr"出力引数:
#uselib "ADVAPI32.dll" #func global BuildImpersonateTrusteeA "BuildImpersonateTrusteeA" var, var ; BuildImpersonateTrusteeA pTrustee, pImpersonateTrustee ; pTrustee : TRUSTEE_A* in/out -> "var" ; pImpersonateTrustee : TRUSTEE_A* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #func global BuildImpersonateTrusteeA "BuildImpersonateTrusteeA" sptr, sptr ; BuildImpersonateTrusteeA varptr(pTrustee), varptr(pImpersonateTrustee) ; pTrustee : TRUSTEE_A* in/out -> "sptr" ; pImpersonateTrustee : TRUSTEE_A* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void BuildImpersonateTrusteeA(TRUSTEE_A* pTrustee, TRUSTEE_A* pImpersonateTrustee) #uselib "ADVAPI32.dll" #func global BuildImpersonateTrusteeA "BuildImpersonateTrusteeA" var, var ; BuildImpersonateTrusteeA pTrustee, pImpersonateTrustee ; pTrustee : TRUSTEE_A* in/out -> "var" ; pImpersonateTrustee : TRUSTEE_A* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void BuildImpersonateTrusteeA(TRUSTEE_A* pTrustee, TRUSTEE_A* pImpersonateTrustee) #uselib "ADVAPI32.dll" #func global BuildImpersonateTrusteeA "BuildImpersonateTrusteeA" intptr, intptr ; BuildImpersonateTrusteeA varptr(pTrustee), varptr(pImpersonateTrustee) ; pTrustee : TRUSTEE_A* in/out -> "intptr" ; pImpersonateTrustee : TRUSTEE_A* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procBuildImpersonateTrusteeA = advapi32.NewProc("BuildImpersonateTrusteeA")
)
// pTrustee (TRUSTEE_A* in/out), pImpersonateTrustee (TRUSTEE_A* optional)
r1, _, err := procBuildImpersonateTrusteeA.Call(
uintptr(pTrustee),
uintptr(pImpersonateTrustee),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure BuildImpersonateTrusteeA(
pTrustee: Pointer; // TRUSTEE_A* in/out
pImpersonateTrustee: Pointer // TRUSTEE_A* optional
); stdcall;
external 'ADVAPI32.dll' name 'BuildImpersonateTrusteeA';result := DllCall("ADVAPI32\BuildImpersonateTrusteeA"
, "Ptr", pTrustee ; TRUSTEE_A* in/out
, "Ptr", pImpersonateTrustee ; TRUSTEE_A* optional
, "Int") ; return: void●BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee) = DLL("ADVAPI32.dll", "int BuildImpersonateTrusteeA(void*, void*)")
# 呼び出し: BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee)
# pTrustee : TRUSTEE_A* in/out -> "void*"
# pImpersonateTrustee : TRUSTEE_A* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn BuildImpersonateTrusteeA(
pTrustee: [*c]TRUSTEE_A, // TRUSTEE_A* in/out
pImpersonateTrustee: [*c]TRUSTEE_A // TRUSTEE_A* optional
) callconv(std.os.windows.WINAPI) void;proc BuildImpersonateTrusteeA(
pTrustee: ptr TRUSTEE_A, # TRUSTEE_A* in/out
pImpersonateTrustee: ptr TRUSTEE_A # TRUSTEE_A* optional
) {.importc: "BuildImpersonateTrusteeA", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
void BuildImpersonateTrusteeA(
TRUSTEE_A* pTrustee, // TRUSTEE_A* in/out
TRUSTEE_A* pImpersonateTrustee // TRUSTEE_A* optional
);ccall((:BuildImpersonateTrusteeA, "ADVAPI32.dll"), stdcall, Cvoid,
(Ptr{TRUSTEE_A}, Ptr{TRUSTEE_A}),
pTrustee, pImpersonateTrustee)
# pTrustee : TRUSTEE_A* in/out -> Ptr{TRUSTEE_A}
# pImpersonateTrustee : TRUSTEE_A* optional -> Ptr{TRUSTEE_A}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void BuildImpersonateTrusteeA(
void* pTrustee,
void* pImpersonateTrustee);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee)
-- pTrustee : TRUSTEE_A* in/out
-- pImpersonateTrustee : TRUSTEE_A* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const BuildImpersonateTrusteeA = lib.func('__stdcall', 'BuildImpersonateTrusteeA', 'void', ['void *', 'void *']);
// BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee)
// pTrustee : TRUSTEE_A* in/out -> 'void *'
// pImpersonateTrustee : TRUSTEE_A* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
BuildImpersonateTrusteeA: { parameters: ["pointer", "pointer"], result: "void" },
});
// lib.symbols.BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee)
// pTrustee : TRUSTEE_A* in/out -> "pointer"
// pImpersonateTrustee : TRUSTEE_A* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void BuildImpersonateTrusteeA(
void* pTrustee,
void* pImpersonateTrustee);
C, "ADVAPI32.dll");
// $ffi->BuildImpersonateTrusteeA(pTrustee, pImpersonateTrustee);
// pTrustee : TRUSTEE_A* in/out
// pImpersonateTrustee : TRUSTEE_A* 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);
void BuildImpersonateTrusteeA(
Pointer pTrustee, // TRUSTEE_A* in/out
Pointer pImpersonateTrustee // TRUSTEE_A* optional
);
}@[Link("advapi32")]
lib LibADVAPI32
fun BuildImpersonateTrusteeA = BuildImpersonateTrusteeA(
pTrustee : TRUSTEE_A*, # TRUSTEE_A* in/out
pImpersonateTrustee : TRUSTEE_A* # TRUSTEE_A* optional
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BuildImpersonateTrusteeANative = Void Function(Pointer<Void>, Pointer<Void>);
typedef BuildImpersonateTrusteeADart = void Function(Pointer<Void>, Pointer<Void>);
final BuildImpersonateTrusteeA = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<BuildImpersonateTrusteeANative, BuildImpersonateTrusteeADart>('BuildImpersonateTrusteeA');
// pTrustee : TRUSTEE_A* in/out -> Pointer<Void>
// pImpersonateTrustee : TRUSTEE_A* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure BuildImpersonateTrusteeA(
pTrustee: Pointer; // TRUSTEE_A* in/out
pImpersonateTrustee: Pointer // TRUSTEE_A* optional
); stdcall;
external 'ADVAPI32.dll' name 'BuildImpersonateTrusteeA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BuildImpersonateTrusteeA"
c_BuildImpersonateTrusteeA :: Ptr () -> Ptr () -> IO ()
-- pTrustee : TRUSTEE_A* in/out -> Ptr ()
-- pImpersonateTrustee : TRUSTEE_A* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let buildimpersonatetrusteea =
foreign "BuildImpersonateTrusteeA"
((ptr void) @-> (ptr void) @-> returning void)
(* pTrustee : TRUSTEE_A* in/out -> (ptr void) *)
(* pImpersonateTrustee : TRUSTEE_A* 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 ("BuildImpersonateTrusteeA" build-impersonate-trustee-a :convention :stdcall) :void
(p-trustee :pointer) ; TRUSTEE_A* in/out
(p-impersonate-trustee :pointer)) ; TRUSTEE_A* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BuildImpersonateTrusteeA = Win32::API::More->new('ADVAPI32',
'void BuildImpersonateTrusteeA(LPVOID pTrustee, LPVOID pImpersonateTrustee)');
# my $ret = $BuildImpersonateTrusteeA->Call($pTrustee, $pImpersonateTrustee);
# pTrustee : TRUSTEE_A* in/out -> LPVOID
# pImpersonateTrustee : TRUSTEE_A* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f BuildImpersonateTrusteeW (Unicode版) — 代理トラスティを設定してTRUSTEE構造体を初期化する。
使用する型