diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 564630d8c..bc74c1f63 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -78,7 +78,7 @@ static void audin_server_send_version(audin_server* audin, wStream* s) { Stream_Write_UINT8(s, MSG_SNDIN_VERSION); Stream_Write_UINT32(s, 1); /* Version (4 bytes) */ - WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_version(audin_server* audin, wStream* s, UINT32 length) @@ -130,7 +130,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) } } - WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 length) @@ -166,6 +166,7 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le Stream_Read_UINT16(s, audin->context.client_formats[i].nBlockAlign); Stream_Read_UINT16(s, audin->context.client_formats[i].wBitsPerSample); Stream_Read_UINT16(s, audin->context.client_formats[i].cbSize); + if (audin->context.client_formats[i].cbSize > 0) { Stream_Seek(s, audin->context.client_formats[i].cbSize); @@ -201,7 +202,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s) Stream_Write_UINT16(s, 16); /* wBitsPerSample */ Stream_Write_UINT16(s, 0); /* cbSize */ - WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 length) @@ -283,10 +284,10 @@ static void* audin_server_thread_func(void* arg) void* buffer; BYTE MessageId; BOOL ready = FALSE; - UINT32 bytes_returned = 0; + DWORD BytesReturned = 0; audin_server* audin = (audin_server*) arg; - if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualFileHandle, &buffer, &bytes_returned) == TRUE) + if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualFileHandle, &buffer, &BytesReturned) == TRUE) { fd = *((void**) buffer); WTSFreeMemory(buffer); @@ -303,7 +304,7 @@ static void* audin_server_thread_func(void* arg) if (WaitForSingleObject(audin->stopEvent, 0) == WAIT_OBJECT_0) break; - if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualChannelReady, &buffer, &bytes_returned) == FALSE) + if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualChannelReady, &buffer, &BytesReturned) == FALSE) break; ready = *((BOOL*) buffer); @@ -330,46 +331,48 @@ static void* audin_server_thread_func(void* arg) Stream_SetPosition(s, 0); - if (WTSVirtualChannelRead(audin->audin_channel, 0, Stream_Buffer(s), - Stream_Capacity(s), &bytes_returned) == FALSE) + if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR) Stream_Buffer(s), + Stream_Capacity(s), &BytesReturned) == FALSE) { - if (bytes_returned == 0) + if (BytesReturned == 0) break; - Stream_EnsureRemainingCapacity(s, (int) bytes_returned); + Stream_EnsureRemainingCapacity(s, BytesReturned); - if (WTSVirtualChannelRead(audin->audin_channel, 0, Stream_Buffer(s), - Stream_Capacity(s), &bytes_returned) == FALSE) + if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR) Stream_Buffer(s), + Stream_Capacity(s), &BytesReturned) == FALSE) + { break; + } } - if (bytes_returned < 1) + if (BytesReturned < 1) continue; Stream_Read_UINT8(s, MessageId); - bytes_returned--; + BytesReturned--; switch (MessageId) { case MSG_SNDIN_VERSION: - if (audin_server_recv_version(audin, s, bytes_returned)) + if (audin_server_recv_version(audin, s, BytesReturned)) audin_server_send_formats(audin, s); break; case MSG_SNDIN_FORMATS: - if (audin_server_recv_formats(audin, s, bytes_returned)) + if (audin_server_recv_formats(audin, s, BytesReturned)) audin_server_send_open(audin, s); break; case MSG_SNDIN_OPEN_REPLY: - audin_server_recv_open_reply(audin, s, bytes_returned); + audin_server_recv_open_reply(audin, s, BytesReturned); break; case MSG_SNDIN_DATA_INCOMING: break; case MSG_SNDIN_DATA: - audin_server_recv_data(audin, s, bytes_returned); + audin_server_recv_data(audin, s, BytesReturned); break; case MSG_SNDIN_FORMATCHANGE: diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index 6744748c5..c3c35c669 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -96,7 +96,7 @@ static int cliprdr_server_send_capabilities(CliprdrServerContext* context) Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -123,7 +123,7 @@ static int cliprdr_server_send_monitor_ready(CliprdrServerContext* context) Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -150,7 +150,7 @@ static int cliprdr_server_send_format_list_response(CliprdrServerContext* contex Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -392,7 +392,7 @@ static void* cliprdr_server_thread(void* arg) int position; HANDLE events[8]; HANDLE ChannelEvent; - UINT32 BytesReturned; + DWORD BytesReturned; CLIPRDR_HEADER header; CliprdrServerContext* context; @@ -429,7 +429,7 @@ static void* cliprdr_server_thread(void* arg) } if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, - Stream_Buffer(s), Stream_Capacity(s), &BytesReturned)) + (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned)) { if (BytesReturned) Stream_Seek(s, BytesReturned); diff --git a/channels/drdynvc/server/drdynvc_main.c b/channels/drdynvc/server/drdynvc_main.c index 2897023d4..ecca8e587 100644 --- a/channels/drdynvc/server/drdynvc_main.c +++ b/channels/drdynvc/server/drdynvc_main.c @@ -35,7 +35,7 @@ static void* drdynvc_server_thread(void* arg) void* buffer; HANDLE events[8]; HANDLE ChannelEvent; - UINT32 BytesReturned; + DWORD BytesReturned; DrdynvcServerContext* context; context = (DrdynvcServerContext*) arg; diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index c55b6ec1b..58f057bac 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -51,7 +51,7 @@ static int rdpdr_server_send_announce_request(RdpdrServerContext* context) Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -319,7 +319,7 @@ static int rdpdr_server_send_core_capability_request(RdpdrServerContext* context Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -393,7 +393,7 @@ static int rdpdr_server_send_client_id_confirm(RdpdrServerContext* context) Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -470,7 +470,7 @@ static int rdpdr_server_send_user_logged_on(RdpdrServerContext* context) Stream_SealLength(s); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_Length(s), NULL); Stream_Free(s, TRUE); @@ -558,7 +558,7 @@ static void* rdpdr_server_thread(void* arg) HANDLE events[8]; RDPDR_HEADER header; HANDLE ChannelEvent; - UINT32 BytesReturned; + DWORD BytesReturned; RdpdrServerContext* context; context = (RdpdrServerContext*) arg; @@ -594,7 +594,7 @@ static void* rdpdr_server_thread(void* arg) break; } - if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, Stream_Pointer(s), + if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR) Stream_Pointer(s), Stream_Capacity(s) - Stream_GetPosition(s), &BytesReturned)) { if (BytesReturned) diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index d56de7fee..070958088 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -74,7 +74,7 @@ static BOOL rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s) Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; @@ -163,7 +163,7 @@ static void* rdpsnd_server_thread(void* arg) UINT16 BodySize; HANDLE events[8]; HANDLE ChannelEvent; - UINT32 BytesReturned; + DWORD BytesReturned; RdpsndServerContext* context; context = (RdpsndServerContext*) arg; @@ -201,7 +201,7 @@ static void* rdpsnd_server_thread(void* arg) Stream_SetPosition(s, 0); if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, - Stream_Buffer(s), Stream_Capacity(s), &BytesReturned)) + (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned)) { if (BytesReturned) Stream_Seek(s, BytesReturned); @@ -214,7 +214,7 @@ static void* rdpsnd_server_thread(void* arg) Stream_EnsureRemainingCapacity(s, BytesReturned); if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0, - Stream_Buffer(s), Stream_Capacity(s), &BytesReturned) == FALSE) + (PCHAR) Stream_Buffer(s), Stream_Capacity(s), &BytesReturned) == FALSE) { break; } @@ -384,7 +384,7 @@ static BOOL rdpsnd_server_send_audio_pdu(RdpsndServerContext* context) Stream_Seek(s, 3); /* bPad */ Stream_Write(s, src, 4); - WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); /* Wave PDU */ @@ -395,7 +395,7 @@ static BOOL rdpsnd_server_send_audio_pdu(RdpsndServerContext* context) if (fill_size > 0) Stream_Zero(s, fill_size); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); context->priv->out_pending_frames = 0; @@ -449,7 +449,7 @@ static BOOL rdpsnd_server_set_volume(RdpsndServerContext* context, int left, int Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; @@ -480,7 +480,7 @@ static BOOL rdpsnd_server_close(RdpsndServerContext* context) Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; diff --git a/channels/server/channels.c b/channels/server/channels.c index a4c9bdc0b..53d474eba 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -662,11 +662,7 @@ void* WTSVirtualChannelOpenEx( return channel; } -BOOL WTSVirtualChannelQuery( - /* __in */ void* hChannelHandle, - /* __in */ WTS_VIRTUAL_CLASS WtsVirtualClass, - /* __out */ void** ppBuffer, - /* __out */ UINT32* pBytesReturned) +BOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned) { void* pfd; BOOL bval; @@ -739,18 +735,12 @@ BOOL WTSVirtualChannelQuery( return result; } -void WTSFreeMemory( - /* __in */ void* pMemory) +VOID WTSFreeMemory(PVOID pMemory) { free(pMemory); } -BOOL WTSVirtualChannelRead( - /* __in */ void* hChannelHandle, - /* __in */ UINT32 TimeOut, - /* __out */ BYTE* Buffer, - /* __in */ UINT32 BufferSize, - /* __out */ UINT32* pBytesRead) +BOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead) { wts_data_item* item; rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle; @@ -784,11 +774,7 @@ BOOL WTSVirtualChannelRead( return TRUE; } -BOOL WTSVirtualChannelWrite( - /* __in */ void* hChannelHandle, - /* __in */ BYTE* Buffer, - /* __in */ UINT32 Length, - /* __out */ UINT32* pBytesWritten) +BOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten) { rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle; wts_data_item* item; diff --git a/include/freerdp/channels/wtsvc.h b/include/freerdp/channels/wtsvc.h index 118cfdaa8..b1191f177 100644 --- a/include/freerdp/channels/wtsvc.h +++ b/include/freerdp/channels/wtsvc.h @@ -35,18 +35,27 @@ #include #include -typedef struct WTSVirtualChannelManager WTSVirtualChannelManager; - -#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001 +#include +#include +//#include typedef enum _WTS_VIRTUAL_CLASS { WTSVirtualClientData, WTSVirtualFileHandle, - WTSVirtualEventHandle, - WTSVirtualChannelReady + WTSVirtualEventHandle, /* Extended */ + WTSVirtualChannelReady /* Extended */ } WTS_VIRTUAL_CLASS; +#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW 0x00000000 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED 0x00000002 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH 0x00000004 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL 0x00000006 +#define WTS_CHANNEL_OPTION_DYNAMIC_NO_COMPRESS 0x00000008 + +typedef struct WTSVirtualChannelManager WTSVirtualChannelManager; + #ifdef __cplusplus extern "C" { #endif @@ -72,6 +81,9 @@ FREERDP_API HANDLE WTSVirtualChannelManagerGetEventHandle(WTSVirtualChannelManag * Static virtual channels must be opened from the main thread. Dynamic virtual channels * can be opened from any thread. */ + +// WINPR_API HANDLE WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags); + FREERDP_API void* WTSVirtualChannelOpenEx( /* __in */ WTSVirtualChannelManager* vcm, /* __in */ const char* pVirtualName, @@ -83,17 +95,14 @@ FREERDP_API void* WTSVirtualChannelOpenEx( * Servers use this function to gain access to a virtual channel file handle * that can be used for asynchronous I/O. */ -FREERDP_API BOOL WTSVirtualChannelQuery( - /* __in */ void* hChannelHandle, - /* __in */ WTS_VIRTUAL_CLASS WtsVirtualClass, - /* __out */ void** ppBuffer, - /* __out */ UINT32* pBytesReturned); + +WINPR_API BOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned); /** * Frees memory allocated by WTSVirtualChannelQuery */ -FREERDP_API void WTSFreeMemory( - /* __in */ void* pMemory); + +WINPR_API VOID WTSFreeMemory(PVOID pMemory); /** * Reads data from the server end of a virtual channel. @@ -112,25 +121,21 @@ FREERDP_API void WTSFreeMemory( * The caller should use the file handle returned by WTSVirtualChannelQuery to * determine whether a packet has arrived. */ -FREERDP_API BOOL WTSVirtualChannelRead( - /* __in */ void* hChannelHandle, - /* __in */ UINT32 TimeOut, - /* __out */ BYTE* Buffer, - /* __in */ UINT32 BufferSize, - /* __out */ UINT32* pBytesRead); + +WINPR_API BOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead); /** * Writes data to the server end of a virtual channel. */ -FREERDP_API BOOL WTSVirtualChannelWrite( - /* __in */ void* hChannelHandle, - /* __in */ BYTE* Buffer, - /* __in */ UINT32 Length, - /* __out */ UINT32* pBytesWritten); + +WINPR_API BOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten); /** * Closes an open virtual channel handle. */ + +// WINPR_API BOOL WTSVirtualChannelClose(HANDLE hChannelHandle); + FREERDP_API BOOL WTSVirtualChannelClose( /* __in */ void* hChannelHandle); diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h index d675255c3..099fc3b2f 100644 --- a/winpr/include/winpr/wtsapi.h +++ b/winpr/include/winpr/wtsapi.h @@ -717,7 +717,9 @@ typedef struct _WTSUSERCONFIGW typedef enum _WTS_VIRTUAL_CLASS { WTSVirtualClientData, - WTSVirtualFileHandle + WTSVirtualFileHandle, + WTSVirtualEventHandle, /* Extended */ + WTSVirtualChannelReady /* Extended */ } WTS_VIRTUAL_CLASS; typedef struct _WTS_SESSION_ADDRESS