Milestone 5: deliver embedded RDP sessions and lifecycle hardening

This commit is contained in:
Keith Smith
2026-03-03 18:59:26 -07:00
parent 230a401386
commit 36006bd4aa
2941 changed files with 724359 additions and 77 deletions

View File

@@ -0,0 +1,63 @@
# FreeRDP: A Remote Desktop Protocol Implementation
# FreeRDP Sample Server cmake build script
#
# 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.
set(MODULE_NAME "sfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_SAMPLE")
set(SRCS
sfreerdp.c
sfreerdp.h
sf_audin.c
sf_audin.h
sf_rdpsnd.c
sf_rdpsnd.h
sf_encomsp.c
sf_encomsp.h
)
if(CHANNEL_AINPUT_SERVER)
list(APPEND SRCS sf_ainput.c sf_ainput.h)
endif()
option(SAMPLE_USE_VENDOR_PRODUCT_CONFIG_DIR "Use <vendor>/<product> path for resources" OFF)
set(SAMPLE_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR})
if(SAMPLE_USE_VENDOR_PRODUCT_CONFIG_DIR)
string(APPEND SAMPLE_RESOURCE_ROOT "/${VENDOR}")
endif()
string(APPEND SAMPLE_RESOURCE_ROOT "/${PRODUCT}")
if(WITH_RESOURCE_VERSIONING)
string(APPEND SAMPLE_RESOURCE_ROOT "${FREERDP_VERSION_MAJOR}")
endif()
string(APPEND SAMPLE_RESOURCE_ROOT "/images")
set(SAMPLE_ICONS test_icon.bmp test_icon.png test_icon.jpg test_icon.webp)
install(FILES ${SAMPLE_ICONS} DESTINATION ${SAMPLE_RESOURCE_ROOT})
# We need this in runtime path for TestConnect
file(COPY test_icon.bmp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
addtargetwithresourcefile(${MODULE_NAME} TRUE "${FREERDP_VERSION}" SRCS)
target_compile_definitions(${MODULE_NAME} PRIVATE SAMPLE_RESOURCE_ROOT="${SAMPLE_RESOURCE_ROOT}")
list(APPEND LIBS freerdp-server)
list(APPEND LIBS winpr freerdp)
target_link_libraries(${MODULE_NAME} ${LIBS})
installwithrpath(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Sample")

View File

@@ -0,0 +1,3 @@
set(FREERDP_SERVER_NAME "sfreerdp-server")
set(FREERDP_SERVER_PLATFORM "Sample")
set(FREERDP_SERVER_VENDOR "FreeRDP")

Binary file not shown.

View File

@@ -0,0 +1,93 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Advanced Input)
*
* Copyright 2022 Armin Novak <armin.novak@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.
*/
#include <freerdp/config.h>
#include <winpr/assert.h>
#include "sfreerdp.h"
#include "sf_ainput.h"
#include <freerdp/server/server-common.h>
#include <freerdp/server/ainput.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("sample.ainput")
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
WINPR_ATTR_NODISCARD
static UINT sf_peer_ainput_mouse_event(WINPR_ATTR_UNUSED ainput_server_context* context,
UINT64 timestamp, UINT64 flags, INT32 x, INT32 y)
{
/* TODO: Implement */
WINPR_ASSERT(context);
WLog_WARN(TAG, "not implemented: 0x%08" PRIx64 ", 0x%08" PRIx64 ", %" PRId32 "x%" PRId32,
timestamp, flags, x, y);
return CHANNEL_RC_OK;
}
void sf_peer_ainput_init(testPeerContext* context)
{
WINPR_ASSERT(context);
context->ainput = ainput_server_context_new(context->vcm);
WINPR_ASSERT(context->ainput);
context->ainput->rdpcontext = &context->_p;
context->ainput->data = context;
context->ainput->MouseEvent = sf_peer_ainput_mouse_event;
}
BOOL sf_peer_ainput_start(testPeerContext* context)
{
if (!context || !context->ainput || !context->ainput->Open)
return FALSE;
return context->ainput->Open(context->ainput) == CHANNEL_RC_OK;
}
BOOL sf_peer_ainput_stop(testPeerContext* context)
{
if (!context || !context->ainput || !context->ainput->Close)
return FALSE;
return context->ainput->Close(context->ainput) == CHANNEL_RC_OK;
}
BOOL sf_peer_ainput_running(testPeerContext* context)
{
if (!context || !context->ainput || !context->ainput->IsOpen)
return FALSE;
return context->ainput->IsOpen(context->ainput);
}
void sf_peer_ainput_uninit(testPeerContext* context)
{
ainput_server_context_free(context->ainput);
}

View File

@@ -0,0 +1,37 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Advanced Input)
*
* Copyright 2022 Armin Novak <armin.novak@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_SERVER_SAMPLE_SF_AINPUT_H
#define FREERDP_SERVER_SAMPLE_SF_AINPUT_H
#include <freerdp/freerdp.h>
#include <freerdp/listener.h>
#include <freerdp/server/ainput.h>
#include "sfreerdp.h"
void sf_peer_ainput_init(testPeerContext* context);
void sf_peer_ainput_uninit(testPeerContext* context);
WINPR_ATTR_NODISCARD BOOL sf_peer_ainput_running(testPeerContext* context);
BOOL sf_peer_ainput_start(testPeerContext* context);
BOOL sf_peer_ainput_stop(testPeerContext* context);
#endif /* FREERDP_SERVER_SAMPLE_SF_AINPUT_H */

