2003-03-27 14:22:29 +01:00
|
|
|
/* -*- c-basic-offset: 8 -*-
|
2000-05-10 09:36:34 +02:00
|
|
|
rdesktop: A Remote Desktop Protocol client.
|
|
|
|
Protocol services - RDP layer
|
2002-09-26 16:26:46 +02:00
|
|
|
Copyright (C) Matthew Chapman 1999-2002
|
2003-07-03 00:02:23 +02:00
|
|
|
|
2000-05-10 09:36:34 +02:00
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2003-07-03 00:02:23 +02:00
|
|
|
|
2000-05-10 09:36:34 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2003-07-03 00:02:23 +02:00
|
|
|
|
2000-05-10 09:36:34 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2003-12-11 18:20:01 +01:00
|
|
|
#include <time.h>
|
2000-08-15 12:23:24 +02:00
|
|
|
#include "rdesktop.h"
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-05-30 23:59:56 +02:00
|
|
|
extern uint16 g_mcs_userid;
|
2003-07-28 23:41:12 +02:00
|
|
|
extern char g_username[16];
|
|
|
|
extern BOOL g_bitmap_compression;
|
|
|
|
extern BOOL g_orders;
|
|
|
|
extern BOOL g_encryption;
|
2003-08-01 19:01:58 +02:00
|
|
|
extern BOOL g_desktop_save;
|
|
|
|
extern BOOL g_use_rdp5;
|
|
|
|
extern uint16 g_server_rdp_version;
|
2004-03-15 15:49:12 +01:00
|
|
|
extern uint32 g_rdp5_performanceflags;
|
2003-08-01 19:01:58 +02:00
|
|
|
extern int g_server_bpp;
|
2004-04-26 15:48:39 +02:00
|
|
|
extern int g_width;
|
|
|
|
extern int g_height;
|
2004-04-27 00:31:22 +02:00
|
|
|
extern BOOL g_bitmap_cache;
|
2004-06-27 19:51:54 +02:00
|
|
|
extern BOOL g_bitmap_cache_persist_enable;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
uint8 *g_next_packet;
|
|
|
|
uint32 g_rdp_shareid;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
extern RDPCOMP g_mppc_dict;
|
2004-04-27 14:55:33 +02:00
|
|
|
|
2003-03-06 15:11:17 +01:00
|
|
|
#if WITH_DEBUG
|
2003-08-01 19:01:58 +02:00
|
|
|
static uint32 g_packetno;
|
2003-03-27 14:22:29 +01:00
|
|
|
#endif
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Receive an RDP packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
static STREAM
|
2002-07-18 18:38:31 +02:00
|
|
|
rdp_recv(uint8 * type)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
static STREAM rdp_s;
|
|
|
|
uint16 length, pdu_type;
|
2004-07-05 21:09:07 +02:00
|
|
|
uint8 rdpver;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
if ((rdp_s == NULL) || (g_next_packet >= rdp_s->end))
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2004-07-05 21:09:07 +02:00
|
|
|
rdp_s = sec_recv(&rdpver);
|
2000-08-15 12:23:24 +02:00
|
|
|
if (rdp_s == NULL)
|
|
|
|
return NULL;
|
2004-07-05 21:09:07 +02:00
|
|
|
if (rdpver != 3)
|
|
|
|
{
|
|
|
|
/* rdp5_process should move g_next_packet ok */
|
|
|
|
rdp5_process(rdp_s);
|
|
|
|
*type = 0;
|
|
|
|
return rdp_s;
|
|
|
|
}
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
g_next_packet = rdp_s->p;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-01 19:01:58 +02:00
|
|
|
rdp_s->p = g_next_packet;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(rdp_s, length);
|
2002-12-10 18:24:27 +01:00
|
|
|
/* 32k packets are really 8, keepalive fix */
|
|
|
|
if (length == 0x8000)
|
|
|
|
{
|
2003-08-01 19:01:58 +02:00
|
|
|
g_next_packet += 8;
|
2002-12-10 18:24:27 +01:00
|
|
|
*type = 0;
|
|
|
|
return rdp_s;
|
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(rdp_s, pdu_type);
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(rdp_s, 2); /* userid */
|
2000-08-15 12:23:24 +02:00
|
|
|
*type = pdu_type & 0xf;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2001-09-14 15:51:38 +02:00
|
|
|
#if WITH_DEBUG
|
2003-08-01 19:01:58 +02:00
|
|
|
DEBUG(("RDP packet #%d, (type %x)\n", ++g_packetno, *type));
|
2003-10-28 02:44:48 +01:00
|
|
|
hexdump(g_next_packet, length);
|
2001-06-20 15:54:48 +02:00
|
|
|
#endif /* */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
g_next_packet += length;
|
2000-08-15 12:23:24 +02:00
|
|
|
return rdp_s;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Initialise an RDP data packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
static STREAM
|
|
|
|
rdp_init_data(int maxlen)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-07-28 23:41:12 +02:00
|
|
|
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, maxlen + 18);
|
2000-08-15 12:23:24 +02:00
|
|
|
s_push_layer(s, rdp_hdr, 18);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an RDP data packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_send_data(STREAM s, uint8 data_pdu_type)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint16 length;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_pop_layer(s, rdp_hdr);
|
|
|
|
length = s->end - s->p;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, length);
|
|
|
|
out_uint16_le(s, (RDP_PDU_DATA | 0x10));
|
2003-05-30 23:59:56 +02:00
|
|
|
out_uint16_le(s, (g_mcs_userid + 1001));
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
out_uint32_le(s, g_rdp_shareid);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint8(s, 0); /* pad */
|
|
|
|
out_uint8(s, 1); /* streamid */
|
2002-09-17 11:55:03 +02:00
|
|
|
out_uint16_le(s, (length - 14));
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, data_pdu_type);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint8(s, 0); /* compress_type */
|
|
|
|
out_uint16(s, 0); /* compress_len */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-07-28 23:41:12 +02:00
|
|
|
sec_send(s, g_encryption ? SEC_ENCRYPT : 0);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output a string in Unicode */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
rdp_out_unistr(STREAM s, char *string, int len)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
int i = 0, j = 0;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
len += 2;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
while (i < len)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
s->p[i++] = string[j++];
|
|
|
|
s->p[i++] = 0;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s->p += len;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2004-01-21 15:40:40 +01:00
|
|
|
/* Input a string in Unicode
|
|
|
|
*
|
|
|
|
* Returns str_len of string
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
rdp_in_unistr(STREAM s, char *string, int uni_len)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (i < uni_len / 2)
|
|
|
|
{
|
|
|
|
in_uint8a(s, &string[i++], 1);
|
|
|
|
in_uint8s(s, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return i - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Parse a logon info packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_send_logon_info(uint32 flags, char *domain, char *user,
|
|
|
|
char *password, char *program, char *directory)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2004-03-04 09:11:40 +01:00
|
|
|
char *ipaddr = tcp_get_address();
|
2001-01-06 04:12:10 +01:00
|
|
|
int len_domain = 2 * strlen(domain);
|
|
|
|
int len_user = 2 * strlen(user);
|
|
|
|
int len_password = 2 * strlen(password);
|
|
|
|
int len_program = 2 * strlen(program);
|
2000-08-15 12:23:24 +02:00
|
|
|
int len_directory = 2 * strlen(directory);
|
2004-03-04 09:11:40 +01:00
|
|
|
int len_ip = 2 * strlen(ipaddr);
|
2003-05-05 14:20:53 +02:00
|
|
|
int len_dll = 2 * strlen("C:\\WINNT\\System32\\mstscax.dll");
|
|
|
|
int packetlen = 0;
|
2003-07-28 23:41:12 +02:00
|
|
|
uint32 sec_flags = g_encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO;
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2003-12-11 18:20:01 +01:00
|
|
|
time_t t = time(NULL);
|
|
|
|
time_t tzone;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
#if 0
|
|
|
|
/* enable rdp compression */
|
|
|
|
/* some problems still exist with rdp5 */
|
|
|
|
flags |= RDP_COMPRESSION;
|
|
|
|
#endif
|
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
if (!g_use_rdp5 || 1 == g_server_rdp_version)
|
2003-03-27 14:22:29 +01:00
|
|
|
{
|
|
|
|
DEBUG_RDP5(("Sending RDP4-style Logon packet\n"));
|
|
|
|
|
|
|
|
s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
|
|
|
|
+ len_program + len_directory + 10);
|
|
|
|
|
|
|
|
out_uint32(s, 0);
|
|
|
|
out_uint32_le(s, flags);
|
|
|
|
out_uint16_le(s, len_domain);
|
|
|
|
out_uint16_le(s, len_user);
|
|
|
|
out_uint16_le(s, len_password);
|
|
|
|
out_uint16_le(s, len_program);
|
|
|
|
out_uint16_le(s, len_directory);
|
|
|
|
rdp_out_unistr(s, domain, len_domain);
|
|
|
|
rdp_out_unistr(s, user, len_user);
|
|
|
|
rdp_out_unistr(s, password, len_password);
|
|
|
|
rdp_out_unistr(s, program, len_program);
|
|
|
|
rdp_out_unistr(s, directory, len_directory);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-04-27 14:55:33 +02:00
|
|
|
|
2003-05-05 14:20:53 +02:00
|
|
|
flags |= RDP_LOGON_BLOB;
|
2003-03-27 14:22:29 +01:00
|
|
|
DEBUG_RDP5(("Sending RDP5-style Logon packet\n"));
|
2003-10-31 21:34:26 +01:00
|
|
|
packetlen = 4 + /* Unknown uint32 */
|
|
|
|
4 + /* flags */
|
|
|
|
2 + /* len_domain */
|
|
|
|
2 + /* len_user */
|
|
|
|
(flags & RDP_LOGON_AUTO ? 2 : 0) + /* len_password */
|
|
|
|
(flags & RDP_LOGON_BLOB ? 2 : 0) + /* Length of BLOB */
|
|
|
|
2 + /* len_program */
|
|
|
|
2 + /* len_directory */
|
|
|
|
(0 < len_domain ? len_domain : 2) + /* domain */
|
|
|
|
len_user + (flags & RDP_LOGON_AUTO ? len_password : 0) + 0 + /* We have no 512 byte BLOB. Perhaps we must? */
|
|
|
|
(flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO) ? 2 : 0) + /* After the BLOB is a unknown int16. If there is a BLOB, that is. */
|
|
|
|
(0 < len_program ? len_program : 2) + (0 < len_directory ? len_directory : 2) + 2 + /* Unknown (2) */
|
|
|
|
2 + /* Client ip length */
|
|
|
|
len_ip + /* Client ip */
|
|
|
|
2 + /* DLL string length */
|
|
|
|
len_dll + /* DLL string */
|
|
|
|
2 + /* Unknown */
|
|
|
|
2 + /* Unknown */
|
|
|
|
64 + /* Time zone #0 */
|
|
|
|
2 + /* Unknown */
|
|
|
|
64 + /* Time zone #1 */
|
|
|
|
32; /* Unknown */
|
2003-06-06 12:47:34 +02:00
|
|
|
|
|
|
|
s = sec_init(sec_flags, packetlen);
|
2003-05-05 14:20:53 +02:00
|
|
|
DEBUG_RDP5(("Called sec_init with packetlen %d\n", packetlen));
|
|
|
|
|
2003-10-31 21:34:26 +01:00
|
|
|
out_uint32(s, 0); /* Unknown */
|
2003-03-27 14:22:29 +01:00
|
|
|
out_uint32_le(s, flags);
|
|
|
|
out_uint16_le(s, len_domain);
|
|
|
|
out_uint16_le(s, len_user);
|
|
|
|
if (flags & RDP_LOGON_AUTO)
|
|
|
|
{
|
|
|
|
out_uint16_le(s, len_password);
|
2003-05-05 14:20:53 +02:00
|
|
|
|
|
|
|
}
|
2003-06-06 12:47:34 +02:00
|
|
|
if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO))
|
|
|
|
{
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 0);
|
2003-03-27 14:22:29 +01:00
|
|
|
}
|
|
|
|
out_uint16_le(s, len_program);
|
|
|
|
out_uint16_le(s, len_directory);
|
2003-05-05 14:20:53 +02:00
|
|
|
if (0 < len_domain)
|
|
|
|
rdp_out_unistr(s, domain, len_domain);
|
2003-06-06 12:47:34 +02:00
|
|
|
else
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 0);
|
|
|
|
rdp_out_unistr(s, user, len_user);
|
2003-03-27 14:22:29 +01:00
|
|
|
if (flags & RDP_LOGON_AUTO)
|
|
|
|
{
|
|
|
|
rdp_out_unistr(s, password, len_password);
|
|
|
|
}
|
2003-06-06 12:47:34 +02:00
|
|
|
if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO))
|
|
|
|
{
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 0);
|
|
|
|
}
|
2003-06-06 12:47:34 +02:00
|
|
|
if (0 < len_program)
|
|
|
|
{
|
2003-03-27 14:22:29 +01:00
|
|
|
rdp_out_unistr(s, program, len_program);
|
2003-06-06 12:47:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 0);
|
|
|
|
}
|
2003-06-06 12:47:34 +02:00
|
|
|
if (0 < len_directory)
|
|
|
|
{
|
2003-03-27 14:22:29 +01:00
|
|
|
rdp_out_unistr(s, directory, len_directory);
|
2003-06-06 12:47:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 0);
|
2003-05-19 23:36:33 +02:00
|
|
|
}
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint16_le(s, 2);
|
2003-10-31 21:34:26 +01:00
|
|
|
out_uint16_le(s, len_ip + 2); /* Length of client ip */
|
2004-03-04 09:11:40 +01:00
|
|
|
rdp_out_unistr(s, ipaddr, len_ip);
|
2003-06-06 12:47:34 +02:00
|
|
|
out_uint16_le(s, len_dll + 2);
|
2003-05-05 14:20:53 +02:00
|
|
|
rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", len_dll);
|
2003-12-11 18:20:01 +01:00
|
|
|
|
2004-02-14 20:30:01 +01:00
|
|
|
tzone = (mktime(gmtime(&t)) - mktime(localtime(&t))) / 60;
|
|
|
|
out_uint32_le(s, tzone);
|
2003-12-11 13:25:38 +01:00
|
|
|
|
2003-06-06 12:47:34 +02:00
|
|
|
rdp_out_unistr(s, "GTB, normaltid", 2 * strlen("GTB, normaltid"));
|
|
|
|
out_uint8s(s, 62 - 2 * strlen("GTB, normaltid"));
|
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
out_uint32_le(s, 0x0a0000);
|
|
|
|
out_uint32_le(s, 0x050000);
|
2003-05-05 14:20:53 +02:00
|
|
|
out_uint32_le(s, 3);
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
out_uint32_le(s, 0);
|
2003-06-06 12:47:34 +02:00
|
|
|
|
|
|
|
rdp_out_unistr(s, "GTB, sommartid", 2 * strlen("GTB, sommartid"));
|
|
|
|
out_uint8s(s, 62 - 2 * strlen("GTB, sommartid"));
|
2003-05-05 14:20:53 +02:00
|
|
|
|
|
|
|
out_uint32_le(s, 0x30000);
|
2003-03-27 14:22:29 +01:00
|
|
|
out_uint32_le(s, 0x050000);
|
|
|
|
out_uint32_le(s, 2);
|
2003-04-16 10:19:15 +02:00
|
|
|
out_uint32(s, 0);
|
2003-03-27 14:22:29 +01:00
|
|
|
out_uint32_le(s, 0xffffffc4);
|
|
|
|
out_uint32_le(s, 0xfffffffe);
|
2004-03-15 15:49:12 +01:00
|
|
|
out_uint32_le(s, g_rdp5_performanceflags);
|
2003-04-16 10:19:15 +02:00
|
|
|
out_uint32(s, 0);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-05-05 14:20:53 +02:00
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
sec_send(s, sec_flags);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send a control PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_send_control(uint16 action)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = rdp_init_data(8);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, action);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16(s, 0); /* userid */
|
|
|
|
out_uint32(s, 0); /* control id */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
rdp_send_data(s, RDP_DATA_PDU_CONTROL);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send a synchronisation PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2002-09-24 09:59:14 +02:00
|
|
|
rdp_send_synchronise(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = rdp_init_data(4);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 1); /* type */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, 1002);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
rdp_send_data(s, RDP_DATA_PDU_SYNCHRONISE);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send a single input event */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-07-30 09:18:48 +02:00
|
|
|
rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = rdp_init_data(16);
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 1); /* number of events */
|
|
|
|
out_uint16(s, 0); /* pad */
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint32_le(s, time);
|
|
|
|
out_uint16_le(s, message_type);
|
|
|
|
out_uint16_le(s, device_flags);
|
|
|
|
out_uint16_le(s, param1);
|
|
|
|
out_uint16_le(s, param2);
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
rdp_send_data(s, RDP_DATA_PDU_INPUT);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
/* Inform the server on the contents of the persistent bitmap cache */
|
|
|
|
static void
|
|
|
|
rdp_enum_bmpcache2(void)
|
|
|
|
{
|
|
|
|
STREAM s;
|
|
|
|
uint8 idlist[BMPCACHE2_NUM_PSTCELLS * sizeof(BITMAP_ID)];
|
|
|
|
uint32 nids, offset, count, flags;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
nids = pstcache_enumerate(2, idlist);
|
|
|
|
|
|
|
|
while (offset < nids)
|
|
|
|
{
|
|
|
|
count = MIN(nids - offset, 169);
|
|
|
|
|
|
|
|
s = rdp_init_data(24 + count * sizeof(BITMAP_ID));
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
if (offset == 0)
|
|
|
|
flags |= PDU_FLAG_FIRST;
|
|
|
|
if (nids - offset <= 169)
|
|
|
|
flags |= PDU_FLAG_LAST;
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
out_uint16_le(s, count);
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint16_le(s, 0);
|
|
|
|
out_uint16_le(s, nids);
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
out_uint32_le(s, flags);
|
|
|
|
|
|
|
|
/* list */
|
2004-07-12 23:07:39 +02:00
|
|
|
out_uint8a(s, idlist + offset * sizeof(BITMAP_ID), count * sizeof(BITMAP_ID));
|
2004-06-27 19:51:54 +02:00
|
|
|
|
|
|
|
s_mark_end(s);
|
|
|
|
rdp_send_data(s, 0x2b);
|
|
|
|
|
|
|
|
offset += 169;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an (empty) font information PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_send_fonts(uint16 seq)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = rdp_init_data(8);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* number of fonts */
|
2004-04-26 15:48:39 +02:00
|
|
|
out_uint16_le(s, 0); /* pad? */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, seq); /* unknown */
|
|
|
|
out_uint16_le(s, 0x32); /* entry size */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
rdp_send_data(s, RDP_DATA_PDU_FONT2);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output general capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_general_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_GENERAL);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_GENERAL);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, 1); /* OS major type */
|
|
|
|
out_uint16_le(s, 3); /* OS minor type */
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0x200); /* Protocol version */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Pad */
|
|
|
|
out_uint16(s, 0); /* Compression types */
|
2003-08-01 19:01:58 +02:00
|
|
|
out_uint16_le(s, g_use_rdp5 ? 0x40d : 0);
|
2003-03-27 14:22:29 +01:00
|
|
|
/* Pad, according to T.128. 0x40d seems to
|
|
|
|
trigger
|
|
|
|
the server to start sending RDP5 packets.
|
|
|
|
However, the value is 0x1d04 with W2KTSK and
|
|
|
|
NT4MS. Hmm.. Anyway, thankyou, Microsoft,
|
|
|
|
for sending such information in a padding
|
|
|
|
field.. */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Update capability */
|
|
|
|
out_uint16(s, 0); /* Remote unshare capability */
|
|
|
|
out_uint16(s, 0); /* Compression level */
|
|
|
|
out_uint16(s, 0); /* Pad */
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output bitmap capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_bitmap_caps(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_BITMAP);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_BITMAP);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-04-16 00:03:24 +02:00
|
|
|
out_uint16_le(s, g_server_bpp); /* Preferred BPP */
|
2002-09-17 11:55:03 +02:00
|
|
|
out_uint16_le(s, 1); /* Receive 1 BPP */
|
|
|
|
out_uint16_le(s, 1); /* Receive 4 BPP */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, 1); /* Receive 8 BPP */
|
|
|
|
out_uint16_le(s, 800); /* Desktop width */
|
|
|
|
out_uint16_le(s, 600); /* Desktop height */
|
|
|
|
out_uint16(s, 0); /* Pad */
|
2004-04-26 15:48:39 +02:00
|
|
|
out_uint16(s, 1); /* Allow resize */
|
2003-07-28 23:41:12 +02:00
|
|
|
out_uint16_le(s, g_bitmap_compression ? 1 : 0); /* Support compression */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Unknown */
|
|
|
|
out_uint16_le(s, 1); /* Unknown */
|
|
|
|
out_uint16(s, 0); /* Pad */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output order capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_order_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 order_caps[32];
|
2000-07-25 14:34:29 +02:00
|
|
|
|
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
memset(order_caps, 0, 32);
|
|
|
|
order_caps[0] = 1; /* dest blt */
|
|
|
|
order_caps[1] = 1; /* pat blt */
|
|
|
|
order_caps[2] = 1; /* screen blt */
|
2004-04-27 14:55:33 +02:00
|
|
|
order_caps[3] = (g_bitmap_cache ? 1 : 0); /* memblt */
|
2001-06-20 15:54:48 +02:00
|
|
|
order_caps[8] = 1; /* line */
|
|
|
|
order_caps[9] = 1; /* line */
|
|
|
|
order_caps[10] = 1; /* rect */
|
2003-08-01 19:01:58 +02:00
|
|
|
order_caps[11] = (g_desktop_save == False ? 0 : 1); /* desksave */
|
2001-06-20 15:54:48 +02:00
|
|
|
order_caps[13] = 1; /* memblt */
|
|
|
|
order_caps[14] = 1; /* triblt */
|
|
|
|
order_caps[22] = 1; /* polyline */
|
|
|
|
order_caps[27] = 1; /* text2 */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_ORDER);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_ORDER);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8s(s, 20); /* Terminal desc, pad */
|
|
|
|
out_uint16_le(s, 1); /* Cache X granularity */
|
|
|
|
out_uint16_le(s, 20); /* Cache Y granularity */
|
|
|
|
out_uint16(s, 0); /* Pad */
|
|
|
|
out_uint16_le(s, 1); /* Max order level */
|
|
|
|
out_uint16_le(s, 0x147); /* Number of fonts */
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0x2a); /* Capability flags */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8p(s, order_caps, 32); /* Orders supported */
|
|
|
|
out_uint16_le(s, 0x6a1); /* Text capability flags */
|
|
|
|
out_uint8s(s, 6); /* Pad */
|
2003-08-01 19:01:58 +02:00
|
|
|
out_uint32_le(s, g_desktop_save == False ? 0 : 0x38400); /* Desktop cache size */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint32(s, 0); /* Unknown */
|
2002-09-17 11:55:03 +02:00
|
|
|
out_uint32_le(s, 0x4e4); /* Unknown */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output bitmap cache capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_bmpcache_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2003-07-03 00:02:23 +02:00
|
|
|
int Bpp;
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_BMPCACHE);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_BMPCACHE);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
Bpp = (g_server_bpp + 7) / 8;
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint8s(s, 24); /* unused */
|
|
|
|
out_uint16_le(s, 0x258); /* entries */
|
2003-07-03 00:02:23 +02:00
|
|
|
out_uint16_le(s, 0x100 * Bpp); /* max cell size */
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0x12c); /* entries */
|
2003-07-03 00:02:23 +02:00
|
|
|
out_uint16_le(s, 0x400 * Bpp); /* max cell size */
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0x106); /* entries */
|
2003-07-03 00:02:23 +02:00
|
|
|
out_uint16_le(s, 0x1000 * Bpp); /* max cell size */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
/* Output bitmap cache v2 capability set */
|
|
|
|
static void
|
|
|
|
rdp_out_bmpcache2_caps(STREAM s)
|
|
|
|
{
|
|
|
|
out_uint16_le(s, RDP_CAPSET_BMPCACHE2);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_BMPCACHE2);
|
|
|
|
|
2004-06-29 18:22:41 +02:00
|
|
|
out_uint16_le(s, g_bitmap_cache_persist_enable ? 2 : 0); /* version */
|
2004-06-27 19:51:54 +02:00
|
|
|
|
|
|
|
out_uint16_le(s, 0x0300); /* flags? number of caches? */
|
|
|
|
|
|
|
|
out_uint32_le(s, BMPCACHE2_C0_CELLS);
|
|
|
|
out_uint32_le(s, BMPCACHE2_C1_CELLS);
|
|
|
|
if (pstcache_init(2))
|
|
|
|
{
|
|
|
|
out_uint32_le(s, BMPCACHE2_NUM_PSTCELLS | BMPCACHE2_FLAG_PERSIST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out_uint32_le(s, BMPCACHE2_C2_CELLS);
|
|
|
|
}
|
2004-07-12 23:07:39 +02:00
|
|
|
out_uint8s(s, 20); /* other bitmap caches not used */
|
2004-06-27 19:51:54 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output control capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_control_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_CONTROL);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_CONTROL);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Control capabilities */
|
|
|
|
out_uint16(s, 0); /* Remote detach */
|
|
|
|
out_uint16_le(s, 2); /* Control interest */
|
|
|
|
out_uint16_le(s, 2); /* Detach interest */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output activation capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_activate_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_ACTIVATE);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Help key */
|
|
|
|
out_uint16(s, 0); /* Help index key */
|
|
|
|
out_uint16(s, 0); /* Extended help key */
|
|
|
|
out_uint16(s, 0); /* Window activate */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output pointer capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_pointer_caps(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_POINTER);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_POINTER);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* Colour pointer */
|
|
|
|
out_uint16_le(s, 20); /* Cache size */
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output share capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_share_caps(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_SHARE);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_SHARE);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16(s, 0); /* userid */
|
|
|
|
out_uint16(s, 0); /* pad */
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output colour cache capability set */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
rdp_out_colcache_caps(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, RDP_CAPSET_COLCACHE);
|
|
|
|
out_uint16_le(s, RDP_CAPLEN_COLCACHE);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, 6); /* cache size */
|
|
|
|
out_uint16(s, 0); /* pad */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
static uint8 caps_0x0d[] = {
|
|
|
|
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
|
|
|
|
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00
|
2000-08-15 12:23:24 +02:00
|
|
|
};
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
static uint8 caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
static uint8 caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
static uint8 caps_0x10[] = {
|
|
|
|
0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
|
|
|
|
0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
|
|
|
|
0xFE, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00,
|
|
|
|
0xFE, 0x00, 0x40, 0x00, 0xFE, 0x00, 0x80, 0x00,
|
|
|
|
0xFE, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08,
|
|
|
|
0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Output unknown capability sets */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2004-07-12 23:07:39 +02:00
|
|
|
rdp_out_unknown_caps(STREAM s, uint16 id, uint16 length, uint8 * caps)
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
2004-06-27 19:51:54 +02:00
|
|
|
out_uint16_le(s, id);
|
|
|
|
out_uint16_le(s, length);
|
2001-01-06 04:12:10 +01:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
out_uint8p(s, caps, length - 4);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
#define RDP5_FLAG 0x0030
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send a confirm active PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2002-09-24 09:59:14 +02:00
|
|
|
rdp_send_confirm_active(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2003-07-28 23:41:12 +02:00
|
|
|
uint32 sec_flags = g_encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG;
|
2001-01-06 04:12:10 +01:00
|
|
|
uint16 caplen =
|
|
|
|
RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +
|
|
|
|
RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +
|
|
|
|
RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
|
2004-06-27 19:51:54 +02:00
|
|
|
RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE +
|
2004-07-12 23:07:39 +02:00
|
|
|
0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ +
|
2004-06-27 19:51:54 +02:00
|
|
|
4 /* w2k fix, why? */ ;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
s = sec_init(sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE));
|
|
|
|
|
|
|
|
out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE));
|
|
|
|
out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */
|
2003-05-30 23:59:56 +02:00
|
|
|
out_uint16_le(s, (g_mcs_userid + 1001));
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
out_uint32_le(s, g_rdp_shareid);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0x3ea); /* userid */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_le(s, sizeof(RDP_SOURCE));
|
|
|
|
out_uint16_le(s, caplen);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_le(s, 0xd); /* num_caps */
|
|
|
|
out_uint8s(s, 2); /* pad */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
rdp_out_general_caps(s);
|
|
|
|
rdp_out_bitmap_caps(s);
|
|
|
|
rdp_out_order_caps(s);
|
2004-06-27 19:51:54 +02:00
|
|
|
g_use_rdp5 ? rdp_out_bmpcache2_caps(s) : rdp_out_bmpcache_caps(s);
|
2000-08-15 12:23:24 +02:00
|
|
|
rdp_out_colcache_caps(s);
|
|
|
|
rdp_out_activate_caps(s);
|
|
|
|
rdp_out_control_caps(s);
|
|
|
|
rdp_out_pointer_caps(s);
|
|
|
|
rdp_out_share_caps(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-07-12 23:07:39 +02:00
|
|
|
rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* international? */
|
2004-06-27 19:51:54 +02:00
|
|
|
rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c);
|
|
|
|
rdp_out_unknown_caps(s, 0x0e, 0x08, caps_0x0e);
|
2004-07-12 23:07:39 +02:00
|
|
|
rdp_out_unknown_caps(s, 0x10, 0x34, caps_0x10); /* glyph cache? */
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
2003-03-27 14:22:29 +01:00
|
|
|
sec_send(s, sec_flags);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2004-04-26 15:48:39 +02:00
|
|
|
/* Process a general capability set */
|
|
|
|
static void
|
|
|
|
rdp_process_general_caps(STREAM s)
|
|
|
|
{
|
|
|
|
uint16 pad2octetsB; /* rdp5 flags? */
|
|
|
|
|
|
|
|
in_uint8s(s, 10);
|
|
|
|
in_uint16_le(s, pad2octetsB);
|
|
|
|
|
|
|
|
if (!pad2octetsB)
|
|
|
|
g_use_rdp5 = False;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process a bitmap capability set */
|
|
|
|
static void
|
|
|
|
rdp_process_bitmap_caps(STREAM s)
|
|
|
|
{
|
|
|
|
uint16 width, height, bpp;
|
|
|
|
|
|
|
|
in_uint16_le(s, bpp);
|
|
|
|
in_uint8s(s, 6);
|
|
|
|
|
|
|
|
in_uint16_le(s, width);
|
|
|
|
in_uint16_le(s, height);
|
|
|
|
|
|
|
|
DEBUG(("setting desktop size and bpp to: %dx%dx%d\n", width, height, bpp));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The server may limit bpp and change the size of the desktop (for
|
|
|
|
* example when shadowing another session).
|
|
|
|
*/
|
2004-06-04 17:01:36 +02:00
|
|
|
if (g_server_bpp != bpp)
|
|
|
|
{
|
|
|
|
warning("colour depth changed from %d to %d\n", g_server_bpp, bpp);
|
|
|
|
g_server_bpp = bpp;
|
|
|
|
}
|
|
|
|
if (g_width != width || g_height != height)
|
|
|
|
{
|
|
|
|
warning("screen size changed from %dx%d to %dx%d\n", g_width, g_height,
|
2004-07-12 23:07:39 +02:00
|
|
|
width, height);
|
2004-06-04 17:01:36 +02:00
|
|
|
g_width = width;
|
|
|
|
g_height = height;
|
|
|
|
ui_resize_window();
|
|
|
|
}
|
2004-04-26 15:48:39 +02:00
|
|
|
}
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
/* Process server capabilities */
|
|
|
|
void
|
|
|
|
rdp_process_server_caps(STREAM s, uint16 length)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2004-04-26 15:48:39 +02:00
|
|
|
int n;
|
2004-06-27 19:51:54 +02:00
|
|
|
uint8 *next, *start;
|
|
|
|
uint16 ncapsets, capset_type, capset_length;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
start = s->p;
|
2004-04-26 15:48:39 +02:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
in_uint16_le(s, ncapsets);
|
2004-04-26 15:48:39 +02:00
|
|
|
in_uint8s(s, 2); /* pad */
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
for (n = 0; n < ncapsets; n++)
|
2004-04-16 00:03:24 +02:00
|
|
|
{
|
2004-06-27 19:51:54 +02:00
|
|
|
if (s->p > start + length)
|
|
|
|
return;
|
|
|
|
|
2004-04-26 15:48:39 +02:00
|
|
|
in_uint16_le(s, capset_type);
|
|
|
|
in_uint16_le(s, capset_length);
|
|
|
|
|
|
|
|
next = s->p + capset_length - 4;
|
|
|
|
|
|
|
|
switch (capset_type)
|
2004-04-16 00:03:24 +02:00
|
|
|
{
|
2004-04-26 15:48:39 +02:00
|
|
|
case RDP_CAPSET_GENERAL:
|
|
|
|
rdp_process_general_caps(s);
|
|
|
|
break;
|
2004-04-16 00:03:24 +02:00
|
|
|
|
2004-04-26 15:48:39 +02:00
|
|
|
case RDP_CAPSET_BITMAP:
|
|
|
|
rdp_process_bitmap_caps(s);
|
|
|
|
break;
|
|
|
|
}
|
2004-04-16 00:03:24 +02:00
|
|
|
|
2004-04-26 15:48:39 +02:00
|
|
|
s->p = next;
|
|
|
|
}
|
2004-06-27 19:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Respond to a demand active PDU */
|
|
|
|
static void
|
|
|
|
process_demand_active(STREAM s)
|
|
|
|
{
|
|
|
|
uint8 type;
|
|
|
|
uint16 len_src_descriptor, len_combined_caps;
|
|
|
|
|
|
|
|
in_uint32_le(s, g_rdp_shareid);
|
|
|
|
in_uint16_le(s, len_src_descriptor);
|
|
|
|
in_uint16_le(s, len_combined_caps);
|
|
|
|
in_uint8s(s, len_src_descriptor);
|
|
|
|
|
|
|
|
DEBUG(("DEMAND_ACTIVE(id=0x%x)\n", g_rdp_shareid));
|
|
|
|
rdp_process_server_caps(s, len_combined_caps);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
rdp_send_confirm_active();
|
|
|
|
rdp_send_synchronise();
|
|
|
|
rdp_send_control(RDP_CTL_COOPERATE);
|
|
|
|
rdp_send_control(RDP_CTL_REQUEST_CONTROL);
|
2001-06-20 15:54:48 +02:00
|
|
|
rdp_recv(&type); /* RDP_PDU_SYNCHRONIZE */
|
|
|
|
rdp_recv(&type); /* RDP_CTL_COOPERATE */
|
|
|
|
rdp_recv(&type); /* RDP_CTL_GRANT_CONTROL */
|
2003-11-03 14:33:35 +01:00
|
|
|
rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(read_keyboard_state()), 0);
|
2004-04-26 15:48:39 +02:00
|
|
|
|
|
|
|
if (g_use_rdp5)
|
|
|
|
{
|
2004-06-27 19:51:54 +02:00
|
|
|
rdp_enum_bmpcache2();
|
2004-04-26 15:48:39 +02:00
|
|
|
rdp_send_fonts(3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rdp_send_fonts(1);
|
|
|
|
rdp_send_fonts(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
rdp_recv(&type); /* RDP_PDU_UNKNOWN 0x28 (Fonts?) */
|
2000-08-15 12:23:24 +02:00
|
|
|
reset_order_state();
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
/* Process a colour pointer PDU */
|
|
|
|
void
|
|
|
|
process_colour_pointer_pdu(STREAM s)
|
|
|
|
{
|
|
|
|
uint16 x, y, width, height, cache_idx, masklen, datalen;
|
|
|
|
uint8 *mask, *data;
|
|
|
|
HCURSOR cursor;
|
|
|
|
|
|
|
|
in_uint16_le(s, cache_idx);
|
|
|
|
in_uint16_le(s, x);
|
|
|
|
in_uint16_le(s, y);
|
|
|
|
in_uint16_le(s, width);
|
|
|
|
in_uint16_le(s, height);
|
|
|
|
in_uint16_le(s, masklen);
|
|
|
|
in_uint16_le(s, datalen);
|
|
|
|
in_uint8p(s, data, datalen);
|
|
|
|
in_uint8p(s, mask, masklen);
|
|
|
|
cursor = ui_create_cursor(x, y, width, height, mask, data);
|
|
|
|
ui_set_cursor(cursor);
|
|
|
|
cache_put_cursor(cache_idx, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process a cached pointer PDU */
|
|
|
|
void
|
|
|
|
process_cached_pointer_pdu(STREAM s)
|
|
|
|
{
|
|
|
|
uint16 cache_idx;
|
|
|
|
|
|
|
|
in_uint16_le(s, cache_idx);
|
|
|
|
ui_set_cursor(cache_get_cursor(cache_idx));
|
|
|
|
}
|
|
|
|
|
2003-10-22 12:55:11 +02:00
|
|
|
/* Process a system pointer PDU */
|
|
|
|
void
|
|
|
|
process_system_pointer_pdu(STREAM s)
|
|
|
|
{
|
|
|
|
uint16 system_pointer_type;
|
|
|
|
|
|
|
|
in_uint16(s, system_pointer_type);
|
|
|
|
switch (system_pointer_type)
|
|
|
|
{
|
|
|
|
case RDP_NULL_POINTER:
|
|
|
|
ui_set_null_cursor();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unimpl("System pointer message 0x%x\n", system_pointer_type);
|
|
|
|
}
|
|
|
|
}
|
2003-03-27 14:22:29 +01:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process a pointer PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
process_pointer_pdu(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint16 message_type;
|
2003-03-27 14:22:29 +01:00
|
|
|
uint16 x, y;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(s, message_type);
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 2); /* pad */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
switch (message_type)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_POINTER_MOVE:
|
|
|
|
in_uint16_le(s, x);
|
|
|
|
in_uint16_le(s, y);
|
|
|
|
if (s_check(s))
|
|
|
|
ui_move_pointer(x, y);
|
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
case RDP_POINTER_COLOR:
|
2003-03-27 14:22:29 +01:00
|
|
|
process_colour_pointer_pdu(s);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDP_POINTER_CACHED:
|
2003-03-27 14:22:29 +01:00
|
|
|
process_cached_pointer_pdu(s);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
|
|
|
|
2003-10-22 12:55:11 +02:00
|
|
|
case RDP_POINTER_SYSTEM:
|
|
|
|
process_system_pointer_pdu(s);
|
|
|
|
break;
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
default:
|
2003-10-22 12:55:11 +02:00
|
|
|
unimpl("Pointer message 0x%x\n", message_type);
|
2000-08-15 12:23:24 +02:00
|
|
|
}
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process bitmap updates */
|
2003-03-27 14:22:29 +01:00
|
|
|
void
|
2001-01-06 04:47:04 +01:00
|
|
|
process_bitmap_updates(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint16 num_updates;
|
|
|
|
uint16 left, top, right, bottom, width, height;
|
2003-02-08 00:43:37 +01:00
|
|
|
uint16 cx, cy, bpp, Bpp, compress, bufsize, size;
|
2001-06-20 15:54:48 +02:00
|
|
|
uint8 *data, *bmpdata;
|
2000-08-15 12:23:24 +02:00
|
|
|
int i;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(s, num_updates);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
for (i = 0; i < num_updates; i++)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(s, left);
|
|
|
|
in_uint16_le(s, top);
|
|
|
|
in_uint16_le(s, right);
|
|
|
|
in_uint16_le(s, bottom);
|
|
|
|
in_uint16_le(s, width);
|
|
|
|
in_uint16_le(s, height);
|
|
|
|
in_uint16_le(s, bpp);
|
2003-02-08 00:43:37 +01:00
|
|
|
Bpp = (bpp + 7) / 8;
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(s, compress);
|
|
|
|
in_uint16_le(s, bufsize);
|
|
|
|
|
|
|
|
cx = right - left + 1;
|
|
|
|
cy = bottom - top + 1;
|
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
DEBUG(("BITMAP_UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,Bpp=%d,cmp=%d)\n",
|
|
|
|
left, top, right, bottom, width, height, Bpp, compress));
|
2000-08-15 12:23:24 +02:00
|
|
|
|
|
|
|
if (!compress)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-06-20 15:54:48 +02:00
|
|
|
int y;
|
2003-06-06 12:47:34 +02:00
|
|
|
bmpdata = (uint8 *) xmalloc(width * height * Bpp);
|
2001-06-20 15:54:48 +02:00
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
2003-02-10 13:58:51 +01:00
|
|
|
in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)],
|
|
|
|
width * Bpp);
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
|
2001-06-20 15:54:48 +02:00
|
|
|
xfree(bmpdata);
|
|
|
|
continue;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
|
|
|
|
if (compress & 0x400)
|
|
|
|
{
|
|
|
|
size = bufsize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
in_uint8s(s, 2); /* pad */
|
|
|
|
in_uint16_le(s, size);
|
|
|
|
in_uint8s(s, 4); /* line_size, final_size */
|
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8p(s, data, size);
|
2003-06-06 12:47:34 +02:00
|
|
|
bmpdata = (uint8 *) xmalloc(width * height * Bpp);
|
2003-02-08 00:43:37 +01:00
|
|
|
if (bitmap_decompress(bmpdata, width, height, data, size, Bpp))
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
|
2000-08-15 12:23:24 +02:00
|
|
|
}
|
2003-03-27 14:22:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DEBUG_RDP5(("Failed to decompress data\n"));
|
|
|
|
}
|
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
xfree(bmpdata);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process a palette update */
|
2003-03-27 14:22:29 +01:00
|
|
|
void
|
2001-01-06 04:47:04 +01:00
|
|
|
process_palette(STREAM s)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2002-11-05 12:22:20 +01:00
|
|
|
COLOURENTRY *entry;
|
2000-08-15 12:23:24 +02:00
|
|
|
COLOURMAP map;
|
2002-11-05 12:22:20 +01:00
|
|
|
HCOLOURMAP hmap;
|
|
|
|
int i;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 2); /* pad */
|
|
|
|
in_uint16_le(s, map.ncolours);
|
|
|
|
in_uint8s(s, 2); /* pad */
|
2002-11-05 12:22:20 +01:00
|
|
|
|
2003-07-28 20:13:30 +02:00
|
|
|
map.colours = (COLOURENTRY *) xmalloc(sizeof(COLOURENTRY) * map.ncolours);
|
2002-11-05 12:22:20 +01:00
|
|
|
|
2003-03-27 14:22:29 +01:00
|
|
|
DEBUG(("PALETTE(c=%d)\n", map.ncolours));
|
|
|
|
|
2002-11-05 12:22:20 +01:00
|
|
|
for (i = 0; i < map.ncolours; i++)
|
|
|
|
{
|
|
|
|
entry = &map.colours[i];
|
|
|
|
in_uint8(s, entry->red);
|
|
|
|
in_uint8(s, entry->green);
|
|
|
|
in_uint8(s, entry->blue);
|
2002-11-18 16:31:19 +01:00
|
|
|
}
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
hmap = ui_create_colourmap(&map);
|
|
|
|
ui_set_colourmap(hmap);
|
2002-11-05 12:22:20 +01:00
|
|
|
|
|
|
|
xfree(map.colours);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process an update PDU */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
process_update_pdu(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2003-03-27 14:22:29 +01:00
|
|
|
uint16 update_type, count;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_le(s, update_type);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-06-16 05:08:55 +02:00
|
|
|
ui_begin_update();
|
2000-08-15 12:23:24 +02:00
|
|
|
switch (update_type)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_UPDATE_ORDERS:
|
2003-03-27 14:22:29 +01:00
|
|
|
in_uint8s(s, 2); /* pad */
|
|
|
|
in_uint16_le(s, count);
|
|
|
|
in_uint8s(s, 2); /* pad */
|
|
|
|
process_orders(s, count);
|
2000-08-15 12:23:24 +02:00
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_UPDATE_BITMAP:
|
|
|
|
process_bitmap_updates(s);
|
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_UPDATE_PALETTE:
|
|
|
|
process_palette(s);
|
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_UPDATE_SYNCHRONIZE:
|
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
default:
|
2001-09-14 15:51:38 +02:00
|
|
|
unimpl("update %d\n", update_type);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2004-06-16 05:08:55 +02:00
|
|
|
ui_end_update();
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2004-04-20 09:01:21 +02:00
|
|
|
/* Process a disconnect PDU */
|
|
|
|
void
|
|
|
|
process_disconnect_pdu(STREAM s, uint32 * ext_disc_reason)
|
|
|
|
{
|
|
|
|
in_uint32_le(s, *ext_disc_reason);
|
|
|
|
|
|
|
|
DEBUG(("Received disconnect PDU\n"));
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process data PDU */
|
2004-04-20 09:01:21 +02:00
|
|
|
static BOOL
|
|
|
|
process_data_pdu(STREAM s, uint32 * ext_disc_reason)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 data_pdu_type;
|
2004-03-04 09:11:40 +01:00
|
|
|
uint8 ctype;
|
|
|
|
uint16 clen;
|
2004-04-27 14:55:33 +02:00
|
|
|
uint32 len;
|
|
|
|
|
|
|
|
uint32 roff, rlen;
|
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
struct stream *ns = &(g_mppc_dict.ns);
|
2004-03-04 09:11:40 +01:00
|
|
|
|
|
|
|
in_uint8s(s, 6); /* shareid, pad, streamid */
|
|
|
|
in_uint16(s, len);
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, data_pdu_type);
|
2004-03-04 09:11:40 +01:00
|
|
|
in_uint8(s, ctype);
|
|
|
|
in_uint16(s, clen);
|
|
|
|
clen -= 18;
|
|
|
|
|
2004-04-27 14:55:33 +02:00
|
|
|
if (ctype & RDP_MPPC_COMPRESSED)
|
2004-03-04 09:11:40 +01:00
|
|
|
{
|
|
|
|
|
2004-04-27 14:55:33 +02:00
|
|
|
if (mppc_expand(s->p, clen, ctype, &roff, &rlen) == -1)
|
|
|
|
error("error while decompressing packet\n");
|
2004-03-04 09:11:40 +01:00
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
//len -= 18;
|
2004-03-04 09:11:40 +01:00
|
|
|
|
2004-04-27 14:55:33 +02:00
|
|
|
/* allocate memory and copy the uncompressed data into the temporary stream */
|
2004-06-16 00:45:12 +02:00
|
|
|
ns->data = (uint8 *) xrealloc(ns->data, rlen);
|
2004-03-04 09:11:40 +01:00
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
memcpy((ns->data), (unsigned char *) (g_mppc_dict.hist + roff), rlen);
|
2004-03-04 09:11:40 +01:00
|
|
|
|
2004-04-30 08:18:08 +02:00
|
|
|
ns->size = rlen;
|
2004-04-27 14:55:33 +02:00
|
|
|
ns->end = (ns->data + ns->size);
|
|
|
|
ns->p = ns->data;
|
|
|
|
ns->rdp_hdr = ns->p;
|
|
|
|
|
|
|
|
s = ns;
|
2004-03-04 09:11:40 +01:00
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
switch (data_pdu_type)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_DATA_PDU_UPDATE:
|
|
|
|
process_update_pdu(s);
|
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2004-04-20 09:01:21 +02:00
|
|
|
case RDP_DATA_PDU_CONTROL:
|
|
|
|
DEBUG(("Received Control PDU\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDP_DATA_PDU_SYNCHRONISE:
|
|
|
|
DEBUG(("Received Sync PDU\n"));
|
|
|
|
break;
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_DATA_PDU_POINTER:
|
|
|
|
process_pointer_pdu(s);
|
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_DATA_PDU_BELL:
|
|
|
|
ui_bell();
|
|
|
|
break;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
case RDP_DATA_PDU_LOGON:
|
2003-03-27 14:22:29 +01:00
|
|
|
DEBUG(("Received Logon PDU\n"));
|
2000-08-15 12:23:24 +02:00
|
|
|
/* User logged on */
|
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-10-29 05:18:00 +01:00
|
|
|
case RDP_DATA_PDU_DISCONNECT:
|
2004-04-20 09:01:21 +02:00
|
|
|
process_disconnect_pdu(s, ext_disc_reason);
|
|
|
|
return True;
|
2003-10-29 05:18:00 +01:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
default:
|
2001-09-14 15:51:38 +02:00
|
|
|
unimpl("data PDU %d\n", data_pdu_type);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2004-04-20 09:01:21 +02:00
|
|
|
return False;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Process incoming packets */
|
2004-07-05 21:09:07 +02:00
|
|
|
/* nevers gets out of here till app is done */
|
2004-04-20 09:01:21 +02:00
|
|
|
void
|
|
|
|
rdp_main_loop(BOOL * deactivated, uint32 * ext_disc_reason)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2004-07-05 21:09:07 +02:00
|
|
|
while (rdp_loop(deactivated, ext_disc_reason))
|
|
|
|
;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2004-07-05 21:09:07 +02:00
|
|
|
/* used in uiports and rdp_main_loop, processes the rdp packets waiting */
|
2004-06-16 05:08:55 +02:00
|
|
|
BOOL
|
|
|
|
rdp_loop(BOOL * deactivated, uint32 * ext_disc_reason)
|
|
|
|
{
|
|
|
|
uint8 type;
|
|
|
|
BOOL disc = False; /* True when a disconnect PDU was received */
|
|
|
|
BOOL cont = True;
|
|
|
|
STREAM s;
|
|
|
|
|
2004-06-17 11:42:58 +02:00
|
|
|
while (cont)
|
2004-06-16 05:08:55 +02:00
|
|
|
{
|
|
|
|
s = rdp_recv(&type);
|
|
|
|
if (s == NULL)
|
|
|
|
return False;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RDP_PDU_DEMAND_ACTIVE:
|
|
|
|
process_demand_active(s);
|
|
|
|
*deactivated = False;
|
|
|
|
break;
|
|
|
|
case RDP_PDU_DEACTIVATE:
|
|
|
|
DEBUG(("RDP_PDU_DEACTIVATE\n"));
|
|
|
|
*deactivated = True;
|
|
|
|
break;
|
|
|
|
case RDP_PDU_DATA:
|
|
|
|
disc = process_data_pdu(s, ext_disc_reason);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unimpl("PDU %d\n", type);
|
|
|
|
}
|
|
|
|
if (disc)
|
|
|
|
return False;
|
|
|
|
cont = g_next_packet < s->end;
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Establish a connection up to the RDP layer */
|
2001-01-06 04:47:04 +01:00
|
|
|
BOOL
|
|
|
|
rdp_connect(char *server, uint32 flags, char *domain, char *password,
|
|
|
|
char *command, char *directory)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2003-07-28 23:41:12 +02:00
|
|
|
if (!sec_connect(server, g_username))
|
2000-07-25 14:34:29 +02:00
|
|
|
return False;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2003-07-28 23:41:12 +02:00
|
|
|
rdp_send_logon_info(flags, domain, g_username, password, command, directory);
|
2000-08-15 12:23:24 +02:00
|
|
|
return True;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Disconnect from the RDP layer */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
rdp_disconnect(void)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
sec_disconnect();
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|