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