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