ホーム › NetworkManagement.IpHelper › MIB_UDPTABLE
MIB_UDPTABLE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwNumEntries | DWORD | 4 | +0 | +0 | table配列に格納されたUDPエンドポイントエントリの数を示す。 |
| table | MIB_UDPROW | 8 | +4 | +4 | UDPリスナー行(MIB_UDPROW)の可変長配列である。 |
各言語での定義
#include <windows.h>
// MIB_UDPROW (x64 8 / x86 8 バイト)
typedef struct MIB_UDPROW {
DWORD dwLocalAddr;
DWORD dwLocalPort;
} MIB_UDPROW;
// MIB_UDPTABLE (x64 12 / x86 12 バイト)
typedef struct MIB_UDPTABLE {
DWORD dwNumEntries;
MIB_UDPROW table[1];
} MIB_UDPTABLE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_UDPROW
{
public uint dwLocalAddr;
public uint dwLocalPort;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_UDPTABLE
{
public uint dwNumEntries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public MIB_UDPROW[] table;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_UDPROW
Public dwLocalAddr As UInteger
Public dwLocalPort As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_UDPTABLE
Public dwNumEntries As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public table() As MIB_UDPROW
End Structureimport ctypes
from ctypes import wintypes
class MIB_UDPROW(ctypes.Structure):
_fields_ = [
("dwLocalAddr", wintypes.DWORD),
("dwLocalPort", wintypes.DWORD),
]
class MIB_UDPTABLE(ctypes.Structure):
_fields_ = [
("dwNumEntries", wintypes.DWORD),
("table", MIB_UDPROW * 1),
]#[repr(C)]
pub struct MIB_UDPROW {
pub dwLocalAddr: u32,
pub dwLocalPort: u32,
}
#[repr(C)]
pub struct MIB_UDPTABLE {
pub dwNumEntries: u32,
pub table: [MIB_UDPROW; 1],
}import "golang.org/x/sys/windows"
type MIB_UDPROW struct {
dwLocalAddr uint32
dwLocalPort uint32
}
type MIB_UDPTABLE struct {
dwNumEntries uint32
table [1]MIB_UDPROW
}type
MIB_UDPROW = record
dwLocalAddr: DWORD;
dwLocalPort: DWORD;
end;
MIB_UDPTABLE = record
dwNumEntries: DWORD;
table: array[0..0] of MIB_UDPROW;
end;const MIB_UDPROW = extern struct {
dwLocalAddr: u32,
dwLocalPort: u32,
};
const MIB_UDPTABLE = extern struct {
dwNumEntries: u32,
table: [1]MIB_UDPROW,
};type
MIB_UDPROW {.bycopy.} = object
dwLocalAddr: uint32
dwLocalPort: uint32
MIB_UDPTABLE {.bycopy.} = object
dwNumEntries: uint32
table: array[1, MIB_UDPROW]struct MIB_UDPROW
{
uint dwLocalAddr;
uint dwLocalPort;
}
struct MIB_UDPTABLE
{
uint dwNumEntries;
MIB_UDPROW[1] table;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_UDPTABLE サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; dwNumEntries : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; table : MIB_UDPROW (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global MIB_UDPROW
#field int dwLocalAddr
#field int dwLocalPort
#endstruct
#defstruct global MIB_UDPTABLE
#field int dwNumEntries
#field MIB_UDPROW table 1
#endstruct
stdim st, MIB_UDPTABLE ; NSTRUCT 変数を確保
st->dwNumEntries = 100
mes "dwNumEntries=" + st->dwNumEntries