ホーム › Security.Authentication.Identity › ApplyControlToken
ApplyControlToken
関数セキュリティコンテキストに制御トークンを適用する。
シグネチャ
// SECUR32.dll
#include <windows.h>
HRESULT ApplyControlToken(
SecHandle* phContext,
SecBufferDesc* pInput
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| phContext | SecHandle* | in |
| pInput | SecBufferDesc* | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
HRESULT ApplyControlToken(
SecHandle* phContext,
SecBufferDesc* pInput
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int ApplyControlToken(
IntPtr phContext, // SecHandle*
IntPtr pInput // SecBufferDesc*
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function ApplyControlToken(
phContext As IntPtr, ' SecHandle*
pInput As IntPtr ' SecBufferDesc*
) As Integer
End Function' phContext : SecHandle*
' pInput : SecBufferDesc*
Declare PtrSafe Function ApplyControlToken Lib "secur32" ( _
ByVal phContext As LongPtr, _
ByVal pInput As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ApplyControlToken = ctypes.windll.secur32.ApplyControlToken
ApplyControlToken.restype = ctypes.c_int
ApplyControlToken.argtypes = [
ctypes.c_void_p, # phContext : SecHandle*
ctypes.c_void_p, # pInput : SecBufferDesc*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
ApplyControlToken = Fiddle::Function.new(
lib['ApplyControlToken'],
[
Fiddle::TYPE_VOIDP, # phContext : SecHandle*
Fiddle::TYPE_VOIDP, # pInput : SecBufferDesc*
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn ApplyControlToken(
phContext: *mut SecHandle, // SecHandle*
pInput: *mut SecBufferDesc // SecBufferDesc*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int ApplyControlToken(IntPtr phContext, IntPtr pInput);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_ApplyControlToken' -Namespace Win32 -PassThru
# $api::ApplyControlToken(phContext, pInput)#uselib "SECUR32.dll"
#func global ApplyControlToken "ApplyControlToken" sptr, sptr
; ApplyControlToken varptr(phContext), varptr(pInput) ; 戻り値は stat
; phContext : SecHandle* -> "sptr"
; pInput : SecBufferDesc* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SECUR32.dll" #cfunc global ApplyControlToken "ApplyControlToken" var, var ; res = ApplyControlToken(phContext, pInput) ; phContext : SecHandle* -> "var" ; pInput : SecBufferDesc* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SECUR32.dll" #cfunc global ApplyControlToken "ApplyControlToken" sptr, sptr ; res = ApplyControlToken(varptr(phContext), varptr(pInput)) ; phContext : SecHandle* -> "sptr" ; pInput : SecBufferDesc* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ApplyControlToken(SecHandle* phContext, SecBufferDesc* pInput) #uselib "SECUR32.dll" #cfunc global ApplyControlToken "ApplyControlToken" var, var ; res = ApplyControlToken(phContext, pInput) ; phContext : SecHandle* -> "var" ; pInput : SecBufferDesc* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ApplyControlToken(SecHandle* phContext, SecBufferDesc* pInput) #uselib "SECUR32.dll" #cfunc global ApplyControlToken "ApplyControlToken" intptr, intptr ; res = ApplyControlToken(varptr(phContext), varptr(pInput)) ; phContext : SecHandle* -> "intptr" ; pInput : SecBufferDesc* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procApplyControlToken = secur32.NewProc("ApplyControlToken")
)
// phContext (SecHandle*), pInput (SecBufferDesc*)
r1, _, err := procApplyControlToken.Call(
uintptr(phContext),
uintptr(pInput),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ApplyControlToken(
phContext: Pointer; // SecHandle*
pInput: Pointer // SecBufferDesc*
): Integer; stdcall;
external 'SECUR32.dll' name 'ApplyControlToken';result := DllCall("SECUR32\ApplyControlToken"
, "Ptr", phContext ; SecHandle*
, "Ptr", pInput ; SecBufferDesc*
, "Int") ; return: HRESULT●ApplyControlToken(phContext, pInput) = DLL("SECUR32.dll", "int ApplyControlToken(void*, void*)")
# 呼び出し: ApplyControlToken(phContext, pInput)
# phContext : SecHandle* -> "void*"
# pInput : SecBufferDesc* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。