ホーム › Security.Cryptography › CryptHashSessionKey
CryptHashSessionKey
関数セッション鍵の内容をハッシュオブジェクトに追加する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL CryptHashSessionKey(
UINT_PTR hHash,
UINT_PTR hKey,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hHash | UINT_PTR | in |
| hKey | UINT_PTR | in |
| dwFlags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL CryptHashSessionKey(
UINT_PTR hHash,
UINT_PTR hKey,
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptHashSessionKey(
UIntPtr hHash, // UINT_PTR
UIntPtr hKey, // UINT_PTR
uint dwFlags // DWORD
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptHashSessionKey(
hHash As UIntPtr, ' UINT_PTR
hKey As UIntPtr, ' UINT_PTR
dwFlags As UInteger ' DWORD
) As Boolean
End Function' hHash : UINT_PTR
' hKey : UINT_PTR
' dwFlags : DWORD
Declare PtrSafe Function CryptHashSessionKey Lib "advapi32" ( _
ByVal hHash As LongPtr, _
ByVal hKey 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
CryptHashSessionKey = ctypes.windll.advapi32.CryptHashSessionKey
CryptHashSessionKey.restype = wintypes.BOOL
CryptHashSessionKey.argtypes = [
ctypes.c_size_t, # hHash : UINT_PTR
ctypes.c_size_t, # hKey : UINT_PTR
wintypes.DWORD, # dwFlags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
CryptHashSessionKey = Fiddle::Function.new(
lib['CryptHashSessionKey'],
[
Fiddle::TYPE_UINTPTR_T, # hHash : UINT_PTR
Fiddle::TYPE_UINTPTR_T, # hKey : UINT_PTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn CryptHashSessionKey(
hHash: usize, // UINT_PTR
hKey: usize, // UINT_PTR
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool CryptHashSessionKey(UIntPtr hHash, UIntPtr hKey, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_CryptHashSessionKey' -Namespace Win32 -PassThru
# $api::CryptHashSessionKey(hHash, hKey, dwFlags)#uselib "ADVAPI32.dll"
#func global CryptHashSessionKey "CryptHashSessionKey" sptr, sptr, sptr
; CryptHashSessionKey hHash, hKey, dwFlags ; 戻り値は stat
; hHash : UINT_PTR -> "sptr"
; hKey : UINT_PTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global CryptHashSessionKey "CryptHashSessionKey" sptr, sptr, int
; res = CryptHashSessionKey(hHash, hKey, dwFlags)
; hHash : UINT_PTR -> "sptr"
; hKey : UINT_PTR -> "sptr"
; dwFlags : DWORD -> "int"; BOOL CryptHashSessionKey(UINT_PTR hHash, UINT_PTR hKey, DWORD dwFlags)
#uselib "ADVAPI32.dll"
#cfunc global CryptHashSessionKey "CryptHashSessionKey" intptr, intptr, int
; res = CryptHashSessionKey(hHash, hKey, dwFlags)
; hHash : UINT_PTR -> "intptr"
; hKey : UINT_PTR -> "intptr"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procCryptHashSessionKey = advapi32.NewProc("CryptHashSessionKey")
)
// hHash (UINT_PTR), hKey (UINT_PTR), dwFlags (DWORD)
r1, _, err := procCryptHashSessionKey.Call(
uintptr(hHash),
uintptr(hKey),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptHashSessionKey(
hHash: NativeUInt; // UINT_PTR
hKey: NativeUInt; // UINT_PTR
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'CryptHashSessionKey';result := DllCall("ADVAPI32\CryptHashSessionKey"
, "UPtr", hHash ; UINT_PTR
, "UPtr", hKey ; UINT_PTR
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●CryptHashSessionKey(hHash, hKey, dwFlags) = DLL("ADVAPI32.dll", "bool CryptHashSessionKey(int, int, dword)")
# 呼び出し: CryptHashSessionKey(hHash, hKey, dwFlags)
# hHash : UINT_PTR -> "int"
# hKey : UINT_PTR -> "int"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。