ホーム › System.Diagnostics.Debug › BindImageEx
BindImageEx
関数コールバック付きでイメージのインポート参照を束縛する拡張版である。
シグネチャ
// imagehlp.dll
#include <windows.h>
BOOL BindImageEx(
DWORD Flags,
LPCSTR ImageName,
LPCSTR DllPath,
LPCSTR SymbolPath,
PIMAGEHLP_STATUS_ROUTINE StatusRoutine // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Flags | DWORD | in |
| ImageName | LPCSTR | in |
| DllPath | LPCSTR | in |
| SymbolPath | LPCSTR | in |
| StatusRoutine | PIMAGEHLP_STATUS_ROUTINE | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// imagehlp.dll
#include <windows.h>
BOOL BindImageEx(
DWORD Flags,
LPCSTR ImageName,
LPCSTR DllPath,
LPCSTR SymbolPath,
PIMAGEHLP_STATUS_ROUTINE StatusRoutine // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool BindImageEx(
uint Flags, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string ImageName, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string DllPath, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SymbolPath, // LPCSTR
IntPtr StatusRoutine // PIMAGEHLP_STATUS_ROUTINE optional
);<DllImport("imagehlp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BindImageEx(
Flags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> ImageName As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> DllPath As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SymbolPath As String, ' LPCSTR
StatusRoutine As IntPtr ' PIMAGEHLP_STATUS_ROUTINE optional
) As Boolean
End Function' Flags : DWORD
' ImageName : LPCSTR
' DllPath : LPCSTR
' SymbolPath : LPCSTR
' StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional
Declare PtrSafe Function BindImageEx Lib "imagehlp" ( _
ByVal Flags As Long, _
ByVal ImageName As String, _
ByVal DllPath As String, _
ByVal SymbolPath As String, _
ByVal StatusRoutine As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BindImageEx = ctypes.windll.imagehlp.BindImageEx
BindImageEx.restype = wintypes.BOOL
BindImageEx.argtypes = [
wintypes.DWORD, # Flags : DWORD
wintypes.LPCSTR, # ImageName : LPCSTR
wintypes.LPCSTR, # DllPath : LPCSTR
wintypes.LPCSTR, # SymbolPath : LPCSTR
ctypes.c_void_p, # StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('imagehlp.dll')
BindImageEx = Fiddle::Function.new(
lib['BindImageEx'],
[
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # ImageName : LPCSTR
Fiddle::TYPE_VOIDP, # DllPath : LPCSTR
Fiddle::TYPE_VOIDP, # SymbolPath : LPCSTR
Fiddle::TYPE_VOIDP, # StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional
],
Fiddle::TYPE_INT)#[link(name = "imagehlp")]
extern "system" {
fn BindImageEx(
Flags: u32, // DWORD
ImageName: *const u8, // LPCSTR
DllPath: *const u8, // LPCSTR
SymbolPath: *const u8, // LPCSTR
StatusRoutine: *const core::ffi::c_void // PIMAGEHLP_STATUS_ROUTINE optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true)]
public static extern bool BindImageEx(uint Flags, [MarshalAs(UnmanagedType.LPStr)] string ImageName, [MarshalAs(UnmanagedType.LPStr)] string DllPath, [MarshalAs(UnmanagedType.LPStr)] string SymbolPath, IntPtr StatusRoutine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'imagehlp_BindImageEx' -Namespace Win32 -PassThru
# $api::BindImageEx(Flags, ImageName, DllPath, SymbolPath, StatusRoutine)#uselib "imagehlp.dll"
#func global BindImageEx "BindImageEx" sptr, sptr, sptr, sptr, sptr
; BindImageEx Flags, ImageName, DllPath, SymbolPath, StatusRoutine ; 戻り値は stat
; Flags : DWORD -> "sptr"
; ImageName : LPCSTR -> "sptr"
; DllPath : LPCSTR -> "sptr"
; SymbolPath : LPCSTR -> "sptr"
; StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "imagehlp.dll"
#cfunc global BindImageEx "BindImageEx" int, str, str, str, sptr
; res = BindImageEx(Flags, ImageName, DllPath, SymbolPath, StatusRoutine)
; Flags : DWORD -> "int"
; ImageName : LPCSTR -> "str"
; DllPath : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"
; StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional -> "sptr"; BOOL BindImageEx(DWORD Flags, LPCSTR ImageName, LPCSTR DllPath, LPCSTR SymbolPath, PIMAGEHLP_STATUS_ROUTINE StatusRoutine)
#uselib "imagehlp.dll"
#cfunc global BindImageEx "BindImageEx" int, str, str, str, intptr
; res = BindImageEx(Flags, ImageName, DllPath, SymbolPath, StatusRoutine)
; Flags : DWORD -> "int"
; ImageName : LPCSTR -> "str"
; DllPath : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"
; StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
procBindImageEx = imagehlp.NewProc("BindImageEx")
)
// Flags (DWORD), ImageName (LPCSTR), DllPath (LPCSTR), SymbolPath (LPCSTR), StatusRoutine (PIMAGEHLP_STATUS_ROUTINE optional)
r1, _, err := procBindImageEx.Call(
uintptr(Flags),
uintptr(unsafe.Pointer(windows.BytePtrFromString(ImageName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DllPath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SymbolPath))),
uintptr(StatusRoutine),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction BindImageEx(
Flags: DWORD; // DWORD
ImageName: PAnsiChar; // LPCSTR
DllPath: PAnsiChar; // LPCSTR
SymbolPath: PAnsiChar; // LPCSTR
StatusRoutine: Pointer // PIMAGEHLP_STATUS_ROUTINE optional
): BOOL; stdcall;
external 'imagehlp.dll' name 'BindImageEx';result := DllCall("imagehlp\BindImageEx"
, "UInt", Flags ; DWORD
, "AStr", ImageName ; LPCSTR
, "AStr", DllPath ; LPCSTR
, "AStr", SymbolPath ; LPCSTR
, "Ptr", StatusRoutine ; PIMAGEHLP_STATUS_ROUTINE optional
, "Int") ; return: BOOL●BindImageEx(Flags, ImageName, DllPath, SymbolPath, StatusRoutine) = DLL("imagehlp.dll", "bool BindImageEx(dword, char*, char*, char*, void*)")
# 呼び出し: BindImageEx(Flags, ImageName, DllPath, SymbolPath, StatusRoutine)
# Flags : DWORD -> "dword"
# ImageName : LPCSTR -> "char*"
# DllPath : LPCSTR -> "char*"
# SymbolPath : LPCSTR -> "char*"
# StatusRoutine : PIMAGEHLP_STATUS_ROUTINE optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。