Exemplo n.º 1
0
static void audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
	AudinALSADevice* alsa = (AudinALSADevice*) device;

	DEBUG_DVC("");

	alsa->receive = receive;
	alsa->user_data = user_data;

	freerdp_thread_start(alsa->thread, audin_alsa_thread_func, alsa);
}
Exemplo n.º 2
0
boolean tf_peer_post_connect(freerdp_peer* client)
{
	int i;
	testPeerContext* context = (testPeerContext*) client->context;

	/**
	 * This callback is called when the entire connection sequence is done, i.e. we've received the
	 * Font List PDU from the client and sent out the Font Map PDU.
	 * The server may start sending graphics output and receiving keyboard/mouse input after this
	 * callback returns.
	 */
	printf("Client %s is activated (osMajorType %d osMinorType %d)", client->hostname,
		client->settings->os_major_type, client->settings->os_minor_type);
	if (client->settings->autologon)
	{
		printf(" and wants to login automatically as %s\\%s",
			client->settings->domain ? client->settings->domain : "",
			client->settings->username);

		/* A real server may perform OS login here if NLA is not executed previously. */
	}
	printf("\n");

	printf("Client requested desktop: %dx%dx%d\n",
		client->settings->width, client->settings->height, client->settings->color_depth);

	/* A real server should tag the peer as activated here and start sending updates in mainloop. */
	test_peer_load_icon(client);

	/* Iterate all channel names requested by the client and activate those supported by the server */
	for (i = 0; i < client->settings->num_channels; i++)
	{
		if (client->settings->channels[i].joined)
		{
			if (strncmp(client->settings->channels[i].name, "rdpdbg", 6) == 0)
			{
				context->debug_channel = WTSVirtualChannelOpenEx(context->vcm, "rdpdbg", 0);
				if (context->debug_channel != NULL)
				{
					printf("Open channel rdpdbg.\n");
					context->debug_channel_thread = freerdp_thread_new();
					freerdp_thread_start(context->debug_channel_thread,
						tf_debug_channel_thread_func, context);
				}
			}
		}
	}

	/* Return false here would stop the execution of the peer mainloop. */
	return true;
}
Exemplo n.º 3
0
static void
scard_irp_request(DEVICE* device, IRP* irp)
{
	COMPLETIONIDINFO* CompletionIdInfo;

	SCARD_DEVICE* scard = (SCARD_DEVICE*)device;

	/* Begin TS Client defect workaround. */
	CompletionIdInfo= xnew(COMPLETIONIDINFO);
	CompletionIdInfo->ID = irp->CompletionId;/* "duplicate" member is set 
	                                          * to false by "xnew()"
	                                          */
	freerdp_mutex_lock(scard->CompletionIdsMutex);
	scard_mark_duplicate_id(scard, irp->CompletionId);
	list_enqueue(scard->CompletionIds, CompletionIdInfo);
	freerdp_mutex_unlock(scard->CompletionIdsMutex);

	irp->Complete = scard_irp_complete;	/* Overwrite the previous
						 * assignment made in 
						 * "irp_new()".
						 */
	/* End TS Client defect workaround. */

	if (irp->MajorFunction == IRP_MJ_DEVICE_CONTROL &&
			scard_async_op(irp))
	{
		/*
		 * certain potentially long running operations
		 * get their own thread
		 * TODO: revise this mechanism.. maybe worker pool
		 */
		struct scard_irp_thread_args *args = xmalloc(sizeof(struct scard_irp_thread_args));


		args->thread = freerdp_thread_new();
		args->scard = scard;
		args->irp = irp;
		freerdp_thread_start(args->thread, scard_process_irp_thread_func, args);

		return;
	}

	freerdp_thread_lock(scard->thread);
	list_enqueue(scard->irp_list, irp);
	freerdp_thread_unlock(scard->thread);

	freerdp_thread_signal(scard->thread);
}
Exemplo n.º 4
0
static void svc_plugin_process_connected(rdpSvcPlugin* plugin, void* pData, uint32 dataLength)
{
	uint32 error;

	error = plugin->channel_entry_points.pVirtualChannelOpen(plugin->priv->init_handle,
		&plugin->priv->open_handle, plugin->channel_def.name, svc_plugin_open_event);

	if (error != CHANNEL_RC_OK)
	{
		printf("svc_plugin_process_connected: open failed\n");
		return;
	}

	plugin->priv->data_in_list = list_new();
	plugin->priv->thread = freerdp_thread_new();

	freerdp_thread_start(plugin->priv->thread, svc_plugin_thread_func, plugin);
}
Exemplo n.º 5
0
static boolean audin_server_open(audin_server_context* context)
{
	audin_server* audin = (audin_server*) context;

	if (audin->audin_channel_thread == NULL)
	{
		audin->audin_channel = WTSVirtualChannelOpenEx(context->vcm, "AUDIO_INPUT", WTS_CHANNEL_OPTION_DYNAMIC);
		if (audin->audin_channel == NULL)
			return false;

		audin->audin_channel_thread = freerdp_thread_new();
		freerdp_thread_start(audin->audin_channel_thread, audin_server_thread_func, audin);

		return true;
	}

	return false;
}
Exemplo n.º 6
0
static boolean rdpsnd_server_initialize(rdpsnd_server_context* context)
{
	rdpsnd_server* rdpsnd = (rdpsnd_server*) context;

	rdpsnd->rdpsnd_channel = WTSVirtualChannelOpenEx(context->vcm, "rdpsnd", 0);
	if (rdpsnd->rdpsnd_channel != NULL)
	{
		rdpsnd->rdpsnd_pdu = stream_new(4096);
		rdpsnd->rdpsnd_channel_thread = freerdp_thread_new();
		freerdp_thread_start(rdpsnd->rdpsnd_channel_thread, rdpsnd_server_thread_func, rdpsnd);

		return true;
	}
	else
	{
		return false;
	}
}
Exemplo n.º 7
0
int
DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
	SCARD_DEVICE* scard;
	char* name;
	char* path;
	int i, length;

	name = (char *)pEntryPoints->plugin_data->data[1];
	path = (char *)pEntryPoints->plugin_data->data[2];

	if (name)
	{
		/* TODO: check if server supports sc redirect (version 5.1) */

		scard = xnew(SCARD_DEVICE);

		scard->device.type = RDPDR_DTYP_SMARTCARD;
		scard->device.name = "SCARD";
		scard->device.IRPRequest = scard_irp_request;
		scard->device.Free = scard_free;

		length = strlen(scard->device.name);
		scard->device.data = stream_new(length + 1);

		for (i = 0; i <= length; i++)
			stream_write_uint8(scard->device.data, name[i] < 0 ? '_' : name[i]);

		scard->path = path;

		scard->irp_list = list_new();
		scard->thread = freerdp_thread_new();

		scard->CompletionIds = list_new();
		scard->CompletionIdsMutex = freerdp_mutex_new();

		pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE *)scard);

		freerdp_thread_start(scard->thread, scard_thread_func, scard);
	}

	return 0;
}
Exemplo n.º 8
0
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
	char* name;
	char* path;
	int i, length;
	RDPDR_PARALLEL* device;
	PARALLEL_DEVICE* parallel;

	device = (RDPDR_PARALLEL*) pEntryPoints->device;
	name = device->Name;
	path = device->Path;

	if (name[0] && path[0])
	{
		parallel = (PARALLEL_DEVICE*) malloc(sizeof(PARALLEL_DEVICE));
		ZeroMemory(parallel, sizeof(PARALLEL_DEVICE));

		parallel->device.type = RDPDR_DTYP_PARALLEL;
		parallel->device.name = name;
		parallel->device.IRPRequest = parallel_irp_request;
		parallel->device.Free = parallel_free;

		length = strlen(name);
		parallel->device.data = stream_new(length + 1);

		for (i = 0; i <= length; i++)
			stream_write_BYTE(parallel->device.data, name[i] < 0 ? '_' : name[i]);

		parallel->path = path;

		parallel->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
		InitializeSListHead(parallel->pIrpList);

		parallel->thread = freerdp_thread_new();

		pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);

		freerdp_thread_start(parallel->thread, parallel_thread_func, parallel);
	}

	return 0;
}
Exemplo n.º 9
0
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
    SERIAL_DEVICE* serial;
    char* name;
    char* path;
    int i, len;

    name = (char*)pEntryPoints->plugin_data->data[1];
    path = (char*)pEntryPoints->plugin_data->data[2];

    if (name[0] && path[0])
    {
        serial = xnew(SERIAL_DEVICE);

        serial->device.type = RDPDR_DTYP_SERIAL;
        serial->device.name = name;
        serial->device.IRPRequest = serial_irp_request;
        serial->device.Free = serial_free;

        len = strlen(name);
        serial->device.data = stream_new(len + 1);
        for (i = 0; i <= len; i++)
            stream_write_uint8(serial->device.data, name[i] < 0 ? '_' : name[i]);

        serial->path = path;
        serial->irp_list = list_new();
        serial->pending_irps = list_new();
        serial->thread = freerdp_thread_new();
        serial->in_event = wait_obj_new();

        pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)serial);

        freerdp_thread_start(serial->thread, serial_thread_func, serial);
    }

    return 0;
}
Exemplo n.º 10
0
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
    char* name;
    char* path;
    int i, length;
    PARALLEL_DEVICE* parallel;

    name = (char*) pEntryPoints->plugin_data->data[1];
    path = (char*) pEntryPoints->plugin_data->data[2];

    if (name[0] && path[0])
    {
        parallel = xnew(PARALLEL_DEVICE);

        parallel->device.type = RDPDR_DTYP_PARALLEL;
        parallel->device.name = name;
        parallel->device.IRPRequest = parallel_irp_request;
        parallel->device.Free = parallel_free;

        length = strlen(name);
        parallel->device.data = stream_new(length + 1);

        for (i = 0; i <= length; i++)
            stream_write_uint8(parallel->device.data, name[i] < 0 ? '_' : name[i]);

        parallel->path = path;

        parallel->irp_list = list_new();
        parallel->thread = freerdp_thread_new();

        pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);

        freerdp_thread_start(parallel->thread, parallel_thread_func, parallel);
    }

    return 0;
}
Exemplo n.º 11
0
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer) {
	PRINTER_DEVICE* printer_dev;
	char* port;
	UNICONV* uniconv;
	uint32 Flags;
	size_t DriverNameLen;
	char* DriverName;
	size_t PrintNameLen;
	char* PrintName;
	uint32 CachedFieldsLen;
	uint8* CachedPrinterConfigData;

	port = xmalloc(10);
	snprintf(port, 10, "PRN%d", printer->id);

	printer_dev = xnew(PRINTER_DEVICE);

	printer_dev->device.type = RDPDR_DTYP_PRINT;
	printer_dev->device.name = port;
	printer_dev->device.IRPRequest = printer_irp_request;
	printer_dev->device.Free = printer_free;

	printer_dev->printer = printer;

	CachedFieldsLen = 0;
	CachedPrinterConfigData = NULL;

	log_debug("Printer '%s' registered", printer->name);

	Flags = 0;
	if (printer->is_default)
		Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;

	uniconv = freerdp_uniconv_new();
	DriverName = freerdp_uniconv_out(uniconv, printer->driver, &DriverNameLen);
	PrintName = freerdp_uniconv_out(uniconv, printer->name, &PrintNameLen);
	freerdp_uniconv_free(uniconv);

	printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);

	stream_write_uint32(printer_dev->device.data, Flags);
	stream_write_uint32(printer_dev->device.data, 0);
	/* CodePage, reserved */
	stream_write_uint32(printer_dev->device.data, 0);
	/* PnPNameLen */
	stream_write_uint32(printer_dev->device.data, DriverNameLen + 2);
	stream_write_uint32(printer_dev->device.data, PrintNameLen + 2);
	stream_write_uint32(printer_dev->device.data, CachedFieldsLen);
	stream_write(printer_dev->device.data, DriverName, DriverNameLen);
	stream_write_uint16(printer_dev->device.data, 0);
	stream_write(printer_dev->device.data, PrintName, PrintNameLen);
	stream_write_uint16(printer_dev->device.data, 0);
	if (CachedFieldsLen > 0) {
		stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);
	}

	xfree(DriverName);
	xfree(PrintName);

	printer_dev->irp_list = list_new();
	printer_dev->thread = freerdp_thread_new();

	pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) printer_dev);

	freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev);
}
Exemplo n.º 12
0
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
{
    char* port;
    UINT32 Flags;
    int DriverNameLen;
    WCHAR* DriverName = NULL;
    int PrintNameLen;
    WCHAR* PrintName = NULL;
    UINT32 CachedFieldsLen;
    BYTE* CachedPrinterConfigData;
    PRINTER_DEVICE* printer_dev;

    port = malloc(10);
    snprintf(port, 10, "PRN%d", printer->id);

    printer_dev = (PRINTER_DEVICE*) malloc(sizeof(PRINTER_DEVICE));
    ZeroMemory(printer_dev, sizeof(PRINTER_DEVICE));

    printer_dev->device.type = RDPDR_DTYP_PRINT;
    printer_dev->device.name = port;
    printer_dev->device.IRPRequest = printer_irp_request;
    printer_dev->device.Free = printer_free;

    printer_dev->printer = printer;

    CachedFieldsLen = 0;
    CachedPrinterConfigData = NULL;

    DEBUG_SVC("Printer %s registered", printer->name);

    Flags = 0;

    if (printer->is_default)
        Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;

    DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, &DriverName, 0) * 2;
    PrintNameLen = ConvertToUnicode(CP_UTF8, 0, printer->name, -1, &PrintName, 0) * 2;

    printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);

    stream_write_UINT32(printer_dev->device.data, Flags);
    stream_write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */
    stream_write_UINT32(printer_dev->device.data, 0); /* PnPNameLen */
    stream_write_UINT32(printer_dev->device.data, DriverNameLen + 2);
    stream_write_UINT32(printer_dev->device.data, PrintNameLen + 2);
    stream_write_UINT32(printer_dev->device.data, CachedFieldsLen);
    stream_write(printer_dev->device.data, DriverName, DriverNameLen);
    stream_write_UINT16(printer_dev->device.data, 0);
    stream_write(printer_dev->device.data, PrintName, PrintNameLen);
    stream_write_UINT16(printer_dev->device.data, 0);

    if (CachedFieldsLen > 0)
    {
        stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);
    }

    free(DriverName);
    free(PrintName);

    printer_dev->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
    InitializeSListHead(printer_dev->pIrpList);

    printer_dev->thread = freerdp_thread_new();

    pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) printer_dev);

    freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev);
}
Exemplo n.º 13
0
BOOL tf_peer_post_connect(freerdp_peer* client)
{
	int i;
	testPeerContext* context = (testPeerContext*) client->context;

	/**
	 * This callback is called when the entire connection sequence is done, i.e. we've received the
	 * Font List PDU from the client and sent out the Font Map PDU.
	 * The server may start sending graphics output and receiving keyboard/mouse input after this
	 * callback returns.
	 */

	printf("Client %s is activated (osMajorType %d osMinorType %d)", client->local ? "(local)" : client->hostname,
			client->settings->OsMajorType, client->settings->OsMinorType);

	if (client->settings->AutoLogonEnabled)
	{
		printf(" and wants to login automatically as %s\\%s",
			client->settings->Domain ? client->settings->Domain : "",
			client->settings->Username);

		/* A real server may perform OS login here if NLA is not executed previously. */
	}
	printf("\n");

	printf("Client requested desktop: %dx%dx%d\n",
		client->settings->DesktopWidth, client->settings->DesktopHeight, client->settings->ColorDepth);

	/* A real server should tag the peer as activated here and start sending updates in main loop. */
	test_peer_load_icon(client);

	/* Iterate all channel names requested by the client and activate those supported by the server */

	for (i = 0; i < client->settings->ChannelCount; i++)
	{
		if (client->settings->ChannelDefArray[i].joined)
		{
			if (strncmp(client->settings->ChannelDefArray[i].Name, "rdpdbg", 6) == 0)
			{
				context->debug_channel = WTSVirtualChannelOpenEx(context->vcm, "rdpdbg", 0);

				if (context->debug_channel != NULL)
				{
					printf("Open channel rdpdbg.\n");
					context->debug_channel_thread = freerdp_thread_new();
					freerdp_thread_start(context->debug_channel_thread,
						tf_debug_channel_thread_func, context);
				}
			}
			else if (strncmp(client->settings->ChannelDefArray[i].Name, "rdpsnd", 6) == 0)
			{
				sf_peer_rdpsnd_init(context); /* Audio Output */
			}
		}
	}

	/* Dynamic Virtual Channels */

	sf_peer_audin_init(context); /* Audio Input */

	/* Return FALSE here would stop the execution of the peer main loop. */

	return TRUE;
}