/robust switch
The /robust switch tells the MIDL compiler to generate additional error-checking information, which the NDR engine uses to perform integrity checks at run time.
midl /robust {/Oicf | /Oif }
-
/Oicf
-
/Oif
-
These switches are identical in their functionality. They specify the codeless proxy method of marshaling and use fast format strings for improved performance. See / Oi.
Using the /robust switch generates additional information that allows the Network Data Representation (NDR) engine to perform run-time error checking on correlated arguments in dynamic arrays, unions, and in out interface pointers in DCOM applications. The /robust switch is only available under Windows 2000 and later versions of Windows.
A correlated argument is an argument that uses any of the attributes that allow the size of a data object to be determined at run time: size_is, length_is, first_is, last_is, max_is, switch_is, and iid_is. In accordance with the OSF-DCE specification for the wire representation, this correlated argument appears in two different places. For example, consider a typical usage of the size_is attribute:
HRESULT Func1([in] long Size,
[in, size_is(Size)]BAR_TYPE *pBarType);
In this example, the client passes a long that specifies the size of a block of BAR_TYPEs (in terms of number of BAR_TYPES elements), and a pointer to the actual block of BAR_TYPEs. The Size argument correlates with the pBarType argument. In accordance with the OSF-DCE specification, the Size argument is represented twice on the wire—first as itself and then with the array of BAR_TYPE elements that represent the pBarType argument. Each argument is unmarshaled independently, according to its own wire representation. Normally, the Size argument and its copy, which is used to represent part of the other argument, have the same values. However, if the Size argument becomes corrupted (for example, when the block of BAR_TYPES is larger than what was allocated), the server application may stop responding, because it uses the value of the Size argument to measure incoming data.
The /robust switch is required to implement valid range checking with the range attribute.
midl /robust /Oicf filename.idl