Пример #1
0
void rdp_out_bitmapcache_rev2_capset(rdpRdp * rdp, STREAM s)
{
	capsetHeaderRef header;
	uint16 flag;

	header = rdp_skip_capset_header(s);
	flag = ALLOW_CACHE_WAITING_LIST_FLAG;
	if (rdp->settings->bitmap_cache_persist_enable)
		flag |= PERSISTENT_KEYS_EXPECTED_FLAG;
	out_uint16_le(s, flag); /* CacheFlags */
	out_uint8s(s, 1); /* pad */
	out_uint8(s, 3); /* numCellCaches */

	/* max cell size for cache 0 is 16x16, 1 = 32x32, 2 = 64x64, etc */
	out_uint32_le(s, BMPCACHE2_C0_CELLS);
	out_uint32_le(s, BMPCACHE2_C1_CELLS);
	if (pstcache_init(rdp->pcache, 2))
	{
		out_uint32_le(s, BMPCACHE2_NUM_PSTCELLS | BMPCACHE2_FLAG_PERSIST);
	}
	else
	{
		out_uint32_le(s, BMPCACHE2_C2_CELLS);
	}
	out_uint8s(s, 20);	/* other bitmap caches not used */
	rdp_out_capset_header(s, header, CAPSET_TYPE_BITMAPCACHE_REV2);
}
Пример #2
0
/* flags can contain WINDOW_ORDER_STATE_NEW and/or
   WINDOW_ORDER_FIELD_ICON_BIG */
