ホーム › 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 | MapAndLoad または ImageLoad の呼び出しによって返される LOADED_IMAGE 構造体へのポインター。 |
| ImageConfigInformation | IMAGE_LOAD_CONFIG_DIRECTORY32* | in | IMAGE_LOAD_CONFIG_DIRECTORY64 構造体へのポインター。 |
戻り値の型: 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 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "imagehlp" fn SetImageConfigInformation(
LoadedImage: [*c]LOADED_IMAGE, // LOADED_IMAGE* in/out
ImageConfigInformation: [*c]IMAGE_LOAD_CONFIG_DIRECTORY32 // IMAGE_LOAD_CONFIG_DIRECTORY32*
) callconv(std.os.windows.WINAPI) i32;proc SetImageConfigInformation(
LoadedImage: ptr LOADED_IMAGE, # LOADED_IMAGE* in/out
ImageConfigInformation: ptr IMAGE_LOAD_CONFIG_DIRECTORY32 # IMAGE_LOAD_CONFIG_DIRECTORY32*
): int32 {.importc: "SetImageConfigInformation", stdcall, dynlib: "imagehlp.dll".}pragma(lib, "imagehlp");
extern(Windows)
int SetImageConfigInformation(
LOADED_IMAGE* LoadedImage, // LOADED_IMAGE* in/out
IMAGE_LOAD_CONFIG_DIRECTORY32* ImageConfigInformation // IMAGE_LOAD_CONFIG_DIRECTORY32*
);ccall((:SetImageConfigInformation, "imagehlp.dll"), stdcall, Int32,
(Ptr{LOADED_IMAGE}, Ptr{IMAGE_LOAD_CONFIG_DIRECTORY32}),
LoadedImage, ImageConfigInformation)
# LoadedImage : LOADED_IMAGE* in/out -> Ptr{LOADED_IMAGE}
# ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> Ptr{IMAGE_LOAD_CONFIG_DIRECTORY32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetImageConfigInformation(
void* LoadedImage,
void* ImageConfigInformation);
]]
local imagehlp = ffi.load("imagehlp")
-- imagehlp.SetImageConfigInformation(LoadedImage, ImageConfigInformation)
-- LoadedImage : LOADED_IMAGE* in/out
-- ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('imagehlp.dll');
const SetImageConfigInformation = lib.func('__stdcall', 'SetImageConfigInformation', 'int32_t', ['void *', 'void *']);
// SetImageConfigInformation(LoadedImage, ImageConfigInformation)
// LoadedImage : LOADED_IMAGE* in/out -> 'void *'
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("imagehlp.dll", {
SetImageConfigInformation: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.SetImageConfigInformation(LoadedImage, ImageConfigInformation)
// LoadedImage : LOADED_IMAGE* in/out -> "pointer"
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetImageConfigInformation(
void* LoadedImage,
void* ImageConfigInformation);
C, "imagehlp.dll");
// $ffi->SetImageConfigInformation(LoadedImage, ImageConfigInformation);
// LoadedImage : LOADED_IMAGE* in/out
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32*
// 構造体/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 SetImageConfigInformation(
Pointer LoadedImage, // LOADED_IMAGE* in/out
Pointer ImageConfigInformation // IMAGE_LOAD_CONFIG_DIRECTORY32*
);
}@[Link("imagehlp")]
lib Libimagehlp
fun SetImageConfigInformation = SetImageConfigInformation(
LoadedImage : LOADED_IMAGE*, # LOADED_IMAGE* in/out
ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* # IMAGE_LOAD_CONFIG_DIRECTORY32*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetImageConfigInformationNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef SetImageConfigInformationDart = int Function(Pointer<Void>, Pointer<Void>);
final SetImageConfigInformation = DynamicLibrary.open('imagehlp.dll')
.lookupFunction<SetImageConfigInformationNative, SetImageConfigInformationDart>('SetImageConfigInformation');
// LoadedImage : LOADED_IMAGE* in/out -> Pointer<Void>
// ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetImageConfigInformation(
LoadedImage: Pointer; // LOADED_IMAGE* in/out
ImageConfigInformation: Pointer // IMAGE_LOAD_CONFIG_DIRECTORY32*
): BOOL; stdcall;
external 'imagehlp.dll' name 'SetImageConfigInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetImageConfigInformation"
c_SetImageConfigInformation :: Ptr () -> Ptr () -> IO CInt
-- LoadedImage : LOADED_IMAGE* in/out -> Ptr ()
-- ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setimageconfiginformation =
foreign "SetImageConfigInformation"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* LoadedImage : LOADED_IMAGE* in/out -> (ptr void) *)
(* ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library imagehlp (t "imagehlp.dll"))
(cffi:use-foreign-library imagehlp)
(cffi:defcfun ("SetImageConfigInformation" set-image-config-information :convention :stdcall) :int32
(loaded-image :pointer) ; LOADED_IMAGE* in/out
(image-config-information :pointer)) ; IMAGE_LOAD_CONFIG_DIRECTORY32*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetImageConfigInformation = Win32::API::More->new('imagehlp',
'BOOL SetImageConfigInformation(LPVOID LoadedImage, LPVOID ImageConfigInformation)');
# my $ret = $SetImageConfigInformation->Call($LoadedImage, $ImageConfigInformation);
# LoadedImage : LOADED_IMAGE* in/out -> LPVOID
# ImageConfigInformation : IMAGE_LOAD_CONFIG_DIRECTORY32* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f GetImageConfigInformation — PEイメージのロード構成ディレクトリ情報を取得する。