ホーム › 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 | LOADED_IMAGE 構造体へのポインター。MapAndLoad または ImageLoad の呼び出しから返されます。 |
| ImageConfigInformation | IMAGE_LOAD_CONFIG_DIRECTORY32* | out | 構成情報を受け取る IMAGE_LOAD_CONFIG_DIRECTORY 構造体へのポインター。 _WIN64 が定義されている場合、IMAGE_LOAD_CONFIG_DIRECTORY は IMAGE_LOAD_CONFIG_DIRECTORY64 として定義されます。一方、_WIN64 が定義されていない場合、IMAGE_LOAD_CONFIG_DIRECTORY は IMAGE_LOAD_CONFIG_DIRECTORY32 として定義されます。 |
戻り値の型: BOOL
公式ドキュメント
イメージのロード構成データを検索して返します。
戻り値
関数が成功した場合、戻り値は TRUE です。
関数が失敗した場合、戻り値は FALSE です。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
SetImageConfigInformation 関数は、イメージのロード構成データを検索して変更します。
この関数を含むすべての ImageHlp 関数はシングルスレッドです。そのため、複数のスレッドからこの関数を呼び出すと、予期しない動作やメモリ破損が発生する可能性が高くなります。これを回避するには、複数のスレッドからこの関数への同時呼び出しをすべて同期する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "imagehlp" fn GetImageConfigInformation(
LoadedImage: [*c]LOADED_IMAGE, // LOADED_IMAGE*
ImageConfigInformation: [*c]IMAGE_LOAD_CONFIG_DIRECTORY32 // IMAGE_LOAD_CONFIG_DIRECTORY32* out
) callconv(std.os.windows.WINAPI) i32;proc GetImageConfigInformation(
LoadedImage: ptr LOADED_IMAGE, # LOADED_IMAGE*
ImageConfigInformation: ptr IMAGE_LOAD_CONFIG_DIRECTORY32 # IMAGE_LOAD_CONFIG_DIRECTORY32* out
): int32 {.importc: "GetImageConfigInformation", stdcall, dynlib: "imagehlp.dll".}pragma(lib, "imagehlp");
extern(Windows)
int GetImageConfigInformation(
LOADED_IMAGE* LoadedImage, // LOADED_IMAGE*
IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation // IMAGE_LOAD_CONFIG_DIRECTORY32* out
);ccall((:GetImageConfigInformation, "imagehlp.dll"), stdcall, Int32,
(Ptr{LOADED_IMAGE}, Ptr{IMAGE_LOAD_CONFIG_DIRECTORY32}),
LoadedImage, ImageConfigInformation)
# LoadedImage : LOADED_IMAGE* -> Ptr{LOADED_IMAGE}
# ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> Ptr{IMAGE_LOAD_CONFIG_DIRECTORY32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetImageConfigInformation(
void* LoadedImage,
void* ImageConfigInformation);
]]
local imagehlp = ffi.load("imagehlp")
-- imagehlp.GetImageConfigInformation(LoadedImage, ImageConfigInformation)
-- LoadedImage : LOADED_IMAGE*
-- ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('imagehlp.dll');
const GetImageConfigInformation = lib.func('__stdcall', 'GetImageConfigInformation', 'int32_t', ['void *', 'void *']);
// GetImageConfigInformation(LoadedImage, ImageConfigInformation)
// LoadedImage : LOADED_IMAGE* -> 'void *'
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("imagehlp.dll", {
GetImageConfigInformation: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetImageConfigInformation(LoadedImage, ImageConfigInformation)
// LoadedImage : LOADED_IMAGE* -> "pointer"
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetImageConfigInformation(
void* LoadedImage,
void* ImageConfigInformation);
C, "imagehlp.dll");
// $ffi->GetImageConfigInformation(LoadedImage, ImageConfigInformation);
// LoadedImage : LOADED_IMAGE*
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* 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 Imagehlp extends StdCallLibrary {
Imagehlp INSTANCE = Native.load("imagehlp", Imagehlp.class);
boolean GetImageConfigInformation(
Pointer LoadedImage, // LOADED_IMAGE*
Pointer ImageConfigInformation // IMAGE_LOAD_CONFIG_DIRECTORY32* out
);
}@[Link("imagehlp")]
lib Libimagehlp
fun GetImageConfigInformation = GetImageConfigInformation(
LoadedImage : LOADED_IMAGE*, # LOADED_IMAGE*
ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* # IMAGE_LOAD_CONFIG_DIRECTORY32* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetImageConfigInformationNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef GetImageConfigInformationDart = int Function(Pointer<Void>, Pointer<Void>);
final GetImageConfigInformation = DynamicLibrary.open('imagehlp.dll')
.lookupFunction<GetImageConfigInformationNative, GetImageConfigInformationDart>('GetImageConfigInformation');
// LoadedImage : LOADED_IMAGE* -> Pointer<Void>
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetImageConfigInformation(
LoadedImage: Pointer; // LOADED_IMAGE*
ImageConfigInformation: Pointer // IMAGE_LOAD_CONFIG_DIRECTORY32* out
): BOOL; stdcall;
external 'imagehlp.dll' name 'GetImageConfigInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetImageConfigInformation"
c_GetImageConfigInformation :: Ptr () -> Ptr () -> IO CInt
-- LoadedImage : LOADED_IMAGE* -> Ptr ()
-- ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getimageconfiginformation =
foreign "GetImageConfigInformation"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* LoadedImage : LOADED_IMAGE* -> (ptr void) *)
(* ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library imagehlp (t "imagehlp.dll"))
(cffi:use-foreign-library imagehlp)
(cffi:defcfun ("GetImageConfigInformation" get-image-config-information :convention :stdcall) :int32
(loaded-image :pointer) ; LOADED_IMAGE*
(image-config-information :pointer)) ; IMAGE_LOAD_CONFIG_DIRECTORY32* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetImageConfigInformation = Win32::API::More->new('imagehlp',
'BOOL GetImageConfigInformation(LPVOID LoadedImage, LPVOID ImageConfigInformation)');
# my $ret = $GetImageConfigInformation->Call($LoadedImage, $ImageConfigInformation);
# LoadedImage : LOADED_IMAGE* -> LPVOID
# ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f SetImageConfigInformation — PEイメージのロード構成ディレクトリ情報を設定する。