Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
20 KiB

  1. /****************************************************************\
  2. * *
  3. * rpcsal.h - markers for documenting the semantics of RPC APIs *
  4. * *
  5. * Version 1.0 *
  6. * *
  7. * Copyright (c) 2004 Microsoft Corporation. All rights reserved. *
  8. * *
  9. \****************************************************************/
  10. // -------------------------------------------------------------------------------
  11. // Introduction
  12. //
  13. // rpcsal.h provides a set of annotations to describe how RPC functions use their
  14. // parameters - the assumptions it makes about them, adn the guarantees it makes
  15. // upon finishing. These annotations are similar to those found in specstrings.h,
  16. // but are designed to be used by the MIDL compiler when it generates annotations
  17. // enabled header files.
  18. //
  19. // IDL authors do not need to annotate their functions declarations. The MIDL compiler
  20. // will interpret the IDL directives and use one of the annotations contained
  21. // in this header. This documentation is intended to help those trying to understand
  22. // the MIDL-generated header files or those who maintain their own copies of these files.
  23. //
  24. // -------------------------------------------------------------------------------
  25. // Differences between rpcsal.h and specstrings.h
  26. //
  27. // There are a few important differences between the annotations found in rpcsal.h and
  28. // those in specstrings.h:
  29. //
  30. // 1. [in] parameters are not marked as read-only. They may be used for scratch space
  31. // at the server and changes will not affect the client.
  32. // 2. String versions of each macro alleviates the need for a special type definition
  33. //
  34. // -------------------------------------------------------------------------------
  35. // Interpreting RPC Annotations
  36. //
  37. // These annotations are interpreted precisely in the same way as those in specstrings.h.
  38. // Please refer to that header for information related to general usage in annotations.
  39. //
  40. // To construct an RPC annotation, concatenate the appropriate value from each category
  41. // along with a leading __RPC_. A typical annotation looks like "__RPC__in_string".
  42. //
  43. // |----------------------------------------------------------------------------------|
  44. // | RPC Annotations |
  45. // |------------|------------|---------|--------|----------|----------|---------------|
  46. // | Level | Usage | Size | Output | Optional | String | Parameters |
  47. // |------------|------------|---------|--------|----------|----------|---------------|
  48. // | <> | <> | <> | <> | <> | <> | <> |
  49. // | _deref | _in | _ecount | _full | _opt | _string | (size) |
  50. // | _deref_opt | _out | _bcount | _part | | | (size,length) |
  51. // | | _inout | | | | | |
  52. // | | | | | | | |
  53. // |------------|------------|---------|--------|----------|----------|---------------|
  54. //
  55. // Level: Describes the buffer pointer's level of indirection from the parameter or
  56. // return value 'p'.
  57. //
  58. // <> : p is the buffer pointer.
  59. // _deref : *p is the buffer pointer. p must not be NULL.
  60. // _deref_opt : *p may be the buffer pointer. p may be NULL, in which case the rest of
  61. // the annotation is ignored.
  62. //
  63. // Usage: Describes how the function uses the buffer.
  64. //
  65. // <> : The buffer is not accessed. If used on the return value or with _deref, the
  66. // function will provide the buffer, and it will be uninitialized at exit.
  67. // Otherwise, the caller must provide the buffer. This should only be used
  68. // for alloc and free functions.
  69. // _in : The function will only read from the buffer. The caller must provide the
  70. // buffer and initialize it. Cannot be used with _deref.
  71. // _out : The function will only write to the buffer. If used on the return value or
  72. // with _deref, the function will provide the buffer and initialize it.
  73. // Otherwise, the caller must provide the buffer, and the function will
  74. // initialize it.
  75. // _inout : The function may freely read from and write to the buffer. The caller must
  76. // provide the buffer and initialize it. If used with _deref, the buffer may
  77. // be reallocated by the function.
  78. //
  79. // Size: Describes the total size of the buffer. This may be less than the space actually
  80. // allocated for the buffer, in which case it describes the accessible amount.
  81. //
  82. // <> : No buffer size is given. If the type specifies the buffer size (such as
  83. // with LPSTR and LPWSTR), that amount is used. Otherwise, the buffer is one
  84. // element long. Must be used with _in, _out, or _inout.
  85. // _ecount : The buffer size is an explicit element count.
  86. // _bcount : The buffer size is an explicit byte count.
  87. //
  88. // Output: Describes how much of the buffer will be initialized by the function. For
  89. // _inout buffers, this also describes how much is initialized at entry. Omit this
  90. // category for _in buffers; they must be fully initialized by the caller.
  91. //
  92. // <> : The type specifies how much is initialized. For instance, a function initializing
  93. // an LPWSTR must NULL-terminate the string.
  94. // _full : The function initializes the entire buffer.
  95. // _part : The function initializes part of the buffer, and explicitly indicates how much.
  96. //
  97. // Optional: Describes if the buffer itself is optional.
  98. //
  99. // <> : The pointer to the buffer must not be NULL.
  100. // _opt : The pointer to the buffer might be NULL. It will be checked before being dereferenced.
  101. //
  102. // String: Describes if the buffer is NULL terminated
  103. //
  104. // <> : The buffer is not assumed to be NULL terminated
  105. // _string : The buffer is assumed to be NULL terminated once it has been initialized
  106. //
  107. // Parameters: Gives explicit counts for the size and length of the buffer.
  108. //
  109. // <> : There is no explicit count. Use when neither _ecount nor _bcount is used.
  110. // (size) : Only the buffer's total size is given. Use with _ecount or _bcount but not _part.
  111. // (size,length) : The buffer's total size and initialized length are given. Use with _ecount_part
  112. // and _bcount_part.
  113. //
  114. // Notes:
  115. //
  116. // 1. Specifying two buffer annotations on a single parameter results in unspecified behavior
  117. // (e.g. __RPC__in_bcount(5) __RPC__out_bcount(6)
  118. //
  119. // 2. The size of the buffer and the amount that has been initialized are separate concepts.
  120. // Specify the size using _ecount or _bcount. Specify the amount that is initialized using
  121. // _full, _part, or _string. As a special case, a single element buffer does not need
  122. // _ecount, _bcount, _full, or _part
  123. //
  124. // 3. The count may be less than the total size of the buffer in which case it describes the
  125. // accessible portion.
  126. //
  127. // 4. "__RPC__opt" and "__RPC_deref" are not valid annotations.
  128. //
  129. // 5. The placement of _opt when using _deref is important:
  130. // __RPC__deref_opt_... : Input may be NULL
  131. // __RPC__deref_..._opt : Output may be NULL
  132. // __RPC__deref_opt_..._opt : Both input and output may be NULL
  133. //
  134. #pragma once
  135. #include <specstrings.h>
  136. #ifndef __RPCSAL_H_VERSION__
  137. #define __RPCSAL_H_VERSION__ ( 100 )
  138. #endif // __RPCSAL_H_VERSION__
  139. #ifdef __REQUIRED_RPCSAL_H_VERSION__
  140. #if ( __RPCSAL_H_VERSION__ < __REQUIRED_RPCSAL_H_VERSION__ )
  141. #error incorrect <rpcsal.h> version. Use the header that matches with the MIDL compiler.
  142. #endif
  143. #endif
  144. #ifdef __cplusplus
  145. extern "C" {
  146. #endif // #ifdef __cplusplus
  147. #if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_)
  148. // [in]
  149. #define __RPC__in __pre __valid
  150. #define __RPC__in_string __RPC__in __pre __nullterminated
  151. #define __RPC__in_ecount(size) __RPC__in __pre __elem_readableTo(size)
  152. #define __RPC__in_ecount_full(size) __RPC__in_ecount(size)
  153. #define __RPC__in_ecount_full_string(size) __RPC__in_ecount_full(size) __pre __nullterminated
  154. #define __RPC__in_ecount_part(size, length) __RPC__in_ecount(length) __pre __elem_writableTo(size)
  155. #define __RPC__in_ecount_full_opt(size) __RPC__in_ecount_full(size) __pre __exceptthat __maybenull
  156. #define __RPC__in_ecount_full_opt_string(size) __RPC__in_ecount_full_opt(size) __pre __nullterminated
  157. #define __RPC__in_ecount_part_opt(size, length) __RPC__in_ecount_part(size, length) __pre __exceptthat __maybenull
  158. #define __RPC__deref_in __RPC__in __deref __notnull
  159. #define __RPC__deref_in_string __RPC__in __pre __deref __nullterminated
  160. #define __RPC__deref_in_opt __RPC__deref_in __deref __exceptthat __maybenull
  161. #define __RPC__deref_opt_in __RPC__in __exceptthat __maybenull
  162. #define __RPC__deref_opt_in_opt __RPC__deref_opt_in __pre __deref __exceptthat __maybenull
  163. #define __RPC__deref_in_ecount(size) __RPC__in __pre __deref __elem_readableTo(size)
  164. #define __RPC__deref_in_ecount_part(size, length) __RPC__deref_in_ecount(size) __pre __deref __elem_readableTo(length)
  165. #define __RPC__deref_in_ecount_full(size) __RPC__deref_in_ecount_part(size, size)
  166. #define __RPC__deref_in_ecount_full_opt(size) __RPC__deref_in_ecount_full(size) __pre __deref __exceptthat __maybenull
  167. #define __RPC__deref_in_ecount_full_opt_string(size) __RPC__deref_in_ecount_full_opt(size) __pre __deref __nullterminated
  168. #define __RPC__deref_in_ecount_full_string(size) __RPC__deref_in_ecount_full(size) __pre __deref __nullterminated
  169. #define __RPC__deref_in_ecount_opt(size) __RPC__deref_in_ecount(size) __pre __deref __exceptthat __maybenull
  170. #define __RPC__deref_in_ecount_opt_string(size) __RPC__deref_in_ecount_opt(size) __pre __deref __nullterminated
  171. #define __RPC__deref_in_ecount_part_opt(size, length) __RPC__deref_in_ecount_opt(size) __pre __deref __elem_readableTo(length)
  172. // [out]
  173. #define __RPC__out __out
  174. #define __RPC__out_ecount(size) __out_ecount(size) __post __elem_writableTo(size)
  175. #define __RPC__out_ecount_string(size) __RPC__out_ecount(size) __post __nullterminated
  176. #define __RPC__out_ecount_part(size, length) __RPC__out_ecount(size) __post __elem_readableTo(length)
  177. #define __RPC__out_ecount_full(size) __RPC__out_ecount_part(size, size)
  178. #define __RPC__out_ecount_full_string(size) __RPC__out_ecount_full(size) __post __nullterminated
  179. // [in,out]
  180. #define __RPC__inout __inout
  181. #define __RPC__inout_string __RPC__inout __pre __nullterminated __post __nullterminated
  182. #define __RPC__inout_ecount(size) __inout_ecount(size)
  183. #define __RPC__inout_ecount_part(size, length) __inout_ecount_part(size, length)
  184. #define __RPC__inout_ecount_full(size) __RPC__inout_ecount_part(size, size)
  185. #define __RPC__inout_ecount_full_string(size) __RPC__inout_ecount_full(size) __pre __nullterminated __post __nullterminated
  186. // [in,unique]
  187. #define __RPC__in_opt __RPC__in __pre __exceptthat __maybenull
  188. #define __RPC__in_opt_string __RPC__in_opt __pre __nullterminated
  189. #define __RPC__in_ecount_opt(size) __RPC__in_ecount(size) __pre __exceptthat __maybenull
  190. #define __RPC__in_ecount_opt_string(size) __RPC__in_ecount_opt(size) __pre __nullterminated
  191. // [in,out,unique]
  192. #define __RPC__inout_opt __inout_opt
  193. #define __RPC__inout_ecount_opt(size) __inout_ecount_opt(size)
  194. #define __RPC__inout_ecount_part_opt(size, length) __inout_ecount_part_opt(size, length)
  195. #define __RPC__inout_ecount_full_opt(size) __RPC__inout_ecount_part_opt(size, size)
  196. #define __RPC__inout_ecount_full_opt_string(size) __RPC__inout_ecount_full_opt(size) __pre __nullterminated __post __nullterminated
  197. // [out] **
  198. #define __RPC__deref_out __deref_out
  199. #define __RPC__deref_out_string __RPC__deref_out __post __deref __nullterminated
  200. // Removed "__post __deref __exceptthat __maybenull" so return values from QueryInterface and the like can be trusted without an explicit NULL check.
  201. // This is a temporary fix until midl.exe can be rev'd to produce more accurate annotations.
  202. #define __RPC__deref_out_opt __RPC__deref_out
  203. #define __RPC__deref_out_opt_string __RPC__deref_out_opt __post __deref __nullterminated __pre __deref __null
  204. #define __RPC__deref_out_ecount(size) __deref_out_ecount(size) __post __deref __elem_writableTo(size)
  205. #define __RPC__deref_out_ecount_part(size, length) __RPC__deref_out_ecount(size) __post __deref __elem_readableTo(length)
  206. #define __RPC__deref_out_ecount_full(size) __RPC__deref_out_ecount_part(size,size)
  207. #define __RPC__deref_out_ecount_full_string(size) __RPC__deref_out_ecount_full(size) __post __deref __nullterminated
  208. // [in,out] **, second pointer decoration.
  209. #define __RPC__deref_inout __deref_inout
  210. #define __RPC__deref_inout_string __RPC__deref_inout __pre __deref __nullterminated __post __deref __nullterminated
  211. #define __RPC__deref_inout_opt __deref_inout_opt
  212. #define __RPC__deref_inout_opt_string __RPC__deref_inout_opt __deref __nullterminated
  213. #define __RPC__deref_inout_ecount_opt(size) __deref_inout_ecount_opt(size)
  214. #define __RPC__deref_inout_ecount_part_opt(size, length) __deref_inout_ecount_part_opt(size , length)
  215. #define __RPC__deref_inout_ecount_full_opt(size) __RPC__deref_inout_ecount_part_opt(size, size)
  216. #define __RPC__deref_inout_ecount_full(size) __deref_inout_ecount_full(size)
  217. #define __RPC__deref_inout_ecount_full_string(size) __RPC__deref_inout_ecount_full(size) __post __deref __nullterminated
  218. #define __RPC__deref_inout_ecount_full_opt_string(size) __RPC__deref_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  219. // #define __RPC_out_opt out_opt is not allowed in rpc
  220. // [in,out,unique]
  221. #define __RPC__deref_opt_inout __deref_opt_inout
  222. #define __RPC__deref_opt_inout_ecount(size) __deref_opt_inout_ecount(size)
  223. #define __RPC__deref_opt_inout_string __RPC__deref_opt_inout __pre __deref __nullterminated __post __deref __nullterminated
  224. #define __RPC__deref_opt_inout_ecount_part(size, length) __deref_opt_inout_ecount_part(size, length)
  225. #define __RPC__deref_opt_inout_ecount_full(size) __deref_opt_inout_ecount_full(size)
  226. #define __RPC__deref_opt_inout_ecount_full_string(size) __RPC__deref_opt_inout_ecount_full(size) __pre __deref __nullterminated __post __deref __nullterminated
  227. // We don't need to specify __pre __deref __exceptthat __maybenull : this is default behavior. While this might not hold in SAL 1.1 syntax, SAL team
  228. // believes it's OK. We can revisit if SAL 1.1 can survive.
  229. #define __RPC__deref_out_ecount_opt(size) __RPC__out_ecount(size) __post __deref __exceptthat __maybenull __pre __deref __null
  230. #define __RPC__deref_out_ecount_part_opt(size, length) __RPC__deref_out_ecount_part(size, length) __post __deref __exceptthat __maybenull __pre __deref __null
  231. #define __RPC__deref_out_ecount_full_opt(size) __RPC__deref_out_ecount_part_opt(size, size) __pre __deref __null
  232. #define __RPC__deref_out_ecount_full_opt_string(size) __RPC__deref_out_ecount_part_opt(size, size) __post __deref __nullterminated __pre __deref __null
  233. #define __RPC__deref_opt_inout_opt __deref_opt_inout_opt
  234. #define __RPC__deref_opt_inout_opt_string __RPC__deref_opt_inout_opt __pre __deref __nullterminated __post __deref __nullterminated
  235. #define __RPC__deref_opt_inout_ecount_opt(size) __deref_opt_inout_ecount_opt(size)
  236. #define __RPC__deref_opt_inout_ecount_part_opt(size, length) __deref_opt_inout_ecount_part_opt(size, length)
  237. #define __RPC__deref_opt_inout_ecount_full_opt(size) __RPC__deref_opt_inout_ecount_part_opt(size, size)
  238. #define __RPC__deref_opt_inout_ecount_full_opt_string(size) __RPC__deref_opt_inout_ecount_full_opt(size) __pre __deref __nullterminated __post __deref __nullterminated
  239. #define __RPC_full_pointer __maybenull
  240. #define __RPC_unique_pointer __maybenull
  241. #define __RPC_ref_pointer __notnull
  242. #define __RPC_string __nullterminated
  243. #else // not prefast
  244. #define RPC_range(min,max)
  245. #define __RPC__in
  246. #define __RPC__in_string
  247. #define __RPC__in_opt_string
  248. #define __RPC__deref_opt_in_opt
  249. #define __RPC__opt_in_opt_string
  250. #define __RPC__in_ecount(size)
  251. #define __RPC__in_ecount_full(size)
  252. #define __RPC__in_ecount_full_string(size)
  253. #define __RPC__in_ecount_part(size, length)
  254. #define __RPC__in_ecount_full_opt(size)
  255. #define __RPC__in_ecount_full_opt_string(size)
  256. #define __RPC__inout_ecount_full_opt_string(size)
  257. #define __RPC__in_ecount_part_opt(size, length)
  258. #define __RPC__deref_in
  259. #define __RPC__deref_in_string
  260. #define __RPC__deref_opt_in
  261. #define __RPC__deref_in_opt
  262. #define __RPC__deref_in_ecount(size)
  263. #define __RPC__deref_in_ecount_part(size, length)
  264. #define __RPC__deref_in_ecount_full(size)
  265. #define __RPC__deref_in_ecount_full_opt(size)
  266. #define __RPC__deref_in_ecount_full_string(size)
  267. #define __RPC__deref_in_ecount_full_opt_string(size)
  268. #define __RPC__deref_in_ecount_opt(size)
  269. #define __RPC__deref_in_ecount_opt_string(size)
  270. #define __RPC__deref_in_ecount_part_opt(size, length)
  271. // [out]
  272. #define __RPC__out
  273. #define __RPC__out_ecount(size)
  274. #define __RPC__out_ecount_part(size, length)
  275. #define __RPC__out_ecount_full(size)
  276. #define __RPC__out_ecount_full_string(size)
  277. // [in,out]
  278. #define __RPC__inout
  279. #define __RPC__inout_string
  280. #define __RPC__opt_inout
  281. #define __RPC__inout_ecount(size)
  282. #define __RPC__inout_ecount_part(size, length)
  283. #define __RPC__inout_ecount_full(size)
  284. #define __RPC__inout_ecount_full_string(size)
  285. // [in,unique]
  286. #define __RPC__in_opt
  287. #define __RPC__in_ecount_opt(size)
  288. // [in,out,unique]
  289. #define __RPC__inout_opt
  290. #define __RPC__inout_ecount_opt(size)
  291. #define __RPC__inout_ecount_part_opt(size, length)
  292. #define __RPC__inout_ecount_full_opt(size)
  293. #define __RPC__inout_ecount_full_string(size)
  294. // [out] **
  295. #define __RPC__deref_out
  296. #define __RPC__deref_out_string
  297. #define __RPC__deref_out_opt
  298. #define __RPC__deref_out_opt_string
  299. #define __RPC__deref_out_ecount(size)
  300. #define __RPC__deref_out_ecount_part(size, length)
  301. #define __RPC__deref_out_ecount_full(size)
  302. #define __RPC__deref_out_ecount_full_string(size)
  303. // [in,out] **, second pointer decoration.
  304. #define __RPC__deref_inout
  305. #define __RPC__deref_inout_string
  306. #define __RPC__deref_inout_opt
  307. #define __RPC__deref_inout_opt_string
  308. #define __RPC__deref_inout_ecount_full(size)
  309. #define __RPC__deref_inout_ecount_full_string(size)
  310. #define __RPC__deref_inout_ecount_opt(size)
  311. #define __RPC__deref_inout_ecount_part_opt(size, length)
  312. #define __RPC__deref_inout_ecount_full_opt(size)
  313. #define __RPC__deref_inout_ecount_full_opt_string(size)
  314. // #define __RPC_out_opt out_opt is not allowed in rpc
  315. // [in,out,unique]
  316. #define __RPC__deref_opt_inout
  317. #define __RPC__deref_opt_inout_string
  318. #define __RPC__deref_opt_inout_ecount(size)
  319. #define __RPC__deref_opt_inout_ecount_part(size, length)
  320. #define __RPC__deref_opt_inout_ecount_full(size)
  321. #define __RPC__deref_opt_inout_ecount_full_string(size)
  322. #define __RPC__deref_out_ecount_opt(size)
  323. #define __RPC__deref_out_ecount_part_opt(size, length)
  324. #define __RPC__deref_out_ecount_full_opt(size)
  325. #define __RPC__deref_out_ecount_full_opt_string(size)
  326. #define __RPC__deref_opt_inout_opt
  327. #define __RPC__deref_opt_inout_opt_string
  328. #define __RPC__deref_opt_inout_ecount_opt(size)
  329. #define __RPC__deref_opt_inout_ecount_part_opt(size, length)
  330. #define __RPC__deref_opt_inout_ecount_full_opt(size)
  331. #define __RPC__deref_opt_inout_ecount_full_opt_string(size)
  332. #define __RPC_full_pointer
  333. #define __RPC_unique_pointer
  334. #define __RPC_ref_pointer
  335. #define __RPC_string
  336. #endif
  337. #ifdef __cplusplus
  338. }
  339. #endif