Merge branch 'master' of github.com:awakecoding/FreeRDP into fdsapi
This commit is contained in:
commit
822b07eb3e
@ -1091,8 +1091,6 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||
|
||||
WLog_SetLogLevel(rdpsnd->log, WLOG_TRACE);
|
||||
|
||||
rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpsnd_virtual_channel_init_event);
|
||||
|
||||
|
@ -176,6 +176,60 @@ FREERDP_API extern int connectErrorCode;
|
||||
#define INSUFFICIENTPRIVILEGESERROR ERRORSTART + 10
|
||||
#define CANCELEDBYUSER ERRORSTART + 11
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* FreeRDP Context Error Codes
|
||||
*/
|
||||
|
||||
#define MAKE_FREERDP_ERROR(_class, _type) \
|
||||
(((FREERDP_ERROR_ ## _class ## _CLASS) << 16) | (_type))
|
||||
|
||||
#define GET_FREERDP_ERROR_CLASS(_errorCode) \
|
||||
((_errorCode >> 16) & 0xFFFF)
|
||||
|
||||
#define GET_FREERDP_ERROR_TYPE(_errorCode) \
|
||||
(_errorCode & 0xFFFF)
|
||||
|
||||
#define GET_FREERDP_ERROR_SUBCODE
|
||||
|
||||
#define FREERDP_ERROR_BASE 0
|
||||
|
||||
#define FREERDP_ERROR_SUCCESS ERRINFO_SUCCESS
|
||||
#define FREERDP_ERROR_NONE ERRINFO_NONE
|
||||
|
||||
/* Error Info Codes */
|
||||
|
||||
#define FREERDP_ERROR_ERRINFO_CLASS (FREERDP_ERROR_BASE + 1)
|
||||
|
||||
#define FREERDP_ERROR_RPC_INITIATED_DISCONNECT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_DISCONNECT)
|
||||
#define FREERDP_ERROR_RPC_INITIATED_LOGOFF MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_LOGOFF)
|
||||
#define FREERDP_ERROR_IDLE_TIMEOUT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_IDLE_TIMEOUT)
|
||||
#define FREERDP_ERROR_LOGON_TIMEOUT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_LOGON_TIMEOUT)
|
||||
#define FREERDP_ERROR_DISCONNECTED_BY_OTHER_CONNECTION MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION)
|
||||
#define FREERDP_ERROR_OUT_OF_MEMORY MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_OUT_OF_MEMORY)
|
||||
#define FREERDP_ERROR_SERVER_DENIED_CONNECTION MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_DENIED_CONNECTION)
|
||||
#define FREERDP_ERROR_SERVER_INSUFFICIENT_PRIVILEGES MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES)
|
||||
#define FREERDP_ERROR_SERVER_FRESH_CREDENTIALS_REQUIRED MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED)
|
||||
#define FREERDP_ERROR_RPC_INITIATED_DISCONNECT_BY_USER MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER)
|
||||
#define FREERDP_ERROR_LOGOFF_BY_USER MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_LOGOFF_BY_USER)
|
||||
|
||||
/* Connection Error Codes */
|
||||
|
||||
#define FREERDP_ERROR_CONNECT_CLASS (FREERDP_ERROR_BASE + 2)
|
||||
|
||||
#define FREERDP_ERROR_PRE_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 1)
|
||||
#define FREERDP_ERROR_CONNECT_UNDEFINED MAKE_FREERDP_ERROR(CONNECT, 2)
|
||||
#define FREERDP_ERROR_POST_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 3)
|
||||
#define FREERDP_ERROR_DNS_ERROR MAKE_FREERDP_ERROR(CONNECT, 4)
|
||||
#define FREERDP_ERROR_DNS_NAME_NOT_FOUND MAKE_FREERDP_ERROR(CONNECT, 5)
|
||||
#define FREERDP_ERROR_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 6)
|
||||
#define FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR MAKE_FREERDP_ERROR(CONNECT, 7)
|
||||
#define FREERDP_ERROR_TLS_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 8)
|
||||
#define FREERDP_ERROR_AUTHENTICATION_FAILED MAKE_FREERDP_ERROR(CONNECT, 9)
|
||||
#define FREERDP_ERROR_INSUFFICIENT_PRIVILEGES MAKE_FREERDP_ERROR(CONNECT, 10)
|
||||
#define FREERDP_ERROR_CONNECT_CANCELLED MAKE_FREERDP_ERROR(CONNECT, 11)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -85,7 +85,9 @@ struct rdp_context
|
||||
This field is used only on the server side. */
|
||||
ALIGN64 BOOL ServerMode; /**< (offset 2) true when context is in server mode */
|
||||
|
||||
UINT64 paddingA[16 - 3]; /* 3 */
|
||||
ALIGN64 UINT32 LastError; /* 3 */
|
||||
|
||||
UINT64 paddingA[16 - 4]; /* 4 */
|
||||
|
||||
ALIGN64 int argc; /**< (offset 16)
|
||||
Number of arguments given to the program at launch time.
|
||||
@ -247,6 +249,9 @@ FREERDP_API void freerdp_free(freerdp* instance);
|
||||
|
||||
FREERDP_API BOOL freerdp_focus_required(freerdp* instance);
|
||||
|
||||
FREERDP_API UINT32 freerdp_get_last_error(rdpContext* context);
|
||||
FREERDP_API void freerdp_set_last_error(rdpContext* context, UINT32 lastError);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -110,13 +110,8 @@ int mppc_decompress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** p
|
||||
|
||||
if (!(flags & PACKET_COMPRESSED))
|
||||
{
|
||||
CopyMemory(HistoryPtr, pSrcData, SrcSize);
|
||||
HistoryPtr += SrcSize;
|
||||
HistoryOffset += SrcSize;
|
||||
mppc->HistoryPtr = HistoryPtr;
|
||||
mppc->HistoryOffset = HistoryOffset;
|
||||
*ppDstData = HistoryPtr;
|
||||
*pDstSize = SrcSize;
|
||||
*ppDstData = pSrcData;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -532,6 +527,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE* pDst
|
||||
*pFlags |= PACKET_FLUSHED;
|
||||
ZeroMemory(HistoryBuffer, HistoryBufferSize);
|
||||
ZeroMemory(mppc->MatchBuffer, sizeof(mppc->MatchBuffer));
|
||||
*pDstSize = SrcSize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -582,6 +578,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE* pDst
|
||||
*pFlags = PACKET_FLUSHED;
|
||||
ZeroMemory(HistoryBuffer, HistoryBufferSize);
|
||||
ZeroMemory(mppc->MatchBuffer, sizeof(mppc->MatchBuffer));
|
||||
*pDstSize = SrcSize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -737,6 +734,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE* pDst
|
||||
*pFlags |= PACKET_FLUSHED;
|
||||
ZeroMemory(HistoryBuffer, HistoryBufferSize);
|
||||
ZeroMemory(mppc->MatchBuffer, sizeof(mppc->MatchBuffer));
|
||||
*pDstSize = SrcSize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1167,10 +1167,7 @@ int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BY
|
||||
|
||||
if (!(flags & PACKET_COMPRESSED))
|
||||
{
|
||||
CopyMemory(HistoryPtr, pSrcData, SrcSize);
|
||||
HistoryPtr += SrcSize;
|
||||
ncrush->HistoryPtr = HistoryPtr;
|
||||
*ppDstData = HistoryPtr;
|
||||
*ppDstData = pSrcData;
|
||||
*pDstSize = SrcSize;
|
||||
return 1;
|
||||
}
|
||||
|
@ -46,29 +46,38 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD
|
||||
UINT32 UncompressedBytes;
|
||||
UINT32 type = flags & 0x0F;
|
||||
|
||||
switch (type)
|
||||
if (flags & PACKET_COMPRESSED)
|
||||
{
|
||||
case PACKET_COMPR_TYPE_8K:
|
||||
mppc_set_compression_level(bulk->mppcRecv, 0);
|
||||
status = mppc_decompress(bulk->mppcRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
switch (type)
|
||||
{
|
||||
case PACKET_COMPR_TYPE_8K:
|
||||
mppc_set_compression_level(bulk->mppcRecv, 0);
|
||||
status = mppc_decompress(bulk->mppcRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
|
||||
case PACKET_COMPR_TYPE_64K:
|
||||
mppc_set_compression_level(bulk->mppcRecv, 1);
|
||||
status = mppc_decompress(bulk->mppcRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
case PACKET_COMPR_TYPE_64K:
|
||||
mppc_set_compression_level(bulk->mppcRecv, 1);
|
||||
status = mppc_decompress(bulk->mppcRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
|
||||
case PACKET_COMPR_TYPE_RDP6:
|
||||
status = ncrush_decompress(bulk->ncrushRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
case PACKET_COMPR_TYPE_RDP6:
|
||||
status = ncrush_decompress(bulk->ncrushRecv, pSrcData, SrcSize, ppDstData, pDstSize, flags);
|
||||
break;
|
||||
|
||||
case PACKET_COMPR_TYPE_RDP61:
|
||||
status = -1;
|
||||
break;
|
||||
case PACKET_COMPR_TYPE_RDP61:
|
||||
status = -1;
|
||||
break;
|
||||
|
||||
case PACKET_COMPR_TYPE_RDP8:
|
||||
status = -1;
|
||||
break;
|
||||
case PACKET_COMPR_TYPE_RDP8:
|
||||
status = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppDstData = pSrcData;
|
||||
*pDstSize = SrcSize;
|
||||
status = 1;
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
@ -87,8 +96,8 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD
|
||||
CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes);
|
||||
TotalCompressionRatio = ((double) bulk->TotalCompressedBytes) / ((double) bulk->TotalUncompressedBytes);
|
||||
|
||||
printf("Type: %d Compression Ratio: %f Total: %f %d / %d\n",
|
||||
type, CompressionRatio, TotalCompressionRatio, CompressedBytes, UncompressedBytes);
|
||||
printf("Type: %d Flags: 0x%04X Compression Ratio: %f Total: %f %d / %d\n",
|
||||
type, flags, CompressionRatio, TotalCompressionRatio, CompressedBytes, UncompressedBytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -102,6 +111,7 @@ int bulk_decompress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstD
|
||||
|
||||
int bulk_compress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags)
|
||||
{
|
||||
UINT32 type;
|
||||
int status = -1;
|
||||
UINT32 CompressedBytes;
|
||||
UINT32 UncompressedBytes;
|
||||
@ -113,7 +123,7 @@ int bulk_compress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstDat
|
||||
mppc_set_compression_level(bulk->mppcSend, bulk->CompressionLevel);
|
||||
status = mppc_compress(bulk->mppcSend, pSrcData, SrcSize, *ppDstData, pDstSize, pFlags);
|
||||
|
||||
if ((status >= 0) && (*pFlags & PACKET_COMPRESSED))
|
||||
if (status >= 0)
|
||||
{
|
||||
CompressedBytes = *pDstSize;
|
||||
UncompressedBytes = SrcSize;
|
||||
@ -126,10 +136,13 @@ int bulk_compress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstDat
|
||||
double CompressionRatio;
|
||||
double TotalCompressionRatio;
|
||||
|
||||
type = bulk->CompressionLevel;
|
||||
|
||||
CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes);
|
||||
TotalCompressionRatio = ((double) bulk->TotalCompressedBytes) / ((double) bulk->TotalUncompressedBytes);
|
||||
|
||||
printf("Compression Ratio: %f Total: %f\n", CompressionRatio, TotalCompressionRatio);
|
||||
printf("Type: %d Flags: 0x%04X Compression Ratio: %f Total: %f %d / %d\n",
|
||||
type, *pFlags, CompressionRatio, TotalCompressionRatio, CompressedBytes, UncompressedBytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -268,6 +268,12 @@ BOOL rdp_client_connect(rdpRdp* rdp)
|
||||
{
|
||||
connectErrorCode = MCSCONNECTINITIALERROR;
|
||||
}
|
||||
|
||||
if (!freerdp_get_last_error(rdp->context))
|
||||
{
|
||||
freerdp_set_last_error(rdp->context, FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Error: unable to send MCS Connect Initial\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -342,6 +342,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
BYTE fragmentation;
|
||||
BYTE compression;
|
||||
BYTE compressionFlags;
|
||||
UINT32 DstSize = 0;
|
||||
BYTE* pDstData = NULL;
|
||||
rdpTransport* transport;
|
||||
|
||||
status = 0;
|
||||
@ -363,26 +365,20 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
|
||||
cs = s;
|
||||
next_pos = Stream_GetPosition(s) + size;
|
||||
|
||||
if (compressionFlags & PACKET_COMPRESSED)
|
||||
if (bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags))
|
||||
{
|
||||
UINT32 DstSize = 0;
|
||||
BYTE* pDstData = NULL;
|
||||
size = DstSize;
|
||||
cs = StreamPool_Take(transport->ReceivePool, DstSize);
|
||||
|
||||
if (bulk_decompress(rdp->bulk, Stream_Pointer(s), size, &pDstData, &DstSize, compressionFlags))
|
||||
{
|
||||
size = DstSize;
|
||||
cs = StreamPool_Take(transport->ReceivePool, DstSize);
|
||||
|
||||
Stream_SetPosition(cs, 0);
|
||||
Stream_Write(cs, pDstData, DstSize);
|
||||
Stream_SealLength(cs);
|
||||
Stream_SetPosition(cs, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "bulk_decompress() failed\n");
|
||||
Stream_Seek(s, size);
|
||||
}
|
||||
Stream_SetPosition(cs, 0);
|
||||
Stream_Write(cs, pDstData, DstSize);
|
||||
Stream_SealLength(cs);
|
||||
Stream_SetPosition(cs, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "bulk_decompress() failed\n");
|
||||
Stream_Seek(s, size);
|
||||
}
|
||||
|
||||
if (fragmentation == FASTPATH_FRAGMENT_SINGLE)
|
||||
@ -855,6 +851,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
{
|
||||
CompressionMaxSize = bulk_compression_max_size(rdp->bulk);
|
||||
maxLength = (maxLength < CompressionMaxSize) ? maxLength : CompressionMaxSize;
|
||||
maxLength -= 20;
|
||||
}
|
||||
|
||||
totalLength = Stream_GetPosition(s);
|
||||
|
@ -65,6 +65,7 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
|
||||
/* We always set the return code to 0 before we start the connect sequence*/
|
||||
connectErrorCode = 0;
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_SUCCESS);
|
||||
|
||||
rdp = instance->context->rdp;
|
||||
settings = instance->settings;
|
||||
@ -87,6 +88,12 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
{
|
||||
connectErrorCode = PREECONNECTERROR;
|
||||
}
|
||||
|
||||
if (!freerdp_get_last_error(rdp->context))
|
||||
{
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_PRE_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s:%d: freerdp_pre_connect failed\n", __FILE__, __LINE__);
|
||||
|
||||
goto freerdp_connect_finally;
|
||||
@ -124,6 +131,11 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
connectErrorCode = POSTCONNECTERROR;
|
||||
}
|
||||
|
||||
if (!freerdp_get_last_error(rdp->context))
|
||||
{
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_POST_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
goto freerdp_connect_finally;
|
||||
}
|
||||
|
||||
@ -177,6 +189,7 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES)
|
||||
{
|
||||
connectErrorCode = INSUFFICIENTPRIVILEGESERROR;
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_INSUFFICIENT_PRIVILEGES);
|
||||
}
|
||||
|
||||
if (!connectErrorCode)
|
||||
@ -465,6 +478,19 @@ UINT32 freerdp_error_info(freerdp* instance)
|
||||
return instance->context->rdp->errorInfo;
|
||||
}
|
||||
|
||||
UINT32 freerdp_get_last_error(rdpContext* context)
|
||||
{
|
||||
return context->LastError;
|
||||
}
|
||||
|
||||
void freerdp_set_last_error(rdpContext* context, UINT32 lastError)
|
||||
{
|
||||
if (lastError)
|
||||
fprintf(stderr, "freerdp_set_last_error 0x%04X\n", lastError);
|
||||
|
||||
context->LastError = lastError;
|
||||
}
|
||||
|
||||
/** Allocator function for the rdp_freerdp structure.
|
||||
* @return an allocated structure filled with 0s. Need to be deallocated using freerdp_free()
|
||||
*/
|
||||
|
@ -142,6 +142,7 @@ int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, TSG_CHANNEL channel)
|
||||
if (!proceed)
|
||||
{
|
||||
connectErrorCode = CANCELEDBYUSER;
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,7 @@ int rpc_send_bind_pdu(rdpRpc* rpc)
|
||||
if (!proceed)
|
||||
{
|
||||
connectErrorCode = CANCELEDBYUSER;
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,17 @@ BOOL rts_connect(rdpRpc* rpc)
|
||||
http_response_print(http_response);
|
||||
http_response_free(http_response);
|
||||
|
||||
if (!connectErrorCode && http_response->StatusCode == HTTP_STATUS_DENIED)
|
||||
if (http_response->StatusCode == HTTP_STATUS_DENIED)
|
||||
{
|
||||
connectErrorCode = AUTHENTICATIONERROR;
|
||||
if (!connectErrorCode)
|
||||
{
|
||||
connectErrorCode = AUTHENTICATIONERROR;
|
||||
}
|
||||
|
||||
if (!freerdp_get_last_error(((freerdp*)(rpc->settings->instance))->context))
|
||||
{
|
||||
freerdp_set_last_error(((freerdp*)(rpc->settings->instance))->context, FREERDP_ERROR_AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -153,6 +153,7 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
|
||||
if (!proceed)
|
||||
{
|
||||
connectErrorCode = CANCELEDBYUSER;
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -238,12 +238,17 @@ BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo)
|
||||
ErrorInfoEventArgs e;
|
||||
rdpContext* context = rdp->instance->context;
|
||||
|
||||
rdp->context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo);
|
||||
rdp_print_errinfo(rdp->errorInfo);
|
||||
|
||||
EventArgsInit(&e, "freerdp");
|
||||
e.code = rdp->errorInfo;
|
||||
PubSub_OnErrorInfo(context->pubSub, context, &e);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdp->context->LastError = FREERDP_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -71,25 +71,8 @@ void transport_attach(rdpTransport* transport, int sockfd)
|
||||
transport->TcpOut = transport->TcpIn;
|
||||
}
|
||||
|
||||
BOOL transport_disconnect(rdpTransport* transport)
|
||||
void transport_stop(rdpTransport* transport)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
|
||||
if (!transport)
|
||||
return FALSE;
|
||||
|
||||
if (transport->layer == TRANSPORT_LAYER_TLS)
|
||||
status &= tls_disconnect(transport->TlsIn);
|
||||
|
||||
if ((transport->layer == TRANSPORT_LAYER_TSG) || (transport->layer == TRANSPORT_LAYER_TSG_TLS))
|
||||
{
|
||||
status &= tsg_disconnect(transport->tsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
status &= tcp_disconnect(transport->TcpIn);
|
||||
}
|
||||
|
||||
if (transport->async)
|
||||
{
|
||||
if (transport->stopEvent)
|
||||
@ -104,6 +87,28 @@ BOOL transport_disconnect(rdpTransport* transport)
|
||||
transport->stopEvent = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL transport_disconnect(rdpTransport* transport)
|
||||
{
|
||||
BOOL status = TRUE;
|
||||
|
||||
if (!transport)
|
||||
return FALSE;
|
||||
|
||||
transport_stop(transport);
|
||||
|
||||
if (transport->layer == TRANSPORT_LAYER_TLS)
|
||||
status &= tls_disconnect(transport->TlsIn);
|
||||
|
||||
if ((transport->layer == TRANSPORT_LAYER_TSG) || (transport->layer == TRANSPORT_LAYER_TSG_TLS))
|
||||
{
|
||||
status &= tsg_disconnect(transport->tsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
status &= tcp_disconnect(transport->TcpIn);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -239,6 +244,11 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
||||
if (!connectErrorCode)
|
||||
connectErrorCode = TLSCONNECTERROR;
|
||||
|
||||
if (!freerdp_get_last_error(((freerdp*)(transport->settings->instance))->context))
|
||||
{
|
||||
freerdp_set_last_error(((freerdp*)(transport->settings->instance))->context, FREERDP_ERROR_TLS_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
tls_free(transport->TsgTls);
|
||||
transport->TsgTls = NULL;
|
||||
|
||||
@ -268,6 +278,11 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
||||
if (!connectErrorCode)
|
||||
connectErrorCode = TLSCONNECTERROR;
|
||||
|
||||
if (!freerdp_get_last_error(((freerdp*)(transport->settings->instance))->context))
|
||||
{
|
||||
freerdp_set_last_error(((freerdp*)(transport->settings->instance))->context, FREERDP_ERROR_TLS_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
tls_free(transport->TlsIn);
|
||||
|
||||
if (transport->TlsIn == transport->TlsOut)
|
||||
@ -313,6 +328,11 @@ BOOL transport_connect_nla(rdpTransport* transport)
|
||||
if (!connectErrorCode)
|
||||
connectErrorCode = AUTHENTICATIONERROR;
|
||||
|
||||
if (!freerdp_get_last_error(instance->context))
|
||||
{
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Authentication failure, check credentials.\n"
|
||||
"If credentials are valid, the NTLMSSP implementation may be to blame.\n");
|
||||
|
||||
@ -874,7 +894,7 @@ int transport_check_fds(rdpTransport* transport)
|
||||
{
|
||||
status = transport_read_nonblocking(transport);
|
||||
|
||||
if (status <= 0)
|
||||
if (status < 0 || Stream_GetPosition(transport->ReceiveBuffer) == 0)
|
||||
return status;
|
||||
|
||||
while ((pos = Stream_GetPosition(transport->ReceiveBuffer)) > 0)
|
||||
@ -1055,7 +1075,7 @@ static void* transport_client_thread(void* arg)
|
||||
|
||||
transport_get_read_handles(transport, (HANDLE*) &handles, &nCount);
|
||||
|
||||
status = WaitForMultipleObjects(nCount, handles, FALSE, 100);
|
||||
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
||||
if (transport->layer == TRANSPORT_LAYER_CLOSED)
|
||||
{
|
||||
rdpRdp* rdp = (rdpRdp*) transport->rdp;
|
||||
@ -1121,20 +1141,7 @@ void transport_free(rdpTransport* transport)
|
||||
{
|
||||
if (transport)
|
||||
{
|
||||
if (transport->async)
|
||||
{
|
||||
if (transport->stopEvent)
|
||||
{
|
||||
SetEvent(transport->stopEvent);
|
||||
WaitForSingleObject(transport->thread, INFINITE);
|
||||
|
||||
CloseHandle(transport->thread);
|
||||
CloseHandle(transport->stopEvent);
|
||||
|
||||
transport->thread = NULL;
|
||||
transport->stopEvent = NULL;
|
||||
}
|
||||
}
|
||||
transport_stop(transport);
|
||||
|
||||
if (transport->ReceiveBuffer)
|
||||
Stream_Release(transport->ReceiveBuffer);
|
||||
|
@ -92,6 +92,7 @@ BOOL transport_connect_tsg(rdpTransport* transport);
|
||||
BOOL transport_accept_rdp(rdpTransport* transport);
|
||||
BOOL transport_accept_tls(rdpTransport* transport);
|
||||
BOOL transport_accept_nla(rdpTransport* transport);
|
||||
void transport_stop(rdpTransport* transport);
|
||||
int transport_read(rdpTransport* transport, wStream* s);
|
||||
int transport_write(rdpTransport* transport, wStream* s);
|
||||
void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount);
|
||||
|
@ -696,6 +696,11 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
|
||||
if (instance->VerifyX509Certificate)
|
||||
{
|
||||
status = instance->VerifyX509Certificate(instance, pemCert, length, hostname, port, 0);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "VerifyX509Certificate: (length = %d) status: %d\n%s\n",
|
||||
@ -787,8 +792,15 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
|
||||
tls_print_certificate_name_mismatch_error(hostname, common_name, alt_names, alt_names_count);
|
||||
|
||||
if (instance->VerifyCertificate)
|
||||
{
|
||||
accept_certificate = instance->VerifyCertificate(instance, subject, issuer, fingerprint);
|
||||
|
||||
if (!accept_certificate)
|
||||
{
|
||||
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
if (!accept_certificate)
|
||||
{
|
||||
/* user did not accept, abort and do not add entry in known_hosts file */
|
||||
@ -807,8 +819,15 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
|
||||
tls_print_certificate_error(hostname, fingerprint, tls->certificate_store->file);
|
||||
|
||||
if (instance->VerifyChangedCertificate)
|
||||
{
|
||||
accept_certificate = instance->VerifyChangedCertificate(instance, subject, issuer, fingerprint, "");
|
||||
|
||||
if (!accept_certificate)
|
||||
{
|
||||
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CONNECT_CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
if (!accept_certificate)
|
||||
{
|
||||
/* user did not accept, abort and do not change known_hosts file */
|
||||
|
@ -423,7 +423,7 @@ void InitializeWtsApiStubs(void)
|
||||
if (!g_WtsApiModule)
|
||||
return;
|
||||
|
||||
pInitWtsApi = GetProcAddress(g_WtsApiModule, "InitWtsApi");
|
||||
pInitWtsApi = (INIT_WTSAPI_FN) GetProcAddress(g_WtsApiModule, "InitWtsApi");
|
||||
|
||||
if (pInitWtsApi)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user