예제 #1
0
void test_drdynvc(void)
{
	rdpChanMan* chan_man;
	rdpSettings settings = { 0 };
	freerdp instance = { 0 };

	settings.hostname = "testhost";
	instance.settings = &settings;
	instance.ChannelDataInput = test_rdp_channel_data;

	chan_man = freerdp_chanman_new();

	freerdp_chanman_load_plugin(chan_man, &settings, "../channels/drdynvc/drdynvc.so", NULL);
	freerdp_chanman_pre_connect(chan_man, &instance);
	freerdp_chanman_post_connect(chan_man, &instance);

	/* server sends capability request PDU */
	freerdp_chanman_data(&instance, 0, (char*)test_capability_request_data, sizeof(test_capability_request_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_capability_request_data) - 1);

	/* drdynvc sends capability response PDU to server */
	data_received = 0;
	while (!data_received)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	freerdp_chanman_close(chan_man, &instance);
	freerdp_chanman_free(chan_man);
}
예제 #2
0
int freerdp_chanman_global_uninit(void)
{
	while (g_chan_man_list)
		freerdp_chanman_free(g_chan_man_list->chan_man);

	freerdp_mutex_free(g_mutex_init);
	freerdp_mutex_free(g_mutex_list);

	return 0;
}
예제 #3
0
파일: dfbfreerdp.c 프로젝트: DrTusk/FreeRDP
int
main(int argc, char ** argv)
{
	struct thread_data * data;
	int rv;
	pthread_t thread;
	int index = 1;

	setlocale(LC_CTYPE, "");

	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	dfb_init(&argc, &argv);
	dfb_kb_init();

	while (1)
	{
		data = (struct thread_data *) malloc(sizeof(struct thread_data));
		data->settings = (rdpSet *) malloc(sizeof(rdpSet));
		data->chan_man = freerdp_chanman_new();
		rv = process_params(data->settings, data->chan_man, argc, argv, &index);
		if (rv == 0)
		{
			g_thread_count++;
			printf("starting thread %d to %s:%d\n", g_thread_count,
				data->settings->server, data->settings->tcp_port_rdp);
			pthread_create(&thread, 0, thread_func, data);
		}
		else
		{
			free(data->settings);
			freerdp_chanman_free(data->chan_man);
			free(data);
			break;
		}
	}

	while (g_thread_count > 0)
	{
		sleep(1);
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	return 0;
}
예제 #4
0
int
freerdp_chanman_uninit(void)
{
	while (g_chan_man_list)
	{
		freerdp_chanman_free(g_chan_man_list->chan_man);
	}

	MUTEX_DESTROY(g_mutex_init);
	MUTEX_DESTROY(g_mutex_list);

	return 0;
}
예제 #5
0
파일: dfbfreerdp.c 프로젝트: alama/freerdp
static void *
thread_func(void * arg)
{
	struct thread_data * data;
	data = (struct thread_data *) arg;
	
	run_dfbfreerdp(data->settings, data->chan_man);
	
	free(data->settings);
	freerdp_chanman_free(data->chan_man);
	free(data);

	pthread_detach(pthread_self());
	g_thread_count--;

	return NULL;
}
예제 #6
0
static void *
thread_func(void * arg)
{
	xfInfo * xfi;

	xfi = (xfInfo *) arg;
	g_error_code = run_xfreerdp(xfi);
	free(xfi->settings);
	freerdp_chanman_free(xfi->chan_man);
	free(xfi);

	pthread_detach(pthread_self());
	g_thread_count--;
	if (g_thread_count < 1)
	{
		freerdp_sem_signal(&g_sem);
	}
	return NULL;
}
예제 #7
0
INT WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    int rv;
    int index = 1;
    wfInfo * wfi;
    WSADATA wsa_data;
    WNDCLASSEX wnd_cls;

    if (WSAStartup(0x101, &wsa_data) != 0)
    {
        return 1;
    }
    g_done_event = CreateEvent(0, 1, 0, 0);
#if defined(WITH_DEBUG) || defined(_DEBUG)
    create_console();
#endif
    if (!freerdp_global_init())
    {
        printf("Error initializing freerdp\n");
        return 1;
    }
    freerdp_chanman_init();
    g_default_cursor = LoadCursor(NULL, IDC_ARROW);

    wnd_cls.cbSize        = sizeof(WNDCLASSEX);
    wnd_cls.style         = CS_HREDRAW | CS_VREDRAW;
    wnd_cls.lpfnWndProc   = wf_event_proc;
    wnd_cls.cbClsExtra    = 0;
    wnd_cls.cbWndExtra    = 0;
    wnd_cls.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wnd_cls.hCursor       = g_default_cursor;
    wnd_cls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wnd_cls.lpszMenuName  = NULL;
    wnd_cls.lpszClassName = g_wnd_class_name;
    wnd_cls.hInstance     = hInstance;
    wnd_cls.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    RegisterClassEx(&wnd_cls);

    g_hInstance = hInstance;

    if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
        printf("error creating keyboard handler thread");

    while (1)
    {
        wfi = (wfInfo *) malloc(sizeof(wfInfo));
        memset(wfi, 0, sizeof(wfInfo));
        wfi->settings = (rdpSet *) malloc(sizeof(rdpSet));
        wfi->chan_man = freerdp_chanman_new();

        wfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
        memset(wfi->clrconv, 0, sizeof(CLRCONV));
        wfi->clrconv->alpha = 1;
        wfi->clrconv->palette = NULL;

        rv = process_params(wfi, __argc, __argv, &index);
        if (rv)
        {
            freerdp_chanman_free(wfi->chan_man);
            free(wfi->settings);
            free(wfi);
            break;
        }
        if (CreateThread(NULL, 0, thread_func, wfi, 0, NULL) != 0)
        {
            g_thread_count++;
        }
    }

    if (g_thread_count > 0)
        WaitForSingleObject(g_done_event, INFINITE);
    else
        MessageBox(GetConsoleWindow(),
                   L"Failed to start wfreerdp.\n\nPlease check the debug output.",
                   L"FreeRDP Error", MB_ICONSTOP);

    freerdp_chanman_uninit();
    freerdp_global_finish();
    WSACleanup();
    return 0;
}
예제 #8
0
static int
run_wfreerdp(wfInfo * wfi)
{
    rdpInst * inst;
    void * read_fds[32];
    void * write_fds[32];
    int read_count;
    int write_count;
    int index;
    HANDLE fds[64];
    int fds_count;
    int gmcode;
    int alldone;
    MSG msg;

    DEBUG("run_wfreerdp:\n");
    /* create an instance of the library */
    wfi->inst = inst = freerdp_new(wfi->settings);
    if (inst == NULL)
    {
        printf("run_wfreerdp: freerdp_new failed\n");
        return 1;
    }
    SET_WFI(inst, wfi);

    if ((inst->version != FREERDP_INTERFACE_VERSION) ||
            (inst->size != sizeof(rdpInst)))
    {
        printf("run_wfreerdp: freerdp_new size, version / size do not "
               "match expecting v %d s %d got v %d s %d\n",
               FREERDP_INTERFACE_VERSION, sizeof(rdpInst),
               inst->version, inst->size);
        return 1;
    }

    inst->settings->keyboard_layout = (int)GetKeyboardLayout(0) & 0x0000FFFF;
    printf("keyboard_layout: 0x%X\n", inst->settings->keyboard_layout);

    if (wf_pre_connect(wfi) != 0)
    {
        printf("run_wfreerdp: wf_pre_connect failed\n");
        return 1;
    }
    if (freerdp_chanman_pre_connect(wfi->chan_man, inst) != 0)
    {
        printf("run_wfreerdp: freerdp_chanman_pre_connect failed\n");
        return 1;
    }
    /* call connect */
    if (inst->rdp_connect(inst) != 0)
    {
        printf("run_wfreerdp: inst->rdp_connect failed\n");
        return 1;
    }
    if (freerdp_chanman_post_connect(wfi->chan_man, inst) != 0)
    {
        printf("run_wfreerdp: freerdp_chanman_post_connect failed\n");
        return 1;
    }
    if (wf_post_connect(wfi) != 0)
    {
        printf("run_wfreerdp: wf_post_connect failed\n");
        return 1;
    }

    /* program main loop */
    while (1)
    {
        read_count = 0;
        write_count = 0;
        /* get libfreerdp fds */
        if (inst->rdp_get_fds(inst, read_fds, &read_count, write_fds, &write_count) != 0)
        {
            printf("run_wfreerdp: inst->rdp_get_fds failed\n");
            break;
        }
        /* get channel fds */
        if (freerdp_chanman_get_fds(wfi->chan_man, inst, read_fds, &read_count, write_fds, &write_count) != 0)
        {
            printf("run_wfreerdp: freerdp_chanman_get_fds failed\n");
            break;
        }
        fds_count = 0;
        /* setup read fds */
        for (index = 0; index < read_count; index++)
        {
            fds[fds_count++] = read_fds[index];
        }
        /* setup write fds */
        for (index = 0; index < write_count; index++)
        {
            fds[fds_count++] = write_fds[index];
        }
        /* exit if nothing to do */
        if (fds_count == 0)
        {
            printf("run_wfreerdp: fds_count is zero\n");
            break;
        }
        /* do the wait */
        if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, INFINITE, QS_ALLINPUT) == WAIT_FAILED)
        {
            printf("run_wfreerdp: WaitForMultipleObjects failed\n");
            break;
        }
        /* check the libfreerdp fds */
        if (inst->rdp_check_fds(inst) != 0)
        {
            printf("run_wfreerdp: inst->rdp_check_fds failed\n");
            break;
        }
        /* check channel fds */
        if (freerdp_chanman_check_fds(wfi->chan_man, inst) != 0)
        {
            printf("run_wfreerdp: freerdp_chanman_check_fds failed\n");
            break;
        }
        alldone = FALSE;
        while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
        {
            gmcode = GetMessage(&msg, 0, 0, 0);
            if (gmcode == 0 || gmcode == -1)
            {
                alldone = TRUE;
                break;
            }
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        if (alldone)
        {
            break;
        }
    }
    /* cleanup */
    wf_uninit(wfi);
    freerdp_chanman_free(wfi->chan_man);
    freerdp_free(inst);
    free(wfi->settings);
    free(wfi);
    return 0;
}
예제 #9
0
int tfreerdp_run(freerdp* instance)
{
	int i;
	int fds;
	int max_fds;
	int rcount;
	int wcount;
	void* rfds[32];
	void* wfds[32];
	fd_set rfds_set;
	fd_set wfds_set;
	rdpChanMan* chanman;

	memset(rfds, 0, sizeof(rfds));
	memset(wfds, 0, sizeof(wfds));

	chanman = GET_CHANMAN(instance);

	instance->Connect(instance);

	while (1)
	{
		rcount = 0;
		wcount = 0;

		if (instance->GetFileDescriptor(instance, rfds, &rcount, wfds, &wcount) != True)
		{
			printf("Failed to get FreeRDP file descriptor\n");
			break;
		}
		if (freerdp_chanman_get_fds(chanman, instance, rfds, &rcount, wfds, &wcount) != True)
		{
			printf("Failed to get channel manager file descriptor\n");
			break;
		}

		max_fds = 0;
		FD_ZERO(&rfds_set);

		for (i = 0; i < rcount; i++)
		{
			fds = (int)(long)(rfds[i]);

			if (fds > max_fds)
				max_fds = fds;

			FD_SET(fds, &rfds_set);
		}

		if (max_fds == 0)
			break;

		if (select(max_fds + 1, &rfds_set, &wfds_set, NULL, NULL) == -1)
		{
			/* these are not really errors */
			if (!((errno == EAGAIN) ||
				(errno == EWOULDBLOCK) ||
				(errno == EINPROGRESS) ||
				(errno == EINTR))) /* signal occurred */
			{
				printf("tfreerdp_run: select failed\n");
				break;
			}
		}

		if (instance->CheckFileDescriptor(instance) != True)
		{
			printf("Failed to check FreeRDP file descriptor\n");
			break;
		}
		if (freerdp_chanman_check_fds(chanman, instance) != True)
		{
			printf("Failed to check channel manager file descriptor\n");
			break;
		}
		tf_process_channel_event(chanman, instance);
	}

	freerdp_chanman_close(chanman, instance);
	freerdp_chanman_free(chanman);
	freerdp_free(instance);

	return 0;
}
예제 #10
0
int
main(int argc, char ** argv)
{
	struct thread_data * data;
	int rv;
	pthread_t thread;
	int index = 1;

	char *home = getenv("HOME");
	if (home) {
		static char resourcefile[512];
		strncat(resourcefile, home, strlen(home));
		resourcefile[512-1] = (char)0;
		strcat(resourcefile, "/.directfbrc");
		resourcefile[512-1] = (char)0;

		char *display = getenv("DISPLAY");

#if   defined(__unix) || defined(__linux)
		char *graphics = "fbdev";
#elif defined(__APPLE__)
		char *graphics = "opengl";
#else
		char *graphics = "gdi";
#endif
		if (display) graphics = "x11";

		static char buffer[128];
		strcat(buffer, "system=");
		strcat(buffer, graphics);
		strcat(buffer, "\ndepth=32\nmode=1024x768\nautoflip-window\nforce-windowed\n");

		FILE *fp;
		fp = fopen(resourcefile, "wx"); /* "x" assures no overwrite of an existing resource file */
		if (fp != NULL)
		{
			fputs((char *)(&buffer), fp);
			fclose(fp);
			printf("INFO: created default DirectFB resource file: %s\n", resourcefile);
		}
	} else {
		printf("WARNING: HOME variable not set, unable to create a default DirectFB ~/.directfbrc resource file\n");
	}

	setlocale(LC_CTYPE, "");

	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	dfb_init(&argc, &argv);
	dfb_kb_init();

	freerdp_sem_create(&g_sem, 0);

	while (1)
	{
		data = (struct thread_data *) xmalloc(sizeof(struct thread_data));
		data->settings = (rdpSet *) xmalloc(sizeof(rdpSet));
		data->chan_man = freerdp_chanman_new();
		rv = process_params(data->settings, data->chan_man, argc, argv, &index);
		if (rv == 0)
		{
			g_thread_count++;
			printf("starting thread %d to %s:%d\n", g_thread_count,
				data->settings->server, data->settings->tcp_port_rdp);
			pthread_create(&thread, 0, thread_func, data);
		}
		else
		{
			free(data->settings);
			freerdp_chanman_free(data->chan_man);
			free(data);
			break;
		}
	}

	while (g_thread_count > 0)
	{
                DEBUG("main thread, waiting for all threads to exit");
                freerdp_sem_wait(&g_sem);
                DEBUG("main thread, all threads did exit");
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	return 0;
}
예제 #11
0
void test_cliprdr(void)
{
	int i;
	rdpChanMan* chan_man;
	rdpSettings settings = { 0 };
	freerdp instance = { 0 };
	FRDP_EVENT* event;
	FRDP_CB_FORMAT_LIST_EVENT* format_list_event;
	FRDP_CB_DATA_REQUEST_EVENT* data_request_event;
	FRDP_CB_DATA_RESPONSE_EVENT* data_response_event;

	settings.hostname = "testhost";
	instance.settings = &settings;
	instance.SendChannelData = test_rdp_channel_data;

	chan_man = freerdp_chanman_new();

	freerdp_chanman_load_plugin(chan_man, &settings, "../channels/cliprdr/cliprdr.so", NULL);
	freerdp_chanman_pre_connect(chan_man, &instance);
	freerdp_chanman_post_connect(chan_man, &instance);

	/* server sends cliprdr capabilities and monitor ready PDU */
	freerdp_chanman_data(&instance, 0, (char*)test_clip_caps_data, sizeof(test_clip_caps_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_clip_caps_data) - 1);

	freerdp_chanman_data(&instance, 0, (char*)test_monitor_ready_data, sizeof(test_monitor_ready_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_monitor_ready_data) - 1);

	/* cliprdr sends clipboard_sync event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_SYNC);
	freerdp_event_free(event);

	/* UI sends format_list event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_FORMAT_LIST, event_process_callback, NULL);
	format_list_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
	format_list_event->num_formats = 2;
	format_list_event->formats = (uint32*)xmalloc(sizeof(uint32) * 2);
	format_list_event->formats[0] = CB_FORMAT_TEXT;
	format_list_event->formats[1] = CB_FORMAT_HTML;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends format list PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* server sends format list response PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_format_list_response_data, sizeof(test_format_list_response_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_response_data) - 1);

	/* server sends format list PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_format_list_data, sizeof(test_format_list_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_data) - 1);

	/* cliprdr sends format_list event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_FORMAT_LIST);
	if (event->event_type == FRDP_EVENT_TYPE_CB_FORMAT_LIST)
	{
		format_list_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
		for (i = 0; i < format_list_event->num_formats; i++)
			printf("Format: 0x%X\n", format_list_event->formats[i]);
	}
	freerdp_event_free(event);

	/* server sends data request PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_data_request_data, sizeof(test_data_request_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_request_data) - 1);

	/* cliprdr sends data request event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_DATA_REQUEST);
	if (event->event_type == FRDP_EVENT_TYPE_CB_DATA_REQUEST)
	{
		data_request_event = (FRDP_CB_DATA_REQUEST_EVENT*)event;
		printf("Requested format: 0x%X\n", data_request_event->format);
	}
	freerdp_event_free(event);

	/* UI sends data response event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_RESPONSE, event_process_callback, NULL);
	data_response_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event;
	data_response_event->data = (uint8*)xmalloc(6);
	strcpy((char*)data_response_event->data, "hello");
	data_response_event->size = 6;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends data response PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* UI sends data request event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_REQUEST, event_process_callback, NULL);
	data_request_event = (FRDP_CB_DATA_REQUEST_EVENT*)event;
	data_request_event->format = CB_FORMAT_UNICODETEXT;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends data request PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* server sends data response PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_data_response_data, sizeof(test_data_response_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_response_data) - 1);

	/* cliprdr sends data response event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_DATA_RESPONSE);
	if (event->event_type == FRDP_EVENT_TYPE_CB_DATA_RESPONSE)
	{
		data_response_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event;
		printf("Data response size: %d\n", data_response_event->size);
		freerdp_hexdump(data_response_event->data, data_response_event->size);
	}
	freerdp_event_free(event);

	freerdp_chanman_close(chan_man, &instance);
	freerdp_chanman_free(chan_man);
}
예제 #12
0
int
main(int argc, char ** argv)
{
	int rv;
	xfInfo * xfi;
	pthread_t thread;
	int index = 1;
	char reason_msg[ERRINFO_BUFFER_SIZE];

	setlocale(LC_CTYPE, "");
	if (argc == 1)
	{
		out_args();
		return 0;
	}
	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	freerdp_sem_create(&g_sem, 0);

	while (1)
	{
		xfi = (xfInfo *) malloc(sizeof(xfInfo));
		memset(xfi, 0, sizeof(xfInfo));
		xfi->settings = (rdpSet *) malloc(sizeof(rdpSet));
		xfi->chan_man = freerdp_chanman_new();
		xfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
		memset(xfi->clrconv, 0, sizeof(CLRCONV));

		xfi->clrconv->alpha = 1;
		xfi->clrconv->palette = NULL;

		rv = process_params(xfi, argc, argv, &index);
		if (rv)
		{
			free(xfi->settings);
			freerdp_chanman_free(xfi->chan_man);
			free(xfi);
			break;
		}

		DEBUG_X11("starting thread %d to %s:%d", g_thread_count,
			xfi->settings->server, xfi->settings->tcp_port_rdp);
		if (pthread_create(&thread, 0, thread_func, xfi) == 0)
		{
			g_thread_count++;
		}
	}

	if (g_thread_count > 0)
	{
		DEBUG_X11("main thread, waiting for all threads to exit");
		freerdp_sem_wait(&g_sem);
		DEBUG_X11("main thread, all threads did exit");
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	if (g_error_code)
		return g_error_code;
	else if (g_disconnect_reason)
	{
		printf("disconnect: %s\n",
			freerdp_str_disconnect_reason(g_disconnect_reason, reason_msg, ERRINFO_BUFFER_SIZE));
	}

	return exit_code_from_disconnect_reason(g_disconnect_reason);
}
예제 #13
0
//-----------------------------------------------------------------------------
void test_rail_plugin(void)
{
	thread_param param;
	pthread_t thread;

	rdpChanMan* chan_man;
	rdpSettings settings = { 0 };
	freerdp s_inst = { 0 };
	freerdp* inst = &s_inst;
	int i;

	RAIL_UI_EVENT event;

	settings.hostname = "testhost";
	inst->settings = &settings;
	inst->SendChannelData = emulate_client_send_channel_data;

	chan_man = freerdp_chanman_new();

	freerdp_chanman_load_plugin(chan_man, &settings, "../channels/rail/rail.so", NULL);
	freerdp_chanman_pre_connect(chan_man, inst);
	freerdp_chanman_post_connect(chan_man, inst);

	param.chan_man = chan_man;
	param.instance = inst;
	param.th_count = 0;
	param.th_to_finish = 0;

	pthread_create(&thread, 0, thread_func, &param);


	// 1. Emulate server handshake binary
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_handshake);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_exec_result_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_sysparam1_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_sysparam2_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_localmovesize_start_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_localmovesize_stop_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_minmaxinfo_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_langbar_pdu);
	EMULATE_SERVER_SEND_CHANNEL_DATA(inst, server_app_get_resp_pdu);

	// 2. Send UI events

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETHIGHCONTRAST;
	event.param.sysparam_info.value.high_contrast_system_info.flags = 0x7e;
	event.param.sysparam_info.value.high_contrast_system_info.color_scheme = "";
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETWORKAREA;
	event.param.sysparam_info.value.work_area.left = 0;
	event.param.sysparam_info.value.work_area.top = 0;
	event.param.sysparam_info.value.work_area.right = 0x0690;
	event.param.sysparam_info.value.work_area.bottom = 0x039a;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = RAIL_SPI_TASKBARPOS;
	event.param.sysparam_info.value.taskbar_size.left = 0;
	event.param.sysparam_info.value.taskbar_size.top = 0x039a;
	event.param.sysparam_info.value.taskbar_size.right = 0x0690;
	event.param.sysparam_info.value.taskbar_size.bottom = 0x03c2;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETMOUSEBUTTONSWAP;
	event.param.sysparam_info.value.left_right_mouse_buttons_swapped = False;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETKEYBOARDPREF;
	event.param.sysparam_info.value.keyboard_for_user_prefered = False;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETDRAGFULLWINDOWS;
	event.param.sysparam_info.value.full_window_drag_enabled = True;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_UPDATE_CLIENT_SYSPARAM);
	event.param.sysparam_info.param = SPI_SETKEYBOARDCUES;
	event.param.sysparam_info.value.full_window_drag_enabled = False;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_EXECUTE_REMOTE_APP);
	event.param.execute_info.exe_or_file = "||iexplore";
	event.param.execute_info.working_directory = "f:\\windows\\system32";
	event.param.execute_info.arguments = "www.bing.com";
	event.param.execute_info.exec_or_file_is_file_path = False;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_ACTIVATE);
	event.param.activate_info.window_id = 0x0007008e;
	event.param.activate_info.enabled = True;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_SYS_COMMAND);
	event.param.syscommand_info.window_id = 0x00020052;
	event.param.syscommand_info.syscommand = 0x0f20;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_NOTIFY);
	event.param.notify_info.window_id = 0x000201aa;
	event.param.notify_info.notify_icon_id = 0x02;
	event.param.notify_info.message = 0x0204;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_WINDOW_MOVE);
	event.param.window_move_info.window_id = 0x00020020;
	event.param.window_move_info.new_position.left = 0x0309;
	event.param.window_move_info.new_position.top = 0x0100;
	event.param.window_move_info.new_position.right = 0x05db;
	event.param.window_move_info.new_position.bottom = 0x0188;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_SYSTEM_MENU);
	event.param.system_menu_info.window_id = 0x00090122;
	event.param.system_menu_info.left = 0xffa4; // TODO: WTF?
	event.param.system_menu_info.top = 0x024a;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_LANGBAR_INFO);
	event.param.langbar_info.status = 0x00000001;
	send_ui_event2plugin(chan_man, &event);

	init_ui_event(&event, RAIL_UI_EVENT_GET_APP_ID);
	event.param.get_app_id_info.window_id = 0x00020052;
	send_ui_event2plugin(chan_man, &event);

	// Waiting for possible events or data
	sleep(5);

	// Finishing thread and wait for it
	param.th_to_finish = 1;
	while (param.th_count > 0)
	{
		usleep(1000);
	}

	// We need to collected all events and data dumps and then to.
	// create CU_ASSERT series here!


	freerdp_chanman_close(chan_man, inst);
	freerdp_chanman_free(chan_man);
}