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

CertSrvRestoreRegisterW

関数
復元するログファイルやマッピング情報を登録する。
DLLcertadm.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

HRESULT CertSrvRestoreRegisterW(
    void* hbc,
    LPCWSTR pwszCheckPointFilePath,
    LPCWSTR pwszLogPath,
    CSEDB_RSTMAPW* rgrstmap,
    INT crstmap,
    LPCWSTR pwszBackupLogPath,
    DWORD genLow,
    DWORD genHigh
);

パラメーター

名前方向説明
hbcvoid*inoutCertSrvRestorePrepareWで取得したリストアコンテキストハンドル。
pwszCheckPointFilePathLPCWSTRinチェックポイントファイルの配置パス。NULL終端のワイド文字列で指定する。
pwszLogPathLPCWSTRinログファイルの配置パス。NULL終端のワイド文字列で指定する。
rgrstmapCSEDB_RSTMAPW*inoutリストア先マッピングを定義するCSEDB_RSTMAPW構造体の配列。
crstmapINTinrgrstmap配列に含まれるマッピング要素の個数。
pwszBackupLogPathLPCWSTRinバックアップログの配置パス。NULL終端のワイド文字列で指定する。
genLowDWORDinリストア対象ログ世代の下限値。
genHighDWORDinリストア対象ログ世代の上限値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CertSrvRestoreRegisterW(
    void* hbc,
    LPCWSTR pwszCheckPointFilePath,
    LPCWSTR pwszLogPath,
    CSEDB_RSTMAPW* rgrstmap,
    INT crstmap,
    LPCWSTR pwszBackupLogPath,
    DWORD genLow,
    DWORD genHigh
);
[DllImport("certadm.dll", ExactSpelling = true)]
static extern int CertSrvRestoreRegisterW(
    IntPtr hbc,   // void* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pwszCheckPointFilePath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pwszLogPath,   // LPCWSTR
    IntPtr rgrstmap,   // CSEDB_RSTMAPW* in/out
    int crstmap,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] string pwszBackupLogPath,   // LPCWSTR
    uint genLow,   // DWORD
    uint genHigh   // DWORD
);
<DllImport("certadm.dll", ExactSpelling:=True)>
Public Shared Function CertSrvRestoreRegisterW(
    hbc As IntPtr,   ' void* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pwszCheckPointFilePath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pwszLogPath As String,   ' LPCWSTR
    rgrstmap As IntPtr,   ' CSEDB_RSTMAPW* in/out
    crstmap As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> pwszBackupLogPath As String,   ' LPCWSTR
    genLow As UInteger,   ' DWORD
    genHigh As UInteger   ' DWORD
) As Integer
End Function
' hbc : void* in/out
' pwszCheckPointFilePath : LPCWSTR
' pwszLogPath : LPCWSTR
' rgrstmap : CSEDB_RSTMAPW* in/out
' crstmap : INT
' pwszBackupLogPath : LPCWSTR
' genLow : DWORD
' genHigh : DWORD
Declare PtrSafe Function CertSrvRestoreRegisterW Lib "certadm" ( _
    ByVal hbc As LongPtr, _
    ByVal pwszCheckPointFilePath As LongPtr, _
    ByVal pwszLogPath As LongPtr, _
    ByVal rgrstmap As LongPtr, _
    ByVal crstmap As Long, _
    ByVal pwszBackupLogPath As LongPtr, _
    ByVal genLow As Long, _
    ByVal genHigh As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertSrvRestoreRegisterW = ctypes.windll.certadm.CertSrvRestoreRegisterW
CertSrvRestoreRegisterW.restype = ctypes.c_int
CertSrvRestoreRegisterW.argtypes = [
    ctypes.POINTER(None),  # hbc : void* in/out
    wintypes.LPCWSTR,  # pwszCheckPointFilePath : LPCWSTR
    wintypes.LPCWSTR,  # pwszLogPath : LPCWSTR
    ctypes.c_void_p,  # rgrstmap : CSEDB_RSTMAPW* in/out
    ctypes.c_int,  # crstmap : INT
    wintypes.LPCWSTR,  # pwszBackupLogPath : LPCWSTR
    wintypes.DWORD,  # genLow : DWORD
    wintypes.DWORD,  # genHigh : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('certadm.dll')
CertSrvRestoreRegisterW = Fiddle::Function.new(
  lib['CertSrvRestoreRegisterW'],
  [
    Fiddle::TYPE_VOIDP,  # hbc : void* in/out
    Fiddle::TYPE_VOIDP,  # pwszCheckPointFilePath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pwszLogPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # rgrstmap : CSEDB_RSTMAPW* in/out
    Fiddle::TYPE_INT,  # crstmap : INT
    Fiddle::TYPE_VOIDP,  # pwszBackupLogPath : LPCWSTR
    -Fiddle::TYPE_INT,  # genLow : DWORD
    -Fiddle::TYPE_INT,  # genHigh : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "certadm")]
extern "system" {
    fn CertSrvRestoreRegisterW(
        hbc: *mut (),  // void* in/out
        pwszCheckPointFilePath: *const u16,  // LPCWSTR
        pwszLogPath: *const u16,  // LPCWSTR
        rgrstmap: *mut CSEDB_RSTMAPW,  // CSEDB_RSTMAPW* in/out
        crstmap: i32,  // INT
        pwszBackupLogPath: *const u16,  // LPCWSTR
        genLow: u32,  // DWORD
        genHigh: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("certadm.dll")]
public static extern int CertSrvRestoreRegisterW(IntPtr hbc, [MarshalAs(UnmanagedType.LPWStr)] string pwszCheckPointFilePath, [MarshalAs(UnmanagedType.LPWStr)] string pwszLogPath, IntPtr rgrstmap, int crstmap, [MarshalAs(UnmanagedType.LPWStr)] string pwszBackupLogPath, uint genLow, uint genHigh);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certadm_CertSrvRestoreRegisterW' -Namespace Win32 -PassThru
# $api::CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
#uselib "certadm.dll"
#func global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CertSrvRestoreRegisterW hbc, pwszCheckPointFilePath, pwszLogPath, varptr(rgrstmap), crstmap, pwszBackupLogPath, genLow, genHigh   ; 戻り値は stat
; hbc : void* in/out -> "sptr"
; pwszCheckPointFilePath : LPCWSTR -> "sptr"
; pwszLogPath : LPCWSTR -> "sptr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "sptr"
; crstmap : INT -> "sptr"
; pwszBackupLogPath : LPCWSTR -> "sptr"
; genLow : DWORD -> "sptr"
; genHigh : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" sptr, wstr, wstr, var, int, wstr, int, int
; res = CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
; hbc : void* in/out -> "sptr"
; pwszCheckPointFilePath : LPCWSTR -> "wstr"
; pwszLogPath : LPCWSTR -> "wstr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "var"
; crstmap : INT -> "int"
; pwszBackupLogPath : LPCWSTR -> "wstr"
; genLow : DWORD -> "int"
; genHigh : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CertSrvRestoreRegisterW(void* hbc, LPCWSTR pwszCheckPointFilePath, LPCWSTR pwszLogPath, CSEDB_RSTMAPW* rgrstmap, INT crstmap, LPCWSTR pwszBackupLogPath, DWORD genLow, DWORD genHigh)
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" intptr, wstr, wstr, var, int, wstr, int, int
; res = CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
; hbc : void* in/out -> "intptr"
; pwszCheckPointFilePath : LPCWSTR -> "wstr"
; pwszLogPath : LPCWSTR -> "wstr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "var"
; crstmap : INT -> "int"
; pwszBackupLogPath : LPCWSTR -> "wstr"
; genLow : DWORD -> "int"
; genHigh : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	certadm = windows.NewLazySystemDLL("certadm.dll")
	procCertSrvRestoreRegisterW = certadm.NewProc("CertSrvRestoreRegisterW")
)

// hbc (void* in/out), pwszCheckPointFilePath (LPCWSTR), pwszLogPath (LPCWSTR), rgrstmap (CSEDB_RSTMAPW* in/out), crstmap (INT), pwszBackupLogPath (LPCWSTR), genLow (DWORD), genHigh (DWORD)
r1, _, err := procCertSrvRestoreRegisterW.Call(
	uintptr(hbc),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszCheckPointFilePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszLogPath))),
	uintptr(rgrstmap),
	uintptr(crstmap),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszBackupLogPath))),
	uintptr(genLow),
	uintptr(genHigh),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CertSrvRestoreRegisterW(
  hbc: Pointer;   // void* in/out
  pwszCheckPointFilePath: PWideChar;   // LPCWSTR
  pwszLogPath: PWideChar;   // LPCWSTR
  rgrstmap: Pointer;   // CSEDB_RSTMAPW* in/out
  crstmap: Integer;   // INT
  pwszBackupLogPath: PWideChar;   // LPCWSTR
  genLow: DWORD;   // DWORD
  genHigh: DWORD   // DWORD
): Integer; stdcall;
  external 'certadm.dll' name 'CertSrvRestoreRegisterW';
