ホーム › Security.Authentication.Identity › SspiUnmarshalAuthIdentity
SspiUnmarshalAuthIdentity
関数マーシャリング済みバイト配列からSSPI認証アイデンティティ構造体を復元する。
シグネチャ
// SECUR32.dll
#include <windows.h>
HRESULT SspiUnmarshalAuthIdentity(
DWORD AuthIdentityLength,
LPSTR AuthIdentityByteArray,
void** ppAuthIdentity
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| AuthIdentityLength | DWORD | in | AuthIdentityByteArrayのバイト数を指定する。 |
| AuthIdentityByteArray | LPSTR | in | アンマーシャリングする元のシリアライズ済みバイト配列へのポインタ。 |
| ppAuthIdentity | void** | out | 出力。復元された認証ID構造体を受け取るポインタ。SspiFreeAuthIdentityで解放する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
HRESULT SspiUnmarshalAuthIdentity(
DWORD AuthIdentityLength,
LPSTR AuthIdentityByteArray,
void** ppAuthIdentity
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SspiUnmarshalAuthIdentity(
uint AuthIdentityLength, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string AuthIdentityByteArray, // LPSTR
IntPtr ppAuthIdentity // void** out
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SspiUnmarshalAuthIdentity(
AuthIdentityLength As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> AuthIdentityByteArray As String, ' LPSTR
ppAuthIdentity As IntPtr ' void** out
) As Integer
End Function' AuthIdentityLength : DWORD
' AuthIdentityByteArray : LPSTR
' ppAuthIdentity : void** out
Declare PtrSafe Function SspiUnmarshalAuthIdentity Lib "secur32" ( _
ByVal AuthIdentityLength As Long, _
ByVal AuthIdentityByteArray As String, _
ByVal ppAuthIdentity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SspiUnmarshalAuthIdentity = ctypes.windll.secur32.SspiUnmarshalAuthIdentity
SspiUnmarshalAuthIdentity.restype = ctypes.c_int
SspiUnmarshalAuthIdentity.argtypes = [
wintypes.DWORD, # AuthIdentityLength : DWORD
wintypes.LPCSTR, # AuthIdentityByteArray : LPSTR
ctypes.c_void_p, # ppAuthIdentity : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
SspiUnmarshalAuthIdentity = Fiddle::Function.new(
lib['SspiUnmarshalAuthIdentity'],
[
-Fiddle::TYPE_INT, # AuthIdentityLength : DWORD
Fiddle::TYPE_VOIDP, # AuthIdentityByteArray : LPSTR
Fiddle::TYPE_VOIDP, # ppAuthIdentity : void** out
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn SspiUnmarshalAuthIdentity(
AuthIdentityLength: u32, // DWORD
AuthIdentityByteArray: *mut u8, // LPSTR
ppAuthIdentity: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int SspiUnmarshalAuthIdentity(uint AuthIdentityLength, [MarshalAs(UnmanagedType.LPStr)] string AuthIdentityByteArray, IntPtr ppAuthIdentity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SspiUnmarshalAuthIdentity' -Namespace Win32 -PassThru
# $api::SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)#uselib "SECUR32.dll"
#func global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" sptr, sptr, sptr
; SspiUnmarshalAuthIdentity AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity ; 戻り値は stat
; AuthIdentityLength : DWORD -> "sptr"
; AuthIdentityByteArray : LPSTR -> "sptr"
; ppAuthIdentity : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SECUR32.dll"
#cfunc global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" int, str, sptr
; res = SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
; AuthIdentityLength : DWORD -> "int"
; AuthIdentityByteArray : LPSTR -> "str"
; ppAuthIdentity : void** out -> "sptr"; HRESULT SspiUnmarshalAuthIdentity(DWORD AuthIdentityLength, LPSTR AuthIdentityByteArray, void** ppAuthIdentity)
#uselib "SECUR32.dll"
#cfunc global SspiUnmarshalAuthIdentity "SspiUnmarshalAuthIdentity" int, str, intptr
; res = SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
; AuthIdentityLength : DWORD -> "int"
; AuthIdentityByteArray : LPSTR -> "str"
; ppAuthIdentity : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procSspiUnmarshalAuthIdentity = secur32.NewProc("SspiUnmarshalAuthIdentity")
)
// AuthIdentityLength (DWORD), AuthIdentityByteArray (LPSTR), ppAuthIdentity (void** out)
r1, _, err := procSspiUnmarshalAuthIdentity.Call(
uintptr(AuthIdentityLength),
uintptr(unsafe.Pointer(windows.BytePtrFromString(AuthIdentityByteArray))),
uintptr(ppAuthIdentity),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SspiUnmarshalAuthIdentity(
AuthIdentityLength: DWORD; // DWORD
AuthIdentityByteArray: PAnsiChar; // LPSTR
ppAuthIdentity: Pointer // void** out
): Integer; stdcall;
external 'SECUR32.dll' name 'SspiUnmarshalAuthIdentity';result := DllCall("SECUR32\SspiUnmarshalAuthIdentity"
, "UInt", AuthIdentityLength ; DWORD
, "AStr", AuthIdentityByteArray ; LPSTR
, "Ptr", ppAuthIdentity ; void** out
, "Int") ; return: HRESULT●SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity) = DLL("SECUR32.dll", "int SspiUnmarshalAuthIdentity(dword, char*, void*)")
# 呼び出し: SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
# AuthIdentityLength : DWORD -> "dword"
# AuthIdentityByteArray : LPSTR -> "char*"
# ppAuthIdentity : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "secur32" fn SspiUnmarshalAuthIdentity(
AuthIdentityLength: u32, // DWORD
AuthIdentityByteArray: [*c]const u8, // LPSTR
ppAuthIdentity: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc SspiUnmarshalAuthIdentity(
AuthIdentityLength: uint32, # DWORD
AuthIdentityByteArray: cstring, # LPSTR
ppAuthIdentity: pointer # void** out
): int32 {.importc: "SspiUnmarshalAuthIdentity", stdcall, dynlib: "SECUR32.dll".}pragma(lib, "secur32");
extern(Windows)
int SspiUnmarshalAuthIdentity(
uint AuthIdentityLength, // DWORD
const(char)* AuthIdentityByteArray, // LPSTR
void** ppAuthIdentity // void** out
);ccall((:SspiUnmarshalAuthIdentity, "SECUR32.dll"), stdcall, Int32,
(UInt32, Cstring, Ptr{Cvoid}),
AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
# AuthIdentityLength : DWORD -> UInt32
# AuthIdentityByteArray : LPSTR -> Cstring
# ppAuthIdentity : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SspiUnmarshalAuthIdentity(
uint32_t AuthIdentityLength,
const char* AuthIdentityByteArray,
void** ppAuthIdentity);
]]
local secur32 = ffi.load("secur32")
-- secur32.SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
-- AuthIdentityLength : DWORD
-- AuthIdentityByteArray : LPSTR
-- ppAuthIdentity : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SECUR32.dll');
const SspiUnmarshalAuthIdentity = lib.func('__stdcall', 'SspiUnmarshalAuthIdentity', 'int32_t', ['uint32_t', 'str', 'void *']);
// SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
// AuthIdentityLength : DWORD -> 'uint32_t'
// AuthIdentityByteArray : LPSTR -> 'str'
// ppAuthIdentity : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SECUR32.dll", {
SspiUnmarshalAuthIdentity: { parameters: ["u32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity)
// AuthIdentityLength : DWORD -> "u32"
// AuthIdentityByteArray : LPSTR -> "buffer"
// ppAuthIdentity : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SspiUnmarshalAuthIdentity(
uint32_t AuthIdentityLength,
const char* AuthIdentityByteArray,
void** ppAuthIdentity);
C, "SECUR32.dll");
// $ffi->SspiUnmarshalAuthIdentity(AuthIdentityLength, AuthIdentityByteArray, ppAuthIdentity);
// AuthIdentityLength : DWORD
// AuthIdentityByteArray : LPSTR
// ppAuthIdentity : void** out
// 構造体/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 Secur32 extends StdCallLibrary {
Secur32 INSTANCE = Native.load("secur32", Secur32.class);
int SspiUnmarshalAuthIdentity(
int AuthIdentityLength, // DWORD
String AuthIdentityByteArray, // LPSTR
Pointer ppAuthIdentity // void** out
);
}@[Link("secur32")]
lib LibSECUR32
fun SspiUnmarshalAuthIdentity = SspiUnmarshalAuthIdentity(
AuthIdentityLength : UInt32, # DWORD
AuthIdentityByteArray : UInt8*, # LPSTR
ppAuthIdentity : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SspiUnmarshalAuthIdentityNative = Int32 Function(Uint32, Pointer<Utf8>, Pointer<Void>);
typedef SspiUnmarshalAuthIdentityDart = int Function(int, Pointer<Utf8>, Pointer<Void>);
final SspiUnmarshalAuthIdentity = DynamicLibrary.open('SECUR32.dll')
.lookupFunction<SspiUnmarshalAuthIdentityNative, SspiUnmarshalAuthIdentityDart>('SspiUnmarshalAuthIdentity');
// AuthIdentityLength : DWORD -> Uint32
// AuthIdentityByteArray : LPSTR -> Pointer<Utf8>
// ppAuthIdentity : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SspiUnmarshalAuthIdentity(
AuthIdentityLength: DWORD; // DWORD
AuthIdentityByteArray: PAnsiChar; // LPSTR
ppAuthIdentity: Pointer // void** out
): Integer; stdcall;
external 'SECUR32.dll' name 'SspiUnmarshalAuthIdentity';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SspiUnmarshalAuthIdentity"
c_SspiUnmarshalAuthIdentity :: Word32 -> CString -> Ptr () -> IO Int32
-- AuthIdentityLength : DWORD -> Word32
-- AuthIdentityByteArray : LPSTR -> CString
-- ppAuthIdentity : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sspiunmarshalauthidentity =
foreign "SspiUnmarshalAuthIdentity"
(uint32_t @-> string @-> (ptr void) @-> returning int32_t)
(* AuthIdentityLength : DWORD -> uint32_t *)
(* AuthIdentityByteArray : LPSTR -> string *)
(* ppAuthIdentity : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library secur32 (t "SECUR32.dll"))
(cffi:use-foreign-library secur32)
(cffi:defcfun ("SspiUnmarshalAuthIdentity" sspi-unmarshal-auth-identity :convention :stdcall) :int32
(auth-identity-length :uint32) ; DWORD
(auth-identity-byte-array :string) ; LPSTR
(pp-auth-identity :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SspiUnmarshalAuthIdentity = Win32::API::More->new('SECUR32',
'int SspiUnmarshalAuthIdentity(DWORD AuthIdentityLength, LPCSTR AuthIdentityByteArray, LPVOID ppAuthIdentity)');
# my $ret = $SspiUnmarshalAuthIdentity->Call($AuthIdentityLength, $AuthIdentityByteArray, $ppAuthIdentity);
# AuthIdentityLength : DWORD -> DWORD
# AuthIdentityByteArray : LPSTR -> LPCSTR
# ppAuthIdentity : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。