--- sourceforge.net/trunk/rdesktop/rdp.c 2003/07/01 09:31:25 432 +++ sourceforge.net/trunk/rdesktop/rdp.c 2003/07/28 21:41:12 437 @@ -2,17 +2,17 @@ rdesktop: A Remote Desktop Protocol client. Protocol services - RDP layer Copyright (C) Matthew Chapman 1999-2002 - + 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. - + 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. - + 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. @@ -21,13 +21,14 @@ #include "rdesktop.h" extern uint16 g_mcs_userid; -extern char username[16]; -extern BOOL bitmap_compression; -extern BOOL orders; -extern BOOL encryption; +extern char g_username[16]; +extern BOOL g_bitmap_compression; +extern BOOL g_orders; +extern BOOL g_encryption; extern BOOL desktop_save; extern BOOL use_rdp5; extern uint16 server_rdp_version; +extern int server_bpp; uint8 *next_packet; uint32 rdp_shareid; @@ -83,7 +84,7 @@ { STREAM s; - s = sec_init(encryption ? SEC_ENCRYPT : 0, maxlen + 18); + s = sec_init(g_encryption ? SEC_ENCRYPT : 0, maxlen + 18); s_push_layer(s, rdp_hdr, 18); return s; @@ -110,7 +111,7 @@ out_uint8(s, 0); /* compress_type */ out_uint16(s, 0); /* compress_len */ - sec_send(s, encryption ? SEC_ENCRYPT : 0); + sec_send(s, g_encryption ? SEC_ENCRYPT : 0); } /* Output a string in Unicode */ @@ -143,7 +144,7 @@ int len_ip = 2 * strlen("127.0.0.1"); int len_dll = 2 * strlen("C:\\WINNT\\System32\\mstscax.dll"); int packetlen = 0; - uint32 sec_flags = encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO; + uint32 sec_flags = g_encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO; STREAM s; if (!use_rdp5 || 1 == server_rdp_version) @@ -178,7 +179,7 @@ (flags & RDP_LOGON_BLOB ? 2 : 0) + // Length of BLOB 2 + // len_program 2 + // len_directory - (0 < len_domain ? len_domain : 2) + // domain + (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) @@ -386,7 +387,7 @@ out_uint16_le(s, 600); /* Desktop height */ out_uint16(s, 0); /* Pad */ out_uint16(s, 0); /* Allow resize */ - out_uint16_le(s, bitmap_compression ? 1 : 0); /* Support compression */ + out_uint16_le(s, g_bitmap_compression ? 1 : 0); /* Support compression */ out_uint16(s, 0); /* Unknown */ out_uint16_le(s, 1); /* Unknown */ out_uint16(s, 0); /* Pad */ @@ -434,16 +435,18 @@ static void rdp_out_bmpcache_caps(STREAM s) { + int Bpp; out_uint16_le(s, RDP_CAPSET_BMPCACHE); out_uint16_le(s, RDP_CAPLEN_BMPCACHE); + Bpp = (server_bpp + 7) / 8; out_uint8s(s, 24); /* unused */ out_uint16_le(s, 0x258); /* entries */ - out_uint16_le(s, 0x100); /* max cell size */ + out_uint16_le(s, 0x100 * Bpp); /* max cell size */ out_uint16_le(s, 0x12c); /* entries */ - out_uint16_le(s, 0x400); /* max cell size */ + out_uint16_le(s, 0x400 * Bpp); /* max cell size */ out_uint16_le(s, 0x106); /* entries */ - out_uint16_le(s, 0x1000); /* max cell size */ + out_uint16_le(s, 0x1000 * Bpp); /* max cell size */ } /* Output control capability set */ @@ -543,7 +546,7 @@ rdp_send_confirm_active(void) { STREAM s; - uint32 sec_flags = encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG; + uint32 sec_flags = g_encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG; uint16 caplen = RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER + RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + @@ -762,7 +765,7 @@ in_uint16_le(s, map.ncolours); in_uint8s(s, 2); /* pad */ - map.colours = (COLOURENTRY *) xmalloc(3 * map.ncolours); + map.colours = (COLOURENTRY *) xmalloc(sizeof(COLOURENTRY) * map.ncolours); DEBUG(("PALETTE(c=%d)\n", map.ncolours)); @@ -886,8 +889,8 @@ } return True; /* We want to detect if we got a clean shutdown, but we - can't. Se above. - return False; */ + can't. Se above. + return False; */ } /* Establish a connection up to the RDP layer */ @@ -895,10 +898,10 @@ rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory) { - if (!sec_connect(server, username)) + if (!sec_connect(server, g_username)) return False; - rdp_send_logon_info(flags, domain, username, password, command, directory); + rdp_send_logon_info(flags, domain, g_username, password, command, directory); return True; }