ホーム › NetworkManagement.P2P › PEER_ENDPOINT
PEER_ENDPOINT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| address | PEER_ADDRESS | 40/32 | +0 | +0 | エンドポイントのアドレスを示すPEER_ADDRESS構造体。 |
| pwzEndpointName | LPWSTR | 8/4 | +40 | +32 | エンドポイント名を表すワイド文字列。NULL可。 |
各言語での定義
#include <windows.h>
// IN6_ADDR (x64 16 / x86 16 バイト)
typedef struct IN6_ADDR {
_u_e__Union u;
} IN6_ADDR;
// SOCKADDR_IN6 (x64 32 / x86 28 バイト)
typedef struct SOCKADDR_IN6 {
ADDRESS_FAMILY sin6_family;
WORD sin6_port;
DWORD sin6_flowinfo;
IN6_ADDR sin6_addr;
_Anonymous_e__Union Anonymous;
} SOCKADDR_IN6;
// PEER_ADDRESS (x64 40 / x86 32 バイト)
typedef struct PEER_ADDRESS {
DWORD dwSize;
SOCKADDR_IN6 sin6;
} PEER_ADDRESS;
// PEER_ENDPOINT (x64 48 / x86 36 バイト)
typedef struct PEER_ENDPOINT {
PEER_ADDRESS address;
LPWSTR pwzEndpointName;
} PEER_ENDPOINT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN6_ADDR
{
public _u_e__Union u;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SOCKADDR_IN6
{
public ushort sin6_family;
public ushort sin6_port;
public uint sin6_flowinfo;
public IN6_ADDR sin6_addr;
public _Anonymous_e__Union Anonymous;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PEER_ADDRESS
{
public uint dwSize;
public SOCKADDR_IN6 sin6;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PEER_ENDPOINT
{
public PEER_ADDRESS address;
public IntPtr pwzEndpointName;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN6_ADDR
Public u As _u_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SOCKADDR_IN6
Public sin6_family As UShort
Public sin6_port As UShort
Public sin6_flowinfo As UInteger
Public sin6_addr As IN6_ADDR
Public Anonymous As _Anonymous_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PEER_ADDRESS
Public dwSize As UInteger
Public sin6 As SOCKADDR_IN6
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PEER_ENDPOINT
Public address As PEER_ADDRESS
Public pwzEndpointName As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class IN6_ADDR(ctypes.Structure):
_fields_ = [
("u", _u_e__Union),
]
class SOCKADDR_IN6(ctypes.Structure):
_fields_ = [
("sin6_family", ctypes.c_ushort),
("sin6_port", ctypes.c_ushort),
("sin6_flowinfo", wintypes.DWORD),
("sin6_addr", IN6_ADDR),
("Anonymous", _Anonymous_e__Union),
]
class PEER_ADDRESS(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
("sin6", SOCKADDR_IN6),
]
class PEER_ENDPOINT(ctypes.Structure):
_fields_ = [
("address", PEER_ADDRESS),
("pwzEndpointName", ctypes.c_void_p),
]#[repr(C)]
pub struct IN6_ADDR {
pub u: _u_e__Union,
}
#[repr(C)]
pub struct SOCKADDR_IN6 {
pub sin6_family: u16,
pub sin6_port: u16,
pub sin6_flowinfo: u32,
pub sin6_addr: IN6_ADDR,
pub Anonymous: _Anonymous_e__Union,
}
#[repr(C)]
pub struct PEER_ADDRESS {
pub dwSize: u32,
pub sin6: SOCKADDR_IN6,
}
#[repr(C)]
pub struct PEER_ENDPOINT {
pub address: PEER_ADDRESS,
pub pwzEndpointName: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type IN6_ADDR struct {
u _u_e__Union
}
type SOCKADDR_IN6 struct {
sin6_family uint16
sin6_port uint16
sin6_flowinfo uint32
sin6_addr IN6_ADDR
Anonymous _Anonymous_e__Union
}
type PEER_ADDRESS struct {
dwSize uint32
sin6 SOCKADDR_IN6
}
type PEER_ENDPOINT struct {
address PEER_ADDRESS
pwzEndpointName uintptr
}type
IN6_ADDR = record
u: _u_e__Union;
end;
SOCKADDR_IN6 = record
sin6_family: Word;
sin6_port: Word;
sin6_flowinfo: DWORD;
sin6_addr: IN6_ADDR;
Anonymous: _Anonymous_e__Union;
end;
PEER_ADDRESS = record
dwSize: DWORD;
sin6: SOCKADDR_IN6;
end;
PEER_ENDPOINT = record
address: PEER_ADDRESS;
pwzEndpointName: Pointer;
end;const IN6_ADDR = extern struct {
u: _u_e__Union,
};
const SOCKADDR_IN6 = extern struct {
sin6_family: u16,
sin6_port: u16,
sin6_flowinfo: u32,
sin6_addr: IN6_ADDR,
Anonymous: _Anonymous_e__Union,
};
const PEER_ADDRESS = extern struct {
dwSize: u32,
sin6: SOCKADDR_IN6,
};
const PEER_ENDPOINT = extern struct {
address: PEER_ADDRESS,
pwzEndpointName: ?*anyopaque,
};type
IN6_ADDR {.bycopy.} = object
u: _u_e__Union
SOCKADDR_IN6 {.bycopy.} = object
sin6_family: uint16
sin6_port: uint16
sin6_flowinfo: uint32
sin6_addr: IN6_ADDR
Anonymous: _Anonymous_e__Union
PEER_ADDRESS {.bycopy.} = object
dwSize: uint32
sin6: SOCKADDR_IN6
PEER_ENDPOINT {.bycopy.} = object
address: PEER_ADDRESS
pwzEndpointName: pointerstruct IN6_ADDR
{
_u_e__Union u;
}
struct SOCKADDR_IN6
{
ushort sin6_family;
ushort sin6_port;
uint sin6_flowinfo;
IN6_ADDR sin6_addr;
_Anonymous_e__Union Anonymous;
}
struct PEER_ADDRESS
{
uint dwSize;
SOCKADDR_IN6 sin6;
}
struct PEER_ENDPOINT
{
PEER_ADDRESS address;
void* pwzEndpointName;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PEER_ENDPOINT サイズ: 36 バイト(x86)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; address : PEER_ADDRESS (+0, 32byte) varptr(st)+0 を基点に操作(32byte:入れ子/配列)
; pwzEndpointName : LPWSTR (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PEER_ENDPOINT サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; address : PEER_ADDRESS (+0, 40byte) varptr(st)+0 を基点に操作(40byte:入れ子/配列)
; pwzEndpointName : LPWSTR (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IN6_ADDR
#field byte u 16
#endstruct
#defstruct global SOCKADDR_IN6
#field short sin6_family
#field short sin6_port
#field int sin6_flowinfo
#field IN6_ADDR sin6_addr
#field byte Anonymous 8
#endstruct
#defstruct global PEER_ADDRESS
#field int dwSize
#field SOCKADDR_IN6 sin6
#endstruct
#defstruct global PEER_ENDPOINT
#field PEER_ADDRESS address
#field intptr pwzEndpointName
#endstruct
stdim st, PEER_ENDPOINT ; NSTRUCT 変数を確保