View File

@@ -0,0 +1,114 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Audio Input)
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* 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.
*/
#include <freerdp/config.h>
#include <winpr/assert.h>
#include "sfreerdp.h"
#include "sf_audin.h"
#include <freerdp/server/server-common.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("sample")
#if defined(CHANNEL_AUDIN_SERVER)
WINPR_ATTR_NODISCARD
static UINT sf_peer_audin_data(WINPR_ATTR_UNUSED audin_server_context* audin,
const SNDIN_DATA* data)
{
/* TODO: Implement */
WINPR_ASSERT(audin);
WINPR_ASSERT(data);
WLog_WARN(TAG, "not implemented");
WLog_DBG(TAG, "receive %" PRIuz " bytes.", Stream_Length(data->Data));
return CHANNEL_RC_OK;
}
#endif
BOOL sf_peer_audin_init(testPeerContext* context)
{
WINPR_ASSERT(context);
#if defined(CHANNEL_AUDIN_SERVER)
context->audin = audin_server_context_new(context->vcm);
WINPR_ASSERT(context->audin);
context->audin->rdpcontext = &context->_p;
context->audin->userdata = context;
context->audin->Data = sf_peer_audin_data;
return audin_server_set_formats(context->audin, -1, nullptr);
#else
return TRUE;
#endif
}
BOOL sf_peer_audin_start(testPeerContext* context)
{
#if defined(CHANNEL_AUDIN_SERVER)
if (!context || !context->audin || !context->audin->Open)
return FALSE;
return context->audin->Open(context->audin);
#else
return FALSE;
#endif
}
BOOL sf_peer_audin_stop(testPeerContext* context)
{
#if defined(CHANNEL_AUDIN_SERVER)
if (!context || !context->audin || !context->audin->Close)
return FALSE;
return context->audin->Close(context->audin);
#else
return FALSE;
#endif
}
BOOL sf_peer_audin_running(testPeerContext* context)
{
#if defined(CHANNEL_AUDIN_SERVER)
if (!context || !context->audin || !context->audin->IsOpen)
return FALSE;
return context->audin->IsOpen(context->audin);
#else
return FALSE;
#endif
}
void sf_peer_audin_uninit(testPeerContext* context)
{
WINPR_ASSERT(context);
#if defined(CHANNEL_AUDIN_SERVER)
audin_server_context_free(context->audin);
context->audin = nullptr;
#endif
}

View File

@@ -0,0 +1,35 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Audio Input)
*
* 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_SERVER_SAMPLE_SF_AUDIN_H
#define FREERDP_SERVER_SAMPLE_SF_AUDIN_H
#include <freerdp/freerdp.h>
#include <freerdp/listener.h>
#include "sfreerdp.h"
WINPR_ATTR_NODISCARD BOOL sf_peer_audin_init(testPeerContext* context);
void sf_peer_audin_uninit(testPeerContext* context);
WINPR_ATTR_NODISCARD BOOL sf_peer_audin_running(testPeerContext* context);
BOOL sf_peer_audin_start(testPeerContext* context);
BOOL sf_peer_audin_stop(testPeerContext* context);
#endif /* FREERDP_SERVER_SAMPLE_SF_AUDIN_H */

View File

