Click here to Skip to main content
12,816,406 members (32,312 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked
Posted 15 Jun 2010

User Mode Transport of the Library Via Virtual Channels

, , 15 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
In this article, we provide the library which can be used in client – server applications to cover transport layer using virtual channels.

General Description

Virtual channels are software extensions that can be used to add functional enhancements to a Remote Desktop Services application. Examples of functional enhancements may include support for special types of hardware, audio, or other additions to the core functionality provided by the Remote Desktop Services Remote Desktop Protocol (RDP).

To use virtual channels, you should provide the server-side and client-side modules of the virtual channels application. The server-side module can be a user-mode application or a kernel-mode driver. The client-side module must be a DLL.

Library Description

In this article, we provide the library which can be used in client – server applications to cover transport layer using virtual channels. Also we attached sample add-in project (client side) and sample server application.

The user interface definitions can be found in the RdcTransport.h header file. This is the master header and should be included in you project.

Interface Description

struct IVirtChannel
    virtual ~IVirtChannel() { }
    virtual void Write(Buffer* pBuffer) = 0; // may take a long time, 
				// need synchronization for multithreading

This structure is used for writing data to the client\server side.

struct IReadHandler
    virtual ~IReadHandler(){};
    virtual void OnRead(Buffer* pBuffer) throw() = 0;
    virtual void OnReadFail(const char* what) throw() = 0;

This structure is used for reading notifications from client\server side.

struct IClientVirtChannelCallback
    virtual ~IClientVirtChannelCallback() { }
    virtual void OnConnect() = 0;
    virtual void OnDisconnect() = 0;
    virtual void OnTerminate() = 0;

Callback interfaces for providing information about the client side connection.

struct IServerVirtChannelCallback
    virtual ~IServerVirtChannelCallback() { }
    virtual void OnDisconnect() = 0;
    virtual void OnReconnect() = 0;

Callback interfaces for providing information about the server side connection.

Build factory:

Client Side

std::auto_ptr<ivirtchannel /> CreateClientChannel(
    __in const char* szChannelName,
    __in PCHANNEL_ENTRY_POINTS pEntryPoints,
    __in IClientVirtChannelCallback* pCallback,
    __in IReadHandler* pReadHandler,
    __in bool bShowProtocol = false);

Server Side

std::auto_ptr<ivirtchannel> CreateServerChannel(
    __in const char* szChannelName,
    __in LPTSTR szAddinRGSName,
    __in IServerVirtChannelCallback* pCallback,
    __in IReadHandler* pReadHandler,
    __in bool bShowProtocol = false);

How To Use

Client Side

For the creation of the add-in DLL of the mstsc.exe file, you need to implement the following function in your DLL:


To work with the client side transport, you need to create the global object, which will contain your transport and provide read\write interfaces. You can do this in the following way:

std::auto_ptr<:ivirtchannel> channel;

        channel =  rdc_transport::CreateClientChannel
		("Test", pEntryPoints, &connection, &reader, false);
        return TRUE;
        // TODO:: add log for example
        return false;

where connection and reader are the objects, which implement the rdc_transport::IClientVirtChannelCallback and rdc_transport::IReadHandler interfaces.

Server Side

To use the server side of the virtual channel transport, you need to create the transport object in your code. This object provides read\write interfaces and contains the server side of the connection. For example, it can be performed in the main function:

int main()
std::auto_ptr<rdc_transport::IVirtChannel> ch = 
	rdc_transport::CreateServerChannel("Test", L"Test",&cc, &rh);

where cc and rh are the objects, which implement the rdc_transport::IServerVirtChannelCallback and rdc_transport::IReadHandler interfaces.

To close the server side connection, destroy the ch object.

You can find the sample of implementation in the test solution.

Build Requirements


  • Visual Studio 2008 sp1
  • Boost 1.40.0 source code (see
  • Nullsoft Scriptable Install System (NSIS) 2.45 or higher (see It is used only for the sample and is not required for the library.

Environment Variables

  • NSIS - should contain the path where NSIS is installed
  • BOOST_ROOT - should contain the path to the Boost directory

Preparing Build System

Before building the sample solution from the source code, you should perform several simple preliminary steps. First of all, you should install all the applications specified in the Build requirements section, and set the environment variables, which are also specified in the section mentioned above.

After that, you should build Boost libraries from the source code. To do this, go to the Boost directory (BOOST_ROOT) and invoke the following two commands one after another:)

  1. bootstrap.bat
  2. bjam.exe toolset=msvc --build-type=complete

That should be enough. For more detailed information, see the Boost documentation.



  • 15th June, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Authors

Sergey Popenko
Software Developer (Junior) ApriorIT
Ukraine Ukraine
Sergey Popenko.
22 years old.
The Driver Team`s software developer.
Master of the Applied Math faculty, the Dnipropetrovsk National University, Ukraine.

Apriorit Inc
Apriorit Inc.
Hungary Hungary
ApriorIT is a Software Research and Development company that works in advanced knowledge-intensive scopes.

Company offers integrated research&development services for the software projects in such directions as Corporate Security, Remote Control, Mobile Development, Embedded Systems, Virtualization, Drivers and others.

Official site
Group type: Organisation

32 members

You may also be interested in...


Comments and Discussions

QuestionWindows 7 / Windows 2008 R2 Pin
Xokar24-Feb-11 7:15
memberXokar24-Feb-11 7:15 
AnswerRe: Windows 7 / Windows 2008 R2 Pin
Abhishek Parajuli15-May-13 8:18
memberAbhishek Parajuli15-May-13 8:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 15 Jun 2010
Article Copyright 2010 by Sergey Popenko, Apriorit Inc
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid