ホーム › System.Diagnostics.Debug.Extensions › DebugConnectWide
DebugConnectWide
関数リモートデバッグセッションに接続しエンジンを取得する(Unicode)。
シグネチャ
// dbgeng.dll
#include <windows.h>
HRESULT DebugConnectWide(
LPCWSTR RemoteOptions,
const GUID* InterfaceId,
void** Interface
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| RemoteOptions | LPCWSTR | in | リモートデバッグ接続先を指定する接続文字列(Unicode)。 |
| InterfaceId | GUID* | in | 要求するデバッグインターフェイスのIID(GUID)へのポインタ。 |
| Interface | void** | out | 取得したインターフェイスポインタを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// dbgeng.dll
#include <windows.h>
HRESULT DebugConnectWide(
LPCWSTR RemoteOptions,
const GUID* InterfaceId,
void** Interface
);[DllImport("dbgeng.dll", ExactSpelling = true)]
static extern int DebugConnectWide(
[MarshalAs(UnmanagedType.LPWStr)] string RemoteOptions, // LPCWSTR
ref Guid InterfaceId, // GUID*
IntPtr Interface // void** out
);<DllImport("dbgeng.dll", ExactSpelling:=True)>
Public Shared Function DebugConnectWide(
<MarshalAs(UnmanagedType.LPWStr)> RemoteOptions As String, ' LPCWSTR
ByRef InterfaceId As Guid, ' GUID*
[Interface] As IntPtr ' void** out
) As Integer
End Function' RemoteOptions : LPCWSTR
' InterfaceId : GUID*
' Interface : void** out
Declare PtrSafe Function DebugConnectWide Lib "dbgeng" ( _
ByVal RemoteOptions As LongPtr, _
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
DebugConnectWide = ctypes.windll.dbgeng.DebugConnectWide
DebugConnectWide.restype = ctypes.c_int
DebugConnectWide.argtypes = [
wintypes.LPCWSTR, # RemoteOptions : LPCWSTR
ctypes.c_void_p, # InterfaceId : GUID*
ctypes.c_void_p, # Interface : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbgeng.dll')
DebugConnectWide = Fiddle::Function.new(
lib['DebugConnectWide'],
[
Fiddle::TYPE_VOIDP, # RemoteOptions : LPCWSTR
Fiddle::TYPE_VOIDP, # InterfaceId : GUID*
Fiddle::TYPE_VOIDP, # Interface : void** out
],
Fiddle::TYPE_INT)#[link(name = "dbgeng")]
extern "system" {
fn DebugConnectWide(
RemoteOptions: *const u16, // LPCWSTR
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 DebugConnectWide([MarshalAs(UnmanagedType.LPWStr)] string RemoteOptions, ref Guid InterfaceId, IntPtr Interface);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbgeng_DebugConnectWide' -Namespace Win32 -PassThru
# $api::DebugConnectWide(RemoteOptions, InterfaceId, Interface)#uselib "dbgeng.dll"
#func global DebugConnectWide "DebugConnectWide" sptr, sptr, sptr
; DebugConnectWide RemoteOptions, varptr(InterfaceId), Interface ; 戻り値は stat
; RemoteOptions : LPCWSTR -> "sptr"
; InterfaceId : GUID* -> "sptr"
; Interface : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dbgeng.dll" #cfunc global DebugConnectWide "DebugConnectWide" wstr, var, sptr ; res = DebugConnectWide(RemoteOptions, InterfaceId, Interface) ; RemoteOptions : LPCWSTR -> "wstr" ; InterfaceId : GUID* -> "var" ; Interface : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dbgeng.dll" #cfunc global DebugConnectWide "DebugConnectWide" wstr, sptr, sptr ; res = DebugConnectWide(RemoteOptions, varptr(InterfaceId), Interface) ; RemoteOptions : LPCWSTR -> "wstr" ; InterfaceId : GUID* -> "sptr" ; Interface : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DebugConnectWide(LPCWSTR RemoteOptions, GUID* InterfaceId, void** Interface) #uselib "dbgeng.dll" #cfunc global DebugConnectWide "DebugConnectWide" wstr, var, intptr ; res = DebugConnectWide(RemoteOptions, InterfaceId, Interface) ; RemoteOptions : LPCWSTR -> "wstr" ; InterfaceId : GUID* -> "var" ; Interface : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DebugConnectWide(LPCWSTR RemoteOptions, GUID* InterfaceId, void** Interface) #uselib "dbgeng.dll" #cfunc global DebugConnectWide "DebugConnectWide" wstr, intptr, intptr ; res = DebugConnectWide(RemoteOptions, varptr(InterfaceId), Interface) ; RemoteOptions : LPCWSTR -> "wstr" ; InterfaceId : GUID* -> "intptr" ; Interface : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbgeng = windows.NewLazySystemDLL("dbgeng.dll")
procDebugConnectWide = dbgeng.NewProc("DebugConnectWide")
)
// RemoteOptions (LPCWSTR), InterfaceId (GUID*), Interface (void** out)
r1, _, err := procDebugConnectWide.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(RemoteOptions))),
uintptr(InterfaceId),
uintptr(Interface),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DebugConnectWide(
RemoteOptions: PWideChar; // LPCWSTR
InterfaceId: PGUID; // GUID*
Interface: Pointer // void** out
): Integer; stdcall;
external 'dbgeng.dll' name 'DebugConnectWide';result := DllCall("dbgeng\DebugConnectWide"
, "WStr", RemoteOptions ; LPCWSTR
, "Ptr", InterfaceId ; GUID*
, "Ptr", Interface ; void** out
, "Int") ; return: HRESULT●DebugConnectWide(RemoteOptions, InterfaceId, Interface) = DLL("dbgeng.dll", "int DebugConnectWide(char*, void*, void*)")
# 呼び出し: DebugConnectWide(RemoteOptions, InterfaceId, Interface)
# RemoteOptions : LPCWSTR -> "char*"
# InterfaceId : GUID* -> "void*"
# Interface : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dbgeng" fn DebugConnectWide(
RemoteOptions: [*c]const u16, // LPCWSTR
InterfaceId: [*c]GUID, // GUID*
Interface: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc DebugConnectWide(
RemoteOptions: WideCString, # LPCWSTR
InterfaceId: ptr GUID, # GUID*
Interface: pointer # void** out
): int32 {.importc: "DebugConnectWide", stdcall, dynlib: "dbgeng.dll".}pragma(lib, "dbgeng");
extern(Windows)
int DebugConnectWide(
const(wchar)* RemoteOptions, // LPCWSTR
GUID* InterfaceId, // GUID*
void** Interface // void** out
);ccall((:DebugConnectWide, "dbgeng.dll"), stdcall, Int32,
(Cwstring, Ptr{GUID}, Ptr{Cvoid}),
RemoteOptions, InterfaceId, Interface)
# RemoteOptions : LPCWSTR -> Cwstring
# InterfaceId : GUID* -> Ptr{GUID}
# Interface : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DebugConnectWide(
const uint16_t* RemoteOptions,
void* InterfaceId,
void** Interface);
]]
local dbgeng = ffi.load("dbgeng")
-- dbgeng.DebugConnectWide(RemoteOptions, InterfaceId, Interface)
-- RemoteOptions : LPCWSTR
-- InterfaceId : GUID*
-- Interface : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dbgeng.dll');
const DebugConnectWide = lib.func('__stdcall', 'DebugConnectWide', 'int32_t', ['str16', 'void *', 'void *']);
// DebugConnectWide(RemoteOptions, InterfaceId, Interface)
// RemoteOptions : LPCWSTR -> 'str16'
// InterfaceId : GUID* -> 'void *'
// Interface : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dbgeng.dll", {
DebugConnectWide: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.DebugConnectWide(RemoteOptions, InterfaceId, Interface)
// RemoteOptions : LPCWSTR -> "buffer"
// InterfaceId : GUID* -> "pointer"
// Interface : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DebugConnectWide(
const uint16_t* RemoteOptions,
void* InterfaceId,
void** Interface);
C, "dbgeng.dll");
// $ffi->DebugConnectWide(RemoteOptions, InterfaceId, Interface);
// RemoteOptions : LPCWSTR
// 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 DebugConnectWide(
WString RemoteOptions, // LPCWSTR
Pointer InterfaceId, // GUID*
Pointer Interface // void** out
);
}@[Link("dbgeng")]
lib Libdbgeng
fun DebugConnectWide = DebugConnectWide(
RemoteOptions : UInt16*, # LPCWSTR
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 DebugConnectWideNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef DebugConnectWideDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final DebugConnectWide = DynamicLibrary.open('dbgeng.dll')
.lookupFunction<DebugConnectWideNative, DebugConnectWideDart>('DebugConnectWide');
// RemoteOptions : LPCWSTR -> Pointer<Utf16>
// InterfaceId : GUID* -> Pointer<Void>
// Interface : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DebugConnectWide(
RemoteOptions: PWideChar; // LPCWSTR
InterfaceId: PGUID; // GUID*
Interface: Pointer // void** out
): Integer; stdcall;
external 'dbgeng.dll' name 'DebugConnectWide';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DebugConnectWide"
c_DebugConnectWide :: CWString -> Ptr () -> Ptr () -> IO Int32
-- RemoteOptions : LPCWSTR -> CWString
-- InterfaceId : GUID* -> Ptr ()
-- Interface : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let debugconnectwide =
foreign "DebugConnectWide"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* RemoteOptions : LPCWSTR -> (ptr uint16_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 ("DebugConnectWide" debug-connect-wide :convention :stdcall) :int32
(remote-options (:string :encoding :utf-16le)) ; LPCWSTR
(interface-id :pointer) ; GUID*
(interface :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DebugConnectWide = Win32::API::More->new('dbgeng',
'int DebugConnectWide(LPCWSTR RemoteOptions, LPVOID InterfaceId, LPVOID Interface)');
# my $ret = $DebugConnectWide->Call($RemoteOptions, $InterfaceId, $Interface);
# RemoteOptions : LPCWSTR -> LPCWSTR
# InterfaceId : GUID* -> LPVOID
# Interface : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。