サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
コピー #include <windows.h>
// IPSEC_TRAFFIC1 (x64 72 / x86 72 バイト)
typedef struct IPSEC_TRAFFIC1 {
FWP_IP_VERSION ipVersion;
_Anonymous1_e__Union Anonymous1;
_Anonymous2_e__Union Anonymous2;
IPSEC_TRAFFIC_TYPE trafficType;
_Anonymous3_e__Union Anonymous3;
WORD remotePort;
WORD localPort;
BYTE ipProtocol;
ULONGLONG localIfLuid;
DWORD realIfProfileId;
} IPSEC_TRAFFIC1;コピー using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPSEC_TRAFFIC1
{
public int ipVersion;
public _Anonymous1_e__Union Anonymous1;
public _Anonymous2_e__Union Anonymous2;
public int trafficType;
public _Anonymous3_e__Union Anonymous3;
public ushort remotePort;
public ushort localPort;
public byte ipProtocol;
public ulong localIfLuid;
public uint realIfProfileId;
}コピー Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPSEC_TRAFFIC1
Public ipVersion As Integer
Public Anonymous1 As _Anonymous1_e__Union
Public Anonymous2 As _Anonymous2_e__Union
Public trafficType As Integer
Public Anonymous3 As _Anonymous3_e__Union
Public remotePort As UShort
Public localPort As UShort
Public ipProtocol As Byte
Public localIfLuid As ULong
Public realIfProfileId As UInteger
End Structureコピー import ctypes
from ctypes import wintypes
class IPSEC_TRAFFIC1(ctypes.Structure):
_fields_ = [
("ipVersion", ctypes.c_int),
("Anonymous1", _Anonymous1_e__Union),
("Anonymous2", _Anonymous2_e__Union),
("trafficType", ctypes.c_int),
("Anonymous3", _Anonymous3_e__Union),
("remotePort", ctypes.c_ushort),
("localPort", ctypes.c_ushort),
("ipProtocol", ctypes.c_ubyte),
("localIfLuid", ctypes.c_ulonglong),
("realIfProfileId", wintypes.DWORD),
]コピー #[repr(C)]
pub struct IPSEC_TRAFFIC1 {
pub ipVersion: i32,
pub Anonymous1: _Anonymous1_e__Union,
pub Anonymous2: _Anonymous2_e__Union,
pub trafficType: i32,
pub Anonymous3: _Anonymous3_e__Union,
pub remotePort: u16,
pub localPort: u16,
pub ipProtocol: u8,
pub localIfLuid: u64,
pub realIfProfileId: u32,
}コピー import "golang.org/x/sys/windows"
type IPSEC_TRAFFIC1 struct {
ipVersion int32
Anonymous1 _Anonymous1_e__Union
Anonymous2 _Anonymous2_e__Union
trafficType int32
Anonymous3 _Anonymous3_e__Union
remotePort uint16
localPort uint16
ipProtocol byte
localIfLuid uint64
realIfProfileId uint32
}コピー type
IPSEC_TRAFFIC1 = record
ipVersion: Integer;
Anonymous1: _Anonymous1_e__Union;
Anonymous2: _Anonymous2_e__Union;
trafficType: Integer;
Anonymous3: _Anonymous3_e__Union;
remotePort: Word;
localPort: Word;
ipProtocol: Byte;
localIfLuid: UInt64;
realIfProfileId: DWORD;
end;コピー const IPSEC_TRAFFIC1 = extern struct {
ipVersion: i32,
Anonymous1: _Anonymous1_e__Union,
Anonymous2: _Anonymous2_e__Union,
trafficType: i32,
Anonymous3: _Anonymous3_e__Union,
remotePort: u16,
localPort: u16,
ipProtocol: u8,
localIfLuid: u64,
realIfProfileId: u32,
};コピー type
IPSEC_TRAFFIC1 {.bycopy.} = object
ipVersion: int32
Anonymous1: _Anonymous1_e__Union
Anonymous2: _Anonymous2_e__Union
trafficType: int32
Anonymous3: _Anonymous3_e__Union
remotePort: uint16
localPort: uint16
ipProtocol: uint8
localIfLuid: uint64
realIfProfileId: uint32コピー struct IPSEC_TRAFFIC1
{
int ipVersion;
_Anonymous1_e__Union Anonymous1;
_Anonymous2_e__Union Anonymous2;
int trafficType;
_Anonymous3_e__Union Anonymous3;
ushort remotePort;
ushort localPort;
ubyte ipProtocol;
ulong localIfLuid;
uint realIfProfileId;
}HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT (#defstruct/stdim/->)で32/64bit共通。
コピー ; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IPSEC_TRAFFIC1 サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; ipVersion : FWP_IP_VERSION (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Anonymous1 : _Anonymous1_e__Union (+4, 16byte) varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; Anonymous2 : _Anonymous2_e__Union (+20, 16byte) varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; trafficType : IPSEC_TRAFFIC_TYPE (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; Anonymous3 : _Anonymous3_e__Union (+40, 8byte) varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; remotePort : WORD (+48, 2byte) wpoke st,48,値 / 値 = wpeek(st,48)
; localPort : WORD (+50, 2byte) wpoke st,50,値 / 値 = wpeek(st,50)
; ipProtocol : BYTE (+52, 1byte) poke st,52,値 / 値 = peek(st,52)
; localIfLuid : ULONGLONG (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; realIfProfileId : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。コピー ; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IPSEC_TRAFFIC1
#field int ipVersion
#field byte Anonymous1 16
#field byte Anonymous2 16
#field int trafficType
#field byte Anonymous3 8
#field short remotePort
#field short localPort
#field byte ipProtocol
#field int64 localIfLuid
#field int realIfProfileId
#endstruct
stdim st, IPSEC_TRAFFIC1 ; NSTRUCT 変数を確保
st->ipVersion = 100
mes "ipVersion=" + st->ipVersion
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。