libfreerdp-core: link against libwinpr-wtsapi, dynamically register proper WtsApi...
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 17 Feb 2014 01:41:19 +0000 (20:41 -0500)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 17 Feb 2014 01:41:19 +0000 (20:41 -0500)
libfreerdp/core/CMakeLists.txt
libfreerdp/core/channels.c
libfreerdp/core/freerdp.c
libfreerdp/core/server.c
libfreerdp/core/server.h
winpr/libwinpr/synch/wait.c
winpr/libwinpr/wtsapi/CMakeLists.txt
winpr/libwinpr/wtsapi/wtsapi.c
winpr/libwinpr/wtsapi/wtsrpc_c.c [deleted file]
winpr/libwinpr/wtsapi/wtsrpc_c.h [deleted file]

index a22f193..8f7d264 100644 (file)
@@ -146,7 +146,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
 set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
        MONOLITHIC ${MONOLITHIC_BUILD}
        MODULE winpr
-       MODULES winpr-registry winpr-utils winpr-interlocked winpr-dsparse winpr-sspi winpr-rpc winpr-handle winpr-crt)
+       MODULES winpr-registry winpr-utils winpr-interlocked winpr-dsparse winpr-sspi winpr-rpc winpr-wtsapi winpr-handle winpr-crt)
 
 if(MONOLITHIC_BUILD)
        set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
index 956be8b..1ba65fd 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "rdp.h"
 #include "client.h"
+#include "server.h"
 #include "channels.h"
 
 BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channelId, BYTE* data, int size)
@@ -181,15 +182,15 @@ static WtsApiFunctionTable FreeRDP_WtsApiFunctionTable =
        NULL, /* LogoffSession */
        NULL, /* ShutdownSystem */
        NULL, /* WaitSystemEvent */
-       NULL, /* VirtualChannelOpen */
-       NULL, /* VirtualChannelOpenEx */
-       NULL, /* VirtualChannelClose */
-       NULL, /* VirtualChannelRead */
-       NULL, /* VirtualChannelWrite */
+       FreeRDP_WTSVirtualChannelOpen, /* VirtualChannelOpen */
+       FreeRDP_WTSVirtualChannelOpenEx, /* VirtualChannelOpenEx */
+       FreeRDP_WTSVirtualChannelClose, /* VirtualChannelClose */
+       FreeRDP_WTSVirtualChannelRead, /* VirtualChannelRead */
+       FreeRDP_WTSVirtualChannelWrite, /* VirtualChannelWrite */
        NULL, /* VirtualChannelPurgeInput */
        NULL, /* VirtualChannelPurgeOutput */
-       NULL, /* VirtualChannelQuery */
-       NULL, /* FreeMemory */
+       FreeRDP_WTSVirtualChannelQuery, /* VirtualChannelQuery */
+       FreeRDP_WTSFreeMemory, /* FreeMemory */
        NULL, /* RegisterSessionNotification */
        NULL, /* UnRegisterSessionNotification */
        NULL, /* RegisterSessionNotificationEx */
index 138ce91..3122277 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <winpr/crt.h>
 #include <winpr/stream.h>
+#include <winpr/wtsapi.h>
 
 #include <freerdp/freerdp.h>
 #include <freerdp/error.h>
index 582340f..7940030 100644 (file)
@@ -631,7 +631,7 @@ HANDLE WTSVirtualChannelManagerOpenEx(WTSVirtualChannelManager* vcm, LPSTR pVirt
        return channel;
 }
 
-BOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned)
+BOOL FreeRDP_WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned)
 {
        void* pfd;
        BOOL bval;
@@ -707,12 +707,68 @@ BOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualC
        return status;
 }
 
-VOID WTSFreeMemory(PVOID pMemory)
+VOID FreeRDP_WTSFreeMemory(PVOID pMemory)
 {
        free(pMemory);
 }
 
-BOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
+HANDLE FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
+{
+       return INVALID_HANDLE_VALUE;
+}
+
+HANDLE FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
+{
+       return INVALID_HANDLE_VALUE;
+}
+
+BOOL FreeRDP_WTSVirtualChannelClose(HANDLE hChannelHandle)
+{
+       wStream* s;
+       rdpMcs* mcs;
+       WTSVirtualChannelManager* vcm;
+       rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle;
+
+       if (channel)
+       {
+               vcm = channel->vcm;
+               mcs = vcm->client->context->rdp->mcs;
+
+               if (channel->channelType == RDP_PEER_CHANNEL_TYPE_SVC)
+               {
+                       if (channel->index < mcs->channelCount)
+                               mcs->channels[channel->index].handle = NULL;
+               }
+               else
+               {
+                       ArrayList_Remove(vcm->dynamicVirtualChannels, channel);
+
+                       if (channel->dvc_open_state == DVC_OPEN_STATE_SUCCEEDED)
+                       {
+                               s = Stream_New(NULL, 8);
+                               wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channelId);
+                               WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL);
+                               Stream_Free(s, TRUE);
+                       }
+               }
+
+               if (channel->receiveData)
+                       Stream_Free(channel->receiveData, TRUE);
+
+               if (channel->queue)
+               {
+                       MessageQueue_Free(channel->queue);
+                       channel->queue = NULL;
+               }
+
+               free(channel);
+       }
+
+       return TRUE;
+}
+
+
+BOOL FreeRDP_WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead)
 {
        BYTE* buffer;
        UINT32 length;
@@ -741,7 +797,7 @@ BOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, U
        return TRUE;
 }
 
-BOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
+BOOL FreeRDP_WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten)
 {
        wStream* s;
        int cbLen;
@@ -812,49 +868,3 @@ BOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, P
 
        return TRUE;
 }
-
-BOOL WTSVirtualChannelClose(HANDLE hChannelHandle)
-{
-       wStream* s;
-       rdpMcs* mcs;
-       WTSVirtualChannelManager* vcm;
-       rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle;
-
-       if (channel)
-       {
-               vcm = channel->vcm;
-               mcs = vcm->client->context->rdp->mcs;
-
-               if (channel->channelType == RDP_PEER_CHANNEL_TYPE_SVC)
-               {
-                       if (channel->index < mcs->channelCount)
-                               mcs->channels[channel->index].handle = NULL;
-               }
-               else
-               {
-                       ArrayList_Remove(vcm->dynamicVirtualChannels, channel);
-
-                       if (channel->dvc_open_state == DVC_OPEN_STATE_SUCCEEDED)
-                       {
-                               s = Stream_New(NULL, 8);
-                               wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channelId);
-                               WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), NULL);
-                               Stream_Free(s, TRUE);
-                       }
-               }
-
-               if (channel->receiveData)
-                       Stream_Free(channel->receiveData, TRUE);
-
-               if (channel->queue)
-               {
-                       MessageQueue_Free(channel->queue);
-                       channel->queue = NULL;
-               }
-
-               free(channel);
-       }
-
-       return TRUE;
-}
index 33c7a78..e643d94 100644 (file)
@@ -90,4 +90,14 @@ struct WTSVirtualChannelManager
        wArrayList* dynamicVirtualChannels;
 };
 
+BOOL FreeRDP_WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, DWORD* pBytesReturned);
+VOID FreeRDP_WTSFreeMemory(PVOID pMemory);
+
+HANDLE FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName);
+HANDLE FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags);
+BOOL FreeRDP_WTSVirtualChannelClose(HANDLE hChannelHandle);
+
+BOOL FreeRDP_WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
+BOOL FreeRDP_WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
+
 #endif /* FREERDP_CORE_SERVER_H */
index eb2268c..304b6e9 100644 (file)
@@ -505,6 +505,7 @@ DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAl
                if (!winpr_Handle_GetInfo(lpHandles[index], &Type, &Object))
                {
                        fprintf(stderr, "WaitForMultipleObjects: invalid handle\n");
+
                        return WAIT_FAILED;
                }
 
index f00c621..fa3e422 100644 (file)
@@ -19,9 +19,7 @@ set(MODULE_NAME "winpr-wtsapi")
 set(MODULE_PREFIX "WINPR_WTSAPI")
 
 set(${MODULE_PREFIX}_SRCS
-       wtsapi.c
-       wtsrpc_c.c
-       wtsrpc_c.h)
+       wtsapi.c)
 
 if(MSVC AND (NOT MONOLITHIC_BUILD))
        set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def)
