2011-12-11 15:49:08 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-12-11 15:49:08 +04:00
|
|
|
* Server Virtual Channel Interface
|
|
|
|
*
|
|
|
|
* Copyright 2011-2012 Vic Lee
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The server-side virtual channel API follows the Microsoft Remote Desktop
|
|
|
|
* Services API functions WTSVirtualChannel* defined in:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa383464.aspx
|
|
|
|
*
|
|
|
|
* Difference between the MS API are documented in this header. All functions
|
|
|
|
* are implemented in and integrated with libfreerdp-channels.
|
|
|
|
*
|
2011-12-12 12:42:42 +04:00
|
|
|
* Unlike MS API, all functions except WTSVirtualChannelOpenEx in this
|
|
|
|
* implementation are thread-safe.
|
2011-12-11 15:49:08 +04:00
|
|
|
*/
|
|
|
|
|
2012-12-14 09:25:48 +04:00
|
|
|
#ifndef FREERDP_WTSVC_H
|
|
|
|
#define FREERDP_WTSVC_H
|
2011-12-11 15:49:08 +04:00
|
|
|
|
|
|
|
#include <freerdp/types.h>
|
|
|
|
#include <freerdp/peer.h>
|
|
|
|
|
2011-12-12 12:42:42 +04:00
|
|
|
typedef struct WTSVirtualChannelManager WTSVirtualChannelManager;
|
|
|
|
|
2011-12-11 15:49:08 +04:00
|
|
|
#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001
|
|
|
|
|
|
|
|
typedef enum _WTS_VIRTUAL_CLASS
|
|
|
|
{
|
|
|
|
WTSVirtualClientData,
|
2012-06-25 16:32:58 +04:00
|
|
|
WTSVirtualFileHandle,
|
|
|
|
WTSVirtualChannelReady
|
2011-12-11 15:49:08 +04:00
|
|
|
} WTS_VIRTUAL_CLASS;
|
|
|
|
|
2011-12-12 12:42:42 +04:00
|
|
|
/**
|
|
|
|
* WTSVirtualChannelManager functions are FreeRDP extensions to the API.
|
|
|
|
*/
|
|
|
|
FREERDP_API WTSVirtualChannelManager* WTSCreateVirtualChannelManager(freerdp_peer* client);
|
|
|
|
FREERDP_API void WTSDestroyVirtualChannelManager(WTSVirtualChannelManager* vcm);
|
|
|
|
FREERDP_API void WTSVirtualChannelManagerGetFileDescriptor(WTSVirtualChannelManager* vcm,
|
|
|
|
void** fds, int* fds_count);
|
2012-10-09 10:38:39 +04:00
|
|
|
FREERDP_API BOOL WTSVirtualChannelManagerCheckFileDescriptor(WTSVirtualChannelManager* vcm);
|
2011-12-12 12:42:42 +04:00
|
|
|
|
2011-12-11 15:49:08 +04:00
|
|
|
/**
|
|
|
|
* Opens a static or dynamic virtual channel and return the handle. If the
|
|
|
|
* operation fails, a NULL handle is returned.
|
|
|
|
*
|
|
|
|
* The original MS API has 'DWORD SessionId' as the first argument, while we
|
2011-12-12 12:42:42 +04:00
|
|
|
* use our WTSVirtualChannelManager object instead.
|
|
|
|
*
|
2012-06-25 12:41:59 +04:00
|
|
|
* Static virtual channels must be opened from the main thread. Dynamic virtual channels
|
|
|
|
* can be opened from any thread.
|
2011-12-11 15:49:08 +04:00
|
|
|
*/
|
|
|
|
FREERDP_API void* WTSVirtualChannelOpenEx(
|
2011-12-12 12:42:42 +04:00
|
|
|
/* __in */ WTSVirtualChannelManager* vcm,
|
2011-12-11 15:49:08 +04:00
|
|
|
/* __in */ const char* pVirtualName,
|
2012-10-09 11:26:39 +04:00
|
|
|
/* __in */ UINT32 flags);
|
2011-12-11 15:49:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns information about a specified virtual channel.
|
|
|
|
*
|
|
|
|
* Servers use this function to gain access to a virtual channel file handle
|
|
|
|
* that can be used for asynchronous I/O.
|
|
|
|
*/
|
2012-10-09 10:38:39 +04:00
|
|
|
FREERDP_API BOOL WTSVirtualChannelQuery(
|
2011-12-11 15:49:08 +04:00
|
|
|
/* __in */ void* hChannelHandle,
|
|
|
|
/* __in */ WTS_VIRTUAL_CLASS WtsVirtualClass,
|
|
|
|
/* __out */ void** ppBuffer,
|
2012-10-09 11:26:39 +04:00
|
|
|
/* __out */ UINT32* pBytesReturned);
|
2011-12-11 15:49:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees memory allocated by WTSVirtualChannelQuery
|
|
|
|
*/
|
|
|
|
FREERDP_API void WTSFreeMemory(
|
|
|
|
/* __in */ void* pMemory);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads data from the server end of a virtual channel.
|
2011-12-12 17:07:23 +04:00
|
|
|
*
|
|
|
|
* FreeRDP behavior:
|
|
|
|
*
|
|
|
|
* This function will always return a complete channel data packet, i.e. chunks
|
|
|
|
* are already assembled. If BufferSize argument is smaller than the packet
|
2012-10-09 10:31:28 +04:00
|
|
|
* size, it will set the desired size in pBytesRead and return FALSE. The
|
2011-12-12 17:07:23 +04:00
|
|
|
* caller should allocate a large enough buffer and call this function again.
|
2012-10-09 10:31:28 +04:00
|
|
|
* Returning FALSE with pBytesRead set to zero indicates an error has occurred.
|
2011-12-12 17:07:23 +04:00
|
|
|
* If no pending packet to be read, it will set pBytesRead to zero and return
|
2012-10-09 10:31:28 +04:00
|
|
|
* TRUE.
|
2011-12-12 17:07:23 +04:00
|
|
|
*
|
|
|
|
* TimeOut is not supported, and this function will always return immediately.
|
|
|
|
* The caller should use the file handle returned by WTSVirtualChannelQuery to
|
|
|
|
* determine whether a packet has arrived.
|
2011-12-11 15:49:08 +04:00
|
|
|
*/
|
2012-10-09 10:38:39 +04:00
|
|
|
FREERDP_API BOOL WTSVirtualChannelRead(
|
2011-12-11 15:49:08 +04:00
|
|
|
/* __in */ void* hChannelHandle,
|
2012-10-09 11:26:39 +04:00
|
|
|
/* __in */ UINT32 TimeOut,
|
2012-10-09 11:01:37 +04:00
|
|
|
/* __out */ BYTE* Buffer,
|
2012-10-09 11:26:39 +04:00
|
|
|
/* __in */ UINT32 BufferSize,
|
|
|
|
/* __out */ UINT32* pBytesRead);
|
2011-12-11 15:49:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes data to the server end of a virtual channel.
|
|
|
|
*/
|
2012-10-09 10:38:39 +04:00
|
|
|
FREERDP_API BOOL WTSVirtualChannelWrite(
|
2011-12-11 15:49:08 +04:00
|
|
|
/* __in */ void* hChannelHandle,
|
2012-10-09 11:01:37 +04:00
|
|
|
/* __in */ BYTE* Buffer,
|
2012-10-09 11:26:39 +04:00
|
|
|
/* __in */ UINT32 Length,
|
|
|
|
/* __out */ UINT32* pBytesWritten);
|
2011-12-11 15:49:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes an open virtual channel handle.
|
|
|
|
*/
|
2012-10-09 10:38:39 +04:00
|
|
|
FREERDP_API BOOL WTSVirtualChannelClose(
|
2011-12-11 15:49:08 +04:00
|
|
|
/* __in */ void* hChannelHandle);
|
|
|
|
|
2012-12-14 09:25:48 +04:00
|
|
|
#endif /* FREERDP_WTSVC_H */
|