libfreerdp-core: added RPC fault error code name tables

This commit is contained in:
Marc-André Moreau 2012-10-31 10:52:04 -04:00
parent 284698c1c3
commit bed7933b83
6 changed files with 253 additions and 34 deletions

View File

@ -36,6 +36,8 @@
#include "rpc.h"
extern const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[];
static char* PTYPE_STRINGS[] =
{
"PTYPE_REQUEST",
@ -62,6 +64,35 @@ static char* PTYPE_STRINGS[] =
""
};
const RPC_FAULT_CODE RPC_FAULT_CODES[] =
{
DEFINE_RPC_FAULT_CODE(nca_s_fault_object_not_found)
DEFINE_RPC_FAULT_CODE(nca_s_fault_cancel)
DEFINE_RPC_FAULT_CODE(nca_s_fault_addr_error)
DEFINE_RPC_FAULT_CODE(nca_s_fault_context_mismatch)
DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_div_zero)
DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_error)
DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_overflow)
DEFINE_RPC_FAULT_CODE(nca_s_fault_fp_underflow)
DEFINE_RPC_FAULT_CODE(nca_s_fault_ill_inst)
DEFINE_RPC_FAULT_CODE(nca_s_fault_int_div_by_zero)
DEFINE_RPC_FAULT_CODE(nca_s_fault_int_overflow)
DEFINE_RPC_FAULT_CODE(nca_s_fault_invalid_bound)
DEFINE_RPC_FAULT_CODE(nca_s_fault_invalid_tag)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_closed)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_comm_error)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_discipline)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_empty)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_memory)
DEFINE_RPC_FAULT_CODE(nca_s_fault_pipe_order)
DEFINE_RPC_FAULT_CODE(nca_s_fault_remote_no_memory)
DEFINE_RPC_FAULT_CODE(nca_s_fault_user_defined)
DEFINE_RPC_FAULT_CODE(nca_s_fault_tx_open_failed)
DEFINE_RPC_FAULT_CODE(nca_s_fault_codeset_conv_error)
DEFINE_RPC_FAULT_CODE(nca_s_fault_no_client_stub)
{ 0, NULL }
};
void rpc_pdu_header_print(RPC_PDU_HEADER* header)
{
printf("rpc_vers: %d\n", header->rpc_vers);
@ -802,12 +833,32 @@ int rpc_out_read(rdpRpc* rpc, BYTE* data, int length)
int rpc_recv_fault_pdu(RPC_PDU_HEADER* header)
{
int index;
rpcconn_fault_hdr_t* fault_pdu;
fault_pdu = (rpcconn_fault_hdr_t*) header;
printf("RPC Fault PDU:\n");
printf("status: 0x%08X\n", fault_pdu->status);
for (index = 0; RPC_FAULT_CODES[index].name != NULL; index++)
{
if (RPC_FAULT_CODES[index].code == fault_pdu->status)
{
printf("status: %s (0x%08X)\n", RPC_FAULT_CODES[index].name, fault_pdu->status);
return 0;
}
}
for (index = 0; RPC_FAULT_CODES[index].name != NULL; index++)
{
if (RPC_TSG_FAULT_CODES[index].code == fault_pdu->status)
{
printf("status: %s (0x%08X)\n", RPC_TSG_FAULT_CODES[index].name, fault_pdu->status);
return 0;
}
}
printf("status: %s (0x%08X)\n", "UNKNOWN", fault_pdu->status);
return 0;
}

View File

@ -314,6 +314,15 @@ typedef struct
/* fault codes */
struct _RPC_FAULT_CODE
{
UINT32 code;
char* name;
};
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
@ -334,7 +343,7 @@ typedef struct
#define nca_s_fault_pipe_memory 0x1C000019
#define nca_s_fault_pipe_order 0x1C000016
#define nca_s_fault_remote_no_memory 0x1C00001B
#define ncs_s_fault_user_defined 0x1C000021
#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_no_client_stub 0x1C000025

View File

@ -43,6 +43,41 @@
* RPC NDR Interface Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/hh802752/
*/
const RPC_FAULT_CODE RPC_TSG_FAULT_CODES[] =
{
DEFINE_RPC_FAULT_CODE(ERROR_SUCCESS)
DEFINE_RPC_FAULT_CODE(ERROR_ACCESS_DENIED)
DEFINE_RPC_FAULT_CODE(ERROR_ONLY_IF_CONNECTED)
DEFINE_RPC_FAULT_CODE(ERROR_INVALID_PARAMETER)
DEFINE_RPC_FAULT_CODE(ERROR_GRACEFUL_DISCONNECT)
DEFINE_RPC_FAULT_CODE(ERROR_OPERATION_ABORTED)
DEFINE_RPC_FAULT_CODE(ERROR_BAD_ARGUMENTS)
DEFINE_RPC_FAULT_CODE(E_PROXY_INTERNALERROR)
DEFINE_RPC_FAULT_CODE(E_PROXY_RAP_ACCESSDENIED)
DEFINE_RPC_FAULT_CODE(E_PROXY_NAP_ACCESSDENIED)
DEFINE_RPC_FAULT_CODE(E_PROXY_TS_CONNECTFAILED)
DEFINE_RPC_FAULT_CODE(E_PROXY_ALREADYDISCONNECTED)
DEFINE_RPC_FAULT_CODE(E_PROXY_QUARANTINE_ACCESSDENIED)
DEFINE_RPC_FAULT_CODE(E_PROXY_NOCERTAVAILABLE)
DEFINE_RPC_FAULT_CODE(E_PROXY_COOKIE_BADPACKET)
DEFINE_RPC_FAULT_CODE(E_PROXY_COOKIE_AUTHENTICATION_ACCESS_DENIED)
DEFINE_RPC_FAULT_CODE(E_PROXY_UNSUPPORTED_AUTHENTICATION_METHOD)
DEFINE_RPC_FAULT_CODE(E_PROXY_CAPABILITYMISMATCH)
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_NOTSUPPORTED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_TS_CONNECTFAILED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_MAXCONNECTIONSREACHED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_INTERNALERROR))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_SESSIONTIMEOUT))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_REAUTH_AUTHN_FAILED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_REAUTH_CAP_FAILED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_REAUTH_RAP_FAILED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_SDR_NOT_SUPPORTED_BY_TS))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_REAUTH_NAP_FAILED))
DEFINE_RPC_FAULT_CODE(HRESULT_CODE(E_PROXY_CONNECTIONABORTED))
DEFINE_RPC_FAULT_CODE(HRESULT_FROM_WIN32(RPC_S_CALL_CANCELLED))
{ 0, NULL }
};
/* this might be a verification trailer */
BYTE TsProxyCreateTunnelUnknownTrailerBytes[60] =
@ -261,9 +296,10 @@ BYTE tsg_packet3[40] =
/**
TsProxyMakeTunnelCall
0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30,
0x53, 0x6C, 0x04, 0x33, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, 0x53, 0x6C, 0x04, 0x33,
0x01, 0x00, 0x00, 0x00,
0x52, 0x47, 0x00, 0x00,
0x52, 0x47, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00,
@ -566,10 +602,22 @@ BOOL tsg_proxy_make_tunnel_call(rdpTsg* tsg)
DEBUG_TSG("TsProxyMakeTunnelCall");
length = sizeof(tsg_packet3);
length = 40;
buffer = (BYTE*) malloc(length);
CopyMemory(buffer, tsg_packet3, length);
CopyMemory(&buffer[4], tsg->TunnelContext, 16);
*((UINT32*) &buffer[0]) = 0x00000000; /* ContextType */
CopyMemory(&buffer[4], tsg->TunnelContext, 16); /* ContextUuid */
*((UINT32*) &buffer[20]) = TSG_TUNNEL_CALL_ASYNC_MSG_REQUEST; /* ProcId */
/* 4-byte alignment */
*((UINT32*) &buffer[24]) = TSG_PACKET_TYPE_MSGREQUEST_PACKET; /* PacketId */
*((UINT32*) &buffer[28]) = TSG_PACKET_TYPE_MSGREQUEST_PACKET; /* SwitchValue */
*((UINT32*) &buffer[32]) = 0x00020000; /* PacketMsgRequestPtr */
*((UINT32*) &buffer[36]) = 0x00000001; /* MaxMessagesPerBatch */
status = rpc_tsg_write(rpc, buffer, length, TsProxyMakeTunnelCallOpnum);
@ -579,10 +627,10 @@ BOOL tsg_proxy_make_tunnel_call(rdpTsg* tsg)
return FALSE;
}
/* read? */
free(buffer);
/* read? */
return TRUE;
}

