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

NT_TIB

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

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

フィールド

フィールドサイズx64x86説明
ExceptionListEXCEPTION_REGISTRATION_RECORD*8/4+0+0構造化例外処理ハンドラーチェーンの先頭へのポインター。
StackBasevoid*8/4+8+4スタックの基底(上端)アドレス。
StackLimitvoid*8/4+16+8スタックの限界(下端)アドレス。
SubSystemTibvoid*8/4+24+12サブシステム固有のTIBへのポインター。
Anonymous_Anonymous_e__Union8/4+32+16FiberDataまたはVersionを保持する無名共用体。
ArbitraryUserPointervoid*8/4+40+20ユーザーが任意に使用できるポインター。
SelfNT_TIB*8/4+48+24このTIB構造体自身へのポインター。

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

フィールドサイズx64x86
FiberDatavoid*8/4+0+0
VersionDWORD4+0+0

各言語での定義

#include <windows.h>

// NT_TIB  (x64 56 / x86 28 バイト)
typedef struct NT_TIB {
    EXCEPTION_REGISTRATION_RECORD* ExceptionList;
    void* StackBase;
    void* StackLimit;
    void* SubSystemTib;
    _Anonymous_e__Union Anonymous;
    void* ArbitraryUserPointer;
    NT_TIB* Self;
} NT_TIB;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NT_TIB
{
    public IntPtr ExceptionList;
    public IntPtr StackBase;
    public IntPtr StackLimit;
    public IntPtr SubSystemTib;
    public _Anonymous_e__Union Anonymous;
    public IntPtr ArbitraryUserPointer;
    public IntPtr Self;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NT_TIB
    Public ExceptionList As IntPtr
    Public StackBase As IntPtr
    Public StackLimit As IntPtr
    Public SubSystemTib As IntPtr
    Public Anonymous As _Anonymous_e__Union
    Public ArbitraryUserPointer As IntPtr
    Public Self As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class NT_TIB(ctypes.Structure):
    _fields_ = [
        ("ExceptionList", ctypes.c_void_p),
        ("StackBase", ctypes.c_void_p),
        ("StackLimit", ctypes.c_void_p),
        ("SubSystemTib", ctypes.c_void_p),
        ("Anonymous", _Anonymous_e__Union),
        ("ArbitraryUserPointer", ctypes.c_void_p),
        ("Self", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct NT_TIB {
    pub ExceptionList: *mut core::ffi::c_void,
    pub StackBase: *mut core::ffi::c_void,
    pub StackLimit: *mut core::ffi::c_void,
    pub SubSystemTib: *mut core::ffi::c_void,
    pub Anonymous: _Anonymous_e__Union,
    pub ArbitraryUserPointer: *mut core::ffi::c_void,
    pub Self: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type NT_TIB struct {
	ExceptionList uintptr
	StackBase uintptr
	StackLimit uintptr
	SubSystemTib uintptr
	Anonymous _Anonymous_e__Union
	ArbitraryUserPointer uintptr
	Self uintptr
}
type
  NT_TIB = record
    ExceptionList: Pointer;
    StackBase: Pointer;
    StackLimit: Pointer;
    SubSystemTib: Pointer;
    Anonymous: _Anonymous_e__Union;
    ArbitraryUserPointer: Pointer;
    Self: Pointer;
  end;
const NT_TIB = extern struct {
    ExceptionList: ?*anyopaque,
    StackBase: ?*anyopaque,
    StackLimit: ?*anyopaque,
    SubSystemTib: ?*anyopaque,
    Anonymous: _Anonymous_e__Union,
    ArbitraryUserPointer: ?*anyopaque,
    Self: ?*anyopaque,
};
type
  NT_TIB {.bycopy.} = object
    ExceptionList: pointer
    StackBase: pointer
    StackLimit: pointer
    SubSystemTib: pointer
    Anonymous: _Anonymous_e__Union
    ArbitraryUserPointer: pointer
    Self: pointer
struct NT_TIB
{
    void* ExceptionList;
    void* StackBase;
    void* StackLimit;
    void* SubSystemTib;
    _Anonymous_e__Union Anonymous;
    void* ArbitraryUserPointer;
    void* Self;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NT_TIB サイズ: 28 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; ExceptionList : EXCEPTION_REGISTRATION_RECORD* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; StackBase : void* (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; StackLimit : void* (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; SubSystemTib : void* (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; ArbitraryUserPointer : void* (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Self : NT_TIB* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NT_TIB サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; ExceptionList : EXCEPTION_REGISTRATION_RECORD* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; StackBase : void* (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; StackLimit : void* (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; SubSystemTib : void* (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; Anonymous : _Anonymous_e__Union (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; ArbitraryUserPointer : void* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; Self : NT_TIB* (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NT_TIB
    #field intptr ExceptionList
    #field intptr StackBase
    #field intptr StackLimit
    #field intptr SubSystemTib
    #field byte Anonymous 8
    #field intptr ArbitraryUserPointer
    #field intptr Self
#endstruct

stdim st, NT_TIB        ; NSTRUCT 変数を確保
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。