Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SEND_GENERIC_TLS_EXTENSION

SEND_GENERIC_TLS_EXTENSION

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

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

フィールド

フィールドサイズx64x86説明
ExtensionTypeWORD2+0+0送信するTLS拡張のタイプ番号を示す。
HandshakeTypeWORD2+2+2拡張を含めるハンドシェイクメッセージの種別を示す。
FlagsDWORD4+4+4拡張送信に関するフラグ。現状予約で0を設定する。
BufferSizeWORD2+8+8Bufferに格納された拡張データのバイト数を示す。
BufferBYTE1+10+10送信するTLS拡張データの先頭バイトを示す可変長バッファ。

各言語での定義

#include <windows.h>

// SEND_GENERIC_TLS_EXTENSION  (x64 12 / x86 12 バイト)
typedef struct SEND_GENERIC_TLS_EXTENSION {
    WORD ExtensionType;
    WORD HandshakeType;
    DWORD Flags;
    WORD BufferSize;
    BYTE Buffer[1];
} SEND_GENERIC_TLS_EXTENSION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SEND_GENERIC_TLS_EXTENSION
{
    public ushort ExtensionType;
    public ushort HandshakeType;
    public uint Flags;
    public ushort BufferSize;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Buffer;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SEND_GENERIC_TLS_EXTENSION
    Public ExtensionType As UShort
    Public HandshakeType As UShort
    Public Flags As UInteger
    Public BufferSize As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Buffer() As Byte
End Structure
import ctypes
from ctypes import wintypes

class SEND_GENERIC_TLS_EXTENSION(ctypes.Structure):
    _fields_ = [
        ("ExtensionType", ctypes.c_ushort),
        ("HandshakeType", ctypes.c_ushort),
        ("Flags", wintypes.DWORD),
        ("BufferSize", ctypes.c_ushort),
        ("Buffer", ctypes.c_ubyte * 1),
    ]
#[repr(C)]
pub struct SEND_GENERIC_TLS_EXTENSION {
    pub ExtensionType: u16,
    pub HandshakeType: u16,
    pub Flags: u32,
    pub BufferSize: u16,
    pub Buffer: [u8; 1],
}
import "golang.org/x/sys/windows"

type SEND_GENERIC_TLS_EXTENSION struct {
	ExtensionType uint16
	HandshakeType uint16
	Flags uint32
	BufferSize uint16
	Buffer [1]byte
}
type
  SEND_GENERIC_TLS_EXTENSION = record
    ExtensionType: Word;
    HandshakeType: Word;
    Flags: DWORD;
    BufferSize: Word;
    Buffer: array[0..0] of Byte;
  end;
const SEND_GENERIC_TLS_EXTENSION = extern struct {
    ExtensionType: u16,
    HandshakeType: u16,
    Flags: u32,
    BufferSize: u16,
    Buffer: [1]u8,
};
type
  SEND_GENERIC_TLS_EXTENSION {.bycopy.} = object
    ExtensionType: uint16
    HandshakeType: uint16
    Flags: uint32
    BufferSize: uint16
    Buffer: array[1, uint8]
struct SEND_GENERIC_TLS_EXTENSION
{
    ushort ExtensionType;
    ushort HandshakeType;
    uint Flags;
    ushort BufferSize;
    ubyte[1] Buffer;
}

HSP用 定義

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

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

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