diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 950a7be7b..d12e2aab6 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -470,8 +470,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) CliprdrClientContext* context; CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx; - cliprdr = (cliprdrPlugin*) malloc(sizeof(cliprdrPlugin)); - ZeroMemory(cliprdr, sizeof(cliprdrPlugin)); + cliprdr = (cliprdrPlugin*) calloc(1, sizeof(cliprdrPlugin)); cliprdr->plugin.channel_def.options = CHANNEL_OPTION_INITIALIZED | @@ -491,8 +490,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) && (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) { - context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext)); - ZeroMemory(context, sizeof(CliprdrClientContext)); + context = (CliprdrClientContext*) calloc(1, sizeof(CliprdrClientContext)); context->handle = (void*) cliprdr; diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 309228688..441184a08 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -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, - void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) +static VOID rdpdr_virtual_channel_open_event(DWORD openHandle, UINT event, + LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) { rdpdrPlugin* rdpdr; @@ -468,7 +468,7 @@ static void* rdpdr_virtual_channel_client_thread(void* arg) 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; @@ -549,8 +549,10 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { rdpdrPlugin* rdpdr; - rdpdr = (rdpdrPlugin*) malloc(sizeof(rdpdrPlugin)); - ZeroMemory(rdpdr, sizeof(rdpdrPlugin)); + rdpdr = (rdpdrPlugin*) calloc(1, sizeof(rdpdrPlugin)); + + if (!rdpdr) + return -1; rdpdr->channelDef.options = CHANNEL_OPTION_INITIALIZED | @@ -559,7 +561,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) 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->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event); diff --git a/channels/rdpdr/client/rdpdr_main.h b/channels/rdpdr/client/rdpdr_main.h index f0699fce9..b9a766590 100644 --- a/channels/rdpdr/client/rdpdr_main.h +++ b/channels/rdpdr/client/rdpdr_main.h @@ -43,7 +43,7 @@ struct rdpdr_plugin HANDLE thread; wStream* data_in; void* InitHandle; - UINT32 OpenHandle; + DWORD OpenHandle; wMessagePipe* MsgPipe; DEVMAN* devman; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 42e3597bf..bb1bbb535 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -60,7 +60,7 @@ struct rdpsnd_plugin HANDLE thread; wStream* data_in; void* InitHandle; - UINT32 OpenHandle; + DWORD OpenHandle; wMessagePipe* MsgPipe; 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, - void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) +static VOID rdpsnd_virtual_channel_open_event(DWORD openHandle, UINT event, + LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags) { rdpsndPlugin* plugin; @@ -979,7 +979,7 @@ static void* rdpsnd_virtual_channel_client_thread(void* arg) 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; @@ -1090,7 +1090,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) 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"); diff --git a/include/freerdp/channels/wtsvc.h b/include/freerdp/channels/wtsvc.h index 9041b523f..026372564 100644 --- a/include/freerdp/channels/wtsvc.h +++ b/include/freerdp/channels/wtsvc.h @@ -37,6 +37,7 @@ #include #include + //#include typedef enum _WTS_VIRTUAL_CLASS diff --git a/include/freerdp/svc.h b/include/freerdp/svc.h index 36213e9d8..2f149a2b0 100644 --- a/include/freerdp/svc.h +++ b/include/freerdp/svc.h @@ -33,20 +33,18 @@ #define CHANNEL_NAME_LEN 7 -struct _CHANNEL_DEF +typedef struct tagCHANNEL_DEF { - char name[8]; - UINT32 options; -}; + char name[CHANNEL_NAME_LEN + 1]; + ULONG options; +} CHANNEL_DEF; +typedef CHANNEL_DEF *PCHANNEL_DEF; +typedef PCHANNEL_DEF *PPCHANNEL_DEF; -typedef struct _CHANNEL_DEF CHANNEL_DEF; -typedef CHANNEL_DEF* PCHANNEL_DEF; -typedef CHANNEL_DEF** PPCHANNEL_DEF; +typedef VOID (FREERDP_CC * PCHANNEL_INIT_EVENT_FN)(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength); -typedef void (FREERDP_CC * PCHANNEL_INIT_EVENT_FN)(void* pInitHandle, UINT32 event, void* pData, UINT32 dataLength); - -typedef void (FREERDP_CC * PCHANNEL_OPEN_EVENT_FN)(UINT32 openHandle, UINT32 event, - void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags); +typedef VOID (FREERDP_CC * PCHANNEL_OPEN_EVENT_FN)(DWORD openHandle, UINT event, + LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags); #define CHANNEL_RC_OK 0 #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 -typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELINIT)(void** ppInitHandle, PCHANNEL_DEF pChannel, - int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc); +typedef UINT (FREERDP_CC * PVIRTUALCHANNELINIT)(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel, + INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc); -typedef UINT32 (FREERDP_CC * PVIRTUALCHANNELOPEN)(void* pInitHandle, UINT32* pOpenHandle, - char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc); +typedef UINT (FREERDP_CC * PVIRTUALCHANNELOPEN)(LPVOID pInitHandle, LPDWORD pOpenHandle, + 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 { - UINT32 cbSize; - UINT32 protocolVersion; + DWORD cbSize; + DWORD protocolVersion; PVIRTUALCHANNELINIT pVirtualChannelInit; PVIRTUALCHANNELOPEN pVirtualChannelOpen; PVIRTUALCHANNELCLOSE pVirtualChannelClose; diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index 4b8376733..a81628046 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -51,7 +51,7 @@ struct rdp_svc_plugin HANDLE thread; wStream* data_in; void* InitHandle; - UINT32 OpenHandle; + DWORD OpenHandle; wMessagePipe* MsgPipe; }; diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index a7710f886..6f0464b50 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -500,12 +500,12 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance) MessagePipe_PostQuit(channels->MsgPipe, 0); } -UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, - int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) +UINT FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel, + INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) { int index; void* pInterface; - UINT32 OpenHandle; + DWORD OpenHandle; rdpChannel* channel; rdpChannels* channels; rdpSettings* settings; @@ -591,8 +591,8 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, return CHANNEL_RC_OK; } -UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, - char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) +UINT FreeRDP_VirtualChannelOpen(LPVOID pInitHandle, LPDWORD pOpenHandle, + PCHAR pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) { void* pInterface; rdpChannels* channels; @@ -628,7 +628,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, return CHANNEL_RC_OK; } -UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle) +UINT FreeRDP_VirtualChannelClose(DWORD openHandle) { CHANNEL_OPEN_DATA* pChannelOpenData; @@ -645,7 +645,7 @@ UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle) 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; CHANNEL_OPEN_DATA* pChannelOpenData; @@ -688,7 +688,7 @@ UINT32 FreeRDP_VirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLe return CHANNEL_RC_OK; } -UINT32 FreeRDP_VirtualChannelEventPush(UINT32 openHandle, wMessage* event) +UINT FreeRDP_VirtualChannelEventPush(DWORD openHandle, wMessage* event) { rdpChannels* channels; 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 status; - CHANNEL_ENTRY_POINTS_EX ep; + CHANNEL_ENTRY_POINTS_EX EntryPoints; CHANNEL_CLIENT_DATA* pChannelClientData; 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->entry = (PVIRTUALCHANNELENTRY) entry; - ep.cbSize = sizeof(ep); - ep.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000; - ep.pVirtualChannelInit = FreeRDP_VirtualChannelInit; - ep.pVirtualChannelOpen = FreeRDP_VirtualChannelOpen; - ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; - ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; + ZeroMemory(&EntryPoints, sizeof(CHANNEL_ENTRY_POINTS_EX)); + + EntryPoints.cbSize = sizeof(EntryPoints); + EntryPoints.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000; + EntryPoints.pVirtualChannelInit = FreeRDP_VirtualChannelInit; + EntryPoints.pVirtualChannelOpen = FreeRDP_VirtualChannelOpen; + EntryPoints.pVirtualChannelClose = FreeRDP_VirtualChannelClose; + EntryPoints.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; g_pInterface = NULL; - ep.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER; - ep.ppInterface = &g_pInterface; - ep.pExtendedData = data; - ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; + EntryPoints.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER; + EntryPoints.ppInterface = &g_pInterface; + EntryPoints.pExtendedData = data; + EntryPoints.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; /* enable VirtualChannelInit */ channels->can_call_init = TRUE; @@ -759,7 +761,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v EnterCriticalSection(&g_channels_lock); g_ChannelInitData.channels = channels; - status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); + status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &EntryPoints); LeaveCriticalSection(&g_channels_lock); diff --git a/libfreerdp/core/server.c b/libfreerdp/core/server.c index 947a54e4d..582340f98 100644 --- a/libfreerdp/core/server.c +++ b/libfreerdp/core/server.c @@ -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); } -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; UINT32 length; diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index 884b6c237..5bcce9224 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -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); } -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) { rdpSvcPlugin* plugin; @@ -207,7 +207,7 @@ static void* svc_plugin_thread_func(void* arg) 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; @@ -285,7 +285,7 @@ void svc_plugin_init(rdpSvcPlugin* plugin, CHANNEL_ENTRY_POINTS* pEntryPoints) * 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_def), 1, VIRTUAL_CHANNEL_VERSION_WIN2000, svc_plugin_init_event);