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

DELAYLOAD_INFO

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

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

フィールド

フィールドサイズx64x86説明
SizeDWORD4+0+0本構造体のバイトサイズで、バージョン互換性の判定に用いる。
DelayloadDescriptorIMAGE_DELAYLOAD_DESCRIPTOR*8/4+8+4遅延ロード記述子(IMAGE_DELAYLOAD_DESCRIPTOR)へのポインター。
ThunkAddressIMAGE_THUNK_DATA32*8/4+16+8解決対象となるインポートサンク(IMAGE_THUNK_DATA32)へのポインター。
TargetDllNameLPSTR8/4+24+12遅延ロード対象DLLの名前を示すANSI文字列。
TargetApiDescriptorDELAYLOAD_PROC_DESCRIPTOR16/8+32+16解決対象APIを記述するDELAYLOAD_PROC_DESCRIPTOR。
TargetModuleBasevoid*8/4+48+24ロード済み対象モジュールのベースアドレス。
Unusedvoid*8/4+56+28予約フィールドで未使用。NULLとなる。
LastErrorDWORD4+64+32遅延ロード失敗時の最終エラーコード(Win32エラー)を保持する。

各言語での定義

#include <windows.h>

// DELAYLOAD_PROC_DESCRIPTOR  (x64 16 / x86 8 バイト)
typedef struct DELAYLOAD_PROC_DESCRIPTOR {
    DWORD ImportDescribedByName;
    _Description_e__Union Description;
} DELAYLOAD_PROC_DESCRIPTOR;

