--- sourceforge.net/trunk/rdesktop/orders.c 2001/01/06 03:47:04 25 +++ sourceforge.net/trunk/rdesktop/orders.c 2001/09/17 12:50:49 37 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. RDP order processing - Copyright (C) Matthew Chapman 1999-2000 + Copyright (C) Matthew Chapman 1999-2001 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include "rdesktop.h" #include "orders.h" -extern unsigned char *next_packet; +extern uint8 *next_packet; static RDP_ORDER_STATE order_state; /* Read field indicating which parameters are present */ @@ -61,7 +61,7 @@ if (delta) { in_uint8(s, change); - *coord += (char) change; + *coord += (signed char) change; } else { @@ -165,8 +165,8 @@ if (present & 0x10) in_uint8(s, os->opcode); - DEBUG("DESTBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d)\n", - os->opcode, os->x, os->y, os->cx, os->cy); + DEBUG(("DESTBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d)\n", + os->opcode, os->x, os->y, os->cx, os->cy)); ui_destblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy); } @@ -198,9 +198,9 @@ rdp_parse_brush(s, &os->brush, present >> 7); - 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, os->y, os->cx, os->cy, - os->brush.style, os->bgcolour, os->fgcolour); + 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, os->y, os->cx, os->cy, + os->brush.style, os->bgcolour, os->fgcolour)); ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, &os->brush, os->bgcolour, os->fgcolour); @@ -231,8 +231,8 @@ if (present & 0x0040) rdp_in_coord(s, &os->srcy, delta); - DEBUG("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n", - os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); + DEBUG(("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n", + os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy)); ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); @@ -265,13 +265,13 @@ rdp_parse_pen(s, &os->pen, present >> 7); - DEBUG("LINE(op=0x%x,sx=%d,sy=%d,dx=%d,dx=%d,fg=0x%x)\n", - os->opcode, os->startx, os->starty, os->endx, os->endy, - os->pen.colour); + DEBUG(("LINE(op=0x%x,sx=%d,sy=%d,dx=%d,dx=%d,fg=0x%x)\n", + os->opcode, os->startx, os->starty, os->endx, os->endy, + os->pen.colour)); if (os->opcode < 0x01 || os->opcode > 0x10) { - ERROR("bad ROP2 0x%x\n", os->opcode); + error("bad ROP2 0x%x\n", os->opcode); return; } @@ -298,8 +298,8 @@ if (present & 0x10) in_uint8(s, os->colour); - DEBUG("RECT(x=%d,y=%d,cx=%d,cy=%d,fg=0x%x)\n", - os->x, os->y, os->cx, os->cy, os->colour); + DEBUG(("RECT(x=%d,y=%d,cx=%d,cy=%d,fg=0x%x)\n", + os->x, os->y, os->cx, os->cy, os->colour)); ui_rect(os->x, os->y, os->cx, os->cy, os->colour); } @@ -328,9 +328,9 @@ if (present & 0x20) in_uint8(s, os->action); - DEBUG("DESKSAVE(l=%d,t=%d,r=%d,b=%d,off=%d,op=%d)\n", - os->left, os->top, os->right, os->bottom, os->offset, - os->action); + DEBUG(("DESKSAVE(l=%d,t=%d,r=%d,b=%d,off=%d,op=%d)\n", + os->left, os->top, os->right, os->bottom, os->offset, + os->action)); width = os->right - os->left + 1; height = os->bottom - os->top + 1; @@ -378,9 +378,9 @@ if (present & 0x0100) in_uint16_le(s, os->cache_idx); - DEBUG("MEMBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d)\n", - os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, - os->cache_idx); + DEBUG(("MEMBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,id=%d,idx=%d)\n", + os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, + os->cache_idx)); bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); if (bitmap == NULL) @@ -437,10 +437,9 @@ if (present & 0x010000) in_uint16_le(s, os->unknown); - 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", - os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, - os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour); + 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", + os->opcode, os->x, os->y, os->cx, os->cy, os->cache_id, + os->cache_idx, os->brush.style, os->bgcolour, os->fgcolour)); bitmap = cache_get_bitmap(os->cache_id, os->cache_idx); if (bitmap == NULL) @@ -499,15 +498,15 @@ in_uint8a(s, os->data, os->datasize); } - DEBUG("POLYLINE(x=%d,y=%d,fl=0x%x,fg=0x%x,n=%d,sz=%d)\n", - os->x, os->y, os->flags, os->fgcolour, os->lines, os->datasize); + DEBUG(("POLYLINE(x=%d,y=%d,fl=0x%x,fg=0x%x,n=%d,sz=%d)\n", + os->x, os->y, os->flags, os->fgcolour, os->lines, os->datasize)); - DEBUG("Data: "); + DEBUG(("Data: ")); for (index = 0; index < os->datasize; index++) - DEBUG("%02x ", os->data[index]); + DEBUG(("%02x ", os->data[index])); - DEBUG("\n"); + DEBUG(("\n")); x = os->x; y = os->y; @@ -533,7 +532,7 @@ if (flags & 0x80) y += parse_delta(os->data, &data); - ui_line(ROP2_COPY, xfrom, yfrom, x, y, &pen); + ui_line(ROP2_NXOR, xfrom, yfrom, x, y, &pen); flags <<= 2; } @@ -600,19 +599,18 @@ in_uint8a(s, os->text, os->length); } - 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,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("Text: "); + DEBUG(("Text: ")); for (i = 0; i < os->length; i++) - DEBUG("%02x ", os->text[i]); + DEBUG(("%02x ", os->text[i])); - DEBUG("\n"); + DEBUG(("\n")); /* Process special cache strings */ if ((os->length >= 2) && (os->text[0] == 0xfe)) @@ -649,7 +647,8 @@ HBITMAP bitmap; uint16 cache_idx, bufsize; uint8 cache_id, width, height, bpp; - uint8 *data; + uint8 *data, *inverted; + int y; in_uint8(s, cache_id); in_uint8s(s, 1); /* pad */ @@ -660,10 +659,17 @@ in_uint16_le(s, cache_idx); in_uint8p(s, data, bufsize); - DEBUG("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", - width, height, cache_id, cache_idx); + DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", + width, height, cache_id, cache_idx)); + inverted = xmalloc(width * height); + for (y = 0; y < height; y++) + { + memcpy(&inverted[(height - y - 1) * width], &data[y * width], + width); + } - bitmap = ui_create_bitmap(width, height, data); + bitmap = ui_create_bitmap(width, height, inverted); + xfree(inverted); cache_put_bitmap(cache_id, cache_idx, bitmap); } @@ -688,8 +694,8 @@ in_uint8s(s, 4); /* row_size, final_size */ 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)\n", + width, height, cache_id, cache_idx)); bmpdata = xmalloc(width * height); @@ -726,7 +732,7 @@ in_uint8s(s, 1); /* pad */ } - DEBUG("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours); + DEBUG(("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours)); hmap = ui_create_colourmap(&map); ui_set_colourmap(hmap); @@ -747,7 +753,7 @@ in_uint8(s, font); in_uint8(s, nglyphs); - DEBUG("FONTCACHE(font=%d,n=%d)\n", font, nglyphs); + DEBUG(("FONTCACHE(font=%d,n=%d)\n", font, nglyphs)); for (i = 0; i < nglyphs; i++) { @@ -799,7 +805,7 @@ break; default: - NOTIMP("secondary order %d\n", type); + unimpl("secondary order %d\n", type); } s->p = next_order; @@ -826,7 +832,7 @@ if (!(order_flags & RDP_ORDER_STANDARD)) { - ERROR("order parsing failed\n"); + error("order parsing failed\n"); break; } @@ -928,7 +934,7 @@ break; default: - NOTIMP("order %d\n", os->order_type); + unimpl("order %d\n", os->order_type); return; } @@ -940,7 +946,7 @@ } if (s->p != next_packet) - WARN("%d bytes remaining\n", (int) (next_packet - s->p)); + error("%d bytes remaining\n", (int) (next_packet - s->p)); } /* Reset order state */ @@ -948,4 +954,5 @@ reset_order_state() { memset(&order_state, 0, sizeof(order_state)); + order_state.order_type = RDP_ORDER_PATBLT; }