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, uint32 * colour) |
rdp_in_colour(STREAM s, uint32 * colour) |
480 |
bitmap, os->srcx, os->srcy, &os->brush, os->bgcolour, os->fgcolour); |
bitmap, os->srcx, os->srcy, &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 |
uint8 opcode; |
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 |
opcode = os->opcode - 1; |
points = (POINT *) xmalloc((os->lines + 1) * sizeof(POINT)); |
694 |
x = os->x; |
memset(points, 0, (os->lines + 1) * sizeof(POINT)); |
695 |
y = os->y; |
|
696 |
pen.style = pen.width = 0; |
points[0].x = os->x; |
697 |
pen.colour = os->fgcolour; |
points[0].y = os->y; |
698 |
|
|
699 |
index = 0; |
index = 0; |
700 |
data = ((os->lines - 1) / 4) + 1; |
data = ((os->lines - 1) / 4) + 1; |
701 |
for (line = 0; (line < os->lines) && (data < os->datasize); line++) |
for (next = 1; (next < os->lines) && (data < os->datasize); next++) |
702 |
{ |
{ |
703 |
xfrom = x; |
if ((next - 1) % 4 == 0) |
|
yfrom = y; |
|
|
|
|
|
if (line % 4 == 0) |
|
704 |
flags = os->data[index++]; |
flags = os->data[index++]; |
705 |
|
|
706 |
if ((flags & 0xc0) == 0) |
if (~flags & 0x80) |
707 |
flags |= 0xc0; /* none = both */ |
points[next].x = parse_delta(os->data, &data); |
|
|
|
|
if (flags & 0x40) |
|
|
x += parse_delta(os->data, &data); |
|
708 |
|
|
709 |
if (flags & 0x80) |
if (~flags & 0x40) |
710 |
y += parse_delta(os->data, &data); |
points[next].y = parse_delta(os->data, &data); |
|
|
|
|
ui_line(opcode, xfrom, yfrom, x, y, &pen); |
|
711 |
|
|
712 |
flags <<= 2; |
flags <<= 2; |
713 |
} |
} |
714 |
|
|
715 |
|
if (next - 1 == os->lines) |
716 |
|
ui_polyline(os->opcode - 1, points, os->lines + 1, &pen); |
717 |
|
else |
718 |
|
error("polyline parse error\n"); |
719 |
|
} |
720 |
|
|
721 |
|
/* Process an ellipse order */ |
722 |
|
static void |
723 |
|
process_ellipse(STREAM s, ELLIPSE_ORDER * os, uint32 present, BOOL delta) |
724 |
|
{ |
725 |
|
if (present & 0x01) |
726 |
|
rdp_in_coord(s, &os->left, delta); |
727 |
|
|
728 |
|
if (present & 0x02) |
729 |
|
rdp_in_coord(s, &os->top, delta); |
730 |
|
|
731 |
|
if (present & 0x04) |
732 |
|
rdp_in_coord(s, &os->right, delta); |
733 |
|
|
734 |
|
if (present & 0x08) |
735 |
|
rdp_in_coord(s, &os->bottom, delta); |
736 |
|
|
737 |
|
if (present & 0x10) |
738 |
|
in_uint8(s, os->opcode); |
739 |
|
|
740 |
|
if (present & 0x20) |
741 |
|
in_uint8(s, os->fillmode); |
742 |
|
|
743 |
|
if (present & 0x40) |
744 |
|
rdp_in_colour(s, &os->fgcolour); |
745 |
|
|
746 |
|
DEBUG(("ELLIPSE(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,fg=0x%x)\n", os->left, os->top, |
747 |
|
os->right, os->bottom, os->opcode, os->fillmode, os->fgcolour)); |
748 |
|
|
749 |
|
ui_ellipse(os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, |
750 |
|
os->bottom - os->top, NULL, 0, os->fgcolour); |
751 |
|
} |
752 |
|
|
753 |
|
/* Process an ellipse2 order */ |
754 |
|
static void |
755 |
|
process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, BOOL delta) |
756 |
|
{ |
757 |
|
if (present & 0x0001) |
758 |
|
rdp_in_coord(s, &os->left, delta); |
759 |
|
|
760 |
|
if (present & 0x0002) |
761 |
|
rdp_in_coord(s, &os->top, delta); |
762 |
|
|
763 |
|
if (present & 0x0004) |
764 |
|
rdp_in_coord(s, &os->right, delta); |
765 |
|
|
766 |
|
if (present & 0x0008) |
767 |
|
rdp_in_coord(s, &os->bottom, delta); |
768 |
|
|
769 |
|
if (present & 0x0010) |
770 |
|
in_uint8(s, os->opcode); |
771 |
|
|
772 |
|
if (present & 0x0020) |
773 |
|
in_uint8(s, os->fillmode); |
774 |
|
|
775 |
|
if (present & 0x0040) |
776 |
|
rdp_in_colour(s, &os->bgcolour); |
777 |
|
|
778 |
|
if (present & 0x0080) |
779 |
|
rdp_in_colour(s, &os->fgcolour); |
780 |
|
|
781 |
|
rdp_parse_brush(s, &os->brush, present >> 8); |
782 |
|
|
783 |
|
DEBUG(("ELLIPSE2(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,bs=%d,bg=0x%x,fg=0x%x)\n", |
784 |
|
os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->brush.style, |
785 |
|
os->bgcolour, os->fgcolour)); |
786 |
|
|
787 |
|
ui_ellipse(os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, |
788 |
|
os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour); |
789 |
} |
} |
790 |
|
|
791 |
/* Process a text order */ |
/* Process a text order */ |
801 |
in_uint8(s, os->flags); |
in_uint8(s, os->flags); |
802 |
|
|
803 |
if (present & 0x000004) |
if (present & 0x000004) |
804 |
in_uint8(s, os->unknown); |
in_uint8(s, os->opcode); |
805 |
|
|
806 |
if (present & 0x000008) |
if (present & 0x000008) |
807 |
in_uint8(s, os->mixmode); |
in_uint8(s, os->mixmode); |
836 |
if (present & 0x002000) |
if (present & 0x002000) |
837 |
in_uint16_le(s, os->boxbottom); |
in_uint16_le(s, os->boxbottom); |
838 |
|
|
839 |
/* |
rdp_parse_brush(s, &os->brush, present >> 14); |
|
* Unknown members, seen when connecting to a session that was disconnected with |
|
|
* mstsc and with wintach's spreadsheet test. |
|
|
*/ |
|
|
if (present & 0x004000) |
|
|
in_uint8s(s, 1); |
|
|
|
|
|
if (present & 0x008000) |
|
|
in_uint8s(s, 1); |
|
|
|
|
|
if (present & 0x010000) |
|
|
{ |
|
|
in_uint8s(s, 1); /* guessing the length here */ |
|
|
warning("Unknown order state member (0x010000) in text2 order.\n"); |
|
|
} |
|
|
|
|
|
if (present & 0x020000) |
|
|
in_uint8s(s, 4); |
|
|
|
|
|
if (present & 0x040000) |
|
|
in_uint8s(s, 4); |
|
840 |
|
|
841 |
if (present & 0x080000) |
if (present & 0x080000) |
842 |
in_uint16_le(s, os->x); |
in_uint16_le(s, os->x); |
850 |
in_uint8a(s, os->text, os->length); |
in_uint8a(s, os->text, os->length); |
851 |
} |
} |
852 |
|
|
853 |
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", 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)); |
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)); |
854 |
|
|
855 |
DEBUG(("Text: ")); |
DEBUG(("Text: ")); |
856 |
|
|
859 |
|
|
860 |
DEBUG(("\n")); |
DEBUG(("\n")); |
861 |
|
|
862 |
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, |
863 |
os->clipleft, os->cliptop, |
os->clipleft, os->cliptop, os->clipright - os->clipleft, |
864 |
os->clipright - os->clipleft, |
os->clipbottom - os->cliptop, os->boxleft, os->boxtop, |
865 |
os->clipbottom - os->cliptop, |
os->boxright - os->boxleft, os->boxbottom - os->boxtop, |
866 |
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); |
|
867 |
} |
} |
868 |
|
|
869 |
/* Process a raw bitmap cache order */ |
/* Process a raw bitmap cache order */ |
1190 |
case RDP_ORDER_PATBLT: |
case RDP_ORDER_PATBLT: |
1191 |
case RDP_ORDER_MEMBLT: |
case RDP_ORDER_MEMBLT: |
1192 |
case RDP_ORDER_LINE: |
case RDP_ORDER_LINE: |
1193 |
|
case RDP_ORDER_POLYGON2: |
1194 |
|
case RDP_ORDER_ELLIPSE2: |
1195 |
size = 2; |
size = 2; |
1196 |
break; |
break; |
1197 |
|
|
1249 |
process_triblt(s, &os->triblt, present, delta); |
process_triblt(s, &os->triblt, present, delta); |
1250 |
break; |
break; |
1251 |
|
|
1252 |
|
case RDP_ORDER_POLYGON: |
1253 |
|
process_polygon(s, &os->polygon, present, delta); |
1254 |
|
break; |
1255 |
|
|
1256 |
|
case RDP_ORDER_POLYGON2: |
1257 |
|
process_polygon2(s, &os->polygon2, present, delta); |
1258 |
|
break; |
1259 |
|
|
1260 |
case RDP_ORDER_POLYLINE: |
case RDP_ORDER_POLYLINE: |
1261 |
process_polyline(s, &os->polyline, present, delta); |
process_polyline(s, &os->polyline, present, delta); |
1262 |
break; |
break; |
1263 |
|
|
1264 |
|
case RDP_ORDER_ELLIPSE: |
1265 |
|
process_ellipse(s, &os->ellipse, present, delta); |
1266 |
|
break; |
1267 |
|
|
1268 |
|
case RDP_ORDER_ELLIPSE2: |
1269 |
|
process_ellipse2(s, &os->ellipse2, present, delta); |
1270 |
|
break; |
1271 |
|
|
1272 |
case RDP_ORDER_TEXT2: |
case RDP_ORDER_TEXT2: |
1273 |
process_text2(s, &os->text2, present, delta); |
process_text2(s, &os->text2, present, delta); |
1274 |
break; |
break; |