ホーム › System.Diagnostics.Debug › GetImageConfigInformation
GetImageConfigInformation
関数PEイメージのロード構成ディレクトリ情報を取得する。
シグネチャ
// imagehlp.dll
#include <windows.h>
BOOL GetImageConfigInformation(
LOADED_IMAGE* LoadedImage,
IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| LoadedImage | LOADED_IMAGE* | in |
| ImageConfigInformation | IMAGE_LOAD_CONFIG_DIRECTORY32* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// imagehlp.dll
#include <windows.h>
BOOL GetImageConfigInformation(
LOADED_IMAGE* LoadedImage,
IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetImageConfigInformation(
IntPtr LoadedImage, // LOADED_IMAGE*
IntPtr ImageConfigInformation // IMAGE_LOAD_CONFIG_DIRECTORY32* out
);<DllImport("imagehlp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetImageConfigInformation(
LoadedImage As IntPtr, ' LOADED_IMAGE*
ImageConfigInformation As IntPtr ' IMAGE_LOAD_CONFIG_DIRECTORY32* out
) As Boolean
End Function' LoadedImage : LOADED_IMAGE*
' ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out
Declare PtrSafe Function GetImageConfigInformation Lib "imagehlp" ( _
ByVal LoadedImage As LongPtr, _
ByVal ImageConfigInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetImageConfigInformation = ctypes.windll.imagehlp.GetImageConfigInformation
GetImageConfigInformation.restype = wintypes.BOOL
GetImageConfigInformation.argtypes = [
ctypes.c_void_p, # LoadedImage : LOADED_IMAGE*
ctypes.c_void_p, # ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('imagehlp.dll')
GetImageConfigInformation = Fiddle::Function.new(
lib['GetImageConfigInformation'],
[
Fiddle::TYPE_VOIDP, # LoadedImage : LOADED_IMAGE*
Fiddle::TYPE_VOIDP, # ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out
],
Fiddle::TYPE_INT)#[link(name = "imagehlp")]
extern "system" {
fn GetImageConfigInformation(
LoadedImage: *mut LOADED_IMAGE, // LOADED_IMAGE*
ImageConfigInformation: *mut IMAGE_LOAD_CONFIG_DIRECTORY32 // IMAGE_LOAD_CONFIG_DIRECTORY32* out
) -> 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 GetImageConfigInformation(IntPtr LoadedImage, IntPtr ImageConfigInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'imagehlp_GetImageConfigInformation' -Namespace Win32 -PassThru
# $api::GetImageConfigInformation(LoadedImage, ImageConfigInformation)#uselib "imagehlp.dll"
#func global GetImageConfigInformation "GetImageConfigInformation" sptr, sptr
; GetImageConfigInformation varptr(LoadedImage), varptr(ImageConfigInformation) ; 戻り値は stat
; LoadedImage : LOADED_IMAGE* -> "sptr"
; ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "imagehlp.dll" #cfunc global GetImageConfigInformation "GetImageConfigInformation" var, var ; res = GetImageConfigInformation(LoadedImage, ImageConfigInformation) ; LoadedImage : LOADED_IMAGE* -> "var" ; ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "imagehlp.dll" #cfunc global GetImageConfigInformation "GetImageConfigInformation" sptr, sptr ; res = GetImageConfigInformation(varptr(LoadedImage), varptr(ImageConfigInformation)) ; LoadedImage : LOADED_IMAGE* -> "sptr" ; ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetImageConfigInformation(LOADED_IMAGE* LoadedImage, IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation) #uselib "imagehlp.dll" #cfunc global GetImageConfigInformation "GetImageConfigInformation" var, var ; res = GetImageConfigInformation(LoadedImage, ImageConfigInformation) ; LoadedImage : LOADED_IMAGE* -> "var" ; ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetImageConfigInformation(LOADED_IMAGE* LoadedImage, IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation) #uselib "imagehlp.dll" #cfunc global GetImageConfigInformation "GetImageConfigInformation" intptr, intptr ; res = GetImageConfigInformation(varptr(LoadedImage), varptr(ImageConfigInformation)) ; LoadedImage : LOADED_IMAGE* -> "intptr" ; ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
procGetImageConfigInformation = imagehlp.NewProc("GetImageConfigInformation")
)
// LoadedImage (LOADED_IMAGE*), ImageConfigInformation (IMAGE_LOAD_CONFIG_DIRECTORY32* out)
r1, _, err := procGetImageConfigInformation.Call(
uintptr(LoadedImage),
uintptr(ImageConfigInformation),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetImageConfigInformation(
LoadedImage: Pointer; // LOADED_IMAGE*
ImageConfigInformation: Pointer // IMAGE_LOAD_CONFIG_DIRECTORY32* out
): BOOL; stdcall;
external 'imagehlp.dll' name 'GetImageConfigInformation';result := DllCall("imagehlp\GetImageConfigInformation"
, "Ptr", LoadedImage ; LOADED_IMAGE*
, "Ptr", ImageConfigInformation ; IMAGE_LOAD_CONFIG_DIRECTORY32* out
, "Int") ; return: BOOL●GetImageConfigInformation(LoadedImage, ImageConfigInformation) = DLL("imagehlp.dll", "bool GetImageConfigInformation(void*, void*)")
# 呼び出し: GetImageConfigInformation(LoadedImage, ImageConfigInformation)
# LoadedImage : LOADED_IMAGE* -> "void*"
# ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。