@@ -0,0 +1,40 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Lync Multiparty)
*
* 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.
*/
#include <freerdp/config.h>
#include <winpr/assert.h>
#include "sf_encomsp.h"
BOOL sf_peer_encomsp_init(testPeerContext* context)
{
WINPR_ASSERT(context);
context->encomsp = encomsp_server_context_new(context->vcm);
if (!context->encomsp)
return FALSE;
context->encomsp->rdpcontext = &context->_p;
WINPR_ASSERT(context->encomsp->Start);
return (context->encomsp->Start(context->encomsp) == CHANNEL_RC_OK);
}

View File

@@ -0,0 +1,31 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Lync Multiparty)
*
* 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_SAMPLE_SF_ENCOMSP_H
#define FREERDP_SERVER_SAMPLE_SF_ENCOMSP_H
#include <freerdp/freerdp.h>
#include <freerdp/listener.h>
#include <freerdp/server/encomsp.h>
#include "sfreerdp.h"
WINPR_ATTR_NODISCARD BOOL sf_peer_encomsp_init(testPeerContext* context);
#endif /* FREERDP_SERVER_SAMPLE_SF_ENCOMSP_H */

View File

@@ -0,0 +1,57 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Audio Output)
*
* Copyright 2012 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.
*/
#include <freerdp/config.h>
#include <winpr/assert.h>
#include "sf_rdpsnd.h"
#include <freerdp/server/server-common.h>
#include <freerdp/log.h>
#define TAG SERVER_TAG("sample")
static void sf_peer_rdpsnd_activated(RdpsndServerContext* context)
{
WINPR_UNUSED(context);
WINPR_ASSERT(context);
WLog_DBG(TAG, "RDPSND Activated");
}
BOOL sf_peer_rdpsnd_init(testPeerContext* context)
{
WINPR_ASSERT(context);
context->rdpsnd = rdpsnd_server_context_new(context->vcm);
WINPR_ASSERT(context->rdpsnd);
context->rdpsnd->rdpcontext = &context->_p;
context->rdpsnd->data = context;
context->rdpsnd->num_server_formats =
server_rdpsnd_get_formats(&context->rdpsnd->server_formats);
if (context->rdpsnd->num_server_formats > 0)
context->rdpsnd->src_format = &context->rdpsnd->server_formats[0];
context->rdpsnd->Activated = sf_peer_rdpsnd_activated;
WINPR_ASSERT(context->rdpsnd->Initialize);
return (context->rdpsnd->Initialize(context->rdpsnd, TRUE) == CHANNEL_RC_OK);
}

View File

@@ -0,0 +1,31 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server (Audio Output)
*
* 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_SERVER_SAMPLE_SF_RDPSND_H
#define FREERDP_SERVER_SAMPLE_SF_RDPSND_H
#include <freerdp/freerdp.h>
#include <freerdp/listener.h>
#include <freerdp/server/rdpsnd.h>
#include "sfreerdp.h"
WINPR_ATTR_NODISCARD BOOL sf_peer_rdpsnd_init(testPeerContext* context);
#endif /* FREERDP_SERVER_SAMPLE_SF_RDPSND_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Sample Server
*
* 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_SERVER_SAMPLE_SFREERDP_SERVER_H
#define FREERDP_SERVER_SAMPLE_SFREERDP_SERVER_H
#include <freerdp/freerdp.h>
#include <freerdp/listener.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/codec/nsc.h>
#include <freerdp/channels/wtsvc.h>
#if defined(CHANNEL_AINPUT_SERVER)
#include <freerdp/server/ainput.h>
#endif
#if defined(CHANNEL_AUDIN_SERVER)
#include <freerdp/server/audin.h>
#endif
#include <freerdp/server/rdpsnd.h>
#include <freerdp/server/encomsp.h>
#include <freerdp/transport_io.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include <winpr/image.h>
struct test_peer_context
{
rdpContext _p;
RFX_CONTEXT* rfx_context;
NSC_CONTEXT* nsc_context;
wStream* s;
BYTE* bg_data;
UINT32 icon_x;
UINT32 icon_y;
BOOL activated;
HANDLE event;
HANDLE stopEvent;
HANDLE vcm;
void* debug_channel;
HANDLE debug_channel_thread;
#if defined(CHANNEL_AUDIN_SERVER)
audin_server_context* audin;
#endif
BOOL audin_open;
#if defined(CHANNEL_AINPUT_SERVER)
ainput_server_context* ainput;
BOOL ainput_open;
#endif
UINT32 frame_id;
RdpsndServerContext* rdpsnd;
EncomspServerContext* encomsp;
rdpTransportIo io;
wImage* image;
};
typedef struct test_peer_context testPeerContext;
#endif /* FREERDP_SERVER_SAMPLE_SFREERDP_SERVER_H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB