virtualChannel: removed static variable usage from

VirtualChannelApi
This commit is contained in:
Martin Haimberger 2016-11-23 04:17:56 -08:00
parent d29848f383
commit 7fe28a8a78
10 changed files with 91 additions and 145 deletions

View File

@ -106,7 +106,8 @@ static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
}
else
{
status = cliprdr->channelEntryPoints.pVirtualChannelWriteEx(cliprdr->InitHandle, cliprdr->OpenHandle,
status = cliprdr->channelEntryPoints.pVirtualChannelWriteEx(cliprdr->InitHandle,
cliprdr->OpenHandle,
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
}
@ -1011,7 +1012,8 @@ static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
@ -1027,8 +1029,9 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength,
totalLength, dataFlags)))
totalLength, dataFlags)))
WLog_ERR(TAG, "failed with error %lu", error);
break;
case CHANNEL_EVENT_WRITE_COMPLETE:
@ -1040,7 +1043,8 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
}
if (error && cliprdr->context->rdpcontext)
setChannelError(cliprdr->context->rdpcontext, error, "cliprdr_virtual_channel_open_event_ex reported an error");
setChannelError(cliprdr->context->rdpcontext, error,
"cliprdr_virtual_channel_open_event_ex reported an error");
}
static void* cliprdr_virtual_channel_client_thread(void* arg)
@ -1272,7 +1276,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
context->ClientFormatDataResponse = cliprdr_client_format_data_response;
context->ClientFileContentsRequest = cliprdr_client_file_contents_request;
context->ClientFileContentsResponse = cliprdr_client_file_contents_response;
*(pEntryPointsEx->ppInterface) = (void*) context;
cliprdr->context = context;
context->rdpcontext = pEntryPointsEx->context;
}
@ -1285,10 +1288,8 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
WLog_Print(cliprdr->log, WLOG_DEBUG, "VirtualChannelEntryEx");
CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
cliprdr->InitHandle = pInitHandle;
rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx((void*) cliprdr, pInitHandle,
rc = cliprdr->channelEntryPoints.pVirtualChannelInitEx(cliprdr, context, pInitHandle,
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
cliprdr_virtual_channel_init_event_ex);
@ -1296,19 +1297,11 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
{
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
WTSErrorToString(rc), rc);
if (context)
*(pEntryPointsEx->ppInterface) = NULL;
free(cliprdr->context);
free(cliprdr);
return FALSE;
}
cliprdr->channelEntryPoints.pInterface = *
(cliprdr->channelEntryPoints.ppInterface);
cliprdr->channelEntryPoints.ppInterface = &
(cliprdr->channelEntryPoints.pInterface);
cliprdr->channelEntryPoints.pInterface = context;
return TRUE;
}

View File

