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

IMAGE_SEPARATE_DEBUG_HEADER

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

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

フィールド

フィールドサイズx64x86説明
SignatureWORD2+0+0分離デバッグファイルのシグネチャ('DI')。
FlagsWORD2+2+2ヘッダーのフラグ。
MachineWORD2+4+4対象マシン種別。
CharacteristicsWORD2+6+6イメージの特性フラグ。
TimeDateStampDWORD4+8+8対応イメージのタイムスタンプ。
CheckSumDWORD4+12+12対応イメージのチェックサム。
ImageBaseDWORD4+16+16イメージの優先ベースアドレス。
SizeOfImageDWORD4+20+20イメージのサイズをバイト単位で示す。
NumberOfSectionsDWORD4+24+24セクション数。
ExportedNamesSizeDWORD4+28+28エクスポート名領域のサイズ。
DebugDirectorySizeDWORD4+32+32デバッグディレクトリのサイズ。
SectionAlignmentDWORD4+36+36セクションのアライメント値。
ReservedDWORD8+40+40予約フィールド配列。

各言語での定義

#include <windows.h>

// IMAGE_SEPARATE_DEBUG_HEADER  (x64 48 / x86 48 バイト)
typedef struct IMAGE_SEPARATE_DEBUG_HEADER {
    WORD Signature;
    WORD Flags;
    WORD Machine;
    WORD Characteristics;
    DWORD TimeDateStamp;
    DWORD CheckSum;
    DWORD ImageBase;
    DWORD SizeOfImage;
    DWORD NumberOfSections;
    DWORD ExportedNamesSize;
    DWORD DebugDirectorySize;
    DWORD SectionAlignment;
    DWORD Reserved[2];
} IMAGE_SEPARATE_DEBUG_HEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IMAGE_SEPARATE_DEBUG_HEADER
{
    public ushort Signature;
    public ushort Flags;
    public ushort Machine;
    public ushort Characteristics;
    public uint TimeDateStamp;
    public uint CheckSum;
    public uint ImageBase;
    public uint SizeOfImage;
    public uint NumberOfSections;
    public uint ExportedNamesSize;
    public uint DebugDirectorySize;
    public uint SectionAlignment;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] Reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IMAGE_SEPARATE_DEBUG_HEADER
    Public Signature As UShort
    Public Flags As UShort
    Public Machine As UShort
    Public Characteristics As UShort
    Public TimeDateStamp As UInteger
    Public CheckSum As UInteger
    Public ImageBase As UInteger
    Public SizeOfImage As UInteger
    Public NumberOfSections As UInteger
    Public ExportedNamesSize As UInteger
    Public DebugDirectorySize As UInteger
    Public SectionAlignment As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Reserved() As UInteger
End Structure
import ctypes
from ctypes import wintypes

class IMAGE_SEPARATE_DEBUG_HEADER(ctypes.Structure):
    _fields_ = [
        ("Signature", ctypes.c_ushort),
        ("Flags", ctypes.c_ushort),
        ("Machine", ctypes.c_ushort),
        ("Characteristics", ctypes.c_ushort),
        ("TimeDateStamp", wintypes.DWORD),
        ("CheckSum", wintypes.DWORD),
        ("ImageBase", wintypes.DWORD),
        ("SizeOfImage", wintypes.DWORD),
        ("NumberOfSections", wintypes.DWORD),
        ("ExportedNamesSize", wintypes.DWORD),
        ("DebugDirectorySize", wintypes.DWORD),
        ("SectionAlignment", wintypes.DWORD),
        ("Reserved", wintypes.DWORD * 2),
    ]
#[repr(C)]
pub struct IMAGE_SEPARATE_DEBUG_HEADER {
    pub Signature: u16,
    pub Flags: u16,
    pub Machine: u16,
    pub Characteristics: u16,
    pub TimeDateStamp: u32,
    pub CheckSum: u32,
    pub ImageBase: u32,
    pub SizeOfImage: u32,
    pub NumberOfSections: u32,
    pub ExportedNamesSize: u32,
    pub DebugDirectorySize: u32,
    pub SectionAlignment: u32,
    pub Reserved: [u32; 2],
}
import "golang.org/x/sys/windows"

type IMAGE_SEPARATE_DEBUG_HEADER struct {
	Signature uint16
	Flags uint16
	Machine uint16
	Characteristics uint16
	TimeDateStamp uint32
	CheckSum uint32
	ImageBase uint32
	SizeOfImage uint32
	NumberOfSections uint32
	ExportedNamesSize uint32
	DebugDirectorySize uint32
	SectionAlignment uint32
	Reserved [2]uint32
}
type
  IMAGE_SEPARATE_DEBUG_HEADER = record
    Signature: Word;
    Flags: Word;
    Machine: Word;
    Characteristics: Word;
    TimeDateStamp: DWORD;
    CheckSum: DWORD;
    ImageBase: DWORD;
    SizeOfImage: DWORD;
    NumberOfSections: DWORD;
    ExportedNamesSize: DWORD;
    DebugDirectorySize: DWORD;
    SectionAlignment: DWORD;
    Reserved: array[0..1] of DWORD;
  end;
const IMAGE_SEPARATE_DEBUG_HEADER = extern struct {
    Signature: u16,
    Flags: u16,
    Machine: u16,
    Characteristics: u16,
    TimeDateStamp: u32,
    CheckSum: u32,
    ImageBase: u32,
    SizeOfImage: u32,
    NumberOfSections: u32,
    ExportedNamesSize: u32,
    DebugDirectorySize: u32,
    SectionAlignment: u32,
    Reserved: [2]u32,
};
type
  IMAGE_SEPARATE_DEBUG_HEADER {.bycopy.} = object
    Signature: uint16
    Flags: uint16
    Machine: uint16
    Characteristics: uint16
    TimeDateStamp: uint32
    CheckSum: uint32
    ImageBase: uint32
    SizeOfImage: uint32
    NumberOfSections: uint32
    ExportedNamesSize: uint32
    DebugDirectorySize: uint32
    SectionAlignment: uint32
    Reserved: array[2, uint32]
struct IMAGE_SEPARATE_DEBUG_HEADER
{
    ushort Signature;
    ushort Flags;
    ushort Machine;
    ushort Characteristics;
    uint TimeDateStamp;
    uint CheckSum;
    uint ImageBase;
    uint SizeOfImage;
    uint NumberOfSections;
    uint ExportedNamesSize;
    uint DebugDirectorySize;
    uint SectionAlignment;
    uint[2] Reserved;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IMAGE_SEPARATE_DEBUG_HEADER サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Signature : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; Flags : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; Machine : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; Characteristics : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; TimeDateStamp : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; CheckSum : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ImageBase : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; SizeOfImage : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; NumberOfSections : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ExportedNamesSize : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; DebugDirectorySize : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; SectionAlignment : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; Reserved : DWORD (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IMAGE_SEPARATE_DEBUG_HEADER
    #field short Signature
    #field short Flags
    #field short Machine
    #field short Characteristics
    #field int TimeDateStamp
    #field int CheckSum
    #field int ImageBase
    #field int SizeOfImage
    #field int NumberOfSections
    #field int ExportedNamesSize
    #field int DebugDirectorySize
    #field int SectionAlignment
    #field int Reserved 2
#endstruct

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