コード例 #1
0
ファイル: server.c プロジェクト: dcatonR1/FreeRDP
VOID WINAPI FreeRDP_WTSCloseServer(HANDLE hServer)
{
	int index;
	int count;
	rdpPeerChannel* channel;
	WTSVirtualChannelManager* vcm;
	vcm = (WTSVirtualChannelManager*) hServer;

	if (vcm)
	{
		HashTable_Remove(g_ServerHandles, (void*)(UINT_PTR) vcm->SessionId);
		ArrayList_Lock(vcm->dynamicVirtualChannels);
		count = ArrayList_Count(vcm->dynamicVirtualChannels);

		for (index = 0; index < count; index++)
		{
			channel = (rdpPeerChannel*) ArrayList_GetItem(vcm->dynamicVirtualChannels,
			          index);
			WTSVirtualChannelClose(channel);
		}

		ArrayList_Unlock(vcm->dynamicVirtualChannels);
		ArrayList_Free(vcm->dynamicVirtualChannels);

		if (vcm->drdynvc_channel)
		{
			WTSVirtualChannelClose(vcm->drdynvc_channel);
			vcm->drdynvc_channel = NULL;
		}

		MessageQueue_Free(vcm->queue);
		free(vcm);
	}
}
コード例 #2
0
ファイル: pool.c プロジェクト: 99455125/FreeRDP
VOID winpr_CloseThreadpool(PTP_POOL ptpp)
{
#ifdef _WIN32
	InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
	if (pCloseThreadpool)
	{
		pCloseThreadpool(ptpp);
		return;
	}
#endif
	SetEvent(ptpp->TerminateEvent);

	ArrayList_Free(ptpp->Threads);
	Queue_Free(ptpp->PendingQueue);
	CountdownEvent_Free(ptpp->WorkComplete);
	CloseHandle(ptpp->TerminateEvent);

	if (ptpp == &DEFAULT_POOL)
	{
		ptpp->Threads = NULL;
		ptpp->PendingQueue = NULL;
		ptpp->WorkComplete = NULL;
		ptpp->TerminateEvent = NULL;
	}
	else
	{
		free(ptpp);
	}
}
コード例 #3
0
static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
{
	DVCMAN* dvcman;

	dvcman = (DVCMAN*) calloc(1, sizeof(DVCMAN));
	if (!dvcman)
	{
		WLog_ERR(TAG, "calloc failed!");
		return NULL;
	}

	dvcman->iface.CreateListener = dvcman_create_listener;
	dvcman->iface.FindChannelById = dvcman_find_channel_by_id;
	dvcman->iface.GetChannelId = dvcman_get_channel_id;
	dvcman->drdynvc = plugin;
	dvcman->channels = ArrayList_New(TRUE);
	if (!dvcman->channels)
	{
		WLog_ERR(TAG, "ArrayList_New failed!");
		free(dvcman);
		return NULL;
	}
	dvcman->channels->object.fnObjectFree = dvcman_channel_free;
	dvcman->pool = StreamPool_New(TRUE, 10);
	if (!dvcman->pool)
	{
		WLog_ERR(TAG, "StreamPool_New failed!");
		ArrayList_Free(dvcman->channels);
		free(dvcman);
		return NULL;
	}

	return (IWTSVirtualChannelManager*) dvcman;
}
コード例 #4
0
ファイル: pool.c プロジェクト: cgull/FreeRDP
VOID CloseThreadpool(PTP_POOL ptpp)
{
#ifdef _WIN32
    module_init();

    if (pCloseThreadpool)
        pCloseThreadpool(ptpp);
#else
    SetEvent(ptpp->TerminateEvent);

    ArrayList_Free(ptpp->Threads);
    Queue_Free(ptpp->PendingQueue);
    CountdownEvent_Free(ptpp->WorkComplete);
    CloseHandle(ptpp->TerminateEvent);

    if (ptpp == &DEFAULT_POOL)
    {
        ptpp->Threads = NULL;
        ptpp->PendingQueue = NULL;
        ptpp->WorkComplete = NULL;
        ptpp->TerminateEvent = NULL;
    }
    else
    {
        free(ptpp);
    }
#endif
}
コード例 #5
0
ファイル: drdynvc_main.c プロジェクト: Devolutions/FreeRDP
static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr)
{
	int i;
	IWTSPlugin* pPlugin;
	DVCMAN_LISTENER* listener;
	DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
	UINT error;
	ArrayList_Free(dvcman->channels);

	for (i = 0; i < dvcman->num_listeners; i++)
	{
		listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
		free(listener->channel_name);
		free(listener);
	}

	dvcman->num_listeners = 0;

	for (i = 0; i < dvcman->num_plugins; i++)
	{
		pPlugin = dvcman->plugins[i];

		if (pPlugin->Terminated)
			if ((error = pPlugin->Terminated(pPlugin)))
				WLog_Print(drdynvc->log, WLOG_ERROR, "Terminated failed with error %"PRIu32"!", error);
	}

	dvcman->num_plugins = 0;
	StreamPool_Free(dvcman->pool);
	free(dvcman);
}
コード例 #6
0
ファイル: xf_event.c プロジェクト: awakecoding/FreeRDP
BOOL xf_event_action_script_init(xfContext* xfc)
{
	char* xevent;
	FILE* actionScript;
	char buffer[1024] = { 0 };
	char command[1024] = { 0 };
	xfc->xevents = ArrayList_New(TRUE);

	if (!xfc->xevents)
		return FALSE;

	ArrayList_Object(xfc->xevents)->fnObjectFree = free;
	sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript);
	actionScript = popen(command, "r");

	if (!actionScript)
		return FALSE;

	while (fgets(buffer, sizeof(buffer), actionScript))
	{
		strtok(buffer, "\n");
		xevent = _strdup(buffer);

		if (!xevent || ArrayList_Add(xfc->xevents, xevent) < 0)
		{
			ArrayList_Free(xfc->xevents);
			xfc->xevents = NULL;
			return FALSE;
		}
	}

	pclose(actionScript);
	return TRUE;
}
コード例 #7
0
ファイル: tsmf_media.c プロジェクト: artemh/FreeRDP
TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCallback* pChannelCallback)
{
	TSMF_PRESENTATION* presentation;

	if (!guid || !pChannelCallback)
		return NULL;

	presentation = (TSMF_PRESENTATION*) calloc(1, sizeof(TSMF_PRESENTATION));
	if (!presentation)
	{
		WLog_ERR(TAG, "calloc failed");
		return NULL;
	}

	CopyMemory(presentation->presentation_id, guid, GUID_SIZE);
	presentation->channel_callback = pChannelCallback;
	presentation->volume = 5000; /* 50% */
	presentation->muted = 0;
	if (!(presentation->stream_list = ArrayList_New(TRUE)))
		goto error_stream_list;

	ArrayList_Object(presentation->stream_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_stream_free;

	if (ArrayList_Add(presentation_list, presentation) < 0)
		goto error_add;

	return presentation;

error_add:
	ArrayList_Free(presentation->stream_list);
error_stream_list:
	free(presentation);
	return NULL;

}
コード例 #8
0
ファイル: rpc_client.c プロジェクト: AlessioLeo/FreeRDP
int rpc_client_free(rdpRpc* rpc)
{
	RpcClient* client;

	client = rpc->client;

	if (client)
	{
		Queue_Free(client->SendQueue);

		if (client->RecvFrag)
			rpc_fragment_free(client->RecvFrag);

		Queue_Free(client->FragmentPool);
		Queue_Free(client->FragmentQueue);

		if (client->pdu)
			rpc_pdu_free(client->pdu);

		Queue_Free(client->ReceivePool);
		Queue_Free(client->ReceiveQueue);

		ArrayList_Free(client->ClientCallList);

		CloseHandle(client->StopEvent);
		CloseHandle(client->PduSentEvent);

		CloseHandle(client->Thread);

		free(client);
	}

	return 0;
}
コード例 #9
0
ファイル: xf_event.c プロジェクト: awakecoding/FreeRDP
void xf_event_action_script_free(xfContext* xfc)
{
	if (xfc->xevents)
	{
		ArrayList_Free(xfc->xevents);
		xfc->xevents = NULL;
	}
}
コード例 #10
0
ファイル: pool.c プロジェクト: cgull/FreeRDP
static BOOL InitializeThreadpool(PTP_POOL pool)
{
    int index;
    HANDLE thread;

    if (pool->Threads)
        return TRUE;

    pool->Minimum = 0;
    pool->Maximum = 500;

    if (!(pool->PendingQueue = Queue_New(TRUE, -1, -1)))
        goto fail_queue_new;

    if (!(pool->WorkComplete = CountdownEvent_New(0)))
        goto fail_countdown_event;

    if (!(pool->TerminateEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
        goto fail_terminate_event;

    if (!(pool->Threads = ArrayList_New(TRUE)))
        goto fail_thread_array;

    pool->Threads->object.fnObjectFree = threads_close;

    for (index = 0; index < 4; index++)
    {
        if (!(thread = CreateThread(NULL, 0,
                                    (LPTHREAD_START_ROUTINE) thread_pool_work_func,
                                    (void*) pool, 0, NULL)))
        {
            goto fail_create_threads;
        }

        if (ArrayList_Add(pool->Threads, thread) < 0)
            goto fail_create_threads;
    }

    return TRUE;

fail_create_threads:
    SetEvent(pool->TerminateEvent);
    ArrayList_Free(pool->Threads);
    pool->Threads = NULL;
fail_thread_array:
    CloseHandle(pool->TerminateEvent);
    pool->TerminateEvent = NULL;
fail_terminate_event:
    CountdownEvent_Free(pool->WorkComplete);
    pool->WorkComplete = NULL;
fail_countdown_event:
    Queue_Free(pool->PendingQueue);
    pool->WorkComplete = NULL;
fail_queue_new:

    return FALSE;

}
コード例 #11
0
ファイル: tsmf_media.c プロジェクト: JunaidLoonat/FreeRDP
void _tsmf_presentation_free(TSMF_PRESENTATION* presentation)
{
	tsmf_presentation_stop(presentation);
	ArrayList_Clear(presentation->stream_list);
	ArrayList_Free(presentation->stream_list);
	free(presentation->rects);
	ZeroMemory(presentation, sizeof(TSMF_PRESENTATION));
	free(presentation);
}
コード例 #12
0
ファイル: xf_keyboard.c プロジェクト: mccart/FreeRDP
BOOL xf_keyboard_action_script_init(xfContext* xfc)
{
	FILE* keyScript;
	char* keyCombination;
	char buffer[1024] = { 0 };
	char command[1024] = { 0 };

	if (xfc->actionScript)
	{
		free(xfc->actionScript);
		xfc->actionScript = NULL;
	}

	if (PathFileExistsA("/usr/share/freerdp/action.sh"))
		xfc->actionScript = _strdup("/usr/share/freerdp/action.sh");

	if (!xfc->actionScript)
		return FALSE;

	xfc->keyCombinations = ArrayList_New(TRUE);
	if (!xfc->keyCombinations)
		return FALSE;

	ArrayList_Object(xfc->keyCombinations)->fnObjectFree = free;

	sprintf_s(command, sizeof(command), "%s key", xfc->actionScript);

	keyScript = popen(command, "r");

	if (!keyScript)
	{
		free(xfc->actionScript);
		xfc->actionScript = NULL;
		return FALSE;
	}

	while (fgets(buffer, sizeof(buffer), keyScript) != NULL)
	{
		strtok(buffer, "\n");
		keyCombination = _strdup(buffer);
		if (!keyCombination || ArrayList_Add(xfc->keyCombinations, keyCombination) < 0)
		{
			ArrayList_Free(xfc->keyCombinations);
			free(xfc->actionScript);
			xfc->actionScript = NULL;
			pclose(keyScript);
			return FALSE;
		}
	}

	pclose(keyScript);
	return xf_event_action_script_init(xfc);

}
コード例 #13
0
ファイル: tsmf_media.c プロジェクト: JozLes77/FreeRDP
void _tsmf_presentation_free(TSMF_PRESENTATION *presentation)
{
	tsmf_presentation_stop(presentation);
	ArrayList_Clear(presentation->stream_list);
	ArrayList_Free(presentation->stream_list);

	if (presentation->rects)
		free(presentation->rects);

	memset(presentation, 0, sizeof(TSMF_PRESENTATION));
	free(presentation);
}
コード例 #14
0
int freerdp_channels_global_uninit(void)
{
	EnterCriticalSection(&g_channels_lock);
	DeleteCriticalSection(&g_channels_lock);

	if (g_ChannelsList)
	{
		ArrayList_Lock(g_ChannelsList);
		ArrayList_Free(g_ChannelsList);
		g_ChannelsList = NULL;
	}

	return 0;
}
コード例 #15
0
ファイル: tsmf_media.c プロジェクト: artemh/FreeRDP
static void tsmf_signal_handler(int s)
{
	TERMINATING = 1;
	ArrayList_Free(presentation_list);

	if (s == SIGINT)
	{
		signal(s, SIG_DFL);
		kill(getpid(), s);
	}
	else if (s == SIGUSR1)
	{
		signal(s, SIG_DFL);
	}
}
コード例 #16
0
ファイル: shadow_mcevent.c プロジェクト: BUGgs/FreeRDP
void shadow_multiclient_free(rdpShadowMultiClientEvent* event)
{
	if (!event)
		return;

	DeleteCriticalSection(&(event->lock));

	ArrayList_Free(event->subscribers);
	CloseHandle(event->doneEvent);
	CloseHandle(event->barrierEvent);
	CloseHandle(event->event);
	free(event);

	return;
}
コード例 #17
0
ファイル: xf_keyboard.c プロジェクト: mccart/FreeRDP
void xf_keyboard_action_script_free(xfContext* xfc)
{
	xf_event_action_script_free(xfc);

	if (xfc->keyCombinations)
	{
		ArrayList_Free(xfc->keyCombinations);
		xfc->keyCombinations = NULL;
	}

	if (xfc->actionScript)
	{
		free(xfc->actionScript);
		xfc->actionScript = NULL;
	}
}
コード例 #18
0
ファイル: shadow_mcevent.c プロジェクト: BUGgs/FreeRDP
rdpShadowMultiClientEvent* shadow_multiclient_new()
{
	rdpShadowMultiClientEvent* event = (rdpShadowMultiClientEvent*) calloc(1, sizeof(rdpShadowMultiClientEvent));
	if (!event)
		goto out_error;

	event->event = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (!event->event)
		goto out_free;

	event->barrierEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (!event->barrierEvent)
		goto out_free_event;

	event->doneEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	if (!event->doneEvent)
		goto out_free_barrierEvent;

	event->subscribers = ArrayList_New(TRUE);
	if (!event->subscribers)
		goto out_free_doneEvent;

	if (!InitializeCriticalSectionAndSpinCount(&(event->lock), 4000))
		goto out_free_subscribers;

	event->consuming = 0;
	event->waiting = 0;
	event->eventid = 0;
	SetEvent(event->doneEvent);
	return event;

out_free_subscribers:
	ArrayList_Free(event->subscribers);
out_free_doneEvent:
	CloseHandle(event->doneEvent);
out_free_barrierEvent:
	CloseHandle(event->barrierEvent);
out_free_event:
	CloseHandle(event->event);
out_free:
	free(event);
out_error:
	return (rdpShadowMultiClientEvent *)NULL;
}
コード例 #19
0
ファイル: rpc.c プロジェクト: 4hosi/FreeRDP
void rpc_free(rdpRpc* rpc)
{
	if (rpc != NULL)
	{
		rpc_client_stop(rpc);

		if (rpc->State >= RPC_CLIENT_STATE_CONTEXT_NEGOTIATED)
		{
			ntlm_client_uninit(rpc->ntlm);
			ntlm_free(rpc->ntlm);
		}

		rpc_client_virtual_connection_free(rpc->VirtualConnection);

		ArrayList_Clear(rpc->VirtualConnectionCookieTable);
		ArrayList_Free(rpc->VirtualConnectionCookieTable);

		free(rpc);
	}
}
コード例 #20
0
ファイル: dvcman.c プロジェクト: Oshirowanen/FreeRDP
void dvcman_free(IWTSVirtualChannelManager* pChannelMgr)
{
	int i;
	int count;
	IWTSPlugin* pPlugin;
	DVCMAN_LISTENER* listener;
	DVCMAN_CHANNEL* channel;
	DVCMAN* dvcman = (DVCMAN*) pChannelMgr;

	ArrayList_Lock(dvcman->channels);

	count = ArrayList_Count(dvcman->channels);

	for (i = 0; i < count; i++)
	{
		channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, i);
		dvcman_channel_free(channel);
	}

	ArrayList_Unlock(dvcman->channels);

	ArrayList_Free(dvcman->channels);

	for (i = 0; i < dvcman->num_listeners; i++)
	{
		listener = (DVCMAN_LISTENER*) dvcman->listeners[i];
		free(listener->channel_name);
		free(listener);
	}

	for (i = 0; i < dvcman->num_plugins; i++)
	{
		pPlugin = dvcman->plugins[i];

		if (pPlugin->Terminated)
			pPlugin->Terminated(pPlugin);
	}

	StreamPool_Free(dvcman->pool);
	free(dvcman);
}
コード例 #21
0
ファイル: TestArrayList.c プロジェクト: 99455125/FreeRDP
int TestArrayList(int argc, char* argv[])
{
	int index;
	int count;
	size_t val;
	wArrayList* arrayList;
	const int elemsToInsert = 10;

	arrayList = ArrayList_New(TRUE);
	if (!arrayList)
		return -1;

	for (index = 0; index < elemsToInsert; index++)
	{
		if (ArrayList_Add(arrayList, (void*) (size_t) index) < 0)
			return -1;
	}

	count = ArrayList_Count(arrayList);

	printf("ArrayList count: %d\n", count);

	index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);

	printf("ArrayList index: %d\n", index);

	if (index != 6)
		return -1;

	ArrayList_Insert(arrayList, 5, (void*) (size_t) 100);

	index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
	printf("ArrayList index: %d\n", index);

	if (index != 7)
		return -1;

	ArrayList_Remove(arrayList, (void*) (size_t) 100);

	index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
	printf("ArrayList index: %d\n", index);

	if (index != 6)
		return -1;

	for (index = 0; index < elemsToInsert; index++) {
		val = (size_t)ArrayList_GetItem(arrayList, 0);
		ArrayList_RemoveAt(arrayList, 0);
		if (val != index)
		{
			printf("ArrayList: shifted %d entries, expected value %d, got %"PRIdz"\n", index, index, val);
			return -1;
		}
	}

	index = ArrayList_IndexOf(arrayList, (void*) (size_t) elemsToInsert, -1, -1);
	printf("ArrayList index: %d\n", index);
	if (index != -1)
		return -1;

	count = ArrayList_Count(arrayList);
	printf("ArrayList count: %d\n", count);
	if (count != 0)
		return -1;

	ArrayList_Clear(arrayList);
	ArrayList_Free(arrayList);

	return 0;
}