ホーム › Security.Cryptography › CryptInstallCancelRetrieval
CryptInstallCancelRetrieval
関数オブジェクト取得をキャンセルするコールバックをインストールする。
シグネチャ
// CRYPTNET.dll
#include <windows.h>
BOOL CryptInstallCancelRetrieval(
PFN_CRYPT_CANCEL_RETRIEVAL pfnCancel,
const void* pvArg, // optional
DWORD dwFlags,
void* pvReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pfnCancel | PFN_CRYPT_CANCEL_RETRIEVAL | in | 取得処理のキャンセル要否を判定するコールバック関数へのポインター。 |
| pvArg | void* | inoptional | コールバックへ渡される呼び出し側定義の引数ポインター。 |
| dwFlags | DWORD | in | 予約フラグ。通常は0を指定する。 |
| pvReserved | void* | optional | 予約パラメーター。NULLを指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPTNET.dll
#include <windows.h>
BOOL CryptInstallCancelRetrieval(
PFN_CRYPT_CANCEL_RETRIEVAL pfnCancel,
const void* pvArg, // optional
DWORD dwFlags,
void* pvReserved // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPTNET.dll", ExactSpelling = true)]
static extern bool CryptInstallCancelRetrieval(
IntPtr pfnCancel, // PFN_CRYPT_CANCEL_RETRIEVAL
IntPtr pvArg, // void* optional
uint dwFlags, // DWORD
IntPtr pvReserved // void* optional
);<DllImport("CRYPTNET.dll", ExactSpelling:=True)>
Public Shared Function CryptInstallCancelRetrieval(
pfnCancel As IntPtr, ' PFN_CRYPT_CANCEL_RETRIEVAL
pvArg As IntPtr, ' void* optional
dwFlags As UInteger, ' DWORD
pvReserved As IntPtr ' void* optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL
' pvArg : void* optional
' dwFlags : DWORD
' pvReserved : void* optional
Declare PtrSafe Function CryptInstallCancelRetrieval Lib "cryptnet" ( _
ByVal pfnCancel As LongPtr, _
ByVal pvArg As LongPtr, _
ByVal dwFlags As Long, _
ByVal pvReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptInstallCancelRetrieval = ctypes.windll.cryptnet.CryptInstallCancelRetrieval
CryptInstallCancelRetrieval.restype = wintypes.BOOL
CryptInstallCancelRetrieval.argtypes = [
ctypes.c_void_p, # pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL
ctypes.POINTER(None), # pvArg : void* optional
wintypes.DWORD, # dwFlags : DWORD
ctypes.POINTER(None), # pvReserved : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPTNET.dll')
CryptInstallCancelRetrieval = Fiddle::Function.new(
lib['CryptInstallCancelRetrieval'],
[
Fiddle::TYPE_VOIDP, # pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL
Fiddle::TYPE_VOIDP, # pvArg : void* optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pvReserved : void* optional
],
Fiddle::TYPE_INT)#[link(name = "cryptnet")]
extern "system" {
fn CryptInstallCancelRetrieval(
pfnCancel: *const core::ffi::c_void, // PFN_CRYPT_CANCEL_RETRIEVAL
pvArg: *const (), // void* optional
dwFlags: u32, // DWORD
pvReserved: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPTNET.dll")]
public static extern bool CryptInstallCancelRetrieval(IntPtr pfnCancel, IntPtr pvArg, uint dwFlags, IntPtr pvReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPTNET_CryptInstallCancelRetrieval' -Namespace Win32 -PassThru
# $api::CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)#uselib "CRYPTNET.dll"
#func global CryptInstallCancelRetrieval "CryptInstallCancelRetrieval" sptr, sptr, sptr, sptr
; CryptInstallCancelRetrieval pfnCancel, pvArg, dwFlags, pvReserved ; 戻り値は stat
; pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> "sptr"
; pvArg : void* optional -> "sptr"
; dwFlags : DWORD -> "sptr"
; pvReserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPTNET.dll"
#cfunc global CryptInstallCancelRetrieval "CryptInstallCancelRetrieval" sptr, sptr, int, sptr
; res = CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
; pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> "sptr"
; pvArg : void* optional -> "sptr"
; dwFlags : DWORD -> "int"
; pvReserved : void* optional -> "sptr"; BOOL CryptInstallCancelRetrieval(PFN_CRYPT_CANCEL_RETRIEVAL pfnCancel, void* pvArg, DWORD dwFlags, void* pvReserved)
#uselib "CRYPTNET.dll"
#cfunc global CryptInstallCancelRetrieval "CryptInstallCancelRetrieval" intptr, intptr, int, intptr
; res = CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
; pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> "intptr"
; pvArg : void* optional -> "intptr"
; dwFlags : DWORD -> "int"
; pvReserved : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cryptnet = windows.NewLazySystemDLL("CRYPTNET.dll")
procCryptInstallCancelRetrieval = cryptnet.NewProc("CryptInstallCancelRetrieval")
)
// pfnCancel (PFN_CRYPT_CANCEL_RETRIEVAL), pvArg (void* optional), dwFlags (DWORD), pvReserved (void* optional)
r1, _, err := procCryptInstallCancelRetrieval.Call(
uintptr(pfnCancel),
uintptr(pvArg),
uintptr(dwFlags),
uintptr(pvReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptInstallCancelRetrieval(
pfnCancel: Pointer; // PFN_CRYPT_CANCEL_RETRIEVAL
pvArg: Pointer; // void* optional
dwFlags: DWORD; // DWORD
pvReserved: Pointer // void* optional
): BOOL; stdcall;
external 'CRYPTNET.dll' name 'CryptInstallCancelRetrieval';result := DllCall("CRYPTNET\CryptInstallCancelRetrieval"
, "Ptr", pfnCancel ; PFN_CRYPT_CANCEL_RETRIEVAL
, "Ptr", pvArg ; void* optional
, "UInt", dwFlags ; DWORD
, "Ptr", pvReserved ; void* optional
, "Int") ; return: BOOL●CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved) = DLL("CRYPTNET.dll", "bool CryptInstallCancelRetrieval(void*, void*, dword, void*)")
# 呼び出し: CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
# pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> "void*"
# pvArg : void* optional -> "void*"
# dwFlags : DWORD -> "dword"
# pvReserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "cryptnet" fn CryptInstallCancelRetrieval(
pfnCancel: ?*anyopaque, // PFN_CRYPT_CANCEL_RETRIEVAL
pvArg: ?*anyopaque, // void* optional
dwFlags: u32, // DWORD
pvReserved: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc CryptInstallCancelRetrieval(
pfnCancel: pointer, # PFN_CRYPT_CANCEL_RETRIEVAL
pvArg: pointer, # void* optional
dwFlags: uint32, # DWORD
pvReserved: pointer # void* optional
): int32 {.importc: "CryptInstallCancelRetrieval", stdcall, dynlib: "CRYPTNET.dll".}pragma(lib, "cryptnet");
extern(Windows)
int CryptInstallCancelRetrieval(
void* pfnCancel, // PFN_CRYPT_CANCEL_RETRIEVAL
void* pvArg, // void* optional
uint dwFlags, // DWORD
void* pvReserved // void* optional
);ccall((:CryptInstallCancelRetrieval, "CRYPTNET.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Ptr{Cvoid}),
pfnCancel, pvArg, dwFlags, pvReserved)
# pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> Ptr{Cvoid}
# pvArg : void* optional -> Ptr{Cvoid}
# dwFlags : DWORD -> UInt32
# pvReserved : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CryptInstallCancelRetrieval(
void* pfnCancel,
void* pvArg,
uint32_t dwFlags,
void* pvReserved);
]]
local cryptnet = ffi.load("cryptnet")
-- cryptnet.CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
-- pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL
-- pvArg : void* optional
-- dwFlags : DWORD
-- pvReserved : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CRYPTNET.dll');
const CryptInstallCancelRetrieval = lib.func('__stdcall', 'CryptInstallCancelRetrieval', 'int32_t', ['void *', 'void *', 'uint32_t', 'void *']);
// CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
// pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> 'void *'
// pvArg : void* optional -> 'void *'
// dwFlags : DWORD -> 'uint32_t'
// pvReserved : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("CRYPTNET.dll", {
CryptInstallCancelRetrieval: { parameters: ["pointer", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved)
// pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> "pointer"
// pvArg : void* optional -> "pointer"
// dwFlags : DWORD -> "u32"
// pvReserved : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CryptInstallCancelRetrieval(
void* pfnCancel,
void* pvArg,
uint32_t dwFlags,
void* pvReserved);
C, "CRYPTNET.dll");
// $ffi->CryptInstallCancelRetrieval(pfnCancel, pvArg, dwFlags, pvReserved);
// pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL
// pvArg : void* optional
// dwFlags : DWORD
// pvReserved : void* optional
// 構造体/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 Cryptnet extends StdCallLibrary {
Cryptnet INSTANCE = Native.load("cryptnet", Cryptnet.class);
boolean CryptInstallCancelRetrieval(
Callback pfnCancel, // PFN_CRYPT_CANCEL_RETRIEVAL
Pointer pvArg, // void* optional
int dwFlags, // DWORD
Pointer pvReserved // void* optional
);
}@[Link("cryptnet")]
lib LibCRYPTNET
fun CryptInstallCancelRetrieval = CryptInstallCancelRetrieval(
pfnCancel : Void*, # PFN_CRYPT_CANCEL_RETRIEVAL
pvArg : Void*, # void* optional
dwFlags : UInt32, # DWORD
pvReserved : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CryptInstallCancelRetrievalNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>);
typedef CryptInstallCancelRetrievalDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final CryptInstallCancelRetrieval = DynamicLibrary.open('CRYPTNET.dll')
.lookupFunction<CryptInstallCancelRetrievalNative, CryptInstallCancelRetrievalDart>('CryptInstallCancelRetrieval');
// pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> Pointer<Void>
// pvArg : void* optional -> Pointer<Void>
// dwFlags : DWORD -> Uint32
// pvReserved : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CryptInstallCancelRetrieval(
pfnCancel: Pointer; // PFN_CRYPT_CANCEL_RETRIEVAL
pvArg: Pointer; // void* optional
dwFlags: DWORD; // DWORD
pvReserved: Pointer // void* optional
): BOOL; stdcall;
external 'CRYPTNET.dll' name 'CryptInstallCancelRetrieval';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CryptInstallCancelRetrieval"
c_CryptInstallCancelRetrieval :: Ptr () -> Ptr () -> Word32 -> Ptr () -> IO CInt
-- pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> Ptr ()
-- pvArg : void* optional -> Ptr ()
-- dwFlags : DWORD -> Word32
-- pvReserved : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cryptinstallcancelretrieval =
foreign "CryptInstallCancelRetrieval"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> (ptr void) *)
(* pvArg : void* optional -> (ptr void) *)
(* dwFlags : DWORD -> uint32_t *)
(* pvReserved : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library cryptnet (t "CRYPTNET.dll"))
(cffi:use-foreign-library cryptnet)
(cffi:defcfun ("CryptInstallCancelRetrieval" crypt-install-cancel-retrieval :convention :stdcall) :int32
(pfn-cancel :pointer) ; PFN_CRYPT_CANCEL_RETRIEVAL
(pv-arg :pointer) ; void* optional
(dw-flags :uint32) ; DWORD
(pv-reserved :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CryptInstallCancelRetrieval = Win32::API::More->new('CRYPTNET',
'BOOL CryptInstallCancelRetrieval(LPVOID pfnCancel, LPVOID pvArg, DWORD dwFlags, LPVOID pvReserved)');
# my $ret = $CryptInstallCancelRetrieval->Call($pfnCancel, $pvArg, $dwFlags, $pvReserved);
# pfnCancel : PFN_CRYPT_CANCEL_RETRIEVAL -> LPVOID
# pvArg : void* optional -> LPVOID
# dwFlags : DWORD -> DWORD
# pvReserved : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。