summaryrefslogtreecommitdiffstats
path: root/include/freerdp/server
diff options
context:
space:
mode:
Diffstat (limited to 'include/freerdp/server')
-rw-r--r--include/freerdp/server/ainput.h124
-rw-r--r--include/freerdp/server/audin.h179
-rw-r--r--include/freerdp/server/channels.h25
-rw-r--r--include/freerdp/server/cliprdr.h146
-rw-r--r--include/freerdp/server/disp.h78
-rw-r--r--include/freerdp/server/drdynvc.h63
-rw-r--r--include/freerdp/server/echo.h102
-rw-r--r--include/freerdp/server/encomsp.h104
-rw-r--r--include/freerdp/server/gfxredir.h103
-rw-r--r--include/freerdp/server/location.h142
-rw-r--r--include/freerdp/server/proxy/proxy_config.h235
-rw-r--r--include/freerdp/server/proxy/proxy_context.h186
-rw-r--r--include/freerdp/server/proxy/proxy_log.h53
-rw-r--r--include/freerdp/server/proxy/proxy_modules_api.h241
-rw-r--r--include/freerdp/server/proxy/proxy_server.h115
-rw-r--r--include/freerdp/server/proxy/proxy_types.h57
-rw-r--r--include/freerdp/server/rail.h157
-rw-r--r--include/freerdp/server/rdpdr.h227
-rw-r--r--include/freerdp/server/rdpecam-enumerator.h137
-rw-r--r--include/freerdp/server/rdpecam.h284
-rw-r--r--include/freerdp/server/rdpei.h81
-rw-r--r--include/freerdp/server/rdpemsc.h132
-rw-r--r--include/freerdp/server/rdpgfx.h156
-rw-r--r--include/freerdp/server/rdpsnd.h196
-rw-r--r--include/freerdp/server/remdesk.h67
-rw-r--r--include/freerdp/server/server-common.h44
-rw-r--r--include/freerdp/server/shadow.h350
-rw-r--r--include/freerdp/server/telemetry.h111
28 files changed, 3895 insertions, 0 deletions
diff --git a/include/freerdp/server/ainput.h b/include/freerdp/server/ainput.h
new file mode 100644
index 0000000..21c47d6
--- /dev/null
+++ b/include/freerdp/server/ainput.h
@@ -0,0 +1,124 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * AInput Virtual Channel Extension
+ *
+ * Copyright 2022 Armin Novak <anovak@thincast.com>
+ * Copyright 2022 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_AINPUT_SERVER_H
+#define FREERDP_CHANNEL_AINPUT_SERVER_H
+
+#include <freerdp/channels/wtsvc.h>
+#include <freerdp/channels/ainput.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef enum AINPUT_SERVER_OPEN_RESULT
+ {
+ AINPUT_SERVER_OPEN_RESULT_OK = 0,
+ AINPUT_SERVER_OPEN_RESULT_CLOSED = 1,
+ AINPUT_SERVER_OPEN_RESULT_NOTSUPPORTED = 2,
+ AINPUT_SERVER_OPEN_RESULT_ERROR = 3
+ } AINPUT_SERVER_OPEN_RESULT;
+
+ typedef struct s_ainput_server_context ainput_server_context;
+
+ typedef BOOL (*psAInputChannelIdAssigned)(ainput_server_context* context, UINT32 channelId);
+
+ typedef UINT (*psAInputServerInitialize)(ainput_server_context* context, BOOL externalThread);
+ typedef UINT (*psAInputServerPoll)(ainput_server_context* context);
+ typedef BOOL (*psAInputServerChannelHandle)(ainput_server_context* context, HANDLE* handle);
+
+ typedef UINT (*psAInputServerOpen)(ainput_server_context* context);
+ typedef UINT (*psAInputServerClose)(ainput_server_context* context);
+ typedef BOOL (*psAInputServerIsOpen)(ainput_server_context* context);
+
+ typedef UINT (*psAInputServerOpenResult)(ainput_server_context* context,
+ AINPUT_SERVER_OPEN_RESULT result);
+ typedef UINT (*psAInputServerMouseEvent)(ainput_server_context* context, UINT64 timestamp,
+ UINT64 flags, INT32 x, INT32 y);
+
+ struct s_ainput_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* data;
+
+ /*** APIs called by the server. ***/
+ /**
+ * Open the ainput channel.
+ */
+ psAInputServerOpen Open;
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE the application is responsible to call
+ * ainput_server_context_poll periodically to process input events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psAInputServerInitialize Initialize;
+
+ /**
+ * @brief Poll When externalThread=TRUE call periodically from your main loop.
+ * if externalThread=FALSE do not call.
+ */
+ psAInputServerPoll Poll;
+
+ /**
+ * @brief Poll When externalThread=TRUE call to get a handle to wait for events.
+ * Will return FALSE until the handle is available.
+ */
+ psAInputServerChannelHandle ChannelHandle;
+
+ /**
+ * Close the ainput channel.
+ */
+ psAInputServerClose Close;
+ /**
+ * Status of the ainput channel.
+ */
+ psAInputServerIsOpen IsOpen;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Receive ainput mouse event PDU.
+ */
+ psAInputServerMouseEvent MouseEvent;
+
+ rdpContext* rdpcontext;
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psAInputChannelIdAssigned ChannelIdAssigned;
+ };
+
+ FREERDP_API void ainput_server_context_free(ainput_server_context* context);
+
+ WINPR_ATTR_MALLOC(ainput_server_context_free, 1)
+ FREERDP_API ainput_server_context* ainput_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_AINPUT_SERVER_H */
diff --git a/include/freerdp/server/audin.h b/include/freerdp/server/audin.h
new file mode 100644
index 0000000..51d83fe
--- /dev/null
+++ b/include/freerdp/server/audin.h
@@ -0,0 +1,179 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Server Audio Input Virtual Channel
+ *
+ * Copyright 2012 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ * Copyright 2023 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_AUDIN_SERVER_H
+#define FREERDP_CHANNEL_AUDIN_SERVER_H
+
+#include <freerdp/config.h>
+
+#include <freerdp/channels/audin.h>
+#include <freerdp/channels/wtsvc.h>
+
+#if !defined(CHANNEL_AUDIN_SERVER)
+#error "This header must not be included if CHANNEL_AUDIN_SERVER is not defined"
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_audin_server_context audin_server_context;
+
+ typedef BOOL (*psAudinServerChannelOpen)(audin_server_context* context);
+ typedef BOOL (*psAudinServerChannelIsOpen)(audin_server_context* context);
+ typedef BOOL (*psAudinServerChannelClose)(audin_server_context* context);
+
+ typedef BOOL (*psAudinServerChannelIdAssigned)(audin_server_context* context, UINT32 channelId);
+
+ typedef UINT (*psAudinServerVersion)(audin_server_context* context,
+ const SNDIN_VERSION* version);
+ typedef UINT (*psAudinServerFormats)(audin_server_context* context,
+ const SNDIN_FORMATS* formats);
+ typedef UINT (*psAudinServerOpen)(audin_server_context* context, const SNDIN_OPEN* open);
+ typedef UINT (*psAudinServerOpenReply)(audin_server_context* context,
+ const SNDIN_OPEN_REPLY* open_reply);
+ typedef UINT (*psAudinServerIncomingData)(audin_server_context* context,
+ const SNDIN_DATA_INCOMING* data_incoming);
+ typedef UINT (*psAudinServerData)(audin_server_context* context, const SNDIN_DATA* data);
+ typedef UINT (*psAudinServerFormatChange)(audin_server_context* context,
+ const SNDIN_FORMATCHANGE* format_change);
+
+ struct s_audin_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /**
+ * Server version to send to the client, when the DVC was successfully
+ * opened.
+ **/
+ SNDIN_VERSION_Version serverVersion;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Open the audio input channel.
+ */
+ psAudinServerChannelOpen Open;
+
+ /**
+ * Check, whether the audio input channel thread was created
+ */
+ psAudinServerChannelIsOpen IsOpen;
+
+ /**
+ * Close the audio input channel.
+ */
+ psAudinServerChannelClose Close;
+
+ /**
+ * For the following server to client PDUs,
+ * the message header does not have to be set.
+ */
+
+ /**
+ * Send a Version PDU.
+ */
+ psAudinServerVersion SendVersion;
+
+ /**
+ * Send a Sound Formats PDU.
+ */
+ psAudinServerFormats SendFormats;
+
+ /**
+ * Send an Open PDU.
+ */
+ psAudinServerOpen SendOpen;
+
+ /**
+ * Send a Format Change PDU.
+ */
+ psAudinServerFormatChange SendFormatChange;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psAudinServerChannelIdAssigned ChannelIdAssigned;
+
+ /*
+ * Callback for the Version PDU.
+ */
+ psAudinServerVersion ReceiveVersion;
+
+ /*
+ * Callback for the Sound Formats PDU.
+ */
+ psAudinServerFormats ReceiveFormats;
+
+ /*
+ * Callback for the Open Reply PDU.
+ */
+ psAudinServerOpenReply OpenReply;
+
+ /*
+ * Callback for the Incoming Data PDU.
+ */
+ psAudinServerIncomingData IncomingData;
+
+ /*
+ * Callback for the Data PDU.
+ */
+ psAudinServerData Data;
+
+ /*
+ * Callback for the Format Change PDU.
+ */
+ psAudinServerFormatChange ReceiveFormatChange;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void audin_server_context_free(audin_server_context* context);
+
+ WINPR_ATTR_MALLOC(audin_server_context_free, 1)
+ FREERDP_API audin_server_context* audin_server_context_new(HANDLE vcm);
+
+ /** \brief sets the supported audio formats for AUDIN server channel context.
+ *
+ * \param context The context to set the formats for
+ * \param count The number of formats found in \b formats. Use \b -1 to set to default formats
+ * supported by FreeRDP \param formats An array of \b count elements
+ *
+ * \return \b TRUE if successful and at least one format is supported, \b FALSE otherwise.
+ */
+ FREERDP_API BOOL audin_server_set_formats(audin_server_context* context, SSIZE_T count,
+ const AUDIO_FORMAT* formats);
+
+ FREERDP_API const AUDIO_FORMAT*
+ audin_server_get_negotiated_format(const audin_server_context* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_AUDIN_SERVER_H */
diff --git a/include/freerdp/server/channels.h b/include/freerdp/server/channels.h
new file mode 100644
index 0000000..65b6b7f
--- /dev/null
+++ b/include/freerdp/server/channels.h
@@ -0,0 +1,25 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Server Channels
+ *
+ * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNELS_SERVER_H
+#define FREERDP_CHANNELS_SERVER_H
+
+#include <freerdp/api.h>
+
+#endif /* FREERDP_CHANNELS_SERVER_H */
diff --git a/include/freerdp/server/cliprdr.h b/include/freerdp/server/cliprdr.h
new file mode 100644
index 0000000..77ebb00
--- /dev/null
+++ b/include/freerdp/server/cliprdr.h
@@ -0,0 +1,146 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Clipboard Virtual Channel Server Interface
+ *
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_CLIPRDR_SERVER_CLIPRDR_H
+#define FREERDP_CHANNEL_CLIPRDR_SERVER_CLIPRDR_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+#include <freerdp/channels/wtsvc.h>
+
+#include <freerdp/channels/cliprdr.h>
+#include <freerdp/client/cliprdr.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * Server Interface
+ */
+
+ typedef struct s_cliprdr_server_context CliprdrServerContext;
+
+ typedef UINT (*psCliprdrOpen)(CliprdrServerContext* context);
+ typedef UINT (*psCliprdrClose)(CliprdrServerContext* context);
+ typedef UINT (*psCliprdrStart)(CliprdrServerContext* context);
+ typedef UINT (*psCliprdrStop)(CliprdrServerContext* context);
+ typedef HANDLE (*psCliprdrGetEventHandle)(CliprdrServerContext* context);
+ typedef UINT (*psCliprdrCheckEventHandle)(CliprdrServerContext* context);
+
+ typedef UINT (*psCliprdrServerCapabilities)(CliprdrServerContext* context,
+ const CLIPRDR_CAPABILITIES* capabilities);
+ typedef UINT (*psCliprdrClientCapabilities)(CliprdrServerContext* context,
+ const CLIPRDR_CAPABILITIES* capabilities);
+ typedef UINT (*psCliprdrMonitorReady)(CliprdrServerContext* context,
+ const CLIPRDR_MONITOR_READY* monitorReady);
+ typedef UINT (*psCliprdrTempDirectory)(CliprdrServerContext* context,
+ const CLIPRDR_TEMP_DIRECTORY* tempDirectory);
+ typedef UINT (*psCliprdrClientFormatList)(CliprdrServerContext* context,
+ const CLIPRDR_FORMAT_LIST* formatList);
+ typedef UINT (*psCliprdrServerFormatList)(CliprdrServerContext* context,
+ const CLIPRDR_FORMAT_LIST* formatList);
+ typedef UINT (*psCliprdrClientFormatListResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse);
+ typedef UINT (*psCliprdrServerFormatListResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse);
+ typedef UINT (*psCliprdrClientLockClipboardData)(
+ CliprdrServerContext* context, const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
+ typedef UINT (*psCliprdrServerLockClipboardData)(
+ CliprdrServerContext* context, const CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData);
+ typedef UINT (*psCliprdrClientUnlockClipboardData)(
+ CliprdrServerContext* context, const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
+ typedef UINT (*psCliprdrServerUnlockClipboardData)(
+ CliprdrServerContext* context, const CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData);
+ typedef UINT (*psCliprdrClientFormatDataRequest)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest);
+ typedef UINT (*psCliprdrServerFormatDataRequest)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest);
+ typedef UINT (*psCliprdrClientFormatDataResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse);
+ typedef UINT (*psCliprdrServerFormatDataResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse);
+ typedef UINT (*psCliprdrClientFileContentsRequest)(
+ CliprdrServerContext* context, const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest);
+ typedef UINT (*psCliprdrServerFileContentsRequest)(
+ CliprdrServerContext* context, const CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest);
+ typedef UINT (*psCliprdrClientFileContentsResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse);
+ typedef UINT (*psCliprdrServerFileContentsResponse)(
+ CliprdrServerContext* context, const CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse);
+
+ struct s_cliprdr_server_context
+ {
+ void* handle;
+ void* custom;
+
+ /* server clipboard capabilities - set by server - updated by the channel after client
+ * capability exchange */
+ BOOL useLongFormatNames;
+ BOOL streamFileClipEnabled;
+ BOOL fileClipNoFilePaths;
+ BOOL canLockClipData;
+
+ psCliprdrOpen Open;
+ psCliprdrClose Close;
+ psCliprdrStart Start;
+ psCliprdrStop Stop;
+ psCliprdrGetEventHandle GetEventHandle;
+ psCliprdrCheckEventHandle CheckEventHandle;
+
+ psCliprdrServerCapabilities ServerCapabilities;
+ psCliprdrClientCapabilities ClientCapabilities;
+ psCliprdrMonitorReady MonitorReady;
+ psCliprdrTempDirectory TempDirectory;
+ psCliprdrClientFormatList ClientFormatList;
+ psCliprdrServerFormatList ServerFormatList;
+ psCliprdrClientFormatListResponse ClientFormatListResponse;
+ psCliprdrServerFormatListResponse ServerFormatListResponse;
+ psCliprdrClientLockClipboardData ClientLockClipboardData;
+ psCliprdrServerLockClipboardData ServerLockClipboardData;
+ psCliprdrClientUnlockClipboardData ClientUnlockClipboardData;
+ psCliprdrServerUnlockClipboardData ServerUnlockClipboardData;
+ psCliprdrClientFormatDataRequest ClientFormatDataRequest;
+ psCliprdrServerFormatDataRequest ServerFormatDataRequest;
+ psCliprdrClientFormatDataResponse ClientFormatDataResponse;
+ psCliprdrServerFormatDataResponse ServerFormatDataResponse;
+ psCliprdrClientFileContentsRequest ClientFileContentsRequest;
+ psCliprdrServerFileContentsRequest ServerFileContentsRequest;
+ psCliprdrClientFileContentsResponse ClientFileContentsResponse;
+ psCliprdrServerFileContentsResponse ServerFileContentsResponse;
+
+ rdpContext* rdpcontext;
+ BOOL autoInitializationSequence;
+ UINT32 lastRequestedFormatId;
+ BOOL hasHugeFileSupport;
+ };
+
+ FREERDP_API void cliprdr_server_context_free(CliprdrServerContext* context);
+
+ WINPR_ATTR_MALLOC(cliprdr_server_context_free, 1)
+ FREERDP_API CliprdrServerContext* cliprdr_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_CLIPRDR_SERVER_CLIPRDR_H */
diff --git a/include/freerdp/server/disp.h b/include/freerdp/server/disp.h
new file mode 100644
index 0000000..d17c3c2
--- /dev/null
+++ b/include/freerdp/server/disp.h
@@ -0,0 +1,78 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * RDPEDISP Virtual Channel Extension
+ *
+ * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_DISP_SERVER_DISP_H
+#define FREERDP_CHANNEL_DISP_SERVER_DISP_H
+
+#include <freerdp/channels/disp.h>
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_disp_server_private DispServerPrivate;
+ typedef struct s_disp_server_context DispServerContext;
+
+ typedef BOOL (*psDispChannelIdAssigned)(DispServerContext* context, UINT32 channelId);
+
+ typedef UINT (*psDispMonitorLayout)(DispServerContext* context,
+ const DISPLAY_CONTROL_MONITOR_LAYOUT_PDU* pdu);
+ typedef UINT (*psDispCaps)(DispServerContext* context);
+ typedef UINT (*psDispOpen)(DispServerContext* context);
+ typedef UINT (*psDispClose)(DispServerContext* context);
+
+ struct s_disp_server_context
+ {
+ void* custom;
+ HANDLE vcm;
+
+ /* Server capabilities */
+ UINT32 MaxNumMonitors;
+ UINT32 MaxMonitorAreaFactorA;
+ UINT32 MaxMonitorAreaFactorB;
+
+ psDispOpen Open;
+ psDispClose Close;
+
+ psDispMonitorLayout DispMonitorLayout;
+ psDispCaps DisplayControlCaps;
+
+ DispServerPrivate* priv;
+ rdpContext* rdpcontext;
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psDispChannelIdAssigned ChannelIdAssigned;
+ };
+
+ FREERDP_API void disp_server_context_free(DispServerContext* context);
+
+ WINPR_ATTR_MALLOC(disp_server_context_free, 1)
+ FREERDP_API DispServerContext* disp_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_DISP_SERVER_DISP_H */
diff --git a/include/freerdp/server/drdynvc.h b/include/freerdp/server/drdynvc.h
new file mode 100644
index 0000000..09453f4
--- /dev/null
+++ b/include/freerdp/server/drdynvc.h
@@ -0,0 +1,63 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Dynamic Virtual Channel Extension
+ *
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_DRDYNVC_SERVER_DRDYNVC_H
+#define FREERDP_CHANNEL_DRDYNVC_SERVER_DRDYNVC_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * Server Interface
+ */
+
+ typedef struct s_drdynvc_server_context DrdynvcServerContext;
+ typedef struct s_drdynvc_server_private DrdynvcServerPrivate;
+
+ typedef UINT (*psDrdynvcStart)(DrdynvcServerContext* context);
+ typedef UINT (*psDrdynvcStop)(DrdynvcServerContext* context);
+
+ struct s_drdynvc_server_context
+ {
+ HANDLE vcm;
+
+ psDrdynvcStart Start;
+ psDrdynvcStop Stop;
+
+ DrdynvcServerPrivate* priv;
+ };
+
+ FREERDP_API void drdynvc_server_context_free(DrdynvcServerContext* context);
+
+ WINPR_ATTR_MALLOC(drdynvc_server_context_free, 1)
+ FREERDP_API DrdynvcServerContext* drdynvc_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_DRDYNVC_SERVER_DRDYNVC_H */
diff --git a/include/freerdp/server/echo.h b/include/freerdp/server/echo.h
new file mode 100644
index 0000000..609d8c3
--- /dev/null
+++ b/include/freerdp/server/echo.h
@@ -0,0 +1,102 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Echo Virtual Channel Extension
+ *
+ * Copyright 2014 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_ECHO_SERVER_H
+#define FREERDP_CHANNEL_ECHO_SERVER_H
+
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef enum ECHO_SERVER_OPEN_RESULT
+ {
+ ECHO_SERVER_OPEN_RESULT_OK = 0,
+ ECHO_SERVER_OPEN_RESULT_CLOSED = 1,
+ ECHO_SERVER_OPEN_RESULT_NOTSUPPORTED = 2,
+ ECHO_SERVER_OPEN_RESULT_ERROR = 3
+ } ECHO_SERVER_OPEN_RESULT;
+
+ typedef struct s_echo_server_context echo_server_context;
+
+ typedef BOOL (*psEchoServerChannelIdAssigned)(echo_server_context* context, UINT32 channelId);
+
+ typedef UINT (*psEchoServerOpen)(echo_server_context* context);
+ typedef UINT (*psEchoServerClose)(echo_server_context* context);
+ typedef BOOL (*psEchoServerRequest)(echo_server_context* context, const BYTE* buffer,
+ UINT32 length);
+
+ typedef UINT (*psEchoServerOpenResult)(echo_server_context* context,
+ ECHO_SERVER_OPEN_RESULT result);
+ typedef UINT (*psEchoServerResponse)(echo_server_context* context, const BYTE* buffer,
+ UINT32 length);
+
+ struct s_echo_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* data;
+
+ /*** APIs called by the server. ***/
+ /**
+ * Open the echo channel.
+ */
+ psEchoServerOpen Open;
+ /**
+ * Close the echo channel.
+ */
+ psEchoServerClose Close;
+ /**
+ * Send echo request PDU.
+ */
+ psEchoServerRequest Request;
+
+ /*** Callbacks registered by the server. ***/
+ /**
+ * Indicate whether the channel is opened successfully.
+ */
+ psEchoServerOpenResult OpenResult;
+ /**
+ * Receive echo response PDU.
+ */
+ psEchoServerResponse Response;
+
+ rdpContext* rdpcontext;
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psEchoServerChannelIdAssigned ChannelIdAssigned;
+ };
+
+ FREERDP_API void echo_server_context_free(echo_server_context* context);
+
+ WINPR_ATTR_MALLOC(echo_server_context_free, 1)
+ FREERDP_API echo_server_context* echo_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_ECHO_SERVER_H */
diff --git a/include/freerdp/server/encomsp.h b/include/freerdp/server/encomsp.h
new file mode 100644
index 0000000..534fd3e
--- /dev/null
+++ b/include/freerdp/server/encomsp.h
@@ -0,0 +1,104 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Multiparty Virtual Channel
+ *
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_ENCOMSP_SERVER_ENCOMSP_H
+#define FREERDP_CHANNEL_ENCOMSP_SERVER_ENCOMSP_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+#include <freerdp/channels/wtsvc.h>
+
+#include <freerdp/channels/encomsp.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * Server Interface
+ */
+
+ typedef struct s_encomsp_server_context EncomspServerContext;
+ typedef struct s_encomsp_server_private EncomspServerPrivate;
+
+ typedef UINT (*psEncomspStart)(EncomspServerContext* context);
+ typedef UINT (*psEncomspStop)(EncomspServerContext* context);
+
+ typedef UINT (*psEncomspFilterUpdated)(EncomspServerContext* context,
+ ENCOMSP_FILTER_UPDATED_PDU* filterUpdated);
+ typedef UINT (*psEncomspApplicationCreated)(
+ EncomspServerContext* context, ENCOMSP_APPLICATION_CREATED_PDU* applicationCreated);
+ typedef UINT (*psEncomspApplicationRemoved)(
+ EncomspServerContext* context, ENCOMSP_APPLICATION_REMOVED_PDU* applicationRemoved);
+ typedef UINT (*psEncomspWindowCreated)(EncomspServerContext* context,
+ ENCOMSP_WINDOW_CREATED_PDU* windowCreated);
+ typedef UINT (*psEncomspWindowRemoved)(EncomspServerContext* context,
+ ENCOMSP_WINDOW_REMOVED_PDU* windowRemoved);
+ typedef UINT (*psEncomspShowWindow)(EncomspServerContext* context,
+ ENCOMSP_SHOW_WINDOW_PDU* showWindow);
+ typedef UINT (*psEncomspParticipantCreated)(
+ EncomspServerContext* context, ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated);
+ typedef UINT (*psEncomspParticipantRemoved)(
+ EncomspServerContext* context, ENCOMSP_PARTICIPANT_REMOVED_PDU* participantRemoved);
+ typedef UINT (*psEncomspChangeParticipantControlLevel)(
+ EncomspServerContext* context,
+ ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU* changeParticipantControlLevel);
+ typedef UINT (*psEncomspGraphicsStreamPaused)(
+ EncomspServerContext* context, ENCOMSP_GRAPHICS_STREAM_PAUSED_PDU* graphicsStreamPaused);
+ typedef UINT (*psEncomspGraphicsStreamResumed)(
+ EncomspServerContext* context, ENCOMSP_GRAPHICS_STREAM_RESUMED_PDU* graphicsStreamResumed);
+
+ struct s_encomsp_server_context
+ {
+ HANDLE vcm;
+ void* custom;
+
+ psEncomspStart Start;
+ psEncomspStop Stop;
+
+ psEncomspFilterUpdated FilterUpdated;
+ psEncomspApplicationCreated ApplicationCreated;
+ psEncomspApplicationRemoved ApplicationRemoved;
+ psEncomspWindowCreated WindowCreated;
+ psEncomspWindowRemoved WindowRemoved;
+ psEncomspShowWindow ShowWindow;
+ psEncomspParticipantCreated ParticipantCreated;
+ psEncomspParticipantRemoved ParticipantRemoved;
+ psEncomspChangeParticipantControlLevel ChangeParticipantControlLevel;
+ psEncomspGraphicsStreamPaused GraphicsStreamPaused;
+ psEncomspGraphicsStreamResumed GraphicsStreamResumed;
+
+ EncomspServerPrivate* priv;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void encomsp_server_context_free(EncomspServerContext* context);
+
+ WINPR_ATTR_MALLOC(encomsp_server_context_free, 1)
+ FREERDP_API EncomspServerContext* encomsp_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_ENCOMSP_SERVER_ENCOMSP_H */
diff --git a/include/freerdp/server/gfxredir.h b/include/freerdp/server/gfxredir.h
new file mode 100644
index 0000000..9e10cdf
--- /dev/null
+++ b/include/freerdp/server/gfxredir.h
@@ -0,0 +1,103 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * RDPXXXX Remote App Graphics Redirection Virtual Channel Extension
+ *
+ * Copyright 2020 Microsoft
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_GFXREDIR_SERVER_GFXREDIR_H
+#define FREERDP_CHANNEL_GFXREDIR_SERVER_GFXREDIR_H
+
+#include <freerdp/channels/gfxredir.h>
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_gfxredir_server_private GfxRedirServerPrivate;
+ typedef struct s_gfxredir_server_context GfxRedirServerContext;
+
+ typedef UINT (*psGfxRedirOpen)(GfxRedirServerContext* context);
+ typedef UINT (*psGfxRedirClose)(GfxRedirServerContext* context);
+
+ typedef UINT (*psGfxRedirError)(GfxRedirServerContext* context,
+ const GFXREDIR_ERROR_PDU* error);
+
+ typedef UINT (*psGfxRedirGraphicsRedirectionLegacyCaps)(
+ GfxRedirServerContext* context, const GFXREDIR_LEGACY_CAPS_PDU* graphicsCaps);
+
+ typedef UINT (*psGfxRedirGraphicsRedirectionCapsAdvertise)(
+ GfxRedirServerContext* context, const GFXREDIR_CAPS_ADVERTISE_PDU* graphicsCapsAdvertise);
+ typedef UINT (*psGfxRedirGraphicsRedirectionCapsConfirm)(
+ GfxRedirServerContext* context, const GFXREDIR_CAPS_CONFIRM_PDU* graphicsCapsConfirm);
+
+ typedef UINT (*psGfxRedirOpenPool)(GfxRedirServerContext* context,
+ const GFXREDIR_OPEN_POOL_PDU* openPool);
+ typedef UINT (*psGfxRedirClosePool)(GfxRedirServerContext* context,
+ const GFXREDIR_CLOSE_POOL_PDU* closePool);
+
+ typedef UINT (*psGfxRedirCreateBuffer)(GfxRedirServerContext* context,
+ const GFXREDIR_CREATE_BUFFER_PDU* createBuffer);
+ typedef UINT (*psGfxRedirDestroyBuffer)(GfxRedirServerContext* context,
+ const GFXREDIR_DESTROY_BUFFER_PDU* destroyBuffer);
+
+ typedef UINT (*psGfxRedirPresentBuffer)(GfxRedirServerContext* context,
+ const GFXREDIR_PRESENT_BUFFER_PDU* presentBuffer);
+ typedef UINT (*psGfxRedirPresentBufferAck)(
+ GfxRedirServerContext* context, const GFXREDIR_PRESENT_BUFFER_ACK_PDU* presentBufferAck);
+
+ struct s_gfxredir_server_context
+ {
+ void* custom;
+ HANDLE vcm;
+
+ psGfxRedirOpen Open;
+ psGfxRedirClose Close;
+
+ psGfxRedirError Error;
+
+ psGfxRedirGraphicsRedirectionLegacyCaps GraphicsRedirectionLegacyCaps;
+
+ psGfxRedirGraphicsRedirectionCapsAdvertise GraphicsRedirectionCapsAdvertise;
+ psGfxRedirGraphicsRedirectionCapsConfirm GraphicsRedirectionCapsConfirm;
+
+ psGfxRedirOpenPool OpenPool;
+ psGfxRedirClosePool ClosePool;
+
+ psGfxRedirCreateBuffer CreateBuffer;
+ psGfxRedirDestroyBuffer DestroyBuffer;
+
+ psGfxRedirPresentBuffer PresentBuffer;
+ psGfxRedirPresentBufferAck PresentBufferAck;
+
+ GfxRedirServerPrivate* priv;
+ rdpContext* rdpcontext;
+
+ UINT32 confirmedCapsVersion;
+ };
+
+ WINPR_ATTR_MALLOC(gfxredir_server_context_free, 1)
+ FREERDP_API GfxRedirServerContext* gfxredir_server_context_new(HANDLE vcm);
+ FREERDP_API void gfxredir_server_context_free(GfxRedirServerContext* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_GFXREDIR_SERVER_GFXREDIR_H */
diff --git a/include/freerdp/server/location.h b/include/freerdp/server/location.h
new file mode 100644
index 0000000..8078878
--- /dev/null
+++ b/include/freerdp/server/location.h
@@ -0,0 +1,142 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Location Virtual Channel Extension
+ *
+ * Copyright 2023 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_LOCATION_SERVER_LOCATION_H
+#define FREERDP_CHANNEL_LOCATION_SERVER_LOCATION_H
+
+#include <freerdp/channels/location.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_location_server_context LocationServerContext;
+
+ typedef UINT (*psLocationServerOpen)(LocationServerContext* context);
+ typedef UINT (*psLocationServerClose)(LocationServerContext* context);
+
+ typedef BOOL (*psLocationServerChannelIdAssigned)(LocationServerContext* context,
+ UINT32 channelId);
+
+ typedef UINT (*psLocationServerInitialize)(LocationServerContext* context, BOOL externalThread);
+ typedef UINT (*psLocationServerPoll)(LocationServerContext* context);
+ typedef BOOL (*psLocationServerChannelHandle)(LocationServerContext* context, HANDLE* handle);
+
+ typedef UINT (*psLocationServerServerReady)(LocationServerContext* context,
+ const RDPLOCATION_SERVER_READY_PDU* serverReady);
+ typedef UINT (*psLocationServerClientReady)(LocationServerContext* context,
+ const RDPLOCATION_CLIENT_READY_PDU* clientReady);
+
+ typedef UINT (*psLocationServerBaseLocation3D)(
+ LocationServerContext* context, const RDPLOCATION_BASE_LOCATION3D_PDU* baseLocation3D);
+ typedef UINT (*psLocationServerLocation2DDelta)(
+ LocationServerContext* context, const RDPLOCATION_LOCATION2D_DELTA_PDU* location2DDelta);
+ typedef UINT (*psLocationServerLocation3DDelta)(
+ LocationServerContext* context, const RDPLOCATION_LOCATION3D_DELTA_PDU* location3DDelta);
+
+ struct s_location_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psLocationServerInitialize Initialize;
+
+ /**
+ * Open the location channel.
+ */
+ psLocationServerOpen Open;
+
+ /**
+ * Close the location channel.
+ */
+ psLocationServerClose Close;
+
+ /**
+ * Poll
+ * When externalThread=TRUE, call Poll() periodically from your main loop.
+ * If externalThread=FALSE do not call.
+ */
+ psLocationServerPoll Poll;
+
+ /**
+ * Retrieve the channel handle for use in conjunction with Poll().
+ * If externalThread=FALSE do not call.
+ */
+ psLocationServerChannelHandle ChannelHandle;
+
+ /* All PDUs sent by the server don't require the header to be set */
+
+ /*
+ * Send a ServerReady PDU.
+ */
+ psLocationServerServerReady ServerReady;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psLocationServerChannelIdAssigned ChannelIdAssigned;
+
+ /**
+ * Callback for the ClientReady PDU.
+ */
+ psLocationServerClientReady ClientReady;
+
+ /**
+ * Callback for the BaseLocation3D PDU.
+ */
+ psLocationServerBaseLocation3D BaseLocation3D;
+
+ /**
+ * Callback for the Location2DDelta PDU.
+ */
+ psLocationServerLocation2DDelta Location2DDelta;
+
+ /**
+ * Callback for the Location3DDelta PDU.
+ */
+ psLocationServerLocation3DDelta Location3DDelta;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void location_server_context_free(LocationServerContext* context);
+
+ WINPR_ATTR_MALLOC(location_server_context_free, 1)
+ FREERDP_API LocationServerContext* location_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_LOCATION_SERVER_LOCATION_H */
diff --git a/include/freerdp/server/proxy/proxy_config.h b/include/freerdp/server/proxy/proxy_config.h
new file mode 100644
index 0000000..237fdf3
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_config.h
@@ -0,0 +1,235 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy Server
+ *
+ * Copyright 2021-2023 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2021-2023 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef FREERDP_SERVER_PROXY_CONFIG_H
+#define FREERDP_SERVER_PROXY_CONFIG_H
+
+#include <winpr/wtypes.h>
+#include <winpr/ini.h>
+
+#include <freerdp/api.h>
+#include <freerdp/server/proxy/proxy_modules_api.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct proxy_config proxyConfig;
+
+ struct proxy_config
+ {
+ /* server */
+ char* Host;
+ UINT16 Port;
+
+ /* target */
+ BOOL FixedTarget;
+ char* TargetHost;
+ UINT16 TargetPort;
+ char* TargetUser;
+ char* TargetDomain;
+ char* TargetPassword;
+
+ /* input */
+ BOOL Keyboard;
+ BOOL Mouse;
+ BOOL Multitouch;
+
+ /* server security */
+ BOOL ServerTlsSecurity;
+ BOOL ServerRdpSecurity;
+ BOOL ServerNlaSecurity;
+
+ /* client security */
+ BOOL ClientNlaSecurity;
+ BOOL ClientTlsSecurity;
+ BOOL ClientRdpSecurity;
+ BOOL ClientAllowFallbackToTls;
+
+ /* channels */
+ BOOL GFX;
+ BOOL DisplayControl;
+ BOOL Clipboard;
+ BOOL AudioOutput;
+ BOOL AudioInput;
+ BOOL RemoteApp;
+ BOOL DeviceRedirection;
+ BOOL VideoRedirection;
+ BOOL CameraRedirection;
+
+ BOOL PassthroughIsBlacklist;
+ char** Passthrough;
+ size_t PassthroughCount;
+ char** Intercept;
+ size_t InterceptCount;
+
+ /* clipboard specific settings */
+ BOOL TextOnly;
+ UINT32 MaxTextLength;
+
+ /* gfx settings */
+ BOOL DecodeGFX;
+
+ /* modules */
+ char** Modules; /* module file names to load */
+ size_t ModulesCount;
+
+ char** RequiredPlugins; /* required plugin names */
+ size_t RequiredPluginsCount;
+
+ char* CertificateFile;
+ char* CertificateContent;
+
+ char* PrivateKeyFile;
+ char* PrivateKeyContent;
+
+ /* Data extracted from CertificateContent or CertificateFile (evaluation in this order) */
+ char* CertificatePEM;
+ size_t CertificatePEMLength;
+
+ /* Data extracted from PrivateKeyContent or PrivateKeyFile (evaluation in this order) */
+ char* PrivateKeyPEM;
+ size_t PrivateKeyPEMLength;
+
+ wIniFile* ini;
+
+ /* target continued */
+ UINT32 TargetTlsSecLevel;
+ };
+
+ /**
+ * @brief pf_server_config_dump Dumps a default INI configuration file
+ * @param file The file to write to. Existing files are truncated.
+ * @return TRUE for success, FALSE if the file could not be written.
+ */
+ FREERDP_API BOOL pf_server_config_dump(const char* file);
+
+ /**
+ * @brief server_config_load_ini Create a proxyConfig from a already loaded
+ * INI file.
+ *
+ * @param ini A pointer to the parsed INI file. Must NOT be NULL.
+ *
+ * @return A proxyConfig or NULL in case of failure.
+ */
+ FREERDP_API proxyConfig* server_config_load_ini(wIniFile* ini);
+ /**
+ * @brief pf_server_config_load_file Create a proxyConfig from a INI file found at path.
+ *
+ * @param path The path of the INI file
+ *
+ * @return A proxyConfig or NULL in case of failure.
+ */
+ FREERDP_API proxyConfig* pf_server_config_load_file(const char* path);
+
+ /**
+ * @brief pf_server_config_load_buffer Create a proxyConfig from a memory string buffer in INI
+ * file format
+ *
+ * @param buffer A pointer to the '\0' terminated INI string.
+ *
+ * @return A proxyConfig or NULL in case of failure.
+ */
+ FREERDP_API proxyConfig* pf_server_config_load_buffer(const char* buffer);
+
+ /**
+ * @brief pf_server_config_print Print the configuration to stdout
+ *
+ * @param config A pointer to the configuration to print. Must NOT be NULL.
+ */
+ FREERDP_API void pf_server_config_print(const proxyConfig* config);
+
+ /**
+ * @brief pf_server_config_free Releases all resources associated with proxyConfig
+ *
+ * @param config A pointer to the proxyConfig to clean up. Might be NULL.
+ */
+ FREERDP_API void pf_server_config_free(proxyConfig* config);
+
+ /**
+ * @brief pf_config_required_plugins_count
+ *
+ * @param config A pointer to the proxyConfig. Must NOT be NULL.
+ *
+ * @return The number of required plugins configured.
+ */
+ FREERDP_API size_t pf_config_required_plugins_count(const proxyConfig* config);
+
+ /**
+ * @brief pf_config_required_plugin
+ * @param config A pointer to the proxyConfig. Must NOT be NULL.
+ * @param index The index of the plugin to return
+ *
+ * @return The name of the plugin or NULL.
+ */
+ FREERDP_API const char* pf_config_required_plugin(const proxyConfig* config, size_t index);
+
+ /**
+ * @brief pf_config_modules_count
+ *
+ * @param config A pointer to the proxyConfig. Must NOT be NULL.
+ *
+ * @return The number of proxy modules configured.
+ */
+ FREERDP_API size_t pf_config_modules_count(const proxyConfig* config);
+
+ /**
+ * @brief pf_config_modules
+ * @param config A pointer to the proxyConfig. Must NOT be NULL.
+ *
+ * @return An array of strings of size pf_config_modules_count with the module names.
+ */
+ FREERDP_API const char** pf_config_modules(const proxyConfig* config);
+
+ /**
+ * @brief pf_config_clone Create a copy of the configuration
+ * @param dst A pointer that receives the newly allocated copy
+ * @param config The source configuration to copy
+ *
+ * @return TRUE for success, FALSE otherwise
+ */
+ FREERDP_API BOOL pf_config_clone(proxyConfig** dst, const proxyConfig* config);
+
+ /**
+ * @brief pf_config_plugin Register a proxy plugin handling event filtering
+ * defined in the configuration.
+ *
+ * @param plugins_manager The plugin manager
+ * @param userdata A proxyConfig* to use as reference
+ *
+ * @return TRUE for success, FALSE for failure
+ */
+ FREERDP_API BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata);
+
+ /**
+ * @brief pf_config_get get a value for a section/key
+ * @param config A pointer to the proxyConfig. Must NOT be NULL.
+ * @param section The name of the section the key is in, must not be \b NULL
+ * @param key The name of the key to look for. Must not be \b NULL
+ *
+ * @return A pointer to the value for \b section/key or \b NULL if not found
+ */
+ FREERDP_API const char* pf_config_get(const proxyConfig* config, const char* section,
+ const char* key);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* FREERDP_SERVER_PROXY_CONFIG_H */
diff --git a/include/freerdp/server/proxy/proxy_context.h b/include/freerdp/server/proxy/proxy_context.h
new file mode 100644
index 0000000..0132c66
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_context.h
@@ -0,0 +1,186 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy Server
+ *
+ * Copyright 2019 Mati Shabtay <matishabtay@gmail.com>
+ * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
+ * Copyright 2019 Idan Freiberg <speidy@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_PROXY_PFCONTEXT_H
+#define FREERDP_SERVER_PROXY_PFCONTEXT_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#include <freerdp/freerdp.h>
+#include <freerdp/channels/wtsvc.h>
+
+#include <freerdp/server/proxy/proxy_config.h>
+#include <freerdp/server/proxy/proxy_types.h>
+
+#define PROXY_SESSION_ID_LENGTH 32
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct proxy_data proxyData;
+ typedef struct proxy_module proxyModule;
+ typedef struct p_server_static_channel_context pServerStaticChannelContext;
+
+ typedef struct s_InterceptContextMapEntry
+ {
+ void (*free)(struct s_InterceptContextMapEntry*);
+ } InterceptContextMapEntry;
+
+ /* All proxy interception channels derive from this base struct
+ * and set their cleanup function accordingly. */
+ FREERDP_API void intercept_context_entry_free(void* obj);
+ typedef PfChannelResult (*proxyChannelDataFn)(proxyData* pdata,
+ const pServerStaticChannelContext* channel,
+ const BYTE* xdata, size_t xsize, UINT32 flags,
+ size_t totalSizepServer);
+ typedef void (*proxyChannelContextDtor)(void* context);
+
+ /** @brief per channel configuration */
+ struct p_server_static_channel_context
+ {
+ char* channel_name;
+ UINT32 front_channel_id;
+ UINT32 back_channel_id;
+ pf_utils_channel_mode channelMode;
+ proxyChannelDataFn onFrontData;
+ proxyChannelDataFn onBackData;
+ proxyChannelContextDtor contextDtor;
+ void* context;
+ };
+
+ void StaticChannelContext_free(pServerStaticChannelContext* ctx);
+
+ /**
+ * Wraps rdpContext and holds the state for the proxy's server.
+ */
+ struct p_server_context
+ {
+ rdpContext context;
+
+ proxyData* pdata;
+
+ HANDLE vcm;
+ HANDLE dynvcReady;
+
+ wHashTable* interceptContextMap;
+ wHashTable* channelsByFrontId;
+ wHashTable* channelsByBackId;
+ };
+ typedef struct p_server_context pServerContext;
+
+ WINPR_ATTR_MALLOC(StaticChannelContext_free, 1)
+ pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const char* name,
+ UINT32 id);
+
+ /**
+ * Wraps rdpContext and holds the state for the proxy's client.
+ */
+ typedef struct p_client_context pClientContext;
+
+ struct p_client_context
+ {
+ rdpContext context;
+
+ proxyData* pdata;
+
+ /*
+ * In a case when freerdp_connect fails,
+ * Used for NLA fallback feature, to check if the server should close the connection.
+ * When it is set to TRUE, proxy's client knows it shouldn't signal the server thread to
+ * closed the connection when pf_client_post_disconnect is called, because it is trying to
+ * connect reconnect without NLA. It must be set to TRUE before the first try, and to FALSE
+ * after the connection fully established, to ensure graceful shutdown of the connection
+ * when it will be closed.
+ */
+ BOOL allow_next_conn_failure;
+
+ BOOL connected; /* Set after client post_connect. */
+
+ pReceiveChannelData client_receive_channel_data_original;
+ wQueue* cached_server_channel_data;
+ BOOL (*sendChannelData)(pClientContext* pc, const proxyChannelDataEventInfo* ev);
+
+ /* X509 specific */
+ char* remote_hostname;
+ wStream* remote_pem;
+ UINT16 remote_port;
+ UINT32 remote_flags;
+
+ BOOL input_state_sync_pending;
+ UINT32 input_state;
+
+ wHashTable* interceptContextMap;
+ UINT32 computerNameLen;
+ BOOL computerNameUnicode;
+ union
+ {
+ WCHAR* wc;
+ char* c;
+ void* v;
+ } computerName;
+ };
+
+ /**
+ * Holds data common to both sides of a proxy's session.
+ */
+ struct proxy_data
+ {
+ proxyModule* module;
+ const proxyConfig* config;
+
+ pServerContext* ps;
+ pClientContext* pc;
+
+ HANDLE abort_event;
+ HANDLE client_thread;
+ HANDLE gfx_server_ready;
+
+ char session_id[PROXY_SESSION_ID_LENGTH + 1];
+
+ /* used to external modules to store per-session info */
+ wHashTable* modules_info;
+ psPeerReceiveChannelData server_receive_channel_data_original;
+ };
+
+ FREERDP_API BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
+ FREERDP_API BOOL pf_context_init_server_context(freerdp_peer* client);
+
+ WINPR_ATTR_MALLOC(freerdp_client_context_free, 1)
+ FREERDP_API pClientContext* pf_context_create_client_context(const rdpSettings* clientSettings);
+
+ FREERDP_API void proxy_data_free(proxyData* pdata);
+
+ WINPR_ATTR_MALLOC(proxy_data_free, 1)
+ FREERDP_API proxyData* proxy_data_new(void);
+ FREERDP_API void proxy_data_set_client_context(proxyData* pdata, pClientContext* context);
+ FREERDP_API void proxy_data_set_server_context(proxyData* pdata, pServerContext* context);
+
+ FREERDP_API BOOL proxy_data_shall_disconnect(proxyData* pdata);
+ FREERDP_API void proxy_data_abort_connect(proxyData* pdata);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_PROXY_PFCONTEXT_H */
diff --git a/include/freerdp/server/proxy/proxy_log.h b/include/freerdp/server/proxy/proxy_log.h
new file mode 100644
index 0000000..3f3be2c
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_log.h
@@ -0,0 +1,53 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy Server
+ *
+ * Copyright 2019 Mati Shabtay <matishabtay@gmail.com>
+ * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
+ * Copyright 2019 Idan Freiberg <speidy@gmail.com>
+ * Copyright 2021 Armin Novak <anovak@thincast.com>
+ * Copyright 2021 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_PROXY_LOG_H
+#define FREERDP_SERVER_PROXY_LOG_H
+
+#include <winpr/wlog.h>
+#include <freerdp/log.h>
+
+#define PROXY_TAG(tag) FREERDP_TAG("proxy." tag)
+
+/*
+ * log format in proxy is:
+ * "[SessionID=%s]: Log message"
+ * SessionID is optional, but if they should be written to the log,
+ * that's the format.
+ */
+
+/* log macros that prepends session id and function name tp the log message */
+#define PROXY_LOG_INFO(_tag, _context, _format, ...) \
+ WLog_INFO(TAG, "[SessionID=%s]: " _format, \
+ (_context && _context->pdata) ? _context->pdata->session_id : "null", ##__VA_ARGS__)
+#define PROXY_LOG_ERR(_tag, _context, _format, ...) \
+ WLog_ERR(TAG, "[SessionID=%s]: " _format, \
+ (_context && _context->pdata) ? _context->pdata->session_id : "null", ##__VA_ARGS__)
+#define PROXY_LOG_DBG(_tag, _context, _format, ...) \
+ WLog_DBG(TAG, "[SessionID=%s]: " _format, \
+ (_context && _context->pdata) ? _context->pdata->session_id : "null", ##__VA_ARGS__)
+#define PROXY_LOG_WARN(_tag, _context, _format, ...) \
+ WLog_WARN(TAG, "[SessionID=%s]: " _format, \
+ (_context && _context->pdata) ? _context->pdata->session_id : "null", ##__VA_ARGS__)
+
+#endif /* FREERDP_SERVER_PROXY_LOG_H */
diff --git a/include/freerdp/server/proxy/proxy_modules_api.h b/include/freerdp/server/proxy/proxy_modules_api.h
new file mode 100644
index 0000000..1887f90
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_modules_api.h
@@ -0,0 +1,241 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy Server
+ *
+ * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
+ * Copyright 2019 Idan Freiberg <speidy@gmail.com>
+ * Copyright 2021 Armin Novak <anovak@thincast.com>
+ * Copyright 2021 Thincast Technologies GmbH
+ * Copyright 2023 Armin Novak <anovak@thincast.com>
+ * Copyright 2023 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_PROXY_MODULES_API_H
+#define FREERDP_SERVER_PROXY_MODULES_API_H
+
+#include <winpr/winpr.h>
+#include <winpr/stream.h>
+#include <winpr/sspi.h>
+
+#include <freerdp/server/proxy/proxy_types.h>
+
+#define MODULE_TAG(module) "proxy.modules." module
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct proxy_data proxyData;
+ typedef struct proxy_module proxyModule;
+ typedef struct proxy_plugin proxyPlugin;
+ typedef struct proxy_plugins_manager proxyPluginsManager;
+
+ /* hook callback. should return TRUE on success or FALSE on error. */
+ typedef BOOL (*proxyHookFn)(proxyPlugin*, proxyData*, void*);
+
+ /*
+ * Filter callback:
+ * It MUST return TRUE if the related event should be proxied,
+ * or FALSE if it should be ignored.
+ */
+ typedef BOOL (*proxyFilterFn)(proxyPlugin*, proxyData*, void*);
+
+ /* describes a plugin: name, description and callbacks to execute.
+ *
+ * This is public API, so always add new fields at the end of the struct to keep
+ * some backward compatibility.
+ */
+ struct proxy_plugin
+ {
+ const char* name; /* 0: unique module name */
+ const char* description; /* 1: module description */
+
+ UINT64 reserved1[32 - 2]; /* 2-32 */
+
+ BOOL (*PluginUnload)(proxyPlugin* plugin); /* 33 */
+ UINT64 reserved2[66 - 34]; /* 34 - 65 */
+
+ /* proxy hooks. a module can set these function pointers to register hooks */
+ proxyHookFn ClientInitConnect; /* 66 custom=rdpContext* */
+ proxyHookFn ClientUninitConnect; /* 67 custom=rdpContext* */
+ proxyHookFn ClientPreConnect; /* 68 custom=rdpContext* */
+ proxyHookFn ClientPostConnect; /* 69 custom=rdpContext* */
+ proxyHookFn ClientPostDisconnect; /* 70 custom=rdpContext* */
+ proxyHookFn ClientX509Certificate; /* 71 custom=rdpContext* */
+ proxyHookFn ClientLoginFailure; /* 72 custom=rdpContext* */
+ proxyHookFn ClientEndPaint; /* 73 custom=rdpContext* */
+ proxyHookFn ClientRedirect; /* 74 custom=rdpContext* */
+ proxyHookFn ClientLoadChannels; /* 75 custom=rdpContext* */
+ UINT64 reserved3[96 - 76]; /* 76-95 */
+
+ proxyHookFn ServerPostConnect; /* 96 custom=freerdp_peer* */
+ proxyHookFn ServerPeerActivate; /* 97 custom=freerdp_peer* */
+ proxyHookFn ServerChannelsInit; /* 98 custom=freerdp_peer* */
+ proxyHookFn ServerChannelsFree; /* 99 custom=freerdp_peer* */
+ proxyHookFn ServerSessionEnd; /* 100 custom=freerdp_peer* */
+ proxyHookFn ServerSessionInitialize; /* 101 custom=freerdp_peer* */
+ proxyHookFn ServerSessionStarted; /* 102 custom=freerdp_peer* */
+
+ UINT64 reserved4[128 - 103]; /* 103 - 127 */
+
+ /* proxy filters. a module can set these function pointers to register filters */
+ proxyFilterFn KeyboardEvent; /* 128 */
+ proxyFilterFn MouseEvent; /* 129 */
+ proxyFilterFn ClientChannelData; /* 130 passthrough channels data */
+ proxyFilterFn ServerChannelData; /* 131 passthrough channels data */
+ proxyFilterFn DynamicChannelCreate; /* 132 passthrough drdynvc channel create data */
+ proxyFilterFn ServerFetchTargetAddr; /* 133 */
+ proxyFilterFn ServerPeerLogon; /* 134 */
+ proxyFilterFn ChannelCreate; /* 135 passthrough drdynvc channel create data */
+ proxyFilterFn UnicodeEvent; /* 136 */
+ proxyFilterFn MouseExEvent; /* 137 */
+
+ /* proxy dynamic channel filters:
+ *
+ * - a function that returns the list of channels to intercept
+ * - a function to call with the data received
+ */
+ proxyFilterFn DynChannelToIntercept; /* 138 */
+ proxyFilterFn DynChannelIntercept; /* 139 */
+ proxyFilterFn StaticChannelToIntercept; /* 140 */
+ UINT64 reserved5[160 - 141]; /* 141-159 */
+
+ /* Runtime data fields */
+ proxyPluginsManager* mgr; /* 160 */ /** Set during plugin registration */
+ void* userdata; /* 161 */ /** Custom data provided with RegisterPlugin, memory managed
+ outside of plugin. */
+ void* custom; /* 162 */ /** Custom configuration data, must be allocated in RegisterPlugin
+ and freed in PluginUnload */
+
+ UINT64 reserved6[192 - 163]; /* 163-191 Add some filler data to allow for new callbacks or
+ * fields without breaking API */
+ };
+
+ /*
+ * Main API for use by external modules.
+ * Supports:
+ * - Registering a plugin.
+ * - Setting/getting plugin's per-session specific data.
+ * - Aborting a session.
+ */
+ struct proxy_plugins_manager
+ {
+ /* 0 used for registering a fresh new proxy plugin. */
+ BOOL (*RegisterPlugin)(struct proxy_plugins_manager* mgr, const proxyPlugin* plugin);
+
+ /* 1 used for setting plugin's per-session info. */
+ BOOL (*SetPluginData)(struct proxy_plugins_manager* mgr, const char*, proxyData*, void*);
+
+ /* 2 used for getting plugin's per-session info. */
+ void* (*GetPluginData)(struct proxy_plugins_manager* mgr, const char*, proxyData*);
+
+ /* 3 used for aborting a session. */
+ void (*AbortConnect)(struct proxy_plugins_manager* mgr, proxyData*);
+
+ UINT64 reserved[128 - 4]; /* 4-127 reserved fields */
+ };
+
+ typedef BOOL (*proxyModuleEntryPoint)(proxyPluginsManager* plugins_manager, void* userdata);
+
+/* filter events parameters */
+#define WINPR_PACK_PUSH
+#include <winpr/pack.h>
+typedef struct proxy_keyboard_event_info
+{
+ UINT16 flags;
+ UINT16 rdp_scan_code;
+} proxyKeyboardEventInfo;
+
+typedef struct proxy_unicode_event_info
+{
+ UINT16 flags;
+ UINT16 code;
+} proxyUnicodeEventInfo;
+
+typedef struct proxy_mouse_event_info
+{
+ UINT16 flags;
+ UINT16 x;
+ UINT16 y;
+} proxyMouseEventInfo;
+
+typedef struct proxy_mouse_ex_event_info
+{
+ UINT16 flags;
+ UINT16 x;
+ UINT16 y;
+} proxyMouseExEventInfo;
+
+typedef struct
+{
+ /* channel metadata */
+ const char* channel_name;
+ UINT16 channel_id;
+
+ /* actual data */
+ const BYTE* data;
+ size_t data_len;
+ size_t total_size;
+ UINT32 flags;
+} proxyChannelDataEventInfo;
+
+typedef struct
+{
+ /* out values */
+ char* target_address;
+ UINT16 target_port;
+
+ /*
+ * If this value is set to true by a plugin, target info will be fetched from config and proxy
+ * will connect any client to the same remote server.
+ */
+ ProxyFetchTargetMethod fetch_method;
+} proxyFetchTargetEventInfo;
+
+typedef struct server_peer_logon
+{
+ const SEC_WINNT_AUTH_IDENTITY* identity;
+ BOOL automatic;
+} proxyServerPeerLogon;
+
+typedef struct dyn_channel_intercept_data
+{
+ const char* name;
+ UINT32 channelId;
+ wStream* data;
+ BOOL isBackData;
+ BOOL first;
+ BOOL last;
+ BOOL rewritten;
+ size_t packetSize;
+ PfChannelResult result;
+} proxyDynChannelInterceptData;
+
+typedef struct dyn_channel_to_intercept_data
+{
+ const char* name;
+ UINT32 channelId;
+ BOOL intercept;
+} proxyChannelToInterceptData;
+
+#define WINPR_PACK_POP
+#include <winpr/pack.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_PROXY_MODULES_API_H */
diff --git a/include/freerdp/server/proxy/proxy_server.h b/include/freerdp/server/proxy/proxy_server.h
new file mode 100644
index 0000000..39e738f
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_server.h
@@ -0,0 +1,115 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy Server
+ *
+ * Copyright 2021 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2021 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef FREERDP_SERVER_PROXY_SERVER_H
+#define FREERDP_SERVER_PROXY_SERVER_H
+
+#include <freerdp/api.h>
+#include <freerdp/server/proxy/proxy_config.h>
+#include <freerdp/server/proxy/proxy_modules_api.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct proxy_server proxyServer;
+
+ /**
+ * @brief pf_server_free Cleans up a (stopped) proxy server instance.
+ *
+ * @param server The proxy server to clean up. Might be NULL.
+ */
+ FREERDP_API void pf_server_free(proxyServer* server);
+
+ /**
+ * @brief pf_server_new Creates a new proxy server instance
+ *
+ * @param config The proxy server configuration to use. Must NOT be NULL.
+ *
+ * @return A new proxy server instance or NULL on failure.
+ */
+ WINPR_ATTR_MALLOC(pf_server_free, 1)
+ FREERDP_API proxyServer* pf_server_new(const proxyConfig* config);
+
+ /**
+ * @brief pf_server_add_module Allows registering proxy modules that are
+ * build-in instead of shipped as separate
+ * module loaded at runtime.
+ *
+ * @param server A proxy instance to add the module to. Must NOT be NULL
+ * @param ep The proxy entry function to add. Must NOT be NULL
+ * @param userdata Custom data for the module. May be NULL
+ *
+ * @return TRUE for success, FALSE otherwise.
+ */
+ FREERDP_API BOOL pf_server_add_module(proxyServer* server, proxyModuleEntryPoint ep,
+ void* userdata);
+
+ /**
+ * @brief pf_server_start Starts the proxy, binding the configured port.
+ *
+ * @param server The server instance. Must NOT be NULL.
+ *
+ * @return TRUE for success, FALSE on error
+ */
+ FREERDP_API BOOL pf_server_start(proxyServer* server);
+
+ /**
+ * @brief pf_server_start_from_socket Starts the proxy using an existing bound socket
+ *
+ * @param server The server instance. Must NOT be NULL.
+ * @param socket The bound socket to wait for events on.
+ *
+ * @return TRUE for success, FALSE on error
+ */
+ FREERDP_API BOOL pf_server_start_from_socket(proxyServer* server, int socket);
+
+ /**
+ * @brief pf_server_start_with_peer_socket Use existing peer socket
+ *
+ * @param server The server instance. Must NOT be NULL.
+ * @param socket Ready to use peer socket
+ *
+ * @return TRUE for success, FALSE on error
+ */
+ FREERDP_API BOOL pf_server_start_with_peer_socket(proxyServer* server, int socket);
+
+ /**
+ * @brief pf_server_stop Stops a server instance asynchronously.
+ * Can be called from any thread to stop a running server instance.
+ * @param server A pointer to the server instance to stop. May be NULL.
+ */
+ FREERDP_API void pf_server_stop(proxyServer* server);
+
+ /**
+ * @brief pf_server_run This (blocking) function runs the main loop of the
+ * proxy.
+ *
+ * @param server The server instance. Must NOT be NULL.
+ *
+ * @return TRUE for successful termination, FALSE otherwise.
+ */
+ FREERDP_API BOOL pf_server_run(proxyServer* server);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_PROXY_SERVER_H */
diff --git a/include/freerdp/server/proxy/proxy_types.h b/include/freerdp/server/proxy/proxy_types.h
new file mode 100644
index 0000000..98ee4b1
--- /dev/null
+++ b/include/freerdp/server/proxy/proxy_types.h
@@ -0,0 +1,57 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Proxy enum types
+ *
+ * Copyright 2023 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2023 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_PROXY_TYPES_H
+#define FREERDP_SERVER_PROXY_TYPES_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /** @brief how is handled a channel */
+ typedef enum
+ {
+ PF_UTILS_CHANNEL_NOT_HANDLED, /*!< channel not handled */
+ PF_UTILS_CHANNEL_BLOCK, /*!< block and drop traffic on this channel */
+ PF_UTILS_CHANNEL_PASSTHROUGH, /*!< pass traffic from this channel */
+ PF_UTILS_CHANNEL_INTERCEPT /*!< inspect traffic from this channel */
+ } pf_utils_channel_mode;
+
+ /** @brief result of a channel treatment */
+ typedef enum
+ {
+ PF_CHANNEL_RESULT_PASS, /*!< pass the packet as is */
+ PF_CHANNEL_RESULT_DROP, /*!< drop the packet */
+ PF_CHANNEL_RESULT_ERROR /*!< error during packet treatment */
+ } PfChannelResult;
+ typedef enum
+ {
+ PROXY_FETCH_TARGET_METHOD_DEFAULT,
+ PROXY_FETCH_TARGET_METHOD_CONFIG,
+ PROXY_FETCH_TARGET_METHOD_LOAD_BALANCE_INFO,
+ PROXY_FETCH_TARGET_USE_CUSTOM_ADDR
+ } ProxyFetchTargetMethod;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_PROXY_TYPES_H */
diff --git a/include/freerdp/server/rail.h b/include/freerdp/server/rail.h
new file mode 100644
index 0000000..0fdd1a3
--- /dev/null
+++ b/include/freerdp/server/rail.h
@@ -0,0 +1,157 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * RAIL Virtual Channel Plugin
+ *
+ * Copyright 2019 Mati Shabtay <matishabtay@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RAIL_SERVER_RAIL_H
+#define FREERDP_CHANNEL_RAIL_SERVER_RAIL_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#include <freerdp/rail.h>
+#include <freerdp/channels/rail.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_rail_server_context RailServerContext;
+ typedef struct s_rail_server_private RailServerPrivate;
+
+ typedef UINT (*psRailStart)(RailServerContext* context);
+ typedef BOOL (*psRailStop)(RailServerContext* context);
+
+ /* Client side callback types */
+ typedef UINT (*psRailClientHandshake)(RailServerContext* context,
+ const RAIL_HANDSHAKE_ORDER* handshake);
+ typedef UINT (*psRailClientClientStatus)(RailServerContext* context,
+ const RAIL_CLIENT_STATUS_ORDER* clientStatus);
+ typedef UINT (*psRailClientExec)(RailServerContext* context, const RAIL_EXEC_ORDER* exec);
+ typedef UINT (*psRailClientSysparam)(RailServerContext* context,
+ const RAIL_SYSPARAM_ORDER* sysparam);
+ typedef UINT (*psRailClientActivate)(RailServerContext* context,
+ const RAIL_ACTIVATE_ORDER* activate);
+ typedef UINT (*psRailClientSysmenu)(RailServerContext* context,
+ const RAIL_SYSMENU_ORDER* sysmenu);
+ typedef UINT (*psRailClientSyscommand)(RailServerContext* context,
+ const RAIL_SYSCOMMAND_ORDER* syscommand);
+ typedef UINT (*psRailClientNotifyEvent)(RailServerContext* context,
+ const RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
+ typedef UINT (*psRailClientGetAppidReq)(RailServerContext* context,
+ const RAIL_GET_APPID_REQ_ORDER* getAppidReq);
+ typedef UINT (*psRailClientWindowMove)(RailServerContext* context,
+ const RAIL_WINDOW_MOVE_ORDER* windowMove);
+ typedef UINT (*psRailClientSnapArrange)(RailServerContext* context,
+ const RAIL_SNAP_ARRANGE* snapArrange);
+ typedef UINT (*psRailClientLangbarInfo)(RailServerContext* context,
+ const RAIL_LANGBAR_INFO_ORDER* langbarInfo);
+ typedef UINT (*psRailClientLanguageImeInfo)(RailServerContext* context,
+ const RAIL_LANGUAGEIME_INFO_ORDER* languageImeInfo);
+ typedef UINT (*psRailClientCompartmentInfo)(RailServerContext* context,
+ const RAIL_COMPARTMENT_INFO_ORDER* compartmentInfo);
+ typedef UINT (*psRailClientCloak)(RailServerContext* context, const RAIL_CLOAK* cloak);
+ typedef UINT (*psRailClientTextScale)(RailServerContext* context, UINT32 TextScale);
+ typedef UINT (*psRailClientCaretBlinkRate)(RailServerContext* context, UINT32 CaretBlinkRate);
+
+ /* Server side messages sending methods */
+ typedef UINT (*psRailServerHandshake)(RailServerContext* context,
+ const RAIL_HANDSHAKE_ORDER* handshake);
+ typedef UINT (*psRailServerHandshakeEx)(RailServerContext* context,
+ const RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
+ typedef UINT (*psRailServerSysparam)(RailServerContext* context,
+ const RAIL_SYSPARAM_ORDER* sysparam);
+ typedef UINT (*psRailServerLocalMoveSize)(RailServerContext* context,
+ const RAIL_LOCALMOVESIZE_ORDER* localMoveSize);
+ typedef UINT (*psRailServerMinMaxInfo)(RailServerContext* context,
+ const RAIL_MINMAXINFO_ORDER* minMaxInfo);
+ typedef UINT (*psRailServerTaskbarInfo)(RailServerContext* context,
+ const RAIL_TASKBAR_INFO_ORDER* taskbarInfo);
+ typedef UINT (*psRailServerLangbarInfo)(RailServerContext* context,
+ const RAIL_LANGBAR_INFO_ORDER* langbarInfo);
+ typedef UINT (*psRailServerExecResult)(RailServerContext* context,
+ const RAIL_EXEC_RESULT_ORDER* execResult);
+ typedef UINT (*psRailServerGetAppidResp)(RailServerContext* context,
+ const RAIL_GET_APPID_RESP_ORDER* getAppIdResp);
+ typedef UINT (*psRailServerZOrderSync)(RailServerContext* context,
+ const RAIL_ZORDER_SYNC* zOrderSync);
+ typedef UINT (*psRailServerCloak)(RailServerContext* context, const RAIL_CLOAK* cloak);
+ typedef UINT (*psRailServerPowerDisplayRequest)(
+ RailServerContext* context, const RAIL_POWER_DISPLAY_REQUEST* PowerDisplayRequest);
+ typedef UINT (*psRailServerGetAppidRespEx)(RailServerContext* context,
+ const RAIL_GET_APPID_RESP_EX* GetAppidRespEx);
+
+ struct s_rail_server_context
+ {
+ HANDLE vcm;
+ void* custom;
+
+ psRailStart Start;
+ psRailStop Stop;
+
+ /* Callbacks from client */
+ psRailClientHandshake ClientHandshake;
+ psRailClientClientStatus ClientClientStatus;
+ psRailClientExec ClientExec;
+ psRailClientSysparam ClientSysparam;
+ psRailClientActivate ClientActivate;
+ psRailClientSysmenu ClientSysmenu;
+ psRailClientSyscommand ClientSyscommand;
+ psRailClientNotifyEvent ClientNotifyEvent;
+ psRailClientGetAppidReq ClientGetAppidReq;
+ psRailClientWindowMove ClientWindowMove;
+ psRailClientSnapArrange ClientSnapArrange;
+ psRailClientLangbarInfo ClientLangbarInfo;
+ psRailClientLanguageImeInfo ClientLanguageImeInfo;
+ psRailClientCompartmentInfo ClientCompartmentInfo;
+ psRailClientCloak ClientCloak;
+ psRailClientTextScale ClientTextScale;
+ psRailClientCaretBlinkRate ClientCaretBlinkRate;
+
+ /* Methods for sending server side messages */
+ psRailServerHandshake ServerHandshake;
+ psRailServerHandshakeEx ServerHandshakeEx;
+ psRailServerSysparam ServerSysparam;
+ psRailServerLocalMoveSize ServerLocalMoveSize;
+ psRailServerMinMaxInfo ServerMinMaxInfo;
+ psRailServerTaskbarInfo ServerTaskbarInfo;
+ psRailServerLangbarInfo ServerLangbarInfo;
+ psRailServerExecResult ServerExecResult;
+ psRailServerZOrderSync ServerZOrderSync;
+ psRailServerCloak ServerCloak;
+ psRailServerPowerDisplayRequest ServerPowerDisplayRequest;
+ psRailServerGetAppidResp ServerGetAppidResp;
+ psRailServerGetAppidRespEx ServerGetAppidRespEx;
+
+ RailServerPrivate* priv;
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void rail_server_context_free(RailServerContext* context);
+
+ WINPR_ATTR_MALLOC(rail_server_context_free, 1)
+ FREERDP_API RailServerContext* rail_server_context_new(HANDLE vcm);
+
+ FREERDP_API UINT rail_server_handle_messages(RailServerContext* context);
+ FREERDP_API void rail_server_set_handshake_ex_flags(RailServerContext* context, DWORD flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RAIL_SERVER_RAIL_H */
diff --git a/include/freerdp/server/rdpdr.h b/include/freerdp/server/rdpdr.h
new file mode 100644
index 0000000..8f01f1f
--- /dev/null
+++ b/include/freerdp/server/rdpdr.h
@@ -0,0 +1,227 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Device Redirection Virtual Channel Server Interface
+ *
+ * Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>
+ * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RDPDR_SERVER_RDPDR_H
+#define FREERDP_CHANNEL_RDPDR_SERVER_RDPDR_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+#include <freerdp/channels/wtsvc.h>
+#include <freerdp/channels/rdpdr.h>
+#include <freerdp/utils/rdpdr_utils.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * Server Interface
+ */
+
+ typedef struct s_rdpdr_server_context RdpdrServerContext;
+ typedef struct s_rdpdr_server_private RdpdrServerPrivate;
+
+ typedef struct
+ {
+ UINT16 Component;
+ UINT16 PacketId;
+ } RDPDR_HEADER;
+
+#ifndef __MINGW32__
+typedef struct
+{
+ UINT32 NextEntryOffset;
+ UINT32 FileIndex;
+ LARGE_INTEGER CreationTime;
+ LARGE_INTEGER LastAccessTime;
+ LARGE_INTEGER LastWriteTime;
+ LARGE_INTEGER ChangeTime;
+ LARGE_INTEGER EndOfFile;
+ LARGE_INTEGER AllocationSize;
+ UINT32 FileAttributes;
+ char FileName[512];
+} FILE_DIRECTORY_INFORMATION;
+#endif
+
+typedef UINT (*psRdpdrStart)(RdpdrServerContext* context);
+typedef UINT (*psRdpdrStop)(RdpdrServerContext* context);
+
+typedef UINT (*psRdpdrCapablityPDU)(RdpdrServerContext* context,
+ const RDPDR_CAPABILITY_HEADER* header, size_t size,
+ const BYTE* data);
+typedef UINT (*psRdpdrReceivePDU)(RdpdrServerContext* context, const RDPDR_HEADER* header,
+ UINT error);
+typedef UINT (*psRdpdrReceiveAnnounceResponse)(RdpdrServerContext* context, UINT16 VersionMajor,
+ UINT16 VersionMinor, UINT32 ClientId);
+typedef UINT (*psRdpdrSendServerAnnounce)(RdpdrServerContext* context);
+typedef UINT (*psRdpdrReceiveDeviceAnnounce)(RdpdrServerContext* context,
+ const RdpdrDevice* device);
+typedef UINT (*psRdpdrReceiveDeviceRemove)(RdpdrServerContext* context, UINT32 deviceId,
+ const RdpdrDevice* device);
+typedef UINT (*psRdpdrReceiveClientNameRequest)(RdpdrServerContext* context, size_t ComputerNameLen,
+ const char* name);
+
+typedef UINT (*psRdpdrDriveCreateDirectory)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path);
+typedef UINT (*psRdpdrDriveDeleteDirectory)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path);
+typedef UINT (*psRdpdrDriveQueryDirectory)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path);
+typedef UINT (*psRdpdrDriveOpenFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path, UINT32 desiredAccess,
+ UINT32 createDisposition);
+typedef UINT (*psRdpdrDriveReadFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId, UINT32 length, UINT32 offset);
+typedef UINT (*psRdpdrDriveWriteFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId, const char* buffer,
+ UINT32 length, UINT32 offset);
+typedef UINT (*psRdpdrDriveCloseFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, UINT32 fileId);
+typedef UINT (*psRdpdrDriveDeleteFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* path);
+typedef UINT (*psRdpdrDriveRenameFile)(RdpdrServerContext* context, void* callbackData,
+ UINT32 deviceId, const char* oldPath, const char* newPath);
+
+typedef void (*psRdpdrOnDriveCreateDirectoryComplete)(RdpdrServerContext* context,
+ void* callbackData, UINT32 ioStatus);
+typedef void (*psRdpdrOnDriveDeleteDirectoryComplete)(RdpdrServerContext* context,
+ void* callbackData, UINT32 ioStatus);
+typedef void (*psRdpdrOnDriveQueryDirectoryComplete)(RdpdrServerContext* context,
+ void* callbackData, UINT32 ioStatus,
+ FILE_DIRECTORY_INFORMATION* fdi);
+typedef void (*psRdpdrOnDriveOpenFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus, UINT32 deviceId, UINT32 fileId);
+typedef void (*psRdpdrOnDriveReadFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus, const char* buffer, UINT32 length);
+typedef void (*psRdpdrOnDriveWriteFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus, UINT32 bytesWritten);
+typedef void (*psRdpdrOnDriveCloseFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus);
+typedef void (*psRdpdrOnDriveDeleteFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus);
+typedef void (*psRdpdrOnDriveRenameFileComplete)(RdpdrServerContext* context, void* callbackData,
+ UINT32 ioStatus);
+
+typedef UINT (*psRdpdrOnDeviceCreate)(RdpdrServerContext* context, const RdpdrDevice* device);
+typedef UINT (*psRdpdrOnDeviceDelete)(RdpdrServerContext* context, UINT32 deviceId);
+
+struct s_rdpdr_server_context
+{
+ HANDLE vcm;
+
+ psRdpdrStart Start;
+ psRdpdrStop Stop;
+
+ RdpdrServerPrivate* priv;
+
+ /* Server self-defined pointer. */
+ void* data;
+
+ /**< Server supported redirections.
+ * initially used to determine which redirections are supported by the
+ * server in the server capability, later on updated with what the client
+ * actually wants to have supported.
+ *
+ * Use the \b RDPDR_DTYP_* defines as a mask to check.
+ */
+ UINT16 supported;
+
+ /*** RDPDR message intercept callbacks */
+ psRdpdrCapablityPDU ReceiveCaps; /**< Called for each received capability */
+ psRdpdrCapablityPDU SendCaps; /**< Called for each capability to be sent */
+ psRdpdrReceivePDU ReceivePDU; /**< Called after a RDPDR pdu was received and parsed */
+ psRdpdrSendServerAnnounce
+ SendServerAnnounce; /**< Called before the server sends the announce message */
+ psRdpdrReceiveAnnounceResponse
+ ReceiveAnnounceResponse; /**< Called after the client announce response is received */
+ psRdpdrReceiveClientNameRequest
+ ReceiveClientNameRequest; /**< Called after a client name request is received */
+ psRdpdrReceiveDeviceAnnounce
+ ReceiveDeviceAnnounce; /** < Called after a new device request was received but before the
+ device is added */
+ psRdpdrReceiveDeviceRemove ReceiveDeviceRemove; /**< Called after a new device request was
+ received, but before it is removed */
+
+ /*** Drive APIs called by the server. ***/
+ psRdpdrDriveCreateDirectory DriveCreateDirectory;
+ psRdpdrDriveDeleteDirectory DriveDeleteDirectory;
+ psRdpdrDriveQueryDirectory DriveQueryDirectory;
+ psRdpdrDriveOpenFile DriveOpenFile;
+ psRdpdrDriveReadFile DriveReadFile;
+ psRdpdrDriveWriteFile DriveWriteFile;
+ psRdpdrDriveCloseFile DriveCloseFile;
+ psRdpdrDriveDeleteFile DriveDeleteFile;
+ psRdpdrDriveRenameFile DriveRenameFile;
+
+ /*** Drive callbacks registered by the server. ***/
+ psRdpdrOnDeviceCreate OnDriveCreate; /**< Called for devices of type \b RDPDR_DTYP_FILESYSTEM
+ after \b ReceiveDeviceAnnounce */
+ psRdpdrOnDeviceDelete OnDriveDelete; /**< Called for devices of type \b RDPDR_DTYP_FILESYSTEM
+ after \b ReceiveDeviceRemove */
+ psRdpdrOnDriveCreateDirectoryComplete OnDriveCreateDirectoryComplete;
+ psRdpdrOnDriveDeleteDirectoryComplete OnDriveDeleteDirectoryComplete;
+ psRdpdrOnDriveQueryDirectoryComplete OnDriveQueryDirectoryComplete;
+ psRdpdrOnDriveOpenFileComplete OnDriveOpenFileComplete;
+ psRdpdrOnDriveReadFileComplete OnDriveReadFileComplete;
+ psRdpdrOnDriveWriteFileComplete OnDriveWriteFileComplete;
+ psRdpdrOnDriveCloseFileComplete OnDriveCloseFileComplete;
+ psRdpdrOnDriveDeleteFileComplete OnDriveDeleteFileComplete;
+ psRdpdrOnDriveRenameFileComplete OnDriveRenameFileComplete;
+
+ /*** Serial Port callbacks registered by the server. ***/
+ psRdpdrOnDeviceCreate OnSerialPortCreate; /**< Called for devices of type \b RDPDR_DTYP_SERIAL
+ after \b ReceiveDeviceAnnounce */
+ psRdpdrOnDeviceDelete OnSerialPortDelete; /**< Called for devices of type \b RDPDR_DTYP_SERIAL
+ after \b ReceiveDeviceRemove */
+
+ /*** Parallel Port callbacks registered by the server. ***/
+ psRdpdrOnDeviceCreate OnParallelPortCreate; /**< Called for devices of type \b
+ RDPDR_DTYP_PARALLEL after \b ReceiveDeviceAnnounce */
+ psRdpdrOnDeviceDelete OnParallelPortDelete; /**< Called for devices of type \b
+ RDPDR_DTYP_PARALLEL after \b ReceiveDeviceRemove */
+
+ /*** Printer callbacks registered by the server. ***/
+ psRdpdrOnDeviceCreate OnPrinterCreate; /**< Called for devices of type RDPDR_DTYP_PRINT after \b
+ ReceiveDeviceAnnounce */
+ psRdpdrOnDeviceDelete OnPrinterDelete; /**< Called for devices of type RDPDR_DTYP_PRINT after \b
+ ReceiveDeviceRemove */
+
+ /*** Smartcard callbacks registered by the server. ***/
+ psRdpdrOnDeviceCreate OnSmartcardCreate; /**< Called for devices of type RDPDR_DTYP_SMARTCARD
+ after \b ReceiveDeviceAnnounce */
+ psRdpdrOnDeviceDelete OnSmartcardDelete; /**< Called for devices of type RDPDR_DTYP_SMARTCARD
+ after \b ReceiveDeviceRemove */
+
+ rdpContext* rdpcontext;
+};
+
+FREERDP_API void rdpdr_server_context_free(RdpdrServerContext* context);
+
+WINPR_ATTR_MALLOC(rdpdr_server_context_free, 1)
+FREERDP_API RdpdrServerContext* rdpdr_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RDPDR_SERVER_RDPDR_H */
diff --git a/include/freerdp/server/rdpecam-enumerator.h b/include/freerdp/server/rdpecam-enumerator.h
new file mode 100644
index 0000000..800caf8
--- /dev/null
+++ b/include/freerdp/server/rdpecam-enumerator.h
@@ -0,0 +1,137 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Video Capture Virtual Channel Extension
+ *
+ * Copyright 2022 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_CAM_DEV_ENUM_SERVER_CAM_DEV_ENUM_H
+#define FREERDP_CHANNEL_CAM_DEV_ENUM_SERVER_CAM_DEV_ENUM_H
+
+#include <freerdp/channels/rdpecam.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_cam_dev_enum_server_context CamDevEnumServerContext;
+
+ typedef UINT (*psCamDevEnumServerServerOpen)(CamDevEnumServerContext* context);
+ typedef UINT (*psCamDevEnumServerServerClose)(CamDevEnumServerContext* context);
+
+ typedef BOOL (*psCamDevEnumServerServerChannelIdAssigned)(CamDevEnumServerContext* context,
+ UINT32 channelId);
+
+ typedef UINT (*psCamDevEnumServerServerInitialize)(CamDevEnumServerContext* context,
+ BOOL externalThread);
+ typedef UINT (*psCamDevEnumServerServerPoll)(CamDevEnumServerContext* context);
+ typedef BOOL (*psCamDevEnumServerServerChannelHandle)(CamDevEnumServerContext* context,
+ HANDLE* handle);
+
+ typedef UINT (*psCamDevEnumServerServerSelectVersionRequest)(
+ CamDevEnumServerContext* context, const CAM_SELECT_VERSION_REQUEST* selectVersionRequest);
+ typedef UINT (*psCamDevEnumServerServerSelectVersionResponse)(
+ CamDevEnumServerContext* context, const CAM_SELECT_VERSION_RESPONSE* selectVersionResponse);
+
+ typedef UINT (*psCamDevEnumServerServerDeviceAddedNotification)(
+ CamDevEnumServerContext* context,
+ const CAM_DEVICE_ADDED_NOTIFICATION* deviceAddedNotification);
+ typedef UINT (*psCamDevEnumServerServerDeviceRemovedNotification)(
+ CamDevEnumServerContext* context,
+ const CAM_DEVICE_REMOVED_NOTIFICATION* deviceRemovedNotification);
+
+ struct s_cam_dev_enum_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psCamDevEnumServerServerInitialize Initialize;
+
+ /**
+ * Open the camera device enumerator channel.
+ */
+ psCamDevEnumServerServerOpen Open;
+
+ /**
+ * Close the camera device enumerator channel.
+ */
+ psCamDevEnumServerServerClose Close;
+
+ /**
+ * Poll
+ * When externalThread=TRUE, call Poll() periodically from your main loop.
+ * If externalThread=FALSE do not call.
+ */
+ psCamDevEnumServerServerPoll Poll;
+
+ /**
+ * Retrieve the channel handle for use in conjunction with Poll().
+ * If externalThread=FALSE do not call.
+ */
+ psCamDevEnumServerServerChannelHandle ChannelHandle;
+
+ /*
+ * Send a Select Version Response PDU.
+ */
+ psCamDevEnumServerServerSelectVersionResponse SelectVersionResponse;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psCamDevEnumServerServerChannelIdAssigned ChannelIdAssigned;
+
+ /**
+ * Callback for the Select Version Request PDU.
+ */
+ psCamDevEnumServerServerSelectVersionRequest SelectVersionRequest;
+
+ /**
+ * Callback for the Device Added Notification PDU.
+ */
+ psCamDevEnumServerServerDeviceAddedNotification DeviceAddedNotification;
+
+ /**
+ * Callback for the Device Removed Notification PDU.
+ */
+ psCamDevEnumServerServerDeviceRemovedNotification DeviceRemovedNotification;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void cam_dev_enum_server_context_free(CamDevEnumServerContext* context);
+
+ WINPR_ATTR_MALLOC(cam_dev_enum_server_context_free, 1)
+ FREERDP_API CamDevEnumServerContext* cam_dev_enum_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_CAM_DEV_ENUM_SERVER_CAM_DEV_ENUM_H */
diff --git a/include/freerdp/server/rdpecam.h b/include/freerdp/server/rdpecam.h
new file mode 100644
index 0000000..dd18494
--- /dev/null
+++ b/include/freerdp/server/rdpecam.h
@@ -0,0 +1,284 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Video Capture Virtual Channel Extension
+ *
+ * Copyright 2022 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_CAMERA_DEVICE_SERVER_CAMERA_DEVICE_H
+#define FREERDP_CHANNEL_CAMERA_DEVICE_SERVER_CAMERA_DEVICE_H
+
+#include <freerdp/channels/rdpecam.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct camera_device_server_context CameraDeviceServerContext;
+
+ typedef UINT (*psCameraDeviceServerOpen)(CameraDeviceServerContext* context);
+ typedef UINT (*psCameraDeviceServerClose)(CameraDeviceServerContext* context);
+
+ typedef BOOL (*psCameraDeviceServerChannelIdAssigned)(CameraDeviceServerContext* context,
+ UINT32 channelId);
+
+ typedef UINT (*psCameraDeviceServerInitialize)(CameraDeviceServerContext* context,
+ BOOL externalThread);
+ typedef UINT (*psCameraDeviceServerPoll)(CameraDeviceServerContext* context);
+ typedef BOOL (*psCameraDeviceServerChannelHandle)(CameraDeviceServerContext* context,
+ HANDLE* handle);
+
+ typedef UINT (*psCameraDeviceServerSuccessResponse)(
+ CameraDeviceServerContext* context, const CAM_SUCCESS_RESPONSE* successResponse);
+ typedef UINT (*psCameraDeviceServerErrorResponse)(CameraDeviceServerContext* context,
+ const CAM_ERROR_RESPONSE* errorResponse);
+
+ typedef UINT (*psCameraDeviceServerActivateDeviceRequest)(
+ CameraDeviceServerContext* context,
+ const CAM_ACTIVATE_DEVICE_REQUEST* activateDeviceRequest);
+ typedef UINT (*psCameraDeviceServerDeactivateDeviceRequest)(
+ CameraDeviceServerContext* context,
+ const CAM_DEACTIVATE_DEVICE_REQUEST* deactivateDeviceRequest);
+
+ typedef UINT (*psCameraDeviceServerStreamListRequest)(
+ CameraDeviceServerContext* context, const CAM_STREAM_LIST_REQUEST* streamListRequest);
+ typedef UINT (*psCameraDeviceServerStreamListResponse)(
+ CameraDeviceServerContext* context, const CAM_STREAM_LIST_RESPONSE* streamListResponse);
+
+ typedef UINT (*psCameraDeviceServerMediaTypeListRequest)(
+ CameraDeviceServerContext* context,
+ const CAM_MEDIA_TYPE_LIST_REQUEST* mediaTypeListRequest);
+ typedef UINT (*psCameraDeviceServerMediaTypeListResponse)(
+ CameraDeviceServerContext* context,
+ const CAM_MEDIA_TYPE_LIST_RESPONSE* mediaTypeListResponse);
+
+ typedef UINT (*psCameraDeviceServerCurrentMediaTypeRequest)(
+ CameraDeviceServerContext* context,
+ const CAM_CURRENT_MEDIA_TYPE_REQUEST* currentMediaTypeRequest);
+ typedef UINT (*psCameraDeviceServerCurrentMediaTypeResponse)(
+ CameraDeviceServerContext* context,
+ const CAM_CURRENT_MEDIA_TYPE_RESPONSE* currentMediaTypeResponse);
+
+ typedef UINT (*psCameraDeviceServerStartStreamsRequest)(
+ CameraDeviceServerContext* context, const CAM_START_STREAMS_REQUEST* startStreamsRequest);
+ typedef UINT (*psCameraDeviceServerStopStreamsRequest)(
+ CameraDeviceServerContext* context, const CAM_STOP_STREAMS_REQUEST* stopStreamsRequest);
+
+ typedef UINT (*psCameraDeviceServerSampleRequest)(CameraDeviceServerContext* context,
+ const CAM_SAMPLE_REQUEST* sampleRequest);
+ typedef UINT (*psCameraDeviceServerSampleResponse)(CameraDeviceServerContext* context,
+ const CAM_SAMPLE_RESPONSE* sampleResponse);
+ typedef UINT (*psCameraDeviceServerSampleErrorResponse)(
+ CameraDeviceServerContext* context, const CAM_SAMPLE_ERROR_RESPONSE* sampleErrorResponse);
+
+ typedef UINT (*psCameraDeviceServerPropertyListRequest)(
+ CameraDeviceServerContext* context, const CAM_PROPERTY_LIST_REQUEST* propertyListRequest);
+ typedef UINT (*psCameraDeviceServerPropertyListResponse)(
+ CameraDeviceServerContext* context, const CAM_PROPERTY_LIST_RESPONSE* propertyListResponse);
+
+ typedef UINT (*psCameraDeviceServerPropertyValueRequest)(
+ CameraDeviceServerContext* context, const CAM_PROPERTY_VALUE_REQUEST* propertyValueRequest);
+ typedef UINT (*psCameraDeviceServerPropertyValueResponse)(
+ CameraDeviceServerContext* context,
+ const CAM_PROPERTY_VALUE_RESPONSE* propertyValueResponse);
+
+ typedef UINT (*psCameraDeviceServerSetPropertyValueRequest)(
+ CameraDeviceServerContext* context,
+ const CAM_SET_PROPERTY_VALUE_REQUEST* setPropertyValueRequest);
+
+ struct camera_device_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /**
+ * Name of the virtual channel. Pointer owned by the CameraDeviceServerContext,
+ * meaning camera_device_server_context_free() takes care of freeing the pointer.
+ *
+ * Server implementations should sanitize the virtual channel name for invalid
+ * names, like names for other known channels
+ * ("ECHO", "AUDIO_PLAYBACK_DVC", etc.)
+ */
+ char* virtualChannelName;
+
+ /**
+ * Protocol version to be used. Every sent server to client PDU has the
+ * version value in the Header set to the following value.
+ */
+ BYTE protocolVersion;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psCameraDeviceServerInitialize Initialize;
+
+ /**
+ * Open the camera device channel.
+ */
+ psCameraDeviceServerOpen Open;
+
+ /**
+ * Close the camera device channel.
+ */
+ psCameraDeviceServerClose Close;
+
+ /**
+ * Poll
+ * When externalThread=TRUE, call Poll() periodically from your main loop.
+ * If externalThread=FALSE do not call.
+ */
+ psCameraDeviceServerPoll Poll;
+
+ /**
+ * Retrieve the channel handle for use in conjunction with Poll().
+ * If externalThread=FALSE do not call.
+ */
+ psCameraDeviceServerChannelHandle ChannelHandle;
+
+ /**
+ * For the following server to client PDUs,
+ * the message header does not have to be set.
+ */
+
+ /**
+ * Send a Activate Device Request PDU.
+ */
+ psCameraDeviceServerActivateDeviceRequest ActivateDeviceRequest;
+
+ /**
+ * Send a Deactivate Device Request PDU.
+ */
+ psCameraDeviceServerDeactivateDeviceRequest DeactivateDeviceRequest;
+
+ /**
+ * Send a Stream List Request PDU.
+ */
+ psCameraDeviceServerStreamListRequest StreamListRequest;
+
+ /**
+ * Send a Media Type List Request PDU.
+ */
+ psCameraDeviceServerMediaTypeListRequest MediaTypeListRequest;
+
+ /**
+ * Send a Current Media Type Request PDU.
+ */
+ psCameraDeviceServerCurrentMediaTypeRequest CurrentMediaTypeRequest;
+
+ /**
+ * Send a Start Streams Request PDU.
+ */
+ psCameraDeviceServerStartStreamsRequest StartStreamsRequest;
+
+ /**
+ * Send a Stop Streams Request PDU.
+ */
+ psCameraDeviceServerStopStreamsRequest StopStreamsRequest;
+
+ /**
+ * Send a Sample Request PDU.
+ */
+ psCameraDeviceServerSampleRequest SampleRequest;
+
+ /**
+ * Send a Property List Request PDU.
+ */
+ psCameraDeviceServerPropertyListRequest PropertyListRequest;
+
+ /**
+ * Send a Property Value Request PDU.
+ */
+ psCameraDeviceServerPropertyValueRequest PropertyValueRequest;
+
+ /**
+ * Send a Set Property Value Request PDU.
+ */
+ psCameraDeviceServerSetPropertyValueRequest SetPropertyValueRequest;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psCameraDeviceServerChannelIdAssigned ChannelIdAssigned;
+
+ /**
+ * Callback for the Success Response PDU.
+ */
+ psCameraDeviceServerSuccessResponse SuccessResponse;
+
+ /**
+ * Callback for the Error Response PDU.
+ */
+ psCameraDeviceServerErrorResponse ErrorResponse;
+
+ /**
+ * Callback for the Stream List Response PDU.
+ */
+ psCameraDeviceServerStreamListResponse StreamListResponse;
+
+ /**
+ * Callback for the Media Type List Response PDU.
+ */
+ psCameraDeviceServerMediaTypeListResponse MediaTypeListResponse;
+
+ /**
+ * Callback for the Current Media Type Response PDU.
+ */
+ psCameraDeviceServerCurrentMediaTypeResponse CurrentMediaTypeResponse;
+
+ /**
+ * Callback for the Sample Response PDU.
+ */
+ psCameraDeviceServerSampleResponse SampleResponse;
+
+ /**
+ * Callback for the Sample Error Response PDU.
+ */
+ psCameraDeviceServerSampleErrorResponse SampleErrorResponse;
+
+ /**
+ * Callback for the Property List Response PDU.
+ */
+ psCameraDeviceServerPropertyListResponse PropertyListResponse;
+
+ /**
+ * Callback for the Property Value Response PDU.
+ */
+ psCameraDeviceServerPropertyValueResponse PropertyValueResponse;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void camera_device_server_context_free(CameraDeviceServerContext* context);
+
+ WINPR_ATTR_MALLOC(camera_device_server_context_free, 1)
+ FREERDP_API CameraDeviceServerContext* camera_device_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_CAMERA_DEVICE_SERVER_CAMERA_DEVICE_H */
diff --git a/include/freerdp/server/rdpei.h b/include/freerdp/server/rdpei.h
new file mode 100644
index 0000000..215f7f1
--- /dev/null
+++ b/include/freerdp/server/rdpei.h
@@ -0,0 +1,81 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Extended Input channel server-side definitions
+ *
+ * Copyright 2014 Thincast Technologies Gmbh.
+ * Copyright 2014 David FORT <contact@hardening-consulting.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RDPEI_SERVER_H
+#define FREERDP_CHANNEL_RDPEI_SERVER_H
+
+#include <freerdp/channels/wtsvc.h>
+#include <freerdp/channels/rdpei.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_rdpei_server_context RdpeiServerContext;
+ typedef struct s_rdpei_server_private RdpeiServerPrivate;
+
+ struct s_rdpei_server_context
+ {
+ HANDLE vcm;
+
+ RdpeiServerPrivate* priv;
+
+ UINT32 clientVersion;
+ UINT16 maxTouchPoints;
+ UINT32 protocolFlags;
+
+ /** callbacks that can be set by the user */
+ UINT (*onClientReady)(RdpeiServerContext* context);
+ UINT (*onTouchEvent)(RdpeiServerContext* context, const RDPINPUT_TOUCH_EVENT* touchEvent);
+ UINT (*onPenEvent)(RdpeiServerContext* context, const RDPINPUT_PEN_EVENT* penEvent);
+ UINT (*onTouchReleased)(RdpeiServerContext* context, BYTE contactId);
+
+ void* user_data; /* user data, useful for callbacks */
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ BOOL (*onChannelIdAssigned)(RdpeiServerContext* context, UINT32 channelId);
+ };
+
+ FREERDP_API void rdpei_server_context_free(RdpeiServerContext* context);
+
+ WINPR_ATTR_MALLOC(rdpei_server_context_free, 1)
+ FREERDP_API RdpeiServerContext* rdpei_server_context_new(HANDLE vcm);
+
+ FREERDP_API void rdpei_server_context_reset(RdpeiServerContext* context);
+
+ FREERDP_API HANDLE rdpei_server_get_event_handle(RdpeiServerContext* context);
+ FREERDP_API UINT rdpei_server_init(RdpeiServerContext* context);
+ FREERDP_API UINT rdpei_server_handle_messages(RdpeiServerContext* context);
+
+ FREERDP_API UINT rdpei_server_send_sc_ready(RdpeiServerContext* context, UINT32 version,
+ UINT32 features);
+ FREERDP_API UINT rdpei_server_suspend(RdpeiServerContext* context);
+ FREERDP_API UINT rdpei_server_resume(RdpeiServerContext* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RDPEI_SERVER_H */
diff --git a/include/freerdp/server/rdpemsc.h b/include/freerdp/server/rdpemsc.h
new file mode 100644
index 0000000..f1ce98a
--- /dev/null
+++ b/include/freerdp/server/rdpemsc.h
@@ -0,0 +1,132 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Mouse Cursor Virtual Channel Extension
+ *
+ * Copyright 2023 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RDPEMSC_SERVER_RDPEMSC_H
+#define FREERDP_CHANNEL_RDPEMSC_SERVER_RDPEMSC_H
+
+#include <freerdp/channels/rdpemsc.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_mouse_cursor_server_context MouseCursorServerContext;
+
+ typedef UINT (*psMouseCursorServerOpen)(MouseCursorServerContext* context);
+ typedef UINT (*psMouseCursorServerClose)(MouseCursorServerContext* context);
+
+ typedef BOOL (*psMouseCursorServerChannelIdAssigned)(MouseCursorServerContext* context,
+ UINT32 channelId);
+
+ typedef UINT (*psMouseCursorServerInitialize)(MouseCursorServerContext* context,
+ BOOL externalThread);
+ typedef UINT (*psMouseCursorServerPoll)(MouseCursorServerContext* context);
+ typedef BOOL (*psMouseCursorServerChannelHandle)(MouseCursorServerContext* context,
+ HANDLE* handle);
+
+ typedef UINT (*psMouseCursorServerCapsAdvertise)(
+ MouseCursorServerContext* context,
+ const RDP_MOUSE_CURSOR_CAPS_ADVERTISE_PDU* capsAdvertise);
+ typedef UINT (*psMouseCursorServerCapsConfirm)(
+ MouseCursorServerContext* context, const RDP_MOUSE_CURSOR_CAPS_CONFIRM_PDU* capsConfirm);
+
+ typedef UINT (*psMouseCursorServerMouseptrUpdate)(
+ MouseCursorServerContext* context,
+ const RDP_MOUSE_CURSOR_MOUSEPTR_UPDATE_PDU* mouseptrUpdate);
+
+ struct s_mouse_cursor_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psMouseCursorServerInitialize Initialize;
+
+ /**
+ * Open the mouse cursor channel.
+ */
+ psMouseCursorServerOpen Open;
+
+ /**
+ * Close the mouse cursor channel.
+ */
+ psMouseCursorServerClose Close;
+
+ /**
+ * Poll
+ * When externalThread=TRUE, call Poll() periodically from your main loop.
+ * If externalThread=FALSE do not call.
+ */
+ psMouseCursorServerPoll Poll;
+
+ /**
+ * Retrieve the channel handle for use in conjunction with Poll().
+ * If externalThread=FALSE do not call.
+ */
+ psMouseCursorServerChannelHandle ChannelHandle;
+
+ /* All PDUs sent by the server don't require the pduType to be set */
+
+ /*
+ * Send a CapsConfirm PDU.
+ */
+ psMouseCursorServerCapsConfirm CapsConfirm;
+
+ /*
+ * Send a MouseptrUpdate PDU.
+ */
+ psMouseCursorServerMouseptrUpdate MouseptrUpdate;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psMouseCursorServerChannelIdAssigned ChannelIdAssigned;
+
+ /**
+ * Callback for the CapsAdvertise PDU.
+ */
+ psMouseCursorServerCapsAdvertise CapsAdvertise;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void mouse_cursor_server_context_free(MouseCursorServerContext* context);
+
+ WINPR_ATTR_MALLOC(mouse_cursor_server_context_free, 1)
+ FREERDP_API MouseCursorServerContext* mouse_cursor_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RDPEMSC_SERVER_RDPEMSC_H */
diff --git a/include/freerdp/server/rdpgfx.h b/include/freerdp/server/rdpgfx.h
new file mode 100644
index 0000000..262bb38
--- /dev/null
+++ b/include/freerdp/server/rdpgfx.h
@@ -0,0 +1,156 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Graphics Pipeline Extension
+ *
+ * Copyright 2016 Jiang Zihao <zihao.jiang@yahoo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RDPGFX_SERVER_RDPGFX_H
+#define FREERDP_CHANNEL_RDPGFX_SERVER_RDPGFX_H
+
+#include <freerdp/channels/rdpgfx.h>
+#include <freerdp/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_rdpgfx_server_context RdpgfxServerContext;
+ typedef struct s_rdpgfx_server_private RdpgfxServerPrivate;
+
+ typedef BOOL (*psRdpgfxServerOpen)(RdpgfxServerContext* context);
+ typedef BOOL (*psRdpgfxServerClose)(RdpgfxServerContext* context);
+
+ typedef BOOL (*psRdpgfxServerChannelIdAssigned)(RdpgfxServerContext* context, UINT32 channelId);
+
+ typedef BOOL (*psRdpgfxServerInitialize)(RdpgfxServerContext* context, BOOL externalThread);
+
+ typedef UINT (*psRdpgfxResetGraphics)(RdpgfxServerContext* context,
+ const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics);
+ typedef UINT (*psRdpgfxStartFrame)(RdpgfxServerContext* context,
+ const RDPGFX_START_FRAME_PDU* startFrame);
+ typedef UINT (*psRdpgfxEndFrame)(RdpgfxServerContext* context,
+ const RDPGFX_END_FRAME_PDU* endFrame);
+ typedef UINT (*psRdpgfxSurfaceCommand)(RdpgfxServerContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd);
+ typedef UINT (*psRdpgfxSurfaceFrameCommand)(RdpgfxServerContext* context,
+ const RDPGFX_SURFACE_COMMAND* cmd,
+ const RDPGFX_START_FRAME_PDU* startFrame,
+ const RDPGFX_END_FRAME_PDU* endFrame);
+ typedef UINT (*psRdpgfxDeleteEncodingContext)(
+ RdpgfxServerContext* context,
+ const RDPGFX_DELETE_ENCODING_CONTEXT_PDU* deleteEncodingContext);
+ typedef UINT (*psRdpgfxCreateSurface)(RdpgfxServerContext* context,
+ const RDPGFX_CREATE_SURFACE_PDU* createSurface);
+ typedef UINT (*psRdpgfxDeleteSurface)(RdpgfxServerContext* context,
+ const RDPGFX_DELETE_SURFACE_PDU* deleteSurface);
+ typedef UINT (*psRdpgfxSolidFill)(RdpgfxServerContext* context,
+ const RDPGFX_SOLID_FILL_PDU* solidFill);
+ typedef UINT (*psRdpgfxSurfaceToSurface)(RdpgfxServerContext* context,
+ const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface);
+ typedef UINT (*psRdpgfxSurfaceToCache)(RdpgfxServerContext* context,
+ const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache);
+ typedef UINT (*psRdpgfxCacheToSurface)(RdpgfxServerContext* context,
+ const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface);
+ typedef UINT (*psRdpgfxCacheImportOffer)(RdpgfxServerContext* context,
+ const RDPGFX_CACHE_IMPORT_OFFER_PDU* cacheImportOffer);
+ typedef UINT (*psRdpgfxCacheImportReply)(RdpgfxServerContext* context,
+ const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply);
+ typedef UINT (*psRdpgfxEvictCacheEntry)(RdpgfxServerContext* context,
+ const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry);
+ typedef UINT (*psRdpgfxMapSurfaceToOutput)(
+ RdpgfxServerContext* context, const RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU* surfaceToOutput);
+ typedef UINT (*psRdpgfxMapSurfaceToWindow)(
+ RdpgfxServerContext* context, const RDPGFX_MAP_SURFACE_TO_WINDOW_PDU* surfaceToWindow);
+ typedef UINT (*psRdpgfxMapSurfaceToScaledOutput)(
+ RdpgfxServerContext* context,
+ const RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU* surfaceToOutput);
+ typedef UINT (*psRdpgfxMapSurfaceToScaledWindow)(
+ RdpgfxServerContext* context,
+ const RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU* surfaceToWindow);
+ typedef UINT (*psRdpgfxCapsAdvertise)(RdpgfxServerContext* context,
+ const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise);
+ typedef UINT (*psRdpgfxCapsConfirm)(RdpgfxServerContext* context,
+ const RDPGFX_CAPS_CONFIRM_PDU* capsConfirm);
+ typedef UINT (*psRdpgfxFrameAcknowledge)(RdpgfxServerContext* context,
+ const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge);
+ typedef UINT (*psRdpgfxQoeFrameAcknowledge)(
+ RdpgfxServerContext* context, const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* qoeFrameAcknowledge);
+
+ struct s_rdpgfx_server_context
+ {
+ HANDLE vcm;
+ void* custom;
+
+ psRdpgfxServerOpen Open;
+ psRdpgfxServerClose Close;
+
+ psRdpgfxResetGraphics ResetGraphics;
+ psRdpgfxStartFrame StartFrame;
+ psRdpgfxEndFrame EndFrame;
+ psRdpgfxSurfaceCommand SurfaceCommand;
+ psRdpgfxSurfaceFrameCommand SurfaceFrameCommand;
+ psRdpgfxDeleteEncodingContext DeleteEncodingContext;
+ psRdpgfxCreateSurface CreateSurface;
+ psRdpgfxDeleteSurface DeleteSurface;
+ psRdpgfxSolidFill SolidFill;
+ psRdpgfxSurfaceToSurface SurfaceToSurface;
+ psRdpgfxSurfaceToCache SurfaceToCache;
+ psRdpgfxCacheToSurface CacheToSurface;
+ psRdpgfxCacheImportOffer CacheImportOffer;
+ psRdpgfxCacheImportReply CacheImportReply;
+ psRdpgfxEvictCacheEntry EvictCacheEntry;
+ psRdpgfxMapSurfaceToOutput MapSurfaceToOutput;
+ psRdpgfxMapSurfaceToWindow MapSurfaceToWindow;
+ psRdpgfxMapSurfaceToScaledOutput MapSurfaceToScaledOutput;
+ psRdpgfxMapSurfaceToScaledWindow MapSurfaceToScaledWindow;
+ psRdpgfxCapsAdvertise CapsAdvertise;
+ psRdpgfxCapsConfirm CapsConfirm;
+ psRdpgfxFrameAcknowledge FrameAcknowledge;
+ psRdpgfxQoeFrameAcknowledge QoeFrameAcknowledge;
+
+ RdpgfxServerPrivate* priv;
+ rdpContext* rdpcontext;
+
+ /**
+ * Callback, when the channel got its id assigned.
+ */
+ psRdpgfxServerChannelIdAssigned ChannelIdAssigned;
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psRdpgfxServerInitialize Initialize;
+ };
+
+ FREERDP_API void rdpgfx_server_context_free(RdpgfxServerContext* context);
+
+ WINPR_ATTR_MALLOC(rdpgfx_server_context_free, 1)
+ FREERDP_API RdpgfxServerContext* rdpgfx_server_context_new(HANDLE vcm);
+
+ FREERDP_API BOOL rdpgfx_server_set_own_thread(RdpgfxServerContext* context,
+ BOOL internalThread);
+ FREERDP_API HANDLE rdpgfx_server_get_event_handle(RdpgfxServerContext* context);
+ FREERDP_API UINT rdpgfx_server_handle_messages(RdpgfxServerContext* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RDPGFX_SERVER_RDPGFX_H */
diff --git a/include/freerdp/server/rdpsnd.h b/include/freerdp/server/rdpsnd.h
new file mode 100644
index 0000000..cbd5eab
--- /dev/null
+++ b/include/freerdp/server/rdpsnd.h
@@ -0,0 +1,196 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Server Audio Virtual Channel
+ *
+ * Copyright 2012 Vic Lee
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_RDPSND_SERVER_H
+#define FREERDP_CHANNEL_RDPSND_SERVER_H
+
+#include <freerdp/channels/wtsvc.h>
+#include <freerdp/channels/rdpsnd.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_rdpsnd_server_context RdpsndServerContext;
+ typedef struct s_rdpsnd_server_context rdpsnd_server_context;
+ typedef struct s_rdpsnd_server_private RdpsndServerPrivate;
+
+ typedef UINT (*psRdpsndStart)(RdpsndServerContext* context);
+ typedef UINT (*psRdpsndStop)(RdpsndServerContext* context);
+
+ typedef BOOL (*psRdpsndChannelIdAssigned)(RdpsndServerContext* context, UINT32 channelId);
+
+ typedef UINT (*psRdpsndServerInitialize)(RdpsndServerContext* context, BOOL ownThread);
+ typedef UINT (*psRdpsndServerSendFormats)(RdpsndServerContext* context);
+ typedef UINT (*psRdpsndServerSelectFormat)(RdpsndServerContext* context,
+ UINT16 client_format_index);
+ typedef UINT (*psRdpsndServerTraining)(RdpsndServerContext* context, UINT16 timestamp,
+ UINT16 packsize, BYTE* data);
+ typedef UINT (*psRdpsndServerTrainingConfirm)(RdpsndServerContext* context, UINT16 timestamp,
+ UINT16 packsize);
+ typedef UINT (*psRdpsndServerSendSamples)(RdpsndServerContext* context, const void* buf,
+ size_t nframes, UINT16 wTimestamp);
+ typedef UINT (*psRdpsndServerSendSamples2)(RdpsndServerContext* context, UINT16 formatNo,
+ const void* buf, size_t size, UINT16 timestamp,
+ UINT32 audioTimeStamp);
+ typedef UINT (*psRdpsndServerConfirmBlock)(RdpsndServerContext* context, BYTE confirmBlockNum,
+ UINT16 wtimestamp);
+ typedef UINT (*psRdpsndServerSetVolume)(RdpsndServerContext* context, UINT16 left,
+ UINT16 right);
+ typedef UINT (*psRdpsndServerClose)(RdpsndServerContext* context);
+
+ typedef void (*psRdpsndServerActivated)(RdpsndServerContext* context);
+
+ struct s_rdpsnd_server_context
+ {
+ HANDLE vcm;
+
+ psRdpsndStart Start;
+ psRdpsndStop Stop;
+
+ RdpsndServerPrivate* priv;
+
+ /* Server self-defined pointer. */
+ void* data;
+
+ /* Server to request to use dynamic virtual channel. */
+ BOOL use_dynamic_virtual_channel;
+
+ /* Server supported formats. Set by server. */
+ AUDIO_FORMAT* server_formats;
+ size_t num_server_formats;
+
+ /* Server source PCM audio format. Set by server. */
+ AUDIO_FORMAT* src_format;
+
+ /* Server audio latency, or buffer size, in milli-seconds. Set by server. */
+ UINT32 latency;
+
+ /* Client supported formats. */
+ AUDIO_FORMAT* client_formats;
+ UINT16 num_client_formats;
+ UINT16 selected_client_format;
+
+ /* Last sent audio block number. */
+ UINT8 block_no;
+
+ /*** APIs called by the server. ***/
+ /**
+ * Initialize the channel. The caller should check the return value to see
+ * whether the initialization succeed. If not, the "Activated" callback
+ * will not be called and the server must not call any API on this context.
+ */
+ psRdpsndServerInitialize Initialize;
+
+ /**
+ * Choose the audio format to be sent. The index argument is an index into
+ * the client_formats array and must be smaller than num_client_formats.
+ */
+ psRdpsndServerSelectFormat SelectFormat;
+ /**
+ * Send audio samples. Actually bytes in the buffer must be:
+ * nframes * src_format.nBitsPerSample * src_format.nChannels / 8
+ */
+ psRdpsndServerSendSamples SendSamples;
+
+ /**
+ * Called when block confirm is received from the client
+ */
+ psRdpsndServerConfirmBlock ConfirmBlock;
+ /**
+ * Set the volume level of the client. Valid range is between 0 and 0xFFFF.
+ */
+ psRdpsndServerSetVolume SetVolume;
+ /**
+ * Close the audio stream.
+ */
+ psRdpsndServerClose Close;
+
+ /*** Callbacks registered by the server. ***/
+ /**
+ * The channel has been activated. The server maybe choose audio format and
+ * start audio stream from this point. Note that this callback is called
+ * from a different thread context so the server must be careful of thread
+ * synchronization.
+ */
+ psRdpsndServerActivated Activated;
+
+ /**
+ * MS-RDPEA channel version the client announces
+ */
+ UINT16 clientVersion;
+
+ rdpContext* rdpcontext;
+
+ /* dwFlags in CLIENT_AUDIO_VERSION_AND_FORMATS */
+ UINT32 capsFlags;
+ /* dwVolume in CLIENT_AUDIO_VERSION_AND_FORMATS */
+ UINT32 initialVolume;
+ /* dwPitch in CLIENT_AUDIO_VERSION_AND_FORMATS */
+ UINT32 initialPitch;
+
+ UINT16 qualityMode;
+
+ /**
+ * Send server formats and version to the client. Automatically sent, when
+ * opening the channel.
+ * Also used to restart the protocol after sending the Close PDU.
+ */
+ psRdpsndServerSendFormats SendFormats;
+ /**
+ * Send Training PDU.
+ */
+ psRdpsndServerTraining Training;
+
+ /**
+ * Send encoded audio samples using a Wave2 PDU.
+ * When successful, the block_no member is incremented.
+ */
+ psRdpsndServerSendSamples2 SendSamples2;
+
+ /**
+ * Called when a TrainingConfirm PDU is received from the client.
+ */
+ psRdpsndServerTrainingConfirm TrainingConfirm;
+
+ /**
+ * Callback, when the channel got its id assigned.
+ * Only called, when use_dynamic_virtual_channel=TRUE.
+ */
+ psRdpsndChannelIdAssigned ChannelIdAssigned;
+ };
+
+ FREERDP_API void rdpsnd_server_context_free(RdpsndServerContext* context);
+
+ WINPR_ATTR_MALLOC(rdpsnd_server_context_free, 1)
+ FREERDP_API RdpsndServerContext* rdpsnd_server_context_new(HANDLE vcm);
+
+ FREERDP_API void rdpsnd_server_context_reset(RdpsndServerContext*);
+
+ FREERDP_API HANDLE rdpsnd_server_get_event_handle(RdpsndServerContext* context);
+ FREERDP_API UINT rdpsnd_server_handle_messages(RdpsndServerContext* context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_RDPSND_SERVER_H */
diff --git a/include/freerdp/server/remdesk.h b/include/freerdp/server/remdesk.h
new file mode 100644
index 0000000..ef45032
--- /dev/null
+++ b/include/freerdp/server/remdesk.h
@@ -0,0 +1,67 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Remote Assistance Virtual Channel
+ *
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ * Copyright 2015 Thincast Technologies GmbH
+ * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_REMDESK_SERVER_REMDESK_H
+#define FREERDP_CHANNEL_REMDESK_SERVER_REMDESK_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+#include <freerdp/channels/wtsvc.h>
+
+#include <freerdp/client/remdesk.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * Server Interface
+ */
+
+ typedef struct s_remdesk_server_context RemdeskServerContext;
+ typedef struct s_remdesk_server_private RemdeskServerPrivate;
+
+ typedef UINT (*psRemdeskStart)(RemdeskServerContext* context);
+ typedef UINT (*psRemdeskStop)(RemdeskServerContext* context);
+
+ struct s_remdesk_server_context
+ {
+ HANDLE vcm;
+ void* custom;
+
+ psRemdeskStart Start;
+ psRemdeskStop Stop;
+
+ RemdeskServerPrivate* priv;
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void remdesk_server_context_free(RemdeskServerContext* context);
+
+ WINPR_ATTR_MALLOC(remdesk_server_context_free, 1)
+ FREERDP_API RemdeskServerContext* remdesk_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_REMDESK_SERVER_REMDESK_H */
diff --git a/include/freerdp/server/server-common.h b/include/freerdp/server/server-common.h
new file mode 100644
index 0000000..eba831b
--- /dev/null
+++ b/include/freerdp/server/server-common.h
@@ -0,0 +1,44 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * FreeRDP Server Common
+ *
+ * Copyright 2018 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2018 Thincast Technologies GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_COMMON_SERVER_H
+#define FREERDP_SERVER_COMMON_SERVER_H
+
+#include <winpr/wtypes.h>
+#include <freerdp/api.h>
+#include <freerdp/codec/audio.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ FREERDP_API size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats);
+ FREERDP_API size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats);
+
+ FREERDP_API void freerdp_server_warn_unmaintained(int argc, char* argv[]);
+ FREERDP_API void freerdp_server_warn_experimental(int argc, char* argv[]);
+ FREERDP_API void freerdp_server_warn_deprecated(int argc, char* argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_COMMON_SERVER_H */
diff --git a/include/freerdp/server/shadow.h b/include/freerdp/server/shadow.h
new file mode 100644
index 0000000..9ddb8ae
--- /dev/null
+++ b/include/freerdp/server/shadow.h
@@ -0,0 +1,350 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Session Shadowing
+ *
+ * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_SERVER_SHADOW_H
+#define FREERDP_SERVER_SHADOW_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#include <freerdp/freerdp.h>
+#include <freerdp/settings.h>
+#include <freerdp/listener.h>
+
+#include <freerdp/channels/wtsvc.h>
+#include <freerdp/channels/channels.h>
+
+#include <freerdp/server/encomsp.h>
+#include <freerdp/server/remdesk.h>
+#include <freerdp/server/rdpsnd.h>
+#if defined(CHANNEL_AUDIN_SERVER)
+#include <freerdp/server/audin.h>
+#endif
+#include <freerdp/server/rdpgfx.h>
+
+#include <freerdp/codec/color.h>
+#include <freerdp/codec/region.h>
+
+#include <winpr/crt.h>
+#include <winpr/synch.h>
+#include <winpr/collections.h>
+#include <winpr/cmdline.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct rdp_shadow_client rdpShadowClient;
+ typedef struct rdp_shadow_server rdpShadowServer;
+ typedef struct rdp_shadow_screen rdpShadowScreen;
+ typedef struct rdp_shadow_surface rdpShadowSurface;
+ typedef struct rdp_shadow_encoder rdpShadowEncoder;
+ typedef struct rdp_shadow_capture rdpShadowCapture;
+ typedef struct rdp_shadow_subsystem rdpShadowSubsystem;
+ typedef struct rdp_shadow_multiclient_event rdpShadowMultiClientEvent;
+
+ typedef struct S_RDP_SHADOW_ENTRY_POINTS RDP_SHADOW_ENTRY_POINTS;
+ typedef int (*pfnShadowSubsystemEntry)(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
+
+ typedef rdpShadowSubsystem* (*pfnShadowSubsystemNew)(void);
+ typedef void (*pfnShadowSubsystemFree)(rdpShadowSubsystem* subsystem);
+
+ typedef int (*pfnShadowSubsystemInit)(rdpShadowSubsystem* subsystem);
+ typedef int (*pfnShadowSubsystemUninit)(rdpShadowSubsystem* subsystem);
+
+ typedef int (*pfnShadowSubsystemStart)(rdpShadowSubsystem* subsystem);
+ typedef int (*pfnShadowSubsystemStop)(rdpShadowSubsystem* subsystem);
+
+ typedef UINT32 (*pfnShadowEnumMonitors)(MONITOR_DEF* monitors, UINT32 maxMonitors);
+
+ typedef int (*pfnShadowAuthenticate)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
+ const char* user, const char* domain,
+ const char* password);
+ typedef BOOL (*pfnShadowClientConnect)(rdpShadowSubsystem* subsystem, rdpShadowClient* client);
+ typedef void (*pfnShadowClientDisconnect)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client);
+ typedef BOOL (*pfnShadowClientCapabilities)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client);
+
+ typedef BOOL (*pfnShadowSynchronizeEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT32 flags);
+ typedef BOOL (*pfnShadowKeyboardEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
+ UINT16 flags, UINT8 code);
+ typedef BOOL (*pfnShadowUnicodeKeyboardEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags,
+ UINT16 code);
+ typedef BOOL (*pfnShadowMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
+ UINT16 flags, UINT16 x, UINT16 y);
+ typedef BOOL (*pfnShadowExtendedMouseEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x,
+ UINT16 y);
+
+ typedef BOOL (*pfnShadowChannelAudinServerReceiveSamples)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client,
+ const AUDIO_FORMAT* format,
+ wStream* data);
+
+ struct rdp_shadow_client
+ {
+ rdpContext context;
+
+ HANDLE thread;
+ BOOL activated;
+ BOOL first_frame;
+ BOOL inLobby;
+ BOOL mayView;
+ BOOL mayInteract;
+ BOOL suppressOutput;
+ UINT16 surfaceId;
+ wMessageQueue* MsgQueue;
+ CRITICAL_SECTION lock;
+ REGION16 invalidRegion;
+ rdpShadowServer* server;
+ rdpShadowEncoder* encoder;
+ rdpShadowSubsystem* subsystem;
+
+ UINT32 pointerX;
+ UINT32 pointerY;
+
+ HANDLE vcm;
+ EncomspServerContext* encomsp;
+ RemdeskServerContext* remdesk;
+ RdpsndServerContext* rdpsnd;
+#if defined(CHANNEL_AUDIN_SERVER)
+ audin_server_context* audin;
+#endif
+ RdpgfxServerContext* rdpgfx;
+
+ BOOL resizeRequested;
+ UINT32 resizeWidth;
+ UINT32 resizeHeight;
+ BOOL areGfxCapsReady;
+ };
+
+ struct rdp_shadow_server
+ {
+ void* ext;
+ HANDLE thread;
+ HANDLE StopEvent;
+ wArrayList* clients;
+ rdpSettings* settings;
+ rdpShadowScreen* screen;
+ rdpShadowSurface* surface;
+ rdpShadowSurface* lobby;
+ rdpShadowCapture* capture;
+ rdpShadowSubsystem* subsystem;
+
+ DWORD port;
+ BOOL mayView;
+ BOOL mayInteract;
+ BOOL shareSubRect;
+ BOOL authentication;
+ UINT32 selectedMonitor;
+ RECTANGLE_16 subRect;
+
+ /* Codec settings */
+ RLGR_MODE rfxMode;
+ H264_RATECONTROL_MODE h264RateControlMode;
+ UINT32 h264BitRate;
+ UINT32 h264FrameRate;
+ UINT32 h264QP;
+
+ char* ipcSocket;
+ char* ConfigPath;
+ char* CertificateFile;
+ char* PrivateKeyFile;
+ CRITICAL_SECTION lock;
+ freerdp_listener* listener;
+
+ size_t maxClientsConnected;
+ };
+
+ struct rdp_shadow_surface
+ {
+ rdpShadowServer* server;
+
+ UINT16 x;
+ UINT16 y;
+ UINT32 width;
+ UINT32 height;
+ UINT32 scanline;
+ DWORD format;
+ BYTE* data;
+
+ CRITICAL_SECTION lock;
+ REGION16 invalidRegion;
+ };
+
+ struct S_RDP_SHADOW_ENTRY_POINTS
+ {
+ pfnShadowSubsystemNew New;
+ pfnShadowSubsystemFree Free;
+
+ pfnShadowSubsystemInit Init;
+ pfnShadowSubsystemUninit Uninit;
+
+ pfnShadowSubsystemStart Start;
+ pfnShadowSubsystemStop Stop;
+
+ pfnShadowEnumMonitors EnumMonitors;
+ };
+
+ struct rdp_shadow_subsystem
+ {
+ RDP_SHADOW_ENTRY_POINTS ep;
+ HANDLE event;
+ UINT32 numMonitors;
+ UINT32 captureFrameRate;
+ UINT32 selectedMonitor;
+ MONITOR_DEF monitors[16];
+ MONITOR_DEF virtualScreen;
+
+ /* This event indicates that we have graphic change */
+ /* such as screen update and resize. It should not be */
+ /* used by subsystem implementation directly */
+ rdpShadowMultiClientEvent* updateEvent;
+
+ wMessagePipe* MsgPipe;
+ UINT32 pointerX;
+ UINT32 pointerY;
+
+ AUDIO_FORMAT* rdpsndFormats;
+ size_t nRdpsndFormats;
+ AUDIO_FORMAT* audinFormats;
+ size_t nAudinFormats;
+
+ pfnShadowSynchronizeEvent SynchronizeEvent;
+ pfnShadowKeyboardEvent KeyboardEvent;
+ pfnShadowUnicodeKeyboardEvent UnicodeKeyboardEvent;
+ pfnShadowMouseEvent MouseEvent;
+ pfnShadowExtendedMouseEvent ExtendedMouseEvent;
+ pfnShadowChannelAudinServerReceiveSamples AudinServerReceiveSamples;
+
+ pfnShadowAuthenticate Authenticate;
+ pfnShadowClientConnect ClientConnect;
+ pfnShadowClientDisconnect ClientDisconnect;
+ pfnShadowClientCapabilities ClientCapabilities;
+
+ rdpShadowServer* server;
+ };
+
+/* Definition of message between subsystem and clients */
+#define SHADOW_MSG_IN_REFRESH_REQUEST_ID 1001
+
+ typedef struct S_SHADOW_MSG_OUT SHADOW_MSG_OUT;
+ typedef void (*MSG_OUT_FREE_FN)(UINT32 id,
+ SHADOW_MSG_OUT* msg); /* function to free SHADOW_MSG_OUT */
+
+ struct S_SHADOW_MSG_OUT
+ {
+ int refCount;
+ MSG_OUT_FREE_FN Free;
+ };
+
+#define SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID 2001
+#define SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE_ID 2002
+#define SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES_ID 2003
+#define SHADOW_MSG_OUT_AUDIO_OUT_VOLUME_ID 2004
+
+ typedef struct
+ {
+ SHADOW_MSG_OUT common;
+ UINT32 xPos;
+ UINT32 yPos;
+ } SHADOW_MSG_OUT_POINTER_POSITION_UPDATE;
+
+ typedef struct
+ {
+ SHADOW_MSG_OUT common;
+ UINT32 xHot;
+ UINT32 yHot;
+ UINT32 width;
+ UINT32 height;
+ UINT32 lengthAndMask;
+ UINT32 lengthXorMask;
+ BYTE* xorMaskData;
+ BYTE* andMaskData;
+ } SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE;
+
+ typedef struct
+ {
+ SHADOW_MSG_OUT common;
+ AUDIO_FORMAT* audio_format;
+ void* buf;
+ size_t nFrames;
+ UINT16 wTimestamp;
+ } SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES;
+
+ typedef struct
+ {
+ SHADOW_MSG_OUT common;
+ UINT16 left;
+ UINT16 right;
+ } SHADOW_MSG_OUT_AUDIO_OUT_VOLUME;
+
+ FREERDP_API void shadow_subsystem_set_entry_builtin(const char* name);
+ FREERDP_API void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry);
+
+ FREERDP_API int shadow_subsystem_pointer_convert_alpha_pointer_data(
+ BYTE* pixels, BOOL premultiplied, UINT32 width, UINT32 height,
+ SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* pointerColor);
+
+ FREERDP_API int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** argv,
+ COMMAND_LINE_ARGUMENT_A* cargs);
+ FREERDP_API int shadow_server_command_line_status_print(rdpShadowServer* server, int argc,
+ char** argv, int status,
+ COMMAND_LINE_ARGUMENT_A* cargs);
+
+ FREERDP_API int shadow_server_start(rdpShadowServer* server);
+ FREERDP_API int shadow_server_stop(rdpShadowServer* server);
+
+ FREERDP_API int shadow_server_init(rdpShadowServer* server);
+ FREERDP_API int shadow_server_uninit(rdpShadowServer* server);
+
+ FREERDP_API UINT32 shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors);
+
+ FREERDP_API void shadow_server_free(rdpShadowServer* server);
+
+ WINPR_ATTR_MALLOC(shadow_server_free, 1)
+ FREERDP_API rdpShadowServer* shadow_server_new(void);
+
+ FREERDP_API int shadow_capture_align_clip_rect(RECTANGLE_16* rect, RECTANGLE_16* clip);
+ FREERDP_API int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth,
+ UINT32 nHeight, BYTE* pData2, UINT32 nStep2,
+ RECTANGLE_16* rect);
+
+ FREERDP_API void shadow_subsystem_frame_update(rdpShadowSubsystem* subsystem);
+
+ FREERDP_API BOOL shadow_client_post_msg(rdpShadowClient* client, void* context, UINT32 type,
+ SHADOW_MSG_OUT* msg, void* lParam);
+ FREERDP_API int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 type,
+ SHADOW_MSG_OUT* msg, void* lParam);
+ FREERDP_API int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode);
+
+ FREERDP_API UINT32 shadow_encoder_preferred_fps(rdpShadowEncoder* encoder);
+ FREERDP_API UINT32 shadow_encoder_inflight_frames(rdpShadowEncoder* encoder);
+
+ FREERDP_API BOOL shadow_screen_resize(rdpShadowScreen* screen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_SERVER_SHADOW_H */
diff --git a/include/freerdp/server/telemetry.h b/include/freerdp/server/telemetry.h
new file mode 100644
index 0000000..0697e70
--- /dev/null
+++ b/include/freerdp/server/telemetry.h
@@ -0,0 +1,111 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Telemetry Virtual Channel Extension
+ *
+ * Copyright 2022 Pascal Nowack <Pascal.Nowack@gmx.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FREERDP_CHANNEL_TELEMETRY_SERVER_TELEMETRY_H
+#define FREERDP_CHANNEL_TELEMETRY_SERVER_TELEMETRY_H
+
+#include <freerdp/channels/telemetry.h>
+#include <freerdp/channels/wtsvc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct s_telemetry_server_context TelemetryServerContext;
+
+ typedef UINT (*psTelemetryServerOpen)(TelemetryServerContext* context);
+ typedef UINT (*psTelemetryServerClose)(TelemetryServerContext* context);
+
+ typedef BOOL (*psTelemetryServerChannelIdAssigned)(TelemetryServerContext* context,
+ UINT32 channelId);
+
+ typedef UINT (*psTelemetryServerInitialize)(TelemetryServerContext* context,
+ BOOL externalThread);
+ typedef UINT (*psTelemetryServerPoll)(TelemetryServerContext* context);
+ typedef BOOL (*psTelemetryServerChannelHandle)(TelemetryServerContext* context, HANDLE* handle);
+
+ typedef UINT (*psTelemetryServerRdpTelemetry)(TelemetryServerContext* context,
+ const TELEMETRY_RDP_TELEMETRY_PDU* rdpTelemetry);
+
+ struct s_telemetry_server_context
+ {
+ HANDLE vcm;
+
+ /* Server self-defined pointer. */
+ void* userdata;
+
+ /*** APIs called by the server. ***/
+
+ /**
+ * Optional: Set thread handling.
+ * When externalThread=TRUE, the application is responsible to call
+ * Poll() periodically to process channel events.
+ *
+ * Defaults to externalThread=FALSE
+ */
+ psTelemetryServerInitialize Initialize;
+
+ /**
+ * Open the telemetry channel.
+ */
+ psTelemetryServerOpen Open;
+
+ /**
+ * Close the telemetry channel.
+ */
+ psTelemetryServerClose Close;
+
+ /**
+ * Poll
+ * When externalThread=TRUE, call Poll() periodically from your main loop.
+ * If externalThread=FALSE do not call.
+ */
+ psTelemetryServerPoll Poll;
+
+ /**
+ * Retrieve the channel handle for use in conjunction with Poll().
+ * If externalThread=FALSE do not call.
+ */
+ psTelemetryServerChannelHandle ChannelHandle;
+
+ /*** Callbacks registered by the server. ***/
+
+ /**
+ * Callback, when the channel got its id assigned
+ */
+ psTelemetryServerChannelIdAssigned ChannelIdAssigned;
+ /**
+ * Callback for the RDP Telemetry PDU.
+ */
+ psTelemetryServerRdpTelemetry RdpTelemetry;
+
+ rdpContext* rdpcontext;
+ };
+
+ FREERDP_API void telemetry_server_context_free(TelemetryServerContext* context);
+
+ WINPR_ATTR_MALLOC(telemetry_server_context_free, 1)
+ FREERDP_API TelemetryServerContext* telemetry_server_context_new(HANDLE vcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREERDP_CHANNEL_TELEMETRY_SERVER_TELEMETRY_H */