FreeRDP
wtsapi_win32.c File Reference
#include <winpr/crt.h>
#include <winpr/io.h>
#include <winpr/nt.h>
#include <winpr/library.h>
#include <winpr/wtsapi.h>
#include "wtsapi_win32.h"
#include "../log.h"

Macros

#define WTSAPI_CHANNEL_MAGIC   0x44484356
 
#define TAG   WINPR_TAG("wtsapi")
 
#define FILE_DEVICE_TERMSRV   0x00000038
 

Typedefs

typedef HANDLE(WINAPI * fnWinStationVirtualOpen) (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
 
typedef HANDLE(WINAPI * fnWinStationVirtualOpenEx) (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName, DWORD flags)
 

Functions

BOOL WINAPI Win32_WTSVirtualChannelClose (HANDLE hChannel)
 
static void_wts_malloc (size_t size)
 
static void_wts_calloc (size_t nmemb, size_t size)
 
static void _wts_free (void *ptr)
 
BOOL Win32_WTSVirtualChannelReadAsync (WTSAPI_CHANNEL *pChannel)
 
HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName, DWORD flags)
 
HANDLE WINAPI Win32_WTSVirtualChannelOpen (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
 
HANDLE WINAPI Win32_WTSVirtualChannelOpenEx (DWORD SessionId, LPSTR pVirtualName, DWORD flags)
 
BOOL WINAPI Win32_WTSVirtualChannelRead_Static (WTSAPI_CHANNEL *pChannel, DWORD dwMilliseconds, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesTransferred)
 
BOOL WINAPI Win32_WTSVirtualChannelRead_Dynamic (WTSAPI_CHANNEL *pChannel, DWORD dwMilliseconds, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesTransferred)
 
BOOL WINAPI Win32_WTSVirtualChannelRead (HANDLE hChannel, DWORD dwMilliseconds, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesTransferred)
 
BOOL WINAPI Win32_WTSVirtualChannelWrite (HANDLE hChannel, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesTransferred)
 
BOOL Win32_WTSVirtualChannelPurge_Internal (HANDLE hChannelHandle, ULONG IoControlCode)
 
BOOL WINAPI Win32_WTSVirtualChannelPurgeInput (HANDLE hChannelHandle)
 
BOOL WINAPI Win32_WTSVirtualChannelPurgeOutput (HANDLE hChannelHandle)
 
BOOL WINAPI Win32_WTSVirtualChannelQuery (HANDLE hChannelHandle, WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID *ppBuffer, DWORD *pBytesReturned)
 
VOID WINAPI Win32_WTSFreeMemory (PVOID pMemory)
 
BOOL WINAPI Win32_WTSFreeMemoryExW (WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries)
 
BOOL WINAPI Win32_WTSFreeMemoryExA (WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries)
 
BOOL Win32_InitializeWinSta (PWtsApiFunctionTable pWtsApi)
 

Variables

static BOOL g_Initialized = FALSE
 
static HMODULE g_WinStaModule = NULL
 
static fnWinStationVirtualOpen pfnWinStationVirtualOpen = NULL
 
static fnWinStationVirtualOpenEx pfnWinStationVirtualOpenEx = NULL
 

Macro Definition Documentation

#define FILE_DEVICE_TERMSRV   0x00000038
#define TAG   WINPR_TAG("wtsapi")
#define WTSAPI_CHANNEL_MAGIC   0x44484356

WinPR: Windows Portable Runtime Windows Terminal Services API

Copyright 2013-2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.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.

Typedef Documentation

typedef HANDLE(WINAPI * fnWinStationVirtualOpen) (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName)
typedef HANDLE(WINAPI * fnWinStationVirtualOpenEx) (HANDLE hServer, DWORD SessionId, LPSTR pVirtualName, DWORD flags)

Function Documentation

static void* _wts_calloc ( size_t  nmemb,
size_t  size 
)
static

Here is the caller graph for this function:

static void _wts_free ( void ptr)
static

Here is the caller graph for this function:

static void* _wts_malloc ( size_t  size)
static

NOTE !! An application using the WinPR wtsapi frees memory via WTSFreeMemory, which might be mapped to Win32_WTSFreeMemory. Latter does not know if the passed pointer was allocated by a function in wtsapi32.dll or in some internal code below. The WTSFreeMemory implementation in all Windows wtsapi32.dll versions up to Windows 10 uses LocalFree since all its allocating functions use LocalAlloc() internally. For that reason we also have to use LocalAlloc() for any memory returned by our WinPR wtsapi functions.

To be safe we only use the _wts_malloc, _wts_calloc, _wts_free wrappers for memory managment the code below.

Here is the caller graph for this function:

BOOL Win32_InitializeWinSta ( PWtsApiFunctionTable  pWtsApi)

WinPR: Windows Portable Runtime Windows Terminal Services API

Copyright 2013-2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.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.

Here is the call graph for this function:

Here is the caller graph for this function:

VOID WINAPI Win32_WTSFreeMemory ( PVOID  pMemory)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSFreeMemoryExA ( WTS_TYPE_CLASS  WTSTypeClass,
PVOID  pMemory,
ULONG  NumberOfEntries 
)

Here is the call graph for this function:

BOOL WINAPI Win32_WTSFreeMemoryExW ( WTS_TYPE_CLASS  WTSTypeClass,
PVOID  pMemory,
ULONG  NumberOfEntries 
)
BOOL WINAPI Win32_WTSVirtualChannelClose ( HANDLE  hChannel)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE WINAPI Win32_WTSVirtualChannelOpen ( HANDLE  hServer,
DWORD  SessionId,
LPSTR  pVirtualName 
)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal ( HANDLE  hServer,
DWORD  SessionId,
LPSTR  pVirtualName,
DWORD  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE WINAPI Win32_WTSVirtualChannelOpenEx ( DWORD  SessionId,
LPSTR  pVirtualName,
DWORD  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL Win32_WTSVirtualChannelPurge_Internal ( HANDLE  hChannelHandle,
ULONG  IoControlCode 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelPurgeInput ( HANDLE  hChannelHandle)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelPurgeOutput ( HANDLE  hChannelHandle)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelQuery ( HANDLE  hChannelHandle,
WTS_VIRTUAL_CLASS  WtsVirtualClass,
PVOID *  ppBuffer,
DWORD *  pBytesReturned 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelRead ( HANDLE  hChannel,
DWORD  dwMilliseconds,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesTransferred 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelRead_Dynamic ( WTSAPI_CHANNEL *  pChannel,
DWORD  dwMilliseconds,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesTransferred 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelRead_Static ( WTSAPI_CHANNEL *  pChannel,
DWORD  dwMilliseconds,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesTransferred 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL Win32_WTSVirtualChannelReadAsync ( WTSAPI_CHANNEL *  pChannel)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI Win32_WTSVirtualChannelWrite ( HANDLE  hChannel,
LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpNumberOfBytesTransferred 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

BOOL g_Initialized = FALSE
static
HMODULE g_WinStaModule = NULL
static
fnWinStationVirtualOpen pfnWinStationVirtualOpen = NULL
static
fnWinStationVirtualOpenEx pfnWinStationVirtualOpenEx = NULL
static