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

SUBSCRIBE_GENERIC_TLS_EXTENSION

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

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

フィールド

フィールドサイズx64x86説明
FlagsDWORD4+0+0購読動作を制御するフラグ。現状予約で0を設定する。
SubscriptionsCountDWORD4+4+4Subscriptions配列の要素数を示す。
SubscriptionsTLS_EXTENSION_SUBSCRIPTION4+8+8購読するTLS拡張(TLS_EXTENSION_SUBSCRIPTION)の可変長配列。

各言語での定義

#include <windows.h>

// TLS_EXTENSION_SUBSCRIPTION  (x64 4 / x86 4 バイト)
typedef struct TLS_EXTENSION_SUBSCRIPTION {
    WORD ExtensionType;
    WORD HandshakeType;
} TLS_EXTENSION_SUBSCRIPTION;

// SUBSCRIBE_GENERIC_TLS_EXTENSION  (x64 12 / x86 12 バイト)
typedef struct SUBSCRIBE_GENERIC_TLS_EXTENSION {
    DWORD Flags;
    DWORD SubscriptionsCount;
    TLS_EXTENSION_SUBSCRIPTION Subscriptions[1];
} SUBSCRIBE_GENERIC_TLS_EXTENSION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TLS_EXTENSION_SUBSCRIPTION
{
    public ushort ExtensionType;
    public ushort HandshakeType;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SUBSCRIBE_GENERIC_TLS_EXTENSION
{
    public uint Flags;
    public uint SubscriptionsCount;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public TLS_EXTENSION_SUBSCRIPTION[] Subscriptions;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TLS_EXTENSION_SUBSCRIPTION
    Public ExtensionType As UShort
    Public HandshakeType As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SUBSCRIBE_GENERIC_TLS_EXTENSION
    Public Flags As UInteger
    Public SubscriptionsCount As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Subscriptions() As TLS_EXTENSION_SUBSCRIPTION
End Structure
import ctypes
from ctypes import wintypes

class TLS_EXTENSION_SUBSCRIPTION(ctypes.Structure):
    _fields_ = [
        ("ExtensionType", ctypes.c_ushort),
        ("HandshakeType", ctypes.c_ushort),
    ]

class SUBSCRIBE_GENERIC_TLS_EXTENSION(ctypes.Structure):
    _fields_ = [
        ("Flags", wintypes.DWORD),
        ("SubscriptionsCount", wintypes.DWORD),
        ("Subscriptions", TLS_EXTENSION_SUBSCRIPTION * 1),
    ]
#[repr(C)]
pub struct TLS_EXTENSION_SUBSCRIPTION {
    pub ExtensionType: u16,
    pub HandshakeType: u16,
}

#[repr(C)]
pub struct SUBSCRIBE_GENERIC_TLS_EXTENSION {
    pub Flags: u32,
    pub SubscriptionsCount: u32,
    pub Subscriptions: [TLS_EXTENSION_SUBSCRIPTION; 1],
}
import "golang.org/x/sys/windows"

type TLS_EXTENSION_SUBSCRIPTION struct {
	ExtensionType uint16
	HandshakeType uint16
}

type SUBSCRIBE_GENERIC_TLS_EXTENSION struct {
	Flags uint32
	SubscriptionsCount uint32
	Subscriptions [1]TLS_EXTENSION_SUBSCRIPTION
}
type
  TLS_EXTENSION_SUBSCRIPTION = record
    ExtensionType: Word;
    HandshakeType: Word;
  end;

  SUBSCRIBE_GENERIC_TLS_EXTENSION = record
    Flags: DWORD;
    SubscriptionsCount: DWORD;
    Subscriptions: array[0..0] of TLS_EXTENSION_SUBSCRIPTION;
  end;
const TLS_EXTENSION_SUBSCRIPTION = extern struct {
    ExtensionType: u16,
    HandshakeType: u16,
};

const SUBSCRIBE_GENERIC_TLS_EXTENSION = extern struct {
    Flags: u32,
    SubscriptionsCount: u32,
    Subscriptions: [1]TLS_EXTENSION_SUBSCRIPTION,
};
type
  TLS_EXTENSION_SUBSCRIPTION {.bycopy.} = object
    ExtensionType: uint16
    HandshakeType: uint16

  SUBSCRIBE_GENERIC_TLS_EXTENSION {.bycopy.} = object
    Flags: uint32
    SubscriptionsCount: uint32
    Subscriptions: array[1, TLS_EXTENSION_SUBSCRIPTION]
struct TLS_EXTENSION_SUBSCRIPTION
{
    ushort ExtensionType;
    ushort HandshakeType;
}

struct SUBSCRIBE_GENERIC_TLS_EXTENSION
{
    uint Flags;
    uint SubscriptionsCount;
    TLS_EXTENSION_SUBSCRIPTION[1] Subscriptions;
}

HSP用 定義

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

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

#defstruct global SUBSCRIBE_GENERIC_TLS_EXTENSION
    #field int Flags
    #field int SubscriptionsCount
    #field TLS_EXTENSION_SUBSCRIPTION Subscriptions 1
#endstruct

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