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