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