Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsFilteringPlatform › FWPM_VSWITCH_EVENT0

FWPM_VSWITCH_EVENT0

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

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

フィールド

フィールドサイズx64x86説明
eventTypeFWPM_VSWITCH_EVENT_TYPE4+0+0仮想スイッチイベントの種類を示す列挙値。
vSwitchIdLPWSTR8/4+8+4対象のHyper-V仮想スイッチのID文字列。
Anonymous_Anonymous_e__Union8/4+16+8イベント種別に応じた詳細情報を保持する共用体。

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

フィールドサイズx64x86
positionInfo_positionInfo_e__Struct8/4+0+0
reorderInfo_reorderInfo_e__Struct8/4+0+0

各言語での定義

#include <windows.h>

// FWPM_VSWITCH_EVENT0  (x64 24 / x86 12 バイト)
typedef struct FWPM_VSWITCH_EVENT0 {
    FWPM_VSWITCH_EVENT_TYPE eventType;
    LPWSTR vSwitchId;
    _Anonymous_e__Union Anonymous;
} FWPM_VSWITCH_EVENT0;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FWPM_VSWITCH_EVENT0
{
    public int eventType;
    public IntPtr vSwitchId;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FWPM_VSWITCH_EVENT0
    Public eventType As Integer
    Public vSwitchId As IntPtr
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class FWPM_VSWITCH_EVENT0(ctypes.Structure):
    _fields_ = [
        ("eventType", ctypes.c_int),
        ("vSwitchId", ctypes.c_void_p),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct FWPM_VSWITCH_EVENT0 {
    pub eventType: i32,
    pub vSwitchId: *mut core::ffi::c_void,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type FWPM_VSWITCH_EVENT0 struct {
	eventType int32
	vSwitchId uintptr
	Anonymous _Anonymous_e__Union
}
type
  FWPM_VSWITCH_EVENT0 = record
    eventType: Integer;
    vSwitchId: Pointer;
    Anonymous: _Anonymous_e__Union;
  end;
const FWPM_VSWITCH_EVENT0 = extern struct {
    eventType: i32,
    vSwitchId: ?*anyopaque,
    Anonymous: _Anonymous_e__Union,
};
type
  FWPM_VSWITCH_EVENT0 {.bycopy.} = object
    eventType: int32
    vSwitchId: pointer
    Anonymous: _Anonymous_e__Union
struct FWPM_VSWITCH_EVENT0
{
    int eventType;
    void* vSwitchId;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

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

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

stdim st, FWPM_VSWITCH_EVENT0        ; NSTRUCT 変数を確保
st->eventType = 100
mes "eventType=" + st->eventType
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。