⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orders.c

📁 运行在sdl上的rdesktop(远程桌面)
💻 C
📖 第 1 页 / 共 2 页
字号:
		rdp_in_coord(s, &os->x, delta);	if (present & 0x02)		rdp_in_coord(s, &os->y, delta);	if (present & 0x04)		in_uint8(s, os->flags);	if (present & 0x10)		rdp_in_colour(s, &os->fgcolour);	if (present & 0x20)		in_uint8(s, os->lines);	if (present & 0x40)	{		in_uint8(s, os->datasize);		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(("Data: "));	for (index = 0; index < os->datasize; index++)		DEBUG(("%02x ", os->data[index]));	DEBUG(("\n"));	x = os->x;	y = os->y;	pen.style = pen.width = 0;	pen.colour = os->fgcolour;	index = 0;	data = ((os->lines - 1) / 4) + 1;	for (line = 0; (line < os->lines) && (data < os->datasize); line++)	{		xfrom = x;		yfrom = y;		if (line % 4 == 0)			flags = os->data[index++];		if ((flags & 0xc0) == 0)			flags |= 0xc0;	/* none = both */		if (flags & 0x40)			x += parse_delta(os->data, &data);		if (flags & 0x80)			y += parse_delta(os->data, &data);		ui_line(ROP2_NXOR, xfrom, yfrom, x, y, &pen);		flags <<= 2;	}}/* Process a text order */static voidprocess_text2(STREAM s, TEXT2_ORDER *os, uint32 present, BOOL delta){	DATABLOB *entry;	int i;	if (present & 0x000001)		in_uint8(s, os->font);	if (present & 0x000002)		in_uint8(s, os->flags);	if (present & 0x000004)		in_uint8(s, os->unknown);	if (present & 0x000008)		in_uint8(s, os->mixmode);	if (present & 0x000010)		rdp_in_colour(s, &os->fgcolour);	if (present & 0x000020)		rdp_in_colour(s, &os->bgcolour);	if (present & 0x000040)		in_uint16_le(s, os->clipleft);	if (present & 0x000080)		in_uint16_le(s, os->cliptop);	if (present & 0x000100)		in_uint16_le(s, os->clipright);	if (present & 0x000200)		in_uint16_le(s, os->clipbottom);	if (present & 0x000400)		in_uint16_le(s, os->boxleft);	if (present & 0x000800)		in_uint16_le(s, os->boxtop);	if (present & 0x001000)		in_uint16_le(s, os->boxright);	if (present & 0x002000)		in_uint16_le(s, os->boxbottom);	if (present & 0x080000)		in_uint16_le(s, os->x);	if (present & 0x100000)		in_uint16_le(s, os->y);	if (present & 0x200000)	{		in_uint8(s, os->length);		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(("Text: "));	for (i = 0; i < os->length; i++)		DEBUG(("%02x ", os->text[i]));	DEBUG(("\n"));	/* Process special cache strings */	if ((os->length >= 2) && (os->text[0] == 0xfe))	{		entry = cache_get_text(os->text[1]);		if (entry == NULL)			return;		memcpy(os->text, entry->data, entry->size);		os->length = entry->size;	}	else if ((os->length >= 3) && (os->text[os->length - 3] == 0xff))	{		os->length -= 3;		cache_put_text(os->text[os->length + 1], os->text,			       os->length);	}	ui_draw_text(os->font, os->flags, os->mixmode, os->x, os->y,		     os->clipleft, os->cliptop,		     os->clipright - os->clipleft,		     os->clipbottom - os->cliptop,		     os->boxleft, os->boxtop,		     os->boxright - os->boxleft,		     os->boxbottom - os->boxtop,		     os->bgcolour, os->fgcolour, os->text, os->length);}/* Process a raw bitmap cache order */static voidprocess_raw_bmpcache(STREAM s){	HBITMAP bitmap;	uint16 cache_idx, bufsize;	uint8 cache_id, width, height, bpp;	uint8 *data, *inverted;	int y;	in_uint8(s, cache_id);	in_uint8s(s, 1);	/* pad */	in_uint8(s, width);	in_uint8(s, height);	in_uint8(s, bpp);	in_uint16_le(s, bufsize);	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));	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, inverted);	xfree(inverted);	cache_put_bitmap(cache_id, cache_idx, bitmap);}/* Process a bitmap cache order */static voidprocess_bmpcache(STREAM s){	HBITMAP bitmap;	uint16 cache_idx, size;	uint8 cache_id, width, height, bpp;	uint8 *data, *bmpdata;	in_uint8(s, cache_id);	in_uint8s(s, 1);	/* pad */	in_uint8(s, width);	in_uint8(s, height);	in_uint8(s, bpp);	in_uint8s(s, 2);	/* 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 */	in_uint8p(s, data, size);	DEBUG(("BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n",	       width, height, cache_id, cache_idx));	bmpdata = xmalloc(width * height);	if (bitmap_decompress(bmpdata, width, height, data, size))	{		bitmap = ui_create_bitmap(width, height, bmpdata);		cache_put_bitmap(cache_id, cache_idx, bitmap);	}	xfree(bmpdata);}/* Process a colourmap cache order */static voidprocess_colcache(STREAM s){	COLOURENTRY *entry;	COLOURMAP map;	HCOLOURMAP hmap;	uint8 cache_id;	int i;	in_uint8(s, cache_id);	in_uint16_le(s, map.ncolours);	map.colours = xmalloc(3 * map.ncolours);	for (i = 0; i < map.ncolours; i++)	{		entry = &map.colours[i];		in_uint8(s, entry->blue);		in_uint8(s, entry->green);		in_uint8(s, entry->red);		in_uint8s(s, 1);	/* pad */	}	DEBUG(("COLCACHE(id=%d,n=%d)\n", cache_id, map.ncolours));	hmap = ui_create_colourmap(&map);	ui_set_colourmap(hmap);	xfree(map.colours);}/* Process a font cache order */static voidprocess_fontcache(STREAM s){	HGLYPH bitmap;	uint8 font, nglyphs;	uint16 character, offset, baseline, width, height;	int i, datasize;	uint8 *data;	in_uint8(s, font);	in_uint8(s, nglyphs);	DEBUG(("FONTCACHE(font=%d,n=%d)\n", font, nglyphs));	for (i = 0; i < nglyphs; i++)	{		in_uint16_le(s, character);		in_uint16_le(s, offset);		in_uint16_le(s, baseline);		in_uint16_le(s, width);		in_uint16_le(s, height);		datasize = (height * ((width + 7) / 8) + 3) & ~3;		in_uint8p(s, data, datasize);		bitmap = ui_create_glyph(width, height, data);		cache_put_font(font, character, offset, baseline,			       width, height, bitmap);	}}/* Process a secondary order */static voidprocess_secondary_order(STREAM s){	uint16 length;	uint8 type;	uint8 *next_order;	in_uint16_le(s, length);	in_uint8s(s, 2);	/* flags */	in_uint8(s, type);	next_order = s->p + length + 7;	switch (type)	{		case RDP_ORDER_RAW_BMPCACHE:			process_raw_bmpcache(s);			break;		case RDP_ORDER_COLCACHE:			process_colcache(s);			break;		case RDP_ORDER_BMPCACHE:			process_bmpcache(s);			break;		case RDP_ORDER_FONTCACHE:			process_fontcache(s);			break;		default:			unimpl("secondary order %d\n", type);	}	s->p = next_order;}/* Process an order PDU */voidprocess_orders(STREAM s){	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);		if (!(order_flags & RDP_ORDER_STANDARD))		{			error("order parsing failed\n");			break;		}		if (order_flags & RDP_ORDER_SECONDARY)		{			process_secondary_order(s);		}		else		{			if (order_flags & RDP_ORDER_CHANGE)			{				in_uint8(s, os->order_type);			}			switch (os->order_type)			{				case RDP_ORDER_TRIBLT:				case RDP_ORDER_TEXT2:					size = 3;					break;				case RDP_ORDER_PATBLT:				case RDP_ORDER_MEMBLT:				case RDP_ORDER_LINE:					size = 2;					break;				default:					size = 1;			}			rdp_in_present(s, &present, order_flags, size);			if (order_flags & RDP_ORDER_BOUNDS)			{				if (!(order_flags & RDP_ORDER_LASTBOUNDS))					rdp_parse_bounds(s, &os->bounds);				ui_set_clip(os->bounds.left,					    os->bounds.top,					    os->bounds.right -					    os->bounds.left + 1,					    os->bounds.bottom -					    os->bounds.top + 1);			}			delta = order_flags & RDP_ORDER_DELTA;			switch (os->order_type)			{				case RDP_ORDER_DESTBLT:					process_destblt(s, &os->destblt,							present, delta);					break;				case RDP_ORDER_PATBLT:					process_patblt(s, &os->patblt,						       present, delta);					break;				case RDP_ORDER_SCREENBLT:					process_screenblt(s, &os->screenblt,							  present, delta);					break;				case RDP_ORDER_LINE:					process_line(s, &os->line,						     present, delta);					break;				case RDP_ORDER_RECT:					process_rect(s, &os->rect,						     present, delta);					break;				case RDP_ORDER_DESKSAVE:					process_desksave(s, &os->desksave,							 present, delta);					break;				case RDP_ORDER_MEMBLT:					process_memblt(s, &os->memblt,						       present, delta);					break;				case RDP_ORDER_TRIBLT:					process_triblt(s, &os->triblt,						       present, delta);					break;				case RDP_ORDER_POLYLINE:					process_polyline(s, &os->polyline,							 present, delta);					break;				case RDP_ORDER_TEXT2:					process_text2(s, &os->text2,						      present, delta);					break;				default:					unimpl("order %d\n", os->order_type);					return;			}			if (order_flags & RDP_ORDER_BOUNDS)				ui_reset_clip();		}		processed++;	}	if (s->p != next_packet)		error("%d bytes remaining\n", (int) (next_packet - s->p));}/* Reset order state */voidreset_order_state(){	memset(&order_state, 0, sizeof(order_state));	order_state.order_type = RDP_ORDER_PATBLT;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -