Esempio n. 1
0
rdpChannels* freerdp_channels_new(void)
{
	rdpChannels* channels;

	channels = (rdpChannels*) calloc(1, sizeof(rdpChannels));
	if (!channels)
		return NULL;

	channels->queue = MessageQueue_New(NULL);
	if (!channels->queue)
		goto error_queue;

	if (!g_OpenHandles)
	{
		g_OpenHandles = HashTable_New(TRUE);
		if (!g_OpenHandles)
			goto error_open_handles;

		if (!InitializeCriticalSectionAndSpinCount(&g_channels_lock, 4000))
			goto error_open_handles;
	}

	return channels;

error_open_handles:
	MessageQueue_Free(channels->queue);
error_queue:
	free(channels);
	return NULL;
}
Esempio n. 2
0
int xf_rail_init(xfContext* xfc, RailClientContext* rail)
{
	rdpContext* context = (rdpContext*) xfc;

	xfc->rail = rail;

	xf_rail_register_update_callbacks(context->update);

	rail->custom = (void*) xfc;

	rail->ServerExecuteResult = xf_rail_server_execute_result;
	rail->ServerSystemParam = xf_rail_server_system_param;
	rail->ServerHandshake = xf_rail_server_handshake;
	rail->ServerHandshakeEx = xf_rail_server_handshake_ex;
	rail->ServerLocalMoveSize = xf_rail_server_local_move_size;
	rail->ServerMinMaxInfo = xf_rail_server_min_max_info;
	rail->ServerLanguageBarInfo = xf_rail_server_language_bar_info;
	rail->ServerGetAppIdResponse = xf_rail_server_get_appid_response;

	xfc->railWindows = HashTable_New(TRUE);
	if (!xfc->railWindows)
		return 0;

	return 1;
}
Esempio n. 3
0
rdpChannels* freerdp_channels_new(freerdp* instance)
{
	rdpChannels* channels;
	channels = (rdpChannels*) calloc(1, sizeof(rdpChannels));

	if (!channels)
		return NULL;

	if (!InitializeCriticalSectionAndSpinCount(&channels->channelsLock, 4000))
		goto error;

	channels->instance = instance;
	channels->queue = MessageQueue_New(NULL);

	if (!channels->queue)
		goto error;

	channels->openHandles = HashTable_New(TRUE);

	if (!channels->openHandles)
		goto error;

	return channels;
error:
	freerdp_channels_free(channels);
	return NULL;
}
Esempio n. 4
0
HierarchyTable* HierarchyTable_New( void ) {
	HierarchyTable* self = NULL;

	if( stgHierarchyTable == NULL ){
		self = (HierarchyTable*) HashTable_New( NULL, NULL, NULL, HASHTABLE_POINTER_KEY );
	}
	else{
		self = stgHierarchyTable;
	}

	return self;
}
Esempio n. 5
0
HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName)
{
	rdpContext* context;
	freerdp_peer* client;
	WTSVirtualChannelManager* vcm;
	HANDLE hServer = INVALID_HANDLE_VALUE;

	context = (rdpContext*) pServerName;

	if (!context)
		return INVALID_HANDLE_VALUE;

	client = context->peer;

	if (!client)
		return INVALID_HANDLE_VALUE;

	vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager));

	if (vcm)
	{
		vcm->client = client;
		vcm->rdp = context->rdp;

		vcm->SessionId = g_SessionId++;

		if (!g_ServerHandles)
			g_ServerHandles = HashTable_New(TRUE);

		HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm);

		vcm->queue = MessageQueue_New(NULL);

		vcm->dvc_channel_id_seq = 1;
		vcm->dynamicVirtualChannels = ArrayList_New(TRUE);

		client->ReceiveChannelData = WTSReceiveChannelData;

		hServer = (HANDLE) vcm;
	}

	return hServer;
}
Esempio n. 6
0
rdpChannels* freerdp_channels_new(void)
{
	rdpChannels* channels;

	channels = (rdpChannels*) calloc(1, sizeof(rdpChannels));

	if (!channels)
		return NULL;

	channels->queue = MessageQueue_New(NULL);

	if (!g_OpenHandles)
	{
		g_OpenHandles = HashTable_New(TRUE);
		InitializeCriticalSectionAndSpinCount(&g_channels_lock, 4000);
	}

	return channels;
}
Esempio n. 7
0
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->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;
}
Esempio n. 8
0
HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName)
{
	rdpContext* context;
	freerdp_peer* client;
	WTSVirtualChannelManager* vcm;
	HANDLE hServer = INVALID_HANDLE_VALUE;

	context = (rdpContext*) pServerName;

	if (!context)
		return INVALID_HANDLE_VALUE;

	client = context->peer;
	if (!client)
	{
		SetLastError(ERROR_INVALID_DATA);
		return INVALID_HANDLE_VALUE;
	}

	vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager));
	if (!vcm)
		goto error_vcm_alloc;

	vcm->client = client;
	vcm->rdp = context->rdp;

	vcm->SessionId = g_SessionId++;

	if (!g_ServerHandles)
	{
		g_ServerHandles = HashTable_New(TRUE);
		if (!g_ServerHandles)
			goto error_free;
	}

	if (HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm) < 0)
		goto error_free;

	vcm->queue = MessageQueue_New(NULL);
	if (!vcm->queue)
		goto error_queue;

	vcm->dvc_channel_id_seq = 0;
	vcm->dynamicVirtualChannels = ArrayList_New(TRUE);
	if (!vcm->dynamicVirtualChannels)
		goto error_dynamicVirtualChannels;

	client->ReceiveChannelData = WTSReceiveChannelData;

	hServer = (HANDLE) vcm;
	return hServer;

