Win32 API 日本語リファレンス
ホームSystem.Rpc › NDR64_USER_MARSHAL_FORMAT

NDR64_USER_MARSHAL_FORMAT

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

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

フィールド

フィールドサイズx64x86説明
FormatCodeBYTE1+0+0user_marshal/wire_marshalによる変換を示すフォーマットコード。
FlagsBYTE1+1+1属性フラグ。
RoutineIndexWORD2+2+2ユーザマーシャルルーチンテーブル内のインデックス(WORD)。
TransmittedTypeWireAlignmentWORD2+4+4転送型のワイヤ上アライメント(バイト数、WORD)。
MemoryAlignmentWORD2+6+6ユーザ型のメモリアライメント(バイト数、WORD)。
UserTypeMemorySizeDWORD4+8+8ユーザ型(アプリ側型)のメモリサイズ(バイト数)。
TransmittedTypeBufferSizeDWORD4+12+12転送型のバッファサイズ(バイト数)。
TransmittedTypevoid*8/4+16+16実際に転送される型の記述へのポインタ。

各言語での定義

#include <windows.h>

// NDR64_USER_MARSHAL_FORMAT  (x64 24 / x86 20 バイト)
typedef struct NDR64_USER_MARSHAL_FORMAT {
    BYTE FormatCode;
    BYTE Flags;
    WORD RoutineIndex;
    WORD TransmittedTypeWireAlignment;
    WORD MemoryAlignment;
    DWORD UserTypeMemorySize;
    DWORD TransmittedTypeBufferSize;
    void* TransmittedType;
} NDR64_USER_MARSHAL_FORMAT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NDR64_USER_MARSHAL_FORMAT
{
    public byte FormatCode;
    public byte Flags;
    public ushort RoutineIndex;
    public ushort TransmittedTypeWireAlignment;
    public ushort MemoryAlignment;
    public uint UserTypeMemorySize;
    public uint TransmittedTypeBufferSize;
    public IntPtr TransmittedType;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NDR64_USER_MARSHAL_FORMAT
    Public FormatCode As Byte
    Public Flags As Byte
    Public RoutineIndex As UShort
    Public TransmittedTypeWireAlignment As UShort
    Public MemoryAlignment As UShort
    Public UserTypeMemorySize As UInteger
    Public TransmittedTypeBufferSize As UInteger
    Public TransmittedType As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class NDR64_USER_MARSHAL_FORMAT(ctypes.Structure):
    _fields_ = [
        ("FormatCode", ctypes.c_ubyte),
        ("Flags", ctypes.c_ubyte),
        ("RoutineIndex", ctypes.c_ushort),
        ("TransmittedTypeWireAlignment", ctypes.c_ushort),
        ("MemoryAlignment", ctypes.c_ushort),
        ("UserTypeMemorySize", wintypes.DWORD),
        ("TransmittedTypeBufferSize", wintypes.DWORD),
        ("TransmittedType", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct NDR64_USER_MARSHAL_FORMAT {
    pub FormatCode: u8,
    pub Flags: u8,
    pub RoutineIndex: u16,
    pub TransmittedTypeWireAlignment: u16,
    pub MemoryAlignment: u16,
    pub UserTypeMemorySize: u32,
    pub TransmittedTypeBufferSize: u32,
    pub TransmittedType: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type NDR64_USER_MARSHAL_FORMAT struct {
	FormatCode byte
	Flags byte
	RoutineIndex uint16
	TransmittedTypeWireAlignment uint16
	MemoryAlignment uint16
	UserTypeMemorySize uint32
	TransmittedTypeBufferSize uint32
	TransmittedType uintptr
}
type
  NDR64_USER_MARSHAL_FORMAT = record
    FormatCode: Byte;
    Flags: Byte;
    RoutineIndex: Word;
    TransmittedTypeWireAlignment: Word;
    MemoryAlignment: Word;
    UserTypeMemorySize: DWORD;
    TransmittedTypeBufferSize: DWORD;
    TransmittedType: Pointer;
  end;
const NDR64_USER_MARSHAL_FORMAT = extern struct {
    FormatCode: u8,
    Flags: u8,
    RoutineIndex: u16,
    TransmittedTypeWireAlignment: u16,
    MemoryAlignment: u16,
    UserTypeMemorySize: u32,
    TransmittedTypeBufferSize: u32,
    TransmittedType: ?*anyopaque,
};
type
  NDR64_USER_MARSHAL_FORMAT {.bycopy.} = object
    FormatCode: uint8
    Flags: uint8
    RoutineIndex: uint16
    TransmittedTypeWireAlignment: uint16
    MemoryAlignment: uint16
    UserTypeMemorySize: uint32
    TransmittedTypeBufferSize: uint32
    TransmittedType: pointer
struct NDR64_USER_MARSHAL_FORMAT
{
    ubyte FormatCode;
    ubyte Flags;
    ushort RoutineIndex;
    ushort TransmittedTypeWireAlignment;
    ushort MemoryAlignment;
    uint UserTypeMemorySize;
    uint TransmittedTypeBufferSize;
    void* TransmittedType;
}

HSP用 定義

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

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

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