int
xrdp_orders_send_window_cached_icon(struct xrdp_orders *self,
                                    int window_id, int cache_entry,
                                    int cache_id, int flags)
{
    int order_size;
    int order_flags;
    int field_present_flags;

    order_size = 14;
    if (xrdp_orders_check(self, order_size) != 0)
    {
        return 1;
    }
    self->order_count++;
    order_flags = RDP_ORDER_SECONDARY;
    order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
    out_uint8(self->out_s, order_flags);
    /* orderSize (2 bytes) */
    out_uint16_le(self->out_s, order_size);
    /* FieldsPresentFlags (4 bytes) */
    field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW |
                          WINDOW_ORDER_CACHED_ICON;
    out_uint32_le(self->out_s, field_present_flags);
    /* windowId (4 bytes) */
    out_uint32_le(self->out_s, window_id);
    /* CacheEntry (2 bytes) */
    out_uint16_le(self->out_s, cache_entry);
    /* CacheId (1 byte) */
    out_uint8(self->out_s, cache_id);
    return 0;
}
Пример #3
0
void
rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,
		      uint32 length)
{
	uint8 magic[4] = "rDCI";
	STREAM s;

#ifdef WITH_SCARD
	scard_lock(SCARD_LOCK_RDPDR);
#endif
	s = channel_init(rdpdr_channel, 20 + length);
	out_uint8a(s, magic, 4);
	out_uint32_le(s, device);
	out_uint32_le(s, id);
	out_uint32_le(s, status);
	out_uint32_le(s, result);
	out_uint8p(s, buffer, length);
	s_mark_end(s);
	/* JIF */
#ifdef WITH_DEBUG_RDP5
	printf("--> rdpdr_send_completion\n");
	/* hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8); */
#endif
	channel_send(s, rdpdr_channel);
#ifdef WITH_SCARD
	scard_unlock(SCARD_LOCK_RDPDR);
#endif
}
Пример #4
0
/* Send a client window information PDU */
BOOL
rdp_send_client_window_status(RDPCLIENT * This, int status)
{
	STREAM s;

	if (This->rdp.current_status == status)
		return True;

	s = rdp_init_data(This, 12);

	if(s == NULL)
		return False;

	out_uint32_le(s, status);

	switch (status)
	{
		case 0:	/* shut the server up */
			break;

		case 1:	/* receive data again */
			out_uint32_le(s, 0);	/* unknown */
			out_uint16_le(s, This->width);
			out_uint16_le(s, This->height);
			break;
	}

	s_mark_end(s);
	This->rdp.current_status = status;
	return rdp_send_data(This, s, RDP_DATA_PDU_CLIENT_WINDOW_STATUS);
}
Пример #5
0
bool APP_CC
xrdp_emt_send_result(struct xrdp_rdp* self, struct xrdp_emt* emt)
{
  struct stream* s;

  if (emt == NULL)
  {
    printf("emt is null\n");
    return false;
  }

  make_stream(s);
  init_stream(s, 40);
  xrdp_sec_init(self->sec_layer, s);

  out_uint8(s, SEC_AUTODETECT_REQ_LENGTH);               // headerLength
  out_uint8(s, TYPE_ID_AUTODETECT_REQUEST);              // headerTypeId
  out_uint16_le(s, emt->seq_number++);                   // sequenceNumber
  out_uint16_le(s, field_all);                           // responseType

  out_uint32_le(s, self->session->base_RTT);
  out_uint32_le(s, self->session->bandwidth);
  out_uint32_le(s, self->session->average_RTT);

  s_mark_end(s);

  xrdp_emt_send_packet(self, emt, s);
  free_stream(s);

  return true;
}
Пример #6
0
int APP_CC
dev_redir_process_close_io_request(int completion_id)
{
	struct stream* s;

	log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[dev_redir_process_close_io_request]:"
	  		"close file : %s",actions[completion_id].path);
	make_stream(s);
	init_stream(s,1100);
	actions[completion_id].last_req = IRP_MJ_CLOSE;
	out_uint16_le(s, RDPDR_CTYP_CORE);
	out_uint16_le(s, PAKID_CORE_DEVICE_IOREQUEST);
	out_uint32_le(s, actions[completion_id].device);
	out_uint32_le(s, actions[completion_id].file_id);
	out_uint32_le(s, completion_id);
	out_uint32_le(s, IRP_MJ_CLOSE);   	/* major version */
	out_uint32_le(s, 0);								/* minor version */
	out_uint8s(s,32);
	s_mark_end(s);
	dev_redir_send(s);
	actions[completion_id].message_id++;
	free_stream(s);
	return 0;
	free_stream(s);
}
Пример #7
0
void cliprdr_send_capability()
{
	/* this message is ignored by rdp applet */
	struct stream* s;

	make_stream(s);
	init_stream(s,1024);

	log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_send_capability]:");
	/* clip header */
	out_uint16_le(s, CB_CLIP_CAPS);                        /* msg type */
	out_uint16_le(s, 0x00);                                /* msg flag */
	out_uint32_le(s, 0);                                   /* msg size */
	/* we only support one capability for now */
	out_uint16_le(s, 1);                                   /* cCapabilitiesSets */
	out_uint8s(s, 16);                                     /* pad */
	/* CLIPRDR_CAPS_SET */
	out_uint16_le(s, CB_CAPSTYPE_GENERAL);                 /* capabilitySetType */
	out_uint16_le(s, 92);                                  /* lengthCapability */
	out_uint32_le(s, CB_CAPS_VERSION_1);                   /* version */
	out_uint32_le(s, 0);                                   /* general flags */


	s_mark_end(s);
	cliprdr_send(s);
	free_stream(s);

}
Пример #8
0
/* used for both Non-Monitored Desktop and Actively Monitored Desktop */
int
xrdp_orders_send_monitored_desktop(struct xrdp_orders *self,
                                   struct rail_monitored_desktop_order *mdo,
                                   int flags)
{
    int order_size;
    int order_flags;
    int field_present_flags;
    int index;

    order_size = 7;
    field_present_flags = flags | WINDOW_ORDER_TYPE_DESKTOP;

    if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
    {
        /* ActiveWindowId (4 bytes) */
        order_size += 4;
    }

    if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
    {
        /* NumWindowIds (1 byte) */
        order_size += 1;
        /* WindowIds (variable) */
        order_size += mdo->num_window_ids *  4;
    }

    if (xrdp_orders_check(self, order_size) != 0)
    {
        return 1;
    }
    self->order_count++;
    order_flags = RDP_ORDER_SECONDARY;
    order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
    out_uint8(self->out_s, order_flags);
    /* orderSize (2 bytes) */
    out_uint16_le(self->out_s, order_size);
    /* FieldsPresentFlags (4 bytes) */
    out_uint32_le(self->out_s, field_present_flags);

    if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
    {
        /* ActiveWindowId (4 bytes) */
        out_uint32_le(self->out_s, mdo->active_window_id);
    }

    if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
    {
        /* NumWindowIds (1 byte) */
        out_uint8(self->out_s, mdo->num_window_ids);

        /* WindowIds (variable) */
        for (index = 0; index < mdo->num_window_ids; index++)
        {
            out_uint32_le(self->out_s, mdo->window_ids[index]);
        }
    }

    return 0;
}
Пример #9
0
/* returns error */
int
xrdp_orders_send_notify_delete(struct xrdp_orders *self, int window_id,
                               int notify_id)
{
    int order_size;
    int order_flags;
    int field_present_flags;

    order_size = 15;
    if (xrdp_orders_check(self, order_size) != 0)
    {
        return 1;
    }
    self->order_count++;
    order_flags = RDP_ORDER_SECONDARY;
    order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
    out_uint8(self->out_s, order_flags);
    /* orderSize (2 bytes) */
    out_uint16_le(self->out_s, order_size);
    /* FieldsPresentFlags (4 bytes) */
    field_present_flags = WINDOW_ORDER_TYPE_NOTIFY | WINDOW_ORDER_STATE_DELETED;
    out_uint32_le(self->out_s, field_present_flags);
    /* windowId (4 bytes) */
    out_uint32_le(self->out_s, window_id);
    /* notifyIconId (4 bytes) */
    out_uint32_le(self->out_s, notify_id);
    return 0;
}
Пример #10
0
int EXPORT_CC
libxrdp_send_bell(struct xrdp_session *session)
{
    struct stream *s = (struct stream *)NULL;

    DEBUG(("libxrdp_send_bell sending bell signal"));
    /* see MS documentation: Server play sound PDU, TS_PLAY_SOUND_PDU_DATA */

    make_stream(s);
    init_stream(s, 8192);

    if (xrdp_rdp_init_data((struct xrdp_rdp *)session->rdp, s) != 0)
    {
        free_stream(s);
        return 1;
    }

    out_uint32_le(s, 440); /* frequency */
    out_uint32_le(s, 100); /* duration (ms) */
    s_mark_end(s);

    if (xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_PLAY_SOUND) != 0)
    {
        free_stream(s);
        return 1;
    }

    free_stream(s);
    return 0;
}
Пример #11
0
/* Send a client window information PDU */
void
rdp_send_client_window_status(int status)
{
    STREAM s;
    static int current_status = 1;

    if (current_status == status)
        return;

    s = rdp_init_data(12);

    out_uint32_le(s, status);

    switch (status)
    {
    case 0:	/* shut the server up */
        break;

    case 1:	/* receive data again */
        out_uint32_le(s, 0);	/* unknown */
        out_uint16_le(s, g_width);
        out_uint16_le(s, g_height);
        break;
    }

    s_mark_end(s);
    rdp_send_data(s, RDP_DATA_PDU_CLIENT_WINDOW_STATUS);
    current_status = status;
}
Пример #12
0
static int APP_CC
sound_send_server_formats(void)
{
    struct stream *s;
    int bytes;
    char *size_ptr;

    print_got_here();

    make_stream(s);
    init_stream(s, 8182);
    out_uint16_le(s, SNDC_FORMATS);
    size_ptr = s->p;
    out_uint16_le(s, 0);        /* size, set later */
    out_uint32_le(s, 0);        /* dwFlags */
    out_uint32_le(s, 0);        /* dwVolume */
    out_uint32_le(s, 0);        /* dwPitch */
    out_uint16_le(s, 0);        /* wDGramPort */
    out_uint16_le(s, 1);        /* wNumberOfFormats */
    out_uint8(s, g_cBlockNo);   /* cLastBlockConfirmed */
    out_uint16_le(s, 2);        /* wVersion */
    out_uint8(s, 0);            /* bPad */

    /* sndFormats */
    /*
        wFormatTag      2 byte offset 0
        nChannels       2 byte offset 2
        nSamplesPerSec  4 byte offset 4
        nAvgBytesPerSec 4 byte offset 8
        nBlockAlign     2 byte offset 12
        wBitsPerSample  2 byte offset 14
        cbSize          2 byte offset 16
        data            variable offset 18
    */

    /*  examples
        01 00 02 00 44 ac 00 00 10 b1 02 00 04 00 10 00 ....D...........
        00 00
        01 00 02 00 22 56 00 00 88 58 01 00 04 00 10 00 ...."V...X......
        00 00
    */

    out_uint16_le(s, 1);         // wFormatTag - WAVE_FORMAT_PCM
    out_uint16_le(s, 2);         // num of channels
    out_uint32_le(s, 44100);     // samples per sec
    out_uint32_le(s, 176400);    // avg bytes per sec
    out_uint16_le(s, 4);         // block align
    out_uint16_le(s, 16);        // bits per sample
    out_uint16_le(s, 0);         // size

    s_mark_end(s);
    bytes = (int)((s->end - s->data) - 4);
    size_ptr[0] = bytes;
    size_ptr[1] = bytes >> 8;
    bytes = (int)(s->end - s->data);
    send_channel_data(g_rdpsnd_chan_id, s->data, bytes);
    free_stream(s);
    return 0;
}
Пример #13
0
static void
rdpdr_send_available(RDPCLIENT * This)
{

	uint8 magic[4] = "rDAD";
	uint32 driverlen, printerlen, bloblen;
	int i;
	STREAM s;
	PRINTER *printerinfo;

	s = channel_init(This, This->rdpdr.channel, announcedata_size(This));
	out_uint8a(s, magic, 4);
	out_uint32_le(s, This->num_devices);

	for (i = 0; i < This->num_devices; i++)
	{
		out_uint32_le(s, This->rdpdr_device[i].device_type);
		out_uint32_le(s, i);	/* RDP Device ID */
		/* Is it possible to use share names longer than 8 chars?
		   /astrand */
		out_uint8p(s, This->rdpdr_device[i].name, 8);

		switch (This->rdpdr_device[i].device_type)
		{
			case DEVICE_TYPE_PRINTER:
				printerinfo = (PRINTER *) This->rdpdr_device[i].pdevice_data;

				driverlen = 2 * strlen(printerinfo->driver) + 2;
				printerlen = 2 * strlen(printerinfo->printer) + 2;
				bloblen = printerinfo->bloblen;

				out_uint32_le(s, 24 + driverlen + printerlen + bloblen);	/* length of extra info */
				out_uint32_le(s, printerinfo->default_printer ? 2 : 0);
				out_uint8s(s, 8);	/* unknown */
				out_uint32_le(s, driverlen);
				out_uint32_le(s, printerlen);
				out_uint32_le(s, bloblen);
				rdp_out_unistr(This, s, printerinfo->driver, driverlen - 2);
				rdp_out_unistr(This, s, printerinfo->printer, printerlen - 2);
				out_uint8a(s, printerinfo->blob, bloblen);

				if (printerinfo->blob)
					xfree(printerinfo->blob);	/* Blob is sent twice if reconnecting */
				break;
			default:
				out_uint32(s, 0);
		}
	}
#if 0
	out_uint32_le(s, 0x20);	/* Device type 0x20 - smart card */
	out_uint32_le(s, 0);
	out_uint8p(s, "SCARD", 5);
	out_uint8s(s, 3);
	out_uint32(s, 0);
#endif

	s_mark_end(s);
	channel_send(This, s, This->rdpdr.channel);
}
Пример #14
0
void
channel_send(STREAM s, VCHANNEL * channel)
{
	uint32 length, flags;
	uint32 thislength, remaining;
	uint8 *data;

#ifdef WITH_SCARD
	scard_lock(SCARD_LOCK_CHANNEL);
#endif

	/* first fragment sent in-place */
	s_pop_layer(s, channel_hdr);
	length = s->end - s->p - 8;

	DEBUG_CHANNEL(("channel_send, length = %d\n", length));

	thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
/* Note: In the original clipboard implementation, this number was
   1592, not 1600. However, I don't remember the reason and 1600 seems
   to work so.. This applies only to *this* length, not the length of
   continuation or ending packets. */
	remaining = length - thislength;
	flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST;
	if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
		flags |= CHANNEL_FLAG_SHOW_PROTOCOL;

	out_uint32_le(s, length);
	out_uint32_le(s, flags);
	data = s->end = s->p + thislength;
	DEBUG_CHANNEL(("Sending %d bytes with FLAG_FIRST\n", thislength));
	sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id);

	/* subsequent segments copied (otherwise would have to generate headers backwards) */
	while (remaining > 0)
	{
		thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH);
		remaining -= thislength;
		flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0;
		if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
			flags |= CHANNEL_FLAG_SHOW_PROTOCOL;

		DEBUG_CHANNEL(("Sending %d bytes with flags %d\n", thislength, flags));

		s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8);
		out_uint32_le(s, length);
		out_uint32_le(s, flags);
		out_uint8p(s, data, thislength);
		s_mark_end(s);
		sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id);

		data += thislength;
	}

