libfreerdp-core: map DCE error codes

This commit is contained in:
Marc-André Moreau 2012-12-07 18:33:52 -05:00
parent 2215e0a57a
commit 2f6192532f
3 changed files with 147 additions and 20 deletions

View File

@ -401,29 +401,50 @@ typedef struct _RPC_FAULT_CODE RPC_FAULT_CODE;
#define DEFINE_RPC_FAULT_CODE(_code) { _code , #_code },
#define nca_s_fault_object_not_found 0x1C000024
#define nca_s_fault_cancel 0x1C00000D
#define nca_s_fault_addr_error 0x1C000002
#define nca_s_fault_context_mismatch 0x1C00001A
#define nca_s_fault_fp_div_zero 0x1C000003
#define nca_s_fault_fp_error 0x1C00000F
#define nca_s_fault_fp_overflow 0x1C000005
#define nca_s_fault_fp_underflow 0x1C000004
#define nca_s_fault_ill_inst 0x1C00000E
#define nca_s_comm_failure 0x1C010001
#define nca_s_op_rng_error 0x1C010002
#define nca_s_unk_if 0x1C010003
#define nca_s_wrong_boot_time 0x1C010006
#define nca_s_you_crashed 0x1C010009
#define nca_s_proto_error 0x1C01000B
#define nca_s_out_args_too_big 0x1C010013
#define nca_s_server_too_busy 0x1C010014
#define nca_s_fault_string_too_long 0x1C010015
#define nca_s_unsupported_type 0x1C010017
#define nca_s_fault_int_div_by_zero 0x1C000001
#define nca_s_fault_int_overflow 0x1C000010
#define nca_s_fault_invalid_bound 0x1C000007
#define nca_s_fault_addr_error 0x1C000002
#define nca_s_fault_fp_div_zero 0x1C000003
#define nca_s_fault_fp_underflow 0x1C000004
#define nca_s_fault_fp_overflow 0x1C000005
#define nca_s_fault_invalid_tag 0x1C000006
#define nca_s_fault_pipe_closed 0x1C000015
#define nca_s_fault_pipe_comm_error 0x1C000018
#define nca_s_fault_pipe_discipline 0x1C000017
#define nca_s_fault_invalid_bound 0x1C000007
#define nca_s_rpc_version_mismatch 0x1C000008
#define nca_s_unspec_reject 0x1C000009
#define nca_s_bad_actid 0x1C00000A
#define nca_s_who_are_you_failed 0x1C00000B
#define nca_s_manager_not_entered 0x1C00000C
#define nca_s_fault_cancel 0x1C00000D
#define nca_s_fault_ill_inst 0x1C00000E
#define nca_s_fault_fp_error 0x1C00000F
#define nca_s_fault_int_overflow 0x1C000010
#define nca_s_fault_unspec 0x1C000012
#define nca_s_fault_remote_comm_failure 0x1C000013
#define nca_s_fault_pipe_empty 0x1C000014
#define nca_s_fault_pipe_memory 0x1C000019
#define nca_s_fault_pipe_closed 0x1C000015
#define nca_s_fault_pipe_order 0x1C000016
#define nca_s_fault_pipe_discipline 0x1C000017
#define nca_s_fault_pipe_comm_error 0x1C000018
#define nca_s_fault_pipe_memory 0x1C000019
#define nca_s_fault_context_mismatch 0x1C00001A
#define nca_s_fault_remote_no_memory 0x1C00001B
#define nca_s_invalid_pres_context_id 0x1C00001C
#define nca_s_unsupported_authn_level 0x1C00001D
#define nca_s_invalid_checksum 0x1C00001F
#define nca_s_invalid_crc 0x1C000020
#define nca_s_fault_user_defined 0x1C000021
#define nca_s_fault_tx_open_failed 0x1C000022
#define nca_s_fault_codeset_conv_error 0x1C000023
#define nca_s_fault_object_not_found 0x1C000024
#define nca_s_fault_no_client_stub 0x1C000025
typedef struct

View File

