int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { char* name; char* path; int length, ck; RDPDR_SMARTCARD* device; SMARTCARD_DEVICE* smartcard; device = (RDPDR_SMARTCARD*) pEntryPoints->device; name = device->Name; path = device->Path; smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE)); if (!smartcard) return -1; smartcard->device.type = RDPDR_DTYP_SMARTCARD; smartcard->device.name = "SCARD"; smartcard->device.IRPRequest = smartcard_irp_request; smartcard->device.Init = smartcard_init; smartcard->device.Free = smartcard_free; length = strlen(smartcard->device.name); smartcard->device.data = Stream_New(NULL, length + 1); Stream_Write(smartcard->device.data, "SCARD", 6); smartcard->name = NULL; smartcard->path = NULL; if (path) { smartcard->path = path; smartcard->name = name; } else if (name) { if (1 == sscanf(name, "%d", &ck)) smartcard->path = name; else smartcard->name = name; } smartcard->log = WLog_Get("com.freerdp.channel.smartcard.client"); //WLog_SetLogLevel(smartcard->log, WLOG_DEBUG); smartcard->IrpQueue = MessageQueue_New(NULL); smartcard->rgSCardContextList = ListDictionary_New(TRUE); smartcard->rgOutstandingMessages = ListDictionary_New(TRUE); smartcard->CompletedIrpQueue = Queue_New(TRUE, -1, -1); smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func, smartcard, CREATE_SUSPENDED, NULL); pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) smartcard); ResumeThread(smartcard->thread); return 0; }
RFX_CONTEXT* rfx_context_new(BOOL encoder) { HKEY hKey; LONG status; DWORD dwType; DWORD dwSize; DWORD dwValue; SYSTEM_INFO sysinfo; RFX_CONTEXT* context; wObject *pool; RFX_CONTEXT_PRIV *priv; context = (RFX_CONTEXT*)calloc(1, sizeof(RFX_CONTEXT)); if (!context) return NULL; context->encoder = encoder; context->priv = priv = (RFX_CONTEXT_PRIV *)calloc(1, sizeof(RFX_CONTEXT_PRIV) ); if (!priv) goto error_priv; WLog_Init(); priv->log = WLog_Get("com.freerdp.codec.rfx"); WLog_OpenAppender(priv->log); #ifdef WITH_DEBUG_RFX WLog_SetLogLevel(priv->log, WLOG_DEBUG); #endif priv->TilePool = ObjectPool_New(TRUE); if (!priv->TilePool) goto error_tilePool; pool = ObjectPool_Object(priv->TilePool); pool->fnObjectInit = (OBJECT_INIT_FN) rfx_tile_init; if (context->encoder) { pool->fnObjectNew = (OBJECT_NEW_FN) rfx_encoder_tile_new; pool->fnObjectFree = (OBJECT_FREE_FN) rfx_encoder_tile_free; } else { pool->fnObjectNew = (OBJECT_NEW_FN) rfx_decoder_tile_new; pool->fnObjectFree = (OBJECT_FREE_FN) rfx_decoder_tile_free; } /* * align buffers to 16 byte boundary (needed for SSE/NEON instructions) * * y_r_buffer, cb_g_buffer, cr_b_buffer: 64 * 64 * sizeof(INT16) = 8192 (0x2000) * dwt_buffer: 32 * 32 * 2 * 2 * sizeof(INT16) = 8192, maximum sub-band width is 32 * * Additionally we add 32 bytes (16 in front and 16 at the back of the buffer) * in order to allow optimized functions (SEE, NEON) to read from positions * that are actually in front/beyond the buffer. Offset calculations are * performed at the BufferPool_Take function calls in rfx_encode/decode.c. * * We then multiply by 3 to use a single, partioned buffer for all 3 channels. */ priv->BufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16); if (!priv->BufferPool) goto error_BufferPool; #ifdef _WIN32 { BOOL isVistaOrLater; OSVERSIONINFOA verinfo; ZeroMemory(&verinfo, sizeof(OSVERSIONINFOA)); verinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); GetVersionExA(&verinfo); isVistaOrLater = ((verinfo.dwMajorVersion >= 6) && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE; priv->UseThreads = isVistaOrLater; } #else priv->UseThreads = TRUE; #endif GetNativeSystemInfo(&sysinfo); priv->MinThreadCount = sysinfo.dwNumberOfProcessors; priv->MaxThreadCount = 0; status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, RFX_KEY, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); if (status == ERROR_SUCCESS) { dwSize = sizeof(dwValue); if (RegQueryValueEx(hKey, _T("UseThreads"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) priv->UseThreads = dwValue ? 1 : 0; if (RegQueryValueEx(hKey, _T("MinThreadCount"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) priv->MinThreadCount = dwValue; if (RegQueryValueEx(hKey, _T("MaxThreadCount"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) priv->MaxThreadCount = dwValue; RegCloseKey(hKey); } if (priv->UseThreads) { /* Call primitives_get here in order to avoid race conditions when using primitives_get */ /* from multiple threads. This call will initialize all function pointers correctly */ /* before any decoding threads are started */ primitives_get(); priv->ThreadPool = CreateThreadpool(NULL); if (!priv->ThreadPool) goto error_threadPool; InitializeThreadpoolEnvironment(&priv->ThreadPoolEnv); SetThreadpoolCallbackPool(&priv->ThreadPoolEnv, priv->ThreadPool); if (priv->MinThreadCount) if (!SetThreadpoolThreadMinimum(priv->ThreadPool, priv->MinThreadCount)) goto error_threadPool_minimum; if (priv->MaxThreadCount) SetThreadpoolThreadMaximum(priv->ThreadPool, priv->MaxThreadCount); } /* initialize the default pixel format */ rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_B8G8R8A8); /* create profilers for default decoding routines */ rfx_profiler_create(context); /* set up default routines */ context->quantization_decode = rfx_quantization_decode; context->quantization_encode = rfx_quantization_encode; context->dwt_2d_decode = rfx_dwt_2d_decode; context->dwt_2d_encode = rfx_dwt_2d_encode; RFX_INIT_SIMD(context); context->state = RFX_STATE_SEND_HEADERS; return context; error_threadPool_minimum: CloseThreadpool(priv->ThreadPool); error_threadPool: BufferPool_Free(priv->BufferPool); error_BufferPool: ObjectPool_Free(priv->TilePool); error_tilePool: free(priv); error_priv: free(context); return NULL; }
namespace freerds { static wLog* logger_taskSwitchTo = WLog_Get("freerds.TaskSwitchTo"); void TaskSwitchTo::run() { CallOutSwitchTo switchToCall; switchToCall.setServiceEndpoint(m_ServiceEndpoint); switchToCall.setConnectionId(m_ConnectionId); APP_CONTEXT.getRpcOutgoingQueue()->addElement(&switchToCall); WaitForSingleObject(switchToCall.getAnswerHandle(), INFINITE); if (switchToCall.getResult() != 0) { WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo answer: RPC error %d!", switchToCall.getResult()); return cleanUpOnError(); } if (switchToCall.decodeResponse()) { // WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo: decoding of switchto answer failed!"); return cleanUpOnError(); } if (!switchToCall.isSuccess()) { WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo: switching in FreeRDS failed!"); return cleanUpOnError(); } SessionPtr currentSession; if (m_OldSessionId != 0) { currentSession = APP_CONTEXT.getSessionStore()->getSession(m_OldSessionId); if (currentSession) { currentSession->stopModule(); APP_CONTEXT.getSessionStore()->removeSession(currentSession->getSessionId()); WLog_Print(logger_taskSwitchTo, WLOG_INFO, "TaskSwitchTo: session with sessionId %d was stopped!", m_OldSessionId); } else { WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo: no session was found for sessionId %d!", m_OldSessionId); } } else { WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo: no oldSessionId was set!"); } ConnectionPtr connection = APP_CONTEXT.getConnectionStore()->getConnection(m_ConnectionId); if (connection) { connection->setSessionId(m_NewSessionId); connection->setAbout2SwitchSessionId(0); } return; } void TaskSwitchTo::setConnectionId(UINT32 connectionId) { m_ConnectionId = connectionId; } void TaskSwitchTo::setServiceEndpoint(std::string serviceEndpoint) { m_ServiceEndpoint = serviceEndpoint; } void TaskSwitchTo::setOldSessionId(UINT32 sessionId) { m_OldSessionId = sessionId; } void TaskSwitchTo::setNewSessionId(UINT32 sessionId) { m_NewSessionId = sessionId; } void TaskSwitchTo::cleanUpOnError() { SessionPtr currentSession = APP_CONTEXT.getSessionStore()->getSession(m_NewSessionId); if (currentSession) { if (currentSession->getConnectState() == WTSActive) { // this was a new session for the connection, remove it currentSession->stopModule(); APP_CONTEXT.getSessionStore()->removeSession(currentSession->getSessionId()); WLog_Print(logger_taskSwitchTo, WLOG_INFO, "TaskSwitchTo: cleaning up session with sessionId %d", m_NewSessionId); } else if (currentSession->getConnectState() == WTSConnectQuery) { // was a previous disconnected session currentSession->setConnectState(WTSDisconnected); } } else { WLog_Print(logger_taskSwitchTo, WLOG_ERROR, "TaskSwitchTo: no session was found for sessionId %d!", m_NewSessionId); } ConnectionPtr connection = APP_CONTEXT.getConnectionStore()->getConnection(m_ConnectionId); if (connection) { connection->setAbout2SwitchSessionId(0); } } }
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { UINT rc; int error; cliprdrPlugin* cliprdr; CliprdrClientContext* context; CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx; cliprdr = (cliprdrPlugin*) calloc(1, sizeof(cliprdrPlugin)); if (!cliprdr) { WLog_ERR(TAG, "calloc failed!"); return FALSE; } cliprdr->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL; strcpy(cliprdr->channelDef.name, "cliprdr"); pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints; if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) && (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) { context = (CliprdrClientContext*) calloc(1, sizeof(CliprdrClientContext)); if (!context) { free(cliprdr); WLog_ERR(TAG, "calloc failed!"); return FALSE; } context->handle = (void*) cliprdr; context->custom = NULL; context->ClientCapabilities = cliprdr_client_capabilities; context->TempDirectory = cliprdr_temp_directory; context->ClientFormatList = cliprdr_client_format_list; context->ClientFormatListResponse = cliprdr_client_format_list_response; context->ClientLockClipboardData = cliprdr_client_lock_clipboard_data; context->ClientUnlockClipboardData = cliprdr_client_unlock_clipboard_data; context->ClientFormatDataRequest = cliprdr_client_format_data_request; context->ClientFormatDataResponse = cliprdr_client_format_data_response; context->ClientFileContentsRequest = cliprdr_client_file_contents_request; context->ClientFileContentsResponse = cliprdr_client_file_contents_response; *(pEntryPointsEx->ppInterface) = (void*) context; cliprdr->context = context; context->rdpcontext = pEntryPointsEx->context; } cliprdr->log = WLog_Get("com.freerdp.channels.cliprdr.client"); cliprdr->useLongFormatNames = TRUE; cliprdr->streamFileClipEnabled = FALSE; cliprdr->fileClipNoFilePaths = TRUE; cliprdr->canLockClipData = FALSE; WLog_Print(cliprdr->log, WLOG_DEBUG, "VirtualChannelEntry"); CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP)); rc = cliprdr->channelEntryPoints.pVirtualChannelInit(&cliprdr->InitHandle, &cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, cliprdr_virtual_channel_init_event); if (CHANNEL_RC_OK != rc) { WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]", WTSErrorToString(rc), rc); free(cliprdr->context); free(cliprdr); return FALSE; } cliprdr->channelEntryPoints.pInterface = *(cliprdr->channelEntryPoints.ppInterface); cliprdr->channelEntryPoints.ppInterface = &(cliprdr->channelEntryPoints.pInterface); if ((error = cliprdr_add_init_handle_data(cliprdr->InitHandle, (void*) cliprdr))) { WLog_ERR(TAG, "cliprdr_add_init_handle_data failed with error %lu", error); free(cliprdr->context); free(cliprdr); return FALSE; } return TRUE; }
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { UINT rc; railPlugin* rail; RailClientContext* context; CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx; rail = (railPlugin*) calloc(1, sizeof(railPlugin)); rail->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL; strcpy(rail->channelDef.name, "rail"); pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints; if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) && (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) { context = (RailClientContext*) calloc(1, sizeof(RailClientContext)); if (!context) return FALSE; context->handle = (void*) rail; context->custom = NULL; context->ClientExecute = rail_client_execute; context->ClientActivate = rail_client_activate; context->ClientSystemParam = rail_client_system_param; context->ServerSystemParam = rail_server_system_param; context->ClientSystemCommand = rail_client_system_command; context->ClientHandshake = rail_client_handshake; context->ServerHandshake = rail_server_handshake; context->ClientHandshakeEx = rail_client_handshake_ex; context->ServerHandshakeEx = rail_server_handshake_ex; context->ClientNotifyEvent = rail_client_notify_event; context->ClientWindowMove = rail_client_window_move; context->ServerLocalMoveSize = rail_server_local_move_size; context->ServerMinMaxInfo = rail_server_min_max_info; context->ClientInformation = rail_client_information; context->ClientSystemMenu = rail_client_system_menu; context->ClientLanguageBarInfo = rail_client_language_bar_info; context->ServerLanguageBarInfo = rail_server_language_bar_info; context->ServerExecuteResult = rail_server_execute_result; context->ClientGetAppIdRequest = rail_client_get_appid_request; context->ServerGetAppIdResponse = rail_server_get_appid_response; *(pEntryPointsEx->ppInterface) = (void*) context; rail->context = context; } WLog_Init(); rail->log = WLog_Get("com.freerdp.channels.rail.client"); WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntry"); CopyMemory(&(rail->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP)); rc = rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle, &rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rail_virtual_channel_init_event); if (CHANNEL_RC_OK != rc) { WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]", WTSErrorToString(rc), rc); free(rail); return -1; } rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface); rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface); return rail_add_init_handle_data(rail->InitHandle, (void*) rail); }
int transport_write(rdpTransport* transport, wStream* s) { int length; int status = -1; int writtenlength = 0; EnterCriticalSection(&(transport->WriteLock)); length = Stream_GetPosition(s); writtenlength = length; Stream_SetPosition(s, 0); if (length > 0) { WLog_Packet(WLog_Get(TAG), WLOG_TRACE, Stream_Buffer(s), length, WLOG_PACKET_OUTBOUND); } while (length > 0) { status = BIO_write(transport->frontBio, Stream_Pointer(s), length); if (status <= 0) { /* the buffered BIO that is at the end of the chain always says OK for writing, * so a retry means that for any reason we need to read. The most probable * is a SSL or TSG BIO in the chain. */ if (!BIO_should_retry(transport->frontBio)) { WLog_ERR_BIO(TAG, "BIO_should_retry", transport->frontBio); goto out_cleanup; } /* non-blocking can live with blocked IOs */ if (!transport->blocking) { WLog_ERR_BIO(TAG, "BIO_write", transport->frontBio); goto out_cleanup; } if (BIO_wait_write(transport->frontBio, 100) < 0) { WLog_ERR_BIO(TAG, "BIO_wait_write", transport->frontBio); status = -1; goto out_cleanup; } continue; } if (transport->blocking || transport->settings->WaitForOutputBufferFlush) { while (BIO_write_blocked(transport->frontBio)) { if (BIO_wait_write(transport->frontBio, 100) < 0) { WLog_ERR(TAG, "error when selecting for write"); status = -1; goto out_cleanup; } if (BIO_flush(transport->frontBio) < 1) { WLog_ERR(TAG, "error when flushing outputBuffer"); status = -1; goto out_cleanup; } } } length -= status; Stream_Seek(s, status); } transport->written += writtenlength; out_cleanup: if (status < 0) { /* A write error indicates that the peer has dropped the connection */ transport->layer = TRANSPORT_LAYER_CLOSED; } Stream_Release(s); LeaveCriticalSection(&(transport->WriteLock)); return status; }
/** * @brief Try to read a complete PDU (NLA, fast-path or tpkt) from the underlying transport. * * If possible a complete PDU is read, in case of non blocking transport this might not succeed. * Except in case of an error the passed stream will point to the last byte read (correct * position). When the pdu read is completed the stream is sealed and the pointer set to 0 * * @param[in] transport rdpTransport * @param[in] s wStream * @return < 0 on error; 0 if not enough data is available (non blocking mode); > 0 number of * bytes of the *complete* pdu read */ int transport_read_pdu(rdpTransport* transport, wStream* s) { int status; int position; int pduLength; BYTE* header; position = 0; pduLength = 0; if (!transport) return -1; if (!s) return -1; position = Stream_GetPosition(s); /* Make sure there is enough space for the longest header within the stream */ if (!Stream_EnsureCapacity(s, 4)) return -1; /* Make sure at least two bytes are read for further processing */ if (position < 2 && (status = transport_read_layer_bytes(transport, s, 2 - position)) != 1) { /* No data available at the moment */ return status; } /* update position value for further checks */ position = Stream_GetPosition(s); header = Stream_Buffer(s); if (transport->NlaMode) { /* * In case NlaMode is set TSRequest package(s) are expected * 0x30 = DER encoded data with these bits set: * bit 6 P/C constructed * bit 5 tag number - sequence */ if (header[0] == 0x30) { /* TSRequest (NLA) */ if (header[1] & 0x80) { if ((header[1] & ~(0x80)) == 1) { /* check for header bytes already was readed in previous calls */ if (position < 3 && (status = transport_read_layer_bytes(transport, s, 3 - position)) != 1) return status; pduLength = header[2]; pduLength += 3; } else if ((header[1] & ~(0x80)) == 2) { /* check for header bytes already was readed in previous calls */ if (position < 4 && (status = transport_read_layer_bytes(transport, s, 4 - position)) != 1) return status; pduLength = (header[2] << 8) | header[3]; pduLength += 4; } else { WLog_ERR(TAG, "Error reading TSRequest!"); return -1; } } else { pduLength = header[1]; pduLength += 2; } } } else { if (header[0] == 0x03) { /* TPKT header */ /* check for header bytes already was readed in previous calls */ if (position < 4 && (status = transport_read_layer_bytes(transport, s, 4 - position)) != 1) return status; pduLength = (header[2] << 8) | header[3]; /* min and max values according to ITU-T Rec. T.123 (01/2007) section 8 */ if (pduLength < 7 || pduLength > 0xFFFF) { WLog_ERR(TAG, "tpkt - invalid pduLength: %d", pduLength); return -1; } } else { /* Fast-Path Header */ if (header[1] & 0x80) { /* check for header bytes already was readed in previous calls */ if (position < 3 && (status = transport_read_layer_bytes(transport, s, 3 - position)) != 1) return status; pduLength = ((header[1] & 0x7F) << 8) | header[2]; } else pduLength = header[1]; /* * fast-path has 7 bits for length so the maximum size, including headers is 0x8000 * The theoretical minimum fast-path PDU consists only of two header bytes plus one * byte for data (e.g. fast-path input synchronize pdu) */ if (pduLength < 3 || pduLength > 0x8000) { WLog_ERR(TAG, "fast path - invalid pduLength: %d", pduLength); return -1; } } } if (!Stream_EnsureCapacity(s, Stream_GetPosition(s) + pduLength)) return -1; status = transport_read_layer_bytes(transport, s, pduLength - Stream_GetPosition(s)); if (status != 1) return status; if (Stream_GetPosition(s) >= pduLength) WLog_Packet(WLog_Get(TAG), WLOG_TRACE, Stream_Buffer(s), pduLength, WLOG_PACKET_INBOUND); Stream_SealLength(s); Stream_SetPosition(s, 0); return Stream_Length(s); }
int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) { int status = 0; RDPGFX_PLUGIN* gfx; RdpgfxClientContext* context; gfx = (RDPGFX_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx"); if (!gfx) { gfx = (RDPGFX_PLUGIN*) calloc(1, sizeof(RDPGFX_PLUGIN)); if (!gfx) return -1; gfx->log = WLog_Get(TAG); gfx->settings = (rdpSettings*) pEntryPoints->GetRdpSettings(pEntryPoints); gfx->iface.Initialize = rdpgfx_plugin_initialize; gfx->iface.Connected = NULL; gfx->iface.Disconnected = NULL; gfx->iface.Terminated = rdpgfx_plugin_terminated; gfx->SurfaceTable = HashTable_New(TRUE); if (!gfx->SurfaceTable) { free (gfx); return -1; } gfx->ThinClient = gfx->settings->GfxThinClient; gfx->SmallCache = gfx->settings->GfxSmallCache; gfx->Progressive = gfx->settings->GfxProgressive; gfx->ProgressiveV2 = gfx->settings->GfxProgressiveV2; gfx->H264 = gfx->settings->GfxH264; if (gfx->H264) gfx->SmallCache = TRUE; if (gfx->SmallCache) gfx->ThinClient = FALSE; gfx->MaxCacheSlot = (gfx->ThinClient) ? 4096 : 25600; context = (RdpgfxClientContext*) calloc(1, sizeof(RdpgfxClientContext)); if (!context) { free(gfx); return -1; } context->handle = (void*) gfx; context->GetSurfaceIds = rdpgfx_get_surface_ids; context->SetSurfaceData = rdpgfx_set_surface_data; context->GetSurfaceData = rdpgfx_get_surface_data; context->SetCacheSlotData = rdpgfx_set_cache_slot_data; context->GetCacheSlotData = rdpgfx_get_cache_slot_data; gfx->iface.pInterface = (void*) context; gfx->zgfx = zgfx_context_new(FALSE); if (!gfx->zgfx) { free(gfx); free(context); return -1; } status = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*) gfx); } return status; }
int TestWLog(int argc, char* argv[]) { wLog* root; wLog* logA; wLog* logB; wLogLayout* layout; wLogAppender* appender; char* tmp_path; char* wlog_file; if (!(tmp_path = GetKnownPath(KNOWN_PATH_TEMP))) { fprintf(stderr, "Failed to get temporary directory!\n"); return -1; } WLog_Init(); root = WLog_GetRoot(); WLog_SetLogAppenderType(root, WLOG_APPENDER_BINARY); appender = WLog_GetLogAppender(root); if(!WLog_ConfigureAppender(appender, "outputfilename", "test_w.log")) return 1; if(!WLog_ConfigureAppender(appender, "outputfilepath", tmp_path)) return 1; layout = WLog_GetLogLayout(root); WLog_Layout_SetPrefixFormat(root, layout, "[%lv:%mn] [%fl|%fn|%ln] - "); WLog_OpenAppender(root); logA = WLog_Get("com.test.ChannelA"); logB = WLog_Get("com.test.ChannelB"); WLog_SetLogLevel(logA, WLOG_INFO); WLog_SetLogLevel(logB, WLOG_ERROR); WLog_Print(logA, WLOG_INFO, "this is a test"); WLog_Print(logA, WLOG_WARN, "this is a %dnd %s", 2, "test"); WLog_Print(logA, WLOG_ERROR, "this is an error"); WLog_Print(logA, WLOG_TRACE, "this is a trace output"); WLog_Print(logB, WLOG_INFO, "just some info"); WLog_Print(logB, WLOG_WARN, "we're warning a %dnd %s", 2, "time"); WLog_Print(logB, WLOG_ERROR, "we've got an error"); WLog_Print(logB, WLOG_TRACE, "leaving a trace behind"); WLog_CloseAppender(root); WLog_Uninit(); if ((wlog_file = GetCombinedPath(tmp_path, "test_w.log"))) { DeleteFileA(wlog_file); free(wlog_file); } return 0; }
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { railPlugin* rail; RailClientContext* context; CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx; rail = (railPlugin*) malloc(sizeof(railPlugin)); ZeroMemory(rail, sizeof(railPlugin)); rail->plugin.channel_def.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL; strcpy(rail->plugin.channel_def.name, "rail"); rail->plugin.connect_callback = rail_process_connect; rail->plugin.receive_callback = rail_process_receive; rail->plugin.event_callback = rail_process_event; rail->plugin.terminate_callback = rail_process_terminate; pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP*) pEntryPoints; if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP)) && (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) { context = (RailClientContext*) malloc(sizeof(RailClientContext)); context->handle = (void*) rail; context->ClientExecute = rail_client_execute; context->ClientActivate = rail_client_activate; context->ClientSystemParam = rail_client_system_param; context->ServerSystemParam = rail_server_system_param; context->ClientSystemCommand = rail_client_system_command; context->ClientHandshake = rail_client_handshake; context->ServerHandshake = rail_server_handshake; context->ClientHandshakeEx = rail_client_handshake_ex; context->ServerHandshakeEx = rail_server_handshake_ex; context->ClientNotifyEvent = rail_client_notify_event; context->ClientWindowMove = rail_client_window_move; context->ServerLocalMoveSize = rail_server_local_move_size; context->ServerMinMaxInfo = rail_server_min_max_info; context->ClientInformation = rail_client_information; context->ClientSystemMenu = rail_client_system_menu; context->ClientLanguageBarInfo = rail_client_language_bar_info; context->ServerLanguageBarInfo = rail_server_language_bar_info; context->ServerExecuteResult = rail_server_execute_result; context->ClientGetAppIdRequest = rail_client_get_appid_request; context->ServerGetAppIdResponse = rail_server_get_appid_response; *(pEntryPointsEx->ppInterface) = (void*) context; } WLog_Init(); rail->log = WLog_Get("com.freerdp.channels.rail.client"); WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntry"); svc_plugin_init((rdpSvcPlugin*) rail, pEntryPoints); return 1; }