ホーム › System.Diagnostics.Debug › BindImage
BindImage
関数イメージのインポート参照をアドレスに束縛して読み込みを高速化する。
シグネチャ
// imagehlp.dll
#include <windows.h>
BOOL BindImage(
LPCSTR ImageName,
LPCSTR DllPath,
LPCSTR SymbolPath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ImageName | LPCSTR | in |
| DllPath | LPCSTR | in |
| SymbolPath | LPCSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// imagehlp.dll
#include <windows.h>
BOOL BindImage(
LPCSTR ImageName,
LPCSTR DllPath,
LPCSTR SymbolPath
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool BindImage(
[MarshalAs(UnmanagedType.LPStr)] string ImageName, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string DllPath, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SymbolPath // LPCSTR
);<DllImport("imagehlp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BindImage(
<MarshalAs(UnmanagedType.LPStr)> ImageName As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> DllPath As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SymbolPath As String ' LPCSTR
) As Boolean
End Function' ImageName : LPCSTR
' DllPath : LPCSTR
' SymbolPath : LPCSTR
Declare PtrSafe Function BindImage Lib "imagehlp" ( _
ByVal ImageName As String, _
ByVal DllPath As String, _
ByVal SymbolPath As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BindImage = ctypes.windll.imagehlp.BindImage
BindImage.restype = wintypes.BOOL
BindImage.argtypes = [
wintypes.LPCSTR, # ImageName : LPCSTR
wintypes.LPCSTR, # DllPath : LPCSTR
wintypes.LPCSTR, # SymbolPath : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('imagehlp.dll')
BindImage = Fiddle::Function.new(
lib['BindImage'],
[
Fiddle::TYPE_VOIDP, # ImageName : LPCSTR
Fiddle::TYPE_VOIDP, # DllPath : LPCSTR
Fiddle::TYPE_VOIDP, # SymbolPath : LPCSTR
],
Fiddle::TYPE_INT)#[link(name = "imagehlp")]
extern "system" {
fn BindImage(
ImageName: *const u8, // LPCSTR
DllPath: *const u8, // LPCSTR
SymbolPath: *const u8 // LPCSTR
) -> 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 BindImage([MarshalAs(UnmanagedType.LPStr)] string ImageName, [MarshalAs(UnmanagedType.LPStr)] string DllPath, [MarshalAs(UnmanagedType.LPStr)] string SymbolPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'imagehlp_BindImage' -Namespace Win32 -PassThru
# $api::BindImage(ImageName, DllPath, SymbolPath)#uselib "imagehlp.dll"
#func global BindImage "BindImage" sptr, sptr, sptr
; BindImage ImageName, DllPath, SymbolPath ; 戻り値は stat
; ImageName : LPCSTR -> "sptr"
; DllPath : LPCSTR -> "sptr"
; SymbolPath : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "imagehlp.dll"
#cfunc global BindImage "BindImage" str, str, str
; res = BindImage(ImageName, DllPath, SymbolPath)
; ImageName : LPCSTR -> "str"
; DllPath : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"; BOOL BindImage(LPCSTR ImageName, LPCSTR DllPath, LPCSTR SymbolPath)
#uselib "imagehlp.dll"
#cfunc global BindImage "BindImage" str, str, str
; res = BindImage(ImageName, DllPath, SymbolPath)
; ImageName : LPCSTR -> "str"
; DllPath : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
procBindImage = imagehlp.NewProc("BindImage")
)
// ImageName (LPCSTR), DllPath (LPCSTR), SymbolPath (LPCSTR)
r1, _, err := procBindImage.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(ImageName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DllPath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SymbolPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction BindImage(
ImageName: PAnsiChar; // LPCSTR
DllPath: PAnsiChar; // LPCSTR
SymbolPath: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'imagehlp.dll' name 'BindImage';result := DllCall("imagehlp\BindImage"
, "AStr", ImageName ; LPCSTR
, "AStr", DllPath ; LPCSTR
, "AStr", SymbolPath ; LPCSTR
, "Int") ; return: BOOL●BindImage(ImageName, DllPath, SymbolPath) = DLL("imagehlp.dll", "bool BindImage(char*, char*, char*)")
# 呼び出し: BindImage(ImageName, DllPath, SymbolPath)
# ImageName : LPCSTR -> "char*"
# DllPath : LPCSTR -> "char*"
# SymbolPath : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。