libfreerdp-core: make client virtual channel API prototypes converge towards original API

This commit is contained in:
Marc-André Moreau 2014-02-16 17:27:36 -05:00
parent 74d054172c
commit b833073f57
10 changed files with 62 additions and 61 deletions

View File

@ -470,8 +470,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
CliprdrClientContext* context; CliprdrClientContext* context;
CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx; CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx;
cliprdr = (cliprdrPlugin*) malloc(sizeof(cliprdrPlugin)); cliprdr = (cliprdrPlugin*) calloc(1, sizeof(cliprdrPlugin));
ZeroMemory(cliprdr, sizeof(cliprdrPlugin));
cliprdr->plugin.channel_def.options = cliprdr->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_INITIALIZED |
@ -491,8 +490,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) && if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) &&
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
{ {
context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext)); context = (CliprdrClientContext*) calloc(1, sizeof(CliprdrClientContext));
ZeroMemory(context, sizeof(CliprdrClientContext));
context->handle = (void*) cliprdr; context->handle = (void*) cliprdr;

View File

@ -410,8 +410,8 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
} }
} }
static void rdpdr_virtual_channel_open_event(UINT32 openHandle, UINT32 event, static VOID rdpdr_virtual_channel_open_event(DWORD openHandle, UINT event,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{ {
rdpdrPlugin* rdpdr; rdpdrPlugin* rdpdr;
@ -468,7 +468,7 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
return NULL; return NULL;
} }
static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, void* pData, UINT32 dataLength) static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pData, UINT32 dataLength)
{ {
UINT32 status; UINT32 status;
@ -549,8 +549,10 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{ {
rdpdrPlugin* rdpdr; rdpdrPlugin* rdpdr;
rdpdr = (rdpdrPlugin*) malloc(sizeof(rdpdrPlugin)); rdpdr = (rdpdrPlugin*) calloc(1, sizeof(rdpdrPlugin));
ZeroMemory(rdpdr, sizeof(rdpdrPlugin));
if (!rdpdr)
return -1;
rdpdr->channelDef.options = rdpdr->channelDef.options =
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_INITIALIZED |
@ -559,7 +561,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
strcpy(rdpdr->channelDef.name, "rdpdr"); strcpy(rdpdr->channelDef.name, "rdpdr");
CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints, pEntryPoints->cbSize); CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_EX));
rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle, rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle,
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event); &rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event);

View File

@ -43,7 +43,7 @@ struct rdpdr_plugin
HANDLE thread; HANDLE thread;
wStream* data_in; wStream* data_in;
void* InitHandle; void* InitHandle;
UINT32 OpenHandle; DWORD OpenHandle;
wMessagePipe* MsgPipe; wMessagePipe* MsgPipe;
DEVMAN* devman; DEVMAN* devman;

View File

@ -60,7 +60,7 @@ struct rdpsnd_plugin
HANDLE thread; HANDLE thread;
wStream* data_in; wStream* data_in;
void* InitHandle; void* InitHandle;
UINT32 OpenHandle; DWORD OpenHandle;
wMessagePipe* MsgPipe; wMessagePipe* MsgPipe;
wLog* log; wLog* log;
@ -921,8 +921,8 @@ static void rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
} }
} }
static void rdpsnd_virtual_channel_open_event(UINT32 openHandle, UINT32 event, static VOID rdpsnd_virtual_channel_open_event(DWORD openHandle, UINT event,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{ {
rdpsndPlugin* plugin; rdpsndPlugin* plugin;
@ -979,7 +979,7 @@ static void* rdpsnd_virtual_channel_client_thread(void* arg)
return NULL; return NULL;
} }
static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, void* pData, UINT32 dataLength) static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID pData, UINT32 dataLength)
{ {
UINT32 status; UINT32 status;
@ -1090,7 +1090,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
strcpy(rdpsnd->channelDef.name, "rdpsnd"); strcpy(rdpsnd->channelDef.name, "rdpsnd");
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints, pEntryPoints->cbSize); CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_EX));
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client"); rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");

View File

@ -37,6 +37,7 @@
#include <winpr/winpr.h> #include <winpr/winpr.h>
#include <winpr/wtypes.h> #include <winpr/wtypes.h>
//#include <winpr/wtsapi.h> //#include <winpr/wtsapi.h>
typedef enum _WTS_VIRTUAL_CLASS typedef enum _WTS_VIRTUAL_CLASS

View File

