1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
RDP order processing |
RDP order processing |
4 |
Copyright (C) Matthew Chapman 1999-2005 |
Copyright (C) Matthew Chapman 1999-2007 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
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 |
23 |
|
|
24 |
extern uint8 *g_next_packet; |
extern uint8 *g_next_packet; |
25 |
static RDP_ORDER_STATE g_order_state; |
static RDP_ORDER_STATE g_order_state; |
26 |
extern BOOL g_use_rdp5; |
extern RD_BOOL g_use_rdp5; |
27 |
|
|
28 |
/* Read field indicating which parameters are present */ |
/* Read field indicating which parameters are present */ |
29 |
static void |
static void |
55 |
|
|
56 |
/* Read a co-ordinate (16-bit, or 8-bit delta) */ |
/* Read a co-ordinate (16-bit, or 8-bit delta) */ |
57 |
static void |
static void |
58 |
rdp_in_coord(STREAM s, sint16 * coord, BOOL delta) |
rdp_in_coord(STREAM s, sint16 * coord, RD_BOOL delta) |
59 |
{ |
{ |
60 |
sint8 change; |
sint8 change; |
61 |
|
|
102 |
} |
} |
103 |
|
|
104 |
/* Parse bounds information */ |
/* Parse bounds information */ |
105 |
static BOOL |
static RD_BOOL |
106 |
rdp_parse_bounds(STREAM s, BOUNDS * bounds) |
rdp_parse_bounds(STREAM s, BOUNDS * bounds) |
107 |
{ |
{ |
108 |
uint8 present; |
uint8 present; |
133 |
} |
} |
134 |
|
|
135 |
/* Parse a pen */ |
/* Parse a pen */ |
136 |
static BOOL |
static RD_BOOL |
137 |
rdp_parse_pen(STREAM s, PEN * pen, uint32 present) |
rdp_parse_pen(STREAM s, PEN * pen, uint32 present) |
138 |
{ |
{ |
139 |
if (present & 1) |
if (present & 1) |
149 |
} |
} |
150 |
|
|
151 |
/* Parse a brush */ |
/* Parse a brush */ |
152 |
static BOOL |
static RD_BOOL |
153 |
rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present) |
rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present) |
154 |
{ |
{ |
155 |
if (present & 1) |
if (present & 1) |
172 |
|
|
173 |
/* Process a destination blt order */ |
/* Process a destination blt order */ |
174 |
static void |
static void |
175 |
process_destblt(STREAM s, DESTBLT_ORDER * os, uint32 present, BOOL delta) |
process_destblt(STREAM s, DESTBLT_ORDER * os, uint32 present, RD_BOOL delta) |
176 |
{ |
{ |
177 |
if (present & 0x01) |
if (present & 0x01) |
178 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
197 |
|
|
198 |
/* Process a pattern blt order */ |
/* Process a pattern blt order */ |
199 |
static void |
static void |
200 |
process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, BOOL delta) |
process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, RD_BOOL delta) |
201 |
{ |
{ |
202 |
if (present & 0x0001) |
if (present & 0x0001) |
203 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
231 |
|
|
232 |
/* Process a screen blt order */ |
/* Process a screen blt order */ |
233 |
static void |
static void |
234 |
process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, BOOL delta) |
process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, RD_BOOL delta) |
235 |
{ |
{ |
236 |
if (present & 0x0001) |
if (present & 0x0001) |
237 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
262 |
|
|
263 |
/* Process a line order */ |
/* Process a line order */ |
264 |
static void |
static void |
265 |
process_line(STREAM s, LINE_ORDER * os, uint32 present, BOOL delta) |
process_line(STREAM s, LINE_ORDER * os, uint32 present, RD_BOOL delta) |
266 |
{ |
{ |
267 |
if (present & 0x0001) |
if (present & 0x0001) |
268 |
in_uint16_le(s, os->mixmode); |
in_uint16_le(s, os->mixmode); |
301 |
|
|
302 |
/* Process an opaque rectangle order */ |
/* Process an opaque rectangle order */ |
303 |
static void |
static void |
304 |
process_rect(STREAM s, RECT_ORDER * os, uint32 present, BOOL delta) |
process_rect(STREAM s, RECT_ORDER * os, uint32 present, RD_BOOL delta) |
305 |
{ |
{ |
306 |
uint32 i; |
uint32 i; |
307 |
if (present & 0x01) |
if (present & 0x01) |
341 |
|
|
342 |
/* Process a desktop save order */ |
/* Process a desktop save order */ |
343 |
static void |
static void |
344 |
process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, BOOL delta) |
process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, RD_BOOL delta) |
345 |
{ |
{ |
346 |
int width, height; |
int width, height; |
347 |
|
|
377 |
|
|
378 |
/* Process a memory blt order */ |
/* Process a memory blt order */ |
379 |
static void |
static void |
380 |
process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, BOOL delta) |
process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, RD_BOOL delta) |
381 |
{ |
{ |
382 |
HBITMAP bitmap; |
RD_HBITMAP bitmap; |
383 |
|
|
384 |
if (present & 0x0001) |
if (present & 0x0001) |
385 |
{ |
{ |
423 |
|
|
424 |
/* Process a 3-way blt order */ |
/* Process a 3-way blt order */ |
425 |
static void |
static void |
426 |
process_triblt(STREAM s, TRIBLT_ORDER * os, uint32 present, BOOL delta) |
process_triblt(STREAM s, TRIBLT_ORDER * os, uint32 present, RD_BOOL delta) |
427 |
{ |
{ |
428 |
HBITMAP bitmap; |
RD_HBITMAP bitmap; |
429 |
|
|
430 |
if (present & 0x000001) |
if (present & 0x000001) |
431 |
{ |
{ |
482 |
|
|
483 |
/* Process a polygon order */ |
/* Process a polygon order */ |
484 |
static void |
static void |
485 |
process_polygon(STREAM s, POLYGON_ORDER * os, uint32 present, BOOL delta) |
process_polygon(STREAM s, POLYGON_ORDER * os, uint32 present, RD_BOOL delta) |
486 |
{ |
{ |
487 |
int index, data, next; |
int index, data, next; |
488 |
uint8 flags = 0; |
uint8 flags = 0; |
489 |
POINT *points; |
RD_POINT *points; |
490 |
|
|
491 |
if (present & 0x01) |
if (present & 0x01) |
492 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
528 |
return; |
return; |
529 |
} |
} |
530 |
|
|
531 |
points = (POINT *) xmalloc((os->npoints + 1) * sizeof(POINT)); |
points = (RD_POINT *) xmalloc((os->npoints + 1) * sizeof(RD_POINT)); |
532 |
memset(points, 0, (os->npoints + 1) * sizeof(POINT)); |
memset(points, 0, (os->npoints + 1) * sizeof(RD_POINT)); |
533 |
|
|
534 |
points[0].x = os->x; |
points[0].x = os->x; |
535 |
points[0].y = os->y; |
points[0].y = os->y; |
561 |
|
|
562 |
/* Process a polygon2 order */ |
/* Process a polygon2 order */ |
563 |
static void |
static void |
564 |
process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, BOOL delta) |
process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, RD_BOOL delta) |
565 |
{ |
{ |
566 |
int index, data, next; |
int index, data, next; |
567 |
uint8 flags = 0; |
uint8 flags = 0; |
568 |
POINT *points; |
RD_POINT *points; |
569 |
|
|
570 |
if (present & 0x0001) |
if (present & 0x0001) |
571 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
613 |
return; |
return; |
614 |
} |
} |
615 |
|
|
616 |
points = (POINT *) xmalloc((os->npoints + 1) * sizeof(POINT)); |
points = (RD_POINT *) xmalloc((os->npoints + 1) * sizeof(RD_POINT)); |
617 |
memset(points, 0, (os->npoints + 1) * sizeof(POINT)); |
memset(points, 0, (os->npoints + 1) * sizeof(RD_POINT)); |
618 |
|
|
619 |
points[0].x = os->x; |
points[0].x = os->x; |
620 |
points[0].y = os->y; |
points[0].y = os->y; |
646 |
|
|
647 |
/* Process a polyline order */ |
/* Process a polyline order */ |
648 |
static void |
static void |
649 |
process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, BOOL delta) |
process_polyline(STREAM s, POLYLINE_ORDER * os, uint32 present, RD_BOOL delta) |
650 |
{ |
{ |
651 |
int index, next, data; |
int index, next, data; |
652 |
uint8 flags = 0; |
uint8 flags = 0; |
653 |
PEN pen; |
PEN pen; |
654 |
POINT *points; |
RD_POINT *points; |
655 |
|
|
656 |
if (present & 0x01) |
if (present & 0x01) |
657 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
690 |
return; |
return; |
691 |
} |
} |
692 |
|
|
693 |
points = (POINT *) xmalloc((os->lines + 1) * sizeof(POINT)); |
points = (RD_POINT *) xmalloc((os->lines + 1) * sizeof(RD_POINT)); |
694 |
memset(points, 0, (os->lines + 1) * sizeof(POINT)); |
memset(points, 0, (os->lines + 1) * sizeof(RD_POINT)); |
695 |
|
|
696 |
points[0].x = os->x; |
points[0].x = os->x; |
697 |
points[0].y = os->y; |
points[0].y = os->y; |
724 |
|
|
725 |
/* Process an ellipse order */ |
/* Process an ellipse order */ |
726 |
static void |
static void |
727 |
process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, BOOL delta) |
process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, RD_BOOL delta) |
728 |
{ |
{ |
729 |
if (present & 0x01) |
if (present & 0x01) |
730 |
rdp_in_coord(s, &os->left, delta); |
rdp_in_coord(s, &os->left, delta); |
756 |
|
|
757 |
/* Process an ellipse2 order */ |
/* Process an ellipse2 order */ |
758 |
static void |
static void |
759 |
process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, BOOL delta) |
process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, RD_BOOL delta) |
760 |
{ |
{ |
761 |
if (present & 0x0001) |
if (present & 0x0001) |
762 |
rdp_in_coord(s, &os->left, delta); |
rdp_in_coord(s, &os->left, delta); |
794 |
|
|
795 |
/* Process a text order */ |
/* Process a text order */ |
796 |
static void |
static void |
797 |
process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, BOOL delta) |
process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, RD_BOOL delta) |
798 |
{ |
{ |
799 |
int i; |
int i; |
800 |
|
|
874 |
static void |
static void |
875 |
process_raw_bmpcache(STREAM s) |
process_raw_bmpcache(STREAM s) |
876 |
{ |
{ |
877 |
HBITMAP bitmap; |
RD_HBITMAP bitmap; |
878 |
uint16 cache_idx, bufsize; |
uint16 cache_idx, bufsize; |
879 |
uint8 cache_id, width, height, bpp, Bpp; |
uint8 cache_id, width, height, bpp, Bpp; |
880 |
uint8 *data, *inverted; |
uint8 *data, *inverted; |
907 |
static void |
static void |
908 |
process_bmpcache(STREAM s) |
process_bmpcache(STREAM s) |
909 |
{ |
{ |
910 |
HBITMAP bitmap; |
RD_HBITMAP bitmap; |
911 |
uint16 cache_idx, size; |
uint16 cache_idx, size; |
912 |
uint8 cache_id, width, height, bpp, Bpp; |
uint8 cache_id, width, height, bpp, Bpp; |
913 |
uint8 *data, *bmpdata; |
uint8 *data, *bmpdata; |
961 |
|
|
962 |
/* Process a bitmap cache v2 order */ |
/* Process a bitmap cache v2 order */ |
963 |
static void |
static void |
964 |
process_bmpcache2(STREAM s, uint16 flags, BOOL compressed) |
process_bmpcache2(STREAM s, uint16 flags, RD_BOOL compressed) |
965 |
{ |
{ |
966 |
HBITMAP bitmap; |
RD_HBITMAP bitmap; |
967 |
int y; |
int y; |
968 |
uint8 cache_id, cache_idx_low, width, height, Bpp; |
uint8 cache_id, cache_idx_low, width, height, Bpp; |
969 |
uint16 cache_idx, bufsize; |
uint16 cache_idx, bufsize; |
1045 |
{ |
{ |
1046 |
COLOURENTRY *entry; |
COLOURENTRY *entry; |
1047 |
COLOURMAP map; |
COLOURMAP map; |
1048 |
HCOLOURMAP hmap; |
RD_HCOLOURMAP hmap; |
1049 |
uint8 cache_id; |
uint8 cache_id; |
1050 |
int i; |
int i; |
1051 |
|
|
1066 |
DEBUG(("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours)); |
DEBUG(("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours)); |
1067 |
|
|
1068 |
hmap = ui_create_colourmap(&map); |
hmap = ui_create_colourmap(&map); |
1069 |
ui_set_colourmap(hmap); |
|
1070 |
|
if (cache_id) |
1071 |
|
ui_set_colourmap(hmap); |
1072 |
|
|
1073 |
xfree(map.colours); |
xfree(map.colours); |
1074 |
} |
} |
1077 |
static void |
static void |
1078 |
process_fontcache(STREAM s) |
process_fontcache(STREAM s) |
1079 |
{ |
{ |
1080 |
HGLYPH bitmap; |
RD_HGLYPH bitmap; |
1081 |
uint8 font, nglyphs; |
uint8 font, nglyphs; |
1082 |
uint16 character, offset, baseline, width, height; |
uint16 character, offset, baseline, width, height; |
1083 |
int i, datasize; |
int i, datasize; |
1163 |
uint32 present; |
uint32 present; |
1164 |
uint8 order_flags; |
uint8 order_flags; |
1165 |
int size, processed = 0; |
int size, processed = 0; |
1166 |
BOOL delta; |
RD_BOOL delta; |
1167 |
|
|
1168 |
while (processed < num_orders) |
while (processed < num_orders) |
1169 |
{ |
{ |