ホーム › System.Diagnostics.Debug › ImageDirectoryEntryToData
ImageDirectoryEntryToData
関数指定したデータディレクトリの位置とサイズを取得する。
シグネチャ
// dbghelp.dll
#include <windows.h>
void* ImageDirectoryEntryToData(
void* Base,
BOOLEAN MappedAsImage,
IMAGE_DIRECTORY_ENTRY DirectoryEntry,
DWORD* Size
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Base | void* | in |
| MappedAsImage | BOOLEAN | in |
| DirectoryEntry | IMAGE_DIRECTORY_ENTRY | in |
| Size | DWORD* | out |
戻り値の型: void*
各言語での呼び出し定義
// dbghelp.dll
#include <windows.h>
void* ImageDirectoryEntryToData(
void* Base,
BOOLEAN MappedAsImage,
IMAGE_DIRECTORY_ENTRY DirectoryEntry,
DWORD* Size
);[DllImport("dbghelp.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr ImageDirectoryEntryToData(
IntPtr Base, // void*
[MarshalAs(UnmanagedType.U1)] bool MappedAsImage, // BOOLEAN
ushort DirectoryEntry, // IMAGE_DIRECTORY_ENTRY
out uint Size // DWORD* out
);<DllImport("dbghelp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ImageDirectoryEntryToData(
Base As IntPtr, ' void*
<MarshalAs(UnmanagedType.U1)> MappedAsImage As Boolean, ' BOOLEAN
DirectoryEntry As UShort, ' IMAGE_DIRECTORY_ENTRY
<Out> ByRef Size As UInteger ' DWORD* out
) As IntPtr
End Function' Base : void*
' MappedAsImage : BOOLEAN
' DirectoryEntry : IMAGE_DIRECTORY_ENTRY
' Size : DWORD* out
Declare PtrSafe Function ImageDirectoryEntryToData Lib "dbghelp" ( _
ByVal Base As LongPtr, _
ByVal MappedAsImage As Byte, _
ByVal DirectoryEntry As Integer, _
ByRef Size As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ImageDirectoryEntryToData = ctypes.windll.dbghelp.ImageDirectoryEntryToData
ImageDirectoryEntryToData.restype = ctypes.c_void_p
ImageDirectoryEntryToData.argtypes = [
ctypes.POINTER(None), # Base : void*
ctypes.c_byte, # MappedAsImage : BOOLEAN
ctypes.c_ushort, # DirectoryEntry : IMAGE_DIRECTORY_ENTRY
ctypes.POINTER(wintypes.DWORD), # Size : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
ImageDirectoryEntryToData = Fiddle::Function.new(
lib['ImageDirectoryEntryToData'],
[
Fiddle::TYPE_VOIDP, # Base : void*
Fiddle::TYPE_CHAR, # MappedAsImage : BOOLEAN
-Fiddle::TYPE_SHORT, # DirectoryEntry : IMAGE_DIRECTORY_ENTRY
Fiddle::TYPE_VOIDP, # Size : DWORD* out
],
Fiddle::TYPE_VOIDP)#[link(name = "dbghelp")]
extern "system" {
fn ImageDirectoryEntryToData(
Base: *mut (), // void*
MappedAsImage: u8, // BOOLEAN
DirectoryEntry: u16, // IMAGE_DIRECTORY_ENTRY
Size: *mut u32 // DWORD* out
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dbghelp.dll", SetLastError = true)]
public static extern IntPtr ImageDirectoryEntryToData(IntPtr Base, [MarshalAs(UnmanagedType.U1)] bool MappedAsImage, ushort DirectoryEntry, out uint Size);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_ImageDirectoryEntryToData' -Namespace Win32 -PassThru
# $api::ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size)#uselib "dbghelp.dll"
#func global ImageDirectoryEntryToData "ImageDirectoryEntryToData" sptr, sptr, sptr, sptr
; ImageDirectoryEntryToData Base, MappedAsImage, DirectoryEntry, varptr(Size) ; 戻り値は stat
; Base : void* -> "sptr"
; MappedAsImage : BOOLEAN -> "sptr"
; DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "sptr"
; Size : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dbghelp.dll" #cfunc global ImageDirectoryEntryToData "ImageDirectoryEntryToData" sptr, int, int, var ; res = ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size) ; Base : void* -> "sptr" ; MappedAsImage : BOOLEAN -> "int" ; DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "int" ; Size : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dbghelp.dll" #cfunc global ImageDirectoryEntryToData "ImageDirectoryEntryToData" sptr, int, int, sptr ; res = ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, varptr(Size)) ; Base : void* -> "sptr" ; MappedAsImage : BOOLEAN -> "int" ; DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "int" ; Size : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void* ImageDirectoryEntryToData(void* Base, BOOLEAN MappedAsImage, IMAGE_DIRECTORY_ENTRY DirectoryEntry, DWORD* Size) #uselib "dbghelp.dll" #cfunc global ImageDirectoryEntryToData "ImageDirectoryEntryToData" intptr, int, int, var ; res = ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size) ; Base : void* -> "intptr" ; MappedAsImage : BOOLEAN -> "int" ; DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "int" ; Size : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void* ImageDirectoryEntryToData(void* Base, BOOLEAN MappedAsImage, IMAGE_DIRECTORY_ENTRY DirectoryEntry, DWORD* Size) #uselib "dbghelp.dll" #cfunc global ImageDirectoryEntryToData "ImageDirectoryEntryToData" intptr, int, int, intptr ; res = ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, varptr(Size)) ; Base : void* -> "intptr" ; MappedAsImage : BOOLEAN -> "int" ; DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "int" ; Size : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procImageDirectoryEntryToData = dbghelp.NewProc("ImageDirectoryEntryToData")
)
// Base (void*), MappedAsImage (BOOLEAN), DirectoryEntry (IMAGE_DIRECTORY_ENTRY), Size (DWORD* out)
r1, _, err := procImageDirectoryEntryToData.Call(
uintptr(Base),
uintptr(MappedAsImage),
uintptr(DirectoryEntry),
uintptr(Size),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function ImageDirectoryEntryToData(
Base: Pointer; // void*
MappedAsImage: ByteBool; // BOOLEAN
DirectoryEntry: Word; // IMAGE_DIRECTORY_ENTRY
Size: Pointer // DWORD* out
): Pointer; stdcall;
external 'dbghelp.dll' name 'ImageDirectoryEntryToData';result := DllCall("dbghelp\ImageDirectoryEntryToData"
, "Ptr", Base ; void*
, "Char", MappedAsImage ; BOOLEAN
, "UShort", DirectoryEntry ; IMAGE_DIRECTORY_ENTRY
, "Ptr", Size ; DWORD* out
, "Ptr") ; return: void*●ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size) = DLL("dbghelp.dll", "void* ImageDirectoryEntryToData(void*, byte, int, void*)")
# 呼び出し: ImageDirectoryEntryToData(Base, MappedAsImage, DirectoryEntry, Size)
# Base : void* -> "void*"
# MappedAsImage : BOOLEAN -> "byte"
# DirectoryEntry : IMAGE_DIRECTORY_ENTRY -> "int"
# Size : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。