22#include <freerdp/config.h>
25#include <winpr/print.h>
26#include <winpr/stream.h>
27#include <freerdp/channels/log.h>
28#include <freerdp/channels/drdynvc.h>
30#include "drdynvc_main.h"
32#define TAG CHANNELS_TAG("drdynvc.server")
39static UINT drdynvc_server_start(DrdynvcServerContext* context)
41 context->priv->ChannelHandle =
42 WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, DRDYNVC_SVC_CHANNEL_NAME);
44 if (!context->priv->ChannelHandle)
46 WLog_ERR(TAG,
"WTSVirtualChannelOpen failed!");
47 return CHANNEL_RC_NO_MEMORY;
50 if (!(context->priv->StopEvent = CreateEvent(
nullptr, TRUE, FALSE,
nullptr)))
52 WLog_ERR(TAG,
"CreateEvent failed!");
53 return ERROR_INTERNAL_ERROR;
56 return ERROR_INTERNAL_ERROR;
64static UINT drdynvc_server_stop(DrdynvcServerContext* context)
67 (void)SetEvent(context->priv->StopEvent);
69 if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
71 error = GetLastError();
72 WLog_ERR(TAG,
"WaitForSingleObject failed with error %" PRIu32
"!", error);
76 (void)CloseHandle(context->priv->Thread);
80DrdynvcServerContext* drdynvc_server_context_new(HANDLE vcm)
82 DrdynvcServerContext* context =
nullptr;
83 context = (DrdynvcServerContext*)calloc(1,
sizeof(DrdynvcServerContext));
88 context->Start = drdynvc_server_start;
89 context->Stop = drdynvc_server_stop;
90 context->priv = (DrdynvcServerPrivate*)calloc(1,
sizeof(DrdynvcServerPrivate));
94 WLog_ERR(TAG,
"calloc failed!");
101 WLog_ERR(TAG,
"calloc failed!");
107void drdynvc_server_context_free(DrdynvcServerContext* context)