sal.h 205 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958
  1. //
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
  4. //
  5. /***
  6. *sal.h - markers for documenting the semantics of APIs
  7. *
  8. *
  9. *Purpose:
  10. * sal.h provides a set of annotations to describe how a function uses its
  11. * parameters - the assumptions it makes about them, and the guarantees it makes
  12. * upon finishing.
  13. ****/
  14. #pragma once
  15. /*==========================================================================
  16. The comments in this file are intended to give basic understanding of
  17. the usage of SAL, the Microsoft Source Code Annotation Language.
  18. For more details, please see https://go.microsoft.com/fwlink/?LinkID=242134
  19. The macros are defined in 3 layers, plus the structural set:
  20. _In_/_Out_/_Ret_ Layer:
  21. ----------------------
  22. This layer provides the highest abstraction and its macros should be used
  23. in most cases. These macros typically start with:
  24. _In_ : input parameter to a function, unmodified by called function
  25. _Out_ : output parameter, written to by called function, pointed-to
  26. location not expected to be initialized prior to call
  27. _Outptr_ : like _Out_ when returned variable is a pointer type
  28. (so param is pointer-to-pointer type). Called function
  29. provides/allocated space.
  30. _Outref_ : like _Outptr_, except param is reference-to-pointer type.
  31. _Inout_ : inout parameter, read from and potentially modified by
  32. called function.
  33. _Ret_ : for return values
  34. _Field_ : class/struct field invariants
  35. For common usage, this class of SAL provides the most concise annotations.
  36. Note that _In_/_Out_/_Inout_/_Outptr_ annotations are designed to be used
  37. with a parameter target. Using them with _At_ to specify non-parameter
  38. targets may yield unexpected results.
  39. This layer also includes a number of other properties that can be specified
  40. to extend the ability of code analysis, most notably:
  41. -- Designating parameters as format strings for printf/scanf/scanf_s
  42. -- Requesting stricter type checking for C enum parameters
  43. _Pre_/_Post_ Layer:
  44. ------------------
  45. The macros of this layer only should be used when there is no suitable macro
  46. in the _In_/_Out_ layer. Its macros start with _Pre_ or _Post_.
  47. This layer provides the most flexibility for annotations.
  48. Implementation Abstraction Layer:
  49. --------------------------------
  50. Macros from this layer should never be used directly. The layer only exists
  51. to hide the implementation of the annotation macros.
  52. Structural Layer:
  53. ----------------
  54. These annotations, like _At_ and _When_, are used with annotations from
  55. any of the other layers as modifiers, indicating exactly when and where
  56. the annotations apply.
  57. Common syntactic conventions:
  58. ----------------------------
  59. Usage:
  60. -----
  61. _In_, _Out_, _Inout_, _Pre_, _Post_, are for formal parameters.
  62. _Ret_, _Deref_ret_ must be used for return values.
  63. Nullness:
  64. --------
  65. If the parameter can be NULL as a precondition to the function, the
  66. annotation contains _opt. If the macro does not contain '_opt' the
  67. parameter cannot be NULL.
  68. If an out/inout parameter returns a null pointer as a postcondition, this is
  69. indicated by _Ret_maybenull_ or _result_maybenull_. If the macro is not
  70. of this form, then the result will not be NULL as a postcondition.
  71. _Outptr_ - output value is not NULL
  72. _Outptr_result_maybenull_ - output value might be NULL
  73. String Type:
  74. -----------
  75. _z: NullTerminated string
  76. for _In_ parameters the buffer must have the specified stringtype before the call
  77. for _Out_ parameters the buffer must have the specified stringtype after the call
  78. for _Inout_ parameters both conditions apply
  79. Extent Syntax:
  80. -------------
  81. Buffer sizes are expressed as element counts, unless the macro explicitly
  82. contains _byte_ or _bytes_. Some annotations specify two buffer sizes, in
  83. which case the second is used to indicate how much of the buffer is valid
  84. as a postcondition. This table outlines the precondition buffer allocation
  85. size, precondition number of valid elements, postcondition allocation size,
  86. and postcondition number of valid elements for representative buffer size
  87. annotations:
  88. Pre | Pre | Post | Post
  89. alloc | valid | alloc | valid
  90. Annotation elems | elems | elems | elems
  91. ---------- ------------------------------------
  92. _In_reads_(s) s | s | s | s
  93. _Inout_updates_(s) s | s | s | s
  94. _Inout_updates_to_(s,c) s | s | s | c
  95. _Out_writes_(s) s | 0 | s | s
  96. _Out_writes_to_(s,c) s | 0 | s | c
  97. _Outptr_result_buffer_(s) ? | ? | s | s
  98. _Outptr_result_buffer_to_(s,c) ? | ? | s | c
  99. For the _Outptr_ annotations, the buffer in question is at one level of
  100. dereference. The called function is responsible for supplying the buffer.
  101. Success and failure:
  102. -------------------
  103. The SAL concept of success allows functions to define expressions that can
  104. be tested by the caller, which if it evaluates to non-zero, indicates the
  105. function succeeded, which means that its postconditions are guaranteed to
  106. hold. Otherwise, if the expression evaluates to zero, the function is
  107. considered to have failed, and the postconditions are not guaranteed.
  108. The success criteria can be specified with the _Success_(expr) annotation:
  109. _Success_(return != FALSE) BOOL
  110. PathCanonicalizeA(_Out_writes_(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath) :
  111. pszBuf is only guaranteed to be NULL-terminated when TRUE is returned,
  112. and FALSE indiates failure. In common practice, callers check for zero
  113. vs. non-zero returns, so it is preferable to express the success
  114. criteria in terms of zero/non-zero, not checked for exactly TRUE.
  115. Functions can specify that some postconditions will still hold, even when
  116. the function fails, using _On_failure_(anno-list), or postconditions that
  117. hold regardless of success or failure using _Always_(anno-list).
  118. The annotation _Return_type_success_(expr) may be used with a typedef to
  119. give a default _Success_ criteria to all functions returning that type.
  120. This is the case for common Windows API status types, including
  121. HRESULT and NTSTATUS. This may be overridden on a per-function basis by
  122. specifying a _Success_ annotation locally.
  123. ============================================================================*/
  124. #define __ATTR_SAL
  125. #ifndef _SAL_VERSION /*IFSTRIP=IGN*/
  126. #define _SAL_VERSION 20
  127. #endif
  128. #ifdef _PREFAST_ // [
  129. // choose attribute or __declspec implementation
  130. #ifndef _USE_DECLSPECS_FOR_SAL // [
  131. #define _USE_DECLSPECS_FOR_SAL 1
  132. #endif // ]
  133. #if _USE_DECLSPECS_FOR_SAL // [
  134. #undef _USE_ATTRIBUTES_FOR_SAL
  135. #define _USE_ATTRIBUTES_FOR_SAL 0
  136. #elif !defined(_USE_ATTRIBUTES_FOR_SAL) // ][
  137. #if _MSC_VER >= 1400 /*IFSTRIP=IGN*/ // [
  138. #define _USE_ATTRIBUTES_FOR_SAL 1
  139. #else // ][
  140. #define _USE_ATTRIBUTES_FOR_SAL 0
  141. #endif // ]
  142. #endif // ]
  143. #if !_USE_DECLSPECS_FOR_SAL // [
  144. #if !_USE_ATTRIBUTES_FOR_SAL // [
  145. #if _MSC_VER >= 1400 /*IFSTRIP=IGN*/ // [
  146. #undef _USE_ATTRIBUTES_FOR_SAL
  147. #define _USE_ATTRIBUTES_FOR_SAL 1
  148. #else // ][
  149. #undef _USE_DECLSPECS_FOR_SAL
  150. #define _USE_DECLSPECS_FOR_SAL 1
  151. #endif // ]
  152. #endif // ]
  153. #endif // ]
  154. #else
  155. // Disable expansion of SAL macros in non-Prefast mode to
  156. // improve compiler throughput.
  157. #ifndef _USE_DECLSPECS_FOR_SAL // [
  158. #define _USE_DECLSPECS_FOR_SAL 0
  159. #endif // ]
  160. #ifndef _USE_ATTRIBUTES_FOR_SAL // [
  161. #define _USE_ATTRIBUTES_FOR_SAL 0
  162. #endif // ]
  163. #endif // ]
  164. // safeguard for MIDL and RC builds
  165. #if _USE_DECLSPECS_FOR_SAL && ( defined( MIDL_PASS ) || defined(__midl) || defined(RC_INVOKED) || !defined(_PREFAST_) ) /*IFSTRIP=IGN*/ // [
  166. #undef _USE_DECLSPECS_FOR_SAL
  167. #define _USE_DECLSPECS_FOR_SAL 0
  168. #endif // ]
  169. #if _USE_ATTRIBUTES_FOR_SAL && ( !defined(_MSC_EXTENSIONS) || defined( MIDL_PASS ) || defined(__midl) || defined(RC_INVOKED) ) /*IFSTRIP=IGN*/ // [
  170. #undef _USE_ATTRIBUTES_FOR_SAL
  171. #define _USE_ATTRIBUTES_FOR_SAL 0
  172. #endif // ]
  173. #if _USE_DECLSPECS_FOR_SAL || _USE_ATTRIBUTES_FOR_SAL
  174. // Special enum type for Y/N/M
  175. enum __SAL_YesNo {_SAL_notpresent, _SAL_no, _SAL_maybe, _SAL_yes, _SAL_default};
  176. #endif
  177. #if defined(BUILD_WINDOWS) && !_USE_ATTRIBUTES_FOR_SAL /*IFSTRIP=IGN*/
  178. #define _SAL1_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1") _GrouP_(annotes _SAL_nop_impl_)
  179. #define _SAL1_1_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1.1") _GrouP_(annotes _SAL_nop_impl_)
  180. #define _SAL1_2_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1.2") _GrouP_(annotes _SAL_nop_impl_)
  181. #define _SAL2_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "2") _GrouP_(annotes _SAL_nop_impl_)
  182. #else
  183. #define _SAL1_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1") _Group_(annotes _SAL_nop_impl_)
  184. #define _SAL1_1_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1.1") _Group_(annotes _SAL_nop_impl_)
  185. #define _SAL1_2_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1.2") _Group_(annotes _SAL_nop_impl_)
  186. #define _SAL2_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "2") _Group_(annotes _SAL_nop_impl_)
  187. #endif
  188. //============================================================================
  189. // Structural SAL:
  190. // These annotations modify the use of other annotations. They may
  191. // express the annotation target (i.e. what parameter/field the annotation
  192. // applies to) or the condition under which the annotation is applicable.
  193. //============================================================================
  194. // _At_(target, annos) specifies that the annotations listed in 'annos' is to
  195. // be applied to 'target' rather than to the identifier which is the current
  196. // lexical target.
  197. #define _At_(target, annos) _At_impl_(target, annos _SAL_nop_impl_)
  198. // _At_buffer_(target, iter, bound, annos) is similar to _At_, except that
  199. // target names a buffer, and each annotation in annos is applied to each
  200. // element of target up to bound, with the variable named in iter usable
  201. // by the annotations to refer to relevant offsets within target.
  202. #define _At_buffer_(target, iter, bound, annos) _At_buffer_impl_(target, iter, bound, annos _SAL_nop_impl_)
  203. // _When_(expr, annos) specifies that the annotations listed in 'annos' only
  204. // apply when 'expr' evaluates to non-zero.
  205. #define _When_(expr, annos) _When_impl_(expr, annos _SAL_nop_impl_)
  206. #define _Group_(annos) _Group_impl_(annos _SAL_nop_impl_)
  207. #define _GrouP_(annos) _GrouP_impl_(annos _SAL_nop_impl_)
  208. // <expr> indicates whether normal post conditions apply to a function
  209. #define _Success_(expr) _SAL2_Source_(_Success_, (expr), _Success_impl_(expr))
  210. // <expr> indicates whether post conditions apply to a function returning
  211. // the type that this annotation is applied to
  212. #define _Return_type_success_(expr) _SAL2_Source_(_Return_type_success_, (expr), _Success_impl_(expr))
  213. // Establish postconditions that apply only if the function does not succeed
  214. #define _On_failure_(annos) _On_failure_impl_(annos _SAL_nop_impl_)
  215. // Establish postconditions that apply in both success and failure cases.
  216. // Only applicable with functions that have _Success_ or _Return_type_succss_.
  217. #define _Always_(annos) _Always_impl_(annos _SAL_nop_impl_)
  218. // Usable on a function defintion. Asserts that a function declaration is
  219. // in scope, and its annotations are to be used. There are no other annotations
  220. // allowed on the function definition.
  221. #define _Use_decl_annotations_ _Use_decl_anno_impl_
  222. // _Notref_ may precede a _Deref_ or "real" annotation, and removes one
  223. // level of dereference if the parameter is a C++ reference (&). If the
  224. // net deref on a "real" annotation is negative, it is simply discarded.
  225. #define _Notref_ _Notref_impl_
  226. // Annotations for defensive programming styles.
  227. #define _Pre_defensive_ _SA_annotes0(SAL_pre_defensive)
  228. #define _Post_defensive_ _SA_annotes0(SAL_post_defensive)
  229. #define _In_defensive_(annotes) _Pre_defensive_ _Group_(annotes)
  230. #define _Out_defensive_(annotes) _Post_defensive_ _Group_(annotes)
  231. #define _Inout_defensive_(annotes) _Pre_defensive_ _Post_defensive_ _Group_(annotes)
  232. //============================================================================
  233. // _In_\_Out_ Layer:
  234. //============================================================================
  235. // Reserved pointer parameters, must always be NULL.
  236. #define _Reserved_ _SAL2_Source_(_Reserved_, (), _Pre1_impl_(__null_impl))
  237. // _Const_ allows specification that any namable memory location is considered
  238. // readonly for a given call.
  239. #define _Const_ _SAL2_Source_(_Const_, (), _Pre1_impl_(__readaccess_impl_notref))
  240. // Input parameters --------------------------
  241. // _In_ - Annotations for parameters where data is passed into the function, but not modified.
  242. // _In_ by itself can be used with non-pointer types (although it is redundant).
  243. // e.g. void SetPoint( _In_ const POINT* pPT );
  244. #define _In_ _SAL2_Source_(_In_, (), _Pre1_impl_(__notnull_impl_notref) _Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))
  245. #define _In_opt_ _SAL2_Source_(_In_opt_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre_valid_impl_ _Deref_pre_readonly_)
  246. // nullterminated 'in' parameters.
  247. // e.g. void CopyStr( _In_z_ const char* szFrom, _Out_z_cap_(cchTo) char* szTo, size_t cchTo );
  248. #define _In_z_ _SAL2_Source_(_In_z_, (), _In_ _Pre1_impl_(__zterm_impl))
  249. #define _In_opt_z_ _SAL2_Source_(_In_opt_z_, (), _In_opt_ _Pre1_impl_(__zterm_impl))
  250. // 'input' buffers with given size
  251. #define _In_reads_(size) _SAL2_Source_(_In_reads_, (size), _Pre_count_(size) _Deref_pre_readonly_)
  252. #define _In_reads_opt_(size) _SAL2_Source_(_In_reads_opt_, (size), _Pre_opt_count_(size) _Deref_pre_readonly_)
  253. #define _In_reads_bytes_(size) _SAL2_Source_(_In_reads_bytes_, (size), _Pre_bytecount_(size) _Deref_pre_readonly_)
  254. #define _In_reads_bytes_opt_(size) _SAL2_Source_(_In_reads_bytes_opt_, (size), _Pre_opt_bytecount_(size) _Deref_pre_readonly_)
  255. #define _In_reads_z_(size) _SAL2_Source_(_In_reads_z_, (size), _In_reads_(size) _Pre_z_)
  256. #define _In_reads_opt_z_(size) _SAL2_Source_(_In_reads_opt_z_, (size), _Pre_opt_count_(size) _Deref_pre_readonly_ _Pre_opt_z_)
  257. #define _In_reads_or_z_(size) _SAL2_Source_(_In_reads_or_z_, (size), _In_ _When_(_String_length_(_Curr_) < (size), _Pre_z_) _When_(_String_length_(_Curr_) >= (size), _Pre1_impl_(__count_impl(size))))
  258. #define _In_reads_or_z_opt_(size) _SAL2_Source_(_In_reads_or_z_opt_, (size), _In_opt_ _When_(_String_length_(_Curr_) < (size), _Pre_z_) _When_(_String_length_(_Curr_) >= (size), _Pre1_impl_(__count_impl(size))))
  259. // 'input' buffers valid to the given end pointer
  260. #define _In_reads_to_ptr_(ptr) _SAL2_Source_(_In_reads_to_ptr_, (ptr), _Pre_ptrdiff_count_(ptr) _Deref_pre_readonly_)
  261. #define _In_reads_to_ptr_opt_(ptr) _SAL2_Source_(_In_reads_to_ptr_opt_, (ptr), _Pre_opt_ptrdiff_count_(ptr) _Deref_pre_readonly_)
  262. #define _In_reads_to_ptr_z_(ptr) _SAL2_Source_(_In_reads_to_ptr_z_, (ptr), _In_reads_to_ptr_(ptr) _Pre_z_)
  263. #define _In_reads_to_ptr_opt_z_(ptr) _SAL2_Source_(_In_reads_to_ptr_opt_z_, (ptr), _Pre_opt_ptrdiff_count_(ptr) _Deref_pre_readonly_ _Pre_opt_z_)
  264. // Output parameters --------------------------
  265. // _Out_ - Annotations for pointer or reference parameters where data passed back to the caller.
  266. // These are mostly used where the pointer/reference is to a non-pointer type.
  267. // _Outptr_/_Outref) (see below) are typically used to return pointers via parameters.
  268. // e.g. void GetPoint( _Out_ POINT* pPT );
  269. #define _Out_ _SAL2_Source_(_Out_, (), _Out_impl_)
  270. #define _Out_opt_ _SAL2_Source_(_Out_opt_, (), _Out_opt_impl_)
  271. #define _Out_writes_(size) _SAL2_Source_(_Out_writes_, (size), _Pre_cap_(size) _Post_valid_impl_)
  272. #define _Out_writes_opt_(size) _SAL2_Source_(_Out_writes_opt_, (size), _Pre_opt_cap_(size) _Post_valid_impl_)
  273. #define _Out_writes_bytes_(size) _SAL2_Source_(_Out_writes_bytes_, (size), _Pre_bytecap_(size) _Post_valid_impl_)
  274. #define _Out_writes_bytes_opt_(size) _SAL2_Source_(_Out_writes_bytes_opt_, (size), _Pre_opt_bytecap_(size) _Post_valid_impl_)
  275. #define _Out_writes_z_(size) _SAL2_Source_(_Out_writes_z_, (size), _Pre_cap_(size) _Post_valid_impl_ _Post_z_)
  276. #define _Out_writes_opt_z_(size) _SAL2_Source_(_Out_writes_opt_z_, (size), _Pre_opt_cap_(size) _Post_valid_impl_ _Post_z_)
  277. #define _Out_writes_to_(size,count) _SAL2_Source_(_Out_writes_to_, (size,count), _Pre_cap_(size) _Post_valid_impl_ _Post_count_(count))
  278. #define _Out_writes_to_opt_(size,count) _SAL2_Source_(_Out_writes_to_opt_, (size,count), _Pre_opt_cap_(size) _Post_valid_impl_ _Post_count_(count))
  279. #define _Out_writes_all_(size) _SAL2_Source_(_Out_writes_all_, (size), _Out_writes_to_(_Old_(size), _Old_(size)))
  280. #define _Out_writes_all_opt_(size) _SAL2_Source_(_Out_writes_all_opt_, (size), _Out_writes_to_opt_(_Old_(size), _Old_(size)))
  281. #define _Out_writes_bytes_to_(size,count) _SAL2_Source_(_Out_writes_bytes_to_, (size,count), _Pre_bytecap_(size) _Post_valid_impl_ _Post_bytecount_(count))
  282. #define _Out_writes_bytes_to_opt_(size,count) _SAL2_Source_(_Out_writes_bytes_to_opt_, (size,count), _Pre_opt_bytecap_(size) _Post_valid_impl_ _Post_bytecount_(count))
  283. #define _Out_writes_bytes_all_(size) _SAL2_Source_(_Out_writes_bytes_all_, (size), _Out_writes_bytes_to_(_Old_(size), _Old_(size)))
  284. #define _Out_writes_bytes_all_opt_(size) _SAL2_Source_(_Out_writes_bytes_all_opt_, (size), _Out_writes_bytes_to_opt_(_Old_(size), _Old_(size)))
  285. #define _Out_writes_to_ptr_(ptr) _SAL2_Source_(_Out_writes_to_ptr_, (ptr), _Pre_ptrdiff_cap_(ptr) _Post_valid_impl_)
  286. #define _Out_writes_to_ptr_opt_(ptr) _SAL2_Source_(_Out_writes_to_ptr_opt_, (ptr), _Pre_opt_ptrdiff_cap_(ptr) _Post_valid_impl_)
  287. #define _Out_writes_to_ptr_z_(ptr) _SAL2_Source_(_Out_writes_to_ptr_z_, (ptr), _Pre_ptrdiff_cap_(ptr) _Post_valid_impl_ Post_z_)
  288. #define _Out_writes_to_ptr_opt_z_(ptr) _SAL2_Source_(_Out_writes_to_ptr_opt_z_, (ptr), _Pre_opt_ptrdiff_cap_(ptr) _Post_valid_impl_ Post_z_)
  289. // Inout parameters ----------------------------
  290. // _Inout_ - Annotations for pointer or reference parameters where data is passed in and
  291. // potentially modified.
  292. // void ModifyPoint( _Inout_ POINT* pPT );
  293. // void ModifyPointByRef( _Inout_ POINT& pPT );
  294. #define _Inout_ _SAL2_Source_(_Inout_, (), _Prepost_valid_)
  295. #define _Inout_opt_ _SAL2_Source_(_Inout_opt_, (), _Prepost_opt_valid_)
  296. // For modifying string buffers
  297. // void toupper( _Inout_z_ char* sz );
  298. #define _Inout_z_ _SAL2_Source_(_Inout_z_, (), _Prepost_z_)
  299. #define _Inout_opt_z_ _SAL2_Source_(_Inout_opt_z_, (), _Prepost_opt_z_)
  300. // For modifying buffers with explicit element size
  301. #define _Inout_updates_(size) _SAL2_Source_(_Inout_updates_, (size), _Pre_cap_(size) _Pre_valid_impl_ _Post_valid_impl_)
  302. #define _Inout_updates_opt_(size) _SAL2_Source_(_Inout_updates_opt_, (size), _Pre_opt_cap_(size) _Pre_valid_impl_ _Post_valid_impl_)
  303. #define _Inout_updates_z_(size) _SAL2_Source_(_Inout_updates_z_, (size), _Pre_cap_(size) _Pre_valid_impl_ _Post_valid_impl_ _Pre1_impl_(__zterm_impl) _Post1_impl_(__zterm_impl))
  304. #define _Inout_updates_opt_z_(size) _SAL2_Source_(_Inout_updates_opt_z_, (size), _Pre_opt_cap_(size) _Pre_valid_impl_ _Post_valid_impl_ _Pre1_impl_(__zterm_impl) _Post1_impl_(__zterm_impl))
  305. #define _Inout_updates_to_(size,count) _SAL2_Source_(_Inout_updates_to_, (size,count), _Out_writes_to_(size,count) _Pre_valid_impl_ _Pre1_impl_(__count_impl(count)))
  306. #define _Inout_updates_to_opt_(size,count) _SAL2_Source_(_Inout_updates_to_opt_, (size,count), _Out_writes_to_opt_(size,count) _Pre_valid_impl_ _Pre1_impl_(__count_impl(count)))
  307. #define _Inout_updates_all_(size) _SAL2_Source_(_Inout_updates_all_, (size), _Inout_updates_to_(_Old_(size), _Old_(size)))
  308. #define _Inout_updates_all_opt_(size) _SAL2_Source_(_Inout_updates_all_opt_, (size), _Inout_updates_to_opt_(_Old_(size), _Old_(size)))
  309. // For modifying buffers with explicit byte size
  310. #define _Inout_updates_bytes_(size) _SAL2_Source_(_Inout_updates_bytes_, (size), _Pre_bytecap_(size) _Pre_valid_impl_ _Post_valid_impl_)
  311. #define _Inout_updates_bytes_opt_(size) _SAL2_Source_(_Inout_updates_bytes_opt_, (size), _Pre_opt_bytecap_(size) _Pre_valid_impl_ _Post_valid_impl_)
  312. #define _Inout_updates_bytes_to_(size,count) _SAL2_Source_(_Inout_updates_bytes_to_, (size,count), _Out_writes_bytes_to_(size,count) _Pre_valid_impl_ _Pre1_impl_(__bytecount_impl(count)))
  313. #define _Inout_updates_bytes_to_opt_(size,count) _SAL2_Source_(_Inout_updates_bytes_to_opt_, (size,count), _Out_writes_bytes_to_opt_(size,count) _Pre_valid_impl_ _Pre1_impl_(__bytecount_impl(count)))
  314. #define _Inout_updates_bytes_all_(size) _SAL2_Source_(_Inout_updates_bytes_all_, (size), _Inout_updates_bytes_to_(_Old_(size), _Old_(size)))
  315. #define _Inout_updates_bytes_all_opt_(size) _SAL2_Source_(_Inout_updates_bytes_all_opt_, (size), _Inout_updates_bytes_to_opt_(_Old_(size), _Old_(size)))
  316. // Pointer to pointer parameters -------------------------
  317. // _Outptr_ - Annotations for output params returning pointers
  318. // These describe parameters where the called function provides the buffer:
  319. // HRESULT SHStrDupW(_In_ LPCWSTR psz, _Outptr_ LPWSTR *ppwsz);
  320. // The caller passes the address of an LPWSTR variable as ppwsz, and SHStrDupW allocates
  321. // and initializes memory and returns the pointer to the new LPWSTR in *ppwsz.
  322. //
  323. // _Outptr_opt_ - describes parameters that are allowed to be NULL.
  324. // _Outptr_*_result_maybenull_ - describes parameters where the called function might return NULL to the caller.
  325. //
  326. // Example:
  327. // void MyFunc(_Outptr_opt_ int **ppData1, _Outptr_result_maybenull_ int **ppData2);
  328. // Callers:
  329. // MyFunc(NULL, NULL); // error: parameter 2, ppData2, should not be NULL
  330. // MyFunc(&pData1, &pData2); // ok: both non-NULL
  331. // if (*pData1 == *pData2) ... // error: pData2 might be NULL after call
  332. #define _Outptr_ _SAL2_Source_(_Outptr_, (), _Out_impl_ _Deref_post2_impl_(__notnull_impl_notref, __count_impl(1)))
  333. #define _Outptr_result_maybenull_ _SAL2_Source_(_Outptr_result_maybenull_, (), _Out_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __count_impl(1)))
  334. #define _Outptr_opt_ _SAL2_Source_(_Outptr_opt_, (), _Out_opt_impl_ _Deref_post2_impl_(__notnull_impl_notref, __count_impl(1)))
  335. #define _Outptr_opt_result_maybenull_ _SAL2_Source_(_Outptr_opt_result_maybenull_, (), _Out_opt_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __count_impl(1)))
  336. // Annotations for _Outptr_ parameters returning pointers to null terminated strings.
  337. #define _Outptr_result_z_ _SAL2_Source_(_Outptr_result_z_, (), _Out_impl_ _Deref_post_z_)
  338. #define _Outptr_opt_result_z_ _SAL2_Source_(_Outptr_opt_result_z_, (), _Out_opt_impl_ _Deref_post_z_)
  339. #define _Outptr_result_maybenull_z_ _SAL2_Source_(_Outptr_result_maybenull_z_, (), _Out_impl_ _Deref_post_opt_z_)
  340. #define _Outptr_opt_result_maybenull_z_ _SAL2_Source_(_Outptr_opt_result_maybenull_z_, (), _Out_opt_impl_ _Deref_post_opt_z_)
  341. // Annotations for _Outptr_ parameters where the output pointer is set to NULL if the function fails.
  342. #define _Outptr_result_nullonfailure_ _SAL2_Source_(_Outptr_result_nullonfailure_, (), _Outptr_ _On_failure_(_Deref_post_null_))
  343. #define _Outptr_opt_result_nullonfailure_ _SAL2_Source_(_Outptr_opt_result_nullonfailure_, (), _Outptr_opt_ _On_failure_(_Deref_post_null_))
  344. // Annotations for _Outptr_ parameters which return a pointer to a ref-counted COM object,
  345. // following the COM convention of setting the output to NULL on failure.
  346. // The current implementation is identical to _Outptr_result_nullonfailure_.
  347. // For pointers to types that are not COM objects, _Outptr_result_nullonfailure_ is preferred.
  348. #define _COM_Outptr_ _SAL2_Source_(_COM_Outptr_, (), _Outptr_ _On_failure_(_Deref_post_null_))
  349. #define _COM_Outptr_result_maybenull_ _SAL2_Source_(_COM_Outptr_result_maybenull_, (), _Outptr_result_maybenull_ _On_failure_(_Deref_post_null_))
  350. #define _COM_Outptr_opt_ _SAL2_Source_(_COM_Outptr_opt_, (), _Outptr_opt_ _On_failure_(_Deref_post_null_))
  351. #define _COM_Outptr_opt_result_maybenull_ _SAL2_Source_(_COM_Outptr_opt_result_maybenull_, (), _Outptr_opt_result_maybenull_ _On_failure_(_Deref_post_null_))
  352. // Annotations for _Outptr_ parameters returning a pointer to buffer with a specified number of elements/bytes
  353. #define _Outptr_result_buffer_(size) _SAL2_Source_(_Outptr_result_buffer_, (size), _Out_impl_ _Deref_post2_impl_(__notnull_impl_notref, __cap_impl(size)))
  354. #define _Outptr_opt_result_buffer_(size) _SAL2_Source_(_Outptr_opt_result_buffer_, (size), _Out_opt_impl_ _Deref_post2_impl_(__notnull_impl_notref, __cap_impl(size)))
  355. #define _Outptr_result_buffer_to_(size, count) _SAL2_Source_(_Outptr_result_buffer_to_, (size, count), _Out_impl_ _Deref_post3_impl_(__notnull_impl_notref, __cap_impl(size), __count_impl(count)))
  356. #define _Outptr_opt_result_buffer_to_(size, count) _SAL2_Source_(_Outptr_opt_result_buffer_to_, (size, count), _Out_opt_impl_ _Deref_post3_impl_(__notnull_impl_notref, __cap_impl(size), __count_impl(count)))
  357. #define _Outptr_result_buffer_all_(size) _SAL2_Source_(_Outptr_result_buffer_all_, (size), _Out_impl_ _Deref_post2_impl_(__notnull_impl_notref, __count_impl(size)))
  358. #define _Outptr_opt_result_buffer_all_(size) _SAL2_Source_(_Outptr_opt_result_buffer_all_, (size), _Out_opt_impl_ _Deref_post2_impl_(__notnull_impl_notref, __count_impl(size)))
  359. #define _Outptr_result_buffer_maybenull_(size) _SAL2_Source_(_Outptr_result_buffer_maybenull_, (size), _Out_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __cap_impl(size)))
  360. #define _Outptr_opt_result_buffer_maybenull_(size) _SAL2_Source_(_Outptr_opt_result_buffer_maybenull_, (size), _Out_opt_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __cap_impl(size)))
  361. #define _Outptr_result_buffer_to_maybenull_(size, count) _SAL2_Source_(_Outptr_result_buffer_to_maybenull_, (size, count), _Out_impl_ _Deref_post3_impl_(__maybenull_impl_notref, __cap_impl(size), __count_impl(count)))
  362. #define _Outptr_opt_result_buffer_to_maybenull_(size, count) _SAL2_Source_(_Outptr_opt_result_buffer_to_maybenull_, (size, count), _Out_opt_impl_ _Deref_post3_impl_(__maybenull_impl_notref, __cap_impl(size), __count_impl(count)))
  363. #define _Outptr_result_buffer_all_maybenull_(size) _SAL2_Source_(_Outptr_result_buffer_all_maybenull_, (size), _Out_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __count_impl(size)))
  364. #define _Outptr_opt_result_buffer_all_maybenull_(size) _SAL2_Source_(_Outptr_opt_result_buffer_all_maybenull_, (size), _Out_opt_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __count_impl(size)))
  365. #define _Outptr_result_bytebuffer_(size) _SAL2_Source_(_Outptr_result_bytebuffer_, (size), _Out_impl_ _Deref_post2_impl_(__notnull_impl_notref, __bytecap_impl(size)))
  366. #define _Outptr_opt_result_bytebuffer_(size) _SAL2_Source_(_Outptr_opt_result_bytebuffer_, (size), _Out_opt_impl_ _Deref_post2_impl_(__notnull_impl_notref, __bytecap_impl(size)))
  367. #define _Outptr_result_bytebuffer_to_(size, count) _SAL2_Source_(_Outptr_result_bytebuffer_to_, (size, count), _Out_impl_ _Deref_post3_impl_(__notnull_impl_notref, __bytecap_impl(size), __bytecount_impl(count)))
  368. #define _Outptr_opt_result_bytebuffer_to_(size, count) _SAL2_Source_(_Outptr_opt_result_bytebuffer_to_, (size, count), _Out_opt_impl_ _Deref_post3_impl_(__notnull_impl_notref, __bytecap_impl(size), __bytecount_impl(count)))
  369. #define _Outptr_result_bytebuffer_all_(size) _SAL2_Source_(_Outptr_result_bytebuffer_all_, (size), _Out_impl_ _Deref_post2_impl_(__notnull_impl_notref, __bytecount_impl(size)))
  370. #define _Outptr_opt_result_bytebuffer_all_(size) _SAL2_Source_(_Outptr_opt_result_bytebuffer_all_, (size), _Out_opt_impl_ _Deref_post2_impl_(__notnull_impl_notref, __bytecount_impl(size)))
  371. #define _Outptr_result_bytebuffer_maybenull_(size) _SAL2_Source_(_Outptr_result_bytebuffer_maybenull_, (size), _Out_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __bytecap_impl(size)))
  372. #define _Outptr_opt_result_bytebuffer_maybenull_(size) _SAL2_Source_(_Outptr_opt_result_bytebuffer_maybenull_, (size), _Out_opt_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __bytecap_impl(size)))
  373. #define _Outptr_result_bytebuffer_to_maybenull_(size, count) _SAL2_Source_(_Outptr_result_bytebuffer_to_maybenull_, (size, count), _Out_impl_ _Deref_post3_impl_(__maybenull_impl_notref, __bytecap_impl(size), __bytecount_impl(count)))
  374. #define _Outptr_opt_result_bytebuffer_to_maybenull_(size, count) _SAL2_Source_(_Outptr_opt_result_bytebuffer_to_maybenull_, (size, count), _Out_opt_impl_ _Deref_post3_impl_(__maybenull_impl_notref, __bytecap_impl(size), __bytecount_impl(count)))
  375. #define _Outptr_result_bytebuffer_all_maybenull_(size) _SAL2_Source_(_Outptr_result_bytebuffer_all_maybenull_, (size), _Out_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __bytecount_impl(size)))
  376. #define _Outptr_opt_result_bytebuffer_all_maybenull_(size) _SAL2_Source_(_Outptr_opt_result_bytebuffer_all_maybenull_, (size), _Out_opt_impl_ _Deref_post2_impl_(__maybenull_impl_notref, __bytecount_impl(size)))
  377. // Annotations for output reference to pointer parameters.
  378. #define _Outref_ _SAL2_Source_(_Outref_, (), _Out_impl_ _Post_notnull_)
  379. #define _Outref_result_maybenull_ _SAL2_Source_(_Outref_result_maybenull_, (), _Pre2_impl_(__notnull_impl_notref, __cap_c_one_notref_impl) _Post_maybenull_ _Post_valid_impl_)
  380. #define _Outref_result_buffer_(size) _SAL2_Source_(_Outref_result_buffer_, (size), _Outref_ _Post1_impl_(__cap_impl(size)))
  381. #define _Outref_result_bytebuffer_(size) _SAL2_Source_(_Outref_result_bytebuffer_, (size), _Outref_ _Post1_impl_(__bytecap_impl(size)))
  382. #define _Outref_result_buffer_to_(size, count) _SAL2_Source_(_Outref_result_buffer_to_, (size, count), _Outref_result_buffer_(size) _Post1_impl_(__count_impl(count)))
  383. #define _Outref_result_bytebuffer_to_(size, count) _SAL2_Source_(_Outref_result_bytebuffer_to_, (size, count), _Outref_result_bytebuffer_(size) _Post1_impl_(__bytecount_impl(count)))
  384. #define _Outref_result_buffer_all_(size) _SAL2_Source_(_Outref_result_buffer_all_, (size), _Outref_result_buffer_to_(size, _Old_(size)))
  385. #define _Outref_result_bytebuffer_all_(size) _SAL2_Source_(_Outref_result_bytebuffer_all_, (size), _Outref_result_bytebuffer_to_(size, _Old_(size)))
  386. #define _Outref_result_buffer_maybenull_(size) _SAL2_Source_(_Outref_result_buffer_maybenull_, (size), _Outref_result_maybenull_ _Post1_impl_(__cap_impl(size)))
  387. #define _Outref_result_bytebuffer_maybenull_(size) _SAL2_Source_(_Outref_result_bytebuffer_maybenull_, (size), _Outref_result_maybenull_ _Post1_impl_(__bytecap_impl(size)))
  388. #define _Outref_result_buffer_to_maybenull_(size, count) _SAL2_Source_(_Outref_result_buffer_to_maybenull_, (size, count), _Outref_result_buffer_maybenull_(size) _Post1_impl_(__count_impl(count)))
  389. #define _Outref_result_bytebuffer_to_maybenull_(size, count) _SAL2_Source_(_Outref_result_bytebuffer_to_maybenull_, (size, count), _Outref_result_bytebuffer_maybenull_(size) _Post1_impl_(__bytecount_impl(count)))
  390. #define _Outref_result_buffer_all_maybenull_(size) _SAL2_Source_(_Outref_result_buffer_all_maybenull_, (size), _Outref_result_buffer_to_maybenull_(size, _Old_(size)))
  391. #define _Outref_result_bytebuffer_all_maybenull_(size) _SAL2_Source_(_Outref_result_bytebuffer_all_maybenull_, (size), _Outref_result_bytebuffer_to_maybenull_(size, _Old_(size)))
  392. // Annotations for output reference to pointer parameters that guarantee
  393. // that the pointer is set to NULL on failure.
  394. #define _Outref_result_nullonfailure_ _SAL2_Source_(_Outref_result_nullonfailure_, (), _Outref_ _On_failure_(_Post_null_))
  395. // Generic annotations to set output value of a by-pointer or by-reference parameter to null/zero on failure.
  396. #define _Result_nullonfailure_ _SAL2_Source_(_Result_nullonfailure_, (), _On_failure_(_Notref_impl_ _Deref_impl_ _Post_null_))
  397. #define _Result_zeroonfailure_ _SAL2_Source_(_Result_zeroonfailure_, (), _On_failure_(_Notref_impl_ _Deref_impl_ _Out_range_(==, 0)))
  398. // return values -------------------------------
  399. //
  400. // _Ret_ annotations
  401. //
  402. // describing conditions that hold for return values after the call
  403. // e.g. _Ret_z_ CString::operator const WCHAR*() const throw();
  404. #define _Ret_z_ _SAL2_Source_(_Ret_z_, (), _Ret2_impl_(__notnull_impl, __zterm_impl) _Ret_valid_impl_)
  405. #define _Ret_maybenull_z_ _SAL2_Source_(_Ret_maybenull_z_, (), _Ret2_impl_(__maybenull_impl,__zterm_impl) _Ret_valid_impl_)
  406. // used with allocated but not yet initialized objects
  407. #define _Ret_notnull_ _SAL2_Source_(_Ret_notnull_, (), _Ret1_impl_(__notnull_impl))
  408. #define _Ret_maybenull_ _SAL2_Source_(_Ret_maybenull_, (), _Ret1_impl_(__maybenull_impl))
  409. #define _Ret_null_ _SAL2_Source_(_Ret_null_, (), _Ret1_impl_(__null_impl))
  410. // used with allocated and initialized objects
  411. // returns single valid object
  412. #define _Ret_valid_ _SAL2_Source_(_Ret_valid_, (), _Ret1_impl_(__notnull_impl_notref) _Ret_valid_impl_)
  413. // returns pointer to initialized buffer of specified size
  414. #define _Ret_writes_(size) _SAL2_Source_(_Ret_writes_, (size), _Ret2_impl_(__notnull_impl, __count_impl(size)) _Ret_valid_impl_)
  415. #define _Ret_writes_z_(size) _SAL2_Source_(_Ret_writes_z_, (size), _Ret3_impl_(__notnull_impl, __count_impl(size), __zterm_impl) _Ret_valid_impl_)
  416. #define _Ret_writes_bytes_(size) _SAL2_Source_(_Ret_writes_bytes_, (size), _Ret2_impl_(__notnull_impl, __bytecount_impl(size)) _Ret_valid_impl_)
  417. #define _Ret_writes_maybenull_(size) _SAL2_Source_(_Ret_writes_maybenull_, (size), _Ret2_impl_(__maybenull_impl,__count_impl(size)) _Ret_valid_impl_)
  418. #define _Ret_writes_maybenull_z_(size) _SAL2_Source_(_Ret_writes_maybenull_z_, (size), _Ret3_impl_(__maybenull_impl,__count_impl(size),__zterm_impl) _Ret_valid_impl_)
  419. #define _Ret_writes_bytes_maybenull_(size) _SAL2_Source_(_Ret_writes_bytes_maybenull_, (size), _Ret2_impl_(__maybenull_impl,__bytecount_impl(size)) _Ret_valid_impl_)
  420. // returns pointer to partially initialized buffer, with total size 'size' and initialized size 'count'
  421. #define _Ret_writes_to_(size,count) _SAL2_Source_(_Ret_writes_to_, (size,count), _Ret3_impl_(__notnull_impl, __cap_impl(size), __count_impl(count)) _Ret_valid_impl_)
  422. #define _Ret_writes_bytes_to_(size,count) _SAL2_Source_(_Ret_writes_bytes_to_, (size,count), _Ret3_impl_(__notnull_impl, __bytecap_impl(size), __bytecount_impl(count)) _Ret_valid_impl_)
  423. #define _Ret_writes_to_maybenull_(size,count) _SAL2_Source_(_Ret_writes_to_maybenull_, (size,count), _Ret3_impl_(__maybenull_impl, __cap_impl(size), __count_impl(count)) _Ret_valid_impl_)
  424. #define _Ret_writes_bytes_to_maybenull_(size,count) _SAL2_Source_(_Ret_writes_bytes_to_maybenull_, (size,count), _Ret3_impl_(__maybenull_impl, __bytecap_impl(size), __bytecount_impl(count)) _Ret_valid_impl_)
  425. // Annotations for strict type checking
  426. #define _Points_to_data_ _SAL2_Source_(_Points_to_data_, (), _Pre_ _Points_to_data_impl_)
  427. #define _Literal_ _SAL2_Source_(_Literal_, (), _Pre_ _Literal_impl_)
  428. #define _Notliteral_ _SAL2_Source_(_Notliteral_, (), _Pre_ _Notliteral_impl_)
  429. // Check the return value of a function e.g. _Check_return_ ErrorCode Foo();
  430. #define _Check_return_ _SAL2_Source_(_Check_return_, (), _Check_return_impl_)
  431. #define _Must_inspect_result_ _SAL2_Source_(_Must_inspect_result_, (), _Must_inspect_impl_ _Check_return_impl_)
  432. // e.g. MyPrintF( _Printf_format_string_ const WCHAR* wzFormat, ... );
  433. #define _Printf_format_string_ _SAL2_Source_(_Printf_format_string_, (), _Printf_format_string_impl_)
  434. #define _Scanf_format_string_ _SAL2_Source_(_Scanf_format_string_, (), _Scanf_format_string_impl_)
  435. #define _Scanf_s_format_string_ _SAL2_Source_(_Scanf_s_format_string_, (), _Scanf_s_format_string_impl_)
  436. #define _Format_string_impl_(kind,where) _SA_annotes2(SAL_IsFormatString2, kind, where)
  437. #define _Printf_format_string_params_(x) _SAL2_Source_(_Printf_format_string_params_, (x), _Format_string_impl_("printf", x))
  438. #define _Scanf_format_string_params_(x) _SAL2_Source_(_Scanf_format_string_params_, (x), _Format_string_impl_("scanf", x))
  439. #define _Scanf_s_format_string_params_(x) _SAL2_Source_(_Scanf_s_format_string_params_, (x), _Format_string_impl_("scanf_s", x))
  440. // annotations to express value of integral or pointer parameter
  441. #define _In_range_(lb,ub) _SAL2_Source_(_In_range_, (lb,ub), _In_range_impl_(lb,ub))
  442. #define _Out_range_(lb,ub) _SAL2_Source_(_Out_range_, (lb,ub), _Out_range_impl_(lb,ub))
  443. #define _Ret_range_(lb,ub) _SAL2_Source_(_Ret_range_, (lb,ub), _Ret_range_impl_(lb,ub))
  444. #define _Deref_in_range_(lb,ub) _SAL2_Source_(_Deref_in_range_, (lb,ub), _Deref_in_range_impl_(lb,ub))
  445. #define _Deref_out_range_(lb,ub) _SAL2_Source_(_Deref_out_range_, (lb,ub), _Deref_out_range_impl_(lb,ub))
  446. #define _Deref_ret_range_(lb,ub) _SAL2_Source_(_Deref_ret_range_, (lb,ub), _Deref_ret_range_impl_(lb,ub))
  447. #define _Pre_equal_to_(expr) _SAL2_Source_(_Pre_equal_to_, (expr), _In_range_(==, expr))
  448. #define _Post_equal_to_(expr) _SAL2_Source_(_Post_equal_to_, (expr), _Out_range_(==, expr))
  449. // annotation to express that a value (usually a field of a mutable class)
  450. // is not changed by a function call
  451. #define _Unchanged_(e) _SAL2_Source_(_Unchanged_, (e), _At_(e, _Post_equal_to_(_Old_(e)) _Const_))
  452. // Annotations to allow expressing generalized pre and post conditions.
  453. // 'cond' may be any valid SAL expression that is considered to be true as a precondition
  454. // or postcondition (respsectively).
  455. #define _Pre_satisfies_(cond) _SAL2_Source_(_Pre_satisfies_, (cond), _Pre_satisfies_impl_(cond))
  456. #define _Post_satisfies_(cond) _SAL2_Source_(_Post_satisfies_, (cond), _Post_satisfies_impl_(cond))
  457. // Annotations to express struct, class and field invariants
  458. #define _Struct_size_bytes_(size) _SAL2_Source_(_Struct_size_bytes_, (size), _Writable_bytes_(size))
  459. #define _Field_size_(size) _SAL2_Source_(_Field_size_, (size), _Notnull_ _Writable_elements_(size))
  460. #define _Field_size_opt_(size) _SAL2_Source_(_Field_size_opt_, (size), _Maybenull_ _Writable_elements_(size))
  461. #define _Field_size_part_(size, count) _SAL2_Source_(_Field_size_part_, (size, count), _Notnull_ _Writable_elements_(size) _Readable_elements_(count))
  462. #define _Field_size_part_opt_(size, count) _SAL2_Source_(_Field_size_part_opt_, (size, count), _Maybenull_ _Writable_elements_(size) _Readable_elements_(count))
  463. #define _Field_size_full_(size) _SAL2_Source_(_Field_size_full_, (size), _Field_size_part_(size, size))
  464. #define _Field_size_full_opt_(size) _SAL2_Source_(_Field_size_full_opt_, (size), _Field_size_part_opt_(size, size))
  465. #define _Field_size_bytes_(size) _SAL2_Source_(_Field_size_bytes_, (size), _Notnull_ _Writable_bytes_(size))
  466. #define _Field_size_bytes_opt_(size) _SAL2_Source_(_Field_size_bytes_opt_, (size), _Maybenull_ _Writable_bytes_(size))
  467. #define _Field_size_bytes_part_(size, count) _SAL2_Source_(_Field_size_bytes_part_, (size, count), _Notnull_ _Writable_bytes_(size) _Readable_bytes_(count))
  468. #define _Field_size_bytes_part_opt_(size, count) _SAL2_Source_(_Field_size_bytes_part_opt_, (size, count), _Maybenull_ _Writable_bytes_(size) _Readable_bytes_(count))
  469. #define _Field_size_bytes_full_(size) _SAL2_Source_(_Field_size_bytes_full_, (size), _Field_size_bytes_part_(size, size))
  470. #define _Field_size_bytes_full_opt_(size) _SAL2_Source_(_Field_size_bytes_full_opt_, (size), _Field_size_bytes_part_opt_(size, size))
  471. #define _Field_z_ _SAL2_Source_(_Field_z_, (), _Null_terminated_)
  472. #define _Field_range_(min,max) _SAL2_Source_(_Field_range_, (min,max), _Field_range_impl_(min,max))
  473. //============================================================================
  474. // _Pre_\_Post_ Layer:
  475. //============================================================================
  476. //
  477. // Raw Pre/Post for declaring custom pre/post conditions
  478. //
  479. #define _Pre_ _Pre_impl_
  480. #define _Post_ _Post_impl_
  481. //
  482. // Validity property
  483. //
  484. #define _Valid_ _Valid_impl_
  485. #define _Notvalid_ _Notvalid_impl_
  486. #define _Maybevalid_ _Maybevalid_impl_
  487. //
  488. // Buffer size properties
  489. //
  490. // Expressing buffer sizes without specifying pre or post condition
  491. #define _Readable_bytes_(size) _SAL2_Source_(_Readable_bytes_, (size), _Readable_bytes_impl_(size))
  492. #define _Readable_elements_(size) _SAL2_Source_(_Readable_elements_, (size), _Readable_elements_impl_(size))
  493. #define _Writable_bytes_(size) _SAL2_Source_(_Writable_bytes_, (size), _Writable_bytes_impl_(size))
  494. #define _Writable_elements_(size) _SAL2_Source_(_Writable_elements_, (size), _Writable_elements_impl_(size))
  495. #define _Null_terminated_ _SAL2_Source_(_Null_terminated_, (), _Null_terminated_impl_)
  496. #define _NullNull_terminated_ _SAL2_Source_(_NullNull_terminated_, (), _NullNull_terminated_impl_)
  497. // Expressing buffer size as pre or post condition
  498. #define _Pre_readable_size_(size) _SAL2_Source_(_Pre_readable_size_, (size), _Pre1_impl_(__count_impl(size)) _Pre_valid_impl_)
  499. #define _Pre_writable_size_(size) _SAL2_Source_(_Pre_writable_size_, (size), _Pre1_impl_(__cap_impl(size)))
  500. #define _Pre_readable_byte_size_(size) _SAL2_Source_(_Pre_readable_byte_size_, (size), _Pre1_impl_(__bytecount_impl(size)) _Pre_valid_impl_)
  501. #define _Pre_writable_byte_size_(size) _SAL2_Source_(_Pre_writable_byte_size_, (size), _Pre1_impl_(__bytecap_impl(size)))
  502. #define _Post_readable_size_(size) _SAL2_Source_(_Post_readable_size_, (size), _Post1_impl_(__count_impl(size)) _Post_valid_impl_)
  503. #define _Post_writable_size_(size) _SAL2_Source_(_Post_writable_size_, (size), _Post1_impl_(__cap_impl(size)))
  504. #define _Post_readable_byte_size_(size) _SAL2_Source_(_Post_readable_byte_size_, (size), _Post1_impl_(__bytecount_impl(size)) _Post_valid_impl_)
  505. #define _Post_writable_byte_size_(size) _SAL2_Source_(_Post_writable_byte_size_, (size), _Post1_impl_(__bytecap_impl(size)))
  506. //
  507. // Pointer null-ness properties
  508. //
  509. #define _Null_ _Null_impl_
  510. #define _Notnull_ _Notnull_impl_
  511. #define _Maybenull_ _Maybenull_impl_
  512. //
  513. // _Pre_ annotations ---
  514. //
  515. // describing conditions that must be met before the call of the function
  516. // e.g. int strlen( _Pre_z_ const char* sz );
  517. // buffer is a zero terminated string
  518. #define _Pre_z_ _SAL2_Source_(_Pre_z_, (), _Pre1_impl_(__zterm_impl) _Pre_valid_impl_)
  519. // valid size unknown or indicated by type (e.g.:LPSTR)
  520. #define _Pre_valid_ _SAL2_Source_(_Pre_valid_, (), _Pre1_impl_(__notnull_impl_notref) _Pre_valid_impl_)
  521. #define _Pre_opt_valid_ _SAL2_Source_(_Pre_opt_valid_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre_valid_impl_)
  522. #define _Pre_invalid_ _SAL2_Source_(_Pre_invalid_, (), _Deref_pre1_impl_(__notvalid_impl))
  523. // Overrides recursive valid when some field is not yet initialized when using _Inout_
  524. #define _Pre_unknown_ _SAL2_Source_(_Pre_unknown_, (), _Pre1_impl_(__maybevalid_impl))
  525. // used with allocated but not yet initialized objects
  526. #define _Pre_notnull_ _SAL2_Source_(_Pre_notnull_, (), _Pre1_impl_(__notnull_impl_notref))
  527. #define _Pre_maybenull_ _SAL2_Source_(_Pre_maybenull_, (), _Pre1_impl_(__maybenull_impl_notref))
  528. #define _Pre_null_ _SAL2_Source_(_Pre_null_, (), _Pre1_impl_(__null_impl_notref))
  529. //
  530. // _Post_ annotations ---
  531. //
  532. // describing conditions that hold after the function call
  533. // void CopyStr( _In_z_ const char* szFrom, _Pre_cap_(cch) _Post_z_ char* szFrom, size_t cchFrom );
  534. // buffer will be a zero-terminated string after the call
  535. #define _Post_z_ _SAL2_Source_(_Post_z_, (), _Post1_impl_(__zterm_impl) _Post_valid_impl_)
  536. // e.g. HRESULT InitStruct( _Post_valid_ Struct* pobj );
  537. #define _Post_valid_ _SAL2_Source_(_Post_valid_, (), _Post_valid_impl_)
  538. #define _Post_invalid_ _SAL2_Source_(_Post_invalid_, (), _Deref_post1_impl_(__notvalid_impl))
  539. // e.g. void free( _Post_ptr_invalid_ void* pv );
  540. #define _Post_ptr_invalid_ _SAL2_Source_(_Post_ptr_invalid_, (), _Post1_impl_(__notvalid_impl))
  541. // e.g. void ThrowExceptionIfNull( _Post_notnull_ const void* pv );
  542. #define _Post_notnull_ _SAL2_Source_(_Post_notnull_, (), _Post1_impl_(__notnull_impl))
  543. // e.g. HRESULT GetObject(_Outptr_ _On_failure_(_At_(*p, _Post_null_)) T **p);
  544. #define _Post_null_ _SAL2_Source_(_Post_null_, (), _Post1_impl_(__null_impl))
  545. #define _Post_maybenull_ _SAL2_Source_(_Post_maybenull_, (), _Post1_impl_(__maybenull_impl))
  546. #define _Prepost_z_ _SAL2_Source_(_Prepost_z_, (), _Pre_z_ _Post_z_)
  547. // #pragma region Input Buffer SAL 1 compatibility macros
  548. /*==========================================================================
  549. This section contains definitions for macros defined for VS2010 and earlier.
  550. Usage of these macros is still supported, but the SAL 2 macros defined above
  551. are recommended instead. This comment block is retained to assist in
  552. understanding SAL that still uses the older syntax.
  553. The macros are defined in 3 layers:
  554. _In_\_Out_ Layer:
  555. ----------------
  556. This layer provides the highest abstraction and its macros should be used
  557. in most cases. Its macros start with _In_, _Out_ or _Inout_. For the
  558. typical case they provide the most concise annotations.
  559. _Pre_\_Post_ Layer:
  560. ------------------
  561. The macros of this layer only should be used when there is no suitable macro
  562. in the _In_\_Out_ layer. Its macros start with _Pre_, _Post_, _Ret_,
  563. _Deref_pre_ _Deref_post_ and _Deref_ret_. This layer provides the most
  564. flexibility for annotations.
  565. Implementation Abstraction Layer:
  566. --------------------------------
  567. Macros from this layer should never be used directly. The layer only exists
  568. to hide the implementation of the annotation macros.
  569. Annotation Syntax:
  570. |--------------|----------|----------------|-----------------------------|
  571. | Usage | Nullness | ZeroTerminated | Extent |
  572. |--------------|----------|----------------|-----------------------------|
  573. | _In_ | <> | <> | <> |
  574. | _Out_ | opt_ | z_ | [byte]cap_[c_|x_]( size ) |
  575. | _Inout_ | | | [byte]count_[c_|x_]( size ) |
  576. | _Deref_out_ | | | ptrdiff_cap_( ptr ) |
  577. |--------------| | | ptrdiff_count_( ptr ) |
  578. | _Ret_ | | | |
  579. | _Deref_ret_ | | | |
  580. |--------------| | | |
  581. | _Pre_ | | | |
  582. | _Post_ | | | |
  583. | _Deref_pre_ | | | |
  584. | _Deref_post_ | | | |
  585. |--------------|----------|----------------|-----------------------------|
  586. Usage:
  587. -----
  588. _In_, _Out_, _Inout_, _Pre_, _Post_, _Deref_pre_, _Deref_post_ are for
  589. formal parameters.
  590. _Ret_, _Deref_ret_ must be used for return values.
  591. Nullness:
  592. --------
  593. If the pointer can be NULL the annotation contains _opt. If the macro
  594. does not contain '_opt' the pointer may not be NULL.
  595. String Type:
  596. -----------
  597. _z: NullTerminated string
  598. for _In_ parameters the buffer must have the specified stringtype before the call
  599. for _Out_ parameters the buffer must have the specified stringtype after the call
  600. for _Inout_ parameters both conditions apply
  601. Extent Syntax:
  602. |------|---------------|---------------|
  603. | Unit | Writ\Readable | Argument Type |
  604. |------|---------------|---------------|
  605. | <> | cap_ | <> |
  606. | byte | count_ | c_ |
  607. | | | x_ |
  608. |------|---------------|---------------|
  609. 'cap' (capacity) describes the writable size of the buffer and is typically used
  610. with _Out_. The default unit is elements. Use 'bytecap' if the size is given in bytes
  611. 'count' describes the readable size of the buffer and is typically used with _In_.
  612. The default unit is elements. Use 'bytecount' if the size is given in bytes.
  613. Argument syntax for cap_, bytecap_, count_, bytecount_:
  614. (<parameter>|return)[+n] e.g. cch, return, cb+2
  615. If the buffer size is a constant expression use the c_ postfix.
  616. E.g. cap_c_(20), count_c_(MAX_PATH), bytecount_c_(16)
  617. If the buffer size is given by a limiting pointer use the ptrdiff_ versions
  618. of the macros.
  619. If the buffer size is neither a parameter nor a constant expression use the x_
  620. postfix. e.g. bytecount_x_(num*size) x_ annotations accept any arbitrary string.
  621. No analysis can be done for x_ annotations but they at least tell the tool that
  622. the buffer has some sort of extent description. x_ annotations might be supported
  623. by future compiler versions.
  624. ============================================================================*/
  625. // e.g. void SetCharRange( _In_count_(cch) const char* rgch, size_t cch )
  626. // valid buffer extent described by another parameter
  627. #define _In_count_(size) _SAL1_1_Source_(_In_count_, (size), _Pre_count_(size) _Deref_pre_readonly_)
  628. #define _In_opt_count_(size) _SAL1_1_Source_(_In_opt_count_, (size), _Pre_opt_count_(size) _Deref_pre_readonly_)
  629. #define _In_bytecount_(size) _SAL1_1_Source_(_In_bytecount_, (size), _Pre_bytecount_(size) _Deref_pre_readonly_)
  630. #define _In_opt_bytecount_(size) _SAL1_1_Source_(_In_opt_bytecount_, (size), _Pre_opt_bytecount_(size) _Deref_pre_readonly_)
  631. // valid buffer extent described by a constant extression
  632. #define _In_count_c_(size) _SAL1_1_Source_(_In_count_c_, (size), _Pre_count_c_(size) _Deref_pre_readonly_)
  633. #define _In_opt_count_c_(size) _SAL1_1_Source_(_In_opt_count_c_, (size), _Pre_opt_count_c_(size) _Deref_pre_readonly_)
  634. #define _In_bytecount_c_(size) _SAL1_1_Source_(_In_bytecount_c_, (size), _Pre_bytecount_c_(size) _Deref_pre_readonly_)
  635. #define _In_opt_bytecount_c_(size) _SAL1_1_Source_(_In_opt_bytecount_c_, (size), _Pre_opt_bytecount_c_(size) _Deref_pre_readonly_)
  636. // nullterminated 'input' buffers with given size
  637. // e.g. void SetCharRange( _In_count_(cch) const char* rgch, size_t cch )
  638. // nullterminated valid buffer extent described by another parameter
  639. #define _In_z_count_(size) _SAL1_1_Source_(_In_z_count_, (size), _Pre_z_ _Pre_count_(size) _Deref_pre_readonly_)
  640. #define _In_opt_z_count_(size) _SAL1_1_Source_(_In_opt_z_count_, (size), _Pre_opt_z_ _Pre_opt_count_(size) _Deref_pre_readonly_)
  641. #define _In_z_bytecount_(size) _SAL1_1_Source_(_In_z_bytecount_, (size), _Pre_z_ _Pre_bytecount_(size) _Deref_pre_readonly_)
  642. #define _In_opt_z_bytecount_(size) _SAL1_1_Source_(_In_opt_z_bytecount_, (size), _Pre_opt_z_ _Pre_opt_bytecount_(size) _Deref_pre_readonly_)
  643. // nullterminated valid buffer extent described by a constant extression
  644. #define _In_z_count_c_(size) _SAL1_1_Source_(_In_z_count_c_, (size), _Pre_z_ _Pre_count_c_(size) _Deref_pre_readonly_)
  645. #define _In_opt_z_count_c_(size) _SAL1_1_Source_(_In_opt_z_count_c_, (size), _Pre_opt_z_ _Pre_opt_count_c_(size) _Deref_pre_readonly_)
  646. #define _In_z_bytecount_c_(size) _SAL1_1_Source_(_In_z_bytecount_c_, (size), _Pre_z_ _Pre_bytecount_c_(size) _Deref_pre_readonly_)
  647. #define _In_opt_z_bytecount_c_(size) _SAL1_1_Source_(_In_opt_z_bytecount_c_, (size), _Pre_opt_z_ _Pre_opt_bytecount_c_(size) _Deref_pre_readonly_)
  648. // buffer capacity is described by another pointer
  649. // e.g. void Foo( _In_ptrdiff_count_(pchMax) const char* pch, const char* pchMax ) { while pch < pchMax ) pch++; }
  650. #define _In_ptrdiff_count_(size) _SAL1_1_Source_(_In_ptrdiff_count_, (size), _Pre_ptrdiff_count_(size) _Deref_pre_readonly_)
  651. #define _In_opt_ptrdiff_count_(size) _SAL1_1_Source_(_In_opt_ptrdiff_count_, (size), _Pre_opt_ptrdiff_count_(size) _Deref_pre_readonly_)
  652. // 'x' version for complex expressions that are not supported by the current compiler version
  653. // e.g. void Set3ColMatrix( _In_count_x_(3*cRows) const Elem* matrix, int cRows );
  654. #define _In_count_x_(size) _SAL1_1_Source_(_In_count_x_, (size), _Pre_count_x_(size) _Deref_pre_readonly_)
  655. #define _In_opt_count_x_(size) _SAL1_1_Source_(_In_opt_count_x_, (size), _Pre_opt_count_x_(size) _Deref_pre_readonly_)
  656. #define _In_bytecount_x_(size) _SAL1_1_Source_(_In_bytecount_x_, (size), _Pre_bytecount_x_(size) _Deref_pre_readonly_)
  657. #define _In_opt_bytecount_x_(size) _SAL1_1_Source_(_In_opt_bytecount_x_, (size), _Pre_opt_bytecount_x_(size) _Deref_pre_readonly_)
  658. // 'out' with buffer size
  659. // e.g. void GetIndeces( _Out_cap_(cIndeces) int* rgIndeces, size_t cIndices );
  660. // buffer capacity is described by another parameter
  661. #define _Out_cap_(size) _SAL1_1_Source_(_Out_cap_, (size), _Pre_cap_(size) _Post_valid_impl_)
  662. #define _Out_opt_cap_(size) _SAL1_1_Source_(_Out_opt_cap_, (size), _Pre_opt_cap_(size) _Post_valid_impl_)
  663. #define _Out_bytecap_(size) _SAL1_1_Source_(_Out_bytecap_, (size), _Pre_bytecap_(size) _Post_valid_impl_)
  664. #define _Out_opt_bytecap_(size) _SAL1_1_Source_(_Out_opt_bytecap_, (size), _Pre_opt_bytecap_(size) _Post_valid_impl_)
  665. // buffer capacity is described by a constant expression
  666. #define _Out_cap_c_(size) _SAL1_1_Source_(_Out_cap_c_, (size), _Pre_cap_c_(size) _Post_valid_impl_)
  667. #define _Out_opt_cap_c_(size) _SAL1_1_Source_(_Out_opt_cap_c_, (size), _Pre_opt_cap_c_(size) _Post_valid_impl_)
  668. #define _Out_bytecap_c_(size) _SAL1_1_Source_(_Out_bytecap_c_, (size), _Pre_bytecap_c_(size) _Post_valid_impl_)
  669. #define _Out_opt_bytecap_c_(size) _SAL1_1_Source_(_Out_opt_bytecap_c_, (size), _Pre_opt_bytecap_c_(size) _Post_valid_impl_)
  670. // buffer capacity is described by another parameter multiplied by a constant expression
  671. #define _Out_cap_m_(mult,size) _SAL1_1_Source_(_Out_cap_m_, (mult,size), _Pre_cap_m_(mult,size) _Post_valid_impl_)
  672. #define _Out_opt_cap_m_(mult,size) _SAL1_1_Source_(_Out_opt_cap_m_, (mult,size), _Pre_opt_cap_m_(mult,size) _Post_valid_impl_)
  673. #define _Out_z_cap_m_(mult,size) _SAL1_1_Source_(_Out_z_cap_m_, (mult,size), _Pre_cap_m_(mult,size) _Post_valid_impl_ _Post_z_)
  674. #define _Out_opt_z_cap_m_(mult,size) _SAL1_1_Source_(_Out_opt_z_cap_m_, (mult,size), _Pre_opt_cap_m_(mult,size) _Post_valid_impl_ _Post_z_)
  675. // buffer capacity is described by another pointer
  676. // e.g. void Foo( _Out_ptrdiff_cap_(pchMax) char* pch, const char* pchMax ) { while pch < pchMax ) pch++; }
  677. #define _Out_ptrdiff_cap_(size) _SAL1_1_Source_(_Out_ptrdiff_cap_, (size), _Pre_ptrdiff_cap_(size) _Post_valid_impl_)
  678. #define _Out_opt_ptrdiff_cap_(size) _SAL1_1_Source_(_Out_opt_ptrdiff_cap_, (size), _Pre_opt_ptrdiff_cap_(size) _Post_valid_impl_)
  679. // buffer capacity is described by a complex expression
  680. #define _Out_cap_x_(size) _SAL1_1_Source_(_Out_cap_x_, (size), _Pre_cap_x_(size) _Post_valid_impl_)
  681. #define _Out_opt_cap_x_(size) _SAL1_1_Source_(_Out_opt_cap_x_, (size), _Pre_opt_cap_x_(size) _Post_valid_impl_)
  682. #define _Out_bytecap_x_(size) _SAL1_1_Source_(_Out_bytecap_x_, (size), _Pre_bytecap_x_(size) _Post_valid_impl_)
  683. #define _Out_opt_bytecap_x_(size) _SAL1_1_Source_(_Out_opt_bytecap_x_, (size), _Pre_opt_bytecap_x_(size) _Post_valid_impl_)
  684. // a zero terminated string is filled into a buffer of given capacity
  685. // e.g. void CopyStr( _In_z_ const char* szFrom, _Out_z_cap_(cchTo) char* szTo, size_t cchTo );
  686. // buffer capacity is described by another parameter
  687. #define _Out_z_cap_(size) _SAL1_1_Source_(_Out_z_cap_, (size), _Pre_cap_(size) _Post_valid_impl_ _Post_z_)
  688. #define _Out_opt_z_cap_(size) _SAL1_1_Source_(_Out_opt_z_cap_, (size), _Pre_opt_cap_(size) _Post_valid_impl_ _Post_z_)
  689. #define _Out_z_bytecap_(size) _SAL1_1_Source_(_Out_z_bytecap_, (size), _Pre_bytecap_(size) _Post_valid_impl_ _Post_z_)
  690. #define _Out_opt_z_bytecap_(size) _SAL1_1_Source_(_Out_opt_z_bytecap_, (size), _Pre_opt_bytecap_(size) _Post_valid_impl_ _Post_z_)
  691. // buffer capacity is described by a constant expression
  692. #define _Out_z_cap_c_(size) _SAL1_1_Source_(_Out_z_cap_c_, (size), _Pre_cap_c_(size) _Post_valid_impl_ _Post_z_)
  693. #define _Out_opt_z_cap_c_(size) _SAL1_1_Source_(_Out_opt_z_cap_c_, (size), _Pre_opt_cap_c_(size) _Post_valid_impl_ _Post_z_)
  694. #define _Out_z_bytecap_c_(size) _SAL1_1_Source_(_Out_z_bytecap_c_, (size), _Pre_bytecap_c_(size) _Post_valid_impl_ _Post_z_)
  695. #define _Out_opt_z_bytecap_c_(size) _SAL1_1_Source_(_Out_opt_z_bytecap_c_, (size), _Pre_opt_bytecap_c_(size) _Post_valid_impl_ _Post_z_)
  696. // buffer capacity is described by a complex expression
  697. #define _Out_z_cap_x_(size) _SAL1_1_Source_(_Out_z_cap_x_, (size), _Pre_cap_x_(size) _Post_valid_impl_ _Post_z_)
  698. #define _Out_opt_z_cap_x_(size) _SAL1_1_Source_(_Out_opt_z_cap_x_, (size), _Pre_opt_cap_x_(size) _Post_valid_impl_ _Post_z_)
  699. #define _Out_z_bytecap_x_(size) _SAL1_1_Source_(_Out_z_bytecap_x_, (size), _Pre_bytecap_x_(size) _Post_valid_impl_ _Post_z_)
  700. #define _Out_opt_z_bytecap_x_(size) _SAL1_1_Source_(_Out_opt_z_bytecap_x_, (size), _Pre_opt_bytecap_x_(size) _Post_valid_impl_ _Post_z_)
  701. // a zero terminated string is filled into a buffer of given capacity
  702. // e.g. size_t CopyCharRange( _In_count_(cchFrom) const char* rgchFrom, size_t cchFrom, _Out_cap_post_count_(cchTo,return)) char* rgchTo, size_t cchTo );
  703. #define _Out_cap_post_count_(cap,count) _SAL1_1_Source_(_Out_cap_post_count_, (cap,count), _Pre_cap_(cap) _Post_valid_impl_ _Post_count_(count))
  704. #define _Out_opt_cap_post_count_(cap,count) _SAL1_1_Source_(_Out_opt_cap_post_count_, (cap,count), _Pre_opt_cap_(cap) _Post_valid_impl_ _Post_count_(count))
  705. #define _Out_bytecap_post_bytecount_(cap,count) _SAL1_1_Source_(_Out_bytecap_post_bytecount_, (cap,count), _Pre_bytecap_(cap) _Post_valid_impl_ _Post_bytecount_(count))
  706. #define _Out_opt_bytecap_post_bytecount_(cap,count) _SAL1_1_Source_(_Out_opt_bytecap_post_bytecount_, (cap,count), _Pre_opt_bytecap_(cap) _Post_valid_impl_ _Post_bytecount_(count))
  707. // a zero terminated string is filled into a buffer of given capacity
  708. // e.g. size_t CopyStr( _In_z_ const char* szFrom, _Out_z_cap_post_count_(cchTo,return+1) char* szTo, size_t cchTo );
  709. #define _Out_z_cap_post_count_(cap,count) _SAL1_1_Source_(_Out_z_cap_post_count_, (cap,count), _Pre_cap_(cap) _Post_valid_impl_ _Post_z_count_(count))
  710. #define _Out_opt_z_cap_post_count_(cap,count) _SAL1_1_Source_(_Out_opt_z_cap_post_count_, (cap,count), _Pre_opt_cap_(cap) _Post_valid_impl_ _Post_z_count_(count))
  711. #define _Out_z_bytecap_post_bytecount_(cap,count) _SAL1_1_Source_(_Out_z_bytecap_post_bytecount_, (cap,count), _Pre_bytecap_(cap) _Post_valid_impl_ _Post_z_bytecount_(count))
  712. #define _Out_opt_z_bytecap_post_bytecount_(cap,count) _SAL1_1_Source_(_Out_opt_z_bytecap_post_bytecount_, (cap,count), _Pre_opt_bytecap_(cap) _Post_valid_impl_ _Post_z_bytecount_(count))
  713. // only use with dereferenced arguments e.g. '*pcch'
  714. #define _Out_capcount_(capcount) _SAL1_1_Source_(_Out_capcount_, (capcount), _Pre_cap_(capcount) _Post_valid_impl_ _Post_count_(capcount))
  715. #define _Out_opt_capcount_(capcount) _SAL1_1_Source_(_Out_opt_capcount_, (capcount), _Pre_opt_cap_(capcount) _Post_valid_impl_ _Post_count_(capcount))
  716. #define _Out_bytecapcount_(capcount) _SAL1_1_Source_(_Out_bytecapcount_, (capcount), _Pre_bytecap_(capcount) _Post_valid_impl_ _Post_bytecount_(capcount))
  717. #define _Out_opt_bytecapcount_(capcount) _SAL1_1_Source_(_Out_opt_bytecapcount_, (capcount), _Pre_opt_bytecap_(capcount) _Post_valid_impl_ _Post_bytecount_(capcount))
  718. #define _Out_capcount_x_(capcount) _SAL1_1_Source_(_Out_capcount_x_, (capcount), _Pre_cap_x_(capcount) _Post_valid_impl_ _Post_count_x_(capcount))
  719. #define _Out_opt_capcount_x_(capcount) _SAL1_1_Source_(_Out_opt_capcount_x_, (capcount), _Pre_opt_cap_x_(capcount) _Post_valid_impl_ _Post_count_x_(capcount))
  720. #define _Out_bytecapcount_x_(capcount) _SAL1_1_Source_(_Out_bytecapcount_x_, (capcount), _Pre_bytecap_x_(capcount) _Post_valid_impl_ _Post_bytecount_x_(capcount))
  721. #define _Out_opt_bytecapcount_x_(capcount) _SAL1_1_Source_(_Out_opt_bytecapcount_x_, (capcount), _Pre_opt_bytecap_x_(capcount) _Post_valid_impl_ _Post_bytecount_x_(capcount))
  722. // e.g. GetString( _Out_z_capcount_(*pLen+1) char* sz, size_t* pLen );
  723. #define _Out_z_capcount_(capcount) _SAL1_1_Source_(_Out_z_capcount_, (capcount), _Pre_cap_(capcount) _Post_valid_impl_ _Post_z_count_(capcount))
  724. #define _Out_opt_z_capcount_(capcount) _SAL1_1_Source_(_Out_opt_z_capcount_, (capcount), _Pre_opt_cap_(capcount) _Post_valid_impl_ _Post_z_count_(capcount))
  725. #define _Out_z_bytecapcount_(capcount) _SAL1_1_Source_(_Out_z_bytecapcount_, (capcount), _Pre_bytecap_(capcount) _Post_valid_impl_ _Post_z_bytecount_(capcount))
  726. #define _Out_opt_z_bytecapcount_(capcount) _SAL1_1_Source_(_Out_opt_z_bytecapcount_, (capcount), _Pre_opt_bytecap_(capcount) _Post_valid_impl_ _Post_z_bytecount_(capcount))
  727. // 'inout' buffers with initialized elements before and after the call
  728. // e.g. void ModifyIndices( _Inout_count_(cIndices) int* rgIndeces, size_t cIndices );
  729. #define _Inout_count_(size) _SAL1_1_Source_(_Inout_count_, (size), _Prepost_count_(size))
  730. #define _Inout_opt_count_(size) _SAL1_1_Source_(_Inout_opt_count_, (size), _Prepost_opt_count_(size))
  731. #define _Inout_bytecount_(size) _SAL1_1_Source_(_Inout_bytecount_, (size), _Prepost_bytecount_(size))
  732. #define _Inout_opt_bytecount_(size) _SAL1_1_Source_(_Inout_opt_bytecount_, (size), _Prepost_opt_bytecount_(size))
  733. #define _Inout_count_c_(size) _SAL1_1_Source_(_Inout_count_c_, (size), _Prepost_count_c_(size))
  734. #define _Inout_opt_count_c_(size) _SAL1_1_Source_(_Inout_opt_count_c_, (size), _Prepost_opt_count_c_(size))
  735. #define _Inout_bytecount_c_(size) _SAL1_1_Source_(_Inout_bytecount_c_, (size), _Prepost_bytecount_c_(size))
  736. #define _Inout_opt_bytecount_c_(size) _SAL1_1_Source_(_Inout_opt_bytecount_c_, (size), _Prepost_opt_bytecount_c_(size))
  737. // nullterminated 'inout' buffers with initialized elements before and after the call
  738. // e.g. void ModifyIndices( _Inout_count_(cIndices) int* rgIndeces, size_t cIndices );
  739. #define _Inout_z_count_(size) _SAL1_1_Source_(_Inout_z_count_, (size), _Prepost_z_ _Prepost_count_(size))
  740. #define _Inout_opt_z_count_(size) _SAL1_1_Source_(_Inout_opt_z_count_, (size), _Prepost_z_ _Prepost_opt_count_(size))
  741. #define _Inout_z_bytecount_(size) _SAL1_1_Source_(_Inout_z_bytecount_, (size), _Prepost_z_ _Prepost_bytecount_(size))
  742. #define _Inout_opt_z_bytecount_(size) _SAL1_1_Source_(_Inout_opt_z_bytecount_, (size), _Prepost_z_ _Prepost_opt_bytecount_(size))
  743. #define _Inout_z_count_c_(size) _SAL1_1_Source_(_Inout_z_count_c_, (size), _Prepost_z_ _Prepost_count_c_(size))
  744. #define _Inout_opt_z_count_c_(size) _SAL1_1_Source_(_Inout_opt_z_count_c_, (size), _Prepost_z_ _Prepost_opt_count_c_(size))
  745. #define _Inout_z_bytecount_c_(size) _SAL1_1_Source_(_Inout_z_bytecount_c_, (size), _Prepost_z_ _Prepost_bytecount_c_(size))
  746. #define _Inout_opt_z_bytecount_c_(size) _SAL1_1_Source_(_Inout_opt_z_bytecount_c_, (size), _Prepost_z_ _Prepost_opt_bytecount_c_(size))
  747. #define _Inout_ptrdiff_count_(size) _SAL1_1_Source_(_Inout_ptrdiff_count_, (size), _Pre_ptrdiff_count_(size))
  748. #define _Inout_opt_ptrdiff_count_(size) _SAL1_1_Source_(_Inout_opt_ptrdiff_count_, (size), _Pre_opt_ptrdiff_count_(size))
  749. #define _Inout_count_x_(size) _SAL1_1_Source_(_Inout_count_x_, (size), _Prepost_count_x_(size))
  750. #define _Inout_opt_count_x_(size) _SAL1_1_Source_(_Inout_opt_count_x_, (size), _Prepost_opt_count_x_(size))
  751. #define _Inout_bytecount_x_(size) _SAL1_1_Source_(_Inout_bytecount_x_, (size), _Prepost_bytecount_x_(size))
  752. #define _Inout_opt_bytecount_x_(size) _SAL1_1_Source_(_Inout_opt_bytecount_x_, (size), _Prepost_opt_bytecount_x_(size))
  753. // e.g. void AppendToLPSTR( _In_ LPCSTR szFrom, _Inout_cap_(cchTo) LPSTR* szTo, size_t cchTo );
  754. #define _Inout_cap_(size) _SAL1_1_Source_(_Inout_cap_, (size), _Pre_valid_cap_(size) _Post_valid_)
  755. #define _Inout_opt_cap_(size) _SAL1_1_Source_(_Inout_opt_cap_, (size), _Pre_opt_valid_cap_(size) _Post_valid_)
  756. #define _Inout_bytecap_(size) _SAL1_1_Source_(_Inout_bytecap_, (size), _Pre_valid_bytecap_(size) _Post_valid_)
  757. #define _Inout_opt_bytecap_(size) _SAL1_1_Source_(_Inout_opt_bytecap_, (size), _Pre_opt_valid_bytecap_(size) _Post_valid_)
  758. #define _Inout_cap_c_(size) _SAL1_1_Source_(_Inout_cap_c_, (size), _Pre_valid_cap_c_(size) _Post_valid_)
  759. #define _Inout_opt_cap_c_(size) _SAL1_1_Source_(_Inout_opt_cap_c_, (size), _Pre_opt_valid_cap_c_(size) _Post_valid_)
  760. #define _Inout_bytecap_c_(size) _SAL1_1_Source_(_Inout_bytecap_c_, (size), _Pre_valid_bytecap_c_(size) _Post_valid_)
  761. #define _Inout_opt_bytecap_c_(size) _SAL1_1_Source_(_Inout_opt_bytecap_c_, (size), _Pre_opt_valid_bytecap_c_(size) _Post_valid_)
  762. #define _Inout_cap_x_(size) _SAL1_1_Source_(_Inout_cap_x_, (size), _Pre_valid_cap_x_(size) _Post_valid_)
  763. #define _Inout_opt_cap_x_(size) _SAL1_1_Source_(_Inout_opt_cap_x_, (size), _Pre_opt_valid_cap_x_(size) _Post_valid_)
  764. #define _Inout_bytecap_x_(size) _SAL1_1_Source_(_Inout_bytecap_x_, (size), _Pre_valid_bytecap_x_(size) _Post_valid_)
  765. #define _Inout_opt_bytecap_x_(size) _SAL1_1_Source_(_Inout_opt_bytecap_x_, (size), _Pre_opt_valid_bytecap_x_(size) _Post_valid_)
  766. // inout string buffers with writable size
  767. // e.g. void AppendStr( _In_z_ const char* szFrom, _Inout_z_cap_(cchTo) char* szTo, size_t cchTo );
  768. #define _Inout_z_cap_(size) _SAL1_1_Source_(_Inout_z_cap_, (size), _Pre_z_cap_(size) _Post_z_)
  769. #define _Inout_opt_z_cap_(size) _SAL1_1_Source_(_Inout_opt_z_cap_, (size), _Pre_opt_z_cap_(size) _Post_z_)
  770. #define _Inout_z_bytecap_(size) _SAL1_1_Source_(_Inout_z_bytecap_, (size), _Pre_z_bytecap_(size) _Post_z_)
  771. #define _Inout_opt_z_bytecap_(size) _SAL1_1_Source_(_Inout_opt_z_bytecap_, (size), _Pre_opt_z_bytecap_(size) _Post_z_)
  772. #define _Inout_z_cap_c_(size) _SAL1_1_Source_(_Inout_z_cap_c_, (size), _Pre_z_cap_c_(size) _Post_z_)
  773. #define _Inout_opt_z_cap_c_(size) _SAL1_1_Source_(_Inout_opt_z_cap_c_, (size), _Pre_opt_z_cap_c_(size) _Post_z_)
  774. #define _Inout_z_bytecap_c_(size) _SAL1_1_Source_(_Inout_z_bytecap_c_, (size), _Pre_z_bytecap_c_(size) _Post_z_)
  775. #define _Inout_opt_z_bytecap_c_(size) _SAL1_1_Source_(_Inout_opt_z_bytecap_c_, (size), _Pre_opt_z_bytecap_c_(size) _Post_z_)
  776. #define _Inout_z_cap_x_(size) _SAL1_1_Source_(_Inout_z_cap_x_, (size), _Pre_z_cap_x_(size) _Post_z_)
  777. #define _Inout_opt_z_cap_x_(size) _SAL1_1_Source_(_Inout_opt_z_cap_x_, (size), _Pre_opt_z_cap_x_(size) _Post_z_)
  778. #define _Inout_z_bytecap_x_(size) _SAL1_1_Source_(_Inout_z_bytecap_x_, (size), _Pre_z_bytecap_x_(size) _Post_z_)
  779. #define _Inout_opt_z_bytecap_x_(size) _SAL1_1_Source_(_Inout_opt_z_bytecap_x_, (size), _Pre_opt_z_bytecap_x_(size) _Post_z_)
  780. // returning pointers to valid objects
  781. #define _Ret_ _SAL1_1_Source_(_Ret_, (), _Ret_valid_)
  782. #define _Ret_opt_ _SAL1_1_Source_(_Ret_opt_, (), _Ret_opt_valid_)
  783. // annotations to express 'boundedness' of integral value parameter
  784. #define _In_bound_ _SAL1_1_Source_(_In_bound_, (), _In_bound_impl_)
  785. #define _Out_bound_ _SAL1_1_Source_(_Out_bound_, (), _Out_bound_impl_)
  786. #define _Ret_bound_ _SAL1_1_Source_(_Ret_bound_, (), _Ret_bound_impl_)
  787. #define _Deref_in_bound_ _SAL1_1_Source_(_Deref_in_bound_, (), _Deref_in_bound_impl_)
  788. #define _Deref_out_bound_ _SAL1_1_Source_(_Deref_out_bound_, (), _Deref_out_bound_impl_)
  789. #define _Deref_inout_bound_ _SAL1_1_Source_(_Deref_inout_bound_, (), _Deref_in_bound_ _Deref_out_bound_)
  790. #define _Deref_ret_bound_ _SAL1_1_Source_(_Deref_ret_bound_, (), _Deref_ret_bound_impl_)
  791. // e.g. HRESULT HrCreatePoint( _Deref_out_opt_ POINT** ppPT );
  792. #define _Deref_out_ _SAL1_1_Source_(_Deref_out_, (), _Out_ _Deref_post_valid_)
  793. #define _Deref_out_opt_ _SAL1_1_Source_(_Deref_out_opt_, (), _Out_ _Deref_post_opt_valid_)
  794. #define _Deref_opt_out_ _SAL1_1_Source_(_Deref_opt_out_, (), _Out_opt_ _Deref_post_valid_)
  795. #define _Deref_opt_out_opt_ _SAL1_1_Source_(_Deref_opt_out_opt_, (), _Out_opt_ _Deref_post_opt_valid_)
  796. // e.g. void CloneString( _In_z_ const WCHAR* wzFrom, _Deref_out_z_ WCHAR** pWzTo );
  797. #define _Deref_out_z_ _SAL1_1_Source_(_Deref_out_z_, (), _Out_ _Deref_post_z_)
  798. #define _Deref_out_opt_z_ _SAL1_1_Source_(_Deref_out_opt_z_, (), _Out_ _Deref_post_opt_z_)
  799. #define _Deref_opt_out_z_ _SAL1_1_Source_(_Deref_opt_out_z_, (), _Out_opt_ _Deref_post_z_)
  800. #define _Deref_opt_out_opt_z_ _SAL1_1_Source_(_Deref_opt_out_opt_z_, (), _Out_opt_ _Deref_post_opt_z_)
  801. //
  802. // _Deref_pre_ ---
  803. //
  804. // describing conditions for array elements of dereferenced pointer parameters that must be met before the call
  805. // e.g. void SaveStringArray( _In_count_(cStrings) _Deref_pre_z_ const WCHAR* const rgpwch[] );
  806. #define _Deref_pre_z_ _SAL1_1_Source_(_Deref_pre_z_, (), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__zterm_impl) _Pre_valid_impl_)
  807. #define _Deref_pre_opt_z_ _SAL1_1_Source_(_Deref_pre_opt_z_, (), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__zterm_impl) _Pre_valid_impl_)
  808. // e.g. void FillInArrayOfStr32( _In_count_(cStrings) _Deref_pre_cap_c_(32) _Deref_post_z_ WCHAR* const rgpwch[] );
  809. // buffer capacity is described by another parameter
  810. #define _Deref_pre_cap_(size) _SAL1_1_Source_(_Deref_pre_cap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_impl(size)))
  811. #define _Deref_pre_opt_cap_(size) _SAL1_1_Source_(_Deref_pre_opt_cap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_impl(size)))
  812. #define _Deref_pre_bytecap_(size) _SAL1_1_Source_(_Deref_pre_bytecap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_impl(size)))
  813. #define _Deref_pre_opt_bytecap_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_impl(size)))
  814. // buffer capacity is described by a constant expression
  815. #define _Deref_pre_cap_c_(size) _SAL1_1_Source_(_Deref_pre_cap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_c_impl(size)))
  816. #define _Deref_pre_opt_cap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_cap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_c_impl(size)))
  817. #define _Deref_pre_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_bytecap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_c_impl(size)))
  818. #define _Deref_pre_opt_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_c_impl(size)))
  819. // buffer capacity is described by a complex condition
  820. #define _Deref_pre_cap_x_(size) _SAL1_1_Source_(_Deref_pre_cap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_x_impl(size)))
  821. #define _Deref_pre_opt_cap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_cap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_x_impl(size)))
  822. #define _Deref_pre_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_bytecap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_x_impl(size)))
  823. #define _Deref_pre_opt_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_x_impl(size)))
  824. // convenience macros for nullterminated buffers with given capacity
  825. #define _Deref_pre_z_cap_(size) _SAL1_1_Source_(_Deref_pre_z_cap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_impl(size)) _Pre_valid_impl_)
  826. #define _Deref_pre_opt_z_cap_(size) _SAL1_1_Source_(_Deref_pre_opt_z_cap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_impl(size)) _Pre_valid_impl_)
  827. #define _Deref_pre_z_bytecap_(size) _SAL1_1_Source_(_Deref_pre_z_bytecap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_impl(size)) _Pre_valid_impl_)
  828. #define _Deref_pre_opt_z_bytecap_(size) _SAL1_1_Source_(_Deref_pre_opt_z_bytecap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_impl(size)) _Pre_valid_impl_)
  829. #define _Deref_pre_z_cap_c_(size) _SAL1_1_Source_(_Deref_pre_z_cap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_c_impl(size)) _Pre_valid_impl_)
  830. #define _Deref_pre_opt_z_cap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_z_cap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_c_impl(size)) _Pre_valid_impl_)
  831. #define _Deref_pre_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_z_bytecap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Pre_valid_impl_)
  832. #define _Deref_pre_opt_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_z_bytecap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Pre_valid_impl_)
  833. #define _Deref_pre_z_cap_x_(size) _SAL1_1_Source_(_Deref_pre_z_cap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_x_impl(size)) _Pre_valid_impl_)
  834. #define _Deref_pre_opt_z_cap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_z_cap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__cap_x_impl(size)) _Pre_valid_impl_)
  835. #define _Deref_pre_z_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_z_bytecap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Pre_valid_impl_)
  836. #define _Deref_pre_opt_z_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_z_bytecap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Pre_valid_impl_)
  837. // known capacity and valid but unknown readable extent
  838. #define _Deref_pre_valid_cap_(size) _SAL1_1_Source_(_Deref_pre_valid_cap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_impl(size)) _Pre_valid_impl_)
  839. #define _Deref_pre_opt_valid_cap_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_cap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_impl(size)) _Pre_valid_impl_)
  840. #define _Deref_pre_valid_bytecap_(size) _SAL1_1_Source_(_Deref_pre_valid_bytecap_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_impl(size)) _Pre_valid_impl_)
  841. #define _Deref_pre_opt_valid_bytecap_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_bytecap_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_impl(size)) _Pre_valid_impl_)
  842. #define _Deref_pre_valid_cap_c_(size) _SAL1_1_Source_(_Deref_pre_valid_cap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_c_impl(size)) _Pre_valid_impl_)
  843. #define _Deref_pre_opt_valid_cap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_cap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_c_impl(size)) _Pre_valid_impl_)
  844. #define _Deref_pre_valid_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_valid_bytecap_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_c_impl(size)) _Pre_valid_impl_)
  845. #define _Deref_pre_opt_valid_bytecap_c_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_bytecap_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_c_impl(size)) _Pre_valid_impl_)
  846. #define _Deref_pre_valid_cap_x_(size) _SAL1_1_Source_(_Deref_pre_valid_cap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__cap_x_impl(size)) _Pre_valid_impl_)
  847. #define _Deref_pre_opt_valid_cap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_cap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__cap_x_impl(size)) _Pre_valid_impl_)
  848. #define _Deref_pre_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_valid_bytecap_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecap_x_impl(size)) _Pre_valid_impl_)
  849. #define _Deref_pre_opt_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_pre_opt_valid_bytecap_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecap_x_impl(size)) _Pre_valid_impl_)
  850. // e.g. void SaveMatrix( _In_count_(n) _Deref_pre_count_(n) const Elem** matrix, size_t n );
  851. // valid buffer extent is described by another parameter
  852. #define _Deref_pre_count_(size) _SAL1_1_Source_(_Deref_pre_count_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__count_impl(size)) _Pre_valid_impl_)
  853. #define _Deref_pre_opt_count_(size) _SAL1_1_Source_(_Deref_pre_opt_count_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__count_impl(size)) _Pre_valid_impl_)
  854. #define _Deref_pre_bytecount_(size) _SAL1_1_Source_(_Deref_pre_bytecount_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecount_impl(size)) _Pre_valid_impl_)
  855. #define _Deref_pre_opt_bytecount_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecount_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecount_impl(size)) _Pre_valid_impl_)
  856. // valid buffer extent is described by a constant expression
  857. #define _Deref_pre_count_c_(size) _SAL1_1_Source_(_Deref_pre_count_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__count_c_impl(size)) _Pre_valid_impl_)
  858. #define _Deref_pre_opt_count_c_(size) _SAL1_1_Source_(_Deref_pre_opt_count_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__count_c_impl(size)) _Pre_valid_impl_)
  859. #define _Deref_pre_bytecount_c_(size) _SAL1_1_Source_(_Deref_pre_bytecount_c_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecount_c_impl(size)) _Pre_valid_impl_)
  860. #define _Deref_pre_opt_bytecount_c_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecount_c_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecount_c_impl(size)) _Pre_valid_impl_)
  861. // valid buffer extent is described by a complex expression
  862. #define _Deref_pre_count_x_(size) _SAL1_1_Source_(_Deref_pre_count_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__count_x_impl(size)) _Pre_valid_impl_)
  863. #define _Deref_pre_opt_count_x_(size) _SAL1_1_Source_(_Deref_pre_opt_count_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__count_x_impl(size)) _Pre_valid_impl_)
  864. #define _Deref_pre_bytecount_x_(size) _SAL1_1_Source_(_Deref_pre_bytecount_x_, (size), _Deref_pre1_impl_(__notnull_impl_notref) _Deref_pre1_impl_(__bytecount_x_impl(size)) _Pre_valid_impl_)
  865. #define _Deref_pre_opt_bytecount_x_(size) _SAL1_1_Source_(_Deref_pre_opt_bytecount_x_, (size), _Deref_pre1_impl_(__maybenull_impl_notref) _Deref_pre1_impl_(__bytecount_x_impl(size)) _Pre_valid_impl_)
  866. // e.g. void PrintStringArray( _In_count_(cElems) _Deref_pre_valid_ LPCSTR rgStr[], size_t cElems );
  867. #define _Deref_pre_valid_ _SAL1_1_Source_(_Deref_pre_valid_, (), _Deref_pre1_impl_(__notnull_impl_notref) _Pre_valid_impl_)
  868. #define _Deref_pre_opt_valid_ _SAL1_1_Source_(_Deref_pre_opt_valid_, (), _Deref_pre1_impl_(__maybenull_impl_notref) _Pre_valid_impl_)
  869. #define _Deref_pre_invalid_ _SAL1_1_Source_(_Deref_pre_invalid_, (), _Deref_pre1_impl_(__notvalid_impl))
  870. #define _Deref_pre_notnull_ _SAL1_1_Source_(_Deref_pre_notnull_, (), _Deref_pre1_impl_(__notnull_impl_notref))
  871. #define _Deref_pre_maybenull_ _SAL1_1_Source_(_Deref_pre_maybenull_, (), _Deref_pre1_impl_(__maybenull_impl_notref))
  872. #define _Deref_pre_null_ _SAL1_1_Source_(_Deref_pre_null_, (), _Deref_pre1_impl_(__null_impl_notref))
  873. // restrict access rights
  874. #define _Deref_pre_readonly_ _SAL1_1_Source_(_Deref_pre_readonly_, (), _Deref_pre1_impl_(__readaccess_impl_notref))
  875. #define _Deref_pre_writeonly_ _SAL1_1_Source_(_Deref_pre_writeonly_, (), _Deref_pre1_impl_(__writeaccess_impl_notref))
  876. //
  877. // _Deref_post_ ---
  878. //
  879. // describing conditions for array elements or dereferenced pointer parameters that hold after the call
  880. // e.g. void CloneString( _In_z_ const Wchar_t* wzIn _Out_ _Deref_post_z_ WCHAR** pWzOut );
  881. #define _Deref_post_z_ _SAL1_1_Source_(_Deref_post_z_, (), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__zterm_impl) _Post_valid_impl_)
  882. #define _Deref_post_opt_z_ _SAL1_1_Source_(_Deref_post_opt_z_, (), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__zterm_impl) _Post_valid_impl_)
  883. // e.g. HRESULT HrAllocateMemory( size_t cb, _Out_ _Deref_post_bytecap_(cb) void** ppv );
  884. // buffer capacity is described by another parameter
  885. #define _Deref_post_cap_(size) _SAL1_1_Source_(_Deref_post_cap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_impl(size)))
  886. #define _Deref_post_opt_cap_(size) _SAL1_1_Source_(_Deref_post_opt_cap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_impl(size)))
  887. #define _Deref_post_bytecap_(size) _SAL1_1_Source_(_Deref_post_bytecap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_impl(size)))
  888. #define _Deref_post_opt_bytecap_(size) _SAL1_1_Source_(_Deref_post_opt_bytecap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_impl(size)))
  889. // buffer capacity is described by a constant expression
  890. #define _Deref_post_cap_c_(size) _SAL1_1_Source_(_Deref_post_cap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_c_impl(size)))
  891. #define _Deref_post_opt_cap_c_(size) _SAL1_1_Source_(_Deref_post_opt_cap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_c_impl(size)))
  892. #define _Deref_post_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_bytecap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_c_impl(size)))
  893. #define _Deref_post_opt_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_opt_bytecap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_c_impl(size)))
  894. // buffer capacity is described by a complex expression
  895. #define _Deref_post_cap_x_(size) _SAL1_1_Source_(_Deref_post_cap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_x_impl(size)))
  896. #define _Deref_post_opt_cap_x_(size) _SAL1_1_Source_(_Deref_post_opt_cap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_x_impl(size)))
  897. #define _Deref_post_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_bytecap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_x_impl(size)))
  898. #define _Deref_post_opt_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_opt_bytecap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_x_impl(size)))
  899. // convenience macros for nullterminated buffers with given capacity
  900. #define _Deref_post_z_cap_(size) _SAL1_1_Source_(_Deref_post_z_cap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_impl(size)) _Post_valid_impl_)
  901. #define _Deref_post_opt_z_cap_(size) _SAL1_1_Source_(_Deref_post_opt_z_cap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_impl(size)) _Post_valid_impl_)
  902. #define _Deref_post_z_bytecap_(size) _SAL1_1_Source_(_Deref_post_z_bytecap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_impl(size)) _Post_valid_impl_)
  903. #define _Deref_post_opt_z_bytecap_(size) _SAL1_1_Source_(_Deref_post_opt_z_bytecap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_impl(size)) _Post_valid_impl_)
  904. #define _Deref_post_z_cap_c_(size) _SAL1_1_Source_(_Deref_post_z_cap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_c_impl(size)) _Post_valid_impl_)
  905. #define _Deref_post_opt_z_cap_c_(size) _SAL1_1_Source_(_Deref_post_opt_z_cap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_c_impl(size)) _Post_valid_impl_)
  906. #define _Deref_post_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_z_bytecap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Post_valid_impl_)
  907. #define _Deref_post_opt_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_opt_z_bytecap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Post_valid_impl_)
  908. #define _Deref_post_z_cap_x_(size) _SAL1_1_Source_(_Deref_post_z_cap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_x_impl(size)) _Post_valid_impl_)
  909. #define _Deref_post_opt_z_cap_x_(size) _SAL1_1_Source_(_Deref_post_opt_z_cap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__cap_x_impl(size)) _Post_valid_impl_)
  910. #define _Deref_post_z_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_z_bytecap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Post_valid_impl_)
  911. #define _Deref_post_opt_z_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_opt_z_bytecap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Post_valid_impl_)
  912. // known capacity and valid but unknown readable extent
  913. #define _Deref_post_valid_cap_(size) _SAL1_1_Source_(_Deref_post_valid_cap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_impl(size)) _Post_valid_impl_)
  914. #define _Deref_post_opt_valid_cap_(size) _SAL1_1_Source_(_Deref_post_opt_valid_cap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_impl(size)) _Post_valid_impl_)
  915. #define _Deref_post_valid_bytecap_(size) _SAL1_1_Source_(_Deref_post_valid_bytecap_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_impl(size)) _Post_valid_impl_)
  916. #define _Deref_post_opt_valid_bytecap_(size) _SAL1_1_Source_(_Deref_post_opt_valid_bytecap_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_impl(size)) _Post_valid_impl_)
  917. #define _Deref_post_valid_cap_c_(size) _SAL1_1_Source_(_Deref_post_valid_cap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_c_impl(size)) _Post_valid_impl_)
  918. #define _Deref_post_opt_valid_cap_c_(size) _SAL1_1_Source_(_Deref_post_opt_valid_cap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_c_impl(size)) _Post_valid_impl_)
  919. #define _Deref_post_valid_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_valid_bytecap_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_c_impl(size)) _Post_valid_impl_)
  920. #define _Deref_post_opt_valid_bytecap_c_(size) _SAL1_1_Source_(_Deref_post_opt_valid_bytecap_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_c_impl(size)) _Post_valid_impl_)
  921. #define _Deref_post_valid_cap_x_(size) _SAL1_1_Source_(_Deref_post_valid_cap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__cap_x_impl(size)) _Post_valid_impl_)
  922. #define _Deref_post_opt_valid_cap_x_(size) _SAL1_1_Source_(_Deref_post_opt_valid_cap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__cap_x_impl(size)) _Post_valid_impl_)
  923. #define _Deref_post_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_valid_bytecap_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecap_x_impl(size)) _Post_valid_impl_)
  924. #define _Deref_post_opt_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_post_opt_valid_bytecap_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecap_x_impl(size)) _Post_valid_impl_)
  925. // e.g. HRESULT HrAllocateZeroInitializedMemory( size_t cb, _Out_ _Deref_post_bytecount_(cb) void** ppv );
  926. // valid buffer extent is described by another parameter
  927. #define _Deref_post_count_(size) _SAL1_1_Source_(_Deref_post_count_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__count_impl(size)) _Post_valid_impl_)
  928. #define _Deref_post_opt_count_(size) _SAL1_1_Source_(_Deref_post_opt_count_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__count_impl(size)) _Post_valid_impl_)
  929. #define _Deref_post_bytecount_(size) _SAL1_1_Source_(_Deref_post_bytecount_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecount_impl(size)) _Post_valid_impl_)
  930. #define _Deref_post_opt_bytecount_(size) _SAL1_1_Source_(_Deref_post_opt_bytecount_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecount_impl(size)) _Post_valid_impl_)
  931. // buffer capacity is described by a constant expression
  932. #define _Deref_post_count_c_(size) _SAL1_1_Source_(_Deref_post_count_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__count_c_impl(size)) _Post_valid_impl_)
  933. #define _Deref_post_opt_count_c_(size) _SAL1_1_Source_(_Deref_post_opt_count_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__count_c_impl(size)) _Post_valid_impl_)
  934. #define _Deref_post_bytecount_c_(size) _SAL1_1_Source_(_Deref_post_bytecount_c_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecount_c_impl(size)) _Post_valid_impl_)
  935. #define _Deref_post_opt_bytecount_c_(size) _SAL1_1_Source_(_Deref_post_opt_bytecount_c_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecount_c_impl(size)) _Post_valid_impl_)
  936. // buffer capacity is described by a complex expression
  937. #define _Deref_post_count_x_(size) _SAL1_1_Source_(_Deref_post_count_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__count_x_impl(size)) _Post_valid_impl_)
  938. #define _Deref_post_opt_count_x_(size) _SAL1_1_Source_(_Deref_post_opt_count_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__count_x_impl(size)) _Post_valid_impl_)
  939. #define _Deref_post_bytecount_x_(size) _SAL1_1_Source_(_Deref_post_bytecount_x_, (size), _Deref_post1_impl_(__notnull_impl_notref) _Deref_post1_impl_(__bytecount_x_impl(size)) _Post_valid_impl_)
  940. #define _Deref_post_opt_bytecount_x_(size) _SAL1_1_Source_(_Deref_post_opt_bytecount_x_, (size), _Deref_post1_impl_(__maybenull_impl_notref) _Deref_post1_impl_(__bytecount_x_impl(size)) _Post_valid_impl_)
  941. // e.g. void GetStrings( _Out_count_(cElems) _Deref_post_valid_ LPSTR const rgStr[], size_t cElems );
  942. #define _Deref_post_valid_ _SAL1_1_Source_(_Deref_post_valid_, (), _Deref_post1_impl_(__notnull_impl_notref) _Post_valid_impl_)
  943. #define _Deref_post_opt_valid_ _SAL1_1_Source_(_Deref_post_opt_valid_, (), _Deref_post1_impl_(__maybenull_impl_notref) _Post_valid_impl_)
  944. #define _Deref_post_notnull_ _SAL1_1_Source_(_Deref_post_notnull_, (), _Deref_post1_impl_(__notnull_impl_notref))
  945. #define _Deref_post_maybenull_ _SAL1_1_Source_(_Deref_post_maybenull_, (), _Deref_post1_impl_(__maybenull_impl_notref))
  946. #define _Deref_post_null_ _SAL1_1_Source_(_Deref_post_null_, (), _Deref_post1_impl_(__null_impl_notref))
  947. //
  948. // _Deref_ret_ ---
  949. //
  950. #define _Deref_ret_z_ _SAL1_1_Source_(_Deref_ret_z_, (), _Deref_ret1_impl_(__notnull_impl_notref) _Deref_ret1_impl_(__zterm_impl))
  951. #define _Deref_ret_opt_z_ _SAL1_1_Source_(_Deref_ret_opt_z_, (), _Deref_ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__zterm_impl))
  952. //
  953. // special _Deref_ ---
  954. //
  955. #define _Deref2_pre_readonly_ _SAL1_1_Source_(_Deref2_pre_readonly_, (), _Deref2_pre1_impl_(__readaccess_impl_notref))
  956. //
  957. // _Ret_ ---
  958. //
  959. // e.g. _Ret_opt_valid_ LPSTR void* CloneSTR( _Pre_valid_ LPSTR src );
  960. #define _Ret_opt_valid_ _SAL1_1_Source_(_Ret_opt_valid_, (), _Ret1_impl_(__maybenull_impl_notref) _Ret_valid_impl_)
  961. #define _Ret_opt_z_ _SAL1_1_Source_(_Ret_opt_z_, (), _Ret2_impl_(__maybenull_impl,__zterm_impl) _Ret_valid_impl_)
  962. // e.g. _Ret_opt_bytecap_(cb) void* AllocateMemory( size_t cb );
  963. // Buffer capacity is described by another parameter
  964. #define _Ret_cap_(size) _SAL1_1_Source_(_Ret_cap_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__cap_impl(size)))
  965. #define _Ret_opt_cap_(size) _SAL1_1_Source_(_Ret_opt_cap_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__cap_impl(size)))
  966. #define _Ret_bytecap_(size) _SAL1_1_Source_(_Ret_bytecap_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecap_impl(size)))
  967. #define _Ret_opt_bytecap_(size) _SAL1_1_Source_(_Ret_opt_bytecap_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecap_impl(size)))
  968. // Buffer capacity is described by a constant expression
  969. #define _Ret_cap_c_(size) _SAL1_1_Source_(_Ret_cap_c_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__cap_c_impl(size)))
  970. #define _Ret_opt_cap_c_(size) _SAL1_1_Source_(_Ret_opt_cap_c_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__cap_c_impl(size)))
  971. #define _Ret_bytecap_c_(size) _SAL1_1_Source_(_Ret_bytecap_c_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecap_c_impl(size)))
  972. #define _Ret_opt_bytecap_c_(size) _SAL1_1_Source_(_Ret_opt_bytecap_c_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecap_c_impl(size)))
  973. // Buffer capacity is described by a complex condition
  974. #define _Ret_cap_x_(size) _SAL1_1_Source_(_Ret_cap_x_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__cap_x_impl(size)))
  975. #define _Ret_opt_cap_x_(size) _SAL1_1_Source_(_Ret_opt_cap_x_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__cap_x_impl(size)))
  976. #define _Ret_bytecap_x_(size) _SAL1_1_Source_(_Ret_bytecap_x_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecap_x_impl(size)))
  977. #define _Ret_opt_bytecap_x_(size) _SAL1_1_Source_(_Ret_opt_bytecap_x_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecap_x_impl(size)))
  978. // return value is nullterminated and capacity is given by another parameter
  979. #define _Ret_z_cap_(size) _SAL1_1_Source_(_Ret_z_cap_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret2_impl_(__zterm_impl,__cap_impl(size)) _Ret_valid_impl_)
  980. #define _Ret_opt_z_cap_(size) _SAL1_1_Source_(_Ret_opt_z_cap_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret2_impl_(__zterm_impl,__cap_impl(size)) _Ret_valid_impl_)
  981. #define _Ret_z_bytecap_(size) _SAL1_1_Source_(_Ret_z_bytecap_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret2_impl_(__zterm_impl,__bytecap_impl(size)) _Ret_valid_impl_)
  982. #define _Ret_opt_z_bytecap_(size) _SAL1_1_Source_(_Ret_opt_z_bytecap_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret2_impl_(__zterm_impl,__bytecap_impl(size)) _Ret_valid_impl_)
  983. // e.g. _Ret_opt_bytecount_(cb) void* AllocateZeroInitializedMemory( size_t cb );
  984. // Valid Buffer extent is described by another parameter
  985. #define _Ret_count_(size) _SAL1_1_Source_(_Ret_count_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__count_impl(size)) _Ret_valid_impl_)
  986. #define _Ret_opt_count_(size) _SAL1_1_Source_(_Ret_opt_count_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__count_impl(size)) _Ret_valid_impl_)
  987. #define _Ret_bytecount_(size) _SAL1_1_Source_(_Ret_bytecount_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecount_impl(size)) _Ret_valid_impl_)
  988. #define _Ret_opt_bytecount_(size) _SAL1_1_Source_(_Ret_opt_bytecount_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecount_impl(size)) _Ret_valid_impl_)
  989. // Valid Buffer extent is described by a constant expression
  990. #define _Ret_count_c_(size) _SAL1_1_Source_(_Ret_count_c_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__count_c_impl(size)) _Ret_valid_impl_)
  991. #define _Ret_opt_count_c_(size) _SAL1_1_Source_(_Ret_opt_count_c_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__count_c_impl(size)) _Ret_valid_impl_)
  992. #define _Ret_bytecount_c_(size) _SAL1_1_Source_(_Ret_bytecount_c_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecount_c_impl(size)) _Ret_valid_impl_)
  993. #define _Ret_opt_bytecount_c_(size) _SAL1_1_Source_(_Ret_opt_bytecount_c_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecount_c_impl(size)) _Ret_valid_impl_)
  994. // Valid Buffer extent is described by a complex expression
  995. #define _Ret_count_x_(size) _SAL1_1_Source_(_Ret_count_x_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__count_x_impl(size)) _Ret_valid_impl_)
  996. #define _Ret_opt_count_x_(size) _SAL1_1_Source_(_Ret_opt_count_x_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__count_x_impl(size)) _Ret_valid_impl_)
  997. #define _Ret_bytecount_x_(size) _SAL1_1_Source_(_Ret_bytecount_x_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret1_impl_(__bytecount_x_impl(size)) _Ret_valid_impl_)
  998. #define _Ret_opt_bytecount_x_(size) _SAL1_1_Source_(_Ret_opt_bytecount_x_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret1_impl_(__bytecount_x_impl(size)) _Ret_valid_impl_)
  999. // return value is nullterminated and length is given by another parameter
  1000. #define _Ret_z_count_(size) _SAL1_1_Source_(_Ret_z_count_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret2_impl_(__zterm_impl,__count_impl(size)) _Ret_valid_impl_)
  1001. #define _Ret_opt_z_count_(size) _SAL1_1_Source_(_Ret_opt_z_count_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret2_impl_(__zterm_impl,__count_impl(size)) _Ret_valid_impl_)
  1002. #define _Ret_z_bytecount_(size) _SAL1_1_Source_(_Ret_z_bytecount_, (size), _Ret1_impl_(__notnull_impl_notref) _Ret2_impl_(__zterm_impl,__bytecount_impl(size)) _Ret_valid_impl_)
  1003. #define _Ret_opt_z_bytecount_(size) _SAL1_1_Source_(_Ret_opt_z_bytecount_, (size), _Ret1_impl_(__maybenull_impl_notref) _Ret2_impl_(__zterm_impl,__bytecount_impl(size)) _Ret_valid_impl_)
  1004. // _Pre_ annotations ---
  1005. #define _Pre_opt_z_ _SAL1_1_Source_(_Pre_opt_z_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__zterm_impl) _Pre_valid_impl_)
  1006. // restrict access rights
  1007. #define _Pre_readonly_ _SAL1_1_Source_(_Pre_readonly_, (), _Pre1_impl_(__readaccess_impl_notref))
  1008. #define _Pre_writeonly_ _SAL1_1_Source_(_Pre_writeonly_, (), _Pre1_impl_(__writeaccess_impl_notref))
  1009. // e.g. void FreeMemory( _Pre_bytecap_(cb) _Post_ptr_invalid_ void* pv, size_t cb );
  1010. // buffer capacity described by another parameter
  1011. #define _Pre_cap_(size) _SAL1_1_Source_(_Pre_cap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_impl(size)))
  1012. #define _Pre_opt_cap_(size) _SAL1_1_Source_(_Pre_opt_cap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_impl(size)))
  1013. #define _Pre_bytecap_(size) _SAL1_1_Source_(_Pre_bytecap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_impl(size)))
  1014. #define _Pre_opt_bytecap_(size) _SAL1_1_Source_(_Pre_opt_bytecap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_impl(size)))
  1015. // buffer capacity described by a constant expression
  1016. #define _Pre_cap_c_(size) _SAL1_1_Source_(_Pre_cap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_c_impl(size)))
  1017. #define _Pre_opt_cap_c_(size) _SAL1_1_Source_(_Pre_opt_cap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_c_impl(size)))
  1018. #define _Pre_bytecap_c_(size) _SAL1_1_Source_(_Pre_bytecap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_c_impl(size)))
  1019. #define _Pre_opt_bytecap_c_(size) _SAL1_1_Source_(_Pre_opt_bytecap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_c_impl(size)))
  1020. #define _Pre_cap_c_one_ _SAL1_1_Source_(_Pre_cap_c_one_, (), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_c_one_notref_impl))
  1021. #define _Pre_opt_cap_c_one_ _SAL1_1_Source_(_Pre_opt_cap_c_one_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_c_one_notref_impl))
  1022. // buffer capacity is described by another parameter multiplied by a constant expression
  1023. #define _Pre_cap_m_(mult,size) _SAL1_1_Source_(_Pre_cap_m_, (mult,size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__mult_impl(mult,size)))
  1024. #define _Pre_opt_cap_m_(mult,size) _SAL1_1_Source_(_Pre_opt_cap_m_, (mult,size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__mult_impl(mult,size)))
  1025. // buffer capacity described by size of other buffer, only used by dangerous legacy APIs
  1026. // e.g. int strcpy(_Pre_cap_for_(src) char* dst, const char* src);
  1027. #define _Pre_cap_for_(param) _SAL1_1_Source_(_Pre_cap_for_, (param), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_for_impl(param)))
  1028. #define _Pre_opt_cap_for_(param) _SAL1_1_Source_(_Pre_opt_cap_for_, (param), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_for_impl(param)))
  1029. // buffer capacity described by a complex condition
  1030. #define _Pre_cap_x_(size) _SAL1_1_Source_(_Pre_cap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_x_impl(size)))
  1031. #define _Pre_opt_cap_x_(size) _SAL1_1_Source_(_Pre_opt_cap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_x_impl(size)))
  1032. #define _Pre_bytecap_x_(size) _SAL1_1_Source_(_Pre_bytecap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_x_impl(size)))
  1033. #define _Pre_opt_bytecap_x_(size) _SAL1_1_Source_(_Pre_opt_bytecap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_x_impl(size)))
  1034. // buffer capacity described by the difference to another pointer parameter
  1035. #define _Pre_ptrdiff_cap_(ptr) _SAL1_1_Source_(_Pre_ptrdiff_cap_, (ptr), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_x_impl(__ptrdiff(ptr))))
  1036. #define _Pre_opt_ptrdiff_cap_(ptr) _SAL1_1_Source_(_Pre_opt_ptrdiff_cap_, (ptr), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_x_impl(__ptrdiff(ptr))))
  1037. // e.g. void AppendStr( _Pre_z_ const char* szFrom, _Pre_z_cap_(cchTo) _Post_z_ char* szTo, size_t cchTo );
  1038. #define _Pre_z_cap_(size) _SAL1_1_Source_(_Pre_z_cap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_impl(size)) _Pre_valid_impl_)
  1039. #define _Pre_opt_z_cap_(size) _SAL1_1_Source_(_Pre_opt_z_cap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_impl(size)) _Pre_valid_impl_)
  1040. #define _Pre_z_bytecap_(size) _SAL1_1_Source_(_Pre_z_bytecap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_impl(size)) _Pre_valid_impl_)
  1041. #define _Pre_opt_z_bytecap_(size) _SAL1_1_Source_(_Pre_opt_z_bytecap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_impl(size)) _Pre_valid_impl_)
  1042. #define _Pre_z_cap_c_(size) _SAL1_1_Source_(_Pre_z_cap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_c_impl(size)) _Pre_valid_impl_)
  1043. #define _Pre_opt_z_cap_c_(size) _SAL1_1_Source_(_Pre_opt_z_cap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_c_impl(size)) _Pre_valid_impl_)
  1044. #define _Pre_z_bytecap_c_(size) _SAL1_1_Source_(_Pre_z_bytecap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Pre_valid_impl_)
  1045. #define _Pre_opt_z_bytecap_c_(size) _SAL1_1_Source_(_Pre_opt_z_bytecap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_c_impl(size)) _Pre_valid_impl_)
  1046. #define _Pre_z_cap_x_(size) _SAL1_1_Source_(_Pre_z_cap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_x_impl(size)) _Pre_valid_impl_)
  1047. #define _Pre_opt_z_cap_x_(size) _SAL1_1_Source_(_Pre_opt_z_cap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__cap_x_impl(size)) _Pre_valid_impl_)
  1048. #define _Pre_z_bytecap_x_(size) _SAL1_1_Source_(_Pre_z_bytecap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Pre_valid_impl_)
  1049. #define _Pre_opt_z_bytecap_x_(size) _SAL1_1_Source_(_Pre_opt_z_bytecap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre2_impl_(__zterm_impl,__bytecap_x_impl(size)) _Pre_valid_impl_)
  1050. // known capacity and valid but unknown readable extent
  1051. #define _Pre_valid_cap_(size) _SAL1_1_Source_(_Pre_valid_cap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_impl(size)) _Pre_valid_impl_)
  1052. #define _Pre_opt_valid_cap_(size) _SAL1_1_Source_(_Pre_opt_valid_cap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_impl(size)) _Pre_valid_impl_)
  1053. #define _Pre_valid_bytecap_(size) _SAL1_1_Source_(_Pre_valid_bytecap_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_impl(size)) _Pre_valid_impl_)
  1054. #define _Pre_opt_valid_bytecap_(size) _SAL1_1_Source_(_Pre_opt_valid_bytecap_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_impl(size)) _Pre_valid_impl_)
  1055. #define _Pre_valid_cap_c_(size) _SAL1_1_Source_(_Pre_valid_cap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_c_impl(size)) _Pre_valid_impl_)
  1056. #define _Pre_opt_valid_cap_c_(size) _SAL1_1_Source_(_Pre_opt_valid_cap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_c_impl(size)) _Pre_valid_impl_)
  1057. #define _Pre_valid_bytecap_c_(size) _SAL1_1_Source_(_Pre_valid_bytecap_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_c_impl(size)) _Pre_valid_impl_)
  1058. #define _Pre_opt_valid_bytecap_c_(size) _SAL1_1_Source_(_Pre_opt_valid_bytecap_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_c_impl(size)) _Pre_valid_impl_)
  1059. #define _Pre_valid_cap_x_(size) _SAL1_1_Source_(_Pre_valid_cap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_x_impl(size)) _Pre_valid_impl_)
  1060. #define _Pre_opt_valid_cap_x_(size) _SAL1_1_Source_(_Pre_opt_valid_cap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_x_impl(size)) _Pre_valid_impl_)
  1061. #define _Pre_valid_bytecap_x_(size) _SAL1_1_Source_(_Pre_valid_bytecap_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecap_x_impl(size)) _Pre_valid_impl_)
  1062. #define _Pre_opt_valid_bytecap_x_(size) _SAL1_1_Source_(_Pre_opt_valid_bytecap_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecap_x_impl(size)) _Pre_valid_impl_)
  1063. // e.g. void AppendCharRange( _Pre_count_(cchFrom) const char* rgFrom, size_t cchFrom, _Out_z_cap_(cchTo) char* szTo, size_t cchTo );
  1064. // Valid buffer extent described by another parameter
  1065. #define _Pre_count_(size) _SAL1_1_Source_(_Pre_count_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__count_impl(size)) _Pre_valid_impl_)
  1066. #define _Pre_opt_count_(size) _SAL1_1_Source_(_Pre_opt_count_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__count_impl(size)) _Pre_valid_impl_)
  1067. #define _Pre_bytecount_(size) _SAL1_1_Source_(_Pre_bytecount_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecount_impl(size)) _Pre_valid_impl_)
  1068. #define _Pre_opt_bytecount_(size) _SAL1_1_Source_(_Pre_opt_bytecount_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecount_impl(size)) _Pre_valid_impl_)
  1069. // Valid buffer extent described by a constant expression
  1070. #define _Pre_count_c_(size) _SAL1_1_Source_(_Pre_count_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__count_c_impl(size)) _Pre_valid_impl_)
  1071. #define _Pre_opt_count_c_(size) _SAL1_1_Source_(_Pre_opt_count_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__count_c_impl(size)) _Pre_valid_impl_)
  1072. #define _Pre_bytecount_c_(size) _SAL1_1_Source_(_Pre_bytecount_c_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecount_c_impl(size)) _Pre_valid_impl_)
  1073. #define _Pre_opt_bytecount_c_(size) _SAL1_1_Source_(_Pre_opt_bytecount_c_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecount_c_impl(size)) _Pre_valid_impl_)
  1074. // Valid buffer extent described by a complex expression
  1075. #define _Pre_count_x_(size) _SAL1_1_Source_(_Pre_count_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__count_x_impl(size)) _Pre_valid_impl_)
  1076. #define _Pre_opt_count_x_(size) _SAL1_1_Source_(_Pre_opt_count_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__count_x_impl(size)) _Pre_valid_impl_)
  1077. #define _Pre_bytecount_x_(size) _SAL1_1_Source_(_Pre_bytecount_x_, (size), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__bytecount_x_impl(size)) _Pre_valid_impl_)
  1078. #define _Pre_opt_bytecount_x_(size) _SAL1_1_Source_(_Pre_opt_bytecount_x_, (size), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__bytecount_x_impl(size)) _Pre_valid_impl_)
  1079. // Valid buffer extent described by the difference to another pointer parameter
  1080. #define _Pre_ptrdiff_count_(ptr) _SAL1_1_Source_(_Pre_ptrdiff_count_, (ptr), _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__count_x_impl(__ptrdiff(ptr))) _Pre_valid_impl_)
  1081. #define _Pre_opt_ptrdiff_count_(ptr) _SAL1_1_Source_(_Pre_opt_ptrdiff_count_, (ptr), _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__count_x_impl(__ptrdiff(ptr))) _Pre_valid_impl_)
  1082. // char * strncpy(_Out_cap_(_Count) _Post_maybez_ char * _Dest, _In_z_ const char * _Source, _In_ size_t _Count)
  1083. // buffer maybe zero-terminated after the call
  1084. #define _Post_maybez_ _SAL1_1_Source_(_Post_maybez_, (), _Post1_impl_(__maybezterm_impl))
  1085. // e.g. SIZE_T HeapSize( _In_ HANDLE hHeap, DWORD dwFlags, _Pre_notnull_ _Post_bytecap_(return) LPCVOID lpMem );
  1086. #define _Post_cap_(size) _SAL1_1_Source_(_Post_cap_, (size), _Post1_impl_(__cap_impl(size)))
  1087. #define _Post_bytecap_(size) _SAL1_1_Source_(_Post_bytecap_, (size), _Post1_impl_(__bytecap_impl(size)))
  1088. // e.g. int strlen( _In_z_ _Post_count_(return+1) const char* sz );
  1089. #define _Post_count_(size) _SAL1_1_Source_(_Post_count_, (size), _Post1_impl_(__count_impl(size)) _Post_valid_impl_)
  1090. #define _Post_bytecount_(size) _SAL1_1_Source_(_Post_bytecount_, (size), _Post1_impl_(__bytecount_impl(size)) _Post_valid_impl_)
  1091. #define _Post_count_c_(size) _SAL1_1_Source_(_Post_count_c_, (size), _Post1_impl_(__count_c_impl(size)) _Post_valid_impl_)
  1092. #define _Post_bytecount_c_(size) _SAL1_1_Source_(_Post_bytecount_c_, (size), _Post1_impl_(__bytecount_c_impl(size)) _Post_valid_impl_)
  1093. #define _Post_count_x_(size) _SAL1_1_Source_(_Post_count_x_, (size), _Post1_impl_(__count_x_impl(size)) _Post_valid_impl_)
  1094. #define _Post_bytecount_x_(size) _SAL1_1_Source_(_Post_bytecount_x_, (size), _Post1_impl_(__bytecount_x_impl(size)) _Post_valid_impl_)
  1095. // e.g. size_t CopyStr( _In_z_ const char* szFrom, _Pre_cap_(cch) _Post_z_count_(return+1) char* szFrom, size_t cchFrom );
  1096. #define _Post_z_count_(size) _SAL1_1_Source_(_Post_z_count_, (size), _Post2_impl_(__zterm_impl,__count_impl(size)) _Post_valid_impl_)
  1097. #define _Post_z_bytecount_(size) _SAL1_1_Source_(_Post_z_bytecount_, (size), _Post2_impl_(__zterm_impl,__bytecount_impl(size)) _Post_valid_impl_)
  1098. #define _Post_z_count_c_(size) _SAL1_1_Source_(_Post_z_count_c_, (size), _Post2_impl_(__zterm_impl,__count_c_impl(size)) _Post_valid_impl_)
  1099. #define _Post_z_bytecount_c_(size) _SAL1_1_Source_(_Post_z_bytecount_c_, (size), _Post2_impl_(__zterm_impl,__bytecount_c_impl(size)) _Post_valid_impl_)
  1100. #define _Post_z_count_x_(size) _SAL1_1_Source_(_Post_z_count_x_, (size), _Post2_impl_(__zterm_impl,__count_x_impl(size)) _Post_valid_impl_)
  1101. #define _Post_z_bytecount_x_(size) _SAL1_1_Source_(_Post_z_bytecount_x_, (size), _Post2_impl_(__zterm_impl,__bytecount_x_impl(size)) _Post_valid_impl_)
  1102. //
  1103. // _Prepost_ ---
  1104. //
  1105. // describing conditions that hold before and after the function call
  1106. #define _Prepost_opt_z_ _SAL1_1_Source_(_Prepost_opt_z_, (), _Pre_opt_z_ _Post_z_)
  1107. #define _Prepost_count_(size) _SAL1_1_Source_(_Prepost_count_, (size), _Pre_count_(size) _Post_count_(size))
  1108. #define _Prepost_opt_count_(size) _SAL1_1_Source_(_Prepost_opt_count_, (size), _Pre_opt_count_(size) _Post_count_(size))
  1109. #define _Prepost_bytecount_(size) _SAL1_1_Source_(_Prepost_bytecount_, (size), _Pre_bytecount_(size) _Post_bytecount_(size))
  1110. #define _Prepost_opt_bytecount_(size) _SAL1_1_Source_(_Prepost_opt_bytecount_, (size), _Pre_opt_bytecount_(size) _Post_bytecount_(size))
  1111. #define _Prepost_count_c_(size) _SAL1_1_Source_(_Prepost_count_c_, (size), _Pre_count_c_(size) _Post_count_c_(size))
  1112. #define _Prepost_opt_count_c_(size) _SAL1_1_Source_(_Prepost_opt_count_c_, (size), _Pre_opt_count_c_(size) _Post_count_c_(size))
  1113. #define _Prepost_bytecount_c_(size) _SAL1_1_Source_(_Prepost_bytecount_c_, (size), _Pre_bytecount_c_(size) _Post_bytecount_c_(size))
  1114. #define _Prepost_opt_bytecount_c_(size) _SAL1_1_Source_(_Prepost_opt_bytecount_c_, (size), _Pre_opt_bytecount_c_(size) _Post_bytecount_c_(size))
  1115. #define _Prepost_count_x_(size) _SAL1_1_Source_(_Prepost_count_x_, (size), _Pre_count_x_(size) _Post_count_x_(size))
  1116. #define _Prepost_opt_count_x_(size) _SAL1_1_Source_(_Prepost_opt_count_x_, (size), _Pre_opt_count_x_(size) _Post_count_x_(size))
  1117. #define _Prepost_bytecount_x_(size) _SAL1_1_Source_(_Prepost_bytecount_x_, (size), _Pre_bytecount_x_(size) _Post_bytecount_x_(size))
  1118. #define _Prepost_opt_bytecount_x_(size) _SAL1_1_Source_(_Prepost_opt_bytecount_x_, (size), _Pre_opt_bytecount_x_(size) _Post_bytecount_x_(size))
  1119. #define _Prepost_valid_ _SAL1_1_Source_(_Prepost_valid_, (), _Pre_valid_ _Post_valid_)
  1120. #define _Prepost_opt_valid_ _SAL1_1_Source_(_Prepost_opt_valid_, (), _Pre_opt_valid_ _Post_valid_)
  1121. //
  1122. // _Deref_<both> ---
  1123. //
  1124. // short version for _Deref_pre_<ann> _Deref_post_<ann>
  1125. // describing conditions for array elements or dereferenced pointer parameters that hold before and after the call
  1126. #define _Deref_prepost_z_ _SAL1_1_Source_(_Deref_prepost_z_, (), _Deref_pre_z_ _Deref_post_z_)
  1127. #define _Deref_prepost_opt_z_ _SAL1_1_Source_(_Deref_prepost_opt_z_, (), _Deref_pre_opt_z_ _Deref_post_opt_z_)
  1128. #define _Deref_prepost_cap_(size) _SAL1_1_Source_(_Deref_prepost_cap_, (size), _Deref_pre_cap_(size) _Deref_post_cap_(size))
  1129. #define _Deref_prepost_opt_cap_(size) _SAL1_1_Source_(_Deref_prepost_opt_cap_, (size), _Deref_pre_opt_cap_(size) _Deref_post_opt_cap_(size))
  1130. #define _Deref_prepost_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_bytecap_, (size), _Deref_pre_bytecap_(size) _Deref_post_bytecap_(size))
  1131. #define _Deref_prepost_opt_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_opt_bytecap_, (size), _Deref_pre_opt_bytecap_(size) _Deref_post_opt_bytecap_(size))
  1132. #define _Deref_prepost_cap_x_(size) _SAL1_1_Source_(_Deref_prepost_cap_x_, (size), _Deref_pre_cap_x_(size) _Deref_post_cap_x_(size))
  1133. #define _Deref_prepost_opt_cap_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_cap_x_, (size), _Deref_pre_opt_cap_x_(size) _Deref_post_opt_cap_x_(size))
  1134. #define _Deref_prepost_bytecap_x_(size) _SAL1_1_Source_(_Deref_prepost_bytecap_x_, (size), _Deref_pre_bytecap_x_(size) _Deref_post_bytecap_x_(size))
  1135. #define _Deref_prepost_opt_bytecap_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_bytecap_x_, (size), _Deref_pre_opt_bytecap_x_(size) _Deref_post_opt_bytecap_x_(size))
  1136. #define _Deref_prepost_z_cap_(size) _SAL1_1_Source_(_Deref_prepost_z_cap_, (size), _Deref_pre_z_cap_(size) _Deref_post_z_cap_(size))
  1137. #define _Deref_prepost_opt_z_cap_(size) _SAL1_1_Source_(_Deref_prepost_opt_z_cap_, (size), _Deref_pre_opt_z_cap_(size) _Deref_post_opt_z_cap_(size))
  1138. #define _Deref_prepost_z_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_z_bytecap_, (size), _Deref_pre_z_bytecap_(size) _Deref_post_z_bytecap_(size))
  1139. #define _Deref_prepost_opt_z_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_opt_z_bytecap_, (size), _Deref_pre_opt_z_bytecap_(size) _Deref_post_opt_z_bytecap_(size))
  1140. #define _Deref_prepost_valid_cap_(size) _SAL1_1_Source_(_Deref_prepost_valid_cap_, (size), _Deref_pre_valid_cap_(size) _Deref_post_valid_cap_(size))
  1141. #define _Deref_prepost_opt_valid_cap_(size) _SAL1_1_Source_(_Deref_prepost_opt_valid_cap_, (size), _Deref_pre_opt_valid_cap_(size) _Deref_post_opt_valid_cap_(size))
  1142. #define _Deref_prepost_valid_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_valid_bytecap_, (size), _Deref_pre_valid_bytecap_(size) _Deref_post_valid_bytecap_(size))
  1143. #define _Deref_prepost_opt_valid_bytecap_(size) _SAL1_1_Source_(_Deref_prepost_opt_valid_bytecap_, (size), _Deref_pre_opt_valid_bytecap_(size) _Deref_post_opt_valid_bytecap_(size))
  1144. #define _Deref_prepost_valid_cap_x_(size) _SAL1_1_Source_(_Deref_prepost_valid_cap_x_, (size), _Deref_pre_valid_cap_x_(size) _Deref_post_valid_cap_x_(size))
  1145. #define _Deref_prepost_opt_valid_cap_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_valid_cap_x_, (size), _Deref_pre_opt_valid_cap_x_(size) _Deref_post_opt_valid_cap_x_(size))
  1146. #define _Deref_prepost_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_prepost_valid_bytecap_x_, (size), _Deref_pre_valid_bytecap_x_(size) _Deref_post_valid_bytecap_x_(size))
  1147. #define _Deref_prepost_opt_valid_bytecap_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_valid_bytecap_x_, (size), _Deref_pre_opt_valid_bytecap_x_(size) _Deref_post_opt_valid_bytecap_x_(size))
  1148. #define _Deref_prepost_count_(size) _SAL1_1_Source_(_Deref_prepost_count_, (size), _Deref_pre_count_(size) _Deref_post_count_(size))
  1149. #define _Deref_prepost_opt_count_(size) _SAL1_1_Source_(_Deref_prepost_opt_count_, (size), _Deref_pre_opt_count_(size) _Deref_post_opt_count_(size))
  1150. #define _Deref_prepost_bytecount_(size) _SAL1_1_Source_(_Deref_prepost_bytecount_, (size), _Deref_pre_bytecount_(size) _Deref_post_bytecount_(size))
  1151. #define _Deref_prepost_opt_bytecount_(size) _SAL1_1_Source_(_Deref_prepost_opt_bytecount_, (size), _Deref_pre_opt_bytecount_(size) _Deref_post_opt_bytecount_(size))
  1152. #define _Deref_prepost_count_x_(size) _SAL1_1_Source_(_Deref_prepost_count_x_, (size), _Deref_pre_count_x_(size) _Deref_post_count_x_(size))
  1153. #define _Deref_prepost_opt_count_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_count_x_, (size), _Deref_pre_opt_count_x_(size) _Deref_post_opt_count_x_(size))
  1154. #define _Deref_prepost_bytecount_x_(size) _SAL1_1_Source_(_Deref_prepost_bytecount_x_, (size), _Deref_pre_bytecount_x_(size) _Deref_post_bytecount_x_(size))
  1155. #define _Deref_prepost_opt_bytecount_x_(size) _SAL1_1_Source_(_Deref_prepost_opt_bytecount_x_, (size), _Deref_pre_opt_bytecount_x_(size) _Deref_post_opt_bytecount_x_(size))
  1156. #define _Deref_prepost_valid_ _SAL1_1_Source_(_Deref_prepost_valid_, (), _Deref_pre_valid_ _Deref_post_valid_)
  1157. #define _Deref_prepost_opt_valid_ _SAL1_1_Source_(_Deref_prepost_opt_valid_, (), _Deref_pre_opt_valid_ _Deref_post_opt_valid_)
  1158. //
  1159. // _Deref_<miscellaneous>
  1160. //
  1161. // used with references to arrays
  1162. #define _Deref_out_z_cap_c_(size) _SAL1_1_Source_(_Deref_out_z_cap_c_, (size), _Deref_pre_cap_c_(size) _Deref_post_z_)
  1163. #define _Deref_inout_z_cap_c_(size) _SAL1_1_Source_(_Deref_inout_z_cap_c_, (size), _Deref_pre_z_cap_c_(size) _Deref_post_z_)
  1164. #define _Deref_out_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_out_z_bytecap_c_, (size), _Deref_pre_bytecap_c_(size) _Deref_post_z_)
  1165. #define _Deref_inout_z_bytecap_c_(size) _SAL1_1_Source_(_Deref_inout_z_bytecap_c_, (size), _Deref_pre_z_bytecap_c_(size) _Deref_post_z_)
  1166. #define _Deref_inout_z_ _SAL1_1_Source_(_Deref_inout_z_, (), _Deref_prepost_z_)
  1167. // #pragma endregion Input Buffer SAL 1 compatibility macros
  1168. //============================================================================
  1169. // Implementation Layer:
  1170. //============================================================================
  1171. // Naming conventions:
  1172. // A symbol the begins with _SA_ is for the machinery of creating any
  1173. // annotations; many of those come from sourceannotations.h in the case
  1174. // of attributes.
  1175. // A symbol that ends with _impl is the very lowest level macro. It is
  1176. // not required to be a legal standalone annotation, and in the case
  1177. // of attribute annotations, usually is not. (In the case of some declspec
  1178. // annotations, it might be, but it should not be assumed so.) Those
  1179. // symols will be used in the _PreN..., _PostN... and _RetN... annotations
  1180. // to build up more complete annotations.
  1181. // A symbol ending in _impl_ is reserved to the implementation as well,
  1182. // but it does form a complete annotation; usually they are used to build
  1183. // up even higher level annotations.
  1184. #if _USE_ATTRIBUTES_FOR_SAL || _USE_DECLSPECS_FOR_SAL // [
  1185. // Sharable "_impl" macros: these can be shared between the various annotation
  1186. // forms but are part of the implementation of the macros. These are collected
  1187. // here to assure that only necessary differences in the annotations
  1188. // exist.
  1189. #define _Always_impl_(annos) _Group_(annos _SAL_nop_impl_) _On_failure_impl_(annos _SAL_nop_impl_)
  1190. #define _Bound_impl_ _SA_annotes0(SAL_bound)
  1191. #define _Field_range_impl_(min,max) _Range_impl_(min,max)
  1192. #define _Literal_impl_ _SA_annotes1(SAL_constant, __yes)
  1193. #define _Maybenull_impl_ _SA_annotes1(SAL_null, __maybe)
  1194. #define _Maybevalid_impl_ _SA_annotes1(SAL_valid, __maybe)
  1195. #define _Must_inspect_impl_ _Post_impl_ _SA_annotes0(SAL_mustInspect)
  1196. #define _Notliteral_impl_ _SA_annotes1(SAL_constant, __no)
  1197. #define _Notnull_impl_ _SA_annotes1(SAL_null, __no)
  1198. #define _Notvalid_impl_ _SA_annotes1(SAL_valid, __no)
  1199. #define _NullNull_terminated_impl_ _Group_(_SA_annotes1(SAL_nullTerminated, __yes) _SA_annotes1(SAL_readableTo,inexpressibleCount("NullNull terminated string")))
  1200. #define _Null_impl_ _SA_annotes1(SAL_null, __yes)
  1201. #define _Null_terminated_impl_ _SA_annotes1(SAL_nullTerminated, __yes)
  1202. #define _Out_impl_ _Pre1_impl_(__notnull_impl_notref) _Pre1_impl_(__cap_c_one_notref_impl) _Post_valid_impl_
  1203. #define _Out_opt_impl_ _Pre1_impl_(__maybenull_impl_notref) _Pre1_impl_(__cap_c_one_notref_impl) _Post_valid_impl_
  1204. #define _Points_to_data_impl_ _At_(*_Curr_, _SA_annotes1(SAL_mayBePointer, __no))
  1205. #define _Post_satisfies_impl_(cond) _Post_impl_ _Satisfies_impl_(cond)
  1206. #define _Post_valid_impl_ _Post1_impl_(__valid_impl)
  1207. #define _Pre_satisfies_impl_(cond) _Pre_impl_ _Satisfies_impl_(cond)
  1208. #define _Pre_valid_impl_ _Pre1_impl_(__valid_impl)
  1209. #define _Range_impl_(min,max) _SA_annotes2(SAL_range, min, max)
  1210. #define _Readable_bytes_impl_(size) _SA_annotes1(SAL_readableTo, byteCount(size))
  1211. #define _Readable_elements_impl_(size) _SA_annotes1(SAL_readableTo, elementCount(size))
  1212. #define _Ret_valid_impl_ _Ret1_impl_(__valid_impl)
  1213. #define _Satisfies_impl_(cond) _SA_annotes1(SAL_satisfies, cond)
  1214. #define _Valid_impl_ _SA_annotes1(SAL_valid, __yes)
  1215. #define _Writable_bytes_impl_(size) _SA_annotes1(SAL_writableTo, byteCount(size))
  1216. #define _Writable_elements_impl_(size) _SA_annotes1(SAL_writableTo, elementCount(size))
  1217. #define _In_range_impl_(min,max) _Pre_impl_ _Range_impl_(min,max)
  1218. #define _Out_range_impl_(min,max) _Post_impl_ _Range_impl_(min,max)
  1219. #define _Ret_range_impl_(min,max) _Post_impl_ _Range_impl_(min,max)
  1220. #define _Deref_in_range_impl_(min,max) _Deref_pre_impl_ _Range_impl_(min,max)
  1221. #define _Deref_out_range_impl_(min,max) _Deref_post_impl_ _Range_impl_(min,max)
  1222. #define _Deref_ret_range_impl_(min,max) _Deref_post_impl_ _Range_impl_(min,max)
  1223. #define _Deref_pre_impl_ _Pre_impl_ _Notref_impl_ _Deref_impl_
  1224. #define _Deref_post_impl_ _Post_impl_ _Notref_impl_ _Deref_impl_
  1225. // The following are for the implementation machinery, and are not
  1226. // suitable for annotating general code.
  1227. // We're tying to phase this out, someday. The parser quotes the param.
  1228. #define __AuToQuOtE _SA_annotes0(SAL_AuToQuOtE)
  1229. // Normally the parser does some simple type checking of annotation params,
  1230. // defer that check to the plugin.
  1231. #define __deferTypecheck _SA_annotes0(SAL_deferTypecheck)
  1232. #define _SA_SPECSTRIZE( x ) #x
  1233. #define _SAL_nop_impl_ /* nothing */
  1234. #define __nop_impl(x) x
  1235. #endif
  1236. #if _USE_ATTRIBUTES_FOR_SAL // [
  1237. // Using attributes for sal
  1238. #include "codeanalysis\sourceannotations.h"
  1239. #define _SA_annotes0(n) [SAL_annotes(Name=#n)]
  1240. #define _SA_annotes1(n,pp1) [SAL_annotes(Name=#n, p1=_SA_SPECSTRIZE(pp1))]
  1241. #define _SA_annotes2(n,pp1,pp2) [SAL_annotes(Name=#n, p1=_SA_SPECSTRIZE(pp1), p2=_SA_SPECSTRIZE(pp2))]
  1242. #define _SA_annotes3(n,pp1,pp2,pp3) [SAL_annotes(Name=#n, p1=_SA_SPECSTRIZE(pp1), p2=_SA_SPECSTRIZE(pp2), p3=_SA_SPECSTRIZE(pp3))]
  1243. #define _Pre_impl_ [SAL_pre]
  1244. #define _Post_impl_ [SAL_post]
  1245. #define _Deref_impl_ [SAL_deref]
  1246. #define _Notref_impl_ [SAL_notref]
  1247. // Declare a function to be an annotation or primop (respectively).
  1248. // Done this way so that they don't appear in the regular compiler's
  1249. // namespace.
  1250. #define __ANNOTATION(fun) _SA_annotes0(SAL_annotation) void __SA_##fun;
  1251. #define __PRIMOP(type, fun) _SA_annotes0(SAL_primop) type __SA_##fun;
  1252. #define __QUALIFIER(fun) _SA_annotes0(SAL_qualifier) void __SA_##fun;
  1253. // Benign declspec needed here for WindowsPREfast
  1254. #define __In_impl_ [SA_Pre(Valid=SA_Yes)] [SA_Pre(Deref=1, Notref=1, Access=SA_Read)] __declspec("SAL_pre SAL_valid")
  1255. #elif _USE_DECLSPECS_FOR_SAL // ][
  1256. // Using declspecs for sal
  1257. #define _SA_annotes0(n) __declspec(#n)
  1258. #define _SA_annotes1(n,pp1) __declspec(#n "(" _SA_SPECSTRIZE(pp1) ")" )
  1259. #define _SA_annotes2(n,pp1,pp2) __declspec(#n "(" _SA_SPECSTRIZE(pp1) "," _SA_SPECSTRIZE(pp2) ")")
  1260. #define _SA_annotes3(n,pp1,pp2,pp3) __declspec(#n "(" _SA_SPECSTRIZE(pp1) "," _SA_SPECSTRIZE(pp2) "," _SA_SPECSTRIZE(pp3) ")")
  1261. #define _Pre_impl_ _SA_annotes0(SAL_pre)
  1262. #define _Post_impl_ _SA_annotes0(SAL_post)
  1263. #define _Deref_impl_ _SA_annotes0(SAL_deref)
  1264. #define _Notref_impl_ _SA_annotes0(SAL_notref)
  1265. // Declare a function to be an annotation or primop (respectively).
  1266. // Done this way so that they don't appear in the regular compiler's
  1267. // namespace.
  1268. #define __ANNOTATION(fun) _SA_annotes0(SAL_annotation) void __SA_##fun
  1269. #define __PRIMOP(type, fun) _SA_annotes0(SAL_primop) type __SA_##fun
  1270. #define __QUALIFIER(fun) _SA_annotes0(SAL_qualifier) void __SA_##fun;
  1271. #define __In_impl_ _Pre_impl_ _SA_annotes0(SAL_valid) _Pre_impl_ _Deref_impl_ _Notref_impl_ _SA_annotes0(SAL_readonly)
  1272. #else // ][
  1273. // Using "nothing" for sal
  1274. #define _SA_annotes0(n)
  1275. #define _SA_annotes1(n,pp1)
  1276. #define _SA_annotes2(n,pp1,pp2)
  1277. #define _SA_annotes3(n,pp1,pp2,pp3)
  1278. #define __ANNOTATION(fun)
  1279. #define __PRIMOP(type, fun)
  1280. #define __QUALIFIER(type, fun)
  1281. #endif // ]
  1282. #if _USE_ATTRIBUTES_FOR_SAL || _USE_DECLSPECS_FOR_SAL // [
  1283. // Declare annotations that need to be declared.
  1284. __ANNOTATION(SAL_useHeader(void));
  1285. __ANNOTATION(SAL_bound(void));
  1286. __ANNOTATION(SAL_allocator(void)); //??? resolve with PFD
  1287. __ANNOTATION(SAL_file_parser(__AuToQuOtE __In_impl_ char *, __In_impl_ char *));
  1288. __ANNOTATION(SAL_source_code_content(__In_impl_ char *));
  1289. __ANNOTATION(SAL_analysisHint(__AuToQuOtE __In_impl_ char *));
  1290. __ANNOTATION(SAL_untrusted_data_source(__AuToQuOtE __In_impl_ char *));
  1291. __ANNOTATION(SAL_untrusted_data_source_this(__AuToQuOtE __In_impl_ char *));
  1292. __ANNOTATION(SAL_validated(__AuToQuOtE __In_impl_ char *));
  1293. __ANNOTATION(SAL_validated_this(__AuToQuOtE __In_impl_ char *));
  1294. __ANNOTATION(SAL_encoded(void));
  1295. __ANNOTATION(SAL_adt(__AuToQuOtE __In_impl_ char *, __AuToQuOtE __In_impl_ char *));
  1296. __ANNOTATION(SAL_add_adt_property(__AuToQuOtE __In_impl_ char *, __AuToQuOtE __In_impl_ char *));
  1297. __ANNOTATION(SAL_remove_adt_property(__AuToQuOtE __In_impl_ char *, __AuToQuOtE __In_impl_ char *));
  1298. __ANNOTATION(SAL_transfer_adt_property_from(__AuToQuOtE __In_impl_ char *));
  1299. __ANNOTATION(SAL_post_type(__AuToQuOtE __In_impl_ char *));
  1300. __ANNOTATION(SAL_volatile(void));
  1301. __ANNOTATION(SAL_nonvolatile(void));
  1302. __ANNOTATION(SAL_entrypoint(__AuToQuOtE __In_impl_ char *, __AuToQuOtE __In_impl_ char *));
  1303. __ANNOTATION(SAL_blocksOn(__In_impl_ void*));
  1304. __ANNOTATION(SAL_mustInspect(void));
  1305. // Only appears in model files, but needs to be declared.
  1306. __ANNOTATION(SAL_TypeName(__AuToQuOtE __In_impl_ char *));
  1307. // To be declared well-known soon.
  1308. __ANNOTATION(SAL_interlocked(void);)
  1309. #pragma warning (suppress: 28227 28241)
  1310. __ANNOTATION(SAL_name(__In_impl_ char *, __In_impl_ char *, __In_impl_ char *);)
  1311. __PRIMOP(char *, _Macro_value_(__In_impl_ char *));
  1312. __PRIMOP(int, _Macro_defined_(__In_impl_ char *));
  1313. __PRIMOP(char *, _Strstr_(__In_impl_ char *, __In_impl_ char *));
  1314. #endif // ]
  1315. #if _USE_ATTRIBUTES_FOR_SAL // [
  1316. #define _Check_return_impl_ [SA_Post(MustCheck=SA_Yes)]
  1317. #define _Success_impl_(expr) [SA_Success(Condition=#expr)]
  1318. #define _On_failure_impl_(annos) [SAL_context(p1="SAL_failed")] _Group_(_Post_impl_ _Group_(annos _SAL_nop_impl_))
  1319. #define _Printf_format_string_impl_ [SA_FormatString(Style="printf")]
  1320. #define _Scanf_format_string_impl_ [SA_FormatString(Style="scanf")]
  1321. #define _Scanf_s_format_string_impl_ [SA_FormatString(Style="scanf_s")]
  1322. #define _In_bound_impl_ [SA_PreBound(Deref=0)]
  1323. #define _Out_bound_impl_ [SA_PostBound(Deref=0)]
  1324. #define _Ret_bound_impl_ [SA_PostBound(Deref=0)]
  1325. #define _Deref_in_bound_impl_ [SA_PreBound(Deref=1)]
  1326. #define _Deref_out_bound_impl_ [SA_PostBound(Deref=1)]
  1327. #define _Deref_ret_bound_impl_ [SA_PostBound(Deref=1)]
  1328. #define __valid_impl Valid=SA_Yes
  1329. #define __maybevalid_impl Valid=SA_Maybe
  1330. #define __notvalid_impl Valid=SA_No
  1331. #define __null_impl Null=SA_Yes
  1332. #define __maybenull_impl Null=SA_Maybe
  1333. #define __notnull_impl Null=SA_No
  1334. #define __null_impl_notref Null=SA_Yes,Notref=1
  1335. #define __maybenull_impl_notref Null=SA_Maybe,Notref=1
  1336. #define __notnull_impl_notref Null=SA_No,Notref=1
  1337. #define __zterm_impl NullTerminated=SA_Yes
  1338. #define __maybezterm_impl NullTerminated=SA_Maybe
  1339. #define __maybzterm_impl NullTerminated=SA_Maybe
  1340. #define __notzterm_impl NullTerminated=SA_No
  1341. #define __readaccess_impl Access=SA_Read
  1342. #define __writeaccess_impl Access=SA_Write
  1343. #define __allaccess_impl Access=SA_ReadWrite
  1344. #define __readaccess_impl_notref Access=SA_Read,Notref=1
  1345. #define __writeaccess_impl_notref Access=SA_Write,Notref=1
  1346. #define __allaccess_impl_notref Access=SA_ReadWrite,Notref=1
  1347. #if _MSC_VER >= 1610 /*IFSTRIP=IGN*/ // [
  1348. // For SAL2, we need to expect general expressions.
  1349. #define __cap_impl(size) WritableElements="\n"#size
  1350. #define __bytecap_impl(size) WritableBytes="\n"#size
  1351. #define __bytecount_impl(size) ValidBytes="\n"#size
  1352. #define __count_impl(size) ValidElements="\n"#size
  1353. #else // ][
  1354. #define __cap_impl(size) WritableElements=#size
  1355. #define __bytecap_impl(size) WritableBytes=#size
  1356. #define __bytecount_impl(size) ValidBytes=#size
  1357. #define __count_impl(size) ValidElements=#size
  1358. #endif // ]
  1359. #define __cap_c_impl(size) WritableElementsConst=size
  1360. #define __cap_c_one_notref_impl WritableElementsConst=1,Notref=1
  1361. #define __cap_for_impl(param) WritableElementsLength=#param
  1362. #define __cap_x_impl(size) WritableElements="\n@"#size
  1363. #define __bytecap_c_impl(size) WritableBytesConst=size
  1364. #define __bytecap_x_impl(size) WritableBytes="\n@"#size
  1365. #define __mult_impl(mult,size) __cap_impl((mult)*(size))
  1366. #define __count_c_impl(size) ValidElementsConst=size
  1367. #define __count_x_impl(size) ValidElements="\n@"#size
  1368. #define __bytecount_c_impl(size) ValidBytesConst=size
  1369. #define __bytecount_x_impl(size) ValidBytes="\n@"#size
  1370. #define _At_impl_(target, annos) [SAL_at(p1=#target)] _Group_(annos)
  1371. #define _At_buffer_impl_(target, iter, bound, annos) [SAL_at_buffer(p1=#target, p2=#iter, p3=#bound)] _Group_(annos)
  1372. #define _When_impl_(expr, annos) [SAL_when(p1=#expr)] _Group_(annos)
  1373. #define _Group_impl_(annos) [SAL_begin] annos [SAL_end]
  1374. #define _GrouP_impl_(annos) [SAL_BEGIN] annos [SAL_END]
  1375. #define _Use_decl_anno_impl_ _SA_annotes0(SAL_useHeader) // this is a special case!
  1376. #define _Pre1_impl_(p1) [SA_Pre(p1)]
  1377. #define _Pre2_impl_(p1,p2) [SA_Pre(p1,p2)]
  1378. #define _Pre3_impl_(p1,p2,p3) [SA_Pre(p1,p2,p3)]
  1379. #define _Post1_impl_(p1) [SA_Post(p1)]
  1380. #define _Post2_impl_(p1,p2) [SA_Post(p1,p2)]
  1381. #define _Post3_impl_(p1,p2,p3) [SA_Post(p1,p2,p3)]
  1382. #define _Ret1_impl_(p1) [SA_Post(p1)]
  1383. #define _Ret2_impl_(p1,p2) [SA_Post(p1,p2)]
  1384. #define _Ret3_impl_(p1,p2,p3) [SA_Post(p1,p2,p3)]
  1385. #define _Deref_pre1_impl_(p1) [SA_Pre(Deref=1,p1)]
  1386. #define _Deref_pre2_impl_(p1,p2) [SA_Pre(Deref=1,p1,p2)]
  1387. #define _Deref_pre3_impl_(p1,p2,p3) [SA_Pre(Deref=1,p1,p2,p3)]
  1388. #define _Deref_post1_impl_(p1) [SA_Post(Deref=1,p1)]
  1389. #define _Deref_post2_impl_(p1,p2) [SA_Post(Deref=1,p1,p2)]
  1390. #define _Deref_post3_impl_(p1,p2,p3) [SA_Post(Deref=1,p1,p2,p3)]
  1391. #define _Deref_ret1_impl_(p1) [SA_Post(Deref=1,p1)]
  1392. #define _Deref_ret2_impl_(p1,p2) [SA_Post(Deref=1,p1,p2)]
  1393. #define _Deref_ret3_impl_(p1,p2,p3) [SA_Post(Deref=1,p1,p2,p3)]
  1394. #define _Deref2_pre1_impl_(p1) [SA_Pre(Deref=2,Notref=1,p1)]
  1395. #define _Deref2_post1_impl_(p1) [SA_Post(Deref=2,Notref=1,p1)]
  1396. #define _Deref2_ret1_impl_(p1) [SA_Post(Deref=2,Notref=1,p1)]
  1397. // Obsolete -- may be needed for transition to attributes.
  1398. #define __inner_typefix(ctype) [SAL_typefix(p1=_SA_SPECSTRIZE(ctype))]
  1399. #define __inner_exceptthat [SAL_except]
  1400. #elif _USE_DECLSPECS_FOR_SAL // ][
  1401. #define _Check_return_impl_ __post _SA_annotes0(SAL_checkReturn)
  1402. #define _Success_impl_(expr) _SA_annotes1(SAL_success, expr)
  1403. #define _On_failure_impl_(annos) _SA_annotes1(SAL_context, SAL_failed) _Group_(_Post_impl_ _Group_(_SAL_nop_impl_ annos))
  1404. #define _Printf_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "printf")
  1405. #define _Scanf_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "scanf")
  1406. #define _Scanf_s_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "scanf_s")
  1407. #define _In_bound_impl_ _Pre_impl_ _Bound_impl_
  1408. #define _Out_bound_impl_ _Post_impl_ _Bound_impl_
  1409. #define _Ret_bound_impl_ _Post_impl_ _Bound_impl_
  1410. #define _Deref_in_bound_impl_ _Deref_pre_impl_ _Bound_impl_
  1411. #define _Deref_out_bound_impl_ _Deref_post_impl_ _Bound_impl_
  1412. #define _Deref_ret_bound_impl_ _Deref_post_impl_ _Bound_impl_
  1413. #define __null_impl _SA_annotes0(SAL_null) // _SA_annotes1(SAL_null, __yes)
  1414. #define __notnull_impl _SA_annotes0(SAL_notnull) // _SA_annotes1(SAL_null, __no)
  1415. #define __maybenull_impl _SA_annotes0(SAL_maybenull) // _SA_annotes1(SAL_null, __maybe)
  1416. #define __valid_impl _SA_annotes0(SAL_valid) // _SA_annotes1(SAL_valid, __yes)
  1417. #define __notvalid_impl _SA_annotes0(SAL_notvalid) // _SA_annotes1(SAL_valid, __no)
  1418. #define __maybevalid_impl _SA_annotes0(SAL_maybevalid) // _SA_annotes1(SAL_valid, __maybe)
  1419. #define __null_impl_notref _Notref_ _Null_impl_
  1420. #define __maybenull_impl_notref _Notref_ _Maybenull_impl_
  1421. #define __notnull_impl_notref _Notref_ _Notnull_impl_
  1422. #define __zterm_impl _SA_annotes1(SAL_nullTerminated, __yes)
  1423. #define __maybezterm_impl _SA_annotes1(SAL_nullTerminated, __maybe)
  1424. #define __maybzterm_impl _SA_annotes1(SAL_nullTerminated, __maybe)
  1425. #define __notzterm_impl _SA_annotes1(SAL_nullTerminated, __no)
  1426. #define __readaccess_impl _SA_annotes1(SAL_access, 0x1)
  1427. #define __writeaccess_impl _SA_annotes1(SAL_access, 0x2)
  1428. #define __allaccess_impl _SA_annotes1(SAL_access, 0x3)
  1429. #define __readaccess_impl_notref _Notref_ _SA_annotes1(SAL_access, 0x1)
  1430. #define __writeaccess_impl_notref _Notref_ _SA_annotes1(SAL_access, 0x2)
  1431. #define __allaccess_impl_notref _Notref_ _SA_annotes1(SAL_access, 0x3)
  1432. #define __cap_impl(size) _SA_annotes1(SAL_writableTo,elementCount(size))
  1433. #define __cap_c_impl(size) _SA_annotes1(SAL_writableTo,elementCount(size))
  1434. #define __cap_c_one_notref_impl _Notref_ _SA_annotes1(SAL_writableTo,elementCount(1))
  1435. #define __cap_for_impl(param) _SA_annotes1(SAL_writableTo,inexpressibleCount(sizeof(param)))
  1436. #define __cap_x_impl(size) _SA_annotes1(SAL_writableTo,inexpressibleCount(#size))
  1437. #define __bytecap_impl(size) _SA_annotes1(SAL_writableTo,byteCount(size))
  1438. #define __bytecap_c_impl(size) _SA_annotes1(SAL_writableTo,byteCount(size))
  1439. #define __bytecap_x_impl(size) _SA_annotes1(SAL_writableTo,inexpressibleCount(#size))
  1440. #define __mult_impl(mult,size) _SA_annotes1(SAL_writableTo,(mult)*(size))
  1441. #define __count_impl(size) _SA_annotes1(SAL_readableTo,elementCount(size))
  1442. #define __count_c_impl(size) _SA_annotes1(SAL_readableTo,elementCount(size))
  1443. #define __count_x_impl(size) _SA_annotes1(SAL_readableTo,inexpressibleCount(#size))
  1444. #define __bytecount_impl(size) _SA_annotes1(SAL_readableTo,byteCount(size))
  1445. #define __bytecount_c_impl(size) _SA_annotes1(SAL_readableTo,byteCount(size))
  1446. #define __bytecount_x_impl(size) _SA_annotes1(SAL_readableTo,inexpressibleCount(#size))
  1447. #define _At_impl_(target, annos) _SA_annotes0(SAL_at(target)) _Group_(annos)
  1448. #define _At_buffer_impl_(target, iter, bound, annos) _SA_annotes3(SAL_at_buffer, target, iter, bound) _Group_(annos)
  1449. #define _Group_impl_(annos) _SA_annotes0(SAL_begin) annos _SA_annotes0(SAL_end)
  1450. #define _GrouP_impl_(annos) _SA_annotes0(SAL_BEGIN) annos _SA_annotes0(SAL_END)
  1451. #define _When_impl_(expr, annos) _SA_annotes0(SAL_when(expr)) _Group_(annos)
  1452. #define _Use_decl_anno_impl_ __declspec("SAL_useHeader()") // this is a special case!
  1453. #define _Pre1_impl_(p1) _Pre_impl_ p1
  1454. #define _Pre2_impl_(p1,p2) _Pre_impl_ p1 _Pre_impl_ p2
  1455. #define _Pre3_impl_(p1,p2,p3) _Pre_impl_ p1 _Pre_impl_ p2 _Pre_impl_ p3
  1456. #define _Post1_impl_(p1) _Post_impl_ p1
  1457. #define _Post2_impl_(p1,p2) _Post_impl_ p1 _Post_impl_ p2
  1458. #define _Post3_impl_(p1,p2,p3) _Post_impl_ p1 _Post_impl_ p2 _Post_impl_ p3
  1459. #define _Ret1_impl_(p1) _Post_impl_ p1
  1460. #define _Ret2_impl_(p1,p2) _Post_impl_ p1 _Post_impl_ p2
  1461. #define _Ret3_impl_(p1,p2,p3) _Post_impl_ p1 _Post_impl_ p2 _Post_impl_ p3
  1462. #define _Deref_pre1_impl_(p1) _Deref_pre_impl_ p1
  1463. #define _Deref_pre2_impl_(p1,p2) _Deref_pre_impl_ p1 _Deref_pre_impl_ p2
  1464. #define _Deref_pre3_impl_(p1,p2,p3) _Deref_pre_impl_ p1 _Deref_pre_impl_ p2 _Deref_pre_impl_ p3
  1465. #define _Deref_post1_impl_(p1) _Deref_post_impl_ p1
  1466. #define _Deref_post2_impl_(p1,p2) _Deref_post_impl_ p1 _Deref_post_impl_ p2
  1467. #define _Deref_post3_impl_(p1,p2,p3) _Deref_post_impl_ p1 _Deref_post_impl_ p2 _Deref_post_impl_ p3
  1468. #define _Deref_ret1_impl_(p1) _Deref_post_impl_ p1
  1469. #define _Deref_ret2_impl_(p1,p2) _Deref_post_impl_ p1 _Deref_post_impl_ p2
  1470. #define _Deref_ret3_impl_(p1,p2,p3) _Deref_post_impl_ p1 _Deref_post_impl_ p2 _Deref_post_impl_ p3
  1471. #define _Deref2_pre1_impl_(p1) _Deref_pre_impl_ _Notref_impl_ _Deref_impl_ p1
  1472. #define _Deref2_post1_impl_(p1) _Deref_post_impl_ _Notref_impl_ _Deref_impl_ p1
  1473. #define _Deref2_ret1_impl_(p1) _Deref_post_impl_ _Notref_impl_ _Deref_impl_ p1
  1474. #define __inner_typefix(ctype) _SA_annotes1(SAL_typefix, ctype)
  1475. #define __inner_exceptthat _SA_annotes0(SAL_except)
  1476. #elif defined(_MSC_EXTENSIONS) && !defined( MIDL_PASS ) && !defined(__midl) && !defined(RC_INVOKED) && defined(_PFT_VER) && _MSC_VER >= 1400 /*IFSTRIP=IGN*/ // ][
  1477. // minimum attribute expansion for foreground build
  1478. #pragma push_macro( "SA" )
  1479. #pragma push_macro( "REPEATABLE" )
  1480. #ifdef __cplusplus // [
  1481. #define SA( id ) id
  1482. #define REPEATABLE [repeatable]
  1483. #else // !__cplusplus // ][
  1484. #define SA( id ) SA_##id
  1485. #define REPEATABLE
  1486. #endif // !__cplusplus // ]
  1487. REPEATABLE
  1488. [source_annotation_attribute( SA( Parameter ) )]
  1489. struct __P_impl
  1490. {
  1491. #ifdef __cplusplus // [
  1492. __P_impl();
  1493. #endif // ]
  1494. int __d_;
  1495. };
  1496. typedef struct __P_impl __P_impl;
  1497. REPEATABLE
  1498. [source_annotation_attribute( SA( ReturnValue ) )]
  1499. struct __R_impl
  1500. {
  1501. #ifdef __cplusplus // [
  1502. __R_impl();
  1503. #endif // ]
  1504. int __d_;
  1505. };
  1506. typedef struct __R_impl __R_impl;
  1507. [source_annotation_attribute( SA( Method ) )]
  1508. struct __M_
  1509. {
  1510. #ifdef __cplusplus // [
  1511. __M_();
  1512. #endif // ]
  1513. int __d_;
  1514. };
  1515. typedef struct __M_ __M_;
  1516. [source_annotation_attribute( SA( All ) )]
  1517. struct __A_
  1518. {
  1519. #ifdef __cplusplus // [
  1520. __A_();
  1521. #endif // ]
  1522. int __d_;
  1523. };
  1524. typedef struct __A_ __A_;
  1525. [source_annotation_attribute( SA( Field ) )]
  1526. struct __F_
  1527. {
  1528. #ifdef __cplusplus // [
  1529. __F_();
  1530. #endif // ]
  1531. int __d_;
  1532. };
  1533. typedef struct __F_ __F_;
  1534. #pragma pop_macro( "REPEATABLE" )
  1535. #pragma pop_macro( "SA" )
  1536. #define _SAL_nop_impl_
  1537. #define _At_impl_(target, annos) [__A_(__d_=0)]
  1538. #define _At_buffer_impl_(target, iter, bound, annos) [__A_(__d_=0)]
  1539. #define _When_impl_(expr, annos) annos
  1540. #define _Group_impl_(annos) annos
  1541. #define _GrouP_impl_(annos) annos
  1542. #define _Use_decl_anno_impl_ [__M_(__d_=0)]
  1543. #define _Points_to_data_impl_ [__P_impl(__d_=0)]
  1544. #define _Literal_impl_ [__P_impl(__d_=0)]
  1545. #define _Notliteral_impl_ [__P_impl(__d_=0)]
  1546. #define _Pre_valid_impl_ [__P_impl(__d_=0)]
  1547. #define _Post_valid_impl_ [__P_impl(__d_=0)]
  1548. #define _Ret_valid_impl_ [__R_impl(__d_=0)]
  1549. #define _Check_return_impl_ [__R_impl(__d_=0)]
  1550. #define _Must_inspect_impl_ [__R_impl(__d_=0)]
  1551. #define _Success_impl_(expr) [__M_(__d_=0)]
  1552. #define _On_failure_impl_(expr) [__M_(__d_=0)]
  1553. #define _Always_impl_(expr) [__M_(__d_=0)]
  1554. #define _Printf_format_string_impl_ [__P_impl(__d_=0)]
  1555. #define _Scanf_format_string_impl_ [__P_impl(__d_=0)]
  1556. #define _Scanf_s_format_string_impl_ [__P_impl(__d_=0)]
  1557. #define _Raises_SEH_exception_impl_ [__M_(__d_=0)]
  1558. #define _Maybe_raises_SEH_exception_impl_ [__M_(__d_=0)]
  1559. #define _In_bound_impl_ [__P_impl(__d_=0)]
  1560. #define _Out_bound_impl_ [__P_impl(__d_=0)]
  1561. #define _Ret_bound_impl_ [__R_impl(__d_=0)]
  1562. #define _Deref_in_bound_impl_ [__P_impl(__d_=0)]
  1563. #define _Deref_out_bound_impl_ [__P_impl(__d_=0)]
  1564. #define _Deref_ret_bound_impl_ [__R_impl(__d_=0)]
  1565. #define _Range_impl_(min,max) [__P_impl(__d_=0)]
  1566. #define _In_range_impl_(min,max) [__P_impl(__d_=0)]
  1567. #define _Out_range_impl_(min,max) [__P_impl(__d_=0)]
  1568. #define _Ret_range_impl_(min,max) [__R_impl(__d_=0)]
  1569. #define _Deref_in_range_impl_(min,max) [__P_impl(__d_=0)]
  1570. #define _Deref_out_range_impl_(min,max) [__P_impl(__d_=0)]
  1571. #define _Deref_ret_range_impl_(min,max) [__R_impl(__d_=0)]
  1572. #define _Field_range_impl_(min,max) [__F_(__d_=0)]
  1573. #define _Pre_satisfies_impl_(cond) [__A_(__d_=0)]
  1574. #define _Post_satisfies_impl_(cond) [__A_(__d_=0)]
  1575. #define _Satisfies_impl_(cond) [__A_(__d_=0)]
  1576. #define _Null_impl_ [__A_(__d_=0)]
  1577. #define _Notnull_impl_ [__A_(__d_=0)]
  1578. #define _Maybenull_impl_ [__A_(__d_=0)]
  1579. #define _Valid_impl_ [__A_(__d_=0)]
  1580. #define _Notvalid_impl_ [__A_(__d_=0)]
  1581. #define _Maybevalid_impl_ [__A_(__d_=0)]
  1582. #define _Readable_bytes_impl_(size) [__A_(__d_=0)]
  1583. #define _Readable_elements_impl_(size) [__A_(__d_=0)]
  1584. #define _Writable_bytes_impl_(size) [__A_(__d_=0)]
  1585. #define _Writable_elements_impl_(size) [__A_(__d_=0)]
  1586. #define _Null_terminated_impl_ [__A_(__d_=0)]
  1587. #define _NullNull_terminated_impl_ [__A_(__d_=0)]
  1588. #define _Pre_impl_ [__P_impl(__d_=0)]
  1589. #define _Pre1_impl_(p1) [__P_impl(__d_=0)]
  1590. #define _Pre2_impl_(p1,p2) [__P_impl(__d_=0)]
  1591. #define _Pre3_impl_(p1,p2,p3) [__P_impl(__d_=0)]
  1592. #define _Post_impl_ [__P_impl(__d_=0)]
  1593. #define _Post1_impl_(p1) [__P_impl(__d_=0)]
  1594. #define _Post2_impl_(p1,p2) [__P_impl(__d_=0)]
  1595. #define _Post3_impl_(p1,p2,p3) [__P_impl(__d_=0)]
  1596. #define _Ret1_impl_(p1) [__R_impl(__d_=0)]
  1597. #define _Ret2_impl_(p1,p2) [__R_impl(__d_=0)]
  1598. #define _Ret3_impl_(p1,p2,p3) [__R_impl(__d_=0)]
  1599. #define _Deref_pre1_impl_(p1) [__P_impl(__d_=0)]
  1600. #define _Deref_pre2_impl_(p1,p2) [__P_impl(__d_=0)]
  1601. #define _Deref_pre3_impl_(p1,p2,p3) [__P_impl(__d_=0)]
  1602. #define _Deref_post1_impl_(p1) [__P_impl(__d_=0)]
  1603. #define _Deref_post2_impl_(p1,p2) [__P_impl(__d_=0)]
  1604. #define _Deref_post3_impl_(p1,p2,p3) [__P_impl(__d_=0)]
  1605. #define _Deref_ret1_impl_(p1) [__R_impl(__d_=0)]
  1606. #define _Deref_ret2_impl_(p1,p2) [__R_impl(__d_=0)]
  1607. #define _Deref_ret3_impl_(p1,p2,p3) [__R_impl(__d_=0)]
  1608. #define _Deref2_pre1_impl_(p1) //[__P_impl(__d_=0)]
  1609. #define _Deref2_post1_impl_(p1) //[__P_impl(__d_=0)]
  1610. #define _Deref2_ret1_impl_(p1) //[__P_impl(__d_=0)]
  1611. #else // ][
  1612. #define _SAL_nop_impl_ X
  1613. #define _At_impl_(target, annos)
  1614. #define _When_impl_(expr, annos)
  1615. #define _Group_impl_(annos)
  1616. #define _GrouP_impl_(annos)
  1617. #define _At_buffer_impl_(target, iter, bound, annos)
  1618. #define _Use_decl_anno_impl_
  1619. #define _Points_to_data_impl_
  1620. #define _Literal_impl_
  1621. #define _Notliteral_impl_
  1622. #define _Notref_impl_
  1623. #define _Pre_valid_impl_
  1624. #define _Post_valid_impl_
  1625. #define _Ret_valid_impl_
  1626. #define _Check_return_impl_
  1627. #define _Must_inspect_impl_
  1628. #define _Success_impl_(expr)
  1629. #define _On_failure_impl_(annos)
  1630. #define _Always_impl_(annos)
  1631. #define _Printf_format_string_impl_
  1632. #define _Scanf_format_string_impl_
  1633. #define _Scanf_s_format_string_impl_
  1634. #define _In_bound_impl_
  1635. #define _Out_bound_impl_
  1636. #define _Ret_bound_impl_
  1637. #define _Deref_in_bound_impl_
  1638. #define _Deref_out_bound_impl_
  1639. #define _Deref_ret_bound_impl_
  1640. #define _Range_impl_(min,max)
  1641. #define _In_range_impl_(min,max)
  1642. #define _Out_range_impl_(min,max)
  1643. #define _Ret_range_impl_(min,max)
  1644. #define _Deref_in_range_impl_(min,max)
  1645. #define _Deref_out_range_impl_(min,max)
  1646. #define _Deref_ret_range_impl_(min,max)
  1647. #define _Satisfies_impl_(expr)
  1648. #define _Pre_satisfies_impl_(expr)
  1649. #define _Post_satisfies_impl_(expr)
  1650. #define _Null_impl_
  1651. #define _Notnull_impl_
  1652. #define _Maybenull_impl_
  1653. #define _Valid_impl_
  1654. #define _Notvalid_impl_
  1655. #define _Maybevalid_impl_
  1656. #define _Field_range_impl_(min,max)
  1657. #define _Pre_impl_
  1658. #define _Pre1_impl_(p1)
  1659. #define _Pre2_impl_(p1,p2)
  1660. #define _Pre3_impl_(p1,p2,p3)
  1661. #define _Post_impl_
  1662. #define _Post1_impl_(p1)
  1663. #define _Post2_impl_(p1,p2)
  1664. #define _Post3_impl_(p1,p2,p3)
  1665. #define _Ret1_impl_(p1)
  1666. #define _Ret2_impl_(p1,p2)
  1667. #define _Ret3_impl_(p1,p2,p3)
  1668. #define _Deref_pre1_impl_(p1)
  1669. #define _Deref_pre2_impl_(p1,p2)
  1670. #define _Deref_pre3_impl_(p1,p2,p3)
  1671. #define _Deref_post1_impl_(p1)
  1672. #define _Deref_post2_impl_(p1,p2)
  1673. #define _Deref_post3_impl_(p1,p2,p3)
  1674. #define _Deref_ret1_impl_(p1)
  1675. #define _Deref_ret2_impl_(p1,p2)
  1676. #define _Deref_ret3_impl_(p1,p2,p3)
  1677. #define _Deref2_pre1_impl_(p1)
  1678. #define _Deref2_post1_impl_(p1)
  1679. #define _Deref2_ret1_impl_(p1)
  1680. #define _Readable_bytes_impl_(size)
  1681. #define _Readable_elements_impl_(size)
  1682. #define _Writable_bytes_impl_(size)
  1683. #define _Writable_elements_impl_(size)
  1684. #define _Null_terminated_impl_
  1685. #define _NullNull_terminated_impl_
  1686. // Obsolete -- may be needed for transition to attributes.
  1687. #define __inner_typefix(ctype)
  1688. #define __inner_exceptthat
  1689. #endif // ]
  1690. // This section contains the deprecated annotations
  1691. /*
  1692. -------------------------------------------------------------------------------
  1693. Introduction
  1694. sal.h provides a set of annotations to describe how a function uses its
  1695. parameters - the assumptions it makes about them, and the guarantees it makes
  1696. upon finishing.
  1697. Annotations may be placed before either a function parameter's type or its return
  1698. type, and describe the function's behavior regarding the parameter or return value.
  1699. There are two classes of annotations: buffer annotations and advanced annotations.
  1700. Buffer annotations describe how functions use their pointer parameters, and
  1701. advanced annotations either describe complex/unusual buffer behavior, or provide
  1702. additional information about a parameter that is not otherwise expressible.
  1703. -------------------------------------------------------------------------------
  1704. Buffer Annotations
  1705. The most important annotations in sal.h provide a consistent way to annotate
  1706. buffer parameters or return values for a function. Each of these annotations describes
  1707. a single buffer (which could be a string, a fixed-length or variable-length array,
  1708. or just a pointer) that the function interacts with: where it is, how large it is,
  1709. how much is initialized, and what the function does with it.
  1710. The appropriate macro for a given buffer can be constructed using the table below.
  1711. Just pick the appropriate values from each category, and combine them together
  1712. with a leading underscore. Some combinations of values do not make sense as buffer
  1713. annotations. Only meaningful annotations can be added to your code; for a list of
  1714. these, see the buffer annotation definitions section.
  1715. Only a single buffer annotation should be used for each parameter.
  1716. |------------|------------|---------|--------|----------|----------|---------------|
  1717. | Level | Usage | Size | Output | NullTerm | Optional | Parameters |
  1718. |------------|------------|---------|--------|----------|----------|---------------|
  1719. | <> | <> | <> | <> | _z | <> | <> |
  1720. | _deref | _in | _ecount | _full | _nz | _opt | (size) |
  1721. | _deref_opt | _out | _bcount | _part | | | (size,length) |
  1722. | | _inout | | | | | |
  1723. | | | | | | | |
  1724. |------------|------------|---------|--------|----------|----------|---------------|
  1725. Level: Describes the buffer pointer's level of indirection from the parameter or
  1726. return value 'p'.
  1727. <> : p is the buffer pointer.
  1728. _deref : *p is the buffer pointer. p must not be NULL.
  1729. _deref_opt : *p may be the buffer pointer. p may be NULL, in which case the rest of
  1730. the annotation is ignored.
  1731. Usage: Describes how the function uses the buffer.
  1732. <> : The buffer is not accessed. If used on the return value or with _deref, the
  1733. function will provide the buffer, and it will be uninitialized at exit.
  1734. Otherwise, the caller must provide the buffer. This should only be used
  1735. for alloc and free functions.
  1736. _in : The function will only read from the buffer. The caller must provide the
  1737. buffer and initialize it. Cannot be used with _deref.
  1738. _out : The function will only write to the buffer. If used on the return value or
  1739. with _deref, the function will provide the buffer and initialize it.
  1740. Otherwise, the caller must provide the buffer, and the function will
  1741. initialize it.
  1742. _inout : The function may freely read from and write to the buffer. The caller must
  1743. provide the buffer and initialize it. If used with _deref, the buffer may
  1744. be reallocated by the function.
  1745. Size: Describes the total size of the buffer. This may be less than the space actually
  1746. allocated for the buffer, in which case it describes the accessible amount.
  1747. <> : No buffer size is given. If the type specifies the buffer size (such as
  1748. with LPSTR and LPWSTR), that amount is used. Otherwise, the buffer is one
  1749. element long. Must be used with _in, _out, or _inout.
  1750. _ecount : The buffer size is an explicit element count.
  1751. _bcount : The buffer size is an explicit byte count.
  1752. Output: Describes how much of the buffer will be initialized by the function. For
  1753. _inout buffers, this also describes how much is initialized at entry. Omit this
  1754. category for _in buffers; they must be fully initialized by the caller.
  1755. <> : The type specifies how much is initialized. For instance, a function initializing
  1756. an LPWSTR must NULL-terminate the string.
  1757. _full : The function initializes the entire buffer.
  1758. _part : The function initializes part of the buffer, and explicitly indicates how much.
  1759. NullTerm: States if the present of a '\0' marks the end of valid elements in the buffer.
  1760. _z : A '\0' indicated the end of the buffer
  1761. _nz : The buffer may not be null terminated and a '\0' does not indicate the end of the
  1762. buffer.
  1763. Optional: Describes if the buffer itself is optional.
  1764. <> : The pointer to the buffer must not be NULL.
  1765. _opt : The pointer to the buffer might be NULL. It will be checked before being dereferenced.
  1766. Parameters: Gives explicit counts for the size and length of the buffer.
  1767. <> : There is no explicit count. Use when neither _ecount nor _bcount is used.
  1768. (size) : Only the buffer's total size is given. Use with _ecount or _bcount but not _part.
  1769. (size,length) : The buffer's total size and initialized length are given. Use with _ecount_part
  1770. and _bcount_part.
  1771. -------------------------------------------------------------------------------
  1772. Buffer Annotation Examples
  1773. LWSTDAPI_(BOOL) StrToIntExA(
  1774. __in LPCSTR pszString,
  1775. DWORD dwFlags,
  1776. __out int *piRet -- A pointer whose dereference will be filled in.
  1777. );
  1778. void MyPaintingFunction(
  1779. __in HWND hwndControl, -- An initialized read-only parameter.
  1780. __in_opt HDC hdcOptional, -- An initialized read-only parameter that might be NULL.
  1781. __inout IPropertyStore *ppsStore -- An initialized parameter that may be freely used
  1782. -- and modified.
  1783. );
  1784. LWSTDAPI_(BOOL) PathCompactPathExA(
  1785. __out_ecount(cchMax) LPSTR pszOut, -- A string buffer with cch elements that will
  1786. -- be NULL terminated on exit.
  1787. __in LPCSTR pszSrc,
  1788. UINT cchMax,
  1789. DWORD dwFlags
  1790. );
  1791. HRESULT SHLocalAllocBytes(
  1792. size_t cb,
  1793. __deref_bcount(cb) T **ppv -- A pointer whose dereference will be set to an
  1794. -- uninitialized buffer with cb bytes.
  1795. );
  1796. __inout_bcount_full(cb) : A buffer with cb elements that is fully initialized at
  1797. entry and exit, and may be written to by this function.
  1798. __out_ecount_part(count, *countOut) : A buffer with count elements that will be
  1799. partially initialized by this function. The function indicates how much it
  1800. initialized by setting *countOut.
  1801. -------------------------------------------------------------------------------
  1802. Advanced Annotations
  1803. Advanced annotations describe behavior that is not expressible with the regular
  1804. buffer macros. These may be used either to annotate buffer parameters that involve
  1805. complex or conditional behavior, or to enrich existing annotations with additional
  1806. information.
  1807. __success(expr) f :
  1808. <expr> indicates whether function f succeeded or not. If <expr> is true at exit,
  1809. all the function's guarantees (as given by other annotations) must hold. If <expr>
  1810. is false at exit, the caller should not expect any of the function's guarantees
  1811. to hold. If not used, the function must always satisfy its guarantees. Added
  1812. automatically to functions that indicate success in standard ways, such as by
  1813. returning an HRESULT.
  1814. __nullterminated p :
  1815. Pointer p is a buffer that may be read or written up to and including the first
  1816. NULL character or pointer. May be used on typedefs, which marks valid (properly
  1817. initialized) instances of that type as being NULL-terminated.
  1818. __nullnullterminated p :
  1819. Pointer p is a buffer that may be read or written up to and including the first
  1820. sequence of two NULL characters or pointers. May be used on typedefs, which marks
  1821. valid instances of that type as being double-NULL terminated.
  1822. __reserved v :
  1823. Value v must be 0/NULL, reserved for future use.
  1824. __checkReturn v :
  1825. Return value v must not be ignored by callers of this function.
  1826. __typefix(ctype) v :
  1827. Value v should be treated as an instance of ctype, rather than its declared type.
  1828. __override f :
  1829. Specify C#-style 'override' behaviour for overriding virtual methods.
  1830. __callback f :
  1831. Function f can be used as a function pointer.
  1832. __format_string p :
  1833. Pointer p is a string that contains % markers in the style of printf.
  1834. __blocksOn(resource) f :
  1835. Function f blocks on the resource 'resource'.
  1836. __fallthrough :
  1837. Annotates switch statement labels where fall-through is desired, to distinguish
  1838. from forgotten break statements.
  1839. -------------------------------------------------------------------------------
  1840. Advanced Annotation Examples
  1841. __success(return != FALSE) LWSTDAPI_(BOOL)
  1842. PathCanonicalizeA(__out_ecount(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath) :
  1843. pszBuf is only guaranteed to be NULL-terminated when TRUE is returned.
  1844. typedef __nullterminated WCHAR* LPWSTR : Initialized LPWSTRs are NULL-terminated strings.
  1845. __out_ecount(cch) __typefix(LPWSTR) void *psz : psz is a buffer parameter which will be
  1846. a NULL-terminated WCHAR string at exit, and which initially contains cch WCHARs.
  1847. -------------------------------------------------------------------------------
  1848. */
  1849. #define __specstrings
  1850. #ifdef __cplusplus // [
  1851. #ifndef __nothrow // [
  1852. # define __nothrow __declspec(nothrow)
  1853. #endif // ]
  1854. extern "C" {
  1855. #else // ][
  1856. #ifndef __nothrow // [
  1857. # define __nothrow
  1858. #endif // ]
  1859. #endif /* #ifdef __cplusplus */ // ]
  1860. /*
  1861. -------------------------------------------------------------------------------
  1862. Helper Macro Definitions
  1863. These express behavior common to many of the high-level annotations.
  1864. DO NOT USE THESE IN YOUR CODE.
  1865. -------------------------------------------------------------------------------
  1866. */
  1867. /*
  1868. The helper annotations are only understood by the compiler version used by
  1869. various defect detection tools. When the regular compiler is running, they
  1870. are defined into nothing, and do not affect the compiled code.
  1871. */
  1872. #if !defined(__midl) && defined(_PREFAST_) // [
  1873. /*
  1874. In the primitive "SAL_*" annotations "SAL" stands for Standard
  1875. Annotation Language. These "SAL_*" annotations are the
  1876. primitives the compiler understands and high-level MACROs
  1877. will decompose into these primivates.
  1878. */
  1879. #define _SA_SPECSTRIZE( x ) #x
  1880. /*
  1881. __null p
  1882. __notnull p
  1883. __maybenull p
  1884. Annotates a pointer p. States that pointer p is null. Commonly used
  1885. in the negated form __notnull or the possibly null form __maybenull.
  1886. */
  1887. #ifndef PAL_STDCPP_COMPAT
  1888. #define __null _Null_impl_
  1889. #define __notnull _Notnull_impl_
  1890. #define __maybenull _Maybenull_impl_
  1891. #endif // !PAL_STDCPP_COMPAT
  1892. /*
  1893. __readonly l
  1894. __notreadonly l
  1895. __mabyereadonly l
  1896. Annotates a location l. States that location l is not modified after
  1897. this point. If the annotation is placed on the precondition state of
  1898. a function, the restriction only applies until the postcondition state
  1899. of the function. __maybereadonly states that the annotated location
  1900. may be modified, whereas __notreadonly states that a location must be
  1901. modified.
  1902. */
  1903. #define __readonly _Pre1_impl_(__readaccess_impl)
  1904. #define __notreadonly _Pre1_impl_(__allaccess_impl)
  1905. #define __maybereadonly _Pre1_impl_(__readaccess_impl)
  1906. /*
  1907. __valid v
  1908. __notvalid v
  1909. __maybevalid v
  1910. Annotates any value v. States that the value satisfies all properties of
  1911. valid values of its type. For example, for a string buffer, valid means
  1912. that the buffer pointer is either NULL or points to a NULL-terminated string.
  1913. */
  1914. #define __valid _Valid_impl_
  1915. #define __notvalid _Notvalid_impl_
  1916. #define __maybevalid _Maybevalid_impl_
  1917. /*
  1918. __readableTo(extent) p
  1919. Annotates a buffer pointer p. If the buffer can be read, extent describes
  1920. how much of the buffer is readable. For a reader of the buffer, this is
  1921. an explicit permission to read up to that amount, rather than a restriction to
  1922. read only up to it.
  1923. */
  1924. #define __readableTo(extent) _SA_annotes1(SAL_readableTo, extent)
  1925. /*
  1926. __elem_readableTo(size)
  1927. Annotates a buffer pointer p as being readable to size elements.
  1928. */
  1929. #define __elem_readableTo(size) _SA_annotes1(SAL_readableTo, elementCount( size ))
  1930. /*
  1931. __byte_readableTo(size)
  1932. Annotates a buffer pointer p as being readable to size bytes.
  1933. */
  1934. #define __byte_readableTo(size) _SA_annotes1(SAL_readableTo, byteCount(size))
  1935. /*
  1936. __writableTo(extent) p
  1937. Annotates a buffer pointer p. If the buffer can be modified, extent
  1938. describes how much of the buffer is writable (usually the allocation
  1939. size). For a writer of the buffer, this is an explicit permission to
  1940. write up to that amount, rather than a restriction to write only up to it.
  1941. */
  1942. #define __writableTo(size) _SA_annotes1(SAL_writableTo, size)
  1943. /*
  1944. __elem_writableTo(size)
  1945. Annotates a buffer pointer p as being writable to size elements.
  1946. */
  1947. #define __elem_writableTo(size) _SA_annotes1(SAL_writableTo, elementCount( size ))
  1948. /*
  1949. __byte_writableTo(size)
  1950. Annotates a buffer pointer p as being writable to size bytes.
  1951. */
  1952. #define __byte_writableTo(size) _SA_annotes1(SAL_writableTo, byteCount( size))
  1953. /*
  1954. __deref p
  1955. Annotates a pointer p. The next annotation applies one dereference down
  1956. in the type. If readableTo(p, size) then the next annotation applies to
  1957. all elements *(p+i) for which i satisfies the size. If p is a pointer
  1958. to a struct, the next annotation applies to all fields of the struct.
  1959. */
  1960. #define __deref _Deref_impl_
  1961. /*
  1962. __pre __next_annotation
  1963. The next annotation applies in the precondition state
  1964. */
  1965. #define __pre _Pre_impl_
  1966. /*
  1967. __post __next_annotation
  1968. The next annotation applies in the postcondition state
  1969. */
  1970. #define __post _Post_impl_
  1971. /*
  1972. __precond(<expr>)
  1973. When <expr> is true, the next annotation applies in the precondition state
  1974. (currently not enabled)
  1975. */
  1976. #define __precond(expr) __pre
  1977. /*
  1978. __postcond(<expr>)
  1979. When <expr> is true, the next annotation applies in the postcondition state
  1980. (currently not enabled)
  1981. */
  1982. #define __postcond(expr) __post
  1983. /*
  1984. __exceptthat
  1985. Given a set of annotations Q containing __exceptthat maybeP, the effect of
  1986. the except clause is to erase any P or notP annotations (explicit or
  1987. implied) within Q at the same level of dereferencing that the except
  1988. clause appears, and to replace it with maybeP.
  1989. Example 1: __valid __pre_except_maybenull on a pointer p means that the
  1990. pointer may be null, and is otherwise valid, thus overriding
  1991. the implicit notnull annotation implied by __valid on
  1992. pointers.
  1993. Example 2: __valid __deref __pre_except_maybenull on an int **p means
  1994. that p is not null (implied by valid), but the elements
  1995. pointed to by p could be null, and are otherwise valid.
  1996. */
  1997. #define __exceptthat __inner_exceptthat
  1998. /*
  1999. _refparam
  2000. Added to all out parameter macros to indicate that they are all reference
  2001. parameters.
  2002. */
  2003. #define __refparam _Notref_ __deref __notreadonly
  2004. /*
  2005. __inner_*
  2006. Helper macros that directly correspond to certain high-level annotations.
  2007. */
  2008. /*
  2009. Macros to classify the entrypoints and indicate their category.
  2010. Pre-defined control point categories include: RPC, LPC, DeviceDriver, UserToKernel, ISAPI, COM.
  2011. */
  2012. #define __inner_control_entrypoint(category) _SA_annotes2(SAL_entrypoint, controlEntry, category)
  2013. /*
  2014. Pre-defined data entry point categories include: Registry, File, Network.
  2015. */
  2016. #define __inner_data_entrypoint(category) _SA_annotes2(SAL_entrypoint, dataEntry, category)
  2017. #define __inner_override _SA_annotes0(__override)
  2018. #define __inner_callback _SA_annotes0(__callback)
  2019. #define __inner_blocksOn(resource) _SA_annotes1(SAL_blocksOn, resource)
  2020. #define __inner_fallthrough_dec __inline __nothrow void __FallThrough() {}
  2021. #define __inner_fallthrough __FallThrough();
  2022. #define __post_except_maybenull __post __inner_exceptthat _Maybenull_impl_
  2023. #define __pre_except_maybenull __pre __inner_exceptthat _Maybenull_impl_
  2024. #define __post_deref_except_maybenull __post __deref __inner_exceptthat _Maybenull_impl_
  2025. #define __pre_deref_except_maybenull __pre __deref __inner_exceptthat _Maybenull_impl_
  2026. #define __inexpressible_readableTo(size) _Readable_elements_impl_(_Inexpressible_(size))
  2027. #define __inexpressible_writableTo(size) _Writable_elements_impl_(_Inexpressible_(size))
  2028. #else // ][
  2029. #ifndef PAL_STDCPP_COMPAT
  2030. #define __null
  2031. #define __notnull
  2032. #endif // !PAL_STDCPP_COMPAT
  2033. #define __maybenull
  2034. #define __readonly
  2035. #define __notreadonly
  2036. #define __maybereadonly
  2037. #define __valid
  2038. #define __notvalid
  2039. #define __maybevalid
  2040. #define __readableTo(extent)
  2041. #define __elem_readableTo(size)
  2042. #define __byte_readableTo(size)
  2043. #define __writableTo(size)
  2044. #define __elem_writableTo(size)
  2045. #define __byte_writableTo(size)
  2046. #define __deref
  2047. #define __pre
  2048. #define __post
  2049. #define __precond(expr)
  2050. #define __postcond(expr)
  2051. #define __exceptthat
  2052. #define __inner_override
  2053. #define __inner_callback
  2054. #define __inner_blocksOn(resource)
  2055. #define __inner_fallthrough_dec
  2056. #define __inner_fallthrough
  2057. #define __refparam
  2058. #define __inner_control_entrypoint(category)
  2059. #define __inner_data_entrypoint(category)
  2060. #define __post_except_maybenull
  2061. #define __pre_except_maybenull
  2062. #define __post_deref_except_maybenull
  2063. #define __pre_deref_except_maybenull
  2064. #define __inexpressible_readableTo(size)
  2065. #define __inexpressible_writableTo(size)
  2066. #endif /* #if !defined(__midl) && defined(_PREFAST_) */ // ]
  2067. /*
  2068. -------------------------------------------------------------------------------
  2069. Buffer Annotation Definitions
  2070. Any of these may be used to directly annotate functions, but only one should
  2071. be used for each parameter. To determine which annotation to use for a given
  2072. buffer, use the table in the buffer annotations section.
  2073. -------------------------------------------------------------------------------
  2074. */
  2075. // These macros conflict with c++ headers.
  2076. #ifndef PAL_STDCPP_COMPAT
  2077. #define __in _SAL1_Source_(__in, (), _In_)
  2078. #define __out _SAL1_Source_(__out, (), _Out_)
  2079. #endif // !PAL_STDCPP_COMPAT
  2080. #define __ecount(size) _SAL1_Source_(__ecount, (size), __notnull __elem_writableTo(size))
  2081. #define __bcount(size) _SAL1_Source_(__bcount, (size), __notnull __byte_writableTo(size))
  2082. #define __in_ecount(size) _SAL1_Source_(__in_ecount, (size), _In_reads_(size))
  2083. #define __in_bcount(size) _SAL1_Source_(__in_bcount, (size), _In_reads_bytes_(size))
  2084. #define __in_z _SAL1_Source_(__in_z, (), _In_z_)
  2085. #define __in_ecount_z(size) _SAL1_Source_(__in_ecount_z, (size), _In_reads_z_(size))
  2086. #define __in_bcount_z(size) _SAL1_Source_(__in_bcount_z, (size), __in_bcount(size) __pre __nullterminated)
  2087. #define __in_nz _SAL1_Source_(__in_nz, (), __in)
  2088. #define __in_ecount_nz(size) _SAL1_Source_(__in_ecount_nz, (size), __in_ecount(size))
  2089. #define __in_bcount_nz(size) _SAL1_Source_(__in_bcount_nz, (size), __in_bcount(size))
  2090. #define __out_ecount(size) _SAL1_Source_(__out_ecount, (size), _Out_writes_(size))
  2091. #define __out_bcount(size) _SAL1_Source_(__out_bcount, (size), _Out_writes_bytes_(size))
  2092. #define __out_ecount_part(size,length) _SAL1_Source_(__out_ecount_part, (size,length), _Out_writes_to_(size,length))
  2093. #define __out_bcount_part(size,length) _SAL1_Source_(__out_bcount_part, (size,length), _Out_writes_bytes_to_(size,length))
  2094. #define __out_ecount_full(size) _SAL1_Source_(__out_ecount_full, (size), _Out_writes_all_(size))
  2095. #define __out_bcount_full(size) _SAL1_Source_(__out_bcount_full, (size), _Out_writes_bytes_all_(size))
  2096. #define __out_z _SAL1_Source_(__out_z, (), __post __valid __refparam __post __nullterminated)
  2097. #define __out_z_opt _SAL1_Source_(__out_z_opt, (), __post __valid __refparam __post __nullterminated __pre_except_maybenull)
  2098. #define __out_ecount_z(size) _SAL1_Source_(__out_ecount_z, (size), __ecount(size) __post __valid __refparam __post __nullterminated)
  2099. #define __out_bcount_z(size) _SAL1_Source_(__out_bcount_z, (size), __bcount(size) __post __valid __refparam __post __nullterminated)
  2100. #define __out_ecount_part_z(size,length) _SAL1_Source_(__out_ecount_part_z, (size,length), __out_ecount_part(size,length) __post __nullterminated)
  2101. #define __out_bcount_part_z(size,length) _SAL1_Source_(__out_bcount_part_z, (size,length), __out_bcount_part(size,length) __post __nullterminated)
  2102. #define __out_ecount_full_z(size) _SAL1_Source_(__out_ecount_full_z, (size), __out_ecount_full(size) __post __nullterminated)
  2103. #define __out_bcount_full_z(size) _SAL1_Source_(__out_bcount_full_z, (size), __out_bcount_full(size) __post __nullterminated)
  2104. #define __out_nz _SAL1_Source_(__out_nz, (), __post __valid __refparam)
  2105. #define __out_nz_opt _SAL1_Source_(__out_nz_opt, (), __post __valid __refparam __post_except_maybenull_)
  2106. #define __out_ecount_nz(size) _SAL1_Source_(__out_ecount_nz, (size), __ecount(size) __post __valid __refparam)
  2107. #define __out_bcount_nz(size) _SAL1_Source_(__out_bcount_nz, (size), __bcount(size) __post __valid __refparam)
  2108. #define __inout _SAL1_Source_(__inout, (), _Inout_)
  2109. #define __inout_ecount(size) _SAL1_Source_(__inout_ecount, (size), _Inout_updates_(size))
  2110. #define __inout_bcount(size) _SAL1_Source_(__inout_bcount, (size), _Inout_updates_bytes_(size))
  2111. #define __inout_ecount_part(size,length) _SAL1_Source_(__inout_ecount_part, (size,length), _Inout_updates_to_(size,length))
  2112. #define __inout_bcount_part(size,length) _SAL1_Source_(__inout_bcount_part, (size,length), _Inout_updates_bytes_to_(size,length))
  2113. #define __inout_ecount_full(size) _SAL1_Source_(__inout_ecount_full, (size), _Inout_updates_all_(size))
  2114. #define __inout_bcount_full(size) _SAL1_Source_(__inout_bcount_full, (size), _Inout_updates_bytes_all_(size))
  2115. #define __inout_z _SAL1_Source_(__inout_z, (), _Inout_z_)
  2116. #define __inout_ecount_z(size) _SAL1_Source_(__inout_ecount_z, (size), _Inout_updates_z_(size))
  2117. #define __inout_bcount_z(size) _SAL1_Source_(__inout_bcount_z, (size), __inout_bcount(size) __pre __nullterminated __post __nullterminated)
  2118. #define __inout_nz _SAL1_Source_(__inout_nz, (), __inout)
  2119. #define __inout_ecount_nz(size) _SAL1_Source_(__inout_ecount_nz, (size), __inout_ecount(size))
  2120. #define __inout_bcount_nz(size) _SAL1_Source_(__inout_bcount_nz, (size), __inout_bcount(size))
  2121. #define __ecount_opt(size) _SAL1_Source_(__ecount_opt, (size), __ecount(size) __pre_except_maybenull)
  2122. #define __bcount_opt(size) _SAL1_Source_(__bcount_opt, (size), __bcount(size) __pre_except_maybenull)
  2123. #define __in_opt _SAL1_Source_(__in_opt, (), _In_opt_)
  2124. #define __in_ecount_opt(size) _SAL1_Source_(__in_ecount_opt, (size), _In_reads_opt_(size))
  2125. #define __in_bcount_opt(size) _SAL1_Source_(__in_bcount_opt, (size), _In_reads_bytes_opt_(size))
  2126. #define __in_z_opt _SAL1_Source_(__in_z_opt, (), _In_opt_z_)
  2127. #define __in_ecount_z_opt(size) _SAL1_Source_(__in_ecount_z_opt, (size), __in_ecount_opt(size) __pre __nullterminated)
  2128. #define __in_bcount_z_opt(size) _SAL1_Source_(__in_bcount_z_opt, (size), __in_bcount_opt(size) __pre __nullterminated)
  2129. #define __in_nz_opt _SAL1_Source_(__in_nz_opt, (), __in_opt)
  2130. #define __in_ecount_nz_opt(size) _SAL1_Source_(__in_ecount_nz_opt, (size), __in_ecount_opt(size))
  2131. #define __in_bcount_nz_opt(size) _SAL1_Source_(__in_bcount_nz_opt, (size), __in_bcount_opt(size))
  2132. #define __out_opt _SAL1_Source_(__out_opt, (), _Out_opt_)
  2133. #define __out_ecount_opt(size) _SAL1_Source_(__out_ecount_opt, (size), _Out_writes_opt_(size))
  2134. #define __out_bcount_opt(size) _SAL1_Source_(__out_bcount_opt, (size), _Out_writes_bytes_opt_(size))
  2135. #define __out_ecount_part_opt(size,length) _SAL1_Source_(__out_ecount_part_opt, (size,length), __out_ecount_part(size,length) __pre_except_maybenull)
  2136. #define __out_bcount_part_opt(size,length) _SAL1_Source_(__out_bcount_part_opt, (size,length), __out_bcount_part(size,length) __pre_except_maybenull)
  2137. #define __out_ecount_full_opt(size) _SAL1_Source_(__out_ecount_full_opt, (size), __out_ecount_full(size) __pre_except_maybenull)
  2138. #define __out_bcount_full_opt(size) _SAL1_Source_(__out_bcount_full_opt, (size), __out_bcount_full(size) __pre_except_maybenull)
  2139. #define __out_ecount_z_opt(size) _SAL1_Source_(__out_ecount_z_opt, (size), __out_ecount_opt(size) __post __nullterminated)
  2140. #define __out_bcount_z_opt(size) _SAL1_Source_(__out_bcount_z_opt, (size), __out_bcount_opt(size) __post __nullterminated)
  2141. #define __out_ecount_part_z_opt(size,length) _SAL1_Source_(__out_ecount_part_z_opt, (size,length), __out_ecount_part_opt(size,length) __post __nullterminated)
  2142. #define __out_bcount_part_z_opt(size,length) _SAL1_Source_(__out_bcount_part_z_opt, (size,length), __out_bcount_part_opt(size,length) __post __nullterminated)
  2143. #define __out_ecount_full_z_opt(size) _SAL1_Source_(__out_ecount_full_z_opt, (size), __out_ecount_full_opt(size) __post __nullterminated)
  2144. #define __out_bcount_full_z_opt(size) _SAL1_Source_(__out_bcount_full_z_opt, (size), __out_bcount_full_opt(size) __post __nullterminated)
  2145. #define __out_ecount_nz_opt(size) _SAL1_Source_(__out_ecount_nz_opt, (size), __out_ecount_opt(size) __post __nullterminated)
  2146. #define __out_bcount_nz_opt(size) _SAL1_Source_(__out_bcount_nz_opt, (size), __out_bcount_opt(size) __post __nullterminated)
  2147. #define __inout_opt _SAL1_Source_(__inout_opt, (), _Inout_opt_)
  2148. #define __inout_ecount_opt(size) _SAL1_Source_(__inout_ecount_opt, (size), __inout_ecount(size) __pre_except_maybenull)
  2149. #define __inout_bcount_opt(size) _SAL1_Source_(__inout_bcount_opt, (size), __inout_bcount(size) __pre_except_maybenull)
  2150. #define __inout_ecount_part_opt(size,length) _SAL1_Source_(__inout_ecount_part_opt, (size,length), __inout_ecount_part(size,length) __pre_except_maybenull)
  2151. #define __inout_bcount_part_opt(size,length) _SAL1_Source_(__inout_bcount_part_opt, (size,length), __inout_bcount_part(size,length) __pre_except_maybenull)
  2152. #define __inout_ecount_full_opt(size) _SAL1_Source_(__inout_ecount_full_opt, (size), __inout_ecount_full(size) __pre_except_maybenull)
  2153. #define __inout_bcount_full_opt(size) _SAL1_Source_(__inout_bcount_full_opt, (size), __inout_bcount_full(size) __pre_except_maybenull)
  2154. #define __inout_z_opt _SAL1_Source_(__inout_z_opt, (), __inout_opt __pre __nullterminated __post __nullterminated)
  2155. #define __inout_ecount_z_opt(size) _SAL1_Source_(__inout_ecount_z_opt, (size), __inout_ecount_opt(size) __pre __nullterminated __post __nullterminated)
  2156. #define __inout_ecount_z_opt(size) _SAL1_Source_(__inout_ecount_z_opt, (size), __inout_ecount_opt(size) __pre __nullterminated __post __nullterminated)
  2157. #define __inout_bcount_z_opt(size) _SAL1_Source_(__inout_bcount_z_opt, (size), __inout_bcount_opt(size))
  2158. #define __inout_nz_opt _SAL1_Source_(__inout_nz_opt, (), __inout_opt)
  2159. #define __inout_ecount_nz_opt(size) _SAL1_Source_(__inout_ecount_nz_opt, (size), __inout_ecount_opt(size))
  2160. #define __inout_bcount_nz_opt(size) _SAL1_Source_(__inout_bcount_nz_opt, (size), __inout_bcount_opt(size))
  2161. #define __deref_ecount(size) _SAL1_Source_(__deref_ecount, (size), _Notref_ __ecount(1) __post _Notref_ __elem_readableTo(1) __post _Notref_ __deref _Notref_ __notnull __post __deref __elem_writableTo(size))
  2162. #define __deref_bcount(size) _SAL1_Source_(__deref_bcount, (size), _Notref_ __ecount(1) __post _Notref_ __elem_readableTo(1) __post _Notref_ __deref _Notref_ __notnull __post __deref __byte_writableTo(size))
  2163. #define __deref_out _SAL1_Source_(__deref_out, (), _Outptr_)
  2164. #define __deref_out_ecount(size) _SAL1_Source_(__deref_out_ecount, (size), _Outptr_result_buffer_(size))
  2165. #define __deref_out_bcount(size) _SAL1_Source_(__deref_out_bcount, (size), _Outptr_result_bytebuffer_(size))
  2166. #define __deref_out_ecount_part(size,length) _SAL1_Source_(__deref_out_ecount_part, (size,length), _Outptr_result_buffer_to_(size,length))
  2167. #define __deref_out_bcount_part(size,length) _SAL1_Source_(__deref_out_bcount_part, (size,length), _Outptr_result_bytebuffer_to_(size,length))
  2168. #define __deref_out_ecount_full(size) _SAL1_Source_(__deref_out_ecount_full, (size), __deref_out_ecount_part(size,size))
  2169. #define __deref_out_bcount_full(size) _SAL1_Source_(__deref_out_bcount_full, (size), __deref_out_bcount_part(size,size))
  2170. #define __deref_out_z _SAL1_Source_(__deref_out_z, (), _Outptr_result_z_)
  2171. #define __deref_out_ecount_z(size) _SAL1_Source_(__deref_out_ecount_z, (size), __deref_out_ecount(size) __post __deref __nullterminated)
  2172. #define __deref_out_bcount_z(size) _SAL1_Source_(__deref_out_bcount_z, (size), __deref_out_bcount(size) __post __deref __nullterminated)
  2173. #define __deref_out_nz _SAL1_Source_(__deref_out_nz, (), __deref_out)
  2174. #define __deref_out_ecount_nz(size) _SAL1_Source_(__deref_out_ecount_nz, (size), __deref_out_ecount(size))
  2175. #define __deref_out_bcount_nz(size) _SAL1_Source_(__deref_out_bcount_nz, (size), __deref_out_ecount(size))
  2176. #define __deref_inout _SAL1_Source_(__deref_inout, (), _Notref_ __notnull _Notref_ __elem_readableTo(1) __pre __deref __valid __post _Notref_ __deref __valid __refparam)
  2177. #define __deref_inout_z _SAL1_Source_(__deref_inout_z, (), __deref_inout __pre __deref __nullterminated __post _Notref_ __deref __nullterminated)
  2178. #define __deref_inout_ecount(size) _SAL1_Source_(__deref_inout_ecount, (size), __deref_inout __pre __deref __elem_writableTo(size) __post _Notref_ __deref __elem_writableTo(size))
  2179. #define __deref_inout_bcount(size) _SAL1_Source_(__deref_inout_bcount, (size), __deref_inout __pre __deref __byte_writableTo(size) __post _Notref_ __deref __byte_writableTo(size))
  2180. #define __deref_inout_ecount_part(size,length) _SAL1_Source_(__deref_inout_ecount_part, (size,length), __deref_inout_ecount(size) __pre __deref __elem_readableTo(length) __post __deref __elem_readableTo(length))
  2181. #define __deref_inout_bcount_part(size,length) _SAL1_Source_(__deref_inout_bcount_part, (size,length), __deref_inout_bcount(size) __pre __deref __byte_readableTo(length) __post __deref __byte_readableTo(length))
  2182. #define __deref_inout_ecount_full(size) _SAL1_Source_(__deref_inout_ecount_full, (size), __deref_inout_ecount_part(size,size))
  2183. #define __deref_inout_bcount_full(size) _SAL1_Source_(__deref_inout_bcount_full, (size), __deref_inout_bcount_part(size,size))
  2184. #define __deref_inout_ecount_z(size) _SAL1_Source_(__deref_inout_ecount_z, (size), __deref_inout_ecount(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2185. #define __deref_inout_bcount_z(size) _SAL1_Source_(__deref_inout_bcount_z, (size), __deref_inout_bcount(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2186. #define __deref_inout_nz _SAL1_Source_(__deref_inout_nz, (), __deref_inout)
  2187. #define __deref_inout_ecount_nz(size) _SAL1_Source_(__deref_inout_ecount_nz, (size), __deref_inout_ecount(size))
  2188. #define __deref_inout_bcount_nz(size) _SAL1_Source_(__deref_inout_bcount_nz, (size), __deref_inout_ecount(size))
  2189. #define __deref_ecount_opt(size) _SAL1_Source_(__deref_ecount_opt, (size), __deref_ecount(size) __post_deref_except_maybenull)
  2190. #define __deref_bcount_opt(size) _SAL1_Source_(__deref_bcount_opt, (size), __deref_bcount(size) __post_deref_except_maybenull)
  2191. #define __deref_out_opt _SAL1_Source_(__deref_out_opt, (), __deref_out __post_deref_except_maybenull)
  2192. #define __deref_out_ecount_opt(size) _SAL1_Source_(__deref_out_ecount_opt, (size), __deref_out_ecount(size) __post_deref_except_maybenull)
  2193. #define __deref_out_bcount_opt(size) _SAL1_Source_(__deref_out_bcount_opt, (size), __deref_out_bcount(size) __post_deref_except_maybenull)
  2194. #define __deref_out_ecount_part_opt(size,length) _SAL1_Source_(__deref_out_ecount_part_opt, (size,length), __deref_out_ecount_part(size,length) __post_deref_except_maybenull)
  2195. #define __deref_out_bcount_part_opt(size,length) _SAL1_Source_(__deref_out_bcount_part_opt, (size,length), __deref_out_bcount_part(size,length) __post_deref_except_maybenull)
  2196. #define __deref_out_ecount_full_opt(size) _SAL1_Source_(__deref_out_ecount_full_opt, (size), __deref_out_ecount_full(size) __post_deref_except_maybenull)
  2197. #define __deref_out_bcount_full_opt(size) _SAL1_Source_(__deref_out_bcount_full_opt, (size), __deref_out_bcount_full(size) __post_deref_except_maybenull)
  2198. #define __deref_out_z_opt _SAL1_Source_(__deref_out_z_opt, (), _Outptr_result_maybenull_z_)
  2199. #define __deref_out_ecount_z_opt(size) _SAL1_Source_(__deref_out_ecount_z_opt, (size), __deref_out_ecount_opt(size) __post __deref __nullterminated)
  2200. #define __deref_out_bcount_z_opt(size) _SAL1_Source_(__deref_out_bcount_z_opt, (size), __deref_out_bcount_opt(size) __post __deref __nullterminated)
  2201. #define __deref_out_nz_opt _SAL1_Source_(__deref_out_nz_opt, (), __deref_out_opt)
  2202. #define __deref_out_ecount_nz_opt(size) _SAL1_Source_(__deref_out_ecount_nz_opt, (size), __deref_out_ecount_opt(size))
  2203. #define __deref_out_bcount_nz_opt(size) _SAL1_Source_(__deref_out_bcount_nz_opt, (size), __deref_out_bcount_opt(size))
  2204. #define __deref_inout_opt _SAL1_Source_(__deref_inout_opt, (), __deref_inout __pre_deref_except_maybenull __post_deref_except_maybenull)
  2205. #define __deref_inout_ecount_opt(size) _SAL1_Source_(__deref_inout_ecount_opt, (size), __deref_inout_ecount(size) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2206. #define __deref_inout_bcount_opt(size) _SAL1_Source_(__deref_inout_bcount_opt, (size), __deref_inout_bcount(size) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2207. #define __deref_inout_ecount_part_opt(size,length) _SAL1_Source_(__deref_inout_ecount_part_opt, (size,length), __deref_inout_ecount_part(size,length) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2208. #define __deref_inout_bcount_part_opt(size,length) _SAL1_Source_(__deref_inout_bcount_part_opt, (size,length), __deref_inout_bcount_part(size,length) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2209. #define __deref_inout_ecount_full_opt(size) _SAL1_Source_(__deref_inout_ecount_full_opt, (size), __deref_inout_ecount_full(size) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2210. #define __deref_inout_bcount_full_opt(size) _SAL1_Source_(__deref_inout_bcount_full_opt, (size), __deref_inout_bcount_full(size) __pre_deref_except_maybenull __post_deref_except_maybenull)
  2211. #define __deref_inout_z_opt _SAL1_Source_(__deref_inout_z_opt, (), __deref_inout_opt __pre __deref __nullterminated __post __deref __nullterminated)
  2212. #define __deref_inout_ecount_z_opt(size) _SAL1_Source_(__deref_inout_ecount_z_opt, (size), __deref_inout_ecount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2213. #define __deref_inout_bcount_z_opt(size) _SAL1_Source_(__deref_inout_bcount_z_opt, (size), __deref_inout_bcount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2214. #define __deref_inout_nz_opt _SAL1_Source_(__deref_inout_nz_opt, (), __deref_inout_opt)
  2215. #define __deref_inout_ecount_nz_opt(size) _SAL1_Source_(__deref_inout_ecount_nz_opt, (size), __deref_inout_ecount_opt(size))
  2216. #define __deref_inout_bcount_nz_opt(size) _SAL1_Source_(__deref_inout_bcount_nz_opt, (size), __deref_inout_bcount_opt(size))
  2217. #define __deref_opt_ecount(size) _SAL1_Source_(__deref_opt_ecount, (size), __deref_ecount(size) __pre_except_maybenull)
  2218. #define __deref_opt_bcount(size) _SAL1_Source_(__deref_opt_bcount, (size), __deref_bcount(size) __pre_except_maybenull)
  2219. #define __deref_opt_out _SAL1_Source_(__deref_opt_out, (), _Outptr_opt_)
  2220. #define __deref_opt_out_z _SAL1_Source_(__deref_opt_out_z, (), _Outptr_opt_result_z_)
  2221. #define __deref_opt_out_ecount(size) _SAL1_Source_(__deref_opt_out_ecount, (size), __deref_out_ecount(size) __pre_except_maybenull)
  2222. #define __deref_opt_out_bcount(size) _SAL1_Source_(__deref_opt_out_bcount, (size), __deref_out_bcount(size) __pre_except_maybenull)
  2223. #define __deref_opt_out_ecount_part(size,length) _SAL1_Source_(__deref_opt_out_ecount_part, (size,length), __deref_out_ecount_part(size,length) __pre_except_maybenull)
  2224. #define __deref_opt_out_bcount_part(size,length) _SAL1_Source_(__deref_opt_out_bcount_part, (size,length), __deref_out_bcount_part(size,length) __pre_except_maybenull)
  2225. #define __deref_opt_out_ecount_full(size) _SAL1_Source_(__deref_opt_out_ecount_full, (size), __deref_out_ecount_full(size) __pre_except_maybenull)
  2226. #define __deref_opt_out_bcount_full(size) _SAL1_Source_(__deref_opt_out_bcount_full, (size), __deref_out_bcount_full(size) __pre_except_maybenull)
  2227. #define __deref_opt_inout _SAL1_Source_(__deref_opt_inout, (), _Inout_opt_)
  2228. #define __deref_opt_inout_ecount(size) _SAL1_Source_(__deref_opt_inout_ecount, (size), __deref_inout_ecount(size) __pre_except_maybenull)
  2229. #define __deref_opt_inout_bcount(size) _SAL1_Source_(__deref_opt_inout_bcount, (size), __deref_inout_bcount(size) __pre_except_maybenull)
  2230. #define __deref_opt_inout_ecount_part(size,length) _SAL1_Source_(__deref_opt_inout_ecount_part, (size,length), __deref_inout_ecount_part(size,length) __pre_except_maybenull)
  2231. #define __deref_opt_inout_bcount_part(size,length) _SAL1_Source_(__deref_opt_inout_bcount_part, (size,length), __deref_inout_bcount_part(size,length) __pre_except_maybenull)
  2232. #define __deref_opt_inout_ecount_full(size) _SAL1_Source_(__deref_opt_inout_ecount_full, (size), __deref_inout_ecount_full(size) __pre_except_maybenull)
  2233. #define __deref_opt_inout_bcount_full(size) _SAL1_Source_(__deref_opt_inout_bcount_full, (size), __deref_inout_bcount_full(size) __pre_except_maybenull)
  2234. #define __deref_opt_inout_z _SAL1_Source_(__deref_opt_inout_z, (), __deref_opt_inout __pre __deref __nullterminated __post __deref __nullterminated)
  2235. #define __deref_opt_inout_ecount_z(size) _SAL1_Source_(__deref_opt_inout_ecount_z, (size), __deref_opt_inout_ecount(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2236. #define __deref_opt_inout_bcount_z(size) _SAL1_Source_(__deref_opt_inout_bcount_z, (size), __deref_opt_inout_bcount(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2237. #define __deref_opt_inout_nz _SAL1_Source_(__deref_opt_inout_nz, (), __deref_opt_inout)
  2238. #define __deref_opt_inout_ecount_nz(size) _SAL1_Source_(__deref_opt_inout_ecount_nz, (size), __deref_opt_inout_ecount(size))
  2239. #define __deref_opt_inout_bcount_nz(size) _SAL1_Source_(__deref_opt_inout_bcount_nz, (size), __deref_opt_inout_bcount(size))
  2240. #define __deref_opt_ecount_opt(size) _SAL1_Source_(__deref_opt_ecount_opt, (size), __deref_ecount_opt(size) __pre_except_maybenull)
  2241. #define __deref_opt_bcount_opt(size) _SAL1_Source_(__deref_opt_bcount_opt, (size), __deref_bcount_opt(size) __pre_except_maybenull)
  2242. #define __deref_opt_out_opt _SAL1_Source_(__deref_opt_out_opt, (), _Outptr_opt_result_maybenull_)
  2243. #define __deref_opt_out_ecount_opt(size) _SAL1_Source_(__deref_opt_out_ecount_opt, (size), __deref_out_ecount_opt(size) __pre_except_maybenull)
  2244. #define __deref_opt_out_bcount_opt(size) _SAL1_Source_(__deref_opt_out_bcount_opt, (size), __deref_out_bcount_opt(size) __pre_except_maybenull)
  2245. #define __deref_opt_out_ecount_part_opt(size,length) _SAL1_Source_(__deref_opt_out_ecount_part_opt, (size,length), __deref_out_ecount_part_opt(size,length) __pre_except_maybenull)
  2246. #define __deref_opt_out_bcount_part_opt(size,length) _SAL1_Source_(__deref_opt_out_bcount_part_opt, (size,length), __deref_out_bcount_part_opt(size,length) __pre_except_maybenull)
  2247. #define __deref_opt_out_ecount_full_opt(size) _SAL1_Source_(__deref_opt_out_ecount_full_opt, (size), __deref_out_ecount_full_opt(size) __pre_except_maybenull)
  2248. #define __deref_opt_out_bcount_full_opt(size) _SAL1_Source_(__deref_opt_out_bcount_full_opt, (size), __deref_out_bcount_full_opt(size) __pre_except_maybenull)
  2249. #define __deref_opt_out_z_opt _SAL1_Source_(__deref_opt_out_z_opt, (), __post __deref __valid __refparam __pre_except_maybenull __pre_deref_except_maybenull __post_deref_except_maybenull __post __deref __nullterminated)
  2250. #define __deref_opt_out_ecount_z_opt(size) _SAL1_Source_(__deref_opt_out_ecount_z_opt, (size), __deref_opt_out_ecount_opt(size) __post __deref __nullterminated)
  2251. #define __deref_opt_out_bcount_z_opt(size) _SAL1_Source_(__deref_opt_out_bcount_z_opt, (size), __deref_opt_out_bcount_opt(size) __post __deref __nullterminated)
  2252. #define __deref_opt_out_nz_opt _SAL1_Source_(__deref_opt_out_nz_opt, (), __deref_opt_out_opt)
  2253. #define __deref_opt_out_ecount_nz_opt(size) _SAL1_Source_(__deref_opt_out_ecount_nz_opt, (size), __deref_opt_out_ecount_opt(size))
  2254. #define __deref_opt_out_bcount_nz_opt(size) _SAL1_Source_(__deref_opt_out_bcount_nz_opt, (size), __deref_opt_out_bcount_opt(size))
  2255. #define __deref_opt_inout_opt _SAL1_Source_(__deref_opt_inout_opt, (), __deref_inout_opt __pre_except_maybenull)
  2256. #define __deref_opt_inout_ecount_opt(size) _SAL1_Source_(__deref_opt_inout_ecount_opt, (size), __deref_inout_ecount_opt(size) __pre_except_maybenull)
  2257. #define __deref_opt_inout_bcount_opt(size) _SAL1_Source_(__deref_opt_inout_bcount_opt, (size), __deref_inout_bcount_opt(size) __pre_except_maybenull)
  2258. #define __deref_opt_inout_ecount_part_opt(size,length) _SAL1_Source_(__deref_opt_inout_ecount_part_opt, (size,length), __deref_inout_ecount_part_opt(size,length) __pre_except_maybenull)
  2259. #define __deref_opt_inout_bcount_part_opt(size,length) _SAL1_Source_(__deref_opt_inout_bcount_part_opt, (size,length), __deref_inout_bcount_part_opt(size,length) __pre_except_maybenull)
  2260. #define __deref_opt_inout_ecount_full_opt(size) _SAL1_Source_(__deref_opt_inout_ecount_full_opt, (size), __deref_inout_ecount_full_opt(size) __pre_except_maybenull)
  2261. #define __deref_opt_inout_bcount_full_opt(size) _SAL1_Source_(__deref_opt_inout_bcount_full_opt, (size), __deref_inout_bcount_full_opt(size) __pre_except_maybenull)
  2262. #define __deref_opt_inout_z_opt _SAL1_Source_(__deref_opt_inout_z_opt, (), __deref_opt_inout_opt __pre __deref __nullterminated __post __deref __nullterminated)
  2263. #define __deref_opt_inout_ecount_z_opt(size) _SAL1_Source_(__deref_opt_inout_ecount_z_opt, (size), __deref_opt_inout_ecount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2264. #define __deref_opt_inout_bcount_z_opt(size) _SAL1_Source_(__deref_opt_inout_bcount_z_opt, (size), __deref_opt_inout_bcount_opt(size) __pre __deref __nullterminated __post __deref __nullterminated)
  2265. #define __deref_opt_inout_nz_opt _SAL1_Source_(__deref_opt_inout_nz_opt, (), __deref_opt_inout_opt)
  2266. #define __deref_opt_inout_ecount_nz_opt(size) _SAL1_Source_(__deref_opt_inout_ecount_nz_opt, (size), __deref_opt_inout_ecount_opt(size))
  2267. #define __deref_opt_inout_bcount_nz_opt(size) _SAL1_Source_(__deref_opt_inout_bcount_nz_opt, (size), __deref_opt_inout_bcount_opt(size))
  2268. /*
  2269. -------------------------------------------------------------------------------
  2270. Advanced Annotation Definitions
  2271. Any of these may be used to directly annotate functions, and may be used in
  2272. combination with each other or with regular buffer macros. For an explanation
  2273. of each annotation, see the advanced annotations section.
  2274. -------------------------------------------------------------------------------
  2275. */
  2276. #define __success(expr) _Success_(expr)
  2277. #define __nullterminated _Null_terminated_
  2278. #define __nullnullterminated
  2279. #define __reserved _SAL1_Source_(__reserved, (), _Reserved_)
  2280. #define __checkReturn _SAL1_Source_(__checkReturn, (), _Check_return_)
  2281. #define __typefix(ctype) _SAL1_Source_(__typefix, (ctype), __inner_typefix(ctype))
  2282. #define __override __inner_override
  2283. #define __callback __inner_callback
  2284. #define __format_string _Printf_format_string_
  2285. #define __blocksOn(resource) __inner_blocksOn(resource)
  2286. #define __control_entrypoint(category) __inner_control_entrypoint(category)
  2287. #define __data_entrypoint(category) __inner_data_entrypoint(category)
  2288. #define __useHeader _Use_decl_anno_impl_
  2289. #define __on_failure(annotes) _On_failure_impl_(annotes _SAL_nop_impl_)
  2290. #ifndef __fallthrough // [
  2291. __inner_fallthrough_dec
  2292. #define __fallthrough __inner_fallthrough
  2293. #endif // ]
  2294. #ifndef __analysis_assume // [
  2295. #ifdef _PREFAST_ // [
  2296. #define __analysis_assume(expr) __assume(expr)
  2297. #else // ][
  2298. #define __analysis_assume(expr)
  2299. #endif // ]
  2300. #endif // ]
  2301. #ifndef _Analysis_assume_ // [
  2302. #ifdef _PREFAST_ // [
  2303. #define _Analysis_assume_(expr) __assume(expr)
  2304. #else // ][
  2305. #define _Analysis_assume_(expr)
  2306. #endif // ]
  2307. #endif // ]
  2308. #define _Analysis_noreturn_ _SAL2_Source_(_Analysis_noreturn_, (), _SA_annotes0(SAL_terminates))
  2309. #ifdef _PREFAST_ // [
  2310. __inline __nothrow
  2311. void __AnalysisAssumeNullterminated(_Post_ __nullterminated void *p);
  2312. #define _Analysis_assume_nullterminated_(x) __AnalysisAssumeNullterminated(x)
  2313. #else // ][
  2314. #define _Analysis_assume_nullterminated_(x)
  2315. #endif // ]
  2316. //
  2317. // Set the analysis mode (global flags to analysis).
  2318. // They take effect at the point of declaration; use at global scope
  2319. // as a declaration.
  2320. //
  2321. // Synthesize a unique symbol.
  2322. #define ___MKID(x, y) x ## y
  2323. #define __MKID(x, y) ___MKID(x, y)
  2324. #define __GENSYM(x) __MKID(x, __COUNTER__)
  2325. __ANNOTATION(SAL_analysisMode(__AuToQuOtE __In_impl_ char *mode);)
  2326. #define _Analysis_mode_impl_(mode) _SA_annotes1(SAL_analysisMode, #mode)
  2327. #define _Analysis_mode_(mode) \
  2328. typedef _Analysis_mode_impl_(mode) int \
  2329. __GENSYM(__prefast_analysis_mode_flag);
  2330. // The following are predefined:
  2331. // _Analysis_operator_new_throw_ (operator new throws)
  2332. // _Analysis_operator_new_null_ (operator new returns null)
  2333. // _Analysis_operator_new_never_fails_ (operator new never fails)
  2334. //
  2335. // Function class annotations.
  2336. __ANNOTATION(SAL_functionClassNew(__In_impl_ char*);)
  2337. __PRIMOP(int, _In_function_class_(__In_impl_ char*);)
  2338. #define _In_function_class_(x) _In_function_class_(#x)
  2339. #define _Function_class_(x) _SA_annotes1(SAL_functionClassNew, #x)
  2340. /*
  2341. * interlocked operand used in interlocked instructions
  2342. */
  2343. //#define _Interlocked_operand_ _Pre_ _SA_annotes0(SAL_interlocked)
  2344. #define _Enum_is_bitflag_ _SA_annotes0(SAL_enumIsBitflag)
  2345. #define _Strict_type_match_ _SA_annotes0(SAL_strictType2)
  2346. #define _Maybe_raises_SEH_exception_ _Pre_ _SA_annotes1(SAL_inTry,__yes)
  2347. #define _Raises_SEH_exception_ _Group_(_Maybe_raises_SEH_exception_ _Analysis_noreturn_)
  2348. #ifdef __cplusplus // [
  2349. }
  2350. #endif // ]
  2351. // Rotor doesn't need concurrency sal.
  2352. // #include <ConcurrencySal.h>