#ifdef WITH_SCARD
	scard_unlock(SCARD_LOCK_CHANNEL);
#endif
}
Пример #15
0
/* send a chunk of the file from server to client */
static int 
clipboard_send_file_data(int streamId, int lindex,
                         int nPositionLow, int cbRequested)
{
    struct stream *s;
    int size;
    int rv;
    int fd;
    char full_fn[256];
    struct cb_file_info *cfi;

    if (g_files_list == 0)
    {
        LLOGLN(10, ("clipboard_send_file_data: error g_files_list is nil"));
        return 1;
    }
    cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
    if (cfi == 0)
    {
        LLOGLN(10, ("clipboard_send_file_data: error cfi is nil"));
        return 1;
    }
    LLOGLN(10, ("clipboard_send_file_data: streamId %d lindex %d "
                "nPositionLow %d cbRequested %d", streamId, lindex,
                nPositionLow, cbRequested));
    g_snprintf(full_fn, 255, "%s/%s", cfi->pathname, cfi->filename);
    fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
    if (fd == -1)
    {
        LLOGLN(0, ("clipboard_send_file_data: file open [%s] failed",
                   full_fn));
        return 1;
    }
    g_file_seek(fd, nPositionLow);
    make_stream(s);
    init_stream(s, cbRequested + 64);
    size = g_file_read(fd, s->data + 12, cbRequested);
    if (size < 1)
    {
        LLOGLN(0, ("clipboard_send_file_data: read error, want %d got %d",
                   cbRequested, size));
        free_stream(s);
        g_file_close(fd);
        return 1;
    }
    out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
    out_uint16_le(s, CB_RESPONSE_OK); /* 1 status */
    out_uint32_le(s, size + 4);
    out_uint32_le(s, streamId);
    s->p += size;
    out_uint32_le(s, 0);
    s_mark_end(s);
    size = (int)(s->end - s->data);
    rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
    free_stream(s);
    g_file_close(fd);
    return rv;
}
Пример #16
0
void rdp_out_order_capset(rdpRdp * rdp, STREAM s)
{
	uint8 orderSupport[32];
	capsetHeaderRef header;

	header = rdp_skip_capset_header(s);

	memset(orderSupport, 0, 32);
	orderSupport[NEG_DSTBLT_INDEX] = 1;
	orderSupport[NEG_PATBLT_INDEX] = 1;
	orderSupport[NEG_SCRBLT_INDEX] = 1;
	orderSupport[NEG_MEMBLT_INDEX] = (rdp->settings->bitmap_cache ? 1 : 0);
	orderSupport[NEG_MEM3BLT_INDEX] = (rdp->settings->triblt ? 1 : 0);
	// orderSupport[NEG_DRAWNINEGRID_INDEX] = 1;
	orderSupport[NEG_LINETO_INDEX] = 1;
	orderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = 1;
	orderSupport[NEG_SAVEBITMAP_INDEX] = (rdp->settings->desktop_save ? 1 : 0);
	// orderSupport[NEG_MULTIDSTBLT_INDEX] = 1;
	orderSupport[NEG_MULTIPATBLT_INDEX] = 1;
	// orderSupport[NEG_MULTISCRBLT_INDEX] = 1;
	orderSupport[NEG_MULTIOPAQUERECT_INDEX] = 1;
	orderSupport[NEG_FAST_INDEX_INDEX] = 1;
	orderSupport[NEG_POLYGON_SC_INDEX] = (rdp->settings->polygon_ellipse_orders ? 1 : 0);
	orderSupport[NEG_POLYGON_CB_INDEX] = (rdp->settings->polygon_ellipse_orders ? 1 : 0);
	orderSupport[NEG_POLYLINE_INDEX] = 1;
	orderSupport[NEG_FAST_GLYPH_INDEX] = 1;
/*	orderSupport[NEG_ELLIPSE_SC_INDEX] = (rdp->settings->polygon_ellipse_orders ? 1 : 0);*/
/*	orderSupport[NEG_ELLIPSE_CB_INDEX] = (rdp->settings->polygon_ellipse_orders ? 1 : 0);*/
	orderSupport[NEG_INDEX_INDEX] = 1;

	out_uint8s(s, 16); /* terminalDescriptor, ignored and should be set to zero */
	out_uint32_le(s, 0); /* pad */
	out_uint16_le(s, 1); /* desktopSaveXGranularity */
	out_uint16_le(s, 20); /* desktopSaveYGranularity */
	out_uint16_le(s, 0); /* pad */
	out_uint16_le(s, 1); /* maximumOrderLevel */
	out_uint16_le(s, 0); /* numberFonts, ignored and should be set to zero */

	out_uint16_le(s,
		NEGOTIATEORDERSUPPORT |
		ZEROBOUNDSDELTASSUPPORT |
		COLORINDEXSUPPORT ); /* orderFlags */

	out_uint8p(s, orderSupport, 32); /* orderSupport */
	out_uint16_le(s, 0); /* textFlags, must be ignored */
	out_uint16_le(s, 0); /* orderSupportExFlags */
	out_uint32_le(s, 0); /* pad */
	out_uint32_le(s, rdp->settings->desktop_save == False ? 0 : 0x38400); /* desktopSaveSize */
	out_uint16_le(s, 0); /* pad */
	out_uint16_le(s, 0); /* pad */

	/* See [MSDN-CP]: http://msdn.microsoft.com/en-us/library/dd317756/ */
	out_uint16_le(s, 0x04E4); /* textANSICodePage, 0x04E4 is "ANSI Latin 1 Western European (Windows)" */
	out_uint16_le(s, 0); /* pad */

	rdp_out_capset_header(s, header, CAPSET_TYPE_ORDER);
}
Пример #17
0
void rdp_out_virtualchannel_capset(STREAM s)
{
	capsetHeaderRef header;

	header = rdp_skip_capset_header(s);
	out_uint32_le(s, VCCAPS_COMPR_SC); /* virtual channel compression flags */
	out_uint32_le(s, 0); /* VCChunkSize, ignored when sent from client to server */
	rdp_out_capset_header(s, header, CAPSET_TYPE_VIRTUALCHANNEL);
}
Пример #18
0
void rdp_out_surface_commands_capset(rdpRdp * rdp, STREAM s)
{
	capsetHeaderRef header;

	header = rdp_skip_capset_header(s);
	out_uint32_le(s, rdp->surface_commands); /* cmdFlags */
	out_uint32_le(s, 0); /* reserved for future use */
	rdp_out_capset_header(s, header, CAPSET_TYPE_SURFACE_COMMANDS);
}
Пример #19
0
/* ask the client to send the file size */
int
clipboard_request_file_size(int stream_id, int lindex)
{
    struct stream *s;
    int size;
    int rv;

    log_debug("clipboard_request_file_size:");
    if (g_file_request_sent_type != 0)
    {
        log_error("clipboard_request_file_size: warning, still waiting "
                   "for CB_FILECONTENTS_RESPONSE");
    }
    make_stream(s);
    init_stream(s, 8192);
    out_uint16_le(s, CB_FILECONTENTS_REQUEST); /* 8 */
    out_uint16_le(s, 0);
    out_uint32_le(s, 28);
    out_uint32_le(s, stream_id);
    out_uint32_le(s, lindex);
    out_uint32_le(s, CB_FILECONTENTS_SIZE);
    out_uint32_le(s, 0); /* nPositionLow */
    out_uint32_le(s, 0); /* nPositionHigh */
    out_uint32_le(s, 0); /* cbRequested */
    out_uint32_le(s, 0); /* clipDataId */
    out_uint32_le(s, 0);
    s_mark_end(s);
    size = (int)(s->end - s->data);
    rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
    free_stream(s);
    g_file_request_sent_type = CB_FILECONTENTS_SIZE;
    return rv;
}
Пример #20
0
/* returns error */
	int APP_CC
