Win32 API 日本語リファレンス
ホームNetworking.WinSock › SERVICE_ADDRESS

SERVICE_ADDRESS

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

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

フィールド

フィールドサイズx64x86説明
dwAddressTypeDWORD4+0+0lpAddress メンバーが指すソケットアドレスが属するアドレスファミリー。
dwAddressFlagsDWORD4+4+4

アドレスのプロパティを指定するビットフラグのセット。次のビットフラグが定義されています。

意味
SERVICE_ADDRESS_FLAG_RPC_CN
このビットフラグが設定されている場合、サービスはこのトランスポートプロトコル上でコネクション指向の RPC をサポートします。
SERVICE_ADDRESS_FLAG_RPC_DG
このビットフラグが設定されている場合、サービスはこのトランスポートプロトコル上でデータグラム指向の RPC をサポートします。
SERVICE_ADDRESS_FLAG_RPC_NB
このビットフラグが設定されている場合、サービスはこのトランスポートプロトコル上で NetBIOS RPC をサポートします。
dwAddressLengthDWORD4+8+8アドレスのサイズ (バイト単位)。
dwPrincipalLengthDWORD4+12+12将来の使用のために予約済みです。0 でなければなりません。
lpAddressBYTE*8/4+16+16適切な型のソケットアドレスへのポインター。
lpPrincipalBYTE*8/4+24+20将来の使用のために予約済みです。NULL でなければなりません。

公式ドキュメント

SERVICE_ADDRESS 構造体は、サービスのアドレス情報を格納します。この構造体は、リモートプロシージャコール (RPC)、名前付きパイプ、ソケットなど、多くの種類のプロセス間通信 (IPC) メカニズムとそのアドレス形式に対応できます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#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;
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;
}
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
import 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),
    ]
#[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,
}
import "golang.org/x/sys/windows"

type SERVICE_ADDRESS struct {
	dwAddressType uint32
	dwAddressFlags uint32
	dwAddressLength uint32
	dwPrincipalLength uint32
	lpAddress uintptr
	lpPrincipal uintptr
}
type
  SERVICE_ADDRESS = record
    dwAddressType: DWORD;
    dwAddressFlags: DWORD;
    dwAddressLength: DWORD;
    dwPrincipalLength: DWORD;
    lpAddress: Pointer;
    lpPrincipal: Pointer;
  end;
const SERVICE_ADDRESS = extern struct {
    dwAddressType: u32,
    dwAddressFlags: u32,
    dwAddressLength: u32,
    dwPrincipalLength: u32,
    lpAddress: ?*anyopaque,
    lpPrincipal: ?*anyopaque,
};
type
  SERVICE_ADDRESS {.bycopy.} = object
    dwAddressType: uint32
    dwAddressFlags: uint32
    dwAddressLength: uint32
    dwPrincipalLength: uint32
    lpAddress: pointer
    lpPrincipal: pointer
struct SERVICE_ADDRESS
{
    uint dwAddressType;
    uint dwAddressFlags;
    uint dwAddressLength;
    uint dwPrincipalLength;
    void* lpAddress;
    void* lpPrincipal;
}

HSP用 定義

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

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

stdim st, SERVICE_ADDRESS        ; NSTRUCT 変数を確保
st->dwAddressType = 100
mes "dwAddressType=" + st->dwAddressType