ホーム › Security.WinTrust › WinVerifyTrust
WinVerifyTrust
関数指定オブジェクトの署名と信頼性を検証する。
シグネチャ
// WINTRUST.dll
#include <windows.h>
INT WinVerifyTrust(
HWND hwnd,
GUID* pgActionID,
void* pWVTData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | ユーザー操作が必要な場合のUI親ウィンドウのハンドル。INVALID_HANDLE_VALUEでUI抑止、0でデスクトップを使用する。 |
| pgActionID | GUID* | inout | 実行する信頼検証アクションを識別するGUIDへのポインタ(WINTRUST_ACTION_GENERIC_VERIFY_V2等)。 |
| pWVTData | void* | inout | 検証対象や設定を記述するWINTRUST_DATA構造体へのポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// WINTRUST.dll
#include <windows.h>
INT WinVerifyTrust(
HWND hwnd,
GUID* pgActionID,
void* pWVTData
);[DllImport("WINTRUST.dll", ExactSpelling = true)]
static extern int WinVerifyTrust(
IntPtr hwnd, // HWND
ref Guid pgActionID, // GUID* in/out
IntPtr pWVTData // void* in/out
);<DllImport("WINTRUST.dll", ExactSpelling:=True)>
Public Shared Function WinVerifyTrust(
hwnd As IntPtr, ' HWND
ByRef pgActionID As Guid, ' GUID* in/out
pWVTData As IntPtr ' void* in/out
) As Integer
End Function' hwnd : HWND
' pgActionID : GUID* in/out
' pWVTData : void* in/out
Declare PtrSafe Function WinVerifyTrust Lib "wintrust" ( _
ByVal hwnd As LongPtr, _
ByVal pgActionID As LongPtr, _
ByVal pWVTData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WinVerifyTrust = ctypes.windll.wintrust.WinVerifyTrust
WinVerifyTrust.restype = ctypes.c_int
WinVerifyTrust.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_void_p, # pgActionID : GUID* in/out
ctypes.POINTER(None), # pWVTData : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINTRUST.dll')
WinVerifyTrust = Fiddle::Function.new(
lib['WinVerifyTrust'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # pgActionID : GUID* in/out
Fiddle::TYPE_VOIDP, # pWVTData : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "wintrust")]
extern "system" {
fn WinVerifyTrust(
hwnd: *mut core::ffi::c_void, // HWND
pgActionID: *mut GUID, // GUID* in/out
pWVTData: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINTRUST.dll")]
public static extern int WinVerifyTrust(IntPtr hwnd, ref Guid pgActionID, IntPtr pWVTData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINTRUST_WinVerifyTrust' -Namespace Win32 -PassThru
# $api::WinVerifyTrust(hwnd, pgActionID, pWVTData)#uselib "WINTRUST.dll"
#func global WinVerifyTrust "WinVerifyTrust" sptr, sptr, sptr
; WinVerifyTrust hwnd, varptr(pgActionID), pWVTData ; 戻り値は stat
; hwnd : HWND -> "sptr"
; pgActionID : GUID* in/out -> "sptr"
; pWVTData : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WINTRUST.dll" #cfunc global WinVerifyTrust "WinVerifyTrust" sptr, var, sptr ; res = WinVerifyTrust(hwnd, pgActionID, pWVTData) ; hwnd : HWND -> "sptr" ; pgActionID : GUID* in/out -> "var" ; pWVTData : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WINTRUST.dll" #cfunc global WinVerifyTrust "WinVerifyTrust" sptr, sptr, sptr ; res = WinVerifyTrust(hwnd, varptr(pgActionID), pWVTData) ; hwnd : HWND -> "sptr" ; pgActionID : GUID* in/out -> "sptr" ; pWVTData : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT WinVerifyTrust(HWND hwnd, GUID* pgActionID, void* pWVTData) #uselib "WINTRUST.dll" #cfunc global WinVerifyTrust "WinVerifyTrust" intptr, var, intptr ; res = WinVerifyTrust(hwnd, pgActionID, pWVTData) ; hwnd : HWND -> "intptr" ; pgActionID : GUID* in/out -> "var" ; pWVTData : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT WinVerifyTrust(HWND hwnd, GUID* pgActionID, void* pWVTData) #uselib "WINTRUST.dll" #cfunc global WinVerifyTrust "WinVerifyTrust" intptr, intptr, intptr ; res = WinVerifyTrust(hwnd, varptr(pgActionID), pWVTData) ; hwnd : HWND -> "intptr" ; pgActionID : GUID* in/out -> "intptr" ; pWVTData : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wintrust = windows.NewLazySystemDLL("WINTRUST.dll")
procWinVerifyTrust = wintrust.NewProc("WinVerifyTrust")
)
// hwnd (HWND), pgActionID (GUID* in/out), pWVTData (void* in/out)
r1, _, err := procWinVerifyTrust.Call(
uintptr(hwnd),
uintptr(pgActionID),
uintptr(pWVTData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction WinVerifyTrust(
hwnd: THandle; // HWND
pgActionID: PGUID; // GUID* in/out
pWVTData: Pointer // void* in/out
): Integer; stdcall;
external 'WINTRUST.dll' name 'WinVerifyTrust';result := DllCall("WINTRUST\WinVerifyTrust"
, "Ptr", hwnd ; HWND
, "Ptr", pgActionID ; GUID* in/out
, "Ptr", pWVTData ; void* in/out
, "Int") ; return: INT●WinVerifyTrust(hwnd, pgActionID, pWVTData) = DLL("WINTRUST.dll", "int WinVerifyTrust(void*, void*, void*)")
# 呼び出し: WinVerifyTrust(hwnd, pgActionID, pWVTData)
# hwnd : HWND -> "void*"
# pgActionID : GUID* in/out -> "void*"
# pWVTData : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wintrust" fn WinVerifyTrust(
hwnd: ?*anyopaque, // HWND
pgActionID: [*c]GUID, // GUID* in/out
pWVTData: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc WinVerifyTrust(
hwnd: pointer, # HWND
pgActionID: ptr GUID, # GUID* in/out
pWVTData: pointer # void* in/out
): int32 {.importc: "WinVerifyTrust", stdcall, dynlib: "WINTRUST.dll".}pragma(lib, "wintrust");
extern(Windows)
int WinVerifyTrust(
void* hwnd, // HWND
GUID* pgActionID, // GUID* in/out
void* pWVTData // void* in/out
);ccall((:WinVerifyTrust, "WINTRUST.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{GUID}, Ptr{Cvoid}),
hwnd, pgActionID, pWVTData)
# hwnd : HWND -> Ptr{Cvoid}
# pgActionID : GUID* in/out -> Ptr{GUID}
# pWVTData : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinVerifyTrust(
void* hwnd,
void* pgActionID,
void* pWVTData);
]]
local wintrust = ffi.load("wintrust")
-- wintrust.WinVerifyTrust(hwnd, pgActionID, pWVTData)
-- hwnd : HWND
-- pgActionID : GUID* in/out
-- pWVTData : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINTRUST.dll');
const WinVerifyTrust = lib.func('__stdcall', 'WinVerifyTrust', 'int32_t', ['void *', 'void *', 'void *']);
// WinVerifyTrust(hwnd, pgActionID, pWVTData)
// hwnd : HWND -> 'void *'
// pgActionID : GUID* in/out -> 'void *'
// pWVTData : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINTRUST.dll", {
WinVerifyTrust: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WinVerifyTrust(hwnd, pgActionID, pWVTData)
// hwnd : HWND -> "pointer"
// pgActionID : GUID* in/out -> "pointer"
// pWVTData : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinVerifyTrust(
void* hwnd,
void* pgActionID,
void* pWVTData);
C, "WINTRUST.dll");
// $ffi->WinVerifyTrust(hwnd, pgActionID, pWVTData);
// hwnd : HWND
// pgActionID : GUID* in/out
// pWVTData : void* in/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 Wintrust extends StdCallLibrary {
Wintrust INSTANCE = Native.load("wintrust", Wintrust.class);
int WinVerifyTrust(
Pointer hwnd, // HWND
Pointer pgActionID, // GUID* in/out
Pointer pWVTData // void* in/out
);
}@[Link("wintrust")]
lib LibWINTRUST
fun WinVerifyTrust = WinVerifyTrust(
hwnd : Void*, # HWND
pgActionID : GUID*, # GUID* in/out
pWVTData : Void* # void* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WinVerifyTrustNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef WinVerifyTrustDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final WinVerifyTrust = DynamicLibrary.open('WINTRUST.dll')
.lookupFunction<WinVerifyTrustNative, WinVerifyTrustDart>('WinVerifyTrust');
// hwnd : HWND -> Pointer<Void>
// pgActionID : GUID* in/out -> Pointer<Void>
// pWVTData : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WinVerifyTrust(
hwnd: THandle; // HWND
pgActionID: PGUID; // GUID* in/out
pWVTData: Pointer // void* in/out
): Integer; stdcall;
external 'WINTRUST.dll' name 'WinVerifyTrust';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinVerifyTrust"
c_WinVerifyTrust :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- hwnd : HWND -> Ptr ()
-- pgActionID : GUID* in/out -> Ptr ()
-- pWVTData : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winverifytrust =
foreign "WinVerifyTrust"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* pgActionID : GUID* in/out -> (ptr void) *)
(* pWVTData : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wintrust (t "WINTRUST.dll"))
(cffi:use-foreign-library wintrust)
(cffi:defcfun ("WinVerifyTrust" win-verify-trust :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(pg-action-id :pointer) ; GUID* in/out
(p-wvtdata :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinVerifyTrust = Win32::API::More->new('WINTRUST',
'int WinVerifyTrust(HANDLE hwnd, LPVOID pgActionID, LPVOID pWVTData)');
# my $ret = $WinVerifyTrust->Call($hwnd, $pgActionID, $pWVTData);
# hwnd : HWND -> HANDLE
# pgActionID : GUID* in/out -> LPVOID
# pWVTData : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WinVerifyTrustEx — 信頼検証データ構造を用いて署名と信頼性を検証する。