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); }
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; }
int main(int argc, char* argv[]) { pthread_t thread; freerdp* instance; struct thread_data* data; rdpChanMan* chanman; freerdp_chanman_global_init(); g_sem = freerdp_sem_new(1); instance = freerdp_new(); instance->PreConnect = tf_pre_connect; instance->PostConnect = tf_post_connect; instance->ReceiveChannelData = tf_receive_channel_data; chanman = freerdp_chanman_new(); SET_CHANMAN(instance, chanman); freerdp_parse_args(instance->settings, argc, argv, tf_process_plugin_args, chanman, NULL, NULL); data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); data->instance = instance; g_thread_count++; pthread_create(&thread, 0, thread_func, data); while (g_thread_count > 0) { freerdp_sem_wait(g_sem); } freerdp_chanman_global_uninit(); return 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; }
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; }
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); }
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); }
//----------------------------------------------------------------------------- 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, ¶m); // 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); }