ホーム › Security.Cryptography.Sip › CryptSIPRetrieveSubjectGuidForCatalogFile
CryptSIPRetrieveSubjectGuidForCatalogFile
関数カタログファイル用のSIP件名GUIDを取得する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptSIPRetrieveSubjectGuidForCatalogFile(
LPCWSTR FileName,
HANDLE hFileIn,
GUID* pgSubject
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileName | LPCWSTR | in | カタログファイル用にサブジェクトGUIDを判定する対象ファイルのパス文字列。 |
| hFileIn | HANDLE | in | 対象ファイルの既に開かれたハンドル。NULL可(その場合FileNameで開く)。 |
| pgSubject | GUID* | inout | 判定されたサブジェクトインターフェイスGUIDを受け取る出力先。 |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptSIPRetrieveSubjectGuidForCatalogFile(
LPCWSTR FileName,
HANDLE hFileIn,
GUID* pgSubject
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptSIPRetrieveSubjectGuidForCatalogFile(
[MarshalAs(UnmanagedType.LPWStr)] string FileName, // LPCWSTR
IntPtr hFileIn, // HANDLE
ref Guid pgSubject // GUID* in/out
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptSIPRetrieveSubjectGuidForCatalogFile(
<MarshalAs(UnmanagedType.LPWStr)> FileName As String, ' LPCWSTR
hFileIn As IntPtr, ' HANDLE
ByRef pgSubject As Guid ' GUID* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' FileName : LPCWSTR
' hFileIn : HANDLE
' pgSubject : GUID* in/out
Declare PtrSafe Function CryptSIPRetrieveSubjectGuidForCatalogFile Lib "crypt32" ( _
ByVal FileName As LongPtr, _
ByVal hFileIn As LongPtr, _
ByVal pgSubject As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptSIPRetrieveSubjectGuidForCatalogFile = ctypes.windll.crypt32.CryptSIPRetrieveSubjectGuidForCatalogFile
CryptSIPRetrieveSubjectGuidForCatalogFile.restype = wintypes.BOOL
CryptSIPRetrieveSubjectGuidForCatalogFile.argtypes = [
wintypes.LPCWSTR, # FileName : LPCWSTR
wintypes.HANDLE, # hFileIn : HANDLE
ctypes.c_void_p, # pgSubject : GUID* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptSIPRetrieveSubjectGuidForCatalogFile = Fiddle::Function.new(
lib['CryptSIPRetrieveSubjectGuidForCatalogFile'],
[
Fiddle::TYPE_VOIDP, # FileName : LPCWSTR
Fiddle::TYPE_VOIDP, # hFileIn : HANDLE
Fiddle::TYPE_VOIDP, # pgSubject : GUID* in/out
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: *const u16, // LPCWSTR
hFileIn: *mut core::ffi::c_void, // HANDLE
pgSubject: *mut GUID // GUID* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CryptSIPRetrieveSubjectGuidForCatalogFile([MarshalAs(UnmanagedType.LPWStr)] string FileName, IntPtr hFileIn, ref Guid pgSubject);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptSIPRetrieveSubjectGuidForCatalogFile' -Namespace Win32 -PassThru
# $api::CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject)#uselib "CRYPT32.dll"
#func global CryptSIPRetrieveSubjectGuidForCatalogFile "CryptSIPRetrieveSubjectGuidForCatalogFile" sptr, sptr, sptr
; CryptSIPRetrieveSubjectGuidForCatalogFile FileName, hFileIn, varptr(pgSubject) ; 戻り値は stat
; FileName : LPCWSTR -> "sptr"
; hFileIn : HANDLE -> "sptr"
; pgSubject : GUID* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CryptSIPRetrieveSubjectGuidForCatalogFile "CryptSIPRetrieveSubjectGuidForCatalogFile" wstr, sptr, var ; res = CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject) ; FileName : LPCWSTR -> "wstr" ; hFileIn : HANDLE -> "sptr" ; pgSubject : GUID* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CryptSIPRetrieveSubjectGuidForCatalogFile "CryptSIPRetrieveSubjectGuidForCatalogFile" wstr, sptr, sptr ; res = CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, varptr(pgSubject)) ; FileName : LPCWSTR -> "wstr" ; hFileIn : HANDLE -> "sptr" ; pgSubject : GUID* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CryptSIPRetrieveSubjectGuidForCatalogFile(LPCWSTR FileName, HANDLE hFileIn, GUID* pgSubject) #uselib "CRYPT32.dll" #cfunc global CryptSIPRetrieveSubjectGuidForCatalogFile "CryptSIPRetrieveSubjectGuidForCatalogFile" wstr, intptr, var ; res = CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject) ; FileName : LPCWSTR -> "wstr" ; hFileIn : HANDLE -> "intptr" ; pgSubject : GUID* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CryptSIPRetrieveSubjectGuidForCatalogFile(LPCWSTR FileName, HANDLE hFileIn, GUID* pgSubject) #uselib "CRYPT32.dll" #cfunc global CryptSIPRetrieveSubjectGuidForCatalogFile "CryptSIPRetrieveSubjectGuidForCatalogFile" wstr, intptr, intptr ; res = CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, varptr(pgSubject)) ; FileName : LPCWSTR -> "wstr" ; hFileIn : HANDLE -> "intptr" ; pgSubject : GUID* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptSIPRetrieveSubjectGuidForCatalogFile = crypt32.NewProc("CryptSIPRetrieveSubjectGuidForCatalogFile")
)
// FileName (LPCWSTR), hFileIn (HANDLE), pgSubject (GUID* in/out)
r1, _, err := procCryptSIPRetrieveSubjectGuidForCatalogFile.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
uintptr(hFileIn),
uintptr(pgSubject),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: PWideChar; // LPCWSTR
hFileIn: THandle; // HANDLE
pgSubject: PGUID // GUID* in/out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptSIPRetrieveSubjectGuidForCatalogFile';result := DllCall("CRYPT32\CryptSIPRetrieveSubjectGuidForCatalogFile"
, "WStr", FileName ; LPCWSTR
, "Ptr", hFileIn ; HANDLE
, "Ptr", pgSubject ; GUID* in/out
, "Int") ; return: BOOL●CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject) = DLL("CRYPT32.dll", "bool CryptSIPRetrieveSubjectGuidForCatalogFile(char*, void*, void*)")
# 呼び出し: CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject)
# FileName : LPCWSTR -> "char*"
# hFileIn : HANDLE -> "void*"
# pgSubject : GUID* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "crypt32" fn CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: [*c]const u16, // LPCWSTR
hFileIn: ?*anyopaque, // HANDLE
pgSubject: [*c]GUID // GUID* in/out
) callconv(std.os.windows.WINAPI) i32;proc CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: WideCString, # LPCWSTR
hFileIn: pointer, # HANDLE
pgSubject: ptr GUID # GUID* in/out
): int32 {.importc: "CryptSIPRetrieveSubjectGuidForCatalogFile", stdcall, dynlib: "CRYPT32.dll".}pragma(lib, "crypt32");
extern(Windows)
int CryptSIPRetrieveSubjectGuidForCatalogFile(
const(wchar)* FileName, // LPCWSTR
void* hFileIn, // HANDLE
GUID* pgSubject // GUID* in/out
);ccall((:CryptSIPRetrieveSubjectGuidForCatalogFile, "CRYPT32.dll"), stdcall, Int32,
(Cwstring, Ptr{Cvoid}, Ptr{GUID}),
FileName, hFileIn, pgSubject)
# FileName : LPCWSTR -> Cwstring
# hFileIn : HANDLE -> Ptr{Cvoid}
# pgSubject : GUID* in/out -> Ptr{GUID}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CryptSIPRetrieveSubjectGuidForCatalogFile(
const uint16_t* FileName,
void* hFileIn,
void* pgSubject);
]]
local crypt32 = ffi.load("crypt32")
-- crypt32.CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject)
-- FileName : LPCWSTR
-- hFileIn : HANDLE
-- pgSubject : GUID* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CRYPT32.dll');
const CryptSIPRetrieveSubjectGuidForCatalogFile = lib.func('__stdcall', 'CryptSIPRetrieveSubjectGuidForCatalogFile', 'int32_t', ['str16', 'void *', 'void *']);
// CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject)
// FileName : LPCWSTR -> 'str16'
// hFileIn : HANDLE -> 'void *'
// pgSubject : GUID* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CRYPT32.dll", {
CryptSIPRetrieveSubjectGuidForCatalogFile: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject)
// FileName : LPCWSTR -> "buffer"
// hFileIn : HANDLE -> "pointer"
// pgSubject : GUID* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CryptSIPRetrieveSubjectGuidForCatalogFile(
const uint16_t* FileName,
void* hFileIn,
void* pgSubject);
C, "CRYPT32.dll");
// $ffi->CryptSIPRetrieveSubjectGuidForCatalogFile(FileName, hFileIn, pgSubject);
// FileName : LPCWSTR
// hFileIn : HANDLE
// pgSubject : GUID* 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 Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = Native.load("crypt32", Crypt32.class);
boolean CryptSIPRetrieveSubjectGuidForCatalogFile(
WString FileName, // LPCWSTR
Pointer hFileIn, // HANDLE
Pointer pgSubject // GUID* in/out
);
}@[Link("crypt32")]
lib LibCRYPT32
fun CryptSIPRetrieveSubjectGuidForCatalogFile = CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName : UInt16*, # LPCWSTR
hFileIn : Void*, # HANDLE
pgSubject : GUID* # GUID* 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 CryptSIPRetrieveSubjectGuidForCatalogFileNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef CryptSIPRetrieveSubjectGuidForCatalogFileDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final CryptSIPRetrieveSubjectGuidForCatalogFile = DynamicLibrary.open('CRYPT32.dll')
.lookupFunction<CryptSIPRetrieveSubjectGuidForCatalogFileNative, CryptSIPRetrieveSubjectGuidForCatalogFileDart>('CryptSIPRetrieveSubjectGuidForCatalogFile');
// FileName : LPCWSTR -> Pointer<Utf16>
// hFileIn : HANDLE -> Pointer<Void>
// pgSubject : GUID* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CryptSIPRetrieveSubjectGuidForCatalogFile(
FileName: PWideChar; // LPCWSTR
hFileIn: THandle; // HANDLE
pgSubject: PGUID // GUID* in/out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptSIPRetrieveSubjectGuidForCatalogFile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CryptSIPRetrieveSubjectGuidForCatalogFile"
c_CryptSIPRetrieveSubjectGuidForCatalogFile :: CWString -> Ptr () -> Ptr () -> IO CInt
-- FileName : LPCWSTR -> CWString
-- hFileIn : HANDLE -> Ptr ()
-- pgSubject : GUID* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cryptsipretrievesubjectguidforcatalogfile =
foreign "CryptSIPRetrieveSubjectGuidForCatalogFile"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* FileName : LPCWSTR -> (ptr uint16_t) *)
(* hFileIn : HANDLE -> (ptr void) *)
(* pgSubject : GUID* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)
(cffi:defcfun ("CryptSIPRetrieveSubjectGuidForCatalogFile" crypt-sipretrieve-subject-guid-for-catalog-file :convention :stdcall) :int32
(file-name (:string :encoding :utf-16le)) ; LPCWSTR
(h-file-in :pointer) ; HANDLE
(pg-subject :pointer)) ; GUID* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CryptSIPRetrieveSubjectGuidForCatalogFile = Win32::API::More->new('CRYPT32',
'BOOL CryptSIPRetrieveSubjectGuidForCatalogFile(LPCWSTR FileName, HANDLE hFileIn, LPVOID pgSubject)');
# my $ret = $CryptSIPRetrieveSubjectGuidForCatalogFile->Call($FileName, $hFileIn, $pgSubject);
# FileName : LPCWSTR -> LPCWSTR
# hFileIn : HANDLE -> HANDLE
# pgSubject : GUID* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。