Leaked source code of windows server 2003
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.

433 lines
8.8 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. rpcasync.h
  5. Abstract:
  6. This module contains the RPC runtime APIs needed to use
  7. [async] RPC features.
  8. --*/
  9. #ifndef __RPCASYNC_H__
  10. #define __RPCASYNC_H__
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif
  14. #if defined(__RPC_WIN64__)
  15. #include <pshpack8.h>
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define RPC_ASYNC_VERSION_1_0 sizeof(RPC_ASYNC_STATE)
  21. typedef
  22. enum _RPC_NOTIFICATION_TYPES
  23. {
  24. RpcNotificationTypeNone,
  25. RpcNotificationTypeEvent,
  26. RpcNotificationTypeApc,
  27. RpcNotificationTypeIoc,
  28. RpcNotificationTypeHwnd,
  29. RpcNotificationTypeCallback
  30. } RPC_NOTIFICATION_TYPES;
  31. typedef
  32. enum _RPC_ASYNC_EVENT {
  33. RpcCallComplete,
  34. RpcSendComplete,
  35. RpcReceiveComplete
  36. } RPC_ASYNC_EVENT;
  37. struct _RPC_ASYNC_STATE;
  38. typedef void RPC_ENTRY
  39. RPCNOTIFICATION_ROUTINE (
  40. struct _RPC_ASYNC_STATE *pAsync,
  41. void *Context,
  42. RPC_ASYNC_EVENT Event);
  43. typedef RPCNOTIFICATION_ROUTINE *PFN_RPCNOTIFICATION_ROUTINE;
  44. typedef struct _RPC_ASYNC_STATE {
  45. unsigned int Size; // size of this structure
  46. unsigned long Signature;
  47. long Lock;
  48. unsigned long Flags;
  49. void *StubInfo;
  50. void *UserInfo;
  51. void *RuntimeInfo;
  52. RPC_ASYNC_EVENT Event;
  53. RPC_NOTIFICATION_TYPES NotificationType;
  54. union {
  55. //
  56. // Notification by APC
  57. //
  58. struct {
  59. PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
  60. HANDLE hThread;
  61. } APC;
  62. //
  63. // Notification by IO completion port
  64. //
  65. struct {
  66. HANDLE hIOPort;
  67. DWORD dwNumberOfBytesTransferred;
  68. DWORD_PTR dwCompletionKey;
  69. LPOVERLAPPED lpOverlapped;
  70. } IOC;
  71. //
  72. // Notification by window message
  73. //
  74. struct {
  75. HWND hWnd;
  76. UINT Msg;
  77. } HWND;
  78. //
  79. // Notification by event
  80. //
  81. HANDLE hEvent;
  82. //
  83. // Notification by callback function
  84. //
  85. // This option is available only to OLE
  86. //
  87. PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
  88. } u;
  89. LONG_PTR Reserved[4];
  90. } RPC_ASYNC_STATE, *PRPC_ASYNC_STATE;
  91. // Possible values for Flags
  92. #define RPC_C_NOTIFY_ON_SEND_COMPLETE 0x1
  93. #define RPC_C_INFINITE_TIMEOUT INFINITE
  94. #define RpcAsyncGetCallHandle(pAsync) (((PRPC_ASYNC_STATE) pAsync)->RuntimeInfo)
  95. RPCRTAPI
  96. RPC_STATUS
  97. RPC_ENTRY
  98. RpcAsyncInitializeHandle (
  99. PRPC_ASYNC_STATE pAsync,
  100. unsigned int Size
  101. );
  102. RPCRTAPI
  103. RPC_STATUS
  104. RPC_ENTRY
  105. RpcAsyncRegisterInfo (
  106. PRPC_ASYNC_STATE pAsync
  107. ) ;
  108. RPCRTAPI
  109. RPC_STATUS
  110. RPC_ENTRY
  111. RpcAsyncGetCallStatus (
  112. PRPC_ASYNC_STATE pAsync
  113. ) ;
  114. RPCRTAPI
  115. RPC_STATUS
  116. RPC_ENTRY
  117. RpcAsyncCompleteCall (
  118. PRPC_ASYNC_STATE pAsync,
  119. void *Reply
  120. ) ;
  121. RPCRTAPI
  122. RPC_STATUS
  123. RPC_ENTRY
  124. RpcAsyncAbortCall (
  125. PRPC_ASYNC_STATE pAsync,
  126. unsigned long ExceptionCode
  127. ) ;
  128. RPCRTAPI
  129. RPC_STATUS
  130. RPC_ENTRY
  131. RpcAsyncCancelCall (
  132. IN PRPC_ASYNC_STATE pAsync,
  133. IN BOOL fAbort
  134. ) ;
  135. RPCRTAPI
  136. RPC_STATUS
  137. RPC_ENTRY
  138. RpcAsyncCleanupThread (
  139. IN DWORD dwTimeout
  140. );
  141. typedef enum tagExtendedErrorParamTypes
  142. {
  143. eeptAnsiString = 1,
  144. eeptUnicodeString,
  145. eeptLongVal,
  146. eeptShortVal,
  147. eeptPointerVal,
  148. eeptNone,
  149. eeptBinary
  150. } ExtendedErrorParamTypes;
  151. #define MaxNumberOfEEInfoParams 4
  152. #define RPC_EEINFO_VERSION 1
  153. typedef struct tagBinaryParam
  154. {
  155. void *Buffer;
  156. short Size;
  157. } BinaryParam;
  158. typedef struct tagRPC_EE_INFO_PARAM
  159. {
  160. ExtendedErrorParamTypes ParameterType;
  161. union
  162. {
  163. LPSTR AnsiString;
  164. LPWSTR UnicodeString;
  165. long LVal;
  166. short SVal;
  167. ULONGLONG PVal;
  168. BinaryParam BVal;
  169. } u;
  170. } RPC_EE_INFO_PARAM;
  171. #define EEInfoPreviousRecordsMissing 1
  172. #define EEInfoNextRecordsMissing 2
  173. #define EEInfoUseFileTime 4
  174. #define EEInfoGCCOM 11
  175. #define EEInfoGCFRS 12
  176. typedef struct tagRPC_EXTENDED_ERROR_INFO
  177. {
  178. ULONG Version;
  179. LPWSTR ComputerName;
  180. ULONG ProcessID;
  181. union
  182. {
  183. SYSTEMTIME SystemTime;
  184. FILETIME FileTime;
  185. } u;
  186. ULONG GeneratingComponent;
  187. ULONG Status;
  188. USHORT DetectionLocation;
  189. USHORT Flags;
  190. int NumberOfParameters;
  191. RPC_EE_INFO_PARAM Parameters[MaxNumberOfEEInfoParams];
  192. } RPC_EXTENDED_ERROR_INFO;
  193. typedef struct tagRPC_ERROR_ENUM_HANDLE
  194. {
  195. ULONG Signature;
  196. void *CurrentPos;
  197. void *Head;
  198. } RPC_ERROR_ENUM_HANDLE;
  199. RPCRTAPI
  200. RPC_STATUS
  201. RPC_ENTRY
  202. RpcErrorStartEnumeration (
  203. IN OUT RPC_ERROR_ENUM_HANDLE *EnumHandle
  204. );
  205. RPCRTAPI
  206. RPC_STATUS
  207. RPC_ENTRY
  208. RpcErrorGetNextRecord (
  209. IN RPC_ERROR_ENUM_HANDLE *EnumHandle,
  210. IN BOOL CopyStrings,
  211. OUT RPC_EXTENDED_ERROR_INFO *ErrorInfo
  212. );
  213. RPCRTAPI
  214. RPC_STATUS
  215. RPC_ENTRY
  216. RpcErrorEndEnumeration (
  217. IN OUT RPC_ERROR_ENUM_HANDLE *EnumHandle
  218. );
  219. RPCRTAPI
  220. RPC_STATUS
  221. RPC_ENTRY
  222. RpcErrorResetEnumeration (
  223. IN OUT RPC_ERROR_ENUM_HANDLE *EnumHandle
  224. );
  225. RPCRTAPI
  226. RPC_STATUS
  227. RPC_ENTRY
  228. RpcErrorGetNumberOfRecords (
  229. IN RPC_ERROR_ENUM_HANDLE *EnumHandle,
  230. OUT int *Records
  231. );
  232. RPCRTAPI
  233. RPC_STATUS
  234. RPC_ENTRY
  235. RpcErrorSaveErrorInfo (
  236. IN RPC_ERROR_ENUM_HANDLE *EnumHandle,
  237. OUT PVOID *ErrorBlob,
  238. OUT size_t *BlobSize
  239. );
  240. RPCRTAPI
  241. RPC_STATUS
  242. RPC_ENTRY
  243. RpcErrorLoadErrorInfo (
  244. IN PVOID ErrorBlob,
  245. IN size_t BlobSize,
  246. OUT RPC_ERROR_ENUM_HANDLE *EnumHandle
  247. );
  248. RPCRTAPI
  249. RPC_STATUS
  250. RPC_ENTRY
  251. RpcErrorAddRecord (
  252. IN RPC_EXTENDED_ERROR_INFO *ErrorInfo
  253. );
  254. RPCRTAPI
  255. void
  256. RPC_ENTRY
  257. RpcErrorClearInformation (
  258. void
  259. );
  260. RPCRTAPI
  261. RPC_STATUS
  262. RPC_ENTRY
  263. RpcGetAuthorizationContextForClient (
  264. IN RPC_BINDING_HANDLE ClientBinding OPTIONAL,
  265. IN BOOL ImpersonateOnReturn,
  266. IN PVOID Reserved1,
  267. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  268. IN LUID Reserved2,
  269. IN DWORD Reserved3,
  270. IN PVOID Reserved4,
  271. OUT PVOID *pAuthzClientContext
  272. );
  273. RPCRTAPI
  274. RPC_STATUS
  275. RPC_ENTRY
  276. RpcFreeAuthorizationContext (
  277. IN OUT PVOID *pAuthzClientContext
  278. );
  279. RPCRTAPI
  280. RPC_STATUS
  281. RPC_ENTRY
  282. RpcSsContextLockExclusive (
  283. IN RPC_BINDING_HANDLE ServerBindingHandle,
  284. IN PVOID UserContext
  285. );
  286. RPCRTAPI
  287. RPC_STATUS
  288. RPC_ENTRY
  289. RpcSsContextLockShared (
  290. IN RPC_BINDING_HANDLE ServerBindingHandle,
  291. IN PVOID UserContext
  292. );
  293. #define RPC_CALL_ATTRIBUTES_VERSION (1)
  294. #define RPC_QUERY_SERVER_PRINCIPAL_NAME (2)
  295. #define RPC_QUERY_CLIENT_PRINCIPAL_NAME (4)
  296. typedef struct tagRPC_CALL_ATTRIBUTES_V1_W
  297. {
  298. unsigned int Version;
  299. unsigned long Flags;
  300. unsigned long ServerPrincipalNameBufferLength;
  301. unsigned short *ServerPrincipalName;
  302. unsigned long ClientPrincipalNameBufferLength;
  303. unsigned short *ClientPrincipalName;
  304. unsigned long AuthenticationLevel;
  305. unsigned long AuthenticationService;
  306. BOOL NullSession;
  307. } RPC_CALL_ATTRIBUTES_V1_W;
  308. typedef struct tagRPC_CALL_ATTRIBUTES_V1_A
  309. {
  310. unsigned int Version;
  311. unsigned long Flags;
  312. unsigned long ServerPrincipalNameBufferLength;
  313. unsigned char *ServerPrincipalName;
  314. unsigned long ClientPrincipalNameBufferLength;
  315. unsigned char *ClientPrincipalName;
  316. unsigned long AuthenticationLevel;
  317. unsigned long AuthenticationService;
  318. BOOL NullSession;
  319. } RPC_CALL_ATTRIBUTES_V1_A;
  320. RPCRTAPI
  321. RPC_STATUS
  322. RPC_ENTRY
  323. RpcServerInqCallAttributesW (
  324. IN RPC_BINDING_HANDLE ClientBinding, OPTIONAL
  325. IN OUT void *RpcCallAttributes
  326. );
  327. RPCRTAPI
  328. RPC_STATUS
  329. RPC_ENTRY
  330. RpcServerInqCallAttributesA (
  331. IN RPC_BINDING_HANDLE ClientBinding, OPTIONAL
  332. IN OUT void *RpcCallAttributes
  333. );
  334. #ifdef UNICODE
  335. # define RPC_CALL_ATTRIBUTES_V1 RPC_CALL_ATTRIBUTES_V1_W
  336. # define RpcServerInqCallAttributes RpcServerInqCallAttributesW
  337. #else
  338. # define RPC_CALL_ATTRIBUTES_V1 RPC_CALL_ATTRIBUTES_V1_A
  339. # define RpcServerInqCallAttributes RpcServerInqCallAttributesA
  340. #endif // !UNICODE
  341. typedef RPC_CALL_ATTRIBUTES_V1 RPC_CALL_ATTRIBUTES;
  342. //
  343. // Internal APIs
  344. //
  345. RPC_STATUS RPC_ENTRY
  346. I_RpcAsyncSetHandle (
  347. IN PRPC_MESSAGE Message,
  348. IN PRPC_ASYNC_STATE pAsync
  349. );
  350. RPC_STATUS RPC_ENTRY
  351. I_RpcAsyncAbortCall (
  352. IN PRPC_ASYNC_STATE pAsync,
  353. IN unsigned long ExceptionCode
  354. ) ;
  355. int
  356. RPC_ENTRY
  357. I_RpcExceptionFilter (
  358. unsigned long ExceptionCode
  359. );
  360. #ifdef __cplusplus
  361. }
  362. #endif
  363. #if defined(__RPC_WIN64__)
  364. #include <poppack.h>
  365. #endif
  366. #endif /* __RPCASYNC_H__ */