ホーム › Security.Cryptography › GetKeyStorageInterface
GetKeyStorageInterface
関数鍵ストレージプロバイダーの関数テーブルを取得する。
シグネチャ
// ncrypt.dll
#include <windows.h>
NTSTATUS GetKeyStorageInterface(
LPCWSTR pszProviderName,
NCRYPT_KEY_STORAGE_FUNCTION_TABLE** ppFunctionTable,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszProviderName | LPCWSTR | in |
| ppFunctionTable | NCRYPT_KEY_STORAGE_FUNCTION_TABLE** | out |
| dwFlags | DWORD | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// ncrypt.dll
#include <windows.h>
NTSTATUS GetKeyStorageInterface(
LPCWSTR pszProviderName,
NCRYPT_KEY_STORAGE_FUNCTION_TABLE** ppFunctionTable,
DWORD dwFlags
);[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int GetKeyStorageInterface(
[MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, // LPCWSTR
IntPtr ppFunctionTable, // NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
uint dwFlags // DWORD
);<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function GetKeyStorageInterface(
<MarshalAs(UnmanagedType.LPWStr)> pszProviderName As String, ' LPCWSTR
ppFunctionTable As IntPtr, ' NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
dwFlags As UInteger ' DWORD
) As Integer
End Function' pszProviderName : LPCWSTR
' ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
' dwFlags : DWORD
Declare PtrSafe Function GetKeyStorageInterface Lib "ncrypt" ( _
ByVal pszProviderName As LongPtr, _
ByVal ppFunctionTable As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetKeyStorageInterface = ctypes.windll.ncrypt.GetKeyStorageInterface
GetKeyStorageInterface.restype = ctypes.c_int
GetKeyStorageInterface.argtypes = [
wintypes.LPCWSTR, # pszProviderName : LPCWSTR
ctypes.c_void_p, # ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ncrypt.dll')
GetKeyStorageInterface = Fiddle::Function.new(
lib['GetKeyStorageInterface'],
[
Fiddle::TYPE_VOIDP, # pszProviderName : LPCWSTR
Fiddle::TYPE_VOIDP, # ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "ncrypt")]
extern "system" {
fn GetKeyStorageInterface(
pszProviderName: *const u16, // LPCWSTR
ppFunctionTable: *mut *mut NCRYPT_KEY_STORAGE_FUNCTION_TABLE, // NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ncrypt.dll")]
public static extern int GetKeyStorageInterface([MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, IntPtr ppFunctionTable, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_GetKeyStorageInterface' -Namespace Win32 -PassThru
# $api::GetKeyStorageInterface(pszProviderName, ppFunctionTable, dwFlags)#uselib "ncrypt.dll"
#func global GetKeyStorageInterface "GetKeyStorageInterface" sptr, sptr, sptr
; GetKeyStorageInterface pszProviderName, varptr(ppFunctionTable), dwFlags ; 戻り値は stat
; pszProviderName : LPCWSTR -> "sptr"
; ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ncrypt.dll" #cfunc global GetKeyStorageInterface "GetKeyStorageInterface" wstr, var, int ; res = GetKeyStorageInterface(pszProviderName, ppFunctionTable, dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ncrypt.dll" #cfunc global GetKeyStorageInterface "GetKeyStorageInterface" wstr, sptr, int ; res = GetKeyStorageInterface(pszProviderName, varptr(ppFunctionTable), dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS GetKeyStorageInterface(LPCWSTR pszProviderName, NCRYPT_KEY_STORAGE_FUNCTION_TABLE** ppFunctionTable, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global GetKeyStorageInterface "GetKeyStorageInterface" wstr, var, int ; res = GetKeyStorageInterface(pszProviderName, ppFunctionTable, dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS GetKeyStorageInterface(LPCWSTR pszProviderName, NCRYPT_KEY_STORAGE_FUNCTION_TABLE** ppFunctionTable, DWORD dwFlags) #uselib "ncrypt.dll" #cfunc global GetKeyStorageInterface "GetKeyStorageInterface" wstr, intptr, int ; res = GetKeyStorageInterface(pszProviderName, varptr(ppFunctionTable), dwFlags) ; pszProviderName : LPCWSTR -> "wstr" ; ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
procGetKeyStorageInterface = ncrypt.NewProc("GetKeyStorageInterface")
)
// pszProviderName (LPCWSTR), ppFunctionTable (NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out), dwFlags (DWORD)
r1, _, err := procGetKeyStorageInterface.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszProviderName))),
uintptr(ppFunctionTable),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction GetKeyStorageInterface(
pszProviderName: PWideChar; // LPCWSTR
ppFunctionTable: Pointer; // NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ncrypt.dll' name 'GetKeyStorageInterface';result := DllCall("ncrypt\GetKeyStorageInterface"
, "WStr", pszProviderName ; LPCWSTR
, "Ptr", ppFunctionTable ; NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out
, "UInt", dwFlags ; DWORD
, "Int") ; return: NTSTATUS●GetKeyStorageInterface(pszProviderName, ppFunctionTable, dwFlags) = DLL("ncrypt.dll", "int GetKeyStorageInterface(char*, void*, dword)")
# 呼び出し: GetKeyStorageInterface(pszProviderName, ppFunctionTable, dwFlags)
# pszProviderName : LPCWSTR -> "char*"
# ppFunctionTable : NCRYPT_KEY_STORAGE_FUNCTION_TABLE** out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。