1 |
/* |
/* -*- 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-2001 |
Copyright (C) Matthew Chapman 1999-2005 |
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 |
21 |
#include "rdesktop.h" |
#include "rdesktop.h" |
22 |
#include "orders.h" |
#include "orders.h" |
23 |
|
|
24 |
extern uint8 *next_packet; |
extern uint8 *g_next_packet; |
25 |
static RDP_ORDER_STATE order_state; |
static RDP_ORDER_STATE g_order_state; |
26 |
|
extern 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 |
30 |
rdp_in_present(STREAM s, uint32 *present, uint8 flags, int size) |
rdp_in_present(STREAM s, uint32 * present, uint8 flags, int size) |
31 |
{ |
{ |
32 |
uint8 bits; |
uint8 bits; |
33 |
int i; |
int i; |
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, uint16 *coord, BOOL delta) |
rdp_in_coord(STREAM s, sint16 * coord, BOOL delta) |
59 |
{ |
{ |
60 |
uint8 change; |
sint8 change; |
61 |
|
|
62 |
if (delta) |
if (delta) |
63 |
{ |
{ |
64 |
in_uint8(s, change); |
in_uint8(s, change); |
65 |
*coord += (signed char) change; |
*coord += change; |
66 |
} |
} |
67 |
else |
else |
68 |
{ |
{ |
70 |
} |
} |
71 |
} |
} |
72 |
|
|
73 |
|
/* Parse a delta co-ordinate in polyline/polygon order form */ |
74 |
|
static int |
75 |
|
parse_delta(uint8 * buffer, int *offset) |
76 |
|
{ |
77 |
|
int value = buffer[(*offset)++]; |
78 |
|
int two_byte = value & 0x80; |
79 |
|
|
80 |
|
if (value & 0x40) /* sign bit */ |
81 |
|
value |= ~0x3f; |
82 |
|
else |
83 |
|
value &= 0x3f; |
84 |
|
|
85 |
|
if (two_byte) |
86 |
|
value = (value << 8) | buffer[(*offset)++]; |
87 |
|
|
88 |
|
return value; |
89 |
|
} |
90 |
|
|
91 |
/* Read a colour entry */ |
/* Read a colour entry */ |
92 |
static void |
static void |
93 |
rdp_in_colour(STREAM s, uint8 *colour) |
rdp_in_colour(STREAM s, uint32 * colour) |
94 |
{ |
{ |
95 |
in_uint8(s, *colour); |
uint32 i; |
96 |
s->p += 2; |
in_uint8(s, i); |
97 |
|
*colour = i; |
98 |
|
in_uint8(s, i); |
99 |
|
*colour |= i << 8; |
100 |
|
in_uint8(s, i); |
101 |
|
*colour |= i << 16; |
102 |
} |
} |
103 |
|
|
104 |
/* Parse bounds information */ |
/* Parse bounds information */ |
105 |
static BOOL |
static BOOL |
106 |
rdp_parse_bounds(STREAM s, BOUNDS *bounds) |
rdp_parse_bounds(STREAM s, BOUNDS * bounds) |
107 |
{ |
{ |
108 |
uint8 present; |
uint8 present; |
109 |
|
|
134 |
|
|
135 |
/* Parse a pen */ |
/* Parse a pen */ |
136 |
static BOOL |
static 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) |
140 |
in_uint8(s, pen->style); |
in_uint8(s, pen->style); |
150 |
|
|
151 |
/* Parse a brush */ |
/* Parse a brush */ |
152 |
static BOOL |
static 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) |
156 |
in_uint8(s, brush->xorigin); |
in_uint8(s, brush->xorigin); |
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, 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, 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); |
222 |
|
|
223 |
rdp_parse_brush(s, &os->brush, present >> 7); |
rdp_parse_brush(s, &os->brush, present >> 7); |
224 |
|
|
225 |
DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", |
DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x, |
226 |
os->opcode, os->x, os->y, os->cx, os->cy, |
os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour)); |
|
os->brush.style, os->bgcolour, os->fgcolour)); |
|
227 |
|
|
228 |
ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, |
ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, |
229 |
&os->brush, os->bgcolour, os->fgcolour); |
&os->brush, os->bgcolour, os->fgcolour); |
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, 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); |
257 |
DEBUG(("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n", |
DEBUG(("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n", |
258 |
os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy)); |
os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy)); |
259 |
|
|
260 |
ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, |
ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); |
|
os->srcx, os->srcy); |
|
261 |
} |
} |
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, BOOL delta) |
266 |
{ |
{ |
267 |
if (present & 0x0001) |
if (present & 0x0001) |
268 |
in_uint16_le(s, os->mixmode); |
in_uint16_le(s, os->mixmode); |
287 |
|
|
288 |
rdp_parse_pen(s, &os->pen, present >> 7); |
rdp_parse_pen(s, &os->pen, present >> 7); |
289 |
|
|
290 |
DEBUG(("LINE(op=0x%x,sx=%d,sy=%d,dx=%d,dx=%d,fg=0x%x)\n", |
DEBUG(("LINE(op=0x%x,sx=%d,sy=%d,dx=%d,dy=%d,fg=0x%x)\n", |
291 |
os->opcode, os->startx, os->starty, os->endx, os->endy, |
os->opcode, os->startx, os->starty, os->endx, os->endy, os->pen.colour)); |
|
os->pen.colour)); |
|
292 |
|
|
293 |
if (os->opcode < 0x01 || os->opcode > 0x10) |
if (os->opcode < 0x01 || os->opcode > 0x10) |
294 |
{ |
{ |
296 |
return; |
return; |
297 |
} |
} |
298 |
|
|
299 |
ui_line(os->opcode - 1, os->startx, os->starty, |
ui_line(os->opcode - 1, os->startx, os->starty, os->endx, os->endy, &os->pen); |
|
os->endx, os->endy, &os->pen); |
|
300 |
} |
} |
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, BOOL delta) |
305 |
{ |
{ |
306 |
|
uint32 i; |
307 |
if (present & 0x01) |
if (present & 0x01) |
308 |
rdp_in_coord(s, &os->x, delta); |
rdp_in_coord(s, &os->x, delta); |
309 |
|
|
317 |
rdp_in_coord(s, &os->cy, delta); |
rdp_in_coord(s, &os->cy, delta); |
318 |
|
|
319 |
if (present & 0x10) |
if (present & 0x10) |
320 |
in_uint8(s, os->colour); |
{ |
321 |
|
in_uint8(s, i); |
322 |
|
os->colour = (os->colour & 0xffffff00) | i; |
323 |
|
} |
324 |
|
|
325 |
|
if (present & 0x20) |
326 |
|
{ |
327 |
|
in_uint8(s, i); |
328 |
|
os->colour = (os->colour & 0xffff00ff) | (i << 8); |
329 |
|
} |
330 |
|
|
331 |
|
if (present & 0x40) |
332 |
|
{ |
333 |
|
in_uint8(s, i); |
334 |
|
os->colour = (os->colour & 0xff00ffff) | (i << 16); |
335 |
|
} |
336 |
|
|
337 |
DEBUG(("RECT(x=%d,y=%d,cx=%d,cy=%d,fg=0x%x)\n", |
DEBUG(("RECT(x=%d,y=%d,cx=%d,cy=%d,fg=0x%x)\n", os->x, os->y, os->cx, os->cy, os->colour)); |
|
os->x, os->y, os->cx, os->cy, os->colour)); |
|
338 |
|
|
339 |
ui_rect(os->x, os->y, os->cx, os->cy, os->colour); |
ui_rect(os->x, os->y, os->cx, os->cy, os->colour); |
340 |
} |
} |
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, BOOL delta) |
345 |
{ |
{ |
346 |
int width, height; |
int width, height; |
347 |
|
|
364 |
in_uint8(s, os->action); |
in_uint8(s, os->action); |
365 |
|
|
366 |
DEBUG(("DESKSAVE(l=%d,t=%d,r=%d,b=%d,off=%d,op=%d)\n", |
DEBUG(("DESKSAVE(l=%d,t=%d,r=%d,b=%d,off=%d,op=%d)\n", |
367 |
os->left, os->top, os->right, os->bottom, os->offset, |
os->left, os->top, os->right, os->bottom, os->offset, os->action)); |
|
os->action)); |
|
368 |
|
|
369 |
width = os->right - os->left + 1; |
width = os->right - os->left + 1; |
370 |
height = os->bottom - os->top + 1; |
height = os->bottom - os->top + 1; |
372 |
if (os->action == 0) |
if (os->action == 0) |
373 |
ui_desktop_save(os->offset, os->left, os->top, width, height); |
ui_desktop_save(os->offset, os->left, os->top, width, height); |
374 |
else |
else |
375 |
ui_desktop_restore(os->offset, os->left, os->top, width, |
ui_desktop_restore(os->offset, os->left, os->top, width, height); |
|
height); |
|
376 |
} |
} |
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, BOOL delta) |
381 |
{ |
{ |
382 |
HBITMAP bitmap; |
HBITMAP bitmap; |
383 |
|
|
412 |
in_uint16_le(s, os->cache_idx); |
in_uint16_le(s, os->cache_idx); |
413 |
|
|
414 |
DEBUG(("MEMBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d)\n", |
DEBUG(("MEMBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d)\n", |
415 |
os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, |
os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, os->cache_idx)); |
|
os->cache_idx)); |
|
416 |
|
|
417 |
bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); |
bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); |
418 |
if (bitmap == NULL) |
if (bitmap == NULL) |
419 |
return; |
return; |
420 |
|
|
421 |
ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, |
ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy); |
|
bitmap, os->srcx, os->srcy); |
|
422 |
} |
} |
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, BOOL delta) |
427 |
{ |
{ |
428 |
HBITMAP bitmap; |
HBITMAP bitmap; |
429 |
|
|
469 |
in_uint16_le(s, os->unknown); |
in_uint16_le(s, os->unknown); |
470 |
|
|
471 |
DEBUG(("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n", |
DEBUG(("TRIBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d,bs=%d,bg=0x%x,fg=0x%x)\n", |
472 |
os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, |
os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, os->cache_idx, |
473 |
os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour)); |
os->brush.style, os->bgcolour, os->fgcolour)); |
474 |
|
|
475 |
bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); |
bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); |
476 |
if (bitmap == NULL) |
if (bitmap == NULL) |
477 |
return; |
return; |
478 |
|
|
479 |
ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy, |
ui_triblt(os->opcode, os->x, os->y, os->cx, os->cy, |
480 |
bitmap, os->srcx, os->srcy, |
bitmap, os->srcx, os->srcy, &os->brush, os->bgcolour, os->fgcolour); |
|
&os->brush, os->bgcolour, os->fgcolour); |
|
481 |
} |
} |
482 |
|
|
483 |
/* Parse a delta co-ordinate in polyline order form */ |
/* Process a polygon order */ |
484 |
static int |
static void |
485 |
parse_delta(uint8 *buffer, int *offset) |
process_polygon(STREAM s, POLYGON_ORDER * os, uint32 present, BOOL delta) |
486 |
{ |
{ |
487 |
int value = buffer[(*offset)++]; |
int index, data, next; |
488 |
int two_byte = value & 0x80; |
uint8 flags = 0; |
489 |
|
POINT *points; |
490 |
|
|
491 |
if (value & 0x40) /* sign bit */ |
if (present & 0x01) |
492 |
value |= ~0x3f; |
rdp_in_coord(s, &os->x, delta); |
493 |
|
|
494 |
|
if (present & 0x02) |
495 |
|
rdp_in_coord(s, &os->y, delta); |
496 |
|
|
497 |
|
if (present & 0x04) |
498 |
|
in_uint8(s, os->opcode); |
499 |
|
|
500 |
|
if (present & 0x08) |
501 |
|
in_uint8(s, os->fillmode); |
502 |
|
|
503 |
|
if (present & 0x10) |
504 |
|
rdp_in_colour(s, &os->fgcolour); |
505 |
|
|
506 |
|
if (present & 0x20) |
507 |
|
in_uint8(s, os->npoints); |
508 |
|
|
509 |
|
if (present & 0x40) |
510 |
|
{ |
511 |
|
in_uint8(s, os->datasize); |
512 |
|
in_uint8a(s, os->data, os->datasize); |
513 |
|
} |
514 |
|
|
515 |
|
DEBUG(("POLYGON(x=%d,y=%d,op=0x%x,fm=%d,fg=0x%x,n=%d,sz=%d)\n", |
516 |
|
os->x, os->y, os->opcode, os->fillmode, os->fgcolour, os->npoints, os->datasize)); |
517 |
|
|
518 |
|
DEBUG(("Data: ")); |
519 |
|
|
520 |
|
for (index = 0; index < os->datasize; index++) |
521 |
|
DEBUG(("%02x ", os->data[index])); |
522 |
|
|
523 |
|
DEBUG(("\n")); |
524 |
|
|
525 |
|
if (os->opcode < 0x01 || os->opcode > 0x10) |
526 |
|
{ |
527 |
|
error("bad ROP2 0x%x\n", os->opcode); |
528 |
|
return; |
529 |
|
} |
530 |
|
|
531 |
|
points = (POINT *) xmalloc((os->npoints + 1) * sizeof(POINT)); |
532 |
|
memset(points, 0, (os->npoints + 1) * sizeof(POINT)); |
533 |
|
|
534 |
|
points[0].x = os->x; |
535 |
|
points[0].y = os->y; |
536 |
|
|
537 |
|
index = 0; |
538 |
|
data = ((os->npoints - 1) / 4) + 1; |
539 |
|
for (next = 1; (next <= os->npoints) && (next < 256) && (data < os->datasize); next++) |
540 |
|
{ |
541 |
|
if ((next - 1) % 4 == 0) |
542 |
|
flags = os->data[index++]; |
543 |
|
|
544 |
|
if (~flags & 0x80) |
545 |
|
points[next].x = parse_delta(os->data, &data); |
546 |
|
|
547 |
|
if (~flags & 0x40) |
548 |
|
points[next].y = parse_delta(os->data, &data); |
549 |
|
|
550 |
|
flags <<= 2; |
551 |
|
} |
552 |
|
|
553 |
|
if (next - 1 == os->npoints) |
554 |
|
ui_polygon(os->opcode - 1, os->fillmode, points, os->npoints + 1, NULL, 0, |
555 |
|
os->fgcolour); |
556 |
else |
else |
557 |
value &= 0x3f; |
error("polygon parse error\n"); |
558 |
|
|
559 |
if (two_byte) |
xfree(points); |
560 |
value = (value << 8) | buffer[(*offset)++]; |
} |
561 |
|
|
562 |
return value; |
/* Process a polygon2 order */ |
563 |
|
static void |
564 |
|
process_polygon2(STREAM s, POLYGON2_ORDER * os, uint32 present, BOOL delta) |
565 |
|
{ |
566 |
|
int index, data, next; |
567 |
|
uint8 flags = 0; |
568 |
|
POINT *points; |
569 |
|
|
570 |
|
if (present & 0x0001) |
571 |
|
rdp_in_coord(s, &os->x, delta); |
572 |
|
|
573 |
|
if (present & 0x0002) |
574 |
|
rdp_in_coord(s, &os->y, delta); |
575 |
|
|
576 |
|
if (present & 0x0004) |
577 |
|
in_uint8(s, os->opcode); |
578 |
|
|
579 |
|
if (present & 0x0008) |
580 |
|
in_uint8(s, os->fillmode); |
581 |
|
|
582 |
|
if (present & 0x0010) |
583 |
|
rdp_in_colour(s, &os->bgcolour); |
584 |
|
|
585 |
|
if (present & 0x0020) |
586 |
|
rdp_in_colour(s, &os->fgcolour); |
587 |
|
|
588 |
|
rdp_parse_brush(s, &os->brush, present >> 6); |
589 |
|
|
590 |
|
if (present & 0x0800) |
591 |
|
in_uint8(s, os->npoints); |
592 |
|
|
593 |
|
if (present & 0x1000) |
594 |
|
{ |
595 |
|
in_uint8(s, os->datasize); |
596 |
|
in_uint8a(s, os->data, os->datasize); |
597 |
|
} |
598 |
|
|
599 |
|
DEBUG(("POLYGON2(x=%d,y=%d,op=0x%x,fm=%d,bs=%d,bg=0x%x,fg=0x%x,n=%d,sz=%d)\n", |
600 |
|
os->x, os->y, os->opcode, os->fillmode, os->brush.style, os->bgcolour, os->fgcolour, |
601 |
|
os->npoints, os->datasize)); |
602 |
|
|
603 |
|
DEBUG(("Data: ")); |
604 |
|
|
605 |
|
for (index = 0; index < os->datasize; index++) |
606 |
|
DEBUG(("%02x ", os->data[index])); |
607 |
|
|
608 |
|
DEBUG(("\n")); |
609 |
|
|
610 |
|
if (os->opcode < 0x01 || os->opcode > 0x10) |
611 |
|
{ |
612 |
|
error("bad ROP2 0x%x\n", os->opcode); |
613 |
|
return; |
614 |
|
} |
615 |
|
|
616 |
|
points = (POINT *) xmalloc((os->npoints + 1) * sizeof(POINT)); |
617 |
|
memset(points, 0, (os->npoints + 1) * sizeof(POINT)); |
618 |
|
|
619 |
|
points[0].x = os->x; |
620 |
|
points[0].y = os->y; |
621 |
|
|
622 |
|
index = 0; |
623 |
|
data = ((os->npoints - 1) / 4) + 1; |
624 |
|
for (next = 1; (next <= os->npoints) && (next < 256) && (data < os->datasize); next++) |
625 |
|
{ |
626 |
|
if ((next - 1) % 4 == 0) |
627 |
|
flags = os->data[index++]; |
628 |
|
|
629 |
|
if (~flags & 0x80) |
630 |
|
points[next].x = parse_delta(os->data, &data); |
631 |
|
|
632 |
|
if (~flags & 0x40) |
633 |
|
points[next].y = parse_delta(os->data, &data); |
634 |
|
|
635 |
|
flags <<= 2; |
636 |
|
} |
637 |
|
|
638 |
|
if (next - 1 == os->npoints) |
639 |
|
ui_polygon(os->opcode - 1, os->fillmode, points, os->npoints + 1, |
640 |
|
&os->brush, os->bgcolour, os->fgcolour); |
641 |
|
else |
642 |
|
error("polygon2 parse error\n"); |
643 |
|
|
644 |
|
xfree(points); |
645 |
} |
} |
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, BOOL delta) |
650 |
{ |
{ |
651 |
int index, line, data; |
int index, next, data; |
|
int x, y, xfrom, yfrom; |
|
652 |
uint8 flags = 0; |
uint8 flags = 0; |
653 |
PEN pen; |
PEN pen; |
654 |
|
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); |
660 |
rdp_in_coord(s, &os->y, delta); |
rdp_in_coord(s, &os->y, delta); |
661 |
|
|
662 |
if (present & 0x04) |
if (present & 0x04) |
663 |
in_uint8(s, os->flags); |
in_uint8(s, os->opcode); |
664 |
|
|
665 |
if (present & 0x10) |
if (present & 0x10) |
666 |
rdp_in_colour(s, &os->fgcolour); |
rdp_in_colour(s, &os->fgcolour); |
674 |
in_uint8a(s, os->data, os->datasize); |
in_uint8a(s, os->data, os->datasize); |
675 |
} |
} |
676 |
|
|
677 |
DEBUG(("POLYLINE(x=%d,y=%d,fl=0x%x,fg=0x%x,n=%d,sz=%d)\n", |
DEBUG(("POLYLINE(x=%d,y=%d,op=0x%x,fg=0x%x,n=%d,sz=%d)\n", |
678 |
os->x, os->y, os->flags, os->fgcolour, os->lines, os->datasize)); |
os->x, os->y, os->opcode, os->fgcolour, os->lines, os->datasize)); |
679 |
|
|
680 |
DEBUG(("Data: ")); |
DEBUG(("Data: ")); |
681 |
|
|
684 |
|
|
685 |
DEBUG(("\n")); |
DEBUG(("\n")); |
686 |
|
|
687 |
x = os->x; |
if (os->opcode < 0x01 || os->opcode > 0x10) |
688 |
y = os->y; |
{ |
689 |
|
error("bad ROP2 0x%x\n", os->opcode); |
690 |
|
return; |
691 |
|
} |
692 |
|
|
693 |
|
points = (POINT *) xmalloc((os->lines + 1) * sizeof(POINT)); |
694 |
|
memset(points, 0, (os->lines + 1) * sizeof(POINT)); |
695 |
|
|
696 |
|
points[0].x = os->x; |
697 |
|
points[0].y = os->y; |
698 |
pen.style = pen.width = 0; |
pen.style = pen.width = 0; |
699 |
pen.colour = os->fgcolour; |
pen.colour = os->fgcolour; |
700 |
|
|
701 |
index = 0; |
index = 0; |
702 |
data = ((os->lines - 1) / 4) + 1; |
data = ((os->lines - 1) / 4) + 1; |
703 |
for (line = 0; (line < os->lines) && (data < os->datasize); line++) |
for (next = 1; (next <= os->lines) && (data < os->datasize); next++) |
704 |
{ |
{ |
705 |
xfrom = x; |
if ((next - 1) % 4 == 0) |
|
yfrom = y; |
|
|
|
|
|
if (line % 4 == 0) |
|
706 |
flags = os->data[index++]; |
flags = os->data[index++]; |
707 |
|
|
708 |
if ((flags & 0xc0) == 0) |
if (~flags & 0x80) |
709 |
flags |= 0xc0; /* none = both */ |
points[next].x = parse_delta(os->data, &data); |
|
|
|
|
if (flags & 0x40) |
|
|
x += parse_delta(os->data, &data); |
|
710 |
|
|
711 |
if (flags & 0x80) |
if (~flags & 0x40) |
712 |
y += parse_delta(os->data, &data); |
points[next].y = parse_delta(os->data, &data); |
|
|
|
|
ui_line(ROP2_NXOR, xfrom, yfrom, x, y, &pen); |
|
713 |
|
|
714 |
flags <<= 2; |
flags <<= 2; |
715 |
} |
} |
716 |
|
|
717 |
|
if (next - 1 == os->lines) |
718 |
|
ui_polyline(os->opcode - 1, points, os->lines + 1, &pen); |
719 |
|
else |
720 |
|
error("polyline parse error\n"); |
721 |
|
|
722 |
|
xfree(points); |
723 |
|
} |
724 |
|
|
725 |
|
/* Process an ellipse order */ |
726 |
|
static void |
727 |
|
process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, BOOL delta) |
728 |
|
{ |
729 |
|
if (present & 0x01) |
730 |
|
rdp_in_coord(s, &os->left, delta); |
731 |
|
|
732 |
|
if (present & 0x02) |
733 |
|
rdp_in_coord(s, &os->top, delta); |
734 |
|
|
735 |
|
if (present & 0x04) |
736 |
|
rdp_in_coord(s, &os->right, delta); |
737 |
|
|
738 |
|
if (present & 0x08) |
739 |
|
rdp_in_coord(s, &os->bottom, delta); |
740 |
|
|
741 |
|
if (present & 0x10) |
742 |
|
in_uint8(s, os->opcode); |
743 |
|
|
744 |
|
if (present & 0x20) |
745 |
|
in_uint8(s, os->fillmode); |
746 |
|
|
747 |
|
if (present & 0x40) |
748 |
|
rdp_in_colour(s, &os->fgcolour); |
749 |
|
|
750 |
|
DEBUG(("ELLIPSE(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,fg=0x%x)\n", os->left, os->top, |
751 |
|
os->right, os->bottom, os->opcode, os->fillmode, os->fgcolour)); |
752 |
|
|
753 |
|
ui_ellipse(os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, |
754 |
|
os->bottom - os->top, NULL, 0, os->fgcolour); |
755 |
|
} |
756 |
|
|
757 |
|
/* Process an ellipse2 order */ |
758 |
|
static void |
759 |
|
process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, BOOL delta) |
760 |
|
{ |
761 |
|
if (present & 0x0001) |
762 |
|
rdp_in_coord(s, &os->left, delta); |
763 |
|
|
764 |
|
if (present & 0x0002) |
765 |
|
rdp_in_coord(s, &os->top, delta); |
766 |
|
|
767 |
|
if (present & 0x0004) |
768 |
|
rdp_in_coord(s, &os->right, delta); |
769 |
|
|
770 |
|
if (present & 0x0008) |
771 |
|
rdp_in_coord(s, &os->bottom, delta); |
772 |
|
|
773 |
|
if (present & 0x0010) |
774 |
|
in_uint8(s, os->opcode); |
775 |
|
|
776 |
|
if (present & 0x0020) |
777 |
|
in_uint8(s, os->fillmode); |
778 |
|
|
779 |
|
if (present & 0x0040) |
780 |
|
rdp_in_colour(s, &os->bgcolour); |
781 |
|
|
782 |
|
if (present & 0x0080) |
783 |
|
rdp_in_colour(s, &os->fgcolour); |
784 |
|
|
785 |
|
rdp_parse_brush(s, &os->brush, present >> 8); |
786 |
|
|
787 |
|
DEBUG(("ELLIPSE2(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,bs=%d,bg=0x%x,fg=0x%x)\n", |
788 |
|
os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->brush.style, |
789 |
|
os->bgcolour, os->fgcolour)); |
790 |
|
|
791 |
|
ui_ellipse(os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, |
792 |
|
os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour); |
793 |
} |
} |
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, BOOL delta) |
798 |
{ |
{ |
799 |
int i; |
int i; |
800 |
|
|
805 |
in_uint8(s, os->flags); |
in_uint8(s, os->flags); |
806 |
|
|
807 |
if (present & 0x000004) |
if (present & 0x000004) |
808 |
in_uint8(s, os->unknown); |
in_uint8(s, os->opcode); |
809 |
|
|
810 |
if (present & 0x000008) |
if (present & 0x000008) |
811 |
in_uint8(s, os->mixmode); |
in_uint8(s, os->mixmode); |
840 |
if (present & 0x002000) |
if (present & 0x002000) |
841 |
in_uint16_le(s, os->boxbottom); |
in_uint16_le(s, os->boxbottom); |
842 |
|
|
843 |
|
rdp_parse_brush(s, &os->brush, present >> 14); |
844 |
|
|
845 |
if (present & 0x080000) |
if (present & 0x080000) |
846 |
in_uint16_le(s, os->x); |
in_uint16_le(s, os->x); |
847 |
|
|
854 |
in_uint8a(s, os->text, os->length); |
in_uint8a(s, os->text, os->length); |
855 |
} |
} |
856 |
|
|
857 |
DEBUG(("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,bb=%d,br=%d,fg=0x%x,bg=0x%x,font=%d,fl=0x%x,mix=%d,unk=0x%x,n=%d)\n", |
DEBUG(("TEXT2(x=%d,y=%d,cl=%d,ct=%d,cr=%d,cb=%d,bl=%d,bt=%d,br=%d,bb=%d,bs=%d,bg=0x%x,fg=0x%x,font=%d,fl=0x%x,op=0x%x,mix=%d,n=%d)\n", os->x, os->y, os->clipleft, os->cliptop, os->clipright, os->clipbottom, os->boxleft, os->boxtop, os->boxright, os->boxbottom, os->brush.style, os->bgcolour, os->fgcolour, os->font, os->flags, os->opcode, os->mixmode, os->length)); |
|
os->x, os->y, os->clipleft, os->cliptop, os->clipright, |
|
|
os->clipbottom, os->boxleft, os->boxtop, os->boxright, |
|
|
os->boxbottom, os->fgcolour, os->bgcolour, os->font, |
|
|
os->flags, os->mixmode, os->unknown, os->length)); |
|
858 |
|
|
859 |
DEBUG(("Text: ")); |
DEBUG(("Text: ")); |
860 |
|
|
863 |
|
|
864 |
DEBUG(("\n")); |
DEBUG(("\n")); |
865 |
|
|
866 |
ui_draw_text(os->font, os->flags, os->mixmode, os->x, os->y, |
ui_draw_text(os->font, os->flags, os->opcode - 1, os->mixmode, os->x, os->y, |
867 |
os->clipleft, os->cliptop, |
os->clipleft, os->cliptop, os->clipright - os->clipleft, |
868 |
os->clipright - os->clipleft, |
os->clipbottom - os->cliptop, os->boxleft, os->boxtop, |
869 |
os->clipbottom - os->cliptop, |
os->boxright - os->boxleft, os->boxbottom - os->boxtop, |
870 |
os->boxleft, os->boxtop, |
&os->brush, os->bgcolour, os->fgcolour, os->text, os->length); |
|
os->boxright - os->boxleft, |
|
|
os->boxbottom - os->boxtop, |
|
|
os->bgcolour, os->fgcolour, os->text, os->length); |
|
871 |
} |
} |
872 |
|
|
873 |
/* Process a raw bitmap cache order */ |
/* Process a raw bitmap cache order */ |
876 |
{ |
{ |
877 |
HBITMAP bitmap; |
HBITMAP bitmap; |
878 |
uint16 cache_idx, bufsize; |
uint16 cache_idx, bufsize; |
879 |
uint8 cache_id, width, height, bpp; |
uint8 cache_id, width, height, bpp, Bpp; |
880 |
uint8 *data, *inverted; |
uint8 *data, *inverted; |
881 |
int y; |
int y; |
882 |
|
|
885 |
in_uint8(s, width); |
in_uint8(s, width); |
886 |
in_uint8(s, height); |
in_uint8(s, height); |
887 |
in_uint8(s, bpp); |
in_uint8(s, bpp); |
888 |
|
Bpp = (bpp + 7) / 8; |
889 |
in_uint16_le(s, bufsize); |
in_uint16_le(s, bufsize); |
890 |
in_uint16_le(s, cache_idx); |
in_uint16_le(s, cache_idx); |
891 |
in_uint8p(s, data, bufsize); |
in_uint8p(s, data, bufsize); |
892 |
|
|
893 |
DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", |
DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx)); |
894 |
width, height, cache_id, cache_idx)); |
inverted = (uint8 *) xmalloc(width * height * Bpp); |
|
inverted = xmalloc(width * height); |
|
895 |
for (y = 0; y < height; y++) |
for (y = 0; y < height; y++) |
896 |
{ |
{ |
897 |
memcpy(&inverted[(height - y - 1) * width], &data[y * width], |
memcpy(&inverted[(height - y - 1) * (width * Bpp)], &data[y * (width * Bpp)], |
898 |
width); |
width * Bpp); |
899 |
} |
} |
900 |
|
|
901 |
bitmap = ui_create_bitmap(width, height, inverted); |
bitmap = ui_create_bitmap(width, height, inverted); |
909 |
{ |
{ |
910 |
HBITMAP bitmap; |
HBITMAP bitmap; |
911 |
uint16 cache_idx, size; |
uint16 cache_idx, size; |
912 |
uint8 cache_id, width, height, bpp; |
uint8 cache_id, width, height, bpp, Bpp; |
913 |
uint8 *data, *bmpdata; |
uint8 *data, *bmpdata; |
914 |
|
uint16 bufsize, pad2, row_size, final_size; |
915 |
|
uint8 pad1; |
916 |
|
|
917 |
|
pad2 = row_size = final_size = 0xffff; /* Shut the compiler up */ |
918 |
|
|
919 |
in_uint8(s, cache_id); |
in_uint8(s, cache_id); |
920 |
in_uint8s(s, 1); /* pad */ |
in_uint8(s, pad1); /* pad */ |
921 |
in_uint8(s, width); |
in_uint8(s, width); |
922 |
in_uint8(s, height); |
in_uint8(s, height); |
923 |
in_uint8(s, bpp); |
in_uint8(s, bpp); |
924 |
in_uint8s(s, 2); /* bufsize */ |
Bpp = (bpp + 7) / 8; |
925 |
|
in_uint16_le(s, bufsize); /* bufsize */ |
926 |
in_uint16_le(s, cache_idx); |
in_uint16_le(s, cache_idx); |
927 |
in_uint8s(s, 2); /* pad */ |
|
928 |
in_uint16_le(s, size); |
if (g_use_rdp5) |
929 |
in_uint8s(s, 4); /* row_size, final_size */ |
{ |
930 |
|
size = bufsize; |
931 |
|
} |
932 |
|
else |
933 |
|
{ |
934 |
|
|
935 |
|
/* Begin compressedBitmapData */ |
936 |
|
in_uint16_le(s, pad2); /* pad */ |
937 |
|
in_uint16_le(s, size); |
938 |
|
/* in_uint8s(s, 4); *//* row_size, final_size */ |
939 |
|
in_uint16_le(s, row_size); |
940 |
|
in_uint16_le(s, final_size); |
941 |
|
|
942 |
|
} |
943 |
in_uint8p(s, data, size); |
in_uint8p(s, data, size); |
944 |
|
|
945 |
DEBUG(("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", |
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)); |
|
width, height, cache_id, cache_idx)); |
|
946 |
|
|
947 |
bmpdata = xmalloc(width * height); |
bmpdata = (uint8 *) xmalloc(width * height * Bpp); |
948 |
|
|
949 |
if (bitmap_decompress(bmpdata, width, height, data, size)) |
if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) |
950 |
{ |
{ |
951 |
bitmap = ui_create_bitmap(width, height, bmpdata); |
bitmap = ui_create_bitmap(width, height, bmpdata); |
952 |
cache_put_bitmap(cache_id, cache_idx, bitmap); |
cache_put_bitmap(cache_id, cache_idx, bitmap); |
953 |
} |
} |
954 |
|
else |
955 |
|
{ |
956 |
|
DEBUG(("Failed to decompress bitmap data\n")); |
957 |
|
} |
958 |
|
|
959 |
|
xfree(bmpdata); |
960 |
|
} |
961 |
|
|
962 |
|
/* Process a bitmap cache v2 order */ |
963 |
|
static void |
964 |
|
process_bmpcache2(STREAM s, uint16 flags, BOOL compressed) |
965 |
|
{ |
966 |
|
HBITMAP bitmap; |
967 |
|
int y; |
968 |
|
uint8 cache_id, cache_idx_low, width, height, Bpp; |
969 |
|
uint16 cache_idx, bufsize; |
970 |
|
uint8 *data, *bmpdata, *bitmap_id; |
971 |
|
|
972 |
|
bitmap_id = NULL; /* prevent compiler warning */ |
973 |
|
cache_id = flags & ID_MASK; |
974 |
|
Bpp = ((flags & MODE_MASK) >> MODE_SHIFT) - 2; |
975 |
|
|
976 |
|
if (flags & PERSIST) |
977 |
|
{ |
978 |
|
in_uint8p(s, bitmap_id, 8); |
979 |
|
} |
980 |
|
|
981 |
|
if (flags & SQUARE) |
982 |
|
{ |
983 |
|
in_uint8(s, width); |
984 |
|
height = width; |
985 |
|
} |
986 |
|
else |
987 |
|
{ |
988 |
|
in_uint8(s, width); |
989 |
|
in_uint8(s, height); |
990 |
|
} |
991 |
|
|
992 |
|
in_uint16_be(s, bufsize); |
993 |
|
bufsize &= BUFSIZE_MASK; |
994 |
|
in_uint8(s, cache_idx); |
995 |
|
|
996 |
|
if (cache_idx & LONG_FORMAT) |
997 |
|
{ |
998 |
|
in_uint8(s, cache_idx_low); |
999 |
|
cache_idx = ((cache_idx ^ LONG_FORMAT) << 8) + cache_idx_low; |
1000 |
|
} |
1001 |
|
|
1002 |
|
in_uint8p(s, data, bufsize); |
1003 |
|
|
1004 |
|
DEBUG(("BMPCACHE2(compr=%d,flags=%x,cx=%d,cy=%d,id=%d,idx=%d,Bpp=%d,bs=%d)\n", |
1005 |
|
compressed, flags, width, height, cache_id, cache_idx, Bpp, bufsize)); |
1006 |
|
|
1007 |
|
bmpdata = (uint8 *) xmalloc(width * height * Bpp); |
1008 |
|
|
1009 |
|
if (compressed) |
1010 |
|
{ |
1011 |
|
if (!bitmap_decompress(bmpdata, width, height, data, bufsize, Bpp)) |
1012 |
|
{ |
1013 |
|
DEBUG(("Failed to decompress bitmap data\n")); |
1014 |
|
xfree(bmpdata); |
1015 |
|
return; |
1016 |
|
} |
1017 |
|
} |
1018 |
|
else |
1019 |
|
{ |
1020 |
|
for (y = 0; y < height; y++) |
1021 |
|
memcpy(&bmpdata[(height - y - 1) * (width * Bpp)], |
1022 |
|
&data[y * (width * Bpp)], width * Bpp); |
1023 |
|
} |
1024 |
|
|
1025 |
|
bitmap = ui_create_bitmap(width, height, bmpdata); |
1026 |
|
|
1027 |
|
if (bitmap) |
1028 |
|
{ |
1029 |
|
cache_put_bitmap(cache_id, cache_idx, bitmap); |
1030 |
|
if (flags & PERSIST) |
1031 |
|
pstcache_save_bitmap(cache_id, cache_idx, bitmap_id, width, height, |
1032 |
|
width * height * Bpp, bmpdata); |
1033 |
|
} |
1034 |
|
else |
1035 |
|
{ |
1036 |
|
DEBUG(("process_bmpcache2: ui_create_bitmap failed\n")); |
1037 |
|
} |
1038 |
|
|
1039 |
xfree(bmpdata); |
xfree(bmpdata); |
1040 |
} |
} |
1052 |
in_uint8(s, cache_id); |
in_uint8(s, cache_id); |
1053 |
in_uint16_le(s, map.ncolours); |
in_uint16_le(s, map.ncolours); |
1054 |
|
|
1055 |
map.colours = xmalloc(3 * map.ncolours); |
map.colours = (COLOURENTRY *) xmalloc(sizeof(COLOURENTRY) * map.ncolours); |
1056 |
|
|
1057 |
for (i = 0; i < map.ncolours; i++) |
for (i = 0; i < map.ncolours; i++) |
1058 |
{ |
{ |
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 |
} |
} |
1100 |
in_uint8p(s, data, datasize); |
in_uint8p(s, data, datasize); |
1101 |
|
|
1102 |
bitmap = ui_create_glyph(width, height, data); |
bitmap = ui_create_glyph(width, height, data); |
1103 |
cache_put_font(font, character, offset, baseline, |
cache_put_font(font, character, offset, baseline, width, height, bitmap); |
|
width, height, bitmap); |
|
1104 |
} |
} |
1105 |
} |
} |
1106 |
|
|
1108 |
static void |
static void |
1109 |
process_secondary_order(STREAM s) |
process_secondary_order(STREAM s) |
1110 |
{ |
{ |
1111 |
|
/* The length isn't calculated correctly by the server. |
1112 |
|
* For very compact orders the length becomes negative |
1113 |
|
* so a signed integer must be used. */ |
1114 |
uint16 length; |
uint16 length; |
1115 |
|
uint16 flags; |
1116 |
uint8 type; |
uint8 type; |
1117 |
uint8 *next_order; |
uint8 *next_order; |
1118 |
|
|
1119 |
in_uint16_le(s, length); |
in_uint16_le(s, length); |
1120 |
in_uint8s(s, 2); /* flags */ |
in_uint16_le(s, flags); /* used by bmpcache2 */ |
1121 |
in_uint8(s, type); |
in_uint8(s, type); |
1122 |
|
|
1123 |
next_order = s->p + length + 7; |
next_order = s->p + (sint16) length + 7; |
1124 |
|
|
1125 |
switch (type) |
switch (type) |
1126 |
{ |
{ |
1140 |
process_fontcache(s); |
process_fontcache(s); |
1141 |
break; |
break; |
1142 |
|
|
1143 |
|
case RDP_ORDER_RAW_BMPCACHE2: |
1144 |
|
process_bmpcache2(s, flags, False); /* uncompressed */ |
1145 |
|
break; |
1146 |
|
|
1147 |
|
case RDP_ORDER_BMPCACHE2: |
1148 |
|
process_bmpcache2(s, flags, True); /* compressed */ |
1149 |
|
break; |
1150 |
|
|
1151 |
default: |
default: |
1152 |
unimpl("secondary order %d\n", type); |
unimpl("secondary order %d\n", type); |
1153 |
} |
} |
1157 |
|
|
1158 |
/* Process an order PDU */ |
/* Process an order PDU */ |
1159 |
void |
void |
1160 |
process_orders(STREAM s) |
process_orders(STREAM s, uint16 num_orders) |
1161 |
{ |
{ |
1162 |
RDP_ORDER_STATE *os = &order_state; |
RDP_ORDER_STATE *os = &g_order_state; |
1163 |
uint32 present; |
uint32 present; |
|
uint16 num_orders; |
|
1164 |
uint8 order_flags; |
uint8 order_flags; |
1165 |
int size, processed = 0; |
int size, processed = 0; |
1166 |
BOOL delta; |
BOOL delta; |
1167 |
|
|
|
in_uint8s(s, 2); /* pad */ |
|
|
in_uint16_le(s, num_orders); |
|
|
in_uint8s(s, 2); /* pad */ |
|
|
|
|
1168 |
while (processed < num_orders) |
while (processed < num_orders) |
1169 |
{ |
{ |
1170 |
in_uint8(s, order_flags); |
in_uint8(s, order_flags); |
1196 |
case RDP_ORDER_PATBLT: |
case RDP_ORDER_PATBLT: |
1197 |
case RDP_ORDER_MEMBLT: |
case RDP_ORDER_MEMBLT: |
1198 |
case RDP_ORDER_LINE: |
case RDP_ORDER_LINE: |
1199 |
|
case RDP_ORDER_POLYGON2: |
1200 |
|
case RDP_ORDER_ELLIPSE2: |
1201 |
size = 2; |
size = 2; |
1202 |
break; |
break; |
1203 |
|
|
1216 |
os->bounds.top, |
os->bounds.top, |
1217 |
os->bounds.right - |
os->bounds.right - |
1218 |
os->bounds.left + 1, |
os->bounds.left + 1, |
1219 |
os->bounds.bottom - |
os->bounds.bottom - os->bounds.top + 1); |
|
os->bounds.top + 1); |
|
1220 |
} |
} |
1221 |
|
|
1222 |
delta = order_flags & RDP_ORDER_DELTA; |
delta = order_flags & RDP_ORDER_DELTA; |
1224 |
switch (os->order_type) |
switch (os->order_type) |
1225 |
{ |
{ |
1226 |
case RDP_ORDER_DESTBLT: |
case RDP_ORDER_DESTBLT: |
1227 |
process_destblt(s, &os->destblt, |
process_destblt(s, &os->destblt, present, delta); |
|
present, delta); |
|
1228 |
break; |
break; |
1229 |
|
|
1230 |
case RDP_ORDER_PATBLT: |
case RDP_ORDER_PATBLT: |
1231 |
process_patblt(s, &os->patblt, |
process_patblt(s, &os->patblt, present, delta); |
|
present, delta); |
|
1232 |
break; |
break; |
1233 |
|
|
1234 |
case RDP_ORDER_SCREENBLT: |
case RDP_ORDER_SCREENBLT: |
1235 |
process_screenblt(s, &os->screenblt, |
process_screenblt(s, &os->screenblt, present, delta); |
|
present, delta); |
|
1236 |
break; |
break; |
1237 |
|
|
1238 |
case RDP_ORDER_LINE: |
case RDP_ORDER_LINE: |
1239 |
process_line(s, &os->line, |
process_line(s, &os->line, present, delta); |
|
present, delta); |
|
1240 |
break; |
break; |
1241 |
|
|
1242 |
case RDP_ORDER_RECT: |
case RDP_ORDER_RECT: |
1243 |
process_rect(s, &os->rect, |
process_rect(s, &os->rect, present, delta); |
|
present, delta); |
|
1244 |
break; |
break; |
1245 |
|
|
1246 |
case RDP_ORDER_DESKSAVE: |
case RDP_ORDER_DESKSAVE: |
1247 |
process_desksave(s, &os->desksave, |
process_desksave(s, &os->desksave, present, delta); |
|
present, delta); |
|
1248 |
break; |
break; |
1249 |
|
|
1250 |
case RDP_ORDER_MEMBLT: |
case RDP_ORDER_MEMBLT: |
1251 |
process_memblt(s, &os->memblt, |
process_memblt(s, &os->memblt, present, delta); |
|
present, delta); |
|
1252 |
break; |
break; |
1253 |
|
|
1254 |
case RDP_ORDER_TRIBLT: |
case RDP_ORDER_TRIBLT: |
1255 |
process_triblt(s, &os->triblt, |
process_triblt(s, &os->triblt, present, delta); |
1256 |
present, delta); |
break; |
1257 |
|
|
1258 |
|
case RDP_ORDER_POLYGON: |
1259 |
|
process_polygon(s, &os->polygon, present, delta); |
1260 |
|
break; |
1261 |
|
|
1262 |
|
case RDP_ORDER_POLYGON2: |
1263 |
|
process_polygon2(s, &os->polygon2, present, delta); |
1264 |
break; |
break; |
1265 |
|
|
1266 |
case RDP_ORDER_POLYLINE: |
case RDP_ORDER_POLYLINE: |
1267 |
process_polyline(s, &os->polyline, |
process_polyline(s, &os->polyline, present, delta); |
1268 |
present, delta); |
break; |
1269 |
|
|
1270 |
|
case RDP_ORDER_ELLIPSE: |
1271 |
|
process_ellipse(s, &os->ellipse, present, delta); |
1272 |
|
break; |
1273 |
|
|
1274 |
|
case RDP_ORDER_ELLIPSE2: |
1275 |
|
process_ellipse2(s, &os->ellipse2, present, delta); |
1276 |
break; |
break; |
1277 |
|
|
1278 |
case RDP_ORDER_TEXT2: |
case RDP_ORDER_TEXT2: |
1279 |
process_text2(s, &os->text2, |
process_text2(s, &os->text2, present, delta); |
|
present, delta); |
|
1280 |
break; |
break; |
1281 |
|
|
1282 |
default: |
default: |
1290 |
|
|
1291 |
processed++; |
processed++; |
1292 |
} |
} |
1293 |
|
#if 0 |
1294 |
|
/* not true when RDP_COMPRESSION is set */ |
1295 |
|
if (s->p != g_next_packet) |
1296 |
|
error("%d bytes remaining\n", (int) (g_next_packet - s->p)); |
1297 |
|
#endif |
1298 |
|
|
|
if (s->p != next_packet) |
|
|
error("%d bytes remaining\n", (int) (next_packet - s->p)); |
|
1299 |
} |
} |
1300 |
|
|
1301 |
/* Reset order state */ |
/* Reset order state */ |
1302 |
void |
void |
1303 |
reset_order_state() |
reset_order_state(void) |
1304 |
{ |
{ |
1305 |
memset(&order_state, 0, sizeof(order_state)); |
memset(&g_order_state, 0, sizeof(g_order_state)); |
1306 |
order_state.order_type = RDP_ORDER_PATBLT; |
g_order_state.order_type = RDP_ORDER_PATBLT; |
1307 |
} |
} |