--- sourceforge.net/trunk/rdesktop/orders.c 2003/02/10 12:58:51 318 +++ sourceforge.net/trunk/rdesktop/orders.c 2003/05/19 21:36:33 376 @@ -1,4 +1,4 @@ -/* +/* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. RDP order processing Copyright (C) Matthew Chapman 1999-2002 @@ -23,6 +23,7 @@ extern uint8 *next_packet; static RDP_ORDER_STATE order_state; +extern BOOL use_rdp5; /* Read field indicating which parameters are present */ static void @@ -54,7 +55,7 @@ /* Read a co-ordinate (16-bit, or 8-bit delta) */ static void -rdp_in_coord(STREAM s, uint16 * coord, BOOL delta) +rdp_in_coord(STREAM s, sint16 * coord, BOOL delta) { sint8 change; @@ -605,6 +606,10 @@ if (present & 0x002000) in_uint16_le(s, os->boxbottom); + if (present & 0x004000) /* fix for connecting to a server that */ + in_uint8s(s, 10); /* was disconnected with mstsc.exe */ + /* 0x008000, 0x020000, and 0x040000 are present too ??? */ + if (present & 0x080000) in_uint16_le(s, os->x); @@ -656,7 +661,7 @@ in_uint8p(s, data, bufsize); DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx)); - inverted = xmalloc(width * height * Bpp); + inverted = (uint8*)xmalloc(width * height * Bpp); for (y = 0; y < height; y++) { memcpy(&inverted[(height - y - 1) * (width * Bpp)], &data[y * (width * Bpp)], @@ -676,29 +681,50 @@ uint16 cache_idx, size; uint8 cache_id, width, height, bpp, Bpp; uint8 *data, *bmpdata; + uint16 bufsize, pad2, row_size, final_size; + uint8 pad1; + + pad2 = row_size = final_size = 0xffff; /* Shut the compiler up */ in_uint8(s, cache_id); - in_uint8s(s, 1); /* pad */ + in_uint8(s, pad1); /* pad */ in_uint8(s, width); in_uint8(s, height); in_uint8(s, bpp); Bpp = (bpp + 7) / 8; - in_uint8s(s, 2); /* bufsize */ + in_uint16_le(s, bufsize); /* bufsize */ in_uint16_le(s, cache_idx); - in_uint8s(s, 2); /* pad */ - in_uint16_le(s, size); - in_uint8s(s, 4); /* row_size, final_size */ + + if (!use_rdp5) { + + /* Begin compressedBitmapData */ + in_uint16_le(s, pad2); /* pad */ + in_uint16_le(s, size); + // in_uint8s(s, 4); /* row_size, final_size */ + in_uint16_le(s, row_size); + in_uint16_le(s, final_size); + + } else { + size = bufsize; + } in_uint8p(s, data, size); - DEBUG(("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx)); + DEBUG(("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d,bpp=%d,size=%d,pad1=%d,bufsize=%d,pad2=%d,rs=%d,fs=%d)\n", + width, height, + cache_id, cache_idx, + bpp, size, pad1, bufsize, pad2, row_size, final_size)); - bmpdata = xmalloc(width * height * Bpp); + bmpdata = (uint8*)xmalloc(width * height * Bpp); if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) { bitmap = ui_create_bitmap(width, height, bmpdata); cache_put_bitmap(cache_id, cache_idx, bitmap); } + else + { + DEBUG(("Failed to decompress bitmap data\n")); + } xfree(bmpdata); } @@ -716,7 +742,7 @@ in_uint8(s, cache_id); in_uint16_le(s, map.ncolours); - map.colours = xmalloc(3 * map.ncolours); + map.colours = (COLOURENTRY*)xmalloc(3 * map.ncolours); for (i = 0; i < map.ncolours; i++) { @@ -807,19 +833,14 @@ /* Process an order PDU */ void -process_orders(STREAM s) +process_orders(STREAM s, uint16 num_orders) { RDP_ORDER_STATE *os = &order_state; uint32 present; - uint16 num_orders; uint8 order_flags; int size, processed = 0; BOOL delta; - in_uint8s(s, 2); /* pad */ - in_uint16_le(s, num_orders); - in_uint8s(s, 2); /* pad */ - while (processed < num_orders) { in_uint8(s, order_flags);