Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › CREATE_PROCESS_DEBUG_INFO

CREATE_PROCESS_DEBUG_INFO

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

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

フィールド

フィールドサイズx64x86説明
hFileHANDLE8/4+0+0プロセスのイメージファイルのハンドル。使用後にクローズが必要。
hProcessHANDLE8/4+8+4作成されたプロセスのハンドル。
hThreadHANDLE8/4+16+8プロセスの初期スレッドのハンドル。
lpBaseOfImagevoid*8/4+24+12イメージがロードされた基底アドレス。
dwDebugInfoFileOffsetDWORD4+32+16デバッグ情報のファイルオフセット。
nDebugInfoSizeDWORD4+36+20デバッグ情報のバイトサイズ。
lpThreadLocalBasevoid*8/4+40+24初期スレッドのTEB基底アドレス。
lpStartAddressLPTHREAD_START_ROUTINE8/4+48+28初期スレッドの開始アドレス。
lpImageNamevoid*8/4+56+32イメージ名文字列へのポインタ(対象プロセスのアドレス空間)。NULL可。
fUnicodeWORD2+64+36lpImageNameがUnicodeなら非0、ANSIなら0。

各言語での定義

#include <windows.h>

// CREATE_PROCESS_DEBUG_INFO  (x64 72 / x86 40 バイト)
typedef struct CREATE_PROCESS_DEBUG_INFO {
    HANDLE hFile;
    HANDLE hProcess;
    HANDLE hThread;
    void* lpBaseOfImage;
    DWORD dwDebugInfoFileOffset;
    DWORD nDebugInfoSize;
    void* lpThreadLocalBase;
    LPTHREAD_START_ROUTINE lpStartAddress;
    void* lpImageName;
    WORD fUnicode;
} CREATE_PROCESS_DEBUG_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CREATE_PROCESS_DEBUG_INFO
{
    public IntPtr hFile;
    public IntPtr hProcess;
    public IntPtr hThread;
    public IntPtr lpBaseOfImage;
    public uint dwDebugInfoFileOffset;
    public uint nDebugInfoSize;
    public IntPtr lpThreadLocalBase;
    public IntPtr lpStartAddress;
    public IntPtr lpImageName;
    public ushort fUnicode;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CREATE_PROCESS_DEBUG_INFO
    Public hFile As IntPtr
    Public hProcess As IntPtr
    Public hThread As IntPtr
    Public lpBaseOfImage As IntPtr
    Public dwDebugInfoFileOffset As UInteger
    Public nDebugInfoSize As UInteger
    Public lpThreadLocalBase As IntPtr
    Public lpStartAddress As IntPtr
    Public lpImageName As IntPtr
    Public fUnicode As UShort
End Structure
import ctypes
from ctypes import wintypes

class CREATE_PROCESS_DEBUG_INFO(ctypes.Structure):
    _fields_ = [
        ("hFile", ctypes.c_void_p),
        ("hProcess", ctypes.c_void_p),
        ("hThread", ctypes.c_void_p),
        ("lpBaseOfImage", ctypes.c_void_p),
        ("dwDebugInfoFileOffset", wintypes.DWORD),
        ("nDebugInfoSize", wintypes.DWORD),
        ("lpThreadLocalBase", ctypes.c_void_p),
        ("lpStartAddress", ctypes.c_void_p),
        ("lpImageName", ctypes.c_void_p),
        ("fUnicode", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct CREATE_PROCESS_DEBUG_INFO {
    pub hFile: *mut core::ffi::c_void,
    pub hProcess: *mut core::ffi::c_void,
    pub hThread: *mut core::ffi::c_void,
    pub lpBaseOfImage: *mut core::ffi::c_void,
    pub dwDebugInfoFileOffset: u32,
    pub nDebugInfoSize: u32,
    pub lpThreadLocalBase: *mut core::ffi::c_void,
    pub lpStartAddress: *mut core::ffi::c_void,
    pub lpImageName: *mut core::ffi::c_void,
    pub fUnicode: u16,
}
import "golang.org/x/sys/windows"

type CREATE_PROCESS_DEBUG_INFO struct {
	hFile uintptr
	hProcess uintptr
	hThread uintptr
	lpBaseOfImage uintptr
	dwDebugInfoFileOffset uint32
	nDebugInfoSize uint32
	lpThreadLocalBase uintptr
	lpStartAddress uintptr
	lpImageName uintptr
	fUnicode uint16
}
type
  CREATE_PROCESS_DEBUG_INFO = record
    hFile: Pointer;
    hProcess: Pointer;
    hThread: Pointer;
    lpBaseOfImage: Pointer;
    dwDebugInfoFileOffset: DWORD;
    nDebugInfoSize: DWORD;
    lpThreadLocalBase: Pointer;
    lpStartAddress: Pointer;
    lpImageName: Pointer;
    fUnicode: Word;
  end;
const CREATE_PROCESS_DEBUG_INFO = extern struct {
    hFile: ?*anyopaque,
    hProcess: ?*anyopaque,
    hThread: ?*anyopaque,
    lpBaseOfImage: ?*anyopaque,
    dwDebugInfoFileOffset: u32,
    nDebugInfoSize: u32,
    lpThreadLocalBase: ?*anyopaque,
    lpStartAddress: ?*anyopaque,
    lpImageName: ?*anyopaque,
    fUnicode: u16,
};
type
  CREATE_PROCESS_DEBUG_INFO {.bycopy.} = object
    hFile: pointer
    hProcess: pointer
    hThread: pointer
    lpBaseOfImage: pointer
    dwDebugInfoFileOffset: uint32
    nDebugInfoSize: uint32
    lpThreadLocalBase: pointer
    lpStartAddress: pointer
    lpImageName: pointer
    fUnicode: uint16
struct CREATE_PROCESS_DEBUG_INFO
{
    void* hFile;
    void* hProcess;
    void* hThread;
    void* lpBaseOfImage;
    uint dwDebugInfoFileOffset;
    uint nDebugInfoSize;
    void* lpThreadLocalBase;
    void* lpStartAddress;
    void* lpImageName;
    ushort fUnicode;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CREATE_PROCESS_DEBUG_INFO サイズ: 40 バイト(x86)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; hFile : HANDLE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; hProcess : HANDLE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; hThread : HANDLE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; lpBaseOfImage : void* (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwDebugInfoFileOffset : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; nDebugInfoSize : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; lpThreadLocalBase : void* (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; lpStartAddress : LPTHREAD_START_ROUTINE (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; lpImageName : void* (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; fUnicode : WORD (+36, 2byte)  wpoke st,36,値  /  値 = wpeek(st,36)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CREATE_PROCESS_DEBUG_INFO サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; hFile : HANDLE (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; hProcess : HANDLE (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; hThread : HANDLE (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpBaseOfImage : void* (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; dwDebugInfoFileOffset : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; nDebugInfoSize : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; lpThreadLocalBase : void* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; lpStartAddress : LPTHREAD_START_ROUTINE (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; lpImageName : void* (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; fUnicode : WORD (+64, 2byte)  wpoke st,64,値  /  値 = wpeek(st,64)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CREATE_PROCESS_DEBUG_INFO
    #field intptr hFile
    #field intptr hProcess
    #field intptr hThread
    #field intptr lpBaseOfImage
    #field int dwDebugInfoFileOffset
    #field int nDebugInfoSize
    #field intptr lpThreadLocalBase
    #field intptr lpStartAddress
    #field intptr lpImageName
    #field short fUnicode
#endstruct

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