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

NDR64_FIX_ARRAY_HEADER_FORMAT

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

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

フィールド

フィールドサイズx64x86説明
FormatCodeBYTE1+0+0固定長配列を示すフォーマットコード。
AlignmentBYTE1+1+1配列のアライメント(バイト数)。
FlagsNDR64_ARRAY_FLAGS1+2+2配列の属性フラグ(NDR64_ARRAY_FLAGS)。
ReservedBYTE1+3+3予約フィールド(BYTE)。将来の拡張用。
TotalSizeDWORD4+4+4配列全体のサイズ(バイト数)。

各言語での定義

#include <windows.h>

// NDR64_ARRAY_FLAGS  (x64 1 / x86 1 バイト)
typedef struct NDR64_ARRAY_FLAGS {
    BYTE _bitfield;
} NDR64_ARRAY_FLAGS;

// NDR64_FIX_ARRAY_HEADER_FORMAT  (x64 8 / x86 8 バイト)
typedef struct NDR64_FIX_ARRAY_HEADER_FORMAT {
    BYTE FormatCode;
    BYTE Alignment;
    NDR64_ARRAY_FLAGS Flags;
    BYTE Reserved;
    DWORD TotalSize;
} NDR64_FIX_ARRAY_HEADER_FORMAT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NDR64_ARRAY_FLAGS
{
    public byte _bitfield;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NDR64_FIX_ARRAY_HEADER_FORMAT
{
    public byte FormatCode;
    public byte Alignment;
    public NDR64_ARRAY_FLAGS Flags;
    public byte Reserved;
    public uint TotalSize;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NDR64_ARRAY_FLAGS
    Public _bitfield As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NDR64_FIX_ARRAY_HEADER_FORMAT
    Public FormatCode As Byte
    Public Alignment As Byte
    Public Flags As NDR64_ARRAY_FLAGS
    Public Reserved As Byte
    Public TotalSize As UInteger
End Structure
import ctypes
from ctypes import wintypes

class NDR64_ARRAY_FLAGS(ctypes.Structure):
    _fields_ = [
        ("_bitfield", ctypes.c_ubyte),
    ]

class NDR64_FIX_ARRAY_HEADER_FORMAT(ctypes.Structure):
    _fields_ = [
        ("FormatCode", ctypes.c_ubyte),
        ("Alignment", ctypes.c_ubyte),
        ("Flags", NDR64_ARRAY_FLAGS),
        ("Reserved", ctypes.c_ubyte),
        ("TotalSize", wintypes.DWORD),
    ]
#[repr(C)]
pub struct NDR64_ARRAY_FLAGS {
    pub _bitfield: u8,
}

#[repr(C)]
pub struct NDR64_FIX_ARRAY_HEADER_FORMAT {
    pub FormatCode: u8,
    pub Alignment: u8,
    pub Flags: NDR64_ARRAY_FLAGS,
    pub Reserved: u8,
    pub TotalSize: u32,
}
import "golang.org/x/sys/windows"

type NDR64_ARRAY_FLAGS struct {
	_bitfield byte
}

type NDR64_FIX_ARRAY_HEADER_FORMAT struct {
	FormatCode byte
	Alignment byte
	Flags NDR64_ARRAY_FLAGS
	Reserved byte
	TotalSize uint32
}
type
  NDR64_ARRAY_FLAGS = record
    _bitfield: Byte;
  end;

  NDR64_FIX_ARRAY_HEADER_FORMAT = record
    FormatCode: Byte;
    Alignment: Byte;
    Flags: NDR64_ARRAY_FLAGS;
    Reserved: Byte;
    TotalSize: DWORD;
  end;
const NDR64_ARRAY_FLAGS = extern struct {
    _bitfield: u8,
};

const NDR64_FIX_ARRAY_HEADER_FORMAT = extern struct {
    FormatCode: u8,
    Alignment: u8,
    Flags: NDR64_ARRAY_FLAGS,
    Reserved: u8,
    TotalSize: u32,
};
type
  NDR64_ARRAY_FLAGS {.bycopy.} = object
    _bitfield: uint8

  NDR64_FIX_ARRAY_HEADER_FORMAT {.bycopy.} = object
    FormatCode: uint8
    Alignment: uint8
    Flags: NDR64_ARRAY_FLAGS
    Reserved: uint8
    TotalSize: uint32
struct NDR64_ARRAY_FLAGS
{
    ubyte _bitfield;
}

struct NDR64_FIX_ARRAY_HEADER_FORMAT
{
    ubyte FormatCode;
    ubyte Alignment;
    NDR64_ARRAY_FLAGS Flags;
    ubyte Reserved;
    uint TotalSize;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NDR64_FIX_ARRAY_HEADER_FORMAT サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; FormatCode : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; Alignment : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; Flags : NDR64_ARRAY_FLAGS (+2, 1byte)  varptr(st)+2 を基点に操作(1byte:入れ子/配列)
; Reserved : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; TotalSize : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NDR64_ARRAY_FLAGS
    #field byte _bitfield
#endstruct

#defstruct global NDR64_FIX_ARRAY_HEADER_FORMAT
    #field byte FormatCode
    #field byte Alignment
    #field NDR64_ARRAY_FLAGS Flags
    #field byte Reserved
    #field int TotalSize
#endstruct

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