From 114a492a4ecd23e27942c7b1ee5edf5317182b5c Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 16 Feb 2015 12:14:20 +0100 Subject: [PATCH 1/2] gitignore: ignore clion files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5aa9ce86b..2f789c6fa 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,6 @@ TAGS # packaging related files !packaging/scripts/prepare_deb_freerdp-nightly.sh + +# +.idea From 0b902eeb5d0c08a006514aba7366f5c4afec1102 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 16 Feb 2015 12:16:54 +0100 Subject: [PATCH 2/2] wtsapi: add WTSStartRemoteControlSessionEx WTSStartRemoteControlSession doesn't allow to specify additional flags therefore add a new extended version WTSStartRemoteControlSessionEx with an additional "flags" parameter. The following flags are defined: REMOTECONTROL_FLAG_DISABLE_KEYBOARD - disable keyboard input REMOTECONTROL_FLAG_DISABLE_MOUSE - disable mouse input REMOTECONTROL_FLAG_DISABLE_INPUT - disable input (keyboard and mouse) --- libfreerdp/core/channels.c | 5 +++- libfreerdp/core/server.c | 11 +++++++ libfreerdp/core/server.h | 3 ++ winpr/include/winpr/wtsapi.h | 19 +++++++++++- winpr/libwinpr/wtsapi/test/CMakeLists.txt | 1 + .../TestWtsApiExtraStartRemoteSessionEx.c | 29 +++++++++++++++++++ winpr/libwinpr/wtsapi/wtsapi.c | 11 +++++++ 7 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c diff --git a/libfreerdp/core/channels.c b/libfreerdp/core/channels.c index 9bc8ee0c7..39f8697d8 100644 --- a/libfreerdp/core/channels.c +++ b/libfreerdp/core/channels.c @@ -3,6 +3,7 @@ * Virtual Channels * * Copyright 2011 Vic Lee + * Copyright 2015 Copyright 2015 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. @@ -245,7 +246,9 @@ static WtsApiFunctionTable FreeRDP_WtsApiFunctionTable = FreeRDP_WTSGetChildSessionId, /* GetChildSessionId */ FreeRDP_WTSGetActiveConsoleSessionId, /* GetActiveConsoleSessionId */ FreeRDP_WTSLogonUser, - FreeRDP_WTSLogoffUser + FreeRDP_WTSLogoffUser, + FreeRDP_WTSStartRemoteControlSessionExW, + FreeRDP_WTSStartRemoteControlSessionExA }; PWtsApiFunctionTable FreeRDP_InitWtsApi(void) diff --git a/libfreerdp/core/server.c b/libfreerdp/core/server.c index a9406e4af..b99e3f06c 100644 --- a/libfreerdp/core/server.c +++ b/libfreerdp/core/server.c @@ -3,6 +3,7 @@ * Server Channels * * Copyright 2014 Marc-Andre Moreau + * Copyright 2015 Copyright 2015 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. @@ -628,6 +629,16 @@ BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG return FALSE; } +BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags) +{ + return FALSE; +} + +BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags) +{ + return FALSE; +} + BOOL WINAPI FreeRDP_WTSStopRemoteControlSession(ULONG LogonId) { return FALSE; diff --git a/libfreerdp/core/server.h b/libfreerdp/core/server.h index 7d53cc9b4..aa165557e 100644 --- a/libfreerdp/core/server.h +++ b/libfreerdp/core/server.h @@ -3,6 +3,7 @@ * Server Channels * * Copyright 2014 Marc-Andre Moreau + * Copyright 2015 Copyright 2015 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. @@ -97,6 +98,8 @@ struct WTSVirtualChannelManager BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers); BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers); +BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); +BOOL WINAPI FreeRDP_WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); BOOL WINAPI FreeRDP_WTSStopRemoteControlSession(ULONG LogonId); BOOL WINAPI FreeRDP_WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait); BOOL WINAPI FreeRDP_WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait); diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h index 376a8518c..4b83c5e44 100644 --- a/winpr/include/winpr/wtsapi.h +++ b/winpr/include/winpr/wtsapi.h @@ -4,6 +4,7 @@ * * Copyright 2013 Marc-Andre Moreau * Copyright 2015 DI (FH) Martin Haimberger + * Copyright 2015 Copyright 2015 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. @@ -82,7 +83,7 @@ typedef struct tagCHANNEL_PDU_HEADER UINT32 flags; } CHANNEL_PDU_HEADER, *PCHANNEL_PDU_HEADER; -#endif +#endif /* _WIN32 */ /** * These channel flags are defined in some versions of pchannel.h only @@ -952,6 +953,10 @@ typedef struct _WTSLISTENERCONFIGA #define PWTSLISTENERCONFIG PWTSLISTENERCONFIGA #endif +#define REMOTECONTROL_FLAG_DISABLE_KEYBOARD 0x00000001 +#define REMOTECONTROL_FLAG_DISABLE_MOUSE 0x00000002 +#define REMOTECONTROL_FLAG_DISABLE_INPUT REMOTECONTROL_FLAG_DISABLE_KEYBOARD | REMOTECONTROL_FLAG_DISABLE_MOUSE + #ifdef __cplusplus extern "C" { #endif @@ -961,6 +966,9 @@ WINPR_API BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId); WINPR_API BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers); WINPR_API BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers); +WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); +WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); + WINPR_API BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait); WINPR_API BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait); @@ -1091,6 +1099,7 @@ WINPR_API BOOL CDECL WTSLogoffUser(HANDLE hServer); #ifdef UNICODE #define WTSStartRemoteControlSession WTSStartRemoteControlSessionW +#define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExW #define WTSConnectSession WTSConnectSessionW #define WTSEnumerateServers WTSEnumerateServersW #define WTSOpenServer WTSOpenServerW @@ -1111,6 +1120,7 @@ WINPR_API BOOL CDECL WTSLogoffUser(HANDLE hServer); #define WTSGetListenerSecurity WTSGetListenerSecurityW #else #define WTSStartRemoteControlSession WTSStartRemoteControlSessionA +#define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExA #define WTSConnectSession WTSConnectSessionA #define WTSEnumerateServers WTSEnumerateServersA #define WTSOpenServer WTSOpenServerA @@ -1151,6 +1161,11 @@ typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_FN_W)(LPWSTR pTargetServ typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_FN_A)(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers); +typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W)(LPWSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); +typedef BOOL (WINAPI * WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A)(LPSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags); + typedef BOOL (WINAPI * WTS_CONNECT_SESSION_FN_W)(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait); typedef BOOL (WINAPI * WTS_CONNECT_SESSION_FN_A)(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, BOOL bWait); @@ -1360,6 +1375,8 @@ struct _WtsApiFunctionTable WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN pGetActiveConsoleSessionId; WTS_LOGON_USER_FN pLogonUser; WTS_LOGOFF_USER_FN pLogoffUser; + WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W pStartRemoteControlSessionExW; + WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A pStartRemoteControlSessionExA; }; typedef struct _WtsApiFunctionTable WtsApiFunctionTable; typedef WtsApiFunctionTable* PWtsApiFunctionTable; diff --git a/winpr/libwinpr/wtsapi/test/CMakeLists.txt b/winpr/libwinpr/wtsapi/test/CMakeLists.txt index c79d823f6..3e7e955a8 100644 --- a/winpr/libwinpr/wtsapi/test/CMakeLists.txt +++ b/winpr/libwinpr/wtsapi/test/CMakeLists.txt @@ -44,6 +44,7 @@ set(${MODULE_PREFIX}_TESTS TestWtsApiExtraLogoffSession.c TestWtsApiExtraSendMessage.c TestWtsApiExtraVirtualChannel.c + TestWtsApiExtraStartRemoteSessionEx.c ) create_test_sourcelist(${MODULE_PREFIX}_SRCS diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c b/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c new file mode 100644 index 000000000..a1d1f67f2 --- /dev/null +++ b/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c @@ -0,0 +1,29 @@ + +#include +#include +#include +#include +#include + +int TestWtsApiExtraStartRemoteSessionEx(int argc, char* argv[]) +{ + BOOL bSuccess; + ULONG logonId = 0; + char logonIdStr[10]; + + bSuccess = GetEnvironmentVariable("TEST_SESSION_LOGON_ID", logonIdStr, 10); + if(bSuccess) + { + sscanf(logonIdStr, "%u\n", &logonId); + } + + bSuccess = WTSStartRemoteControlSessionEx(NULL, logonId, VK_F10, REMOTECONTROL_KBDSHIFT_HOTKEY|REMOTECONTROL_KBDCTRL_HOTKEY, REMOTECONTROL_FLAG_DISABLE_INPUT); + + if (!bSuccess) + { + printf("WTSStartRemoteControlSessionEx failed: %d\n", (int) GetLastError()); + return -1; + } + + return 0; +} diff --git a/winpr/libwinpr/wtsapi/wtsapi.c b/winpr/libwinpr/wtsapi/wtsapi.c index 8001fffcc..9062e723d 100644 --- a/winpr/libwinpr/wtsapi/wtsapi.c +++ b/winpr/libwinpr/wtsapi/wtsapi.c @@ -4,6 +4,7 @@ * * Copyright 2013 Marc-Andre Moreau * Copyright 2015 DI (FH) Martin Haimberger + * Copyright 2015 Copyright 2015 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. @@ -219,6 +220,16 @@ BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, ULONG TargetL WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionA, pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers); } +BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags) +{ + WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionExW, pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers, flags); +} + +BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers, DWORD flags) +{ + WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionExA, pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers, flags); +} + BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId) { WTSAPI_STUB_CALL_BOOL(StopRemoteControlSession, LogonId);