From 1afeb448b40cc02c68028dcd9c25de405c478fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 16 Feb 2014 20:12:45 -0500 Subject: [PATCH] libfreerdp-core: expose stubbed WtsApi function table from the core --- client/X11/xf_client.h | 10 ++-- include/freerdp/channels/channels.h | 5 ++ include/freerdp/constants.h | 36 -------------- include/freerdp/svc.h | 2 + include/freerdp/utils/svc_plugin.h | 1 + libfreerdp/core/channels.c | 76 +++++++++++++++++++++++++++++ winpr/include/winpr/wtsapi.h | 22 ++++++--- winpr/libwinpr/wtsapi/wtsapi.c | 8 +++ 8 files changed, 113 insertions(+), 47 deletions(-) diff --git a/client/X11/xf_client.h b/client/X11/xf_client.h index dec4876f2..a7e601006 100644 --- a/client/X11/xf_client.h +++ b/client/X11/xf_client.h @@ -20,6 +20,11 @@ #ifndef __XF_CLIENT_H #define __XF_CLIENT_H +#include +#include +#include +#include + #include #include #include @@ -31,11 +36,6 @@ #include #include -#include -#include -#include -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/freerdp/channels/channels.h b/include/freerdp/channels/channels.h index 589dba353..c136411dd 100644 --- a/include/freerdp/channels/channels.h +++ b/include/freerdp/channels/channels.h @@ -21,6 +21,9 @@ #ifndef FREERDP_CHANNELS_H #define FREERDP_CHANNELS_H +#include +#include + #include #include #include @@ -54,6 +57,8 @@ FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance); FREERDP_API int freerdp_channels_data(freerdp* instance, UINT16 channelId, BYTE* data, int dataSize, int flags, int totalSize); +FREERDP_API PWtsApiFunctionTable FreeRDP_InitWtsApi(void); + #ifdef __cplusplus } #endif diff --git a/include/freerdp/constants.h b/include/freerdp/constants.h index d5e1e9873..24517f7ce 100644 --- a/include/freerdp/constants.h +++ b/include/freerdp/constants.h @@ -32,37 +32,6 @@ enum RDP_CODEC_ID RDP_CODEC_ID_IMAGE_REMOTEFX = 0x04 }; -/** - * Static Virtual Channel Flags - */ -enum RDP_SVC_CHANNEL_FLAG -{ - CHANNEL_FLAG_MIDDLE = 0, - CHANNEL_FLAG_FIRST = 0x01, - CHANNEL_FLAG_LAST = 0x02, - CHANNEL_FLAG_ONLY = (CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST), - CHANNEL_FLAG_SHOW_PROTOCOL = 0x10, - CHANNEL_FLAG_SUSPEND = 0x20, - CHANNEL_FLAG_RESUME = 0x40, - CHANNEL_FLAG_FAIL = 0x100 -}; - -/** - * Static Virtual Channel Events - */ -enum RDP_SVC_CHANNEL_EVENT -{ - CHANNEL_EVENT_INITIALIZED = 0, - CHANNEL_EVENT_CONNECTED = 1, - CHANNEL_EVENT_V1_CONNECTED = 2, - CHANNEL_EVENT_DISCONNECTED = 3, - CHANNEL_EVENT_TERMINATED = 4, - CHANNEL_EVENT_DATA_RECEIVED = 10, - CHANNEL_EVENT_WRITE_COMPLETE = 11, - CHANNEL_EVENT_WRITE_CANCELLED = 12, - CHANNEL_EVENT_USER = 1000 -}; - /** * Pixel format */ @@ -79,11 +48,6 @@ enum RDP_PIXEL_FORMAT }; typedef enum RDP_PIXEL_FORMAT RDP_PIXEL_FORMAT; -/** - * Virtual Channel Constants - */ -#define CHANNEL_CHUNK_LENGTH 1600 - /** * CPU Optimization flags */ diff --git a/include/freerdp/svc.h b/include/freerdp/svc.h index 2616af331..fb9af4f47 100644 --- a/include/freerdp/svc.h +++ b/include/freerdp/svc.h @@ -25,6 +25,8 @@ #include +#define CHANNEL_EVENT_USER 1000 + #define CHANNEL_EXPORT_FUNC_NAME "VirtualChannelEntry" typedef UINT (FREERDP_CC * PVIRTUALCHANNELEVENTPUSH)(DWORD openHandle, wMessage* event); diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index ddcdbe61a..b18faa385 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/libfreerdp/core/channels.c b/libfreerdp/core/channels.c index 44658bec5..956be8b92 100644 --- a/libfreerdp/core/channels.c +++ b/libfreerdp/core/channels.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -143,3 +144,78 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann return TRUE; } + +static WtsApiFunctionTable FreeRDP_WtsApiFunctionTable = +{ + 0, /* dwVersion */ + 0, /* dwFlags */ + + NULL, /* StopRemoteControlSession */ + NULL, /* StartRemoteControlSessionW */ + NULL, /* StartRemoteControlSessionA */ + NULL, /* ConnectSessionW */ + NULL, /* ConnectSessionA */ + NULL, /* EnumerateServersW */ + NULL, /* EnumerateServersA */ + NULL, /* OpenServerW */ + NULL, /* OpenServerA */ + NULL, /* OpenServerExW */ + NULL, /* OpenServerExA */ + NULL, /* CloseServer */ + NULL, /* EnumerateSessionsW */ + NULL, /* EnumerateSessionsA */ + NULL, /* EnumerateSessionsExW */ + NULL, /* EnumerateSessionsExA */ + NULL, /* EnumerateProcessesW */ + NULL, /* EnumerateProcessesA */ + NULL, /* TerminateProcess */ + NULL, /* QuerySessionInformationW */ + NULL, /* QuerySessionInformationA */ + NULL, /* QueryUserConfigW */ + NULL, /* QueryUserConfigA */ + NULL, /* SetUserConfigW */ + NULL, /* SetUserConfigA */ + NULL, /* SendMessageW */ + NULL, /* SendMessageA */ + NULL, /* DisconnectSession */ + NULL, /* LogoffSession */ + NULL, /* ShutdownSystem */ + NULL, /* WaitSystemEvent */ + NULL, /* VirtualChannelOpen */ + NULL, /* VirtualChannelOpenEx */ + NULL, /* VirtualChannelClose */ + NULL, /* VirtualChannelRead */ + NULL, /* VirtualChannelWrite */ + NULL, /* VirtualChannelPurgeInput */ + NULL, /* VirtualChannelPurgeOutput */ + NULL, /* VirtualChannelQuery */ + NULL, /* FreeMemory */ + NULL, /* RegisterSessionNotification */ + NULL, /* UnRegisterSessionNotification */ + NULL, /* RegisterSessionNotificationEx */ + NULL, /* UnRegisterSessionNotificationEx */ + NULL, /* QueryUserToken */ + NULL, /* FreeMemoryExW */ + NULL, /* FreeMemoryExA */ + NULL, /* EnumerateProcessesExW */ + NULL, /* EnumerateProcessesExA */ + NULL, /* EnumerateListenersW */ + NULL, /* EnumerateListenersA */ + NULL, /* QueryListenerConfigW */ + NULL, /* QueryListenerConfigA */ + NULL, /* CreateListenerW */ + NULL, /* CreateListenerA */ + NULL, /* SetListenerSecurityW */ + NULL, /* SetListenerSecurityA */ + NULL, /* GetListenerSecurityW */ + NULL, /* GetListenerSecurityA */ + NULL, /* EnableChildSessions */ + NULL, /* IsChildSessionsEnabled */ + NULL, /* GetChildSessionId */ + NULL /* GetActiveConsoleSessionId */ +}; + +PWtsApiFunctionTable FreeRDP_InitWtsApi(void) +{ + return &FreeRDP_WtsApiFunctionTable; +} diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h index cb0a71aba..2a4fa68a7 100644 --- a/winpr/include/winpr/wtsapi.h +++ b/winpr/include/winpr/wtsapi.h @@ -29,6 +29,11 @@ #include +/** + * Workaround for X11 "CurrentTime" header conflict + */ +#define CurrentTime _CurrentTime + #else /** @@ -437,12 +442,12 @@ typedef struct _WTSINFOW DWORD OutgoingCompressedBytes; WCHAR WinStationName[WINSTATIONNAME_LENGTH]; WCHAR Domain[DOMAIN_LENGTH]; - WCHAR UserName[USERNAME_LENGTH+1]; + WCHAR UserName[USERNAME_LENGTH + 1]; LARGE_INTEGER ConnectTime; LARGE_INTEGER DisconnectTime; LARGE_INTEGER LastInputTime; LARGE_INTEGER LogonTime; - LARGE_INTEGER CurrentTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ } WTSINFOW, *PWTSINFOW; typedef struct _WTSINFOA @@ -462,7 +467,7 @@ typedef struct _WTSINFOA LARGE_INTEGER DisconnectTime; LARGE_INTEGER LastInputTime; LARGE_INTEGER LogonTime; - LARGE_INTEGER CurrentTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ } WTSINFOA, *PWTSINFOA; #define WTS_SESSIONSTATE_UNKNOWN 0xFFFFFFFF @@ -481,7 +486,7 @@ typedef struct _WTSINFOEX_LEVEL1_W LARGE_INTEGER ConnectTime; LARGE_INTEGER DisconnectTime; LARGE_INTEGER LastInputTime; - LARGE_INTEGER CurrentTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ DWORD IncomingBytes; DWORD OutgoingBytes; DWORD IncomingFrames; @@ -502,7 +507,7 @@ typedef struct _WTSINFOEX_LEVEL1_A LARGE_INTEGER ConnectTime; LARGE_INTEGER DisconnectTime; LARGE_INTEGER LastInputTime; - LARGE_INTEGER CurrentTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ DWORD IncomingBytes; DWORD OutgoingBytes; DWORD IncomingFrames; @@ -711,7 +716,7 @@ typedef struct _WTSUSERCONFIGW #define WTS_EVENT_LOGOFF 0x00000040 #define WTS_EVENT_STATECHANGE 0x00000080 #define WTS_EVENT_LICENSE 0x00000100 -#define WTS_EVENT_ALL 0x7fffffff +#define WTS_EVENT_ALL 0x7FFFFFFF #define WTS_EVENT_FLUSH 0x80000000 #define REMOTECONTROL_KBDSHIFT_HOTKEY 0x1 @@ -1046,6 +1051,8 @@ WINPR_API BOOL WTSIsChildSessionsEnabled(PBOOL pbEnabled); WINPR_API BOOL WTSGetChildSessionId(PULONG pSessionId); +WINPR_API DWORD WTSGetActiveConsoleSessionId(void); + #ifdef __cplusplus } #endif @@ -1235,6 +1242,8 @@ typedef BOOL (WTSAPI * WTS_IS_CHILD_SESSIONS_ENABLED_FN)(PBOOL pbEnabled); typedef BOOL (WTSAPI * WTS_GET_CHILD_SESSION_ID_FN)(PULONG pSessionId); +typedef DWORD (WTSAPI * WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN)(void); + struct _WtsApiFunctionTable { DWORD dwVersion; @@ -1302,6 +1311,7 @@ struct _WtsApiFunctionTable WTS_ENABLE_CHILD_SESSIONS_FN EnableChildSessions; WTS_IS_CHILD_SESSIONS_ENABLED_FN IsChildSessionsEnabled; WTS_GET_CHILD_SESSION_ID_FN GetChildSessionId; + WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN GetActiveConsoleSessionId; }; typedef struct _WtsApiFunctionTable WtsApiFunctionTable; typedef WtsApiFunctionTable* PWtsApiFunctionTable; diff --git a/winpr/libwinpr/wtsapi/wtsapi.c b/winpr/libwinpr/wtsapi/wtsapi.c index b74e4d4de..e6eb9aba3 100644 --- a/winpr/libwinpr/wtsapi/wtsapi.c +++ b/winpr/libwinpr/wtsapi/wtsapi.c @@ -551,6 +551,14 @@ BOOL WTSGetChildSessionId(PULONG pSessionId) return g_WtsApi->GetChildSessionId(pSessionId); } +DWORD WTSGetActiveConsoleSessionId(void) +{ + if (!g_WtsApi || !g_WtsApi->GetActiveConsoleSessionId) + return 0xFFFFFFFF; + + return g_WtsApi->GetActiveConsoleSessionId(); +} + #endif BOOL WTSRegisterWtsApiFunctionTable(PWtsApiFunctionTable table)