大网数据广告活动
网络与域名解析

Marshaling Rules for user_marshal and wire_marshal

· 52CE 我爱测

The OSF-DCE specification for marshaling embedded pointer types requires that you observe the following restrictions when implementing the type _UserSize, type _UserMarshal, and type _UserUnMarshal functions.

The OSF-DCE specification for marshaling embedded pointer types requires that you observe the following restrictions when implementing the <type>_UserSize, <type>_UserMarshal, and <type>_UserUnMarshal functions. (The rules and examples given here are for marshaling. However, your sizing and unmarshaling routines must follow the same restrictions):

  • If the wire-type is a flat type with no pointers, your marshaling routine for the corresponding userm-type should simply marshal the data according to the layout of the wire-type. For example:

    typedef [wire_marshal (long)] void * HANDLE_HANDLE;
    

    Note that the wire type, long, is a flat type. Your HANDLE_HANDLE_UserMarshal function marshals a long whenever a HANDLE_HANDLE object is passed to it.

  • If the wire-type is a pointer to another type, your marshaling routine for the corresponding userm-type should marshal the data according to the layout for the type that the wire-type points to. The NDR engine takes care of the pointer. For example:

    typedef struct HDATA
    {
        long size;
        [size_is(size)] long * pData;
    } HDATA;
    
    typedef HDATA * WIRE_TYPE;
    typedef [wire_marshal(WIRE_TYPE)] void * HANDLE_DATA;
    

    Note that the wire type, WIRE_TYPE, is a pointer type. Your HANDLE_DATA_UserMarshal function marshals the data related to the handle, using the HDATA layout, rather than the HDATA * layout.

  • A wire-type must be either a flat data type or a pointer type. If your transmissible type must be something else (a structure with pointers, for example), use a pointer to your desired type as the wire-type.

The effect of these restrictions is that the types defined with the [wire_marshal] or [user_marshal] attributes can be freely embedded in other types.

Related topics

wire_marshal

user_marshal

The type_UserSize Function

The type_UserMarshal Function

Thetype_UserUnMarshalFunction

Thetype_UserFreeFunction

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。