Decipher the contents of the DR_CORE_CAPABILITY_RSP message

Add relevant constants from the specification and use them while
building the capabilities reply.
This commit is contained in:
Karl Mikaelsson 2017-01-20 16:05:59 +01:00
parent 79b9813df5
commit b093dc198d
2 changed files with 72 additions and 29 deletions

View File

@ -482,6 +482,43 @@ enum RDP_INPUT_DEVICE
#define FILE_DELETE_ON_CLOSE 0x00001000 #define FILE_DELETE_ON_CLOSE 0x00001000
#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
#define CAP_GENERAL_TYPE 0x0001
#define CAP_PRINTER_TYPE 0x0002
#define CAP_PORT_TYPE 0x0003
#define CAP_DRIVE_TYPE 0x0004
#define CAP_SMARTCARD_TYPE 0x0005
#define GENERAL_CAPABILITY_VERSION_01 0x00000001
#define GENERAL_CAPABILITY_VERSION_02 0x00000002
#define PRINT_CAPABILITY_VERSION_01 0x00000001
#define PORT_CAPABILITY_VERSION_01 0x00000001
#define DRIVE_CAPABILITY_VERSION_01 0x00000001
#define DRIVE_CAPABILITY_VERSION_02 0x00000002
#define SMARTCARD_CAPABILITY_VERSION_01 0x00000001
#define RDPDR_IRP_MJ_CREATE 0x00000001
#define RDPDR_IRP_MJ_CLEANUP 0x00000002
#define RDPDR_IRP_MJ_CLOSE 0x00000004
#define RDPDR_IRP_MJ_READ 0x00000008
#define RDPDR_IRP_MJ_WRITE 0x00000010
#define RDPDR_IRP_MJ_FLUSH_BUFFERS 0x00000020
#define RDPDR_IRP_MJ_SHUTDOWN 0x00000040
#define RDPDR_IRP_MJ_DEVICE_CONTROL 0x00000080
#define RDPDR_IRP_MJ_QUERY_VOLUME_INFORMATION 0x00000100
#define RDPDR_IRP_MJ_SET_VOLUME_INFORMATION 0x00000200
#define RDPDR_IRP_MJ_QUERY_INFORMATION 0x00000400
#define RDPDR_IRP_MJ_SET_INFORMATION 0x00000800
#define RDPDR_IRP_MJ_DIRECTORY_CONTROL 0x00001000
#define RDPDR_IRP_MJ_LOCK_CONTROL 0x00002000
#define RDPDR_IRP_MJ_QUERY_SECURITY 0x00004000
#define RDPDR_IRP_MJ_SET_SECURITY 0x00008000
#define ALL_RDPDR_IRP_MJ 0x0000FFFF
#define RDPDR_DEVICE_REMOVE_PDUS 0x00000001
#define RDPDR_CLIENT_DISPLAY_NAME_PDU 0x00000002
#define RDPDR_USER_LOGGEDON_PDU 0x00000004
/* RDP5 disconnect PDU */ /* RDP5 disconnect PDU */
#define exDiscReasonNoInfo 0x0000 #define exDiscReasonNoInfo 0x0000
#define exDiscReasonAPIInitiatedDisconnect 0x0001 #define exDiscReasonAPIInitiatedDisconnect 0x0001

64
rdpdr.c
View File

@ -3,6 +3,7 @@
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008 Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
Copyright 2004-2011 Peter Astrand <astrand@cendio.se> for Cendio AB Copyright 2004-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
Copyright 2010-2014 Henrik Andersson <hean01@cendio.se> for Cendio AB Copyright 2010-2014 Henrik Andersson <hean01@cendio.se> for Cendio AB
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -756,35 +757,40 @@ rdpdr_send_client_capability_response(void)
/* DR_CORE_CAPABILITY_RSP */ /* DR_CORE_CAPABILITY_RSP */
STREAM s; STREAM s;
s = channel_init(rdpdr_channel, 0x50); s = channel_init(rdpdr_channel, 0x50);
out_uint16_le(s, RDPDR_CTYP_CORE);
out_uint16_le(s, PAKID_CORE_CLIENT_CAPABILITY); out_uint16_le(s, RDPDR_CTYP_CORE); /* Header */
out_uint32_le(s, 5); /* count */ out_uint16_le(s, PAKID_CORE_CLIENT_CAPABILITY); /* Header */
out_uint16_le(s, 1); /* first */ out_uint16_le(s, 5); /* numCapabilities */
out_uint16_le(s, 0x28); /* length */ out_uint16_le(s, 0); /* Padding */
out_uint32_le(s, 1);
out_uint32_le(s, 2); out_uint16_le(s, CAP_GENERAL_TYPE); /* CapabilityType */
out_uint16_le(s, 2); out_uint16_le(s, 0x28); /* CapabilityLength */
out_uint16_le(s, 5); out_uint32_le(s, GENERAL_CAPABILITY_VERSION_01); /* Version */
out_uint16_le(s, 1); out_uint32_le(s, 0); /* osType */
out_uint16_le(s, 5); out_uint32_le(s, 0); /* osVersion */
out_uint16_le(s, 0xFFFF); out_uint16_le(s, 1); /* protocolMajorVersion */
out_uint16_le(s, 0); out_uint16_le(s, 5); /* protocolMinorVersion */
out_uint32_le(s, 0); out_uint32_le(s, ALL_RDPDR_IRP_MJ); /* ioCode1 */
out_uint32_le(s, 3); out_uint32_le(s, 0); /* ioCode2 */
out_uint32_le(s, 0); out_uint32_le(s, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU); /* extendedPDU */
out_uint32_le(s, 0); out_uint32_le(s, 0); /* extraFlags1 */
out_uint16_le(s, 2); /* second */ out_uint32_le(s, 0); /* extraFlags2 */
out_uint16_le(s, 8); /* length */
out_uint32_le(s, 1); out_uint16_le(s, CAP_PRINTER_TYPE); /* CapabilityType */
out_uint16_le(s, 3); /* third */ out_uint16_le(s, 8); /* CapabilityLength */
out_uint16_le(s, 8); /* length */ out_uint32_le(s, PRINT_CAPABILITY_VERSION_01); /* Version */
out_uint32_le(s, 1);
out_uint16_le(s, 4); /* fourth */ out_uint16_le(s, CAP_PORT_TYPE); /* CapabilityType */
out_uint16_le(s, 8); /* length */ out_uint16_le(s, 8); /* CapabilityLength */
out_uint32_le(s, 1); out_uint32_le(s, PORT_CAPABILITY_VERSION_01); /* Version */
out_uint16_le(s, 5); /* fifth */
out_uint16_le(s, 8); /* length */ out_uint16_le(s, CAP_DRIVE_TYPE); /* CapabilityType */
out_uint32_le(s, 1); out_uint16_le(s, 8); /* CapabilityLength */
out_uint32_le(s, DRIVE_CAPABILITY_VERSION_01); /* Version */
out_uint16_le(s, CAP_SMARTCARD_TYPE); /* CapabilityType */
out_uint16_le(s, 8); /* CapabilityLength */
out_uint32_le(s, SMARTCARD_CAPABILITY_VERSION_01); /* Version */
s_mark_end(s); s_mark_end(s);
channel_send(s, rdpdr_channel); channel_send(s, rdpdr_channel);