index e6eb9ab..1d4bc65 100644 (file)
  * http://msdn.microsoft.com/en-us/library/windows/desktop/aa383464/
  */
 
-static PWtsApiFunctionTable g_WtsApi;
+static PWtsApiFunctionTable g_WtsApi = NULL;
 
 #ifndef _WIN32
 
-#include "wtsrpc_c.h"
-
 BOOL WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
 {
        if (!g_WtsApi || !g_WtsApi->StartRemoteControlSessionW)
diff --git a/winpr/libwinpr/wtsapi/wtsrpc_c.c b/winpr/libwinpr/wtsapi/wtsrpc_c.c
deleted file mode 100644 (file)
index 18b4a05..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * WinPR: Windows Portable Runtime
- * Windows Terminal Services API
- *
- * Copyright 2013 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <winpr/crt.h>
-
-#include <winpr/wtsapi.h>
-
-#ifndef _WIN32
-
-#include "wtsrpc_c.h"
-
-/**
- * RPC Client Stubs
- */
-
-BOOL RpcStartRemoteControlSession(void* context, LPWSTR pTargetServerName,
-               ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
-{
-       return TRUE;
-}
-
-BOOL RpcStopRemoteControlSession(void* context, ULONG LogonId)
-{
-       return TRUE;
-}
-
-BOOL RpcConnectSession(void* context, ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait)
-{
-       return TRUE;
-}
-
-BOOL RpcEnumerateServers(void* context, LPWSTR pDomainName, DWORD Reserved,
-               DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount)
-{
-       return TRUE;
-}
-
-HANDLE RpcOpenServer(void* context, LPWSTR pServerName)
-{
-       return NULL;
-}
-
-HANDLE RpcOpenServerEx(void* context, LPWSTR pServerName)
-{
-       return NULL;
-}
-
-VOID RpcCloseServer(void* context, HANDLE hServer)
-{
-
-}
-
-BOOL RpcEnumerateSessions(void* context, HANDLE hServer, DWORD Reserved,
-               DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount)
-{
-       return TRUE;
-}
-
-BOOL RpcEnumerateSessionsEx(void* context, HANDLE hServer, DWORD* pLevel,
-               DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount)
-{
-       return TRUE;
-}
-
-BOOL RpcEnumerateProcesses(void* context, HANDLE hServer, DWORD Reserved,
-               DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
-{
-       return TRUE;
-}
-
-BOOL RpcTerminateProcess(void* context, HANDLE hServer, DWORD ProcessId, DWORD ExitCode)
-{
-       return TRUE;
-}
-
-BOOL RpcQuerySessionInformation(void* context, HANDLE hServer, DWORD SessionId,
-               WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned)
-{
-       return TRUE;
-}
-
-BOOL RpcQueryUserConfig(void* context, LPWSTR pServerName, LPWSTR pUserName,
-               WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned)
-{
-       return TRUE;
-}
-
-BOOL RpcSetUserConfig(void* context, LPWSTR pServerName, LPWSTR pUserName,
-               WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength)
-{
-       return TRUE;
-}
-
-BOOL RpcSendMessage(void* context, HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength,
-               LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait)
-{
-       return TRUE;
-}
-
-BOOL RpcDisconnectSession(void* context, HANDLE hServer, DWORD SessionId, BOOL bWait)
-{
-       return TRUE;
-}
-
-BOOL RpcLogoffSession(void* context, HANDLE hServer, DWORD SessionId, BOOL bWait)
-{
-       return TRUE;
-}
-
-BOOL RpcShutdownSystem(void* context, HANDLE hServer, DWORD ShutdownFlag)
-{
-       return TRUE;
-}
-
-BOOL RpcRegisterSessionNotification(void* context, HWND hWnd, DWORD dwFlags)
-{
-       return TRUE;
-}
-
-BOOL RpcUnRegisterSessionNotification(void* context, HWND hWnd)
-{
-       return TRUE;
-}
-
-BOOL RpcRegisterSessionNotificationEx(void* context, HANDLE hServer, HWND hWnd, DWORD dwFlags)
-{
-       return TRUE;
-}
-
-BOOL RpcUnRegisterSessionNotificationEx(void* context, HANDLE hServer, HWND hWnd)
-{
-       return TRUE;
-}
-
-BOOL RpcEnableChildSessions(void* context, BOOL bEnable)
-{
-       return TRUE;
-}
-
-BOOL RpcIsChildSessionsEnabled(void* context, PBOOL pbEnabled)
-{
-       return TRUE;
-}
-
-BOOL RpcGetChildSessionId(void* context, PULONG pSessionId)
-{
-       return TRUE;
-}
-
-#endif
diff --git a/winpr/libwinpr/wtsapi/wtsrpc_c.h b/winpr/libwinpr/wtsapi/wtsrpc_c.h
deleted file mode 100644 (file)
index 8377f78..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * WinPR: Windows Portable Runtime
- * Windows Terminal Services API
- *
- * Copyright 2013 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 WINPR_WTSAPI_RPC_CLIENT_STUBS_H
-#define WINPR_WTSAPI_RPC_CLIENT_STUBS_H
-
-/**
- * RPC Client Stubs
- */
-
-BOOL RpcStartRemoteControlSession(void* context, LPWSTR pTargetServerName,
-               ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers);
-BOOL RpcStopRemoteControlSession(void* context, ULONG LogonId);
-
-BOOL RpcConnectSession(void* context, ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, BOOL bWait);
-
-BOOL RpcEnumerateServers(void* context, LPWSTR pDomainName, DWORD Reserved,
-               DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
-
-HANDLE RpcOpenServer(void* context, LPWSTR pServerName);
-HANDLE RpcOpenServerEx(void* context, LPWSTR pServerName);
-VOID RpcCloseServer(void* context, HANDLE hServer);
-
-BOOL RpcEnumerateSessions(void* context, HANDLE hServer, DWORD Reserved,
-               DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
-BOOL RpcEnumerateSessionsEx(void* context, HANDLE hServer, DWORD* pLevel,
-               DWORD Filter, PWTS_SESSION_INFO_1W* ppSessionInfo, DWORD* pCount);
-
-BOOL RpcEnumerateProcesses(void* context, HANDLE hServer, DWORD Reserved,
-               DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
-BOOL RpcTerminateProcess(void* context, HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
-
-BOOL RpcQuerySessionInformation(void* context, HANDLE hServer, DWORD SessionId,
-               WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
-
-BOOL RpcQueryUserConfig(void* context, LPWSTR pServerName, LPWSTR pUserName,
-               WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
-BOOL RpcSetUserConfig(void* context, LPWSTR pServerName, LPWSTR pUserName,
-               WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
-
-BOOL RpcSendMessage(void* context, HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength,
-               LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait);
-
-BOOL RpcDisconnectSession(void* context, HANDLE hServer, DWORD SessionId, BOOL bWait);
-
-BOOL RpcLogoffSession(void* context, HANDLE hServer, DWORD SessionId, BOOL bWait);
-
-BOOL RpcShutdownSystem(void* context, HANDLE hServer, DWORD ShutdownFlag);
-
-BOOL RpcRegisterSessionNotification(void* context, HWND hWnd, DWORD dwFlags);
-BOOL RpcUnRegisterSessionNotification(void* context, HWND hWnd);
-
-BOOL RpcRegisterSessionNotificationEx(void* context, HANDLE hServer, HWND hWnd, DWORD dwFlags);
-BOOL RpcUnRegisterSessionNotificationEx(void* context, HANDLE hServer, HWND hWnd);
-
-BOOL RpcEnableChildSessions(void* context, BOOL bEnable);
-BOOL RpcIsChildSessionsEnabled(void* context, PBOOL pbEnabled);
-BOOL RpcGetChildSessionId(void* context, PULONG pSessionId);
-
-#endif /* WINPR_WTSAPI_RPC_CLIENT_STUBS_H */