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

MCCP Buffer Protection

· 52CE 我爱测

Starting with Windows Vista, the RPC Marshalling Engine takes further steps to try to prevent client-side buffer overruns due to returned data. This facility is called Mini Compute Conformance Protection (MCCP).

Starting with Windows Vista, the RPC Marshalling Engine takes further steps to try to prevent client-side buffer overruns due to returned data. This facility is called Mini Compute Conformance Protection (MCCP).

When the client passes a pointer to an existing buffer to an [out] or [in,out] parameter, returned data for that parameter is copied into the existing buffer. If the returned data is larger than the passed buffer, a buffer overrun can occur when RPC copies the returned data into the too-small buffer. See Top-Level and Embedded Pointers.

With MCCP, RPC attempts to detect this condition and reject the call if it is detected. For buffers with a correlation value, such as [size_is], if the returned data does not fit in the specified buffer size, the call is rejected and RPC_X_BAD_STUB_DATA exception is raised. For unsized strings, the call is rejected if the existing string size (length until the null terminator) is insufficient to hold the returned string, the call is rejected. RPC cannot detect buffer overruns in all conditions, so the developer is advised to continue to take normal precautions against buffer overruns.

If the client does not pass an existing buffer for an [out] parameter, but instead passes a dereferenced pointer to NULL, RPC will follow normal rules to allocate a new buffer on the client’s behalf. This buffer will be allocated with sufficient space to hold the returned data.

A second protection is that for correlated parameters, RPC will enforce that a non-null buffer is passed when the correlation count variable is non-null.

HRESULT PassString( [in] DWORD Length, [in, unique, string, size_is( Length )]LPWSTR MyString );

If MyString is NULL, RPC will reject the call unless Length is set to 0. Note that RPC will allow Length to be 0 while MyString is non-NULL, and RPC will treat MyString as a 0-length buffer allocation.

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)

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

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