send_channel_data(int chan_id, char* data, int size)
{
	struct stream* s;
	int chan_flags;
	int total_size;
	int sent;
	int rv;

	s = trans_get_out_s(g_con_trans, 8192);
	if (s == 0)
	{
		log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[send_channel_data]: "
				"No client RDP client");
		return 1;
	}
	rv = 0;
	sent = 0;
	total_size = size;
	while (sent < total_size)
	{
		size = MIN(1600, total_size - sent);
		chan_flags = 0;
		if (sent == 0)
		{
			chan_flags |= 1; /* first */
		}
		if (size + sent == total_size)
		{
			chan_flags |= 2; /* last */
		}
		out_uint32_le(s, 0); /* version */
		out_uint32_le(s, 8 + 8 + 2 + 2 + 2 + 4 + size); /* size */
		out_uint32_le(s, 8); /* msg id */
		out_uint32_le(s, 8 + 2 + 2 + 2 + 4 + size); /* size */
		out_uint16_le(s, chan_id);
		out_uint16_le(s, chan_flags);
		out_uint16_le(s, size);
		out_uint32_le(s, total_size);
		out_uint8a(s, data + sent, size);
		s_mark_end(s);
		rv = trans_force_write(g_con_trans);
		if (rv != 0)
		{
			break;
		}

		sent += size;
		s = trans_get_out_s(g_con_trans, 8192);
	}
	return rv;
}
Пример #21
0
void rdp_out_draw_gdiplus_capset(STREAM s)
{
	capsetHeaderRef header;

	header = rdp_skip_capset_header(s);
	out_uint32_le(s, DRAW_GDIPLUS_DEFAULT); /* drawGDIPlusSupportLevel */
	out_uint32_le(s, 0); /* gdipVersion, build number for the GDI+ 1.1 subsystem */
	out_uint32_le(s, DRAW_GDIPLUS_CACHE_LEVEL_DEFAULT); /* drawGdiplusCacheLevel */
	rdp_out_gdiplus_cache_entries(s); /* gdipCacheEntries */
	rdp_out_gdiplus_cache_chunk_size(s); /* gdipCacheChunkSize */
	rdp_out_gdiplus_image_cache_properties(s); /* gdipImageCacheProperties */
	rdp_out_capset_header(s, header, CAPSET_TYPE_DRAWGDIPLUS);
}
Пример #22
0
STREAM
surface_codec_cap(rdpRdp * rdp, uint8 * codec_guid, int codec_id,
	uint8 * codec_property, int codec_properties_size)
{
	STREAM s;

	s = 0;
	if (memcmp(codec_guid, g_rfx_guid, 16) == 0)
	{
		//printf("got remotefx guid\n");
		if (rdp->settings->rfx_flags)
		{
			s = stream_new(1024);
			out_uint8a(s, g_rfx_guid, 16);
			out_uint8(s, codec_id);
			out_uint16_le(s, 29 + 12);
			out_uint32_le(s, 29 + 12); /* total size */
			out_uint32_le(s, 0x00000000); /* Capture Flags */
			out_uint32_le(s, 29); /* size after this */
			/* struct CbyCaps */
			out_uint16_le(s, 0xcbc0); /* CBY_CAPS */
			out_uint32_le(s, 8); /* size of this struct */
			out_uint16_le(s, 1); /* numCapsets */
			/* struct ClyCapset */
			out_uint16_le(s, 0xcbc1); /* CBY_CAPSET */
			out_uint32_le(s, 21); /* size of this struct */
			out_uint8(s, 1); /* codec id */
			out_uint16_le(s, 0xcfc0); /* CLY_CAPSET */
			out_uint16_le(s, 1); /* numIcaps */
			out_uint16_le(s, 8); /* icapLen */
			/* 64x64 tiles */
			out_uint16_le(s, 0x100); /* version */
			out_uint16_le(s, 64); /* tile size */
			out_uint8(s, 0); /* flags */
			out_uint8(s, 1); /* colConvBits */
			out_uint8(s, 1); /* transformBits */
			out_uint8(s, 1); /* entropyBits */
			s_mark_end(s);
		}
	}
	else if (memcmp(codec_guid, g_nsc_guid, 16) == 0)
	{
		//printf("got nscodec guid\n");
	}
	else
	{
		//printf("unknown guid\n");
		hexdump(codec_guid, 16);
	}
	return s;
}
Пример #23
0
/* Output order capability set */
static void rdp_out_order_caps(STREAM s) {
	uint8 order_caps[32];

	memset(order_caps, 0, 32);
	order_caps[0] = 1; /* dest blt */
	order_caps[1] = 1; /* pat blt */
	order_caps[2] = 1; /* screen blt */
	order_caps[3] = (g_bitmap_cache ? 1 : 0); /* memblt */
	order_caps[4] = 0; /* triblt */
	order_caps[8] = 1; /* line */
	order_caps[9] = 1; /* line */
	order_caps[10] = 1; /* rect */
	order_caps[11] = (g_desktop_save ? 1 : 0); /* desksave */
	order_caps[13] = 1; /* memblt */
	order_caps[14] = 1; /* triblt */
	order_caps[20] = (g_polygon_ellipse_orders ? 1 : 0); /* polygon */
	order_caps[21] = (g_polygon_ellipse_orders ? 1 : 0); /* polygon2 */
	order_caps[22] = 1; /* polyline */
	order_caps[25] = (g_polygon_ellipse_orders ? 1 : 0); /* ellipse */
	order_caps[26] = (g_polygon_ellipse_orders ? 1 : 0); /* ellipse2 */
	order_caps[27] = 1; /* text2 */
	out_uint16_le(s, RDP_CAPSET_ORDER);
	out_uint16_le(s, RDP_CAPLEN_ORDER);

	out_uint8s(s, 20);
	/* Terminal desc, pad */
	out_uint16_le(s, 1);
	/* Cache X granularity */
	out_uint16_le(s, 20);
	/* Cache Y granularity */
	out_uint16(s, 0);
	/* Pad */
	out_uint16_le(s, 1);
	/* Max order level */
	out_uint16_le(s, 0x147);
	/* Number of fonts */
	out_uint16_le(s, 0x2a);
	/* Capability flags */
	out_uint8p(s, order_caps, 32);
	/* Orders supported */
	out_uint16_le(s, 0x6a1);
	/* Text capability flags */
	out_uint8s(s, 6);
	/* Pad */
	out_uint32_le(s, g_desktop_save == False ? 0 : 0x38400);
	/* Desktop cache size */
	out_uint32(s, 0);
	/* Unknown */
	out_uint32_le(s, 0x4e4);
	/* Unknown */
}
Пример #24
0
/* Send persistent bitmap cache enumeration PDU's */
static BOOL
rdp_enum_bmpcache2(RDPCLIENT * This) // THIS
{
	STREAM s;
	HASH_KEY keylist[BMPCACHE2_NUM_PSTCELLS];
	uint32 num_keys, offset, count, flags;

	offset = 0;
	num_keys = pstcache_enumerate(This, 2, keylist);

	while (offset < num_keys)
	{
		count = MIN(num_keys - offset, 169);

		s = rdp_init_data(This, 24 + count * sizeof(HASH_KEY));

		if(s == NULL)
			return False;

		flags = 0;
		if (offset == 0)
			flags |= PDU_FLAG_FIRST;
		if (num_keys - offset <= 169)
			flags |= PDU_FLAG_LAST;

		/* header */
		out_uint32_le(s, 0);
		out_uint16_le(s, count);
		out_uint16_le(s, 0);
		out_uint16_le(s, 0);
		out_uint16_le(s, 0);
		out_uint16_le(s, 0);
		out_uint16_le(s, num_keys);
		out_uint32_le(s, 0);
		out_uint32_le(s, flags);

		/* list */
		out_uint8a(s, keylist[offset], count * sizeof(HASH_KEY));

		s_mark_end(s);
		if(!rdp_send_data(This, s, 0x2b))
			return False;

		offset += 169;
	}

	return True;
}
Пример #25
0
/* Output brush cache capability set */
static void
rdp_out_brushcache_caps(STREAM s)
{
    out_uint16_le(s, RDP_CAPSET_BRUSHCACHE);
    out_uint16_le(s, RDP_CAPLEN_BRUSHCACHE);
    out_uint32_le(s, 1);	/* cache type */
}
Пример #26
0
static int
rdpup_send_msg(struct stream* s)
{
  int len;
  int rv;

  rv = 1;
  if (s != 0)
  {
    len = s->end - s->data;
    if (len > s->size)
    {
      rdpLog("overrun error len %d count %d\n", len, g_count);
    }
    s_pop_layer(s, iso_hdr);
    out_uint16_le(s, 1);
    out_uint16_le(s, g_count);
    out_uint32_le(s, len - 8);
    rv = rdpup_send(s->data, len);
  }
  if (rv != 0)
  {
    rdpLog("error in rdpup_send_msg\n");
  }
  return rv;
}
Пример #27
0
void cliprdr_send_data(int request_type)
{
	struct stream* s;
	int clipboard_size = clipboard_get_current_clipboard_data_size(&clipboard, format_utf8_string_atom);
	char* clipboard_data = (char*)clipboard_get_current_clipboard_data(&clipboard, format_utf8_string_atom);

	int uni_clipboard_len = (clipboard_size+1)*2;
	int packet_len = uni_clipboard_len + 12;
	char* temp;

	make_stream(s);
	init_stream(s,packet_len);

	log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[cliprdr_send_data]:");
	/* clip header */
	out_uint16_le(s, CB_FORMAT_DATA_RESPONSE);             /* msg type */
	out_uint16_le(s, 0);                                   /* msg flag */
	out_uint32_le(s, uni_clipboard_len);                   /* msg size */
	temp = s->p;
	uni_rdp_out_str(s, clipboard_data, uni_clipboard_len);


	s_mark_end(s);
	cliprdr_send(s);
	free_stream(s);

}
Пример #28
0
/* Send a confirm active PDU */
static void rdp_send_confirm_active(void) {
	STREAM s;
	uint32 sec_flags = g_encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG;
	uint16 caplen = RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER
			+ RDP_CAPLEN_COLCACHE + RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL
			+ RDP_CAPLEN_SHARE + RDP_CAPLEN_BRUSHCACHE + 0x58 + 0x08 + 0x08
			+ 0x34 /* unknown caps */+ 4 /* w2k fix, sessionid */;

	if (g_use_rdp5) {
		caplen += RDP_CAPLEN_BMPCACHE2;
		caplen += RDP_CAPLEN_NEWPOINTER;
	} else {
		caplen += RDP_CAPLEN_BMPCACHE;
		caplen += RDP_CAPLEN_POINTER;
	}

	s = sec_init(sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE));

	out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE));
	out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10));
	/* Version 1 */
	out_uint16_le(s, (g_mcs_userid + 1001));

	out_uint32_le(s, g_rdp_shareid);
	out_uint16_le(s, 0x3ea);
	/* userid */
	out_uint16_le(s, sizeof(RDP_SOURCE));
	out_uint16_le(s, caplen);

	out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));
	out_uint16_le(s, 0xe);
	/* num_caps */
	out_uint8s(s, 2);
	/* pad */

	rdp_out_general_caps(s);
	rdp_out_bitmap_caps(s);
	rdp_out_order_caps(s);
	if (g_use_rdp5) {
		rdp_out_bmpcache2_caps(s);
		rdp_out_newpointer_caps(s);
	} else {
		rdp_out_bmpcache_caps(s);
		rdp_out_pointer_caps(s);
	}
	rdp_out_colcache_caps(s);
	rdp_out_activate_caps(s);
	rdp_out_control_caps(s);
	rdp_out_share_caps(s);
	rdp_out_brushcache_caps(s);

	rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* CAPSTYPE_INPUT */
	rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c); /* CAPSTYPE_SOUND */
	rdp_out_unknown_caps(s, 0x0e, 0x08, caps_0x0e); /* CAPSTYPE_FONT */
	rdp_out_unknown_caps(s, 0x10, 0x34, caps_0x10); /* CAPSTYPE_GLYPHCACHE */

	s_mark_end(s);
	sec_send(s, sec_flags);
}
Пример #29
0
/* flags can contain WINDOW_ORDER_STATE_NEW and/or
   WINDOW_ORDER_FIELD_ICON_BIG */
