Conflicts:
	channels/rdpdr/server/rdpdr_main.c
This commit is contained in:
Marc-André Moreau 2015-05-20 11:40:48 -04:00
commit 7e1dbd505b
11 changed files with 1572 additions and 51 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
* FreeRDP: A Remote Desktop Protocol Implementation * FreeRDP: A Remote Desktop Protocol Implementation
* Device Redirection Virtual Channel Extension * Device Redirection Virtual Channel Extension
* *
* Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +21,7 @@
#ifndef FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H #ifndef FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H
#define FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H #define FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H
#include <winpr/collections.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/synch.h> #include <winpr/synch.h>
#include <winpr/thread.h> #include <winpr/thread.h>
@ -39,6 +41,9 @@ struct _rdpdr_server_private
char* ClientComputerName; char* ClientComputerName;
BOOL UserLoggedOnPdu; BOOL UserLoggedOnPdu;
wListDictionary* IrpList;
UINT32 NextCompletionId;
}; };
#define RDPDR_HEADER_LENGTH 4 #define RDPDR_HEADER_LENGTH 4
@ -67,4 +72,16 @@ struct _RDPDR_CAPABILITY_HEADER
}; };
typedef struct _RDPDR_CAPABILITY_HEADER RDPDR_CAPABILITY_HEADER; typedef struct _RDPDR_CAPABILITY_HEADER RDPDR_CAPABILITY_HEADER;
struct _RDPDR_IRP
{
UINT32 CompletionId;
UINT32 DeviceId;
UINT32 FileId;
char PathName[256];
char ExtraBuffer[256];
void *CallbackData;
void (*Callback)(RdpdrServerContext* context, wStream* s, struct _RDPDR_IRP* irp, UINT32 deviceId, UINT32 completionId, UINT32 ioStatus);
};
typedef struct _RDPDR_IRP RDPDR_IRP;
#endif /* FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H */ #endif /* FREERDP_CHANNEL_SERVER_RDPDR_MAIN_H */

View File

