ReactOS  0.4.15-dev-1377-ga59cecd
specstrings.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS PSDK
3  * LICENSE: MIT (https://spdx.org/licenses/MIT)
4  * PURPOSE: Support for markers for documenting the semantics of APIs
5  * COPYRIGHT: Microsoft Corporation.
6  * SOURCE: https://github.com/microsoft/ChakraCore/blob/master/pal/inc/rt/specstrings.h
7  */
8 //
9 // Copyright (c) Microsoft. All rights reserved.
10 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 //
12 
13 
14 //
15 #ifndef SPECSTRINGS_H
16 #define SPECSTRINGS_H
17 
18 /***
19 *specstrings.h - support for markers for documenting the semantics of APIs
20 *
21 
22 *
23 * [Public]
24 ****/
25 
26 /*************************************************************************
27 * See specstrings_strict.h for documentation of all user visible macros.
28 *************************************************************************/
29 
30 #if _MSC_VER
31 #pragma once
32 #endif
33 
34 #if !defined(_SAL_VERSION_SAL2)
35 
36  #if defined(__BUILDMACHINE__) || defined(_USE_SAL2_ONLY)
37  #define _SAL_VERSION_SAL2(_A) SAL_2_Clean_Violation_using ## _A
38  #else
39  #define _SAL_VERSION_SAL2(_A)
40  #endif
41 
42  #ifdef _USE_SAL2_ONLY
43  #define _SAL2_STRICT
44  #define _SAL_VERSION_CHECK(_A) _SAL_VERSION_SAL2(_A)
45  #else
46  #define _SAL_VERSION_CHECK(_A)
47  #endif
48 
49  #ifndef SAL_VERSION_CHECK
50  #define SAL_VERSION_CHECK(_A) _SAL_VERSION_CHECK(_A)
51  #define SAL_VERSION_SAL2(_A) _SAL_VERSION_SAL2(_A)
52  #endif
53 
54 #endif
55 
56 #include <sal.h>
57 
58 #ifndef __SAL_H_FULL_VER
59 #define __SAL_H_FULL_VER 140050727
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /* version specific fixes to bring sal.h upto date */
67 #if __SAL_H_FULL_VER <= 140050727
68 
69 #if !defined(__midl) && defined(_PREFAST_) && _MSC_VER >= 1000 // [
70 
71 /* Missing from RTM sal.h */
72 #define __inner_bound _SA_annotes0(SAL_bound)
73 #define __inner_range(lb,ub) _SA_annotes2(SAL_range,lb,ub)
74 #define __inner_assume_bound_dec __inline __nothrow void __AssumeBoundInt(_Post_ __inner_bound int i) {i;}
75 #define __inner_assume_bound(i) __AssumeBoundInt(i);
76 #define __inner_allocator _SA_annotes0(SAL_allocator)
77 
78 #define __static_context(ctx, annotes) \
79  _SA_annotes1(SAL_context,ctx) _Group_(__nop_impl(annotes))
80 
81 #define __failure(x) __static_context(SAL_return_convention, \
82  _SA_annotes1(SAL_failure,x))
83 
84 __ANNOTATION(SAL_valueUndefined());
85 #define __valueUndefined _SA_annotes0(SAL_valueUndefined)
86 
87 enum __SAL_failureKind{__failureUnspecified = 0, __failureUndefined = 1};
88 
89 __ANNOTATION(SAL_failureDefault(enum __SAL_failureKind));
90 #define __failureDefault(kind) __static_context(SAL_return_convention, \
91  _SA_annotes1(SAL_failureDefault,kind))
92 
93 #else // ][
94 
95 #define __inner_bound
96 #define __inner_range(lb,ub)
97 #define __inner_assume_bound_dec
98 #define __inner_assume_bound(i)
99 #define __inner_allocator
100 
101 #define __static_context(ctx, annotes)
102 #define __failure(x)
103 #define __valueUndefined
104 #define __failureDefault(x)
105 
106 #endif // ]
107 
108 #define __xcount(size) __notnull __inexpressible_writableTo(size)
109 #define __in_xcount(size) __in _Pre_ __inexpressible_readableTo(size)
110 #define __out_xcount(size) __xcount(size) _Post_ __valid __refparam
111 #define __out_xcount_part(size,length) __out_xcount(size) _Post_ __inexpressible_readableTo(length)
112 #define __out_xcount_full(size) __out_xcount_part(size,size)
113 #define __inout_xcount(size) __out_xcount(size) _Pre_ __valid
114 #define __inout_xcount_part(size,length) __out_xcount_part(size,length) _Pre_ __valid _Pre_ __inexpressible_readableTo(length)
115 #define __inout_xcount_full(size) __inout_xcount_part(size,size)
116 #define __xcount_opt(size) __xcount(size) __exceptthat __maybenull
117 #define __in_xcount_opt(size) __in_xcount(size) __exceptthat __maybenull
118 #define __out_xcount_opt(size) __out_xcount(size) __exceptthat __maybenull
119 #define __out_xcount_part_opt(size,length) __out_xcount_part(size,length) __exceptthat __maybenull
120 #define __out_xcount_full_opt(size) __out_xcount_full(size) __exceptthat __maybenull
121 #define __inout_xcount_opt(size) __inout_xcount(size) __exceptthat __maybenull
122 #define __inout_xcount_part_opt(size,length) __inout_xcount_part(size,length) __exceptthat __maybenull
123 #define __inout_xcount_full_opt(size) __inout_xcount_full(size) __exceptthat __maybenull
124 #define __deref_xcount(size) __ecount(1) _Post_ __elem_readableTo(1) _Post_ __deref __notnull _Post_ __deref __inexpressible_writableTo(size)
125 #define __deref_in __in _Pre_ __deref __deref __readonly
126 #define __deref_in_ecount(size) __deref_in _Pre_ __deref __elem_readableTo(size)
127 #define __deref_in_bcount(size) __deref_in _Pre_ __deref __byte_readableTo(size)
128 #define __deref_in_xcount(size) __deref_in _Pre_ __deref __inexpressible_readableTo(size)
129 #define __deref_out_xcount(size) __deref_xcount(size) _Post_ __deref __valid __refparam
130 #define __deref_out_xcount_part(size,length) __deref_out_xcount(size) _Post_ __deref __inexpressible_readableTo(length)
131 #define __deref_out_xcount_full(size) __deref_out_xcount_part(size,size)
132 #define __deref_out_xcount(size) __deref_xcount(size) _Post_ __deref __valid __refparam
133 #define __inout_xcount_opt(size) __inout_xcount(size) __exceptthat __maybenull
134 #define __inout_xcount_part_opt(size,length) __inout_xcount_part(size,length) __exceptthat __maybenull
135 #define __inout_xcount_full_opt(size) __inout_xcount_full(size) __exceptthat __maybenull
136 #define __deref_xcount(size) __ecount(1) _Post_ __elem_readableTo(1) _Post_ __deref __notnull _Post_ __deref __inexpressible_writableTo(size)
137 #define __deref_in __in _Pre_ __deref __deref __readonly
138 #define __deref_in_ecount(size) __deref_in _Pre_ __deref __elem_readableTo(size)
139 #define __deref_in_bcount(size) __deref_in _Pre_ __deref __byte_readableTo(size)
140 #define __deref_in_xcount(size) __deref_in _Pre_ __deref __inexpressible_readableTo(size)
141 #define __deref_out_xcount(size) __deref_xcount(size) _Post_ __deref __valid __refparam
142 #define __deref_out_xcount_part(size,length) __deref_out_xcount(size) _Post_ __deref __inexpressible_readableTo(length)
143 #define __deref_out_xcount_full(size) __deref_out_xcount_part(size,size)
144 #define __deref_out_xcount(size) __deref_xcount(size) _Post_ __deref __valid __refparam
145 #define __deref_inout_xcount(size) __deref_inout _Pre_ __deref __inexpressible_writableTo(size) _Post_ __deref __inexpressible_writableTo(size)
146 #define __deref_inout_xcount_part(size,length) __deref_inout_xcount(size) _Pre_ __deref __inexpressible_readableTo(length) _Post_ __deref __inexpressible_readableTo(length)
147 #define __deref_inout_xcount_full(size) __deref_inout_xcount_part(size,size)
148 #define __deref_xcount_opt(size) __deref_xcount(size) _Post_ __deref __exceptthat __maybenull
149 #define __deref_in_opt __deref_in _Pre_ __deref __exceptthat __maybenull
150 #define __deref_in_opt_out __deref_inout _Pre_ __deref __exceptthat __maybenull _Post_ __deref __notnull
151 #define __deref_in_ecount_opt(size) __deref_in_ecount(size) _Pre_ __deref __exceptthat __maybenull
152 #define __deref_in_bcount_opt(size) __deref_in_bcount(size) _Pre_ __deref __exceptthat __maybenull
153 #define __deref_in_xcount_opt(size) __deref_in_xcount(size) _Pre_ __deref __exceptthat __maybenull
154 #define __deref_out_xcount_opt(size) __deref_out_xcount(size) _Post_ __deref __exceptthat __maybenull
155 #define __deref_out_xcount_part_opt(size,length) __deref_out_xcount_part(size,length) _Post_ __deref __exceptthat __maybenull
156 #define __deref_out_xcount_full_opt(size) __deref_out_xcount_full(size) _Post_ __deref __exceptthat __maybenull
157 #define __deref_inout_xcount_opt(size) __deref_inout_xcount(size) _Pre_ __deref __exceptthat __maybenull _Post_ __deref __exceptthat __maybenull
158 #define __deref_inout_xcount_part_opt(size,length) __deref_inout_xcount_part(size,length) _Pre_ __deref __exceptthat __maybenull _Post_ __deref __exceptthat __maybenull
159 #define __deref_inout_xcount_full_opt(size) __deref_inout_xcount_full(size) _Pre_ __deref __exceptthat __maybenull _Post_ __deref __exceptthat __maybenull
160 #define __deref_opt_xcount(size) __deref_xcount(size) __exceptthat __maybenull
161 #define __deref_opt_in __deref_in __exceptthat __maybenull
162 #define __deref_opt_in_ecount(size) __deref_in_ecount(size) __exceptthat __maybenull
163 #define __deref_opt_in_bcount(size) __deref_in_bcount(size) __exceptthat __maybenull
164 #define __deref_opt_in_xcount(size) __deref_in_xcount(size) __exceptthat __maybenull
165 #define __deref_opt_out_xcount(size) __deref_out_xcount(size) __exceptthat __maybenull
166 #define __deref_opt_out_xcount_part(size,length) __deref_out_xcount_part(size,length) __exceptthat __maybenull
167 #define __deref_opt_out_xcount_full(size) __deref_out_xcount_full(size) __exceptthat __maybenull
168 #define __deref_opt_inout_xcount(size) __deref_inout_xcount(size) __exceptthat __maybenull
169 #define __deref_opt_inout_xcount_part(size,length) __deref_inout_xcount_part(size,length) __exceptthat __maybenull
170 #define __deref_opt_inout_xcount_full(size) __deref_inout_xcount_full(size) __exceptthat __maybenull
171 #define __deref_opt_xcount_opt(size) __deref_xcount_opt(size) __exceptthat __maybenull
172 #define __deref_opt_in_opt __deref_in_opt __exceptthat __maybenull
173 #define __deref_opt_in_ecount_opt(size) __deref_in_ecount_opt(size) __exceptthat __maybenull
174 #define __deref_opt_in_bcount_opt(size) __deref_in_bcount_opt(size) __exceptthat __maybenull
175 #define __deref_opt_in_xcount_opt(size) __deref_in_xcount_opt(size) __exceptthat __maybenull
176 #define __deref_opt_out_xcount_opt(size) __deref_out_xcount_opt(size) __exceptthat __maybenull
177 #define __deref_opt_out_xcount_part_opt(size,length) __deref_out_xcount_part_opt(size,length) __exceptthat __maybenull
178 #define __deref_opt_out_xcount_full_opt(size) __deref_out_xcount_full_opt(size) __exceptthat __maybenull
179 #define __deref_opt_inout_xcount_opt(size) __deref_inout_xcount_opt(size) __exceptthat __maybenull
180 #define __deref_opt_inout_xcount_part_opt(size,length) __deref_inout_xcount_part_opt(size,length) __exceptthat __maybenull
181 #define __deref_opt_inout_xcount_full_opt(size) __deref_inout_xcount_full_opt(size) __exceptthat __maybenull
182 
183 #define __deref_in_ecount_iterator(size, incr) __inout _Pre_ __deref __elem_readableTo(size) __deref_out_range(==, _Old_(*_Curr_) + incr)
184 #define __deref_out_ecount_iterator(size, incr) __inout _Pre_ __deref __elem_writableTo(size) __deref_out_range(==, _Old_(*_Curr_) + incr)
185 #define __deref_inout_ecount_iterator(size, incr) __inout _Pre_ __deref __elem_readableTo(size) _Pre_ __deref __elem_writableTo(size) __deref_out_range(==, _Old_(*_Curr_) + incr)
186 
187 #define __post_bcount(size) _Post_ __byte_writableTo(size)
188 #define __post_ecount(size) _Post_ __elem_writableTo(size)
189 
190 #define __deref_realloc_bcount(insize, outsize) __inout _Pre_ __deref __byte_readableTo(insize) _Post_ __deref __byte_writableTo(outsize)
191 
192 /* __in_ecount_or_z(c) specifies semantics like strncmp, where a string
193  * parameter is either null terminated, or valid up to c elements.
194  */
195 #define __in_ecount_or_z(c) _When_(_String_length_(_Curr_) < (c), __in_z) \
196  _When_(_String_length_(_Curr_) >= (c), __in_ecount(c))
197 
198 
199 /* Provide default definition to be overridden when needed */
200 #define __post_nullnullterminated
201 
202 /* Must protect redfinitions of macros to workaround rc.exe issues. */
203 #ifndef RC_INVOKED
204 
205 #undef __nullnullterminated
206 #define __nullnullterminated __inexpressible_readableTo("string terminated by two nulls") __nullterminated
207 
208 #undef __post_nullnullterminated
209 #define __post_nullnullterminated _Post_ __inexpressible_readableTo("string terminated by two nulls") _Post_ __nullterminated
210 
211 #endif
212 #endif //__SAL_H_FULL_VER <= 140050727
213 
214 /************************************************************************
215  New extensions to sal.h follow here.
216 *************************************************************************/
217 
218 #if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_)
219 
220 #define __file_parser(typ) _SA_annotes2(SAL_file_parser,"function",typ)
221 #define __file_parser_class(typ) _SA_annotes2(SAL_file_parser,"class",typ)
222 #define __file_parser_library(typ) extern int _SA_annotes2(SAL_file_parser, "library", typ) __iSALFileParserLibrary##typ;
223 #define __source_code_content(typ) extern int _SA_annotes1(SAL_source_code_content, typ) __iSAL_Source_Code_Content##typ;
224 #define __class_code_content(typ) _SA_annotes1(SAL_class_code_content, typ)
225 #define __analysis_assert(e) __assume(e)
226 #define __analysis_hint(hint) _SA_annotes1(SAL_analysisHint, hint)
227 // For "breakpoint": doesn't return as far as analysis is concerned.
228 #define __analysis_noreturn __declspec(noreturn)
229 /* Internal defintions */
230 #define __inner_data_source(src_raw) _SA_annotes1(SAL_untrusted_data_source,src_raw)
231 #define __inner_this_data_source(src_raw) _SA_annotes1(SAL_untrusted_data_source_this,src_raw)
232 #define __inner_out_validated(typ_raw) _Post_ _SA_annotes1(SAL_validated,typ_raw)
233 #define __inner_this_out_validated(typ_raw) _SA_annotes1(SAL_validated_this,typ_raw)
234 #define __inner_assume_validated_dec __inline __nothrow void __AssumeValidated(__inner_out_validated("BY_DESIGN") const void *p) {p;}
235 #define __inner_assume_validated(p) __AssumeValidated(p)
236 #define __inner_transfer(formal) _SA_annotes1(SAL_transfer_adt_property_from,formal)
237 #define __inner_encoded _SA_annotes0(SAL_encoded)
238 
239 #if defined(_MSC_EXTENSIONS) || defined(_PREFAST_) || defined(OACR)
240 #define __inner_adt_prop(adt,prop) _SA_annotes2(SAL_adt, adt,prop)
241 #define __inner_adt_add_prop(adt,prop) _SA_annotes2(SAL_add_adt_property,adt,prop)
242 #define __inner_adt_remove_prop(adt,prop) _SA_annotes2(SAL_remove_adt_property,adt,prop)
243 #define __inner_adt_transfer_prop(arg) _SA_annotes1(SAL_transfer_adt_property_from,arg)
244 #define __inner_adt_type_props(typ) _SA_annotes1(SAL_post_type,typ)
245 #define __inner_volatile _SA_annotes0(SAL_volatile)
246 #define __inner_nonvolatile _SA_annotes0(SAL_nonvolatile)
247 #define __inner_possibly_notnullterminated _SA_annotes1(SAL_nullTerminated,__maybe)
248 #define __inner_analysis_assume_nullterminated_dec __inline __nothrow void __AnalysisAssumeNullterminated(_Post_ __nullterminated void *p) {*(char*)p=0;}
249 #define __inner_analysis_assume_nullterminated(x) __AnalysisAssumeNullterminated(x);
250 #endif
251 
252 #else
253 
254 #define __file_parser(typ)
255 #define __file_parser_class(typ)
256 #define __file_parser_library(typ)
257 #define __source_code_content(typ)
258 #define __class_code_content(typ)
259 #define __analysis_assert(e)
260 #define __analysis_hint(hint)
261 #define __analysis_noreturn
262 /* Internal defintions */
263 #define __inner_data_source(src_raw)
264 #define __inner_this_data_source(src_raw)
265 #define __inner_out_validated(typ_raw)
266 #define __inner_this_out_validated(typ_raw)
267 #define __inner_assume_validated_dec
268 #define __inner_assume_validated(p)
269 #define __inner_transfer(formal)
270 #define __inner_encoded
271 #define __inner_adt_prop(adt,prop)
272 #define __inner_adt_add_prop(adt,prop)
273 #define __inner_adt_remove_prop(adt,prop)
274 #define __inner_adt_transfer_prop(arg)
275 #define __inner_adt_type_props(typ)
276 #define __inner_volatile
277 #define __inner_nonvolatile
278 #define __inner_possibly_notnullterminated
279 #define __inner_analysis_assume_nullterminated_dec
280 #define __inner_analysis_assume_nullterminated(x)
281 
282 #endif // #if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_)
283 
284 #define __field_ecount(size) __notnull __elem_writableTo(size)
285 #define __field_bcount(size) __notnull __byte_writableTo(size)
286 #define __field_xcount(size) __notnull __inexpressible_writableTo(size)
287 
288 #define __field_ecount_opt(size) __maybenull __elem_writableTo(size)
289 #define __field_bcount_opt(size) __maybenull __byte_writableTo(size)
290 #define __field_xcount_opt(size) __maybenull __inexpressible_writableTo(size)
291 
292 #define __field_ecount_part(size,init) __notnull __elem_writableTo(size) __elem_readableTo(init)
293 #define __field_bcount_part(size,init) __notnull __byte_writableTo(size) __byte_readableTo(init)
294 #define __field_xcount_part(size,init) __notnull __inexpressible_writableTo(size) __inexpressible_readableTo(init)
295 
296 #define __field_ecount_part_opt(size,init) __maybenull __elem_writableTo(size) __elem_readableTo(init)
297 #define __field_bcount_part_opt(size,init) __maybenull __byte_writableTo(size) __byte_readableTo(init)
298 #define __field_xcount_part_opt(size,init) __maybenull __inexpressible_writableTo(size) __inexpressible_readableTo(init)
299 
300 #define __field_ecount_full(size) __field_ecount_part(size,size)
301 #define __field_bcount_full(size) __field_bcount_part(size,size)
302 #define __field_xcount_full(size) __field_xcount_part(size,size)
303 
304 #define __field_ecount_full_opt(size) __field_ecount_part_opt(size,size)
305 #define __field_bcount_full_opt(size) __field_bcount_part_opt(size,size)
306 #define __field_xcount_full_opt(size) __field_xcount_part_opt(size,size)
307 
308 #define __field_nullterminated __nullterminated
309 
310 #define __struct_bcount(size) __byte_writableTo(size)
311 #define __struct_xcount(size) __inexpressible_writableTo(size)
312 
313 #define __out_awcount(expr,size) _Pre_ __notnull \
314  __byte_writableTo((expr) ? (size) : (size) * 2) \
315  _Post_ __valid __refparam
316 #define __in_awcount(expr,size) _Pre_ __valid \
317  _Pre_ _Notref_ __deref __readonly \
318  __byte_readableTo((expr) ? (size) : (size) * 2)
319 #define __post_invalid _Post_ __notvalid
320 /* integer related macros */
321 #define __allocator __inner_allocator
322 #ifndef PAL_STDCPP_COMPAT
323 #define __deallocate(kind) _Pre_ __notnull __post_invalid
324 #define __deallocate_opt(kind) _Pre_ __maybenull __post_invalid
325 #endif
326 #define __bound __inner_bound
327 #define __range(lb,ub) __inner_range(lb,ub)
328 #define __in_bound _Pre_ __inner_bound
329 #define __out_bound _Post_ __inner_bound
330 #define __deref_out_bound _Post_ __deref __inner_bound
331 #define __in_range(lb,ub) _Pre_ __inner_range(lb,ub)
332 #define __out_range(lb,ub) _Post_ __inner_range(lb,ub)
333 #define __deref_in_range(lb,ub) _Pre_ __deref __inner_range(lb,ub)
334 #define __deref_out_range(lb,ub) _Post_ __deref __inner_range(lb,ub)
335 #define __deref_inout_range(lb,ub) __deref_in_range(lb,ub) __deref_out_range(lb,ub)
336 #define __field_range(lb,ub) __range(lb,ub)
337 #define __field_data_source(src_sym) __inner_data_source(#src_sym)
338 
339 #define __range_max(a,b) __range(==, a > b ? a : b)
340 #define __range_min(a,b) __range(==, a < b ? a : b)
341 
342 
343 /* Penetration review macros */
344 #define __in_data_source(src_sym) _Pre_ __inner_data_source(#src_sym)
345 #define __out_data_source(src_sym) _Post_ __inner_data_source(#src_sym)
346 #define __out_validated(typ_sym) __inner_out_validated(#typ_sym)
347 #define __this_out_data_source(src_sym) __inner_this_data_source(#src_sym)
348 #define __this_out_validated(typ_sym) __inner_this_out_validated(#typ_sym)
349 #define __transfer(formal) _Post_ __inner_transfer(formal)
350 #define __rpc_entry __inner_control_entrypoint(RPC)
351 #define __kernel_entry __inner_control_entrypoint(UserToKernel)
352 #define __gdi_entry __inner_control_entrypoint(GDI)
353 #define __encoded_pointer __inner_encoded
354 #define __encoded_array __inner_encoded
355 #define __field_encoded_pointer __inner_encoded
356 #define __field_encoded_array __inner_encoded
357 #if defined(_MSC_EXTENSIONS) || defined(_PREFAST_) || defined(OACR)
358 #define __type_has_adt_prop(adt,prop) __inner_adt_prop(adt,prop)
359 #define __out_has_adt_prop(adt,prop) _Post_ __inner_adt_add_prop(adt,prop)
360 #define __out_not_has_adt_prop(adt,prop) _Post_ __inner_adt_remove_prop(adt,prop)
361 #define __out_transfer_adt_prop(arg) _Post_ __inner_adt_transfer_prop(arg)
362 #define __out_has_type_adt_props(typ) _Post_ __inner_adt_type_props(typ)
363 
364 /* useful PFD related macros */
365 #define __possibly_notnullterminated __inner_possibly_notnullterminated
366 
367 /* Windows Internal */
368 #define __volatile __inner_volatile
369 #define __nonvolatile __inner_nonvolatile
370 #else
371 #define __out_has_type_adt_props(typ) /* nothing */
372 #endif
373 #define __deref_volatile __deref __volatile
374 #define __deref_nonvolatile __deref __nonvolatile
375 
376 /* declare stub functions for macros */
380 #define __analysis_assume_nullterminated(x) __inner_analysis_assume_nullterminated(x)
381 #define __assume_validated(p) __inner_assume_validated(p)
382 #define __assume_bound(i) __inner_assume_bound(i)
383 
384 
385 /**************************************************************************
386 * SAL 2 extensions for Windows-specific APIs.
387 ***************************************************************************/
388 
389 // Annotation for parameters that are not used in any way by the function.
390 // Unlike _Reserved_, an _Unreferenced_parameter_ pointer need not be NULL.
391 #ifndef _Unreferenced_parameter_
392 #define _Unreferenced_parameter_ _Const_
393 #endif
394 
395 // Pointer parameters that are freed by the function, and thus the pointed-to
396 // memory should not be used after return.
397 #ifndef _Frees_ptr_
398 #define _Frees_ptr_ _Pre_notnull_ _Post_ptr_invalid_
399 #endif
400 #ifndef _Frees_ptr_opt_
401 #define _Frees_ptr_opt_ _Pre_maybenull_ _Post_ptr_invalid_
402 #endif
403 
404 // NLS APIs allow strings to be specified either by an element count or
405 // null termination. Unlike _In_reads_or_z_, this is not whichever comes
406 // first, but based on whether the size is negative or not.
407 #define _In_NLS_string_(size) _When_((size) < 0, _In_z_) \
408  _When_((size) >= 0, _In_reads_(size))
409 
410 
411 // Minifilter CompletionContext parameters on the pre-operation callback
412 // default to NULL. For return type FLT_PREOP_SUCCESS_WITH_CALLBACK or
413 // FLT_PREOP_SYNCHRONIZE, it may be set to NULL or a valid pointer. For all
414 // other returns, it must be NULL.
415 #define _Flt_CompletionContext_Outptr_ \
416  _Outptr_result_maybenull_ _Pre_valid_ \
417  _At_(*_Curr_, _Pre_null_ \
418  _When_(return != FLT_PREOP_SUCCESS_WITH_CALLBACK && return != FLT_PREOP_SYNCHRONIZE, _Post_null_))
419 
420 // Minifilter ConnectionCookie parameters on the port connect notify callback
421 // default to NULL. On successful return, it may be set to NULL or non-NULL,
422 // but it must be NULL on failure.
423 #define _Flt_ConnectionCookie_Outptr_ \
424  _Outptr_result_maybenull_ _Pre_valid_ \
425  _At_(*_Curr_, _Pre_null_ _On_failure_(_Post_null_))
426 
427 
428 //
429 // A common pattern is to pass an "_Inout_ PCHAR* ppBuf" of size "_Inout_ DWORD* pSize"
430 // to a function that writes to **pBuf, incrementing *ppBuf to point to one
431 // past the last written byte. Thus the length of the write is
432 // (*ppBuf - Old(*ppBuf)). The size of the remaining unwritten capacity
433 // is written to *pSize.
434 //
435 // This pattern is frequently used when progressively filling a
436 // large buffer in chunks
437 // (e.g. when reading from a network interface in a driver).
438 //
439 // It is expected that these supplementary annotations would be used inside an
440 // _At_, like so:
441 //
442 // _At_(*ppBuf, _Writes_and_advances_ptr_(*pBufSize))
443 // HRESULT WriteChunkOfData(_Inout_ PCHAR* ppBuf, _Inout_ DWORD* pBufSize);
444 //
445 #ifndef _Writes_and_advances_ptr_
446 #define _Writes_and_advances_ptr_(size) \
447  _At_((void*)_Curr_, _Inout_) \
448  _At_(_Curr_, \
449  _Pre_writable_size_(size) \
450  _Post_writable_size_(size) \
451  _Post_satisfies_(_Curr_ - _Old_(_Curr_) == size)) \
452  _At_(_Old_(_Curr_), \
453  _Post_readable_size_(_Old_(size) - size))
454 #endif
455 
456 #ifndef _Writes_bytes_and_advances_ptr_
457 #define _Writes_bytes_and_advances_ptr_(size) \
458  _At_((void*)_Curr_, _Inout_) \
459  _At_(_Curr_, \
460  _Pre_writable_byte_size_(size) \
461  _Post_writable_byte_size_(size) \
462  _Post_satisfies_(((char*)_Curr_) - ((void*)_Old_(_Curr_)) == size)) \
463  _At_(_Old_(_Curr_), \
464  _Post_readable_byte_size_(_Old_(size) - size))
465 #endif
466 
467 //
468 // Gets the current error code (as returned by GetLastError()), and stores
469 // in _Curr_ as a postcondition. This is currently approximated by assuming
470 // that GetLastError() always returns a failed error code. This is not a
471 // completely accurate approximation, but reasonable.
472 //
473 #define _Post_equals_last_error_ _Post_satisfies_(_Curr_ != 0)
474 
475 #ifdef __cplusplus
476 }
477 #endif
478 
479 #ifdef _PREFIX_
480 /**************************************************************************
481 * Defintion of __pfx_assume and __pfx_assert. Thse should be the only
482 * defintions of these functions.
483 ***************************************************************************/
484 #if __cplusplus
485 extern "C" void __pfx_assert(bool, const char *);
486 extern "C" void __pfx_assume(bool, const char *);
487 #else
488 void __pfx_assert(int, const char *);
489 void __pfx_assume(int, const char *);
490 #endif
491 /**************************************************************************
492 * Redefintion of __analysis_assume and __analysis_assert for PREFIX build
493 **************************************************************************/
494 #undef __analysis_assume
495 #undef __analysis_assert
496 #define __analysis_assume(e) (__pfx_assume(e,"pfx_assume"),__assume(e));
497 #define __analysis_assert(e) (__pfx_assert(e,"pfx_assert"),__assume(e));
498 #endif /* ifdef _PREFIX_ */
499 
500 /**************************************************************************
501 * This include should always be the last thing in this file.
502 * Must avoid redfinitions of macros to workaround rc.exe issues.
503 ***************************************************************************/
504 #if !(defined(RC_INVOKED) || defined(SORTPP_PASS))
505 #include <specstrings_strict.h>
506 #endif /* if !(defined(RC_INVOKED) || defined(SORTPP_PASS)) */
507 
508 /*
509  If no SAL 2 appears to have been defined (_Outptr_ is a representative choice)
510  then we must be operating in a downlevel build environment (such as VS10).
511  We also test against the compiler version to identify a downlevel environment,
512  as VS11 is the minimum required for SAL 2 support.
513 
514  If we are operating in a downlevel build environment (such as VS10)
515  we need to undefine the following symbols before including driverspecs.h
516  or we will end up referencing SAL 2 implementation symbols and cause
517  build failures.
518 */
519 #if (!defined(_Outptr_) || _MSC_VER <= 1600) && !( defined( MIDL_PASS ) || defined(__midl) || defined(RC_INVOKED) ) /*IFSTRIP=IGN*/
520 #undef __ANNOTATION
521 #define __ANNOTATION(fun) /* fun */
522 #undef __PRIMOP
523 #define __PRIMOP(type, fun)
524 #endif /* !defined(_Outptr_) || _MSC_VER <= 1600 */
525 
526 // ROTOR doesn't need driverspecs.h
527 // #include <driverspecs.h>
528 
529 /*
530  If no SAL 2 appears to have been defined (_Outptr_ is a representative choice)
531  then we must be operating in a downlevel build environment (such as VS10).
532  We also test against the compiler version to identify a downlevel environment,
533  as VS11 is the minimum required for SAL 2 support.
534 
535  If we are in a downlevel environment, we can go ahead and include no_sal2.h
536  to make all of SAL 2 no-ops to ensure no build failures.
537 */
538 #if (!defined(_Outptr_) /* || _MSC_VER <= 1600 */) && !( defined( MIDL_PASS ) || defined(__midl) || defined(RC_INVOKED) ) && !( defined( _SDV_ ) ) /*IFSTRIP=IGN*/
539 #include <no_sal2.h>
540 #endif /* !defined(_Outptr_) || _MSC_VER <= 1600 */
541 
542 #endif /* #ifndef SPECSTRINGS_H */
543 
544 
#define __inner_analysis_assume_nullterminated_dec
Definition: specstrings.h:279
#define __inner_assume_validated_dec
Definition: specstrings.h:267
#define __ANNOTATION(fun)
Definition: specstrings.h:521
#define __inner_assume_bound_dec
Definition: specstrings.h:97