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