@ -2,6 +2,7 @@
* FreeRDP: A Remote Desktop Protocol Implementation * FreeRDP: A Remote Desktop Protocol Implementation
* Device Redirection Virtual Channel Server Interface * Device Redirection Virtual Channel Server Interface
* *
* Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -32,9 +33,55 @@
typedef struct _rdpdr_server_context RdpdrServerContext; typedef struct _rdpdr_server_context RdpdrServerContext;
typedef struct _rdpdr_server_private RdpdrServerPrivate; typedef struct _rdpdr_server_private RdpdrServerPrivate;
struct _FILE_DIRECTORY_INFORMATION
{
UINT32 NextEntryOffset;
UINT32 FileIndex;
UINT64 CreationTime;
UINT64 LastAccessTime;
UINT64 LastWriteTime;
UINT64 ChangeTime;
UINT64 EndOfFile;
UINT64 AllocationSize;
UINT32 FileAttributes;
char FileName[512];
};
typedef struct _FILE_DIRECTORY_INFORMATION FILE_DIRECTORY_INFORMATION;
typedef int (*psRdpdrStart)(RdpdrServerContext* context); typedef int (*psRdpdrStart)(RdpdrServerContext* context);
typedef int (*psRdpdrStop)(RdpdrServerContext* context); typedef int (*psRdpdrStop)(RdpdrServerContext* context);
typedef BOOL (*psRdpdrDriveCreateDirectory)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* path);
typedef BOOL (*psRdpdrDriveDeleteDirectory)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* path);
typedef BOOL (*psRdpdrDriveQueryDirectory)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* path);
typedef BOOL (*psRdpdrDriveOpenFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* path, UINT32 desiredAccess, UINT32 createDisposition);
typedef BOOL (*psRdpdrDriveReadFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, UINT32 fileId, UINT32 length, UINT32 offset);
typedef BOOL (*psRdpdrDriveWriteFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, UINT32 fileId, const char* buffer, UINT32 length, UINT32 offset);
typedef BOOL (*psRdpdrDriveCloseFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, UINT32 fileId);
typedef BOOL (*psRdpdrDriveDeleteFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* path);
typedef BOOL (*psRdpdrDriveRenameFile)(RdpdrServerContext* context, void* callbackData, UINT32 deviceId, const char* oldPath, const char* newPath);
typedef void (*psRdpdrOnDriveCreate)(RdpdrServerContext* context, UINT32 deviceId, const char* name);
typedef void (*psRdpdrOnDriveDelete)(RdpdrServerContext* context, UINT32 deviceId);
typedef void (*psRdpdrOnDriveCreateDirectoryComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus);
typedef void (*psRdpdrOnDriveDeleteDirectoryComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus);
typedef void (*psRdpdrOnDriveQueryDirectoryComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus, FILE_DIRECTORY_INFORMATION* fdi);
typedef void (*psRdpdrOnDriveOpenFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus, UINT32 deviceId, UINT32 fileId);
typedef void (*psRdpdrOnDriveReadFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus, const char* buffer, UINT32 length);
typedef void (*psRdpdrOnDriveWriteFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus, UINT32 bytesWritten);
typedef void (*psRdpdrOnDriveCloseFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus);
typedef void (*psRdpdrOnDriveDeleteFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus);
typedef void (*psRdpdrOnDriveRenameFileComplete)(RdpdrServerContext* context, void* callbackData, UINT32 ioStatus);
typedef void (*psRdpdrOnPortCreate)(RdpdrServerContext* context, UINT32 deviceId, const char* name);
typedef void (*psRdpdrOnPortDelete)(RdpdrServerContext* context, UINT32 deviceId);
typedef void (*psRdpdrOnPrinterCreate)(RdpdrServerContext* context, UINT32 deviceId, const char* name);
typedef void (*psRdpdrOnPrinterDelete)(RdpdrServerContext* context, UINT32 deviceId);
typedef void (*psRdpdrOnSmartcardCreate)(RdpdrServerContext* context, UINT32 deviceId, const char* name);
typedef void (*psRdpdrOnSmartcardDelete)(RdpdrServerContext* context, UINT32 deviceId);
struct _rdpdr_server_context struct _rdpdr_server_context
{ {
HANDLE vcm; HANDLE vcm;
@ -43,6 +90,51 @@ struct _rdpdr_server_context
psRdpdrStop Stop; psRdpdrStop Stop;
RdpdrServerPrivate* priv; RdpdrServerPrivate* priv;
/* Server self-defined pointer. */
void* data;
/* Server supported redirections. Set by server. */
BOOL supportsDrives;
BOOL supportsPorts;
BOOL supportsPrinters;
BOOL supportsSmartcards;
/*** Drive APIs called by the server. ***/
psRdpdrDriveCreateDirectory DriveCreateDirectory;
psRdpdrDriveDeleteDirectory DriveDeleteDirectory;
psRdpdrDriveQueryDirectory DriveQueryDirectory;
psRdpdrDriveOpenFile DriveOpenFile;
psRdpdrDriveReadFile DriveReadFile;
psRdpdrDriveWriteFile DriveWriteFile;
psRdpdrDriveCloseFile DriveCloseFile;
psRdpdrDriveDeleteFile DriveDeleteFile;
psRdpdrDriveRenameFile DriveRenameFile;
/*** Drive callbacks registered by the server. ***/
psRdpdrOnDriveCreate OnDriveCreate;
psRdpdrOnDriveDelete OnDriveDelete;
psRdpdrOnDriveCreateDirectoryComplete OnDriveCreateDirectoryComplete;
psRdpdrOnDriveDeleteDirectoryComplete OnDriveDeleteDirectoryComplete;
psRdpdrOnDriveQueryDirectoryComplete OnDriveQueryDirectoryComplete;
psRdpdrOnDriveOpenFileComplete OnDriveOpenFileComplete;
psRdpdrOnDriveReadFileComplete OnDriveReadFileComplete;
psRdpdrOnDriveWriteFileComplete OnDriveWriteFileComplete;
psRdpdrOnDriveCloseFileComplete OnDriveCloseFileComplete;
psRdpdrOnDriveDeleteFileComplete OnDriveDeleteFileComplete;
psRdpdrOnDriveRenameFileComplete OnDriveRenameFileComplete;
/*** Port callbacks registered by the server. ***/
psRdpdrOnPortCreate OnPortCreate;
psRdpdrOnPortDelete OnPortDelete;
/*** Printer callbacks registered by the server. ***/
psRdpdrOnPrinterCreate OnPrinterCreate;
psRdpdrOnPrinterDelete OnPrinterDelete;
/*** Smartcard callbacks registered by the server. ***/
psRdpdrOnSmartcardCreate OnSmartcardCreate;
psRdpdrOnSmartcardDelete OnSmartcardDelete;
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -2685,10 +2685,21 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting
Stream_Read_UINT8(s, transformBits); /* transformBits (1 byte) */ Stream_Read_UINT8(s, transformBits); /* transformBits (1 byte) */
Stream_Read_UINT8(s, entropyBits); /* entropyBits (1 byte) */ Stream_Read_UINT8(s, entropyBits); /* entropyBits (1 byte) */
if (version != 0x0100) if (version == 0x0009)
return FALSE; {
/* Version 0.9 */
if (tileSize != 0x0040) if (tileSize != 0x0080)
return FALSE;
}
else if (version == 0x0100)
{
/* Version 1.0 */
if (tileSize != 0x0040)
return FALSE;
}
else
return FALSE; return FALSE;
if (colConvBits != 1) if (colConvBits != 1)

View File

@ -62,7 +62,7 @@ static HANDLE freerdp_peer_virtual_channel_open(freerdp_peer* client, const char
if (!mcsChannel->joined) if (!mcsChannel->joined)
continue; continue;
if (strncmp(name, mcsChannel->Name, length) == 0) if (_strnicmp(name, mcsChannel->Name, length) == 0)
{ {
joined = TRUE; joined = TRUE;
break; break;

View File

@ -0,0 +1,52 @@
/**
* WinPR: Windows Portable Runtime
* Shell Functions
*
* Copyright 2015 Dell Software <Mike.McDonald@software.dell.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_SHELL_H
#define WINPR_SHELL_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#ifndef _WIN32
#ifdef __cplusplus
extern "C" {
#endif
WINPR_API BOOL GetUserProfileDirectoryA(HANDLE hToken, LPSTR lpProfileDir, LPDWORD lpcchSize);
WINPR_API BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize);
#ifdef __cplusplus
}
#endif
#ifdef UNICODE
#define GetUserProfileDirectory GetUserProfileDirectoryW
#else
#define GetUserProfileDirectory GetUserProfileDirectoryA
#endif
#endif
#endif /* WINPR_SHELL_H */

View File

@ -75,7 +75,7 @@ endmacro()
# Level "1" API as defined for MinCore.lib # Level "1" API as defined for MinCore.lib
set(WINPR_CORE synch locale library file comm pipe interlocked security set(WINPR_CORE synch locale library file comm pipe interlocked security
environment crypto registry credentials path io memory input environment crypto registry credentials path io memory input shell
heap utils error com timezone sysinfo pool handle thread) heap utils error com timezone sysinfo pool handle thread)
foreach(DIR ${WINPR_CORE}) foreach(DIR ${WINPR_CORE})

View File

@ -0,0 +1,18 @@
# WinPR: Windows Portable Runtime
# libwinpr-shell cmake build script
#
# Copyright 2015 Dell Software <Mike.McDonald@software.dell.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.
winpr_module_add(shell.c)

View File

@ -0,0 +1,9 @@
set(MINWIN_LAYER "0")
set(MINWIN_GROUP "none")
set(MINWIN_MAJOR_VERSION "0")
set(MINWIN_MINOR_VERSION "0")
set(MINWIN_SHORT_NAME "shell")
set(MINWIN_LONG_NAME "Shell Functions")
set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}")

View File

@ -0,0 +1,127 @@
/**
* WinPR: Windows Portable Runtime
* Shell Functions
*
* Copyright 2015 Dell Software <Mike.McDonald@software.dell.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/shell.h>
/**
* shell32.dll:
*
* GetUserProfileDirectoryA
* GetUserProfileDirectoryW
*/
#ifndef _WIN32
#include <winpr/crt.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <pwd.h>
#include <grp.h>
#include "../handle/handle.h"
#include "../security/security.h"
BOOL GetUserProfileDirectoryA(HANDLE hToken, LPSTR lpProfileDir, LPDWORD lpcchSize)
{
DWORD cchDirSize;
struct passwd* pw;
WINPR_ACCESS_TOKEN* token;
token = (WINPR_ACCESS_TOKEN*) hToken;
if ((token == NULL) || (token->Type != HANDLE_TYPE_ACCESS_TOKEN) || (lpcchSize == NULL))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
pw = getpwnam(token->Username);
if (pw == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
cchDirSize = strlen(pw->pw_dir) + 1;
if ((lpProfileDir == NULL) || (*lpcchSize < cchDirSize))
{
*lpcchSize = cchDirSize;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
ZeroMemory(lpProfileDir, *lpcchSize);
strcpy(lpProfileDir, pw->pw_dir);
*lpcchSize = cchDirSize;
return TRUE;
}
BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize)
{
BOOL bStatus;
DWORD cchSizeA;
LPSTR lpProfileDirA;
if (lpcchSize == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
cchSizeA = *lpcchSize;
lpProfileDirA = NULL;
if (lpProfileDir)
{
lpProfileDirA = (LPSTR) malloc(cchSizeA);
if (lpProfileDirA == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
}
bStatus = GetUserProfileDirectoryA(hToken, lpProfileDirA, &cchSizeA);
if (bStatus)
{
MultiByteToWideChar(CP_ACP, 0, lpProfileDirA, cchSizeA, lpProfileDir, *lpcchSize);
}
if (lpProfileDirA)
{
free(lpProfileDirA);
}
*lpcchSize = cchSizeA;
return bStatus;
}
#endif

View File

@ -22,6 +22,7 @@
#endif #endif
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/environment.h>
#include <winpr/file.h> #include <winpr/file.h>
#include <winpr/path.h> #include <winpr/path.h>
#include <winpr/thread.h> #include <winpr/thread.h>
@ -188,6 +189,9 @@ int WLog_FileAppender_WriteImageMessage(wLog* log, wLogFileAppender* appender, w
wLogFileAppender* WLog_FileAppender_New(wLog* log) wLogFileAppender* WLog_FileAppender_New(wLog* log)
{ {
LPSTR env;
LPCSTR name;
DWORD nSize;
wLogFileAppender* FileAppender; wLogFileAppender* FileAppender;
FileAppender = (wLogFileAppender*) malloc(sizeof(wLogFileAppender)); FileAppender = (wLogFileAppender*) malloc(sizeof(wLogFileAppender));
@ -211,7 +215,33 @@ wLogFileAppender* WLog_FileAppender_New(wLog* log)
FileAppender->FileName = NULL; FileAppender->FileName = NULL;
FileAppender->FilePath = NULL; FileAppender->FilePath = NULL;
FileAppender->FullFileName = NULL; FileAppender->FullFileName = NULL;
}
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_PATH";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
{
nSize = GetEnvironmentVariableA(name, env, nSize);
WLog_FileAppender_SetOutputFilePath(log, FileAppender, env);
free(env);
}
}
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_NAME";
nSize = GetEnvironmentVariableA(name, NULL, 0);
if (nSize)
{
env = (LPSTR) malloc(nSize);
if (env)
{
nSize = GetEnvironmentVariableA(name, env, nSize);
WLog_FileAppender_SetOutputFileName(log, FileAppender, env);
free(env);
}
}
}
return FileAppender; return FileAppender;
} }