Win32 API 日本語リファレンス
ホームSystem.SystemServices › IMAGE_IMPORT_DESCRIPTOR

IMAGE_IMPORT_DESCRIPTOR

構造体
サイズx64: 20 バイト / x86: 20 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
Anonymous_Anonymous_e__Union4+0+0CharacteristicsまたはインポートルックアップテーブルへのRVAを保持する無名共用体。
TimeDateStampDWORD4+4+4バインド情報のタイムスタンプ。0なら未バインド。
ForwarderChainDWORD4+8+8フォワーダ参照の最初のインデックス。
NameDWORD4+12+12インポート元DLL名文字列へのRVA。
FirstThunkDWORD4+16+16インポートアドレステーブル(IAT)へのRVA。

共用体: _Anonymous_e__Union x64 4B / x86 4B

フィールドサイズx64x86
CharacteristicsDWORD4+0+0
OriginalFirstThunkDWORD4+0+0

各言語での定義

#include <windows.h>

// IMAGE_IMPORT_DESCRIPTOR  (x64 20 / x86 20 バイト)
typedef struct IMAGE_IMPORT_DESCRIPTOR {
    _Anonymous_e__Union Anonymous;
    DWORD TimeDateStamp;
    DWORD ForwarderChain;
    DWORD Name;
    DWORD FirstThunk;
} IMAGE_IMPORT_DESCRIPTOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IMAGE_IMPORT_DESCRIPTOR
{
    public _Anonymous_e__Union Anonymous;
    public uint TimeDateStamp;
    public uint ForwarderChain;
    public uint Name;
    public uint FirstThunk;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IMAGE_IMPORT_DESCRIPTOR
    Public Anonymous As _Anonymous_e__Union
    Public TimeDateStamp As UInteger
    Public ForwarderChain As UInteger
    Public Name As UInteger
    Public FirstThunk As UInteger
End Structure
import ctypes
from ctypes import wintypes

class IMAGE_IMPORT_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Union),
        ("TimeDateStamp", wintypes.DWORD),
        ("ForwarderChain", wintypes.DWORD),
        ("Name", wintypes.DWORD),
        ("FirstThunk", wintypes.DWORD),
    ]
#[repr(C)]
pub struct IMAGE_IMPORT_DESCRIPTOR {
    pub Anonymous: _Anonymous_e__Union,
    pub TimeDateStamp: u32,
    pub ForwarderChain: u32,
    pub Name: u32,
    pub FirstThunk: u32,
}
import "golang.org/x/sys/windows"

type IMAGE_IMPORT_DESCRIPTOR struct {
	Anonymous _Anonymous_e__Union
	TimeDateStamp uint32
	ForwarderChain uint32
	Name uint32
	FirstThunk uint32
}
type
  IMAGE_IMPORT_DESCRIPTOR = record
    Anonymous: _Anonymous_e__Union;
    TimeDateStamp: DWORD;
    ForwarderChain: DWORD;
    Name: DWORD;
    FirstThunk: DWORD;
  end;
const IMAGE_IMPORT_DESCRIPTOR = extern struct {
    Anonymous: _Anonymous_e__Union,
    TimeDateStamp: u32,
    ForwarderChain: u32,
    Name: u32,
    FirstThunk: u32,
};
type
  IMAGE_IMPORT_DESCRIPTOR {.bycopy.} = object
    Anonymous: _Anonymous_e__Union
    TimeDateStamp: uint32
    ForwarderChain: uint32
    Name: uint32
    FirstThunk: uint32
struct IMAGE_IMPORT_DESCRIPTOR
{
    _Anonymous_e__Union Anonymous;
    uint TimeDateStamp;
    uint ForwarderChain;
    uint Name;
    uint FirstThunk;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IMAGE_IMPORT_DESCRIPTOR サイズ: 20 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; Anonymous : _Anonymous_e__Union (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; TimeDateStamp : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ForwarderChain : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Name : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; FirstThunk : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IMAGE_IMPORT_DESCRIPTOR
    #field byte Anonymous 4
    #field int TimeDateStamp
    #field int ForwarderChain
    #field int Name
    #field int FirstThunk
#endstruct

stdim st, IMAGE_IMPORT_DESCRIPTOR        ; NSTRUCT 変数を確保
st->TimeDateStamp = 100
mes "TimeDateStamp=" + st->TimeDateStamp
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。