error_dynamicVirtualChannels:
	MessageQueue_Free(vcm->queue);
error_queue:
	HashTable_Remove(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId);
error_free:
	free(vcm);
error_vcm_alloc:
	SetLastError(ERROR_NOT_ENOUGH_MEMORY);
	return INVALID_HANDLE_VALUE;
}
Esempio n. 9
0
int test_hash_table_string()
{
	int count;
	char* value;
	wHashTable* table;

	table = HashTable_New(TRUE);
	if (!table)
		return -1;

	table->hash = HashTable_StringHash;
	table->keyCompare = HashTable_StringCompare;
	table->valueCompare = HashTable_StringCompare;
	table->keyClone = HashTable_StringClone;
	table->valueClone = HashTable_StringClone;
	table->keyFree = HashTable_StringFree;
	table->valueFree = HashTable_StringFree;

	HashTable_Add(table, key1, val1);
	HashTable_Add(table, key2, val2);
	HashTable_Add(table, key3, val3);

	count = HashTable_Count(table);

	if (count != 3)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count);
		return -1;
	}

	HashTable_Remove(table, key2);

	count = HashTable_Count(table);

	if (count != 2)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 2, count);
		return -1;
	}

	HashTable_Remove(table, key3);

	count = HashTable_Count(table);

	if (count != 1)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 1, count);
		return -1;
	}

	HashTable_Remove(table, key1);

	count = HashTable_Count(table);

	if (count != 0)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count);
		return -1;
	}

	HashTable_Add(table, key1, val1);
	HashTable_Add(table, key2, val2);
	HashTable_Add(table, key3, val3);

	count = HashTable_Count(table);

	if (count != 3)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count);
		return -1;
	}

	value = (char*) HashTable_GetItemValue(table, key1);

	if (strcmp(value, val1) != 0)
	{
		printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val1, value);
		return -1;
	}

	value = (char*) HashTable_GetItemValue(table, key2);

	if (strcmp(value, val2) != 0)
	{
		printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val2, value);
		return -1;
	}

	value = (char*) HashTable_GetItemValue(table, key3);

	if (strcmp(value, val3) != 0)
	{
		printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val3, value);
		return -1;
	}

	HashTable_SetItemValue(table, key2, "apple");

	value = (char*) HashTable_GetItemValue(table, key2);

	if (strcmp(value, "apple") != 0)
	{
		printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", "apple", value);
		return -1;
	}

	if (!HashTable_Contains(table, key2))
	{
		printf("HashTable_Contains: Expected : %d, Actual: %d\n", TRUE, FALSE);
		return -1;
	}

	if (!HashTable_Remove(table, key2))
	{
		printf("HashTable_Remove: Expected : %d, Actual: %d\n", TRUE, FALSE);
		return -1;
	}

	if (HashTable_Remove(table, key2))
	{
		printf("HashTable_Remove: Expected : %d, Actual: %d\n", FALSE, TRUE);
		return -1;
	}

	HashTable_Clear(table);

	count = HashTable_Count(table);

	if (count != 0)
	{
		printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count);
		return -1;
	}

	HashTable_Free(table);

	return 1;
}
Esempio n. 10
0
/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
	UINT error = CHANNEL_RC_OK;
	RDPGFX_PLUGIN* gfx;
	RdpgfxClientContext* context;
	gfx = (RDPGFX_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx");

	if (!gfx)
	{
		gfx = (RDPGFX_PLUGIN*) calloc(1, sizeof(RDPGFX_PLUGIN));

		if (!gfx)
		{
			WLog_ERR(TAG, "calloc failed!");
			return CHANNEL_RC_NO_MEMORY;
		}

		gfx->log = WLog_Get(TAG);
		if (!gfx->log)
		{
			free(gfx);
			WLog_ERR(TAG, "Failed to acquire reference to WLog %s", TAG);
			return ERROR_INTERNAL_ERROR;
		}

		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->rdpcontext = ((freerdp *)gfx->settings->instance)->context;

		gfx->SurfaceTable = HashTable_New(TRUE);
		if (!gfx->SurfaceTable)
		{
			free(gfx);
			WLog_ERR(TAG, "HashTable_New failed!");
			return CHANNEL_RC_NO_MEMORY;
		}

		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;
		gfx->AVC444 = gfx->settings->GfxAVC444;
		gfx->SendQoeAck = gfx->settings->GfxSendQoeAck;

		if (gfx->H264)
			gfx->SmallCache = TRUE;

		gfx->MaxCacheSlot = gfx->SmallCache ? 4096 : 25600;

		context = (RdpgfxClientContext *)calloc(1, sizeof(RdpgfxClientContext));
		if (!context)
		{
			free(gfx);
			WLog_ERR(TAG, "calloc failed!");
			return CHANNEL_RC_NO_MEMORY;
		}

		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);
			WLog_ERR(TAG, "zgfx_context_new failed!");
			return CHANNEL_RC_NO_MEMORY;
		}

		error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*) gfx);
	}

	return error;
}
Esempio n. 11
0
void AsyncHashTable_Initialize(AsyncHashTable* table) {
	assert(table != NULL);

	table->BaseTable = HashTable_New();
	table->Lock = SAL_Mutex_Create();
}