Exemple #1
0
void test_peer_context_free(freerdp_peer* client, testPeerContext* context)
{
	if (context)
	{
		if (context->debug_channel_thread)
		{
			SetEvent(context->stopEvent);
			WaitForSingleObject(context->debug_channel_thread, INFINITE);
			CloseHandle(context->debug_channel_thread);
		}

		Stream_Free(context->s, TRUE);
		free(context->icon_data);
		free(context->bg_data);

		rfx_context_free(context->rfx_context);
		nsc_context_free(context->nsc_context);

		if (context->debug_channel)
			WTSVirtualChannelClose(context->debug_channel);

		if (context->audin)
			audin_server_context_free(context->audin);

		if (context->rdpsnd)
			rdpsnd_server_context_free(context->rdpsnd);

		WTSCloseServer((HANDLE) context->vcm);
	}
}
Exemple #2
0
bool mod_ts::closeServer(HANDLE hServer)
{
	if(hServer != WTS_CURRENT_SERVER_HANDLE)
		WTSCloseServer(hServer);

	return true;
}
Exemple #3
0
/* Called after a peer disconnects */
void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
{
	if (context)
	{
		mf_info_peer_unregister(context->info, context);
		
		dispatch_suspend(info_timer);
		
		Stream_Free(context->s, TRUE);
		
		rfx_context_free(context->rfx_context);
		//nsc_context_free(context->nsc_context);
		
#ifdef CHANNEL_AUDIN_SERVER
		if (context->audin)
			audin_server_context_free(context->audin);
#endif
		
		//#ifdef CHANNEL_RDPSND_SERVER
		mf_peer_rdpsnd_stop();
		if (context->rdpsnd)
			rdpsnd_server_context_free(context->rdpsnd);
		//#endif
		
		WTSCloseServer(context->vcm);
	}
}
Exemple #4
0
	virtual BOOL Close(void) {
		if (m_handle){
			// No return value
			WTSCloseServer(m_handle);
			m_handle = 0;
			}
		return TRUE;
	}