result := DllCall("certadm\CertSrvRestoreRegisterW"
    , "Ptr", hbc   ; void* in/out
    , "WStr", pwszCheckPointFilePath   ; LPCWSTR
    , "WStr", pwszLogPath   ; LPCWSTR
    , "Ptr", rgrstmap   ; CSEDB_RSTMAPW* in/out
    , "Int", crstmap   ; INT
    , "WStr", pwszBackupLogPath   ; LPCWSTR
    , "UInt", genLow   ; DWORD
    , "UInt", genHigh   ; DWORD
    , "Int")   ; return: HRESULT
●CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh) = DLL("certadm.dll", "int CertSrvRestoreRegisterW(void*, char*, char*, void*, int, char*, dword, dword)")
# 呼び出し: CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
# hbc : void* in/out -> "void*"
# pwszCheckPointFilePath : LPCWSTR -> "char*"
# pwszLogPath : LPCWSTR -> "char*"
# rgrstmap : CSEDB_RSTMAPW* in/out -> "void*"
# crstmap : INT -> "int"
# pwszBackupLogPath : LPCWSTR -> "char*"
# genLow : DWORD -> "dword"
# genHigh : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef CertSrvRestoreRegisterWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Int32, Pointer<Utf16>, Uint32, Uint32);
typedef CertSrvRestoreRegisterWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, int, Pointer<Utf16>, int, int);
final CertSrvRestoreRegisterW = DynamicLibrary.open('certadm.dll')
    .lookupFunction<CertSrvRestoreRegisterWNative, CertSrvRestoreRegisterWDart>('CertSrvRestoreRegisterW');
