Vitual channel Program

Source: Internet
Author: User
1. Implementation of Virtual Channel

Rdp5.1 supports virtual channels (the same below) technology. A virtual channel is a custom set of independent data formats associated with the RDP protocol. This technology makes it unnecessary to change the RDP protocol and add new features.

In the following situations, the virtual channel technology is the most suitable. Of course, some other situations may also use virtual channels. We do not impose any special restrictions on the use of the virtual channel mechanism.
1. Common core devices, such as serial ports or printers
2. Redirect the File System
3. user programs, such as remote cut and Replication
4. Audio Devices

A virtual channel program requires a client component and a server component:
1. The server component runs on the terminal service server. It can be a user program or a core device.
2. The client component is a dynamic connection library. When the client of the terminal service is running, it must be loaded into the memory.

The following sections describe these components:
Virtual Channel server application
Virtual Channel Client
Virtual Channel client Registration
Remote-control persistent virtual channels

Note: The original path of this article is
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/wcerdp/htm/ceoriimplementingvirtualchannels. asp

Ii. virtual channel server application
The component that uses the virtual channel technical program must be a program in a client session running on the terminal service server. You must provide methods to run this program. The following methods can be used to run a program, such as a login script or a plan or script in the Start folder. Of course, the user can also activate the program.

You must save the server-side program of the virtual channel in the Registry by adding a sub-Key to the path under the Registry. HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/terminalserver/addins

The server program can call wtsvirtualchannelopen to obtain a virtual channel handle. in the program, you can use this handle to use the following methods.
Wtsvirtualchannelclose
Disable virtual channel
Wtsvirtualchannelpurgeinput
Clears all input data requests sent from the client in a virtual channel.
Wtsvirtualchannelpurgeoutput
Clears all output data requests from the client in a virtual channel.
Wtsvirtualchannelquery
Returns the information of a specified virtual channel.
Wtsvirtualchannelread
Read data from the End Server of a virtual channel
Wtsvirtualchannelwrite
Write Data from the End Server of a virtual channel

Virtual Channel Client
The client component of the virtual channel program is a dynamic Connection Library, which is loaded when the client terminal service of the customer computer is initialized. The dll must be registered on the client's computer. For more information, see the next article virtual channel client registry.

The client DLL exports a virtualchannelentry function, which is called during Terminal Service initialization. The virtualchannelentry points to a pointer to the channel_entry_points structure. This pointer will be used by the following functions, which are used by the client DLL to access the functions of the virtual channel.

Iii. virtualchannelinit
Register the name of the virtual channel used, and provide a virtualchannelinitevent callback function. Through this callback, the terminal service prompts the client to connect some events to the customer.
Virtualchannelopen
Open a customer at the end of a specified virtual channel and provide the virtualchannelopenevent callback function. Through this callback Terminal Service, the client is prompted to connect some events to the customer.
Virtualchannelwrite
Write Data in the virtual channel. The Terminal Service sends the data to the server of the virtual channel .. The server calls the wtsvirtualchannelread function to read the data.
Virtualchannelclose
Close a virtual channel

The virtualchannelentry function must call the virtualchannelinit function to initialize access to a virtual channel. When virtualchannelinit is called, a pointer to the virtualchannelinitevent callback function must be used. After the initialization is complete, the terminal service calls this function again after establishing a connection with a terminal server.

After the connection is established, you can call the virtualchannelopen function to open the virtual channel registered by the virtualchannelinit function. The virtualchannelopen function specifies a pointer for your virtualchannelopenevent callback function.

After the virtualchannelopen function is returned, you can call the virtualchannelwrite function to write the virtual channel. The write process is asynchronous, so you do not have to release or re-allocate the buffer until the virtualchannelopenevent function shows that the write process has been completed.

When you call the virtualchannelwrite function, you can refer to the write Process status through some user data. When you call virtualchannelopenevent, the terminal service notifies you that the write process has been completed by calling the returned user data. On the server at the end of the virtual channel, the server plug-in calls the wtsvirtualchannelread function to read the data.

When the server component writes the data to the server, the terminal service can also call the virtualchannelopenevent function to obtain the relevant information. The server component writes data to the server by calling the wtsvirtualchannelwrite function.

Client and server components can write data of any size in the virtual channel. However, before sending data, the terminal service splits the data into segments of the channel_chunk_length bytes. The terminal service calls the virtualchannelopenevent function for each data segment, instead of re-establishing the data into a package of the original size. Each call to virtualchannelopenevent shows the size of the data segment, and displays the start, center, or end of the data sending.

The virtualchannelclose function is used to close a channel. However, you do not have to use this function. Because when a crying user disconnects from the server, the terminal service automatically closes all channels.

Iv. Virtual Channel client Registration
You must register the client DLL name in the registry. Add the sub-key to one of the following paths.
HKEY_CURRENT_USER/software/Microsoft/Terminal Server Client/default/addins
HKEY_CURRENT_USER/software/Microsoft/Terminal Server Client/connection/addins

Join to the default/addins key applies to all connections. Join to the connection/addins key only applies to the specified connection. You can use the Connection Manager to create and manage the splitting.

The sub-key can be any name. It must contain a value of the REG_SZ or reg_expand_sz type. You can also add a REG_DWORD value. The following is a prototype of REG_SZ or reg_expand_sz.
Name = dllname

If you use a reg_expand_sz value, it includes an environment variable that is not extended and will be extended at runtime. The value of dllname is a full path. If the dllname does not include a full path, the standard DLL search path will be applied.

The following is a prototype of REG_DWORD.
Remotecontrolpersistent = Flag

The flag value is 1 or 0, and 0 is the default value. If the value is 1, the plug-in will not obtain information about the start and end of remote control. If the value is 0, the plug-in will not obtain information about the start and end of remote control.

5. Remote-control persistent virtual channels
In Windows CE. NET and Windows XP, a DLL can specify one or more virtual channels as permanent remote control. Such a channel will not be closed when the customer connects or disconnects a connection session. Data will be sent and received through this channel. Virtual channels that are not specified as permanent remote control will be disabled. The virtual channel with permanent remote control is specified by calling the virtualchannelinit function. For more information, see the virtualchannelinit function.

6. Disabling Terminal Services features
To enhance security, you can choose to block some functions of the Terminal Service, such as the clipboard redirection and pointer redirection when using Remote Desktop ActiveX Control connection.

How to shield Terminal Service Functions
1. Add the following key to the registry of the client computer.
HKEY_LOCAL_MACHINE/software/Microsoft/Terminal Server/disableclipredirection
HKEY_LOCAL_MACHINE/software/Microsoft/Terminal Server/disableprinterredirection
2. Set the values of these two keys to 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.