--- sourceforge.net/trunk/rdesktop/rdp.c 2003/10/22 10:55:11 508 +++ sourceforge.net/trunk/rdesktop/rdp.c 2003/12/09 09:57:44 554 @@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include "rdesktop.h" extern uint16 g_mcs_userid; @@ -29,6 +30,7 @@ extern BOOL g_use_rdp5; extern uint16 g_server_rdp_version; extern int g_server_bpp; +extern time_t timezone; uint8 *g_next_packet; uint32 g_rdp_shareid; @@ -71,7 +73,7 @@ #if WITH_DEBUG DEBUG(("RDP packet #%d, (type %x)\n", ++g_packetno, *type)); - // hexdump(g_next_packet, length); + hexdump(g_next_packet, length); #endif /* */ g_next_packet += length; @@ -146,6 +148,7 @@ int packetlen = 0; uint32 sec_flags = g_encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO; STREAM s; + tzset(); if (!g_use_rdp5 || 1 == g_server_rdp_version) { @@ -171,33 +174,33 @@ { flags |= RDP_LOGON_BLOB; DEBUG_RDP5(("Sending RDP5-style Logon packet\n")); - 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 + 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 */ s = sec_init(sec_flags, packetlen); DEBUG_RDP5(("Called sec_init with packetlen %d\n", packetlen)); - out_uint32(s, 0); // Unknown + out_uint32(s, 0); /* Unknown */ out_uint32_le(s, flags); out_uint16_le(s, len_domain); out_uint16_le(s, len_user); @@ -243,12 +246,12 @@ out_uint16_le(s, 0); } out_uint16_le(s, 2); - out_uint16_le(s, len_ip + 2); // Length of client ip + out_uint16_le(s, len_ip + 2); /* Length of client ip */ rdp_out_unistr(s, "127.0.0.1", len_ip); out_uint16_le(s, len_dll + 2); rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", len_dll); - out_uint16_le(s, 0xffc4); - out_uint16_le(s, 0xffff); + out_uint16_le(s, timezone/60); + out_uint16_le(s, 0x0000); rdp_out_unistr(s, "GTB, normaltid", 2 * strlen("GTB, normaltid")); out_uint8s(s, 62 - 2 * strlen("GTB, normaltid")); @@ -600,7 +603,7 @@ rdp_recv(&type); /* RDP_PDU_SYNCHRONIZE */ rdp_recv(&type); /* RDP_CTL_COOPERATE */ rdp_recv(&type); /* RDP_CTL_GRANT_CONTROL */ - rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0); + rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(read_keyboard_state()), 0); rdp_send_fonts(1); rdp_send_fonts(2); rdp_recv(&type); /* RDP_PDU_UNKNOWN 0x28 */ @@ -724,6 +727,13 @@ 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)); + /* Server may limit bpp - this is how we find out */ + if (g_server_bpp != bpp) + { + warning("Server limited colour depth to %d bits\n", bpp); + g_server_bpp = bpp; + } + if (!compress) { int y; @@ -858,6 +868,12 @@ /* User logged on */ break; + case RDP_DATA_PDU_DISCONNECT: + /* Normally received when user logs out or disconnects from a + console session on Windows XP and 2003 Server */ + DEBUG(("Received disconnect PDU\n")); + break; + default: unimpl("data PDU %d\n", data_pdu_type); }