@ -701,13 +701,13 @@ static UINT drdynvc_send(drdynvcPlugin* drdynvc, wStream* s)
else
{
status = drdynvc->channelEntryPoints.pVirtualChannelWriteEx(drdynvc->InitHandle,
drdynvc->OpenHandle, Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
drdynvc->OpenHandle, Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
}
if (status != CHANNEL_RC_OK)
{
Stream_Free(s, TRUE);
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]", WTSErrorToString(status), status);
WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08X]", WTSErrorToString(status), status);
}
return status;
@ -799,7 +799,7 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
if (status != CHANNEL_RC_OK)
{
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08X]",
WTSErrorToString(status), status);
return status;
}
@ -832,7 +832,7 @@ static UINT drdynvc_send_capability_response(drdynvcPlugin* drdynvc)
if (status != CHANNEL_RC_OK)
{
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08X]",
WTSErrorToString(status), status);
}
@ -956,7 +956,7 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
if (status != CHANNEL_RC_OK)
{
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08X]",
WTSErrorToString(status), status);
return status;
}
@ -1053,7 +1053,7 @@ static UINT drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp,
error = drdynvc_send(drdynvc, data_out);
if (error)
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
WLog_ERR(TAG, "VirtualChannelWriteEx failed with %s [%08X]",
WTSErrorToString(error), error);
return error;
@ -1182,8 +1182,10 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength, totalLength, dataFlags)))
if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength, totalLength,
dataFlags)))
WLog_ERR(TAG, "drdynvc_virtual_channel_event_data_received failed with error %lu", error);
break;
case CHANNEL_EVENT_WRITE_COMPLETE:
@ -1240,7 +1242,8 @@ static void* drdynvc_virtual_channel_client_thread(void* arg)
}
if (error && drdynvc->rdpcontext)
setChannelError(drdynvc->rdpcontext, error, "drdynvc_virtual_channel_client_thread reported an error");
setChannelError(drdynvc->rdpcontext, error,
"drdynvc_virtual_channel_client_thread reported an error");
ExitThread((DWORD) error);
return NULL;
@ -1251,14 +1254,14 @@ static void* drdynvc_virtual_channel_client_thread(void* arg)
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVOID pData, UINT32 dataLength)
static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVOID pData,
UINT32 dataLength)
{
UINT error;
UINT32 status;
UINT32 index;
ADDIN_ARGV* args;
rdpSettings* settings;
status = drdynvc->channelEntryPoints.pVirtualChannelOpenEx(drdynvc->InitHandle,
&drdynvc->OpenHandle, drdynvc->channelDef.name, drdynvc_virtual_channel_open_event_ex);
@ -1329,7 +1332,7 @@ static UINT drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
UINT status;
if (MessageQueue_PostQuit(drdynvc->queue, 0) &&
(WaitForSingleObject(drdynvc->thread, INFINITE) == WAIT_FAILED))
(WaitForSingleObject(drdynvc->thread, INFINITE) == WAIT_FAILED))
{
status = GetLastError();
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", status);
@ -1340,8 +1343,8 @@ static UINT drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
CloseHandle(drdynvc->thread);
drdynvc->queue = NULL;
drdynvc->thread = NULL;
status = drdynvc->channelEntryPoints.pVirtualChannelCloseEx(drdynvc->InitHandle, drdynvc->OpenHandle);
status = drdynvc->channelEntryPoints.pVirtualChannelCloseEx(drdynvc->InitHandle,
drdynvc->OpenHandle);
if (status != CHANNEL_RC_OK)
{
@ -1378,7 +1381,8 @@ static UINT drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc)
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
UINT event, LPVOID pData, UINT dataLength)
{
UINT error = CHANNEL_RC_OK;
drdynvcPlugin* drdynvc = (drdynvcPlugin*) lpUserParam;
@ -1394,21 +1398,25 @@ static VOID VCAPITYPE drdynvc_virtual_channel_init_event_ex(LPVOID lpUserParam,
case CHANNEL_EVENT_CONNECTED:
if ((error = drdynvc_virtual_channel_event_connected(drdynvc, pData, dataLength)))
WLog_ERR(TAG, "drdynvc_virtual_channel_event_connected failed with error %lu", error);
break;
case CHANNEL_EVENT_DISCONNECTED:
if ((error = drdynvc_virtual_channel_event_disconnected(drdynvc)))
WLog_ERR(TAG, "drdynvc_virtual_channel_event_disconnected failed with error %lu", error);
break;
case CHANNEL_EVENT_TERMINATED:
if ((error = drdynvc_virtual_channel_event_terminated(drdynvc)))
WLog_ERR(TAG, "drdynvc_virtual_channel_event_terminated failed with error %lu", error);
break;
}
if (error && drdynvc->rdpcontext)
setChannelError(drdynvc->rdpcontext, error, "drdynvc_virtual_channel_init_event_ex reported an error");
setChannelError(drdynvc->rdpcontext, error,
"drdynvc_virtual_channel_init_event_ex reported an error");
}
/**
@ -1439,13 +1447,11 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
}
drdynvc->channelDef.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
strcpy(drdynvc->channelDef.name, "drdynvc");
drdynvc->state = DRDYNVC_STATE_INITIAL;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
@ -1465,37 +1471,25 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
drdynvc->context = context;
context->GetVersion = drdynvc_get_version;
drdynvc->rdpcontext = pEntryPointsEx->context;
*(pEntryPointsEx->ppInterface) = (void*) context;
}
drdynvc->log = WLog_Get("com.freerdp.channels.drdynvc.client");
WLog_Print(drdynvc->log, WLOG_DEBUG, "VirtualChannelEntryEx");
CopyMemory(&(drdynvc->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
drdynvc->InitHandle = pInitHandle;
rc = drdynvc->channelEntryPoints.pVirtualChannelInitEx((void*) drdynvc, pInitHandle,
&drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, drdynvc_virtual_channel_init_event_ex);
rc = drdynvc->channelEntryPoints.pVirtualChannelInitEx(drdynvc, context, pInitHandle,
&drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, drdynvc_virtual_channel_init_event_ex);
if (CHANNEL_RC_OK != rc)
{
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
WTSErrorToString(rc), rc);
if (context)
*(pEntryPointsEx->ppInterface) = NULL;
free(drdynvc->context);
free(drdynvc);
return FALSE;
}
drdynvc->channelEntryPoints.pInterface = *
(drdynvc->channelEntryPoints.ppInterface);
drdynvc->channelEntryPoints.ppInterface = &
(drdynvc->channelEntryPoints.pInterface);
drdynvc->channelEntryPoints.pInterface = context;
return TRUE;
}

View File

@ -118,7 +118,8 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
WLog_INFO(TAG, "EncomspWrite (%d)", Stream_Length(s));
winpr_HexDump(Stream_Buffer(s), Stream_Length(s));
#endif
status = encomsp->channelEntryPoints.pVirtualChannelWriteEx(encomsp->InitHandle, encomsp->OpenHandle,
status = encomsp->channelEntryPoints.pVirtualChannelWriteEx(encomsp->InitHandle,
encomsp->OpenHandle,
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
if (status != CHANNEL_RC_OK)
@ -999,7 +1000,8 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
@ -1041,7 +1043,6 @@ static void* encomsp_virtual_channel_client_thread(void* arg)
wMessage message;
encomspPlugin* encomsp = (encomspPlugin*) arg;
UINT error = CHANNEL_RC_OK;
encomsp_process_connect(encomsp);
while (1)
@ -1268,7 +1269,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
encomsp_send_change_participant_control_level_pdu;
context->GraphicsStreamPaused = NULL;
context->GraphicsStreamResumed = NULL;
*(pEntryPointsEx->ppInterface) = (void*) context;
encomsp->context = context;
encomsp->rdpcontext = pEntryPointsEx->context;
isFreerdp = TRUE;
@ -1277,7 +1277,7 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
CopyMemory(&(encomsp->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
encomsp->InitHandle = pInitHandle;
rc = encomsp->channelEntryPoints.pVirtualChannelInitEx((void*) encomsp, pInitHandle,
rc = encomsp->channelEntryPoints.pVirtualChannelInitEx(encomsp, context, pInitHandle,
&encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
encomsp_virtual_channel_init_event_ex);
@ -1288,17 +1288,10 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOI
goto error_out;
}
encomsp->channelEntryPoints.pInterface = *
(encomsp->channelEntryPoints.ppInterface);
encomsp->channelEntryPoints.ppInterface = &
(encomsp->channelEntryPoints.pInterface);
encomsp->channelEntryPoints.pInterface = context;
return TRUE;
error_out:
if (context)
*(pEntryPointsEx->ppInterface) = NULL;
if (isFreerdp)
free(encomsp->context);

View File

@ -809,7 +809,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
context->ClientGetAppIdRequest = rail_client_get_appid_request;
context->ServerGetAppIdResponse = rail_server_get_appid_response;
rail->rdpcontext = pEntryPointsEx->context;
*(pEntryPointsEx->ppInterface) = (void*) context;
rail->context = context;
isFreerdp = TRUE;
}
@ -819,10 +818,8 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntryEx");
CopyMemory(&(rail->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
rail->InitHandle = pInitHandle;
rc = rail->channelEntryPoints.pVirtualChannelInitEx((void*) rail, pInitHandle,
rc = rail->channelEntryPoints.pVirtualChannelInitEx(rail, context, pInitHandle,
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
rail_virtual_channel_init_event_ex);
@ -833,15 +830,10 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
goto error_out;
}
rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface);
rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface);
rail->channelEntryPoints.pInterface = context;
return TRUE;
error_out:
if (context)
*(pEntryPointsEx->ppInterface) = NULL;
if (isFreerdp)
free(rail->context);

9
channels/rdpdr/client/rdpdr_main.c Executable file → Normal file
View File

@ -1509,7 +1509,8 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
@ -1692,7 +1693,6 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
rdpdr->devman = NULL;
}
return error;
}
@ -1769,7 +1769,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
strcpy(rdpdr->channelDef.name, "rdpdr");
rdpdr->sequenceId = 0;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
@ -1782,10 +1781,8 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
rdpdr->InitHandle = pInitHandle;
rc = rdpdr->channelEntryPoints.pVirtualChannelInitEx((void*) rdpdr, pInitHandle,
rc = rdpdr->channelEntryPoints.pVirtualChannelInitEx(rdpdr, NULL, pInitHandle,
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
rdpdr_virtual_channel_init_event_ex);

View File

@ -111,7 +111,6 @@ static void* rdpsnd_schedule_thread(void* arg)
HANDLE events[2];
UINT error = CHANNEL_RC_OK;
DWORD status;
events[0] = MessageQueue_Event(rdpsnd->MsgPipe->Out);
events[1] = rdpsnd->stopEvent;
@ -1203,7 +1202,8 @@ static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
@ -1485,7 +1485,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
rdpsnd->channelDef.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP;
strcpy(rdpsnd->channelDef.name, "rdpsnd");
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;

View File

@ -56,7 +56,8 @@ static UINT remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s)
return CHANNEL_RC_INVALID_INSTANCE;
}
status = remdesk->channelEntryPoints.pVirtualChannelWriteEx(remdesk->InitHandle, remdesk->OpenHandle,
status = remdesk->channelEntryPoints.pVirtualChannelWriteEx(remdesk->InitHandle,
remdesk->OpenHandle,
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
if (status != CHANNEL_RC_OK)
@ -800,7 +801,8 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
return CHANNEL_RC_OK;
}
static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle, UINT event,
static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
UINT event,
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
UINT error = CHANNEL_RC_OK;
@ -845,7 +847,6 @@ static void* remdesk_virtual_channel_client_thread(void* arg)
wMessage message;
remdeskPlugin* remdesk = (remdeskPlugin*) arg;
UINT error = CHANNEL_RC_OK;
remdesk_process_connect(remdesk);
while (1)
@ -1049,7 +1050,6 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
strcpy(remdesk->channelDef.name, "remdesk");
remdesk->Version = 2;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
@ -1066,17 +1066,14 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
}
context->handle = (void*) remdesk;
*(pEntryPointsEx->ppInterface) = (void*) context;
remdesk->context = context;
remdesk->rdpcontext = pEntryPointsEx->context;
}
CopyMemory(&(remdesk->channelEntryPoints), pEntryPoints,
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
remdesk->InitHandle = pInitHandle;
rc = remdesk->channelEntryPoints.pVirtualChannelInitEx((void*) remdesk, pInitHandle,
rc = remdesk->channelEntryPoints.pVirtualChannelInitEx(remdesk, context, pInitHandle,
&remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
remdesk_virtual_channel_init_event_ex);
@ -1087,17 +1084,9 @@ BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID p
goto error_out;
}
remdesk->channelEntryPoints.pInterface = *
(remdesk->channelEntryPoints.ppInterface);
remdesk->channelEntryPoints.ppInterface = &
(remdesk->channelEntryPoints.pInterface);
remdesk->channelEntryPoints.pInterface = context;
return TRUE;
error_out:
if (context)
*(pEntryPointsEx->ppInterface) = NULL;
free(remdesk);
free(context);
return FALSE;

View File

@ -34,7 +34,8 @@
static WINPR_TLS void* g_pInterface = NULL;
static WINPR_TLS rdpChannels* g_channels = NULL; /* use only for VirtualChannelInit hack */
static UINT32 g_OpenHandleSeq = 1; /* use global counter to ensure uniqueness across channel manager instances */
static UINT32 g_OpenHandleSeq =
1; /* use global counter to ensure uniqueness across channel manager instances */
static rdpChannelHandles g_ChannelHandles = { NULL, NULL };
static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(
@ -198,12 +199,12 @@ UINT freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance)
if (pChannelClientData->pChannelInitEventProc)
{
pChannelClientData->pChannelInitEventProc(
pChannelClientData->pInitHandle, CHANNEL_EVENT_INITIALIZED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_INITIALIZED, 0, 0);
}
else if (pChannelClientData->pChannelInitEventProcEx)
{
pChannelClientData->pChannelInitEventProcEx(pChannelClientData->lpUserParam,
pChannelClientData->pInitHandle, CHANNEL_EVENT_INITIALIZED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_INITIALIZED, 0, 0);
}
if (CHANNEL_RC_OK != getChannelError(instance->context))
@ -234,25 +235,23 @@ UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
{
ChannelConnectedEventArgs e;
CHANNEL_OPEN_DATA* pChannelOpenData = NULL;
pChannelClientData = &channels->clientDataList[index];
if (pChannelClientData->pChannelInitEventProc)
{
pChannelClientData->pChannelInitEventProc(
pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
}
else if (pChannelClientData->pChannelInitEventProcEx)
{
pChannelClientData->pChannelInitEventProcEx(pChannelClientData->lpUserParam,
pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
}
if (getChannelError(instance->context) != CHANNEL_RC_OK)
goto fail;
pChannelOpenData = &channels->openDataList[index];
name = (char*) malloc(9);
if (!name)
@ -327,12 +326,12 @@ int freerdp_channels_data(freerdp* instance, UINT16 channelId, BYTE* data,
if (pChannelOpenData->pChannelOpenEventProc)
{
pChannelOpenData->pChannelOpenEventProc(
pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, dataSize, totalSize, flags);
pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, dataSize, totalSize, flags);
}
else if (pChannelOpenData->pChannelOpenEventProcEx)
{
pChannelOpenData->pChannelOpenEventProcEx(pChannelOpenData->lpUserParam,
pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, dataSize, totalSize, flags);
pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, dataSize, totalSize, flags);
}
return 0;
@ -374,12 +373,14 @@ static int freerdp_channels_process_sync(rdpChannels* channels,
if (pChannelOpenData->pChannelOpenEventProc)
{
pChannelOpenData->pChannelOpenEventProc(
pChannelOpenData->OpenHandle, CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength, item->DataLength, 0);
pChannelOpenData->OpenHandle, CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength,
item->DataLength, 0);
}
else if (pChannelOpenData->pChannelOpenEventProcEx)
{
pChannelOpenData->pChannelOpenEventProcEx(pChannelOpenData->lpUserParam,
pChannelOpenData->OpenHandle, CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength, item->DataLength, 0);
pChannelOpenData->OpenHandle, CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength,
item->DataLength, 0);
}
free(item);
@ -482,12 +483,12 @@ UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance)
if (pChannelClientData->pChannelInitEventProc)
{
pChannelClientData->pChannelInitEventProc(
pChannelClientData->pInitHandle, CHANNEL_EVENT_DISCONNECTED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_DISCONNECTED, 0, 0);
}
else if (pChannelClientData->pChannelInitEventProcEx)
{
pChannelClientData->pChannelInitEventProcEx(pChannelClientData->lpUserParam,
pChannelClientData->pInitHandle, CHANNEL_EVENT_DISCONNECTED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_DISCONNECTED, 0, 0);
}
if (getChannelError(instance->context) != CHANNEL_RC_OK)
@ -526,24 +527,24 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
if (pChannelClientData->pChannelInitEventProc)
{
pChannelClientData->pChannelInitEventProc(
pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
}
else if (pChannelClientData->pChannelInitEventProcEx)
{
pChannelClientData->pChannelInitEventProcEx(pChannelClientData->lpUserParam,
pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
}
}
MessageQueue_PostQuit(channels->queue, 0);
}
static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID pInitHandle,
PCHANNEL_DEF pChannel, INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx)
static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID clientContext,
LPVOID pInitHandle,
PCHANNEL_DEF pChannel, INT channelCount, ULONG versionRequested,
PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx)
{
INT index;
void* pInterface;
DWORD OpenHandle;
CHANNEL_DEF* channel;
rdpSettings* settings;
PCHANNEL_DEF pChannelDef;
@ -558,11 +559,9 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID pI
if (!pChannel || (channelCount <= 0) || !pChannelInitEventProcEx)
return CHANNEL_RC_INITIALIZATION_ERROR;
pInterface = g_pInterface;
pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle;
channels = pChannelInitData->channels;
pChannelInitData->pInterface = pInterface;
pChannelInitData->pInterface = clientContext;
if (!channels->can_call_init)
return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY;
@ -601,12 +600,10 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID pI
{
pChannelDef = &pChannel[index];
pChannelOpenData = &channels->openDataList[channels->openDataCount];
OpenHandle = g_OpenHandleSeq++;
pChannelOpenData->OpenHandle = OpenHandle;
pChannelOpenData->OpenHandle = ++channels->openHandleSequence;
pChannelOpenData->channels = channels;
pChannelOpenData->lpUserParam = lpUserParam;
freerdp_channel_add_open_handle_data(&g_ChannelHandles, OpenHandle, (void*) channels);
HashTable_Add(channels->openHandles, (void*)(UINT_PTR) OpenHandle,
HashTable_Add(channels->openHandles, (void*)(UINT_PTR) pChannelOpenData->OpenHandle,
(void*) pChannelOpenData);
pChannelOpenData->flags = 1; /* init */
strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN);
@ -717,13 +714,12 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle,
}
static UINT VCAPITYPE FreeRDP_VirtualChannelOpenEx(LPVOID pInitHandle,
LPDWORD pOpenHandle, PCHAR pChannelName, PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx)
LPDWORD pOpenHandle, PCHAR pChannelName, PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx)
{
void* pInterface;
rdpChannels* channels;
CHANNEL_INIT_DATA* pChannelInitData;
CHANNEL_OPEN_DATA* pChannelOpenData;
pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle;
channels = pChannelInitData->channels;
pInterface = pChannelInitData->pInterface;
@ -749,7 +745,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelOpenEx(LPVOID pInitHandle,
pChannelOpenData->pInterface = pInterface;
pChannelOpenData->pChannelOpenEventProcEx = pChannelOpenEventProcEx;
*pOpenHandle = pChannelOpenData->OpenHandle;
return CHANNEL_RC_OK;
}
@ -760,7 +755,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelOpen(LPVOID pInitHandle,
rdpChannels* channels;
CHANNEL_INIT_DATA* pChannelInitData;
CHANNEL_OPEN_DATA* pChannelOpenData;
pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle;
channels = pChannelInitData->channels;
pInterface = pChannelInitData->pInterface;
@ -786,7 +780,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelOpen(LPVOID pInitHandle,
pChannelOpenData->pInterface = pInterface;
pChannelOpenData->pChannelOpenEventProc = pChannelOpenEventProc;
*pOpenHandle = pChannelOpenData->OpenHandle;
return CHANNEL_RC_OK;
}
@ -814,7 +807,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelCloseEx(LPVOID pInitHandle, DWORD op
return CHANNEL_RC_NOT_OPEN;
pChannelOpenData->flags = 0;
return CHANNEL_RC_OK;
}
@ -822,7 +814,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelClose(DWORD openHandle)
{
rdpChannels* channels;
CHANNEL_OPEN_DATA* pChannelOpenData;
channels = (rdpChannels*) freerdp_channel_get_open_handle_data(&g_ChannelHandles, openHandle);
if (!channels)
@ -837,12 +828,11 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelClose(DWORD openHandle)
return CHANNEL_RC_NOT_OPEN;
pChannelOpenData->flags = 0;
return CHANNEL_RC_OK;
}
static UINT VCAPITYPE FreeRDP_VirtualChannelWriteEx(LPVOID pInitHandle, DWORD openHandle,
LPVOID pData, ULONG dataLength, LPVOID pUserData)
LPVOID pData, ULONG dataLength, LPVOID pUserData)
{
rdpChannels* channels = NULL;
CHANNEL_INIT_DATA* pChannelInitData = NULL;
@ -899,7 +889,8 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelWrite(DWORD openHandle,
{
CHANNEL_OPEN_DATA* pChannelOpenData;
CHANNEL_OPEN_EVENT* pChannelOpenEvent;
rdpChannels* channels = (rdpChannels*) freerdp_channel_get_open_handle_data(&g_ChannelHandles, openHandle);
rdpChannels* channels = (rdpChannels*) freerdp_channel_get_open_handle_data(&g_ChannelHandles,
openHandle);
if (!channels)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
@ -1022,7 +1013,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings,
}
int freerdp_channels_client_load_ex(rdpChannels* channels, rdpSettings* settings,
PVIRTUALCHANNELENTRYEX entryEx, void* data)
PVIRTUALCHANNELENTRYEX entryEx, void* data)
{
int status;
void* pInitHandle = NULL;
@ -1044,11 +1035,9 @@ int freerdp_channels_client_load_ex(rdpChannels* channels, rdpSettings* settings
pChannelClientData = &channels->clientDataList[channels->clientDataCount];
pChannelClientData->entryEx = entryEx;
pChannelInitData = &(channels->initDataList[channels->initDataCount++]);
pInitHandle = pChannelInitData;
pChannelInitData->channels = channels;
ZeroMemory(&EntryPointsEx, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
EntryPointsEx.cbSize = sizeof(EntryPointsEx);
EntryPointsEx.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000;
@ -1057,13 +1046,11 @@ int freerdp_channels_client_load_ex(rdpChannels* channels, rdpSettings* settings
EntryPointsEx.pVirtualChannelCloseEx = FreeRDP_VirtualChannelCloseEx;
EntryPointsEx.pVirtualChannelWriteEx = FreeRDP_VirtualChannelWriteEx;
EntryPointsEx.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER;
EntryPointsEx.ppInterface = &g_pInterface;
EntryPointsEx.pExtendedData = data;
EntryPointsEx.context = ((freerdp*) settings->instance)->context;
/* enable VirtualChannelInit */
channels->can_call_init = TRUE;
EnterCriticalSection(&channels->channelsLock);
g_pInterface = NULL;
status = pChannelClientData->entryEx((PCHANNEL_ENTRY_POINTS_EX) &EntryPointsEx, pInitHandle);
LeaveCriticalSection(&channels->channelsLock);
/* disable MyVirtualChannelInit */
@ -1082,10 +1069,10 @@ int freerdp_channels_client_load_ex(rdpChannels* channels, rdpSettings* settings
* this is called when processing the command line parameters
* called only from main thread
*/
int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, const char* name, void* data)
int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, const char* name,
void* data)
{
PVIRTUALCHANNELENTRY entry;
entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
if (!entry)

View File

@ -110,6 +110,8 @@ struct rdp_channels
DrdynvcClientContext* drdynvc;
CRITICAL_SECTION channelsLock;
int openHandleSequence;
wHashTable* openHandles;
};

View File

@ -179,7 +179,7 @@ typedef UINT VCAPITYPE VIRTUALCHANNELINIT(LPVOID* ppInitHandle,
typedef VIRTUALCHANNELINIT* PVIRTUALCHANNELINIT;
typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam,
typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam, LPVOID clientContext,
LPVOID pInitHandle, PCHANNEL_DEF pChannel,
INT channelCount, ULONG versionRequested,
PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx);