Exemplo n.º 1
0
/* software decode */
int
surface_cmd(rdpRdp * rdp, STREAM s)
{
	int cmdType;
	int frameAction;
	int frameId;
	int destLeft;
	int destTop;
	int destRight;
	int destBottom;
	int bpp;
	int codecID;
	int width;
	int height;
	int bitmapDataLength;

	//printf("surface_cmd: size %d\n", s->end - s->p);
	//hexdump(s->p, 1024);
	frameId = 0;
	while (s->p < s->end)
	{
		in_uint16_le(s, cmdType);
		//printf("  surface_cmd: %d\n", cmdType);
		switch (cmdType)
		{
			case CMDTYPE_FRAME_MARKER:
				in_uint16_le(s, frameAction);
				in_uint32_le(s, frameId);
				//printf("    surface_cmd: CMDTYPE_FRAME_MARKER %d %d\n", frameAction, frameId);
				if (frameAction == SURFACECMD_FRAMEACTION_END)
				{
					rdp_send_frame_ack(rdp, frameId);
				}
				break;
			case CMDTYPE_STREAM_SURFACE_BITS:
				in_uint16_le(s, destLeft);
				in_uint16_le(s, destTop);
				in_uint16_le(s, destRight);
				in_uint16_le(s, destBottom);
				in_uint8(s, bpp);
				in_uint8s(s, 2);
				in_uint8(s, codecID);
				in_uint16_le(s, width);
				in_uint16_le(s, height);
				in_uint32_le(s, bitmapDataLength);
				in_uint8s(s, bitmapDataLength);
				//printf("    surface_cmd: CMDTYPE_STREAM_SURFACE_BITS "
				//	"id %d width %d height %d bpp %d size %d\n",
				//	codecID, width, height, bpp, bitmapDataLength);
				break;
		}
	}
	return 0;
}
Exemplo n.º 2
0
/* return error */
static int APP_CC
process_server_composite(struct mod *mod, struct stream *s)
{
    int rv;
    int srcidx;
    int srcformat;
    int srcwidth;
    int srcrepeat;
    int transform[10];
    int mskflags;
    int mskidx;
    int mskformat;
    int mskwidth;
    int mskrepeat;
    int op;
    int srcx;
    int srcy;
    int mskx;
    int msky;
    int dstx;
    int dsty;
    int width;
    int height;
    int dstformat;

    in_uint16_le(s, srcidx);
    in_uint32_le(s, srcformat);
    in_uint16_le(s, srcwidth);
    in_uint8(s, srcrepeat);
    g_memcpy(transform, s->p, 40);
    in_uint8s(s, 40);
    in_uint8(s, mskflags);
    in_uint16_le(s, mskidx);
    in_uint32_le(s, mskformat);
    in_uint16_le(s, mskwidth);
    in_uint8(s, mskrepeat);
    in_uint8(s, op);
    in_sint16_le(s, srcx);
    in_sint16_le(s, srcy);
    in_sint16_le(s, mskx);
    in_sint16_le(s, msky);
    in_sint16_le(s, dstx);
    in_sint16_le(s, dsty);
    in_uint16_le(s, width);
    in_uint16_le(s, height);
    in_uint32_le(s, dstformat);
    rv = mod->server_composite(mod, srcidx, srcformat, srcwidth, srcrepeat,
                               transform, mskflags, mskidx, mskformat,
                               mskwidth, mskrepeat, op, srcx, srcy, mskx, msky,
                               dstx, dsty, width, height, dstformat);
    return rv;
}
Exemplo n.º 3
0
/* Parse a pen */
static BOOL
rdp_parse_pen(STREAM s, PEN * pen, uint32 present)
{
	if (present & 1)
		in_uint8(s, pen->style);

	if (present & 2)
		in_uint8(s, pen->width);

	if (present & 4)
		rdp_in_colour(s, &pen->colour);

	return s_check(s);
}
Exemplo n.º 4
0
/* Process a licence packet */
void
licence_process(RDConnectionRef conn, RDStreamRef s)
{
	uint8 tag;

	in_uint8(s, tag);
	in_uint8s(s, 3);	/* version, length */

	switch (tag)
	{
		case LICENCE_TAG_DEMAND:
			licence_process_demand(conn, s);
			break;

		case LICENCE_TAG_AUTHREQ:
			licence_process_authreq(conn, s);
			break;

		case LICENCE_TAG_ISSUE:
			licence_process_issue(conn, s);
			break;

		case LICENCE_TAG_REISSUE:
		case LICENCE_TAG_RESULT:
			break;

		default:
			unimpl("licence tag 0x%x\n", tag);
	}
}
Exemplo n.º 5
0
void nego_process_negotiation_failure(NEGO *nego, STREAM s)
{
	uint8 flags;
	uint16 length;
	uint32 failureCode;

	in_uint8(s, flags);
	in_uint16_le(s, length);
	in_uint32_le(s, failureCode);

	switch (failureCode)
	{
		case SSL_REQUIRED_BY_SERVER:
			//printf("Error: SSL_REQUIRED_BY_SERVER\n");
			break;
		case SSL_NOT_ALLOWED_BY_SERVER:
			//printf("Error: SSL_NOT_ALLOWED_BY_SERVER\n");
			break;
		case SSL_CERT_NOT_ON_SERVER:
			//printf("Error: SSL_CERT_NOT_ON_SERVER\n");
			break;
		case INCONSISTENT_FLAGS:
			//printf("Error: INCONSISTENT_FLAGS\n");
			break;
		case HYBRID_REQUIRED_BY_SERVER:
			//printf("Error: HYBRID_REQUIRED_BY_SERVER\n");
			break;
		default:
			printf("Error: Unknown protocol security error %d\n", failureCode);
			break;
	}
}
Exemplo n.º 6
0
Arquivo: sound.c Projeto: OSgenie/xrdp
/* data in from client ( clinet -> xrdp -> chansrv ) */
int APP_CC
sound_data_in(struct stream *s, int chan_id, int chan_flags, int length,
              int total_length)
{
    int code;
    int size;

    print_got_here();

    in_uint8(s, code);
    in_uint8s(s, 1);
    in_uint16_le(s, size);

    switch (code)
    {
        case SNDC_WAVECONFIRM:
            sound_process_wave_confirm(s, size);
            break;

        case SNDC_TRAINING:
            sound_process_training(s, size);
            break;

        case SNDC_FORMATS:
            sound_process_formats(s, size);
            break;

        default:
            LOG(0, ("sound_data_in: unknown code %d size %d", code, size));
            break;
    }

    return 0;
}
Exemplo n.º 7
0
/* Parse bounds information */
static BOOL
rdp_parse_bounds(STREAM s, BOUNDS * bounds)
{
	uint8 present;

	in_uint8(s, present);

	if (present & 1)
		rdp_in_coord(s, &bounds->left, False);
	else if (present & 16)
		rdp_in_coord(s, &bounds->left, True);

	if (present & 2)
		rdp_in_coord(s, &bounds->top, False);
	else if (present & 32)
		rdp_in_coord(s, &bounds->top, True);

	if (present & 4)
		rdp_in_coord(s, &bounds->right, False);
	else if (present & 64)
		rdp_in_coord(s, &bounds->right, True);

	if (present & 8)
		rdp_in_coord(s, &bounds->bottom, False);
	else if (present & 128)
		rdp_in_coord(s, &bounds->bottom, True);

	return s_check(s);
}
Exemplo n.º 8
0
/* Process a desktop save order */
static void
process_desksave(STREAM s, DESKSAVE_ORDER * os, uint32 present, BOOL delta)
{
	int width, height;

	if (present & 0x01)
		in_uint32_le(s, os->offset);

	if (present & 0x02)
		rdp_in_coord(s, &os->left, delta);

	if (present & 0x04)
		rdp_in_coord(s, &os->top, delta);

	if (present & 0x08)
		rdp_in_coord(s, &os->right, delta);

	if (present & 0x10)
		rdp_in_coord(s, &os->bottom, delta);

	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));

	width = os->right - os->left + 1;
	height = os->bottom - os->top + 1;

	if (os->action == 0)
		ui_desktop_save(os->offset, os->left, os->top, width, height);
	else
		ui_desktop_restore(os->offset, os->left, os->top, width, height);
}
Exemplo n.º 9
0
/* Process a pattern blt order */
static void
process_patblt(STREAM s, PATBLT_ORDER * os, uint32 present, BOOL delta)
{
	if (present & 0x0001)
		rdp_in_coord(s, &os->x, delta);

	if (present & 0x0002)
		rdp_in_coord(s, &os->y, delta);

	if (present & 0x0004)
		rdp_in_coord(s, &os->cx, delta);

	if (present & 0x0008)
		rdp_in_coord(s, &os->cy, delta);

	if (present & 0x0010)
		in_uint8(s, os->opcode);

	if (present & 0x0020)
		rdp_in_colour(s, &os->bgcolour);

	if (present & 0x0040)
		rdp_in_colour(s, &os->fgcolour);

	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));

	ui_patblt(ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy,
		  &os->brush, os->bgcolour, os->fgcolour);
}
Exemplo n.º 10
0
/* Read field indicating which parameters are present */
static void
rdp_in_present(STREAM s, uint32 * present, uint8 flags, int size)
{
	uint8 bits;
	int i;

	if (flags & RDP_ORDER_SMALL)
	{
		size--;
	}

	if (flags & RDP_ORDER_TINY)
	{
		if (size < 2)
			size = 0;
		else
			size -= 2;
	}

	*present = 0;
	for (i = 0; i < size; i++)
	{
		in_uint8(s, bits);
		*present |= bits << (i * 8);
	}
}
Exemplo n.º 11
0
/* return error */
static int APP_CC
process_server_paint_rect_bpp(struct mod *mod, struct stream *s)
{
    int rv;
    int x;
    int y;
    int cx;
    int cy;
    int len_bmpdata;
    char *bmpdata;
    int width;
    int height;
    int srcx;
    int srcy;
    int bpp;

    in_sint16_le(s, x);
    in_sint16_le(s, y);
    in_uint16_le(s, cx);
    in_uint16_le(s, cy);
    in_uint32_le(s, len_bmpdata);
    in_uint8p(s, bmpdata, len_bmpdata);
    in_uint16_le(s, width);
    in_uint16_le(s, height);
    in_sint16_le(s, srcx);
    in_sint16_le(s, srcy);
    in_uint8(s, bpp);
    rv = mod->server_paint_rect_bpp(mod, x, y, cx, cy,
                                    bmpdata, width, height,
                                    srcx, srcy, bpp);
    return rv;
}
Exemplo n.º 12
0
/* Process a licence packet */
void
licence_process(RDPCLIENT * This, STREAM s)
{
	uint8 tag;

	in_uint8(s, tag);
	in_uint8s(s, 3);	/* version, length */

	switch (tag)
	{
		case LICENCE_TAG_DEMAND:
			licence_process_demand(This, s);
			break;

		case LICENCE_TAG_AUTHREQ:
			licence_process_authreq(This, s);
			break;

		case LICENCE_TAG_ISSUE:
			licence_process_issue(This, s);
			break;

		case LICENCE_TAG_REISSUE:
		case LICENCE_TAG_RESULT:
			break;

		default:
			unimpl("licence tag 0x%x\n", tag);
	}
}
Exemplo n.º 13
0
/* Process a screen blt order */
static void
process_screenblt(STREAM s, SCREENBLT_ORDER * os, uint32 present, BOOL delta)
{
	if (present & 0x0001)
		rdp_in_coord(s, &os->x, delta);

	if (present & 0x0002)
		rdp_in_coord(s, &os->y, delta);

	if (present & 0x0004)
		rdp_in_coord(s, &os->cx, delta);

	if (present & 0x0008)
		rdp_in_coord(s, &os->cy, delta);

	if (present & 0x0010)
		in_uint8(s, os->opcode);

	if (present & 0x0020)
		rdp_in_coord(s, &os->srcx, delta);

	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));

	ui_screenblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, os->srcx, os->srcy);
}
Exemplo n.º 14
0
/* Try to read TPKT header for X.224 from stream and return length
 * (including the 4 bytes TPKT header already read).
 * If not possible then return untouched stream and length -1. */
static int
tpkt_input_header(STREAM s)
{
	if (*s->p == 3)	/* Peeking is less ugly than rewinding */
	{
		uint8 version;
		uint8 reserved;
		uint16 length;

		in_uint8(s, version);
		in_uint8(s, reserved);
		in_uint16_be(s, length);
		return length;
	}
	return -1;	/* Probably Fast-Path */
}
Exemplo n.º 15
0
/* Receive a message on the ISO layer, return code */
static STREAM
iso_recv_msg(uint8 * code, uint8 * rdpver)
{
	STREAM s;
	uint16 length;
	uint8 version;

	s = tcp_recv(NULL, 4);
	if (s == NULL)
		return NULL;
	in_uint8(s, version);
	if (rdpver != NULL)
		*rdpver = version;
	if (version == 3)
	{
		in_uint8s(s, 1);	/* pad */
		in_uint16_be(s, length);
	}
	else
	{
		in_uint8(s, length);
		if (length & 0x80)
		{
			length &= ~0x80;
			next_be(s, length);
		}
	}
	if (length < 4)
	{
		error("Bad packet header\n");
		return NULL;
	}
	s = tcp_recv(s, length - 4);
	if (s == NULL)
		return NULL;
	if (version != 3)
		return s;
	in_uint8s(s, 1);	/* hdrlen */
	in_uint8(s, *code);
	if (*code == ISO_PDU_DT)
	{
		in_uint8s(s, 1);	/* eot */
		return s;
	}
	in_uint8s(s, 5);	/* dst_ref, src_ref, class */
	return s;
}
Exemplo n.º 16
0
static void
rdpsnd_process(STREAM s)
{
	uint16 len;

	while (!s_check_end(s))
	{
		/* New packet */
		if (packet.size == 0)
		{
			if ((s->end - s->p) < 4)
			{
				logger(Sound, Error,
				       "rdpsnd_process(), split at packet header, things will go south from here...");
				return;
			}
			in_uint8(s, packet_opcode);
			in_uint8s(s, 1);	/* Padding */
			in_uint16_le(s, len);

			logger(Sound, Debug, "rdpsnd_process(), Opcode = 0x%x Length= %d",
			       (int) packet_opcode, (int) len);

			packet.p = packet.data;
			packet.end = packet.data + len;
			packet.size = len;
		}
		else
		{
			len = MIN(s->end - s->p, packet.end - packet.p);

			/* Microsoft's server is so broken it's not even funny... */
			if (packet_opcode == SNDC_WAVE)
			{
				if ((packet.p - packet.data) < 12)
					len = MIN(len, 12 - (packet.p - packet.data));
				else if ((packet.p - packet.data) == 12)
				{
					logger(Sound, Debug,
					       "rdpsnd_process(), eating 4 bytes of %d bytes...",
					       len);
					in_uint8s(s, 4);
					len -= 4;
				}
			}

			in_uint8a(s, packet.p, len);
			packet.p += len;
		}

		/* Packet fully assembled */
		if (packet.p == packet.end)
		{
			packet.p = packet.data;
			rdpsnd_process_packet(packet_opcode, &packet);
			packet.size = 0;
		}
	}
}
Exemplo n.º 17
0
void rdp_process_bitmapcache_hostsupport_capset(rdpRdp * rdp, STREAM s)
{
	uint8 cacheVersion;

	in_uint8(s, cacheVersion); /* cacheVersion, must be set to BITMAPCACHE_REV2 */
	/* pad (1 byte) */
	/* pad (2 bytes) */
}
Exemplo n.º 18
0
/* returns error */
static int APP_CC
rdp_iso_recv_msg(struct rdp_iso *self, struct stream *s, int *code)
{
    int ver;
    int len;

    *code = 0;

    if (rdp_tcp_recv(self->tcp_layer, s, 4) != 0)
    {
        DEBUG(("   out rdp_iso_recv_msg error rdp_tcp_recv 1 failed"));
        return 1;
    }

    in_uint8(s, ver);

    if (ver != 3)
    {
        DEBUG(("   out rdp_iso_recv_msg error ver != 3"));
        return 1;
    }

    in_uint8s(s, 1);
    in_uint16_be(s, len);

    if (rdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
    {
        DEBUG(("   out rdp_iso_recv_msg error rdp_tcp_recv 2 failed"));
        return 1;
    }

    in_uint8s(s, 1);
    in_uint8(s, *code);

    if (*code == ISO_PDU_DT)
    {
        in_uint8s(s, 1);
    }
    else
    {
        in_uint8s(s, 5);
    }

    return 0;
}
Exemplo n.º 19
0
static void
rdpsnd_process(STREAM s)
{
	uint16 len;

	while (!s_check_end(s))
	{
		/* New packet */
		if (packet.size == 0)
		{
			if ((s->end - s->p) < 4)
			{
				error("RDPSND: Split at packet header. Things will go south from here...\n");
				return;
			}
			in_uint8(s, packet_opcode);
			in_uint8s(s, 1);	/* Padding */
			in_uint16_le(s, len);

			DEBUG_SOUND(("RDPSND: == Opcode %x Length: %d ==\n",
				     (int) packet_opcode, (int) len));

			packet.p = packet.data;
			packet.end = packet.data + len;
			packet.size = len;
		}
		else
		{
			len = MIN(s->end - s->p, packet.end - packet.p);

			/* Microsoft's server is so broken it's not even funny... */
			if (packet_opcode == RDPSND_WRITE)
			{
				if ((packet.p - packet.data) < 12)
					len = MIN(len, 12 - (packet.p - packet.data));
				else if ((packet.p - packet.data) == 12)
				{
					DEBUG_SOUND(("RDPSND: Eating 4 bytes of %d bytes...\n",
						     len));
					in_uint8s(s, 4);
					len -= 4;
				}
			}

			in_uint8a(s, packet.p, len);
			packet.p += len;
		}

		/* Packet fully assembled */
		if (packet.p == packet.end)
		{
			packet.p = packet.data;
			rdpsnd_process_packet(packet_opcode, &packet);
			packet.size = 0;
		}
	}
}
Exemplo n.º 20
0
/* Process a Licensing packet */
void
licence_process(rdpLicence * licence, STREAM s)
{
    uint8 tag;
    uint16 wMsgSize;
    uint8* license_start = s->p;

    /* Licensing Preamble */
    in_uint8(s, tag);	/* bMsgType */
    in_uint8s(s, 1);	/* Ignoring bVersion */
    in_uint16_le(s, wMsgSize);
    /* Now pointing at LicensingMessage */

    switch (tag)
    {
    case LICENSE_REQUEST:
        DEBUG("LICENSE_REQUEST\n");
        licence_process_request(licence, s);
        ASSERT(s->p == license_start + wMsgSize);
        break;

    case LICENSE_PLATFORM_CHALLENGE:
        DEBUG("LICENCE PLATFORM_CHALLENGE\n");
        licence_process_platform_challenge(licence, s);
        break;

    case NEW_LICENSE:
        DEBUG("NEW_LICENSE\n");
        licence_process_new_license(licence, s);
        break;

    case UPGRADE_LICENSE:
        DEBUG("UPGRADE_LICENSE\n");
        break;

    case LICENCE_ERROR_ALERT:
        DEBUG("LICENCE ERROR_ALERT - assuming it is a license grant\n");
        {
            uint32 dwErrorCode, dwStateTransition;
            uint32 wBlobType, wBlobLen;
            in_uint32_le(s, dwErrorCode);
            in_uint32_le(s, dwStateTransition);
            DEBUG("dwErrorCode %x dwStateTransition %x\n", dwErrorCode, dwStateTransition);
            in_uint16_le(s, wBlobType);
            in_uint16_le(s, wBlobLen);
            DEBUG("bbErrorInfo: wBlobType %x wBlobLen %x\n", wBlobType, wBlobLen);
            /* hexdump(s->p, wBlobLen); */
        }
        licence->licence_issued = True;	/* TODO ... */
        break;

    default:
        ui_unimpl(licence->sec->rdp->inst, "Unknown licence tag 0x%x\n", tag);
    }
    s->p = license_start + wMsgSize;	/* FIXME: Shouldn't be necessary if parsed properly */
    ASSERT(s->p <= s->end);
}
Exemplo n.º 21
0
/* Process a memory blt order */
static void
process_memblt(STREAM s, MEMBLT_ORDER * os, uint32 present, BOOL delta)
{
	HBITMAP bitmap;

	if (present & 0x0001)
	{
		in_uint8(s, os->cache_id);
		in_uint8(s, os->colour_table);
	}

	if (present & 0x0002)
		rdp_in_coord(s, &os->x, delta);

	if (present & 0x0004)
		rdp_in_coord(s, &os->y, delta);

	if (present & 0x0008)
		rdp_in_coord(s, &os->cx, delta);

	if (present & 0x0010)
		rdp_in_coord(s, &os->cy, delta);

	if (present & 0x0020)
		in_uint8(s, os->opcode);

	if (present & 0x0040)
		rdp_in_coord(s, &os->srcx, delta);

	if (present & 0x0080)
		rdp_in_coord(s, &os->srcy, delta);

	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));

	bitmap = cache_get_bitmap(os->cache_id, os->cache_idx);
	if (bitmap == NULL)
		return;

	ui_memblt(ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy);
}
Exemplo n.º 22
0
/* Receive a packet from tcp and return stream.
 * If no ptype then only TPKT header with X.224 is accepted.
 * If ptype then Fast-Path packets are accepted too.
 * Return NULL on error. */
STREAM
tpkt_recv(rdpIso * iso, uint8 * pcode, isoRecvType * ptype)
{
	STREAM s;
	int length;

	s = tcp_recv(iso->tcp, NULL, 4);

	if (s == NULL)
		return NULL;

	length = tpkt_input_header(s);

	if (length >= 0)
	{
		/* Valid TPKT header, payload is X.224 TPDU */
		if (ptype != NULL)
			*ptype = ISO_RECV_X224;

		s = x224_recv(iso, s, length, pcode);
		return s;
	}
	else if (ptype != NULL)
	{
		/* Fast-Path header */
		uint8 fpInputHeader;

		in_uint8(s, fpInputHeader);
		ASSERT((fpInputHeader & 3) == 0);	/* assume actionCode FASTPATH_OUTPUT_ACTION_FASTPATH */
		*ptype = (fpInputHeader & 0x80) ? ISO_RECV_FAST_PATH_ENCRYPTED : ISO_RECV_FAST_PATH;
		/* TODO: 0x40 FASTPATH_OUTPUT_SECURE_CHECKSUM indicates salted MAC */

		in_uint8(s, length);
		if (length & 0x80)
		{
			length &= ~0x80;
			next_be(s, length);
		}

		s = tcp_recv(iso->tcp, s, length - 4);
		return s;
	}
	return NULL;	/* Fast-Path not allowed */
}
Exemplo n.º 23
0
/* returns error
   returns 0 if everything is ok
   returns 1 if problem reading file */
static int APP_CC
l_file_read_sections(int fd, int max_file_size, struct list *names)
{
    struct stream *s;
    char text[FILE_MAX_LINE_BYTES];
    char c;
    int in_it;
    int in_it_index;
    int len;
    int index;
    int rv;

    rv = 0;
    g_file_seek(fd, 0);
    in_it_index = 0;
    in_it = 0;
    g_memset(text, 0, FILE_MAX_LINE_BYTES);
    list_clear(names);
    make_stream(s);
    init_stream(s, max_file_size);
    len = g_file_read(fd, s->data, max_file_size);

    if (len > 0)
    {
        s->end = s->p + len;

        for (index = 0; index < len; index++)
        {
            in_uint8(s, c);

            if (c == '[')
            {
                in_it = 1;
            }
            else if (c == ']')
            {
                list_add_item(names, (tbus)g_strdup(text));
                in_it = 0;
                in_it_index = 0;
                g_memset(text, 0, FILE_MAX_LINE_BYTES);
            }
            else if (in_it)
            {
                text[in_it_index] = c;
                in_it_index++;
            }
        }
    }
    else if (len < 0)
    {
        rv = 1;
    }

    free_stream(s);
    return rv;
}
Exemplo n.º 24
0
bool APP_CC
xrdp_iso_parse_connection_request(struct xrdp_iso* self, struct stream* s, int code)
{
  unsigned char type;
  unsigned char flags;
  unsigned short length;
  unsigned int protocol;

  // Get cookie
  char* p = g_strstr(s->p, "\r\n");
  if (p != NULL) // There is a cookie or a routingToken
  {
    int cookie_len = p - s->p;
    if (cookie_len > 0)
    {
      char* cookie = g_malloc(cookie_len + 1, 1);
      g_strncpy(cookie, s->p, cookie_len);
      printf("cookie: %s\n", cookie);
      s->p += (cookie_len + 2); // CR+LF
      g_free(cookie);
    }
  }

  if (s->p == s->end)
  {
    return true;
  }

  // parse rdpNegData
  in_uint8(s, type);           // type
  in_uint8(s, flags);          // flags
  in_uint16_le(s, length);     // length
  in_uint32_le(s, protocol);   // selectedProtocol

  if (type == TYPE_RDP_NEG_REQ && length == RDP_NEG_REQ_LEN)
  {
    self->need_negotiation_response = true;
    return true;
  }

  self->mcs_layer->sec_layer->rdp_layer->client_info.support_network_detection = false;
  return true;
}
Exemplo n.º 25
0
/* Receive a message on the ISO layer, return code */
static STREAM
iso_recv_msg(RDPCLIENT * This, uint8 * code, uint8 * rdpver)
{
	STREAM s;
	uint16 length;
	uint8 version;

	s = tcp_recv(This, NULL, 4);
	if (s == NULL)
		return NULL;
	in_uint8(s, version);
	if (rdpver != NULL)
		*rdpver = version;
	if (version == 3)
	{
		in_uint8s(s, 1);	/* pad */
		in_uint16_be(s, length);
	}
	else
	{
		in_uint8(s, length);
		if (length & 0x80)
		{
			length &= ~0x80;
			next_be(s, length);
		}
	}
	s = tcp_recv(This, s, length - 4);
	if (s == NULL)
		return NULL;
	if (version != 3)
		return s;
	in_uint8s(s, 1);	/* hdrlen */
	in_uint8(s, *code);
	if (*code == ISO_PDU_DT)
	{
		in_uint8s(s, 1);	/* eot */
		return s;
	}
	in_uint8s(s, 5);	/* dst_ref, src_ref, class */
	return s;
}
Exemplo n.º 26
0
/* Parse a brush */
static BOOL
rdp_parse_brush(STREAM s, BRUSH * brush, uint32 present)
{
	if (present & 1)
		in_uint8(s, brush->xorigin);

	if (present & 2)
		in_uint8(s, brush->yorigin);

	if (present & 4)
		in_uint8(s, brush->style);

	if (present & 8)
		in_uint8(s, brush->pattern[0]);

	if (present & 16)
		in_uint8a(s, &brush->pattern[1], 7);

	return s_check(s);
}
Exemplo n.º 27
0
/* Receive a message on the ISO layer, return code */
static STREAM
iso_recv_msg(uint8 * code)
{
	STREAM s;
	uint16 length;
	uint8 version;

	s = tcp_recv(4);
	if (s == NULL)
	{
		return NULL;
	}

	in_uint8(s, version);
	if (version != 3)
	{
		error("TPKT v%d\n", version);
		return NULL;
	}

	in_uint8s(s, 1);	/* pad */
	in_uint16_be(s, length);

	s = tcp_recv(length - 4);
	if (s == NULL)
		return NULL;

	in_uint8s(s, 1);	/* hdrlen */
	in_uint8(s, *code);

	if (*code == ISO_PDU_DT)
	{
		in_uint8s(s, 1);	/* eot */
		return s;
	}

	in_uint8s(s, 5);	/* dst_ref, src_ref, class */
	return s;
}
Exemplo n.º 28
0
void rdp_process_window_capset(rdpRdp * rdp, STREAM s)
{
	uint32 wndSupportLevel;
	uint8 numIconCaches;
	uint16 numIconCacheEntries;

	in_uint32_le(s, wndSupportLevel); /* wndSupportLevel */
	in_uint8(s, numIconCaches); /* numIconCaches */
	in_uint16_le(s, numIconCacheEntries); /* numIconCacheEntries */

	rail_process_window_capset(rdp->rail_session, wndSupportLevel, numIconCaches,
			numIconCacheEntries);
}
Exemplo n.º 29
0
/* Read a co-ordinate (16-bit, or 8-bit delta) */
static void
rdp_in_coord(STREAM s, uint16 * coord, BOOL delta)
{
	sint8 change;

	if (delta)
	{
		in_uint8(s, change);
		*coord += change;
	}
	else
	{
		in_uint16_le(s, *coord);
	}
}
Exemplo n.º 30
0
void nego_recv(NEGO *nego, STREAM s)
{
	uint8 type;
	in_uint8(s, type); /* Type */

	switch (type)
	{
		case TYPE_RDP_NEG_RSP:
			nego_process_negotiation_response(nego, s);
			break;
		case TYPE_RDP_NEG_FAILURE:
			nego_process_negotiation_failure(nego, s);
			break;
	}
}