Exemple #5
0
void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context)
{
	wf_info_peer_unregister(context->info, context);

	if (context->rdpsnd)
	{
		wf_rdpsnd_lock();
		context->info->snd_stop = TRUE;
		rdpsnd_server_context_free(context->rdpsnd);
		wf_rdpsnd_unlock();
	}

	WTSCloseServer(context->vcm);
}
Exemple #6
0
// @pymethod |win32ts|WTSCloseServer|Closes a terminal server handle
static PyObject *PyWTSCloseServer(PyObject *self, PyObject *args, PyObject *kwargs)
{
	static char *keywords[]={"Server",NULL};
	PyObject *obh;
	HANDLE h;
	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:WTSCloseServer", keywords,
		&obh))	// @pyparm <o PyHANDLE>|Server||Terminal Server handle
		return NULL;
	if (!PyWinObject_AsHANDLE(obh, &h))
		return NULL;
	WTSCloseServer(h);
	Py_INCREF(Py_None);
	return Py_None;
}
Exemple #7
0
BOOL wf_peer_context_new(freerdp_peer* client, wfPeerContext* context)
{
	if (!(context->info = wf_info_get_instance()))
		return FALSE;

	context->vcm = WTSOpenServerA((LPSTR) client->context);

	if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE)
		return FALSE;

	if (!wf_info_peer_register(context->info, context))
	{
		WTSCloseServer(context->vcm);
		context->vcm = NULL;
		return FALSE;
	}

	return TRUE;
}
Exemple #8
0
void shadow_client_context_free(freerdp_peer* peer, rdpShadowClient* client)
{
	rdpShadowServer* server = client->server;

	ArrayList_Remove(server->clients, (void*) client);

	DeleteCriticalSection(&(client->lock));

	region16_uninit(&(client->invalidRegion));

	WTSCloseServer((HANDLE) client->vcm);

    /* Clear queued messages and free resource */
	MessageQueue_Clear(client->MsgQueue);
	MessageQueue_Free(client->MsgQueue);

	if (client->encoder)
	{
		shadow_encoder_free(client->encoder);
		client->encoder = NULL;
	}
}
Exemple #9
0
BOOL shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
{
	rdpSettings* settings;
	rdpShadowServer* server;
	const wObject cb = { NULL, NULL, NULL, shadow_client_free_queued_message, NULL };

	server = (rdpShadowServer*) peer->ContextExtra;
	client->server = server;
	client->subsystem = server->subsystem;

	settings = peer->settings;

	settings->ColorDepth = 32;
	settings->NSCodec = TRUE;
	settings->RemoteFxCodec = TRUE;
	settings->BitmapCacheV3Enabled = TRUE;
	settings->FrameMarkerCommandEnabled = TRUE;
	settings->SurfaceFrameMarkerEnabled = TRUE;
	settings->SupportGraphicsPipeline = FALSE;

	settings->DrawAllowSkipAlpha = TRUE;
	settings->DrawAllowColorSubsampling = TRUE;
	settings->DrawAllowDynamicColorFidelity = TRUE;

	settings->CompressionLevel = PACKET_COMPR_TYPE_RDP6;

	settings->RdpSecurity = TRUE;
	settings->TlsSecurity = TRUE;
	settings->NlaSecurity = FALSE;

	if (!(settings->CertificateFile = _strdup(server->CertificateFile)))
		goto fail_cert_file;
	if (!(settings->PrivateKeyFile = _strdup(server->PrivateKeyFile)))
		goto fail_privkey_file;
	if (!(settings->RdpKeyFile = _strdup(settings->PrivateKeyFile)))
		goto fail_rdpkey_file;


	if (server->ipcSocket)
	{
		settings->LyncRdpMode = TRUE;
		settings->CompressionEnabled = FALSE;
	}

	client->inLobby = TRUE;
	client->mayView = server->mayView;
	client->mayInteract = server->mayInteract;

	if (!InitializeCriticalSectionAndSpinCount(&(client->lock), 4000))
		goto fail_client_lock;

	region16_init(&(client->invalidRegion));

	client->vcm = WTSOpenServerA((LPSTR) peer->context);
	if (!client->vcm || client->vcm == INVALID_HANDLE_VALUE)
		goto fail_open_server;

	if (!(client->MsgQueue = MessageQueue_New(&cb)))
		goto fail_message_queue;

	if (!(client->encoder = shadow_encoder_new(client)))
		goto fail_encoder_new;

	if (ArrayList_Add(server->clients, (void*) client) >= 0)
		return TRUE;

	shadow_encoder_free(client->encoder);
	client->encoder = NULL;
fail_encoder_new:
	MessageQueue_Free(client->MsgQueue);
	client->MsgQueue = NULL;
fail_message_queue:
	WTSCloseServer((HANDLE) client->vcm);
	client->vcm = NULL;
fail_open_server:
	DeleteCriticalSection(&(client->lock));
fail_client_lock:
	free(settings->RdpKeyFile);
	settings->RdpKeyFile = NULL;
fail_rdpkey_file:
	free(settings->PrivateKeyFile);
	settings->PrivateKeyFile = NULL;
fail_privkey_file:
	free(settings->CertificateFile);
	settings->CertificateFile = NULL;
fail_cert_file:

	return FALSE;
}
void CProcessDlg::OnCancel() 
{
	WTSCloseServer(serverHandle);
	WTSFreeMemory(pProcessInfo);
	CDialog::OnCancel();
}
Exemple #11
0
void freerds_peer_context_free(freerdp_peer* client, rdsConnection* context)
{
	freerds_connection_uninit(context);
	WTSCloseServer((HANDLE) context->vcm);
}
Exemple #12
0
void main(int argc, char *argv[])
{
	char *helpMsg = "\nUSAGE: users.exe [hostname]\n\nNot specifying a hostname implies localhost.\nThis command will return information about users currently logged onto\na local or remote computer, including the client's hostname and IP.\nUsers.exe was written by Ryan Ries.\n";
	char *hostName, *connState = "";
	char *addrFamily = "";
	HANDLE hHost = NULL;
	int retVal = 0;
	unsigned int i = 0;
	PWTS_SESSION_INFO pSessionInfo = 0;
	DWORD dwSessionCount, pBytesReturned = 0;
	LPTSTR pUser, pDomain, pClientName, pClientAddress;
	PWTS_CLIENT_ADDRESS pClientAddressStruct = NULL;

	if(argc > 2)
	{
		printf(helpMsg);
		return;
	}
	if(argc == 2)
	{
		if(strchr(argv[1],'?') || strchr(argv[1],'/') || strchr(argv[1],'\\'))
		{
			printf(helpMsg);
			return;
		}
	}
	
	if(argc < 2)
		hostName = "localhost";
	else
		hostName = argv[1];

	hHost = WTSOpenServer(hostName);	
	retVal = WTSEnumerateSessions(hHost, 0, 1, &pSessionInfo, &dwSessionCount);	
	if(retVal == 0)
	{
		printf("ERROR %d: Could not connect to %s!", GetLastError(), hostName);
		WTSCloseServer(hHost);
		return;
	}

	printf("\n");
	for(i = 0; i < dwSessionCount; i++)
	{		
		WTS_SESSION_INFO si = pSessionInfo[i];
		// To weed out nonsense
		if(si.SessionId > 2048 || si.SessionId < 0)
			continue;
		WTSQuerySessionInformation(hHost, si.SessionId, WTSUserName, &pUser, &pBytesReturned);
        WTSQuerySessionInformation(hHost, si.SessionId, WTSDomainName, &pDomain, &pBytesReturned);
        WTSQuerySessionInformation(hHost, si.SessionId, WTSClientName, &pClientName, &pBytesReturned);
		WTSQuerySessionInformation(hHost, si.SessionId, WTSClientAddress, &pClientAddress, &pBytesReturned);
		pClientAddressStruct = (PWTS_CLIENT_ADDRESS)pClientAddress;

		switch(pClientAddressStruct->AddressFamily)
		{
		case 0:
            addrFamily = "AF_UNSPEC";
            break;
		case 2:
            addrFamily = "AF_INET";
            break;
		case 6:
            addrFamily = "AF_IPX";
            break;
		case 17:
			addrFamily = "AF_NETBIOS";
            break;
		default:
			addrFamily = "Unknown";
			break;
		}

		printf("Session ID  : %i\n", si.SessionId);
		if(strlen(pUser) < 1)
			printf("Domain\\User : System\n");
		else
			printf("Domain\\User : %s\\%s\n", pDomain, pUser);
		if(strlen(pClientName) < 1)
			printf("Client Name : Local\n");
		else
			printf("Client Name : %s\n", pClientName);
		if(pClientAddressStruct->Address[2] == 0 || addrFamily == "AF_UNSPEC")
			printf("Net Address : n/a\n");
		else
			printf("Net Address : %u.%u.%u.%u (%s)\n", pClientAddressStruct->Address[2], pClientAddressStruct->Address[3], pClientAddressStruct->Address[4], pClientAddressStruct->Address[5], addrFamily);		
		
		switch(si.State)
		{
		case 0:
			connState = "Active";
			break;
		case 1:
			connState = "Connected";
			break;
		case 4:
			connState = "Disconnected";
			break;
		case 5:
			connState = "Idle";
			break;
		default:
			connState = "Unknown";
			break;
		}
		printf("Conn. State : %s\n", connState);
		printf("\n");		
		WTSFreeMemory(pClientAddress);
		WTSFreeMemory(pClientName);
		WTSFreeMemory(pDomain);
		WTSFreeMemory(pUser);
	}
	WTSFreeMemory(pSessionInfo);
	WTSCloseServer(hHost);
}