1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifndef __RPCASYNC_H__
7 #define __RPCASYNC_H__
8 
9 #include <_mingw_unicode.h>
10 #ifdef __RPC_WIN64__
11 #include <pshpack8.h>
12 #endif
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define RPC_ASYNC_VERSION_1_0 sizeof(RPC_ASYNC_STATE)
19 
20   typedef enum _RPC_NOTIFICATION_TYPES {
21     RpcNotificationTypeNone,RpcNotificationTypeEvent,RpcNotificationTypeApc,RpcNotificationTypeIoc,RpcNotificationTypeHwnd,
22     RpcNotificationTypeCallback
23   } RPC_NOTIFICATION_TYPES;
24 
25   typedef enum _RPC_ASYNC_EVENT {
26     RpcCallComplete,RpcSendComplete,RpcReceiveComplete
27   } RPC_ASYNC_EVENT;
28 
29   struct _RPC_ASYNC_STATE;
30 
31   typedef void RPC_ENTRY RPCNOTIFICATION_ROUTINE(struct _RPC_ASYNC_STATE *pAsync,void *Context,RPC_ASYNC_EVENT Event);
32   typedef RPCNOTIFICATION_ROUTINE *PFN_RPCNOTIFICATION_ROUTINE;
33 
34   typedef struct _RPC_ASYNC_STATE {
35     unsigned int Size;
36     unsigned __LONG32 Signature;
37     __LONG32 Lock;
38     unsigned __LONG32 Flags;
39     void *StubInfo;
40     void *UserInfo;
41     void *RuntimeInfo;
42     RPC_ASYNC_EVENT Event;
43     RPC_NOTIFICATION_TYPES NotificationType;
44     union {
45       struct {
46 	PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
47 	HANDLE hThread;
48       } APC;
49       struct {
50 	HANDLE hIOPort;
51 	DWORD dwNumberOfBytesTransferred;
52 	DWORD_PTR dwCompletionKey;
53 	LPOVERLAPPED lpOverlapped;
54       } IOC;
55       struct {
56 	HWND hWnd;
57 	UINT Msg;
58       } HWND;
59       HANDLE hEvent;
60       PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
61     } u;
62     LONG_PTR Reserved[4];
63   } RPC_ASYNC_STATE,*PRPC_ASYNC_STATE;
64 
65 #define RPC_C_NOTIFY_ON_SEND_COMPLETE 0x1
66 #define RPC_C_INFINITE_TIMEOUT INFINITE
67 
68 #define RpcAsyncGetCallHandle(pAsync) (((PRPC_ASYNC_STATE) pAsync)->RuntimeInfo)
69 
70   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncInitializeHandle(PRPC_ASYNC_STATE pAsync,unsigned int Size);
71   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncRegisterInfo(PRPC_ASYNC_STATE pAsync);
72   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncGetCallStatus(PRPC_ASYNC_STATE pAsync);
73   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncCompleteCall(PRPC_ASYNC_STATE pAsync,void *Reply);
74   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync,unsigned __LONG32 ExceptionCode);
75   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncCancelCall(PRPC_ASYNC_STATE pAsync,WINBOOL fAbort);
76   RPCRTAPI RPC_STATUS RPC_ENTRY RpcAsyncCleanupThread(DWORD dwTimeout);
77 
78   typedef enum tagExtendedErrorParamTypes {
79     eeptAnsiString = 1,eeptUnicodeString,eeptLongVal,eeptShortVal,eeptPointerVal,eeptNone,eeptBinary
80   } ExtendedErrorParamTypes;
81 
82 #define MaxNumberOfEEInfoParams 4
83 #define RPC_EEINFO_VERSION 1
84 
85   typedef struct tagBinaryParam {
86     void *Buffer;
87     short Size;
88   } BinaryParam;
89 
90   typedef struct tagRPC_EE_INFO_PARAM {
91     ExtendedErrorParamTypes ParameterType;
92     union {
93       LPSTR AnsiString;
94       LPWSTR UnicodeString;
95       __LONG32 LVal;
96       short SVal;
97       ULONGLONG PVal;
98       BinaryParam BVal;
99     } u;
100   } RPC_EE_INFO_PARAM;
101 
102 #define EEInfoPreviousRecordsMissing 1
103 #define EEInfoNextRecordsMissing 2
104 #define EEInfoUseFileTime 4
105 
106 #define EEInfoGCCOM 11
107 #define EEInfoGCFRS 12
108 
109   typedef struct tagRPC_EXTENDED_ERROR_INFO {
110     ULONG Version;
111     LPWSTR ComputerName;
112     ULONG ProcessID;
113     union {
114       SYSTEMTIME SystemTime;
115       FILETIME FileTime;
116     } u;
117     ULONG GeneratingComponent;
118     ULONG Status;
119     USHORT DetectionLocation;
120     USHORT Flags;
121     int NumberOfParameters;
122     RPC_EE_INFO_PARAM Parameters[MaxNumberOfEEInfoParams];
123   } RPC_EXTENDED_ERROR_INFO;
124 
125   typedef struct tagRPC_ERROR_ENUM_HANDLE {
126     ULONG Signature;
127     void *CurrentPos;
128     void *Head;
129   } RPC_ERROR_ENUM_HANDLE;
130 
131   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorStartEnumeration(RPC_ERROR_ENUM_HANDLE *EnumHandle);
132   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorGetNextRecord(RPC_ERROR_ENUM_HANDLE *EnumHandle,WINBOOL CopyStrings,RPC_EXTENDED_ERROR_INFO *ErrorInfo);
133   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorEndEnumeration(RPC_ERROR_ENUM_HANDLE *EnumHandle);
134   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorResetEnumeration(RPC_ERROR_ENUM_HANDLE *EnumHandle);
135   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorGetNumberOfRecords(RPC_ERROR_ENUM_HANDLE *EnumHandle,int *Records);
136   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorSaveErrorInfo(RPC_ERROR_ENUM_HANDLE *EnumHandle,PVOID *ErrorBlob,size_t *BlobSize);
137   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorLoadErrorInfo(PVOID ErrorBlob,size_t BlobSize,RPC_ERROR_ENUM_HANDLE *EnumHandle);
138   RPCRTAPI RPC_STATUS RPC_ENTRY RpcErrorAddRecord(RPC_EXTENDED_ERROR_INFO *ErrorInfo);
139   RPCRTAPI void RPC_ENTRY RpcErrorClearInformation(void);
140   RPCRTAPI RPC_STATUS RPC_ENTRY RpcGetAuthorizationContextForClient(RPC_BINDING_HANDLE ClientBinding,WINBOOL ImpersonateOnReturn,PVOID Reserved1,PLARGE_INTEGER pExpirationTime,LUID Reserved2,DWORD Reserved3,PVOID Reserved4,PVOID *pAuthzClientContext);
141   RPCRTAPI RPC_STATUS RPC_ENTRY RpcFreeAuthorizationContext(PVOID *pAuthzClientContext);
142   RPCRTAPI RPC_STATUS RPC_ENTRY RpcSsContextLockExclusive(RPC_BINDING_HANDLE ServerBindingHandle,PVOID UserContext);
143   RPCRTAPI RPC_STATUS RPC_ENTRY RpcSsContextLockShared(RPC_BINDING_HANDLE ServerBindingHandle,PVOID UserContext);
144 
145 #define RPC_CALL_ATTRIBUTES_VERSION (1)
146 #define RPC_QUERY_SERVER_PRINCIPAL_NAME (2)
147 #define RPC_QUERY_CLIENT_PRINCIPAL_NAME (4)
148 
149   typedef struct tagRPC_CALL_ATTRIBUTES_V1_W {
150     unsigned int Version;
151     unsigned __LONG32 Flags;
152     unsigned __LONG32 ServerPrincipalNameBufferLength;
153     unsigned short *ServerPrincipalName;
154     unsigned __LONG32 ClientPrincipalNameBufferLength;
155     unsigned short *ClientPrincipalName;
156     unsigned __LONG32 AuthenticationLevel;
157     unsigned __LONG32 AuthenticationService;
158     WINBOOL NullSession;
159   } RPC_CALL_ATTRIBUTES_V1_W;
160 
161   typedef struct tagRPC_CALL_ATTRIBUTES_V1_A {
162     unsigned int Version;
163     unsigned __LONG32 Flags;
164     unsigned __LONG32 ServerPrincipalNameBufferLength;
165     unsigned char *ServerPrincipalName;
166     unsigned __LONG32 ClientPrincipalNameBufferLength;
167     unsigned char *ClientPrincipalName;
168     unsigned __LONG32 AuthenticationLevel;
169     unsigned __LONG32 AuthenticationService;
170     WINBOOL NullSession;
171   } RPC_CALL_ATTRIBUTES_V1_A;
172 
173 #define RPC_CALL_ATTRIBUTES_V1 __MINGW_NAME_UAW(RPC_CALL_ATTRIBUTES_V1)
174 #define RpcServerInqCallAttributes __MINGW_NAME_AW(RpcServerInqCallAttributes)
175 
176   RPCRTAPI RPC_STATUS RPC_ENTRY RpcServerInqCallAttributesW(RPC_BINDING_HANDLE ClientBinding,void *RpcCallAttributes);
177   RPCRTAPI RPC_STATUS RPC_ENTRY RpcServerInqCallAttributesA(RPC_BINDING_HANDLE ClientBinding,void *RpcCallAttributes);
178 
179   typedef RPC_CALL_ATTRIBUTES_V1 RPC_CALL_ATTRIBUTES;
180 
181   RPC_STATUS RPC_ENTRY I_RpcAsyncSetHandle(PRPC_MESSAGE Message,PRPC_ASYNC_STATE pAsync);
182   RPC_STATUS RPC_ENTRY I_RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync,unsigned __LONG32 ExceptionCode);
183   int RPC_ENTRY I_RpcExceptionFilter(unsigned __LONG32 ExceptionCode);
184 
185 typedef union _RPC_ASYNC_NOTIFICATION_INFO {
186   struct {
187     PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
188     HANDLE                      hThread;
189   } APC;
190   struct {
191     HANDLE       hIOPort;
192     DWORD        dwNumberOfBytesTransferred;
193     DWORD_PTR    dwCompletionKey;
194     LPOVERLAPPED lpOverlapped;
195   } IOC;
196   struct {
197     HWND hWnd;
198     UINT Msg;
199   } HWND;
200   HANDLE                      hEvent;
201   PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
202 } RPC_ASYNC_NOTIFICATION_INFO, *PRPC_ASYNC_NOTIFICATION_INFO;
203 
204 RPC_STATUS RPC_ENTRY RpcBindingBind(
205   PRPC_ASYNC_STATE pAsync,
206   RPC_BINDING_HANDLE Binding,
207   RPC_IF_HANDLE IfSpec
208 );
209 
210 RPC_STATUS RPC_ENTRY RpcBindingUnbind(
211   RPC_BINDING_HANDLE Binding
212 );
213 
214 typedef enum _RpcCallType {
215   rctInvalid,
216   rctNormal,
217   rctTraining,
218   rctGuaranteed
219 } RpcCallType;
220 
221 typedef enum _RpcLocalAddressFormat {
222   rlafInvalid,
223   rlafIPv4,
224   rlafIPv6
225 } RpcLocalAddressFormat;
226 
227 typedef enum _RPC_NOTIFICATIONS {
228   RpcNotificationCallNone           = 0,
229   RpcNotificationClientDisconnect   = 1,
230   RpcNotificationCallCancel         = 2
231 } RPC_NOTIFICATIONS;
232 
233 typedef enum _RpcCallClientLocality {
234   rcclInvalid,
235   rcclLocal,
236   rcclRemote,
237   rcclClientUnknownLocality
238 } RpcCallClientLocality;
239 
240 RPC_STATUS RPC_ENTRY RpcServerSubscribeForNotification(
241   RPC_BINDING_HANDLE Binding,
242   DWORD Notification,
243   RPC_NOTIFICATION_TYPES NotificationType,
244   RPC_ASYNC_NOTIFICATION_INFO *NotificationInfo
245 );
246 
247 RPC_STATUS RPC_ENTRY RpcServerUnsubscribeForNotification(
248   RPC_BINDING_HANDLE Binding,
249   RPC_NOTIFICATIONS Notification,
250   unsigned __LONG32 *NotificationsQueued
251 );
252 
253 #if (_WIN32_WINNT >= 0x0600)
254 
255 typedef struct tagRPC_CALL_LOCAL_ADDRESS_V1_A {
256   unsigned int          Version;
257   void                  *Buffer;
258   unsigned __LONG32     BufferSize;
259   RpcLocalAddressFormat AddressFormat;
260 } RPC_CALL_LOCAL_ADDRESS_V1_A, RPC_CALL_LOCAL_ADDRESS_A;
261 
262 typedef struct tagRPC_CALL_LOCAL_ADDRESS_V1_W {
263   unsigned int          Version;
264   void                  *Buffer;
265   unsigned __LONG32     BufferSize;
266   RpcLocalAddressFormat AddressFormat;
267 } RPC_CALL_LOCAL_ADDRESS_V1_W, RPC_CALL_LOCAL_ADDRESS_W;
268 
269 #define RPC_CALL_LOCAL_ADDRESS_V1 __MINGW_NAME_AW(RPC_CALL_LOCAL_ADDRESS_V1_)
270 #define RPC_CALL_LOCAL_ADDRESS __MINGW_NAME_AW(RPC_CALL_LOCAL_ADDRESS_)
271 
272 typedef struct tagRPC_CALL_ATTRIBUTES_V2A {
273   unsigned int           Version;
274   unsigned __LONG32      Flags;
275   unsigned __LONG32      ServerPrincipalNameBufferLength;
276   unsigned short         *ServerPrincipalName;
277   unsigned __LONG32      ClientPrincipalNameBufferLength;
278   unsigned short         *ClientPrincipalName;
279   unsigned __LONG32      AuthenticationLevel;
280   unsigned __LONG32      AuthenticationService;
281   WINBOOL                NullSession;
282   WINBOOL                KernelMode;
283   unsigned __LONG32      ProtocolSequence;
284   RpcCallClientLocality  IsClientLocal;
285   HANDLE                 ClientPID;
286   unsigned __LONG32      CallStatus;
287   RpcCallType            CallType;
288   RPC_CALL_LOCAL_ADDRESS_A *CallLocalAddress;
289   unsigned short         OpNum;
290   UUID                   InterfaceUuid;
291 } RPC_CALL_ATTRIBUTES_V2_A, RPC_CALL_ATTRIBUTES_A;
292 
293 typedef struct tagRPC_CALL_ATTRIBUTES_V2W {
294   unsigned int           Version;
295   unsigned __LONG32      Flags;
296   unsigned __LONG32      ServerPrincipalNameBufferLength;
297   unsigned short         *ServerPrincipalName;
298   unsigned __LONG32      ClientPrincipalNameBufferLength;
299   unsigned short         *ClientPrincipalName;
300   unsigned __LONG32      AuthenticationLevel;
301   unsigned __LONG32      AuthenticationService;
302   WINBOOL                NullSession;
303   WINBOOL                KernelMode;
304   unsigned __LONG32      ProtocolSequence;
305   RpcCallClientLocality  IsClientLocal;
306   HANDLE                 ClientPID;
307   unsigned __LONG32      CallStatus;
308   RpcCallType            CallType;
309   RPC_CALL_LOCAL_ADDRESS_W *CallLocalAddress;
310   unsigned short         OpNum;
311   UUID                   InterfaceUuid;
312 } RPC_CALL_ATTRIBUTES_V2_W, RPC_CALL_ATTRIBUTES_W;
313 
314 #define RPC_CALL_ATTRIBUTES_V2 __MINGW_NAME_AW(RPC_CALL_ATTRIBUTES_V2_)
315 
316 RPC_STATUS RPC_ENTRY RpcDiagnoseError(
317   RPC_BINDING_HANDLE BindingHandle,
318   RPC_IF_HANDLE IfSpec,
319   RPC_STATUS RpcStatus,
320   RPC_ERROR_ENUM_HANDLE *EnumHandle,
321   ULONG Options,
322   HWND ParentWindow
323 );
324 #endif /*(_WIN32_WINNT >= 0x0600)*/
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #ifdef __RPC_WIN64__
331 #include <poppack.h>
332 #endif
333 #endif
334