// hbc : void* in/out -> Pointer<Void>
// pwszCheckPointFilePath : LPCWSTR -> Pointer<Utf16>
// pwszLogPath : LPCWSTR -> Pointer<Utf16>
// rgrstmap : CSEDB_RSTMAPW* in/out -> Pointer<Void>
// crstmap : INT -> Int32
// pwszBackupLogPath : LPCWSTR -> Pointer<Utf16>
// genLow : DWORD -> Uint32
// genHigh : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CertSrvRestoreRegisterW(
  hbc: Pointer;   // void* in/out
  pwszCheckPointFilePath: PWideChar;   // LPCWSTR
  pwszLogPath: PWideChar;   // LPCWSTR
  rgrstmap: Pointer;   // CSEDB_RSTMAPW* in/out
  crstmap: Integer;   // INT
  pwszBackupLogPath: PWideChar;   // LPCWSTR
  genLow: DWORD;   // DWORD
  genHigh: DWORD   // DWORD
): Integer; stdcall;
  external 'certadm.dll' name 'CertSrvRestoreRegisterW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CertSrvRestoreRegisterW"
  c_CertSrvRestoreRegisterW :: Ptr () -> CWString -> CWString -> Ptr () -> Int32 -> CWString -> Word32 -> Word32 -> IO Int32
-- hbc : void* in/out -> Ptr ()
-- pwszCheckPointFilePath : LPCWSTR -> CWString
-- pwszLogPath : LPCWSTR -> CWString
-- rgrstmap : CSEDB_RSTMAPW* in/out -> Ptr ()
-- crstmap : INT -> Int32
-- pwszBackupLogPath : LPCWSTR -> CWString
-- genLow : DWORD -> Word32
-- genHigh : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let certsrvrestoreregisterw =
  foreign "CertSrvRestoreRegisterW"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> int32_t @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> returning int32_t)
(* hbc : void* in/out -> (ptr void) *)
(* pwszCheckPointFilePath : LPCWSTR -> (ptr uint16_t) *)
(* pwszLogPath : LPCWSTR -> (ptr uint16_t) *)
(* rgrstmap : CSEDB_RSTMAPW* in/out -> (ptr void) *)
(* crstmap : INT -> int32_t *)
(* pwszBackupLogPath : LPCWSTR -> (ptr uint16_t) *)
(* genLow : DWORD -> uint32_t *)
(* genHigh : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library certadm (t "certadm.dll"))
(cffi:use-foreign-library certadm)

(cffi:defcfun ("CertSrvRestoreRegisterW" cert-srv-restore-register-w :convention :stdcall) :int32
  (hbc :pointer)   ; void* in/out
  (pwsz-check-point-file-path (:string :encoding :utf-16le))   ; LPCWSTR
  (pwsz-log-path (:string :encoding :utf-16le))   ; LPCWSTR
  (rgrstmap :pointer)   ; CSEDB_RSTMAPW* in/out
  (crstmap :int32)   ; INT
  (pwsz-backup-log-path (:string :encoding :utf-16le))   ; LPCWSTR
  (gen-low :uint32)   ; DWORD
  (gen-high :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CertSrvRestoreRegisterW = Win32::API::More->new('certadm',
    'int CertSrvRestoreRegisterW(LPVOID hbc, LPCWSTR pwszCheckPointFilePath, LPCWSTR pwszLogPath, LPVOID rgrstmap, int crstmap, LPCWSTR pwszBackupLogPath, DWORD genLow, DWORD genHigh)');
# my $ret = $CertSrvRestoreRegisterW->Call($hbc, $pwszCheckPointFilePath, $pwszLogPath, $rgrstmap, $crstmap, $pwszBackupLogPath, $genLow, $genHigh);
# hbc : void* in/out -> LPVOID
# pwszCheckPointFilePath : LPCWSTR -> LPCWSTR
# pwszLogPath : LPCWSTR -> LPCWSTR
# rgrstmap : CSEDB_RSTMAPW* in/out -> LPVOID
# crstmap : INT -> int
# pwszBackupLogPath : LPCWSTR -> LPCWSTR
# genLow : DWORD -> DWORD
# genHigh : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型