Win32 API 日本語リファレンス
ホームNetworking.WinSock › SOCKET_SECURITY_QUERY_INFO_IPSEC2

SOCKET_SECURITY_QUERY_INFO_IPSEC2

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

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

フィールド

フィールドサイズx64x86説明
SecurityProtocolSOCKET_SECURITY_PROTOCOL4+0+0適用されているSOCKET_SECURITY_PROTOCOL列挙値。
FlagsDWORD4+4+4セキュリティ状態を示すフラグのビットマスク。
PeerApplicationAccessTokenHandleULONGLONG8+8+8ピアアプリケーションのアクセストークンハンドルを示す64ビット値。
PeerMachineAccessTokenHandleULONGLONG8+16+16ピアマシンのアクセストークンハンドルを示す64ビット値。
MmSaIdULONGLONG8+24+24IPsecメインモードSAの識別子を示す。
QmSaIdULONGLONG8+32+32IPsecクイックモードSAの識別子を示す。
NegotiationWinerrDWORD4+40+40セキュリティネゴシエーション結果のWin32エラーコード。0は成功を示す。
SaLookupContextGUID16+44+44SA検索に用いるコンテキストを示すGUID。

各言語での定義

#include <windows.h>

// SOCKET_SECURITY_QUERY_INFO_IPSEC2  (x64 64 / x86 64 バイト)
typedef struct SOCKET_SECURITY_QUERY_INFO_IPSEC2 {
    SOCKET_SECURITY_PROTOCOL SecurityProtocol;
    DWORD Flags;
    ULONGLONG PeerApplicationAccessTokenHandle;
    ULONGLONG PeerMachineAccessTokenHandle;
    ULONGLONG MmSaId;
    ULONGLONG QmSaId;
    DWORD NegotiationWinerr;
    GUID SaLookupContext;
} SOCKET_SECURITY_QUERY_INFO_IPSEC2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SOCKET_SECURITY_QUERY_INFO_IPSEC2
{
    public int SecurityProtocol;
    public uint Flags;
    public ulong PeerApplicationAccessTokenHandle;
    public ulong PeerMachineAccessTokenHandle;
    public ulong MmSaId;
    public ulong QmSaId;
    public uint NegotiationWinerr;
    public Guid SaLookupContext;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SOCKET_SECURITY_QUERY_INFO_IPSEC2
    Public SecurityProtocol As Integer
    Public Flags As UInteger
    Public PeerApplicationAccessTokenHandle As ULong
    Public PeerMachineAccessTokenHandle As ULong
    Public MmSaId As ULong
    Public QmSaId As ULong
    Public NegotiationWinerr As UInteger
    Public SaLookupContext As Guid
End Structure
import ctypes
from ctypes import wintypes

class SOCKET_SECURITY_QUERY_INFO_IPSEC2(ctypes.Structure):
    _fields_ = [
        ("SecurityProtocol", ctypes.c_int),
        ("Flags", wintypes.DWORD),
        ("PeerApplicationAccessTokenHandle", ctypes.c_ulonglong),
        ("PeerMachineAccessTokenHandle", ctypes.c_ulonglong),
        ("MmSaId", ctypes.c_ulonglong),
        ("QmSaId", ctypes.c_ulonglong),
        ("NegotiationWinerr", wintypes.DWORD),
        ("SaLookupContext", GUID),
    ]
#[repr(C)]
pub struct SOCKET_SECURITY_QUERY_INFO_IPSEC2 {
    pub SecurityProtocol: i32,
    pub Flags: u32,
    pub PeerApplicationAccessTokenHandle: u64,
    pub PeerMachineAccessTokenHandle: u64,
    pub MmSaId: u64,
    pub QmSaId: u64,
    pub NegotiationWinerr: u32,
    pub SaLookupContext: GUID,
}
import "golang.org/x/sys/windows"

type SOCKET_SECURITY_QUERY_INFO_IPSEC2 struct {
	SecurityProtocol int32
	Flags uint32
	PeerApplicationAccessTokenHandle uint64
	PeerMachineAccessTokenHandle uint64
	MmSaId uint64
	QmSaId uint64
	NegotiationWinerr uint32
	SaLookupContext windows.GUID
}
type
  SOCKET_SECURITY_QUERY_INFO_IPSEC2 = record
    SecurityProtocol: Integer;
    Flags: DWORD;
    PeerApplicationAccessTokenHandle: UInt64;
    PeerMachineAccessTokenHandle: UInt64;
    MmSaId: UInt64;
    QmSaId: UInt64;
    NegotiationWinerr: DWORD;
    SaLookupContext: TGUID;
  end;
const SOCKET_SECURITY_QUERY_INFO_IPSEC2 = extern struct {
    SecurityProtocol: i32,
    Flags: u32,
    PeerApplicationAccessTokenHandle: u64,
    PeerMachineAccessTokenHandle: u64,
    MmSaId: u64,
    QmSaId: u64,
    NegotiationWinerr: u32,
    SaLookupContext: GUID,
};
type
  SOCKET_SECURITY_QUERY_INFO_IPSEC2 {.bycopy.} = object
    SecurityProtocol: int32
    Flags: uint32
    PeerApplicationAccessTokenHandle: uint64
    PeerMachineAccessTokenHandle: uint64
    MmSaId: uint64
    QmSaId: uint64
    NegotiationWinerr: uint32
    SaLookupContext: GUID
struct SOCKET_SECURITY_QUERY_INFO_IPSEC2
{
    int SecurityProtocol;
    uint Flags;
    ulong PeerApplicationAccessTokenHandle;
    ulong PeerMachineAccessTokenHandle;
    ulong MmSaId;
    ulong QmSaId;
    uint NegotiationWinerr;
    GUID SaLookupContext;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SOCKET_SECURITY_QUERY_INFO_IPSEC2 サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; SecurityProtocol : SOCKET_SECURITY_PROTOCOL (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Flags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; PeerApplicationAccessTokenHandle : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; PeerMachineAccessTokenHandle : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; MmSaId : ULONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; QmSaId : ULONGLONG (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; NegotiationWinerr : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; SaLookupContext : GUID (+44, 16byte)  varptr(st)+44 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global SOCKET_SECURITY_QUERY_INFO_IPSEC2
    #field int SecurityProtocol
    #field int Flags
    #field int64 PeerApplicationAccessTokenHandle
    #field int64 PeerMachineAccessTokenHandle
    #field int64 MmSaId
    #field int64 QmSaId
    #field int NegotiationWinerr
    #field GUID SaLookupContext
#endstruct

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