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