// DELAYLOAD_INFO  (x64 72 / x86 36 バイト)
typedef struct DELAYLOAD_INFO {
    DWORD Size;
    IMAGE_DELAYLOAD_DESCRIPTOR* DelayloadDescriptor;
    IMAGE_THUNK_DATA32* ThunkAddress;
    LPSTR TargetDllName;
    DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor;
    void* TargetModuleBase;
    void* Unused;
    DWORD LastError;
} DELAYLOAD_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DELAYLOAD_PROC_DESCRIPTOR
{
    public uint ImportDescribedByName;
    public _Description_e__Union Description;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DELAYLOAD_INFO
{
    public uint Size;
    public IntPtr DelayloadDescriptor;
    public IntPtr ThunkAddress;
    public IntPtr TargetDllName;
    public DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor;
    public IntPtr TargetModuleBase;
    public IntPtr Unused;
    public uint LastError;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DELAYLOAD_PROC_DESCRIPTOR
    Public ImportDescribedByName As UInteger
    Public Description As _Description_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DELAYLOAD_INFO
    Public Size As UInteger
    Public DelayloadDescriptor As IntPtr
    Public ThunkAddress As IntPtr
    Public TargetDllName As IntPtr
    Public TargetApiDescriptor As DELAYLOAD_PROC_DESCRIPTOR
    Public TargetModuleBase As IntPtr
    Public Unused As IntPtr
    Public LastError As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DELAYLOAD_PROC_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("ImportDescribedByName", wintypes.DWORD),
        ("Description", _Description_e__Union),
    ]

class DELAYLOAD_INFO(ctypes.Structure):
    _fields_ = [
        ("Size", wintypes.DWORD),
        ("DelayloadDescriptor", ctypes.c_void_p),
        ("ThunkAddress", ctypes.c_void_p),
        ("TargetDllName", ctypes.c_void_p),
        ("TargetApiDescriptor", DELAYLOAD_PROC_DESCRIPTOR),
        ("TargetModuleBase", ctypes.c_void_p),
        ("Unused", ctypes.c_void_p),
        ("LastError", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DELAYLOAD_PROC_DESCRIPTOR {
    pub ImportDescribedByName: u32,
    pub Description: _Description_e__Union,
}

#[repr(C)]
pub struct DELAYLOAD_INFO {
    pub Size: u32,
    pub DelayloadDescriptor: *mut core::ffi::c_void,
    pub ThunkAddress: *mut core::ffi::c_void,
    pub TargetDllName: *mut core::ffi::c_void,
    pub TargetApiDescriptor: DELAYLOAD_PROC_DESCRIPTOR,
    pub TargetModuleBase: *mut core::ffi::c_void,
    pub Unused: *mut core::ffi::c_void,
    pub LastError: u32,
}
import "golang.org/x/sys/windows"

type DELAYLOAD_PROC_DESCRIPTOR struct {
	ImportDescribedByName uint32
	Description _Description_e__Union
}

type DELAYLOAD_INFO struct {
	Size uint32
	DelayloadDescriptor uintptr
	ThunkAddress uintptr
	TargetDllName uintptr
	TargetApiDescriptor DELAYLOAD_PROC_DESCRIPTOR
	TargetModuleBase uintptr
	Unused uintptr
	LastError uint32
}
type
  DELAYLOAD_PROC_DESCRIPTOR = record
    ImportDescribedByName: DWORD;
    Description: _Description_e__Union;
  end;

  DELAYLOAD_INFO = record
    Size: DWORD;
    DelayloadDescriptor: Pointer;
    ThunkAddress: Pointer;
    TargetDllName: Pointer;
    TargetApiDescriptor: DELAYLOAD_PROC_DESCRIPTOR;
    TargetModuleBase: Pointer;
    Unused: Pointer;
    LastError: DWORD;
  end;
const DELAYLOAD_PROC_DESCRIPTOR = extern struct {
    ImportDescribedByName: u32,
    Description: _Description_e__Union,
};

const DELAYLOAD_INFO = extern struct {
    Size: u32,
    DelayloadDescriptor: ?*anyopaque,
    ThunkAddress: ?*anyopaque,
    TargetDllName: ?*anyopaque,
    TargetApiDescriptor: DELAYLOAD_PROC_DESCRIPTOR,
    TargetModuleBase: ?*anyopaque,
    Unused: ?*anyopaque,
    LastError: u32,
};
type
  DELAYLOAD_PROC_DESCRIPTOR {.bycopy.} = object
    ImportDescribedByName: uint32
    Description: _Description_e__Union

  DELAYLOAD_INFO {.bycopy.} = object
    Size: uint32
    DelayloadDescriptor: pointer
    ThunkAddress: pointer
    TargetDllName: pointer
    TargetApiDescriptor: DELAYLOAD_PROC_DESCRIPTOR
    TargetModuleBase: pointer
    Unused: pointer
    LastError: uint32
struct DELAYLOAD_PROC_DESCRIPTOR
{
    uint ImportDescribedByName;
    _Description_e__Union Description;
}

struct DELAYLOAD_INFO
{
    uint Size;
    void* DelayloadDescriptor;
    void* ThunkAddress;
    void* TargetDllName;
    DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor;
    void* TargetModuleBase;
    void* Unused;
    uint LastError;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DELAYLOAD_INFO サイズ: 36 バイト(x86)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; Size : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; DelayloadDescriptor : IMAGE_DELAYLOAD_DESCRIPTOR* (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ThunkAddress : IMAGE_THUNK_DATA32* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; TargetDllName : LPSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; TargetApiDescriptor : DELAYLOAD_PROC_DESCRIPTOR (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; TargetModuleBase : void* (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; Unused : void* (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; LastError : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DELAYLOAD_INFO サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; Size : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; DelayloadDescriptor : IMAGE_DELAYLOAD_DESCRIPTOR* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ThunkAddress : IMAGE_THUNK_DATA32* (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; TargetDllName : LPSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; TargetApiDescriptor : DELAYLOAD_PROC_DESCRIPTOR (+32, 16byte)  varptr(st)+32 を基点に操作(16byte:入れ子/配列)
; TargetModuleBase : void* (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; Unused : void* (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; LastError : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DELAYLOAD_PROC_DESCRIPTOR
    #field int ImportDescribedByName
    #field byte Description 8
#endstruct

#defstruct global DELAYLOAD_INFO
    #field int Size
    #field intptr DelayloadDescriptor
    #field intptr ThunkAddress
    #field intptr TargetDllName
    #field DELAYLOAD_PROC_DESCRIPTOR TargetApiDescriptor
    #field intptr TargetModuleBase
    #field intptr Unused
    #field int LastError
#endstruct

stdim st, DELAYLOAD_INFO        ; NSTRUCT 変数を確保
st->Size = 100
mes "Size=" + st->Size