@ -33,20 +33,18 @@
#define CHANNEL_NAME_LEN 7 #define CHANNEL_NAME_LEN 7
struct _CHANNEL_DEF typedef struct tagCHANNEL_DEF
{ {
char name[8]; char name[CHANNEL_NAME_LEN + 1];
UINT32 options; ULONG options;
}; } CHANNEL_DEF;
typedef struct _CHANNEL_DEF CHANNEL_DEF;
typedef CHANNEL_DEF *PCHANNEL_DEF; typedef CHANNEL_DEF *PCHANNEL_DEF;
typedef CHANNEL_DEF** PPCHANNEL_DEF; typedef PCHANNEL_DEF *PPCHANNEL_DEF;
typedef void (FREERDP_CC * PCHANNEL_INIT_EVENT_FN)(void* pInitHandle, UINT32 event, void* pData, UINT32 dataLength); typedef VOID (FREERDP_CC * PCHANNEL_INIT_EVENT_FN)(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength);
typedef void (FREERDP_CC * PCHANNEL_OPEN_EVENT_FN)(UINT32 openHandle, UINT32 event, typedef VOID (FREERDP_CC * PCHANNEL_OPEN_EVENT_FN)(DWORD openHandle, UINT event,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags); LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags);
#define CHANNEL_RC_OK 0 #define CHANNEL_RC_OK 0
#define CHANNEL_RC_ALREADY_INITIALIZED 1 #define CHANNEL_RC_ALREADY_INITIALIZED 1
@ -69,22 +67,22 @@ typedef void (FREERDP_CC * PCHANNEL_OPEN_EVENT_FN)(UINT32 openHandle, UINT32 eve
#define VIRTUAL_CHANNEL_VERSION_WIN2000 1 #define VIRTUAL_CHANNEL_VERSION_WIN2000 1
typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELINIT)(void** ppInitHandle, PCHANNEL_DEF pChannel, typedef UINT (FREERDP_CC * PVIRTUALCHANNELINIT)(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel,
int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc); INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc);
typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELOPEN)(void* pInitHandle, UINT32* pOpenHandle, typedef UINT (FREERDP_CC * PVIRTUALCHANNELOPEN)(LPVOID pInitHandle, LPDWORD pOpenHandle,
char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc); PCHAR pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc);
typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELCLOSE)(UINT32 openHandle); typedef UINT (FREERDP_CC * PVIRTUALCHANNELCLOSE)(DWORD openHandle);
typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELWRITE)(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData); typedef UINT (FREERDP_CC * PVIRTUALCHANNELWRITE)(DWORD openHandle, LPVOID pData, ULONG dataLength, LPVOID pUserData);
typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELEVENTPUSH)(UINT32 openHandle, wMessage* event); typedef UINT (FREERDP_CC * PVIRTUALCHANNELEVENTPUSH)(DWORD openHandle, wMessage* event);
struct _CHANNEL_ENTRY_POINTS struct _CHANNEL_ENTRY_POINTS
{ {
UINT32 cbSize; DWORD cbSize;
UINT32 protocolVersion; DWORD protocolVersion;
PVIRTUALCHANNELINIT pVirtualChannelInit; PVIRTUALCHANNELINIT pVirtualChannelInit;
PVIRTUALCHANNELOPEN pVirtualChannelOpen; PVIRTUALCHANNELOPEN pVirtualChannelOpen;
PVIRTUALCHANNELCLOSE pVirtualChannelClose; PVIRTUALCHANNELCLOSE pVirtualChannelClose;

View File

@ -51,7 +51,7 @@ struct rdp_svc_plugin
HANDLE thread; HANDLE thread;
wStream* data_in; wStream* data_in;
void* InitHandle; void* InitHandle;
UINT32 OpenHandle; DWORD OpenHandle;
wMessagePipe* MsgPipe; wMessagePipe* MsgPipe;
}; };

View File

