Win32 API 日本語リファレンス
ホームSecurity.Cryptography › CryptXmlGetReference

CryptXmlGetReference

関数
XML署名のReference構造体情報を取得する。
DLLCRYPTXML.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// CRYPTXML.dll
#include <windows.h>

HRESULT CryptXmlGetReference(
    void* hCryptXml,
    const CRYPT_XML_REFERENCE** ppStruct
);

パラメーター

名前方向説明
hCryptXmlvoid*in取得する Reference 要素のハンドル。
ppStructCRYPT_XML_REFERENCE**out返される Reference 要素を格納する CRYPT_XML_REFERENCE 構造体へのポインターへのポインター。

戻り値の型: HRESULT

公式ドキュメント

指定されたハンドルで示される Reference 要素を返します。

戻り値

関数が成功した場合は、0 を返します。

関数が失敗した場合は、エラーを示す HRESULT 値を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// CRYPTXML.dll
#include <windows.h>

HRESULT CryptXmlGetReference(
    void* hCryptXml,
    const CRYPT_XML_REFERENCE** ppStruct
);
[DllImport("CRYPTXML.dll", ExactSpelling = true)]
static extern int CryptXmlGetReference(
    IntPtr hCryptXml,   // void*
    IntPtr ppStruct   // CRYPT_XML_REFERENCE** out
);
<DllImport("CRYPTXML.dll", ExactSpelling:=True)>
Public Shared Function CryptXmlGetReference(
    hCryptXml As IntPtr,   ' void*
    ppStruct As IntPtr   ' CRYPT_XML_REFERENCE** out
) As Integer
End Function
' hCryptXml : void*
' ppStruct : CRYPT_XML_REFERENCE** out
Declare PtrSafe Function CryptXmlGetReference Lib "cryptxml" ( _
    ByVal hCryptXml As LongPtr, _
    ByVal ppStruct As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CryptXmlGetReference = ctypes.windll.cryptxml.CryptXmlGetReference
CryptXmlGetReference.restype = ctypes.c_int
CryptXmlGetReference.argtypes = [
    ctypes.POINTER(None),  # hCryptXml : void*
    ctypes.c_void_p,  # ppStruct : CRYPT_XML_REFERENCE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPTXML.dll')
CryptXmlGetReference = Fiddle::Function.new(
  lib['CryptXmlGetReference'],
  [
    Fiddle::TYPE_VOIDP,  # hCryptXml : void*
    Fiddle::TYPE_VOIDP,  # ppStruct : CRYPT_XML_REFERENCE** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "cryptxml")]
extern "system" {
    fn CryptXmlGetReference(
        hCryptXml: *mut (),  // void*
        ppStruct: *const *const CRYPT_XML_REFERENCE  // CRYPT_XML_REFERENCE** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CRYPTXML.dll")]
public static extern int CryptXmlGetReference(IntPtr hCryptXml, IntPtr ppStruct);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPTXML_CryptXmlGetReference' -Namespace Win32 -PassThru
# $api::CryptXmlGetReference(hCryptXml, ppStruct)
#uselib "CRYPTXML.dll"
#func global CryptXmlGetReference "CryptXmlGetReference" sptr, sptr
; CryptXmlGetReference hCryptXml, varptr(ppStruct)   ; 戻り値は stat
; hCryptXml : void* -> "sptr"
; ppStruct : CRYPT_XML_REFERENCE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CRYPTXML.dll"
#cfunc global CryptXmlGetReference "CryptXmlGetReference" sptr, var
; res = CryptXmlGetReference(hCryptXml, ppStruct)
; hCryptXml : void* -> "sptr"
; ppStruct : CRYPT_XML_REFERENCE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CryptXmlGetReference(void* hCryptXml, CRYPT_XML_REFERENCE** ppStruct)
#uselib "CRYPTXML.dll"
#cfunc global CryptXmlGetReference "CryptXmlGetReference" intptr, var
; res = CryptXmlGetReference(hCryptXml, ppStruct)
; hCryptXml : void* -> "intptr"
; ppStruct : CRYPT_XML_REFERENCE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cryptxml = windows.NewLazySystemDLL("CRYPTXML.dll")
	procCryptXmlGetReference = cryptxml.NewProc("CryptXmlGetReference")
)

// hCryptXml (void*), ppStruct (CRYPT_XML_REFERENCE** out)
r1, _, err := procCryptXmlGetReference.Call(
	uintptr(hCryptXml),
	uintptr(ppStruct),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CryptXmlGetReference(
  hCryptXml: Pointer;   // void*
  ppStruct: Pointer   // CRYPT_XML_REFERENCE** out
): Integer; stdcall;
  external 'CRYPTXML.dll' name 'CryptXmlGetReference';
result := DllCall("CRYPTXML\CryptXmlGetReference"
    , "Ptr", hCryptXml   ; void*
    , "Ptr", ppStruct   ; CRYPT_XML_REFERENCE** out
    , "Int")   ; return: HRESULT
●CryptXmlGetReference(hCryptXml, ppStruct) = DLL("CRYPTXML.dll", "int CryptXmlGetReference(void*, void*)")
# 呼び出し: CryptXmlGetReference(hCryptXml, ppStruct)
# hCryptXml : void* -> "void*"
# ppStruct : CRYPT_XML_REFERENCE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "cryptxml" fn CryptXmlGetReference(
    hCryptXml: ?*anyopaque, // void*
    ppStruct: [*c][*c]CRYPT_XML_REFERENCE // CRYPT_XML_REFERENCE** out
) callconv(std.os.windows.WINAPI) i32;
proc CryptXmlGetReference(
    hCryptXml: pointer,  # void*
    ppStruct: ptr CRYPT_XML_REFERENCE  # CRYPT_XML_REFERENCE** out
): int32 {.importc: "CryptXmlGetReference", stdcall, dynlib: "CRYPTXML.dll".}
pragma(lib, "cryptxml");
extern(Windows)
int CryptXmlGetReference(
    void* hCryptXml,   // void*
    CRYPT_XML_REFERENCE** ppStruct   // CRYPT_XML_REFERENCE** out
);
ccall((:CryptXmlGetReference, "CRYPTXML.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{CRYPT_XML_REFERENCE}),
      hCryptXml, ppStruct)
# hCryptXml : void* -> Ptr{Cvoid}
# ppStruct : CRYPT_XML_REFERENCE** out -> Ptr{CRYPT_XML_REFERENCE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CryptXmlGetReference(
    void* hCryptXml,
    void* ppStruct);
]]
local cryptxml = ffi.load("cryptxml")
-- cryptxml.CryptXmlGetReference(hCryptXml, ppStruct)
-- hCryptXml : void*
-- ppStruct : CRYPT_XML_REFERENCE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CRYPTXML.dll');
const CryptXmlGetReference = lib.func('__stdcall', 'CryptXmlGetReference', 'int32_t', ['void *', 'void *']);
// CryptXmlGetReference(hCryptXml, ppStruct)
// hCryptXml : void* -> 'void *'
// ppStruct : CRYPT_XML_REFERENCE** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CRYPTXML.dll", {
  CryptXmlGetReference: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.CryptXmlGetReference(hCryptXml, ppStruct)
// hCryptXml : void* -> "pointer"
// ppStruct : CRYPT_XML_REFERENCE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CryptXmlGetReference(
    void* hCryptXml,
    void* ppStruct);
C, "CRYPTXML.dll");
// $ffi->CryptXmlGetReference(hCryptXml, ppStruct);
// hCryptXml : void*
// ppStruct : CRYPT_XML_REFERENCE** 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 Cryptxml extends StdCallLibrary {
    Cryptxml INSTANCE = Native.load("cryptxml", Cryptxml.class);
    int CryptXmlGetReference(
        Pointer hCryptXml,   // void*
        Pointer ppStruct   // CRYPT_XML_REFERENCE** out
    );
}
@[Link("cryptxml")]
lib LibCRYPTXML
  fun CryptXmlGetReference = CryptXmlGetReference(
    hCryptXml : Void*,   # void*
    ppStruct : CRYPT_XML_REFERENCE**   # CRYPT_XML_REFERENCE** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CryptXmlGetReferenceNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef CryptXmlGetReferenceDart = int Function(Pointer<Void>, Pointer<Void>);
final CryptXmlGetReference = DynamicLibrary.open('CRYPTXML.dll')
    .lookupFunction<CryptXmlGetReferenceNative, CryptXmlGetReferenceDart>('CryptXmlGetReference');
// hCryptXml : void* -> Pointer<Void>
// ppStruct : CRYPT_XML_REFERENCE** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CryptXmlGetReference(
  hCryptXml: Pointer;   // void*
  ppStruct: Pointer   // CRYPT_XML_REFERENCE** out
): Integer; stdcall;
  external 'CRYPTXML.dll' name 'CryptXmlGetReference';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CryptXmlGetReference"
  c_CryptXmlGetReference :: Ptr () -> Ptr () -> IO Int32
-- hCryptXml : void* -> Ptr ()
-- ppStruct : CRYPT_XML_REFERENCE** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let cryptxmlgetreference =
  foreign "CryptXmlGetReference"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* hCryptXml : void* -> (ptr void) *)
(* ppStruct : CRYPT_XML_REFERENCE** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library cryptxml (t "CRYPTXML.dll"))
(cffi:use-foreign-library cryptxml)

(cffi:defcfun ("CryptXmlGetReference" crypt-xml-get-reference :convention :stdcall) :int32
  (h-crypt-xml :pointer)   ; void*
  (pp-struct :pointer))   ; CRYPT_XML_REFERENCE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CryptXmlGetReference = Win32::API::More->new('CRYPTXML',
    'int CryptXmlGetReference(LPVOID hCryptXml, LPVOID ppStruct)');
# my $ret = $CryptXmlGetReference->Call($hCryptXml, $ppStruct);
# hCryptXml : void* -> LPVOID
# ppStruct : CRYPT_XML_REFERENCE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型