@ -190,31 +190,136 @@ const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
{ 0, NULL }
};
/**
* [MS-RPCE] 3.1.1.5.5 Returning Win32 Error Values:
* http://msdn.microsoft.com/en-us/library/ee442005/
*/
UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code)
{
switch (code)
{
case nca_s_comm_failure:
return RPC_S_COMM_FAILURE;
case nca_s_op_rng_error:
return RPC_S_PROCNUM_OUT_OF_RANGE;
case nca_s_unk_if:
return RPC_S_UNKNOWN_IF;
case nca_s_wrong_boot_time:
return nca_s_wrong_boot_time;
case nca_s_you_crashed:
return RPC_S_CALL_FAILED;
case nca_s_proto_error:
return RPC_S_PROTOCOL_ERROR;
case nca_s_out_args_too_big:
return RPC_S_SERVER_OUT_OF_MEMORY;
case nca_s_server_too_busy:
return RPC_S_SERVER_TOO_BUSY;
case nca_s_unsupported_type:
return RPC_S_UNSUPPORTED_TYPE;
case nca_s_fault_int_div_by_zero:
return RPC_S_ZERO_DIVIDE;
case nca_s_fault_addr_error:
return RPC_S_ADDRESS_ERROR;
case nca_s_fault_fp_div_zero:
return RPC_S_FP_DIV_ZERO;
case nca_s_fault_fp_underflow:
return RPC_S_FP_UNDERFLOW;
case nca_s_fault_fp_overflow:
return RPC_S_FP_OVERFLOW;
case nca_s_fault_invalid_tag:
return RPC_S_INVALID_TAG;
case nca_s_fault_invalid_bound:
return RPC_S_INVALID_BOUND;
case nca_s_rpc_version_mismatch:
return RPC_S_PROTOCOL_ERROR;
case nca_s_unspec_reject:
return RPC_S_CALL_FAILED;
case nca_s_bad_actid:
return RPC_S_CALL_FAILED_DNE;
case nca_s_who_are_you_failed:
return RPC_S_CALL_FAILED;
case nca_s_manager_not_entered:
return RPC_S_CALL_FAILED_DNE;
case nca_s_fault_cancel:
return RPC_S_CALL_CANCELLED;
case nca_s_fault_ill_inst:
return RPC_S_ADDRESS_ERROR;
case nca_s_fault_fp_error:
return RPC_S_FP_OVERFLOW;
case nca_s_fault_int_overflow:
return RPC_S_ADDRESS_ERROR;
case nca_s_fault_unspec:
return RPC_S_CALL_FAILED;
case nca_s_fault_remote_comm_failure:
return nca_s_fault_remote_comm_failure;
case nca_s_fault_pipe_empty:
return RPC_X_PIPE_EMPTY;
case nca_s_fault_pipe_closed:
return RPC_X_PIPE_CLOSED;
case nca_s_fault_pipe_order:
return RPC_X_WRONG_PIPE_ORDER;
case nca_s_fault_pipe_discipline:
return RPC_X_PIPE_DISCIPLINE_ERROR;
case nca_s_fault_pipe_comm_error:
return RPC_S_COMM_FAILURE;
case nca_s_fault_pipe_memory:
return RPC_S_OUT_OF_MEMORY;
case nca_s_fault_context_mismatch:
return RPC_X_SS_CONTEXT_MISMATCH;
case nca_s_fault_remote_no_memory:
return RPC_S_SERVER_OUT_OF_MEMORY;
case nca_s_invalid_pres_context_id:
return RPC_S_PROTOCOL_ERROR;
case nca_s_unsupported_authn_level:
return RPC_S_UNSUPPORTED_AUTHN_LEVEL;
case nca_s_invalid_checksum:
return RPC_S_CALL_FAILED_DNE;
case nca_s_invalid_crc:
return RPC_S_CALL_FAILED_DNE;
case nca_s_fault_user_defined:
return nca_s_fault_user_defined;
case nca_s_fault_tx_open_failed:
return nca_s_fault_tx_open_failed;
case nca_s_fault_codeset_conv_error:
return nca_s_fault_codeset_conv_error;
case nca_s_fault_object_not_found:
return nca_s_fault_object_not_found;
case nca_s_fault_no_client_stub:
return nca_s_fault_no_client_stub;
}
return code;
}
int rpc_recv_fault_pdu(rpcconn_hdr_t* header)
{
int index;
UINT32 code;
printf("RPC Fault PDU:\n");
code = rpc_map_status_code_to_win32_error_code(header->fault.status);
for (index = 0; RPC_FAULT_CODES[index].name != NULL; index++)
{
if (RPC_FAULT_CODES[index].code == header->fault.status)
if (RPC_FAULT_CODES[index].code == code)
{
printf("status: %s (0x%08X)\n", RPC_FAULT_CODES[index].name, header->fault.status);
printf("status: %s (0x%08X)\n", RPC_FAULT_CODES[index].name, code);
return 0;
}
}
for (index = 0; RPC_FAULT_CODES[index].name != NULL; index++)
{
if (RPC_TSG_FAULT_CODES[index].code == header->fault.status)
if (RPC_TSG_FAULT_CODES[index].code == code)
{
printf("status: %s (0x%08X)\n", RPC_TSG_FAULT_CODES[index].name, header->fault.status);
printf("status: %s (0x%08X)\n", RPC_TSG_FAULT_CODES[index].name, code);
return 0;
}
}
printf("status: %s (0x%08X)\n", "UNKNOWN", header->fault.status);
printf("status: %s (0x%08X)\n", "UNKNOWN", code);
return 0;
}

View File

@ -25,5 +25,6 @@
#include <winpr/wtypes.h>
int rpc_recv_fault_pdu(rpcconn_hdr_t* header);
UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code);
#endif /* FREERDP_CORE_RPC_FAULT_H */