@ -500,12 +500,12 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
MessagePipe_PostQuit(channels->MsgPipe, 0); MessagePipe_PostQuit(channels->MsgPipe, 0);
} }
UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, UINT FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel,
int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc)
{ {
int index; int index;
void* pInterface; void* pInterface;
UINT32 OpenHandle; DWORD OpenHandle;
rdpChannel* channel; rdpChannel* channel;
rdpChannels* channels; rdpChannels* channels;
rdpSettings* settings; rdpSettings* settings;
@ -591,8 +591,8 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, UINT FreeRDP_VirtualChannelOpen(LPVOID pInitHandle, LPDWORD pOpenHandle,
char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) PCHAR pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc)
{ {
void* pInterface; void* pInterface;
rdpChannels* channels; rdpChannels* channels;
@ -628,7 +628,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle,
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle) UINT FreeRDP_VirtualChannelClose(DWORD openHandle)
{ {
CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_OPEN_DATA* pChannelOpenData;
@ -645,7 +645,7 @@ UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle)
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
UINT32 FreeRDP_VirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData) UINT FreeRDP_VirtualChannelWrite(DWORD openHandle, LPVOID pData, ULONG dataLength, LPVOID pUserData)
{ {
rdpChannels* channels; rdpChannels* channels;
CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_OPEN_DATA* pChannelOpenData;
@ -688,7 +688,7 @@ UINT32 FreeRDP_VirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLe
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
UINT32 FreeRDP_VirtualChannelEventPush(UINT32 openHandle, wMessage* event) UINT FreeRDP_VirtualChannelEventPush(DWORD openHandle, wMessage* event)
{ {
rdpChannels* channels; rdpChannels* channels;
CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_OPEN_DATA* pChannelOpenData;
@ -727,7 +727,7 @@ UINT32 FreeRDP_VirtualChannelEventPush(UINT32 openHandle, wMessage* event)
int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, void* entry, void* data) int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, void* entry, void* data)
{ {
int status; int status;
CHANNEL_ENTRY_POINTS_EX ep; CHANNEL_ENTRY_POINTS_EX EntryPoints;
CHANNEL_CLIENT_DATA* pChannelClientData; CHANNEL_CLIENT_DATA* pChannelClientData;
if (channels->clientDataCount + 1 >= CHANNEL_MAX_COUNT) if (channels->clientDataCount + 1 >= CHANNEL_MAX_COUNT)
@ -739,18 +739,20 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
pChannelClientData = &channels->clientDataList[channels->clientDataCount]; pChannelClientData = &channels->clientDataList[channels->clientDataCount];
pChannelClientData->entry = (PVIRTUALCHANNELENTRY) entry; pChannelClientData->entry = (PVIRTUALCHANNELENTRY) entry;
ep.cbSize = sizeof(ep); ZeroMemory(&EntryPoints, sizeof(CHANNEL_ENTRY_POINTS_EX));
ep.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000;
ep.pVirtualChannelInit = FreeRDP_VirtualChannelInit; EntryPoints.cbSize = sizeof(EntryPoints);
ep.pVirtualChannelOpen = FreeRDP_VirtualChannelOpen; EntryPoints.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000;
ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; EntryPoints.pVirtualChannelInit = FreeRDP_VirtualChannelInit;
ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; EntryPoints.pVirtualChannelOpen = FreeRDP_VirtualChannelOpen;
EntryPoints.pVirtualChannelClose = FreeRDP_VirtualChannelClose;
EntryPoints.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite;
g_pInterface = NULL; g_pInterface = NULL;
ep.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER; EntryPoints.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER;
ep.ppInterface = &g_pInterface; EntryPoints.ppInterface = &g_pInterface;
ep.pExtendedData = data; EntryPoints.pExtendedData = data;
ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; EntryPoints.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush;
/* enable VirtualChannelInit */ /* enable VirtualChannelInit */
channels->can_call_init = TRUE; channels->can_call_init = TRUE;
@ -759,7 +761,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
EnterCriticalSection(&g_channels_lock); EnterCriticalSection(&g_channels_lock);
g_ChannelInitData.channels = channels; g_ChannelInitData.channels = channels;
status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &EntryPoints);
LeaveCriticalSection(&g_channels_lock); LeaveCriticalSection(&g_channels_lock);

View File

@ -83,7 +83,7 @@ static void wts_queue_receive_data(rdpPeerChannel* channel, const BYTE* Buffer,
MessageQueue_Post(channel->queue, (void*) (UINT_PTR) channelId, 0, (void*) buffer, (void*) (UINT_PTR) length); MessageQueue_Post(channel->queue, (void*) (UINT_PTR) channelId, 0, (void*) buffer, (void*) (UINT_PTR) length);
} }
static void wts_queue_send_item(rdpPeerChannel* channel, const BYTE* Buffer, UINT32 Length) static void wts_queue_send_item(rdpPeerChannel* channel, BYTE* Buffer, UINT32 Length)
{ {
BYTE* buffer; BYTE* buffer;
UINT32 length; UINT32 length;

View File

@ -132,7 +132,7 @@ static void svc_plugin_process_event(rdpSvcPlugin* plugin, wMessage* event_in)
MessageQueue_Post(plugin->MsgPipe->In, NULL, 1, (void*) event_in, NULL); MessageQueue_Post(plugin->MsgPipe->In, NULL, 1, (void*) event_in, NULL);
} }
static void svc_plugin_open_event(UINT32 openHandle, UINT32 event, void* pData, UINT32 dataLength, static VOID svc_plugin_open_event(DWORD openHandle, UINT event, LPVOID pData, UINT32 dataLength,
UINT32 totalLength, UINT32 dataFlags) UINT32 totalLength, UINT32 dataFlags)
{ {
rdpSvcPlugin* plugin; rdpSvcPlugin* plugin;
@ -207,7 +207,7 @@ static void* svc_plugin_thread_func(void* arg)
return 0; return 0;
} }
static void svc_plugin_process_connected(rdpSvcPlugin* plugin, void* pData, UINT32 dataLength) static void svc_plugin_process_connected(rdpSvcPlugin* plugin, LPVOID pData, UINT32 dataLength)
{ {
UINT32 status; UINT32 status;
@ -285,7 +285,7 @@ void svc_plugin_init(rdpSvcPlugin* plugin, CHANNEL_ENTRY_POINTS* pEntryPoints)
* VirtualChannelInit at a time. So this should be safe. * VirtualChannelInit at a time. So this should be safe.
*/ */
CopyMemory(&(plugin->channel_entry_points), pEntryPoints, pEntryPoints->cbSize); CopyMemory(&(plugin->channel_entry_points), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_EX));
plugin->channel_entry_points.pVirtualChannelInit(&(plugin->InitHandle), plugin->channel_entry_points.pVirtualChannelInit(&(plugin->InitHandle),
&(plugin->channel_def), 1, VIRTUAL_CHANNEL_VERSION_WIN2000, svc_plugin_init_event); &(plugin->channel_def), 1, VIRTUAL_CHANNEL_VERSION_WIN2000, svc_plugin_init_event);