channels/rdpdr: start server-side device redirection
This commit is contained in:
parent
af93bee5d2
commit
363bd27d76
@ -20,3 +20,7 @@ define_channel("rdpdr")
|
|||||||
if(WITH_CLIENT_CHANNELS)
|
if(WITH_CLIENT_CHANNELS)
|
||||||
add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME})
|
add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_SERVER_CHANNELS)
|
||||||
|
add_channel_server(${MODULE_PREFIX} ${CHANNEL_NAME})
|
||||||
|
endif()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
set(OPTION_DEFAULT OFF)
|
set(OPTION_DEFAULT OFF)
|
||||||
set(OPTION_CLIENT_DEFAULT ON)
|
set(OPTION_CLIENT_DEFAULT ON)
|
||||||
set(OPTION_SERVER_DEFAULT OFF)
|
set(OPTION_SERVER_DEFAULT ON)
|
||||||
|
|
||||||
define_channel_options(NAME "rdpdr" TYPE "static"
|
define_channel_options(NAME "rdpdr" TYPE "static"
|
||||||
DESCRIPTION "Device Redirection Virtual Channel Extension"
|
DESCRIPTION "Device Redirection Virtual Channel Extension"
|
||||||
|
@ -33,132 +33,132 @@
|
|||||||
#include "rdpdr_capabilities.h"
|
#include "rdpdr_capabilities.h"
|
||||||
|
|
||||||
/* Output device redirection capability set header */
|
/* Output device redirection capability set header */
|
||||||
static void rdpdr_write_capset_header(wStream* data_out, UINT16 capabilityType, UINT16 capabilityLength, UINT32 version)
|
static void rdpdr_write_capset_header(wStream* s, UINT16 capabilityType, UINT16 capabilityLength, UINT32 version)
|
||||||
{
|
{
|
||||||
Stream_Write_UINT16(data_out, capabilityType);
|
Stream_Write_UINT16(s, capabilityType);
|
||||||
Stream_Write_UINT16(data_out, capabilityLength);
|
Stream_Write_UINT16(s, capabilityLength);
|
||||||
Stream_Write_UINT32(data_out, version);
|
Stream_Write_UINT32(s, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output device direction general capability set */
|
/* Output device direction general capability set */
|
||||||
static void rdpdr_write_general_capset(rdpdrPlugin* rdpdr, wStream* data_out)
|
static void rdpdr_write_general_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
rdpdr_write_capset_header(data_out, CAP_GENERAL_TYPE, 44, GENERAL_CAPABILITY_VERSION_02);
|
rdpdr_write_capset_header(s, CAP_GENERAL_TYPE, 44, GENERAL_CAPABILITY_VERSION_02);
|
||||||
|
|
||||||
Stream_Write_UINT32(data_out, 0); /* osType, ignored on receipt */
|
Stream_Write_UINT32(s, 0); /* osType, ignored on receipt */
|
||||||
Stream_Write_UINT32(data_out, 0); /* osVersion, unused and must be set to zero */
|
Stream_Write_UINT32(s, 0); /* osVersion, unused and must be set to zero */
|
||||||
Stream_Write_UINT16(data_out, 1); /* protocolMajorVersion, must be set to 1 */
|
Stream_Write_UINT16(s, 1); /* protocolMajorVersion, must be set to 1 */
|
||||||
Stream_Write_UINT16(data_out, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */
|
Stream_Write_UINT16(s, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */
|
||||||
Stream_Write_UINT32(data_out, 0x0000FFFF); /* ioCode1 */
|
Stream_Write_UINT32(s, 0x0000FFFF); /* ioCode1 */
|
||||||
Stream_Write_UINT32(data_out, 0); /* ioCode2, must be set to zero, reserved for future use */
|
Stream_Write_UINT32(s, 0); /* ioCode2, must be set to zero, reserved for future use */
|
||||||
Stream_Write_UINT32(data_out, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */
|
Stream_Write_UINT32(s, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */
|
||||||
Stream_Write_UINT32(data_out, ENABLE_ASYNCIO); /* extraFlags1 */
|
Stream_Write_UINT32(s, ENABLE_ASYNCIO); /* extraFlags1 */
|
||||||
Stream_Write_UINT32(data_out, 0); /* extraFlags2, must be set to zero, reserved for future use */
|
Stream_Write_UINT32(s, 0); /* extraFlags2, must be set to zero, reserved for future use */
|
||||||
Stream_Write_UINT32(data_out, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */
|
Stream_Write_UINT32(s, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process device direction general capability set */
|
/* Process device direction general capability set */
|
||||||
static void rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
static void rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 capabilityLength;
|
UINT16 capabilityLength;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, capabilityLength);
|
Stream_Read_UINT16(s, capabilityLength);
|
||||||
Stream_Seek(data_in, capabilityLength - 4);
|
Stream_Seek(s, capabilityLength - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output printer direction capability set */
|
/* Output printer direction capability set */
|
||||||
static void rdpdr_write_printer_capset(rdpdrPlugin* rdpdr, wStream* data_out)
|
static void rdpdr_write_printer_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
rdpdr_write_capset_header(data_out, CAP_PRINTER_TYPE, 8, PRINT_CAPABILITY_VERSION_01);
|
rdpdr_write_capset_header(s, CAP_PRINTER_TYPE, 8, PRINT_CAPABILITY_VERSION_01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process printer direction capability set */
|
/* Process printer direction capability set */
|
||||||
static void rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
static void rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 capabilityLength;
|
UINT16 capabilityLength;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, capabilityLength);
|
Stream_Read_UINT16(s, capabilityLength);
|
||||||
Stream_Seek(data_in, capabilityLength - 4);
|
Stream_Seek(s, capabilityLength - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output port redirection capability set */
|
/* Output port redirection capability set */
|
||||||
static void rdpdr_write_port_capset(rdpdrPlugin* rdpdr, wStream* data_out)
|
static void rdpdr_write_port_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
rdpdr_write_capset_header(data_out, CAP_PORT_TYPE, 8, PORT_CAPABILITY_VERSION_01);
|
rdpdr_write_capset_header(s, CAP_PORT_TYPE, 8, PORT_CAPABILITY_VERSION_01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process port redirection capability set */
|
/* Process port redirection capability set */
|
||||||
static void rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
static void rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 capabilityLength;
|
UINT16 capabilityLength;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, capabilityLength);
|
Stream_Read_UINT16(s, capabilityLength);
|
||||||
Stream_Seek(data_in, capabilityLength - 4);
|
Stream_Seek(s, capabilityLength - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output drive redirection capability set */
|
/* Output drive redirection capability set */
|
||||||
static void rdpdr_write_drive_capset(rdpdrPlugin* rdpdr, wStream* data_out)
|
static void rdpdr_write_drive_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
rdpdr_write_capset_header(data_out, CAP_DRIVE_TYPE, 8, DRIVE_CAPABILITY_VERSION_02);
|
rdpdr_write_capset_header(s, CAP_DRIVE_TYPE, 8, DRIVE_CAPABILITY_VERSION_02);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process drive redirection capability set */
|
/* Process drive redirection capability set */
|
||||||
static void rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
static void rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 capabilityLength;
|
UINT16 capabilityLength;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, capabilityLength);
|
Stream_Read_UINT16(s, capabilityLength);
|
||||||
Stream_Seek(data_in, capabilityLength - 4);
|
Stream_Seek(s, capabilityLength - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output smart card redirection capability set */
|
/* Output smart card redirection capability set */
|
||||||
static void rdpdr_write_smartcard_capset(rdpdrPlugin* rdpdr, wStream* data_out)
|
static void rdpdr_write_smartcard_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
rdpdr_write_capset_header(data_out, CAP_SMARTCARD_TYPE, 8, SMARTCARD_CAPABILITY_VERSION_01);
|
rdpdr_write_capset_header(s, CAP_SMARTCARD_TYPE, 8, SMARTCARD_CAPABILITY_VERSION_01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process smartcard redirection capability set */
|
/* Process smartcard redirection capability set */
|
||||||
static void rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* data_in)
|
static void rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 capabilityLength;
|
UINT16 capabilityLength;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, capabilityLength);
|
Stream_Read_UINT16(s, capabilityLength);
|
||||||
Stream_Seek(data_in, capabilityLength - 4);
|
Stream_Seek(s, capabilityLength - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in)
|
void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s)
|
||||||
{
|
{
|
||||||
UINT16 i;
|
UINT16 i;
|
||||||
UINT16 numCapabilities;
|
UINT16 numCapabilities;
|
||||||
UINT16 capabilityType;
|
UINT16 capabilityType;
|
||||||
|
|
||||||
Stream_Read_UINT16(data_in, numCapabilities);
|
Stream_Read_UINT16(s, numCapabilities);
|
||||||
Stream_Seek(data_in, 2); /* pad (2 bytes) */
|
Stream_Seek(s, 2); /* pad (2 bytes) */
|
||||||
|
|
||||||
for(i = 0; i < numCapabilities; i++)
|
for (i = 0; i < numCapabilities; i++)
|
||||||
{
|
{
|
||||||
Stream_Read_UINT16(data_in, capabilityType);
|
Stream_Read_UINT16(s, capabilityType);
|
||||||
|
|
||||||
switch (capabilityType)
|
switch (capabilityType)
|
||||||
{
|
{
|
||||||
case CAP_GENERAL_TYPE:
|
case CAP_GENERAL_TYPE:
|
||||||
rdpdr_process_general_capset(rdpdr, data_in);
|
rdpdr_process_general_capset(rdpdr, s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_PRINTER_TYPE:
|
case CAP_PRINTER_TYPE:
|
||||||
rdpdr_process_printer_capset(rdpdr, data_in);
|
rdpdr_process_printer_capset(rdpdr, s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_PORT_TYPE:
|
case CAP_PORT_TYPE:
|
||||||
rdpdr_process_port_capset(rdpdr, data_in);
|
rdpdr_process_port_capset(rdpdr, s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_DRIVE_TYPE:
|
case CAP_DRIVE_TYPE:
|
||||||
rdpdr_process_drive_capset(rdpdr, data_in);
|
rdpdr_process_drive_capset(rdpdr, s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_SMARTCARD_TYPE:
|
case CAP_SMARTCARD_TYPE:
|
||||||
rdpdr_process_smartcard_capset(rdpdr, data_in);
|
rdpdr_process_smartcard_capset(rdpdr, s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -170,21 +170,21 @@ void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in)
|
|||||||
|
|
||||||
void rdpdr_send_capability_response(rdpdrPlugin* rdpdr)
|
void rdpdr_send_capability_response(rdpdrPlugin* rdpdr)
|
||||||
{
|
{
|
||||||
wStream* data_out;
|
wStream* s;
|
||||||
|
|
||||||
data_out = Stream_New(NULL, 256);
|
s = Stream_New(NULL, 256);
|
||||||
|
|
||||||
Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE);
|
Stream_Write_UINT16(s, RDPDR_CTYP_CORE);
|
||||||
Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_CAPABILITY);
|
Stream_Write_UINT16(s, PAKID_CORE_CLIENT_CAPABILITY);
|
||||||
|
|
||||||
Stream_Write_UINT16(data_out, 5); /* numCapabilities */
|
Stream_Write_UINT16(s, 5); /* numCapabilities */
|
||||||
Stream_Write_UINT16(data_out, 0); /* pad */
|
Stream_Write_UINT16(s, 0); /* pad */
|
||||||
|
|
||||||
rdpdr_write_general_capset(rdpdr, data_out);
|
rdpdr_write_general_capset(rdpdr, s);
|
||||||
rdpdr_write_printer_capset(rdpdr, data_out);
|
rdpdr_write_printer_capset(rdpdr, s);
|
||||||
rdpdr_write_port_capset(rdpdr, data_out);
|
rdpdr_write_port_capset(rdpdr, s);
|
||||||
rdpdr_write_drive_capset(rdpdr, data_out);
|
rdpdr_write_drive_capset(rdpdr, s);
|
||||||
rdpdr_write_smartcard_capset(rdpdr, data_out);
|
rdpdr_write_smartcard_capset(rdpdr, s);
|
||||||
|
|
||||||
svc_plugin_send((rdpSvcPlugin*)rdpdr, data_out);
|
svc_plugin_send((rdpSvcPlugin*)rdpdr, s);
|
||||||
}
|
}
|
||||||
|
35
channels/rdpdr/server/CMakeLists.txt
Normal file
35
channels/rdpdr/server/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# FreeRDP: A Remote Desktop Protocol Implementation
|
||||||
|
# FreeRDP cmake build script
|
||||||
|
#
|
||||||
|
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
define_channel_server("rdpdr")
|
||||||
|
|
||||||
|
set(${MODULE_PREFIX}_SRCS
|
||||||
|
rdpdr_main.c
|
||||||
|
rdpdr_main.h)
|
||||||
|
|
||||||
|
add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE "VirtualChannelEntry")
|
||||||
|
|
||||||
|
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||||
|
|
||||||
|
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||||
|
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||||
|
MODULE freerdp
|
||||||
|
MODULES freerdp-utils)
|
||||||
|
|
||||||
|
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||||
|
|
||||||
|
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")
|
572
channels/rdpdr/server/rdpdr_main.c
Normal file
572
channels/rdpdr/server/rdpdr_main.c
Normal file
@ -0,0 +1,572 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||||
|
* Device Redirection Virtual Channel Extension
|
||||||
|
*
|
||||||
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
#include <winpr/print.h>
|
||||||
|
#include <winpr/stream.h>
|
||||||
|
|
||||||
|
#include "rdpdr_main.h"
|
||||||
|
|
||||||
|
static UINT32 g_ClientId = 0;
|
||||||
|
|
||||||
|
static int cliprdr_server_send_announce_request(RdpdrServerContext* context)
|
||||||
|
{
|
||||||
|
wStream* s;
|
||||||
|
BOOL status;
|
||||||
|
RDPDR_HEADER header;
|
||||||
|
|
||||||
|
printf("RdpdrServerSendAnnounceRequest\n");
|
||||||
|
|
||||||
|
header.Component = RDPDR_CTYP_CORE;
|
||||||
|
header.PacketId = PAKID_CORE_SERVER_ANNOUNCE;
|
||||||
|
|
||||||
|
s = Stream_New(NULL, RDPDR_HEADER_LENGTH + 8);
|
||||||
|
|
||||||
|
Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
|
||||||
|
|
||||||
|
Stream_Write_UINT16(s, context->priv->VersionMajor); /* VersionMajor (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, context->priv->VersionMinor); /* VersionMinor (2 bytes) */
|
||||||
|
Stream_Write_UINT32(s, context->priv->ClientId); /* ClientId (4 bytes) */
|
||||||
|
|
||||||
|
Stream_SealLength(s);
|
||||||
|
|
||||||
|
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL);
|
||||||
|
|
||||||
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_receive_announce_response(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
|
||||||
|
{
|
||||||
|
UINT32 ClientId;
|
||||||
|
UINT16 VersionMajor;
|
||||||
|
UINT16 VersionMinor;
|
||||||
|
|
||||||
|
Stream_Read_UINT16(s, VersionMajor); /* VersionMajor (2 bytes) */
|
||||||
|
Stream_Read_UINT16(s, VersionMinor); /* VersionMinor (2 bytes) */
|
||||||
|
Stream_Read_UINT32(s, ClientId); /* ClientId (4 bytes) */
|
||||||
|
|
||||||
|
printf("Client Announce Response: VersionMajor: 0x%04X VersionMinor: 0x%04X ClientId: 0x%04X\n",
|
||||||
|
VersionMajor, VersionMinor, ClientId);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_receive_client_name_request(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
|
||||||
|
{
|
||||||
|
UINT32 UnicodeFlag;
|
||||||
|
UINT32 ComputerNameLen;
|
||||||
|
|
||||||
|
Stream_Read_UINT32(s, UnicodeFlag); /* UnicodeFlag (4 bytes) */
|
||||||
|
Stream_Seek_UINT32(s); /* CodePage (4 bytes), MUST be set to zero */
|
||||||
|
Stream_Read_UINT32(s, ComputerNameLen); /* ComputerNameLen (4 bytes) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caution: ComputerNameLen is given *bytes*,
|
||||||
|
* not in characters, including the NULL terminator!
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (UnicodeFlag)
|
||||||
|
{
|
||||||
|
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
|
||||||
|
-1, &(context->priv->ClientComputerName), 0, NULL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context->priv->ClientComputerName = _strdup((char*) Stream_Pointer(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream_Seek(s, ComputerNameLen);
|
||||||
|
|
||||||
|
printf("ClientComputerName: %s\n", context->priv->ClientComputerName);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_capability_set_header(wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
Stream_Read_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
|
||||||
|
Stream_Read_UINT16(s, header->CapabilityLength); /* CapabilityLength (2 bytes) */
|
||||||
|
Stream_Read_UINT32(s, header->Version); /* Version (4 bytes) */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_capability_set_header(wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
Stream_Write_UINT16(s, header->CapabilityType); /* CapabilityType (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, header->CapabilityLength); /* CapabilityLength (2 bytes) */
|
||||||
|
Stream_Write_UINT32(s, header->Version); /* Version (4 bytes) */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_general_capability_set(RdpdrServerContext* context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
UINT32 ioCode1;
|
||||||
|
UINT32 extraFlags1;
|
||||||
|
UINT32 extendedPdu;
|
||||||
|
UINT16 VersionMajor;
|
||||||
|
UINT16 VersionMinor;
|
||||||
|
UINT32 SpecialTypeDeviceCap;
|
||||||
|
|
||||||
|
Stream_Seek_UINT32(s); /* osType (4 bytes), ignored on receipt */
|
||||||
|
Stream_Seek_UINT32(s); /* osVersion (4 bytes), unused and must be set to zero */
|
||||||
|
Stream_Read_UINT16(s, VersionMajor); /* protocolMajorVersion (2 bytes) */
|
||||||
|
Stream_Read_UINT16(s, VersionMinor); /* protocolMinorVersion (2 bytes) */
|
||||||
|
Stream_Read_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
|
||||||
|
Stream_Seek_UINT32(s); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
|
||||||
|
Stream_Read_UINT32(s, extendedPdu); /* extendedPdu (4 bytes) */
|
||||||
|
Stream_Read_UINT32(s, extraFlags1); /* extraFlags1 (4 bytes) */
|
||||||
|
Stream_Seek_UINT32(s); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
|
||||||
|
Stream_Read_UINT32(s, SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_general_capability_set(RdpdrServerContext* context, wStream* s)
|
||||||
|
{
|
||||||
|
UINT32 ioCode1;
|
||||||
|
UINT32 extendedPdu;
|
||||||
|
UINT32 extraFlags1;
|
||||||
|
UINT32 SpecialTypeDeviceCap;
|
||||||
|
RDPDR_CAPABILITY_HEADER header;
|
||||||
|
|
||||||
|
header.CapabilityType = CAP_GENERAL_TYPE;
|
||||||
|
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH + 36;
|
||||||
|
header.Version = GENERAL_CAPABILITY_VERSION_02;
|
||||||
|
|
||||||
|
ioCode1 = 0;
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_CREATE; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_CLEANUP; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_CLOSE; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_READ; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_WRITE; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_FLUSH_BUFFERS; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_SHUTDOWN; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_DEVICE_CONTROL; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_QUERY_VOLUME_INFORMATION; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_SET_VOLUME_INFORMATION; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_QUERY_INFORMATION; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_SET_INFORMATION; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_DIRECTORY_CONTROL; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_LOCK_CONTROL; /* always set */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_QUERY_SECURITY; /* optional */
|
||||||
|
ioCode1 |= RDPDR_IRP_MJ_SET_SECURITY; /* optional */
|
||||||
|
|
||||||
|
extendedPdu = 0;
|
||||||
|
extendedPdu |= RDPDR_CLIENT_DISPLAY_NAME_PDU; /* always set */
|
||||||
|
extendedPdu |= RDPDR_DEVICE_REMOVE_PDUS; /* optional */
|
||||||
|
extendedPdu |= RDPDR_USER_LOGGEDON_PDU; /* optional */
|
||||||
|
|
||||||
|
extraFlags1 = 0;
|
||||||
|
extraFlags1 |= ENABLE_ASYNCIO; /* optional */
|
||||||
|
|
||||||
|
SpecialTypeDeviceCap = 0;
|
||||||
|
|
||||||
|
Stream_EnsureRemainingCapacity(s, header.CapabilityLength);
|
||||||
|
rdpdr_server_write_capability_set_header(s, &header);
|
||||||
|
|
||||||
|
Stream_Write_UINT32(s, 0); /* osType (4 bytes), ignored on receipt */
|
||||||
|
Stream_Write_UINT32(s, 0); /* osVersion (4 bytes), unused and must be set to zero */
|
||||||
|
Stream_Write_UINT16(s, context->priv->VersionMajor); /* protocolMajorVersion (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, context->priv->VersionMinor); /* protocolMinorVersion (2 bytes) */
|
||||||
|
Stream_Write_UINT32(s, ioCode1); /* ioCode1 (4 bytes) */
|
||||||
|
Stream_Write_UINT32(s, 0); /* ioCode2 (4 bytes), must be set to zero, reserved for future use */
|
||||||
|
Stream_Write_UINT32(s, extendedPdu); /* extendedPdu (4 bytes) */
|
||||||
|
Stream_Write_UINT32(s, extraFlags1); /* extraFlags1 (4 bytes) */
|
||||||
|
Stream_Write_UINT32(s, 0); /* extraFlags2 (4 bytes), must be set to zero, reserved for future use */
|
||||||
|
Stream_Write_UINT32(s, SpecialTypeDeviceCap); /* SpecialTypeDeviceCap (4 bytes) */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_printer_capability_set(RdpdrServerContext* context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_printer_capability_set(RdpdrServerContext* context, wStream* s)
|
||||||
|
{
|
||||||
|
RDPDR_CAPABILITY_HEADER header;
|
||||||
|
|
||||||
|
header.CapabilityType = CAP_PRINTER_TYPE;
|
||||||
|
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH;
|
||||||
|
header.Version = PRINT_CAPABILITY_VERSION_01;
|
||||||
|
|
||||||
|
Stream_EnsureRemainingCapacity(s, header.CapabilityLength);
|
||||||
|
rdpdr_server_write_capability_set_header(s, &header);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_port_capability_set(RdpdrServerContext* context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_port_capability_set(RdpdrServerContext* context, wStream* s)
|
||||||
|
{
|
||||||
|
RDPDR_CAPABILITY_HEADER header;
|
||||||
|
|
||||||
|
header.CapabilityType = CAP_PORT_TYPE;
|
||||||
|
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH;
|
||||||
|
header.Version = PORT_CAPABILITY_VERSION_01;
|
||||||
|
|
||||||
|
Stream_EnsureRemainingCapacity(s, header.CapabilityLength);
|
||||||
|
rdpdr_server_write_capability_set_header(s, &header);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_drive_capability_set(RdpdrServerContext* context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_drive_capability_set(RdpdrServerContext* context, wStream* s)
|
||||||
|
{
|
||||||
|
RDPDR_CAPABILITY_HEADER header;
|
||||||
|
|
||||||
|
header.CapabilityType = CAP_DRIVE_TYPE;
|
||||||
|
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH;
|
||||||
|
header.Version = DRIVE_CAPABILITY_VERSION_02;
|
||||||
|
|
||||||
|
Stream_EnsureRemainingCapacity(s, header.CapabilityLength);
|
||||||
|
rdpdr_server_write_capability_set_header(s, &header);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_read_smartcard_capability_set(RdpdrServerContext* context, wStream* s, RDPDR_CAPABILITY_HEADER* header)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_write_smartcard_capability_set(RdpdrServerContext* context, wStream* s)
|
||||||
|
{
|
||||||
|
RDPDR_CAPABILITY_HEADER header;
|
||||||
|
|
||||||
|
header.CapabilityType = CAP_SMARTCARD_TYPE;
|
||||||
|
header.CapabilityLength = RDPDR_CAPABILITY_HEADER_LENGTH;
|
||||||
|
header.Version = SMARTCARD_CAPABILITY_VERSION_01;
|
||||||
|
|
||||||
|
Stream_EnsureRemainingCapacity(s, header.CapabilityLength);
|
||||||
|
rdpdr_server_write_capability_set_header(s, &header);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_send_core_capability_request(RdpdrServerContext* context)
|
||||||
|
{
|
||||||
|
wStream* s;
|
||||||
|
BOOL status;
|
||||||
|
RDPDR_HEADER header;
|
||||||
|
UINT16 numCapabilities;
|
||||||
|
|
||||||
|
printf("RdpdrServerSendCoreCapabilityRequest\n");
|
||||||
|
|
||||||
|
header.Component = RDPDR_CTYP_CORE;
|
||||||
|
header.PacketId = PAKID_CORE_SERVER_CAPABILITY;
|
||||||
|
|
||||||
|
numCapabilities = 5;
|
||||||
|
|
||||||
|
s = Stream_New(NULL, RDPDR_HEADER_LENGTH + 512);
|
||||||
|
|
||||||
|
Stream_Write_UINT16(s, header.Component); /* Component (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
|
||||||
|
|
||||||
|
Stream_Write_UINT16(s, numCapabilities); /* numCapabilities (2 bytes) */
|
||||||
|
Stream_Write_UINT16(s, 0); /* Padding (2 bytes) */
|
||||||
|
|
||||||
|
rdpdr_server_write_general_capability_set(context, s);
|
||||||
|
rdpdr_server_write_printer_capability_set(context, s);
|
||||||
|
rdpdr_server_write_port_capability_set(context, s);
|
||||||
|
rdpdr_server_write_drive_capability_set(context, s);
|
||||||
|
rdpdr_server_write_smartcard_capability_set(context, s);
|
||||||
|
|
||||||
|
Stream_SealLength(s);
|
||||||
|
|
||||||
|
status = WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Buffer(s), Stream_Length(s), NULL);
|
||||||
|
|
||||||
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_receive_core_capability_response(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
UINT16 numCapabilities;
|
||||||
|
RDPDR_CAPABILITY_HEADER capabilityHeader;
|
||||||
|
|
||||||
|
Stream_Read_UINT16(s, numCapabilities); /* numCapabilities (2 bytes) */
|
||||||
|
Stream_Seek_UINT16(s); /* Padding (2 bytes) */
|
||||||
|
|
||||||
|
for (i = 0; i < numCapabilities; i++)
|
||||||
|
{
|
||||||
|
rdpdr_server_read_capability_set_header(s, &capabilityHeader);
|
||||||
|
|
||||||
|
switch (capabilityHeader.CapabilityType)
|
||||||
|
{
|
||||||
|
case CAP_GENERAL_TYPE:
|
||||||
|
rdpdr_server_read_general_capability_set(context, s, &capabilityHeader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAP_PRINTER_TYPE:
|
||||||
|
rdpdr_server_read_printer_capability_set(context, s, &capabilityHeader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAP_PORT_TYPE:
|
||||||
|
rdpdr_server_read_port_capability_set(context, s, &capabilityHeader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAP_DRIVE_TYPE:
|
||||||
|
rdpdr_server_read_drive_capability_set(context, s, &capabilityHeader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAP_SMARTCARD_TYPE:
|
||||||
|
rdpdr_server_read_smartcard_capability_set(context, s, &capabilityHeader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("Unknown capabilityType %d\n", capabilityHeader.CapabilityType);
|
||||||
|
Stream_Seek(s, capabilityHeader.CapabilityLength - RDPDR_CAPABILITY_HEADER_LENGTH);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_receive_pdu(RdpdrServerContext* context, wStream* s, RDPDR_HEADER* header)
|
||||||
|
{
|
||||||
|
printf("RdpdrServerReceivePdu: Component: 0x%04X PacketId: 0x%04X\n",
|
||||||
|
header->Component, header->PacketId);
|
||||||
|
|
||||||
|
winpr_HexDump(Stream_Buffer(s), Stream_Length(s));
|
||||||
|
|
||||||
|
if (header->Component == RDPDR_CTYP_CORE)
|
||||||
|
{
|
||||||
|
switch (header->PacketId)
|
||||||
|
{
|
||||||
|
case PAKID_CORE_CLIENTID_CONFIRM:
|
||||||
|
rdpdr_server_receive_announce_response(context, s, header);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_CLIENT_NAME:
|
||||||
|
rdpdr_server_receive_client_name_request(context, s, header);
|
||||||
|
rdpdr_server_send_core_capability_request(context);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_CLIENT_CAPABILITY:
|
||||||
|
rdpdr_server_receive_core_capability_response(context, s, header);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_DEVICELIST_ANNOUNCE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_DEVICE_REPLY:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_DEVICE_IOREQUEST:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_DEVICE_IOCOMPLETION:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_CORE_DEVICELIST_REMOVE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (header->Component == RDPDR_CTYP_PRN)
|
||||||
|
{
|
||||||
|
switch (header->PacketId)
|
||||||
|
{
|
||||||
|
case PAKID_PRN_CACHE_DATA:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAKID_PRN_USING_XPS:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Unknown RDPDR_HEADER.Component: 0x%04X\n", header->Component);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* rdpdr_server_thread(void* arg)
|
||||||
|
{
|
||||||
|
wStream* s;
|
||||||
|
DWORD status;
|
||||||
|
DWORD nCount;
|
||||||
|
void* buffer;
|
||||||
|
int position;
|
||||||
|
HANDLE events[8];
|
||||||
|
RDPDR_HEADER header;
|
||||||
|
HANDLE ChannelEvent;
|
||||||
|
UINT32 BytesReturned;
|
||||||
|
RdpdrServerContext* context;
|
||||||
|
|
||||||
|
context = (RdpdrServerContext*) arg;
|
||||||
|
|
||||||
|
buffer = NULL;
|
||||||
|
BytesReturned = 0;
|
||||||
|
ChannelEvent = NULL;
|
||||||
|
|
||||||
|
s = Stream_New(NULL, 4096);
|
||||||
|
|
||||||
|
if (WTSVirtualChannelQuery(context->priv->ChannelHandle, WTSVirtualEventHandle, &buffer, &BytesReturned) == TRUE)
|
||||||
|
{
|
||||||
|
if (BytesReturned == sizeof(HANDLE))
|
||||||
|
CopyMemory(&ChannelEvent, buffer, sizeof(HANDLE));
|
||||||
|
|
||||||
|
WTSFreeMemory(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
nCount = 0;
|
||||||
|
events[nCount++] = ChannelEvent;
|
||||||
|
events[nCount++] = context->priv->StopEvent;
|
||||||
|
|
||||||
|
cliprdr_server_send_announce_request(context);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||||
|
|
||||||
|
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
|
||||||
|
Stream_Buffer(s), Stream_Capacity(s), &BytesReturned))
|
||||||
|
{
|
||||||
|
if (BytesReturned)
|
||||||
|
Stream_Seek(s, BytesReturned);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stream_EnsureRemainingCapacity(s, BytesReturned);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Stream_GetPosition(s) >= RDPDR_HEADER_LENGTH)
|
||||||
|
{
|
||||||
|
position = Stream_GetPosition(s);
|
||||||
|
Stream_SetPosition(s, 0);
|
||||||
|
|
||||||
|
Stream_Read_UINT16(s, header.Component); /* Component (2 bytes) */
|
||||||
|
Stream_Read_UINT16(s, header.PacketId); /* PacketId (2 bytes) */
|
||||||
|
|
||||||
|
Stream_SetPosition(s, position);
|
||||||
|
|
||||||
|
Stream_SealLength(s);
|
||||||
|
Stream_SetPosition(s, RDPDR_HEADER_LENGTH);
|
||||||
|
|
||||||
|
rdpdr_server_receive_pdu(context, s, &header);
|
||||||
|
Stream_SetPosition(s, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream_Free(s, TRUE);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_start(RdpdrServerContext* context)
|
||||||
|
{
|
||||||
|
context->priv->ChannelHandle = WTSVirtualChannelOpenEx(context->vcm, "rdpdr", 0);
|
||||||
|
|
||||||
|
if (!context->priv->ChannelHandle)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
context->priv->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
|
context->priv->Thread = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE) rdpdr_server_thread, (void*) context, 0, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rdpdr_server_stop(RdpdrServerContext* context)
|
||||||
|
{
|
||||||
|
SetEvent(context->priv->StopEvent);
|
||||||
|
|
||||||
|
WaitForSingleObject(context->priv->Thread, INFINITE);
|
||||||
|
CloseHandle(context->priv->Thread);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RdpdrServerContext* rdpdr_server_context_new(WTSVirtualChannelManager* vcm)
|
||||||
|
{
|
||||||
|
RdpdrServerContext* context;
|
||||||
|
|
||||||
|
context = (RdpdrServerContext*) malloc(sizeof(RdpdrServerContext));
|
||||||
|
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
ZeroMemory(context, sizeof(RdpdrServerContext));
|
||||||
|
|
||||||
|
context->vcm = vcm;
|
||||||
|
|
||||||
|
context->Start = rdpdr_server_start;
|
||||||
|
context->Stop = rdpdr_server_stop;
|
||||||
|
|
||||||
|
context->priv = (RdpdrServerPrivate*) malloc(sizeof(RdpdrServerPrivate));
|
||||||
|
|
||||||
|
if (context->priv)
|
||||||
|
{
|
||||||
|
ZeroMemory(context->priv, sizeof(RdpdrServerPrivate));
|
||||||
|
|
||||||
|
context->priv->VersionMajor = RDPDR_VERSION_MAJOR;
|
||||||
|
context->priv->VersionMinor = RDPDR_VERSION_MINOR_RDP6X;
|
||||||
|
context->priv->ClientId = g_ClientId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdpdr_server_context_free(RdpdrServerContext* context)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
if (context->priv)
|
||||||
|
{
|
||||||
|
free(context->priv);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(context);
|
||||||
|
}
|
||||||
|
}
|
67
channels/rdpdr/server/rdpdr_main.h
Normal file
67
channels/rdpdr/server/rdpdr_main.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||||
|
* Device Redirection Virtual Channel Extension
|
||||||
|
*
|
||||||
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H
|
||||||
|
#define FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H
|
||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
#include <winpr/synch.h>
|
||||||
|
#include <winpr/thread.h>
|
||||||
|
|
||||||
|
#include <freerdp/server/rdpdr.h>
|
||||||
|
|
||||||
|
struct _rdpdr_server_private
|
||||||
|
{
|
||||||
|
HANDLE Thread;
|
||||||
|
HANDLE StopEvent;
|
||||||
|
void* ChannelHandle;
|
||||||
|
|
||||||
|
UINT32 ClientId;
|
||||||
|
UINT16 VersionMajor;
|
||||||
|
UINT16 VersionMinor;
|
||||||
|
char* ClientComputerName;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RDPDR_HEADER_LENGTH 4
|
||||||
|
|
||||||
|
struct _RDPDR_HEADER
|
||||||
|
{
|
||||||
|
UINT16 Component;
|
||||||
|
UINT16 PacketId;
|
||||||
|
};
|
||||||
|
typedef struct _RDPDR_HEADER RDPDR_HEADER;
|
||||||
|
|
||||||
|
#define RDPDR_VERSION_MAJOR 0x0001
|
||||||
|
|
||||||
|
#define RDPDR_VERSION_MINOR_RDP50 0x0002
|
||||||
|
#define RDPDR_VERSION_MINOR_RDP51 0x0005
|
||||||
|
#define RDPDR_VERSION_MINOR_RDP52 0x000A
|
||||||
|
#define RDPDR_VERSION_MINOR_RDP6X 0x000C
|
||||||
|
|
||||||
|
#define RDPDR_CAPABILITY_HEADER_LENGTH 8
|
||||||
|
|
||||||
|
struct _RDPDR_CAPABILITY_HEADER
|
||||||
|
{
|
||||||
|
UINT16 CapabilityType;
|
||||||
|
UINT16 CapabilityLength;
|
||||||
|
UINT32 Version;
|
||||||
|
};
|
||||||
|
typedef struct _RDPDR_CAPABILITY_HEADER RDPDR_CAPABILITY_HEADER;
|
||||||
|
|
||||||
|
#endif /* FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H */
|
@ -43,6 +43,7 @@
|
|||||||
#include <freerdp/server/audin.h>
|
#include <freerdp/server/audin.h>
|
||||||
#include <freerdp/server/rdpsnd.h>
|
#include <freerdp/server/rdpsnd.h>
|
||||||
#include <freerdp/server/cliprdr.h>
|
#include <freerdp/server/cliprdr.h>
|
||||||
|
#include <freerdp/server/rdpdr.h>
|
||||||
|
|
||||||
void freerdp_channels_dummy()
|
void freerdp_channels_dummy()
|
||||||
{
|
{
|
||||||
@ -54,6 +55,9 @@ void freerdp_channels_dummy()
|
|||||||
|
|
||||||
cliprdr_server_context_new(NULL);
|
cliprdr_server_context_new(NULL);
|
||||||
cliprdr_server_context_free(NULL);
|
cliprdr_server_context_free(NULL);
|
||||||
|
|
||||||
|
rdpdr_server_context_new(NULL);
|
||||||
|
rdpdr_server_context_free(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
51
include/freerdp/server/rdpdr.h
Normal file
51
include/freerdp/server/rdpdr.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||||
|
* Device Redirection Virtual Channel Server Interface
|
||||||
|
*
|
||||||
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FREERDP_CHANNEL_SERVER_RDPDR_H
|
||||||
|
#define FREERDP_CHANNEL_SERVER_RDPDR_H
|
||||||
|
|
||||||
|
#include <freerdp/api.h>
|
||||||
|
#include <freerdp/types.h>
|
||||||
|
#include <freerdp/channels/wtsvc.h>
|
||||||
|
#include <freerdp/channels/rdpdr.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server Interface
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _rdpdr_server_context RdpdrServerContext;
|
||||||
|
typedef struct _rdpdr_server_private RdpdrServerPrivate;
|
||||||
|
|
||||||
|
typedef int (*psRdpdrStart)(RdpdrServerContext* context);
|
||||||
|
typedef int (*psRdpdrStop)(RdpdrServerContext* context);
|
||||||
|
|
||||||
|
struct _rdpdr_server_context
|
||||||
|
{
|
||||||
|
WTSVirtualChannelManager* vcm;
|
||||||
|
|
||||||
|
psRdpdrStart Start;
|
||||||
|
psRdpdrStop Stop;
|
||||||
|
|
||||||
|
RdpdrServerPrivate* priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
FREERDP_API RdpdrServerContext* rdpdr_server_context_new(WTSVirtualChannelManager* vcm);
|
||||||
|
FREERDP_API void rdpdr_server_context_free(RdpdrServerContext* context);
|
||||||
|
|
||||||
|
#endif /* FREERDP_CHANNEL_SERVER_RDPDR_H */
|
Loading…
Reference in New Issue
Block a user