Merge pull request #2319 from akallabeth/channel_reconnect_fix
Channel reconnect fix
This commit is contained in:
commit
8e7b80b25a
@ -412,7 +412,6 @@ static int audin_plugin_terminated(IWTSPlugin* pPlugin)
|
||||
|
||||
if (audin->device)
|
||||
{
|
||||
IFCALL(audin->device->Close, audin->device);
|
||||
IFCALL(audin->device->Free, audin->device);
|
||||
audin->device = NULL;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "audin_server_thread_func: unknown MessageId %d\n", MessageId);
|
||||
WLog_ERR(TAG, "audin_server_thread_func: unknown MessageId %d", MessageId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,8 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "cliprdr_packet_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,8 +716,8 @@ int cliprdr_client_file_contents_response(CliprdrClientContext* context, CLIPRDR
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void cliprdr_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -736,6 +737,11 @@ void* cliprdr_get_init_handle_data(void* pInitHandle)
|
||||
void cliprdr_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cliprdr_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -760,6 +766,12 @@ void cliprdr_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
|
||||
@ -821,6 +833,9 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event(DWORD openHandle, UINT
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -863,7 +878,8 @@ static void cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr, LPVO
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "cliprdr_virtual_channel_event_connected: open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -873,22 +889,23 @@ static void cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr, LPVO
|
||||
(LPTHREAD_START_ROUTINE) cliprdr_virtual_channel_client_thread, (void*) cliprdr, 0, NULL);
|
||||
}
|
||||
|
||||
static void cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
|
||||
static void cliprdr_virtual_channel_event_disconnected(cliprdrPlugin* cliprdr)
|
||||
{
|
||||
if (cliprdr->queue)
|
||||
UINT rc;
|
||||
|
||||
MessageQueue_PostQuit(cliprdr->queue, 0);
|
||||
WaitForSingleObject(cliprdr->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(cliprdr->queue);
|
||||
CloseHandle(cliprdr->thread);
|
||||
|
||||
rc = cliprdr->channelEntryPoints.pVirtualChannelClose(cliprdr->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessageQueue_PostQuit(cliprdr->queue, 0);
|
||||
WaitForSingleObject(cliprdr->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(cliprdr->queue);
|
||||
cliprdr->queue = NULL;
|
||||
|
||||
CloseHandle(cliprdr->thread);
|
||||
cliprdr->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
cliprdr->channelEntryPoints.pVirtualChannelClose(cliprdr->OpenHandle);
|
||||
|
||||
if (cliprdr->data_in)
|
||||
{
|
||||
Stream_Free(cliprdr->data_in, TRUE);
|
||||
@ -896,9 +913,11 @@ static void cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
|
||||
}
|
||||
|
||||
cliprdr_remove_open_handle_data(cliprdr->OpenHandle);
|
||||
cliprdr_remove_init_handle_data(cliprdr->InitHandle);
|
||||
}
|
||||
|
||||
free(cliprdr->context);
|
||||
static void cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
|
||||
{
|
||||
cliprdr_remove_init_handle_data(cliprdr->InitHandle);
|
||||
|
||||
free(cliprdr);
|
||||
}
|
||||
@ -922,6 +941,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
cliprdr_virtual_channel_event_disconnected(cliprdr);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -935,6 +955,8 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
|
||||
cliprdrPlugin* cliprdr;
|
||||
CliprdrClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -985,8 +1007,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
cliprdr->channelEntryPoints.pVirtualChannelInit(&cliprdr->InitHandle,
|
||||
rc = cliprdr->channelEntryPoints.pVirtualChannelInit(&cliprdr->InitHandle,
|
||||
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, cliprdr_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(cliprdr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cliprdr->channelEntryPoints.pInterface = *(cliprdr->channelEntryPoints.ppInterface);
|
||||
cliprdr->channelEntryPoints.ppInterface = &(cliprdr->channelEntryPoints.pInterface);
|
||||
|
@ -101,7 +101,7 @@ int disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback
|
||||
|
||||
Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */
|
||||
|
||||
//WLog_ERR(TAG, "NumMonitors: %d\n", NumMonitors);
|
||||
//WLog_ERR(TAG, "NumMonitors: %d", NumMonitors);
|
||||
|
||||
for (index = 0; index < NumMonitors; index++)
|
||||
{
|
||||
@ -134,14 +134,14 @@ int disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback
|
||||
Stream_Write_UINT32(s, Monitors[index].DeviceScaleFactor); /* DeviceScaleFactor (4 bytes) */
|
||||
|
||||
#if 0
|
||||
WLog_DBG(TAG, "\t: Flags: 0x%04X\n", Monitors[index].Flags);
|
||||
WLog_DBG(TAG, "\t: Left: %d\n", Monitors[index].Left);
|
||||
WLog_DBG(TAG, "\t: Top: %d\n", Monitors[index].Top);
|
||||
WLog_DBG(TAG, "\t: Width: %d\n", Monitors[index].Width);
|
||||
WLog_DBG(TAG, "\t: Height: %d\n", Monitors[index].Height);
|
||||
WLog_DBG(TAG, "\t: PhysicalWidth: %d\n", Monitors[index].PhysicalWidth);
|
||||
WLog_DBG(TAG, "\t: PhysicalHeight: %d\n", Monitors[index].PhysicalHeight);
|
||||
WLog_DBG(TAG, "\t: Orientation: %d\n", Monitors[index].Orientation);
|
||||
WLog_DBG(TAG, "\t: Flags: 0x%04X", Monitors[index].Flags);
|
||||
WLog_DBG(TAG, "\t: Left: %d", Monitors[index].Left);
|
||||
WLog_DBG(TAG, "\t: Top: %d", Monitors[index].Top);
|
||||
WLog_DBG(TAG, "\t: Width: %d", Monitors[index].Width);
|
||||
WLog_DBG(TAG, "\t: Height: %d", Monitors[index].Height);
|
||||
WLog_DBG(TAG, "\t: PhysicalWidth: %d", Monitors[index].PhysicalWidth);
|
||||
WLog_DBG(TAG, "\t: PhysicalHeight: %d", Monitors[index].PhysicalHeight);
|
||||
WLog_DBG(TAG, "\t: Orientation: %d", Monitors[index].Orientation);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ int disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback, wStream*
|
||||
Stream_Read_UINT32(s, disp->MaxNumMonitors); /* MaxNumMonitors (4 bytes) */
|
||||
Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorA); /* MaxMonitorAreaFactorA (4 bytes) */
|
||||
Stream_Read_UINT32(s, disp->MaxMonitorAreaFactorB); /* MaxMonitorAreaFactorB (4 bytes) */
|
||||
//WLog_ERR(TAG, "DisplayControlCapsPdu: MaxNumMonitors: %d MaxMonitorWidth: %d MaxMonitorHeight: %d\n",
|
||||
//WLog_ERR(TAG, "DisplayControlCapsPdu: MaxNumMonitors: %d MaxMonitorWidth: %d MaxMonitorHeight: %d",
|
||||
// disp->MaxNumMonitors, disp->MaxMonitorWidth, disp->MaxMonitorHeight);
|
||||
|
||||
return 0;
|
||||
@ -183,7 +183,7 @@ int disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
|
||||
Stream_Read_UINT32(s, type); /* Type (4 bytes) */
|
||||
Stream_Read_UINT32(s, length); /* Length (4 bytes) */
|
||||
|
||||
//WLog_ERR(TAG, "Type: %d Length: %d\n", type, length);
|
||||
//WLog_ERR(TAG, "Type: %d Length: %d", type, length);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -547,7 +547,8 @@ int drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "drdynvc_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -636,7 +637,8 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
drdynvc->channel_error = status;
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -656,7 +658,8 @@ static int drdynvc_send_capability_response(drdynvcPlugin* drdynvc)
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -761,7 +764,8 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -824,7 +828,8 @@ static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbC
|
||||
|
||||
if (error != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", error);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(error), error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -878,8 +883,8 @@ static void drdynvc_order_recv(drdynvcPlugin* drdynvc, wStream* s)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void drdynvc_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -899,6 +904,11 @@ void* drdynvc_get_init_handle_data(void* pInitHandle)
|
||||
void drdynvc_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void drdynvc_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -923,6 +933,11 @@ void drdynvc_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void drdynvc_virtual_channel_event_data_received(drdynvcPlugin* drdynvc,
|
||||
@ -984,6 +999,9 @@ static VOID VCAPITYPE drdynvc_virtual_channel_open_event(DWORD openHandle, UINT
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1030,7 +1048,8 @@ static void drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "drdynvc_virtual_channel_event_connected: open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1055,22 +1074,26 @@ static void drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
|
||||
(LPTHREAD_START_ROUTINE) drdynvc_virtual_channel_client_thread, (void*) drdynvc, 0, NULL);
|
||||
}
|
||||
|
||||
static void drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc)
|
||||
static void drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
|
||||
{
|
||||
if (drdynvc->queue)
|
||||
UINT rc;
|
||||
|
||||
MessageQueue_PostQuit(drdynvc->queue, 0);
|
||||
WaitForSingleObject(drdynvc->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(drdynvc->queue);
|
||||
CloseHandle(drdynvc->thread);
|
||||
|
||||
drdynvc->queue = NULL;
|
||||
drdynvc->thread = NULL;
|
||||
|
||||
rc = drdynvc->channelEntryPoints.pVirtualChannelClose(drdynvc->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessageQueue_PostQuit(drdynvc->queue, 0);
|
||||
WaitForSingleObject(drdynvc->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(drdynvc->queue);
|
||||
drdynvc->queue = NULL;
|
||||
|
||||
CloseHandle(drdynvc->thread);
|
||||
drdynvc->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
drdynvc->channelEntryPoints.pVirtualChannelClose(drdynvc->OpenHandle);
|
||||
|
||||
if (drdynvc->data_in)
|
||||
{
|
||||
Stream_Free(drdynvc->data_in, TRUE);
|
||||
@ -1084,8 +1107,11 @@ static void drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc)
|
||||
}
|
||||
|
||||
drdynvc_remove_open_handle_data(drdynvc->OpenHandle);
|
||||
drdynvc_remove_init_handle_data(drdynvc->InitHandle);
|
||||
}
|
||||
|
||||
static void drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc)
|
||||
{
|
||||
drdynvc_remove_init_handle_data(drdynvc->InitHandle);
|
||||
free(drdynvc);
|
||||
}
|
||||
|
||||
@ -1108,6 +1134,7 @@ static VOID VCAPITYPE drdynvc_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
drdynvc_virtual_channel_event_disconnected(drdynvc);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -1131,6 +1158,7 @@ int drdynvc_get_version(DrdynvcClientContext* context)
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
drdynvcPlugin* drdynvc;
|
||||
DrdynvcClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -1178,8 +1206,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(drdynvc->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
drdynvc->channelEntryPoints.pVirtualChannelInit(&drdynvc->InitHandle,
|
||||
rc = drdynvc->channelEntryPoints.pVirtualChannelInit(&drdynvc->InitHandle,
|
||||
&drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, drdynvc_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(drdynvc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
drdynvc->channelEntryPoints.pInterface = *(drdynvc->channelEntryPoints.ppInterface);
|
||||
drdynvc->channelEntryPoints.ppInterface = &(drdynvc->channelEntryPoints.pInterface);
|
||||
|
@ -92,7 +92,8 @@ int encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_virtual_channel_write: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -658,8 +659,8 @@ static void encomsp_process_connect(encomspPlugin* encomsp)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void encomsp_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -679,6 +680,11 @@ void* encomsp_get_init_handle_data(void* pInitHandle)
|
||||
void encomsp_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void encomsp_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -703,6 +709,11 @@ void encomsp_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int encomsp_send(encomspPlugin* encomsp, wStream* s)
|
||||
@ -723,7 +734,8 @@ int encomsp_send(encomspPlugin* encomsp, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "encomsp_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -788,6 +800,9 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle, UINT
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,7 +847,8 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_virtual_channel_event_connected: open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -842,22 +858,25 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
(LPTHREAD_START_ROUTINE) encomsp_virtual_channel_client_thread, (void*) encomsp, 0, NULL);
|
||||
}
|
||||
|
||||
static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
static void encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
|
||||
{
|
||||
if (encomsp->queue)
|
||||
UINT rc;
|
||||
MessageQueue_PostQuit(encomsp->queue, 0);
|
||||
WaitForSingleObject(encomsp->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(encomsp->queue);
|
||||
CloseHandle(encomsp->thread);
|
||||
|
||||
encomsp->queue = NULL;
|
||||
encomsp->thread = NULL;
|
||||
|
||||
rc = encomsp->channelEntryPoints.pVirtualChannelClose(encomsp->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessageQueue_PostQuit(encomsp->queue, 0);
|
||||
WaitForSingleObject(encomsp->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(encomsp->queue);
|
||||
encomsp->queue = NULL;
|
||||
|
||||
CloseHandle(encomsp->thread);
|
||||
encomsp->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
encomsp->channelEntryPoints.pVirtualChannelClose(encomsp->OpenHandle);
|
||||
|
||||
if (encomsp->data_in)
|
||||
{
|
||||
Stream_Free(encomsp->data_in, TRUE);
|
||||
@ -865,10 +884,12 @@ static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
}
|
||||
|
||||
encomsp_remove_open_handle_data(encomsp->OpenHandle);
|
||||
}
|
||||
|
||||
|
||||
static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
{
|
||||
encomsp_remove_init_handle_data(encomsp->InitHandle);
|
||||
|
||||
free(encomsp->context);
|
||||
|
||||
free(encomsp);
|
||||
}
|
||||
|
||||
@ -891,6 +912,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
encomsp_virtual_channel_event_disconnected(encomsp);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -904,6 +926,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
encomspPlugin* encomsp;
|
||||
EncomspClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -945,9 +968,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(encomsp->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
encomsp->channelEntryPoints.pVirtualChannelInit(&encomsp->InitHandle,
|
||||
rc = encomsp->channelEntryPoints.pVirtualChannelInit(&encomsp->InitHandle,
|
||||
&encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, encomsp_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(encomsp);
|
||||
return -1;
|
||||
}
|
||||
encomsp->channelEntryPoints.pInterface = *(encomsp->channelEntryPoints.ppInterface);
|
||||
encomsp->channelEntryPoints.ppInterface = &(encomsp->channelEntryPoints.pInterface);
|
||||
|
||||
|
@ -55,7 +55,8 @@ int rail_send(railPlugin* rail, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "rail_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -313,8 +314,8 @@ int rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RE
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rail_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -334,6 +335,11 @@ void* rail_get_init_handle_data(void* pInitHandle)
|
||||
void rail_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void rail_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -358,6 +364,11 @@ void rail_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void rail_virtual_channel_event_data_received(railPlugin* rail,
|
||||
@ -419,6 +430,9 @@ static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle, UINT eve
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,7 +475,8 @@ static void rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "rail_virtual_channel_event_connected: open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -471,22 +486,25 @@ static void rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
(LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0, NULL);
|
||||
}
|
||||
|
||||
static void rail_virtual_channel_event_terminated(railPlugin* rail)
|
||||
static void rail_virtual_channel_event_disconnected(railPlugin* rail)
|
||||
{
|
||||
if (rail->queue)
|
||||
UINT rc;
|
||||
MessageQueue_PostQuit(rail->queue, 0);
|
||||
WaitForSingleObject(rail->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(rail->queue);
|
||||
CloseHandle(rail->thread);
|
||||
|
||||
rail->queue = NULL;
|
||||
rail->thread = NULL;
|
||||
|
||||
rc = rail->channelEntryPoints.pVirtualChannelClose(rail->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessageQueue_PostQuit(rail->queue, 0);
|
||||
WaitForSingleObject(rail->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(rail->queue);
|
||||
rail->queue = NULL;
|
||||
|
||||
CloseHandle(rail->thread);
|
||||
rail->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
rail->channelEntryPoints.pVirtualChannelClose(rail->OpenHandle);
|
||||
|
||||
if (rail->data_in)
|
||||
{
|
||||
Stream_Free(rail->data_in, TRUE);
|
||||
@ -494,10 +512,11 @@ static void rail_virtual_channel_event_terminated(railPlugin* rail)
|
||||
}
|
||||
|
||||
rail_remove_open_handle_data(rail->OpenHandle);
|
||||
}
|
||||
|
||||
static void rail_virtual_channel_event_terminated(railPlugin* rail)
|
||||
{
|
||||
rail_remove_init_handle_data(rail->InitHandle);
|
||||
|
||||
free(rail->context);
|
||||
|
||||
free(rail);
|
||||
}
|
||||
|
||||
@ -520,6 +539,7 @@ static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle, UINT e
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
rail_virtual_channel_event_disconnected(rail);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -533,6 +553,7 @@ static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle, UINT e
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
railPlugin* rail;
|
||||
RailClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -589,8 +610,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(rail->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle,
|
||||
rc = rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle,
|
||||
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rail_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rail);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface);
|
||||
rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface);
|
||||
|
@ -762,18 +762,18 @@ static void rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "rdpdr_process_receive: RDPDR_CTYP_CORE unknown PacketId: 0x%04X", packetId);
|
||||
WLog_ERR(TAG, "RDPDR_CTYP_CORE unknown PacketId: 0x%04X", packetId);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if (component == RDPDR_CTYP_PRN)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_process_receive: RDPDR_CTYP_PRN unknown PacketId: 0x%04X", packetId);
|
||||
WLog_ERR(TAG, "RDPDR_CTYP_PRN unknown PacketId: 0x%04X", packetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_process_receive: unknown message: Component: 0x%04X PacketId: 0x%04X",
|
||||
WLog_ERR(TAG, "unknown message: Component: 0x%04X PacketId: 0x%04X",
|
||||
component, packetId);
|
||||
}
|
||||
|
||||
@ -784,8 +784,8 @@ static void rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
/****************************************************************************************/
|
||||
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rdpdr_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -805,6 +805,11 @@ void* rdpdr_get_init_handle_data(void* pInitHandle)
|
||||
void rdpdr_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void rdpdr_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -829,6 +834,11 @@ void rdpdr_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
|
||||
@ -849,7 +859,8 @@ int rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "rdpdr_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -873,7 +884,7 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
|
||||
|
||||
if (dataFlags & CHANNEL_FLAG_FIRST)
|
||||
{
|
||||
if (rdpdr->data_in)
|
||||
if (rdpdr->data_in != NULL)
|
||||
Stream_Free(rdpdr->data_in, TRUE);
|
||||
|
||||
rdpdr->data_in = Stream_New(NULL, totalLength);
|
||||
@ -887,7 +898,7 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
|
||||
{
|
||||
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_event_data_received: read error\n");
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_event_data_received: read error");
|
||||
}
|
||||
|
||||
rdpdr->data_in = NULL;
|
||||
@ -907,7 +918,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle, UINT ev
|
||||
|
||||
if (!rdpdr)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_open_event: error no match\n");
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_open_event: error no match");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -920,6 +931,9 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle, UINT ev
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,7 +978,8 @@ static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_event_connected: open failed: status: %d\n", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -974,23 +989,27 @@ static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa
|
||||
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0, NULL);
|
||||
}
|
||||
|
||||
static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
|
||||
static void rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
if (rdpdr->queue)
|
||||
{
|
||||
MessageQueue_PostQuit(rdpdr->queue, 0);
|
||||
WaitForSingleObject(rdpdr->thread, INFINITE);
|
||||
UINT rc;
|
||||
|
||||
MessageQueue_Free(rdpdr->queue);
|
||||
rdpdr->queue = NULL;
|
||||
MessageQueue_PostQuit(rdpdr->queue, 0);
|
||||
WaitForSingleObject(rdpdr->thread, INFINITE);
|
||||
|
||||
CloseHandle(rdpdr->thread);
|
||||
rdpdr->thread = NULL;
|
||||
}
|
||||
MessageQueue_Free(rdpdr->queue);
|
||||
CloseHandle(rdpdr->thread);
|
||||
|
||||
rdpdr->queue = NULL;
|
||||
rdpdr->thread = NULL;
|
||||
|
||||
drive_hotplug_thread_terminate(rdpdr);
|
||||
|
||||
rdpdr->channelEntryPoints.pVirtualChannelClose(rdpdr->OpenHandle);
|
||||
rc = rdpdr->channelEntryPoints.pVirtualChannelClose(rdpdr->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
if (rdpdr->data_in)
|
||||
{
|
||||
@ -1005,6 +1024,10 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
rdpdr_remove_open_handle_data(rdpdr->OpenHandle);
|
||||
}
|
||||
|
||||
static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
rdpdr_remove_init_handle_data(rdpdr->InitHandle);
|
||||
|
||||
free(rdpdr);
|
||||
@ -1029,6 +1052,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle, UINT
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
rdpdr_virtual_channel_event_disconnected(rdpdr);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -1042,6 +1066,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle, UINT
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
rdpdrPlugin* rdpdr;
|
||||
|
||||
rdpdr = (rdpdrPlugin*) calloc(1, sizeof(rdpdrPlugin));
|
||||
@ -1060,8 +1085,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle,
|
||||
rc = rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle,
|
||||
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpdr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rdpdr_add_init_handle_data(rdpdr->InitHandle, (void*) rdpdr);
|
||||
|
||||
|
@ -343,7 +343,7 @@ int rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
||||
Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
|
||||
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
|
||||
|
||||
WLog_Print(gfx->log, WLOG_DEBUG, "RecvStartFramePdu: frameId: %d timestamp: 0x%04X\n",
|
||||
WLog_Print(gfx->log, WLOG_DEBUG, "RecvStartFramePdu: frameId: %d timestamp: 0x%04X",
|
||||
pdu.frameId, pdu.timestamp);
|
||||
|
||||
if (context && context->StartFrame)
|
||||
@ -368,7 +368,7 @@ int rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
||||
|
||||
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
|
||||
|
||||
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEndFramePdu: frameId: %d\n", pdu.frameId);
|
||||
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEndFramePdu: frameId: %d", pdu.frameId);
|
||||
|
||||
if (context && context->EndFrame)
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ struct rdpsnd_plugin
|
||||
wMessagePipe* MsgPipe;
|
||||
|
||||
wLog* log;
|
||||
HANDLE stopEvent;
|
||||
HANDLE ScheduleThread;
|
||||
|
||||
BYTE cBlockNo;
|
||||
@ -104,12 +105,13 @@ static void* rdpsnd_schedule_thread(void* arg)
|
||||
UINT16 wCurrentTime;
|
||||
RDPSND_WAVE* wave;
|
||||
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
|
||||
HANDLE events[2];
|
||||
|
||||
while (1)
|
||||
events[0] = MessageQueue_Event(rdpsnd->MsgPipe->Out);
|
||||
events[1] = rdpsnd->stopEvent;
|
||||
|
||||
while (WaitForMultipleObjects(2, events, FALSE, INFINITE) == WAIT_OBJECT_0)
|
||||
{
|
||||
if (!MessageQueue_Wait(rdpsnd->MsgPipe->Out))
|
||||
break;
|
||||
|
||||
if (!MessageQueue_Peek(rdpsnd->MsgPipe->Out, &message, TRUE))
|
||||
break;
|
||||
|
||||
@ -132,6 +134,7 @@ static void* rdpsnd_schedule_thread(void* arg)
|
||||
free(wave);
|
||||
}
|
||||
|
||||
ExitThread(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -151,7 +154,7 @@ void rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd)
|
||||
rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
||||
}
|
||||
|
||||
void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
{
|
||||
int index;
|
||||
AUDIO_FORMAT* serverFormat;
|
||||
@ -197,10 +200,10 @@ void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
#if 0
|
||||
WLog_ERR(TAG, "Server ");
|
||||
rdpsnd_print_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
||||
WLog_ERR(TAG, "\n");
|
||||
WLog_ERR(TAG, "");
|
||||
WLog_ERR(TAG, "Client ");
|
||||
rdpsnd_print_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
|
||||
WLog_ERR(TAG, "\n");
|
||||
WLog_ERR(TAG, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -543,7 +546,7 @@ static void rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
Stream_Seek_UINT8(s); /* bPad */
|
||||
Stream_Read_UINT16(s, BodySize);
|
||||
|
||||
//WLog_ERR(TAG, "msgType %d BodySize %d\n", msgType, BodySize);
|
||||
//WLog_ERR(TAG, "msgType %d BodySize %d", msgType, BodySize);
|
||||
|
||||
switch (msgType)
|
||||
{
|
||||
@ -800,18 +803,29 @@ static void rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if (!rdpsnd->device->DisableConfirmThread)
|
||||
{
|
||||
rdpsnd->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
rdpsnd->ScheduleThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_schedule_thread,
|
||||
(void*) rdpsnd, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void rdpsnd_process_disconnect(rdpsndPlugin* rdpsnd)
|
||||
{
|
||||
if (rdpsnd->ScheduleThread)
|
||||
{
|
||||
SetEvent(rdpsnd->stopEvent);
|
||||
WaitForSingleObject(rdpsnd->ScheduleThread, INFINITE);
|
||||
CloseHandle(rdpsnd->ScheduleThread);
|
||||
CloseHandle(rdpsnd->stopEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rdpsnd_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -831,6 +845,11 @@ void* rdpsnd_get_init_handle_data(void* pInitHandle)
|
||||
void rdpsnd_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void rdpsnd_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -855,6 +874,11 @@ void rdpsnd_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
@ -874,7 +898,8 @@ int rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_write: VirtualChannelWrite failed %d\n", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -906,7 +931,7 @@ static void rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
|
||||
{
|
||||
if (Stream_Capacity(s) != Stream_GetPosition(s))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_data_received: read error\n");
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_data_received: read error");
|
||||
}
|
||||
|
||||
plugin->data_in = NULL;
|
||||
@ -926,7 +951,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle, UINT e
|
||||
|
||||
if (!rdpsnd)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_open_event: error no match");
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_open_event: error no match");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -939,6 +964,9 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle, UINT e
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -968,12 +996,7 @@ static void* rdpsnd_virtual_channel_client_thread(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (rdpsnd->ScheduleThread)
|
||||
{
|
||||
WaitForSingleObject(rdpsnd->ScheduleThread, INFINITE);
|
||||
CloseHandle(rdpsnd->ScheduleThread);
|
||||
rdpsnd->ScheduleThread = NULL;
|
||||
}
|
||||
rdpsnd_process_disconnect(rdpsnd);
|
||||
|
||||
ExitThread(0);
|
||||
return NULL;
|
||||
@ -990,7 +1013,8 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_connected: open failed: status: %d\n", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1000,46 +1024,63 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_virtual_channel_client_thread, (void*) plugin, 0, NULL);
|
||||
}
|
||||
|
||||
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||
static void rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
||||
{
|
||||
if (rdpsnd->MsgPipe)
|
||||
UINT rc;
|
||||
|
||||
MessagePipe_PostQuit(rdpsnd->MsgPipe, 0);
|
||||
WaitForSingleObject(rdpsnd->thread, INFINITE);
|
||||
|
||||
CloseHandle(rdpsnd->thread);
|
||||
rdpsnd->thread = NULL;
|
||||
|
||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelClose(rdpsnd->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessagePipe_PostQuit(rdpsnd->MsgPipe, 0);
|
||||
WaitForSingleObject(rdpsnd->thread, INFINITE);
|
||||
|
||||
MessagePipe_Free(rdpsnd->MsgPipe);
|
||||
rdpsnd->MsgPipe = NULL;
|
||||
|
||||
CloseHandle(rdpsnd->thread);
|
||||
rdpsnd->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
rdpsnd->channelEntryPoints.pVirtualChannelClose(rdpsnd->OpenHandle);
|
||||
|
||||
if (rdpsnd->data_in)
|
||||
{
|
||||
Stream_Free(rdpsnd->data_in, TRUE);
|
||||
rdpsnd->data_in = NULL;
|
||||
}
|
||||
|
||||
if (rdpsnd->device)
|
||||
IFCALL(rdpsnd->device->Free, rdpsnd->device);
|
||||
|
||||
free(rdpsnd->subsystem);
|
||||
rdpsnd->subsystem = NULL;
|
||||
|
||||
free(rdpsnd->device_name);
|
||||
rdpsnd->device_name = NULL;
|
||||
|
||||
rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
||||
rdpsnd->NumberOfServerFormats = 0;
|
||||
rdpsnd->ServerFormats = NULL;
|
||||
MessagePipe_Free(rdpsnd->MsgPipe);
|
||||
rdpsnd->MsgPipe = NULL;
|
||||
|
||||
rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
|
||||
rdpsnd->NumberOfClientFormats = 0;
|
||||
rdpsnd->ClientFormats = NULL;
|
||||
|
||||
rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
||||
rdpsnd->NumberOfServerFormats = 0;
|
||||
rdpsnd->ServerFormats = NULL;
|
||||
|
||||
if (rdpsnd->device)
|
||||
{
|
||||
IFCALL(rdpsnd->device->Free, rdpsnd->device);
|
||||
rdpsnd->device = NULL;
|
||||
}
|
||||
|
||||
if (rdpsnd->subsystem)
|
||||
{
|
||||
free(rdpsnd->subsystem);
|
||||
rdpsnd->subsystem = NULL;
|
||||
}
|
||||
|
||||
if (rdpsnd->device_name)
|
||||
{
|
||||
free(rdpsnd->device_name);
|
||||
rdpsnd->device_name = NULL;
|
||||
}
|
||||
|
||||
rdpsnd_remove_open_handle_data(rdpsnd->OpenHandle);
|
||||
}
|
||||
|
||||
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||
{
|
||||
rdpsnd_remove_init_handle_data(rdpsnd->InitHandle);
|
||||
|
||||
free(rdpsnd);
|
||||
@ -1053,7 +1094,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_init_event: error no match\n");
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_init_event: error no match");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1064,6 +1105,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
rdpsnd_virtual_channel_event_disconnected(plugin);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -1077,6 +1119,8 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
|
||||
rdpsndPlugin* rdpsnd;
|
||||
|
||||
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
|
||||
@ -1102,8 +1146,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||
|
||||
rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpsnd_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpsnd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rdpsnd_add_init_handle_data(rdpsnd->InitHandle, (void*) rdpsnd);
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO
|
||||
switch (uMsg)
|
||||
{
|
||||
case MM_WOM_OPEN:
|
||||
WLog_ERR(TAG, "MM_WOM_OPEN\n");
|
||||
WLog_ERR(TAG, "MM_WOM_OPEN");
|
||||
break;
|
||||
|
||||
case MM_WOM_CLOSE:
|
||||
WLog_ERR(TAG, "MM_WOM_CLOSE\n");
|
||||
WLog_ERR(TAG, "MM_WOM_CLOSE");
|
||||
break;
|
||||
|
||||
case MM_WOM_DONE:
|
||||
@ -122,7 +122,7 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO
|
||||
if (!wave)
|
||||
return;
|
||||
|
||||
WLog_ERR(TAG, "MM_WOM_DONE: dwBufferLength: %d cBlockNo: %d\n",
|
||||
WLog_ERR(TAG, "MM_WOM_DONE: dwBufferLength: %d cBlockNo: %d",
|
||||
lpWaveHdr->dwBufferLength, wave->cBlockNo);
|
||||
wave->wLocalTimeB = GetTickCount();
|
||||
wTimeDelta = wave->wLocalTimeB - wave->wLocalTimeA;
|
||||
@ -155,7 +155,7 @@ static void rdpsnd_winmm_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format,
|
||||
|
||||
if (mmResult != MMSYSERR_NOERROR)
|
||||
{
|
||||
WLog_ERR(TAG, "waveOutOpen failed: %d\n", mmResult);
|
||||
WLog_ERR(TAG, "waveOutOpen failed: %d", mmResult);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device)
|
||||
|
||||
if (mmResult != MMSYSERR_NOERROR)
|
||||
{
|
||||
WLog_ERR(TAG, "waveOutClose failure: %d\n", mmResult);
|
||||
WLog_ERR(TAG, "waveOutClose failure: %d", mmResult);
|
||||
}
|
||||
|
||||
winmm->hWaveOut = NULL;
|
||||
@ -299,7 +299,7 @@ void rdpsnd_winmm_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
|
||||
|
||||
if (mmResult != MMSYSERR_NOERROR)
|
||||
{
|
||||
WLog_ERR(TAG, "waveOutPrepareHeader failure: %d\n", mmResult);
|
||||
WLog_ERR(TAG, "waveOutPrepareHeader failure: %d", mmResult);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ void rdpsnd_winmm_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
|
||||
|
||||
if (mmResult != MMSYSERR_NOERROR)
|
||||
{
|
||||
WLog_ERR(TAG, "waveOutWrite failure: %d\n", mmResult);
|
||||
WLog_ERR(TAG, "waveOutWrite failure: %d", mmResult);
|
||||
waveOutUnprepareHeader(winmm->hWaveOut, lpWaveHdr, sizeof(WAVEHDR));
|
||||
return;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ static BOOL rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStrea
|
||||
|
||||
Stream_Read_UINT16(s, quality);
|
||||
Stream_Seek_UINT16(s); // reserved
|
||||
WLog_ERR(TAG, "Client requested sound quality: %#0X\n", quality);
|
||||
WLog_ERR(TAG, "Client requested sound quality: %#0X", quality);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ static BOOL rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
|
||||
|
||||
if (!context->num_client_formats)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: client doesn't support any format!\n", __FUNCTION__);
|
||||
WLog_ERR(TAG, "client doesn't support any format!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ static BOOL rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s)
|
||||
|
||||
if (!context->num_client_formats)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: client doesn't support any known format!\n", __FUNCTION__);
|
||||
WLog_ERR(TAG, "client doesn't support any known format!");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ static BOOL rdpsnd_server_select_format(RdpsndServerContext* context, int client
|
||||
|
||||
if (client_format_index < 0 || client_format_index >= context->num_client_formats)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: index %d is not correct.\n", __FUNCTION__, client_format_index);
|
||||
WLog_ERR(TAG, "index %d is not correct.", client_format_index);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ static BOOL rdpsnd_server_select_format(RdpsndServerContext* context, int client
|
||||
|
||||
if (format->nSamplesPerSec == 0)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: invalid Client Sound Format!!\n", __FUNCTION__);
|
||||
WLog_ERR(TAG, "invalid Client Sound Format!!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -476,8 +476,8 @@ static int rdpsnd_server_start(RdpsndServerContext* context)
|
||||
|
||||
if (!WTSVirtualChannelQuery(priv->ChannelHandle, WTSVirtualEventHandle, &buffer, &bytesReturned) || (bytesReturned != sizeof(HANDLE)))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%d)\n",
|
||||
__FUNCTION__, bytesReturned);
|
||||
WLog_ERR(TAG, "error during WTSVirtualChannelQuery(WTSVirtualEventHandle) or invalid returned size(%d)",
|
||||
bytesReturned);
|
||||
|
||||
if (buffer)
|
||||
WTSFreeMemory(buffer);
|
||||
@ -527,9 +527,13 @@ static int rdpsnd_server_stop(RdpsndServerContext* context)
|
||||
|
||||
WaitForSingleObject(context->priv->Thread, INFINITE);
|
||||
CloseHandle(context->priv->Thread);
|
||||
CloseHandle(context->priv->StopEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (context->priv->rdpsnd_pdu)
|
||||
Stream_Free(context->priv->rdpsnd_pdu, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -591,24 +595,18 @@ void rdpsnd_server_context_reset(RdpsndServerContext *context)
|
||||
|
||||
void rdpsnd_server_context_free(RdpsndServerContext* context)
|
||||
{
|
||||
if (!context->priv->StopEvent)
|
||||
{
|
||||
SetEvent(context->priv->StopEvent);
|
||||
WaitForSingleObject(context->priv->Thread, INFINITE);
|
||||
}
|
||||
|
||||
if (context->priv->ChannelHandle)
|
||||
WTSVirtualChannelClose(context->priv->ChannelHandle);
|
||||
|
||||
if (context->priv->rdpsnd_pdu)
|
||||
Stream_Free(context->priv->rdpsnd_pdu, TRUE);
|
||||
|
||||
if (context->priv->out_buffer)
|
||||
free(context->priv->out_buffer);
|
||||
|
||||
if (context->priv->dsp_context)
|
||||
freerdp_dsp_context_free(context->priv->dsp_context);
|
||||
|
||||
if (context->priv->input_stream)
|
||||
Stream_Free(context->priv->input_stream, TRUE);
|
||||
|
||||
if (context->client_formats)
|
||||
free(context->client_formats);
|
||||
|
||||
@ -642,7 +640,7 @@ int rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
return -1;
|
||||
|
||||
WLog_ERR(TAG, "%s: channel connection closed\n", __FUNCTION__);
|
||||
WLog_ERR(TAG, "channel connection closed");
|
||||
return 0;
|
||||
}
|
||||
priv->expectedBytes -= bytesReturned;
|
||||
@ -699,7 +697,7 @@ int rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "%s: UNKOWN MESSAGE TYPE!! (%#0X)\n\n", __FUNCTION__, priv->msgType);
|
||||
WLog_ERR(TAG, "UNKOWN MESSAGE TYPE!! (%#0X)", priv->msgType);
|
||||
ret = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ int remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s)
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -519,8 +520,8 @@ static void remdesk_process_connect(remdeskPlugin* remdesk)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
static wListDictionary* g_InitHandles;
|
||||
static wListDictionary* g_OpenHandles;
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void remdesk_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
@ -540,6 +541,11 @@ void* remdesk_get_init_handle_data(void* pInitHandle)
|
||||
void remdesk_remove_init_handle_data(void* pInitHandle)
|
||||
{
|
||||
ListDictionary_Remove(g_InitHandles, pInitHandle);
|
||||
if (ListDictionary_Count(g_InitHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_InitHandles);
|
||||
g_InitHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void remdesk_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
@ -564,6 +570,11 @@ void remdesk_remove_open_handle_data(DWORD openHandle)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
ListDictionary_Remove(g_OpenHandles, pOpenHandle);
|
||||
if (ListDictionary_Count(g_OpenHandles) < 1)
|
||||
{
|
||||
ListDictionary_Free(g_OpenHandles);
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int remdesk_send(remdeskPlugin* remdesk, wStream* s)
|
||||
@ -584,7 +595,8 @@ int remdesk_send(remdeskPlugin* remdesk, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -649,6 +661,9 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event(DWORD openHandle, UINT
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,7 +708,8 @@ static void remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -703,22 +719,26 @@ static void remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO
|
||||
(LPTHREAD_START_ROUTINE) remdesk_virtual_channel_client_thread, (void*) remdesk, 0, NULL);
|
||||
}
|
||||
|
||||
static void remdesk_virtual_channel_event_terminated(remdeskPlugin* remdesk)
|
||||
static void remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk)
|
||||
{
|
||||
if (remdesk->queue)
|
||||
UINT rc;
|
||||
|
||||
MessageQueue_PostQuit(remdesk->queue, 0);
|
||||
WaitForSingleObject(remdesk->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(remdesk->queue);
|
||||
CloseHandle(remdesk->thread);
|
||||
|
||||
remdesk->queue = NULL;
|
||||
remdesk->thread = NULL;
|
||||
|
||||
rc = remdesk->channelEntryPoints.pVirtualChannelClose(remdesk->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
MessageQueue_PostQuit(remdesk->queue, 0);
|
||||
WaitForSingleObject(remdesk->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(remdesk->queue);
|
||||
remdesk->queue = NULL;
|
||||
|
||||
CloseHandle(remdesk->thread);
|
||||
remdesk->thread = NULL;
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
remdesk->channelEntryPoints.pVirtualChannelClose(remdesk->OpenHandle);
|
||||
|
||||
if (remdesk->data_in)
|
||||
{
|
||||
Stream_Free(remdesk->data_in, TRUE);
|
||||
@ -726,9 +746,11 @@ static void remdesk_virtual_channel_event_terminated(remdeskPlugin* remdesk)
|
||||
}
|
||||
|
||||
remdesk_remove_open_handle_data(remdesk->OpenHandle);
|
||||
remdesk_remove_init_handle_data(remdesk->InitHandle);
|
||||
}
|
||||
|
||||
free(remdesk->context);
|
||||
static void remdesk_virtual_channel_event_terminated(remdeskPlugin* remdesk)
|
||||
{
|
||||
remdesk_remove_init_handle_data(remdesk->InitHandle);
|
||||
|
||||
free(remdesk);
|
||||
}
|
||||
@ -752,6 +774,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
remdesk_virtual_channel_event_disconnected(remdesk);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -765,6 +788,8 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
|
||||
remdeskPlugin* remdesk;
|
||||
RemdeskClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -799,8 +824,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(remdesk->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
remdesk->channelEntryPoints.pVirtualChannelInit(&remdesk->InitHandle,
|
||||
rc = remdesk->channelEntryPoints.pVirtualChannelInit(&remdesk->InitHandle,
|
||||
&remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, remdesk_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(remdesk);
|
||||
return -1;
|
||||
}
|
||||
|
||||
remdesk->channelEntryPoints.pInterface = *(remdesk->channelEntryPoints.ppInterface);
|
||||
remdesk->channelEntryPoints.ppInterface = &(remdesk->channelEntryPoints.pInterface);
|
||||
|
@ -227,7 +227,7 @@ UINT32 smartcard_unpack_redir_scard_context(SMARTCARD_DEVICE* smartcard, wStream
|
||||
|
||||
if ((context->cbContext != 0) && (context->cbContext != 4) && (context->cbContext != 8))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length is not 0, 4 or 8: %d\n", context->cbContext);
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length is not 0, 4 or 8: %d", context->cbContext);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ UINT32 smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wSt
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
@ -280,20 +280,20 @@ UINT32 smartcard_unpack_redir_scard_context_ref(SMARTCARD_DEVICE* smartcard, wSt
|
||||
|
||||
if (length != context->cbContext)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length (%d) cbContext (%d) mismatch\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length (%d) cbContext (%d) mismatch",
|
||||
length, context->cbContext);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((context->cbContext != 0) && (context->cbContext != 4) && (context->cbContext != 8))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length is not 4 or 8: %d\n", context->cbContext);
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT length is not 4 or 8: %d", context->cbContext);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Stream_GetRemainingLength(s) < context->cbContext)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDCONTEXT is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), context->cbContext);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
@ -363,7 +363,7 @@ UINT32 smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStr
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
@ -372,20 +372,20 @@ UINT32 smartcard_unpack_redir_scard_handle_ref(SMARTCARD_DEVICE* smartcard, wStr
|
||||
|
||||
if (length != handle->cbHandle)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE length (%d) cbHandle (%d) mismatch\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE length (%d) cbHandle (%d) mismatch",
|
||||
length, handle->cbHandle);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((handle->cbHandle != 4) && (handle->cbHandle != 8))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE length is not 4 or 8: %d\n", handle->cbHandle);
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE length is not 4 or 8: %d", handle->cbHandle);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Stream_GetRemainingLength(s) < handle->cbHandle) || (!handle->cbHandle))
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "REDIR_SCARDHANDLE is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), handle->cbHandle);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
@ -410,7 +410,7 @@ UINT32 smartcard_unpack_establish_context_call(SMARTCARD_DEVICE* smartcard, wStr
|
||||
{
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
{
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "EstablishContext_Call is too short: Actual: %d, Expected: %d\n",
|
||||
WLog_Print(smartcard->log, WLOG_WARN, "EstablishContext_Call is too short: Actual: %d, Expected: %d",
|
||||
(int) Stream_GetRemainingLength(s), 4);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ int android_context_new(freerdp* instance, rdpContext* context)
|
||||
|
||||
void android_context_free(freerdp* instance, rdpContext* context)
|
||||
{
|
||||
freerdp_channels_close(instance->context->channels, instance);
|
||||
freerdp_channels_free(context->channels);
|
||||
android_event_queue_uninit(instance);
|
||||
}
|
||||
@ -541,7 +542,7 @@ static int android_freerdp_run(freerdp* instance)
|
||||
freerdp_callback("OnDisconnecting", "(I)V", instance);
|
||||
|
||||
DEBUG_ANDROID("Close channels...");
|
||||
freerdp_channels_close(instance->context->channels, instance);
|
||||
freerdp_channels_disconnect(instance->context->channels, instance);
|
||||
|
||||
DEBUG_ANDROID("Cleanup threads...");
|
||||
|
||||
|
@ -404,6 +404,9 @@ int dfreerdp_run(freerdp* instance)
|
||||
df_process_channel_event(channels, instance);
|
||||
}
|
||||
|
||||
freerdp_channels_disconnect(channels, instance);
|
||||
freerdp_disconnect(instance);
|
||||
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_free(channels);
|
||||
df_free(dfi);
|
||||
|
@ -212,6 +212,9 @@ int tfreerdp_run(freerdp* instance)
|
||||
}
|
||||
}
|
||||
|
||||
freerdp_channels_disconnect(channels, instance);
|
||||
freerdp_disconnect(instance);
|
||||
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_free(channels);
|
||||
freerdp_free(instance);
|
||||
|
@ -245,6 +245,9 @@ int wlfreerdp_run(freerdp* instance)
|
||||
wlf_DestroyInput(context, context->input);
|
||||
wlf_DestroyDisplay(context, context->display);
|
||||
|
||||
freerdp_channels_disconnect(instance->context->channels, instance);
|
||||
freerdp_disconnect(instance);
|
||||
|
||||
freerdp_channels_close(instance->context->channels, instance);
|
||||
freerdp_channels_free(instance->context->channels);
|
||||
freerdp_free(instance);
|
||||
|
@ -854,7 +854,7 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam)
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_disconnect(channels, instance);
|
||||
|
||||
if (async_input)
|
||||
{
|
||||
@ -1134,9 +1134,12 @@ int wfreerdp_client_new(freerdp* instance, rdpContext* context)
|
||||
|
||||
void wfreerdp_client_free(freerdp* instance, rdpContext* context)
|
||||
{
|
||||
rdpChannels *channels = context->channels;
|
||||
|
||||
if (context->cache)
|
||||
cache_free(context->cache);
|
||||
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_free(context->channels);
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
switch (Msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
DEBUG_CLIPRDR("info: %s - WM_CREATE", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_CREATE");
|
||||
clipboard = (wfClipboard*)((CREATESTRUCT*) lParam)->lpCreateParams;
|
||||
if (!AddClipboardFormatListener(hWnd)) {
|
||||
DEBUG_CLIPRDR("error: AddClipboardFormatListener failed with %#x.", GetLastError());
|
||||
@ -1082,12 +1082,12 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
DEBUG_CLIPRDR("info: %s - WM_CLOSE", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_CLOSE");
|
||||
RemoveClipboardFormatListener(hWnd);
|
||||
break;
|
||||
|
||||
case WM_CLIPBOARDUPDATE:
|
||||
DEBUG_CLIPRDR("info: %s - WM_CLIPBOARDUPDATE", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_CLIPBOARDUPDATE");
|
||||
if (clipboard->sync)
|
||||
{
|
||||
if ((GetClipboardOwner() != clipboard->hwnd) &&
|
||||
@ -1105,7 +1105,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
break;
|
||||
|
||||
case WM_RENDERALLFORMATS:
|
||||
DEBUG_CLIPRDR("info: %s - WM_RENDERALLFORMATS", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_RENDERALLFORMATS");
|
||||
/* discard all contexts in clipboard */
|
||||
if (!OpenClipboard(clipboard->hwnd))
|
||||
{
|
||||
@ -1117,7 +1117,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
break;
|
||||
|
||||
case WM_RENDERFORMAT:
|
||||
DEBUG_CLIPRDR("info: %s - WM_RENDERFORMAT", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_RENDERFORMAT");
|
||||
if (cliprdr_send_data_request(clipboard, (UINT32) wParam) != 0)
|
||||
{
|
||||
DEBUG_CLIPRDR("error: cliprdr_send_data_request failed.");
|
||||
@ -1138,11 +1138,11 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
break;
|
||||
|
||||
case WM_CLIPRDR_MESSAGE:
|
||||
DEBUG_CLIPRDR("info: %s - WM_CLIPRDR_MESSAGE", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: WM_CLIPRDR_MESSAGE");
|
||||
switch (wParam)
|
||||
{
|
||||
case OLE_SETCLIPBOARD:
|
||||
DEBUG_CLIPRDR("info: %s - OLE_SETCLIPBOARD", __FUNCTION__);
|
||||
DEBUG_CLIPRDR("info: OLE_SETCLIPBOARD");
|
||||
if (wf_create_file_obj(clipboard, &clipboard->data_obj))
|
||||
{
|
||||
if (OleSetClipboard(clipboard->data_obj) != S_OK)
|
||||
|
@ -788,6 +788,7 @@ int _xf_error_handler(Display* d, XErrorEvent* ev)
|
||||
static void xf_post_disconnect(freerdp* instance)
|
||||
{
|
||||
xfContext* xfc;
|
||||
rdpChannels* channels = channels = instance->context->channels;
|
||||
|
||||
if (!instance || !instance->context || !instance->settings)
|
||||
return;
|
||||
@ -924,7 +925,6 @@ BOOL xf_pre_connect(freerdp* instance)
|
||||
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
|
||||
(pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler);
|
||||
|
||||
freerdp_client_load_addins(channels, instance->settings);
|
||||
freerdp_channels_pre_connect(channels, instance);
|
||||
|
||||
if (!settings->Username)
|
||||
@ -1638,7 +1638,7 @@ void* xf_thread(void *param)
|
||||
}
|
||||
/* Close the channels first. This will signal the internal message pipes
|
||||
* that the threads should quit. */
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_disconnect(channels, instance);
|
||||
|
||||
if (async_input)
|
||||
{
|
||||
@ -1812,6 +1812,7 @@ static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
|
||||
settings = instance->settings;
|
||||
xfc->settings = instance->context->settings;
|
||||
|
||||
freerdp_client_load_addins(context->channels, instance->settings);
|
||||
PubSub_SubscribeTerminate(context->pubSub, (pTerminateEventHandler) xf_TerminateEventHandler);
|
||||
|
||||
#ifdef WITH_XRENDER
|
||||
@ -1838,6 +1839,7 @@ static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
|
||||
|
||||
if (context->channels)
|
||||
{
|
||||
freerdp_channels_close(context->channels, instance);
|
||||
freerdp_channels_free(context->channels);
|
||||
context->channels = NULL;
|
||||
}
|
||||
|
@ -2012,6 +2012,7 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
|
||||
UINT32 index;
|
||||
ADDIN_ARGV* args;
|
||||
|
||||
settings->DynamicChannelCount = 0;
|
||||
if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) ||
|
||||
(freerdp_dynamic_channel_collection_find(settings, "tsmf")))
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ int ios_run_freerdp(freerdp* instance)
|
||||
mfi->connection_state = TSXConnectionDisconnected;
|
||||
|
||||
// Cleanup
|
||||
freerdp_channels_close(channels, instance);
|
||||
freerdp_channels_disconnect(channels, instance);
|
||||
freerdp_disconnect(instance);
|
||||
gdi_free(instance);
|
||||
cache_free(instance->context->cache);
|
||||
@ -252,6 +252,7 @@ int ios_context_new(freerdp* instance, rdpContext* context)
|
||||
void ios_context_free(freerdp* instance, rdpContext* context)
|
||||
{
|
||||
mfInfo* mfi = ((mfContext*) context)->mfi;
|
||||
freerdp_channels_close(context->channels, instance);
|
||||
freerdp_channels_free(context->channels);
|
||||
ios_events_free_pipe(mfi);
|
||||
free(mfi);
|
||||
|
@ -35,11 +35,12 @@ extern "C" {
|
||||
FREERDP_API rdpChannels* freerdp_channels_new(void);
|
||||
FREERDP_API void freerdp_channels_free(rdpChannels* channels);
|
||||
FREERDP_API int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings,
|
||||
void* entry, void* data);
|
||||
PVIRTUALCHANNELENTRY entry, void* data);
|
||||
FREERDP_API int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings,
|
||||
const char* name, void* data);
|
||||
FREERDP_API int freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance);
|
||||
FREERDP_API int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance);
|
||||
FREERDP_API int freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance);
|
||||
FREERDP_API BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** read_fds,
|
||||
int* read_count, void** write_fds, int* write_count);
|
||||
FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance);
|
||||
|
@ -169,7 +169,7 @@ int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
|
||||
subcodecByteCount = *((UINT32*) &pSrcData[offset + 8]);
|
||||
offset += 12;
|
||||
|
||||
//WLog_DBG(TAG, "residualByteCount: %d bandsByteCount: %d subcodecByteCount: %d\n",
|
||||
//WLog_DBG(TAG, "residualByteCount: %d bandsByteCount: %d subcodecByteCount: %d",
|
||||
// residualByteCount, bandsByteCount, subcodecByteCount);
|
||||
|
||||
if (residualByteCount > 0)
|
||||
@ -554,7 +554,7 @@ int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
|
||||
subcodecId = subcodecs[suboffset + 12];
|
||||
suboffset += 13;
|
||||
|
||||
//WLog_DBG(TAG, "bitmapDataByteCount: %d subcodecByteCount: %d suboffset: %d subCodecId: %d\n",
|
||||
//WLog_DBG(TAG, "bitmapDataByteCount: %d subcodecByteCount: %d suboffset: %d subCodecId: %d",
|
||||
// bitmapDataByteCount, subcodecByteCount, suboffset, subcodecId);
|
||||
|
||||
if ((subcodecByteCount - suboffset) < bitmapDataByteCount)
|
||||
|
@ -1045,7 +1045,7 @@ BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data,
|
||||
|
||||
context->rlePlanes[3] = &context->rlePlanesBuffer[offset];
|
||||
offset += dstSizes[3];
|
||||
//WLog_DBG(TAG, "R: [%d/%d] G: [%d/%d] B: [%d/%d]\n",
|
||||
//WLog_DBG(TAG, "R: [%d/%d] G: [%d/%d] B: [%d/%d]",
|
||||
// dstSizes[1], planeSize, dstSizes[2], planeSize, dstSizes[3], planeSize);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void region16_print(const REGION16 *region)
|
||||
if (rects->top != currentBandY)
|
||||
{
|
||||
currentBandY = rects->top;
|
||||
WLog_DBG(TAG, "\nband %d: ", currentBandY);
|
||||
WLog_DBG(TAG, "band %d: ", currentBandY);
|
||||
}
|
||||
|
||||
WLog_DBG(TAG, "(%d,%d-%d,%d)", rects->left, rects->top, rects->right, rects->bottom);
|
||||
|
@ -572,7 +572,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
if (Stream_GetRemainingLength(s) < certLength)
|
||||
return FALSE;
|
||||
|
||||
DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength);
|
||||
DEBUG_CERTIFICATE("X.509 Certificate #%d, length:%d", i + 1, certLength);
|
||||
certificate->x509_cert_chain->array[i].data = (BYTE*) malloc(certLength);
|
||||
|
||||
if (!certificate->x509_cert_chain->array[i].data)
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.client")
|
||||
|
||||
static void* g_pInterface;
|
||||
static void* g_pInterface = NULL;
|
||||
static CHANNEL_INIT_DATA g_ChannelInitData;
|
||||
|
||||
static wHashTable* g_OpenHandles = NULL;
|
||||
@ -98,12 +98,34 @@ rdpChannels* freerdp_channels_new(void)
|
||||
|
||||
void freerdp_channels_free(rdpChannels* channels)
|
||||
{
|
||||
int index;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
|
||||
if (channels->queue)
|
||||
{
|
||||
MessageQueue_Free(channels->queue);
|
||||
channels->queue = NULL;
|
||||
}
|
||||
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
pChannelOpenData = &channels->openDataList[index];
|
||||
|
||||
if (pChannelOpenData->pInterface)
|
||||
{
|
||||
free(pChannelOpenData->pInterface);
|
||||
pChannelOpenData->pInterface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_OpenHandles)
|
||||
{
|
||||
HashTable_Free(g_OpenHandles);
|
||||
DeleteCriticalSection(&g_channels_lock);
|
||||
|
||||
g_OpenHandles = NULL;
|
||||
}
|
||||
|
||||
free(channels);
|
||||
}
|
||||
|
||||
@ -376,7 +398,7 @@ BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
|
||||
int freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance)
|
||||
{
|
||||
int index;
|
||||
char* name;
|
||||
@ -392,6 +414,10 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
|
||||
ChannelDisconnectedEventArgs e;
|
||||
|
||||
pChannelClientData = &channels->clientDataList[index];
|
||||
|
||||
if (pChannelClientData->pChannelInitEventProc)
|
||||
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_DISCONNECTED, 0, 0);
|
||||
|
||||
pChannelOpenData = &channels->openDataList[index];
|
||||
|
||||
name = (char*) malloc(9);
|
||||
@ -404,6 +430,22 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
|
||||
PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e);
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
|
||||
{
|
||||
int index;
|
||||
CHANNEL_CLIENT_DATA* pChannelClientData;
|
||||
|
||||
freerdp_channels_check_fds(channels, instance);
|
||||
|
||||
/* tell all libraries we are shutting down */
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
pChannelClientData = &channels->clientDataList[index];
|
||||
|
||||
if (pChannelClientData->pChannelInitEventProc)
|
||||
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
|
||||
@ -600,7 +642,7 @@ UINT VCAPITYPE FreeRDP_VirtualChannelWrite(DWORD openHandle, LPVOID pData, ULONG
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, void* entry, void* data)
|
||||
int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, PVIRTUALCHANNELENTRY entry, void* data)
|
||||
{
|
||||
int status;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP EntryPoints;
|
||||
@ -608,12 +650,12 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
|
||||
|
||||
if (channels->clientDataCount + 1 >= CHANNEL_MAX_COUNT)
|
||||
{
|
||||
WLog_ERR(TAG, "error: too many channels");
|
||||
WLog_ERR(TAG, "error: too many channels");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pChannelClientData = &channels->clientDataList[channels->clientDataCount];
|
||||
pChannelClientData->entry = (PVIRTUALCHANNELENTRY) entry;
|
||||
pChannelClientData->entry = entry;
|
||||
|
||||
ZeroMemory(&EntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
|
@ -755,7 +755,7 @@ BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
Stream_Read_UINT32(s, infoType); /* infoType (4 bytes) */
|
||||
|
||||
//WLog_ERR(TAG, "%s\n", INFO_TYPE_LOGON_STRINGS[infoType]);
|
||||
//WLog_ERR(TAG, "%s", INFO_TYPE_LOGON_STRINGS[infoType]);
|
||||
|
||||
switch (infoType)
|
||||
{
|
||||
|
@ -1357,6 +1357,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
WINPR_API BOOL WTSRegisterWtsApiFunctionTable(PWtsApiFunctionTable table);
|
||||
WINPR_API const CHAR* WTSErrorToString(UINT error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ ConversionResult ConvertUTF16toUTF32(
|
||||
|
||||
if (result == sourceIllegal)
|
||||
{
|
||||
WLOG_WARN(TAG, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2);
|
||||
WLOG_WARN(TAG, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x", ch, ch2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -219,13 +219,13 @@ BOOL CloseHandle(HANDLE hObject)
|
||||
|
||||
if (pNamedPipe->clientfd != -1)
|
||||
{
|
||||
//WLOG_DBG(TAG, "%s: closing clientfd %d\n", __FUNCTION__, pNamedPipe->clientfd);
|
||||
//WLOG_DBG(TAG, "closing clientfd %d", pNamedPipe->clientfd);
|
||||
close(pNamedPipe->clientfd);
|
||||
}
|
||||
|
||||
if (pNamedPipe->serverfd != -1)
|
||||
{
|
||||
//WLOG_DBG(TAG, "%s: closing serverfd %d\n", __FUNCTION__, pNamedPipe->serverfd);
|
||||
//WLOG_DBG(TAG, "closing serverfd %d", pNamedPipe->serverfd);
|
||||
close(pNamedPipe->serverfd);
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe)
|
||||
|
||||
assert(pNamedPipe->name);
|
||||
assert(g_NamedPipeServerSockets);
|
||||
//WLog_VRB(TAG, "%s: %p (%s)", __FUNCTION__, pNamedPipe, pNamedPipe->name);
|
||||
//WLog_VRB(TAG, "%p (%s)", pNamedPipe, pNamedPipe->name);
|
||||
ArrayList_Lock(g_NamedPipeServerSockets);
|
||||
|
||||
for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++)
|
||||
@ -150,8 +150,8 @@ static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe)
|
||||
|
||||
if (--baseSocket->references == 0)
|
||||
{
|
||||
//WLog_DBG(TAG, "%s: removing shared server socked resource", __FUNCTION__);
|
||||
//WLog_DBG(TAG, "%s: closing shared serverfd %d", __FUNCTION__, baseSocket->serverfd);
|
||||
//WLog_DBG(TAG, "removing shared server socked resource");
|
||||
//WLog_DBG(TAG, "closing shared serverfd %d", baseSocket->serverfd);
|
||||
ArrayList_Remove(g_NamedPipeServerSockets, baseSocket);
|
||||
close(baseSocket->serverfd);
|
||||
free(baseSocket->name);
|
||||
|
@ -105,7 +105,7 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
|
||||
|
||||
case FC_CALLBACK:
|
||||
{
|
||||
WLog_ERR(TAG, "warning: NdrpComputeConformance FC_CALLBACK unimplemented\n");
|
||||
WLog_ERR(TAG, "warning: NdrpComputeConformance FC_CALLBACK unimplemented");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ static void* thread_launcher(void* arg)
|
||||
|
||||
if (!fkt)
|
||||
{
|
||||
WLog_ERR(TAG, "Thread function argument is %p\n", fkt);
|
||||
WLog_ERR(TAG, "Thread function argument is %p", fkt);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -610,7 +610,7 @@ VOID DumpThreadHandles(void)
|
||||
ULONG_PTR *keys = NULL;
|
||||
ListDictionary_Lock(thread_list);
|
||||
int x, count = ListDictionary_GetKeys(thread_list, &keys);
|
||||
WLog_DBG(TAG, "Dumping %d elements\n", count);
|
||||
WLog_DBG(TAG, "Dumping %d elements", count);
|
||||
|
||||
for (x = 0; x < count; x++)
|
||||
{
|
||||
|
@ -555,6 +555,78 @@ DWORD WINAPI WTSGetActiveConsoleSessionId(void)
|
||||
|
||||
#endif
|
||||
|
||||
const CHAR* WTSErrorToString(UINT error)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case CHANNEL_RC_OK:
|
||||
return "CHANNEL_RC_OK";
|
||||
|
||||
case CHANNEL_RC_ALREADY_INITIALIZED:
|
||||
return "CHANNEL_RC_ALREADY_INITIALIZED";
|
||||
|
||||
case CHANNEL_RC_NOT_INITIALIZED:
|
||||
return "CHANNEL_RC_NOT_INITIALIZED";
|
||||
|
||||
case CHANNEL_RC_ALREADY_CONNECTED:
|
||||
return "CHANNEL_RC_ALREADY_CONNECTED";
|
||||
|
||||
case CHANNEL_RC_NOT_CONNECTED:
|
||||
return "CHANNEL_RC_NOT_CONNECTED";
|
||||
|
||||
case CHANNEL_RC_TOO_MANY_CHANNELS:
|
||||
return "CHANNEL_RC_TOO_MANY_CHANNELS";
|
||||
|
||||
case CHANNEL_RC_BAD_CHANNEL:
|
||||
return "CHANNEL_RC_BAD_CHANNEL";
|
||||
|
||||
case CHANNEL_RC_BAD_CHANNEL_HANDLE:
|
||||
return "CHANNEL_RC_BAD_CHANNEL_HANDLE";
|
||||
|
||||
case CHANNEL_RC_NO_BUFFER:
|
||||
return "CHANNEL_RC_NO_BUFFER";
|
||||
|
||||
case CHANNEL_RC_BAD_INIT_HANDLE:
|
||||
return "CHANNEL_RC_BAD_INIT_HANDLE";
|
||||
|
||||
case CHANNEL_RC_NOT_OPEN:
|
||||
return "CHANNEL_RC_NOT_OPEN";
|
||||
|
||||
case CHANNEL_RC_BAD_PROC:
|
||||
return "CHANNEL_RC_BAD_PROC";
|
||||
|
||||
case CHANNEL_RC_NO_MEMORY:
|
||||
return "CHANNEL_RC_NO_MEMORY";
|
||||
|
||||
case CHANNEL_RC_UNKNOWN_CHANNEL_NAME:
|
||||
return "CHANNEL_RC_UNKNOWN_CHANNEL_NAME";
|
||||
|
||||
case CHANNEL_RC_ALREADY_OPEN:
|
||||
return "CHANNEL_RC_ALREADY_OPEN";
|
||||
|
||||
case CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY:
|
||||
return "CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY";
|
||||
|
||||
case CHANNEL_RC_NULL_DATA:
|
||||
return "CHANNEL_RC_NULL_DATA";
|
||||
|
||||
case CHANNEL_RC_ZERO_LENGTH:
|
||||
return "CHANNEL_RC_ZERO_LENGTH";
|
||||
|
||||
case CHANNEL_RC_INVALID_INSTANCE:
|
||||
return "CHANNEL_RC_INVALID_INSTANCE";
|
||||
|
||||
case CHANNEL_RC_UNSUPPORTED_VERSION:
|
||||
return "CHANNEL_RC_UNSUPPORTED_VERSION";
|
||||
|
||||
case CHANNEL_RC_INITIALIZATION_ERROR:
|
||||
return "CHANNEL_RC_INITIALIZATION_ERROR";
|
||||
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WTSRegisterWtsApiFunctionTable(PWtsApiFunctionTable table)
|
||||
{
|
||||
g_WtsApi = table;
|
||||
|
Loading…
Reference in New Issue
Block a user