Click here to Skip to main content
Click here to Skip to main content

Tagged as

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:

BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS  pEntryPoints)
{
}

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;

BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS  pEntryPoints)
{
    try
    {
        channel =  rdc_transport::CreateClientChannel
		("Test", pEntryPoints, &connection, &reader, false);
        
        return TRUE;
    }
    catch(...)
    {
        // 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

Software

  • Visual Studio 2008 sp1
  • Boost 1.40.0 source code (see http://boost.org)
  • Nullsoft Scriptable Install System (NSIS) 2.45 or higher (see http://nsis.sourceforge.net/). 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 anotherSmile | :)

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

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

Links

History

  • 15th June, 2010: Initial post

License

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

Share

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.
Ukraine Ukraine
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 http://www.apriorit.com
Group type: Organisation

31 members

Follow on   LinkedIn

Comments and Discussions

 
QuestionClient to Server Messages PinmemberAbhishek Parajuli17-May-13 4:33 
QuestionHanging server apps following CreateServerChannel calls from a DLL PinmemberDesmond Kearns4-Aug-11 0:53 
AnswerRe: Hanging server apps following CreateServerChannel calls from a DLL PinmemberAbhishek Parajuli15-May-13 8:30 
BugClient response messages not being cleared from the channel Buffer [modified] PinmemberDesmond Kearns11-Jul-11 0:39 
SuggestionRe: Client response messages not being cleared from the channel Buffer PinmemberDesmond Kearns4-Aug-11 0:55 
GeneralRe: Client response messages not being cleared from the channel Buffer PinmemberAbhishek Parajuli15-May-13 8:20 
QuestionWindows 7 / Windows 2008 R2 PinmemberXokar24-Feb-11 7:15 
AnswerRe: Windows 7 / Windows 2008 R2 PinmemberAbhishek Parajuli15-May-13 8:18 

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

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

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