View File

@ -29,6 +29,7 @@ typedef struct rdp_tsg rdpTsg;
#include <winpr/rpc.h>
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#include <winpr/error.h>
#include <time.h>
#include <freerdp/types.h>
@ -71,32 +72,78 @@ typedef struct _tsendpointinfo
UINT32 Port;
} TSENDPOINTINFO, *PTSENDPOINTINFO;
#define TS_GATEWAY_TRANSPORT 0x5452
#define TS_GATEWAY_TRANSPORT 0x5452
#define TSG_PACKET_TYPE_HEADER 0x00004844
#define TSG_PACKET_TYPE_VERSIONCAPS 0x00005643
#define TSG_PACKET_TYPE_QUARCONFIGREQUEST 0x00005143
#define TSG_PACKET_TYPE_QUARREQUEST 0x00005152
#define TSG_PACKET_TYPE_RESPONSE 0x00005052
#define TSG_PACKET_TYPE_QUARENC_RESPONSE 0x00004552
#define TSG_CAPABILITY_TYPE_NAP 0x00000001
#define TSG_PACKET_TYPE_CAPS_RESPONSE 0x00004350
#define TSG_PACKET_TYPE_MSGREQUEST_PACKET 0x00004752
#define TSG_PACKET_TYPE_MESSAGE_PACKET 0x00004750
#define TSG_PACKET_TYPE_AUTH 0x00004054
#define TSG_PACKET_TYPE_REAUTH 0x00005250
#define TSG_PACKET_TYPE_HEADER 0x00004844
#define TSG_PACKET_TYPE_VERSIONCAPS 0x00005643
#define TSG_PACKET_TYPE_QUARCONFIGREQUEST 0x00005143
#define TSG_PACKET_TYPE_QUARREQUEST 0x00005152
#define TSG_PACKET_TYPE_RESPONSE 0x00005052
#define TSG_PACKET_TYPE_QUARENC_RESPONSE 0x00004552
#define TSG_CAPABILITY_TYPE_NAP 0x00000001
#define TSG_PACKET_TYPE_CAPS_RESPONSE 0x00004350
#define TSG_PACKET_TYPE_MSGREQUEST_PACKET 0x00004752
#define TSG_PACKET_TYPE_MESSAGE_PACKET 0x00004750
#define TSG_PACKET_TYPE_AUTH 0x00004054
#define TSG_PACKET_TYPE_REAUTH 0x00005250
#define TSG_ASYNC_MESSAGE_CONSENT_MESSAGE 0x00000001
#define TSG_ASYNC_MESSAGE_SERVICE_MESSAGE 0x00000002
#define TSG_ASYNC_MESSAGE_REAUTH 0x00000003
#define TSG_TUNNEL_CALL_ASYNC_MSG_REQUEST 0x00000001
#define TSG_TUNNEL_CANCEL_ASYNC_MSG_REQUEST 0x00000002
#define TSG_ASYNC_MESSAGE_CONSENT_MESSAGE 0x00000001
#define TSG_ASYNC_MESSAGE_SERVICE_MESSAGE 0x00000002
#define TSG_ASYNC_MESSAGE_REAUTH 0x00000003
#define TSG_TUNNEL_CALL_ASYNC_MSG_REQUEST 0x00000001
#define TSG_TUNNEL_CANCEL_ASYNC_MSG_REQUEST 0x00000002
#define TSG_NAP_CAPABILITY_QUAR_SOH 0x00000001
#define TSG_NAP_CAPABILITY_IDLE_TIMEOUT 0x00000002
#define TSG_MESSAGING_CAP_CONSENT_SIGN 0x00000004
#define TSG_MESSAGING_CAP_SERVICE_MSG 0x00000008
#define TSG_MESSAGING_CAP_REAUTH 0x00000010
#define TSG_NAP_CAPABILITY_QUAR_SOH 0x00000001
#define TSG_NAP_CAPABILITY_IDLE_TIMEOUT 0x00000002
#define TSG_MESSAGING_CAP_CONSENT_SIGN 0x00000004
#define TSG_MESSAGING_CAP_SERVICE_MSG 0x00000008
#define TSG_MESSAGING_CAP_REAUTH 0x00000010
/* Error Codes */
#define E_PROXY_INTERNALERROR 0x800759D8
#define E_PROXY_RAP_ACCESSDENIED 0x800759DA
#define E_PROXY_NAP_ACCESSDENIED 0x800759DB
#define E_PROXY_TS_CONNECTFAILED 0x800759DD
#define E_PROXY_ALREADYDISCONNECTED 0x800759DF
#define E_PROXY_QUARANTINE_ACCESSDENIED 0x800759ED
#define E_PROXY_NOCERTAVAILABLE 0x800759EE
#define E_PROXY_COOKIE_BADPACKET 0x800759F7
#define E_PROXY_COOKIE_AUTHENTICATION_ACCESS_DENIED 0x800759F8
#define E_PROXY_UNSUPPORTED_AUTHENTICATION_METHOD 0x800759F9
#define E_PROXY_CAPABILITYMISMATCH 0x800759E9
#define E_PROXY_NOTSUPPORTED 0x000059E8
#define E_PROXY_MAXCONNECTIONSREACHED 0x000059E6
#define E_PROXY_SESSIONTIMEOUT 0x000059F6
#define E_PROXY_REAUTH_AUTHN_FAILED 0X000059FA
#define E_PROXY_REAUTH_CAP_FAILED 0x000059FB
#define E_PROXY_REAUTH_RAP_FAILED 0x000059FC
#define E_PROXY_SDR_NOT_SUPPORTED_BY_TS 0x000059FD
#define E_PROXY_REAUTH_NAP_FAILED 0x00005A00
#define E_PROXY_CONNECTIONABORTED 0x000004D4
/*
ERROR_SUCCESS
ERROR_ACCESS_DENIED
ERROR_ONLY_IF_CONNECTED
ERROR_INVALID_PARAMETER
ERROR_GRACEFUL_DISCONNECT
ERROR_OPERATION_ABORTED
ERROR_BAD_ARGUMENTS
HRESULT_CODE(E_PROXY_NOTSUPPORTED)
HRESULT_CODE(E_PROXY_TS_CONNECTFAILED)
HRESULT_CODE(E_PROXY_MAXCONNECTIONSREACHED)
HRESULT_CODE(E_PROXY_INTERNALERROR)
HRESULT_CODE(E_PROXY_SESSIONTIMEOUT)
HRESULT_CODE(E_PROXY_REAUTH_AUTHN_FAILED)
HRESULT_CODE(E_PROXY_REAUTH_CAP_FAILED)
HRESULT_CODE(E_PROXY_REAUTH_RAP_FAILED)
HRESULT_CODE(E_PROXY_SDR_NOT_SUPPORTED_BY_TS)
HRESULT_CODE(E_PROXY_REAUTH_NAP_FAILED)
HRESULT_CODE(E_PROXY_CONNECTIONABORTED)
HRESULT_FROM_WIN32(RPC_S_CALL_CANCELLED)
*/
typedef struct _TSG_PACKET_HEADER
{
@ -228,7 +275,7 @@ typedef union
typedef struct TSG_PACKET_REAUTH
{
unsigned __int64 tunnelContext;
UINT64 tunnelContext;
UINT32 packetId;
TSG_INITIAL_PACKET_TYPE_UNION tsgInitialPacket;
} TSG_PACKET_REAUTH, *PTSG_PACKET_REAUTH;

View File

@ -25,6 +25,68 @@
#ifndef _WIN32
#define FACILITY_WINDOWSUPDATE 36
#define FACILITY_WINDOWS_CE 24
#define FACILITY_WINDOWS 8
#define FACILITY_URT 19
#define FACILITY_UMI 22
#define FACILITY_SXS 23
#define FACILITY_STORAGE 3
#define FACILITY_STATE_MANAGEMENT 34
#define FACILITY_SSPI 9
#define FACILITY_SCARD 16
#define FACILITY_SETUPAPI 15
#define FACILITY_SECURITY 9
#define FACILITY_RPC 1
#define FACILITY_WIN32 7
#define FACILITY_CONTROL 10
#define FACILITY_NULL 0
#define FACILITY_METADIRECTORY 35
#define FACILITY_MSMQ 14
#define FACILITY_MEDIASERVER 13
#define FACILITY_INTERNET 12
#define FACILITY_ITF 4
#define FACILITY_HTTP 25
#define FACILITY_DPLAY 21
#define FACILITY_DISPATCH 2
#define FACILITY_DIRECTORYSERVICE 37
#define FACILITY_CONFIGURATION 33
#define FACILITY_COMPLUS 17
#define FACILITY_CERT 11
#define FACILITY_BACKGROUNDCOPY 32
#define FACILITY_ACS 20
#define FACILITY_AAF 18
#define FACILITY_NT_BIT 0x10000000
#define SEVERITY_SUCCESS 0
#define SEVERITY_ERROR 1
#define HRESULT_CODE(hr) ((hr) & 0xFFFF)
#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1FFF)
#define HRESULT_FROM_NT(x) ((HRESULT) ((x) | FACILITY_NT_BIT))
#define __HRESULT_FROM_WIN32(x) ((HRESULT) (x) <= 0 ? ((HRESULT) (x)) : \
((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))
#define HRESULT_FROM_WIN32(x) __HRESULT_FROM_WIN32(x)
#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1)
#define SUCCEEDED(hr) (((HRESULT) (hr)) >= 0)
#define FAILED(hr) (((HRESULT) (hr)) < 0)
#define IS_ERROR(Status) (((unsigned long) (Status)) >> 31 == SEVERITY_ERROR)
#define MAKE_HRESULT(sev, fac, code) \
((HRESULT) (((unsigned long) (sev) << 31) | ((unsigned long) (fac) << 16) | ((unsigned long) (code)))
#define SCODE_CODE(sc) ((sc) & 0xFFFF)
#define SCODE_FACILITY(sc) (((sc) >> 16) & 0x1FFF)
#define SCODE_SEVERITY(sc) (((sc) >> 31) & 0x1)
#define MAKE_SCODE(sev,fac,code) \
((SCODE) (((unsigned long) (sev) << 31) | ((unsigned long) (fac) << 16) | ((unsigned long) (code))))
#define S_OK ((HRESULT) 0L)
#define S_FALSE ((HRESULT) 1L)

View File

@ -84,7 +84,6 @@ typedef const WCHAR* LMCSTR;
typedef WCHAR* LMSTR;
typedef long LONG, *PLONG, *LPLONG;
typedef signed __int64 LONGLONG;
typedef LONG HRESULT;
typedef __int3264 LONG_PTR, *PLONG_PTR;
typedef unsigned __int3264 ULONG_PTR, *PULONG_PTR;
@ -108,6 +107,9 @@ typedef unsigned int UINT32;
typedef unsigned __int64 UINT64;
typedef unsigned long ULONG, *PULONG;
typedef ULONG HRESULT;
typedef ULONG SCODE;
typedef ULONG_PTR DWORD_PTR;
typedef ULONG_PTR SIZE_T;
typedef unsigned int ULONG32;