FreeRDP
rpc_fault.c
1 
20 #include <freerdp/config.h>
21 
22 #include <freerdp/log.h>
23 
24 #include "rpc_fault.h"
25 
26 #include "rpc.h"
27 
28 #define TAG FREERDP_TAG("core.gateway.rpc")
29 
30 static ALIGN64 const RPC_FAULT_CODE RPC_FAULT_CODES[] = {
31  DEFINE_RPC_FAULT_CODE(nca_s_fault_object_not_found, CAT_GATEWAY),
32  DEFINE_RPC_FAULT_CODE(nca_s_fault_cancel, CAT_GATEWAY),
33  DEFINE_RPC_FAULT_CODE(nca_s_fault_addr_error, CAT_GATEWAY),
34  DEFINE_RPC_FAULT_CODE(nca_s_fault_context_mismatch, CAT_GATEWAY),
35  DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_div_zero, CAT_GATEWAY),
36  DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_error, CAT_GATEWAY),
37  DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_overflow, CAT_GATEWAY),
38  DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_underflow, CAT_GATEWAY),
39  DEFINE_RPC_FAULT_CODE(nca_s_fault_ill_inst, CAT_GATEWAY),
40  DEFINE_RPC_FAULT_CODE(nca_s_fault_int_div_by_zero, CAT_GATEWAY),
41  DEFINE_RPC_FAULT_CODE(nca_s_fault_int_overflow, CAT_GATEWAY),
42  DEFINE_RPC_FAULT_CODE(nca_s_fault_invalid_bound, CAT_GATEWAY),
43  DEFINE_RPC_FAULT_CODE(nca_s_fault_invalid_tag, CAT_GATEWAY),
44  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_closed, CAT_GATEWAY),
45  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_comm_error, CAT_GATEWAY),
46  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_discipline, CAT_GATEWAY),
47  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_empty, CAT_GATEWAY),
48  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_memory, CAT_GATEWAY),
49  DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_order, CAT_GATEWAY),
50  DEFINE_RPC_FAULT_CODE(nca_s_fault_remote_no_memory, CAT_GATEWAY),
51  DEFINE_RPC_FAULT_CODE(nca_s_fault_user_defined, CAT_GATEWAY),
52  DEFINE_RPC_FAULT_CODE(nca_s_fault_tx_open_failed, CAT_GATEWAY),
53  DEFINE_RPC_FAULT_CODE(nca_s_fault_codeset_conv_error, CAT_GATEWAY),
54  DEFINE_RPC_FAULT_CODE(nca_s_fault_no_client_stub, CAT_GATEWAY),
55  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_STRING_BINDING, CAT_GATEWAY),
56  DEFINE_RPC_FAULT_CODE(RPC_S_WRONG_KIND_OF_BINDING, CAT_GATEWAY),
57  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_BINDING, CAT_GATEWAY),
58  DEFINE_RPC_FAULT_CODE(RPC_S_PROTSEQ_NOT_SUPPORTED, CAT_GATEWAY),
59  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_RPC_PROTSEQ, CAT_GATEWAY),
60  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_STRING_UUID, CAT_GATEWAY),
61  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_ENDPOINT_FORMAT, CAT_GATEWAY),
62  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_NET_ADDR, CAT_GATEWAY),
63  DEFINE_RPC_FAULT_CODE(RPC_S_NO_ENDPOINT_FOUND, CAT_GATEWAY),
64  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_TIMEOUT, CAT_GATEWAY),
65  DEFINE_RPC_FAULT_CODE(RPC_S_OBJECT_NOT_FOUND, CAT_GATEWAY),
66  DEFINE_RPC_FAULT_CODE(RPC_S_ALREADY_REGISTERED, CAT_GATEWAY),
67  DEFINE_RPC_FAULT_CODE(RPC_S_TYPE_ALREADY_REGISTERED, CAT_GATEWAY),
68  DEFINE_RPC_FAULT_CODE(RPC_S_ALREADY_LISTENING, CAT_GATEWAY),
69  DEFINE_RPC_FAULT_CODE(RPC_S_NO_PROTSEQS_REGISTERED, CAT_GATEWAY),
70  DEFINE_RPC_FAULT_CODE(RPC_S_NOT_LISTENING, CAT_GATEWAY),
71  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_MGR_TYPE, CAT_GATEWAY),
72  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_IF, CAT_GATEWAY),
73  DEFINE_RPC_FAULT_CODE(RPC_S_NO_BINDINGS, CAT_GATEWAY),
74  DEFINE_RPC_FAULT_CODE(RPC_S_NO_PROTSEQS, CAT_GATEWAY),
75  DEFINE_RPC_FAULT_CODE(RPC_S_CANT_CREATE_ENDPOINT, CAT_GATEWAY),
76  DEFINE_RPC_FAULT_CODE(RPC_S_OUT_OF_RESOURCES, CAT_GATEWAY),
77  DEFINE_RPC_FAULT_CODE(RPC_S_SERVER_UNAVAILABLE, CAT_GATEWAY),
78  DEFINE_RPC_FAULT_CODE(RPC_S_SERVER_TOO_BUSY, CAT_GATEWAY),
79  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_NETWORK_OPTIONS, CAT_GATEWAY),
80  DEFINE_RPC_FAULT_CODE(RPC_S_NO_CALL_ACTIVE, CAT_GATEWAY),
81  DEFINE_RPC_FAULT_CODE(RPC_S_CALL_FAILED, CAT_GATEWAY),
82  DEFINE_RPC_FAULT_CODE(RPC_S_CALL_FAILED_DNE, CAT_GATEWAY),
83  DEFINE_RPC_FAULT_CODE(RPC_S_PROTOCOL_ERROR, CAT_GATEWAY),
84  DEFINE_RPC_FAULT_CODE(RPC_S_PROXY_ACCESS_DENIED, CAT_GATEWAY),
85  DEFINE_RPC_FAULT_CODE(RPC_S_UNSUPPORTED_TRANS_SYN, CAT_GATEWAY),
86  DEFINE_RPC_FAULT_CODE(RPC_S_UNSUPPORTED_TYPE, CAT_GATEWAY),
87  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_TAG, CAT_GATEWAY),
88  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_BOUND, CAT_GATEWAY),
89  DEFINE_RPC_FAULT_CODE(RPC_S_NO_ENTRY_NAME, CAT_GATEWAY),
90  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_NAME_SYNTAX, CAT_GATEWAY),
91  DEFINE_RPC_FAULT_CODE(RPC_S_UNSUPPORTED_NAME_SYNTAX, CAT_GATEWAY),
92  DEFINE_RPC_FAULT_CODE(RPC_S_UUID_NO_ADDRESS, CAT_GATEWAY),
93  DEFINE_RPC_FAULT_CODE(RPC_S_DUPLICATE_ENDPOINT, CAT_GATEWAY),
94  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_AUTHN_TYPE, CAT_GATEWAY),
95  DEFINE_RPC_FAULT_CODE(RPC_S_MAX_CALLS_TOO_SMALL, CAT_GATEWAY),
96  DEFINE_RPC_FAULT_CODE(RPC_S_STRING_TOO_LONG, CAT_GATEWAY),
97  DEFINE_RPC_FAULT_CODE(RPC_S_PROTSEQ_NOT_FOUND, CAT_GATEWAY),
98  DEFINE_RPC_FAULT_CODE(RPC_S_PROCNUM_OUT_OF_RANGE, CAT_GATEWAY),
99  DEFINE_RPC_FAULT_CODE(RPC_S_BINDING_HAS_NO_AUTH, CAT_GATEWAY),
100  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_AUTHN_SERVICE, CAT_GATEWAY),
101  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_AUTHN_LEVEL, CAT_GATEWAY),
102  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_AUTH_IDENTITY, CAT_GATEWAY),
103  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_AUTHZ_SERVICE, CAT_GATEWAY),
104  DEFINE_RPC_FAULT_CODE(EPT_S_INVALID_ENTRY, CAT_GATEWAY),
105  DEFINE_RPC_FAULT_CODE(EPT_S_CANT_PERFORM_OP, CAT_GATEWAY),
106  DEFINE_RPC_FAULT_CODE(EPT_S_NOT_REGISTERED, CAT_GATEWAY),
107  DEFINE_RPC_FAULT_CODE(RPC_S_NOTHING_TO_EXPORT, CAT_GATEWAY),
108  DEFINE_RPC_FAULT_CODE(RPC_S_INCOMPLETE_NAME, CAT_GATEWAY),
109  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_VERS_OPTION, CAT_GATEWAY),
110  DEFINE_RPC_FAULT_CODE(RPC_S_NO_MORE_MEMBERS, CAT_GATEWAY),
111  DEFINE_RPC_FAULT_CODE(RPC_S_NOT_ALL_OBJS_UNEXPORTED, CAT_GATEWAY),
112  DEFINE_RPC_FAULT_CODE(RPC_S_INTERFACE_NOT_FOUND, CAT_GATEWAY),
113  DEFINE_RPC_FAULT_CODE(RPC_S_ENTRY_ALREADY_EXISTS, CAT_GATEWAY),
114  DEFINE_RPC_FAULT_CODE(RPC_S_ENTRY_NOT_FOUND, CAT_GATEWAY),
115  DEFINE_RPC_FAULT_CODE(RPC_S_NAME_SERVICE_UNAVAILABLE, CAT_GATEWAY),
116  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_NAF_ID, CAT_GATEWAY),
117  DEFINE_RPC_FAULT_CODE(RPC_S_CANNOT_SUPPORT, CAT_GATEWAY),
118  DEFINE_RPC_FAULT_CODE(RPC_S_NO_CONTEXT_AVAILABLE, CAT_GATEWAY),
119  DEFINE_RPC_FAULT_CODE(RPC_S_INTERNAL_ERROR, CAT_GATEWAY),
120  DEFINE_RPC_FAULT_CODE(RPC_S_ZERO_DIVIDE, CAT_GATEWAY),
121  DEFINE_RPC_FAULT_CODE(RPC_S_ADDRESS_ERROR, CAT_GATEWAY),
122  DEFINE_RPC_FAULT_CODE(RPC_S_FP_DIV_ZERO, CAT_GATEWAY),
123  DEFINE_RPC_FAULT_CODE(RPC_S_FP_UNDERFLOW, CAT_GATEWAY),
124  DEFINE_RPC_FAULT_CODE(RPC_S_FP_OVERFLOW, CAT_GATEWAY),
125  DEFINE_RPC_FAULT_CODE(RPC_X_NO_MORE_ENTRIES, CAT_GATEWAY),
126  DEFINE_RPC_FAULT_CODE(RPC_X_SS_CHAR_TRANS_OPEN_FAIL, CAT_GATEWAY),
127  DEFINE_RPC_FAULT_CODE(RPC_X_SS_CHAR_TRANS_SHORT_FILE, CAT_GATEWAY),
128  DEFINE_RPC_FAULT_CODE(RPC_X_SS_IN_NULL_CONTEXT, CAT_GATEWAY),
129  DEFINE_RPC_FAULT_CODE(RPC_X_SS_CONTEXT_DAMAGED, CAT_GATEWAY),
130  DEFINE_RPC_FAULT_CODE(RPC_X_SS_HANDLES_MISMATCH, CAT_GATEWAY),
131  DEFINE_RPC_FAULT_CODE(RPC_X_SS_CANNOT_GET_CALL_HANDLE, CAT_GATEWAY),
132  DEFINE_RPC_FAULT_CODE(RPC_X_NULL_REF_POINTER, CAT_GATEWAY),
133  DEFINE_RPC_FAULT_CODE(RPC_X_ENUM_VALUE_OUT_OF_RANGE, CAT_GATEWAY),
134  DEFINE_RPC_FAULT_CODE(RPC_X_BYTE_COUNT_TOO_SMALL, CAT_GATEWAY),
135  DEFINE_RPC_FAULT_CODE(RPC_X_BAD_STUB_DATA, CAT_GATEWAY),
136  DEFINE_RPC_FAULT_CODE(RPC_S_NO_INTERFACES, CAT_GATEWAY),
137  DEFINE_RPC_FAULT_CODE(RPC_S_CALL_CANCELLED, CAT_GATEWAY),
138  DEFINE_RPC_FAULT_CODE(RPC_S_BINDING_INCOMPLETE, CAT_GATEWAY),
139  DEFINE_RPC_FAULT_CODE(RPC_S_COMM_FAILURE, CAT_GATEWAY),
140  DEFINE_RPC_FAULT_CODE(RPC_S_UNSUPPORTED_AUTHN_LEVEL, CAT_GATEWAY),
141  DEFINE_RPC_FAULT_CODE(RPC_S_NO_PRINC_NAME, CAT_GATEWAY),
142  DEFINE_RPC_FAULT_CODE(RPC_S_NOT_RPC_ERROR, CAT_GATEWAY),
143  DEFINE_RPC_FAULT_CODE(RPC_S_UUID_LOCAL_ONLY, CAT_GATEWAY),
144  DEFINE_RPC_FAULT_CODE(RPC_S_SEC_PKG_ERROR, CAT_GATEWAY),
145  DEFINE_RPC_FAULT_CODE(RPC_S_NOT_CANCELLED, CAT_GATEWAY),
146  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_ES_ACTION, CAT_GATEWAY),
147  DEFINE_RPC_FAULT_CODE(RPC_X_WRONG_ES_VERSION, CAT_GATEWAY),
148  DEFINE_RPC_FAULT_CODE(RPC_X_WRONG_STUB_VERSION, CAT_GATEWAY),
149  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_PIPE_OBJECT, CAT_GATEWAY),
150  DEFINE_RPC_FAULT_CODE(RPC_X_WRONG_PIPE_ORDER, CAT_GATEWAY),
151  DEFINE_RPC_FAULT_CODE(RPC_X_WRONG_PIPE_VERSION, CAT_GATEWAY),
152  DEFINE_RPC_FAULT_CODE(RPC_S_COOKIE_AUTH_FAILED, CAT_GATEWAY),
153  DEFINE_RPC_FAULT_CODE(RPC_S_GROUP_MEMBER_NOT_FOUND, CAT_GATEWAY),
154  DEFINE_RPC_FAULT_CODE(EPT_S_CANT_CREATE, CAT_GATEWAY),
155  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_OBJECT, CAT_GATEWAY)
156 };
157 
158 static const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] = {
159  DEFINE_RPC_FAULT_CODE(RPC_S_OK, CAT_GATEWAY),
160  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_ARG, CAT_GATEWAY),
161  DEFINE_RPC_FAULT_CODE(RPC_S_OUT_OF_MEMORY, CAT_GATEWAY),
162  DEFINE_RPC_FAULT_CODE(RPC_S_OUT_OF_THREADS, CAT_GATEWAY),
163  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_LEVEL, CAT_GATEWAY),
164  DEFINE_RPC_FAULT_CODE(RPC_S_BUFFER_TOO_SMALL, CAT_GATEWAY),
165  DEFINE_RPC_FAULT_CODE(RPC_S_INVALID_SECURITY_DESC, CAT_GATEWAY),
166  DEFINE_RPC_FAULT_CODE(RPC_S_ACCESS_DENIED, CAT_GATEWAY),
167  DEFINE_RPC_FAULT_CODE(RPC_S_SERVER_OUT_OF_MEMORY, CAT_GATEWAY),
168  DEFINE_RPC_FAULT_CODE(RPC_S_ASYNC_CALL_PENDING, CAT_GATEWAY),
169  DEFINE_RPC_FAULT_CODE(RPC_S_UNKNOWN_PRINCIPAL, CAT_GATEWAY),
170  DEFINE_RPC_FAULT_CODE(RPC_S_TIMEOUT, CAT_GATEWAY),
171  DEFINE_RPC_FAULT_CODE(RPC_X_NO_MEMORY, CAT_GATEWAY),
172  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_BOUND, CAT_GATEWAY),
173  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_TAG, CAT_GATEWAY),
174  DEFINE_RPC_FAULT_CODE(RPC_X_ENUM_VALUE_TOO_LARGE, CAT_GATEWAY),
175  DEFINE_RPC_FAULT_CODE(RPC_X_SS_CONTEXT_MISMATCH, CAT_GATEWAY),
176  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_BUFFER, CAT_GATEWAY),
177  DEFINE_RPC_FAULT_CODE(RPC_X_PIPE_APP_MEMORY, CAT_GATEWAY),
178  DEFINE_RPC_FAULT_CODE(RPC_X_INVALID_PIPE_OPERATION, CAT_GATEWAY),
179  DEFINE_RPC_FAULT_CODE(ERROR_ONLY_IF_CONNECTED, CAT_GATEWAY),
180  DEFINE_RPC_FAULT_CODE(ERROR_GRACEFUL_DISCONNECT, CAT_GATEWAY),
181  DEFINE_RPC_FAULT_CODE(ERROR_OPERATION_ABORTED, CAT_GATEWAY),
182  DEFINE_RPC_FAULT_CODE(ERROR_BAD_ARGUMENTS, CAT_GATEWAY),
183  DEFINE_RPC_FAULT_CODE(E_PROXY_INTERNALERROR, CAT_GATEWAY),
184  DEFINE_RPC_FAULT_CODE(E_PROXY_RAP_ACCESSDENIED, CAT_GATEWAY),
185  DEFINE_RPC_FAULT_CODE(E_PROXY_NAP_ACCESSDENIED, CAT_GATEWAY),
186  DEFINE_RPC_FAULT_CODE(E_PROXY_TS_CONNECTFAILED, CAT_GATEWAY),
187  DEFINE_RPC_FAULT_CODE(E_PROXY_ALREADYDISCONNECTED, CAT_GATEWAY),
188  DEFINE_RPC_FAULT_CODE(E_PROXY_QUARANTINE_ACCESSDENIED, CAT_GATEWAY),
189  DEFINE_RPC_FAULT_CODE(E_PROXY_NOCERTAVAILABLE, CAT_GATEWAY),
190  DEFINE_RPC_FAULT_CODE(E_PROXY_COOKIE_BADPACKET, CAT_GATEWAY),
191  DEFINE_RPC_FAULT_CODE(E_PROXY_COOKIE_AUTHENTICATION_ACCESS_DENIED, CAT_GATEWAY),
192  DEFINE_RPC_FAULT_CODE(E_PROXY_UNSUPPORTED_AUTHENTICATION_METHOD, CAT_GATEWAY),
193  DEFINE_RPC_FAULT_CODE(E_PROXY_CAPABILITYMISMATCH, CAT_GATEWAY),
194  { HRESULT_CODE(E_PROXY_NOTSUPPORTED), "E_PROXY_NOTSUPPORTED", CAT_GATEWAY },
195  { HRESULT_CODE(E_PROXY_TS_CONNECTFAILED), "E_PROXY_TS_CONNECTFAILED", CAT_GATEWAY },
196  { HRESULT_CODE(E_PROXY_MAXCONNECTIONSREACHED), "E_PROXY_MAXCONNECTIONSREACHED", CAT_GATEWAY },
197  { HRESULT_CODE(E_PROXY_INTERNALERROR), "E_PROXY_INTERNALERROR", CAT_GATEWAY },
198  { HRESULT_CODE(E_PROXY_SESSIONTIMEOUT), "E_PROXY_SESSIONTIMEOUT", CAT_GATEWAY },
199  { HRESULT_CODE(E_PROXY_REAUTH_AUTHN_FAILED), "E_PROXY_REAUTH_AUTHN_FAILED", CAT_GATEWAY },
200  { HRESULT_CODE(E_PROXY_REAUTH_CAP_FAILED), "E_PROXY_REAUTH_CAP_FAILED", CAT_GATEWAY },
201  { HRESULT_CODE(E_PROXY_REAUTH_RAP_FAILED), "E_PROXY_REAUTH_RAP_FAILED", CAT_GATEWAY },
202  { HRESULT_CODE(E_PROXY_SDR_NOT_SUPPORTED_BY_TS), "E_PROXY_SDR_NOT_SUPPORTED_BY_TS",
203  CAT_GATEWAY },
204  { HRESULT_CODE(E_PROXY_REAUTH_NAP_FAILED), "E_PROXY_REAUTH_NAP_FAILED", CAT_GATEWAY },
205  { HRESULT_CODE(E_PROXY_CONNECTIONABORTED), "E_PROXY_CONNECTIONABORTED", CAT_GATEWAY },
206  { HRESULT_CODE(E_PROXY_NOCERTAVAILABLE), "E_PROXY_NOCERTAVAILABLE", CAT_GATEWAY },
207  { HRESULT_CODE(RPC_S_CALL_CANCELLED), "RPC_S_CALL_CANCELLED", CAT_GATEWAY }
208 };
209 
215 static UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code)
216 {
217  switch (code)
218  {
219  case nca_s_comm_failure:
220  return RPC_S_COMM_FAILURE;
221 
222  case nca_s_op_rng_error:
223  return RPC_S_PROCNUM_OUT_OF_RANGE;
224 
225  case nca_s_unk_if:
226  return RPC_S_UNKNOWN_IF;
227 
228  case nca_s_wrong_boot_time:
229  return nca_s_wrong_boot_time;
230 
231  case nca_s_you_crashed:
232  return RPC_S_CALL_FAILED;
233 
234  case nca_s_proto_error:
235  return RPC_S_PROTOCOL_ERROR;
236 
237  case nca_s_out_args_too_big:
238  return RPC_S_SERVER_OUT_OF_MEMORY;
239 
240  case nca_s_server_too_busy:
241  return RPC_S_SERVER_TOO_BUSY;
242 
243  case nca_s_unsupported_type:
244  return RPC_S_UNSUPPORTED_TYPE;
245 
246  case nca_s_fault_int_div_by_zero:
247  return RPC_S_ZERO_DIVIDE;
248 
249  case nca_s_fault_addr_error:
250  return RPC_S_ADDRESS_ERROR;
251 
252  case nca_s_fault_fp_div_zero:
253  return RPC_S_FP_DIV_ZERO;
254 
255  case nca_s_fault_fp_underflow:
256  return RPC_S_FP_UNDERFLOW;
257 
258  case nca_s_fault_fp_overflow:
259  return RPC_S_FP_OVERFLOW;
260 
261  case nca_s_fault_invalid_tag:
262  return RPC_S_INVALID_TAG;
263 
264  case nca_s_fault_invalid_bound:
265  return RPC_S_INVALID_BOUND;
266 
267  case nca_s_rpc_version_mismatch:
268  return RPC_S_PROTOCOL_ERROR;
269 
270  case nca_s_unspec_reject:
271  return RPC_S_CALL_FAILED;
272 
273  case nca_s_bad_actid:
274  return RPC_S_CALL_FAILED_DNE;
275 
276  case nca_s_who_are_you_failed:
277  return RPC_S_CALL_FAILED;
278 
279  case nca_s_manager_not_entered:
280  return RPC_S_CALL_FAILED_DNE;
281 
282  case nca_s_fault_cancel:
283  return RPC_S_CALL_CANCELLED;
284 
285  case nca_s_fault_ill_inst:
286  return RPC_S_ADDRESS_ERROR;
287 
288  case nca_s_fault_fp_error:
289  return RPC_S_FP_OVERFLOW;
290 
291  case nca_s_fault_int_overflow:
292  return RPC_S_ADDRESS_ERROR;
293 
294  case nca_s_fault_unspec:
295  return RPC_S_CALL_FAILED;
296 
297  case nca_s_fault_remote_comm_failure:
298  return nca_s_fault_remote_comm_failure;
299 
300  case nca_s_fault_pipe_empty:
301  return RPC_X_PIPE_EMPTY;
302 
303  case nca_s_fault_pipe_closed:
304  return RPC_X_PIPE_CLOSED;
305 
306  case nca_s_fault_pipe_order:
307  return RPC_X_WRONG_PIPE_ORDER;
308 
309  case nca_s_fault_pipe_discipline:
310  return RPC_X_PIPE_DISCIPLINE_ERROR;
311 
312  case nca_s_fault_pipe_comm_error:
313  return RPC_S_COMM_FAILURE;
314 
315  case nca_s_fault_pipe_memory:
316  return RPC_S_OUT_OF_MEMORY;
317 
318  case nca_s_fault_context_mismatch:
319  return RPC_X_SS_CONTEXT_MISMATCH;
320 
321  case nca_s_fault_remote_no_memory:
322  return RPC_S_SERVER_OUT_OF_MEMORY;
323 
324  case nca_s_invalid_pres_context_id:
325  return RPC_S_PROTOCOL_ERROR;
326 
327  case nca_s_unsupported_authn_level:
328  return RPC_S_UNSUPPORTED_AUTHN_LEVEL;
329 
330  case nca_s_invalid_checksum:
331  return RPC_S_CALL_FAILED_DNE;
332 
333  case nca_s_invalid_crc:
334  return RPC_S_CALL_FAILED_DNE;
335 
336  case nca_s_fault_user_defined:
337  return nca_s_fault_user_defined;
338 
339  case nca_s_fault_tx_open_failed:
340  return nca_s_fault_tx_open_failed;
341 
342  case nca_s_fault_codeset_conv_error:
343  return nca_s_fault_codeset_conv_error;
344 
345  case nca_s_fault_object_not_found:
346  return nca_s_fault_object_not_found;
347 
348  case nca_s_fault_no_client_stub:
349  return nca_s_fault_no_client_stub;
350  default:
351  break;
352  }
353 
354  return code;
355 }
356 
357 const char* rpc_error_to_string(UINT32 code)
358 {
359  static char buffer[1024];
360 
361  for (size_t index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++)
362  {
363  const RPC_FAULT_CODE* current = &RPC_FAULT_CODES[index];
364  if (current->code == code)
365  {
366  (void)sprintf_s(buffer, ARRAYSIZE(buffer), "%s", current->name);
367  goto out;
368  }
369  }
370 
371  for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++)
372  {
373  const RPC_FAULT_CODE* current = &RPC_TSG_FAULT_CODES[index];
374  if (current->code == code)
375  {
376  (void)sprintf_s(buffer, ARRAYSIZE(buffer), "%s", current->name);
377  goto out;
378  }
379  }
380 
381  for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++)
382  {
383  const RPC_FAULT_CODE* current = &RPC_TSG_FAULT_CODES[index];
384  if (current->code == HRESULT_CODE(code))
385  {
386  (void)sprintf_s(buffer, ARRAYSIZE(buffer), "%s", current->name);
387  goto out;
388  }
389  }
390 
391  (void)sprintf_s(buffer, ARRAYSIZE(buffer), "%s [0x%08" PRIX32 "]", "UNKNOWN", code);
392 out:
393  return buffer;
394 }
395 
396 const char* rpc_error_to_category(UINT32 code)
397 {
398  for (size_t index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++)
399  {
400  const RPC_FAULT_CODE* current = &RPC_FAULT_CODES[index];
401  if (current->code == code)
402  return current->category;
403  }
404 
405  for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++)
406  {
407  const RPC_FAULT_CODE* current = &RPC_TSG_FAULT_CODES[index];
408  if (current->code == code)
409  return current->category;
410  }
411 
412  for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++)
413  {
414  const RPC_FAULT_CODE* current = &RPC_TSG_FAULT_CODES[index];
415  if (current->code == HRESULT_CODE(code))
416  return current->category;
417  }
418 
419  return "UNKNOWN";
420 }
421 
422 int rpc_recv_fault_pdu(UINT32 status)
423 {
424  UINT32 code = rpc_map_status_code_to_win32_error_code(status);
425  WLog_ERR(TAG, "RPC Fault PDU: status=%s", rpc_error_to_string(code));
426  return 0;
427 }