int
xrdp_orders_send_window_icon(struct xrdp_orders *self,
                             int window_id, int cache_entry, int cache_id,
                             struct rail_icon_info *icon_info,
                             int flags)
{
    int order_size;
    int order_flags;
    int field_present_flags;
    int use_cmap;

    use_cmap = 0;

    if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
    {
        use_cmap = 1;
    }

    order_size = 23 + icon_info->mask_bytes + icon_info->data_bytes;

    if (use_cmap)
    {
        order_size += icon_info->cmap_bytes + 2;
    }

    if (xrdp_orders_check(self, order_size) != 0)
    {
        return 1;
    }
    self->order_count++;
    order_flags = RDP_ORDER_SECONDARY;
    order_flags |= 0xb << 2; /* type TS_ALTSEC_WINDOW */
    out_uint8(self->out_s, order_flags);
    /* orderSize (2 bytes) */
    out_uint16_le(self->out_s, order_size);
    /* FieldsPresentFlags (4 bytes) */
    field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW |
                          WINDOW_ORDER_ICON;
    out_uint32_le(self->out_s, field_present_flags);
    /* windowId (4 bytes) */
    out_uint32_le(self->out_s, window_id);

    xrdp_orders_send_ts_icon(self->out_s, cache_entry, cache_id, icon_info);

    return 0;
}
Пример #30
0
static int APP_CC
xrdp_mm_chan_send_init(struct xrdp_mm* self)
{
  struct stream* s = (struct stream *)NULL;

  s = trans_get_out_s(self->chan_trans, 8192);
  if (s == 0)
  {
    return 1;
  }
  out_uint32_le(s, 0); /* version */
  out_uint32_le(s, 8 + 8); /* size */
  out_uint32_le(s, 1); /* msg id */
  out_uint32_le(s, 8); /* size */
  s_mark_end(s);
  return trans_force_write(self->chan_trans);
}