sal.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /***
  2. *sal.h - markers for documenting the semantics of APIs
  3. *
  4. * Copyright (c) Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * sal.h provides a set of annotations to describe how a function uses its
  8. * parameters - the assumptions it makes about them, and the guarantees it makes
  9. * upon finishing.
  10. *
  11. * [Public]
  12. *
  13. ****/
  14. /*
  15. -------------------------------------------------------------------------------
  16. Introduction
  17. sal.h provides a set of annotations to describe how a function uses its
  18. parameters - the assumptions it makes about them, and the guarantees it makes
  19. upon finishing.
  20. Annotations may be placed before either a function parameter's type or its return
  21. type, and describe the function's behavior regarding the parameter or return value.
  22. There are two classes of annotations: buffer annotations and advanced annotations.
  23. Buffer annotations describe how functions use their pointer parameters, and
  24. advanced annotations either describe complex/unusual buffer behavior, or provide
  25. additional information about a parameter that is not otherwise expressible.
  26. -------------------------------------------------------------------------------
  27. Buffer Annotations
  28. The most important annotations in sal.h provide a consistent way to annotate
  29. buffer parameters or return values for a function. Each of these annotations describes
  30. a single buffer (which could be a string, a fixed-length or variable-length array,
  31. or just a pointer) that the function interacts with: where it is, how large it is,
  32. how much is initialized, and what the function does with it.
  33. The appropriate macro for a given buffer can be constructed using the table below.
  34. Just pick the appropriate values from each category, and combine them together
  35. with a leading underscore. Some combinations of values do not make sense as buffer
  36. annotations. Only meaningful annotations can be added to your code; for a list of
  37. these, see the buffer annotation definitions section.
  38. Only a single buffer annotation should be used for each parameter.
  39. |------------|------------|---------|--------|----------|----------|---------------|
  40. | Level | Usage | Size | Output | NullTerm | Optional | Parameters |
  41. |------------|------------|---------|--------|----------|----------|---------------|
  42. | <> | <> | <> | <> | _z | <> | <> |
  43. | _deref | _in | _ecount | _full | _nz | _opt | (size) |
  44. | _deref_opt | _out | _bcount | _part | | | (size,length) |
  45. | | _inout | | | | | |
  46. | | | | | | | |
  47. |------------|------------|---------|--------|----------|----------|---------------|
  48. Level: Describes the buffer pointer's level of indirection from the parameter or
  49. return value 'p'.
  50. <> : p is the buffer pointer.
  51. _deref : *p is the buffer pointer. p must not be NULL.
  52. _deref_opt : *p may be the buffer pointer. p may be NULL, in which case the rest of
  53. the annotation is ignored.
  54. Usage: Describes how the function uses the buffer.
  55. <> : The buffer is not accessed. If used on the return value or with _deref, the
  56. function will provide the buffer, and it will be uninitialized at exit.
  57. Otherwise, the caller must provide the buffer. This should only be used
  58. for alloc and free functions.
  59. _in : The function will only read from the buffer. The caller must provide the
  60. buffer and initialize it. Cannot be used with _deref.
  61. _out : The function will only write to the buffer. If used on the return value or
  62. with _deref, the function will provide the buffer and initialize it.
  63. Otherwise, the caller must provide the buffer, and the function will
  64. initialize it.
  65. _inout : The function may freely read from and write to the buffer. The caller must
  66. provide the buffer and initialize it. If used with _deref, the buffer may
  67. be reallocated by the function.
  68. Size: Describes the total size of the buffer. This may be less than the space actually
  69. allocated for the buffer, in which case it describes the accessible amount.
  70. <> : No buffer size is given. If the type specifies the buffer size (such as
  71. with LPSTR and LPWSTR), that amount is used. Otherwise, the buffer is one
  72. element long. Must be used with _in, _out, or _inout.
  73. _ecount : The buffer size is an explicit element count.
  74. _bcount : The buffer size is an explicit byte count.
  75. Output: Describes how much of the buffer will be initialized by the function. For
  76. _inout buffers, this also describes how much is initialized at entry. Omit this
  77. category for _in buffers; they must be fully initialized by the caller.
  78. <> : The type specifies how much is initialized. For instance, a function initializing
  79. an LPWSTR must NULL-terminate the string.
  80. _full : The function initializes the entire buffer.
  81. _part : The function initializes part of the buffer, and explicitly indicates how much.
  82. NullTerm: States if the present of a '\0' marks the end of valid elements in the buffer.
  83. _z : A '\0' indicated the end of the buffer
  84. _nz : The buffer may not be null terminated and a '\0' does not indicate the end of the
  85. buffer.
  86. Optional: Describes if the buffer itself is optional.
  87. <> : The pointer to the buffer must not be NULL.
  88. _opt : The pointer to the buffer might be NULL. It will be checked before being dereferenced.
  89. Parameters: Gives explicit counts for the size and length of the buffer.
  90. <> : There is no explicit count. Use when neither _ecount nor _bcount is used.
  91. (size) : Only the buffer's total size is given. Use with _ecount or _bcount but not _part.
  92. (size,length) : The buffer's total size and initialized length are given. Use with _ecount_part
  93. and _bcount_part.
  94. -------------------------------------------------------------------------------
  95. Buffer Annotation Examples
  96. LWSTDAPI_(BOOL) StrToIntExA(
  97. LPCSTR pszString, -- No annotation required, const implies __in.
  98. DWORD dwFlags,
  99. __out int *piRet -- A pointer whose dereference will be filled in.
  100. );
  101. void MyPaintingFunction(
  102. __in HWND hwndControl, -- An initialized read-only parameter.
  103. __in_opt HDC hdcOptional, -- An initialized read-only parameter that might be NULL.
  104. __inout IPropertyStore *ppsStore -- An initialized parameter that may be freely used
  105. -- and modified.
  106. );
  107. LWSTDAPI_(BOOL) PathCompactPathExA(
  108. __out_ecount(cchMax) LPSTR pszOut, -- A string buffer with cch elements that will
  109. -- be NULL terminated on exit.
  110. LPCSTR pszSrc, -- No annotation required, const implies __in.
  111. UINT cchMax,
  112. DWORD dwFlags
  113. );
  114. HRESULT SHLocalAllocBytes(
  115. size_t cb,
  116. __deref_bcount(cb) T **ppv -- A pointer whose dereference will be set to an
  117. -- uninitialized buffer with cb bytes.
  118. );
  119. __inout_bcount_full(cb) : A buffer with cb elements that is fully initialized at
  120. entry and exit, and may be written to by this function.
  121. __out_ecount_part(count, *countOut) : A buffer with count elements that will be
  122. partially initialized by this function. The function indicates how much it
  123. initialized by setting *countOut.
  124. -------------------------------------------------------------------------------
  125. Advanced Annotations
  126. Advanced annotations describe behavior that is not expressible with the regular
  127. buffer macros. These may be used either to annotate buffer parameters that involve
  128. complex or conditional behavior, or to enrich existing annotations with additional
  129. information.
  130. __success(expr) f :
  131. <expr> indicates whether function f succeeded or not. If <expr> is true at exit,
  132. all the function's guarantees (as given by other annotations) must hold. If <expr>
  133. is false at exit, the caller should not expect any of the function's guarantees
  134. to hold. If not used, the function must always satisfy its guarantees. Added
  135. automatically to functions that indicate success in standard ways, such as by
  136. returning an HRESULT.
  137. __nullterminated p :
  138. Pointer p is a buffer that may be read or written up to and including the first
  139. NULL character or pointer. May be used on typedefs, which marks valid (properly
  140. initialized) instances of that type as being NULL-terminated.
  141. __nullnullterminated p :
  142. Pointer p is a buffer that may be read or written up to and including the first
  143. sequence of two NULL characters or pointers. May be used on typedefs, which marks
  144. valid instances of that type as being double-NULL terminated.
  145. __reserved v :
  146. Value v must be 0/NULL, reserved for future use.
  147. __checkReturn v :
  148. Return value v must not be ignored by callers of this function.
  149. __typefix(ctype) v :
  150. Value v should be treated as an instance of ctype, rather than its declared type.
  151. __override f :
  152. Specify C#-style 'override' behaviour for overriding virtual methods.
  153. __callback f :
  154. Function f can be used as a function pointer.
  155. __format_string p :
  156. Pointer p is a string that contains % markers in the style of printf.
  157. __blocksOn(resource) f :
  158. Function f blocks on the resource 'resource'.
  159. __fallthrough :
  160. Annotates switch statement labels where fall-through is desired, to distinguish
  161. from forgotten break statements.
  162. -------------------------------------------------------------------------------
  163. Advanced Annotation Examples
  164. __success(return == TRUE) LWSTDAPI_(BOOL)
  165. PathCanonicalizeA(__out_ecount(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath) :
  166. pszBuf is only guaranteed to be NULL-terminated when TRUE is returned.
  167. typedef __nullterminated WCHAR* LPWSTR : Initialized LPWSTRs are NULL-terminated strings.
  168. __out_ecount(cch) __typefix(LPWSTR) void *psz : psz is a buffer parameter which will be
  169. a NULL-terminated WCHAR string at exit, and which initially contains cch WCHARs.
  170. -------------------------------------------------------------------------------
  171. */
  172. #pragma once
  173. #define __specstrings
  174. #ifdef __cplusplus
  175. #ifndef __nothrow
  176. # define __nothrow __declspec(nothrow)
  177. #endif
  178. extern "C" {
  179. #else
  180. #ifndef __nothrow
  181. # define __nothrow
  182. #endif
  183. #endif /* #ifdef __cplusplus */
  184. /*
  185. -------------------------------------------------------------------------------
  186. Helper Macro Definitions
  187. These express behavior common to many of the high-level annotations.
  188. DO NOT USE THESE IN YOUR CODE.
  189. -------------------------------------------------------------------------------
  190. */
  191. /*
  192. The helper annotations are only understood by the compiler version used by various
  193. defect detection tools. When the regular compiler is running, they are defined into
  194. nothing, and do not affect the compiled code.
  195. */
  196. #if !defined(__midl) && defined(_PREFAST_)
  197. /*
  198. In the primitive __declspec("SAL_*") annotations "SAL" stands for Standard
  199. Annotation Language. These __declspec("SAL_*") annotations are the
  200. primitives the compiler understands and all high-level SpecString MACROs
  201. will decompose into these primivates.
  202. */
  203. #define SPECSTRINGIZE( x ) #x
  204. /*
  205. __null p
  206. __notnull p
  207. __maybenull p
  208. Annotates a pointer p. States that pointer p is null. Commonly used
  209. in the negated form __notnull or the possibly null form __maybenull.
  210. */
  211. #define __null __declspec("SAL_null")
  212. #define __notnull __declspec("SAL_notnull")
  213. #define __maybenull __declspec("SAL_maybenull")
  214. /*
  215. __readonly l
  216. __notreadonly l
  217. __mabyereadonly l
  218. Annotates a location l. States that location l is not modified after
  219. this point. If the annotation is placed on the precondition state of
  220. a function, the restriction only applies until the postcondition state
  221. of the function. __maybereadonly states that the annotated location
  222. may be modified, whereas __notreadonly states that a location must be
  223. modified.
  224. */
  225. #define __readonly __declspec("SAL_readonly")
  226. #define __notreadonly __declspec("SAL_notreadonly")
  227. #define __maybereadonly __declspec("SAL_maybereadonly")
  228. /*
  229. __valid v
  230. __notvalid v
  231. __maybevalid v
  232. Annotates any value v. States that the value satisfies all properties of
  233. valid values of its type. For example, for a string buffer, valid means
  234. that the buffer pointer is either NULL or points to a NULL-terminated string.
  235. */
  236. #define __valid __declspec("SAL_valid")
  237. #define __notvalid __declspec("SAL_notvalid")
  238. #define __maybevalid __declspec("SAL_maybevalid")
  239. /*
  240. __readableTo(extent) p
  241. Annotates a buffer pointer p. If the buffer can be read, extent describes
  242. how much of the buffer is readable. For a reader of the buffer, this is
  243. an explicit permission to read up to that amount, rather than a restriction to
  244. read only up to it.
  245. */
  246. #define __readableTo(extent) __declspec("SAL_readableTo("SPECSTRINGIZE(extent)")")
  247. /*
  248. __elem_readableTo(size)
  249. Annotates a buffer pointer p as being readable to size elements.
  250. */
  251. #define __elem_readableTo(size) __declspec("SAL_readableTo(elementCount("SPECSTRINGIZE(size)"))")
  252. /*
  253. __byte_readableTo(size)
  254. Annotates a buffer pointer p as being readable to size bytes.
  255. */
  256. #define __byte_readableTo(size) __declspec("SAL_readableTo(byteCount("SPECSTRINGIZE(size)"))")
  257. /*
  258. __writableTo(extent) p
  259. Annotates a buffer pointer p. If the buffer can be modified, extent
  260. describes how much of the buffer is writable (usually the allocation
  261. size). For a writer of the buffer, this is an explicit permission to
  262. write up to that amount, rather than a restriction to write only up to it.
  263. */
  264. #define __writableTo(size) __declspec("SAL_writableTo("SPECSTRINGIZE(size)")")
  265. /*
  266. __elem_writableTo(size)
  267. Annotates a buffer pointer p as being writable to size elements.
  268. */
  269. #define __elem_writableTo(size) __declspec("SAL_writableTo(elementCount("SPECSTRINGIZE(size)"))")
  270. /*
  271. __byte_writableTo(size)
  272. Annotates a buffer pointer p as being writable to size bytes.
  273. */
  274. #define __byte_writableTo(size) __declspec("SAL_writableTo(byteCount("SPECSTRINGIZE(size)"))")
  275. /*
  276. __deref p
  277. Annotates a pointer p. The next annotation applies one dereference down
  278. in the type. If readableTo(p, size) then the next annotation applies to
  279. all elements *(p+i) for which i satisfies the size. If p is a pointer
  280. to a struct, the next annotation applies to all fields of the struct.
  281. */
  282. #define __deref __declspec("SAL_deref")
  283. /*
  284. __pre __next_annotation
  285. The next annotation applies in the precondition state
  286. */
  287. #define __pre __declspec("SAL_pre")
  288. /*
  289. __post __next_annotation
  290. The next annotation applies in the postcondition state
  291. */
  292. #define __post __declspec("SAL_post")
  293. /*
  294. __precond(<expr>)
  295. When <expr> is true, the next annotation applies in the precondition state
  296. (currently not enabled)
  297. */
  298. #define __precond(expr) __pre
  299. /*
  300. __postcond(<expr>)
  301. When <expr> is true, the next annotation applies in the postcondition state
  302. (currently not enabled)
  303. */
  304. #define __postcond(expr) __post
  305. /*
  306. __exceptthat
  307. Given a set of annotations Q containing __exceptthat maybeP, the effect of
  308. the except clause is to erase any P or notP annotations (explicit or
  309. implied) within Q at the same level of dereferencing that the except
  310. clause appears, and to replace it with maybeP.
  311. Example 1: __valid __exceptthat __maybenull on a pointer p means that the
  312. pointer may be null, and is otherwise valid, thus overriding
  313. the implicit notnull annotation implied by __valid on
  314. pointers.
  315. Example 2: __valid __deref __exceptthat __maybenull on an int **p means
  316. that p is not null (implied by valid), but the elements
  317. pointed to by p could be null, and are otherwise valid.
  318. */
  319. #define __exceptthat __declspec("SAL_except")
  320. #define __execeptthat __exceptthat
  321. /*
  322. _refparam
  323. Added to all out parameter macros to indicate that they are all reference
  324. parameters.
  325. */
  326. #define __refparam __deref __notreadonly
  327. /*
  328. __inner_*
  329. Helper macros that directly correspond to certain high-level annotations.
  330. */
  331. /*
  332. Macros to classify the entrypoints and indicate their category.
  333. Pre-defined control point categories include: RPC, LPC, DeviceDriver, UserToKernel, ISAPI, COM.
  334. */
  335. #define __inner_control_entrypoint(category) __declspec("SAL_entrypoint(controlEntry, "SPECSTRINGIZE(category)")")
  336. /*
  337. Pre-defined data entry point categories include: Registry, File, Network.
  338. */
  339. #define __inner_data_entrypoint(category) __declspec("SAL_entrypoint(dataEntry, "SPECSTRINGIZE(category)")")
  340. #define __inner_success(expr) __declspec("SAL_success("SPECSTRINGIZE(expr)")")
  341. #define __inner_checkReturn __declspec("SAL_checkReturn")
  342. #define __inner_typefix(ctype) __declspec("SAL_typefix("SPECSTRINGIZE(ctype)")")
  343. #define __inner_override __declspec("__override")
  344. #define __inner_callback __declspec("__callback")
  345. #define __inner_blocksOn(resource) __declspec("SAL_blocksOn("SPECSTRINGIZE(resource)")")
  346. #define __inner_fallthrough_dec __inline __nothrow void __FallThrough() {}
  347. #define __inner_fallthrough __FallThrough();
  348. #else
  349. #define __null
  350. #define __notnull
  351. #define __maybenull
  352. #define __readonly
  353. #define __notreadonly
  354. #define __maybereadonly
  355. #define __valid
  356. #define __notvalid
  357. #define __maybevalid
  358. #define __readableTo(extent)
  359. #define __elem_readableTo(size)
  360. #define __byte_readableTo(size)
  361. #define __writableTo(size)
  362. #define __elem_writableTo(size)
  363. #define __byte_writableTo(size)
  364. #define __deref
  365. #define __pre
  366. #define __post
  367. #define __precond(expr)
  368. #define __postcond(expr)
  369. #define __exceptthat
  370. #define __execeptthat
  371. #define __inner_success(expr)
  372. #define __inner_checkReturn
  373. #define __inner_typefix(ctype)
  374. #define __inner_override
  375. #define __inner_callback
  376. #define __inner_blocksOn(resource)
  377. #define __inner_fallthrough_dec
  378. #define __inner_fallthrough
  379. #define __refparam
  380. #define __inner_control_entrypoint(category)
  381. #define __inner_data_entrypoint(category)
  382. #endif /* #if !defined(__midl) && defined(_PREFAST_) */
  383. /*
  384. -------------------------------------------------------------------------------
  385. Buffer Annotation Definitions
  386. Any of these may be used to directly annotate functions, but only one should
  387. be used for each parameter. To determine which annotation to use for a given
  388. buffer, use the table in the buffer annotations section.
  389. -------------------------------------------------------------------------------
  390. */
  391. #define __ecount(size) __notnull __elem_writableTo(size)
  392. #define __bcount(size) __notnull __byte_writableTo(size)
  393. #define __in __pre __valid __pre __deref __readonly
  394. #define __in_ecount(size) __in __pre __elem_readableTo(size)
  395. #define __in_bcount(size) __in __pre __byte_readableTo(size)
  396. #define __in_z __in __pre __nullterminated
  397. #define __in_ecount_z(size) __in_ecount(size) __pre __nullterminated
  398. #define __in_bcount_z(size) __in_bcount(size) __pre __nullterminated
  399. #define __in_nz __in
  400. #define __in_ecount_nz(size) __in_ecount(size)
  401. #define __in_bcount_nz(size) __in_bcount(size)
  402. #define __out __ecount(1) __post __valid __refparam
  403. #define __out_ecount(size) __ecount(size) __post __valid __refparam
  404. #define __out_bcount(size) __bcount(size) __post __valid __refparam
  405. #define __out_ecount_part(size,length) __out_ecount(size) __post __elem_readableTo(length)
  406. #define __out_bcount_part(size,length) __out_bcount(size) __post __byte_readableTo(length)
  407. #define __out_ecount_full(size) __out_ecount_part(size,size)
  408. #define __out_bcount_full(size) __out_bcount_part(size,size)
  409. #define __out_z __post __valid __refparam __post __nullterminated
  410. #define __out_z_opt __post __valid __refparam __post __nullterminated __exceptthat __maybenull
  411. #define __out_ecount_z(size) __ecount(size) __post __valid __refparam __post __nullterminated
  412. #define __out_bcount_z(size) __bcount(size) __post __valid __refparam __post __nullterminated
  413. #define __out_ecount_part_z(size,length) __out_ecount_part(size,length) __post __nullterminated
  414. #define __out_bcount_part_z(size,length) __out_bcount_part(size,length) __post __nullterminated
  415. #define __out_ecount_full_z(size) __out_ecount_full(size) __post __nullterminated
  416. #define __out_bcount_full_z(size) __out_bcount_full(size) __post __nullterminated
  417. #define __out_nz __post __valid __refparam __post
  418. #define __out_nz_opt __post __valid __refparam __post __exceptthat __maybenull
  419. #define __out_ecount_nz(size) __ecount(size) __post __valid __refparam
  420. #define __out_bcount_nz(size) __bcount(size) __post __valid __refparam
  421. #define __inout __pre __valid __post __valid __refparam
  422. #define __inout_ecount(size) __out_ecount(size) __pre __valid
  423. #define __inout_bcount(size) __out_bcount(size) __pre __valid
  424. #define __inout_ecount_part(size,length) __out_ecount_part(size,length) __pre __valid __pre __elem_readableTo(length)
  425. #define __inout_bcount_part(size,length) __out_bcount_part(size,length) __pre __valid __pre __byte_readableTo(length)
  426. #define __inout_ecount_full(size) __inout_ecount_part(size,size)
  427. #define __inout_bcount_full(size) __inout_bcount_part(size,size)
  428. #define __inout_z __inout __pre __nullterminated __post __nullterminated
  429. #define __inout_ecount_z(size) __inout_ecount(size) __pre __nullterminated __post __nullterminated
  430. #define __inout_bcount_z(size) __inout_bcount(size) __pre __nullterminated __post __nullterminated
  431. #define __inout_nz __inout
  432. #define __inout_ecount_nz(size) __inout_ecount(size)
  433. #define __inout_bcount_nz(size) __inout_bcount(size)
  434. #define __ecount_opt(size) __ecount(size) __exceptthat __maybenull
  435. #define __bcount_opt(size) __bcount(size) __exceptthat __maybenull
  436. #define __in_opt __in __exceptthat __maybenull
  437. #define __in_ecount_opt(size) __in_ecount(size) __exceptthat __maybenull
  438. #define __in_bcount_opt(size) __in_bcount(size) __exceptthat __maybenull
  439. #define __in_z_opt __in_opt __pre __nullterminated
  440. #define __in_ecount_z_opt(size) __in_ecount_opt(size) __pre __nullterminated
  441. #define __in_bcount_z_opt(size) __in_bcount_opt(size) __pre __nullterminated
  442. #define __in_nz_opt __in_opt
  443. #define __in_ecount_nz_opt(size) __in_ecount_opt(size)
  444. #define __in_bcount_nz_opt(size) __in_bcount_opt(size)
  445. #define __out_opt __out __exceptthat __maybenull
  446. #define __out_ecount_opt(size) __out_ecount(size) __exceptthat __maybenull
  447. #define __out_bcount_opt(size) __out_bcount(size) __exceptthat __maybenull
  448. #define __out_ecount_part_opt(size,length) __out_ecount_part(size,length) __exceptthat __maybenull
  449. #define __out_bcount_part_opt(size,length) __out_bcount_part(size,length) __exceptthat __maybenull
  450. #define __out_ecount_full_opt(size) __out_ecount_full(size) __exceptthat __maybenull
  451. #define __out_bcount_full_opt(size) __out_bcount_full(size) __exceptthat __maybenull
  452. #define __out_ecount_z_opt(size) __out_ecount_opt(size) __post __nullterminated
  453. #define __out_bcount_z_opt(size) __out_bcount_opt(size) __post __nullterminated
  454. #define __out_ecount_part_z_opt(size,length) __out_ecount_part_opt(size,length) __post __nullterminated
  455. #define __out_bcount_part_z_opt(size,length) __out_bcount_part_opt(size,length) __post __nullterminated
  456. #define __out_ecount_full_z_opt(size) __out_ecount_full_opt(size) __post __nullterminated
  457. #define __out_bcount_full_z_opt(size) __out_bcount_full_opt(size) __post __nullterminated
  458. #define __out_ecount_nz_opt(size) __out_ecount_opt(size) __post __nullterminated
  459. #define __out_bcount_nz_opt(size) __out_bcount_opt(size) __post __nullterminated
  460. #define __inout_opt __inout __exceptthat __maybenull
  461. #define __inout_ecount_opt(size) __inout_ecount(size) __exceptthat __maybenull
  462. #define __inout_bcount_opt(size) __inout_bcount(size) __exceptthat __maybenull
  463. #define __inout_ecount_part_opt(size,length) __inout_ecount_part(size,length) __exceptthat __maybenull
  464. #define __inout_bcount_part_opt(size,length) __inout_bcount_part(size,length) __exceptthat __maybenull
  465. #define __inout_ecount_full_opt(size) __inout_ecount_full(size) __exceptthat __maybenull
  466. #define __inout_bcount_full_opt(size) __inout_bcount_full(size) __exceptthat __maybenull
  467. #define __inout_z_opt __inout_opt __pre __nullterminated __post __nullterminated
  468. #define __inout_ecount_z_opt(size) __inout_ecount_opt(size) __pre __nullterminated __post __nullterminated
  469. #define __inout_ecount_z_opt(size) __inout_ecount_opt(size) __pre __nullterminated __post __nullterminated
  470. #define __inout_bcount_z_opt(size) __inout_bcount_opt(size)
  471. #define __inout_nz_opt __inout_opt
  472. #define __inout_ecount_nz_opt(size) __inout_ecount_opt(size)
  473. #define __inout_bcount_nz_opt(size) __inout_bcount_opt(size)
  474. #define __deref_ecount(size) __ecount(1) __post __elem_readableTo(1) __post __deref __notnull __post __deref __elem_writableTo(size)
  475. #define __deref_bcount(size) __ecount(1) __post __elem_readableTo(1) __post __deref __notnull __post __deref __byte_writableTo(size)
  476. #define __deref_out __deref_ecount(1) __post __deref __valid __refparam
  477. #define __deref_out_ecount(size) __deref_ecount(size) __post __deref __valid __refparam
  478. #define __deref_out_bcount(size) __deref_bcount(size) __post __deref __valid __refparam
  479. #define __deref_out_ecount_part(size,length) __deref_out_ecount(size) __post __deref __elem_readableTo(length)
  480. #define __deref_out_bcount_part(size,length) __deref_out_bcount(size) __post __deref __byte_readableTo(length)
  481. #define __deref_out_ecount_full(size) __deref_out_ecount_part(size,size)
  482. #define __deref_out_bcount_full(size) __deref_out_bcount_part(size,size)
  483. #define __deref_out_z __post __deref __valid __refparam __post __deref __nullterminated
  484. #define __deref_out_ecount_z(size) __deref_out_ecount(size) __post __deref __nullterminated
  485. #define __deref_out_bcount_z(size) __deref_out_ecount(size) __post __deref __nullterminated
  486. #define __deref_out_nz __deref_out
  487. #define __deref_out_ecount_nz(size) __deref_out_ecount(size)
  488. #define __deref_out_bcount_nz(size) __deref_out_ecount(size)
  489. #define __deref_inout __notnull __elem_readableTo(1) __pre __deref __valid __post __deref __valid __refparam
  490. #define __deref_inout_z __deref_inout __pre __deref __nullterminated __post __deref __nullterminated
  491. #define __deref_inout_ecount(size) __deref_inout __pre __deref __elem_writableTo(size) __post __deref __elem_writableTo(size)
  492. #define __deref_inout_bcount(size) __deref_inout __pre __deref __byte_writableTo(size) __post __deref __byte_writableTo(size)
  493. #define __deref_inout_ecount_part(size,length) __deref_inout_ecount(size) __pre __deref __elem_readableTo(length) __post __deref __elem_readableTo(length)
  494. #define __deref_inout_bcount_part(size,length) __deref_inout_bcount(size) __pre __deref __byte_readableTo(length) __post __deref __byte_readableTo(length)
  495. #define __deref_inout_ecount_full(size) __deref_inout_ecount_part(size,size)
  496. #define __deref_inout_bcount_full(size) __deref_inout_bcount_part(size,size)
  497. #define __deref_inout_z __deref_inout __pre __deref __nullterminated __post __deref __nullterminated
  498. #define __deref_inout_ecount_z(size) __deref_inout_ecount(size) __pre __deref __nullterminated __post __deref __nullterminated
  499. #define __deref_inout_bcount_z(size) __deref_inout_ecount(size) __pre __deref __nullterminated __post __deref __nullterminated
  500. #define __deref_inout_nz __deref_inout
  501. #define __deref_inout_ecount_nz(size) __deref_inout_ecount(size)
  502. #define __deref_inout_bcount_nz(size) __deref_inout_ecount(size)
  503. #define __deref_ecount_opt(size) __deref_ecount(size) __post __deref __exceptthat __maybenull
  504. #define __deref_bcount_opt(size) __deref_bcount(size) __post __deref __exceptthat __maybenull
  505. #define __deref_out_opt __deref_out __post __deref __exceptthat __maybenull
  506. #define __deref_out_ecount_opt(size) __deref_out_ecount(size) __post __deref __exceptthat __maybenull
  507. #define __deref_out_bcount_opt(size) __deref_out_bcount(size) __post __deref __exceptthat __maybenull
  508. #define __deref_out_ecount_part_opt(size,length) __deref_out_ecount_part(size,length) __post __deref __exceptthat __maybenull
  509. #define __deref_out_bcount_part_opt(size,length) __deref_out_bcount_part(size,length) __post __deref __exceptthat __maybenull
  510. #define __deref_out_ecount_full_opt(size) __deref_out_ecount_full(size) __post __deref __exceptthat __maybenull
  511. #define __deref_out_bcount_full_opt(size) __deref_out_bcount_full(size) __post __deref __exceptthat __maybenull
  512. #define __deref_out_z_opt __post __deref __valid __refparam __execeptthat __maybenull __post __deref __nullterminated
  513. #define __deref_out_ecount_z_opt(size) __deref_out_ecount_opt(size) __post __deref __nullterminated
  514. #define __deref_out_bcount_z_opt(size) __deref_out_bcount_opt(size) __post __deref __nullterminated
  515. #define __deref_out_nz_opt __deref_out_opt
  516. #define __deref_out_ecount_nz_opt(size) __deref_out_ecount_opt(size)
  517. #define __deref_out_bcount_nz_opt(size) __deref_out_bcount_opt(size)
  518. #define __deref_inout_opt __deref_inout __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  519. #define __deref_inout_ecount_opt(size) __deref_inout_ecount(size) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  520. #define __deref_inout_bcount_opt(size) __deref_inout_bcount(size) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  521. #define __deref_inout_ecount_part_opt(size,length) __deref_inout_ecount_part(size,length) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  522. #define __deref_inout_bcount_part_opt(size,length) __deref_inout_bcount_part(size,length) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  523. #define __deref_inout_ecount_full_opt(size) __deref_inout_ecount_full(size) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  524. #define __deref_inout_bcount_full_opt(size) __deref_inout_bcount_full(size) __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull
  525. #define __deref_inout_z_opt __deref_inout_opt __pre __deref __nullterminated __post __deref __nullterminated
  526. #define __deref_inout_ecount_z_opt(size) __deref_inout_ecount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  527. #define __deref_inout_bcount_z_opt(size) __deref_inout_bcount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  528. #define __deref_inout_nz_opt __deref_inout_opt
  529. #define __deref_inout_ecount_nz_opt(size) __deref_inout_ecount_opt(size)
  530. #define __deref_inout_bcount_nz_opt(size) __deref_inout_bcount_opt(size)
  531. #define __deref_opt_ecount(size) __deref_ecount(size) __exceptthat __maybenull
  532. #define __deref_opt_bcount(size) __deref_bcount(size) __exceptthat __maybenull
  533. #define __deref_opt_out __deref_out __exceptthat __maybenull
  534. #define __deref_opt_out_z __deref_opt_out __post __deref __nullterminated
  535. #define __deref_opt_out_ecount(size) __deref_out_ecount(size) __exceptthat __maybenull
  536. #define __deref_opt_out_bcount(size) __deref_out_bcount(size) __exceptthat __maybenull
  537. #define __deref_opt_out_ecount_part(size,length) __deref_out_ecount_part(size,length) __exceptthat __maybenull
  538. #define __deref_opt_out_bcount_part(size,length) __deref_out_bcount_part(size,length) __exceptthat __maybenull
  539. #define __deref_opt_out_ecount_full(size) __deref_out_ecount_full(size) __exceptthat __maybenull
  540. #define __deref_opt_out_bcount_full(size) __deref_out_bcount_full(size) __exceptthat __maybenull
  541. #define __deref_opt_inout __deref_inout __exceptthat __maybenull
  542. #define __deref_opt_inout_ecount(size) __deref_inout_ecount(size) __exceptthat __maybenull
  543. #define __deref_opt_inout_bcount(size) __deref_inout_bcount(size) __exceptthat __maybenull
  544. #define __deref_opt_inout_ecount_part(size,length) __deref_inout_ecount_part(size,length) __exceptthat __maybenull
  545. #define __deref_opt_inout_bcount_part(size,length) __deref_inout_bcount_part(size,length) __exceptthat __maybenull
  546. #define __deref_opt_inout_ecount_full(size) __deref_inout_ecount_full(size) __exceptthat __maybenull
  547. #define __deref_opt_inout_bcount_full(size) __deref_inout_bcount_full(size) __exceptthat __maybenull
  548. #define __deref_opt_inout_z __deref_opt_inout __pre __deref __nullterminated __post __deref __nullterminated
  549. #define __deref_opt_inout_ecount_z(size) __deref_opt_inout_ecount(size) __pre __deref __nullterminated __post __deref __nullterminated
  550. #define __deref_opt_inout_bcount_z(size) __deref_opt_inout_bcount(size) __pre __deref __nullterminated __post __deref __nullterminated
  551. #define __deref_opt_inout_nz __deref_opt_inout
  552. #define __deref_opt_inout_ecount_nz(size) __deref_opt_inout_ecount(size)
  553. #define __deref_opt_inout_bcount_nz(size) __deref_opt_inout_bcount(size)
  554. #define __deref_opt_ecount_opt(size) __deref_ecount_opt(size) __exceptthat __maybenull
  555. #define __deref_opt_bcount_opt(size) __deref_bcount_opt(size) __exceptthat __maybenull
  556. #define __deref_opt_out_opt __deref_out_opt __exceptthat __maybenull
  557. #define __deref_opt_out_ecount_opt(size) __deref_out_ecount_opt(size) __exceptthat __maybenull
  558. #define __deref_opt_out_bcount_opt(size) __deref_out_bcount_opt(size) __exceptthat __maybenull
  559. #define __deref_opt_out_ecount_part_opt(size,length) __deref_out_ecount_part_opt(size,length) __exceptthat __maybenull
  560. #define __deref_opt_out_bcount_part_opt(size,length) __deref_out_bcount_part_opt(size,length) __exceptthat __maybenull
  561. #define __deref_opt_out_ecount_full_opt(size) __deref_out_ecount_full_opt(size) __exceptthat __maybenull
  562. #define __deref_opt_out_bcount_full_opt(size) __deref_out_bcount_full_opt(size) __exceptthat __maybenull
  563. #define __deref_opt_out_z_opt __post __deref __valid __refparam __exceptthat __maybenull __pre __deref __exceptthat __maybenull __post __deref __exceptthat __maybenull __post __deref __nullterminated
  564. #define __deref_opt_out_ecount_z_opt(size) __deref_opt_out_ecount_opt(size) __post __deref __nullterminated
  565. #define __deref_opt_out_bcount_z_opt(size) __deref_opt_out_bcount_opt(size) __post __deref __nullterminated
  566. #define __deref_opt_out_nz_opt __deref_opt_out_opt
  567. #define __deref_opt_out_ecount_nz_opt(size) __deref_opt_out_ecount_opt(size)
  568. #define __deref_opt_out_bcount_nz_opt(size) __deref_opt_out_bcount_opt(size)
  569. #define __deref_opt_inout_opt __deref_inout_opt __exceptthat __maybenull
  570. #define __deref_opt_inout_ecount_opt(size) __deref_inout_ecount_opt(size) __exceptthat __maybenull
  571. #define __deref_opt_inout_bcount_opt(size) __deref_inout_bcount_opt(size) __exceptthat __maybenull
  572. #define __deref_opt_inout_ecount_part_opt(size,length) __deref_inout_ecount_part_opt(size,length) __exceptthat __maybenull
  573. #define __deref_opt_inout_bcount_part_opt(size,length) __deref_inout_bcount_part_opt(size,length) __exceptthat __maybenull
  574. #define __deref_opt_inout_ecount_full_opt(size) __deref_inout_ecount_full_opt(size) __exceptthat __maybenull
  575. #define __deref_opt_inout_bcount_full_opt(size) __deref_inout_bcount_full_opt(size) __exceptthat __maybenull
  576. #define __deref_opt_inout_z_opt __deref_opt_inout_opt __pre __deref __nullterminated __post __deref __nullterminated
  577. #define __deref_opt_inout_ecount_z_opt(size) __deref_opt_inout_ecount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  578. #define __deref_opt_inout_bcount_z_opt(size) __deref_opt_inout_bcount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  579. #define __deref_opt_inout_nz_opt __deref_opt_inout_opt
  580. #define __deref_opt_inout_ecount_nz_opt(size) __deref_opt_inout_ecount_opt(size)
  581. #define __deref_opt_inout_bcount_nz_opt(size) __deref_opt_inout_bcount_opt(size)
  582. /*
  583. -------------------------------------------------------------------------------
  584. Advanced Annotation Definitions
  585. Any of these may be used to directly annotate functions, and may be used in
  586. combination with each other or with regular buffer macros. For an explanation
  587. of each annotation, see the advanced annotations section.
  588. -------------------------------------------------------------------------------
  589. */
  590. #define __success(expr) __inner_success(expr)
  591. #define __nullterminated __readableTo(sentinel(0))
  592. #define __nullnullterminated
  593. #define __reserved __pre __null
  594. #define __checkReturn __inner_checkReturn
  595. #define __typefix(ctype) __inner_typefix(ctype)
  596. #define __override __inner_override
  597. #define __callback __inner_callback
  598. #define __format_string
  599. #define __blocksOn(resource) __inner_blocksOn(resource)
  600. #define __control_entrypoint(category) __inner_control_entrypoint(category)
  601. #define __data_entrypoint(category) __inner_data_entrypoint(category)
  602. #ifndef __fallthrough
  603. __inner_fallthrough_dec
  604. #define __fallthrough __inner_fallthrough
  605. #endif
  606. #ifndef __analysis_assume
  607. #ifdef _PREFAST_
  608. #define __analysis_assume(expr) __assume(expr)
  609. #else
  610. #define __analysis_assume(expr)
  611. #endif
  612. #endif
  613. #ifdef __cplusplus
  614. }
  615. #endif