From d0e989a549f0d05748afda038b0d2c26cab49c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 11 Apr 2013 11:51:10 -0400 Subject: [PATCH 001/144] libfreerdp-core: add support for load balance info --- client/common/cmdline.c | 6 ++++++ client/common/file.c | 6 ++++++ libfreerdp/core/connection.c | 3 +++ libfreerdp/core/nego.c | 8 +++++--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 5150a9a01..dc5e6a681 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -63,6 +63,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "gu", COMMAND_LINE_VALUE_REQUIRED, "[\\] or [@]", NULL, NULL, -1, NULL, "Gateway username" }, { "gp", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Gateway password" }, { "gd", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Gateway domain" }, + { "load-balance-info", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Load balance info" }, { "app", COMMAND_LINE_VALUE_REQUIRED, "|| or ", NULL, NULL, -1, NULL, "Remote application program" }, { "app-name", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Remote application name for user interface" }, { "app-icon", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Remote application icon for user interface" }, @@ -1214,6 +1215,11 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin settings->DisableWallpaper = TRUE; settings->DisableFullWindowDrag = TRUE; } + CommandLineSwitchCase(arg, "load-balance-info") + { + settings->LoadBalanceInfo = (BYTE*) _strdup(arg->Value); + settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo); + } CommandLineSwitchCase(arg, "app-name") { settings->RemoteApplicationName = _strdup(arg->Value); diff --git a/client/common/file.c b/client/common/file.c index 755aa9391..a90a5fe81 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -517,6 +517,12 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* if (~((size_t) file->ShellWorkingDirectory)) settings->ShellWorkingDirectory = file->ShellWorkingDirectory; + if (~((size_t) file->LoadBalanceInfo)) + { + settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo); + settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo); + } + if (~file->ConnectionType) { freerdp_set_connection_type(settings, file->ConnectionType); diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index dabba597f..4b60d868b 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -135,6 +135,9 @@ BOOL rdp_client_connect(rdpRdp* rdp) nego_set_cookie_max_length(rdp->nego, settings->CookieMaxLength); + if (settings->LoadBalanceInfo) + nego_set_routing_token(rdp->nego, settings->LoadBalanceInfo, settings->LoadBalanceInfoLength); + if (!nego_connect(rdp->nego)) { fprintf(stderr, "Error: protocol security negotiation or connection failure\n"); diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 6ee58d9b7..b15730228 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -648,12 +648,14 @@ BOOL nego_send_negotiation_request(rdpNego* nego) stream_get_mark(s, bm); stream_seek(s, length); - if (nego->RoutingToken != NULL) + if (nego->RoutingToken) { stream_write(s, nego->RoutingToken, nego->RoutingTokenLength); - length += nego->RoutingTokenLength; + stream_write_BYTE(s, 0x0D); /* CR */ + stream_write_BYTE(s, 0x0A); /* LF */ + length += nego->RoutingTokenLength + 2; } - else if (nego->cookie != NULL) + else if (nego->cookie) { cookie_length = strlen(nego->cookie); From 0be8a12d78c954f246c273b4374b4d6521f20e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 11 Apr 2013 16:27:12 -0400 Subject: [PATCH 002/144] winpr: fix string.h for C++ --- winpr/include/winpr/string.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winpr/include/winpr/string.h b/winpr/include/winpr/string.h index 6bcae3eee..8cb2466f0 100644 --- a/winpr/include/winpr/string.h +++ b/winpr/include/winpr/string.h @@ -25,6 +25,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 #define CSTR_LESS_THAN 1 @@ -174,4 +178,8 @@ WINPR_API int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteS WINPR_API int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR* lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_CRT_STRING_H */ From a89c75b3c2417010a9ce670e1e0aa51e200f771d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 11 Apr 2013 18:09:28 -0400 Subject: [PATCH 003/144] mfreerdp: cleanup cmake script --- client/Mac/CMakeLists.txt | 41 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 2183eb9d2..80b03ca62 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -6,12 +6,10 @@ set(MODULE_PREFIX "FREERDP_CLIENT_MAC") set(FRAMEWORK_HEADERS_PATH /System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/) include_directories(${FRAMEWORK_HEADERS_PATH} /System/Library/Frameworks) - -# set(CMAKE_OSX_SYSROOT MacOSX10.7.sdk) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4") set(GUI_TYPE MACOSX_BUNDLE) -# Import libraries find_library(FOUNDATION_LIBRARY Foundation) find_library(COCOA_LIBRARY Cocoa) find_library(APPKIT_LIBRARY AppKit) @@ -33,16 +31,32 @@ mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY) set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY}) set(APP_TYPE MACOSX_BUNDLE) -# OS X Interface Builder files -file(GLOB ${MODULE_NAME}_XIBS *.xib) +set(${MODULE_NAME}_XIBS + MainMenu.xib + PasswordDialog.xib) -set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_XIBS} ${MACOSX_BUNDLE_ICON_FILE}) +set(${MODULE_NAME}_RESOURCES + ${${MODULE_NAME}_XIBS} + ${MACOSX_BUNDLE_ICON_FILE}) -# Headers -file(GLOB ${MODULE_NAME}_HEADERS *.h) +set(${MODULE_NAME}_HEADERS + AppDelegate.h + MRDPCursor.h + MRDPRailView.h + MRDPRailWindow.h + MRDPView.h + MRDPWindow.h + PasswordDialog.h) -# Source -file(GLOB ${MODULE_NAME}_SOURCES *.m) +set(${MODULE_NAME}_SOURCES + main.m + AppDelegate.m + MRDPCursor.m + MRDPRailView.m + MRDPRailWindow.m + MRDPView.m + MRDPWindow.m + PasswordDialog.m) add_executable(${MODULE_NAME} ${APP_TYPE} @@ -63,13 +77,6 @@ set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOU # Support for automatic reference counting requires non-fragile abi. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi") -# XCode project architecture to native architecture of build machine -# ----------------------------------------------------------------------------------------------------- -# Issue: Had some issues with FreeRDP project building only 64 bit and -# MacFreeRDP attempting to link to both 32 and 64 for dual target. -# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons: -# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage -# If you know the solutions for 1 and 2, please add below. set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") # Set the info plist to the custom instance From f94f90c08b3110d4d48ee4897bed68ebb571955b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 11 Apr 2013 21:59:02 -0400 Subject: [PATCH 004/144] winpr-utils: initial stream pool implementation --- winpr/include/winpr/collections.h | 1 + winpr/include/winpr/stream.h | 27 +++ winpr/libwinpr/utils/CMakeLists.txt | 1 + winpr/libwinpr/utils/collections/StreamPool.c | 197 ++++++++++++++++++ winpr/libwinpr/utils/test/CMakeLists.txt | 1 + winpr/libwinpr/utils/test/TestStreamPool.c | 70 +++++++ 6 files changed, 297 insertions(+) create mode 100644 winpr/libwinpr/utils/collections/StreamPool.c create mode 100644 winpr/libwinpr/utils/test/TestStreamPool.c diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index 32b412529..521e8578e 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -28,6 +28,7 @@ #include #include +#include typedef void* (*OBJECT_NEW_FN)(void); typedef void (*OBJECT_FREE_FN)(void* obj); diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index 3c0924eb0..d2c151585 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -28,12 +28,17 @@ extern "C" { #endif +typedef struct _wStreamPool wStreamPool; + struct _wStream { BYTE* buffer; BYTE* pointer; size_t length; size_t capacity; + + DWORD count; + wStreamPool* pool; }; typedef struct _wStream wStream; @@ -337,6 +342,28 @@ static INLINE BOOL stream_skip(wStream* s, int sz) { return TRUE; } +/* StreamPool */ + +struct _wStreamPool +{ + int size; + int capacity; + wStream** array; + HANDLE mutex; + BOOL synchronized; +}; + +WINPR_API wStream* StreamPool_Take(wStreamPool* pool, size_t size); +WINPR_API void StreamPool_Return(wStreamPool* pool, wStream* s); + +WINPR_API void Stream_AddRef(wStream* s); +WINPR_API void Stream_Release(wStream* s); + +WINPR_API void StreamPool_Clear(wStreamPool* pool); + +WINPR_API wStreamPool* StreamPool_New(BOOL synchronized); +WINPR_API void StreamPool_Free(wStreamPool* pool); + #ifdef __cplusplus } #endif diff --git a/winpr/libwinpr/utils/CMakeLists.txt b/winpr/libwinpr/utils/CMakeLists.txt index d3f210838..50c6eaad7 100644 --- a/winpr/libwinpr/utils/CMakeLists.txt +++ b/winpr/libwinpr/utils/CMakeLists.txt @@ -29,6 +29,7 @@ set(${MODULE_PREFIX}_COLLECTIONS_SRCS collections/CountdownEvent.c collections/BufferPool.c collections/ObjectPool.c + collections/StreamPool.c collections/MessageQueue.c collections/MessagePipe.c) diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c new file mode 100644 index 000000000..b15eb8a2a --- /dev/null +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -0,0 +1,197 @@ +/** + * WinPR: Windows Portable Runtime + * Object Pool + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 + +#include + +/** + * Methods + */ + +/** + * Gets a stream from the pool. + */ + +wStream* StreamPool_Take(wStreamPool* pool, size_t size) +{ + wStream* s = NULL; + + if (pool->synchronized) + WaitForSingleObject(pool->mutex, INFINITE); + + if (pool->size > 0) + s = pool->array[--(pool->size)]; + + if (!s) + { + s = Stream_New(NULL, size); + s->pool = (void*) pool; + s->count = 1; + } + else + { + Stream_EnsureCapacity(s, size); + Stream_Pointer(s) = Stream_Buffer(s); + s->pool = (void*) pool; + s->count = 1; + } + + if (pool->synchronized) + ReleaseMutex(pool->mutex); + + return s; +} + +/** + * Returns an object to the pool. + */ + +void StreamPool_Return(wStreamPool* pool, wStream* s) +{ + if (pool->synchronized) + WaitForSingleObject(pool->mutex, INFINITE); + + if ((pool->size + 1) >= pool->capacity) + { + pool->capacity *= 2; + pool->array = (wStream**) realloc(pool->array, sizeof(wStream*) * pool->capacity); + } + + pool->array[(pool->size)++] = s; + + if (pool->synchronized) + ReleaseMutex(pool->mutex); +} + +/** + * Lock the stream pool + */ + +void StreamPool_Lock(wStreamPool* pool) +{ + WaitForSingleObject(pool->mutex, INFINITE); +} + +/** + * Unlock the stream pool + */ + +void StreamPool_Unlock(wStreamPool* pool) +{ + ReleaseMutex(pool->mutex); +} + +/** + * Increment stream reference count + */ + +void Stream_AddRef(wStream* s) +{ + if (s->pool) + { + StreamPool_Lock(s->pool); + s->count++; + StreamPool_Unlock(s->pool); + } +} + +/** + * Decrement stream reference count + */ + +void Stream_Release(wStream* s) +{ + DWORD count; + + if (s->pool) + { + StreamPool_Lock(s->pool); + count = --(s->count); + StreamPool_Unlock(s->pool); + + if (count == 0) + StreamPool_Return(s->pool, s); + } +} + +/** + * Releases the streams currently cached in the pool. + */ + +void StreamPool_Clear(wStreamPool* pool) +{ + if (pool->synchronized) + WaitForSingleObject(pool->mutex, INFINITE); + + while (pool->size > 0) + { + (pool->size)--; + Stream_Free(pool->array[pool->size], TRUE); + } + + if (pool->synchronized) + ReleaseMutex(pool->mutex); +} + +/** + * Construction, Destruction + */ + +wStreamPool* StreamPool_New(BOOL synchronized) +{ + wStreamPool* pool = NULL; + + pool = (wStreamPool*) malloc(sizeof(wStreamPool)); + + if (pool) + { + ZeroMemory(pool, sizeof(wStreamPool)); + + pool->synchronized = synchronized; + + if (pool->synchronized) + pool->mutex = CreateMutex(NULL, FALSE, NULL); + + pool->size = 0; + pool->capacity = 32; + pool->array = (wStream**) malloc(sizeof(wStream*) * pool->capacity); + } + + return pool; +} + +void StreamPool_Free(wStreamPool* pool) +{ + if (pool) + { + StreamPool_Clear(pool); + + if (pool->synchronized) + CloseHandle(pool->mutex); + + free(pool->array); + + free(pool); + } +} diff --git a/winpr/libwinpr/utils/test/CMakeLists.txt b/winpr/libwinpr/utils/test/CMakeLists.txt index cf967be4b..307aae204 100644 --- a/winpr/libwinpr/utils/test/CMakeLists.txt +++ b/winpr/libwinpr/utils/test/CMakeLists.txt @@ -9,6 +9,7 @@ set(${MODULE_PREFIX}_TESTS TestPrint.c TestArrayList.c TestCmdLine.c + TestStreamPool.c TestMessageQueue.c TestMessagePipe.c) diff --git a/winpr/libwinpr/utils/test/TestStreamPool.c b/winpr/libwinpr/utils/test/TestStreamPool.c new file mode 100644 index 000000000..29adf2eab --- /dev/null +++ b/winpr/libwinpr/utils/test/TestStreamPool.c @@ -0,0 +1,70 @@ + +#include +#include +#include + +#define BUFFER_SIZE 16384 + +int TestStreamPool(int argc, char* argv[]) +{ + wStream* s[5]; + wStreamPool* pool; + + pool = StreamPool_New(TRUE); + + s[0] = StreamPool_Take(pool, BUFFER_SIZE); + s[1] = StreamPool_Take(pool, BUFFER_SIZE); + s[2] = StreamPool_Take(pool, BUFFER_SIZE); + + printf("StreamPool: size: %d\n", pool->size); + + Stream_Release(s[0]); + Stream_Release(s[1]); + Stream_Release(s[2]); + + printf("StreamPool: size: %d\n", pool->size); + + s[3] = StreamPool_Take(pool, BUFFER_SIZE); + s[4] = StreamPool_Take(pool, BUFFER_SIZE); + + printf("StreamPool: size: %d\n", pool->size); + + Stream_Release(s[3]); + Stream_Release(s[4]); + + printf("StreamPool: size: %d\n", pool->size); + + s[2] = StreamPool_Take(pool, BUFFER_SIZE); + s[3] = StreamPool_Take(pool, BUFFER_SIZE); + s[4] = StreamPool_Take(pool, BUFFER_SIZE); + + printf("StreamPool: size: %d\n", pool->size); + + Stream_AddRef(s[2]); + + Stream_AddRef(s[3]); + Stream_AddRef(s[3]); + + Stream_AddRef(s[4]); + Stream_AddRef(s[4]); + Stream_AddRef(s[4]); + + Stream_Release(s[2]); + Stream_Release(s[2]); + + Stream_Release(s[3]); + Stream_Release(s[3]); + Stream_Release(s[3]); + + Stream_Release(s[4]); + Stream_Release(s[4]); + Stream_Release(s[4]); + Stream_Release(s[4]); + + printf("StreamPool: size: %d\n", pool->size); + + StreamPool_Free(pool); + + return 0; +} + From edaf5073e316924096ecba33b7ac89f6f84afce3 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Thu, 11 Apr 2013 20:52:54 -0700 Subject: [PATCH 005/144] winpr: do not redefine UNICODE_STRING on Windows. --- winpr/include/winpr/security.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/winpr/include/winpr/security.h b/winpr/include/winpr/security.h index ab342cf3d..59f02d953 100644 --- a/winpr/include/winpr/security.h +++ b/winpr/include/winpr/security.h @@ -23,13 +23,6 @@ #include #include -typedef struct _LSA_UNICODE_STRING -{ - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING; - /** * Windows Integrity Mechanism Design: * http://msdn.microsoft.com/en-us/library/bb625963.aspx @@ -37,6 +30,13 @@ typedef struct _LSA_UNICODE_STRING #ifndef _WIN32 +typedef struct _LSA_UNICODE_STRING +{ + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING; + #define SECURITY_MANDATORY_UNTRUSTED_RID 0x0000 #define SECURITY_MANDATORY_LOW_RID 0x1000 #define SECURITY_MANDATORY_MEDIUM_RID 0x2000 From 0fded8c2d0188c8bdbb9a8477ec1f6f1427566bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 12 Apr 2013 12:20:20 -0400 Subject: [PATCH 006/144] winpr-utils: fix StreamPool --- winpr/include/winpr/stream.h | 18 +- winpr/libwinpr/utils/collections/StreamPool.c | 162 ++++++++++++++++-- winpr/libwinpr/utils/test/TestStreamPool.c | 61 +++++-- 3 files changed, 204 insertions(+), 37 deletions(-) diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index d2c151585..6910734a0 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -346,11 +346,17 @@ static INLINE BOOL stream_skip(wStream* s, int sz) { struct _wStreamPool { - int size; - int capacity; - wStream** array; + int aSize; + int aCapacity; + wStream** aArray; + + int uSize; + int uCapacity; + wStream** uArray; + HANDLE mutex; BOOL synchronized; + size_t defaultSize; }; WINPR_API wStream* StreamPool_Take(wStreamPool* pool, size_t size); @@ -359,9 +365,13 @@ WINPR_API void StreamPool_Return(wStreamPool* pool, wStream* s); WINPR_API void Stream_AddRef(wStream* s); WINPR_API void Stream_Release(wStream* s); +WINPR_API wStream* StreamPool_Find(wStreamPool* pool, BYTE* ptr); +WINPR_API void StreamPool_AddRef(wStreamPool* pool, BYTE* ptr); +WINPR_API void StreamPool_Release(wStreamPool* pool, BYTE* ptr); + WINPR_API void StreamPool_Clear(wStreamPool* pool); -WINPR_API wStreamPool* StreamPool_New(BOOL synchronized); +WINPR_API wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize); WINPR_API void StreamPool_Free(wStreamPool* pool); #ifdef __cplusplus diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index b15eb8a2a..978b09799 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -29,6 +29,65 @@ * Methods */ +void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count) +{ + if (count > 0) + { + if (pool->uSize + count > pool->uCapacity) + { + pool->uCapacity *= 2; + pool->uArray = (wStream**) realloc(pool->uArray, sizeof(wStream*) * pool->uCapacity); + } + + MoveMemory(&pool->uArray[index + count], &pool->uArray[index], (pool->uSize - index) * sizeof(wStream*)); + pool->uSize += count; + } + else if (count < 0) + { + MoveMemory(&pool->uArray[index], &pool->uArray[index - count], (pool->uSize + count) * sizeof(wStream*)); + pool->uSize += count; + } +} + +/** + * Adds a used stream to the pool. + */ + +void StreamPool_AddUsed(wStreamPool* pool, wStream* s) +{ + int index; + + if ((pool->uSize + 1) >= pool->uCapacity) + { + pool->uCapacity *= 2; + pool->uArray = (wStream**) realloc(pool->uArray, sizeof(wStream*) * pool->uCapacity); + } + + pool->uArray[(pool->uSize)++] = s; +} + +/** + * Removes a used stream from the pool. + */ + +void StreamPool_RemoveUsed(wStreamPool* pool, wStream* s) +{ + int index; + BOOL found = FALSE; + + for (index = 0; index < pool->uSize; index++) + { + if (pool->uArray[index] == s) + { + found = TRUE; + break; + } + } + + if (found) + StreamPool_ShiftUsed(pool, index, -1); +} + /** * Gets a stream from the pool. */ @@ -40,23 +99,27 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) if (pool->synchronized) WaitForSingleObject(pool->mutex, INFINITE); - if (pool->size > 0) - s = pool->array[--(pool->size)]; + if (pool->aSize > 0) + s = pool->aArray[--(pool->aSize)]; + + if (size < 0) + size = pool->defaultSize; if (!s) { s = Stream_New(NULL, size); - s->pool = (void*) pool; - s->count = 1; } else { Stream_EnsureCapacity(s, size); Stream_Pointer(s) = Stream_Buffer(s); - s->pool = (void*) pool; - s->count = 1; } + s->pool = pool; + s->count = 1; + + StreamPool_AddUsed(pool, s); + if (pool->synchronized) ReleaseMutex(pool->mutex); @@ -72,13 +135,14 @@ void StreamPool_Return(wStreamPool* pool, wStream* s) if (pool->synchronized) WaitForSingleObject(pool->mutex, INFINITE); - if ((pool->size + 1) >= pool->capacity) + if ((pool->aSize + 1) >= pool->aCapacity) { - pool->capacity *= 2; - pool->array = (wStream**) realloc(pool->array, sizeof(wStream*) * pool->capacity); + pool->aCapacity *= 2; + pool->aArray = (wStream**) realloc(pool->aArray, sizeof(wStream*) * pool->aCapacity); } - pool->array[(pool->size)++] = s; + pool->aArray[(pool->aSize)++] = s; + StreamPool_RemoveUsed(pool, s); if (pool->synchronized) ReleaseMutex(pool->mutex); @@ -135,6 +199,62 @@ void Stream_Release(wStream* s) } } +/** + * Find stream in pool using pointer inside buffer + */ + +wStream* StreamPool_Find(wStreamPool* pool, BYTE* ptr) +{ + int index; + wStream* s = NULL; + BOOL found = FALSE; + + WaitForSingleObject(pool->mutex, INFINITE); + + for (index = 0; index < pool->uSize; index++) + { + s = pool->uArray[index]; + + if ((ptr >= s->buffer) && (ptr < (s->buffer + s->capacity))) + { + found = TRUE; + break; + } + } + + ReleaseMutex(pool->mutex); + + return (found) ? s : NULL; +} + +/** + * Find stream in pool and increment reference count + */ + +void StreamPool_AddRef(wStreamPool* pool, BYTE* ptr) +{ + wStream* s; + + s = StreamPool_Find(pool, ptr); + + if (s) + Stream_AddRef(s); +} + +/** + * Find stream in pool and decrement reference count + */ + +void StreamPool_Release(wStreamPool* pool, BYTE* ptr) +{ + wStream* s; + + s = StreamPool_Find(pool, ptr); + + if (s) + Stream_Release(s); +} + /** * Releases the streams currently cached in the pool. */ @@ -144,10 +264,10 @@ void StreamPool_Clear(wStreamPool* pool) if (pool->synchronized) WaitForSingleObject(pool->mutex, INFINITE); - while (pool->size > 0) + while (pool->aSize > 0) { - (pool->size)--; - Stream_Free(pool->array[pool->size], TRUE); + (pool->aSize)--; + Stream_Free(pool->aArray[pool->aSize], TRUE); } if (pool->synchronized) @@ -158,7 +278,7 @@ void StreamPool_Clear(wStreamPool* pool) * Construction, Destruction */ -wStreamPool* StreamPool_New(BOOL synchronized) +wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize) { wStreamPool* pool = NULL; @@ -169,13 +289,18 @@ wStreamPool* StreamPool_New(BOOL synchronized) ZeroMemory(pool, sizeof(wStreamPool)); pool->synchronized = synchronized; + pool->defaultSize = defaultSize; if (pool->synchronized) pool->mutex = CreateMutex(NULL, FALSE, NULL); - pool->size = 0; - pool->capacity = 32; - pool->array = (wStream**) malloc(sizeof(wStream*) * pool->capacity); + pool->aSize = 0; + pool->aCapacity = 32; + pool->aArray = (wStream**) malloc(sizeof(wStream*) * pool->aCapacity); + + pool->uSize = 0; + pool->uCapacity = 32; + pool->uArray = (wStream**) malloc(sizeof(wStream*) * pool->uCapacity); } return pool; @@ -190,7 +315,8 @@ void StreamPool_Free(wStreamPool* pool) if (pool->synchronized) CloseHandle(pool->mutex); - free(pool->array); + free(pool->aArray); + free(pool->uArray); free(pool); } diff --git a/winpr/libwinpr/utils/test/TestStreamPool.c b/winpr/libwinpr/utils/test/TestStreamPool.c index 29adf2eab..d768e8c14 100644 --- a/winpr/libwinpr/utils/test/TestStreamPool.c +++ b/winpr/libwinpr/utils/test/TestStreamPool.c @@ -10,35 +10,35 @@ int TestStreamPool(int argc, char* argv[]) wStream* s[5]; wStreamPool* pool; - pool = StreamPool_New(TRUE); + pool = StreamPool_New(TRUE, BUFFER_SIZE); - s[0] = StreamPool_Take(pool, BUFFER_SIZE); - s[1] = StreamPool_Take(pool, BUFFER_SIZE); - s[2] = StreamPool_Take(pool, BUFFER_SIZE); + s[0] = StreamPool_Take(pool, -1); + s[1] = StreamPool_Take(pool, -1); + s[2] = StreamPool_Take(pool, -1); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); Stream_Release(s[0]); Stream_Release(s[1]); Stream_Release(s[2]); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); - s[3] = StreamPool_Take(pool, BUFFER_SIZE); - s[4] = StreamPool_Take(pool, BUFFER_SIZE); + s[3] = StreamPool_Take(pool, -1); + s[4] = StreamPool_Take(pool, -1); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); Stream_Release(s[3]); Stream_Release(s[4]); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); - s[2] = StreamPool_Take(pool, BUFFER_SIZE); - s[3] = StreamPool_Take(pool, BUFFER_SIZE); - s[4] = StreamPool_Take(pool, BUFFER_SIZE); + s[2] = StreamPool_Take(pool, -1); + s[3] = StreamPool_Take(pool, -1); + s[4] = StreamPool_Take(pool, -1); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); Stream_AddRef(s[2]); @@ -61,7 +61,38 @@ int TestStreamPool(int argc, char* argv[]) Stream_Release(s[4]); Stream_Release(s[4]); - printf("StreamPool: size: %d\n", pool->size); + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); + + s[2] = StreamPool_Take(pool, -1); + s[3] = StreamPool_Take(pool, -1); + s[4] = StreamPool_Take(pool, -1); + + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); + + StreamPool_AddRef(pool, s[2]->buffer + 1024); + + StreamPool_AddRef(pool, s[3]->buffer + 1024); + StreamPool_AddRef(pool, s[3]->buffer + 1024 * 2); + + StreamPool_AddRef(pool, s[4]->buffer + 1024); + StreamPool_AddRef(pool, s[4]->buffer + 1024 * 2); + StreamPool_AddRef(pool, s[4]->buffer + 1024 * 3); + + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); + + StreamPool_Release(pool, s[2]->buffer + 2048); + StreamPool_Release(pool, s[2]->buffer + 2048 * 2); + + StreamPool_Release(pool, s[3]->buffer + 2048); + StreamPool_Release(pool, s[3]->buffer + 2048 * 2); + StreamPool_Release(pool, s[3]->buffer + 2048 * 3); + + StreamPool_Release(pool, s[4]->buffer + 2048); + StreamPool_Release(pool, s[4]->buffer + 2048 * 2); + StreamPool_Release(pool, s[4]->buffer + 2048 * 3); + StreamPool_Release(pool, s[4]->buffer + 2048 * 4); + + printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); StreamPool_Free(pool); From d04b76d005034a76eb6532ff537b4fdf433eca38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 12 Apr 2013 13:44:23 -0400 Subject: [PATCH 007/144] libfreerdp-core: use stream pool --- client/X11/cli/xfreerdp.c | 3 +-- client/X11/xf_interface.c | 18 ++++++++++---- libfreerdp/core/freerdp.c | 4 +++- libfreerdp/core/transport.c | 24 +++++-------------- libfreerdp/core/transport.h | 2 +- winpr/libwinpr/utils/collections/StreamPool.c | 2 +- winpr/libwinpr/utils/test/TestStreamPool.c | 22 ++++++++--------- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index b242c11ee..a2911207e 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -49,8 +49,7 @@ int main(int argc, char* argv[]) GetExitCodeThread(xfi->thread, &dwExitCode); - freerdp_context_free(instance); - freerdp_free(instance); + freerdp_client_free(xfi); freerdp_client_global_uninit(); diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index c2d6d0a60..3d27a5b49 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1382,9 +1382,6 @@ void* xf_thread(void* param) freerdp_channels_free(channels); freerdp_disconnect(instance); gdi_free(instance); - freerdp_client_free(xfi); - - exit_code = 123; ExitThread(exit_code); } @@ -1475,8 +1472,6 @@ xfInfo* freerdp_client_new(int argc, char** argv) freerdp_context_new(instance); instance->context->argc = argc; - instance->context->argv = argv; - instance->context->argv = (char**) malloc(sizeof(char*) * argc); for (index = 0; index < argc; index++) @@ -1544,12 +1539,25 @@ void freerdp_client_free(xfInfo* xfi) { if (xfi) { + int index; + rdpContext* context; + xf_window_free(xfi); free(xfi->bmp_codec_none); XCloseDisplay(xfi->display); + context = (rdpContext*) xfi->context; + + for (index = 0; index < context->argc; index++) + free(context->argv[index]); + + free(context->argv); + + freerdp_context_free(xfi->instance); + freerdp_free(xfi->instance); + free(xfi); } } diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index b1d05fb82..6770a1ab3 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -340,7 +340,7 @@ void freerdp_context_new(freerdp* instance) */ void freerdp_context_free(freerdp* instance) { - if (instance->context == NULL) + if (!instance->context) return; IFCALL(instance->ContextFree, instance, instance->context); @@ -348,6 +348,8 @@ void freerdp_context_free(freerdp* instance) rdp_free(instance->context->rdp); graphics_free(instance->context->graphics); + free(instance->context->client); + free(instance->context); instance->context = NULL; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 29f8e6297..458fca7fc 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -703,7 +703,7 @@ int transport_check_fds(rdpTransport** ptransport) } received = transport->ReceiveBuffer; - transport->ReceiveBuffer = ObjectPool_Take(transport->ReceivePool); + transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0); transport->ReceiveBuffer->pointer = transport->ReceiveBuffer->buffer; stream_set_pos(received, length); @@ -720,7 +720,7 @@ int transport_check_fds(rdpTransport** ptransport) recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra); - ObjectPool_Return(transport->ReceivePool, received); + StreamPool_Return(transport->ReceivePool, received); if (recv_status < 0) status = -1; @@ -799,16 +799,6 @@ static void* transport_client_thread(void* arg) return NULL; } -wStream* transport_receive_buffer_pool_new() -{ - wStream* pdu = NULL; - - pdu = stream_new(BUFFER_SIZE); - pdu->pointer = pdu->buffer; - - return pdu; -} - rdpTransport* transport_new(rdpSettings* settings) { rdpTransport* transport; @@ -826,12 +816,10 @@ rdpTransport* transport_new(rdpSettings* settings) /* a small 0.1ms delay when transport is blocking. */ transport->SleepInterval = 100; - transport->ReceivePool = ObjectPool_New(TRUE); - ObjectPool_Object(transport->ReceivePool)->fnObjectFree = (OBJECT_FREE_FN) stream_free; - ObjectPool_Object(transport->ReceivePool)->fnObjectNew = (OBJECT_NEW_FN) transport_receive_buffer_pool_new; + transport->ReceivePool = StreamPool_New(TRUE, BUFFER_SIZE); /* receive buffer for non-blocking read. */ - transport->ReceiveBuffer = ObjectPool_Take(transport->ReceivePool); + transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0); transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL); /* buffers for blocking read/write */ @@ -851,9 +839,9 @@ void transport_free(rdpTransport* transport) if (transport != NULL) { if (transport->ReceiveBuffer) - ObjectPool_Return(transport->ReceivePool, transport->ReceiveBuffer); + StreamPool_Return(transport->ReceivePool, transport->ReceiveBuffer); - ObjectPool_Free(transport->ReceivePool); + StreamPool_Free(transport->ReceivePool); stream_free(transport->ReceiveStream); stream_free(transport->SendStream); diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 0dc04122a..67a2e2783 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -69,7 +69,7 @@ struct rdp_transport HANDLE GatewayEvent; BOOL blocking; BOOL SplitInputOutput; - wObjectPool* ReceivePool; + wStreamPool* ReceivePool; HANDLE stopEvent; HANDLE thread; BOOL async; diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index 978b09799..96a491acf 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -102,7 +102,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) if (pool->aSize > 0) s = pool->aArray[--(pool->aSize)]; - if (size < 0) + if (size == 0) size = pool->defaultSize; if (!s) diff --git a/winpr/libwinpr/utils/test/TestStreamPool.c b/winpr/libwinpr/utils/test/TestStreamPool.c index d768e8c14..ab8a371e4 100644 --- a/winpr/libwinpr/utils/test/TestStreamPool.c +++ b/winpr/libwinpr/utils/test/TestStreamPool.c @@ -12,9 +12,9 @@ int TestStreamPool(int argc, char* argv[]) pool = StreamPool_New(TRUE, BUFFER_SIZE); - s[0] = StreamPool_Take(pool, -1); - s[1] = StreamPool_Take(pool, -1); - s[2] = StreamPool_Take(pool, -1); + s[0] = StreamPool_Take(pool, 0); + s[1] = StreamPool_Take(pool, 0); + s[2] = StreamPool_Take(pool, 0); printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); @@ -24,8 +24,8 @@ int TestStreamPool(int argc, char* argv[]) printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); - s[3] = StreamPool_Take(pool, -1); - s[4] = StreamPool_Take(pool, -1); + s[3] = StreamPool_Take(pool, 0); + s[4] = StreamPool_Take(pool, 0); printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); @@ -34,9 +34,9 @@ int TestStreamPool(int argc, char* argv[]) printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); - s[2] = StreamPool_Take(pool, -1); - s[3] = StreamPool_Take(pool, -1); - s[4] = StreamPool_Take(pool, -1); + s[2] = StreamPool_Take(pool, 0); + s[3] = StreamPool_Take(pool, 0); + s[4] = StreamPool_Take(pool, 0); printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); @@ -63,9 +63,9 @@ int TestStreamPool(int argc, char* argv[]) printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); - s[2] = StreamPool_Take(pool, -1); - s[3] = StreamPool_Take(pool, -1); - s[4] = StreamPool_Take(pool, -1); + s[2] = StreamPool_Take(pool, 0); + s[3] = StreamPool_Take(pool, 0); + s[4] = StreamPool_Take(pool, 0); printf("StreamPool: aSize: %d uSize: %d\n", pool->aSize, pool->uSize); From d776a2d4ea30f7cfa8a619866148509b5ab3341e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 12 Apr 2013 17:05:42 -0400 Subject: [PATCH 008/144] libfreerdp-core: start using stream pool --- libfreerdp/codec/rfx_decode.c | 4 +++- libfreerdp/core/fastpath.c | 9 ++++++--- libfreerdp/core/message.c | 30 ++++++++++++++++++++++++++++-- libfreerdp/core/surface.c | 6 +++--- libfreerdp/core/transport.c | 11 ++++++----- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/libfreerdp/codec/rfx_decode.c b/libfreerdp/codec/rfx_decode.c index 15aa4cf00..1acffda27 100644 --- a/libfreerdp/codec/rfx_decode.c +++ b/libfreerdp/codec/rfx_decode.c @@ -202,11 +202,12 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in, else #endif { - if (stream_get_left(data_in) < y_size+cb_size+cr_size) + if (stream_get_left(data_in) < y_size + cb_size + cr_size) { DEBUG_WARN("rfx_decode_rgb: packet too small for y_size+cb_size+cr_size"); return FALSE; } + rfx_decode_component(context, y_quants, stream_get_tail(data_in), y_size, pSrcDst[0]); /* YData */ stream_seek(data_in, y_size); @@ -230,5 +231,6 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in, BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[0] - 16); BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[1] - 16); BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[2] - 16); + return TRUE; } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 56d06a983..8a680d7e7 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -169,20 +169,21 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s) rdpUpdate* update = fastpath->rdp->update; rdpContext* context = update->context; - if(stream_get_left(s) < 2) + if (stream_get_left(s) < 2) return FALSE; + stream_read_UINT16(s, updateType); /* updateType (2 bytes) */ switch (updateType) { case UPDATE_TYPE_BITMAP: - if(!update_read_bitmap(update, s, &update->bitmap_update)) + if (!update_read_bitmap(update, s, &update->bitmap_update)) return FALSE; IFCALL(update->BitmapUpdate, context, &update->bitmap_update); break; case UPDATE_TYPE_PALETTE: - if(!update_read_palette(update, s, &update->palette_update)) + if (!update_read_palette(update, s, &update->palette_update)) return FALSE; IFCALL(update->Palette, context, &update->palette_update); break; @@ -328,6 +329,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) } update_stream = NULL; + if (fragmentation == FASTPATH_FRAGMENT_SINGLE) { totalSize = size; @@ -340,6 +342,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) stream_check_size(fastpath->updateData, size); stream_copy(fastpath->updateData, comp_stream, size); + if (stream_get_length(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize) { fprintf(stderr, "fastpath PDU is bigger than MultifragMaxRequestSize\n"); diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 3e2900b03..3ccea28d3 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -21,11 +21,18 @@ #include "config.h" #endif +#include "rdp.h" #include "message.h" +#include "transport.h" + +#include #include +#include #include +//#define WITH_STREAM_POOL 1 + /* Update */ static void update_message_BeginPaint(rdpContext* context) @@ -79,13 +86,15 @@ static void update_message_BitmapUpdate(rdpContext* context, BITMAP_UPDATE* bitm wParam->rectangles = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * wParam->number); CopyMemory(wParam->rectangles, bitmap->rectangles, sizeof(BITMAP_DATA) * wParam->number); - /* TODO: increment reference count to original stream instead of copying */ - for (index = 0; index < wParam->number; index++) { +#ifdef WITH_STREAM_POOL + StreamPool_AddRef(context->rdp->transport->ReceivePool, bitmap->rectangles[index].bitmapDataStream); +#else wParam->rectangles[index].bitmapDataStream = (BYTE*) malloc(wParam->rectangles[index].bitmapLength); CopyMemory(wParam->rectangles[index].bitmapDataStream, bitmap->rectangles[index].bitmapDataStream, wParam->rectangles[index].bitmapLength); +#endif } MessageQueue_Post(context->update->queue, (void*) context, @@ -160,8 +169,12 @@ static void update_message_SurfaceBits(rdpContext* context, SURFACE_BITS_COMMAND wParam = (SURFACE_BITS_COMMAND*) malloc(sizeof(SURFACE_BITS_COMMAND)); CopyMemory(wParam, surfaceBitsCommand, sizeof(SURFACE_BITS_COMMAND)); +#ifdef WITH_STREAM_POOL + StreamPool_AddRef(context->rdp->transport->ReceivePool, surfaceBitsCommand->bitmapData); +#else wParam->bitmapData = (BYTE*) malloc(wParam->bitmapDataLength); CopyMemory(wParam->bitmapData, surfaceBitsCommand->bitmapData, wParam->bitmapDataLength); +#endif MessageQueue_Post(context->update->queue, (void*) context, MakeMessageId(Update, SurfaceBits), (void*) wParam, NULL); @@ -952,7 +965,14 @@ int update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg, in BITMAP_UPDATE* wParam = (BITMAP_UPDATE*) msg->wParam; for (index = 0; index < wParam->number; index++) + { +#ifdef WITH_STREAM_POOL + rdpContext* context = (rdpContext*) msg->context; + StreamPool_Release(context->rdp->transport->ReceivePool, wParam->rectangles[index].bitmapDataStream); +#else free(wParam->rectangles[index].bitmapDataStream); +#endif + } free(wParam); } @@ -993,9 +1013,15 @@ int update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg, in case Update_SurfaceBits: IFCALL(proxy->SurfaceBits, msg->context, (SURFACE_BITS_COMMAND*) msg->wParam); { +#ifdef WITH_STREAM_POOL + rdpContext* context = (rdpContext*) msg->context; + SURFACE_BITS_COMMAND* wParam = (SURFACE_BITS_COMMAND*) msg->wParam; + StreamPool_Release(context->rdp->transport->ReceivePool, wParam->bitmapData); +#else SURFACE_BITS_COMMAND* wParam = (SURFACE_BITS_COMMAND*) msg->wParam; free(wParam->bitmapData); free(wParam); +#endif } break; diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 1c961f5d9..42d39f1ab 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -25,7 +25,7 @@ #include "surface.h" -static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32 *length) +static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length) { int pos; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; @@ -50,11 +50,11 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 pos = stream_get_pos(s) + cmd->bitmapDataLength; cmd->bitmapData = stream_get_tail(s); - IFCALL(update->SurfaceBits, update->context, cmd); - stream_set_pos(s, pos); *length = 20 + cmd->bitmapDataLength; + IFCALL(update->SurfaceBits, update->context, cmd); + return 0; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 458fca7fc..c1033e225 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -704,7 +704,6 @@ int transport_check_fds(rdpTransport** ptransport) received = transport->ReceiveBuffer; transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0); - transport->ReceiveBuffer->pointer = transport->ReceiveBuffer->buffer; stream_set_pos(received, length); stream_seal(received); @@ -720,7 +719,7 @@ int transport_check_fds(rdpTransport** ptransport) recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra); - StreamPool_Return(transport->ReceivePool, received); + Stream_Release(received); if (recv_status < 0) status = -1; @@ -823,7 +822,7 @@ rdpTransport* transport_new(rdpSettings* settings) transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL); /* buffers for blocking read/write */ - transport->ReceiveStream = stream_new(BUFFER_SIZE); + transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0); transport->SendStream = stream_new(BUFFER_SIZE); transport->blocking = TRUE; @@ -839,11 +838,13 @@ void transport_free(rdpTransport* transport) if (transport != NULL) { if (transport->ReceiveBuffer) - StreamPool_Return(transport->ReceivePool, transport->ReceiveBuffer); + Stream_Release(transport->ReceiveBuffer); + + if (transport->ReceiveStream) + Stream_Release(transport->ReceiveStream); StreamPool_Free(transport->ReceivePool); - stream_free(transport->ReceiveStream); stream_free(transport->SendStream); CloseHandle(transport->ReceiveEvent); From 073c6fb98374d805bea5f388506be8c3cc039e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 12 Apr 2013 18:03:56 -0400 Subject: [PATCH 009/144] libfreerdp-core: fix handling of SSL_CERT_NOT_ON_SERVER --- client/common/file.c | 28 +++++++++++++++------------- libfreerdp/core/nego.c | 13 ++++++++++--- libfreerdp/core/nego.h | 1 + libfreerdp/core/settings.c | 1 + 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/client/common/file.c b/client/common/file.c index a90a5fe81..a13ca239b 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -308,7 +308,7 @@ BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, BYTE* buffer, siz line = strtok_s((char*) buffer, "\r\n", &context); - while (line != NULL) + while (line) { length = strlen(line); @@ -458,8 +458,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name) if (file_size < 1) return FALSE; - buffer = (BYTE*) malloc(file_size); - + buffer = (BYTE*) malloc(file_size + 2); read_size = fread(buffer, file_size, 1, fp); if (!read_size) @@ -475,6 +474,9 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name) return FALSE; } + buffer[file_size] = '\0'; + buffer[file_size + 1] = '\0'; + return freerdp_client_parse_rdp_file_buffer(file, buffer, file_size); } @@ -497,7 +499,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* if (~file->ServerPort) settings->ServerPort = file->ServerPort; if (~((size_t) file->FullAddress)) - settings->ServerHostname = file->FullAddress; + settings->ServerHostname = _strdup(file->FullAddress); if (~file->DesktopWidth) settings->DesktopWidth = file->DesktopWidth; if (~file->DesktopHeight) @@ -513,9 +515,9 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* if (~file->EnableCredSSPSupport) settings->NlaSecurity = file->EnableCredSSPSupport; if (~((size_t) file->AlternateShell)) - settings->AlternateShell = file->AlternateShell; + settings->AlternateShell = _strdup(file->AlternateShell); if (~((size_t) file->ShellWorkingDirectory)) - settings->ShellWorkingDirectory = file->ShellWorkingDirectory; + settings->ShellWorkingDirectory = _strdup(file->ShellWorkingDirectory); if (~((size_t) file->LoadBalanceInfo)) { @@ -546,7 +548,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* } if (~((size_t) file->GatewayHostname)) - settings->GatewayHostname = file->GatewayHostname; + settings->GatewayHostname = _strdup(file->GatewayHostname); if (~file->GatewayUsageMethod) settings->GatewayUsageMethod = TRUE; if (~file->PromptCredentialOnce) @@ -555,17 +557,17 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* if (~file->RemoteApplicationMode) settings->RemoteApplicationMode = file->RemoteApplicationMode; if (~((size_t) file->RemoteApplicationProgram)) - settings->RemoteApplicationProgram = file->RemoteApplicationProgram; + settings->RemoteApplicationProgram = _strdup(file->RemoteApplicationProgram); if (~((size_t) file->RemoteApplicationName)) - settings->RemoteApplicationName = file->RemoteApplicationName; + settings->RemoteApplicationName = _strdup(file->RemoteApplicationName); if (~((size_t) file->RemoteApplicationIcon)) - settings->RemoteApplicationIcon = file->RemoteApplicationIcon; + settings->RemoteApplicationIcon = _strdup(file->RemoteApplicationIcon); if (~((size_t) file->RemoteApplicationFile)) - settings->RemoteApplicationFile = file->RemoteApplicationFile; + settings->RemoteApplicationFile = _strdup(file->RemoteApplicationFile); if (~((size_t) file->RemoteApplicationGuid)) - settings->RemoteApplicationGuid = file->RemoteApplicationGuid; + settings->RemoteApplicationGuid = _strdup(file->RemoteApplicationGuid); if (~((size_t) file->RemoteApplicationCmdLine)) - settings->RemoteApplicationCmdLine = file->RemoteApplicationCmdLine; + settings->RemoteApplicationCmdLine = _strdup(file->RemoteApplicationCmdLine); if (~file->SpanMonitors) settings->SpanMonitors = file->SpanMonitors; diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index b15730228..0227620ae 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -490,7 +490,7 @@ int nego_recv(rdpTransport* transport, wStream* s, void* extra) if (length == 0) return -1; - if(!tpdu_read_connection_confirm(s, &li)) + if (!tpdu_read_connection_confirm(s, &li)) return -1; if (li > 6) @@ -563,7 +563,8 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) BYTE type; tpkt_read_header(s); - if(!tpdu_read_connection_request(s, &li)) + + if (!tpdu_read_connection_request(s, &li)) return FALSE; if (li != stream_get_left(s) + 6) @@ -671,7 +672,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego) DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols); - if (nego->requested_protocols > PROTOCOL_RDP) + if ((nego->requested_protocols > PROTOCOL_RDP) || (nego->sendNegoData)) { /* RDP_NEG_DATA must be present for TLS and NLA */ stream_write_BYTE(s, TYPE_RDP_NEG_REQ); @@ -764,18 +765,24 @@ void nego_process_negotiation_failure(rdpNego* nego, wStream* s) case SSL_REQUIRED_BY_SERVER: DEBUG_NEGO("Error: SSL_REQUIRED_BY_SERVER"); break; + case SSL_NOT_ALLOWED_BY_SERVER: DEBUG_NEGO("Error: SSL_NOT_ALLOWED_BY_SERVER"); break; + case SSL_CERT_NOT_ON_SERVER: DEBUG_NEGO("Error: SSL_CERT_NOT_ON_SERVER"); + nego->sendNegoData = TRUE; break; + case INCONSISTENT_FLAGS: DEBUG_NEGO("Error: INCONSISTENT_FLAGS"); break; + case HYBRID_REQUIRED_BY_SERVER: DEBUG_NEGO("Error: HYBRID_REQUIRED_BY_SERVER"); break; + default: DEBUG_NEGO("Error: Unknown protocol security error %d", failureCode); break; diff --git a/libfreerdp/core/nego.h b/libfreerdp/core/nego.h index 48e3d0410..e8f429fb8 100644 --- a/libfreerdp/core/nego.h +++ b/libfreerdp/core/nego.h @@ -100,6 +100,7 @@ struct rdp_nego BOOL security_connected; UINT32 cookie_max_length; + BOOL sendNegoData; UINT32 selected_protocol; UINT32 requested_protocols; BOOL NegotiateSecurityLayer; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index c44ae9667..8411b4b88 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -454,6 +454,7 @@ void freerdp_settings_free(rdpSettings* settings) free(settings->ConfigPath); free(settings->CurrentPath); free(settings->HomePath); + free(settings->LoadBalanceInfo); freerdp_device_collection_free(settings); freerdp_static_channel_collection_free(settings); freerdp_dynamic_channel_collection_free(settings); From fa5ee0a7dde73cc64bc42fe2b0845a8f9775d0dd Mon Sep 17 00:00:00 2001 From: Hardening Date: Sun, 14 Apr 2013 15:40:34 +0200 Subject: [PATCH 010/144] Fixed external declaration for C++ --- winpr/include/winpr/input.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 3c22ec6d2..6ca12d302 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -20,6 +20,7 @@ #ifndef WINPR_INPUT_H #define WINPR_INPUT_H + #include #include @@ -854,6 +855,10 @@ #define APPLE_VK_DownArrow 0x7D #define APPLE_VK_UpArrow 0x7E +#ifdef __cplusplus +extern "C" { +#endif + /** * Functions */ @@ -870,4 +875,8 @@ WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeybo WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_INPUT_H */ From 4b9f61596bdacad296357ca7c269a89bed44233d Mon Sep 17 00:00:00 2001 From: Hardening Date: Sun, 14 Apr 2013 15:41:04 +0200 Subject: [PATCH 011/144] Fixed signed/unsigned warning --- winpr/include/winpr/stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index 3c0924eb0..eb1b5acf0 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -330,8 +330,8 @@ WINPR_API void stream_extend(wStream* stream, int request_size); _src->pointer += _n; \ } while (0) -static INLINE BOOL stream_skip(wStream* s, int sz) { - if ((int) stream_get_left(s) < sz) +static INLINE BOOL stream_skip(wStream* s, size_t sz) { + if (stream_get_left(s) < sz) return FALSE; stream_seek(s, sz); return TRUE; From 5530bfb71e07e04d6b350ad773bbd3c4311a97c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 14 Apr 2013 11:28:07 -0400 Subject: [PATCH 012/144] mfreerdp: minor cleanup --- client/Mac/Info.plist | 2 +- client/Mac/MRDPView.h | 24 ++++++++++++------------ client/Mac/main.m | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/Mac/Info.plist b/client/Mac/Info.plist index cb6976502..253612c6e 100644 --- a/client/Mac/Info.plist +++ b/client/Mac/Info.plist @@ -25,7 +25,7 @@ LSMinimumSystemVersion NSHumanReadableCopyright - Copyright © 2012 __MyCompanyName__. All rights reserved. + Copyright © 2012 FreeRDP Open Source Project. NSMainNibFile MainMenu NSPrincipalClass diff --git a/client/Mac/MRDPView.h b/client/Mac/MRDPView.h index c894cb939..c15b35641 100644 --- a/client/Mac/MRDPView.h +++ b/client/Mac/MRDPView.h @@ -76,8 +76,8 @@ @public NSWindow* ourMainWindow; - NSPasteboard* pasteboard_rd; /* for reading from clipboard */ - NSPasteboard* pasteboard_wr; /* for writing to clipboard */ + NSPasteboard* pasteboard_rd; + NSPasteboard* pasteboard_wr; int pasteboard_changecount; int pasteboard_format; int is_connected; @@ -95,20 +95,21 @@ @end /* Pointer Flags */ -#define PTR_FLAGS_WHEEL 0x0200 -#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100 -#define PTR_FLAGS_MOVE 0x0800 -#define PTR_FLAGS_DOWN 0x8000 -#define PTR_FLAGS_BUTTON1 0x1000 -#define PTR_FLAGS_BUTTON2 0x2000 -#define PTR_FLAGS_BUTTON3 0x4000 -#define WheelRotationMask 0x01FF +#define PTR_FLAGS_WHEEL 0x0200 +#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100 +#define PTR_FLAGS_MOVE 0x0800 +#define PTR_FLAGS_DOWN 0x8000 +#define PTR_FLAGS_BUTTON1 0x1000 +#define PTR_FLAGS_BUTTON2 0x2000 +#define PTR_FLAGS_BUTTON3 0x4000 +#define WheelRotationMask 0x01FF void mf_Pointer_New(rdpContext* context, rdpPointer* pointer); void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer); void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer); void mf_Pointer_SetNull(rdpContext* context); void mf_Pointer_SetDefault(rdpContext* context); + int rdp_connect(void); BOOL mac_pre_connect(freerdp* instance); BOOL mac_post_connect(freerdp* instance); @@ -154,11 +155,10 @@ void mac_rail_enable_remoteapp_mode(void); void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, wMessage* event); void mac_process_rail_server_localmovesize_event(freerdp* instance, wMessage* event); void apple_center_window(NSRect* r); -void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER * windowMove); +void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove); struct mac_context { - // *must* have this - do not delete rdpContext _p; }; diff --git a/client/Mac/main.m b/client/Mac/main.m index 4cba6cfc1..5726f5c03 100644 --- a/client/Mac/main.m +++ b/client/Mac/main.m @@ -19,7 +19,7 @@ #import -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - return NSApplicationMain(argc, (const char **)argv); + return NSApplicationMain(argc, (const char**) argv); } From fb2a087dbfa5344e3c0a3b6823945e6610f41eb4 Mon Sep 17 00:00:00 2001 From: Nigel Reeves Date: Mon, 15 Apr 2013 11:14:09 +0100 Subject: [PATCH 013/144] Fix to issue #773. Ensure resume in correct NumLock state, when reconnectin to a session --- client/X11/xf_keyboard.c | 11 +++---- client/X11/xfreerdp.c | 6 +++- include/freerdp/freerdp.h | 1 + include/freerdp/input.h | 6 +++- libfreerdp/core/activation.c | 1 + libfreerdp/core/fastpath.c | 28 +++++++++++++++--- libfreerdp/core/fastpath.h | 2 ++ libfreerdp/core/freerdp.c | 16 +++++++++++ libfreerdp/core/input.c | 56 +++++++++++++++++++++++++++++++++++- libfreerdp/core/rdp.h | 1 + 10 files changed, 116 insertions(+), 12 deletions(-) diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 73ae107da..a7ff67ce0 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -191,15 +191,16 @@ void xf_kbd_focus_in(xfInfo* xfi) { rdpInput* input; UINT32 syncFlags; + int dummy, mouseX, mouseY; + Window wdummy; + UINT32 state = 0; input = xfi->instance->input; - /* on focus in send a tab up like mstsc.exe */ - input->KeyboardEvent(input, KBD_FLAGS_RELEASE, 0x0F); - - /* synchronize toggle keys */ syncFlags = xf_kbd_get_toggle_keys_state(xfi); - input->SynchronizeEvent(input, syncFlags); + XQueryPointer(xfi->display, xfi->window->handle, &wdummy, &wdummy, &mouseX, &mouseY, &dummy, &dummy, &state); + + input->FocusInEvent(input, syncFlags, mouseX, mouseY); } BOOL xf_kbd_handle_special_keys(xfInfo* xfi, KeySym keysym) diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 88c0f5e3e..c17b34973 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -1262,7 +1262,6 @@ int xfreerdp_run(freerdp* instance) xf_free(xfi); return XF_EXIT_CONN_FAILED; } - channels = instance->context->channels; settings = instance->context->settings; @@ -1291,6 +1290,11 @@ int xfreerdp_run(freerdp* instance) rcount = 0; wcount = 0; + if (freerdp_focus_required(instance)) + { + xf_kbd_focus_in(xfi); + } + if (!async_transport) { if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE) diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index 6b9aa5315..29760de81 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -215,6 +215,7 @@ FREERDP_API void freerdp_get_version(int* major, int* minor, int* revision); FREERDP_API freerdp* freerdp_new(void); FREERDP_API void freerdp_free(freerdp* instance); +FREERDP_API BOOL freerdp_focus_required(freerdp* instance); #ifdef __cplusplus } #endif diff --git a/include/freerdp/input.h b/include/freerdp/input.h index f437dde28..649aa634b 100644 --- a/include/freerdp/input.h +++ b/include/freerdp/input.h @@ -67,6 +67,7 @@ typedef void (*pKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code); typedef void (*pUnicodeKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code); typedef void (*pMouseEvent)(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); typedef void (*pExtendedMouseEvent)(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +typedef void (*pFocusInEvent)(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y); struct rdp_input { @@ -79,7 +80,9 @@ struct rdp_input pUnicodeKeyboardEvent UnicodeKeyboardEvent; /* 18 */ pMouseEvent MouseEvent; /* 19 */ pExtendedMouseEvent ExtendedMouseEvent; /* 20 */ - UINT32 paddingB[32 - 21]; /* 21 */ + pFocusInEvent FocusInEvent; /*21 */ + + UINT32 paddingB[32 - 22]; /* 22 */ /* Internal */ @@ -98,6 +101,7 @@ FREERDP_API void freerdp_input_send_keyboard_event_ex(rdpInput* input, BOOL down FREERDP_API void freerdp_input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code); FREERDP_API void freerdp_input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); FREERDP_API void freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +FREERDP_API void freerdp_input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y); #ifdef __cplusplus } diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 61c7007dd..4ba621a79 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -129,6 +129,7 @@ BOOL rdp_recv_server_control_pdu(rdpRdp* rdp, wStream* s) case CTRLACTION_GRANTED_CONTROL: rdp->finalize_sc_pdus |= FINALIZE_SC_CONTROL_GRANTED_PDU; + rdp->resendFocus = TRUE; break; } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 56d06a983..6ad20e31c 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -242,6 +242,7 @@ static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 s case FASTPATH_UPDATETYPE_PTR_DEFAULT: update->pointer->pointer_system.type = SYSPTR_DEFAULT; IFCALL(pointer->PointerSystem, context, &pointer->pointer_system); + break; case FASTPATH_UPDATETYPE_PTR_POSITION: @@ -575,7 +576,7 @@ static UINT32 fastpath_get_sec_bytes(rdpRdp* rdp) return sec_bytes; } -wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode) +wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath) { rdpRdp *rdp; wStream* s; @@ -584,17 +585,31 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev s = transport_send_stream_init(rdp->transport, 256); stream_seek(s, 3); /* fpInputHeader, length1 and length2 */ - if (rdp->do_crypt) { + + if (rdp->do_crypt) + { rdp->sec_flags |= SEC_ENCRYPT; if (rdp->do_secure_checksum) rdp->sec_flags |= SEC_SECURE_CHECKSUM; } stream_seek(s, fastpath_get_sec_bytes(rdp)); + + return s; +} + +wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode) +{ + rdpRdp *rdp; + wStream* s; + + rdp = fastpath->rdp; + + s = fastpath_input_pdu_init_header(fastpath); stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ return s; } -BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) +BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNumEvents) { rdpRdp *rdp; UINT16 length; @@ -611,7 +626,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) } eventHeader = FASTPATH_INPUT_ACTION_FASTPATH; - eventHeader |= (1 << 2); /* numberEvents */ + eventHeader |= (iNumEvents << 2); /* numberEvents */ if (rdp->sec_flags & SEC_ENCRYPT) eventHeader |= (FASTPATH_INPUT_ENCRYPTED << 6); if (rdp->sec_flags & SEC_SECURE_CHECKSUM) @@ -651,6 +666,11 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) return TRUE; } +BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) +{ + return fastpath_send_multiple_input_pdu(fastpath, s, 1); +} + wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) { wStream* s; diff --git a/libfreerdp/core/fastpath.h b/libfreerdp/core/fastpath.h index e7bcab46c..9c0b20732 100644 --- a/libfreerdp/core/fastpath.h +++ b/libfreerdp/core/fastpath.h @@ -109,7 +109,9 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length) int fastpath_recv_updates(rdpFastPath* fastpath, wStream* s); int fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s); +wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath); wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE eventCode); +BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iEventCount); BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s); wStream* fastpath_update_pdu_init(rdpFastPath* fastpath); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index bee255038..41bc89cb6 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -272,6 +272,22 @@ BOOL freerdp_shall_disconnect(freerdp* instance) return instance->context->rdp->disconnect; } +FREERDP_API BOOL freerdp_focus_required(freerdp* instance) +{ + rdpRdp* rdp; + BOOL bRetCode = FALSE; + + rdp = instance->context->rdp; + + if (rdp->resendFocus) + { + bRetCode = TRUE; + rdp->resendFocus = FALSE; + } + + return bRetCode; +} + void freerdp_get_version(int* major, int* minor, int* revision) { if (major != NULL) diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 06e31f84d..77683a546 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -65,6 +65,7 @@ void input_send_synchronize_event(rdpInput* input, UINT32 flags) { wStream* s; rdpRdp* rdp = input->context->rdp; + printf("In input_send_synchronize_event\n"); s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_SYNC); input_write_synchronize_event(s, flags); @@ -151,11 +152,28 @@ void input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI rdp_send_client_input_pdu(rdp, s); } +void input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + printf("In input_send_focus_in_event\n"); + + /* send a tab up like mstsc.exe */ + input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f); + + /* send the toggle key states */ + input_send_synchronize_event(input, (toggleStates & 0x1F)); + + /* send another tab up like mstsc.exe */ + input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f); + + /* finish with a mouse pointer position like mstsc.exe */ + input_send_extended_mouse_event(input, PTR_FLAGS_MOVE, x, y); +} + void input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags) { wStream* s; rdpRdp* rdp = input->context->rdp; - +printf("In input_send_fastpath_synchronize_event\n"); /* The FastPath Synchronization eventFlags has identical values as SlowPath */ s = fastpath_input_pdu_init(rdp->fastpath, (BYTE) flags, FASTPATH_INPUT_EVENT_SYNC); fastpath_send_input_pdu(rdp->fastpath, s); @@ -206,6 +224,35 @@ void input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags, UIN fastpath_send_input_pdu(rdp->fastpath, s); } +void input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + wStream* s; + rdpRdp* rdp = input->context->rdp; + BYTE eventFlags = 0; + + s = fastpath_input_pdu_init_header(rdp->fastpath); + /* send a tab up like mstsc.exe */ + eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; + stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ + stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + + /* send the toggle key states */ + eventFlags = (toggleStates & 0x1F) | FASTPATH_INPUT_EVENT_SYNC << 5; + stream_write_BYTE(s, eventFlags); /* toggle state (1 byte) */ + + /* send another tab up like mstsc.exe */ + eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; + stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ + stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + + /* finish with a mouse pointer position like mstsc.exe */ + eventFlags = 0 | FASTPATH_INPUT_EVENT_MOUSE << 5; + stream_write_BYTE(s, eventFlags); /* Mouse Pointer event (1 byte) */ + input_write_extended_mouse_event(s, PTR_FLAGS_MOVE, x, y); + + fastpath_send_multiple_input_pdu(rdp->fastpath, s, 4); +} + static BOOL input_recv_sync_event(rdpInput* input, wStream* s) { UINT32 toggleFlags; @@ -379,6 +426,7 @@ void input_register_client_callbacks(rdpInput* input) input->UnicodeKeyboardEvent = input_send_fastpath_unicode_keyboard_event; input->MouseEvent = input_send_fastpath_mouse_event; input->ExtendedMouseEvent = input_send_fastpath_extended_mouse_event; + input->FocusInEvent = input_send_fastpath_focus_in_event; } else { @@ -387,6 +435,7 @@ void input_register_client_callbacks(rdpInput* input) input->UnicodeKeyboardEvent = input_send_unicode_keyboard_event; input->MouseEvent = input_send_mouse_event; input->ExtendedMouseEvent = input_send_extended_mouse_event; + input->FocusInEvent = input_send_focus_in_event; } input->asynchronous = settings->AsyncInput; @@ -430,6 +479,11 @@ void freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT IFCALL(input->ExtendedMouseEvent, input, flags, x, y); } +void freerdp_input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) +{ + IFCALL(input->FocusInEvent, input, toggleStates, x, y); +} + int input_process_events(rdpInput* input) { return input_message_queue_process_pending_messages(input); diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index a8128c2ee..5188facc5 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -156,6 +156,7 @@ struct rdp_rdp UINT32 errorInfo; UINT32 finalize_sc_pdus; BOOL disconnect; + BOOL resendFocus; }; BOOL rdp_read_security_header(wStream* s, UINT16* flags); From 53e641abf16cccabff7c31b761c8870f91665bc6 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Wed, 17 Apr 2013 03:03:31 +0200 Subject: [PATCH 014/144] xfreerdp: fix xfi lifecycle and other crashers --- client/X11/cli/xfreerdp.c | 6 ++++++ client/X11/xf_interface.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index a2911207e..0fa20b98b 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -41,6 +41,12 @@ int main(int argc, char* argv[]) freerdp_client_global_init(); xfi = freerdp_client_new(argc, argv); + + if (xfi == NULL) + { + return 1; + } + instance = xfi->instance; freerdp_client_start(xfi); diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 3d27a5b49..7a84adc4f 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1020,6 +1020,7 @@ void xf_window_free(xfInfo* xfi) } freerdp_clrconv_free(xfi->clrconv); + xfi->clrconv = NULL; if (xfi->hdc) gdi_DeleteDC(xfi->hdc); @@ -1186,7 +1187,6 @@ void* xf_thread(void* param) if (!status) { - freerdp_client_free(xfi); exit_code = XF_EXIT_CONN_FAILED; ExitThread(exit_code); } @@ -1489,6 +1489,13 @@ xfInfo* freerdp_client_new(int argc, char** argv) status = freerdp_client_parse_command_line_arguments(instance->context->argc, instance->context->argv, settings); + if (status < 0) + { + freerdp_context_free(xfi->instance); + freerdp_free(xfi->instance); + free(xfi); + return NULL; + } if (settings->ConnectionFile) { From ce4e02ae48295063feb57f5d5fe14429d11b2de5 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Wed, 17 Apr 2013 13:09:53 +0200 Subject: [PATCH 015/144] iOS: Fixed possible crash on disconnect --- client/iOS/Models/RDPSession.m | 4 +++- libfreerdp/crypto/der.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index af400bb61..87a1aafc6 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -190,7 +190,9 @@ NSString* TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect" - (CGContextRef)bitmapContext { - return [self mfi]->bitmap_context; + if ([self mfi]->connection_state == TSXConnectionConnected) + return [self mfi]->bitmap_context; + return NULL; } #pragma mark - diff --git a/libfreerdp/crypto/der.c b/libfreerdp/crypto/der.c index 7c4694f17..1cc5eb770 100644 --- a/libfreerdp/crypto/der.c +++ b/libfreerdp/crypto/der.c @@ -27,9 +27,9 @@ int _der_skip_length(int length) { - if (length > 0x81 && length <= 0x102) + if (length > 0x7F && length <= 0xFF) return 2; - else if (length > 0x102) + else if (length > 0xFF) return 3; else return 1; From dcdb411208d87c86642e1668b4b754bf680358c4 Mon Sep 17 00:00:00 2001 From: Hardening Date: Wed, 17 Apr 2013 23:06:48 +0200 Subject: [PATCH 016/144] Fix winpr headers for C++ usage This patch add missing extern "C" declaration to use the headers in C++ projects. --- winpr/include/winpr/asn1.h | 9 +++++++++ winpr/include/winpr/bcrypt.h | 7 +++++++ winpr/include/winpr/cmdline.h | 8 ++++++++ winpr/include/winpr/collections.h | 7 +++++++ winpr/include/winpr/credentials.h | 8 ++++++++ winpr/include/winpr/credui.h | 8 ++++++++ winpr/include/winpr/crt.h | 9 +++++++++ winpr/include/winpr/crypto.h | 8 ++++++++ winpr/include/winpr/dsparse.h | 8 ++++++++ winpr/include/winpr/environment.h | 9 +++++++++ winpr/include/winpr/file.h | 16 ++++++++++++++++ winpr/include/winpr/handle.h | 8 ++++++++ winpr/include/winpr/heap.h | 8 ++++++++ winpr/include/winpr/interlocked.h | 8 ++++++++ winpr/include/winpr/io.h | 8 ++++++++ winpr/include/winpr/library.h | 8 ++++++++ winpr/include/winpr/midl.h | 8 ++++++++ winpr/include/winpr/ndr.h | 8 ++++++++ winpr/include/winpr/ntlm.h | 8 ++++++++ winpr/include/winpr/path.h | 17 +++++++++++++++++ winpr/include/winpr/pipe.h | 8 ++++++++ winpr/include/winpr/pool.h | 8 ++++++++ winpr/include/winpr/print.h | 8 ++++++++ winpr/include/winpr/registry.h | 8 ++++++++ winpr/include/winpr/rpc.h | 8 ++++++++ winpr/include/winpr/sam.h | 8 ++++++++ winpr/include/winpr/sspi.h | 17 +++++++++++++++++ winpr/include/winpr/sspicli.h | 8 ++++++++ winpr/include/winpr/sysinfo.h | 8 ++++++++ winpr/include/winpr/winhttp.h | 8 ++++++++ 30 files changed, 267 insertions(+) diff --git a/winpr/include/winpr/asn1.h b/winpr/include/winpr/asn1.h index 69f95e550..6c2e46e6c 100644 --- a/winpr/include/winpr/asn1.h +++ b/winpr/include/winpr/asn1.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef unsigned char ASN1uint8_t; typedef signed char ASN1int8_t; @@ -304,6 +308,7 @@ enum ASN1DECODE_NOASSERT = ASN1FLAGS_NOASSERT, }; + WINPR_API ASN1module_t ASN1_CreateModule(ASN1uint32_t nVersion, ASN1encodingrule_e eRule, ASN1uint32_t dwFlags, ASN1uint32_t cPDU, const ASN1GenericFun_t apfnEncoder[], const ASN1GenericFun_t apfnDecoder[], const ASN1FreeFun_t apfnFreeMemory[], @@ -501,5 +506,9 @@ WINPR_API int ASN1DEREncNewBlkElement(void* pBlk, ASN1encoding_t* enc2); WINPR_API int ASN1DEREncFlushBlkElement(void* pBlk); WINPR_API int ASN1DEREncEndBlk(void* pBlk); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_ASN1_H */ diff --git a/winpr/include/winpr/bcrypt.h b/winpr/include/winpr/bcrypt.h index d9e4f1d33..cf9a784eb 100644 --- a/winpr/include/winpr/bcrypt.h +++ b/winpr/include/winpr/bcrypt.h @@ -83,6 +83,10 @@ typedef PVOID BCRYPT_SECRET_HANDLE; #define BCRYPT_PRIMITIVE_TYPE L"PrimitiveType" #define BCRYPT_IS_KEYED_HASH L"IsKeyedHash" +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API NTSTATUS BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE* phAlgorithm, LPCWSTR pszAlgId, LPCWSTR pszImplementation, ULONG dwFlags); @@ -122,4 +126,7 @@ WINPR_API NTSTATUS BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG c VOID* pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG* pcbResult, ULONG dwFlags); +#ifdef __cplusplus +} +#endif #endif /* WINPR_BCRYPT_MEMORY_H */ diff --git a/winpr/include/winpr/cmdline.h b/winpr/include/winpr/cmdline.h index 6a3b8c6b8..bc67d4f52 100644 --- a/winpr/include/winpr/cmdline.h +++ b/winpr/include/winpr/cmdline.h @@ -123,6 +123,10 @@ typedef int (*COMMAND_LINE_PRE_FILTER_FN_W)(void* context, int index, int argc, typedef int (*COMMAND_LINE_POST_FILTER_FN_A)(void* context, COMMAND_LINE_ARGUMENT_A* arg); typedef int (*COMMAND_LINE_POST_FILTER_FN_W)(void* context, COMMAND_LINE_ARGUMENT_W* arg); +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options); WINPR_API int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options); @@ -136,6 +140,10 @@ WINPR_API COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMEN WINPR_API COMMAND_LINE_ARGUMENT_A* CommandLineFindNextArgumentA(COMMAND_LINE_ARGUMENT_A* argument); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define CommandLineClearArguments CommandLineClearArgumentsW #define CommandLineParseArguments CommandLineParseArgumentsW diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index 521e8578e..a8ed0765e 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -30,6 +30,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef void* (*OBJECT_NEW_FN)(void); typedef void (*OBJECT_FREE_FN)(void* obj); typedef void (*OBJECT_EQUALS_FN)(void* objA, void* objB); @@ -335,4 +339,7 @@ WINPR_API void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode); WINPR_API wMessagePipe* MessagePipe_New(void); WINPR_API void MessagePipe_Free(wMessagePipe* pipe); +#ifdef __cplusplus +} +#endif #endif /* WINPR_COLLECTIONS_H */ diff --git a/winpr/include/winpr/credentials.h b/winpr/include/winpr/credentials.h index a5f4f0d82..f3764cd0f 100644 --- a/winpr/include/winpr/credentials.h +++ b/winpr/include/winpr/credentials.h @@ -167,6 +167,10 @@ typedef enum _CRED_PROTECTION_TYPE #define PCREDENTIAL_TARGET_INFORMATION PCREDENTIAL_TARGET_INFORMATIONA #endif +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL CredWriteW(PCREDENTIALW Credential, DWORD Flags); WINPR_API BOOL CredWriteA(PCREDENTIALA Credential, DWORD Flags); @@ -220,6 +224,10 @@ WINPR_API BOOL CredGetSessionTypes(DWORD MaximumPersistCount, LPDWORD MaximumPer WINPR_API VOID CredFree(PVOID Buffer); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define CredWrite CredWriteW #define CredRead CredReadW diff --git a/winpr/include/winpr/credui.h b/winpr/include/winpr/credui.h index abefd1e78..3fac9f77b 100644 --- a/winpr/include/winpr/credui.h +++ b/winpr/include/winpr/credui.h @@ -96,6 +96,10 @@ typedef struct _CREDUI_INFOW #define PCREDUI_INFO PCREDUI_INFOA #endif +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API DWORD CredUIPromptForCredentialsW(PCREDUI_INFOW pUiInfo, PCWSTR pszTargetName, PCtxtHandle pContext, DWORD dwAuthError, PWSTR pszUserName, ULONG ulUserNameBufferSize, PWSTR pszPassword, ULONG ulPasswordBufferSize, BOOL* save, DWORD dwFlags); @@ -122,6 +126,10 @@ WINPR_API DWORD CredUIStoreSSOCredA(PCSTR pszRealm, PCSTR pszUsername, PCSTR psz WINPR_API DWORD CredUIReadSSOCredW(PCWSTR pszRealm, PWSTR* ppszUsername); WINPR_API DWORD CredUIReadSSOCredA(PCSTR pszRealm, PSTR* ppszUsername); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define CredUIPromptForCredentials CredUIPromptForCredentialsW #define CredUIParseUserName CredUIParseUserNameW diff --git a/winpr/include/winpr/crt.h b/winpr/include/winpr/crt.h index ed5e56a9a..70ea058e5 100644 --- a/winpr/include/winpr/crt.h +++ b/winpr/include/winpr/crt.h @@ -44,6 +44,10 @@ typedef int errno_t; #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) #define _ARRAYSIZE(A) RTL_NUMBER_OF_V1(A) +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API void* _aligned_malloc(size_t size, size_t alignment); WINPR_API void* _aligned_realloc(void* memblock, size_t size, size_t alignment); WINPR_API void* _aligned_recalloc(void* memblock, size_t num, size_t size, size_t alignment); @@ -65,6 +69,11 @@ WINPR_API errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int WINPR_API errno_t memmove_s(void* dest, size_t numberOfElements, const void* src, size_t count); WINPR_API errno_t wmemmove_s(WCHAR* dest, size_t numberOfElements, const WCHAR* src, size_t count); +#ifdef __cplusplus +} +#endif + + #endif #endif /* WINPR_CRT_H */ diff --git a/winpr/include/winpr/crypto.h b/winpr/include/winpr/crypto.h index 56fd6d981..1ce92b2b9 100644 --- a/winpr/include/winpr/crypto.h +++ b/winpr/include/winpr/crypto.h @@ -365,6 +365,10 @@ WINPR_API BOOL CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags); #define CertOpenSystemStore CertOpenSystemStoreA #endif +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void* pvFindPara, PCCERT_CONTEXT pPrevCertContext); @@ -375,6 +379,10 @@ DWORD CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void* pvTypePara, LPSTR pszNameString, DWORD cchNameString); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define CertGetNameString CertGetNameStringW #else diff --git a/winpr/include/winpr/dsparse.h b/winpr/include/winpr/dsparse.h index 013aadb2d..91455873a 100644 --- a/winpr/include/winpr/dsparse.h +++ b/winpr/include/winpr/dsparse.h @@ -93,6 +93,10 @@ typedef struct PDS_NAME_RESULT_ITEM rItems; } DS_NAME_RESULT, *PDS_NAME_RESULT; +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API DWORD DsCrackSpnW(LPCWSTR pszSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName, LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName, USHORT* pInstancePort); @@ -111,6 +115,10 @@ WINPR_API DWORD DsMakeSpnW(LPCWSTR ServiceClass, LPCWSTR ServiceName, LPCWSTR In WINPR_API DWORD DsMakeSpnA(LPCSTR ServiceClass, LPCSTR ServiceName, LPCSTR InstanceName, USHORT InstancePort, LPCSTR Referrer, DWORD* pcSpnLength, LPSTR pszSpn); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define DsMakeSpn DsMakeSpnW #else diff --git a/winpr/include/winpr/environment.h b/winpr/include/winpr/environment.h index eab6a8891..b77ab71bf 100644 --- a/winpr/include/winpr/environment.h +++ b/winpr/include/winpr/environment.h @@ -25,6 +25,10 @@ #ifndef _WIN32 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer); WINPR_API DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer); @@ -62,6 +66,11 @@ WINPR_API DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSi WINPR_API BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock); WINPR_API BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock); +#ifdef __cplusplus +} +#endif + + #ifdef UNICODE #define GetCurrentDirectory GetCurrentDirectoryW #define SetCurrentDirectory SetCurrentDirectoryW diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h index efc190b23..b1dfe22f5 100644 --- a/winpr/include/winpr/file.h +++ b/winpr/include/winpr/file.h @@ -194,6 +194,10 @@ typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode, DWORD dwNumbe #define LPWIN32_FIND_DATA LPWIN32_FIND_DATAA #endif +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); @@ -260,6 +264,10 @@ WINPR_API BOOL FindClose(HANDLE hFindFile); WINPR_API BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes); WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define CreateFile CreateFileW #define DeleteFile DeleteFileW @@ -287,8 +295,16 @@ WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecu #define WILDCARD_DOS_QM 0x00000120 #define WILDCARD_DOS_DOT 0x00000140 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern); WINPR_API LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_FILE_H */ diff --git a/winpr/include/winpr/handle.h b/winpr/include/winpr/handle.h index f479a4a63..ef586c223 100644 --- a/winpr/include/winpr/handle.h +++ b/winpr/include/winpr/handle.h @@ -36,6 +36,10 @@ #define HANDLE_TYPE_NAMED_PIPE 6 #define HANDLE_TYPE_ANONYMOUS_PIPE 7 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object); WINPR_API BOOL winpr_Handle_Remove(HANDLE handle); @@ -58,5 +62,9 @@ WINPR_API BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags) #endif +#ifdef __cplusplus +} +#endif + #endif /* WINPR_HANDLE_H */ diff --git a/winpr/include/winpr/heap.h b/winpr/include/winpr/heap.h index 2d5d256cd..30ab48ca9 100644 --- a/winpr/include/winpr/heap.h +++ b/winpr/include/winpr/heap.h @@ -33,11 +33,19 @@ #define HEAP_ZERO_MEMORY 0x00000008 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API HANDLE GetProcessHeap(void); WINPR_API LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes); WINPR_API LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes); WINPR_API BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_HEAP_H */ diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h index 0fea91a72..e96a2b62f 100644 --- a/winpr/include/winpr/interlocked.h +++ b/winpr/include/winpr/interlocked.h @@ -25,6 +25,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 /* workaround for SLIST_ENTRY conflict */ @@ -172,5 +176,9 @@ WINPR_API VOID AppendTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListToAppend); WINPR_API VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry); WINPR_API PSINGLE_LIST_ENTRY PopEntryList(PSINGLE_LIST_ENTRY ListHead); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_INTERLOCKED_H */ diff --git a/winpr/include/winpr/io.h b/winpr/include/winpr/io.h index 237f2674b..3f4365b85 100644 --- a/winpr/include/winpr/io.h +++ b/winpr/include/winpr/io.h @@ -49,6 +49,10 @@ typedef struct _OVERLAPPED_ENTRY DWORD dwNumberOfBytesTransferred; } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); WINPR_API BOOL GetOverlappedResultEx(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, DWORD dwMilliseconds, BOOL bAlertable); @@ -72,6 +76,10 @@ WINPR_API BOOL CancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped); WINPR_API BOOL CancelSynchronousIo(HANDLE hThread); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_IO_H */ diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h index b38cf2a6e..721d2b70e 100644 --- a/winpr/include/winpr/library.h +++ b/winpr/include/winpr/library.h @@ -32,6 +32,10 @@ typedef HANDLE DLL_DIRECTORY_COOKIE; #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 #define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory); WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie); WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags); @@ -54,6 +58,10 @@ WINPR_API FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName); WINPR_API BOOL FreeLibrary(HMODULE hLibModule); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_LIBRARY_H */ diff --git a/winpr/include/winpr/midl.h b/winpr/include/winpr/midl.h index 0f87efe8d..a0daaa4da 100644 --- a/winpr/include/winpr/midl.h +++ b/winpr/include/winpr/midl.h @@ -22,6 +22,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 WINPR_API void* MIDL_user_allocate(size_t cBytes); @@ -29,4 +33,8 @@ WINPR_API void MIDL_user_free(void* p); #endif +#ifdef __cplusplus +} +#endif + #endif /* WINPR_RPC_MIDL_H */ diff --git a/winpr/include/winpr/ndr.h b/winpr/include/winpr/ndr.h index adafd5467..12ab5c2e5 100644 --- a/winpr/include/winpr/ndr.h +++ b/winpr/include/winpr/ndr.h @@ -523,8 +523,16 @@ typedef void (*NDR_TYPE_MARSHALL_ROUTINE)(PMIDL_STUB_MESSAGE pStubMsg, unsigned typedef void (*NDR_TYPE_UNMARSHALL_ROUTINE)(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar); typedef void (*NDR_TYPE_FREE_ROUTINE)(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat); +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_RPC_NDR_H */ diff --git a/winpr/include/winpr/ntlm.h b/winpr/include/winpr/ntlm.h index d6514f92a..8b62ebdc8 100644 --- a/winpr/include/winpr/ntlm.h +++ b/winpr/include/winpr/ntlm.h @@ -26,6 +26,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BYTE* NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash); WINPR_API BYTE* NTOWFv1A(LPSTR Password, UINT32 PasswordLength, BYTE* NtHash); @@ -39,6 +43,10 @@ WINPR_API BYTE* NTOWFv2FromHashW(BYTE* NtHashV1, LPWSTR User, UINT32 UserLength, WINPR_API BYTE* NTOWFv2FromHashA(BYTE* NtHashV1, LPSTR User, UINT32 UserLength, LPSTR Domain, UINT32 DomainLength, BYTE* NtHash); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define NTOWFv1 NTOWFv1W #define NTOWFv2 NTOWFv2W diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h index d320ee17d..9c3ec4c01 100644 --- a/winpr/include/winpr/path.h +++ b/winpr/include/winpr/path.h @@ -33,6 +33,10 @@ #else +#ifdef __cplusplus +extern "C" { +#endif + #define PATHCCH_ALLOW_LONG_PATHS 0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */ #define VOLUME_PREFIX _T("\\\\?\\Volume") @@ -111,6 +115,7 @@ WINPR_API HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath); WINPR_API HRESULT PathCchRemoveFileSpecA(PSTR pszPath, size_t cchPath); WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath); + #ifdef UNICODE #define PathCchAddBackslash PathCchAddBackslashW #define PathCchRemoveBackslash PathCchRemoveBackslashW @@ -248,6 +253,10 @@ WINPR_API PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags); #define PathGetSharedLibraryExtension PathGetSharedLibraryExtensionA #endif +#ifdef __cplusplus +} +#endif + #endif /** @@ -261,6 +270,10 @@ WINPR_API PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags); #define KNOWN_PATH_XDG_CACHE_HOME 5 #define KNOWN_PATH_XDG_RUNTIME_DIR 6 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API char* GetKnownPath(int id); WINPR_API char* GetKnownSubPath(int id, char* path); WINPR_API char* GetCombinedPath(char* basePath, char* subPath); @@ -270,6 +283,10 @@ WINPR_API char* GetCombinedPath(char* basePath, char* subPath); WINPR_API BOOL PathFileExistsA(LPCSTR pszPath); WINPR_API BOOL PathFileExistsW(LPCWSTR pszPath); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define PathFileExists PathFileExistsW #else diff --git a/winpr/include/winpr/pipe.h b/winpr/include/winpr/pipe.h index e95de7106..3875c4b6c 100644 --- a/winpr/include/winpr/pipe.h +++ b/winpr/include/winpr/pipe.h @@ -28,8 +28,16 @@ #ifndef _WIN32 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_PIPE_H */ diff --git a/winpr/include/winpr/pool.h b/winpr/include/winpr/pool.h index 4ea9751b3..8ff2ff855 100644 --- a/winpr/include/winpr/pool.h +++ b/winpr/include/winpr/pool.h @@ -152,6 +152,10 @@ typedef VOID (*PTP_WIN32_IO_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Cont #endif +#ifdef __cplusplus +extern "C" { +#endif + /* Synch */ @@ -225,4 +229,8 @@ WINPR_API VOID DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci); WINPR_API void winpr_pool_dummy(void); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_POOL_H */ diff --git a/winpr/include/winpr/print.h b/winpr/include/winpr/print.h index 72049692d..d5e9cc724 100644 --- a/winpr/include/winpr/print.h +++ b/winpr/include/winpr/print.h @@ -25,8 +25,16 @@ #define WINPR_HEXDUMP_LINE_LENGTH 16 +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API void winpr_HexDump(BYTE* data, int length); WINPR_API int wprintfx(const char *fmt, ...); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_UTILS_PRINT_H */ diff --git a/winpr/include/winpr/registry.h b/winpr/include/winpr/registry.h index 2994ae8bc..a4021b360 100644 --- a/winpr/include/winpr/registry.h +++ b/winpr/include/winpr/registry.h @@ -28,6 +28,10 @@ #else +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -402,6 +406,10 @@ WINPR_API LONG RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey); #define RegUnLoadKey RegUnLoadKeyA #endif +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_REGISTRY_H */ diff --git a/winpr/include/winpr/rpc.h b/winpr/include/winpr/rpc.h index b009bd1f1..428ebf7e7 100644 --- a/winpr/include/winpr/rpc.h +++ b/winpr/include/winpr/rpc.h @@ -445,6 +445,10 @@ typedef struct _RPC_BINDING_HANDLE_TEMPLATE #include #include +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API RPC_STATUS RpcBindingCopy(RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE* DestinationBinding); WINPR_API RPC_STATUS RpcBindingFree(RPC_BINDING_HANDLE* Binding); WINPR_API RPC_STATUS RpcBindingSetOption(RPC_BINDING_HANDLE hBinding, unsigned long option, ULONG_PTR optionValue); @@ -601,6 +605,10 @@ WINPR_API RPC_STATUS RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN Authori WINPR_API RPC_STATUS RpcServerInqBindingHandle(RPC_BINDING_HANDLE* Binding); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_RPC_H */ diff --git a/winpr/include/winpr/sam.h b/winpr/include/winpr/sam.h index 92475947f..ea252e01a 100644 --- a/winpr/include/winpr/sam.h +++ b/winpr/include/winpr/sam.h @@ -43,6 +43,10 @@ struct winpr_sam_entry }; typedef struct winpr_sam_entry WINPR_SAM_ENTRY; +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API WINPR_SAM_ENTRY* SamLookupUserA(WINPR_SAM* sam, LPSTR User, UINT32 UserLength, LPSTR Domain, UINT32 DomainLength); WINPR_API WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPWSTR User, UINT32 UserLength, LPWSTR Domain, UINT32 DomainLength); @@ -51,5 +55,9 @@ WINPR_API void SamFreeEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry); WINPR_API WINPR_SAM* SamOpen(BOOL read_only); WINPR_API void SamClose(WINPR_SAM* sam); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_UTILS_SAM_H */ diff --git a/winpr/include/winpr/sspi.h b/winpr/include/winpr/sspi.h index a2d780a47..f2adcd2bb 100644 --- a/winpr/include/winpr/sspi.h +++ b/winpr/include/winpr/sspi.h @@ -930,6 +930,10 @@ typedef PSecurityFunctionTableW (SEC_ENTRY * INIT_SECURITY_INTERFACE_W)(void); #define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_A #endif +#ifdef __cplusplus +extern "C" { +#endif + /* Package Management */ WINPR_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(ULONG* pcPackages, PSecPkgInfoA* ppPackageInfo); @@ -992,6 +996,15 @@ WINPR_API SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG WINPR_API SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo); WINPR_API SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP); +#ifdef __cplusplus +} +#endif + +#endif // WINPR_SSPI + + +#ifdef __cplusplus +extern "C" { #endif /* Custom API */ @@ -1005,4 +1018,8 @@ WINPR_API void sspi_SecBufferFree(PSecBuffer SecBuffer); WINPR_API void sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, char* user, char* domain, char* password); WINPR_API void sspi_CopyAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, SEC_WINNT_AUTH_IDENTITY* srcIdentity); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_SSPI_H */ diff --git a/winpr/include/winpr/sspicli.h b/winpr/include/winpr/sspicli.h index 602da2931..30869a1ab 100644 --- a/winpr/include/winpr/sspicli.h +++ b/winpr/include/winpr/sspicli.h @@ -75,9 +75,17 @@ typedef enum } EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT; +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize); WINPR_API BOOL GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize); +#ifdef __cplusplus +} +#endif + #ifdef UNICODE #define GetUserNameEx GetUserNameExW #else diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h index 0a6ad2e42..80f4e4af7 100644 --- a/winpr/include/winpr/sysinfo.h +++ b/winpr/include/winpr/sysinfo.h @@ -26,6 +26,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 #define PROCESSOR_ARCHITECTURE_INTEL 0 @@ -310,4 +314,8 @@ WINPR_API BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature); #define PF_SSE_INSTRUCTIONS_AVAILABLE PF_XMMI_INSTRUCTIONS_AVAILABLE #define PF_SSE2_INSTRUCTIONS_AVAILABLE PF_XMMI64_INSTRUCTIONS_AVAILABLE +#ifdef __cplusplus +} +#endif + #endif /* WINPR_SYSINFO_H */ diff --git a/winpr/include/winpr/winhttp.h b/winpr/include/winpr/winhttp.h index 5f296eb9d..07762bc37 100644 --- a/winpr/include/winpr/winhttp.h +++ b/winpr/include/winpr/winhttp.h @@ -593,6 +593,10 @@ typedef struct #define WINHTTP_ERROR_LAST (WINHTTP_ERROR_BASE + 186) +#ifdef __cplusplus +extern "C" { +#endif + WINPR_API BOOL WinHttpTimeFromSystemTime(const SYSTEMTIME* pst, LPWSTR pwszTime); WINPR_API BOOL WinHttpTimeToSystemTime(LPCWSTR pwszTime, SYSTEMTIME* pst); @@ -651,6 +655,10 @@ WINPR_API BOOL WinHttpGetProxyForUrl(HINTERNET hSession, LPCWSTR lpcwszUrl, WINPR_API BOOL WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG* pProxyConfig); +#ifdef __cplusplus +} +#endif + #endif #endif /* WINPR_WINHTTP_H */ From dd5cbef46756ebaffa4d8b5cadbb8024de982b14 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Thu, 18 Apr 2013 10:51:39 +0200 Subject: [PATCH 017/144] iOS: Fix resource leak --- client/iOS/FreeRDP/ios_freerdp.m | 4 +++- client/iOS/Models/RDPSession.m | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/iOS/FreeRDP/ios_freerdp.m b/client/iOS/FreeRDP/ios_freerdp.m index ae3f1e084..ee0cdddc0 100644 --- a/client/iOS/FreeRDP/ios_freerdp.m +++ b/client/iOS/FreeRDP/ios_freerdp.m @@ -221,7 +221,9 @@ ios_run_freerdp(freerdp * instance) [pool release]; pool = nil; } - + + CGContextRelease(mfi->bitmap_context); + mfi->bitmap_context = NULL; mfi->connection_state = TSXConnectionDisconnected; // Cleanup diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index 87a1aafc6..6144637d1 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -190,9 +190,7 @@ NSString* TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect" - (CGContextRef)bitmapContext { - if ([self mfi]->connection_state == TSXConnectionConnected) - return [self mfi]->bitmap_context; - return NULL; + return [self mfi]->bitmap_context; } #pragma mark - From 6b48a8c7c58cae5f21f4ef126e531a6b5f5b5d1f Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Thu, 18 Apr 2013 03:43:52 -0700 Subject: [PATCH 018/144] Android: Fixed possible crash with a session being null --- .../com/freerdp/freerdpcore/application/GlobalApp.java | 6 +----- .../freerdp/freerdpcore/presentation/SessionActivity.java | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java index c37f8df5a..aca737a4b 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/application/GlobalApp.java @@ -194,8 +194,7 @@ public class GlobalApp extends Application implements LibFreeRDP.EventListener { Log.v("LibFreeRDP", "OnConnectionFailure"); - // free session - GlobalApp.freeSession(instance); + // send notification to session activity sendRDPNotification(FREERDP_EVENT_CONNECTION_FAILURE, instance); } @@ -210,8 +209,5 @@ public class GlobalApp extends Application implements LibFreeRDP.EventListener public void OnDisconnected(int instance) { Log.v("LibFreeRDP", "OnDisconnected"); - - // free session - GlobalApp.freeSession(instance); } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java index 657678bc7..3d1c5adc1 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java @@ -256,7 +256,6 @@ public class SessionActivity extends Activity if (!connectCancelledByUser) uiHandler.sendMessage(Message.obtain(null, UIHandler.DISPLAY_TOAST, getResources().getText(R.string.error_connection_failure))); - session = null; closeSessionActivity(RESULT_CANCELED); } @@ -271,7 +270,6 @@ public class SessionActivity extends Activity } session.setUIEventListener(null); - session = null; closeSessionActivity(RESULT_OK); } } @@ -518,9 +516,13 @@ public class SessionActivity extends Activity protected void onDestroy() { super.onDestroy(); Log.v(TAG, "Session.onDestroy"); - + // unregister freerdp events broadcast receiver unregisterReceiver(libFreeRDPBroadcastReceiver); + + // free session + GlobalApp.freeSession(session.getInstance()); + session = null; } @Override From 84bd674e0a3eec8a41955209b35876c596dd4955 Mon Sep 17 00:00:00 2001 From: Nigel Reeves Date: Mon, 22 Apr 2013 13:32:22 +0100 Subject: [PATCH 019/144] removed unnecessary printfs --- libfreerdp/core/input.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 77683a546..30b82dd0b 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -65,7 +65,6 @@ void input_send_synchronize_event(rdpInput* input, UINT32 flags) { wStream* s; rdpRdp* rdp = input->context->rdp; - printf("In input_send_synchronize_event\n"); s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_SYNC); input_write_synchronize_event(s, flags); @@ -154,8 +153,6 @@ void input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI void input_send_focus_in_event(rdpInput* input, UINT16 toggleStates, UINT16 x, UINT16 y) { - printf("In input_send_focus_in_event\n"); - /* send a tab up like mstsc.exe */ input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f); @@ -173,7 +170,7 @@ void input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags) { wStream* s; rdpRdp* rdp = input->context->rdp; -printf("In input_send_fastpath_synchronize_event\n"); + /* The FastPath Synchronization eventFlags has identical values as SlowPath */ s = fastpath_input_pdu_init(rdp->fastpath, (BYTE) flags, FASTPATH_INPUT_EVENT_SYNC); fastpath_send_input_pdu(rdp->fastpath, s); From 914ac31cbf94d87c1247bf721600cad3de287a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 22 Apr 2013 08:33:41 -0400 Subject: [PATCH 020/144] xfreerdp: fail differently if no hostname is given --- client/X11/xf_interface.c | 8 ++++++++ client/common/cmdline.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 3d27a5b49..521c6b8b8 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1428,6 +1428,14 @@ int freerdp_client_global_uninit() int freerdp_client_start(xfInfo* xfi) { + rdpSettings* settings = xfi->settings; + + if (!settings->ServerHostname) + { + fprintf(stderr, "error: server hostname was not specified with /v:[:port]\n"); + return -1; + } + xfi->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) xfi->instance, 0, NULL); return 0; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index dc5e6a681..5451d3158 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -992,8 +992,8 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin if (!settings->ConnectionFile && !(arg->Flags & COMMAND_LINE_VALUE_PRESENT)) { - fprintf(stderr, "error: server hostname was not specified with /v:[:port]\n"); - return COMMAND_LINE_ERROR_MISSING_ARGUMENT; + //fprintf(stderr, "error: server hostname was not specified with /v:[:port]\n"); + //return COMMAND_LINE_ERROR_MISSING_ARGUMENT; } arg = args; From 4a48266743db985e2fba00406312aaeba2e47c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 22 Apr 2013 16:32:08 -0400 Subject: [PATCH 021/144] cmake: fix 64-bit build with cmake 2.8.8 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22c361b1a..78ba4ae0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,7 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") endif() - if(${CMAKE_VERSION} VERSION_LESS 2.8.8) + if(${CMAKE_VERSION} VERSION_LESS 2.8.9) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") endif() if(WITH_SSE2) From a64465857377aa109c5464f0259bdf315d8a5f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 22 Apr 2013 18:47:53 -0400 Subject: [PATCH 022/144] server: add hook --- server/.gitignore | 2 ++ server/CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 server/.gitignore diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 000000000..d18fe8fe7 --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,2 @@ +WaykServer + diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 97bef04f5..0d54cf7e5 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -35,3 +35,7 @@ else() add_subdirectory(Windows) endif() +if(WITH_WAYK) + add_subdirectory(WaykServer) +endif() + From 1a336c30b8031b6b28846679315994473598d667 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Tue, 23 Apr 2013 10:15:12 +0200 Subject: [PATCH 023/144] iOS: Fix for shift key handling (by bslande) --- client/iOS/Models/RDPKeyboard.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/iOS/Models/RDPKeyboard.m b/client/iOS/Models/RDPKeyboard.m index 17aa66543..f43ed9e5d 100644 --- a/client/iOS/Models/RDPKeyboard.m +++ b/client/iOS/Models/RDPKeyboard.m @@ -238,7 +238,7 @@ if(isupper(character) && _shift_pressed == NO) { character = tolower(character); - [self sendVirtualKey:VK_SHIFT up:NO]; + [self sendVirtualKey:VK_LSHIFT up:NO]; shift_was_sent = YES; } @@ -253,7 +253,7 @@ // send the missing shift up if we had a shift down if(shift_was_sent) - [self sendVirtualKey:VK_SHIFT up:YES]; + [self sendVirtualKey:VK_LSHIFT up:YES]; } - (void)handleSpecialKey:(int)character From 4bb700d85b81e8e94610e7bed82d40a781f8287f Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Tue, 23 Apr 2013 04:04:06 -0700 Subject: [PATCH 024/144] Android: Added missing french translation --- client/Android/aFreeRDP/res/values-fr/strings.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 client/Android/aFreeRDP/res/values-fr/strings.xml diff --git a/client/Android/aFreeRDP/res/values-fr/strings.xml b/client/Android/aFreeRDP/res/values-fr/strings.xml new file mode 100644 index 000000000..3c36d79ff --- /dev/null +++ b/client/Android/aFreeRDP/res/values-fr/strings.xml @@ -0,0 +1,7 @@ + + + aFreeRDP + + aFreeRDP + L\'ordinateur distant + From fcad37ee6a3c316224414ea181d46383a862a998 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Tue, 23 Apr 2013 08:58:37 -0700 Subject: [PATCH 025/144] Android: Changed version string for APKs --- client/Android/FreeRDPCore/AndroidManifest.xml.cmake | 2 +- client/Android/aFreeRDP/AndroidManifest.xml.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/Android/FreeRDPCore/AndroidManifest.xml.cmake b/client/Android/FreeRDPCore/AndroidManifest.xml.cmake index 639d5ac80..890df2fdd 100644 --- a/client/Android/FreeRDPCore/AndroidManifest.xml.cmake +++ b/client/Android/FreeRDPCore/AndroidManifest.xml.cmake @@ -4,7 +4,7 @@ android:installLocation="auto" package="com.freerdp.freerdpcore" android:versionCode="1" - android:versionName="@FREERDP_VERSION_FULL@" > + android:versionName="@GIT_REVISION@" > diff --git a/client/Android/aFreeRDP/AndroidManifest.xml.cmake b/client/Android/aFreeRDP/AndroidManifest.xml.cmake index 7e6e0e86c..ac4f97bcb 100644 --- a/client/Android/aFreeRDP/AndroidManifest.xml.cmake +++ b/client/Android/aFreeRDP/AndroidManifest.xml.cmake @@ -4,7 +4,7 @@ android:installLocation="auto" package="com.freerdp.afreerdp" android:versionCode="1" - android:versionName="@FREERDP_VERSION_FULL@" > + android:versionName="@GIT_REVISION@" > From fae24b1ef9aafefd8dd7ee0ab0c2fbf1c1e07c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 23 Apr 2013 18:17:01 -0400 Subject: [PATCH 026/144] xfreerdp-server: auto-generate self-signed certificate --- client/X11/xf_interface.c | 2 +- libfreerdp/crypto/tls.c | 7 ++- server/X11/CMakeLists.txt | 3 ++ server/X11/xf_peer.c | 67 +++++++++++++++++++++++------ winpr/libwinpr/path/shell.c | 3 ++ winpr/tools/makecert/CMakeLists.txt | 2 +- winpr/tools/makecert/makecert.c | 6 +++ winpr/tools/makecert/makecert.h | 1 + 8 files changed, 73 insertions(+), 18 deletions(-) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 521c6b8b8..3a2ce8b8a 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -642,7 +642,7 @@ BOOL xf_pre_connect(freerdp* instance) xfi->display = XOpenDisplay(NULL); - if (xfi->display == NULL) + if (!xfi->display) { fprintf(stderr, "xf_pre_connect: failed to open display: %s\n", XDisplayName(NULL)); fprintf(stderr, "Please check that the $DISPLAY environment variable is properly set.\n"); diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 878502f7f..e195031d9 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -249,17 +249,16 @@ BOOL tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file) SSL_CTX_set_options(tls->ctx, options); - fprintf(stderr, "private key file: %s\n", privatekey_file); - if (SSL_CTX_use_RSAPrivateKey_file(tls->ctx, privatekey_file, SSL_FILETYPE_PEM) <= 0) { fprintf(stderr, "SSL_CTX_use_RSAPrivateKey_file failed\n"); + fprintf(stderr, "PrivateKeyFile: %s\n", privatekey_file); return FALSE; } tls->ssl = SSL_new(tls->ctx); - if (tls->ssl == NULL) + if (!tls->ssl) { fprintf(stderr, "SSL_new failed\n"); return FALSE; @@ -273,7 +272,7 @@ BOOL tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file) cert = tls_get_certificate(tls, FALSE); - if (cert == NULL) + if (!cert) { fprintf(stderr, "tls_connect: tls_get_certificate failed to return the server certificate.\n"); return FALSE; diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index d4e708df8..799b58e18 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -19,6 +19,7 @@ set(MODULE_NAME "xfreerdp-server") set(MODULE_PREFIX "FREERDP_SERVER_X11") include_directories(${X11_INCLUDE_DIRS}) +include_directories("../../winpr/tools/makecert") set(${MODULE_PREFIX}_SRCS xf_peer.c @@ -96,6 +97,8 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MODULE winpr MODULES winpr-sspi) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-makecert-tool) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 7a4baddd3..3cda413e0 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,8 @@ #include "xf_input.h" #include "xf_encode.h" +#include "makecert.h" + #include "xf_peer.h" #ifdef WITH_XDAMAGE @@ -190,6 +193,8 @@ xfInfo* xf_info_init() */ xfi->use_xshm = FALSE; + setenv("DISPLAY", ":0", 1); /* Set DISPLAY variable if not already set */ + if (!XInitThreads()) fprintf(stderr, "warning: XInitThreads() failure\n"); @@ -521,7 +526,53 @@ BOOL xf_peer_activate(freerdp_peer* client) return TRUE; } -void* xf_peer_main_loop(void* arg) +const char* makecert_argv[4] = +{ + "makecert", + "-rdp", + "-live", + "-silent" +}; + +int makecert_argc = (sizeof(makecert_argv) / sizeof(char*)); + +int xf_generate_certificate(rdpSettings* settings) +{ + char* server_file_path; + MAKECERT_CONTEXT* context; + + server_file_path = GetCombinedPath(settings->ConfigPath, "server"); + + if (!PathFileExistsA(server_file_path)) + CreateDirectoryA(server_file_path, 0); + + settings->CertificateFile = GetCombinedPath(server_file_path, "server.crt"); + settings->PrivateKeyFile = GetCombinedPath(server_file_path, "server.key"); + + if ((!PathFileExistsA(settings->CertificateFile)) || + (!PathFileExistsA(settings->PrivateKeyFile))) + { + context = makecert_context_new(); + + makecert_context_process(context, makecert_argc, (char**) makecert_argv); + + makecert_context_set_output_file_name(context, "server"); + + if (!PathFileExistsA(settings->CertificateFile)) + makecert_context_output_certificate_file(context, server_file_path); + + if (!PathFileExistsA(settings->PrivateKeyFile)) + makecert_context_output_private_key_file(context, server_file_path); + + makecert_context_free(context); + } + + free(server_file_path); + + return 0; +} + +static void* xf_peer_main_loop(void* arg) { int i; int fds; @@ -530,7 +581,6 @@ void* xf_peer_main_loop(void* arg) void* rfds[32]; fd_set rfds_set; rdpSettings* settings; - char* server_file_path; freerdp_peer* client = (freerdp_peer*) arg; xfPeerContext* xfp; @@ -545,13 +595,7 @@ void* xf_peer_main_loop(void* arg) /* Initialize the real server settings here */ - server_file_path = GetCombinedPath(settings->ConfigPath, "server"); - - if (!PathFileExistsA(server_file_path)) - CreateDirectoryA(server_file_path, 0); - - settings->CertificateFile = GetCombinedPath(server_file_path, "server.crt"); - settings->PrivateKeyFile = GetCombinedPath(server_file_path, "server.key"); + xf_generate_certificate(settings); settings->RemoteFxCodec = TRUE; settings->ColorDepth = 32; @@ -638,8 +682,7 @@ void* xf_peer_main_loop(void* arg) void xf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) { - pthread_t th; + HANDLE thread; - pthread_create(&th, 0, xf_peer_main_loop, client); - pthread_detach(th); + thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_peer_main_loop, client, 0, NULL); } diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index c60baa7ac..0c41e54c0 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -140,6 +140,9 @@ char* GetPath_XDG_CONFIG_HOME() home = GetPath_HOME(); + if (!home) + home = GetPath_TEMP(); + path = (char*) malloc(strlen(home) + strlen("/.config") + 1); sprintf(path, "%s%s", home, "/.config"); diff --git a/winpr/tools/makecert/CMakeLists.txt b/winpr/tools/makecert/CMakeLists.txt index 17b164aae..7663caa18 100644 --- a/winpr/tools/makecert/CMakeLists.txt +++ b/winpr/tools/makecert/CMakeLists.txt @@ -25,7 +25,7 @@ set(${MODULE_PREFIX}_SRCS include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) -add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES} diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c index 0a5538fa9..6b16dc76b 100644 --- a/winpr/tools/makecert/makecert.c +++ b/winpr/tools/makecert/makecert.c @@ -362,6 +362,12 @@ int makecert_context_parse_arguments(MAKECERT_CONTEXT* context, int argc, char** return 1; } +int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, char* name) +{ + context->output_file = _strdup(name); + return 1; +} + int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* path) { FILE* fp; diff --git a/winpr/tools/makecert/makecert.h b/winpr/tools/makecert/makecert.h index b46e5c320..e06154a49 100644 --- a/winpr/tools/makecert/makecert.h +++ b/winpr/tools/makecert/makecert.h @@ -27,6 +27,7 @@ typedef struct _MAKECERT_CONTEXT MAKECERT_CONTEXT; WINPR_API int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv); +WINPR_API int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, char* name); WINPR_API int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* path); WINPR_API int makecert_context_output_private_key_file(MAKECERT_CONTEXT* context, char* path); From e6e5b236dbeaee66c476ba7aac695a89ac802646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 23 Apr 2013 20:01:07 -0400 Subject: [PATCH 027/144] xfreerdp-server: remove thread tick thread --- server/X11/xf_encode.c | 45 ------------------------------------------ server/X11/xf_peer.c | 40 +++++++++++++++---------------------- server/X11/xfreerdp.c | 9 --------- 3 files changed, 16 insertions(+), 78 deletions(-) diff --git a/server/X11/xf_encode.c b/server/X11/xf_encode.c index ca10744c4..3f3096c57 100644 --- a/server/X11/xf_encode.c +++ b/server/X11/xf_encode.c @@ -65,49 +65,6 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int #endif } -void* xf_frame_rate_thread(void* param) -{ - xfInfo* xfi; - HGDI_RGN region; - xfPeerContext* xfp; - freerdp_peer* client; - UINT32 wait_interval; - - client = (freerdp_peer*) param; - xfp = (xfPeerContext*) client->context; - xfi = xfp->info; - - region = xfp->hdc->hwnd->invalid; - wait_interval = 1000000 / xfp->fps; - - while (1) - { - /* check if we should terminate */ - pthread_testcancel(); - - if (!region->null) - { - UINT32 xy, wh; - - pthread_mutex_lock(&(xfp->mutex)); - - xy = (region->x << 16) | region->y; - wh = (region->w << 16) | region->h; - region->null = 1; - - pthread_mutex_unlock(&(xfp->mutex)); - - MessageQueue_Post(xfp->queue, (void*) xfp, - MakeMessageId(PeerEvent, EncodeRegion), - (void*) (size_t) xy, (void*) (size_t) wh); - } - - USleep(wait_interval); - } - - return NULL; -} - void* xf_monitor_updates(void* param) { int fds; @@ -130,8 +87,6 @@ void* xf_monitor_updates(void* param) wait_interval = 1000000 / xfp->fps; ZeroMemory(&timeout, sizeof(struct timeval)); - pthread_create(&(xfp->frame_rate_thread), 0, xf_frame_rate_thread, (void*) client); - while (1) { /* check if we should terminate */ diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 3cda413e0..2d5617e10 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -431,35 +431,25 @@ BOOL xf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) BOOL xf_peer_check_fds(freerdp_peer* client) { xfInfo* xfi; - wMessage message; + HGDI_RGN region; xfPeerContext* xfp; xfp = (xfPeerContext*) client->context; xfi = xfp->info; - if (xfp->activated == FALSE) + if (!xfp->activated) return TRUE; - if (MessageQueue_Peek(xfp->queue, &message, TRUE)) - { - if (message.id == MakeMessageId(PeerEvent, EncodeRegion)) - { - UINT32 xy, wh; - UINT16 x, y, w, h; + region = xfp->hdc->hwnd->invalid; - xy = (UINT32) (size_t) message.wParam; - wh = (UINT32) (size_t) message.lParam; + pthread_mutex_lock(&(xfp->mutex)); - x = ((xy & 0xFFFF0000) >> 16); - y = (xy & 0x0000FFFF); + if ((region->w * region->h) > 0) + xf_peer_rfx_update(client, region->x, region->y, region->w, region->h); - w = ((wh & 0xFFFF0000) >> 16); - h = (wh & 0x0000FFFF); + region->null = 1; - if (w * h > 0) - xf_peer_rfx_update(client, x, y, w, h); - } - } + pthread_mutex_unlock(&(xfp->mutex)); return TRUE; } @@ -583,18 +573,17 @@ static void* xf_peer_main_loop(void* arg) rdpSettings* settings; freerdp_peer* client = (freerdp_peer*) arg; xfPeerContext* xfp; + struct timeval timeout; ZeroMemory(rfds, sizeof(rfds)); + ZeroMemory(&timeout, sizeof(struct timeval)); fprintf(stderr, "We've got a client %s\n", client->hostname); xf_peer_init(client); xfp = (xfPeerContext*) client->context; - settings = client->settings; - /* Initialize the real server settings here */ - xf_generate_certificate(settings); settings->RemoteFxCodec = TRUE; @@ -617,6 +606,7 @@ static void* xf_peer_main_loop(void* arg) fprintf(stderr, "Failed to get FreeRDP file descriptor\n"); break; } + if (xf_peer_get_fds(client, rfds, &rcount) != TRUE) { fprintf(stderr, "Failed to get xfreerdp file descriptor\n"); @@ -639,7 +629,10 @@ static void* xf_peer_main_loop(void* arg) if (max_fds == 0) break; - if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) + timeout.tv_sec = 0; + timeout.tv_usec = 100; + + if (select(max_fds + 1, &rfds_set, NULL, NULL, &timeout) == -1) { /* these are not really errors */ if (!((errno == EAGAIN) || @@ -657,6 +650,7 @@ static void* xf_peer_main_loop(void* arg) fprintf(stderr, "Failed to check freerdp file descriptor\n"); break; } + if ((xf_peer_check_fds(client)) != TRUE) { fprintf(stderr, "Failed to check xfreerdp file descriptor\n"); @@ -669,10 +663,8 @@ static void* xf_peer_main_loop(void* arg) client->Disconnect(client); pthread_cancel(xfp->thread); - pthread_cancel(xfp->frame_rate_thread); pthread_join(xfp->thread, NULL); - pthread_join(xfp->frame_rate_thread, NULL); freerdp_peer_context_free(client); freerdp_peer_free(client); diff --git a/server/X11/xfreerdp.c b/server/X11/xfreerdp.c index 62bd98901..ce89aba0d 100644 --- a/server/X11/xfreerdp.c +++ b/server/X11/xfreerdp.c @@ -33,9 +33,6 @@ #include "xf_peer.h" #include "xfreerdp.h" -char* xf_pcap_file = NULL; -BOOL xf_pcap_dump_realtime = TRUE; - void xf_server_main_loop(freerdp_listener* instance) { int i; @@ -106,12 +103,6 @@ int main(int argc, char* argv[]) instance = freerdp_listener_new(); instance->PeerAccepted = xf_peer_accepted; - if (argc > 1) - xf_pcap_file = argv[1]; - - if (argc > 2 && !strcmp(argv[2], "--fast")) - xf_pcap_dump_realtime = FALSE; - /* Open the server socket and start listening. */ if (instance->Open(instance, NULL, 3389)) { From afd9065cce1062b5c51dfd93b508da25d402c0f4 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Wed, 24 Apr 2013 00:36:48 -0700 Subject: [PATCH 028/144] iOS/Android: Updated version number --- client/Android/aFreeRDP/AndroidManifest.xml.cmake | 2 +- client/iOS/iFreeRDP.plist | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/Android/aFreeRDP/AndroidManifest.xml.cmake b/client/Android/aFreeRDP/AndroidManifest.xml.cmake index ac4f97bcb..751c235b9 100644 --- a/client/Android/aFreeRDP/AndroidManifest.xml.cmake +++ b/client/Android/aFreeRDP/AndroidManifest.xml.cmake @@ -3,7 +3,7 @@ diff --git a/client/iOS/iFreeRDP.plist b/client/iOS/iFreeRDP.plist index 8727f716b..d01a583b8 100644 --- a/client/iOS/iFreeRDP.plist +++ b/client/iOS/iFreeRDP.plist @@ -24,11 +24,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.0.1 CFBundleSignature ???? CFBundleVersion - 0 + 1 LSRequiresIPhoneOS NSMainNibFile From 19acfbd6ee8e4fc782a79951e727978e4b22d325 Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Thu, 25 Apr 2013 12:31:11 +0200 Subject: [PATCH 029/144] iOS: Improved handling of chinese keyboards --- .../iOS/Controllers/RDPSessionViewController.h | 1 + .../iOS/Controllers/RDPSessionViewController.m | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/iOS/Controllers/RDPSessionViewController.h b/client/iOS/Controllers/RDPSessionViewController.h index 996c2915f..0c68386e5 100644 --- a/client/iOS/Controllers/RDPSessionViewController.h +++ b/client/iOS/Controllers/RDPSessionViewController.h @@ -57,6 +57,7 @@ AdvancedKeyboardView* _advanced_keyboard_view; BOOL _advanced_keyboard_visible; BOOL _requesting_advanced_keyboard; + CGFloat _keyboard_height_delta; // delayed mouse move event sending NSTimer* _mouse_move_event_timer; diff --git a/client/iOS/Controllers/RDPSessionViewController.m b/client/iOS/Controllers/RDPSessionViewController.m index c431d8c51..436be3fab 100644 --- a/client/iOS/Controllers/RDPSessionViewController.m +++ b/client/iOS/Controllers/RDPSessionViewController.m @@ -50,7 +50,8 @@ _advanced_keyboard_view = nil; _advanced_keyboard_visible = NO; - _requesting_advanced_keyboard = NO; + _requesting_advanced_keyboard = NO; + _keyboard_height_delta = 0; _session_toolbar_visible = NO; @@ -227,8 +228,7 @@ { for(int i = 0 ; i < [string length] ; i++) { - NSString *characterTyped = [string substringWithRange:NSMakeRange(i, 1)]; - unichar curChar = [characterTyped characterAtIndex:0]; + unichar curChar = [string characterAtIndex:i]; // special handling for return/enter key if(curChar == '\n') @@ -581,14 +581,20 @@ #pragma mark iOS Keyboard Notification Handlers - (void)keyboardWillShow:(NSNotification *)notification -{ +{ CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil]; + + CGFloat newHeightDelta = (keyboardFrame.size.height - _keyboard_height_delta); + if (newHeightDelta < 0.1 && newHeightDelta > -0.1) + return; // nothing changed [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]]; [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; CGRect frame = [_session_scrollview frame]; - frame.size.height -= [[self view] convertRect:keyboardEndFrame toView:nil].size.height; + frame.size.height -= newHeightDelta; + _keyboard_height_delta += newHeightDelta; [_session_scrollview setFrame:frame]; [_touchpointer_view setFrame:frame]; [UIView commitAnimations]; @@ -618,6 +624,7 @@ [_session_scrollview setFrame:frame]; [_touchpointer_view setFrame:frame]; [UIView commitAnimations]; + _keyboard_height_delta = 0; } - (void)keyboardDidHide:(NSNotification*)notification From c0dffd6edfa8d9fee8cc94241de5466276a61b3c Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Thu, 25 Apr 2013 07:30:33 -0700 Subject: [PATCH 030/144] Android: Added SDCard redirection support --- channels/drive/ChannelOptions.cmake | 5 - channels/drive/client/drive_file.c | 6 +- channels/drive/client/drive_file.h | 6 + channels/drive/client/drive_main.c | 8 ++ .../FreeRDPCore/AndroidManifest.xml.cmake | 2 + .../Android/FreeRDPCore/jni/android_freerdp.c | 21 ++- .../Android/FreeRDPCore/jni/android_freerdp.h | 1 + .../jni/generated/android_freerdp_jni.c | 6 + ..._freerdp_freerdpcore_services_LibFreeRDP.h | 8 ++ .../FreeRDPCore/res/values-es/strings.xml | 17 +-- .../FreeRDPCore/res/values-fr/strings.xml | 1 + .../FreeRDPCore/res/values/strings.xml | 1 + .../FreeRDPCore/res/xml/advanced_settings.xml | 1 + .../freerdpcore/domain/BookmarkBase.java | 14 ++ .../services/BookmarkBaseGateway.java | 4 + .../freerdpcore/services/BookmarkDB.java | 123 +++++++++++++----- .../freerdpcore/services/LibFreeRDP.java | 6 + 17 files changed, 185 insertions(+), 45 deletions(-) diff --git a/channels/drive/ChannelOptions.cmake b/channels/drive/ChannelOptions.cmake index 717764cf2..0792c1e47 100644 --- a/channels/drive/ChannelOptions.cmake +++ b/channels/drive/ChannelOptions.cmake @@ -3,11 +3,6 @@ set(OPTION_DEFAULT OFF) set(OPTION_CLIENT_DEFAULT ON) set(OPTION_SERVER_DEFAULT OFF) -if(ANDROID) - set(OPTION_CLIENT_DEFAULT OFF) - set(OPTION_SERVER_DEFAULT OFF) -endif() - define_channel_options(NAME "drive" TYPE "device" DESCRIPTION "Drive Redirection Virtual Channel Extension" SPECIFICATIONS "[MS-RDPEFS]" diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index aa5a3d5f2..e6b206231 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -462,7 +462,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN tv[1].tv_usec = 0; #ifndef WIN32 /* TODO on win32 */ - futimes(file->fd, tv); +#ifdef ANDROID + utimes(file->fullpath, tv); +#else + futimes(file->fd, tv); +#endif if (FileAttributes > 0) { diff --git a/channels/drive/client/drive_file.h b/channels/drive/client/drive_file.h index 60c8cb477..6d90a308a 100644 --- a/channels/drive/client/drive_file.h +++ b/channels/drive/client/drive_file.h @@ -63,6 +63,12 @@ typedef UINT32 mode_t; #define FSTAT fstat #define STATVFS statvfs #define O_LARGEFILE 0 +#elif defined(ANDROID) +#define STAT stat +#define OPEN open +#define LSEEK lseek +#define FSTAT fstat +#define STATVFS statfs #else #define STAT stat64 #define OPEN open64 diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 8e7d1c8a1..23912693d 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -407,7 +407,11 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* stream_write_UINT32(output, 17 + length); /* Length */ stream_check_size(output, 17 + length); stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ +#ifdef ANDROID + stream_write_UINT32(output, svfst.f_fsid.__val[0]); /* VolumeSerialNumber */ +#else stream_write_UINT32(output, svfst.f_fsid); /* VolumeSerialNumber */ +#endif stream_write_UINT32(output, length); /* VolumeLabelLength */ stream_write_BYTE(output, 0); /* SupportsObjects */ /* Reserved(1), MUST NOT be added! */ @@ -434,7 +438,11 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK); /* FileSystemAttributes */ +#ifdef ANDROID + stream_write_UINT32(output, 255); /* MaximumComponentNameLength */ +#else stream_write_UINT32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */ +#endif stream_write_UINT32(output, length); /* FileSystemNameLength */ stream_write(output, outStr, length); /* FileSystemName (Unicode) */ free(outStr); diff --git a/client/Android/FreeRDPCore/AndroidManifest.xml.cmake b/client/Android/FreeRDPCore/AndroidManifest.xml.cmake index 890df2fdd..1632a7c18 100644 --- a/client/Android/FreeRDPCore/AndroidManifest.xml.cmake +++ b/client/Android/FreeRDPCore/AndroidManifest.xml.cmake @@ -9,6 +9,8 @@ + + diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index e93c6b217..215c5518e 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -119,7 +121,8 @@ BOOL android_pre_connect(freerdp* instance) settings->FrameAcknowledge = 10; - freerdp_channels_load_plugin(instance->context->channels, instance->settings, "tsxlc", NULL); + freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0); + freerdp_client_load_addins(instance->context->channels, instance->settings); freerdp_channels_pre_connect(instance->context->channels, instance); @@ -729,6 +732,22 @@ JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls (*env)->ReleaseStringUTFChars(env, jWorkDir, work_dir); } +JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath) +{ + freerdp* inst = (freerdp*)instance; + rdpSettings * settings = inst->settings; + char* args[] = {"drive", "Android", ""}; + + const jbyte *path = (*env)->GetStringUTFChars(env, jpath, NULL); + DEBUG_ANDROID("drive redirect: %s", (char*)path); + + args[2] = (char*)path; + freerdp_client_add_device_channel(settings, 3, args); + settings->DeviceRedirection = TRUE; + + (*env)->ReleaseStringUTFChars(env, jpath, path); +} + void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp) { int i, j; diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index e932220d0..32753ad78 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -42,6 +42,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_connection_info(JNIEnv *env, jclass cls, JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls, jint instance, jboolean remotefx, jboolean disableWallpaper, jboolean disableFullWindowDrag, jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition); JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir); +JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory); JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height); JNIEXPORT void JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags); diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index 308c146cb..b263b1d66 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -70,6 +70,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_set_performance_flags(env, cls, instance, remotefx, disableWallpaper, disableFullWindowDrag, disableMenuAnimations, disableTheming, enableFontSmoothing, enableDesktopComposition); } +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection + (JNIEnv *env, jclass cls, jint inst, jstring path) +{ + jni_freerdp_set_drive_redirection(env, cls, inst, path); +} + JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics( JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height) { diff --git a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h index 17c62cd99..a5c30412b 100644 --- a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h +++ b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h @@ -79,6 +79,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory (JNIEnv *, jclass, jint, jstring); +/* + * Class: com_freerdp_freerdpcore_services_LibFreeRDP + * Method: freerdp_set_drive_redirection + * Signature: (ILjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection + (JNIEnv *, jclass, jint, jstring); + /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_update_graphics diff --git a/client/Android/FreeRDPCore/res/values-es/strings.xml b/client/Android/FreeRDPCore/res/values-es/strings.xml index 2f9d36d8e..93a16bdbf 100644 --- a/client/Android/FreeRDPCore/res/values-es/strings.xml +++ b/client/Android/FreeRDPCore/res/values-es/strings.xml @@ -28,7 +28,7 @@ Conexión Manual Sesiones Activas - Connectarse a iWinCloud + Connect to Computer Login No hay escritorios virtuales @@ -37,13 +37,13 @@ Conexión perdida Contraseña equivocada Usuario Invalido - Agregar escritorio virtual de iWinCloud + Add Connection Host Su nombre IP Puerto - Credenciales de iWinCloud + Credenciales Credenciales Usuario Contraseña @@ -105,6 +105,7 @@ Configuracion 3G Pantalla 3G Rendimiento 3G + Redirect SDCard Seguridad Automatico @@ -141,28 +142,28 @@ Configuración de la conexión Configuración - iWinCloud - iWinCloud para Android + aFreeRDP - aFreeRDP para Android Conexiones RDP Ayuda Sobre Cancelar sin guardar? Pulse el botón "Cancelar" para abortar! \ NPulse "Continuar" para especificar los campos obligatorios! - No se pudo establecer una conexión con iWinCloud! + Failed to establish a connection to the server! Los ajustes de pantalla se han cambiado porque el escritorio virtual no es compatible con la configuración especificada! Eliminado el cache del certificado! No se pudo borrar el caché del certificado! verificar el certificado - La identidad de su escritorio de iWinCloud debe ser verificada. ¿Desea conectarse de todos modos? + The identity of the remote computer cannot be verified. Do you want to connect anyway? Por favor, introduzca sus credenciales Crear acceso directo Nombre corto: Conectando ... Ingresando a ... - Sobre iWinCloud - Version: %1$s\n\u00A9 2012 iWinCloud LLc + Sobre aFreeRDP + Version: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH Guardar configuración de conexión? La configuración de conexión no se han guardado! ¿Quieres guardarlos? Guardar Conexión diff --git a/client/Android/FreeRDPCore/res/values-fr/strings.xml b/client/Android/FreeRDPCore/res/values-fr/strings.xml index 95f3d6490..a55366019 100644 --- a/client/Android/FreeRDPCore/res/values-fr/strings.xml +++ b/client/Android/FreeRDPCore/res/values-fr/strings.xml @@ -104,6 +104,7 @@ "Paramètres 3G" "Écran 3G" "Performance 3G" + "Redirect SDCard" "Securité" "Automatique" diff --git a/client/Android/FreeRDPCore/res/values/strings.xml b/client/Android/FreeRDPCore/res/values/strings.xml index 810127219..774e981d8 100644 --- a/client/Android/FreeRDPCore/res/values/strings.xml +++ b/client/Android/FreeRDPCore/res/values/strings.xml @@ -105,6 +105,7 @@ 3G Settings 3G Screen 3G Performance + Redirect SDCard Security Automatic diff --git a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml index 9158acf16..7fdabd5e6 100644 --- a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml +++ b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml @@ -28,6 +28,7 @@ android:data="preferences://performance_flags_3g" /> + diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java index 12828ffd4..981386b6d 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/BookmarkBase.java @@ -284,6 +284,7 @@ public class BookmarkBase implements Parcelable, Cloneable private boolean enable3GSettings; private ScreenSettings screen3G; private PerformanceFlags performance3G; + private boolean redirectSDCard; private int security; private boolean consoleMode; private String remoteProgram; @@ -297,6 +298,7 @@ public class BookmarkBase implements Parcelable, Cloneable enable3GSettings = (parcel.readInt() == 1) ? true : false; screen3G = parcel.readParcelable(ScreenSettings.class.getClassLoader()); performance3G = parcel.readParcelable(PerformanceFlags.class.getClassLoader()); + redirectSDCard = (parcel.readInt() == 1) ? true : false; security = parcel.readInt(); consoleMode = (parcel.readInt() == 1) ? true : false; remoteProgram = parcel.readString(); @@ -307,6 +309,7 @@ public class BookmarkBase implements Parcelable, Cloneable enable3GSettings = false; screen3G = new ScreenSettings(); performance3G = new PerformanceFlags(); + redirectSDCard = false; security = 0; consoleMode = false; remoteProgram = ""; @@ -337,6 +340,14 @@ public class BookmarkBase implements Parcelable, Cloneable this.performance3G = performance3G; } + public void setRedirectSDCard(boolean redirectSDCard) { + this.redirectSDCard = redirectSDCard; + } + + public boolean getRedirectSDCard() { + return redirectSDCard; + } + public void setSecurity(int security) { this.security = security; } @@ -396,6 +407,7 @@ public class BookmarkBase implements Parcelable, Cloneable out.writeInt(enable3GSettings ? 1 : 0); out.writeParcelable(screen3G, flags); out.writeParcelable(performance3G, flags); + out.writeInt(redirectSDCard ? 1 : 0); out.writeInt(security); out.writeInt(consoleMode ? 1 : 0); out.writeString(remoteProgram); @@ -597,6 +609,7 @@ public class BookmarkBase implements Parcelable, Cloneable editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings.getPerformance3G().getMenuAnimations()); editor.putBoolean("bookmark.perf_themes_3g", advancedSettings.getPerformance3G().getTheming()); + editor.putBoolean("bookmark.redirect_sdcard", advancedSettings.getRedirectSDCard()); editor.putInt("bookmark.security", advancedSettings.getSecurity()); editor.putString("bookmark.remote_program", advancedSettings.getRemoteProgram()); editor.putString("bookmark.work_dir", advancedSettings.getWorkDir()); @@ -638,6 +651,7 @@ public class BookmarkBase implements Parcelable, Cloneable advancedSettings.getPerformance3G().setMenuAnimations(sharedPrefs.getBoolean("bookmark.perf_menu_animation_3g", false)); advancedSettings.getPerformance3G().setTheming(sharedPrefs.getBoolean("bookmark.perf_themes_3g", false)); + advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false)); advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0)); advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", "")); advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", "")); diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java index 6abac51d2..7f6a939b1 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkBaseGateway.java @@ -63,6 +63,7 @@ public abstract class BookmarkBaseGateway values.put("screen_3g", rowid); rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G()); values.put("performance_3g", rowid); + values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard()); values.put("security", bookmark.getAdvancedSettings().getSecurity()); values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode()); values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); @@ -98,6 +99,7 @@ public abstract class BookmarkBaseGateway // update 3G screen and 3G performance settings settings updateScreenSettings3G(db, bookmark); updatePerformanceFlags3G(db, bookmark); + values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard()); values.put("security", bookmark.getAdvancedSettings().getSecurity()); values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode()); values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram()); @@ -216,6 +218,7 @@ public abstract class BookmarkBaseGateway // advanced settings columns.add("enable_3g_settings"); + columns.add("redirect_sdcard"); columns.add("security"); columns.add("console_mode"); columns.add("remote_program"); @@ -273,6 +276,7 @@ public abstract class BookmarkBaseGateway bookmark.getAdvancedSettings().setEnable3GSettings(cursor.getInt(cursor.getColumnIndex("enable_3g_settings")) == 0 ? false : true); readScreenSettings3G(bookmark, cursor); readPerformanceFlags3G(bookmark, cursor); + bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex("redirect_sdcard")) == 0 ? false : true); bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex("security"))); bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex("console_mode")) == 0 ? false : true); bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program"))); diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java index 5d10d7048..61022b470 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java @@ -9,14 +9,20 @@ package com.freerdp.freerdpcore.services; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import android.content.Context; import android.provider.BaseColumns; +import android.util.Log; +import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class BookmarkDB extends SQLiteOpenHelper { - private static final int DB_VERSION = 1; + private static final int DB_VERSION = 2; private static final String DB_NAME = "bookmarks.db"; public static final String ID = BaseColumns._ID; @@ -52,33 +58,7 @@ public class BookmarkDB extends SQLiteOpenHelper db.execSQL(sqlPerformanceFlags); - String sqlManualBookmarks = - "CREATE TABLE tbl_manual_bookmarks (" - + ID + " INTEGER PRIMARY KEY, " - + "label TEXT NOT NULL, " - + "hostname TEXT NOT NULL, " - + "username TEXT NOT NULL, " - + "password TEXT, " - + "domain TEXT, " - + "port TEXT, " - + "screen_settings INTEGER NOT NULL, " - + "performance_flags INTEGER NOT NULL, " - - + "enable_3g_settings INTEGER DEFAULT 0, " - + "screen_3g INTEGER NOT NULL, " - + "performance_3g INTEGER NOT NULL, " - + "security INTEGER, " - + "remote_program TEXT, " - + "work_dir TEXT, " - + "console_mode INTEGER, " - - + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " - + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " - + "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), " - + "FOREIGN KEY(performance_3g) REFERENCES tbl_performance_flags(" + ID + ") " - - + ");"; - + String sqlManualBookmarks = getManualBookmarksCreationString(); db.execSQL(sqlManualBookmarks); @@ -120,6 +100,7 @@ public class BookmarkDB extends SQLiteOpenHelper + "performance_flags, " + "screen_3g, " + "performance_3g, " + + "redirect_sdcard, " + "security, " + "remote_program, " + "work_dir, " @@ -131,12 +112,94 @@ public class BookmarkDB extends SQLiteOpenHelper + "'', " + "'', " + "3389, " - + "1, 1, 2, 2, 0, '', '', 0);"; + + "1, 1, 2, 2, 0, 0, '', '', 0);"; db.execSQL(sqlInsertDefaultSessionEntry); } + private String getManualBookmarksCreationString() + { + return ( + "CREATE TABLE IF NOT EXISTS tbl_manual_bookmarks (" + + ID + " INTEGER PRIMARY KEY, " + + "label TEXT NOT NULL, " + + "hostname TEXT NOT NULL, " + + "username TEXT NOT NULL, " + + "password TEXT, " + + "domain TEXT, " + + "port TEXT, " + + "screen_settings INTEGER NOT NULL, " + + "performance_flags INTEGER NOT NULL, " + + + "enable_3g_settings INTEGER DEFAULT 0, " + + "screen_3g INTEGER NOT NULL, " + + "performance_3g INTEGER NOT NULL, " + + "redirect_sdcard INTEGER, " + + "security INTEGER, " + + "remote_program TEXT, " + + "work_dir TEXT, " + + "console_mode INTEGER, " + + + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " + + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " + + "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), " + + "FOREIGN KEY(performance_3g) REFERENCES tbl_performance_flags(" + ID + ") " + + + ");"); + } + + // from http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) - { + { + db.beginTransaction(); + + // run a table creation with if not exists (we are doing an upgrade, so the table might + // not exists yet, it will fail alter and drop) + db.execSQL(getManualBookmarksCreationString()); + // put in a list the existing columns + List columns = GetColumns(db, "tbl_manual_bookmarks"); + // backup table + db.execSQL("ALTER TABLE tbl_manual_bookmarks RENAME TO 'temp_tbl_manual_bookmarks'"); + // create new table (with new scheme) + db.execSQL(getManualBookmarksCreationString()); + // get the intersection with the new columns, this time columns taken from the upgraded table + columns.retainAll(GetColumns(db, "tbl_manual_bookmarks")); + // restore data + String cols = joinStrings(columns, ","); + db.execSQL(String.format("INSERT INTO %s (%s) SELECT %s from 'temp_%s", "tbl_manual_bookmarks", cols, cols, "tbl_manual_bookmarks'")); + // remove backup table + db.execSQL("DROP table 'temp_tbl_manual_bookmarks'"); + + db.setTransactionSuccessful(); + db.endTransaction(); } + + private static List GetColumns(SQLiteDatabase db, String tableName) { + List ar = null; + Cursor c = null; + try { + c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null); + if (c != null) { + ar = new ArrayList(Arrays.asList(c.getColumnNames())); + } + } catch (Exception e) { + Log.v(tableName, e.getMessage(), e); + e.printStackTrace(); + } finally { + if (c != null) + c.close(); + } + return ar; + } + + private static String joinStrings(List list, String delim) { + StringBuilder buf = new StringBuilder(); + int num = list.size(); + for (int i = 0; i < num; i++) { + if (i != 0) + buf.append(delim); + buf.append((String) list.get(i)); + } + return buf.toString(); + } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java index 8fec00aa7..248e9ac6f 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -39,6 +39,8 @@ public class LibFreeRDP private static native void freerdp_set_data_directory(int inst, String directory); + private static native void freerdp_set_drive_redirection(int inst, String path); + private static native boolean freerdp_update_graphics(int inst, Bitmap bitmap, int x, int y, int width, int height); @@ -143,6 +145,10 @@ public class LibFreeRDP BookmarkBase.AdvancedSettings advancedSettings = bookmark.getAdvancedSettings(); freerdp_set_advanced_settings(inst, advancedSettings.getRemoteProgram(), advancedSettings.getWorkDir()); + // drive redirection enabled? + if (advancedSettings.getRedirectSDCard()) + freerdp_set_drive_redirection(inst, android.os.Environment.getExternalStorageDirectory().getPath()); + return true; } From fc3f75d867d42654b30b2735281ee6d2b5ea1daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 25 Apr 2013 17:00:43 -0400 Subject: [PATCH 031/144] xfreerdp: start experimenting with multitouch --- client/X11/CMakeLists.txt | 11 ++++++ client/X11/xf_window.c | 73 +++++++++++++++++++++++++++++++++++++++ cmake/FindXi.cmake | 46 ++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 cmake/FindXi.cmake diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 7d08ea670..2f833ed9d 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -94,11 +94,16 @@ set(XV_FEATURE_TYPE "RECOMMENDED") set(XV_FEATURE_PURPOSE "video") set(XV_FEATURE_DESCRIPTION "X11 video extension") +set(XI_FEATURE_TYPE "RECOMMENDED") +set(XI_FEATURE_PURPOSE "input") +set(XI_FEATURE_DESCRIPTION "X11 input extension") + find_feature(XShm ${XSHM_FEATURE_TYPE} ${XSHM_FEATURE_PURPOSE} ${XSHM_FEATURE_DESCRIPTION}) find_feature(Xinerama ${XINERAMA_FEATURE_TYPE} ${XINERAMA_FEATURE_PURPOSE} ${XINERAMA_FEATURE_DESCRIPTION}) find_feature(Xext ${XEXT_FEATURE_TYPE} ${XEXT_FEATURE_PURPOSE} ${XEXT_FEATURE_DESCRIPTION}) find_feature(Xcursor ${XCURSOR_FEATURE_TYPE} ${XCURSOR_FEATURE_PURPOSE} ${XCURSOR_FEATURE_DESCRIPTION}) find_feature(Xv ${XV_FEATURE_TYPE} ${XV_FEATURE_PURPOSE} ${XV_FEATURE_DESCRIPTION}) +find_feature(Xi ${XI_FEATURE_TYPE} ${XI_FEATURE_PURPOSE} ${XI_FEATURE_DESCRIPTION}) if(WITH_XINERAMA) add_definitions(-DWITH_XINERAMA) @@ -124,6 +129,12 @@ if(WITH_XV) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XV_LIBRARIES}) endif() +if(WITH_XI) + add_definitions(-DWITH_XI) + include_directories(${XI_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XI_LIBRARIES}) +endif() + include_directories(${CMAKE_SOURCE_DIR}/resources) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index fd6631c33..46f5507af 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -42,6 +42,10 @@ #include #endif +#ifdef WITH_XI +#include +#endif + #ifdef WITH_DEBUG_X11 #define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__) #else @@ -319,6 +323,73 @@ static void xf_SetWindowPID(xfInfo* xfi, xfWindow* window, pid_t pid) 32, PropModeReplace, (unsigned char *)&pid, 1); } +int xf_input_init(xfInfo* xfi, Window window) +{ + int i, j; + int ndevices; + int major = 2; + int minor = 2; + Status xstatus; + XIEventMask evmask; + XIDeviceInfo* info; + int opcode, event, error; + XIGrabModifiers mods = { 1 }; + unsigned char mask[XIMaskLen(XI_LASTEVENT)]; + + if (!XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error)) + { + printf("XInput extension not available.\n"); + return -1; + } + + XIQueryVersion(xfi->display, &major, &minor); + + if (major * 1000 + minor < 2002) + { + printf("Server does not support XI 2.2\n"); + return -1; + } + + info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices); + + for (i = 0; i < ndevices; i++) + { + XIDeviceInfo* dev = &info[i]; + + for (j = 0; j < dev->num_classes; j++) + { + XIAnyClassInfo* class = dev->classes[j]; + XITouchClassInfo* t = (XITouchClassInfo*) class; + + if (class->type != XITouchClass) + continue; + + printf("%s %s touch device, supporting %d touches.\n", + dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); + } + } + + evmask.mask = mask; + evmask.mask_len = sizeof(mask); + ZeroMemory(mask, sizeof(mask)); + evmask.deviceid = XIAllDevices; + + XISetMask(mask, XI_TouchBegin); + XISetMask(mask, XI_TouchUpdate); + XISetMask(mask, XI_TouchEnd); + + xstatus = XISelectEvents(xfi->display, window, &evmask, 1); + //XIClearMask(mask, XI_TouchOwnership); + + mods.modifiers = XIAnyModifier; + + //XIGrabTouchBegin(xfi->display, XIAllMasterDevices, window, XINoOwnerEvents, &evmask, 1, &mods); + + XSync(xfi->display, False); + + return -1; +} + xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, BOOL decorations) { xfWindow* window; @@ -403,6 +474,8 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, XClearWindow(xfi->display, window->handle); XMapWindow(xfi->display, window->handle); + xf_input_init(xfi, window->handle); + /* * NOTE: This must be done here to handle reparenting the window, * so that we don't miss the event and hang waiting for the next one diff --git a/cmake/FindXi.cmake b/cmake/FindXi.cmake new file mode 100644 index 000000000..80bcdd694 --- /dev/null +++ b/cmake/FindXi.cmake @@ -0,0 +1,46 @@ +# - Find Xi +# Find the Xi libraries +# +# This module defines the following variables: +# XI_FOUND - true if XI_INCLUDE_DIR & XI_LIBRARY are found +# XI_LIBRARIES - Set when XI_LIBRARY is found +# XI_INCLUDE_DIRS - Set when XI_INCLUDE_DIR is found +# +# XI_INCLUDE_DIR - where to find XInput2.h, etc. +# XI_LIBRARY - the Xi library +# + +#============================================================================= +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# 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. +#============================================================================= + +find_path(XI_INCLUDE_DIR NAMES X11/extensions/XInput2.h + DOC "The Xi include directory") + +find_library(XI_LIBRARY NAMES Xi + DOC "The Xi library") + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xi DEFAULT_MSG XI_LIBRARY XI_INCLUDE_DIR) + +if(XI_FOUND) + set(XI_LIBRARIES ${XI_LIBRARY}) + set(XI_INCLUDE_DIRS ${XI_INCLUDE_DIR}) +endif() + +mark_as_advanced(XI_INCLUDE_DIR XI_LIBRARY) + From a1708572bacdbdc06d627cf340bad047cb24018a Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Fri, 26 Apr 2013 05:59:16 -0700 Subject: [PATCH 032/144] Android: Added clipboard redirection support --- client/Android/FreeRDPCore/jni/CMakeLists.txt | 8 + .../Android/FreeRDPCore/jni/android_cliprdr.c | 619 ++++++++++++++++++ .../Android/FreeRDPCore/jni/android_cliprdr.h | 30 + .../Android/FreeRDPCore/jni/android_event.c | 37 ++ .../Android/FreeRDPCore/jni/android_event.h | 11 + .../Android/FreeRDPCore/jni/android_freerdp.c | 148 +---- .../Android/FreeRDPCore/jni/android_freerdp.h | 4 + .../FreeRDPCore/jni/android_jni_utils.c | 211 ++++++ .../FreeRDPCore/jni/android_jni_utils.h | 34 + .../jni/generated/android_freerdp_jni.c | 12 + ..._freerdp_freerdpcore_services_LibFreeRDP.h | 16 + client/Android/FreeRDPCore/project.properties | 2 +- .../presentation/SessionActivity.java | 30 +- .../freerdpcore/services/LibFreeRDP.java | 25 +- .../utils/ClipboardManagerProxy.java | 89 +++ client/Android/aFreeRDP/project.properties | 2 +- 16 files changed, 1157 insertions(+), 121 deletions(-) create mode 100644 client/Android/FreeRDPCore/jni/android_cliprdr.c create mode 100644 client/Android/FreeRDPCore/jni/android_cliprdr.h create mode 100644 client/Android/FreeRDPCore/jni/android_jni_utils.c create mode 100644 client/Android/FreeRDPCore/jni/android_jni_utils.h create mode 100644 client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java diff --git a/client/Android/FreeRDPCore/jni/CMakeLists.txt b/client/Android/FreeRDPCore/jni/CMakeLists.txt index 58d96f6c7..5aec24ef1 100644 --- a/client/Android/FreeRDPCore/jni/CMakeLists.txt +++ b/client/Android/FreeRDPCore/jni/CMakeLists.txt @@ -33,6 +33,8 @@ set(${MODULE_PREFIX}_SRCS android_event.h android_freerdp.c android_freerdp.h + android_jni_utils.c + android_jni_utils.h android_jni_callback.c android_jni_callback.h) @@ -40,6 +42,12 @@ set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} generated/android_freerdp_jni.c generated/android_freerdp_jni.h) +if(WITH_CLIENT_CHANNELS) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} + android_cliprdr.c + android_cliprdr.h) +endif() + add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS}) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) diff --git a/client/Android/FreeRDPCore/jni/android_cliprdr.c b/client/Android/FreeRDPCore/jni/android_cliprdr.c new file mode 100644 index 000000000..1c62d2b4c --- /dev/null +++ b/client/Android/FreeRDPCore/jni/android_cliprdr.c @@ -0,0 +1,619 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Android Clipboard Redirection + * + * Copyright 2013 Felix Long + * + * 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 +#include + +#include +#include + +#include +#include +#include + +#include "android_debug.h" +#include "android_cliprdr.h" +#include "android_jni_utils.h" +#include "android_jni_callback.h" + +typedef struct clipboard_context clipboardContext; +struct clipboard_context +{ + freerdp* instance; + rdpChannels* channels; + + /* server->client data */ + UINT32* formats; + int num_formats; + BYTE* data; + UINT32 data_format; + int data_length; + + /* client->server data */ + UINT32* android_formats; + int android_num_formats; + BYTE* android_data; + int android_data_length; +}; + +static BYTE* lf2crlf(BYTE* data, int* size) +{ + BYTE c; + BYTE* outbuf; + BYTE* out; + BYTE* in_end; + BYTE* in; + int out_size; + + out_size = (*size) * 2 + 1; + outbuf = (BYTE*) malloc(out_size); + ZeroMemory(outbuf, out_size); + + out = outbuf; + in = data; + in_end = data + (*size); + + while (in < in_end) + { + c = *in++; + if (c == '\n') + { + *out++ = '\r'; + *out++ = '\n'; + } + else + { + *out++ = c; + } + } + + *out++ = 0; + *size = out - outbuf; + + return outbuf; +} + +static void crlf2lf(BYTE* data, int* size) +{ + BYTE c; + BYTE* out; + BYTE* in; + BYTE* in_end; + + out = data; + in = data; + in_end = data + (*size); + + while (in < in_end) + { + c = *in++; + + if (c != '\r') + *out++ = c; + } + + *size = out - data; +} + +static void be2le(BYTE* data, int size) +{ + BYTE c; + + while (size >= 2) + { + c = data[0]; + data[0] = data[1]; + data[1] = c; + + data += 2; + size -= 2; + } +} + +void android_cliprdr_init(freerdp* inst) +{ + androidContext* ctx = (androidContext*)inst->context; + clipboardContext* cb; + + cb = (clipboardContext*)malloc(sizeof(clipboardContext)); + ZeroMemory(cb, sizeof(clipboardContext)); + cb->instance = inst; + cb->channels = inst->context->channels; + + cb->android_formats = (UINT32*)malloc(sizeof(UINT32) * 3); + cb->android_formats[0] = CB_FORMAT_TEXT; + cb->android_formats[1] = CB_FORMAT_UNICODETEXT; + cb->android_formats[2] = CB_FORMAT_HTML; + cb->android_num_formats = 3; + +#if 0 + cb->android_data = strdup("ANDROID_CLIPBOARD_TEST"); + cb->android_data_length = strlen(cb->android_data); +#endif + + ctx->clipboard_context = cb; +} + +void android_cliprdr_uninit(freerdp* inst) +{ + androidContext* ctx = (androidContext*)inst->context; + clipboardContext* cb = (clipboardContext*)ctx->clipboard_context; + + if (cb) + { + if (cb->formats) + free(cb->formats); + if (cb->data) + free(cb->data); + if (cb->android_formats) + free(cb->android_formats); + if (cb->android_data) + free(cb->android_data); + free(cb); + ctx->clipboard_context = NULL; + } +} + +static void android_cliprdr_send_null_format_list(clipboardContext* cb) +{ + RDP_CB_FORMAT_LIST_EVENT* event; + + event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class, + CliprdrChannel_FormatList, NULL, NULL); + + event->num_formats = 0; + + freerdp_channels_send_event(cb->channels, (wMessage*) event); +} + +static void android_cliprdr_send_supported_format_list(clipboardContext* cb) +{ + int i; + RDP_CB_FORMAT_LIST_EVENT* event; + + event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class, + CliprdrChannel_FormatList, NULL, NULL); + + event->formats = (UINT32*) malloc(sizeof(UINT32) * cb->android_num_formats); + event->num_formats = cb->android_num_formats; + + for (i = 0; i < cb->android_num_formats; i++) + { + event->formats[i] = cb->android_formats[i]; + } + + freerdp_channels_send_event(cb->channels, (wMessage*) event); +} + +static void android_cliprdr_send_format_list(clipboardContext* cb) +{ + if (cb->android_data) + { + android_cliprdr_send_supported_format_list(cb); + } + else + { + android_cliprdr_send_null_format_list(cb); + } +} + +static void android_cliprdr_send_data_request(clipboardContext* cb, UINT32 format) +{ + RDP_CB_DATA_REQUEST_EVENT* event; + + event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class, + CliprdrChannel_DataRequest, NULL, NULL); + + event->format = format; + + freerdp_channels_send_event(cb->channels, (wMessage*) event); +} + +static void android_cliprdr_send_data_response(clipboardContext* cb, BYTE* data, int size) +{ + RDP_CB_DATA_RESPONSE_EVENT* event; + + event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(CliprdrChannel_Class, + CliprdrChannel_DataResponse, NULL, NULL); + + event->data = data; + event->size = size; + + freerdp_channels_send_event(cb->channels, (wMessage*) event); +} + +static void android_cliprdr_send_null_data_response(clipboardContext* cb) +{ + android_cliprdr_send_data_response(cb, NULL, 0); +} + +static void android_cliprdr_process_cb_monitor_ready_event(clipboardContext* cb) +{ + android_cliprdr_send_format_list(cb); +} + +static BYTE* android_cliprdr_process_requested_unicodetext(BYTE* data, int* size) +{ + char* inbuf; + WCHAR* outbuf = NULL; + int out_size; + + inbuf = (char*) lf2crlf(data, size); + out_size = ConvertToUnicode(CP_UTF8, 0, inbuf, -1, &outbuf, 0); + free(inbuf); + + *size = (int) ((out_size + 1) * 2); + + return (BYTE*) outbuf; +} + +static BYTE* android_cliprdr_process_requested_text(BYTE* data, int* size) +{ + BYTE* outbuf; + + outbuf = lf2crlf(data, size); + + return outbuf; +} + +static BYTE* android_cliprdr_process_requested_html(BYTE* data, int* size) +{ + char* inbuf; + BYTE* in; + BYTE* outbuf; + char num[11]; + + inbuf = NULL; + + if (*size > 2) + { + if ((BYTE) data[0] == 0xFE && (BYTE) data[1] == 0xFF) + { + be2le(data, *size); + } + + if ((BYTE) data[0] == 0xFF && (BYTE) data[1] == 0xFE) + { + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) (data + 2), (*size - 2) / 2, &inbuf, 0, NULL, NULL); + } + } + + if (inbuf == NULL) + { + inbuf = malloc(*size + 1); + ZeroMemory(inbuf, *size + 1); + + memcpy(inbuf, data, *size); + } + + outbuf = (BYTE*) malloc(*size + 200); + ZeroMemory(outbuf, *size + 200); + + strcpy((char*) outbuf, + "Version:0.9\r\n" + "StartHTML:0000000000\r\n" + "EndHTML:0000000000\r\n" + "StartFragment:0000000000\r\n" + "EndFragment:0000000000\r\n"); + + in = (BYTE*) strstr((char*) inbuf, ""); + } + strcat((char*) outbuf, ""); + /* StartFragment */ + snprintf(num, sizeof(num), "%010lu", (unsigned long) strlen((char*) outbuf)); + memcpy(outbuf + 69, num, 10); + strcat((char*) outbuf, (char*) inbuf); + /* EndFragment */ + snprintf(num, sizeof(num), "%010lu", (unsigned long) strlen((char*) outbuf)); + memcpy(outbuf + 93, num, 10); + strcat((char*) outbuf, ""); + if (in == NULL) + { + strcat((char*) outbuf, ""); + } + /* EndHTML */ + snprintf(num, sizeof(num), "%010lu", (unsigned long) strlen((char*) outbuf)); + memcpy(outbuf + 43, num, 10); + + *size = strlen((char*) outbuf) + 1; + free(inbuf); + + return outbuf; +} + +static void android_cliprdr_process_cb_data_request_event(clipboardContext* cb, RDP_CB_DATA_REQUEST_EVENT* event) +{ + int i; + + DEBUG_ANDROID("format %d", event->format); + + for(i = 0; i < cb->android_num_formats; i++) + { + if (event->format == cb->android_formats[i]) + break; + } + + if (i >= cb->android_num_formats) + { + DEBUG_ANDROID("unsupported format requested"); + android_cliprdr_send_null_data_response(cb); + } + else if (!cb->android_data) + { + DEBUG_ANDROID("no android clipdata"); + android_cliprdr_send_null_data_response(cb); + } + else + { + BYTE* outbuf; + int size = cb->android_data_length; + + switch (event->format) + { + case CB_FORMAT_RAW: + case CB_FORMAT_PNG: + case CB_FORMAT_JPEG: + case CB_FORMAT_GIF: + case CB_FORMAT_DIB: + default: + DEBUG_ANDROID("unsupported format %x\n", event->format); + outbuf = NULL; + break; + + case CB_FORMAT_UNICODETEXT: + outbuf = android_cliprdr_process_requested_unicodetext(cb->android_data, &size); + break; + + case CB_FORMAT_TEXT: + outbuf = android_cliprdr_process_requested_text(cb->android_data, &size); + break; + + case CB_FORMAT_HTML: + outbuf = android_cliprdr_process_requested_html(cb->android_data, &size); + break; + } + if (outbuf) + android_cliprdr_send_data_response(cb, outbuf, size); + else + android_cliprdr_send_null_data_response(cb); + } + + /* Resend the format list, otherwise the server won't request again for the next paste */ + android_cliprdr_send_format_list(cb); +} + +static BOOL android_cliprdr_has_format(UINT32* formats, int num_formats, UINT32 format) +{ + int i; + for(i = 0; i < num_formats; i++) + { + if (formats[i] == format) + return TRUE; + } + return FALSE; +} + +static void android_cliprdr_process_cb_format_list_event(clipboardContext* cb, RDP_CB_FORMAT_LIST_EVENT* event) +{ + if (cb->data) + { + free(cb->data); + cb->data = NULL; + cb->data_length = 0; + } + + if (cb->formats) + free(cb->formats); + + cb->data_format = CB_FORMAT_RAW; + cb->formats = event->formats; + cb->num_formats = event->num_formats; + event->formats = NULL; + event->num_formats = 0; + + if (android_cliprdr_has_format(cb->formats, cb->num_formats, CB_FORMAT_TEXT)) + { + cb->data_format = CB_FORMAT_TEXT; + android_cliprdr_send_data_request(cb, CB_FORMAT_TEXT); + } + else if (android_cliprdr_has_format(cb->formats, cb->num_formats, CB_FORMAT_UNICODETEXT)) + { + cb->data_format = CB_FORMAT_UNICODETEXT; + android_cliprdr_send_data_request(cb, CB_FORMAT_UNICODETEXT); + } + else if (android_cliprdr_has_format(cb->formats, cb->num_formats, CB_FORMAT_HTML)) + { + cb->data_format = CB_FORMAT_HTML; + android_cliprdr_send_data_request(cb, CB_FORMAT_HTML); + } +} + +static void android_cliprdr_process_text(clipboardContext* cb, BYTE* data, int size) +{ + if (size > 0 && data) + { + cb->data = (BYTE*) malloc(size + 1); + memcpy(cb->data, data, size); + cb->data[size] = 0; + cb->data_length = size; + } +} + +static void android_cliprdr_process_unicodetext(clipboardContext* cb, BYTE* data, int size) +{ + cb->data_length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) data, size / 2, (CHAR**) &(cb->data), 0, NULL, NULL); + crlf2lf(cb->data, &cb->data_length); +} + +static void android_cliprdr_process_html(clipboardContext* cb, BYTE* data, int size) +{ + char* start_str; + char* end_str; + int start; + int end; + + start_str = strstr((char*) data, "StartHTML:"); + end_str = strstr((char*) data, "EndHTML:"); + if (start_str == NULL || end_str == NULL) + { + DEBUG_ANDROID("invalid HTML clipboard format"); + return; + } + start = atoi(start_str + 10); + end = atoi(end_str + 8); + if (start > size || end > size || start >= end) + { + DEBUG_ANDROID("invalid HTML offset"); + return; + } + + cb->data = (BYTE*) malloc(end - start + 1); + memcpy(cb->data, data + start, end - start); + cb->data[end - start] = 0; + cb->data_length = end - start; +} + +static void android_cliprdr_process_cb_data_response_event(clipboardContext* cb, RDP_CB_DATA_RESPONSE_EVENT* event) +{ + DEBUG_ANDROID("size=%d", event->size); + + if (event->size > 0) + { + if (cb->data) + { + free(cb->data); + cb->data = NULL; + cb->data_length = 0; + } + switch (cb->data_format) + { + case CB_FORMAT_RAW: + case CB_FORMAT_PNG: + case CB_FORMAT_JPEG: + case CB_FORMAT_GIF: + case CB_FORMAT_DIB: + default: + DEBUG_ANDROID("unsupported format\n"); + break; + + case CB_FORMAT_TEXT: + android_cliprdr_process_text(cb, event->data, event->size - 1); + break; + + case CB_FORMAT_UNICODETEXT: + android_cliprdr_process_unicodetext(cb, event->data, event->size - 2); + break; + + case CB_FORMAT_HTML: + android_cliprdr_process_html(cb, event->data, event->size); + break; + } + DEBUG_ANDROID("computer_clipboard_data %s ", (char*)cb->data); + if (cb->data) + { //CALLBACK + JNIEnv* env; + jboolean attached = jni_attach_thread(&env); + jstring jdata = jniNewStringUTF(env, cb->data, cb->data_length); + + freerdp_callback("OnRemoteClipboardChanged", "(ILjava/lang/String;)V", cb->instance, jdata); + + (*env)->DeleteLocalRef(env, jdata); + if(attached == JNI_TRUE) + { + jni_detach_thread(); + } + } + } +} + +void android_process_cliprdr_event(freerdp* inst, wMessage* event) +{ + androidContext* ctx = (androidContext*)inst->context; + clipboardContext* cb = (clipboardContext*) ctx->clipboard_context; + + if (!cb) + { + return; + } + + switch (GetMessageType(event->id)) + { + case CliprdrChannel_MonitorReady: + android_cliprdr_process_cb_monitor_ready_event(cb); + break; + + case CliprdrChannel_FormatList: + android_cliprdr_process_cb_format_list_event(cb, (RDP_CB_FORMAT_LIST_EVENT*) event); + break; + + case CliprdrChannel_DataRequest: + android_cliprdr_process_cb_data_request_event(cb, (RDP_CB_DATA_REQUEST_EVENT*) event); + break; + + case CliprdrChannel_DataResponse: + android_cliprdr_process_cb_data_response_event(cb, (RDP_CB_DATA_RESPONSE_EVENT*) event); + break; + + default: + DEBUG_ANDROID("unknown event type %d", event->event_type); + break; + } +} + +void android_process_cliprdr_send_clipboard_data(freerdp* inst, void* data, int len) +{ + androidContext* ctx = (androidContext*)inst->context; + clipboardContext* cb = (clipboardContext*) ctx->clipboard_context; + + DEBUG_ANDROID("android_clipboard_data %s ", (char*)data); + + if (cb && (data == NULL || cb->android_data == NULL || len != cb->android_data_length || memcmp(data, cb->android_data, len))) + { + if (cb->android_data) + { + free(cb->android_data); + cb->android_data = NULL; + cb->android_data_length = 0; + } + if (data) + { + cb->android_data = (BYTE*)malloc(len + 1); + memcpy(cb->android_data, data, len); + cb->android_data[len] = 0; + cb->android_data_length = len; + } + android_cliprdr_send_format_list(cb); + } +} + diff --git a/client/Android/FreeRDPCore/jni/android_cliprdr.h b/client/Android/FreeRDPCore/jni/android_cliprdr.h new file mode 100644 index 000000000..233bff380 --- /dev/null +++ b/client/Android/FreeRDPCore/jni/android_cliprdr.h @@ -0,0 +1,30 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Android Clipboard Redirection + * + * Copyright 2013 Felix Long + * + * 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 __ANDROID_CLIPRDR_H__ +#define __ANDROID_CLIPRDR_H__ + +#include "android_freerdp.h" + +void android_cliprdr_init(freerdp* inst); +void android_cliprdr_uninit(freerdp* inst); +void android_process_cliprdr_send_clipboard_data(freerdp* inst, void* data, int len); +void android_process_cliprdr_event(freerdp* inst, wMessage* event); + +#endif /* __ANDROID_CLIPRDR_H__ */ diff --git a/client/Android/FreeRDPCore/jni/android_event.c b/client/Android/FreeRDPCore/jni/android_event.c index bb0f55bb1..c25582cfc 100644 --- a/client/Android/FreeRDPCore/jni/android_event.c +++ b/client/Android/FreeRDPCore/jni/android_event.c @@ -26,6 +26,7 @@ #endif #include "android_freerdp.h" +#include "android_cliprdr.h" int android_is_event_set(ANDROID_EVENT_QUEUE * queue) { @@ -137,6 +138,12 @@ int android_process_event(ANDROID_EVENT_QUEUE * queue, freerdp * inst) inst->input->MouseEvent(inst->input, cursor_event->flags, cursor_event->x, cursor_event->y); android_event_cursor_free(cursor_event); } + else if (event->type == EVENT_TYPE_CLIPBOARD) + { + ANDROID_EVENT_CLIPBOARD* clipboard_event = (ANDROID_EVENT_CLIPBOARD*)event; + android_process_cliprdr_send_clipboard_data(inst, clipboard_event->data, clipboard_event->data_length); + android_event_clipboard_free(clipboard_event); + } else if (event->type == EVENT_TYPE_DISCONNECT) { android_event_disconnect_free(event); @@ -254,6 +261,36 @@ void android_event_disconnect_free(ANDROID_EVENT* event) free(event); } +ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length) +{ + ANDROID_EVENT_CLIPBOARD* event; + + event = (ANDROID_EVENT_CLIPBOARD*) malloc(sizeof(ANDROID_EVENT_CLIPBOARD)); + memset(event, 0, sizeof(ANDROID_EVENT_CLIPBOARD)); + + event->type = EVENT_TYPE_CLIPBOARD; + if (data) + { + event->data = malloc(data_length); + memcpy(event->data, data, data_length); + event->data_length = data_length; + } + + return event; +} + +void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event) +{ + if (event != NULL) + { + if (event->data) + { + free(event->data); + } + free(event); + } +} + void android_event_queue_init(freerdp * inst) { androidContext* aCtx = (androidContext*)inst->context; diff --git a/client/Android/FreeRDPCore/jni/android_event.h b/client/Android/FreeRDPCore/jni/android_event.h index 7a3b6e599..7872ec770 100644 --- a/client/Android/FreeRDPCore/jni/android_event.h +++ b/client/Android/FreeRDPCore/jni/android_event.h @@ -17,6 +17,7 @@ #define EVENT_TYPE_CURSOR 2 #define EVENT_TYPE_DISCONNECT 3 #define EVENT_TYPE_KEY_UNICODE 4 +#define EVENT_TYPE_CLIPBOARD 5 struct _ANDROID_EVENT { @@ -41,6 +42,14 @@ struct _ANDROID_EVENT_CURSOR }; typedef struct _ANDROID_EVENT_CURSOR ANDROID_EVENT_CURSOR; +struct _ANDROID_EVENT_CLIPBOARD +{ + int type; + void* data; + int data_length; +}; +typedef struct _ANDROID_EVENT_CLIPBOARD ANDROID_EVENT_CLIPBOARD; + struct _ANDROID_EVENT_QUEUE { int size; @@ -64,10 +73,12 @@ ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode); ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key); ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y); ANDROID_EVENT* android_event_disconnect_new(void); +ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length); void android_event_key_free(ANDROID_EVENT_KEY* event); void android_event_unicodekey_free(ANDROID_EVENT_KEY* event); void android_event_cursor_free(ANDROID_EVENT_CURSOR* event); void android_event_disconnect_free(ANDROID_EVENT* event); +void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event); void android_event_queue_init(freerdp * inst); void android_event_queue_uninit(freerdp * inst); diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 215c5518e..10aa20926 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -28,11 +27,12 @@ #include #include -#include #include "android_freerdp.h" #include "android_jni_callback.h" +#include "android_jni_utils.h" #include "android_debug.h" +#include "android_cliprdr.h" struct thread_data { @@ -143,10 +143,7 @@ BOOL android_post_connect(freerdp* instance) instance->update->EndPaint = android_end_paint; instance->update->DesktopResize = android_desktop_resize; - //ai->rail = rail_new(instance->settings); - //instance->update->rail = (void*) ai->rail; - //rail_register_update_callbacks(xfi->rail, instance->update); - //android_rail_register_callbacks(xfi, xfi->rail); + android_cliprdr_init(instance); freerdp_channels_post_connect(instance->context->channels, instance); @@ -156,74 +153,6 @@ BOOL android_post_connect(freerdp* instance) return TRUE; } -jobject create_string_builder(JNIEnv *env, char* initialStr) -{ - jclass cls; - jmethodID methodId; - jobject obj; - - // get class - cls = (*env)->FindClass(env, "java/lang/StringBuilder"); - if(!cls) - return NULL; - - if(initialStr) - { - // get method id for constructor - methodId = (*env)->GetMethodID(env, cls, "", "(Ljava/lang/String;)V"); - if(!methodId) - return NULL; - - // create string that holds our initial string - jstring jstr = (*env)->NewStringUTF(env, initialStr); - - // construct new StringBuilder - obj = (*env)->NewObject(env, cls, methodId, jstr); - } - else - { - // get method id for constructor - methodId = (*env)->GetMethodID(env, cls, "", "()V"); - if(!methodId) - return NULL; - - // construct new StringBuilder - obj = (*env)->NewObject(env, cls, methodId); - } - - return obj; -} - -char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder) -{ - jclass cls; - jmethodID methodId; - jstring strObj; - const jbyte* native_str; - char* result; - - // get class - cls = (*env)->FindClass(env, "java/lang/StringBuilder"); - if(!cls) - return NULL; - - // get method id for constructor - methodId = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); - if(!methodId) - return NULL; - - // get jstring representation of our buffer - strObj = (*env)->CallObjectMethod(env, strBuilder, methodId); - - // read string - native_str = (*env)->GetStringUTFChars(env, strObj, NULL); - result = strdup(native_str); - (*env)->ReleaseStringUTFChars(env, strObj, native_str); - - return result; -} - - BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain) { DEBUG_ANDROID("Authenticate user:"); @@ -291,19 +220,6 @@ BOOL android_verify_changed_certificate(freerdp* instance, char* subject, char* return android_verify_certificate(instance, subject, issuer, new_fingerprint); } - -/* -int xf_process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data) -{ - rdpChanMan* chanman = (rdpChanMan*) user_data; - - printf("loading plugin %s\n", name); - freerdp_chanman_load_plugin(chanman, settings, name, plugin_data); - - return 1; -} -*/ - int android_receive_channel_data(freerdp* instance, int channelId, UINT8* data, int size, int flags, int total_size) { return freerdp_channels_data(instance, channelId, data, size, flags, total_size); @@ -317,25 +233,16 @@ void android_process_channel_event(rdpChannels* channels, freerdp* instance) if (event) { -/* switch (event->event_class) + switch(GetMessageClass(event->id)) { - case RailChannel_Class: - xf_process_rail_event(ai, chanman, event); + case CliprdrChannel_Class: + android_process_cliprdr_event(instance, event); break; default: break; } - switch (event->event_type) - { - case RDP_EVENT_TYPE_CB_SYNC: - android_process_cb_sync_event(chanman, instance); - break; - default: - break; - } -*/ freerdp_event_free(event); } } @@ -437,6 +344,7 @@ int android_freerdp_run(freerdp* instance) freerdp_disconnect(instance); gdi_free(instance); cache_free(instance->context->cache); + android_cliprdr_uninit(instance); freerdp_callback("OnDisconnected", "(I)V", instance); return 0; @@ -456,20 +364,6 @@ void* android_thread_func(void* param) return NULL; } -jint JNI_OnLoad(JavaVM* vm, void* reserved) -{ - - DEBUG_ANDROID("JNI_OnLoad"); - - jint res = init_callback_environment(vm); - - setlocale(LC_ALL, ""); - - freerdp_channels_global_init(); - - return res; -} - JNIEXPORT jint JNICALL jni_freerdp_new(JNIEnv *env, jclass cls) { freerdp* instance; @@ -657,7 +551,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags( { freerdp* inst = (freerdp*)instance; rdpSettings * settings = inst->settings; - + DEBUG_ANDROID("remotefx: %d", (remotefx == JNI_TRUE) ? 1 : 0); if (remotefx == JNI_TRUE) { @@ -748,6 +642,16 @@ JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls (*env)->ReleaseStringUTFChars(env, jpath, path); } +JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable) +{ + freerdp* inst = (freerdp*)instance; + rdpSettings * settings = inst->settings; + + DEBUG_ANDROID("clipboard redirect: %s", enable ? "TRUE" : "FALSE"); + + settings->RedirectClipboard = enable ? TRUE : FALSE; +} + void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp) { int i, j; @@ -860,6 +764,22 @@ JNIEXPORT void JNICALL jni_freerdp_send_cursor_event( DEBUG_ANDROID("send_cursor_event: (%d, %d), %d", x, y, flags); } +JNIEXPORT void JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata) +{ + ANDROID_EVENT* event; + freerdp* inst = (freerdp*)instance; + const jbyte *data = jdata != NULL ? (*env)->GetStringUTFChars(env, jdata, NULL) : NULL; + int data_length = data ? strlen(data) : 0; + + event = (ANDROID_EVENT*) android_event_clipboard_new((void*)data, data_length); + android_push_event(inst, event); + + DEBUG_ANDROID("send_clipboard_data: (%s)", data); + + if (data) + (*env)->ReleaseStringUTFChars(env, jdata, data); +} + JNIEXPORT jstring JNICALL jni_freerdp_get_version(JNIEnv *env, jclass cls) { return (*env)->NewStringUTF(env, GIT_REVISION); diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index 32753ad78..f4c660b3d 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -23,6 +23,8 @@ struct android_context ANDROID_EVENT_QUEUE* event_queue; pthread_t thread; BOOL is_connected; + + void* clipboard_context; }; typedef struct android_context androidContext; @@ -43,11 +45,13 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls jboolean disableMenuAnimations, jboolean disableTheming, jboolean enableFontSmoothing, jboolean enableDesktopComposition); JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir); JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); +JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory); JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height); JNIEXPORT void JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags); JNIEXPORT void JNICALL jni_freerdp_send_key_event(JNIEnv *env, jclass cls, jint instance, jint keycode, jboolean down); JNIEXPORT void JNICALL jni_freerdp_send_unicodekey_event(JNIEnv *env, jclass cls, jint instance, jint keycode); +JNIEXPORT void JNICALL jni_freerdp_send_clipboard_data(JNIEnv *env, jclass cls, jint instance, jstring jdata); JNIEXPORT jstring JNICALL jni_freerdp_get_version(JNIEnv *env, jclass cls); #endif /* __ANDROID_FREERDP_H */ diff --git a/client/Android/FreeRDPCore/jni/android_jni_utils.c b/client/Android/FreeRDPCore/jni/android_jni_utils.c new file mode 100644 index 000000000..0424c501a --- /dev/null +++ b/client/Android/FreeRDPCore/jni/android_jni_utils.c @@ -0,0 +1,211 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Android Event System + * + * Copyright 2013 Felix Long + * Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "android_jni_utils.h" + +#include +#include + +#include "android_debug.h" +#include "android_jni_callback.h" + + +JavaVM *g_JavaVm; + + +JavaVM* getJavaVM() +{ + return g_JavaVm; +} + +JNIEnv* getJNIEnv() +{ + JNIEnv* env = NULL; + if ((*g_JavaVm)->GetEnv(g_JavaVm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) + { + DEBUG_ANDROID("Failed to obtain JNIEnv"); + return NULL; + } + return env; +} + +jobject create_string_builder(JNIEnv *env, char* initialStr) +{ + jclass cls; + jmethodID methodId; + jobject obj; + + // get class + cls = (*env)->FindClass(env, "java/lang/StringBuilder"); + if(!cls) + return NULL; + + if(initialStr) + { + // get method id for constructor + methodId = (*env)->GetMethodID(env, cls, "", "(Ljava/lang/String;)V"); + if(!methodId) + return NULL; + + // create string that holds our initial string + jstring jstr = (*env)->NewStringUTF(env, initialStr); + + // construct new StringBuilder + obj = (*env)->NewObject(env, cls, methodId, jstr); + } + else + { + // get method id for constructor + methodId = (*env)->GetMethodID(env, cls, "", "()V"); + if(!methodId) + return NULL; + + // construct new StringBuilder + obj = (*env)->NewObject(env, cls, methodId); + } + + return obj; +} + +char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder) +{ + jclass cls; + jmethodID methodId; + jstring strObj; + const jbyte* native_str; + char* result; + + // get class + cls = (*env)->FindClass(env, "java/lang/StringBuilder"); + if(!cls) + return NULL; + + // get method id for constructor + methodId = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); + if(!methodId) + return NULL; + + // get jstring representation of our buffer + strObj = (*env)->CallObjectMethod(env, strBuilder, methodId); + + // read string + native_str = (*env)->GetStringUTFChars(env, strObj, NULL); + result = strdup(native_str); + (*env)->ReleaseStringUTFChars(env, strObj, native_str); + + return result; +} + +jstring jniNewStringUTF(JNIEnv* env, const char* in, int len) +{ + jstring out = NULL; + jchar* unicode = NULL; + jint result_size = 0; + jint i; + unsigned char* utf8 = (unsigned char*)in; + + if (!in) + { + return NULL; + } + if (len < 0) + len = strlen(in); + + unicode = (jchar*)malloc(sizeof(jchar) * (len + 1)); + if (!unicode) + { + return NULL; + } + + for(i = 0; i < len; i++) + { + unsigned char one = utf8[i]; + switch(one >> 4) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + unicode[result_size++] = one; + break; + case 0x08: + case 0x09: + case 0x0a: + case 0x0b: + //case 0x0f: + /* + * Bit pattern 10xx or 1111, which are illegal start bytes. + * Note: 1111 is valid for normal UTF-8, but not the + * modified UTF-8 used here. + */ + break; + case 0x0f: + case 0x0e: + // Bit pattern 111x, so there are two additional bytes. + if (i < (len - 2)) + { + unsigned char two = utf8[i+1]; + unsigned char three = utf8[i+2]; + if ((two & 0xc0) == 0x80 && (three & 0xc0) == 0x80) + { + i += 2; + unicode[result_size++] = + ((one & 0x0f) << 12) + | ((two & 0x3f) << 6) + | (three & 0x3f); + } + } + break; + case 0x0c: + case 0x0d: + // Bit pattern 110x, so there is one additional byte. + if (i < (len - 1)) + { + unsigned char two = utf8[i+1]; + if ((two & 0xc0) == 0x80) + { + i += 1; + unicode[result_size++] = + ((one & 0x1f) << 6) + | (two & 0x3f); + } + } + break; + } + } + + out = (*env)->NewString(env, unicode, result_size); + free(unicode); + + return out; +} + +jint JNI_OnLoad(JavaVM* vm, void* reserved) +{ + jint result = JNI_ERR; + + DEBUG_ANDROID("JNI_OnLoad"); + + g_JavaVm = vm; + result = init_callback_environment(vm); + + setlocale(LC_ALL, ""); + + freerdp_channels_global_init(); + + return result; +} + diff --git a/client/Android/FreeRDPCore/jni/android_jni_utils.h b/client/Android/FreeRDPCore/jni/android_jni_utils.h new file mode 100644 index 000000000..f5ac12e36 --- /dev/null +++ b/client/Android/FreeRDPCore/jni/android_jni_utils.h @@ -0,0 +1,34 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Android Event System + * + * Copyright 2013 Felix Long + * Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef _ANDROID_JNI_UTILS_H_ +#define _ANDROID_JNI_UTILS_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEnv* getJNIEnv(); + +JavaVM* getJavaVM(); + +char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder); +jobject create_string_builder(JNIEnv *env, char* initialStr); +jstring jniNewStringUTF(JNIEnv* env, const char* in, int len); + +#ifdef __cplusplus +} +#endif + +#endif /* _ANDROID_JNI_UTILS_H_ */ diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index b263b1d66..861a9087a 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -70,6 +70,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_set_performance_flags(env, cls, instance, remotefx, disableWallpaper, disableFullWindowDrag, disableMenuAnimations, disableTheming, enableFontSmoothing, enableDesktopComposition); } +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1clipboard_1redirection + (JNIEnv *env, jclass cls, jint inst, jboolean enable) +{ + jni_freerdp_set_clipboard_redirection(env, cls, inst, enable); +} + JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection (JNIEnv *env, jclass cls, jint inst, jstring path) { @@ -100,6 +106,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_send_unicodekey_event(env, cls, instance, keycode); } +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data + (JNIEnv *env, jclass cls, jint instance, jstring data) +{ + jni_freerdp_send_clipboard_data(env, cls, instance, data); +} + JNIEXPORT jstring JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1get_1version(JNIEnv *env, jclass cls) { return jni_freerdp_get_version(env, cls); diff --git a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h index a5c30412b..08188f700 100644 --- a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h +++ b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h @@ -79,6 +79,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1data_1directory (JNIEnv *, jclass, jint, jstring); +/* + * Class: com_freerdp_freerdpcore_services_LibFreeRDP + * Method: freerdp_set_clipboard_redirection + * Signature: (IZ)V + */ +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1clipboard_1redirection + (JNIEnv *, jclass, jint, jboolean); + /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_set_drive_redirection @@ -119,6 +127,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1unicodekey_1event (JNIEnv *, jclass, jint, jint); +/* + * Class: com_freerdp_freerdpcore_services_LibFreeRDP + * Method: freerdp_send_clipboard_data + * Signature: (ILjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data + (JNIEnv *, jclass, jint, jstring); + /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_get_version diff --git a/client/Android/FreeRDPCore/project.properties b/client/Android/FreeRDPCore/project.properties index db721fd89..b4af3b428 100644 --- a/client/Android/FreeRDPCore/project.properties +++ b/client/Android/FreeRDPCore/project.properties @@ -11,5 +11,5 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-8 +target=android-11 android.library=true diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java index 3d1c5adc1..055b48b73 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/SessionActivity.java @@ -22,6 +22,7 @@ import com.freerdp.freerdpcore.domain.ManualBookmark; import com.freerdp.freerdpcore.services.LibFreeRDP; import com.freerdp.freerdpcore.utils.KeyboardMapper; import com.freerdp.freerdpcore.utils.Mouse; +import com.freerdp.freerdpcore.utils.ClipboardManagerProxy; import android.app.Activity; import android.app.Dialog; @@ -59,7 +60,8 @@ import android.inputmethodservice.KeyboardView; public class SessionActivity extends Activity implements LibFreeRDP.UIEventListener, KeyboardView.OnKeyboardActionListener, ScrollView2D.ScrollView2DListener, - KeyboardMapper.KeyProcessingListener, SessionView.SessionViewListener, TouchPointerView.TouchPointerListener + KeyboardMapper.KeyProcessingListener, SessionView.SessionViewListener, TouchPointerView.TouchPointerListener, + ClipboardManagerProxy.OnClipboardChangedListener { private class UIHandler extends Handler { @@ -328,6 +330,8 @@ public class SessionActivity extends Activity private static final int SEND_MOVE_EVENT_TIMEOUT = 150; private int discardedMoveEvents = 0; + private ClipboardManagerProxy mClipboardManager; + private void createDialogs() { // build verify certificate dialog @@ -477,6 +481,9 @@ public class SessionActivity extends Activity IntentFilter filter = new IntentFilter(); filter.addAction(GlobalApp.ACTION_EVENT_FREERDP); registerReceiver(libFreeRDPBroadcastReceiver, filter); + + mClipboardManager = ClipboardManagerProxy.getClipboardManager(this); + mClipboardManager.addClipboardChangedListener(this); } @Override @@ -519,7 +526,10 @@ public class SessionActivity extends Activity // unregister freerdp events broadcast receiver unregisterReceiver(libFreeRDPBroadcastReceiver); - + + // remove clipboard listener + mClipboardManager.removeClipboardboardChangedListener(this); + // free session GlobalApp.freeSession(session.getInstance()); session = null; @@ -1013,7 +1023,13 @@ public class SessionActivity extends Activity return callbackDialogResult; } - + @Override + public void OnRemoteClipboardChanged(String data) + { + Log.v(TAG, "OnRemoteClipboardChanged: " + data); + mClipboardManager.setClipboardData(data); + } + // **************************************************************************** // ScrollView2DListener implementation private void resetZoomControlsAutoHideTimeout() { @@ -1131,5 +1147,13 @@ public class SessionActivity extends Activity public void onTouchPointerResetScrollZoom() { sessionView.setZoom(1.0f); scrollView.scrollTo(0, 0); + } + + // **************************************************************************** + // ClipboardManagerProxy.OnClipboardChangedListener + @Override + public void onClipboardChanged(String data) { + Log.v(TAG, "onClipboardChanged: " + data); + LibFreeRDP.sendClipboardData(session.getInstance(), data); } } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java index 248e9ac6f..455d0a379 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -39,6 +39,7 @@ public class LibFreeRDP private static native void freerdp_set_data_directory(int inst, String directory); + private static native void freerdp_set_clipboard_redirection(int inst, boolean enable); private static native void freerdp_set_drive_redirection(int inst, String path); private static native boolean freerdp_update_graphics(int inst, @@ -47,7 +48,8 @@ public class LibFreeRDP private static native void freerdp_send_cursor_event(int inst, int x, int y, int flags); private static native void freerdp_send_key_event(int inst, int keycode, boolean down); private static native void freerdp_send_unicodekey_event(int inst, int keycode); - + private static native void freerdp_send_clipboard_data(int inst, String data); + private static native String freerdp_get_version(); private static final String TAG = "LibFreeRDP"; @@ -67,6 +69,7 @@ public class LibFreeRDP boolean OnVerifiyCertificate(String subject, String issuer, String fingerprint); void OnGraphicsUpdate(int x, int y, int width, int height); void OnGraphicsResize(int width, int height, int bpp); + void OnRemoteClipboardChanged(String data); } private static EventListener listener; @@ -149,6 +152,9 @@ public class LibFreeRDP if (advancedSettings.getRedirectSDCard()) freerdp_set_drive_redirection(inst, android.os.Environment.getExternalStorageDirectory().getPath()); + // always enable clipboard redirection + freerdp_set_clipboard_redirection(inst, true); + return true; } @@ -177,6 +183,11 @@ public class LibFreeRDP freerdp_send_unicodekey_event(inst, keycode); } + public static void sendClipboardData(int inst, String data) + { + freerdp_send_clipboard_data(inst, data); + } + private static void OnConnectionSuccess(int inst) { if (listener != null) @@ -252,7 +263,17 @@ public class LibFreeRDP if (uiEventListener != null) uiEventListener.OnGraphicsResize(width, height, bpp); } - + + private static void OnRemoteClipboardChanged(int inst, String data) + { + SessionState s = GlobalApp.getSession(inst); + if (s == null) + return; + UIEventListener uiEventListener = s.getUIEventListener(); + if (uiEventListener != null) + uiEventListener.OnRemoteClipboardChanged(data); + } + public static String getVersion() { return freerdp_get_version(); diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java new file mode 100644 index 000000000..83f6ca562 --- /dev/null +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/utils/ClipboardManagerProxy.java @@ -0,0 +1,89 @@ +package com.freerdp.freerdpcore.utils; + +import android.annotation.TargetApi; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; + +public abstract class ClipboardManagerProxy { + + public static ClipboardManagerProxy getClipboardManager(Context ctx) { + if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) + return new PreHCClipboardManager(ctx); + else + return new HCClipboardManager(ctx); + } + + public static interface OnClipboardChangedListener { + void onClipboardChanged(String data); + } + + public abstract void setClipboardData(String data); + public abstract void addClipboardChangedListener(OnClipboardChangedListener listener); + public abstract void removeClipboardboardChangedListener(OnClipboardChangedListener listener); + + private static class PreHCClipboardManager extends ClipboardManagerProxy { + + public PreHCClipboardManager(Context ctx) { + + } + + @Override + public void setClipboardData(String data) { + } + + @Override + public void addClipboardChangedListener( + OnClipboardChangedListener listener) { + } + + @Override + public void removeClipboardboardChangedListener( + OnClipboardChangedListener listener) { + } + } + + @TargetApi(11) + private static class HCClipboardManager extends ClipboardManagerProxy implements ClipboardManager.OnPrimaryClipChangedListener { + private ClipboardManager mClipboardManager; + private OnClipboardChangedListener mListener; + + public HCClipboardManager(Context ctx) { + mClipboardManager = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); + } + + @Override + public void setClipboardData(String data) { + mClipboardManager.setPrimaryClip(ClipData.newPlainText("rdp-clipboard", data == null ? "" : data)); + } + + @Override + public void onPrimaryClipChanged() { + ClipData clip = mClipboardManager.getPrimaryClip(); + String data = null; + + if (clip != null && clip.getItemCount() > 0) { + data = clip.getItemAt(0).getText().toString(); + } + if (mListener != null) { + mListener.onClipboardChanged(data); + } + } + + @Override + public void addClipboardChangedListener( + OnClipboardChangedListener listener) { + mListener = listener; + mClipboardManager.addPrimaryClipChangedListener(this); + } + + @Override + public void removeClipboardboardChangedListener( + OnClipboardChangedListener listener) { + mListener = null; + mClipboardManager.removePrimaryClipChangedListener(this); + } + } +} diff --git a/client/Android/aFreeRDP/project.properties b/client/Android/aFreeRDP/project.properties index 857d31de6..4507b1846 100644 --- a/client/Android/aFreeRDP/project.properties +++ b/client/Android/aFreeRDP/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-8 +target=android-11 android.library.reference.1=../FreeRDPCore manifestmerger.enabled=true From e55b0ab64f2b7a30dc73eeb1900dcca1c840c41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 28 Apr 2013 00:23:36 -0400 Subject: [PATCH 033/144] xfreerdp: make client interface fully opaque --- client/X11/cli/CMakeLists.txt | 3 +- client/X11/cli/xfreerdp.h | 25 ---- client/X11/xf_cliprdr.h | 1 + client/X11/xf_event.h | 1 + client/X11/xf_gdi.h | 1 + client/X11/xf_graphics.h | 1 + client/X11/xf_interface.c | 17 +++ client/X11/xf_interface.h | 190 +----------------------------- client/X11/xf_keyboard.h | 1 + client/X11/xf_monitor.h | 1 + client/X11/xf_rail.h | 1 + client/X11/xf_tsmf.h | 1 + client/X11/xf_window.h | 1 + client/X11/xfreerdp.h | 210 ++++++++++++++++++++++++++++++++++ 14 files changed, 241 insertions(+), 213 deletions(-) delete mode 100644 client/X11/cli/xfreerdp.h create mode 100644 client/X11/xfreerdp.h diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index b4d27b5d7..0abac9e69 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -21,8 +21,7 @@ set(MODULE_PREFIX "FREERDP_CLIENT_X11") include_directories(..) set(${MODULE_PREFIX}_SRCS - xfreerdp.c - xfreerdp.h) + xfreerdp.c) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) diff --git a/client/X11/cli/xfreerdp.h b/client/X11/cli/xfreerdp.h deleted file mode 100644 index c8e4780a6..000000000 --- a/client/X11/cli/xfreerdp.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * X11 Client - * - * Copyright 2011 Marc-Andre Moreau - * - * 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 __XFREERDP_H -#define __XFREERDP_H - - - -#endif /* __XFREERDP_H */ diff --git a/client/X11/xf_cliprdr.h b/client/X11/xf_cliprdr.h index ead887606..f2ee57dfd 100644 --- a/client/X11/xf_cliprdr.h +++ b/client/X11/xf_cliprdr.h @@ -21,6 +21,7 @@ #define __XF_CLIPRDR_H #include "xf_interface.h" +#include "xfreerdp.h" void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman); void xf_cliprdr_uninit(xfInfo* xfi); diff --git a/client/X11/xf_event.h b/client/X11/xf_event.h index 722a7a56e..93e0c7732 100644 --- a/client/X11/xf_event.h +++ b/client/X11/xf_event.h @@ -23,6 +23,7 @@ #include "xf_keyboard.h" #include "xf_interface.h" +#include "xfreerdp.h" BOOL xf_event_process(freerdp* instance, XEvent* event); void xf_event_SendClientEvent(xfInfo *xfi, xfWindow* window, Atom atom, unsigned int numArgs, ...); diff --git a/client/X11/xf_gdi.h b/client/X11/xf_gdi.h index b3ac75df9..64e98d0cb 100644 --- a/client/X11/xf_gdi.h +++ b/client/X11/xf_gdi.h @@ -23,6 +23,7 @@ #include #include "xf_interface.h" +#include "xfreerdp.h" void xf_gdi_register_update_callbacks(rdpUpdate* update); diff --git a/client/X11/xf_graphics.h b/client/X11/xf_graphics.h index 9d8cfd62f..60bbba6bf 100644 --- a/client/X11/xf_graphics.h +++ b/client/X11/xf_graphics.h @@ -21,6 +21,7 @@ #define __XF_GRAPHICS_H #include "xf_interface.h" +#include "xfreerdp.h" void xf_register_graphics(rdpGraphics* graphics); diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 3a2ce8b8a..86bfc4fdf 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -74,6 +74,8 @@ #include "xf_graphics.h" #include "xf_keyboard.h" +#include "xfreerdp.h" + static long xv_port = 0; static const size_t password_size = 512; @@ -1457,6 +1459,21 @@ int freerdp_client_stop(xfInfo* xfi) return 0; } +freerdp* freerdp_client_get_instance(cfInfo* cfi) +{ + return cfi->instance; +} + +HANDLE freerdp_client_get_thread(cfInfo* cfi) +{ + return cfi->thread; +} + +rdpClient* freerdp_client_get_interface(cfInfo* cfi) +{ + return cfi->client; +} + xfInfo* freerdp_client_new(int argc, char** argv) { int index; diff --git a/client/X11/xf_interface.h b/client/X11/xf_interface.h index 9f4483fc8..c27e7948f 100644 --- a/client/X11/xf_interface.h +++ b/client/X11/xf_interface.h @@ -36,196 +36,10 @@ typedef struct xf_info xfInfo; -#include "xf_window.h" -#include "xf_monitor.h" - #ifdef __cplusplus extern "C" { #endif -struct xf_WorkArea -{ - UINT32 x; - UINT32 y; - UINT32 width; - UINT32 height; -}; -typedef struct xf_WorkArea xfWorkArea; - -struct xf_pointer -{ - rdpPointer pointer; - Cursor cursor; -}; -typedef struct xf_pointer xfPointer; - -struct xf_bitmap -{ - rdpBitmap bitmap; - Pixmap pixmap; -}; -typedef struct xf_bitmap xfBitmap; - -struct xf_glyph -{ - rdpGlyph glyph; - Pixmap pixmap; -}; -typedef struct xf_glyph xfGlyph; - -struct xf_context -{ - rdpContext _p; - - xfInfo* xfi; - rdpSettings* settings; -}; -typedef struct xf_context xfContext; - -struct xf_info -{ - freerdp* instance; - xfContext* context; - rdpContext* _context; - - rdpClient* client; - rdpSettings* settings; - - GC gc; - int bpp; - int xfds; - int depth; - int width; - int height; - int srcBpp; - GC gc_mono; - Screen* screen; - XImage* image; - Pixmap primary; - Pixmap drawing; - Visual* visual; - Display* display; - Drawable drawable; - Pixmap bitmap_mono; - Colormap colormap; - int screen_number; - int scanline_pad; - BOOL big_endian; - BOOL fullscreen; - BOOL grab_keyboard; - BOOL unobscured; - BOOL debug; - xfWindow* window; - xfWorkArea workArea; - int current_desktop; - BOOL remote_app; - BOOL disconnect; - HCLRCONV clrconv; - HANDLE mutex; - HANDLE thread; - BOOL UseXThreads; - - HGDI_DC hdc; - BYTE* primary_buffer; - - BOOL frame_begin; - UINT16 frame_x1; - UINT16 frame_y1; - UINT16 frame_x2; - UINT16 frame_y2; - - BOOL focused; - BOOL mouse_active; - BOOL suppress_output; - BOOL fullscreen_toggle; - UINT32 keyboard_layout_id; - BOOL pressed_keys[256]; - XModifierKeymap* modifier_map; - XSetWindowAttributes attribs; - BOOL complex_regions; - VIRTUAL_SCREEN vscreen; - BYTE* bmp_codec_none; - BYTE* bmp_codec_nsc; - void* rfx_context; - void* nsc_context; - void* xv_context; - void* clipboard_context; - - Atom _NET_WM_ICON; - Atom _MOTIF_WM_HINTS; - Atom _NET_CURRENT_DESKTOP; - Atom _NET_WORKAREA; - - Atom _NET_WM_STATE; - Atom _NET_WM_STATE_FULLSCREEN; - Atom _NET_WM_STATE_SKIP_TASKBAR; - Atom _NET_WM_STATE_SKIP_PAGER; - - Atom _NET_WM_WINDOW_TYPE; - Atom _NET_WM_WINDOW_TYPE_NORMAL; - Atom _NET_WM_WINDOW_TYPE_DIALOG; - Atom _NET_WM_WINDOW_TYPE_UTILITY; - Atom _NET_WM_WINDOW_TYPE_POPUP; - Atom _NET_WM_WINDOW_TYPE_DROPDOWN_MENU; - - Atom _NET_WM_MOVERESIZE; - Atom _NET_MOVERESIZE_WINDOW; - - Atom WM_STATE; - Atom WM_PROTOCOLS; - Atom WM_DELETE_WINDOW; -}; - -void xf_create_window(xfInfo* xfi); -void xf_toggle_fullscreen(xfInfo* xfi); -BOOL xf_post_connect(freerdp* instance); - -enum XF_EXIT_CODE -{ - /* section 0-15: protocol-independent codes */ - XF_EXIT_SUCCESS = 0, - XF_EXIT_DISCONNECT = 1, - XF_EXIT_LOGOFF = 2, - XF_EXIT_IDLE_TIMEOUT = 3, - XF_EXIT_LOGON_TIMEOUT = 4, - XF_EXIT_CONN_REPLACED = 5, - XF_EXIT_OUT_OF_MEMORY = 6, - XF_EXIT_CONN_DENIED = 7, - XF_EXIT_CONN_DENIED_FIPS = 8, - XF_EXIT_USER_PRIVILEGES = 9, - XF_EXIT_FRESH_CREDENTIALS_REQUIRED = 10, - XF_EXIT_DISCONNECT_BY_USER = 11, - - /* section 16-31: license error set */ - XF_EXIT_LICENSE_INTERNAL = 16, - XF_EXIT_LICENSE_NO_LICENSE_SERVER = 17, - XF_EXIT_LICENSE_NO_LICENSE = 18, - XF_EXIT_LICENSE_BAD_CLIENT_MSG = 19, - XF_EXIT_LICENSE_HWID_DOESNT_MATCH = 20, - XF_EXIT_LICENSE_BAD_CLIENT = 21, - XF_EXIT_LICENSE_CANT_FINISH_PROTOCOL = 22, - XF_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL = 23, - XF_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION = 24, - XF_EXIT_LICENSE_CANT_UPGRADE = 25, - XF_EXIT_LICENSE_NO_REMOTE_CONNECTIONS = 26, - - /* section 32-127: RDP protocol error set */ - XF_EXIT_RDP = 32, - - /* section 128-254: xfreerdp specific exit codes */ - XF_EXIT_PARSE_ARGUMENTS = 128, - XF_EXIT_MEMORY = 129, - XF_EXIT_PROTOCOL = 130, - XF_EXIT_CONN_FAILED = 131, - - XF_EXIT_UNKNOWN = 255, -}; - -void xf_lock_x11(xfInfo* xfi, BOOL display); -void xf_unlock_x11(xfInfo* xfi, BOOL display); - -DWORD xf_exit_code_from_disconnect_reason(DWORD reason); - /** * Client Interface */ @@ -238,6 +52,10 @@ FREERDP_API int freerdp_client_global_uninit(); FREERDP_API int freerdp_client_start(cfInfo* cfi); FREERDP_API int freerdp_client_stop(cfInfo* cfi); +FREERDP_API freerdp* freerdp_client_get_instance(cfInfo* cfi); +FREERDP_API HANDLE freerdp_client_get_thread(cfInfo* cfi); +FREERDP_API rdpClient* freerdp_client_get_interface(cfInfo* cfi); + FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv); FREERDP_API void freerdp_client_free(cfInfo* cfi); diff --git a/client/X11/xf_keyboard.h b/client/X11/xf_keyboard.h index 01ec6111a..493a67cb5 100644 --- a/client/X11/xf_keyboard.h +++ b/client/X11/xf_keyboard.h @@ -23,6 +23,7 @@ #include #include "xf_interface.h" +#include "xfreerdp.h" void xf_kbd_init(xfInfo* xfi); void xf_kbd_clear(xfInfo* xfi); diff --git a/client/X11/xf_monitor.h b/client/X11/xf_monitor.h index 1020817e6..e0fa01872 100644 --- a/client/X11/xf_monitor.h +++ b/client/X11/xf_monitor.h @@ -41,6 +41,7 @@ struct _VIRTUAL_SCREEN typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN; #include "xf_interface.h" +#include "xfreerdp.h" BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings); diff --git a/client/X11/xf_rail.h b/client/X11/xf_rail.h index e395681c9..29e24b8e9 100644 --- a/client/X11/xf_rail.h +++ b/client/X11/xf_rail.h @@ -21,6 +21,7 @@ #define __XF_RAIL_H #include "xf_interface.h" +#include "xfreerdp.h" void xf_rail_paint(xfInfo* xfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom); void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail); diff --git a/client/X11/xf_tsmf.h b/client/X11/xf_tsmf.h index db2395204..65d7838d8 100644 --- a/client/X11/xf_tsmf.h +++ b/client/X11/xf_tsmf.h @@ -21,6 +21,7 @@ #define __XF_TSMF_H #include "xf_interface.h" +#include "xfreerdp.h" void xf_tsmf_init(xfInfo* xfi, long xv_port); void xf_tsmf_uninit(xfInfo* xfi); diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h index 257515925..96d08be50 100644 --- a/client/X11/xf_window.h +++ b/client/X11/xf_window.h @@ -28,6 +28,7 @@ typedef struct xf_localmove xfLocalMove; typedef struct xf_window xfWindow; #include "xf_interface.h" +#include "xfreerdp.h" // Extended ICCM flags http://standards.freedesktop.org/wm-spec/wm-spec-latest.html #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h new file mode 100644 index 000000000..9f79c07d3 --- /dev/null +++ b/client/X11/xfreerdp.h @@ -0,0 +1,210 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Client + * + * Copyright 2011 Marc-Andre Moreau + * + * 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 __XFREERDP_H +#define __XFREERDP_H + +#include "xf_window.h" +#include "xf_monitor.h" + +struct xf_WorkArea +{ + UINT32 x; + UINT32 y; + UINT32 width; + UINT32 height; +}; +typedef struct xf_WorkArea xfWorkArea; + +struct xf_pointer +{ + rdpPointer pointer; + Cursor cursor; +}; +typedef struct xf_pointer xfPointer; + +struct xf_bitmap +{ + rdpBitmap bitmap; + Pixmap pixmap; +}; +typedef struct xf_bitmap xfBitmap; + +struct xf_glyph +{ + rdpGlyph glyph; + Pixmap pixmap; +}; +typedef struct xf_glyph xfGlyph; + +struct xf_context +{ + rdpContext _p; + + xfInfo* xfi; + rdpSettings* settings; +}; +typedef struct xf_context xfContext; + +struct xf_info +{ + freerdp* instance; + xfContext* context; + rdpContext* _context; + + rdpClient* client; + rdpSettings* settings; + + GC gc; + int bpp; + int xfds; + int depth; + int width; + int height; + int srcBpp; + GC gc_mono; + Screen* screen; + XImage* image; + Pixmap primary; + Pixmap drawing; + Visual* visual; + Display* display; + Drawable drawable; + Pixmap bitmap_mono; + Colormap colormap; + int screen_number; + int scanline_pad; + BOOL big_endian; + BOOL fullscreen; + BOOL grab_keyboard; + BOOL unobscured; + BOOL debug; + xfWindow* window; + xfWorkArea workArea; + int current_desktop; + BOOL remote_app; + BOOL disconnect; + HCLRCONV clrconv; + HANDLE mutex; + HANDLE thread; + BOOL UseXThreads; + + HGDI_DC hdc; + BYTE* primary_buffer; + + BOOL frame_begin; + UINT16 frame_x1; + UINT16 frame_y1; + UINT16 frame_x2; + UINT16 frame_y2; + + BOOL focused; + BOOL mouse_active; + BOOL suppress_output; + BOOL fullscreen_toggle; + UINT32 keyboard_layout_id; + BOOL pressed_keys[256]; + XModifierKeymap* modifier_map; + XSetWindowAttributes attribs; + BOOL complex_regions; + VIRTUAL_SCREEN vscreen; + BYTE* bmp_codec_none; + BYTE* bmp_codec_nsc; + void* rfx_context; + void* nsc_context; + void* xv_context; + void* clipboard_context; + + Atom _NET_WM_ICON; + Atom _MOTIF_WM_HINTS; + Atom _NET_CURRENT_DESKTOP; + Atom _NET_WORKAREA; + + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_FULLSCREEN; + Atom _NET_WM_STATE_SKIP_TASKBAR; + Atom _NET_WM_STATE_SKIP_PAGER; + + Atom _NET_WM_WINDOW_TYPE; + Atom _NET_WM_WINDOW_TYPE_NORMAL; + Atom _NET_WM_WINDOW_TYPE_DIALOG; + Atom _NET_WM_WINDOW_TYPE_UTILITY; + Atom _NET_WM_WINDOW_TYPE_POPUP; + Atom _NET_WM_WINDOW_TYPE_DROPDOWN_MENU; + + Atom _NET_WM_MOVERESIZE; + Atom _NET_MOVERESIZE_WINDOW; + + Atom WM_STATE; + Atom WM_PROTOCOLS; + Atom WM_DELETE_WINDOW; +}; + +void xf_create_window(xfInfo* xfi); +void xf_toggle_fullscreen(xfInfo* xfi); +BOOL xf_post_connect(freerdp* instance); + +enum XF_EXIT_CODE +{ + /* section 0-15: protocol-independent codes */ + XF_EXIT_SUCCESS = 0, + XF_EXIT_DISCONNECT = 1, + XF_EXIT_LOGOFF = 2, + XF_EXIT_IDLE_TIMEOUT = 3, + XF_EXIT_LOGON_TIMEOUT = 4, + XF_EXIT_CONN_REPLACED = 5, + XF_EXIT_OUT_OF_MEMORY = 6, + XF_EXIT_CONN_DENIED = 7, + XF_EXIT_CONN_DENIED_FIPS = 8, + XF_EXIT_USER_PRIVILEGES = 9, + XF_EXIT_FRESH_CREDENTIALS_REQUIRED = 10, + XF_EXIT_DISCONNECT_BY_USER = 11, + + /* section 16-31: license error set */ + XF_EXIT_LICENSE_INTERNAL = 16, + XF_EXIT_LICENSE_NO_LICENSE_SERVER = 17, + XF_EXIT_LICENSE_NO_LICENSE = 18, + XF_EXIT_LICENSE_BAD_CLIENT_MSG = 19, + XF_EXIT_LICENSE_HWID_DOESNT_MATCH = 20, + XF_EXIT_LICENSE_BAD_CLIENT = 21, + XF_EXIT_LICENSE_CANT_FINISH_PROTOCOL = 22, + XF_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL = 23, + XF_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION = 24, + XF_EXIT_LICENSE_CANT_UPGRADE = 25, + XF_EXIT_LICENSE_NO_REMOTE_CONNECTIONS = 26, + + /* section 32-127: RDP protocol error set */ + XF_EXIT_RDP = 32, + + /* section 128-254: xfreerdp specific exit codes */ + XF_EXIT_PARSE_ARGUMENTS = 128, + XF_EXIT_MEMORY = 129, + XF_EXIT_PROTOCOL = 130, + XF_EXIT_CONN_FAILED = 131, + + XF_EXIT_UNKNOWN = 255, +}; + +void xf_lock_x11(xfInfo* xfi, BOOL display); +void xf_unlock_x11(xfInfo* xfi, BOOL display); + +DWORD xf_exit_code_from_disconnect_reason(DWORD reason); + +#endif /* __XFREERDP_H */ + From 3d285f06a984c430fbb8d2cfb12e82c81608260d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 28 Apr 2013 01:11:29 -0400 Subject: [PATCH 034/144] xfreerdp: add OnWindowStateChange client event --- client/X11/xf_interface.c | 3 +++ include/freerdp/client.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 86bfc4fdf..728f3f7dc 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -438,6 +438,9 @@ void xf_toggle_fullscreen(xfInfo* xfi) XFreePixmap(xfi->display, contents); xf_unlock_x11(xfi, TRUE); + + IFCALL(xfi->client->OnWindowStateChange, xfi->instance, + xfi->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0); } void xf_lock_x11(xfInfo* xfi, BOOL display) diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 5c0cc966d..9963d06c3 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -29,11 +29,19 @@ typedef struct rdp_client rdpClient; extern "C" { #endif +#define FREERDP_WINDOW_STATE_NORMAL 0 +#define FREERDP_WINDOW_STATE_MINIMIZED 1 +#define FREERDP_WINDOW_STATE_MAXIMIZED 2 +#define FREERDP_WINDOW_STATE_FULLSCREEN 3 +#define FREERDP_WINDOW_STATE_ACTIVE 4 + typedef void (*pOnResizeWindow)(freerdp* instance, int width, int height); +typedef void (*pOnWindowStateChange)(freerdp* instance, int state); struct rdp_client { pOnResizeWindow OnResizeWindow; + pOnWindowStateChange OnWindowStateChange; }; /** From 1cfda17da9989ac85a62eb933abeb93afdf25719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 28 Apr 2013 16:27:23 -0400 Subject: [PATCH 035/144] xfreerdp: partial multimonitor patch from Hans-Peter Jansen --- client/X11/xf_monitor.c | 109 ++++++++++++++++++++--------------- client/X11/xf_window.c | 5 +- include/freerdp/settings.h | 6 +- libfreerdp/common/settings.c | 16 +++++ libfreerdp/core/settings.c | 2 + 5 files changed, 90 insertions(+), 48 deletions(-) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index aad52dd12..6ce66da8b 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -40,6 +40,9 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) { int i; + int nmonitors; + int primaryMonitor; + int maxWidth, maxHeight; VIRTUAL_SCREEN* vscreen; #ifdef WITH_XINERAMA @@ -49,33 +52,6 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) vscreen = &xfi->vscreen; - if (xf_GetWorkArea(xfi) != TRUE) - { - xfi->workArea.x = 0; - xfi->workArea.y = 0; - xfi->workArea.width = WidthOfScreen(xfi->screen); - xfi->workArea.height = HeightOfScreen(xfi->screen); - } - - if (settings->Fullscreen) - { - settings->DesktopWidth = WidthOfScreen(xfi->screen); - settings->DesktopHeight = HeightOfScreen(xfi->screen); - } - else if (settings->Workarea) - { - settings->DesktopWidth = xfi->workArea.width; - settings->DesktopHeight = xfi->workArea.height; - } - else if (settings->PercentScreen) - { - settings->DesktopWidth = (xfi->workArea.width * settings->PercentScreen) / 100; - settings->DesktopHeight = (xfi->workArea.height * settings->PercentScreen) / 100; - } - - if (settings->Fullscreen != TRUE && settings->Workarea != TRUE) - return TRUE; - #ifdef WITH_XINERAMA if (XineramaQueryExtension(xfi->display, &ignored, &ignored2)) { @@ -108,32 +84,73 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) } #endif - settings->MonitorCount = vscreen->nmonitors; + if (!xf_GetWorkArea(xfi)) + { + xfi->workArea.x = 0; + xfi->workArea.y = 0; + xfi->workArea.width = WidthOfScreen(xfi->screen); + xfi->workArea.height = HeightOfScreen(xfi->screen); + } + + if (settings->Fullscreen) + { + settings->DesktopWidth = WidthOfScreen(xfi->screen); + settings->DesktopHeight = HeightOfScreen(xfi->screen); + maxWidth = settings->DesktopWidth; + maxHeight = settings->DesktopHeight; + } + else if (settings->Workarea) + { + settings->DesktopWidth = xfi->workArea.width; + settings->DesktopHeight = xfi->workArea.height; + maxWidth = settings->DesktopWidth; + maxHeight = settings->DesktopHeight; + } + else if (settings->PercentScreen) + { + settings->DesktopWidth = (xfi->workArea.width * settings->PercentScreen) / 100; + settings->DesktopHeight = (xfi->workArea.height * settings->PercentScreen) / 100; + maxWidth = settings->DesktopWidth; + maxHeight = settings->DesktopHeight; + } + else + { + maxWidth = WidthOfScreen(xfi->screen); + maxHeight = HeightOfScreen(xfi->screen); + } + + if (!settings->Fullscreen && !settings->Workarea && !settings->UseMultimon) + return TRUE; + + nmonitors = 0; + primaryMonitor = 0; + + vscreen->area.left = settings->DesktopPosX; + vscreen->area.right = MIN(settings->DesktopPosX + settings->DesktopWidth - 1, maxWidth); + vscreen->area.top = settings->DesktopPosY; + vscreen->area.bottom = MIN(settings->DesktopPosY + settings->DesktopHeight - 1, maxHeight); for (i = 0; i < vscreen->nmonitors; i++) { - settings->MonitorDefArray[i].x = vscreen->monitors[i].area.left; - settings->MonitorDefArray[i].y = vscreen->monitors[i].area.top; - settings->MonitorDefArray[i].width = vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1; - settings->MonitorDefArray[i].height = vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1; - settings->MonitorDefArray[i].is_primary = vscreen->monitors[i].primary; + if ((vscreen->monitors[i].area.left > vscreen->area.right) || (vscreen->monitors[i].area.right < vscreen->area.left) || + (vscreen->monitors[i].area.top > vscreen->area.bottom) || (vscreen->monitors[i].area.bottom < vscreen->area.top)) + continue; - vscreen->area.left = MIN(vscreen->monitors[i].area.left, vscreen->area.left); - vscreen->area.right = MAX(vscreen->monitors[i].area.right, vscreen->area.right); - vscreen->area.top = MIN(vscreen->monitors[i].area.top, vscreen->area.top); - vscreen->area.bottom = MAX(vscreen->monitors[i].area.bottom, vscreen->area.bottom); + settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left - settings->DesktopPosX; + settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top - settings->DesktopPosY; + settings->MonitorDefArray[nmonitors].width = MIN(vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1, settings->DesktopWidth); + settings->MonitorDefArray[nmonitors].height = MIN(vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1, settings->DesktopHeight); + settings->MonitorDefArray[nmonitors].is_primary = vscreen->monitors[i].primary; + + primaryMonitor |= vscreen->monitors[i].primary; + nmonitors++; } - /* if no monitor information is present then make sure variables are set accordingly */ - if (settings->MonitorCount == 0) - { - vscreen->area.left = 0; - vscreen->area.right = settings->DesktopWidth -1; - vscreen->area.top = 0; - vscreen->area.bottom = settings->DesktopHeight - 1; - } + settings->MonitorCount = nmonitors; + + if (nmonitors && !primaryMonitor) + settings->MonitorDefArray[0].is_primary = TRUE; - if (settings->MonitorCount) { settings->DesktopWidth = vscreen->area.right - vscreen->area.left + 1; diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 46f5507af..d09f78546 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -394,9 +394,11 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, { xfWindow* window; XEvent xevent; + rdpSettings* settings; window = (xfWindow*) malloc(sizeof(xfWindow)); ZeroMemory(window, sizeof(xfWindow)); + settings = xfi->instance->settings; if (window) { @@ -494,7 +496,8 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, if (xfi->instance->settings->RemoteApplicationMode) XMoveWindow(xfi->display, window->handle, 0, 0); - + else if (settings->DesktopPosX || settings->DesktopPosY) + XMoveWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY); } xf_SetWindowText(xfi, window, name); diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 0a078c280..8b71045a7 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -511,6 +511,8 @@ typedef struct _RDPDR_PARALLEL RDPDR_PARALLEL; #define FreeRDP_SpanMonitors 387 #define FreeRDP_UseMultimon 388 #define FreeRDP_ForceMultimon 389 +#define FreeRDP_DesktopPosX 390 +#define FreeRDP_DesktopPosY 391 #define FreeRDP_MultitransportFlags 512 #define FreeRDP_AlternateShell 640 #define FreeRDP_ShellWorkingDirectory 641 @@ -807,7 +809,9 @@ struct rdp_settings ALIGN64 BOOL SpanMonitors; /* 387 */ ALIGN64 BOOL UseMultimon; /* 388 */ ALIGN64 BOOL ForceMultimon; /* 389 */ - UINT64 padding0448[448 - 390]; /* 390 */ + ALIGN64 UINT32 DesktopPosX; /* 390 */ + ALIGN64 UINT32 DesktopPosY; /* 391 */ + UINT64 padding0448[448 - 392]; /* 392 */ /* Client Message Channel Data */ UINT64 padding0512[512 - 448]; /* 448 */ diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index c8a82cde8..421d9af44 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -1245,6 +1245,14 @@ UINT32 freerdp_get_param_uint32(rdpSettings* settings, int id) return settings->MonitorDefArraySize; break; + case FreeRDP_DesktopPosX: + return settings->DesktopPosX; + break; + + case FreeRDP_DesktopPosY: + return settings->DesktopPosY; + break; + case FreeRDP_MultitransportFlags: return settings->MultitransportFlags; break; @@ -1553,6 +1561,14 @@ int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param) settings->MonitorDefArraySize = param; break; + case FreeRDP_DesktopPosX: + settings->DesktopPosX = param; + break; + + case FreeRDP_DesktopPosY: + settings->DesktopPosY = param; + break; + case FreeRDP_MultitransportFlags: settings->MultitransportFlags = param; break; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 8411b4b88..8f22cc336 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -240,6 +240,8 @@ rdpSettings* freerdp_settings_new(void* instance) settings->ServerPort = 3389; settings->DesktopResize = TRUE; settings->ToggleFullscreen = TRUE; + settings->DesktopPosX = 0; + settings->DesktopPosY = 0; settings->PerformanceFlags = PERF_DISABLE_FULLWINDOWDRAG | From 24573ef08de7751c2c584956ae7f4852cbb2269d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 28 Apr 2013 17:10:43 -0400 Subject: [PATCH 036/144] xfreerdp: add /monitor-list option --- client/X11/xf_interface.c | 5 +++++ client/X11/xf_monitor.c | 44 ++++++++++++++++++++++++++++++++++++++ client/X11/xf_monitor.h | 1 + client/common/cmdline.c | 16 ++++++++++++-- include/freerdp/settings.h | 3 ++- 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 728f3f7dc..516b4bfd6 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1560,6 +1560,11 @@ xfInfo* freerdp_client_new(int argc, char** argv) settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE; + if (settings->ListMonitors) + { + xf_list_monitors(xfi); + } + return xfi; } diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 6ce66da8b..1d978bc65 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -37,6 +37,50 @@ /* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */ +int xf_list_monitors(xfInfo* xfi) +{ +#ifdef WITH_XINERAMA + Display* display; + int i, nmonitors = 0; + int ignored, ignored2; + XineramaScreenInfo* screen = NULL; + + display = XOpenDisplay(NULL); + + if (XineramaQueryExtension(display, &ignored, &ignored2)) + { + if (XineramaIsActive(display)) + { + screen = XineramaQueryScreens(display, &nmonitors); + + for (i = 0; i < nmonitors; i++) + { + printf(" %s [%d] %dx%d\t+%d+%d\n", + (i == 0) ? "*" : " ", i, + screen[i].width, screen[i].height, + screen[i].x_org, screen[i].y_org); + } + + XFree(screen); + } + } + + XCloseDisplay(display); +#else + Screen* screen; + Display* display; + + display = XOpenDisplay(NULL); + + screen = ScreenOfDisplay(display, DefaultScreen(display)); + printf(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); + + XCloseDisplay(display); +#endif + + return 0; +} + BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) { int i; diff --git a/client/X11/xf_monitor.h b/client/X11/xf_monitor.h index e0fa01872..4f3b1de8e 100644 --- a/client/X11/xf_monitor.h +++ b/client/X11/xf_monitor.h @@ -43,6 +43,7 @@ typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN; #include "xf_interface.h" #include "xfreerdp.h" +int xf_list_monitors(xfInfo* xfi); BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings); #endif /* __XF_MONITOR_H */ diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 5451d3158..c4dd9dfd8 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -48,8 +48,9 @@ COMMAND_LINE_ARGUMENT_A args[] = { "kbd-subtype", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Keyboard subtype" }, { "kbd-fn-key", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Keyboard function key count" }, { "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" }, - { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Multi-monitor" }, - { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Work area" }, + { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" }, + { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" }, + { "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" }, { "t", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, "title", "Window title" }, { "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" }, { "smart-sizing", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Scale remote desktop to window size" }, @@ -985,6 +986,13 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin printf("\n"); } + arg = CommandLineFindArgumentA(args, "monitor-list"); + + if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) + { + settings->ListMonitors = TRUE; + } + return COMMAND_LINE_STATUS_PRINT; } @@ -1084,6 +1092,10 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin { settings->Workarea = TRUE; } + CommandLineSwitchCase(arg, "monitor-list") + { + settings->ListMonitors = TRUE; + } CommandLineSwitchCase(arg, "t") { settings->WindowTitle = _strdup(arg->Value); diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 8b71045a7..cd31e5997 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -811,7 +811,8 @@ struct rdp_settings ALIGN64 BOOL ForceMultimon; /* 389 */ ALIGN64 UINT32 DesktopPosX; /* 390 */ ALIGN64 UINT32 DesktopPosY; /* 391 */ - UINT64 padding0448[448 - 392]; /* 392 */ + ALIGN64 BOOL ListMonitors; /* 392 */ + UINT64 padding0448[448 - 393]; /* 393 */ /* Client Message Channel Data */ UINT64 padding0512[512 - 448]; /* 448 */ From 12ec6c60db789ddd52b6b758a53ece236c671103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 28 Apr 2013 18:48:27 -0400 Subject: [PATCH 037/144] xfreerdp: add support for selecting individual monitors --- client/X11/xf_monitor.c | 46 +++++++++++++++++++++++++++++--------- client/X11/xf_window.c | 8 ++++++- client/common/cmdline.c | 19 ++++++++++++++++ include/freerdp/settings.h | 4 +++- 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 1d978bc65..b41c8d357 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -83,9 +83,10 @@ int xf_list_monitors(xfInfo* xfi) BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) { - int i; + int i, j; int nmonitors; int primaryMonitor; + int vWidth, vHeight; int maxWidth, maxHeight; VIRTUAL_SCREEN* vscreen; @@ -169,19 +170,24 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) nmonitors = 0; primaryMonitor = 0; - vscreen->area.left = settings->DesktopPosX; - vscreen->area.right = MIN(settings->DesktopPosX + settings->DesktopWidth - 1, maxWidth); - vscreen->area.top = settings->DesktopPosY; - vscreen->area.bottom = MIN(settings->DesktopPosY + settings->DesktopHeight - 1, maxHeight); - for (i = 0; i < vscreen->nmonitors; i++) { - if ((vscreen->monitors[i].area.left > vscreen->area.right) || (vscreen->monitors[i].area.right < vscreen->area.left) || - (vscreen->monitors[i].area.top > vscreen->area.bottom) || (vscreen->monitors[i].area.bottom < vscreen->area.top)) - continue; + if (settings->NumMonitorIds) + { + BOOL found = FALSE; - settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left - settings->DesktopPosX; - settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top - settings->DesktopPosY; + for (j = 0; j < settings->NumMonitorIds; j++) + { + if (settings->MonitorIds[j] == i) + found = TRUE; + } + + if (!found) + continue; + } + + settings->MonitorDefArray[nmonitors].x = vscreen->monitors[i].area.left; + settings->MonitorDefArray[nmonitors].y = vscreen->monitors[i].area.top; settings->MonitorDefArray[nmonitors].width = MIN(vscreen->monitors[i].area.right - vscreen->monitors[i].area.left + 1, settings->DesktopWidth); settings->MonitorDefArray[nmonitors].height = MIN(vscreen->monitors[i].area.bottom - vscreen->monitors[i].area.top + 1, settings->DesktopHeight); settings->MonitorDefArray[nmonitors].is_primary = vscreen->monitors[i].primary; @@ -192,6 +198,24 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) settings->MonitorCount = nmonitors; + vWidth = vHeight = 0; + settings->DesktopPosX = maxWidth - 1; + settings->DesktopPosY = maxHeight - 1; + + for (i = 0; i < settings->MonitorCount; i++) + { + settings->DesktopPosX = MIN(settings->DesktopPosX, settings->MonitorDefArray[i].x); + settings->DesktopPosY = MIN(settings->DesktopPosY, settings->MonitorDefArray[i].y); + + vWidth += settings->MonitorDefArray[i].width; + vHeight = MAX(vHeight, settings->MonitorDefArray[i].height); + } + + vscreen->area.left = 0; + vscreen->area.right = vWidth - 1; + vscreen->area.top = 0; + vscreen->area.bottom = vHeight - 1; + if (nmonitors && !primaryMonitor) settings->MonitorDefArray[0].is_primary = TRUE; diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index d09f78546..bb9e1c95b 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -140,9 +140,11 @@ void xf_SetWindowFullscreen(xfInfo* xfi, xfWindow* window, BOOL fullscreen) { if (fullscreen) { + rdpSettings* settings = xfi->instance->settings; + xf_SetWindowDecorations(xfi, window, FALSE); - XMoveResizeWindow(xfi->display, window->handle, 0, 0, window->width, window->height); + XMoveResizeWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY, window->width, window->height); XMapRaised(xfi->display, window->handle); window->fullscreen = TRUE; @@ -495,9 +497,13 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, */ if (xfi->instance->settings->RemoteApplicationMode) + { XMoveWindow(xfi->display, window->handle, 0, 0); + } else if (settings->DesktopPosX || settings->DesktopPosY) + { XMoveWindow(xfi->display, window->handle, settings->DesktopPosX, settings->DesktopPosY); + } } xf_SetWindowText(xfi, window, name); diff --git a/client/common/cmdline.c b/client/common/cmdline.c index c4dd9dfd8..b3b900153 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -50,6 +50,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" }, { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" }, { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" }, + { "monitors", COMMAND_LINE_VALUE_REQUIRED, "<0,1,2...>", NULL, NULL, -1, NULL, "Select monitors to use" }, { "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" }, { "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" }, { "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" }, @@ -1092,6 +1093,24 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin { settings->Workarea = TRUE; } + CommandLineSwitchCase(arg, "monitors") + { + if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) + { + char** p; + int i, count = 0; + + p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count); + + settings->NumMonitorIds = count; + settings->MonitorIds = (UINT32*) malloc(sizeof(UINT32) * settings->NumMonitorIds); + + for (i = 0; i < settings->NumMonitorIds; i++) + { + settings->MonitorIds[i] = atoi(p[i]); + } + } + } CommandLineSwitchCase(arg, "monitor-list") { settings->ListMonitors = TRUE; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index cd31e5997..6c76735b2 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -812,7 +812,9 @@ struct rdp_settings ALIGN64 UINT32 DesktopPosX; /* 390 */ ALIGN64 UINT32 DesktopPosY; /* 391 */ ALIGN64 BOOL ListMonitors; /* 392 */ - UINT64 padding0448[448 - 393]; /* 393 */ + ALIGN64 UINT32* MonitorIds; /* 393 */ + ALIGN64 UINT32 NumMonitorIds; /* 394 */ + UINT64 padding0448[448 - 395]; /* 395 */ /* Client Message Channel Data */ UINT64 padding0512[512 - 448]; /* 448 */ From 7cf23aff0293ecc5d79e461c16510d1102f17578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 28 Apr 2013 19:16:23 -0400 Subject: [PATCH 038/144] xfreerdp: fix workarea option --- client/X11/xf_monitor.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index b41c8d357..0667e354c 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -167,6 +167,28 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) if (!settings->Fullscreen && !settings->Workarea && !settings->UseMultimon) return TRUE; + if ((settings->Fullscreen && !settings->UseMultimon && !settings->SpanMonitors) || + (settings->Workarea && !settings->RemoteApplicationMode)) + { + /* Select a single monitor */ + + if (settings->NumMonitorIds != 1) + { + settings->NumMonitorIds = 1; + settings->MonitorIds = (UINT32*) malloc(sizeof(UINT32) * settings->NumMonitorIds); + settings->MonitorIds[0] = 0; + + for (i = 0; i < vscreen->nmonitors; i++) + { + if (vscreen->monitors[i].primary) + { + settings->MonitorIds[0] = i; + break; + } + } + } + } + nmonitors = 0; primaryMonitor = 0; @@ -216,6 +238,12 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) vscreen->area.top = 0; vscreen->area.bottom = vHeight - 1; + if (settings->Workarea) + { + vscreen->area.top = xfi->workArea.y; + vscreen->area.bottom = (vHeight - (vHeight - (xfi->workArea.height + xfi->workArea.y))) - 1; + } + if (nmonitors && !primaryMonitor) settings->MonitorDefArray[0].is_primary = TRUE; From fc3324151ce51e8a18ce068f229c9f1b02ce8d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 28 Apr 2013 20:16:04 -0400 Subject: [PATCH 039/144] libfreerdp-locale: fix C++ header --- include/freerdp/locale/keyboard.h | 9 +++++++++ libfreerdp/locale/keyboard_layout.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index 3e57e0b32..32a7ed5fe 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -199,10 +199,19 @@ typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; #define KBD_TYPE_NOKIA_9140 0x00000006 /* Nokia 9140 and similar keyboards */ #define KBD_TYPE_JAPANESE 0x00000007 /* Japanese keyboard */ +#ifdef __cplusplus +extern "C" { +#endif + FREERDP_API DWORD freerdp_keyboard_init(DWORD keyboardLayoutId); FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutId); +FREERDP_API DWORD freerdp_keyboard_get_layout_id_from_name(const char* name); FREERDP_API DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode); FREERDP_API DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended); +#ifdef __cplusplus +} +#endif + #endif /* FREERDP_LOCALE_KEYBOARD_H */ diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index bbc5bbdbf..78e98cf5b 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -285,3 +285,28 @@ const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID) return "unknown"; } + +DWORD freerdp_keyboard_get_layout_id_from_name(const char* name) +{ + int i; + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_LAYOUT_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_LAYOUT_TABLE[i].code; + } + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; + } + + for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) + { + if (strcmp(RDP_KEYBOARD_IME_TABLE[i].name, name) == 0) + return RDP_KEYBOARD_IME_TABLE[i].code; + } + + return 0; +} From 4386f49746b937c4401cebc3c7a4fade719d6b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 28 Apr 2013 20:40:49 -0400 Subject: [PATCH 040/144] libfreerdp-core: add client hook for OnErrorInfo --- include/freerdp/client.h | 2 + include/freerdp/error.h | 104 ++++++++++++++++++++++++++++++++++++++ libfreerdp/core/errinfo.h | 100 ------------------------------------ libfreerdp/core/rdp.c | 6 +++ libfreerdp/core/rdp.h | 4 +- 5 files changed, 114 insertions(+), 102 deletions(-) diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 9963d06c3..0cfbe5d29 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -37,11 +37,13 @@ extern "C" { typedef void (*pOnResizeWindow)(freerdp* instance, int width, int height); typedef void (*pOnWindowStateChange)(freerdp* instance, int state); +typedef void (*pOnErrorInfo)(freerdp* instance, UINT32 code); struct rdp_client { pOnResizeWindow OnResizeWindow; pOnWindowStateChange OnWindowStateChange; + pOnErrorInfo OnErrorInfo; }; /** diff --git a/include/freerdp/error.h b/include/freerdp/error.h index 0bb673956..27d54886a 100644 --- a/include/freerdp/error.h +++ b/include/freerdp/error.h @@ -24,6 +24,110 @@ extern "C" { #endif +/** + * Error Info Codes (Error Info PDU) + */ + +/* Protocol-independent codes */ +#define ERRINFO_RPC_INITIATED_DISCONNECT 0x00000001 +#define ERRINFO_RPC_INITIATED_LOGOFF 0x00000002 +#define ERRINFO_IDLE_TIMEOUT 0x00000003 +#define ERRINFO_LOGON_TIMEOUT 0x00000004 +#define ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION 0x00000005 +#define ERRINFO_OUT_OF_MEMORY 0x00000006 +#define ERRINFO_SERVER_DENIED_CONNECTION 0x00000007 +#define ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES 0x00000009 +#define ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED 0x0000000A +#define ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER 0x0000000B +#define ERRINFO_LOGOFF_BY_USER 0x0000000C + +/* Protocol-independent licensing codes */ +#define ERRINFO_LICENSE_INTERNAL 0x00000100 +#define ERRINFO_LICENSE_NO_LICENSE_SERVER 0x00000101 +#define ERRINFO_LICENSE_NO_LICENSE 0x00000102 +#define ERRINFO_LICENSE_BAD_CLIENT_MSG 0x00000103 +#define ERRINFO_LICENSE_HWID_DOESNT_MATCH_LICENSE 0x00000104 +#define ERRINFO_LICENSE_BAD_CLIENT_LICENSE 0x00000105 +#define ERRINFO_LICENSE_CANT_FINISH_PROTOCOL 0x00000106 +#define ERRINFO_LICENSE_CLIENT_ENDED_PROTOCOL 0x00000107 +#define ERRINFO_LICENSE_BAD_CLIENT_ENCRYPTION 0x00000108 +#define ERRINFO_LICENSE_CANT_UPGRADE_LICENSE 0x00000109 +#define ERRINFO_LICENSE_NO_REMOTE_CONNECTIONS 0x0000010A + +/* RDP specific codes */ +#define ERRINFO_UNKNOWN_DATA_PDU_TYPE 0x000010C9 +#define ERRINFO_UNKNOWN_PDU_TYPE 0x000010CA +#define ERRINFO_DATA_PDU_SEQUENCE 0x000010CB +#define ERRINFO_CONTROL_PDU_SEQUENCE 0x000010CD +#define ERRINFO_INVALID_CONTROL_PDU_ACTION 0x000010CE +#define ERRINFO_INVALID_INPUT_PDU_TYPE 0x000010CF +#define ERRINFO_INVALID_INPUT_PDU_MOUSE 0x000010D0 +#define ERRINFO_INVALID_REFRESH_RECT_PDU 0x000010D1 +#define ERRINFO_CREATE_USER_DATA_FAILED 0x000010D2 +#define ERRINFO_CONNECT_FAILED 0x000010D3 +#define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_SHAREID 0x000010D4 +#define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_ORIGINATOR 0x000010D5 +#define ERRINFO_PERSISTENT_KEY_PDU_BAD_LENGTH 0x000010DA +#define ERRINFO_PERSISTENT_KEY_PDU_ILLEGAL_FIRST 0x000010DB +#define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_TOTAL_KEYS 0x000010DC +#define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_CACHE_KEYS 0x000010DD +#define ERRINFO_INPUT_PDU_BAD_LENGTH 0x000010DE +#define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH 0x000010DF +#define ERRINFO_SECURITY_DATA_TOO_SHORT 0x000010E0 +#define ERRINFO_VCHANNEL_DATA_TOO_SHORT 0x000010E1 +#define ERRINFO_SHARE_DATA_TOO_SHORT 0x000010E2 +#define ERRINFO_BAD_SUPPRESS_OUTPUT_PDU 0x000010E3 +#define ERRINFO_CONFIRM_ACTIVE_PDU_TOO_SHORT 0x000010E5 +#define ERRINFO_CAPABILITY_SET_TOO_SMALL 0x000010E7 +#define ERRINFO_CAPABILITY_SET_TOO_LARGE 0x000010E8 +#define ERRINFO_NO_CURSOR_CACHE 0x000010E9 +#define ERRINFO_BAD_CAPABILITIES 0x000010EA +#define ERRINFO_VIRTUAL_CHANNEL_DECOMPRESSION 0x000010EC +#define ERRINFO_INVALID_VC_COMPRESSION_TYPE 0x000010ED +#define ERRINFO_INVALID_CHANNEL_ID 0x000010EF +#define ERRINFO_VCHANNELS_TOO_MANY 0x000010F0 +#define ERRINFO_REMOTEAPP_NOT_ENABLED 0x000010F3 +#define ERRINFO_CACHE_CAP_NOT_SET 0x000010F4 +#define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH2 0x000010F5 +#define ERRINFO_OFFSCREEN_CACHE_ERROR_PDU_BAD_LENGTH 0x000010F6 +#define ERRINFO_DRAWNINEGRID_CACHE_ERROR_PDU_BAD_LENGTH 0x000010F7 +#define ERRINFO_GDIPLUS_PDU_BAD_LENGTH 0x000010F8 +#define ERRINFO_SECURITY_DATA_TOO_SHORT2 0x00001111 +#define ERRINFO_SECURITY_DATA_TOO_SHORT3 0x00001112 +#define ERRINFO_SECURITY_DATA_TOO_SHORT4 0x00001113 +#define ERRINFO_SECURITY_DATA_TOO_SHORT5 0x00001114 +#define ERRINFO_SECURITY_DATA_TOO_SHORT6 0x00001115 +#define ERRINFO_SECURITY_DATA_TOO_SHORT7 0x00001116 +#define ERRINFO_SECURITY_DATA_TOO_SHORT8 0x00001117 +#define ERRINFO_SECURITY_DATA_TOO_SHORT9 0x00001118 +#define ERRINFO_SECURITY_DATA_TOO_SHORT10 0x00001119 +#define ERRINFO_SECURITY_DATA_TOO_SHORT11 0x0000111A +#define ERRINFO_SECURITY_DATA_TOO_SHORT12 0x0000111B +#define ERRINFO_SECURITY_DATA_TOO_SHORT13 0x0000111C +#define ERRINFO_SECURITY_DATA_TOO_SHORT14 0x0000111D +#define ERRINFO_SECURITY_DATA_TOO_SHORT15 0x0000111E +#define ERRINFO_SECURITY_DATA_TOO_SHORT16 0x0000111F +#define ERRINFO_SECURITY_DATA_TOO_SHORT17 0x00001120 +#define ERRINFO_SECURITY_DATA_TOO_SHORT18 0x00001121 +#define ERRINFO_SECURITY_DATA_TOO_SHORT19 0x00001122 +#define ERRINFO_SECURITY_DATA_TOO_SHORT20 0x00001123 +#define ERRINFO_SECURITY_DATA_TOO_SHORT21 0x00001124 +#define ERRINFO_SECURITY_DATA_TOO_SHORT22 0x00001125 +#define ERRINFO_SECURITY_DATA_TOO_SHORT23 0x00001126 +#define ERRINFO_BAD_MONITOR_DATA 0x00001129 +#define ERRINFO_VC_DECOMPRESSED_REASSEMBLE_FAILED 0x0000112A +#define ERRINFO_VC_DATA_TOO_LONG 0x0000112B +#define ERRINFO_GRAPHICS_MODE_NOT_SUPPORTED 0x0000112D +#define ERRINFO_GRAPHICS_SUBSYSTEM_RESET_FAILED 0x0000112E +#define ERRINFO_UPDATE_SESSION_KEY_FAILED 0x00001191 +#define ERRINFO_DECRYPT_FAILED 0x00001192 +#define ERRINFO_ENCRYPT_FAILED 0x00001193 +#define ERRINFO_ENCRYPTION_PACKAGE_MISMATCH 0x00001194 +#define ERRINFO_DECRYPT_FAILED2 0x00001195 + +#define ERRINFO_SUCCESS 0x00000000 +#define ERRINFO_NONE 0xFFFFFFFF + /** * This static variable holds an error code if the return value from connect is FALSE. * This variable is always set to 0 in the beginning of the connect sequence. diff --git a/libfreerdp/core/errinfo.h b/libfreerdp/core/errinfo.h index aab6ff340..54c1ee7d6 100644 --- a/libfreerdp/core/errinfo.h +++ b/libfreerdp/core/errinfo.h @@ -22,106 +22,6 @@ #include <freerdp/freerdp.h> -/* Protocol-independent codes */ -#define ERRINFO_RPC_INITIATED_DISCONNECT 0x00000001 -#define ERRINFO_RPC_INITIATED_LOGOFF 0x00000002 -#define ERRINFO_IDLE_TIMEOUT 0x00000003 -#define ERRINFO_LOGON_TIMEOUT 0x00000004 -#define ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION 0x00000005 -#define ERRINFO_OUT_OF_MEMORY 0x00000006 -#define ERRINFO_SERVER_DENIED_CONNECTION 0x00000007 -#define ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES 0x00000009 -#define ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED 0x0000000A -#define ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER 0x0000000B -#define ERRINFO_LOGOFF_BY_USER 0x0000000C - -/* Protocol-independent licensing codes */ -#define ERRINFO_LICENSE_INTERNAL 0x00000100 -#define ERRINFO_LICENSE_NO_LICENSE_SERVER 0x00000101 -#define ERRINFO_LICENSE_NO_LICENSE 0x00000102 -#define ERRINFO_LICENSE_BAD_CLIENT_MSG 0x00000103 -#define ERRINFO_LICENSE_HWID_DOESNT_MATCH_LICENSE 0x00000104 -#define ERRINFO_LICENSE_BAD_CLIENT_LICENSE 0x00000105 -#define ERRINFO_LICENSE_CANT_FINISH_PROTOCOL 0x00000106 -#define ERRINFO_LICENSE_CLIENT_ENDED_PROTOCOL 0x00000107 -#define ERRINFO_LICENSE_BAD_CLIENT_ENCRYPTION 0x00000108 -#define ERRINFO_LICENSE_CANT_UPGRADE_LICENSE 0x00000109 -#define ERRINFO_LICENSE_NO_REMOTE_CONNECTIONS 0x0000010A - -/* RDP specific codes */ -#define ERRINFO_UNKNOWN_DATA_PDU_TYPE 0x000010C9 -#define ERRINFO_UNKNOWN_PDU_TYPE 0x000010CA -#define ERRINFO_DATA_PDU_SEQUENCE 0x000010CB -#define ERRINFO_CONTROL_PDU_SEQUENCE 0x000010CD -#define ERRINFO_INVALID_CONTROL_PDU_ACTION 0x000010CE -#define ERRINFO_INVALID_INPUT_PDU_TYPE 0x000010CF -#define ERRINFO_INVALID_INPUT_PDU_MOUSE 0x000010D0 -#define ERRINFO_INVALID_REFRESH_RECT_PDU 0x000010D1 -#define ERRINFO_CREATE_USER_DATA_FAILED 0x000010D2 -#define ERRINFO_CONNECT_FAILED 0x000010D3 -#define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_SHAREID 0x000010D4 -#define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_ORIGINATOR 0x000010D5 -#define ERRINFO_PERSISTENT_KEY_PDU_BAD_LENGTH 0x000010DA -#define ERRINFO_PERSISTENT_KEY_PDU_ILLEGAL_FIRST 0x000010DB -#define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_TOTAL_KEYS 0x000010DC -#define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_CACHE_KEYS 0x000010DD -#define ERRINFO_INPUT_PDU_BAD_LENGTH 0x000010DE -#define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH 0x000010DF -#define ERRINFO_SECURITY_DATA_TOO_SHORT 0x000010E0 -#define ERRINFO_VCHANNEL_DATA_TOO_SHORT 0x000010E1 -#define ERRINFO_SHARE_DATA_TOO_SHORT 0x000010E2 -#define ERRINFO_BAD_SUPPRESS_OUTPUT_PDU 0x000010E3 -#define ERRINFO_CONFIRM_ACTIVE_PDU_TOO_SHORT 0x000010E5 -#define ERRINFO_CAPABILITY_SET_TOO_SMALL 0x000010E7 -#define ERRINFO_CAPABILITY_SET_TOO_LARGE 0x000010E8 -#define ERRINFO_NO_CURSOR_CACHE 0x000010E9 -#define ERRINFO_BAD_CAPABILITIES 0x000010EA -#define ERRINFO_VIRTUAL_CHANNEL_DECOMPRESSION 0x000010EC -#define ERRINFO_INVALID_VC_COMPRESSION_TYPE 0x000010ED -#define ERRINFO_INVALID_CHANNEL_ID 0x000010EF -#define ERRINFO_VCHANNELS_TOO_MANY 0x000010F0 -#define ERRINFO_REMOTEAPP_NOT_ENABLED 0x000010F3 -#define ERRINFO_CACHE_CAP_NOT_SET 0x000010F4 -#define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH2 0x000010F5 -#define ERRINFO_OFFSCREEN_CACHE_ERROR_PDU_BAD_LENGTH 0x000010F6 -#define ERRINFO_DRAWNINEGRID_CACHE_ERROR_PDU_BAD_LENGTH 0x000010F7 -#define ERRINFO_GDIPLUS_PDU_BAD_LENGTH 0x000010F8 -#define ERRINFO_SECURITY_DATA_TOO_SHORT2 0x00001111 -#define ERRINFO_SECURITY_DATA_TOO_SHORT3 0x00001112 -#define ERRINFO_SECURITY_DATA_TOO_SHORT4 0x00001113 -#define ERRINFO_SECURITY_DATA_TOO_SHORT5 0x00001114 -#define ERRINFO_SECURITY_DATA_TOO_SHORT6 0x00001115 -#define ERRINFO_SECURITY_DATA_TOO_SHORT7 0x00001116 -#define ERRINFO_SECURITY_DATA_TOO_SHORT8 0x00001117 -#define ERRINFO_SECURITY_DATA_TOO_SHORT9 0x00001118 -#define ERRINFO_SECURITY_DATA_TOO_SHORT10 0x00001119 -#define ERRINFO_SECURITY_DATA_TOO_SHORT11 0x0000111A -#define ERRINFO_SECURITY_DATA_TOO_SHORT12 0x0000111B -#define ERRINFO_SECURITY_DATA_TOO_SHORT13 0x0000111C -#define ERRINFO_SECURITY_DATA_TOO_SHORT14 0x0000111D -#define ERRINFO_SECURITY_DATA_TOO_SHORT15 0x0000111E -#define ERRINFO_SECURITY_DATA_TOO_SHORT16 0x0000111F -#define ERRINFO_SECURITY_DATA_TOO_SHORT17 0x00001120 -#define ERRINFO_SECURITY_DATA_TOO_SHORT18 0x00001121 -#define ERRINFO_SECURITY_DATA_TOO_SHORT19 0x00001122 -#define ERRINFO_SECURITY_DATA_TOO_SHORT20 0x00001123 -#define ERRINFO_SECURITY_DATA_TOO_SHORT21 0x00001124 -#define ERRINFO_SECURITY_DATA_TOO_SHORT22 0x00001125 -#define ERRINFO_SECURITY_DATA_TOO_SHORT23 0x00001126 -#define ERRINFO_BAD_MONITOR_DATA 0x00001129 -#define ERRINFO_VC_DECOMPRESSED_REASSEMBLE_FAILED 0x0000112A -#define ERRINFO_VC_DATA_TOO_LONG 0x0000112B -#define ERRINFO_GRAPHICS_MODE_NOT_SUPPORTED 0x0000112D -#define ERRINFO_GRAPHICS_SUBSYSTEM_RESET_FAILED 0x0000112E -#define ERRINFO_UPDATE_SESSION_KEY_FAILED 0x00001191 -#define ERRINFO_DECRYPT_FAILED 0x00001192 -#define ERRINFO_ENCRYPT_FAILED 0x00001193 -#define ERRINFO_ENCRYPTION_PACKAGE_MISMATCH 0x00001194 -#define ERRINFO_DECRYPT_FAILED2 0x00001195 - -#define ERRINFO_SUCCESS 0x00000000 -#define ERRINFO_NONE 0xFFFFFFFF - struct _ERRINFO { UINT32 code; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index d5ca4e2f9..e7f3f5e82 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -490,8 +490,14 @@ BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s) stream_read_UINT32(s, rdp->errorInfo); /* errorInfo (4 bytes) */ if (rdp->errorInfo != ERRINFO_SUCCESS) + { + rdpClient* client = rdp->instance->context->client; + rdp_print_errinfo(rdp->errorInfo); + IFCALL(client->OnErrorInfo, rdp->instance, rdp->errorInfo); + } + return TRUE; } diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index a8128c2ee..ef1668515 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -54,8 +54,8 @@ #define SEC_ENCRYPT 0x0008 #define SEC_RESET_SEQNO 0x0010 #define SEC_IGNORE_SEQNO 0x0020 -#define SEC_INFO_PKT 0x0040 -#define SEC_LICENSE_PKT 0x0080 +#define SEC_INFO_PKT 0x0040 +#define SEC_LICENSE_PKT 0x0080 #define SEC_LICENSE_ENCRYPT_CS 0x0200 #define SEC_LICENSE_ENCRYPT_SC 0x0200 #define SEC_REDIRECTION_PKT 0x0400 From 52dbb7f47da543eaa9ca3925260340fcec3d23a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 13:09:23 -0400 Subject: [PATCH 041/144] libfreerdp-gdi: fix C++ headers --- include/freerdp/gdi/gdi.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/freerdp/gdi/gdi.h b/include/freerdp/gdi/gdi.h index 4403c3424..a4172521e 100644 --- a/include/freerdp/gdi/gdi.h +++ b/include/freerdp/gdi/gdi.h @@ -288,6 +288,10 @@ struct rdp_gdi gdiBitmap* image; }; +#ifdef __cplusplus +extern "C" { +#endif + FREERDP_API UINT32 gdi_rop3_code(BYTE code); FREERDP_API BYTE* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y); FREERDP_API BYTE* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y); @@ -297,6 +301,10 @@ FREERDP_API void gdi_resize(rdpGdi* gdi, int width, int height); FREERDP_API int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer); FREERDP_API void gdi_free(freerdp* instance); +#ifdef __cplusplus +} +#endif + #ifdef WITH_DEBUG_GDI #define DEBUG_GDI(fmt, ...) DEBUG_CLASS(GDI, fmt, ## __VA_ARGS__) #else From 037d6edd19c33b4073eae0fa13c1ba398764a83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 15:38:18 -0400 Subject: [PATCH 042/144] xfreerdp-server: implement interface --- server/X11/CMakeLists.txt | 8 +- server/X11/xf_interface.c | 153 ++++++++++++++++++++++++++++++++++++++ server/X11/xf_interface.h | 50 +++++++++++++ server/X11/xfreerdp.c | 97 ++++-------------------- server/X11/xfreerdp.h | 17 ++++- 5 files changed, 240 insertions(+), 85 deletions(-) create mode 100644 server/X11/xf_interface.c create mode 100644 server/X11/xf_interface.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 799b58e18..1aa0f94cf 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -23,9 +23,15 @@ include_directories("../../winpr/tools/makecert") set(${MODULE_PREFIX}_SRCS xf_peer.c + xf_peer.h xf_input.c + xf_input.h xf_encode.c - xfreerdp.c) + xf_encode.h + xf_interface.c + xf_interface.h + xfreerdp.c + xfreerdp.h) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) diff --git a/server/X11/xf_interface.c b/server/X11/xf_interface.c new file mode 100644 index 000000000..2d70b3c1c --- /dev/null +++ b/server/X11/xf_interface.c @@ -0,0 +1,153 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP X11 Server Interface + * + * 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. + */ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <sys/select.h> +#include <sys/signal.h> + +#include "xf_peer.h" +#include "xfreerdp.h" + +#include "xf_interface.h" + +void* xf_server_thread(void* param) +{ + int i; + int fds; + int max_fds; + int rcount; + void* rfds[32]; + fd_set rfds_set; + xfServer* server; + freerdp_listener* listener; + + ZeroMemory(rfds, sizeof(rfds)); + + server = (xfServer*) param; + listener = server->listener; + + while (1) + { + rcount = 0; + + if (listener->GetFileDescriptor(listener, rfds, &rcount) != TRUE) + { + fprintf(stderr, "Failed to get FreeRDP file descriptor\n"); + break; + } + + max_fds = 0; + FD_ZERO(&rfds_set); + + for (i = 0; i < rcount; i++) + { + fds = (int)(long)(rfds[i]); + + if (fds > max_fds) + max_fds = fds; + + FD_SET(fds, &rfds_set); + } + + if (max_fds == 0) + break; + + if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) + { + /* these are not really errors */ + if (!((errno == EAGAIN) || + (errno == EWOULDBLOCK) || + (errno == EINPROGRESS) || + (errno == EINTR))) /* signal occurred */ + { + fprintf(stderr, "select failed\n"); + break; + } + } + + if (listener->CheckFileDescriptor(listener) != TRUE) + { + fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); + break; + } + } + + listener->Close(listener); + + return NULL; +} + +int freerdp_server_global_init() +{ + /* + * ignore SIGPIPE, otherwise an SSL_write failure could crash the server + */ + signal(SIGPIPE, SIG_IGN); + + return 0; +} + +int freerdp_server_global_uninit() +{ + return 0; +} + +int freerdp_server_start(xfServer* server) +{ + if (server->listener->Open(server->listener, NULL, 3389)) + { + server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) server, 0, NULL); + } + + return 0; +} + +int freerdp_server_stop(xfServer* server) +{ + return 0; +} + +xfServer* freerdp_server_new(int argc, char** argv) +{ + xfServer* server; + + server = (xfServer*) malloc(sizeof(xfServer)); + + if (server) + { + server->listener = freerdp_listener_new(); + server->listener->PeerAccepted = xf_peer_accepted; + } + + return server; +} + +void freerdp_server_free(xfServer* server) +{ + if (server) + { + freerdp_listener_free(server->listener); + free(server); + } +} diff --git a/server/X11/xf_interface.h b/server/X11/xf_interface.h new file mode 100644 index 000000000..1fd07e47f --- /dev/null +++ b/server/X11/xf_interface.h @@ -0,0 +1,50 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP X11 Server Interface + * + * 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 XFREERDP_SERVER_INTERFACE_H +#define XFREERDP_SERVER_INTERFACE_H + +#include <freerdp/api.h> +#include <freerdp/freerdp.h> + +typedef struct xf_info xfInfo; +typedef struct xf_server xfServer; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Server Interface + */ + +FREERDP_API int freerdp_server_global_init(); +FREERDP_API int freerdp_server_global_uninit(); + +FREERDP_API int freerdp_server_start(xfServer* server); +FREERDP_API int freerdp_server_stop(xfServer* server); + +FREERDP_API xfServer* freerdp_server_new(int argc, char** argv); +FREERDP_API void freerdp_server_free(xfServer* server); + +#ifdef __cplusplus +} +#endif + +#endif /* XFREERDP_SERVER_INTERFACE_H */ diff --git a/server/X11/xfreerdp.c b/server/X11/xfreerdp.c index ce89aba0d..3f952f1c6 100644 --- a/server/X11/xfreerdp.c +++ b/server/X11/xfreerdp.c @@ -21,97 +21,30 @@ #include "config.h" #endif -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <sys/select.h> -#include <sys/signal.h> - #include "xf_peer.h" #include "xfreerdp.h" -void xf_server_main_loop(freerdp_listener* instance) -{ - int i; - int fds; - int max_fds; - int rcount; - void* rfds[32]; - fd_set rfds_set; - - ZeroMemory(rfds, sizeof(rfds)); - - while (1) - { - rcount = 0; - - if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE) - { - fprintf(stderr, "Failed to get FreeRDP file descriptor\n"); - break; - } - - max_fds = 0; - FD_ZERO(&rfds_set); - - for (i = 0; i < rcount; i++) - { - fds = (int)(long)(rfds[i]); - - if (fds > max_fds) - max_fds = fds; - - FD_SET(fds, &rfds_set); - } - - if (max_fds == 0) - break; - - if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) - { - /* these are not really errors */ - if (!((errno == EAGAIN) || - (errno == EWOULDBLOCK) || - (errno == EINPROGRESS) || - (errno == EINTR))) /* signal occurred */ - { - fprintf(stderr, "select failed\n"); - break; - } - } - - if (instance->CheckFileDescriptor(instance) != TRUE) - { - fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); - break; - } - } - - instance->Close(instance); -} - int main(int argc, char* argv[]) { - freerdp_listener* instance; + xfServer* server; + DWORD dwExitCode; - /* ignore SIGPIPE, otherwise an SSL_write failure could crash the server */ - signal(SIGPIPE, SIG_IGN); + freerdp_server_global_init(); - instance = freerdp_listener_new(); - instance->PeerAccepted = xf_peer_accepted; + server = freerdp_server_new(argc, argv); - /* Open the server socket and start listening. */ - if (instance->Open(instance, NULL, 3389)) - { - /* Entering the server main loop. In a real server the listener can be run in its own thread. */ - xf_server_main_loop(instance); - } + if (!server) + return 0; - freerdp_listener_free(instance); + freerdp_server_start(server); + + WaitForSingleObject(server->thread, INFINITE); + + GetExitCodeThread(server->thread, &dwExitCode); + + freerdp_server_free(server); + + freerdp_server_global_uninit(); return 0; } - diff --git a/server/X11/xfreerdp.h b/server/X11/xfreerdp.h index d2d4a8f41..f0ca84f19 100644 --- a/server/X11/xfreerdp.h +++ b/server/X11/xfreerdp.h @@ -20,6 +20,12 @@ #ifndef __XFREERDP_H #define __XFREERDP_H +#include "xf_interface.h" + +#include <freerdp/api.h> +#include <freerdp/freerdp.h> +#include <freerdp/listener.h> + #include <freerdp/codec/color.h> #ifdef WITH_XSHM @@ -38,8 +44,6 @@ #include <X11/extensions/Xdamage.h> #endif -typedef struct xf_info xfInfo; - struct xf_info { int bpp; @@ -70,4 +74,13 @@ struct xf_info #endif }; +struct xf_server +{ + DWORD port; + HANDLE thread; + freerdp_listener* listener; +}; + +void* xf_server_thread(void* param); + #endif /* __XFREERDP_H */ From 983f42254d66cf7c6232748f681e09a59aef9d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 16:37:11 -0400 Subject: [PATCH 043/144] xfreerdp-server: split into library/executable --- CMakeLists.txt | 7 +++---- client/X11/CMakeLists.txt | 3 ++- client/X11/cli/CMakeLists.txt | 3 ++- server/X11/CMakeLists.txt | 24 +++++++++++++++++---- server/X11/cli/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++ server/X11/cli/xfreerdp-server | Bin 0 -> 10847 bytes server/X11/{ => cli}/xfreerdp.c | 10 +++++---- server/X11/xf_interface.c | 7 ++++++- server/X11/xf_interface.h | 4 ++++ 9 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 server/X11/cli/CMakeLists.txt create mode 100755 server/X11/cli/xfreerdp-server rename server/X11/{ => cli}/xfreerdp.c (86%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78ba4ae0e..e1e369aff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,9 @@ endif() # Compiler-specific flags if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686") - if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") endif() endif() @@ -151,9 +153,6 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") endif() - if(${CMAKE_VERSION} VERSION_LESS 2.8.9) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() if(WITH_SSE2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") endif() diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 2f833ed9d..96f4ec419 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -53,6 +53,7 @@ if(WITH_CLIENT_INTERFACE) else() set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/xfreerdp.c cli/xfreerdp.h) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") endif() set(${MODULE_PREFIX}_LIBS @@ -146,7 +147,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHI target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) if(WITH_IPP) - target_link_libraries(xfreerdp ${IPP_LIBRARY_LIST}) + target_link_libraries(${MODULE_NAME} ${IPP_LIBRARY_LIST}) endif() if(WITH_CLIENT_INTERFACE) diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index 0abac9e69..2beef85b9 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(MODULE_NAME "xfreerdp") +set(MODULE_NAME "xfreerdp-cli") set(MODULE_PREFIX "FREERDP_CLIENT_X11") include_directories(..) @@ -24,6 +24,7 @@ set(${MODULE_PREFIX}_SRCS xfreerdp.c) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-client) diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 1aa0f94cf..2128d8f31 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -16,7 +16,7 @@ # limitations under the License. set(MODULE_NAME "xfreerdp-server") -set(MODULE_PREFIX "FREERDP_SERVER_X11") +set(MODULE_PREFIX "FREERDP_SERVER_X11_CONTROL") include_directories(${X11_INCLUDE_DIRS}) include_directories("../../winpr/tools/makecert") @@ -30,10 +30,20 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_interface.c xf_interface.h - xfreerdp.c xfreerdp.h) -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +if(WITH_SERVER_INTERFACE) + if(SERVER_INTERFACE_SHARED) + add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS}) + else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + endif() + set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION} PREFIX "lib") +else() + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/xfreerdp.c) + add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server") +endif() set(XEXT_FEATURE_TYPE "RECOMMENDED") set(XEXT_FEATURE_PURPOSE "X11 extension") @@ -106,7 +116,13 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-makecert-tool) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) -install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(WITH_SERVER_INTERFACE) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + add_subdirectory(cli) +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) +endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11") diff --git a/server/X11/cli/CMakeLists.txt b/server/X11/cli/CMakeLists.txt new file mode 100644 index 000000000..9d5dd037d --- /dev/null +++ b/server/X11/cli/CMakeLists.txt @@ -0,0 +1,36 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP X11 cmake build script +# +# Copyright 2012 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. + +set(MODULE_NAME "xfreerdp-server-cli") +set(MODULE_PREFIX "FREERDP_SERVER_X11") + +include_directories(..) + +set(${MODULE_PREFIX}_SRCS + xfreerdp.c) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server") + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-server) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11") + diff --git a/server/X11/cli/xfreerdp-server b/server/X11/cli/xfreerdp-server new file mode 100755 index 0000000000000000000000000000000000000000..9e837526bcf2d214862ecced6059b2a82ddf5e02 GIT binary patch literal 10847 zcmeHNdvIITnLoOcZ8>%v=K&2#0CjOnV6bGT#<-yYIetW@N&<-kX(3$8(zUH1ORjWf zJ1pI%lfqODVNJ`hY};Yd>CU#(*D&oqvMfVG(;<{8GwEZy?1r7m!iKdW3}MMK-nQWV zednA{y1J5f(w*sl{Sw{pe82B;9{1ey^7-sQbkOj41d}0d5hOj;7?zNFLcUyz8tV~_ zA}rd(hebV*I{d;?LtLepFY3_D{o2k8?!&LgP(Y6nmI>w?6fBr?35ipFB?{}L;=gKE zB6A@E5+FY+>)GW}1Rs$J=5x9nPiW45B$D5v_FL3`%mv$P&h?|Z(QjDe!$ueq$zfum zUp`BmY>93^XD6huu7|HVEOF*HNJ$9h>~{zJsGOHdT+ZD(zgq1Q(B)^&?;(^*j&^s2 zQi=9dGM%4opY7>x@9qlbGQrKV-mNGI*>2ytR~CuFQ2Ey4M`d1vAN2v!Zw(*FUiS9V z*EXIT{>Ba0e*F4t2Y0+hx)%J%uK~Zg)<b^r;WdqZpKtjWd?HM`mH1J-Z3F*w{y<~j zumAD2FFnw_<u97P`-#_19Qf>49@sp3=B?vL-)VXI)B84@dFiz$-}vR*Ez8%u`XpRx z($}F`RYhx{GSzUqhW$rs*uPlA{(9g6{M__+0IKEtpEdAXfCun%)3zGrc?5>l;;#oD za0h|>sT%k&;<w^$Otp@bc`e5aBz(k$k4yV2#H<Tn0sBA|`ww8hQmhbyzXzSmF5s)g za`DWvutfe+<Es&ea304rEPjW?D$yhs{b7bAzgw5bUH)}C&PbE8FKDkWiMNQ08s}iw zYx@ftho}hO%j{Uzva*S(_MDZSwzBlGbOt+xX^u~3(q_(%Wo^?G=55pFZfiW5v#o4j zDwfMxIbjYB?=TZqR>Q+P`cj#+H5?mFSxQ$`qq8$rcILQcoAyN3iY0_gleT8ukSvWG zBsVuUp302IQf5A#OegIcN~yXlmb3>m**(ehc*@!}dcca?0*x}0Oi#(C=s;6!x9ox0 zq}`WESi`EMu!vJbb)%Umt($2wmP`xNO2q6K6r;JE!U3fdA~cbiv_i3&*nL)LJZY;` zJd;4qp+Qt(cmM4n)h3~Rot;}Q#T;4dHoGKqSt%MKWnv57(JmAa1u*kDD}fSI!MVt) zUh!Psl<lPJN%9x~u{}Dpt<T&X+#I}-`%)R_9_A6%|0!eA^~gT1<ovp1BaN<GwEN<U z5viatT2DPvUaP-P8iV0pq<{nG5|DC}1E(>Zsl$QuoJG1G2kxBL!w#JCW{Nm)p2J9Y zy8~aw#^C!Lc#{K<96s-#KLa3g_$U68CB@Q>|5YClOB*lZx#H?DQY251!NS=k(8f1N zrlwdpE#+59rY2Z8A?1H1nX10<l$3u#GF5run3P{6nX0-lC*>cLOwGP<NXk!>+(7b_ zlz%`nRdrzma_3t^g`eLWDZCmv{2v!?A09e&f<~Iispn{bikvz{<KX<?!|>wR9Mv&$ zq;4ewL>@e08%w8UWygXmuKqmY2~<!VpFsodjkMFa7dgDx5-FUUG4`K4PHJ+xxc^6_ zS~|Pp>O+JbCyDK!TlB&{QuuM?xi@Z&cuq$O&qsd#K_323lWpX|Uljdc)&7UJ{!d*% zi2TaE@SOiM6m<Xdb*}^RynB+`J92pIJ}(UH^~EBr-20;o%Tc<*xuw(l7ycA33)6Uv z%~1%{v7_*rS0aV{Y3VTkoe!3lB1iU~J~9CC*M(E_PZLlWxDYw~nF}J{Ag$iKJ8}dF zv>T+kN_QyBMd%ivMGkN~HQz+w(Y^BoA|OF)9X>Z8tukK4sh^%KweVb|kZOB5T1d2= zjT~*CF#;lbbmIgu;PcUf-F6{bc%TiD?`gx^Io}h#?p$x-{h`8pk>}p`4i)}+e$V^J z|G~HH4V`DGeWHcmL<{fr7vAn&TJuWe@JUbPV{hi)h#a}64X--Y)*3yMXj>aaDiA$l zw{40Zd7!NWZ@mYNdkC*YynAwNPWB7k?L8O+JnOwTZ-S0GX*06x2S1M5q`>b%Gdv7_ z9{g{>Y28NTxqr9t%(i;gH#hj_@HMmnqqX{p-z_a20~al=gDq=sThTP*KO}Blck}fh zZTk~~$%f+hBfgxgds|u`GWwR+8;>E9ij#o;1?UUl;*N*w9;!E6!iO9F+<3%$)MxB# zp^t&eLFMW|xt!w<pg)qM1?Dgw5KU<=1w42xck|0Nz&OnrL|A!AN@=-S%e;=#+oR%o z=nAdp{S~bziRj%Cty4_Q<I5)EeID!o`-7zn;ZGQ0V#Ph*M4gg(ud`?<naBJ=-5GeS zUkhKN%M>d<X@Hi5;f#p;(92RP^>Z4Ci9V#52<UYq<9;o3xj8>fu98?rcb4^;ZwN~q z-B!xn&KI=&eXUpCfB0u{AM48MBYOYet@)tlcWOSS`LyN_Y5ut8f33MItk~Yyw<WM? z?`S@4=R?tCI+o1@x`H<aH@9!jOR)1gCD*X*4t}(~v%_HuAh5Zkb92YXI(q_}rm|Qh zr>t1cx=wD9)oWER$Gt^x7p)8LLfd;*L+MH4@dAGAxEE6_li_cmA<yvmZzE<j{4FtG z!*vp@k4mtv9wEKHx@6iGhQE#`efWJB%;&H3)7H`O)bEif=}37sSp8L0lCAB8_<Z!K z)_;hQJ5tidHwsqgPm^Ug9^NaT#j{}_9v;7^h1fdJU0~J9?de3M#&1d^vN0ZwHvU#h z-;+{!St|@Y8@?)~iDh?_?n-hp9vxYBD@j)sq;4O|@I$18XQgLj%jza?%lej;o>iV! ze40j^Xll9z5K5<$cn7`}Kv8sJLuldp%Z0aPOViC#Xjl#5;}}-_LC>wt3ct2_Xf=fl z*FV0knchibUD3n97r(5lOcZ`9rZ`Jw^8B`CIiB)liz;*}i~Q1_AQVp}FKHX07W&C_ zJe5yaAt_ywUwKxcU{DC&9R}m{#%Jt<Q&uiGK|OMI3_Ant2FGG?3y2)L8V!EC-gTaZ zWBzD<`k9OVHU5rgj(yU=l<vU>aXcU&)cfRq31=;VKK*r-)cJHSIi9u>0kWGN+avd; zA~C}oF;O&#PsFlR7*%+Y$mD7N`TMtQ$Whf;c04X}$@?v;ugFbgvUZ@DA(iO&4=)gN zT8yPKF<S?uIC|$B>D}2M9T5F@?b=Pt5JhNjNrsrAE+omPIj~kvKT*V{TRF`K4&<xV zB^JyboU~)3BABzYicfF~WwNqUBACwDR<L*5P`e!)*V1@89~{jmakiFBh#*N5vD}0R zCJv?%PjNe|G&o1dB{S(V!GsQ@V2m7eYAR)mpxj;tZEF^3xwQ;tGjazVv?k24Y;4jp zClc^wNqLyDY&LdKd2sqb9A=0fn@q-$bp`?P2+CYkL~O}LFrJy5w9xj!gf*HUhjT1F zj?)Y+CevdXPRB+^v(_|AI8wAYjrQVXDibd??f)}H>kxXyYM`g{=P;zwIW(_BB!~xh z2bQlvg64kqA2z~}O6R-*DU}}Fbr|VH!s%}tVX3lpz&0tB9&Z1BsNTa`f%AXD2uou= zx4uV8rS+1#Pws>sV{ozji$)j{&bM{IDa~npMRjNYwPXak6F(Y&IDcM`$sH|lUVkAe z$=!bU0;RPN`}2C|`_w3)F2#!LJ+@<hAM~`AVwu-d^V&b4{oUo)u(%%yYE$+vuHSS; zxt?-9hMl|qpLhB5dN803UxuED{4tqT_&)-S+N8LC)$7Ma?T;C=jNI>^=3b|Nt6pcd zHY&GcW!`l5s)+ex5S{*fKKhjQ@8^bb`Dsyn#pTcEpBJf9fpi!p;OQ>^F<_K`@yxk7 z3<*Sy1#;W7%=}xhA%89=|6RnV{coTk4q`us=sex&-=XvG(EfkLhMM#HXZQpX^p4~t z49@!-{`-mB-Yx$OKD3u&f8PJh>kX9K-YrxAqVlspos1A&xJ3VdgDv$v_UH9K|9y)a zmis5?&;93h_&W3FbHhcd6o~DWRFWBg6AGulXdO|eIs+{!3{UoBei4|{pZ~5fqW!s? z9Dw~;{*8{w^{3-3qABg@ws-fRCD>B_9pvO7_NVd5Nn}gJoYohdRvPs@qw{yib=%TL zz>QIaCi-I-i1+JCs<gePhJT;_Aiv0tn!EF&oq!u7)0eb=vrFj`#a8X_uIImCbx+jh za$u2pMEfi2()0Z_Dm_wyWQzS5re@-I&lvIj`hZ}M%fThey7SoM^nZ#rZlFVY9=ZnU zoABfQ#PbS`kJa+;xE2af$fb1WudJ#+y(nFe5w1{r@lg*~#l6C=iu;P^F3w<H%xa5O z?dx%(9d??^v==KKp5L8HFIt7??Q*<P@O)g3FDstAl;f3u$0NNLlL^m@<@S|-4^;M* zf5%fe1~s0a9D%%;Re9cVz{q!{;Q6E+UsaqZ%JJ33^RIGz4aV~kCnVEeoMQ2K?NoZj z<$}lIavY~tJia;<-YS1zCAC*vQStX%h4X2hBZ#!8)pR9!i>G<zI<L609MF<iTvY?t zAC*h%6#*Bb#w4G3hlb}e>W5_D@4&C<brLIwk*H>G0{7r_+1>sr9Y-t+BUPf$AxZH& zT=-)ecb~g{8@R{O&isA<gTyQQ!&x0?&K3W>w6E+}O$b=6UbX5==e-{E+taRoPUCR3 zc0jgO<9A5=wPM26-_&?t*>4B6J<q=smuNR|S{?Gbh$N!8#(BM^P$8yeoXURwFz{;k z5xxw(+Wmqjfmgd<@IBzw?ic((;#`UnKPB<X@#Li%_W!Qq^E#X(&DXHU*-mNg%*Nnr zBwjfls{0ELL!G<{_JK-Re4<8t6L__I94U!c-sAXmjW`c$d-r>%{VTPz`<}(OfLAN$ zPqe-Jp2e>uURkksYvA>mZ>z<>tOhPZ`COL%vL70c$3wXFWOjGyD^NJ73E?Okhk5#c zg*KkGlfjIL$5JWBoeu#xXXnSpaPnuGxApBdqeFX!aTBC;;ls2i%{X28$O*pb;ec?R zAY<x#7zsO*&6%<Mtia*RRLZigM6mm&t}eQBP-!G@7^p)X+?=qp2XTRej)4;S$;pFo zaY*uVLYb-K6wfpVclYiXFb8(_(+w6`2~H<+8FM0*PS91A{!i}g-7(Y$3tV9-TGP2y zF*4nbZ~*Eain%?yYg=#B+%-73XJFVI?%ft0KtAgJhx0B)`8^AH>gl@cq65nFuWDCP z^sNk+m*ehC<sB7uZ^P|Tb}y#dr5=|9iKx4?HguWAWu;%UJjyG(_~O1r@_*eJD%r|r csJK}Z4m&TMxJp2mh1^$`C^PPuWtWrw7g?b$^Z)<= literal 0 HcmV?d00001 diff --git a/server/X11/xfreerdp.c b/server/X11/cli/xfreerdp.c similarity index 86% rename from server/X11/xfreerdp.c rename to server/X11/cli/xfreerdp.c index 3f952f1c6..bd3b27729 100644 --- a/server/X11/xfreerdp.c +++ b/server/X11/cli/xfreerdp.c @@ -21,11 +21,11 @@ #include "config.h" #endif -#include "xf_peer.h" -#include "xfreerdp.h" +#include "xf_interface.h" int main(int argc, char* argv[]) { + HANDLE thread; xfServer* server; DWORD dwExitCode; @@ -38,9 +38,11 @@ int main(int argc, char* argv[]) freerdp_server_start(server); - WaitForSingleObject(server->thread, INFINITE); + thread = freerdp_server_get_thread(server); - GetExitCodeThread(server->thread, &dwExitCode); + WaitForSingleObject(thread, INFINITE); + + GetExitCodeThread(thread, &dwExitCode); freerdp_server_free(server); diff --git a/server/X11/xf_interface.c b/server/X11/xf_interface.c index 2d70b3c1c..1c93b5e4e 100644 --- a/server/X11/xf_interface.c +++ b/server/X11/xf_interface.c @@ -117,7 +117,7 @@ int freerdp_server_start(xfServer* server) { if (server->listener->Open(server->listener, NULL, 3389)) { - server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) server, 0, NULL); + server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_server_thread, (void*) server, 0, NULL); } return 0; @@ -128,6 +128,11 @@ int freerdp_server_stop(xfServer* server) return 0; } +HANDLE freerdp_server_get_thread(xfServer* server) +{ + return server->thread; +} + xfServer* freerdp_server_new(int argc, char** argv) { xfServer* server; diff --git a/server/X11/xf_interface.h b/server/X11/xf_interface.h index 1fd07e47f..f62d36450 100644 --- a/server/X11/xf_interface.h +++ b/server/X11/xf_interface.h @@ -20,6 +20,8 @@ #ifndef XFREERDP_SERVER_INTERFACE_H #define XFREERDP_SERVER_INTERFACE_H +#include <winpr/crt.h> + #include <freerdp/api.h> #include <freerdp/freerdp.h> @@ -40,6 +42,8 @@ FREERDP_API int freerdp_server_global_uninit(); FREERDP_API int freerdp_server_start(xfServer* server); FREERDP_API int freerdp_server_stop(xfServer* server); +FREERDP_API HANDLE freerdp_server_get_thread(xfServer* server); + FREERDP_API xfServer* freerdp_server_new(int argc, char** argv); FREERDP_API void freerdp_server_free(xfServer* server); From 97b0aebeef01123143564e4d93508cb35baa9cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 16:40:30 -0400 Subject: [PATCH 044/144] xfreerdp: change default build tree output path --- client/X11/cli/CMakeLists.txt | 2 +- server/X11/cli/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index 2beef85b9..ccd38e1d1 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -24,7 +24,7 @@ set(${MODULE_PREFIX}_SRCS xfreerdp.c) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp" RUNTIME_OUTPUT_DIRECTORY "..") set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-client) diff --git a/server/X11/cli/CMakeLists.txt b/server/X11/cli/CMakeLists.txt index 9d5dd037d..6d0d45ff3 100644 --- a/server/X11/cli/CMakeLists.txt +++ b/server/X11/cli/CMakeLists.txt @@ -24,7 +24,7 @@ set(${MODULE_PREFIX}_SRCS xfreerdp.c) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server") +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server" RUNTIME_OUTPUT_DIRECTORY "..") set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-server) From d1e4798372699f17913db3eccd1a383742749a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 19:53:56 -0400 Subject: [PATCH 045/144] cmake: fix default server interface option --- CMakeLists.txt | 24 ++++++++---------------- cmake/ConfigOptions.cmake | 3 ++- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1e369aff..52e3dbd7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,15 +76,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Default to release build type if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - -if(NOT DEFINED WITH_CLIENT_INTERFACE) - set(WITH_CLIENT_INTERFACE ON) -endif() - -if(NOT DEFINED WITH_SERVER_INTERFACE) - set(WITH_SERVER_INTERFACE ON) + set(CMAKE_BUILD_TYPE "Release") endif() if(NOT DEFINED BUILD_SHARED_LIBS) @@ -245,6 +237,7 @@ if(ANDROID) endif() set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + if(NOT IOS AND NOT ANDROID) find_package(Threads REQUIRED) endif() @@ -443,9 +436,10 @@ if(WITH_CHANNELS) endif() if (IOS) -set(CMAKE_OSX_DEPLOYMENT_TARGET "") -set(CMAKE_OSX_SYSROOT "iphoneos") + set(CMAKE_OSX_DEPLOYMENT_TARGET "") + set(CMAKE_OSX_SYSROOT "iphoneos") endif() + if(WITH_CLIENT) add_subdirectory(client) endif() @@ -477,7 +471,6 @@ if(NOT WIN32) endif() endif() - endif() set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") @@ -556,10 +549,9 @@ set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Development") # problems when compiling freerdp/jni. To prevent this problem # we set the macros to "". if (ANDROID AND CMAKE_EXTRA_GENERATOR STREQUAL "Eclipse CDT4") - set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "") - message(STATUS "Disabled CXX system defines for eclipse (workaround).") + set(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "") + message(STATUS "Disabled CXX system defines for eclipse (workaround).") endif() - - include(CPack) + diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 07dfdc823..84032718f 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -76,7 +76,8 @@ endif() option(WITH_THIRD_PARTY "Build third-party components" OFF) -option(WITH_SERVER_INTERFACE "Build server as a library with an interface" OFF) +option(WITH_CLIENT_INTERFACE "Build clients as a library with an interface" ON) +option(WITH_SERVER_INTERFACE "Build servers as a library with an interface" ON) option(WITH_DEBUG_ALL "Print all debug messages." OFF) From 51715636a5e8391a7200950b31e0377006532182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 22:35:15 -0400 Subject: [PATCH 046/144] freerdp: remove some deprecated stream utils --- channels/audin/client/audin_main.c | 18 +- channels/audin/server/audin.c | 28 +- channels/cliprdr/client/cliprdr_format.c | 20 +- channels/cliprdr/client/cliprdr_main.c | 10 +- channels/drdynvc/client/drdynvc_main.c | 42 +-- channels/drdynvc/client/dvcman.c | 6 +- channels/drive/client/drive_file.c | 12 +- channels/drive/client/drive_main.c | 14 +- channels/parallel/client/parallel_main.c | 10 +- channels/printer/client/printer_main.c | 4 +- channels/rail/client/rail_orders.c | 26 +- channels/rdpdr/client/irp.c | 8 +- channels/rdpdr/client/rdpdr_capabilities.c | 12 +- channels/rdpdr/client/rdpdr_main.c | 20 +- channels/rdpsnd/client/rdpsnd_main.c | 16 +- channels/rdpsnd/server/rdpsnd.c | 64 ++--- channels/sample/client/sample_main.c | 4 +- channels/serial/client/serial_main.c | 14 +- channels/serial/client/serial_tty.c | 8 +- channels/server/channels.c | 47 ++-- channels/smartcard/client/smartcard_main.c | 6 +- .../smartcard/client/smartcard_operations.c | 176 ++++++------- channels/tsmf/client/tsmf_codec.c | 64 ++--- channels/tsmf/client/tsmf_ifman.c | 72 +++--- channels/tsmf/client/tsmf_main.c | 14 +- client/X11/xf_cliprdr.c | 4 +- cunit/test_freerdp.c | 2 +- cunit/test_nsc.c | 6 +- cunit/test_orders.c | 38 +-- cunit/test_rfx.c | 8 +- libfreerdp/codec/nsc.c | 4 +- libfreerdp/codec/rfx.c | 82 +++--- libfreerdp/codec/rfx_decode.c | 26 +- libfreerdp/codec/rfx_encode.c | 12 +- libfreerdp/core/activation.c | 32 +-- libfreerdp/core/capabilities.c | 242 +++++++++--------- libfreerdp/core/certificate.c | 30 +-- libfreerdp/core/channel.c | 12 +- libfreerdp/core/connection.c | 8 +- libfreerdp/core/fastpath.c | 68 ++--- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gateway/http.c | 2 +- libfreerdp/core/gateway/rpc_client.c | 24 +- libfreerdp/core/gateway/tsg.c | 2 +- libfreerdp/core/gcc.c | 54 ++-- libfreerdp/core/info.c | 110 ++++---- libfreerdp/core/input.c | 28 +- libfreerdp/core/license.c | 32 +-- libfreerdp/core/mcs.c | 34 +-- libfreerdp/core/nego.c | 16 +- libfreerdp/core/nla.c | 14 +- libfreerdp/core/orders.c | 202 +++++++-------- libfreerdp/core/peer.c | 6 +- libfreerdp/core/rdp.c | 84 +++--- libfreerdp/core/redirection.c | 14 +- libfreerdp/core/surface.c | 14 +- libfreerdp/core/timezone.c | 10 +- libfreerdp/core/tpdu.c | 6 +- libfreerdp/core/tpkt.c | 2 +- libfreerdp/core/transport.c | 48 ++-- libfreerdp/core/update.c | 72 +++--- libfreerdp/core/window.c | 58 ++--- libfreerdp/crypto/ber.c | 26 +- libfreerdp/crypto/er.c | 4 +- libfreerdp/crypto/per.c | 30 +-- libfreerdp/utils/rail.c | 4 +- libfreerdp/utils/svc_plugin.c | 8 +- server/Mac/mf_peer.c | 4 +- server/Sample/sfreerdp.c | 16 +- server/Windows/wf_update.c | 4 +- server/X11/xf_peer.c | 4 +- winpr/include/winpr/stream.h | 28 +- winpr/libwinpr/sspi/NTLM/ntlm_compute.c | 2 +- winpr/libwinpr/sspi/NTLM/ntlm_message.c | 16 +- winpr/libwinpr/utils/collections/StreamPool.c | 44 +++- winpr/libwinpr/utils/stream.c | 4 +- 76 files changed, 1169 insertions(+), 1148 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 428684519..50c8f1387 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -101,7 +101,7 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w out = stream_new(5); stream_write_BYTE(out, MSG_SNDIN_VERSION); stream_write_UINT32(out, Version); - error = callback->channel->Write(callback->channel, stream_get_length(s), stream_get_head(s), NULL); + error = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); stream_free(out); return error; @@ -135,13 +135,13 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w DEBUG_WARN("bad NumFormats %d", NumFormats); return 1; } - stream_seek_UINT32(s); /* cbSizeFormatsPacket */ + Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */ callback->formats = (audinFormat*) malloc(NumFormats * sizeof(audinFormat)); ZeroMemory(callback->formats, NumFormats * sizeof(audinFormat)); out = stream_new(9); - stream_seek(out, 9); + Stream_Seek(out, 9); /* SoundFormats (variable) */ for (i = 0; i < NumFormats; i++) @@ -150,12 +150,12 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w stream_read_UINT16(s, format.wFormatTag); stream_read_UINT16(s, format.nChannels); stream_read_UINT32(s, format.nSamplesPerSec); - stream_seek_UINT32(s); /* nAvgBytesPerSec */ + Stream_Seek_UINT32(s); /* nAvgBytesPerSec */ stream_read_UINT16(s, format.nBlockAlign); stream_read_UINT16(s, format.wBitsPerSample); stream_read_UINT16(s, format.cbSize); - format.data = stream_get_tail(s); - stream_seek(s, format.cbSize); + format.data = Stream_Pointer(s); + Stream_Seek(s, format.cbSize); DEBUG_DVC("wFormatTag=%d nChannels=%d nSamplesPerSec=%d " "nBlockAlign=%d wBitsPerSample=%d cbSize=%d", @@ -182,8 +182,8 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w audin_send_incoming_data_pdu(pChannelCallback); - cbSizeFormatsPacket = stream_get_pos(out); - stream_set_pos(out, 0); + cbSizeFormatsPacket = Stream_GetPosition(out); + Stream_SetPosition(out, 0); stream_write_BYTE(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */ stream_write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */ @@ -239,7 +239,7 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data) out = stream_new(size + 1); stream_write_BYTE(out, MSG_SNDIN_DATA); stream_write(out, data, size); - error = callback->channel->Write(callback->channel, stream_get_length(out), stream_get_head(out), NULL); + error = callback->channel->Write(callback->channel, Stream_GetPosition(out), stream_get_head(out), NULL); stream_free(out); return (error == 0 ? TRUE : FALSE); diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 75a143fda..c5d00bc9d 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -78,7 +78,7 @@ static void audin_server_send_version(audin_server* audin, wStream* s) { stream_write_BYTE(s, MSG_SNDIN_VERSION); stream_write_UINT32(s, 1); /* Version (4 bytes) */ - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_version(audin_server* audin, wStream* s, UINT32 length) @@ -101,7 +101,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) int i; UINT32 nAvgBytesPerSec; - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); stream_write_BYTE(s, MSG_SNDIN_FORMATS); stream_write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */ stream_write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */ @@ -127,7 +127,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) } } - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 length) @@ -138,7 +138,7 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le return FALSE; stream_read_UINT32(s, audin->context.num_client_formats); /* NumFormats (4 bytes) */ - stream_seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */ + Stream_Seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */ length -= 8; if (audin->context.num_client_formats <= 0) @@ -159,13 +159,13 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le stream_read_UINT16(s, audin->context.client_formats[i].wFormatTag); stream_read_UINT16(s, audin->context.client_formats[i].nChannels); stream_read_UINT32(s, audin->context.client_formats[i].nSamplesPerSec); - stream_seek_UINT32(s); /* nAvgBytesPerSec */ + Stream_Seek_UINT32(s); /* nAvgBytesPerSec */ stream_read_UINT16(s, audin->context.client_formats[i].nBlockAlign); stream_read_UINT16(s, audin->context.client_formats[i].wBitsPerSample); stream_read_UINT16(s, audin->context.client_formats[i].cbSize); if (audin->context.client_formats[i].cbSize > 0) { - stream_seek(s, audin->context.client_formats[i].cbSize); + Stream_Seek(s, audin->context.client_formats[i].cbSize); } } @@ -181,7 +181,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s) audin->opened = TRUE; - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); stream_write_BYTE(s, MSG_SNDIN_OPEN); stream_write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */ stream_write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */ @@ -198,7 +198,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s) stream_write_UINT16(s, 16); /* wBitsPerSample */ stream_write_UINT16(s, 0); /* cbSize */ - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 length) @@ -232,7 +232,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt if (format->wFormatTag == WAVE_FORMAT_ADPCM) { audin->dsp_context->decode_ms_adpcm(audin->dsp_context, - stream_get_tail(s), length, format->nChannels, format->nBlockAlign); + Stream_Pointer(s), length, format->nChannels, format->nBlockAlign); size = audin->dsp_context->adpcm_size; src = audin->dsp_context->adpcm_buffer; sbytes_per_sample = 2; @@ -241,7 +241,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt else if (format->wFormatTag == WAVE_FORMAT_DVI_ADPCM) { audin->dsp_context->decode_ima_adpcm(audin->dsp_context, - stream_get_tail(s), length, format->nChannels, format->nBlockAlign); + Stream_Pointer(s), length, format->nChannels, format->nBlockAlign); size = audin->dsp_context->adpcm_size; src = audin->dsp_context->adpcm_buffer; sbytes_per_sample = 2; @@ -250,7 +250,7 @@ static BOOL audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt else { size = length; - src = stream_get_tail(s); + src = Stream_Pointer(s); sbytes_per_sample = format->wBitsPerSample / 8; sbytes_per_frame = format->nChannels * sbytes_per_sample; } @@ -325,10 +325,10 @@ static void* audin_server_thread_func(void* arg) if (WaitForSingleObject(audin->stopEvent, 0) == WAIT_OBJECT_0) break; - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) break; @@ -336,7 +336,7 @@ static void* audin_server_thread_func(void* arg) stream_check_size(s, (int) bytes_returned); if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) break; } diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index aa4dfa03b..373c2abcd 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -87,14 +87,14 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS if (!cliprdr->use_long_format_names) name_length = 32; - stream_extend(body, stream_get_size(body) + 4 + name_length); + stream_extend(body, Stream_Capacity(body) + 4 + name_length); stream_write_UINT32(body, cb_event->formats[i]); stream_write(body, name, name_length); } - s = cliprdr_packet_new(CB_FORMAT_LIST, 0, stream_get_size(body)); - stream_write(s, stream_get_head(body), stream_get_size(body)); + s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body)); + stream_write(s, stream_get_head(body), Stream_Capacity(body)); stream_free(body); } @@ -150,7 +150,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) s->pointer, 32 / 2, &format_name->name, 0, NULL, NULL); } - stream_seek(s, 32); + Stream_Seek(s, 32); } } @@ -166,7 +166,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3 cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) malloc(sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats); cliprdr->num_format_names = 0; - while (stream_get_left(s) >= 6) + while (Stream_GetRemainingLength(s) >= 6) { BYTE* p; int name_len; @@ -184,15 +184,15 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3 format_name->name = NULL; format_name->length = 0; - for (p = stream_get_tail(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2) + for (p = Stream_Pointer(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2) { if (*((unsigned short*) p) == 0) break; } - format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), name_len / 2, &format_name->name, 0, NULL, NULL); + format_name->length = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), name_len / 2, &format_name->name, 0, NULL, NULL); - stream_seek(s, name_len + 2); + Stream_Seek(s, name_len + 2); } } @@ -210,7 +210,7 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 data if (dataLen > 0) { cb_event->raw_format_data = (BYTE*) malloc(dataLen); - memcpy(cb_event->raw_format_data, stream_get_tail(s), dataLen); + memcpy(cb_event->raw_format_data, Stream_Pointer(s), dataLen); cb_event->raw_format_data_size = dataLen; } @@ -354,7 +354,7 @@ void cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, wStream* s, UI { cb_event->size = dataLen; cb_event->data = (BYTE*) malloc(dataLen); - CopyMemory(cb_event->data, stream_get_tail(s), dataLen); + CopyMemory(cb_event->data, Stream_Pointer(s), dataLen); } svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event); diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index c19479e85..8b5c4ebed 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -61,7 +61,7 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen) stream_write_UINT16(s, msgType); stream_write_UINT16(s, msgFlags); /* Write actual length after the entire packet has been constructed. */ - stream_seek(s, 4); + Stream_Seek(s, 4); return s; } @@ -71,11 +71,11 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s) int pos; UINT32 dataLen; - pos = stream_get_pos(s); + pos = Stream_GetPosition(s); dataLen = pos - 8; - stream_set_pos(s, 4); + Stream_SetPosition(s, 4); stream_write_UINT32(s, dataLen); - stream_set_pos(s, pos); + Stream_SetPosition(s, pos); svc_plugin_send((rdpSvcPlugin*) cliprdr, s); } @@ -138,7 +138,7 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16 UINT16 capabilitySetType; stream_read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */ - stream_seek_UINT16(s); /* pad1 (2 bytes) */ + Stream_Seek_UINT16(s); /* pad1 (2 bytes) */ DEBUG_CLIPRDR("cCapabilitiesSets %d", cCapabilitiesSets); diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index a6b062692..f1d47df8e 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -93,23 +93,23 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN return 1; data_out = stream_new(CHANNEL_CHUNK_LENGTH); - stream_set_pos(data_out, 1); + Stream_SetPosition(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); if (data_size == 0) { - pos = stream_get_pos(data_out); - stream_set_pos(data_out, 0); + pos = Stream_GetPosition(data_out); + Stream_SetPosition(data_out, 0); stream_write_BYTE(data_out, 0x40 | cbChId); - stream_set_pos(data_out, pos); + Stream_SetPosition(data_out, pos); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); } else if (data_size <= CHANNEL_CHUNK_LENGTH - pos) { - pos = stream_get_pos(data_out); - stream_set_pos(data_out, 0); + pos = Stream_GetPosition(data_out); + Stream_SetPosition(data_out, 0); stream_write_BYTE(data_out, 0x30 | cbChId); - stream_set_pos(data_out, pos); + Stream_SetPosition(data_out, pos); stream_write(data_out, data, data_size); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); } @@ -117,10 +117,10 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN { /* Fragment the data */ cbLen = drdynvc_write_variable_uint(data_out, data_size); - pos = stream_get_pos(data_out); - stream_set_pos(data_out, 0); + pos = Stream_GetPosition(data_out); + Stream_SetPosition(data_out, 0); stream_write_BYTE(data_out, 0x20 | cbChId | (cbLen << 2)); - stream_set_pos(data_out, pos); + Stream_SetPosition(data_out, pos); chunk_len = CHANNEL_CHUNK_LENGTH - pos; stream_write(data_out, data, chunk_len); data += chunk_len; @@ -130,13 +130,13 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN while (error == CHANNEL_RC_OK && data_size > 0) { data_out = stream_new(CHANNEL_CHUNK_LENGTH); - stream_set_pos(data_out, 1); + Stream_SetPosition(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); - pos = stream_get_pos(data_out); - stream_set_pos(data_out, 0); + pos = Stream_GetPosition(data_out); + Stream_SetPosition(data_out, 0); stream_write_BYTE(data_out, 0x30 | cbChId); - stream_set_pos(data_out, pos); + Stream_SetPosition(data_out, pos); chunk_len = data_size; if (chunk_len > CHANNEL_CHUNK_LENGTH - pos) @@ -179,7 +179,7 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in int error; DEBUG_DVC("Sp=%d cbChId=%d", Sp, cbChId); - stream_seek(s, 1); /* pad */ + Stream_Seek(s, 1); /* pad */ stream_read_UINT16(s, drdynvc->version); if (drdynvc->version == 2) @@ -236,14 +236,14 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb wStream* data_out; ChannelId = drdynvc_read_variable_uint(s, cbChId); - pos = stream_get_pos(s); - DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, stream_get_tail(s)); + pos = Stream_GetPosition(s); + DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, Stream_Pointer(s)); - error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) stream_get_tail(s)); + error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); data_out = stream_new(pos + 4); stream_write_BYTE(data_out, 0x10 | cbChId); - stream_set_pos(s, 1); + Stream_SetPosition(s, 1); stream_copy(data_out, s, pos - 1); if (error == 0) @@ -284,7 +284,7 @@ static int drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId return error; return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, - stream_get_tail(s), stream_get_left(s)); + Stream_Pointer(s), Stream_GetRemainingLength(s)); } static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) @@ -295,7 +295,7 @@ static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStr DEBUG_DVC("ChannelId=%d", ChannelId); return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, - stream_get_tail(s), stream_get_left(s)); + Stream_Pointer(s), Stream_GetRemainingLength(s)); } static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index 831205a3a..accef0c47 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -445,7 +445,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C if (channel->dvc_data) { /* Fragmented data */ - if (stream_get_length(channel->dvc_data) + data_size > (UINT32) stream_get_size(channel->dvc_data)) + if (Stream_GetPosition(channel->dvc_data) + data_size > (UINT32) Stream_Capacity(channel->dvc_data)) { DEBUG_WARN("data exceeding declared length!"); stream_free(channel->dvc_data); @@ -455,10 +455,10 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C stream_write(channel->dvc_data, data, data_size); - if (stream_get_length(channel->dvc_data) >= stream_get_size(channel->dvc_data)) + if (Stream_GetPosition(channel->dvc_data) >= Stream_Capacity(channel->dvc_data)) { error = channel->channel_callback->OnDataReceived(channel->channel_callback, - stream_get_size(channel->dvc_data), stream_get_data(channel->dvc_data)); + Stream_Capacity(channel->dvc_data), Stream_Buffer(channel->dvc_data)); stream_free(channel->dvc_data); channel->dvc_data = NULL; } diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index e6b206231..8c1006eed 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -447,10 +447,10 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN { case FileBasicInformation: /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */ - stream_seek_UINT64(input); /* CreationTime */ - stream_seek_UINT64(input); /* LastAccessTime */ + Stream_Seek_UINT64(input); /* CreationTime */ + Stream_Seek_UINT64(input); /* LastAccessTime */ stream_read_UINT64(input, LastWriteTime); - stream_seek_UINT64(input); /* ChangeTime */ + Stream_Seek_UINT64(input); /* ChangeTime */ stream_read_UINT32(input, FileAttributes); if (FSTAT(file->fd, &st) != 0) @@ -501,11 +501,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN case FileRenameInformation: /* http://msdn.microsoft.com/en-us/library/cc232085.aspx */ - stream_seek_BYTE(input); /* ReplaceIfExists */ - stream_seek_BYTE(input); /* RootDirectory */ + Stream_Seek_BYTE(input); /* ReplaceIfExists */ + Stream_Seek_BYTE(input); /* RootDirectory */ stream_read_UINT32(input, FileNameLength); - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(input), + status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(input), FileNameLength / 2, &s, 0, NULL, NULL); if (status < 1) diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 23912693d..015e1f125 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -128,12 +128,12 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp) UINT32 PathLength; stream_read_UINT32(irp->input, DesiredAccess); - stream_seek(irp->input, 16); /* AllocationSize(8), FileAttributes(4), SharedAccess(4) */ + Stream_Seek(irp->input, 16); /* AllocationSize(8), FileAttributes(4), SharedAccess(4) */ stream_read_UINT32(irp->input, CreateDisposition); stream_read_UINT32(irp->input, CreateOptions); stream_read_UINT32(irp->input, PathLength); - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input), + status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); if (status < 1) @@ -284,7 +284,7 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp) stream_read_UINT32(irp->input, Length); stream_read_UINT64(irp->input, Offset); - stream_seek(irp->input, 20); /* Padding */ + Stream_Seek(irp->input, 20); /* Padding */ file = drive_get_file_by_id(disk, irp->FileId); @@ -302,7 +302,7 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp) DEBUG_WARN("seek %s(%d) failed.", file->fullpath, file->id); } - else if (!drive_file_write(file, stream_get_tail(irp->input), Length)) + else if (!drive_file_write(file, Stream_Pointer(irp->input), Length)) { irp->IoStatus = STATUS_UNSUCCESSFUL; Length = 0; @@ -357,7 +357,7 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp) stream_read_UINT32(irp->input, FsInformationClass); stream_read_UINT32(irp->input, Length); - stream_seek(irp->input, 24); /* Padding */ + Stream_Seek(irp->input, 24); /* Padding */ file = drive_get_file_by_id(disk, irp->FileId); @@ -504,9 +504,9 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp) stream_read_UINT32(irp->input, FsInformationClass); stream_read_BYTE(irp->input, InitialQuery); stream_read_UINT32(irp->input, PathLength); - stream_seek(irp->input, 23); /* Padding */ + Stream_Seek(irp->input, 23); /* Padding */ - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input), + status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); if (status < 1) diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 4b210b1c5..f785475da 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -75,12 +75,12 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) int status; UINT32 PathLength; - stream_seek(irp->input, 28); + Stream_Seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_UINT32(irp->input, PathLength); - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input), + status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); if (status < 1) @@ -175,7 +175,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) stream_read_UINT32(irp->input, Length); stream_read_UINT64(irp->input, Offset); - stream_seek(irp->input, 20); /* Padding */ + Stream_Seek(irp->input, 20); /* Padding */ DEBUG_SVC("Length %u Offset %llu", Length, Offset); @@ -183,7 +183,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) while (len > 0) { - status = write(parallel->file, stream_get_tail(irp->input), len); + status = write(parallel->file, Stream_Pointer(irp->input), len); if (status < 0) { @@ -194,7 +194,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) break; } - stream_seek(irp->input, status); + Stream_Seek(irp->input, status); len -= status; } diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 57518219f..3703877db 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -116,7 +116,7 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) stream_read_UINT32(irp->input, Length); stream_read_UINT64(irp->input, Offset); - stream_seek(irp->input, 20); /* Padding */ + Stream_Seek(irp->input, 20); /* Padding */ if (printer_dev->printer) printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId); @@ -130,7 +130,7 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) } else { - printjob->Write(printjob, stream_get_tail(irp->input), Length); + printjob->Write(printjob, Stream_Pointer(irp->input), Length); DEBUG_SVC("printjob id %d written %d bytes.", irp->FileId, Length); } diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 2533df326..c280c81d2 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -90,7 +90,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_ BOOL rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, *orderType); /* orderType (2 bytes) */ stream_read_UINT16(s, *orderLength); /* orderLength (2 bytes) */ @@ -107,7 +107,7 @@ wStream* rail_pdu_init(int length) { wStream* s; s = stream_new(length + RAIL_PDU_HEADER_LENGTH); - stream_seek(s, RAIL_PDU_HEADER_LENGTH); + Stream_Seek(s, RAIL_PDU_HEADER_LENGTH); return s; } @@ -115,11 +115,11 @@ void rail_send_pdu(rdpRailOrder* rail_order, wStream* s, UINT16 orderType) { UINT16 orderLength; - orderLength = stream_get_length(s); - stream_set_pos(s, 0); + orderLength = Stream_GetPosition(s); + Stream_SetPosition(s, 0); rail_write_pdu_header(s, orderType, orderLength); - stream_set_pos(s, orderLength); + Stream_SetPosition(s, orderLength); /* send */ DEBUG_RAIL("Sending %s PDU, length:%d", @@ -138,7 +138,7 @@ void rail_write_high_contrast(wStream* s, HIGH_CONTRAST* high_contrast) BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */ return TRUE; @@ -146,12 +146,12 @@ BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake) BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec_result) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT16(s, exec_result->flags); /* flags (2 bytes) */ stream_read_UINT16(s, exec_result->execResult); /* execResult (2 bytes) */ stream_read_UINT32(s, exec_result->rawResult); /* rawResult (4 bytes) */ - stream_seek_UINT16(s); /* padding (2 bytes) */ + Stream_Seek_UINT16(s); /* padding (2 bytes) */ return rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */ } @@ -159,7 +159,7 @@ BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam) { BYTE body; - if (stream_get_left(s) < 5) + if (Stream_GetRemainingLength(s) < 5) return FALSE; stream_read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */ stream_read_BYTE(s, body); /* body (1 byte) */ @@ -182,7 +182,7 @@ BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam) BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmaxinfo) { - if (stream_get_left(s) < 20) + if (Stream_GetRemainingLength(s) < 20) return FALSE; stream_read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */ stream_read_UINT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */ @@ -199,7 +199,7 @@ BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmax BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* localmovesize) { UINT16 isMoveSizeStart; - if (stream_get_left(s) < 12) + if (Stream_GetRemainingLength(s) < 12) return FALSE; stream_read_UINT32(s, localmovesize->windowId); /* windowId (4 bytes) */ @@ -214,7 +214,7 @@ BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER* get_appid_resp) { - if (stream_get_left(s) < 516) + if (Stream_GetRemainingLength(s) < 516) return FALSE; stream_read_UINT32(s, get_appid_resp->windowId); /* windowId (4 bytes) */ stream_read(s, &get_appid_resp->applicationIdBuffer[0], 512); /* applicationId (256 UNICODE chars) */ @@ -226,7 +226,7 @@ BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */ return TRUE; diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c index 19e83879e..5fb3d74ae 100644 --- a/channels/rdpdr/client/irp.c +++ b/channels/rdpdr/client/irp.c @@ -51,10 +51,10 @@ static void irp_complete(IRP* irp) DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId); - pos = stream_get_pos(irp->output); - stream_set_pos(irp->output, 12); + pos = Stream_GetPosition(irp->output); + Stream_SetPosition(irp->output, 12); stream_write_UINT32(irp->output, irp->IoStatus); - stream_set_pos(irp->output, pos); + Stream_SetPosition(irp->output, pos); svc_plugin_send(irp->devman->plugin, irp->output); irp->output = NULL; @@ -93,7 +93,7 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in) stream_write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION); stream_write_UINT32(irp->output, DeviceId); stream_write_UINT32(irp->output, irp->CompletionId); - stream_seek_UINT32(irp->output); /* IoStatus */ + Stream_Seek_UINT32(irp->output); /* IoStatus */ irp->Complete = irp_complete; irp->Discard = irp_free; diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index 081f035cd..8dcaf747c 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -63,7 +63,7 @@ static void rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityLength; stream_read_UINT16(data_in, capabilityLength); - stream_seek(data_in, capabilityLength - 4); + Stream_Seek(data_in, capabilityLength - 4); } /* Output printer direction capability set */ @@ -78,7 +78,7 @@ static void rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityLength; stream_read_UINT16(data_in, capabilityLength); - stream_seek(data_in, capabilityLength - 4); + Stream_Seek(data_in, capabilityLength - 4); } /* Output port redirection capability set */ @@ -93,7 +93,7 @@ static void rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityLength; stream_read_UINT16(data_in, capabilityLength); - stream_seek(data_in, capabilityLength - 4); + Stream_Seek(data_in, capabilityLength - 4); } /* Output drive redirection capability set */ @@ -108,7 +108,7 @@ static void rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityLength; stream_read_UINT16(data_in, capabilityLength); - stream_seek(data_in, capabilityLength - 4); + Stream_Seek(data_in, capabilityLength - 4); } /* Output smart card redirection capability set */ @@ -123,7 +123,7 @@ static void rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityLength; stream_read_UINT16(data_in, capabilityLength); - stream_seek(data_in, capabilityLength - 4); + Stream_Seek(data_in, capabilityLength - 4); } void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in) @@ -133,7 +133,7 @@ void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 capabilityType; stream_read_UINT16(data_in, numCapabilities); - stream_seek(data_in, 2); /* pad (2 bytes) */ + Stream_Seek(data_in, 2); /* pad (2 bytes) */ for(i = 0; i < numCapabilities; i++) { diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 110701103..662aa0624 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -157,9 +157,9 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use stream_write_UINT16(data_out, RDPDR_CTYP_CORE); stream_write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE); - count_pos = stream_get_pos(data_out); + count_pos = Stream_GetPosition(data_out); count = 0; - stream_seek_UINT32(data_out); /* deviceCount */ + Stream_Seek_UINT32(data_out); /* deviceCount */ for (item = rdpdr->devman->devices->head; item; item = item->next) { @@ -175,12 +175,12 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use if ((rdpdr->versionMinor == 0x0005) || (device->type == RDPDR_DTYP_SMARTCARD) || user_loggedon) { - data_len = (device->data == NULL ? 0 : stream_get_length(device->data)); + data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data)); stream_check_size(data_out, 20 + data_len); stream_write_UINT32(data_out, device->type); /* deviceType */ stream_write_UINT32(data_out, device->id); /* deviceID */ - strncpy((char*) stream_get_tail(data_out), device->name, 8); + strncpy((char*) Stream_Pointer(data_out), device->name, 8); for (i = 0; i < 8; i++) { @@ -189,13 +189,13 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use if (c > 0x7F) stream_write_BYTE(data_out, '_'); else - stream_seek_BYTE(data_out); + Stream_Seek_BYTE(data_out); } stream_write_UINT32(data_out, data_len); if (data_len > 0) - stream_write(data_out, stream_get_data(device->data), data_len); + stream_write(data_out, Stream_Buffer(device->data), data_len); count++; @@ -204,11 +204,11 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use } } - pos = stream_get_pos(data_out); - stream_set_pos(data_out, count_pos); + pos = Stream_GetPosition(data_out); + Stream_SetPosition(data_out, count_pos); stream_write_UINT32(data_out, count); - stream_set_pos(data_out, pos); - stream_seal(data_out); + Stream_SetPosition(data_out, pos); + Stream_SealLength(data_out); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); } diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 8e54f15e2..30fe201d6 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -262,14 +262,14 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) rdpsnd->NumberOfServerFormats = 0; rdpsnd->ServerFormats = NULL; - stream_seek_UINT32(s); /* dwFlags */ - stream_seek_UINT32(s); /* dwVolume */ - stream_seek_UINT32(s); /* dwPitch */ - stream_seek_UINT16(s); /* wDGramPort */ + Stream_Seek_UINT32(s); /* dwFlags */ + Stream_Seek_UINT32(s); /* dwVolume */ + Stream_Seek_UINT32(s); /* dwPitch */ + Stream_Seek_UINT16(s); /* wDGramPort */ stream_read_UINT16(s, wNumberOfFormats); stream_read_BYTE(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */ stream_read_UINT16(s, wVersion); /* wVersion */ - stream_seek_BYTE(s); /* bPad */ + Stream_Seek_BYTE(s); /* bPad */ rdpsnd->NumberOfServerFormats = wNumberOfFormats; rdpsnd->ServerFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * wNumberOfFormats); @@ -333,7 +333,7 @@ static void rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 B stream_read_UINT16(s, rdpsnd->wTimeStamp); stream_read_UINT16(s, wFormatNo); stream_read_BYTE(s, rdpsnd->cBlockNo); - stream_seek(s, 3); /* bPad */ + Stream_Seek(s, 3); /* bPad */ stream_read(s, rdpsnd->waveData, 4); rdpsnd->waveDataSize = BodySize - 8; @@ -402,7 +402,7 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s) CopyMemory(stream_get_head(s), rdpsnd->waveData, 4); data = stream_get_head(s); - size = stream_get_size(s); + size = Stream_Capacity(s); wave = (RDPSND_WAVE*) malloc(sizeof(RDPSND_WAVE)); @@ -481,7 +481,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s) } stream_read_BYTE(s, msgType); /* msgType */ - stream_seek_BYTE(s); /* bPad */ + Stream_Seek_BYTE(s); /* bPad */ stream_read_UINT16(s, BodySize); //fprintf(stderr, "msgType %d BodySize %d\n", msgType, BodySize); diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index 75e4af02a..4c2f88caf 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -63,7 +63,7 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s) stream_write_BYTE(s, SNDC_FORMATS); stream_write_BYTE(s, 0); - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); stream_write_UINT32(s, 0); /* dwFlags */ stream_write_UINT32(s, 0); /* dwVolume */ @@ -94,12 +94,12 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s) } } - pos = stream_get_pos(s); - stream_set_pos(s, 2); + pos = Stream_GetPosition(s); + Stream_SetPosition(s, 2); stream_write_UINT16(s, pos - 4); - stream_set_pos(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL); - stream_set_pos(s, 0); + Stream_SetPosition(s, pos); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + Stream_SetPosition(s, 0); return status; } @@ -112,7 +112,7 @@ static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, wStream* s) BYTE confirmBlockNum = 0; stream_read_UINT16(s, timestamp); stream_read_BYTE(s, confirmBlockNum); - stream_seek_BYTE(s); // padding + Stream_Seek_BYTE(s); // padding } static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s) @@ -121,7 +121,7 @@ static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s) UINT16 quality; stream_read_UINT16(s, quality); - stream_seek_UINT16(s); // reserved + Stream_Seek_UINT16(s); // reserved fprintf(stderr, "Client requested sound quality: %#0X\n", quality); } @@ -141,7 +141,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s) stream_read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */ stream_read_BYTE(s, lastblock); /* cLastBlockConfirmed */ stream_read_UINT16(s, version); /* wVersion */ - stream_seek_BYTE(s); /* bPad */ + Stream_Seek_BYTE(s); /* bPad */ if (rdpsnd->context.num_client_formats > 0) { @@ -160,7 +160,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s) if (rdpsnd->context.client_formats[i].cbSize > 0) { - stream_seek(s, rdpsnd->context.client_formats[i].cbSize); + Stream_Seek(s, rdpsnd->context.client_formats[i].cbSize); } if (rdpsnd->context.client_formats[i].wFormatTag != 0) @@ -216,10 +216,10 @@ static void* rdpsnd_server_thread_func(void* arg) break; } - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) break; @@ -227,12 +227,12 @@ static void* rdpsnd_server_thread_func(void* arg) stream_check_size(s, (int) bytes_returned); if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) break; } stream_read_BYTE(s, msgType); - stream_seek_BYTE(s); /* bPad */ + Stream_Seek_BYTE(s); /* bPad */ stream_read_UINT16(s, BodySize); switch (msgType) @@ -399,7 +399,7 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) } /* WaveInfo PDU */ - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); stream_write_BYTE(s, SNDC_WAVE); /* msgType */ stream_write_BYTE(s, 0); /* bPad */ stream_write_UINT16(s, size + fill_size + 8); /* BodySize */ @@ -407,11 +407,11 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) stream_write_UINT16(s, 0); /* wTimeStamp */ stream_write_UINT16(s, rdpsnd->context.selected_client_format); /* wFormatNo */ stream_write_BYTE(s, rdpsnd->context.block_no); /* cBlockNo */ - stream_seek(s, 3); /* bPad */ + Stream_Seek(s, 3); /* bPad */ stream_write(s, src, 4); - WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL); - stream_set_pos(s, 0); + WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + Stream_SetPosition(s, 0); /* Wave PDU */ stream_check_size(s, size + fill_size); @@ -421,8 +421,8 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) if (fill_size > 0) stream_write_zero(s, fill_size); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL); - stream_set_pos(s, 0); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + Stream_SetPosition(s, 0); rdpsnd->out_pending_frames = 0; @@ -467,17 +467,17 @@ static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, i stream_write_BYTE(s, SNDC_SETVOLUME); stream_write_BYTE(s, 0); - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); stream_write_UINT16(s, left); stream_write_UINT16(s, right); - pos = stream_get_pos(s); - stream_set_pos(s, 2); + pos = Stream_GetPosition(s); + Stream_SetPosition(s, 2); stream_write_UINT16(s, pos - 4); - stream_set_pos(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL); - stream_set_pos(s, 0); + Stream_SetPosition(s, pos); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + Stream_SetPosition(s, 0); return status; } @@ -502,14 +502,14 @@ static BOOL rdpsnd_server_close(rdpsnd_server_context* context) stream_write_BYTE(s, SNDC_CLOSE); stream_write_BYTE(s, 0); - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); - pos = stream_get_pos(s); - stream_set_pos(s, 2); + pos = Stream_GetPosition(s); + Stream_SetPosition(s, 2); stream_write_UINT16(s, pos - 4); - stream_set_pos(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), stream_get_length(s), NULL); - stream_set_pos(s, 0); + Stream_SetPosition(s, pos); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + Stream_SetPosition(s, 0); return status; } diff --git a/channels/sample/client/sample_main.c b/channels/sample/client/sample_main.c index b36a07f8b..9d6c90e54 100644 --- a/channels/sample/client/sample_main.c +++ b/channels/sample/client/sample_main.c @@ -64,7 +64,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in) /* process data in (from server) here */ /* here we just send the same data back */ - bytes = stream_get_size(data_in); + bytes = Stream_Capacity(data_in); fprintf(stderr, "sample_process_receive: got bytes %d\n", bytes); if (bytes > 0) @@ -74,7 +74,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in) /* svc_plugin_send takes ownership of data_out, that is why we do not free it */ - bytes = stream_get_length(data_in); + bytes = Stream_GetPosition(data_in); fprintf(stderr, "sample_process_receive: sending bytes %d\n", bytes); svc_plugin_send(plugin, data_out); diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index f505c2c00..ec6e5abea 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -90,11 +90,11 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp) UINT32 PathLength; UINT32 FileId; - stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ + Stream_Seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_UINT32(irp->input, PathLength); - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(irp->input), + status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); if (status < 1) @@ -210,7 +210,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp) stream_read_UINT32(irp->input, Length); stream_read_UINT64(irp->input, Offset); - stream_seek(irp->input, 20); /* Padding */ + Stream_Seek(irp->input, 20); /* Padding */ DEBUG_SVC("length %u offset %llu", Length, Offset); @@ -223,7 +223,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp) DEBUG_WARN("tty not valid."); } - else if (!serial_tty_write(tty, stream_get_tail(irp->input), Length)) + else if (!serial_tty_write(tty, Stream_Pointer(irp->input), Length)) { irp->IoStatus = STATUS_UNSUCCESSFUL; Length = 0; @@ -254,7 +254,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp) stream_read_UINT32(irp->input, InputBufferLength); stream_read_UINT32(irp->input, OutputBufferLength); stream_read_UINT32(irp->input, IoControlCode); - stream_seek(irp->input, 20); /* Padding */ + Stream_Seek(irp->input, 20); /* Padding */ tty = serial->tty; @@ -478,9 +478,9 @@ void serial_get_timeouts(SERIAL_DEVICE* serial, IRP* irp, UINT32* timeout, UINT3 UINT32 Length; UINT32 pos; - pos = stream_get_pos(irp->input); + pos = Stream_GetPosition(irp->input); stream_read_UINT32(irp->input, Length); - stream_set_pos(irp->input, pos); + Stream_SetPosition(irp->input, pos); DEBUG_SVC("length read %u", Length); diff --git a/channels/serial/client/serial_tty.c b/channels/serial/client/serial_tty.c index 74b2d09ef..51a7ca76a 100644 --- a/channels/serial/client/serial_tty.c +++ b/channels/serial/client/serial_tty.c @@ -90,7 +90,7 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, DEBUG_SVC("in"); - stream_seek(output, sizeof(UINT32)); + Stream_Seek(output, sizeof(UINT32)); switch (IoControlCode) { @@ -361,10 +361,10 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, } /* Write OutputBufferLength */ - pos = stream_get_pos(output); - stream_set_pos(output, 16); + pos = Stream_GetPosition(output); + Stream_SetPosition(output, 16); stream_write_UINT32(output, length); - stream_set_pos(output, pos); + Stream_SetPosition(output, pos); return ret; } diff --git a/channels/server/channels.c b/channels/server/channels.c index d7fc26c13..e7a41f912 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -31,6 +31,7 @@ #include <winpr/crt.h> #include <winpr/synch.h> +#include <winpr/stream.h> #include "channels.h" @@ -133,19 +134,19 @@ static int wts_read_variable_uint(wStream* s, int cbLen, UINT32* val) switch (cbLen) { case 0: - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return 0; stream_read_BYTE(s, *val); return 1; case 1: - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return 0; stream_read_UINT16(s, *val); return 2; default: - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return 0; stream_read_UINT32(s, *val); return 4; @@ -159,7 +160,7 @@ static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, UINT if (length < 3) return; - stream_seek_BYTE(channel->receive_data); /* Pad (1 byte) */ + Stream_Seek_BYTE(channel->receive_data); /* Pad (1 byte) */ stream_read_UINT16(channel->receive_data, Version); DEBUG_DVC("Version: %d", Version); @@ -204,25 +205,25 @@ static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int if (length > channel->dvc_total_length) return; - stream_set_pos(channel->receive_data, 0); + Stream_SetPosition(channel->receive_data, 0); stream_check_size(channel->receive_data, (int) channel->dvc_total_length); - stream_write(channel->receive_data, stream_get_tail(s), length); + stream_write(channel->receive_data, Stream_Pointer(s), length); } static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 length) { if (channel->dvc_total_length > 0) { - if (stream_get_length(channel->receive_data) + length > channel->dvc_total_length) + if (Stream_GetPosition(channel->receive_data) + length > channel->dvc_total_length) { channel->dvc_total_length = 0; fprintf(stderr, "wts_read_drdynvc_data: incorrect fragment data, discarded.\n"); return; } - stream_write(channel->receive_data, stream_get_tail(s), length); + stream_write(channel->receive_data, Stream_Pointer(s), length); - if (stream_get_length(channel->receive_data) >= (int) channel->dvc_total_length) + if (Stream_GetPosition(channel->receive_data) >= (int) channel->dvc_total_length) { wts_queue_receive_data(channel, stream_get_head(channel->receive_data), channel->dvc_total_length); channel->dvc_total_length = 0; @@ -230,7 +231,7 @@ static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le } else { - wts_queue_receive_data(channel, stream_get_tail(s), length); + wts_queue_receive_data(channel, Stream_Pointer(s), length); } } @@ -250,12 +251,12 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel) UINT32 ChannelId; rdpPeerChannel* dvc; - length = stream_get_pos(channel->receive_data); + length = Stream_GetPosition(channel->receive_data); if (length < 1) return; - stream_set_pos(channel->receive_data, 0); + Stream_SetPosition(channel->receive_data, 0); stream_read_BYTE(channel->receive_data, value); length--; @@ -344,7 +345,7 @@ static void wts_write_drdynvc_header(wStream *s, BYTE Cmd, UINT32 ChannelId) int cbChId; stream_get_mark(s, bm); - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); cbChId = wts_write_variable_uint(s, ChannelId); *bm = ((Cmd & 0x0F) << 4) | cbChId; } @@ -363,7 +364,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* { if (flags & CHANNEL_FLAG_FIRST) { - stream_set_pos(channel->receive_data, 0); + Stream_SetPosition(channel->receive_data, 0); } stream_check_size(channel->receive_data, size); @@ -371,7 +372,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* if (flags & CHANNEL_FLAG_LAST) { - if (stream_get_length(channel->receive_data) != total_size) + if (Stream_GetPosition(channel->receive_data) != total_size) { fprintf(stderr, "WTSProcessChannelData: read error\n"); } @@ -381,9 +382,9 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* } else { - wts_queue_receive_data(channel, stream_get_head(channel->receive_data), stream_get_length(channel->receive_data)); + wts_queue_receive_data(channel, stream_get_head(channel->receive_data), Stream_GetPosition(channel->receive_data)); } - stream_set_pos(channel->receive_data, 0); + Stream_SetPosition(channel->receive_data, 0); } } @@ -575,7 +576,7 @@ void* WTSVirtualChannelOpenEx( s = stream_new(64); wts_write_drdynvc_create_request(s, channel->channel_id, pVirtualName); - WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), stream_get_length(s), NULL); + WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL); stream_free(s); DEBUG_DVC("ChannelId %d.%s (total %d)", channel->channel_id, pVirtualName, list_size(vcm->dvc_channel_list)); @@ -783,10 +784,10 @@ BOOL WTSVirtualChannelWrite( item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize); stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize); - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); cbChId = wts_write_variable_uint(s, channel->channel_id); - if (first && (Length > (UINT32) stream_get_left(s))) + if (first && (Length > (UINT32) Stream_GetRemainingLength(s))) { cbLen = wts_write_variable_uint(s, Length); item->buffer[0] = (DATA_FIRST_PDU << 4) | (cbLen << 2) | cbChId; @@ -797,13 +798,13 @@ BOOL WTSVirtualChannelWrite( } first = FALSE; - written = stream_get_left(s); + written = Stream_GetRemainingLength(s); if (written > Length) written = Length; stream_write(s, Buffer, written); - item->length = stream_get_length(s); + item->length = Stream_GetPosition(s); stream_detach(s); Length -= written; Buffer += written; @@ -846,7 +847,7 @@ BOOL WTSVirtualChannelClose( { s = stream_new(8); wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id); - WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), stream_get_length(s), NULL); + WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL); stream_free(s); } } diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index d241e4a0e..86c2c5021 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -220,10 +220,10 @@ static void smartcard_irp_complete(IRP* irp) DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId); - pos = stream_get_pos(irp->output); - stream_set_pos(irp->output, 12); + pos = Stream_GetPosition(irp->output); + Stream_SetPosition(irp->output, 12); stream_write_UINT32(irp->output, irp->IoStatus); - stream_set_pos(irp->output, pos); + Stream_SetPosition(irp->output, pos); /* Begin TS Client defect workaround. */ WaitForSingleObject(smartcard->CompletionIdsMutex, INFINITE); diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index 2c4b595b9..fe2603202 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -89,7 +89,7 @@ static UINT32 smartcard_output_string(IRP* irp, char* src, BOOL wide) BYTE* p; UINT32 len; - p = stream_get_tail(irp->output); + p = Stream_Pointer(irp->output); len = strlen(src) + 1; if (wide) @@ -109,7 +109,7 @@ static UINT32 smartcard_output_string(IRP* irp, char* src, BOOL wide) memcpy(p, src, len); } - stream_seek(irp->output, len); + Stream_Seek(irp->output, len); return len; } @@ -120,7 +120,7 @@ static void smartcard_output_alignment(IRP* irp, UINT32 seed) * CompletionID, and IoStatus * of Section 2.2.1.5.5 of MS-RDPEFS. */ - UINT32 size = stream_get_length(irp->output) - field_lengths; + UINT32 size = Stream_GetPosition(irp->output) - field_lengths; UINT32 add = (seed - (size % seed)) % seed; if (add > 0) @@ -212,14 +212,14 @@ static void smartcard_input_repos(IRP* irp, UINT32 read) UINT32 add = 4 - (read % 4); if (add < 4 && add > 0) - stream_seek(irp->input, add); + Stream_Seek(irp->input, add); } static void smartcard_input_reader_name(IRP* irp, char** dest, BOOL wide) { UINT32 dataLength; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, dataLength); DEBUG_SCARD("datalength %d", dataLength); @@ -233,7 +233,7 @@ static void smartcard_input_skip_linked(IRP* irp) if (len > 0) { - stream_seek(irp->input, len); + Stream_Seek(irp->input, len); smartcard_input_repos(irp, len); } } @@ -267,13 +267,13 @@ static UINT32 handle_EstablishContext(IRP* irp) UINT32 scope; SCARDCONTEXT hContext = -1; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, len); if (len != 8) return SCARD_F_INTERNAL_ERROR; - stream_seek_UINT32(irp->input); + Stream_Seek_UINT32(irp->input); stream_read_UINT32(irp->input, scope); status = SCardEstablishContext(scope, NULL, NULL, &hContext); @@ -295,10 +295,10 @@ static UINT32 handle_ReleaseContext(IRP* irp) UINT32 len, status; SCARDCONTEXT hContext = -1; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, len); - stream_seek(irp->input, 0x10); + Stream_Seek(irp->input, 0x10); stream_read_UINT32(irp->input, hContext); status = SCardReleaseContext(hContext); @@ -318,7 +318,7 @@ static UINT32 handle_IsValidContext(IRP* irp) UINT32 status; SCARDCONTEXT hContext; - stream_seek(irp->input, 0x1C); + Stream_Seek(irp->input, 0x1C); stream_read_UINT32(irp->input, hContext); status = SCardIsValidContext(hContext); @@ -342,10 +342,10 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) int elemLength, dataLength; int pos, poslen1, poslen2; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, len); - stream_seek(irp->input, 0x1c); + Stream_Seek(irp->input, 0x1c); stream_read_UINT32(irp->input, len); if (len != 4) @@ -373,13 +373,13 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) /* DEBUG_SCARD("Success 0x%08x %d %d", (unsigned) hContext, (unsigned) cchReaders, (int) strlen(readerList));*/ - poslen1 = stream_get_pos(irp->output); - stream_seek_UINT32(irp->output); + poslen1 = Stream_GetPosition(irp->output); + Stream_Seek_UINT32(irp->output); stream_write_UINT32(irp->output, 0x01760650); - poslen2 = stream_get_pos(irp->output); - stream_seek_UINT32(irp->output); + poslen2 = Stream_GetPosition(irp->output); + Stream_Seek_UINT32(irp->output); walker = readerList; dataLength = 0; @@ -397,14 +397,14 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) dataLength += smartcard_output_string(irp, "\0", wide); - pos = stream_get_pos(irp->output); + pos = Stream_GetPosition(irp->output); - stream_set_pos(irp->output, poslen1); + Stream_SetPosition(irp->output, poslen1); stream_write_UINT32(irp->output, dataLength); - stream_set_pos(irp->output, poslen2); + Stream_SetPosition(irp->output, poslen2); stream_write_UINT32(irp->output, dataLength); - stream_set_pos(irp->output, pos); + Stream_SetPosition(irp->output, pos); smartcard_output_repos(irp, dataLength); smartcard_output_alignment(irp, 8); @@ -427,15 +427,15 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) DWORD readerCount = 0; SCARD_READERSTATE *readerStates, *cur; - stream_seek(irp->input, 0x18); + Stream_Seek(irp->input, 0x18); stream_read_UINT32(irp->input, dwTimeout); stream_read_UINT32(irp->input, readerCount); - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, hContext); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); DEBUG_SCARD("context: 0x%08x, timeout: 0x%08x, count: %d", (unsigned) hContext, (unsigned) dwTimeout, (int) readerCount); @@ -452,7 +452,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) { cur = &readerStates[i]; - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); /* * TODO: on-wire is little endian; need to either @@ -464,7 +464,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) stream_read_UINT32(irp->input, cur->cbAtr); stream_read(irp->input, cur->rgbAtr, 32); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); /* reset high bytes? */ cur->dwCurrentState &= 0x0000FFFF; @@ -476,7 +476,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) cur = &readerStates[i]; UINT32 dataLength; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, dataLength); smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide)); @@ -536,7 +536,7 @@ static UINT32 handle_Cancel(IRP *irp) LONG status; SCARDCONTEXT hContext; - stream_seek(irp->input, 0x1C); + Stream_Seek(irp->input, 0x1C); stream_read_UINT32(irp->input, hContext); status = SCardCancel(hContext); @@ -561,13 +561,13 @@ static UINT32 handle_Connect(IRP* irp, BOOL wide) DWORD dwActiveProtocol = 0; SCARDHANDLE hCard; - stream_seek(irp->input, 0x1c); + Stream_Seek(irp->input, 0x1c); stream_read_UINT32(irp->input, dwShareMode); stream_read_UINT32(irp->input, dwPreferredProtocol); smartcard_input_reader_name(irp, &readerName, wide); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); stream_read_UINT32(irp->input, hContext); DEBUG_SCARD("(context: 0x%08x, share: 0x%08x, proto: 0x%08x, reader: \"%s\")", @@ -606,14 +606,14 @@ static UINT32 handle_Reconnect(IRP* irp) DWORD dwInitialization = 0; DWORD dwActiveProtocol = 0; - stream_seek(irp->input, 0x20); + Stream_Seek(irp->input, 0x20); stream_read_UINT32(irp->input, dwShareMode); stream_read_UINT32(irp->input, dwPreferredProtocol); stream_read_UINT32(irp->input, dwInitialization); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, hContext); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, hCard); DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, share: 0x%08x, proto: 0x%08x, init: 0x%08x)", @@ -641,11 +641,11 @@ static UINT32 handle_Disconnect(IRP* irp) SCARDHANDLE hCard; DWORD dwDisposition = 0; - stream_seek(irp->input, 0x20); + Stream_Seek(irp->input, 0x20); stream_read_UINT32(irp->input, dwDisposition); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); stream_read_UINT32(irp->input, hContext); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); stream_read_UINT32(irp->input, hCard); DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, disposition: 0x%08x)", @@ -668,7 +668,7 @@ static UINT32 handle_BeginTransaction(IRP* irp) LONG status; SCARDCONTEXT hCard; - stream_seek(irp->input, 0x30); + Stream_Seek(irp->input, 0x30); stream_read_UINT32(irp->input, hCard); status = SCardBeginTransaction(hCard); @@ -689,10 +689,10 @@ static UINT32 handle_EndTransaction(IRP* irp) SCARDCONTEXT hCard; DWORD dwDisposition = 0; - stream_seek(irp->input, 0x20); + Stream_Seek(irp->input, 0x20); stream_read_UINT32(irp->input, dwDisposition); - stream_seek(irp->input, 0x0C); + Stream_Seek(irp->input, 0x0C); stream_read_UINT32(irp->input, hCard); status = SCardEndTransaction(hCard, dwDisposition); @@ -721,12 +721,12 @@ static UINT32 handle_State(IRP* irp) int i; #endif - stream_seek(irp->input, 0x24); - stream_seek_UINT32(irp->input); /* atrLen */ + Stream_Seek(irp->input, 0x24); + Stream_Seek_UINT32(irp->input); /* atrLen */ - stream_seek(irp->input, 0x0c); + Stream_Seek(irp->input, 0x0c); stream_read_UINT32(irp->input, hCard); - stream_seek(irp->input, 0x04); + Stream_Seek(irp->input, 0x04); #ifdef SCARD_AUTOALLOCATE readerLen = SCARD_AUTOALLOCATE; @@ -792,12 +792,12 @@ static DWORD handle_Status(IRP *irp, BOOL wide) int i; #endif - stream_seek(irp->input, 0x24); + Stream_Seek(irp->input, 0x24); stream_read_UINT32(irp->input, readerLen); stream_read_UINT32(irp->input, atrLen); - stream_seek(irp->input, 0x0c); + Stream_Seek(irp->input, 0x0c); stream_read_UINT32(irp->input, hCard); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); atrLen = MAX_ATR_SIZE; @@ -830,7 +830,7 @@ static DWORD handle_Status(IRP *irp, BOOL wide) state = smartcard_map_state(state); - poslen1 = stream_get_pos(irp->output); + poslen1 = Stream_GetPosition(irp->output); stream_write_UINT32(irp->output, readerLen); stream_write_UINT32(irp->output, 0x00020000); stream_write_UINT32(irp->output, state); @@ -841,19 +841,19 @@ static DWORD handle_Status(IRP *irp, BOOL wide) stream_write_zero(irp->output, 32 - atrLen); stream_write_UINT32(irp->output, atrLen); - poslen2 = stream_get_pos(irp->output); + poslen2 = Stream_GetPosition(irp->output); stream_write_UINT32(irp->output, readerLen); dataLength = smartcard_output_string(irp, readerName, wide); dataLength += smartcard_output_string(irp, "\0", wide); smartcard_output_repos(irp, dataLength); - pos = stream_get_pos(irp->output); - stream_set_pos(irp->output, poslen1); + pos = Stream_GetPosition(irp->output); + Stream_SetPosition(irp->output, poslen1); stream_write_UINT32(irp->output,dataLength); - stream_set_pos(irp->output, poslen2); + Stream_SetPosition(irp->output, poslen2); stream_write_UINT32(irp->output,dataLength); - stream_set_pos(irp->output, pos); + Stream_SetPosition(irp->output, pos); smartcard_output_alignment(irp, 8); @@ -876,9 +876,9 @@ static UINT32 handle_Transmit(IRP* irp) DWORD cbSendLength = 0, cbRecvLength = 0; BYTE *sendBuf = NULL, *recvBuf = NULL; - stream_seek(irp->input, 0x14); + Stream_Seek(irp->input, 0x14); stream_read_UINT32(irp->input, map[0]); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, map[1]); stream_read_UINT32(irp->input, pioSendPci.dwProtocol); @@ -894,7 +894,7 @@ static UINT32 handle_Transmit(IRP* irp) if (map[0] & SCARD_INPUT_LINKED) smartcard_input_skip_linked(irp); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); stream_read_UINT32(irp->input, hCard); if (map[2] & SCARD_INPUT_LINKED) @@ -903,7 +903,7 @@ static UINT32 handle_Transmit(IRP* irp) stream_read_UINT32(irp->input, linkedLen); stream_read_UINT32(irp->input, pioSendPci.dwProtocol); - stream_seek(irp->input, linkedLen - 4); + Stream_Seek(irp->input, linkedLen - 4); smartcard_input_repos(irp, linkedLen); } @@ -928,7 +928,7 @@ static UINT32 handle_Transmit(IRP* irp) stream_read_UINT32(irp->input, linkedLen); stream_read_UINT32(irp->input, pioRecvPci.dwProtocol); - stream_seek(irp->input, linkedLen - 4); + Stream_Seek(irp->input, linkedLen - 4); smartcard_input_repos(irp, linkedLen); @@ -937,7 +937,7 @@ static UINT32 handle_Transmit(IRP* irp) { /* not sure what this is */ stream_read_UINT32(irp->input, linkedLen); - stream_seek(irp->input, linkedLen); + Stream_Seek(irp->input, linkedLen); smartcard_input_repos(irp, linkedLen); } @@ -993,18 +993,18 @@ static UINT32 handle_Control(IRP* irp) DWORD nBytesReturned; DWORD outBufferSize; - stream_seek(irp->input, 0x14); + Stream_Seek(irp->input, 0x14); stream_read_UINT32(irp->input, map[0]); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, map[1]); stream_read_UINT32(irp->input, controlCode); stream_read_UINT32(irp->input, recvLength); stream_read_UINT32(irp->input, map[2]); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, outBufferSize); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, hContext); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, hCard); /* Translate Windows SCARD_CTL_CODE's to corresponding local code */ @@ -1069,11 +1069,11 @@ static UINT32 handle_GetAttrib(IRP* irp) DWORD attrLen = 0; BYTE* pbAttr = NULL; - stream_seek(irp->input, 0x20); + Stream_Seek(irp->input, 0x20); stream_read_UINT32(irp->input, dwAttrId); - stream_seek(irp->input, 0x4); + Stream_Seek(irp->input, 0x4); stream_read_UINT32(irp->input, dwAttrLen); - stream_seek(irp->input, 0xC); + Stream_Seek(irp->input, 0xC); stream_read_UINT32(irp->input, hCard); DEBUG_SCARD("hcard: 0x%08x, attrib: 0x%08x (%d bytes)", @@ -1182,7 +1182,7 @@ void scard_error(SMARTCARD_DEVICE* scard, IRP* irp, UINT32 ntstatus) /* [MS-RDPESC] 3.1.4.4 */ fprintf(stderr, "scard processing error %x\n", ntstatus); - stream_set_pos(irp->output, 0); /* CHECKME */ + Stream_SetPosition(irp->output, 0); /* CHECKME */ irp->IoStatus = ntstatus; irp->Complete(irp); } @@ -1209,7 +1209,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) SERVER_SCARD_ATRMASK* curAtr = NULL; SERVER_SCARD_ATRMASK* pAtrMasks = NULL; - stream_seek(irp->input, 0x2C); + Stream_Seek(irp->input, 0x2C); stream_read_UINT32(irp->input, hContext); stream_read_UINT32(irp->input, atrMaskCount); @@ -1237,7 +1237,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) { cur = &readerStates[i]; - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); /* * TODO: on-wire is little endian; need to either @@ -1249,7 +1249,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) stream_read_UINT32(irp->input, cur->cbAtr); stream_read(irp->input, cur->rgbAtr, 32); - stream_seek(irp->input, 4); + Stream_Seek(irp->input, 4); /* reset high bytes? */ cur->dwCurrentState &= 0x0000FFFF; @@ -1262,7 +1262,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) cur = &readerStates[i]; UINT32 dataLength; - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, dataLength); smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide)); @@ -1334,9 +1334,9 @@ BOOL smartcard_async_op(IRP* irp) UINT32 ioctl_code; /* peek ahead */ - stream_seek(irp->input, 8); + Stream_Seek(irp->input, 8); stream_read_UINT32(irp->input, ioctl_code); - stream_rewind(irp->input, 12); + Stream_Rewind(irp->input, 12); switch (ioctl_code) { @@ -1388,16 +1388,16 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) stream_read_UINT32(irp->input, input_len); stream_read_UINT32(irp->input, ioctl_code); - stream_seek(irp->input, 20); /* padding */ + Stream_Seek(irp->input, 20); /* padding */ - // stream_seek(irp->input, 4); /* TODO: parse len, le, v1 */ - // stream_seek(irp->input, 4); /* 0xcccccccc */ - // stream_seek(irp->input, 4); /* rpce len */ + // Stream_Seek(irp->input, 4); /* TODO: parse len, le, v1 */ + // Stream_Seek(irp->input, 4); /* 0xcccccccc */ + // Stream_Seek(irp->input, 4); /* rpce len */ /* [MS-RDPESC] 3.2.5.1 Sending Outgoing Messages */ stream_extend(irp->output, 2048); - irp_result_pos = stream_get_pos(irp->output); + irp_result_pos = Stream_GetPosition(irp->output); stream_write_UINT32(irp->output, 0x00000000); /* MS-RDPEFS * OutputBufferLength @@ -1409,13 +1409,13 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) stream_write_UINT32(irp->output, 0x00081001); /* len 8, LE, v1 */ stream_write_UINT32(irp->output, 0xcccccccc); /* filler */ - output_len_pos = stream_get_pos(irp->output); - stream_seek(irp->output, 4); /* size */ + output_len_pos = Stream_GetPosition(irp->output); + Stream_Seek(irp->output, 4); /* size */ stream_write_UINT32(irp->output, 0x0); /* filler */ - result_pos = stream_get_pos(irp->output); - stream_seek(irp->output, 4); /* result */ + result_pos = Stream_GetPosition(irp->output); + Stream_Seek(irp->output, 4); /* result */ /* body */ switch (ioctl_code) @@ -1529,24 +1529,24 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) result = 0x80100022; /* handle response packet */ - pos = stream_get_pos(irp->output); + pos = Stream_GetPosition(irp->output); stream_len = pos - irp_result_pos - 4; /* Value of OutputBufferLength */ - stream_set_pos(irp->output, irp_result_pos); + Stream_SetPosition(irp->output, irp_result_pos); stream_write_UINT32(irp->output, stream_len); - stream_set_pos(irp->output, output_len_pos); + Stream_SetPosition(irp->output, output_len_pos); /* Remove the effect of the MS-RPCE Common Type Header and Private * Header (Sections 2.2.6.1 and 2.2.6.2). */ stream_write_UINT32(irp->output, stream_len - header_lengths); - stream_set_pos(irp->output, result_pos); + Stream_SetPosition(irp->output, result_pos); stream_write_UINT32(irp->output, result); - stream_set_pos(irp->output, pos); + Stream_SetPosition(irp->output, pos); #ifdef WITH_DEBUG_SCARD - winpr_HexDump(stream_get_data(irp->output), stream_get_length(irp->output)); + winpr_HexDump(Stream_Buffer(irp->output), Stream_GetPosition(irp->output)); #endif irp->IoStatus = 0; diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index 9cf19e92a..80a19b2e0 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -293,7 +293,7 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt stream_read_UINT32(s, biSize); stream_read_UINT32(s, biWidth); stream_read_UINT32(s, biHeight); - stream_seek(s, 28); + Stream_Seek(s, 28); if (mediatype->Width == 0) mediatype->Width = biWidth; @@ -302,7 +302,7 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt /* Assume there will be no color table for video? */ if (bypass && biSize > 40) - stream_seek(s, biSize - 40); + Stream_Seek(s, biSize - 40); return (bypass ? biSize : 40); } @@ -313,22 +313,22 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wSt UINT64 AvgTimePerFrame; /* VIDEOINFOHEADER2.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */ - stream_seek_UINT32(s); - stream_seek_UINT32(s); + Stream_Seek_UINT32(s); + Stream_Seek_UINT32(s); stream_read_UINT32(s, mediatype->Width); stream_read_UINT32(s, mediatype->Height); /* VIDEOINFOHEADER2.rcTarget */ - stream_seek(s, 16); + Stream_Seek(s, 16); /* VIDEOINFOHEADER2.dwBitRate */ stream_read_UINT32(s, mediatype->BitRate); /* VIDEOINFOHEADER2.dwBitErrorRate */ - stream_seek_UINT32(s); + Stream_Seek_UINT32(s); /* VIDEOINFOHEADER2.AvgTimePerFrame */ stream_read_UINT64(s, AvgTimePerFrame); mediatype->SamplesPerSecond.Numerator = 1000000; mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL); /* Remaining fields before bmiHeader */ - stream_seek(s, 24); + Stream_Seek(s, 24); return 72; } @@ -349,16 +349,16 @@ typedef struct tagVIDEOINFOHEADER { UINT64 AvgTimePerFrame; /* VIDEOINFOHEADER.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */ - stream_seek_UINT32(s); - stream_seek_UINT32(s); + Stream_Seek_UINT32(s); + Stream_Seek_UINT32(s); stream_read_UINT32(s, mediatype->Width); stream_read_UINT32(s, mediatype->Height); /* VIDEOINFOHEADER.rcTarget */ - stream_seek(s, 16); + Stream_Seek(s, 16); /* VIDEOINFOHEADER.dwBitRate */ stream_read_UINT32(s, mediatype->BitRate); /* VIDEOINFOHEADER.dwBitErrorRate */ - stream_seek_UINT32(s); + Stream_Seek_UINT32(s); /* VIDEOINFOHEADER.AvgTimePerFrame */ stream_read_UINT64(s, AvgTimePerFrame); mediatype->SamplesPerSecond.Numerator = 1000000; @@ -377,55 +377,55 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) /* MajorType */ DEBUG_DVC("MajorType:"); - tsmf_print_guid(stream_get_tail(s)); + tsmf_print_guid(Stream_Pointer(s)); for (i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++) { - if (memcmp(tsmf_major_type_map[i].guid, stream_get_tail(s), 16) == 0) + if (memcmp(tsmf_major_type_map[i].guid, Stream_Pointer(s), 16) == 0) break; } mediatype->MajorType = tsmf_major_type_map[i].type; if (mediatype->MajorType == TSMF_MAJOR_TYPE_UNKNOWN) ret = FALSE; DEBUG_DVC("MajorType %s", tsmf_major_type_map[i].name); - stream_seek(s, 16); + Stream_Seek(s, 16); /* SubType */ DEBUG_DVC("SubType:"); - tsmf_print_guid(stream_get_tail(s)); + tsmf_print_guid(Stream_Pointer(s)); for (i = 0; tsmf_sub_type_map[i].type != TSMF_SUB_TYPE_UNKNOWN; i++) { - if (memcmp(tsmf_sub_type_map[i].guid, stream_get_tail(s), 16) == 0) + if (memcmp(tsmf_sub_type_map[i].guid, Stream_Pointer(s), 16) == 0) break; } mediatype->SubType = tsmf_sub_type_map[i].type; if (mediatype->SubType == TSMF_SUB_TYPE_UNKNOWN) ret = FALSE; DEBUG_DVC("SubType %s", tsmf_sub_type_map[i].name); - stream_seek(s, 16); + Stream_Seek(s, 16); /* bFixedSizeSamples, bTemporalCompression, SampleSize */ - stream_seek(s, 12); + Stream_Seek(s, 12); /* FormatType */ DEBUG_DVC("FormatType:"); - tsmf_print_guid(stream_get_tail(s)); + tsmf_print_guid(Stream_Pointer(s)); for (i = 0; tsmf_format_type_map[i].type != TSMF_FORMAT_TYPE_UNKNOWN; i++) { - if (memcmp(tsmf_format_type_map[i].guid, stream_get_tail(s), 16) == 0) + if (memcmp(tsmf_format_type_map[i].guid, Stream_Pointer(s), 16) == 0) break; } mediatype->FormatType = tsmf_format_type_map[i].type; if (mediatype->FormatType == TSMF_FORMAT_TYPE_UNKNOWN) ret = FALSE; DEBUG_DVC("FormatType %s", tsmf_format_type_map[i].name); - stream_seek(s, 16); + Stream_Seek(s, 16); /* cbFormat */ stream_read_UINT32(s, cbFormat); DEBUG_DVC("cbFormat %d", cbFormat); #ifdef WITH_DEBUG_DVC - winpr_HexDump(stream_get_tail(s), cbFormat); + winpr_HexDump(Stream_Pointer(s), cbFormat); #endif switch (mediatype->FormatType) @@ -433,28 +433,28 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) case TSMF_FORMAT_TYPE_MFVIDEOFORMAT: /* http://msdn.microsoft.com/en-us/library/aa473808.aspx */ - stream_seek(s, 8); /* dwSize and ? */ + Stream_Seek(s, 8); /* dwSize and ? */ stream_read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */ stream_read_UINT32(s, mediatype->Height); /* videoInfo.dwHeight */ - stream_seek(s, 32); + Stream_Seek(s, 32); /* videoInfo.FramesPerSecond */ stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator); stream_read_UINT32(s, mediatype->SamplesPerSecond.Denominator); - stream_seek(s, 80); + Stream_Seek(s, 80); stream_read_UINT32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */ - stream_seek(s, 36); + Stream_Seek(s, 36); if (cbFormat > 176) { mediatype->ExtraDataSize = cbFormat - 176; - mediatype->ExtraData = stream_get_tail(s); + mediatype->ExtraData = Stream_Pointer(s); } break; case TSMF_FORMAT_TYPE_WAVEFORMATEX: /* http://msdn.microsoft.com/en-us/library/dd757720.aspx */ - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); stream_read_UINT16(s, mediatype->Channels); stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator); mediatype->SamplesPerSecond.Denominator = 1; @@ -464,7 +464,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) stream_read_UINT16(s, mediatype->BitsPerSample); stream_read_UINT16(s, mediatype->ExtraDataSize); if (mediatype->ExtraDataSize > 0) - mediatype->ExtraData = stream_get_tail(s); + mediatype->ExtraData = Stream_Pointer(s); break; @@ -476,7 +476,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) if (cbFormat > i) { mediatype->ExtraDataSize = cbFormat - i; - mediatype->ExtraData = stream_get_tail(s); + mediatype->ExtraData = Stream_Pointer(s); } break; @@ -488,7 +488,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) if (cbFormat > i) { mediatype->ExtraDataSize = cbFormat - i; - mediatype->ExtraData = stream_get_tail(s); + mediatype->ExtraData = Stream_Pointer(s); } break; @@ -498,7 +498,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) if (cbFormat > i) { mediatype->ExtraDataSize = cbFormat - i; - mediatype->ExtraData = stream_get_tail(s); + mediatype->ExtraData = Stream_Pointer(s); } break; diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index b3bd1e97b..aeee1c591 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -60,18 +60,18 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) UINT32 cbCapabilityLength; UINT32 numHostCapabilities; - pos = stream_get_pos(ifman->output); + pos = Stream_GetPosition(ifman->output); stream_check_size(ifman->output, ifman->input_size + 4); stream_copy(ifman->output, ifman->input, ifman->input_size); - stream_set_pos(ifman->output, pos); + Stream_SetPosition(ifman->output, pos); stream_read_UINT32(ifman->output, numHostCapabilities); for (i = 0; i < numHostCapabilities; i++) { stream_read_UINT32(ifman->output, CapabilityType); stream_read_UINT32(ifman->output, cbCapabilityLength); - pos = stream_get_pos(ifman->output); + pos = Stream_GetPosition(ifman->output); switch (CapabilityType) { @@ -90,7 +90,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) DEBUG_WARN("unknown capability type %d", CapabilityType); break; } - stream_set_pos(ifman->output, pos + cbCapabilityLength); + Stream_SetPosition(ifman->output, pos + cbCapabilityLength); } stream_write_UINT32(ifman->output, 0); /* Result */ @@ -106,7 +106,7 @@ int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman) UINT32 FormatSupported = 1; stream_read_UINT32(ifman->input, PlatformCookie); - stream_seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */ + Stream_Seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */ stream_read_UINT32(ifman->input, numMediaType); DEBUG_DVC("PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType); @@ -143,7 +143,7 @@ int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman) } - presentation = tsmf_presentation_new(stream_get_tail(ifman->input), ifman->channel_callback); + presentation = tsmf_presentation_new(Stream_Pointer(ifman->input), ifman->channel_callback); pexisted = presentation; if (presentation == NULL) @@ -165,8 +165,8 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) DEBUG_DVC(""); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); - stream_seek(ifman->input, 16); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); + Stream_Seek(ifman->input, 16); if (presentation == NULL) { @@ -175,7 +175,7 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) else { stream_read_UINT32(ifman->input, StreamId); - stream_seek_UINT32(ifman->input); /* numMediaType */ + Stream_Seek_UINT32(ifman->input); /* numMediaType */ stream = tsmf_stream_new(presentation, StreamId); if (stream) @@ -208,8 +208,8 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) DEBUG_DVC(""); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); - stream_seek(ifman->input, 16); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); + Stream_Seek(ifman->input, 16); if (presentation == NULL) { @@ -236,7 +236,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) DEBUG_DVC(""); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_free(presentation); @@ -256,14 +256,14 @@ int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) DEBUG_DVC("on stream volume"); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { UINT32 newVolume; UINT32 muted; - stream_seek(ifman->input, 16); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, newVolume); DEBUG_DVC("on stream volume: new volume=[%d]", newVolume); stream_read_UINT32(ifman->input, muted); @@ -286,14 +286,14 @@ int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman) DEBUG_DVC("on channel volume"); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { UINT32 channelVolume; UINT32 changedChannel; - stream_seek(ifman->input, 16); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, channelVolume); DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume); stream_read_UINT32(ifman->input, changedChannel); @@ -327,19 +327,19 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) int i; int pos; - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); - stream_seek(ifman->input, 16); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, numGeometryInfo); - pos = stream_get_pos(ifman->input); + pos = Stream_GetPosition(ifman->input); - stream_seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */ + Stream_Seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */ stream_read_UINT32(ifman->input, Width); stream_read_UINT32(ifman->input, Height); stream_read_UINT32(ifman->input, Left); stream_read_UINT32(ifman->input, Top); - stream_set_pos(ifman->input, pos + numGeometryInfo); + Stream_SetPosition(ifman->input, pos + numGeometryInfo); stream_read_UINT32(ifman->input, cbVisibleRect); num_rects = cbVisibleRect / 16; @@ -360,13 +360,13 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) for (i = 0; i < num_rects; i++) { stream_read_UINT16(ifman->input, rects[i].y); /* Top */ - stream_seek_UINT16(ifman->input); + Stream_Seek_UINT16(ifman->input); stream_read_UINT16(ifman->input, rects[i].x); /* Left */ - stream_seek_UINT16(ifman->input); + Stream_Seek_UINT16(ifman->input); stream_read_UINT16(ifman->input, rects[i].height); /* Bottom */ - stream_seek_UINT16(ifman->input); + Stream_Seek_UINT16(ifman->input); stream_read_UINT16(ifman->input, rects[i].width); /* Right */ - stream_seek_UINT16(ifman->input); + Stream_Seek_UINT16(ifman->input); rects[i].width -= rects[i].x; rects[i].height -= rects[i].y; @@ -407,13 +407,13 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) UINT32 SampleExtensions; UINT32 cbData; - stream_seek(ifman->input, 16); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, StreamId); - stream_seek_UINT32(ifman->input); /* numSample */ + Stream_Seek_UINT32(ifman->input); /* numSample */ stream_read_UINT64(ifman->input, SampleStartTime); stream_read_UINT64(ifman->input, SampleEndTime); stream_read_UINT64(ifman->input, ThrottleDuration); - stream_seek_UINT32(ifman->input); /* SampleFlags */ + Stream_Seek_UINT32(ifman->input); /* SampleFlags */ stream_read_UINT32(ifman->input, SampleExtensions); stream_read_UINT32(ifman->input, cbData); @@ -440,7 +440,7 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions, - cbData, stream_get_tail(ifman->input)); + cbData, Stream_Pointer(ifman->input)); ifman->output_pending = TRUE; @@ -452,7 +452,7 @@ int tsmf_ifman_on_flush(TSMF_IFMAN* ifman) UINT32 StreamId; TSMF_PRESENTATION* presentation; - stream_seek(ifman->input, 16); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, StreamId); DEBUG_DVC("StreamId %d", StreamId); @@ -477,8 +477,8 @@ int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); - stream_seek(ifman->input, 16); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); + Stream_Seek(ifman->input, 16); stream_read_UINT32(ifman->input, StreamId); if (presentation) @@ -505,7 +505,7 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman) DEBUG_DVC(""); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_start(presentation); @@ -531,7 +531,7 @@ int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman) /* Added pause control so gstreamer pipeline can be paused accordingly */ - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_paused(presentation); @@ -550,7 +550,7 @@ int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman) /* Added restart control so gstreamer pipeline can be resumed accordingly */ - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_restarted(presentation); @@ -566,7 +566,7 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) DEBUG_DVC(""); - presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_stop(presentation); diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 591b59659..3d00688ba 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -89,8 +89,8 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, stream_write_UINT64(s, duration); /* DataDuration */ stream_write_UINT64(s, data_size); /* cbData */ - DEBUG_DVC("response size %d", (int) stream_get_length(s)); - status = callback->channel->Write(callback->channel, stream_get_length(s), stream_get_head(s), NULL); + DEBUG_DVC("response size %d", (int) Stream_GetPosition(s)); + status = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); if (status) { @@ -139,7 +139,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, input = stream_new(0); stream_attach(input, (BYTE*) pBuffer, cbSize); output = stream_new(256); - stream_seek(output, 8); + Stream_Seek(output, 8); stream_read_UINT32(input, InterfaceId); stream_read_UINT32(input, MessageId); @@ -181,8 +181,8 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, switch (FunctionId) { case SET_CHANNEL_PARAMS: - memcpy(callback->presentation_id, stream_get_tail(input), 16); - stream_seek(input, 16); + memcpy(callback->presentation_id, Stream_Pointer(input), 16); + Stream_Seek(input, 16); stream_read_UINT32(input, callback->stream_id); DEBUG_DVC("SET_CHANNEL_PARAMS StreamId=%d", callback->stream_id); ifman.output_pending = TRUE; @@ -317,8 +317,8 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, if (status == 0 && !ifman.output_pending) { /* Response packet does not have FunctionId */ - length = stream_get_length(output); - stream_set_pos(output, 0); + length = Stream_GetPosition(output); + Stream_SetPosition(output, 0); stream_write_UINT32(output, ifman.output_interface_id); stream_write_UINT32(output, MessageId); diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index c2acee2ac..7fdd936fc 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -930,7 +930,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) s = stream_new(0); stream_attach(s, data, size); - stream_seek(s, 14); + Stream_Seek(s, 14); stream_read_UINT16(s, bpp); stream_read_UINT32(s, ncolors); offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0); @@ -948,7 +948,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) stream_write(s, data, size); cb->data = stream_get_head(s); - cb->data_length = stream_get_length(s); + cb->data_length = Stream_GetPosition(s); stream_detach(s); stream_free(s); } diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index f9a9644a5..636da91c9 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -70,7 +70,7 @@ void assert_stream(wStream* s, BYTE* data, int length, const char* func, int lin BYTE* actual_data; actual_data = s->buffer; - actual_length = stream_get_length(s); + actual_length = Stream_GetPosition(s); if (actual_length != length) { diff --git a/cunit/test_nsc.c b/cunit/test_nsc.c index 5376c4a31..a59240c43 100644 --- a/cunit/test_nsc.c +++ b/cunit/test_nsc.c @@ -363,11 +363,11 @@ void test_nsc_encode(void) for (i = 0; i < 30000; i++) { - stream_set_pos(enc_stream, 0); + Stream_SetPosition(enc_stream, 0); nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3); } - /*winpr_HexDump(stream_get_head(enc_stream), stream_get_length(enc_stream));*/ - nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), stream_get_length(enc_stream)); + /*winpr_HexDump(stream_get_head(enc_stream), Stream_GetPosition(enc_stream));*/ + nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), Stream_GetPosition(enc_stream)); /*winpr_HexDump(context->bmpdata, 64 * 64 * 4);*/ stream_free(enc_stream); diff --git a/cunit/test_orders.c b/cunit/test_orders.c index 08d030a65..2f6d2b82d 100644 --- a/cunit/test_orders.c +++ b/cunit/test_orders.c @@ -91,7 +91,7 @@ void test_read_dstblt_order(void) CU_ASSERT(dstblt.nHeight == 311); CU_ASSERT(dstblt.bRop == 0); - CU_ASSERT(stream_get_length(s) == (sizeof(dstblt_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(dstblt_order) - 1)); } BYTE patblt_order[] = "\x1a\x00\xc3\x01\x0d\x00\x0d\x00\xf0\xff\xff\x00\x5b\xef\x00\x81"; @@ -121,7 +121,7 @@ void test_read_patblt_order(void) CU_ASSERT(patblt.brush.y == 0); CU_ASSERT(patblt.brush.style == (BMF_1BPP | CACHED_BRUSH)); - CU_ASSERT(stream_get_length(s) == (sizeof(patblt_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(patblt_order) - 1)); } BYTE scrblt_order[] = "\x07\x00\xa1\x01\xf1\x00\xcc\x2f\x01\x8e\x00"; @@ -148,7 +148,7 @@ void test_read_scrblt_order(void) CU_ASSERT(scrblt.nXSrc == 303); CU_ASSERT(scrblt.nYSrc == 142); - CU_ASSERT(stream_get_length(s) == (sizeof(scrblt_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(scrblt_order) - 1)); } BYTE opaque_rect_order[] = "\x00\x04\x00\x03\x73\x02\x06"; @@ -173,7 +173,7 @@ void test_read_opaque_rect_order(void) CU_ASSERT(opaque_rect.nHeight == 768); CU_ASSERT(opaque_rect.color == 0x00060273); - CU_ASSERT(stream_get_length(s) == (sizeof(opaque_rect_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(opaque_rect_order) - 1)); } BYTE draw_nine_grid_order[] = "\xfb\xf9\x0d\x00"; @@ -202,7 +202,7 @@ void test_read_draw_nine_grid_order(void) CU_ASSERT(draw_nine_grid.srcBottom == 33); CU_ASSERT(draw_nine_grid.bitmapId == 13); - CU_ASSERT(stream_get_length(s) == (sizeof(draw_nine_grid_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(draw_nine_grid_order) - 1)); } @@ -253,7 +253,7 @@ void test_read_multi_opaque_rect_order(void) CU_ASSERT(multi_opaque_rect.rectangles[4].width == 241); CU_ASSERT(multi_opaque_rect.rectangles[4].height == 1); - CU_ASSERT(stream_get_length(s) == (sizeof(multi_opaque_rect_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(multi_opaque_rect_order) - 1)); } BYTE line_to_order[] = "\x03\xb1\x0e\xa6\x5b\xef\x00"; @@ -288,7 +288,7 @@ void test_read_line_to_order(void) CU_ASSERT(line_to.penWidth == 0); CU_ASSERT(line_to.penColor == 0x00EF5B); - CU_ASSERT(stream_get_length(s) == (sizeof(line_to_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(line_to_order) - 1)); } BYTE polyline_order[] = @@ -357,7 +357,7 @@ void test_read_polyline_order(void) CU_ASSERT(polyline.points[31].x == -153); CU_ASSERT(polyline.points[32].x == 0); - CU_ASSERT(stream_get_length(s) == (sizeof(polyline_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(polyline_order) - 1)); } BYTE glyph_index_order_1[] = @@ -387,7 +387,7 @@ void test_read_glyph_index_order(void) CU_ASSERT(glyph_index.bkRight == 618); - CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_1) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(glyph_index_order_1) - 1)); s->pointer = s->buffer = glyph_index_order_2; @@ -412,7 +412,7 @@ void test_read_glyph_index_order(void) CU_ASSERT(glyph_index.x == 524); CU_ASSERT(glyph_index.y == 377); - CU_ASSERT(stream_get_length(s) == (sizeof(glyph_index_order_2) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(glyph_index_order_2) - 1)); } BYTE fast_index_order[] = @@ -450,7 +450,7 @@ void test_read_fast_index_order(void) CU_ASSERT(fast_index.x == -32768); CU_ASSERT(fast_index.y == 124); - CU_ASSERT(stream_get_length(s) == (sizeof(fast_index_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(fast_index_order) - 1)); } BYTE fast_glyph_order[] = @@ -486,7 +486,7 @@ void test_read_fast_glyph_order(void) CU_ASSERT(fast_glyph.x == -32768); CU_ASSERT(fast_glyph.y == 187); - CU_ASSERT(stream_get_length(s) == (sizeof(fast_glyph_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(fast_glyph_order) - 1)); } BYTE polygon_cb_order[] = @@ -520,7 +520,7 @@ void test_read_polygon_cb_order(void) CU_ASSERT(polygon_cb.numPoints == 3); CU_ASSERT(polygon_cb.cbData == 5); - CU_ASSERT(stream_get_length(s) == (sizeof(polygon_cb_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(polygon_cb_order) - 1)); } BYTE cache_bitmap_order[] = "\x00\x00\x10\x01\x08\x01\x00\x00\x00\x10"; @@ -546,7 +546,7 @@ void test_read_cache_bitmap_order(void) CU_ASSERT(cache_bitmap.bitmapLength == 1); CU_ASSERT(cache_bitmap.cacheIndex == 0); - CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_order) - 1)); } BYTE cache_bitmap_v2_order[] = @@ -588,7 +588,7 @@ void test_read_cache_bitmap_v2_order(void) CU_ASSERT(cache_bitmap_v2.bitmapLength == 220); CU_ASSERT(cache_bitmap_v2.cacheIndex == 32767); - CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v2_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_v2_order) - 1)); } BYTE cache_bitmap_v3_order[] = @@ -622,7 +622,7 @@ void test_read_cache_bitmap_v3_order(void) CU_ASSERT(cache_bitmap_v3.bitmapData.height == 2); CU_ASSERT(cache_bitmap_v3.bitmapData.length == 40); - CU_ASSERT(stream_get_length(s) == (sizeof(cache_bitmap_v3_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_bitmap_v3_order) - 1)); } BYTE cache_brush_order[] = "\x00\x01\x08\x08\x81\x08\xaa\x55\xaa\x55\xaa\x55\xaa\x55"; @@ -646,7 +646,7 @@ void test_read_cache_brush_order(void) CU_ASSERT(cache_brush.style == 0x81); CU_ASSERT(cache_brush.length == 8); - CU_ASSERT(stream_get_length(s) == (sizeof(cache_brush_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(cache_brush_order) - 1)); } BYTE create_offscreen_bitmap_order[] = "\x00\x80\x60\x01\x10\x00\x01\x00\x02\x00"; @@ -674,7 +674,7 @@ void test_read_create_offscreen_bitmap_order(void) CU_ASSERT(create_offscreen_bitmap.cy == 16); CU_ASSERT(create_offscreen_bitmap.deleteList.cIndices == 1); - CU_ASSERT(stream_get_length(s) == (sizeof(create_offscreen_bitmap_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(create_offscreen_bitmap_order) - 1)); } BYTE switch_surface_order[] = "\xff\xff"; @@ -693,7 +693,7 @@ void test_read_switch_surface_order(void) CU_ASSERT(switch_surface.bitmapId == 0xFFFF); - CU_ASSERT(stream_get_length(s) == (sizeof(switch_surface_order) - 1)); + CU_ASSERT(Stream_GetPosition(s) == (sizeof(switch_surface_order) - 1)); } int opaque_rect_count; diff --git a/cunit/test_rfx.c b/cunit/test_rfx.c index a69f85447..dcf848ded 100644 --- a/cunit/test_rfx.c +++ b/cunit/test_rfx.c @@ -310,7 +310,7 @@ void test_decode(void) stream_write(s, y_data, sizeof(y_data)); stream_write(s, cb_data, sizeof(cb_data)); stream_write(s, cr_data, sizeof(cr_data)); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); context = rfx_context_new(); context->mode = RLGR3; @@ -358,7 +358,7 @@ void test_encode(void) printf("*** Cr ***\n"); winpr_HexDump(stream_get_head(enc_stream) + y_size + cb_size, cr_size);*/ - stream_set_pos(enc_stream, 0); + Stream_SetPosition(enc_stream, 0); rfx_decode_rgb(context, enc_stream, y_size, test_quantization_values, cb_size, test_quantization_values, @@ -398,9 +398,9 @@ void test_message(void) stream_clear(s); rfx_compose_message(context, s, &rect, 1, rgb_data, 100, 80, 100 * 3); - stream_seal(s); + Stream_SealLength(s); /*hexdump(buffer, size);*/ - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); message = rfx_process_message(context, s->pointer, s->capacity); if (i == 0) { diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 9e9db09e1..89a9e26ac 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -178,9 +178,9 @@ static void nsc_stream_initialize(NSC_CONTEXT* context, wStream* s) stream_read_BYTE(s, context->nsc_stream.ColorLossLevel); stream_read_BYTE(s, context->nsc_stream.ChromaSubSamplingLevel); - stream_seek(s, 2); + Stream_Seek(s, 2); - context->nsc_stream.Planes = stream_get_tail(s); + context->nsc_stream.Planes = Stream_Pointer(s); } static void nsc_context_initialize(NSC_CONTEXT* context, wStream* s) diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 05c5735a3..cb9b4dcb4 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -330,7 +330,7 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s) UINT32 magic; /* RFX_SYNC */ - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) { DEBUG_WARN("RfxSync packet too small"); return FALSE; @@ -359,7 +359,7 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s) { BYTE numCodecs; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) { DEBUG_WARN("RfxCodecVersion packet too small"); return FALSE; @@ -372,7 +372,7 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s) return FALSE; } - if (stream_get_left(s) < 2 * numCodecs) + if (Stream_GetRemainingLength(s) < 2 * numCodecs) { DEBUG_WARN("RfxCodecVersion packet too small for numCodecs=%d", numCodecs); return FALSE; @@ -391,7 +391,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) BYTE channelId; BYTE numChannels; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) { DEBUG_WARN("RfxMessageChannels packet too small"); return FALSE; @@ -408,7 +408,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) return TRUE; } - if (stream_get_left(s) < numChannels * 5) + if (Stream_GetRemainingLength(s) < numChannels * 5) { DEBUG_WARN("RfxMessageChannels packet too small for numChannels=%d", numChannels); return FALSE; @@ -420,7 +420,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) stream_read_UINT16(s, context->height); /* height (2 bytes) */ /* Now, only the first monitor can be used, therefore the other channels will be ignored. */ - stream_seek(s, 5 * (numChannels - 1)); + Stream_Seek(s, 5 * (numChannels - 1)); DEBUG_RFX("numChannels %d id %d, %dx%d.", numChannels, channelId, context->width, context->height); @@ -433,7 +433,7 @@ static BOOL rfx_process_message_context(RFX_CONTEXT* context, wStream* s) UINT16 tileSize; UINT16 properties; - if (stream_get_left(s) < 5) + if (Stream_GetRemainingLength(s) < 5) { DEBUG_WARN("RfxMessageContext packet too small"); return FALSE; @@ -477,7 +477,7 @@ static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context, RFX_MESSAGE* m UINT32 frameIdx; UINT16 numRegions; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) { DEBUG_WARN("RfxMessageFrameBegin packet too small"); return FALSE; @@ -498,13 +498,13 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag { int i; - if (stream_get_left(s) < 3) + if (Stream_GetRemainingLength(s) < 3) { DEBUG_WARN("RfxMessageRegion packet too small"); return FALSE; } - stream_seek_BYTE(s); /* regionFlags (1 byte) */ + Stream_Seek_BYTE(s); /* regionFlags (1 byte) */ stream_read_UINT16(s, message->num_rects); /* numRects (2 bytes) */ if (message->num_rects < 1) @@ -513,7 +513,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag return TRUE; } - if (stream_get_left(s) < 8 * message->num_rects) + if (Stream_GetRemainingLength(s) < 8 * message->num_rects) { DEBUG_WARN("RfxMessageRegion packet too small for num_rects=%d", message->num_rects); return FALSE; @@ -547,7 +547,7 @@ static BOOL rfx_process_message_tile(RFX_CONTEXT* context, RFX_TILE* tile, wStre UINT16 xIdx, yIdx; UINT16 YLen, CbLen, CrLen; - if (stream_get_left(s) < 13) + if (Stream_GetRemainingLength(s) < 13) { DEBUG_WARN("RfxMessageTile packet too small"); return FALSE; @@ -603,7 +603,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa PTP_WORK* work_objects = NULL; RFX_TILE_WORK_PARAM* params = NULL; - if (stream_get_left(s) < 14) + if (Stream_GetRemainingLength(s) < 14) { DEBUG_WARN("RfxMessageTileSet packet too small"); return FALSE; @@ -617,11 +617,11 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa return FALSE; } - stream_seek_UINT16(s); /* idx (2 bytes), must be set to 0x0000 */ - stream_seek_UINT16(s); /* properties (2 bytes) */ + Stream_Seek_UINT16(s); /* idx (2 bytes), must be set to 0x0000 */ + Stream_Seek_UINT16(s); /* properties (2 bytes) */ stream_read_BYTE(s, context->num_quants); /* numQuant (1 byte) */ - stream_seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */ + Stream_Seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */ if (context->num_quants < 1) { @@ -646,7 +646,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa quants = context->quants; /* quantVals */ - if (stream_get_left(s) < context->num_quants * 5) + if (Stream_GetRemainingLength(s) < context->num_quants * 5) { DEBUG_WARN("RfxMessageTileSet packet too small for num_quants=%d", context->num_quants); return FALSE; @@ -692,7 +692,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa for (i = 0; i < message->num_tiles; i++) { /* RFX_TILE */ - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) { DEBUG_WARN("RfxMessageTileSet packet too small to read tile %d/%d", i, message->num_tiles); return FALSE; @@ -701,13 +701,13 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa stream_read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */ stream_read_UINT32(s, blockLen); /* blockLen (4 bytes) */ - if (stream_get_left(s) < blockLen - 6) + if (Stream_GetRemainingLength(s) < blockLen - 6) { DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", i, message->num_tiles, blockLen); return FALSE; } - pos = stream_get_pos(s) - 6 + blockLen; + pos = Stream_GetPosition(s) - 6 + blockLen; if (blockType != CBT_TILE) { @@ -733,7 +733,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa rfx_process_message_tile(context, message->tiles[i], s); } - stream_set_pos(s, pos); + Stream_SetPosition(s, pos); } if (context->priv->UseThreads) @@ -761,7 +761,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length s = stream_new(0); stream_attach(s, data, length); - while (stream_get_left(s) > 6) + while (Stream_GetRemainingLength(s) > 6) { /* RFX_BLOCKT */ stream_read_UINT16(s, blockType); /* blockType (2 bytes) */ @@ -775,14 +775,14 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length break; } - if (stream_get_left(s) < blockLen - 6) + if (Stream_GetRemainingLength(s) < blockLen - 6) { DEBUG_WARN("rfx_process_message: packet too small for blocklen=%d", blockLen); break; } - pos = stream_get_pos(s) - 6 + blockLen; + pos = Stream_GetPosition(s) - 6 + blockLen; if (blockType >= WBT_CONTEXT && blockType <= WBT_EXTENSION) { @@ -835,7 +835,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length break; } - stream_set_pos(s, pos); + Stream_SetPosition(s, pos); } stream_detach(s); @@ -1005,17 +1005,17 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, int start_pos, end_pos; stream_check_size(s, 19); - start_pos = stream_get_pos(s); + start_pos = Stream_GetPosition(s); stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */ - stream_seek_UINT32(s); /* set BlockT.blockLen later */ + Stream_Seek_UINT32(s); /* set BlockT.blockLen later */ stream_write_BYTE(s, quantIdxY); stream_write_BYTE(s, quantIdxCb); stream_write_BYTE(s, quantIdxCr); stream_write_UINT16(s, xIdx); stream_write_UINT16(s, yIdx); - stream_seek(s, 6); /* YLen, CbLen, CrLen */ + Stream_Seek(s, 6); /* YLen, CbLen, CrLen */ rfx_encode_rgb(context, tile_data, tile_width, tile_height, rowstride, quantVals + quantIdxY * 10, quantVals + quantIdxCb * 10, quantVals + quantIdxCr * 10, @@ -1024,16 +1024,16 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, DEBUG_RFX("xIdx=%d yIdx=%d width=%d height=%d YLen=%d CbLen=%d CrLen=%d", xIdx, yIdx, tile_width, tile_height, YLen, CbLen, CrLen); - end_pos = stream_get_pos(s); + end_pos = Stream_GetPosition(s); - stream_set_pos(s, start_pos + 2); + Stream_SetPosition(s, start_pos + 2); stream_write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */ - stream_set_pos(s, start_pos + 13); + Stream_SetPosition(s, start_pos + 13); stream_write_UINT16(s, YLen); stream_write_UINT16(s, CbLen); stream_write_UINT16(s, CrLen); - stream_set_pos(s, end_pos); + Stream_SetPosition(s, end_pos); } static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, @@ -1078,10 +1078,10 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, size = 22 + numQuants * 5; stream_check_size(s, size); - start_pos = stream_get_pos(s); + start_pos = Stream_GetPosition(s); stream_write_UINT16(s, WBT_EXTENSION); /* CodecChannelT.blockType */ - stream_seek_UINT32(s); /* set CodecChannelT.blockLen later */ + Stream_Seek_UINT32(s); /* set CodecChannelT.blockLen later */ stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ stream_write_UINT16(s, CBT_TILESET); /* subtype */ @@ -1090,7 +1090,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, stream_write_BYTE(s, numQuants); /* numQuants */ stream_write_BYTE(s, 0x40); /* tileSize */ stream_write_UINT16(s, numTiles); /* numTiles */ - stream_seek_UINT32(s); /* set tilesDataSize later */ + Stream_Seek_UINT32(s); /* set tilesDataSize later */ quantValsPtr = quantVals; for (i = 0; i < numQuants * 5; i++) @@ -1101,7 +1101,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, DEBUG_RFX("width:%d height:%d rowstride:%d", width, height, rowstride); - end_pos = stream_get_pos(s); + end_pos = Stream_GetPosition(s); for (yIdx = 0; yIdx < numTilesY; yIdx++) { for (xIdx = 0; xIdx < numTilesX; xIdx++) @@ -1113,16 +1113,16 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, rowstride, quantVals, quantIdxY, quantIdxCb, quantIdxCr, xIdx, yIdx); } } - tilesDataSize = stream_get_pos(s) - end_pos; + tilesDataSize = Stream_GetPosition(s) - end_pos; size += tilesDataSize; - end_pos = stream_get_pos(s); + end_pos = Stream_GetPosition(s); - stream_set_pos(s, start_pos + 2); + Stream_SetPosition(s, start_pos + 2); stream_write_UINT32(s, size); /* CodecChannelT.blockLen */ - stream_set_pos(s, start_pos + 18); + Stream_SetPosition(s, start_pos + 18); stream_write_UINT32(s, tilesDataSize); - stream_set_pos(s, end_pos); + Stream_SetPosition(s, end_pos); } static void rfx_compose_message_frame_end(RFX_CONTEXT* context, wStream* s) diff --git a/libfreerdp/codec/rfx_decode.c b/libfreerdp/codec/rfx_decode.c index 1acffda27..960096f1d 100644 --- a/libfreerdp/codec/rfx_decode.c +++ b/libfreerdp/codec/rfx_decode.c @@ -165,24 +165,24 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in, params[0].context = context; params[0].quantization_values = y_quants; - params[0].buffer = stream_get_tail(data_in); + params[0].buffer = Stream_Pointer(data_in); params[0].capacity = y_size; params[0].buffer = pSrcDst[0]; - stream_seek(data_in, y_size); + Stream_Seek(data_in, y_size); params[1].context = context; params[1].quantization_values = cb_quants; - params[1].buffer = stream_get_tail(data_in); + params[1].buffer = Stream_Pointer(data_in); params[1].capacity = cb_size; params[1].buffer = pSrcDst[1]; - stream_seek(data_in, cb_size); + Stream_Seek(data_in, cb_size); params[2].context = context; params[2].quantization_values = cr_quants; - params[2].buffer = stream_get_tail(data_in); + params[2].buffer = Stream_Pointer(data_in); params[2].capacity = cr_size; params[2].buffer = pSrcDst[2]; - stream_seek(data_in, cr_size); + Stream_Seek(data_in, cr_size); work_objects[0] = CreateThreadpoolWork((PTP_WORK_CALLBACK) rfx_decode_component_work_callback, (void*) ¶ms[0], &context->priv->ThreadPoolEnv); @@ -202,20 +202,20 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* context, wStream* data_in, else #endif { - if (stream_get_left(data_in) < y_size + cb_size + cr_size) + if (Stream_GetRemainingLength(data_in) < y_size + cb_size + cr_size) { DEBUG_WARN("rfx_decode_rgb: packet too small for y_size+cb_size+cr_size"); return FALSE; } - rfx_decode_component(context, y_quants, stream_get_tail(data_in), y_size, pSrcDst[0]); /* YData */ - stream_seek(data_in, y_size); + rfx_decode_component(context, y_quants, Stream_Pointer(data_in), y_size, pSrcDst[0]); /* YData */ + Stream_Seek(data_in, y_size); - rfx_decode_component(context, cb_quants, stream_get_tail(data_in), cb_size, pSrcDst[1]); /* CbData */ - stream_seek(data_in, cb_size); + rfx_decode_component(context, cb_quants, Stream_Pointer(data_in), cb_size, pSrcDst[1]); /* CbData */ + Stream_Seek(data_in, cb_size); - rfx_decode_component(context, cr_quants, stream_get_tail(data_in), cr_size, pSrcDst[2]); /* CrData */ - stream_seek(data_in, cr_size); + rfx_decode_component(context, cr_quants, Stream_Pointer(data_in), cr_size, pSrcDst[2]); /* CrData */ + Stream_Seek(data_in, cr_size); } prims->yCbCrToRGB_16s16s_P3P3((const INT16**) pSrcDst, 64 * sizeof(INT16), diff --git a/libfreerdp/codec/rfx_encode.c b/libfreerdp/codec/rfx_encode.c index af54d8997..030d9fe04 100644 --- a/libfreerdp/codec/rfx_encode.c +++ b/libfreerdp/codec/rfx_encode.c @@ -245,18 +245,18 @@ void rfx_encode_rgb(RFX_CONTEXT* context, const BYTE* rgb_data, int width, int h stream_check_size(data_out, 4096); rfx_encode_component(context, y_quants, pSrcDst[0], - stream_get_tail(data_out), stream_get_left(data_out), y_size); - stream_seek(data_out, *y_size); + Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), y_size); + Stream_Seek(data_out, *y_size); stream_check_size(data_out, 4096); rfx_encode_component(context, cb_quants, pSrcDst[1], - stream_get_tail(data_out), stream_get_left(data_out), cb_size); - stream_seek(data_out, *cb_size); + Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cb_size); + Stream_Seek(data_out, *cb_size); stream_check_size(data_out, 4096); rfx_encode_component(context, cr_quants, pSrcDst[2], - stream_get_tail(data_out), stream_get_left(data_out), cr_size); - stream_seek(data_out, *cr_size); + Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cr_size); + Stream_Seek(data_out, *cr_size); PROFILER_EXIT(context->priv->prof_rfx_encode_rgb); diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 61c7007dd..bf8e82426 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -70,7 +70,7 @@ BOOL rdp_recv_client_synchronize_pdu(rdpRdp* rdp, wStream* s) rdp->finalize_sc_pdus |= FINALIZE_SC_SYNCHRONIZE_PDU; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ @@ -79,7 +79,7 @@ BOOL rdp_recv_client_synchronize_pdu(rdpRdp* rdp, wStream* s) return FALSE; /* targetUser (2 bytes) */ - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); return TRUE; } @@ -97,12 +97,12 @@ BOOL rdp_send_client_synchronize_pdu(rdpRdp* rdp) BOOL rdp_recv_control_pdu(wStream* s, UINT16* action) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT16(s, *action); /* action (2 bytes) */ - stream_seek_UINT16(s); /* grantId (2 bytes) */ - stream_seek_UINT32(s); /* controlId (4 bytes) */ + Stream_Seek_UINT16(s); /* grantId (2 bytes) */ + Stream_Seek_UINT32(s); /* controlId (4 bytes) */ return TRUE; } @@ -208,7 +208,7 @@ BOOL rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp) BOOL rdp_recv_client_font_list_pdu(wStream* s) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; return TRUE; @@ -249,12 +249,12 @@ BOOL rdp_recv_server_font_map_pdu(rdpRdp* rdp, wStream* s) BOOL rdp_recv_client_font_map_pdu(rdpRdp* rdp, wStream* s) { rdp->finalize_sc_pdus |= FINALIZE_SC_FONT_MAP_PDU; - if(stream_get_left(s) >= 8) + if(Stream_GetRemainingLength(s) >= 8) { - stream_seek_UINT16(s); /* numberEntries (2 bytes) */ - stream_seek_UINT16(s); /* totalNumEntries (2 bytes) */ - stream_seek_UINT16(s); /* mapFlags (2 bytes) */ - stream_seek_UINT16(s); /* entrySize (2 bytes) */ + Stream_Seek_UINT16(s); /* numberEntries (2 bytes) */ + Stream_Seek_UINT16(s); /* totalNumEntries (2 bytes) */ + Stream_Seek_UINT16(s); /* mapFlags (2 bytes) */ + Stream_Seek_UINT16(s); /* entrySize (2 bytes) */ } return TRUE; @@ -282,18 +282,18 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s) * Windows XP can send short DEACTIVATE_ALL PDU that doesn't contain * the following fields. */ - if (stream_get_left(s) > 0) + if (Stream_GetRemainingLength(s) > 0) { do { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) break; stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ - if(stream_get_left(s) < 2) + if(Stream_GetRemainingLength(s) < 2) break; stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ - if(stream_get_left(s) < lengthSourceDescriptor) + if(Stream_GetRemainingLength(s) < lengthSourceDescriptor) break; - stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */ + Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */ } while(0); } diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index a927b3cc2..2ddacd9f8 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -171,17 +171,17 @@ BOOL rdp_read_general_capability_set(wStream* s, UINT16 length, rdpSettings* set } else { - stream_seek_UINT16(s); /* osMajorType (2 bytes) */ - stream_seek_UINT16(s); /* osMinorType (2 bytes) */ + Stream_Seek_UINT16(s); /* osMajorType (2 bytes) */ + Stream_Seek_UINT16(s); /* osMinorType (2 bytes) */ } - stream_seek_UINT16(s); /* protocolVersion (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */ - stream_seek_UINT16(s); /* generalCompressionTypes (2 bytes) */ + Stream_Seek_UINT16(s); /* protocolVersion (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ + Stream_Seek_UINT16(s); /* generalCompressionTypes (2 bytes) */ stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - stream_seek_UINT16(s); /* updateCapabilityFlag (2 bytes) */ - stream_seek_UINT16(s); /* remoteUnshareFlag (2 bytes) */ - stream_seek_UINT16(s); /* generalCompressionLevel (2 bytes) */ + Stream_Seek_UINT16(s); /* updateCapabilityFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* remoteUnshareFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* generalCompressionLevel (2 bytes) */ stream_read_BYTE(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ stream_read_BYTE(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ @@ -303,18 +303,18 @@ BOOL rdp_read_bitmap_capability_set(wStream* s, UINT16 length, rdpSettings* sett return FALSE; stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ - stream_seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */ - stream_seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */ - stream_seek_UINT16(s); /* receive8BitsPerPixel (2 bytes) */ + Stream_Seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */ + Stream_Seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */ + Stream_Seek_UINT16(s); /* receive8BitsPerPixel (2 bytes) */ stream_read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */ stream_read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */ - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ stream_read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ - stream_seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */ - stream_seek_BYTE(s); /* highColorFlags (1 byte) */ + Stream_Seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */ + Stream_Seek_BYTE(s); /* highColorFlags (1 byte) */ stream_read_BYTE(s, drawingFlags); /* drawingFlags (1 byte) */ - stream_seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */ + Stream_Seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */ if (!settings->ServerMode && (preferredBitsPerPixel != settings->ColorDepth)) { @@ -448,23 +448,23 @@ BOOL rdp_read_order_capability_set(wStream* s, UINT16 length, rdpSettings* setti if (length < 88) return FALSE; - stream_seek(s, 16); /* terminalDescriptor (16 bytes) */ - stream_seek_UINT32(s); /* pad4OctetsA (4 bytes) */ - stream_seek_UINT16(s); /* desktopSaveXGranularity (2 bytes) */ - stream_seek_UINT16(s); /* desktopSaveYGranularity (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */ - stream_seek_UINT16(s); /* maximumOrderLevel (2 bytes) */ - stream_seek_UINT16(s); /* numberFonts (2 bytes) */ + Stream_Seek(s, 16); /* terminalDescriptor (16 bytes) */ + Stream_Seek_UINT32(s); /* pad4OctetsA (4 bytes) */ + Stream_Seek_UINT16(s); /* desktopSaveXGranularity (2 bytes) */ + Stream_Seek_UINT16(s); /* desktopSaveYGranularity (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ + Stream_Seek_UINT16(s); /* maximumOrderLevel (2 bytes) */ + Stream_Seek_UINT16(s); /* numberFonts (2 bytes) */ stream_read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ stream_read(s, orderSupport, 32); /* orderSupport (32 bytes) */ - stream_seek_UINT16(s); /* textFlags (2 bytes) */ + Stream_Seek_UINT16(s); /* textFlags (2 bytes) */ stream_read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ - stream_seek_UINT32(s); /* pad4OctetsB (4 bytes) */ - stream_seek_UINT32(s); /* desktopSaveSize (4 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsC (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsD (2 bytes) */ - stream_seek_UINT16(s); /* textANSICodePage (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsE (2 bytes) */ + Stream_Seek_UINT32(s); /* pad4OctetsB (4 bytes) */ + Stream_Seek_UINT32(s); /* desktopSaveSize (4 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsC (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsD (2 bytes) */ + Stream_Seek_UINT16(s); /* textANSICodePage (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsE (2 bytes) */ for (i = 0; i < 32; i++) { @@ -640,18 +640,18 @@ BOOL rdp_read_bitmap_cache_capability_set(wStream* s, UINT16 length, rdpSettings if (length < 40) return FALSE; - stream_seek_UINT32(s); /* pad1 (4 bytes) */ - stream_seek_UINT32(s); /* pad2 (4 bytes) */ - stream_seek_UINT32(s); /* pad3 (4 bytes) */ - stream_seek_UINT32(s); /* pad4 (4 bytes) */ - stream_seek_UINT32(s); /* pad5 (4 bytes) */ - stream_seek_UINT32(s); /* pad6 (4 bytes) */ - stream_seek_UINT16(s); /* Cache0Entries (2 bytes) */ - stream_seek_UINT16(s); /* Cache0MaximumCellSize (2 bytes) */ - stream_seek_UINT16(s); /* Cache1Entries (2 bytes) */ - stream_seek_UINT16(s); /* Cache1MaximumCellSize (2 bytes) */ - stream_seek_UINT16(s); /* Cache2Entries (2 bytes) */ - stream_seek_UINT16(s); /* Cache2MaximumCellSize (2 bytes) */ + Stream_Seek_UINT32(s); /* pad1 (4 bytes) */ + Stream_Seek_UINT32(s); /* pad2 (4 bytes) */ + Stream_Seek_UINT32(s); /* pad3 (4 bytes) */ + Stream_Seek_UINT32(s); /* pad4 (4 bytes) */ + Stream_Seek_UINT32(s); /* pad5 (4 bytes) */ + Stream_Seek_UINT32(s); /* pad6 (4 bytes) */ + Stream_Seek_UINT16(s); /* Cache0Entries (2 bytes) */ + Stream_Seek_UINT16(s); /* Cache0MaximumCellSize (2 bytes) */ + Stream_Seek_UINT16(s); /* Cache1Entries (2 bytes) */ + Stream_Seek_UINT16(s); /* Cache1MaximumCellSize (2 bytes) */ + Stream_Seek_UINT16(s); /* Cache2Entries (2 bytes) */ + Stream_Seek_UINT16(s); /* Cache2MaximumCellSize (2 bytes) */ return TRUE; } @@ -753,10 +753,10 @@ BOOL rdp_read_control_capability_set(wStream* s, UINT16 length, rdpSettings* set if (length < 12) return FALSE; - stream_seek_UINT16(s); /* controlFlags (2 bytes) */ - stream_seek_UINT16(s); /* remoteDetachFlag (2 bytes) */ - stream_seek_UINT16(s); /* controlInterest (2 bytes) */ - stream_seek_UINT16(s); /* detachInterest (2 bytes) */ + Stream_Seek_UINT16(s); /* controlFlags (2 bytes) */ + Stream_Seek_UINT16(s); /* remoteDetachFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* controlInterest (2 bytes) */ + Stream_Seek_UINT16(s); /* detachInterest (2 bytes) */ return TRUE; } @@ -820,10 +820,10 @@ BOOL rdp_read_window_activation_capability_set(wStream* s, UINT16 length, rdpSet if (length < 12) return FALSE; - stream_seek_UINT16(s); /* helpKeyFlag (2 bytes) */ - stream_seek_UINT16(s); /* helpKeyIndexFlag (2 bytes) */ - stream_seek_UINT16(s); /* helpExtendedKeyFlag (2 bytes) */ - stream_seek_UINT16(s); /* windowManagerKeyFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* helpKeyFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* helpKeyIndexFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* helpExtendedKeyFlag (2 bytes) */ + Stream_Seek_UINT16(s); /* windowManagerKeyFlag (2 bytes) */ return TRUE; } @@ -967,8 +967,8 @@ BOOL rdp_read_share_capability_set(wStream* s, UINT16 length, rdpSettings* setti if (length < 8) return FALSE; - stream_seek_UINT16(s); /* nodeId (2 bytes) */ - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* nodeId (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ return TRUE; } @@ -1027,8 +1027,8 @@ BOOL rdp_read_color_cache_capability_set(wStream* s, UINT16 length, rdpSettings* if (length < 8) return FALSE; - stream_seek_UINT16(s); /* colorTableCacheSize (2 bytes) */ - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* colorTableCacheSize (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ return TRUE; } @@ -1087,7 +1087,7 @@ BOOL rdp_read_sound_capability_set(wStream* s, UINT16 length, rdpSettings* setti return FALSE; stream_read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ settings->SoundBeepsEnabled = (soundFlags & SOUND_BEEPS_FLAG) ? TRUE : FALSE; @@ -1151,7 +1151,7 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti return FALSE; stream_read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ if (settings->ServerMode) { @@ -1162,13 +1162,13 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti } else { - stream_seek_UINT32(s); /* keyboardLayout (4 bytes) */ - stream_seek_UINT32(s); /* keyboardType (4 bytes) */ - stream_seek_UINT32(s); /* keyboardSubType (4 bytes) */ - stream_seek_UINT32(s); /* keyboardFunctionKeys (4 bytes) */ + Stream_Seek_UINT32(s); /* keyboardLayout (4 bytes) */ + Stream_Seek_UINT32(s); /* keyboardType (4 bytes) */ + Stream_Seek_UINT32(s); /* keyboardSubType (4 bytes) */ + Stream_Seek_UINT32(s); /* keyboardFunctionKeys (4 bytes) */ } - stream_seek(s, 64); /* imeFileName (64 bytes) */ + Stream_Seek(s, 64); /* imeFileName (64 bytes) */ if (settings->ServerMode != TRUE) { @@ -1242,7 +1242,7 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length) stream_read_UINT32(s, keyboardType); /* keyboardType (4 bytes) */ stream_read_UINT32(s, keyboardSubType); /* keyboardSubType (4 bytes) */ stream_read_UINT32(s, keyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ - stream_seek(s, 64); /* imeFileName (64 bytes) */ + Stream_Seek(s, 64); /* imeFileName (64 bytes) */ fprintf(stderr, "\tinputFlags: 0x%04X\n", inputFlags); fprintf(stderr, "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); @@ -1265,10 +1265,10 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length) BOOL rdp_read_font_capability_set(wStream* s, UINT16 length, rdpSettings* settings) { if (length > 4) - stream_seek_UINT16(s); /* fontSupportFlags (2 bytes) */ + Stream_Seek_UINT16(s); /* fontSupportFlags (2 bytes) */ if (length > 6) - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ return TRUE; } @@ -1324,7 +1324,7 @@ BOOL rdp_read_brush_capability_set(wStream* s, UINT16 length, rdpSettings* setti if (length < 8) return FALSE; - stream_seek_UINT32(s); /* brushSupportLevel (4 bytes) */ + Stream_Seek_UINT32(s); /* brushSupportLevel (4 bytes) */ return TRUE; } @@ -1400,10 +1400,10 @@ BOOL rdp_read_glyph_cache_capability_set(wStream* s, UINT16 length, rdpSettings* if (length < 52) return FALSE; - stream_seek(s, 40); /* glyphCache (40 bytes) */ - stream_seek_UINT32(s); /* fragCache (4 bytes) */ + Stream_Seek(s, 40); /* glyphCache (40 bytes) */ + Stream_Seek_UINT32(s); /* fragCache (4 bytes) */ stream_read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ settings->GlyphSupportLevel = glyphSupportLevel; @@ -1575,8 +1575,8 @@ BOOL rdp_read_bitmap_cache_host_support_capability_set(wStream* s, UINT16 length return FALSE; stream_read_BYTE(s, cacheVersion); /* cacheVersion (1 byte) */ - stream_seek_BYTE(s); /* pad1 (1 byte) */ - stream_seek_UINT16(s); /* pad2 (2 bytes) */ + Stream_Seek_BYTE(s); /* pad1 (1 byte) */ + Stream_Seek_UINT16(s); /* pad2 (2 bytes) */ if (cacheVersion & BITMAP_CACHE_V2) settings->BitmapCachePersistEnabled = TRUE; @@ -1667,15 +1667,15 @@ BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, UINT16 length, rdpSetti if (length < 40) return FALSE; - stream_seek_UINT16(s); /* cacheFlags (2 bytes) */ - stream_seek_BYTE(s); /* pad2 (1 byte) */ - stream_seek_BYTE(s); /* numCellCaches (1 byte) */ - stream_seek(s, 4); /* bitmapCache0CellInfo (4 bytes) */ - stream_seek(s, 4); /* bitmapCache1CellInfo (4 bytes) */ - stream_seek(s, 4); /* bitmapCache2CellInfo (4 bytes) */ - stream_seek(s, 4); /* bitmapCache3CellInfo (4 bytes) */ - stream_seek(s, 4); /* bitmapCache4CellInfo (4 bytes) */ - stream_seek(s, 12); /* pad3 (12 bytes) */ + Stream_Seek_UINT16(s); /* cacheFlags (2 bytes) */ + Stream_Seek_BYTE(s); /* pad2 (1 byte) */ + Stream_Seek_BYTE(s); /* numCellCaches (1 byte) */ + Stream_Seek(s, 4); /* bitmapCache0CellInfo (4 bytes) */ + Stream_Seek(s, 4); /* bitmapCache1CellInfo (4 bytes) */ + Stream_Seek(s, 4); /* bitmapCache2CellInfo (4 bytes) */ + Stream_Seek(s, 4); /* bitmapCache3CellInfo (4 bytes) */ + Stream_Seek(s, 4); /* bitmapCache4CellInfo (4 bytes) */ + Stream_Seek(s, 12); /* pad3 (12 bytes) */ return TRUE; } @@ -1732,7 +1732,7 @@ BOOL rdp_print_bitmap_cache_v2_capability_set(wStream* s, UINT16 length) rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[2]); /* bitmapCache2CellInfo (4 bytes) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[3]); /* bitmapCache3CellInfo (4 bytes) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[4]); /* bitmapCache4CellInfo (4 bytes) */ - stream_seek(s, 12); /* pad3 (12 bytes) */ + Stream_Seek(s, 12); /* pad3 (12 bytes) */ fprintf(stderr, "\tcacheFlags: 0x%04X\n", cacheFlags); fprintf(stderr, "\tpad2: 0x%02X\n", pad2); @@ -1928,11 +1928,11 @@ BOOL rdp_read_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length, rdpSe return FALSE; stream_read_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */ - stream_seek_UINT32(s); /* GdipVersion (4 bytes) */ + Stream_Seek_UINT32(s); /* GdipVersion (4 bytes) */ stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */ - stream_seek(s, 10); /* GdipCacheEntries (10 bytes) */ - stream_seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ - stream_seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ + Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */ + Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ + Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ if (drawGDIPlusSupportLevel & DRAW_GDIPLUS_SUPPORTED) settings->DrawGdiPlusEnabled = TRUE; @@ -1985,9 +1985,9 @@ BOOL rdp_print_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length) stream_read_UINT32(s, drawGdiPlusSupportLevel); /* drawGdiPlusSupportLevel (4 bytes) */ stream_read_UINT32(s, GdipVersion); /* GdipVersion (4 bytes) */ stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiPlusCacheLevel (4 bytes) */ - stream_seek(s, 10); /* GdipCacheEntries (10 bytes) */ - stream_seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ - stream_seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ + Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */ + Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ + Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ return TRUE; } @@ -2073,9 +2073,9 @@ BOOL rdp_read_window_list_capability_set(wStream* s, UINT16 length, rdpSettings* if (length < 11) return FALSE; - stream_seek_UINT32(s); /* wndSupportLevel (4 bytes) */ - stream_seek_BYTE(s); /* numIconCaches (1 byte) */ - stream_seek_UINT16(s); /* numIconCacheEntries (2 bytes) */ + Stream_Seek_UINT32(s); /* wndSupportLevel (4 bytes) */ + Stream_Seek_BYTE(s); /* numIconCaches (1 byte) */ + Stream_Seek_UINT16(s); /* numIconCacheEntries (2 bytes) */ return TRUE; } @@ -2138,7 +2138,7 @@ BOOL rdp_read_desktop_composition_capability_set(wStream* s, UINT16 length, rdpS if (length < 6) return FALSE; - stream_seek_UINT16(s); /* compDeskSupportLevel (2 bytes) */ + Stream_Seek_UINT16(s); /* compDeskSupportLevel (2 bytes) */ return TRUE; } @@ -2191,10 +2191,12 @@ BOOL rdp_print_desktop_composition_capability_set(wStream* s, UINT16 length) BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdpSettings* settings) { UINT32 multifragMaxRequestSize; + if (length < 8) return FALSE; stream_read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ + if (settings->MultifragMaxRequestSize < multifragMaxRequestSize) settings->MultifragMaxRequestSize = multifragMaxRequestSize; @@ -2248,7 +2250,7 @@ BOOL rdp_read_large_pointer_capability_set(wStream* s, UINT16 length, rdpSetting if (length < 6) return FALSE; - stream_seek_UINT16(s); /* largePointerSupportFlags (2 bytes) */ + Stream_Seek_UINT16(s); /* largePointerSupportFlags (2 bytes) */ return TRUE; } @@ -2303,8 +2305,8 @@ BOOL rdp_read_surface_commands_capability_set(wStream* s, UINT16 length, rdpSett if (length < 12) return FALSE; - stream_seek_UINT32(s); /* cmdFlags (4 bytes) */ - stream_seek_UINT32(s); /* reserved (4 bytes) */ + Stream_Seek_UINT32(s); /* cmdFlags (4 bytes) */ + Stream_Seek_UINT32(s); /* reserved (4 bytes) */ settings->SurfaceCommandsEnabled = TRUE; @@ -2473,12 +2475,12 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting } else { - stream_seek_BYTE(s); /* codecID (1 byte) */ + Stream_Seek_BYTE(s); /* codecID (1 byte) */ } } else { - stream_seek_BYTE(s); /* codecID (1 byte) */ + Stream_Seek_BYTE(s); /* codecID (1 byte) */ } stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ @@ -2491,9 +2493,9 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting { if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status)) { - stream_seek_UINT32(s); /* length */ + Stream_Seek_UINT32(s); /* length */ stream_read_UINT32(s, settings->RemoteFxCaptureFlags); /* captureFlags */ - stream_rewind(s, 8); + Stream_Rewind(s, 8); if (settings->RemoteFxCaptureFlags & CARDP_CAPS_CAPTURE_NON_CAC) { @@ -2502,7 +2504,7 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting } } - stream_seek(s, codecPropertiesLength); /* codecProperties */ + Stream_Seek(s, codecPropertiesLength); /* codecProperties */ remainingLength -= codecPropertiesLength; bitmapCodecCount--; @@ -2747,7 +2749,7 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) if (remainingLength < codecPropertiesLength) return FALSE; - stream_seek(s, codecPropertiesLength); /* codecProperties */ + Stream_Seek(s, codecPropertiesLength); /* codecProperties */ remainingLength -= codecPropertiesLength; bitmapCodecCount--; @@ -2774,7 +2776,7 @@ BOOL rdp_read_frame_acknowledge_capability_set(wStream* s, UINT16 length, rdpSet } else { - stream_seek_UINT32(s); /* (4 bytes) */ + Stream_Seek_UINT32(s); /* (4 bytes) */ } return TRUE; } @@ -2867,7 +2869,7 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei em = bm + length; - if (stream_get_left(s) < length - 4) + if (Stream_GetRemainingLength(s) < length - 4) { fprintf(stderr, "error processing stream\n"); return FALSE; @@ -3058,7 +3060,7 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa settings->ReceivedCapabilities[type] = TRUE; em = bm + length; - if (stream_get_left(s) < length - 4) + if (Stream_GetRemainingLength(s) < length - 4) { fprintf(stderr, "error processing stream\n"); return FALSE; @@ -3302,18 +3304,18 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) return FALSE; } - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - if (!stream_skip(s, lengthSourceDescriptor) || stream_get_left(s) < 4) /* sourceDescriptor */ + if (!stream_skip(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */ return FALSE; stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* capabilitySets */ if (!rdp_read_capability_sets(s, rdp->settings, numberCapabilities)) @@ -3337,11 +3339,11 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) stream_write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ stream_get_mark(s, lm); - stream_seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ stream_write(s, "RDP", 4); /* sourceDescriptor */ stream_get_mark(s, bm); - stream_seek_UINT16(s); /* numberCapabilities (2 bytes) */ + Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ numberCapabilities = 14; @@ -3376,10 +3378,10 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); stream_set_mark(s, bm); - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); #endif stream_set_mark(s, em); @@ -3421,20 +3423,20 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s) if (pduType != PDU_TYPE_CONFIRM_ACTIVE) return FALSE; - if (stream_get_left(s) < 10) + if (Stream_GetRemainingLength(s) < 10) return FALSE; - stream_seek_UINT32(s); /* shareId (4 bytes) */ - stream_seek_UINT16(s); /* originatorId (2 bytes) */ + Stream_Seek_UINT32(s); /* shareId (4 bytes) */ + Stream_Seek_UINT16(s); /* originatorId (2 bytes) */ stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - if (stream_get_left(s) < lengthSourceDescriptor + 4) + if (Stream_GetRemainingLength(s) < lengthSourceDescriptor + 4) return FALSE; - stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor */ + Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor */ stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ return rdp_read_capability_sets(s, rdp->settings, numberCapabilities); } @@ -3453,11 +3455,11 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) stream_write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */ stream_get_mark(s, lm); - stream_seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ stream_write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */ stream_get_mark(s, bm); - stream_seek_UINT16(s); /* numberCapabilities (2 bytes) */ + Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ /* Capability Sets */ @@ -3561,10 +3563,10 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); stream_set_mark(s, bm); - stream_seek_UINT16(s); + Stream_Seek_UINT16(s); #endif stream_set_mark(s, em); diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index d97ba11a2..603811da1 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -232,7 +232,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) /* skip zero padding, if any */ do { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) goto error1; stream_peek_BYTE(s, padding); @@ -246,7 +246,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) while (padding == 0); error++; - if(stream_get_left(s) < modulus_length) + if(Stream_GetRemainingLength(s) < modulus_length) goto error1; info->ModulusLength = modulus_length; info->Modulus = (BYTE*) malloc(info->ModulusLength); @@ -256,7 +256,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) if(!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */ goto error2; error++; - if(stream_get_left(s) < exponent_length || exponent_length > 4) + if(Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4) goto error2; stream_read(s, &info->exponent[4 - exponent_length], exponent_length); crypto_reverse(info->Modulus, info->ModulusLength); @@ -325,7 +325,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w UINT32 datalen; UINT32 modlen; - if(stream_get_left(s) < 20) + if(Stream_GetRemainingLength(s) < 20) return FALSE; stream_read(s, magic, 4); @@ -341,13 +341,13 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w stream_read(s, certificate->cert_info.exponent, 4); modlen = keylen - 8; - if(stream_get_left(s) < modlen + 8) // count padding + if(Stream_GetRemainingLength(s) < modlen + 8) // count padding return FALSE; certificate->cert_info.ModulusLength = modlen; certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength); stream_read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength); /* 8 bytes of zero padding */ - stream_seek(s, 8); + Stream_Seek(s, 8); return TRUE; } @@ -425,11 +425,11 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate BYTE* sigdata; int sigdatalen; - if(stream_get_left(s) < 12) + if(Stream_GetRemainingLength(s) < 12) return FALSE; /* -4, because we need to include dwVersion */ - sigdata = stream_get_tail(s) - 4; + sigdata = Stream_Pointer(s) - 4; stream_read_UINT32(s, dwSigAlgId); stream_read_UINT32(s, dwKeyAlgId); @@ -448,7 +448,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate } stream_read_UINT16(s, wPublicKeyBlobLen); - if(stream_get_left(s) < wPublicKeyBlobLen) + if(Stream_GetRemainingLength(s) < wPublicKeyBlobLen) return FALSE; if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen)) @@ -457,10 +457,10 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; } - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; - sigdatalen = stream_get_tail(s) - sigdata; + sigdatalen = Stream_Pointer(s) - sigdata; stream_read_UINT16(s, wSignatureBlobType); if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB) @@ -470,7 +470,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate } stream_read_UINT16(s, wSignatureBlobLen); - if(stream_get_left(s) < wSignatureBlobLen) + if(Stream_GetRemainingLength(s) < wSignatureBlobLen) return FALSE; if (wSignatureBlobLen != 72) @@ -503,7 +503,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, DEBUG_CERTIFICATE("Server X.509 Certificate Chain"); - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, numCertBlobs); /* numCertBlobs */ @@ -511,10 +511,10 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, for (i = 0; i < (int) numCertBlobs; i++) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, certLength); - if(stream_get_left(s) < certLength) + if(Stream_GetRemainingLength(s) < certLength) return FALSE; DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength); diff --git a/libfreerdp/core/channel.c b/libfreerdp/core/channel.c index 45d11c8d9..8342d0d62 100644 --- a/libfreerdp/core/channel.c +++ b/libfreerdp/core/channel.c @@ -99,15 +99,15 @@ BOOL freerdp_channel_process(freerdp* instance, wStream* s, UINT16 channel_id) UINT32 flags; int chunk_length; - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, length); stream_read_UINT32(s, flags); - chunk_length = stream_get_left(s); + chunk_length = Stream_GetRemainingLength(s); IFCALL(instance->ReceiveChannelData, instance, - channel_id, stream_get_tail(s), chunk_length, flags, length); + channel_id, Stream_Pointer(s), chunk_length, flags, length); return TRUE; } @@ -118,13 +118,13 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann UINT32 flags; int chunk_length; - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, length); stream_read_UINT32(s, flags); - chunk_length = stream_get_left(s); + chunk_length = Stream_GetRemainingLength(s); IFCALL(client->ReceiveChannelData, client, - channel_id, stream_get_tail(s), chunk_length, flags, length); + channel_id, Stream_Pointer(s), chunk_length, flags, length); return TRUE; } diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 4b60d868b..bc1637b6e 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -349,10 +349,10 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) return FALSE; } - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, rand_len); - if(stream_get_left(s) < rand_len + 8) /* include 8 bytes of padding */ + if(Stream_GetRemainingLength(s) < rand_len + 8) /* include 8 bytes of padding */ return FALSE; key_len = rdp->settings->RdpServerRsaKey->ModulusLength; @@ -366,7 +366,7 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) memset(crypt_client_random, 0, sizeof(crypt_client_random)); stream_read(s, crypt_client_random, rand_len); /* 8 zero bytes of padding */ - stream_seek(s, 8); + Stream_Seek(s, 8); mod = rdp->settings->RdpServerRsaKey->Modulus; priv_exp = rdp->settings->RdpServerRsaKey->PrivateExponent; crypto_rsa_private_decrypt(crypt_client_random, rand_len - 8, key_len, mod, priv_exp, client_random); @@ -535,7 +535,7 @@ BOOL rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s) UINT16 channelId; stream_set_mark(s, mark); rdp_recv_get_active_header(rdp, s, &channelId); - /* Was stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + /* Was Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); * but the headers aren't always that length, * so that could result in a bad offset. */ diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 8a680d7e7..b94ec77b1 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -76,9 +76,9 @@ UINT16 fastpath_header_length(wStream* s) { BYTE length1; - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); stream_read_BYTE(s, length1); - stream_rewind(s, 2); + Stream_Rewind(s, 2); return ((length1 & 0x80) != 0 ? 3 : 2); } @@ -142,7 +142,7 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length) if (!per_read_length(s, length)) return FALSE; - *length = *length - stream_get_length(s); + *length = *length - Stream_GetPosition(s); return TRUE; } @@ -169,7 +169,7 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s) rdpUpdate* update = fastpath->rdp->update; rdpContext* context = update->context; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, updateType); /* updateType (2 bytes) */ @@ -305,10 +305,10 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) stream_read_UINT16(s, size); - if (stream_get_left(s) < size) + if (Stream_GetRemainingLength(s) < size) return -1; - next_pos = stream_get_pos(s) + size; + next_pos = Stream_GetPosition(s) + size; comp_stream = s; if (compressionFlags & PACKET_COMPRESSED) @@ -324,7 +324,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) else { fprintf(stderr, "decompress_rdp() failed\n"); - stream_seek(s, size); + Stream_Seek(s, size); } } @@ -338,12 +338,12 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) else { if (fragmentation == FASTPATH_FRAGMENT_FIRST) - stream_set_pos(fastpath->updateData, 0); + Stream_SetPosition(fastpath->updateData, 0); stream_check_size(fastpath->updateData, size); stream_copy(fastpath->updateData, comp_stream, size); - if (stream_get_length(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize) + if (Stream_GetPosition(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize) { fprintf(stderr, "fastpath PDU is bigger than MultifragMaxRequestSize\n"); return -1; @@ -352,8 +352,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (fragmentation == FASTPATH_FRAGMENT_LAST) { update_stream = fastpath->updateData; - totalSize = stream_get_length(update_stream); - stream_set_pos(update_stream, 0); + totalSize = Stream_GetPosition(update_stream); + Stream_SetPosition(update_stream, 0); } } @@ -365,7 +365,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) return -1; } - stream_set_pos(s, next_pos); + Stream_SetPosition(s, next_pos); if (comp_stream != s) free(comp_stream); @@ -380,7 +380,7 @@ int fastpath_recv_updates(rdpFastPath* fastpath, wStream* s) IFCALL(update->BeginPaint, update->context); - while (stream_get_left(s) >= 3) + while (Stream_GetRemainingLength(s) >= 3) { if (fastpath_recv_update_data(fastpath, s) < 0) return -1; @@ -395,7 +395,7 @@ static BOOL fastpath_read_input_event_header(wStream* s, BYTE* eventFlags, BYTE* { BYTE eventHeader; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, eventHeader); /* eventHeader (1 byte) */ @@ -411,7 +411,7 @@ static BOOL fastpath_recv_input_event_scancode(rdpFastPath* fastpath, wStream* s UINT16 flags; UINT16 code; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, code); /* keyCode (1 byte) */ @@ -436,7 +436,7 @@ static BOOL fastpath_recv_input_event_mouse(rdpFastPath* fastpath, wStream* s, B UINT16 xPos; UINT16 yPos; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ @@ -454,7 +454,7 @@ static BOOL fastpath_recv_input_event_mousex(rdpFastPath* fastpath, wStream* s, UINT16 xPos; UINT16 yPos; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ @@ -478,7 +478,7 @@ static BOOL fastpath_recv_input_event_unicode(rdpFastPath* fastpath, wStream* s, UINT16 unicodeCode; UINT16 flags; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ @@ -548,7 +548,7 @@ int fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s) * as one additional byte here. */ - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return -1; stream_read_BYTE(s, fastpath->numberEvents); /* eventHeader (1 byte) */ @@ -586,13 +586,13 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev rdp = fastpath->rdp; s = transport_send_stream_init(rdp->transport, 256); - stream_seek(s, 3); /* fpInputHeader, length1 and length2 */ + Stream_Seek(s, 3); /* fpInputHeader, length1 and length2 */ if (rdp->do_crypt) { rdp->sec_flags |= SEC_ENCRYPT; if (rdp->do_secure_checksum) rdp->sec_flags |= SEC_SECURE_CHECKSUM; } - stream_seek(s, fastpath_get_sec_bytes(rdp)); + Stream_Seek(s, fastpath_get_sec_bytes(rdp)); stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ return s; } @@ -606,7 +606,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) rdp = fastpath->rdp; - length = stream_get_length(s); + length = Stream_GetPosition(s); if (length >= (2 << 14)) { fprintf(stderr, "Maximum FastPath PDU length is 32767\n"); @@ -620,7 +620,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) if (rdp->sec_flags & SEC_SECURE_CHECKSUM) eventHeader |= (FASTPATH_INPUT_SECURE_CHECKSUM << 6); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); stream_write_BYTE(s, eventHeader); sec_bytes = fastpath_get_sec_bytes(fastpath->rdp); /* @@ -636,18 +636,18 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) BYTE* fpInputEvents; UINT16 fpInputEvents_length; - fpInputEvents = stream_get_tail(s) + sec_bytes; + fpInputEvents = Stream_Pointer(s) + sec_bytes; fpInputEvents_length = length - 3 - sec_bytes; if (rdp->sec_flags & SEC_SECURE_CHECKSUM) - security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, TRUE, stream_get_tail(s)); + security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, TRUE, Stream_Pointer(s)); else - security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, stream_get_tail(s)); + security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, Stream_Pointer(s)); security_encrypt(fpInputEvents, fpInputEvents_length, rdp); } rdp->sec_flags = 0; - stream_set_pos(s, length); + Stream_SetPosition(s, length); if (transport_write(fastpath->rdp->transport, s) < 0) return FALSE; @@ -658,9 +658,9 @@ wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) { wStream* s; s = transport_send_stream_init(fastpath->rdp->transport, FASTPATH_MAX_PACKET_SIZE); - stream_seek(s, 3); /* fpOutputHeader, length1 and length2 */ - stream_seek(s, fastpath_get_sec_bytes(fastpath->rdp)); - stream_seek(s, 3); /* updateHeader, size */ + Stream_Seek(s, 3); /* fpOutputHeader, length1 and length2 */ + Stream_Seek(s, fastpath_get_sec_bytes(fastpath->rdp)); + Stream_Seek(s, 3); /* updateHeader, size */ return s; } @@ -694,8 +694,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s rdp = fastpath->rdp; sec_bytes = fastpath_get_sec_bytes(rdp); maxLength = FASTPATH_MAX_PACKET_SIZE - (6 + sec_bytes); - totalLength = stream_get_length(s) - (6 + sec_bytes); - stream_set_pos(s, 0); + totalLength = Stream_GetPosition(s) - (6 + sec_bytes); + Stream_SetPosition(s, 0); update = stream_new(0); try_comp = rdp->settings->CompressionEnabled; comp_update = stream_new(0); @@ -745,7 +745,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s stream_write_BYTE(ls, pduLength & 0xFF); /* length2 */ if (sec_bytes > 0) - stream_seek(ls, sec_bytes); + Stream_Seek(ls, sec_bytes); fastpath_write_update_header(ls, updateCode, fragmentation, comp_flags); @@ -761,7 +761,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s stream_write_UINT16(ls, pdu_data_bytes); stream_attach(update, bm, pduLength); - stream_seek(update, pduLength); + Stream_Seek(update, pduLength); if (sec_bytes > 0) { diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 6770a1ab3..6533f89a0 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -140,7 +140,7 @@ BOOL freerdp_connect(freerdp* instance) s->capacity = record.length; pcap_get_next_record_content(update->pcap_rfx, &record); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); update->BeginPaint(update->context); update_recv_surfcmds(update, s->capacity, s); diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index 9c2ee81fb..96f15c09f 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -249,7 +249,7 @@ wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request Stream_Write(s, "\0", 1); /* append null terminator */ Stream_Rewind(s, 1); /* don't include null terminator in length */ - Stream_Length(s) = Stream_Position(s); + Stream_Length(s) = Stream_GetPosition(s); return s; } diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index d60ab3381..3456b604c 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -105,7 +105,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) Stream_EnsureCapacity(rpc->client->pdu->s, Stream_Length(fragment)); Stream_Write(rpc->client->pdu->s, buffer, Stream_Length(fragment)); - Stream_Length(rpc->client->pdu->s) = Stream_Position(rpc->client->pdu->s); + Stream_Length(rpc->client->pdu->s) = Stream_GetPosition(rpc->client->pdu->s); rpc_client_fragment_pool_return(rpc, fragment); @@ -195,7 +195,7 @@ int rpc_client_on_fragment_received_event(rdpRpc* rpc) rpc->client->pdu->Flags = RPC_PDU_FLAG_STUB; rpc->client->pdu->CallId = rpc->StubCallId; - Stream_Length(rpc->client->pdu->s) = Stream_Position(rpc->client->pdu->s); + Stream_Length(rpc->client->pdu->s) = Stream_GetPosition(rpc->client->pdu->s); rpc->StubFragCount = 0; rpc->StubCallId = 0; @@ -219,12 +219,12 @@ int rpc_client_on_read_event(rdpRpc* rpc) if (!rpc->client->RecvFrag) rpc->client->RecvFrag = rpc_client_fragment_pool_take(rpc); - position = Stream_Position(rpc->client->RecvFrag); + position = Stream_GetPosition(rpc->client->RecvFrag); - if (Stream_Position(rpc->client->RecvFrag) < RPC_COMMON_FIELDS_LENGTH) + if (Stream_GetPosition(rpc->client->RecvFrag) < RPC_COMMON_FIELDS_LENGTH) { status = rpc_out_read(rpc, Stream_Pointer(rpc->client->RecvFrag), - RPC_COMMON_FIELDS_LENGTH - Stream_Position(rpc->client->RecvFrag)); + RPC_COMMON_FIELDS_LENGTH - Stream_GetPosition(rpc->client->RecvFrag)); if (status < 0) { @@ -235,7 +235,7 @@ int rpc_client_on_read_event(rdpRpc* rpc) Stream_Seek(rpc->client->RecvFrag, status); } - if (Stream_Position(rpc->client->RecvFrag) >= RPC_COMMON_FIELDS_LENGTH) + if (Stream_GetPosition(rpc->client->RecvFrag) >= RPC_COMMON_FIELDS_LENGTH) { header = (rpcconn_common_hdr_t*) Stream_Buffer(rpc->client->RecvFrag); @@ -243,14 +243,14 @@ int rpc_client_on_read_event(rdpRpc* rpc) { fprintf(stderr, "rpc_client_frag_read: invalid fragment size: %d (max: %d)\n", header->frag_length, rpc->max_recv_frag); - winpr_HexDump(Stream_Buffer(rpc->client->RecvFrag), Stream_Position(rpc->client->RecvFrag)); + winpr_HexDump(Stream_Buffer(rpc->client->RecvFrag), Stream_GetPosition(rpc->client->RecvFrag)); return -1; } - if (Stream_Position(rpc->client->RecvFrag) < header->frag_length) + if (Stream_GetPosition(rpc->client->RecvFrag) < header->frag_length) { status = rpc_out_read(rpc, Stream_Pointer(rpc->client->RecvFrag), - header->frag_length - Stream_Position(rpc->client->RecvFrag)); + header->frag_length - Stream_GetPosition(rpc->client->RecvFrag)); if (status < 0) { @@ -269,13 +269,13 @@ int rpc_client_on_read_event(rdpRpc* rpc) if (status < 0) return -1; - status = Stream_Position(rpc->client->RecvFrag) - position; + status = Stream_GetPosition(rpc->client->RecvFrag) - position; - if (Stream_Position(rpc->client->RecvFrag) >= header->frag_length) + if (Stream_GetPosition(rpc->client->RecvFrag) >= header->frag_length) { /* complete fragment received */ - Stream_Length(rpc->client->RecvFrag) = Stream_Position(rpc->client->RecvFrag); + Stream_Length(rpc->client->RecvFrag) = Stream_GetPosition(rpc->client->RecvFrag); Stream_SetPosition(rpc->client->RecvFrag, 0); Queue_Enqueue(rpc->client->FragmentQueue, rpc->client->RecvFrag); diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index 1aa2f9a5e..7d2b4a7fc 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -121,7 +121,7 @@ DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], UINT32 count, if (buffer3Length > 0) Stream_Write(s, buffer3, buffer3Length); /* buffer3 (variable) */ - Stream_Length(s) = Stream_Position(s); + Stream_Length(s) = Stream_GetPosition(s); status = rpc_write(tsg->rpc, Stream_Buffer(s), Stream_Length(s), TsProxySendToServerOpnum); diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 2904fe619..02afcb0b6 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -179,7 +179,7 @@ BOOL gcc_read_conference_create_request(wStream* s, rdpSettings* settings) /* userData::value (OCTET_STRING) */ if (!per_read_length(s, &length)) return FALSE; - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; if (!gcc_read_client_data_blocks(s, settings, length)) return FALSE; @@ -201,7 +201,7 @@ void gcc_write_conference_create_request(wStream* s, wStream* user_data) per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */ /* ConnectData::connectPDU (OCTET_STRING) */ - per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */ + per_write_length(s, Stream_GetPosition(user_data) + 14); /* connectPDU length */ /* ConnectGCCPDU */ per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */ @@ -219,7 +219,7 @@ void gcc_write_conference_create_request(wStream* s, wStream* user_data) per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */ /* userData::value (OCTET_STRING) */ - per_write_octet_string(s, user_data->buffer, stream_get_length(user_data), 0); /* array of client data blocks */ + per_write_octet_string(s, user_data->buffer, Stream_GetPosition(user_data), 0); /* array of client data blocks */ } BOOL gcc_read_conference_create_response(wStream* s, rdpSettings* settings) @@ -278,7 +278,7 @@ void gcc_write_conference_create_response(wStream* s, wStream* user_data) per_write_object_identifier(s, t124_02_98_oid); /* ConnectData::connectPDU (OCTET_STRING) */ - per_write_length(s, stream_get_length(user_data) + 2); + per_write_length(s, Stream_GetPosition(user_data) + 2); /* ConnectGCCPDU */ per_write_choice(s, 0x14); @@ -302,7 +302,7 @@ void gcc_write_conference_create_response(wStream* s, wStream* user_data) per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */ /* userData (OCTET_STRING) */ - per_write_octet_string(s, user_data->buffer, stream_get_length(user_data), 0); /* array of server data blocks */ + per_write_octet_string(s, user_data->buffer, Stream_GetPosition(user_data), 0); /* array of server data blocks */ } BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length) @@ -313,7 +313,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length) while (length > 0) { - pos = stream_get_pos(s); + pos = Stream_GetPosition(s); if(!gcc_read_user_data_header(s, &type, &blockLength)) return FALSE; @@ -349,7 +349,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpSettings* settings, int length) } length -= blockLength; - stream_set_pos(s, pos + blockLength); + Stream_SetPosition(s, pos + blockLength); } return TRUE; @@ -453,13 +453,13 @@ void gcc_write_server_data_blocks(wStream* s, rdpSettings* settings) BOOL gcc_read_user_data_header(wStream* s, UINT16* type, UINT16* length) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, *type); /* type */ stream_read_UINT16(s, *length); /* length */ - if (stream_get_left(s) < *length - 4) + if (Stream_GetRemainingLength(s) < *length - 4) return FALSE; return TRUE; @@ -507,13 +507,13 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe stream_read_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ stream_read_UINT16(s, settings->DesktopHeight); /* DesktopHeight */ stream_read_UINT16(s, colorDepth); /* ColorDepth */ - stream_seek_UINT16(s); /* SASSequence (Secure Access Sequence) */ + Stream_Seek_UINT16(s); /* SASSequence (Secure Access Sequence) */ stream_read_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */ stream_read_UINT32(s, settings->ClientBuild); /* ClientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 32 / 2, &str, 0, NULL, NULL); - stream_seek(s, 32); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 32 / 2, &str, 0, NULL, NULL); + Stream_Seek(s, 32); sprintf_s(settings->ClientHostname, 31, "%s", str); settings->ClientHostname[31] = 0; free(str); @@ -523,7 +523,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe stream_read_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ stream_read_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ - stream_seek(s, 64); /* imeFileName */ + Stream_Seek(s, 64); /* imeFileName */ blockLength -= 128; @@ -543,12 +543,12 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 2) break; - stream_seek_UINT16(s); /* clientProductID */ + Stream_Seek_UINT16(s); /* clientProductID */ blockLength -= 2; if (blockLength < 4) break; - stream_seek_UINT32(s); /* serialNumber */ + Stream_Seek_UINT32(s); /* serialNumber */ blockLength -= 4; if (blockLength < 2) @@ -569,8 +569,8 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 64) break; - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL); - stream_seek(s, 64); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL); + Stream_Seek(s, 64); sprintf_s(settings->ClientProductId, 32, "%s", str); free(str); blockLength -= 64; @@ -582,7 +582,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 1) break; - stream_seek_BYTE(s); /* pad1octet */ + Stream_Seek_BYTE(s); /* pad1octet */ blockLength -= 1; if (blockLength < 4) @@ -753,7 +753,7 @@ BOOL gcc_read_server_core_data(wStream* s, rdpSettings* settings) UINT32 version; UINT32 clientRequestedProtocols; - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, version); /* version */ stream_read_UINT32(s, clientRequestedProtocols); /* clientRequestedProtocols */ @@ -794,7 +794,7 @@ BOOL gcc_read_client_security_data(wStream* s, rdpSettings* settings, UINT16 blo } else { - stream_seek(s, 8); + Stream_Seek(s, 8); } return TRUE; } @@ -828,7 +828,7 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) BYTE* data; UINT32 length; - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */ stream_read_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */ @@ -842,12 +842,12 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) return TRUE; } - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, settings->ServerRandomLength); /* serverRandomLen */ stream_read_UINT32(s, settings->ServerCertificateLength); /* serverCertLen */ - if (stream_get_left(s) < settings->ServerRandomLength + settings->ServerCertificateLength) + if (Stream_GetRemainingLength(s) < settings->ServerRandomLength + settings->ServerCertificateLength) return FALSE; if (settings->ServerRandomLength > 0) @@ -1016,7 +1016,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) crypto_nonce(settings->ServerRandom, serverRandomLen); stream_write(s, settings->ServerRandom, serverRandomLen); - sigData = stream_get_tail(s); + sigData = Stream_Pointer(s); stream_write_UINT32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */ stream_write_UINT32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */ @@ -1033,7 +1033,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) stream_write(s, settings->RdpServerRsaKey->Modulus, keyLen); stream_write_zero(s, 8); - sigDataLen = stream_get_tail(s) - sigData; + sigDataLen = Stream_Pointer(s) - sigData; stream_write_UINT16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */ stream_write_UINT16(s, keyLen + 8); /* wSignatureBlobLen */ @@ -1119,7 +1119,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings) UINT16 channelCount; UINT16 channelId; - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, MCSChannelId); /* MCSChannelId */ stream_read_UINT16(s, channelCount); /* channelCount */ @@ -1130,7 +1130,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings) settings->ChannelCount, channelCount); } - if(stream_get_left(s) < channelCount * 2) + if(Stream_GetRemainingLength(s) < channelCount * 2) return FALSE; for (i = 0; i < channelCount; i++) diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 60caf5bf1..8eadd9fea 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -54,7 +54,7 @@ BOOL rdp_read_server_auto_reconnect_cookie(wStream* s, rdpSettings* settings) ARC_SC_PRIVATE_PACKET* autoReconnectCookie; autoReconnectCookie = settings->ServerAutoReconnectCookie; - if (stream_get_left(s) < 4+4+4+16) + if (Stream_GetRemainingLength(s) < 4+4+4+16) return FALSE; stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ stream_read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ @@ -75,7 +75,7 @@ BOOL rdp_read_client_auto_reconnect_cookie(wStream* s, rdpSettings* settings) ARC_CS_PRIVATE_PACKET* autoReconnectCookie; autoReconnectCookie = settings->ClientAutoReconnectCookie; - if (stream_get_left(s) < 28) + if (Stream_GetRemainingLength(s) < 28) return FALSE; stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ @@ -118,38 +118,38 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings) UINT16 cbClientDir; UINT16 cbAutoReconnectLen; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, clientAddressFamily); /* clientAddressFamily */ stream_read_UINT16(s, cbClientAddress); /* cbClientAddress */ settings->IPv6Enabled = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? TRUE : FALSE); - if (stream_get_left(s) < cbClientAddress) + if (Stream_GetRemainingLength(s) < cbClientAddress) return FALSE; - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL); - stream_seek(s, cbClientAddress); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL); + Stream_Seek(s, cbClientAddress); - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, cbClientDir); /* cbClientDir */ - if (stream_get_left(s) < cbClientDir) + if (Stream_GetRemainingLength(s) < cbClientDir) return FALSE; if (settings->ClientDir) free(settings->ClientDir); - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL); - stream_seek(s, cbClientDir); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL); + Stream_Seek(s, cbClientDir); if (!rdp_read_client_time_zone(s, settings)) return FALSE; - if (stream_get_left(s) < 10) + if (Stream_GetRemainingLength(s) < 10) return FALSE; - stream_seek_UINT32(s); /* clientSessionId, should be set to 0 */ + Stream_Seek_UINT32(s); /* clientSessionId, should be set to 0 */ stream_read_UINT32(s, settings->PerformanceFlags); /* performanceFlags */ stream_read_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */ @@ -234,10 +234,10 @@ BOOL rdp_read_info_packet(wStream* s, rdpSettings* settings) UINT16 cbAlternateShell; UINT16 cbWorkingDir; - if (stream_get_left(s) < 18) // invalid packet + if (Stream_GetRemainingLength(s) < 18) // invalid packet return FALSE; - stream_seek_UINT32(s); /* CodePage */ + Stream_Seek_UINT32(s); /* CodePage */ stream_read_UINT32(s, flags); /* flags */ settings->AutoLogonEnabled = ((flags & INFO_AUTOLOGON) ? TRUE : FALSE); @@ -251,55 +251,55 @@ BOOL rdp_read_info_packet(wStream* s, rdpSettings* settings) stream_read_UINT16(s, cbAlternateShell); /* cbAlternateShell */ stream_read_UINT16(s, cbWorkingDir); /* cbWorkingDir */ - if (stream_get_left(s) < cbDomain + 2) + if (Stream_GetRemainingLength(s) < cbDomain + 2) return FALSE; if (cbDomain > 0) { - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbDomain / 2, &settings->Domain, 0, NULL, NULL); - stream_seek(s, cbDomain); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbDomain / 2, &settings->Domain, 0, NULL, NULL); + Stream_Seek(s, cbDomain); } - stream_seek(s, 2); + Stream_Seek(s, 2); - if (stream_get_left(s) < cbUserName + 2) + if (Stream_GetRemainingLength(s) < cbUserName + 2) return FALSE; if (cbUserName > 0) { - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbUserName / 2, &settings->Username, 0, NULL, NULL); - stream_seek(s, cbUserName); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbUserName / 2, &settings->Username, 0, NULL, NULL); + Stream_Seek(s, cbUserName); } - stream_seek(s, 2); + Stream_Seek(s, 2); - if (stream_get_left(s) < cbPassword + 2) + if (Stream_GetRemainingLength(s) < cbPassword + 2) return FALSE; if (cbPassword > 0) { - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbPassword / 2, &settings->Password, 0, NULL, NULL); - stream_seek(s, cbPassword); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbPassword / 2, &settings->Password, 0, NULL, NULL); + Stream_Seek(s, cbPassword); } - stream_seek(s, 2); + Stream_Seek(s, 2); - if (stream_get_left(s) < cbAlternateShell + 2) + if (Stream_GetRemainingLength(s) < cbAlternateShell + 2) return FALSE; if (cbAlternateShell > 0) { - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbAlternateShell / 2, &settings->AlternateShell, 0, NULL, NULL); - stream_seek(s, cbAlternateShell); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbAlternateShell / 2, &settings->AlternateShell, 0, NULL, NULL); + Stream_Seek(s, cbAlternateShell); } - stream_seek(s, 2); + Stream_Seek(s, 2); - if (stream_get_left(s) < cbWorkingDir + 2) + if (Stream_GetRemainingLength(s) < cbWorkingDir + 2) return FALSE; if (cbWorkingDir > 0) { - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), cbWorkingDir / 2, &settings->ShellWorkingDirectory, 0, NULL, NULL); - stream_seek(s, cbWorkingDir); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbWorkingDir / 2, &settings->ShellWorkingDirectory, 0, NULL, NULL); + Stream_Seek(s, cbWorkingDir); } - stream_seek(s, 2); + Stream_Seek(s, 2); if (settings->RdpVersion >= 5) return rdp_read_extended_info_packet(s, settings); /* extraInfo */ @@ -488,14 +488,14 @@ BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s) UINT32 cbDomain; UINT32 cbUserName; - if (stream_get_left(s) < (4 + 52 + 4 + 512 + 4)) + if (Stream_GetRemainingLength(s) < (4 + 52 + 4 + 512 + 4)) return FALSE; stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ - stream_seek(s, 52); /* domain (52 bytes) */ + Stream_Seek(s, 52); /* domain (52 bytes) */ stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ - stream_seek(s, 512); /* userName (512 bytes) */ - stream_seek_UINT32(s); /* sessionId (4 bytes) */ + Stream_Seek(s, 512); /* userName (512 bytes) */ + Stream_Seek_UINT32(s); /* sessionId (4 bytes) */ return TRUE; } @@ -505,31 +505,31 @@ BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s) UINT32 cbDomain; UINT32 cbUserName; - if (stream_get_left(s) < (2 + 4 + 4 + 4 + 4 + 558)) + if (Stream_GetRemainingLength(s) < (2 + 4 + 4 + 4 + 4 + 558)) return FALSE; - stream_seek_UINT16(s); /* version (2 bytes) */ - stream_seek_UINT32(s); /* size (4 bytes) */ - stream_seek_UINT32(s); /* sessionId (4 bytes) */ + Stream_Seek_UINT16(s); /* version (2 bytes) */ + Stream_Seek_UINT32(s); /* size (4 bytes) */ + Stream_Seek_UINT32(s); /* sessionId (4 bytes) */ stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ - stream_seek(s, 558); /* pad */ + Stream_Seek(s, 558); /* pad */ - if (stream_get_left(s) < cbDomain+cbUserName) + if (Stream_GetRemainingLength(s) < cbDomain+cbUserName) return FALSE; - stream_seek(s, cbDomain); /* domain */ - stream_seek(s, cbUserName); /* userName */ + Stream_Seek(s, cbDomain); /* domain */ + Stream_Seek(s, cbUserName); /* userName */ return TRUE; } BOOL rdp_recv_logon_plain_notify(rdpRdp* rdp, wStream* s) { - if (stream_get_left(s) < 576) + if (Stream_GetRemainingLength(s) < 576) return FALSE; - stream_seek(s, 576); /* pad */ + Stream_Seek(s, 576); /* pad */ return TRUE; } @@ -539,7 +539,7 @@ BOOL rdp_recv_logon_error_info(rdpRdp* rdp, wStream* s) UINT32 errorNotificationData; UINT32 errorNotificationType; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */ @@ -556,7 +556,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) UINT32 fieldsPresent; UINT16 Length; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, Length); /* The total size in bytes of this structure */ @@ -566,7 +566,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) if (fieldsPresent & LOGON_EX_AUTORECONNECTCOOKIE) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ @@ -577,7 +577,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) if (fieldsPresent & LOGON_EX_LOGONERRORS) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ @@ -586,10 +586,10 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) return FALSE; } - if (stream_get_left(s) < 570) + if (Stream_GetRemainingLength(s) < 570) return FALSE; - stream_seek(s, 570); /* pad */ + Stream_Seek(s, 570); /* pad */ return TRUE; } @@ -598,7 +598,7 @@ BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s) { UINT32 infoType; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, infoType); /* infoType (4 bytes) */ diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 06e31f84d..143e6535e 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -210,10 +210,10 @@ static BOOL input_recv_sync_event(rdpInput* input, wStream* s) { UINT32 toggleFlags; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ stream_read_UINT32(s, toggleFlags); /* toggleFlags (4 bytes) */ IFCALL(input->SynchronizeEvent, input, toggleFlags); @@ -225,12 +225,12 @@ static BOOL input_recv_keyboard_event(rdpInput* input, wStream* s) { UINT16 keyboardFlags, keyCode; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ stream_read_UINT16(s, keyCode); /* keyCode (2 bytes) */ - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ IFCALL(input->KeyboardEvent, input, keyboardFlags, keyCode); @@ -241,12 +241,12 @@ static BOOL input_recv_unicode_keyboard_event(rdpInput* input, wStream* s) { UINT16 keyboardFlags, unicodeCode; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* * According to the specification, the slow path Unicode Keyboard Event @@ -270,7 +270,7 @@ static BOOL input_recv_mouse_event(rdpInput* input, wStream* s) { UINT16 pointerFlags, xPos, yPos; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ @@ -286,7 +286,7 @@ static BOOL input_recv_extended_mouse_event(rdpInput* input, wStream* s) { UINT16 pointerFlags, xPos, yPos; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ @@ -302,10 +302,10 @@ static BOOL input_recv_event(rdpInput* input, wStream* s) { UINT16 messageType; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_seek(s, 4); /* eventTime (4 bytes), ignored by the server */ + Stream_Seek(s, 4); /* eventTime (4 bytes), ignored by the server */ stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ switch (messageType) @@ -338,7 +338,7 @@ static BOOL input_recv_event(rdpInput* input, wStream* s) default: fprintf(stderr, "Unknown messageType %u\n", messageType); /* Each input event uses 6 bytes. */ - stream_seek(s, 6); + Stream_Seek(s, 6); break; } @@ -349,14 +349,14 @@ BOOL input_recv(rdpInput* input, wStream* s) { UINT16 i, numberEvents; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, numberEvents); /* numberEvents (2 bytes) */ - stream_seek(s, 2); /* pad2Octets (2 bytes) */ + Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* Each input event uses 6 exactly bytes. */ - if (stream_get_left(s) < 6 * numberEvents) + if (Stream_GetRemainingLength(s) < 6 * numberEvents) return FALSE; for (i = 0; i < numberEvents; i++) diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index be43a21ca..71711fb60 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -126,7 +126,7 @@ void license_print_scope_list(SCOPE_LIST* scopeList) BOOL license_read_preamble(wStream* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsgSize) { /* preamble (4 bytes) */ - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_BYTE(s, *bMsgType); /* bMsgType (1 byte) */ @@ -164,7 +164,7 @@ wStream* license_send_stream_init(rdpLicense* license) wStream* s; s = transport_send_stream_init(license->rdp->transport, 4096); - stream_seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH); + Stream_Seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH); return s; } @@ -185,8 +185,8 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type) DEBUG_LICENSE("Sending %s Packet", LICENSE_MESSAGE_STRINGS[type & 0x1F]); - length = stream_get_length(s); - stream_set_pos(s, 0); + length = Stream_GetPosition(s); + Stream_SetPosition(s, 0); sec_flags = SEC_LICENSE_PKT; wMsgSize = length - LICENSE_PACKET_HEADER_MAX_LENGTH + 4; @@ -206,7 +206,7 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type) winpr_HexDump(s->pointer - 4, wMsgSize); #endif - stream_set_pos(s, length); + Stream_SetPosition(s, length); if (transport_write(license->rdp->transport, s) < 0) return FALSE; @@ -252,7 +252,7 @@ BOOL license_recv(rdpLicense* license, wStream* s) if (!(securityFlags & SEC_LICENSE_PKT)) { if (!(securityFlags & SEC_ENCRYPT)) - stream_rewind(s, RDP_SECURITY_HEADER_LENGTH); + Stream_Rewind(s, RDP_SECURITY_HEADER_LENGTH); if (rdp_recv_out_of_sequence_pdu(license->rdp, s) != TRUE) { @@ -463,14 +463,14 @@ void license_decrypt_platform_challenge(rdpLicense* license) BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */ stream_read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */ - if (stream_get_left(s) < productInfo->cbCompanyName + 4) + if (Stream_GetRemainingLength(s) < productInfo->cbCompanyName + 4) return FALSE; productInfo->pbCompanyName = (BYTE*) malloc(productInfo->cbCompanyName); @@ -478,7 +478,7 @@ BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo) stream_read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */ - if (stream_get_left(s) < productInfo->cbProductId) + if (Stream_GetRemainingLength(s) < productInfo->cbProductId) { free(productInfo->pbCompanyName); productInfo->pbCompanyName = NULL; @@ -540,13 +540,13 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) { UINT16 wBlobType; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, wBlobType); /* wBlobType (2 bytes) */ stream_read_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ - if (stream_get_left(s) < blob->length) + if (Stream_GetRemainingLength(s) < blob->length) return FALSE; /* @@ -649,7 +649,7 @@ BOOL license_read_scope_list(wStream* s, SCOPE_LIST* scopeList) UINT32 i; UINT32 scopeCount; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */ @@ -722,7 +722,7 @@ void license_free_scope_list(SCOPE_LIST* scopeList) BOOL license_read_license_request_packet(rdpLicense* license, wStream* s) { /* ServerRandom (32 bytes) */ - if (stream_get_left(s) < 32) + if (Stream_GetRemainingLength(s) < 32) return FALSE; stream_read(s, license->ServerRandom, 32); @@ -781,7 +781,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s) DEBUG_LICENSE("Receiving Platform Challenge Packet"); - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */ @@ -791,7 +791,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s) license_read_binary_blob(s, license->EncryptedPlatformChallenge); license->EncryptedPlatformChallenge->type = BB_ENCRYPTED_DATA_BLOB; - if (stream_get_left(s) < 16) + if (Stream_GetRemainingLength(s) < 16) return FALSE; stream_read(s, MacData, 16); /* MACData (16 bytes) */ @@ -856,7 +856,7 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s) UINT32 dwErrorCode; UINT32 dwStateTransition; - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, dwErrorCode); /* dwErrorCode (4 bytes) */ diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 560df65e1..486a35fd7 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -284,7 +284,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) int length; wStream* tmps; - tmps = stream_new(stream_get_size(s)); + tmps = stream_new(Stream_Capacity(s)); ber_write_integer(tmps, domainParameters->maxChannelIds); ber_write_integer(tmps, domainParameters->maxUserIds); ber_write_integer(tmps, domainParameters->maxTokenIds); @@ -294,7 +294,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) ber_write_integer(tmps, domainParameters->maxMCSPDUsize); ber_write_integer(tmps, domainParameters->protocolVersion); - length = stream_get_length(tmps); + length = Stream_GetPosition(tmps); ber_write_sequence_tag(s, length); stream_write(s, stream_get_head(tmps), length); stream_free(tmps); @@ -341,14 +341,14 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s) return FALSE; /* callingDomainSelector (OCTET_STRING) */ - if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length) + if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length) return FALSE; - stream_seek(s, length); + Stream_Seek(s, length); /* calledDomainSelector (OCTET_STRING) */ - if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length) + if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length) return FALSE; - stream_seek(s, length); + Stream_Seek(s, length); /* upwardFlag (BOOLEAN) */ if (!ber_read_BOOL(s, &upwardFlag)) @@ -366,7 +366,7 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s) if(!mcs_read_domain_parameters(s, &mcs->maximumParameters)) return FALSE; - if (!ber_read_octet_string_tag(s, &length) || stream_get_left(s) < length) + if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length) return FALSE; if (!gcc_read_conference_create_request(s, mcs->transport->settings)) @@ -388,7 +388,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) int length; wStream* tmps; - tmps = stream_new(stream_get_size(s)); + tmps = stream_new(Stream_Capacity(s)); /* callingDomainSelector (OCTET_STRING) */ ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector)); @@ -409,9 +409,9 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) mcs_write_domain_parameters(tmps, &mcs->maximumParameters); /* userData (OCTET_STRING) */ - ber_write_octet_string(tmps, user_data->buffer, stream_get_length(user_data)); + ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data)); - length = stream_get_length(tmps); + length = Stream_GetPosition(tmps); /* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */ ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length); stream_write(s, stream_get_head(tmps), length); @@ -431,15 +431,15 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) int length; wStream* tmps; - tmps = stream_new(stream_get_size(s)); + tmps = stream_new(Stream_Capacity(s)); ber_write_enumerated(tmps, 0, MCS_Result_enum_length); ber_write_integer(tmps, 0); /* calledConnectId */ mcs->domainParameters = mcs->targetParameters; mcs_write_domain_parameters(tmps, &(mcs->domainParameters)); /* userData (OCTET_STRING) */ - ber_write_octet_string(tmps, user_data->buffer, stream_get_length(user_data)); + ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data)); - length = stream_get_length(tmps); + length = Stream_GetPosition(tmps); ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length); stream_write(s, stream_get_head(tmps), length); stream_free(tmps); @@ -465,11 +465,11 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) gcc_CCrq = stream_new(512); gcc_write_conference_create_request(gcc_CCrq, client_data); - length = stream_get_length(gcc_CCrq) + 7; + length = Stream_GetPosition(gcc_CCrq) + 7; s = transport_send_stream_init(mcs->transport, 1024); stream_get_mark(s, bm); - stream_seek(s, 7); + Stream_Seek(s, 7); mcs_write_connect_initial(s, mcs, gcc_CCrq); stream_get_mark(s, em); @@ -544,11 +544,11 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) gcc_CCrsp = stream_new(512); gcc_write_conference_create_response(gcc_CCrsp, server_data); - length = stream_get_length(gcc_CCrsp) + 7; + length = Stream_GetPosition(gcc_CCrsp) + 7; s = transport_send_stream_init(mcs->transport, 1024); stream_get_mark(s, bm); - stream_seek(s, 7); + Stream_Seek(s, 7); mcs_write_connect_response(s, mcs, gcc_CCrsp); stream_get_mark(s, em); diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 0227620ae..d04e8bece 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -567,16 +567,16 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) if (!tpdu_read_connection_request(s, &li)) return FALSE; - if (li != stream_get_left(s) + 6) + if (li != Stream_GetRemainingLength(s) + 6) { fprintf(stderr, "Incorrect TPDU length indicator.\n"); return FALSE; } - if (stream_get_left(s) > 8) + if (Stream_GetRemainingLength(s) > 8) { /* Optional routingToken or cookie, ending with CR+LF */ - while (stream_get_left(s) > 0) + while (Stream_GetRemainingLength(s) > 0) { stream_read_BYTE(s, c); @@ -588,12 +588,12 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) if (c != '\x0A') continue; - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); break; } } - if (stream_get_left(s) >= 8) + if (Stream_GetRemainingLength(s) >= 8) { /* rdpNegData (optional) */ @@ -647,7 +647,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego) s = transport_send_stream_init(nego->transport, 256); length = TPDU_CONNECTION_REQUEST_LENGTH; stream_get_mark(s, bm); - stream_seek(s, length); + Stream_Seek(s, length); if (nego->RoutingToken) { @@ -728,7 +728,7 @@ void nego_process_negotiation_response(rdpNego* nego, wStream* s) DEBUG_NEGO("RDP_NEG_RSP"); - if (stream_get_left(s) < 7) + if (Stream_GetRemainingLength(s) < 7) { DEBUG_NEGO("RDP_INVALID_NEG_RSP"); nego->state = NEGO_STATE_FAIL; @@ -811,7 +811,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego) s = transport_send_stream_init(nego->transport, 256); length = TPDU_CONNECTION_CONFIRM_LENGTH; stream_get_mark(s, bm); - stream_seek(s, length); + Stream_Seek(s, length); if (nego->selected_protocol > PROTOCOL_RDP) { diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 7d87ed9c0..5bbdcf0f0 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -818,7 +818,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) credssp->identity.DomainLength = (UINT32) length; credssp->identity.Domain = (UINT16*) malloc(length); CopyMemory(credssp->identity.Domain, s->pointer, credssp->identity.DomainLength); - stream_seek(s, credssp->identity.DomainLength); + Stream_Seek(s, credssp->identity.DomainLength); credssp->identity.DomainLength /= 2; /* [1] userName (OCTET STRING) */ @@ -827,7 +827,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) credssp->identity.UserLength = (UINT32) length; credssp->identity.User = (UINT16*) malloc(length); CopyMemory(credssp->identity.User, s->pointer, credssp->identity.UserLength); - stream_seek(s, credssp->identity.UserLength); + Stream_Seek(s, credssp->identity.UserLength); credssp->identity.UserLength /= 2; /* [2] password (OCTET STRING) */ @@ -836,7 +836,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) credssp->identity.PasswordLength = (UINT32) length; credssp->identity.Password = (UINT16*) malloc(length); CopyMemory(credssp->identity.Password, s->pointer, credssp->identity.PasswordLength); - stream_seek(s, credssp->identity.PasswordLength); + Stream_Seek(s, credssp->identity.PasswordLength); credssp->identity.PasswordLength /= 2; credssp->identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; @@ -1148,7 +1148,7 @@ int credssp_recv(rdpCredssp* credssp) s = stream_new(4096); status = transport_read(credssp->transport, s); - s->capacity = status; + Stream_Length(s) = status; if (status < 0) { @@ -1170,7 +1170,7 @@ int credssp_recv(rdpCredssp* credssp) !ber_read_sequence_tag(s, &length) || /* NegoDataItem */ !ber_read_contextual_tag(s, 0, &length, TRUE) || /* [0] negoToken */ !ber_read_octet_string_tag(s, &length) || /* OCTET STRING */ - stream_get_left(s) < length) + Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->negoToken, length); stream_read(s, credssp->negoToken.pvBuffer, length); @@ -1181,7 +1181,7 @@ int credssp_recv(rdpCredssp* credssp) if (ber_read_contextual_tag(s, 2, &length, TRUE) != FALSE) { if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */ - stream_get_left(s) < length) + Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->authInfo, length); stream_read(s, credssp->authInfo.pvBuffer, length); @@ -1192,7 +1192,7 @@ int credssp_recv(rdpCredssp* credssp) if (ber_read_contextual_tag(s, 3, &length, TRUE) != FALSE) { if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */ - stream_get_left(s) < length) + Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->pubKeyAuth, length); stream_read(s, credssp->pubKeyAuth.pvBuffer, length); diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 32e4b1bed..277287032 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -152,14 +152,14 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) if (delta) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, lsi8); *coord += lsi8; } else { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, lsi16); *coord = lsi16; @@ -171,7 +171,7 @@ static INLINE BOOL update_read_color(wStream* s, UINT32* color) { BYTE byte; - if (stream_get_left(s) < 3) + if (Stream_GetRemainingLength(s) < 3) return FALSE; stream_read_BYTE(s, byte); *color = byte; @@ -192,7 +192,7 @@ static INLINE void update_read_colorref(wStream* s, UINT32* color) *color |= (byte << 8); stream_read_BYTE(s, byte); *color |= (byte << 16); - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); } static INLINE void update_read_color_quad(wStream* s, UINT32* color) @@ -205,20 +205,20 @@ static INLINE void update_read_color_quad(wStream* s, UINT32* color) *color |= (byte << 8); stream_read_BYTE(s, byte); *color |= byte; - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); } static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) { BYTE byte; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); if (byte & 0x80) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; *value = (byte & 0x7F) << 8; @@ -237,7 +237,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value) BYTE byte; BOOL negative; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -248,7 +248,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value) if (byte & 0x80) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); *value = (*value << 8) | byte; @@ -264,12 +264,12 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value) BYTE byte; BYTE count; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); count = (byte & 0xC0) >> 6; - if (stream_get_left(s) < count) + if (Stream_GetRemainingLength(s) < count) return FALSE; switch (count) @@ -312,7 +312,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value) { BYTE byte; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -323,7 +323,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value) if (byte & 0x80) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); *value = (*value << 8) | byte; @@ -350,35 +350,35 @@ static INLINE void update_seek_glyph_delta(wStream* s) stream_read_BYTE(s, byte); if (byte & 0x80) - stream_seek_BYTE(s); + Stream_Seek_BYTE(s); } static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags) { if (fieldFlags & ORDER_FIELD_01) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, brush->x); } if (fieldFlags & ORDER_FIELD_02) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, brush->y); } if (fieldFlags & ORDER_FIELD_03) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, brush->style); } if (fieldFlags & ORDER_FIELD_04) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, brush->hatch); } @@ -395,7 +395,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag if (fieldFlags & ORDER_FIELD_05) { - if (stream_get_left(s) < 7) + if (Stream_GetRemainingLength(s) < 7) return FALSE; brush->data = (BYTE*) brush->p8x8; stream_read_BYTE(s, brush->data[7]); @@ -422,10 +422,10 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i zeroBitsSize = ((number + 1) / 2); - if (stream_get_left(s) < zeroBitsSize) + if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; stream_get_mark(s, zeroBits); - stream_seek(s, zeroBitsSize); + Stream_Seek(s, zeroBitsSize); memset(rectangles, 0, sizeof(DELTA_RECT) * (number + 1)); @@ -473,10 +473,10 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int zeroBitsSize = ((number + 3) / 4); - if (stream_get_left(s) < zeroBitsSize) + if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; stream_get_mark(s, zeroBits); - stream_seek(s, zeroBitsSize); + Stream_Seek(s, zeroBitsSize); memset(points, 0, sizeof(DELTA_POINT) * number); @@ -501,7 +501,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int do {\ if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ - if (stream_get_left(s) < 1) {\ + if (Stream_GetRemainingLength(s) < 1) {\ fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ @@ -513,7 +513,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int do {\ if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ - if (stream_get_left(s) < 2) { \ + if (Stream_GetRemainingLength(s) < 2) { \ fprintf(stderr, "%s: error reading %s or %s\n", __FUNCTION__, #TARGET1, #TARGET2); \ return FALSE; \ } \ @@ -526,7 +526,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int do {\ if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ - if (stream_get_left(s) < 2) { \ + if (Stream_GetRemainingLength(s) < 2) { \ fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ @@ -537,7 +537,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int do {\ if (orderInfo->fieldFlags & (1 << (NO-1))) \ { \ - if (stream_get_left(s) < 4) { \ + if (Stream_GetRemainingLength(s) < 4) { \ fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ @@ -563,7 +563,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int #define FIELD_SKIP_BUFFER16(s, TARGET_LEN) \ do { \ - if (stream_get_left(s) < 2) {\ + if (Stream_GetRemainingLength(s) < 2) {\ fprintf(stderr, "%s: error reading length %s\n", __FUNCTION__, #TARGET_LEN); \ return FALSE; \ }\ @@ -621,21 +621,21 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC if (orderInfo->fieldFlags & ORDER_FIELD_05) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFFFF00) | byte; } if (orderInfo->fieldFlags & ORDER_FIELD_06) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFF00FF) | (byte << 8); } if (orderInfo->fieldFlags & ORDER_FIELD_07) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFF00FFFF) | (byte << 16); @@ -664,7 +664,7 @@ BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DST if (orderInfo->fieldFlags & ORDER_FIELD_07) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, multi_dstblt->cbData); return update_read_delta_rects(s, multi_dstblt->rectangles, multi_dstblt->numRectangles); @@ -689,7 +689,7 @@ BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PAT if (orderInfo->fieldFlags & ORDER_FIELD_14) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, multi_patblt->cbData); if (!update_read_delta_rects(s, multi_patblt->rectangles, multi_patblt->numRectangles)) @@ -711,7 +711,7 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR if (orderInfo->fieldFlags & ORDER_FIELD_09) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, multi_scrblt->cbData); return update_read_delta_rects(s, multi_scrblt->rectangles, multi_scrblt->numRectangles); @@ -729,7 +729,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT if (orderInfo->fieldFlags & ORDER_FIELD_05) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFFFF00) | byte; @@ -737,7 +737,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT if (orderInfo->fieldFlags & ORDER_FIELD_06) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFF00FF) | (byte << 8); @@ -745,7 +745,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT if (orderInfo->fieldFlags & ORDER_FIELD_07) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFF00FFFF) | (byte << 16); @@ -755,7 +755,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT if (orderInfo->fieldFlags & ORDER_FIELD_09) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, multi_opaque_rect->cbData); return update_read_delta_rects(s, multi_opaque_rect->rectangles, multi_opaque_rect->numRectangles); @@ -808,7 +808,7 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE if (orderInfo->fieldFlags & ORDER_FIELD_07) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, polyline->cbData); @@ -897,14 +897,14 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE if (orderInfo->fieldFlags & ORDER_FIELD_22) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, glyph_index->cbData); - if (stream_get_left(s) < glyph_index->cbData) + if (Stream_GetRemainingLength(s) < glyph_index->cbData) return FALSE; memcpy(glyph_index->data, s->pointer, glyph_index->cbData); - stream_seek(s, glyph_index->cbData); + Stream_Seek(s, glyph_index->cbData); } return TRUE; } @@ -928,14 +928,14 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ if (orderInfo->fieldFlags & ORDER_FIELD_15) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, fast_index->cbData); - if (stream_get_left(s) < fast_index->cbData) + if (Stream_GetRemainingLength(s) < fast_index->cbData) return FALSE; memcpy(fast_index->data, s->pointer, fast_index->cbData); - stream_seek(s, fast_index->cbData); + Stream_Seek(s, fast_index->cbData); } return TRUE; } @@ -962,12 +962,12 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ if (orderInfo->fieldFlags & ORDER_FIELD_15) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, fast_glyph->cbData); - if (stream_get_left(s) < fast_glyph->cbData) + if (Stream_GetRemainingLength(s) < fast_glyph->cbData) return FALSE; memcpy(fast_glyph->data, s->pointer, fast_glyph->cbData); @@ -991,7 +991,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; - if (stream_get_left(s) < glyph->cb) + if (Stream_GetRemainingLength(s) < glyph->cb) return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); @@ -1014,7 +1014,7 @@ BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ if (orderInfo->fieldFlags & ORDER_FIELD_07) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, polygon_sc->cbData); @@ -1044,7 +1044,7 @@ BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ if (orderInfo->fieldFlags & ORDER_FIELD_13) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, polygon_cb->cbData); @@ -1091,10 +1091,10 @@ BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags) { - if (stream_get_left(s) < 9) + if (Stream_GetRemainingLength(s) < 9) return FALSE; stream_read_BYTE(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ - stream_seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ stream_read_BYTE(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ stream_read_BYTE(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */ stream_read_BYTE(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */ @@ -1106,25 +1106,25 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0) { BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap_order->bitmapComprHdr); - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ cache_bitmap_order->bitmapLength -= 8; } - if (stream_get_left(s) < cache_bitmap_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) return FALSE; stream_get_mark(s, cache_bitmap_order->bitmapDataStream); - stream_seek(s, cache_bitmap_order->bitmapLength); + Stream_Seek(s, cache_bitmap_order->bitmapLength); } else { - if (stream_get_left(s) < cache_bitmap_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) return FALSE; stream_get_mark(s, cache_bitmap_order->bitmapDataStream); - stream_seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */ + Stream_Seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */ } cache_bitmap_order->compressed = compressed; return TRUE; @@ -1142,7 +1142,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (cache_bitmap_v2_order->flags & CBR2_PERSISTENT_KEY_PRESENT) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, cache_bitmap_v2_order->key1); /* key1 (4 bytes) */ stream_read_UINT32(s, cache_bitmap_v2_order->key2); /* key2 (4 bytes) */ @@ -1172,7 +1172,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ { if (!(cache_bitmap_v2_order->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT16(s, cache_bitmap_v2_order->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ @@ -1182,17 +1182,17 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ cache_bitmap_v2_order->bitmapLength = cache_bitmap_v2_order->cbCompMainBodySize; } - if (stream_get_left(s) < cache_bitmap_v2_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) return FALSE; stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); - stream_seek(s, cache_bitmap_v2_order->bitmapLength); + Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); } else { - if (stream_get_left(s) < cache_bitmap_v2_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) return FALSE; stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); - stream_seek(s, cache_bitmap_v2_order->bitmapLength); + Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); } cache_bitmap_v2_order->compressed = compressed; return TRUE; @@ -1209,7 +1209,7 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ bitsPerPixelId = (flags & 0x00000078) >> 3; cache_bitmap_v3_order->bpp = CBR23_BPP[bitsPerPixelId]; - if (stream_get_left(s) < 21) + if (Stream_GetRemainingLength(s) < 21) return FALSE; stream_read_UINT16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */ stream_read_UINT32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */ @@ -1218,14 +1218,14 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ bitmapData = &cache_bitmap_v3_order->bitmapData; stream_read_BYTE(s, bitmapData->bpp); - stream_seek_BYTE(s); /* reserved1 (1 byte) */ - stream_seek_BYTE(s); /* reserved2 (1 byte) */ + Stream_Seek_BYTE(s); /* reserved1 (1 byte) */ + Stream_Seek_BYTE(s); /* reserved2 (1 byte) */ stream_read_BYTE(s, bitmapData->codecID); /* codecID (1 byte) */ stream_read_UINT16(s, bitmapData->width); /* width (2 bytes) */ stream_read_UINT16(s, bitmapData->height); /* height (2 bytes) */ stream_read_UINT32(s, bitmapData->length); /* length (4 bytes) */ - if (stream_get_left(s) < bitmapData->length) + if (Stream_GetRemainingLength(s) < bitmapData->length) return FALSE; if (bitmapData->data == NULL) bitmapData->data = (BYTE*) malloc(bitmapData->length); @@ -1241,7 +1241,7 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca int i; UINT32* colorTable; - if (stream_get_left(s) < 3) + if (Stream_GetRemainingLength(s) < 3) return FALSE; stream_read_BYTE(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */ @@ -1253,7 +1253,7 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca return FALSE; } - if (stream_get_left(s) < cache_color_table_order->numberColors * 4) + if (Stream_GetRemainingLength(s) < cache_color_table_order->numberColors * 4) return FALSE; colorTable = (UINT32*) &cache_color_table_order->colorTable; @@ -1272,7 +1272,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or INT16 lsi16; GLYPH_DATA* glyph; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_BYTE(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */ @@ -1282,7 +1282,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or { glyph = &cache_glyph_order->glyphData[i]; - if (stream_get_left(s) < 10) + if (Stream_GetRemainingLength(s) < 10) return FALSE; stream_read_UINT16(s, glyph->cacheIndex); @@ -1296,7 +1296,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; - if (stream_get_left(s) < glyph->cb) + if (Stream_GetRemainingLength(s) < glyph->cb) return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); @@ -1324,7 +1324,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl { glyph = &cache_glyph_v2_order->glyphData[i]; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, glyph->cacheIndex); @@ -1340,7 +1340,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; - if (stream_get_left(s) < glyph->cb) + if (Stream_GetRemainingLength(s) < glyph->cb) return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); @@ -1366,7 +1366,7 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp) palette = s->pointer + 16; bytesPerPixel = ((bpp + 1) / 8); - if (stream_get_left(s) < 16) // 64 / 4 + if (Stream_GetRemainingLength(s) < 16) // 64 / 4 return FALSE; for (y = 7; y >= 0; y--) @@ -1394,7 +1394,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or BYTE iBitmapFormat; BOOL compressed = FALSE; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_BYTE(s, cache_brush_order->index); /* cacheEntry (1 byte) */ @@ -1420,7 +1420,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or } /* rows are encoded in reverse order */ - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; for (i = 7; i >= 0; i--) @@ -1448,7 +1448,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or /* uncompressed brush */ int scanline = (cache_brush_order->bpp / 8) * 8; - if (stream_get_left(s) < scanline * 8) + if (Stream_GetRemainingLength(s) < scanline * 8) return FALSE; for (i = 7; i >= 0; i--) @@ -1470,7 +1470,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM BOOL deleteListPresent; OFFSCREEN_DELETE_LIST* deleteList; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, flags); /* flags (2 bytes) */ create_offscreen_bitmap->id = flags & 0x7FFF; @@ -1483,7 +1483,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM if (deleteListPresent) { int i; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, deleteList->cIndices); @@ -1493,7 +1493,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM deleteList->indices = realloc(deleteList->indices, deleteList->sIndices * 2); } - if (stream_get_left(s) < 2 * deleteList->cIndices) + if (Stream_GetRemainingLength(s) < 2 * deleteList->cIndices) return FALSE; for (i = 0; i < (int) deleteList->cIndices; i++) @@ -1510,7 +1510,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ return TRUE; @@ -1520,7 +1520,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM { NINE_GRID_BITMAP_INFO* nineGridInfo; - if (stream_get_left(s) < 19) + if (Stream_GetRemainingLength(s) < 19) return FALSE; stream_read_BYTE(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ stream_read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ @@ -1537,7 +1537,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, frame_marker->action); /* action (4 bytes) */ return TRUE; @@ -1545,7 +1545,7 @@ BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first) { - if (stream_get_left(s) < 10) // 8 + 2 at least + if (Stream_GetRemainingLength(s) < 10) // 8 + 2 at least return FALSE; stream_read_BYTE(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */ stream_read_BYTE(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */ @@ -1554,11 +1554,11 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER stream_read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */ if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */ } else { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */ } @@ -1569,7 +1569,7 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next) { - if (stream_get_left(s) < 5) + if (Stream_GetRemainingLength(s) < 5) return FALSE; stream_read_BYTE(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */ stream_read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */ @@ -1579,9 +1579,9 @@ BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first) { - if (stream_get_left(s) < 11) + if (Stream_GetRemainingLength(s) < 11) return FALSE; - stream_seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ stream_read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */ stream_read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ stream_read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ @@ -1591,18 +1591,18 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next) { - if (stream_get_left(s) < 3) + if (Stream_GetRemainingLength(s) < 3) return FALSE; - stream_seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize); /* cbSize(2 bytes) + emfRecords */ return TRUE; } BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end) { - if (stream_get_left(s) < 11) + if (Stream_GetRemainingLength(s) < 11) return FALSE; - stream_seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ stream_read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */ stream_read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ stream_read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ @@ -1612,7 +1612,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first) { - if (stream_get_left(s) < 11) + if (Stream_GetRemainingLength(s) < 11) return FALSE; stream_read_BYTE(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */ stream_read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */ @@ -1625,7 +1625,7 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next) { - if (stream_get_left(s) < 7) + if (Stream_GetRemainingLength(s) < 7) return FALSE; stream_read_BYTE(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */ stream_read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */ @@ -1637,7 +1637,7 @@ BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NE BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end) { - if (stream_get_left(s) < 11) + if (Stream_GetRemainingLength(s) < 11) return FALSE; stream_read_BYTE(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */ stream_read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */ @@ -1664,7 +1664,7 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi fieldBytes = 0; } - if (stream_get_left(s) < fieldBytes) + if (Stream_GetRemainingLength(s) < fieldBytes) return FALSE; *fieldFlags = 0; @@ -1680,7 +1680,7 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds) { BYTE flags; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, flags); /* field flags */ @@ -1923,7 +1923,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) rdpContext* context = update->context; rdpSecondaryUpdate* secondary = update->secondary; - if (stream_get_left(s) < 5) + if (Stream_GetRemainingLength(s) < 5) return FALSE; stream_read_UINT16(s, orderLength); /* orderLength (2 bytes) */ stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ @@ -2111,7 +2111,7 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s) { BYTE controlFlags; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, controlFlags); /* controlFlags (1 byte) */ diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index daeefdf1e..ca017e9ac 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -135,7 +135,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) return FALSE; case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE: - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, client->ack_frame_id); break; @@ -232,7 +232,7 @@ static int peer_recv_fastpath_pdu(freerdp_peer* client, wStream* s) fastpath_read_header_rdp(fastpath, s, &length); - if ((length == 0) || (length > stream_get_left(s))) + if ((length == 0) || (length > Stream_GetRemainingLength(s))) { fprintf(stderr, "incorrect FastPath PDU header length %d\n", length); return -1; @@ -326,7 +326,7 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra) * During reactivation sequence the client might sent some input or channel data * before receiving the Deactivate All PDU. We need to process them as usual. */ - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); return peer_recv_pdu(client, s); } break; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index e7f3f5e82..5f328b2fd 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -80,10 +80,10 @@ static const char* const DATA_PDU_TYPE_STRINGS[] = BOOL rdp_read_security_header(wStream* s, UINT16* flags) { /* Basic Security Header */ - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, *flags); /* flags */ - stream_seek(s, 2); /* flagsHi (unused) */ + Stream_Seek(s, 2); /* flagsHi (unused) */ return TRUE; } @@ -103,13 +103,13 @@ void rdp_write_security_header(wStream* s, UINT16 flags) BOOL rdp_read_share_control_header(wStream* s, UINT16* length, UINT16* type, UINT16* channel_id) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; /* Share Control Header */ stream_read_UINT16(s, *length); /* totalLength */ - if (*length - 2 > stream_get_left(s)) + if (*length - 2 > Stream_GetRemainingLength(s)) return FALSE; stream_read_UINT16(s, *type); /* pduType */ @@ -136,13 +136,13 @@ void rdp_write_share_control_header(wStream* s, UINT16 length, UINT16 type, UINT BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* share_id, BYTE *compressed_type, UINT16 *compressed_len) { - if (stream_get_left(s) < 12) + if (Stream_GetRemainingLength(s) < 12) return FALSE; /* Share Data Header */ stream_read_UINT32(s, *share_id); /* shareId (4 bytes) */ - stream_seek_BYTE(s); /* pad1 (1 byte) */ - stream_seek_BYTE(s); /* streamId (1 byte) */ + Stream_Seek_BYTE(s); /* pad1 (1 byte) */ + Stream_Seek_BYTE(s); /* streamId (1 byte) */ stream_read_UINT16(s, *length); /* uncompressedLength (2 bytes) */ stream_read_BYTE(s, *type); /* pduType2, Data PDU Type (1 byte) */ stream_read_BYTE(s, *compressed_type); /* compressedType (1 byte) */ @@ -170,10 +170,10 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s) { if (rdp->do_crypt) { - stream_seek(s, 12); + Stream_Seek(s, 12); if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS) - stream_seek(s, 4); + Stream_Seek(s, 4); rdp->sec_flags |= SEC_ENCRYPT; @@ -182,7 +182,7 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s) } else if (rdp->sec_flags != 0) { - stream_seek(s, 4); + Stream_Seek(s, 4); } return 0; @@ -199,7 +199,7 @@ wStream* rdp_send_stream_init(rdpRdp* rdp) wStream* s; s = transport_send_stream_init(rdp->transport, 2048); - stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); rdp_security_stream_init(rdp, s); return s; @@ -209,9 +209,9 @@ wStream* rdp_pdu_init(rdpRdp* rdp) { wStream* s; s = transport_send_stream_init(rdp->transport, 2048); - stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); rdp_security_stream_init(rdp, s); - stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); + Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); return s; } @@ -219,10 +219,10 @@ wStream* rdp_data_pdu_init(rdpRdp* rdp) { wStream* s; s = transport_send_stream_init(rdp->transport, 2048); - stream_seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); rdp_security_stream_init(rdp, s); - stream_seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); - stream_seek(s, RDP_SHARE_DATA_HEADER_LENGTH); + Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); + Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH); return s; } @@ -247,7 +247,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id return FALSE; } - if (*length - 8 > stream_get_left(s)) + if (*length - 8 > Stream_GetRemainingLength(s)) return FALSE; if (MCSPDU == DomainMCSPDU_DisconnectProviderUltimatum) @@ -262,15 +262,15 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id return TRUE; } - if(stream_get_left(s) < 5) + if(Stream_GetRemainingLength(s) < 5) return FALSE; per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */ per_read_integer16(s, channel_id, 0); /* channelId */ - stream_seek(s, 1); /* dataPriority + Segmentation (0x70) */ + Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */ if(!per_read_length(s, length)) /* userData (OCTET_STRING) */ return FALSE; - if (*length > stream_get_left(s)) + if (*length > Stream_GetRemainingLength(s)) return FALSE; return TRUE; @@ -349,7 +349,7 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) stream_write_BYTE(s, pad); security_hmac_signature(data, length, s->pointer, rdp); - stream_seek(s, 8); + Stream_Seek(s, 8); security_fips_encrypt(data, length + pad, rdp); } else @@ -360,7 +360,7 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) security_salted_mac_signature(rdp, data, length, TRUE, s->pointer); else security_mac_signature(rdp, data, length, s->pointer); - stream_seek(s, 8); + Stream_Seek(s, 8); security_encrypt(s->pointer, length, rdp); } } @@ -407,19 +407,19 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) UINT32 sec_bytes; BYTE* sec_hold; - length = stream_get_length(s); - stream_set_pos(s, 0); + length = Stream_GetPosition(s); + Stream_SetPosition(s, 0); rdp_write_header(rdp, s, length, channel_id); sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = s->pointer; - stream_seek(s, sec_bytes); + Stream_Seek(s, sec_bytes); s->pointer = sec_hold; length += rdp_security_stream_out(rdp, s, length); - stream_set_pos(s, length); + Stream_SetPosition(s, length); if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -433,21 +433,21 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) UINT32 sec_bytes; BYTE* sec_hold; - length = stream_get_length(s); - stream_set_pos(s, 0); + length = Stream_GetPosition(s); + Stream_SetPosition(s, 0); rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = s->pointer; - stream_seek(s, sec_bytes); + Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, type, channel_id); s->pointer = sec_hold; length += rdp_security_stream_out(rdp, s, length); - stream_set_pos(s, length); + Stream_SetPosition(s, length); if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -460,14 +460,14 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) UINT32 sec_bytes; BYTE* sec_hold; - length = stream_get_length(s); - stream_set_pos(s, 0); + length = Stream_GetPosition(s); + Stream_SetPosition(s, 0); rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); sec_hold = s->pointer; - stream_seek(s, sec_bytes); + Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id); rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId); @@ -475,7 +475,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) s->pointer = sec_hold; length += rdp_security_stream_out(rdp, s, length); - stream_set_pos(s, length); + Stream_SetPosition(s, length); if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -484,7 +484,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, rdp->errorInfo); /* errorInfo (4 bytes) */ @@ -519,7 +519,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) if (compressed_type & PACKET_COMPRESSED) { - if (stream_get_left(s) < compressed_len - 18) + if (Stream_GetRemainingLength(s) < compressed_len - 18) { fprintf(stderr, "decompress_rdp: not enough bytes for compressed_len=%d\n", compressed_len); return -1; @@ -536,7 +536,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) fprintf(stderr, "decompress_rdp() failed\n"); return -1; } - stream_seek(s, compressed_len - 18); + Stream_Seek(s, compressed_len - 18); } #ifdef WITH_DEBUG_RDP @@ -689,7 +689,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) BYTE version, pad; BYTE* sig; - if (stream_get_left(s) < 12) + if (Stream_GetRemainingLength(s) < 12) return FALSE; stream_read_UINT16(s, len); /* 0x10 */ @@ -697,7 +697,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) stream_read_BYTE(s, pad); sig = s->pointer; - stream_seek(s, 8); /* signature */ + Stream_Seek(s, 8); /* signature */ length -= 12; @@ -718,7 +718,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) return TRUE; } - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read(s, wmac, sizeof(wmac)); @@ -802,7 +802,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) } else { - while (stream_get_left(s) > 3) + while (Stream_GetRemainingLength(s) > 3) { stream_get_mark(s, nextp); @@ -854,7 +854,7 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, wStream* s) if (!fastpath_read_header_rdp(fastpath, s, &length)) return -1; - if ((length == 0) || (length > stream_get_left(s))) + if ((length == 0) || (length > Stream_GetRemainingLength(s))) { fprintf(stderr, "incorrect FastPath PDU header length %d\n", length); return -1; diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 6ca3dac65..16896d771 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -63,12 +63,12 @@ void rdp_print_redirection_flags(UINT32 flags) BOOL rdp_string_read_length32(wStream* s, rdpString* string) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, string->length); - if(stream_get_left(s) < string->length) + if(Stream_GetRemainingLength(s) < string->length) return FALSE; string->unicode = (char*) malloc(string->length); @@ -94,7 +94,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) UINT16 length; rdpRedirection* redirection = rdp->redirection; - if (stream_get_left(s) < 12) + if (Stream_GetRemainingLength(s) < 12) return FALSE; stream_read_UINT16(s, flags); /* flags (2 bytes) */ stream_read_UINT16(s, length); /* length (2 bytes) */ @@ -116,10 +116,10 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (redirection->flags & LB_LOAD_BALANCE_INFO) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, redirection->LoadBalanceInfoLength); - if (stream_get_left(s) < redirection->LoadBalanceInfoLength) + if (Stream_GetRemainingLength(s) < redirection->LoadBalanceInfoLength) return FALSE; redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength); @@ -147,7 +147,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (redirection->flags & LB_PASSWORD) { /* Note: length (hopefully) includes double zero termination */ - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, redirection->PasswordCookieLength); redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength); @@ -186,7 +186,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) UINT32 count; UINT32 targetNetAddressesLength; - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, targetNetAddressesLength); diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 42d39f1ab..909e722ff 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -30,7 +30,7 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 int pos; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; - if (stream_get_left(s) < 20) + if (Stream_GetRemainingLength(s) < 20) return -1; stream_read_UINT16(s, cmd->destLeft); @@ -38,19 +38,19 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 stream_read_UINT16(s, cmd->destRight); stream_read_UINT16(s, cmd->destBottom); stream_read_BYTE(s, cmd->bpp); - stream_seek(s, 2); /* reserved1, reserved2 */ + Stream_Seek(s, 2); /* reserved1, reserved2 */ stream_read_BYTE(s, cmd->codecID); stream_read_UINT16(s, cmd->width); stream_read_UINT16(s, cmd->height); stream_read_UINT32(s, cmd->bitmapDataLength); - if (stream_get_left(s) < cmd->bitmapDataLength) + if (Stream_GetRemainingLength(s) < cmd->bitmapDataLength) return -1; - pos = stream_get_pos(s) + cmd->bitmapDataLength; - cmd->bitmapData = stream_get_tail(s); + pos = Stream_GetPosition(s) + cmd->bitmapDataLength; + cmd->bitmapData = Stream_Pointer(s); - stream_set_pos(s, pos); + Stream_SetPosition(s, pos); *length = 20 + cmd->bitmapDataLength; IFCALL(update->SurfaceBits, update->context, cmd); @@ -71,7 +71,7 @@ static int update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s, UINT3 { SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return -1; stream_read_UINT16(s, marker->frameAction); diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 30a291ffc..85718f129 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -79,7 +79,7 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) char* str = NULL; TIME_ZONE_INFO* clientTimeZone; - if (stream_get_left(s) < 172) + if (Stream_GetRemainingLength(s) < 172) return FALSE; clientTimeZone = settings->ClientTimeZone; @@ -87,8 +87,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) stream_read_UINT32(s, clientTimeZone->bias); /* Bias */ /* standardName (64 bytes) */ - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL); - stream_seek(s, 64); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL); + Stream_Seek(s, 64); strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName)); free(str); str = NULL; @@ -97,8 +97,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) stream_read_UINT32(s, clientTimeZone->standardBias); /* StandardBias */ /* daylightName (64 bytes) */ - ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) stream_get_tail(s), 64 / 2, &str, 0, NULL, NULL); - stream_seek(s, 64); + ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL); + Stream_Seek(s, 64); strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName)); free(str); diff --git a/libfreerdp/core/tpdu.c b/libfreerdp/core/tpdu.c index 228d6e14a..d9d6a2e87 100644 --- a/libfreerdp/core/tpdu.c +++ b/libfreerdp/core/tpdu.c @@ -68,7 +68,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li) { - if(stream_get_left(s) < 3) + if(Stream_GetRemainingLength(s) < 3) return FALSE; stream_read_BYTE(s, *li); /* LI */ @@ -77,7 +77,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li) if (*code == X224_TPDU_DATA) { /* EOT (1 byte) */ - stream_seek(s, 1); + Stream_Seek(s, 1); } else { @@ -165,7 +165,7 @@ BOOL tpdu_read_connection_confirm(wStream* s, BYTE *li) return FALSE; } - return (stream_get_left(s) >= *li); + return (Stream_GetRemainingLength(s) >= *li); } /** diff --git a/libfreerdp/core/tpkt.c b/libfreerdp/core/tpkt.c index f5f55eb79..4f0bdd524 100644 --- a/libfreerdp/core/tpkt.c +++ b/libfreerdp/core/tpkt.c @@ -90,7 +90,7 @@ UINT16 tpkt_read_header(wStream* s) if (version == 3) { - stream_seek(s, 2); + Stream_Seek(s, 2); stream_read_UINT16_be(s, length); } else diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index c1033e225..a2a2b7e8f 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -54,7 +54,7 @@ wStream* transport_recv_stream_init(rdpTransport* transport, int size) { wStream* s = transport->ReceiveStream; stream_check_size(s, size); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); return s; } @@ -62,7 +62,7 @@ wStream* transport_send_stream_init(rdpTransport* transport, int size) { wStream* s = transport->SendStream; stream_check_size(s, size); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); return s; } @@ -322,13 +322,13 @@ UINT32 nla_read_header(wStream* s) { length = s->pointer[2]; length += 3; - stream_seek(s, 3); + Stream_Seek(s, 3); } else if ((s->pointer[1] & ~(0x80)) == 2) { length = (s->pointer[2] << 8) | s->pointer[3]; length += 4; - stream_seek(s, 4); + Stream_Seek(s, 4); } else { @@ -339,7 +339,7 @@ UINT32 nla_read_header(wStream* s) { length = s->pointer[1]; length += 2; - stream_seek(s, 2); + Stream_Seek(s, 2); } return length; @@ -414,7 +414,7 @@ int transport_read(rdpTransport* transport, wStream* s) transport_status = 0; /* first check if we have header */ - stream_bytes = stream_get_length(s); + stream_bytes = Stream_GetPosition(s); if (stream_bytes < 4) { @@ -504,7 +504,7 @@ static int transport_read_nonblocking(rdpTransport* transport) if (status <= 0) return status; - stream_seek(transport->ReceiveBuffer, status); + Stream_Seek(transport->ReceiveBuffer, status); return status; } @@ -514,8 +514,8 @@ int transport_write(rdpTransport* transport, wStream* s) int status = -1; int length; - length = stream_get_length(s); - stream_set_pos(s, 0); + length = Stream_GetPosition(s); + Stream_SetPosition(s, 0); #ifdef WITH_DEBUG_TRANSPORT if (length > 0) @@ -528,11 +528,11 @@ int transport_write(rdpTransport* transport, wStream* s) while (length > 0) { if (transport->layer == TRANSPORT_LAYER_TLS) - status = tls_write(transport->TlsOut, stream_get_tail(s), length); + status = tls_write(transport->TlsOut, Stream_Pointer(s), length); else if (transport->layer == TRANSPORT_LAYER_TCP) - status = tcp_write(transport->TcpOut, stream_get_tail(s), length); + status = tcp_write(transport->TcpOut, Stream_Pointer(s), length); else if (transport->layer == TRANSPORT_LAYER_TSG) - status = tsg_write(transport->tsg, stream_get_tail(s), length); + status = tsg_write(transport->tsg, Stream_Pointer(s), length); if (status < 0) break; /* error occurred */ @@ -556,7 +556,7 @@ int transport_write(rdpTransport* transport, wStream* s) } length -= status; - stream_seek(s, status); + Stream_Seek(s, status); } if (status < 0) @@ -631,16 +631,16 @@ int transport_check_fds(rdpTransport** ptransport) if (status < 0) return status; - while ((pos = stream_get_pos(transport->ReceiveBuffer)) > 0) + while ((pos = Stream_GetPosition(transport->ReceiveBuffer)) > 0) { - stream_set_pos(transport->ReceiveBuffer, 0); + Stream_SetPosition(transport->ReceiveBuffer, 0); if (tpkt_verify_header(transport->ReceiveBuffer)) /* TPKT */ { /* Ensure the TPKT header is available. */ if (pos <= 4) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; } @@ -653,7 +653,7 @@ int transport_check_fds(rdpTransport** ptransport) /* Ensure the TSRequest header is available. */ if (pos <= 4) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; } @@ -662,7 +662,7 @@ int transport_check_fds(rdpTransport** ptransport) if (pos < length) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; } @@ -673,7 +673,7 @@ int transport_check_fds(rdpTransport** ptransport) /* Ensure the Fast Path header is available. */ if (pos <= 2) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; } @@ -682,7 +682,7 @@ int transport_check_fds(rdpTransport** ptransport) if (pos < length) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; } @@ -698,16 +698,16 @@ int transport_check_fds(rdpTransport** ptransport) if (pos < length) { - stream_set_pos(transport->ReceiveBuffer, pos); + Stream_SetPosition(transport->ReceiveBuffer, pos); return 0; /* Packet is not yet completely received. */ } received = transport->ReceiveBuffer; transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0); - stream_set_pos(received, length); - stream_seal(received); - stream_set_pos(received, 0); + Stream_SetPosition(received, length); + Stream_SealLength(received); + Stream_SetPosition(received, 0); /** * ReceiveCallback return values: diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 578c5ed4d..44eee1bcd 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -46,12 +46,12 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s) { UINT16 numberOrders; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_seek_UINT16(s); /* pad2OctetsA (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ stream_read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ - stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */ while (numberOrders > 0) { @@ -65,7 +65,7 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s) BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data) { - if (stream_get_left(s) < 18) + if (Stream_GetRemainingLength(s) < 18) return FALSE; stream_read_UINT16(s, bitmap_data->destLeft); @@ -91,15 +91,15 @@ BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data) bitmap_data->compressed = TRUE; stream_get_mark(s, bitmap_data->bitmapDataStream); - stream_seek(s, bitmap_data->bitmapLength); + Stream_Seek(s, bitmap_data->bitmapLength); } else { - if (stream_get_left(s) < bitmap_data->bitmapLength) + if (Stream_GetRemainingLength(s) < bitmap_data->bitmapLength) return FALSE; bitmap_data->compressed = FALSE; stream_get_mark(s, bitmap_data->bitmapDataStream); - stream_seek(s, bitmap_data->bitmapLength); + Stream_Seek(s, bitmap_data->bitmapLength); } return TRUE; } @@ -108,7 +108,7 @@ BOOL update_read_bitmap(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bitmap_upd { int i; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, bitmap_update->number); /* numberRectangles (2 bytes) */ @@ -142,16 +142,16 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_ int i; PALETTE_ENTRY* entry; - if (stream_get_left(s) < 6) + if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ stream_read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */ if (palette_update->number > 256) palette_update->number = 256; - if (stream_get_left(s) < palette_update->number * 3) + if (Stream_GetRemainingLength(s) < palette_update->number * 3) return FALSE; /* paletteEntries */ @@ -168,7 +168,7 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_ void update_read_synchronize(rdpUpdate* update, wStream* s) { - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ /** * The Synchronize Update is an artifact from the @@ -178,7 +178,7 @@ void update_read_synchronize(rdpUpdate* update, wStream* s) BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound) { - if (stream_get_left(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, play_sound->duration); /* duration (4 bytes) */ @@ -198,7 +198,7 @@ BOOL update_recv_play_sound(rdpUpdate* update, wStream* s) BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_position) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, pointer_position->xPos); /* xPos (2 bytes) */ @@ -208,7 +208,7 @@ BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_p BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_system) { - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, pointer_system->type); /* systemPointerType (4 bytes) */ @@ -217,7 +217,7 @@ BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_syste BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) { - if (stream_get_left(s) < 14) + if (Stream_GetRemainingLength(s) < 14) return FALSE; stream_read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */ @@ -241,7 +241,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) if (pointer_color->lengthXorMask > 0) { - if (stream_get_left(s) < pointer_color->lengthXorMask) + if (Stream_GetRemainingLength(s) < pointer_color->lengthXorMask) return FALSE; if (!pointer_color->xorMaskData) @@ -254,7 +254,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) if (pointer_color->lengthAndMask > 0) { - if (stream_get_left(s) < pointer_color->lengthAndMask) + if (Stream_GetRemainingLength(s) < pointer_color->lengthAndMask) return FALSE; if (!pointer_color->andMaskData) @@ -265,15 +265,15 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) stream_read(s, pointer_color->andMaskData, pointer_color->lengthAndMask); } - if (stream_get_left(s) > 0) - stream_seek_BYTE(s); /* pad (1 byte) */ + if (Stream_GetRemainingLength(s) > 0) + Stream_Seek_BYTE(s); /* pad (1 byte) */ return TRUE; } BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ @@ -282,7 +282,7 @@ BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new) BOOL update_read_pointer_cached(wStream* s, POINTER_CACHED_UPDATE* pointer_cached) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */ @@ -295,11 +295,11 @@ BOOL update_recv_pointer(rdpUpdate* update, wStream* s) rdpContext* context = update->context; rdpPointerUpdate* pointer = update->pointer; - if (stream_get_left(s) < 2 + 2) + if (Stream_GetRemainingLength(s) < 2 + 2) return FALSE; stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ - stream_seek_UINT16(s); /* pad2Octets (2 bytes) */ + Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ switch (messageType) { @@ -344,7 +344,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s) UINT16 updateType; rdpContext* context = update->context; - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, updateType); /* updateType (2 bytes) */ @@ -452,7 +452,7 @@ static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* area int i; stream_write_BYTE(s, count); /* numberOfAreas (1 byte) */ - stream_seek(s, 3); /* pad3Octets (3 bytes) */ + Stream_Seek(s, 3); /* pad3Octets (3 bytes) */ for (i = 0; i < count; i++) { @@ -480,7 +480,7 @@ static void update_send_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_ static void update_write_suppress_output(wStream* s, BYTE allow, RECTANGLE_16* area) { stream_write_BYTE(s, allow); /* allowDisplayUpdates (1 byte) */ - stream_seek(s, 3); /* pad3Octets (3 bytes) */ + Stream_Seek(s, 3); /* pad3Octets (3 bytes) */ if (allow > 0) { @@ -511,8 +511,8 @@ static void update_send_surface_command(rdpContext* context, wStream* s) rdpRdp* rdp = context->rdp; update = fastpath_update_pdu_init(rdp->fastpath); - stream_check_size(update, stream_get_length(s)); - stream_write(update, stream_get_head(s), stream_get_length(s)); + stream_check_size(update, Stream_GetPosition(s)); + stream_write(update, stream_get_head(s), Stream_GetPosition(s)); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update); } @@ -666,13 +666,13 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) BYTE numberOfAreas; RECTANGLE_16* areas; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_BYTE(s, numberOfAreas); - stream_seek(s, 3); /* pad3Octects */ + Stream_Seek(s, 3); /* pad3Octects */ - if (stream_get_left(s) < numberOfAreas * 4 * 2) + if (Stream_GetRemainingLength(s) < numberOfAreas * 4 * 2) return FALSE; areas = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * numberOfAreas); @@ -695,17 +695,17 @@ BOOL update_read_suppress_output(rdpUpdate* update, wStream* s) { BYTE allowDisplayUpdates; - if (stream_get_left(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_BYTE(s, allowDisplayUpdates); - stream_seek(s, 3); /* pad3Octects */ + Stream_Seek(s, 3); /* pad3Octects */ - if (allowDisplayUpdates > 0 && stream_get_left(s) < 8) + if (allowDisplayUpdates > 0 && Stream_GetRemainingLength(s) < 8) return FALSE; IFCALL(update->SuppressOutput, update->context, allowDisplayUpdates, - allowDisplayUpdates > 0 ? (RECTANGLE_16*) stream_get_tail(s) : NULL); + allowDisplayUpdates > 0 ? (RECTANGLE_16*) Stream_Pointer(s) : NULL); return TRUE; } diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index 418e4b696..44fd08e1b 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -30,7 +30,7 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT16(s, icon_info->cacheEntry); /* cacheEntry (2 bytes) */ stream_read_BYTE(s, icon_info->cacheId); /* cacheId (1 byte) */ @@ -40,19 +40,19 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info) /* cbColorTable is only present when bpp is 1, 2 or 4 */ if (icon_info->bpp == 1 || icon_info->bpp == 2 || icon_info->bpp == 4) { - if(stream_get_left(s) < 2) + if(Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, icon_info->cbColorTable); /* cbColorTable (2 bytes) */ } else { icon_info->cbColorTable = 0; } - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, icon_info->cbBitsMask); /* cbBitsMask (2 bytes) */ stream_read_UINT16(s, icon_info->cbBitsColor); /* cbBitsColor (2 bytes) */ - if(stream_get_left(s) < icon_info->cbBitsMask + icon_info->cbBitsColor) + if(Stream_GetRemainingLength(s) < icon_info->cbBitsMask + icon_info->cbBitsColor) return FALSE; /* bitsMask */ @@ -80,7 +80,7 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info) BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cached_icon_info) { - if(stream_get_left(s) < 3) + if(Stream_GetRemainingLength(s) < 3) return FALSE; stream_read_UINT16(s, cached_icon_info->cacheEntry); /* cacheEntry (2 bytes) */ stream_read_BYTE(s, cached_icon_info->cacheId); /* cacheId (1 byte) */ @@ -89,7 +89,7 @@ BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cached_icon_info BOOL update_read_notify_icon_infotip(wStream* s, NOTIFY_ICON_INFOTIP* notify_icon_infotip) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, notify_icon_infotip->timeout); /* timeout (4 bytes) */ stream_read_UINT32(s, notify_icon_infotip->flags); /* infoFlags (4 bytes) */ @@ -103,21 +103,21 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI int size; if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, window_state->ownerWindowId); /* ownerWindowId (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, window_state->style); /* style (4 bytes) */ stream_read_UINT32(s, window_state->extendedStyle); /* extendedStyle (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, window_state->showState); /* showState (1 byte) */ } @@ -129,7 +129,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, window_state->clientOffsetX); /* clientOffsetX (4 bytes) */ stream_read_UINT32(s, window_state->clientOffsetY); /* clientOffsetY (4 bytes) */ @@ -137,27 +137,27 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, window_state->clientAreaWidth); /* clientAreaWidth (4 bytes) */ stream_read_UINT32(s, window_state->clientAreaHeight); /* clientAreaHeight (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, window_state->RPContent); /* RPContent (1 byte) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, window_state->rootParentHandle);/* rootParentHandle (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, window_state->windowOffsetX); /* windowOffsetX (4 bytes) */ stream_read_UINT32(s, window_state->windowOffsetY); /* windowOffsetY (4 bytes) */ @@ -165,7 +165,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, window_state->windowClientDeltaX); /* windowClientDeltaX (4 bytes) */ stream_read_UINT32(s, window_state->windowClientDeltaY); /* windowClientDeltaY (4 bytes) */ @@ -173,7 +173,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) { - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, window_state->windowWidth); /* windowWidth (4 bytes) */ stream_read_UINT32(s, window_state->windowHeight); /* windowHeight (4 bytes) */ @@ -181,14 +181,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { - if(stream_get_left(s) < 2) + if(Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, window_state->numWindowRects); /* numWindowRects (2 bytes) */ size = sizeof(RECTANGLE_16) * window_state->numWindowRects; window_state->windowRects = (RECTANGLE_16*) malloc(size); - if(stream_get_left(s) < 8 * window_state->numWindowRects) + if(Stream_GetRemainingLength(s) < 8 * window_state->numWindowRects) return FALSE; /* windowRects */ @@ -203,7 +203,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, window_state->visibleOffsetX); /* visibleOffsetX (4 bytes) */ stream_read_UINT32(s, window_state->visibleOffsetY); /* visibleOffsetY (4 bytes) */ @@ -211,14 +211,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { - if(stream_get_left(s) < 2) + if(Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, window_state->numVisibilityRects); /* numVisibilityRects (2 bytes) */ size = sizeof(RECTANGLE_16) * window_state->numVisibilityRects; window_state->visibilityRects = (RECTANGLE_16*) malloc(size); - if(stream_get_left(s) < window_state->numVisibilityRects * 8) + if(Stream_GetRemainingLength(s) < window_state->numVisibilityRects * 8) return FALSE; /* visibilityRects */ @@ -256,7 +256,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I rdpContext* context = update->context; rdpWindowUpdate* window = update->window; - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ @@ -297,7 +297,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, NOTIFY_ICON_STATE_ORDER* notify_icon_state) { if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */ } @@ -313,7 +313,7 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, notify_icon_state->state); /* state (4 bytes) */ } @@ -340,7 +340,7 @@ BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WIN rdpContext* context = update->context; rdpWindowUpdate* window = update->window; - if(stream_get_left(s) < 8) + if(Stream_GetRemainingLength(s) < 8) return FALSE; stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ stream_read_UINT32(s, orderInfo->notifyIconId); /* notifyIconId (4 bytes) */ @@ -371,18 +371,18 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* int size; if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND) { - if(stream_get_left(s) < 4) + if(Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT32(s, monitored_desktop->activeWindowId); /* activeWindowId (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER) { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, monitored_desktop->numWindowIds); /* numWindowIds (1 byte) */ - if(stream_get_left(s) < 4 * monitored_desktop->numWindowIds) + if(Stream_GetRemainingLength(s) < 4 * monitored_desktop->numWindowIds) return FALSE; size = sizeof(UINT32) * monitored_desktop->numWindowIds; @@ -432,7 +432,7 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) UINT16 orderSize; rdpWindowUpdate* window = update->window; - if(stream_get_left(s) < 6) + if(Stream_GetRemainingLength(s) < 6) return FALSE; stream_read_UINT16(s, orderSize); /* orderSize (2 bytes) */ stream_read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */ diff --git a/libfreerdp/crypto/ber.c b/libfreerdp/crypto/ber.c index 3272ff687..17bf37d1e 100644 --- a/libfreerdp/crypto/ber.c +++ b/libfreerdp/crypto/ber.c @@ -30,7 +30,7 @@ BOOL ber_read_length(wStream* s, int* length) { BYTE byte; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -38,7 +38,7 @@ BOOL ber_read_length(wStream* s, int* length) { byte &= ~(0x80); - if(stream_get_left(s) < byte) + if(Stream_GetRemainingLength(s) < byte) return FALSE; if (byte == 1) @@ -103,7 +103,7 @@ BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc) { BYTE byte; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -138,14 +138,14 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length) if (tag > 30) { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); if (byte != ((BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK)) return FALSE; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -156,7 +156,7 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length) } else { - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -195,13 +195,13 @@ BOOL ber_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) { BYTE byte; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); if (byte != ((BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag))) { - stream_rewind(s, 1); + Stream_Rewind(s, 1); return FALSE; } @@ -223,7 +223,7 @@ BOOL ber_read_sequence_tag(wStream* s, int* length) { BYTE byte; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); @@ -263,7 +263,7 @@ BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) !ber_read_length(s, &length)) return FALSE; - if (length != 1 || stream_get_left(s) < 1) + if (length != 1 || Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *enumerated); @@ -288,7 +288,7 @@ BOOL ber_read_bit_string(wStream* s, int* length, BYTE* padding) !ber_read_length(s, length)) return FALSE; - if(stream_get_left(s) < 1) + if(Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *padding); return TRUE; @@ -342,7 +342,7 @@ BOOL ber_read_BOOL(wStream* s, BOOL* value) !ber_read_length(s, &length)) return FALSE; - if (length != 1 || stream_get_left(s) < 1) + if (length != 1 || Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, v); @@ -369,7 +369,7 @@ BOOL ber_read_integer(wStream* s, UINT32* value) if (!ber_read_universal_tag(s, BER_TAG_INTEGER, FALSE) || !ber_read_length(s, &length) || - stream_get_left(s) < length) + Stream_GetRemainingLength(s) < length) return FALSE; if (value == NULL) diff --git a/libfreerdp/crypto/er.c b/libfreerdp/crypto/er.c index 612752221..47fa748e1 100644 --- a/libfreerdp/crypto/er.c +++ b/libfreerdp/crypto/er.c @@ -178,7 +178,7 @@ BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) if (byte != ((ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag))) { - stream_rewind(s, 1); + Stream_Rewind(s, 1); return FALSE; } @@ -355,7 +355,7 @@ BOOL er_read_integer(wStream* s, UINT32* value) if (value == NULL) { - stream_seek(s, length); + Stream_Seek(s, length); return TRUE; } diff --git a/libfreerdp/crypto/per.c b/libfreerdp/crypto/per.c index 2a3631c01..00960b249 100644 --- a/libfreerdp/crypto/per.c +++ b/libfreerdp/crypto/per.c @@ -34,14 +34,14 @@ BOOL per_read_length(wStream* s, UINT16* length) { BYTE byte; - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, byte); if (byte & 0x80) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; byte &= ~(0x80); @@ -80,7 +80,7 @@ void per_write_length(wStream* s, int length) BOOL per_read_choice(wStream* s, BYTE* choice) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *choice); @@ -107,7 +107,7 @@ void per_write_choice(wStream* s, BYTE choice) BOOL per_read_selection(wStream* s, BYTE* selection) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *selection); @@ -134,7 +134,7 @@ void per_write_selection(wStream* s, BYTE selection) BOOL per_read_number_of_sets(wStream* s, BYTE* number) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *number); @@ -160,10 +160,10 @@ void per_write_number_of_sets(wStream* s, BYTE number) BOOL per_read_padding(wStream* s, int length) { - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; - stream_seek(s, length); + Stream_Seek(s, length); return TRUE; } @@ -195,7 +195,7 @@ BOOL per_read_integer(wStream* s, UINT32* integer) if (!per_read_length(s, &length)) return FALSE; - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; if (length == 1) @@ -243,7 +243,7 @@ void per_write_integer(wStream* s, UINT32 integer) BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16_be(s, *integer); @@ -278,7 +278,7 @@ void per_write_integer16(wStream* s, UINT16 integer, UINT16 min) BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) { - if (stream_get_left(s) < 1) + if (Stream_GetRemainingLength(s) < 1) return FALSE; stream_read_BYTE(s, *enumerated); @@ -322,7 +322,7 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6]) if (length != 5) return FALSE; - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; stream_read_BYTE(s, t12); /* first two tuples */ @@ -399,11 +399,11 @@ BOOL per_read_octet_string(wStream* s, BYTE* oct_str, int length, int min) if (mlength + min != length) return FALSE; - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; a_oct_str = s->pointer; - stream_seek(s, length); + Stream_Seek(s, length); for (i = 0; i < length; i++) { @@ -453,10 +453,10 @@ BOOL per_read_numeric_string(wStream* s, int min) length = (mlength + min + 1) / 2; - if (stream_get_left(s) < length) + if (Stream_GetRemainingLength(s) < length) return FALSE; - stream_seek(s, length); + Stream_Seek(s, length); return TRUE; } diff --git a/libfreerdp/utils/rail.c b/libfreerdp/utils/rail.c index 521710091..162d95ef6 100644 --- a/libfreerdp/utils/rail.c +++ b/libfreerdp/utils/rail.c @@ -48,12 +48,12 @@ void rail_unicode_string_free(RAIL_UNICODE_STRING* unicode_string) BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) { - if (stream_get_left(s) < 2) + if (Stream_GetRemainingLength(s) < 2) return FALSE; stream_read_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ - if (stream_get_left(s) < unicode_string->length) + if (Stream_GetRemainingLength(s) < unicode_string->length) return FALSE; if (unicode_string->string == NULL) diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index a47898fd7..9dc0c9405 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -127,13 +127,13 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3 if (dataFlags & CHANNEL_FLAG_LAST) { - if (stream_get_size(data_in) != stream_get_length(data_in)) + if (Stream_Capacity(data_in) != Stream_GetPosition(data_in)) { fprintf(stderr, "svc_plugin_process_received: read error\n"); } plugin->data_in = NULL; - stream_set_pos(data_in, 0); + Stream_SetPosition(data_in, 0); MessageQueue_Post(plugin->MsgPipe->In, NULL, 0, (void*) data_in, NULL); } @@ -305,13 +305,13 @@ int svc_plugin_send(rdpSvcPlugin* plugin, wStream* data_out) { UINT32 status = 0; - DEBUG_SVC("length %d", (int) stream_get_length(data_out)); + DEBUG_SVC("length %d", (int) Stream_GetPosition(data_out)); if (!plugin) status = CHANNEL_RC_BAD_INIT_HANDLE; else status = plugin->channel_entry_points.pVirtualChannelWrite(plugin->open_handle, - stream_get_data(data_out), stream_get_length(data_out), data_out); + Stream_Buffer(data_out), Stream_GetPosition(data_out), data_out); if (status != CHANNEL_RC_OK) { diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index 2d0c8ee61..21e52a85a 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -134,7 +134,7 @@ void mf_peer_rfx_update(freerdp_peer* client) s = mfp->s; stream_clear(s); - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale; @@ -160,7 +160,7 @@ void mf_peer_rfx_update(freerdp_peer* client) cmd->codecID = 3; cmd->width = rect.width; cmd->height = rect.height; - cmd->bitmapDataLength = stream_get_length(s); + cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = stream_get_head(s); //send diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 323edc532..370d1993d 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -105,7 +105,7 @@ static void test_peer_init(freerdp_peer* client) static wStream* test_peer_stream_init(testPeerContext* context) { stream_clear(context->s); - stream_set_pos(context->s, 0); + Stream_SetPosition(context->s, 0); return context->s; } @@ -179,7 +179,7 @@ static void test_peer_draw_background(freerdp_peer* client) cmd->bpp = 32; cmd->width = rect.width; cmd->height = rect.height; - cmd->bitmapDataLength = stream_get_length(s); + cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); @@ -278,7 +278,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y) cmd->bpp = 32; cmd->width = context->icon_width; cmd->height = context->icon_height; - cmd->bitmapDataLength = stream_get_length(s); + cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); } @@ -305,7 +305,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y) cmd->bpp = 32; cmd->width = context->icon_width; cmd->height = context->icon_height; - cmd->bitmapDataLength = stream_get_length(s); + cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); @@ -417,10 +417,10 @@ static void* tf_debug_channel_thread_func(void* arg) if (WaitForSingleObject(context->stopEvent, 0) == WAIT_OBJECT_0) break; - stream_set_pos(s, 0); + Stream_SetPosition(s, 0); if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) break; @@ -428,14 +428,14 @@ static void* tf_debug_channel_thread_func(void* arg) stream_check_size(s, bytes_returned); if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s), - stream_get_size(s), &bytes_returned) == FALSE) + Stream_Capacity(s), &bytes_returned) == FALSE) { /* should not happen */ break; } } - stream_set_pos(s, bytes_returned); + Stream_SetPosition(s, bytes_returned); printf("got %d bytes\n", bytes_returned); } diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 7b68f4f9c..2e5c2b3c3 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -123,7 +123,7 @@ void wf_update_encode(wfInfo* wfi) cmd = &wfi->cmd; - stream_set_pos(wfi->s, 0); + Stream_SetPosition(wfi->s, 0); wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride); @@ -149,7 +149,7 @@ void wf_update_encode(wfInfo* wfi) cmd->codecID = 3; cmd->width = width; cmd->height = height; - cmd->bitmapDataLength = stream_get_length(wfi->s); + cmd->bitmapDataLength = Stream_GetPosition(wfi->s); cmd->bitmapData = stream_get_head(wfi->s); } diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 2d5617e10..da973296a 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -326,7 +326,7 @@ void xf_peer_init(freerdp_peer* client) wStream* xf_peer_stream_init(xfPeerContext* context) { stream_clear(context->s); - stream_set_pos(context->s, 0); + Stream_SetPosition(context->s, 0); return context->s; } @@ -408,7 +408,7 @@ void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int heigh cmd->codecID = client->settings->RemoteFxCodecId; cmd->width = width; cmd->height = height; - cmd->bitmapDataLength = stream_get_length(s); + cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index b57a47072..cc9396959 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -190,10 +190,13 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); #define Stream_Buffer(_s) _s->buffer #define Stream_Length(_s) _s->length #define Stream_Capacity(_s) _s->capacity -#define Stream_Position(_s) (_s->pointer - _s->buffer) +#define Stream_GetPosition(_s) (_s->pointer - _s->buffer) #define Stream_SetPosition(_s, _p) _s->pointer = _s->buffer + (_p) +#define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer) +#define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer)) + /* Deprecated STREAM API */ WINPR_API wStream* stream_new(int size); @@ -201,6 +204,7 @@ WINPR_API void stream_free(wStream* stream); #define stream_attach(_s, _buf, _size) do { \ _s->capacity = _size; \ + _s->length = _size; \ _s->buffer = _buf; \ _s->pointer = _buf; } while (0) #define stream_detach(_s) memset(_s, 0, sizeof(wStream)) @@ -211,19 +215,9 @@ WINPR_API void stream_extend(wStream* stream, int request_size); while (_s->pointer - _s->buffer + (_n) > _s->capacity) \ stream_extend(_s, _n) -#define stream_get_pos(_s) (_s->pointer - _s->buffer) -#define stream_set_pos(_s,_m) _s->pointer = _s->buffer + (_m) -#define stream_seek(_s,_offset) _s->pointer += (_offset) -#define stream_rewind(_s,_offset) _s->pointer -= (_offset) -#define stream_seal(_s) _s->capacity = (_s->pointer - _s->buffer) #define stream_get_mark(_s,_mark) _mark = _s->pointer #define stream_set_mark(_s,_mark) _s->pointer = _mark #define stream_get_head(_s) _s->buffer -#define stream_get_tail(_s) _s->pointer -#define stream_get_length(_s) (_s->pointer - _s->buffer) -#define stream_get_data(_s) (_s->buffer) -#define stream_get_size(_s) (_s->capacity) -#define stream_get_left(_s) (_s->capacity - (_s->pointer - _s->buffer)) #define stream_read_BYTE(_s, _v) do { _v = *_s->pointer++; } while (0) #define stream_read_UINT16(_s, _v) do { _v = \ @@ -305,10 +299,10 @@ WINPR_API void stream_extend(wStream* stream, int request_size); (((UINT64)(*(_s->pointer + 7))) << 56); \ } while (0) -#define stream_seek_BYTE(_s) stream_seek(_s, 1) -#define stream_seek_UINT16(_s) stream_seek(_s, 2) -#define stream_seek_UINT32(_s) stream_seek(_s, 4) -#define stream_seek_UINT64(_s) stream_seek(_s, 8) +#define Stream_Seek_BYTE(_s) Stream_Seek(_s, 1) +#define Stream_Seek_UINT16(_s) Stream_Seek(_s, 2) +#define Stream_Seek_UINT32(_s) Stream_Seek(_s, 4) +#define Stream_Seek_UINT64(_s) Stream_Seek(_s, 8) #define stream_read_UINT16_be(_s, _v) do { _v = \ (((UINT16)(*_s->pointer)) << 8) + \ @@ -336,9 +330,9 @@ WINPR_API void stream_extend(wStream* stream, int request_size); } while (0) static INLINE BOOL stream_skip(wStream* s, size_t sz) { - if (stream_get_left(s) < sz) + if (Stream_GetRemainingLength(s) < sz) return FALSE; - stream_seek(s, sz); + Stream_Seek(s, sz); return TRUE; } diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c index 050d1fabf..854e13581 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c @@ -119,7 +119,7 @@ void ntlm_read_ntlm_v2_client_challenge(wStream* s, NTLMv2_CLIENT_CHALLENGE* cha Stream_Read(s, challenge->ClientChallenge, 8); Stream_Read_UINT32(s, challenge->Reserved3); - size = Stream_Length(s) - Stream_Position(s); + size = Stream_Length(s) - Stream_GetPosition(s); challenge->AvPairs = (NTLM_AV_PAIR*) malloc(size); Stream_Read(s, challenge->AvPairs, size); } diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index d4789c6e3..a753b5029 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -233,7 +233,7 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION) ntlm_read_version_info(s, &(message->Version)); /* Version (8 bytes) */ - length = Stream_Position(s); + length = Stream_GetPosition(s); buffer->cbBuffer = length; sspi_SecBufferAlloc(&context->NegotiateMessage, length); @@ -317,7 +317,7 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION) ntlm_write_version_info(s, &(message->Version)); - length = Stream_Position(s); + length = Stream_GetPosition(s); buffer->cbBuffer = length; sspi_SecBufferAlloc(&context->NegotiateMessage, length); @@ -606,7 +606,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_TARGET_INFO) ntlm_write_message_fields_buffer(s, &(message->TargetInfo)); - length = Stream_Position(s); + length = Stream_GetPosition(s); buffer->cbBuffer = length; sspi_SecBufferAlloc(&context->ChallengeMessage, length); @@ -682,7 +682,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION) ntlm_read_version_info(s, &(message->Version)); /* Version (8 bytes) */ - PayloadBufferOffset = Stream_Position(s); + PayloadBufferOffset = Stream_GetPosition(s); ntlm_read_message_fields_buffer(s, &(message->DomainName)); /* DomainName */ @@ -718,7 +718,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer ntlm_read_message_fields_buffer(s, &(message->EncryptedRandomSessionKey)); CopyMemory(context->EncryptedRandomSessionKey, message->EncryptedRandomSessionKey.Buffer, 16); - length = Stream_Position(s); + length = Stream_GetPosition(s); sspi_SecBufferAlloc(&context->AuthenticateMessage, length); CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length); buffer->cbBuffer = length; @@ -727,7 +727,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer if (flags & MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK) { - MicOffset = Stream_Position(s); + MicOffset = Stream_GetPosition(s); Stream_Read(s, message->MessageIntegrityCheck, 16); PayloadBufferOffset += 16; } @@ -995,7 +995,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer if (context->UseMIC) { - MicOffset = Stream_Position(s); + MicOffset = Stream_GetPosition(s); Stream_Zero(s, 16); /* Message Integrity Check (16 bytes) */ } @@ -1014,7 +1014,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_KEY_EXCH) ntlm_write_message_fields_buffer(s, &(message->EncryptedRandomSessionKey)); /* EncryptedRandomSessionKey */ - length = Stream_Position(s); + length = Stream_GetPosition(s); sspi_SecBufferAlloc(&context->AuthenticateMessage, length); CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length); buffer->cbBuffer = length; diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index 96a491acf..be36c30f6 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -55,8 +55,6 @@ void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count) void StreamPool_AddUsed(wStreamPool* pool, wStream* s) { - int index; - if ((pool->uSize + 1) >= pool->uCapacity) { pool->uCapacity *= 2; @@ -88,32 +86,58 @@ void StreamPool_RemoveUsed(wStreamPool* pool, wStream* s) StreamPool_ShiftUsed(pool, index, -1); } +void StreamPool_ShiftAvailable(wStreamPool* pool, int index, int count) +{ + if (count > 0) + { + if (pool->aSize + count > pool->aCapacity) + { + pool->aCapacity *= 2; + pool->aArray = (wStream**) realloc(pool->aArray, sizeof(wStream*) * pool->aCapacity); + } + + MoveMemory(&pool->aArray[index + count], &pool->aArray[index], (pool->aSize - index) * sizeof(wStream*)); + pool->aSize += count; + } + else if (count < 0) + { + MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize + count) * sizeof(wStream*)); + pool->aSize += count; + } +} + /** * Gets a stream from the pool. */ wStream* StreamPool_Take(wStreamPool* pool, size_t size) { + int index; wStream* s = NULL; + BOOL found = FALSE; if (pool->synchronized) WaitForSingleObject(pool->mutex, INFINITE); - if (pool->aSize > 0) - s = pool->aArray[--(pool->aSize)]; - if (size == 0) size = pool->defaultSize; - if (!s) + for (index = 0; index < pool->aSize; index++) { + s = pool->aArray[index]; + + if (s->capacity == size) + { + StreamPool_ShiftAvailable(pool, index, -1); + found = TRUE; + break; + } + } + + if (!found) s = Stream_New(NULL, size); - } else - { - Stream_EnsureCapacity(s, size); Stream_Pointer(s) = Stream_Buffer(s); - } s->pool = pool; s->count = 1; diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 1dad2ec92..c80e8c9a3 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -147,7 +147,7 @@ void stream_extend(wStream* stream, int request_size) int original_size; int increased_size; - pos = stream_get_pos(stream); + pos = Stream_GetPosition(stream); original_size = stream->capacity; increased_size = (request_size > original_size ? request_size : original_size); stream->capacity += increased_size; @@ -158,5 +158,5 @@ void stream_extend(wStream* stream, int request_size) stream->buffer = (BYTE*) realloc(stream->buffer, stream->capacity); memset(stream->buffer + original_size, 0, increased_size); - stream_set_pos(stream, pos); + Stream_SetPosition(stream, pos); } From 83af4266bf5c0f466cd43ef37789fb0b046ad009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 29 Apr 2013 23:55:44 -0400 Subject: [PATCH 047/144] libfreerdp-core: refactor fastpath fragmentation --- libfreerdp/core/fastpath.c | 156 ++++++++++++++---- libfreerdp/core/fastpath.h | 1 + winpr/libwinpr/utils/collections/StreamPool.c | 7 +- winpr/libwinpr/utils/stream.c | 7 +- 4 files changed, 133 insertions(+), 38 deletions(-) diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index b94ec77b1..505b66b76 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -26,10 +26,10 @@ #include <string.h> #include <winpr/crt.h> +#include <winpr/stream.h> #include <freerdp/api.h> #include <freerdp/crypto/per.h> -#include <winpr/stream.h> #include "orders.h" #include "update.h" @@ -277,21 +277,34 @@ static int fastpath_recv_update(rdpFastPath* fastpath, BYTE updateCode, UINT32 s return status; } +const char* fastpath_get_fragmentation_string(BYTE fragmentation) +{ + if (fragmentation == FASTPATH_FRAGMENT_SINGLE) + return "FASTPATH_FRAGMENT_SINGLE"; + else if (fragmentation == FASTPATH_FRAGMENT_LAST) + return "FASTPATH_FRAGMENT_LAST"; + else if (fragmentation == FASTPATH_FRAGMENT_FIRST) + return "FASTPATH_FRAGMENT_FIRST"; + else if (fragmentation == FASTPATH_FRAGMENT_NEXT) + return "FASTPATH_FRAGMENT_NEXT"; + + return "FASTPATH_FRAGMENT_UNKNOWN"; +} + static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) { int status; UINT16 size; + UINT32 roff; + UINT32 rlen; + rdpRdp* rdp; int next_pos; UINT32 totalSize; BYTE updateCode; BYTE fragmentation; BYTE compression; BYTE compressionFlags; - wStream* update_stream; wStream* comp_stream; - rdpRdp* rdp; - UINT32 roff; - UINT32 rlen; status = 0; rdp = fastpath->rdp; @@ -328,42 +341,107 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) } } - update_stream = NULL; - if (fragmentation == FASTPATH_FRAGMENT_SINGLE) { - totalSize = size; - update_stream = comp_stream; - } - else - { - if (fragmentation == FASTPATH_FRAGMENT_FIRST) - Stream_SetPosition(fastpath->updateData, 0); - - stream_check_size(fastpath->updateData, size); - stream_copy(fastpath->updateData, comp_stream, size); - - if (Stream_GetPosition(fastpath->updateData) > rdp->settings->MultifragMaxRequestSize) + if (fastpath->fragmentation != -1) { - fprintf(stderr, "fastpath PDU is bigger than MultifragMaxRequestSize\n"); + fprintf(stderr, "Unexpected FASTPATH_FRAGMENT_SINGLE\n"); return -1; } - if (fragmentation == FASTPATH_FRAGMENT_LAST) - { - update_stream = fastpath->updateData; - totalSize = Stream_GetPosition(update_stream); - Stream_SetPosition(update_stream, 0); - } - } - - if (update_stream) - { - status = fastpath_recv_update(fastpath, updateCode, totalSize, update_stream); + totalSize = size; + status = fastpath_recv_update(fastpath, updateCode, totalSize, comp_stream); if (status < 0) return -1; } + else + { + rdpTransport* transport = fastpath->rdp->transport; + + if (fragmentation == FASTPATH_FRAGMENT_FIRST) + { + if (fastpath->fragmentation != -1) + { + fprintf(stderr, "Unexpected FASTPATH_FRAGMENT_FIRST\n"); + return -1; + } + + fastpath->fragmentation = FASTPATH_FRAGMENT_FIRST; + + totalSize = size; + + if (totalSize > transport->settings->MultifragMaxRequestSize) + { + fprintf(stderr, "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", + totalSize, transport->settings->MultifragMaxRequestSize); + return -1; + } + + fastpath->updateData = StreamPool_Take(transport->ReceivePool, size); + Stream_SetPosition(fastpath->updateData, 0); + + Stream_Copy(fastpath->updateData, comp_stream, size); + } + else if (fragmentation == FASTPATH_FRAGMENT_NEXT) + { + if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && + (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) + { + fprintf(stderr, "Unexpected FASTPATH_FRAGMENT_NEXT\n"); + return -1; + } + + fastpath->fragmentation = FASTPATH_FRAGMENT_NEXT; + + totalSize = Stream_GetPosition(fastpath->updateData) + size; + + if (totalSize > transport->settings->MultifragMaxRequestSize) + { + fprintf(stderr, "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", + totalSize, transport->settings->MultifragMaxRequestSize); + return -1; + } + + Stream_EnsureCapacity(fastpath->updateData, totalSize); + + Stream_Copy(fastpath->updateData, comp_stream, size); + } + else if (fragmentation == FASTPATH_FRAGMENT_LAST) + { + if ((fastpath->fragmentation != FASTPATH_FRAGMENT_FIRST) && + (fastpath->fragmentation != FASTPATH_FRAGMENT_NEXT)) + { + fprintf(stderr, "Unexpected FASTPATH_FRAGMENT_LAST\n"); + return -1; + } + + fastpath->fragmentation = -1; + + totalSize = Stream_GetPosition(fastpath->updateData) + size; + + if (totalSize > transport->settings->MultifragMaxRequestSize) + { + fprintf(stderr, "Total size (%d) exceeds MultifragMaxRequestSize (%d)\n", + totalSize, transport->settings->MultifragMaxRequestSize); + return -1; + } + + Stream_EnsureCapacity(fastpath->updateData, totalSize); + + Stream_Copy(fastpath->updateData, comp_stream, size); + + Stream_SealLength(fastpath->updateData); + Stream_SetPosition(fastpath->updateData, 0); + + status = fastpath_recv_update(fastpath, updateCode, totalSize, fastpath->updateData); + + Stream_Release(fastpath->updateData); + + if (status < 0) + return -1; + } + } Stream_SetPosition(s, next_pos); @@ -798,16 +876,22 @@ rdpFastPath* fastpath_new(rdpRdp* rdp) rdpFastPath* fastpath; fastpath = (rdpFastPath*) malloc(sizeof(rdpFastPath)); - ZeroMemory(fastpath, sizeof(rdpFastPath)); - fastpath->rdp = rdp; - fastpath->updateData = stream_new(4096); + if (fastpath) + { + ZeroMemory(fastpath, sizeof(rdpFastPath)); + + fastpath->rdp = rdp; + fastpath->fragmentation = -1; + } return fastpath; } void fastpath_free(rdpFastPath* fastpath) { - stream_free(fastpath->updateData); - free(fastpath); + if (fastpath) + { + free(fastpath); + } } diff --git a/libfreerdp/core/fastpath.h b/libfreerdp/core/fastpath.h index e7bcab46c..4603fc42c 100644 --- a/libfreerdp/core/fastpath.h +++ b/libfreerdp/core/fastpath.h @@ -101,6 +101,7 @@ struct rdp_fastpath BYTE encryptionFlags; BYTE numberEvents; wStream* updateData; + int fragmentation; }; UINT16 fastpath_header_length(wStream* s); diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index be36c30f6..69e0049bf 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -126,7 +126,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) { s = pool->aArray[index]; - if (s->capacity == size) + if (s->capacity >= size) { StreamPool_ShiftAvailable(pool, index, -1); found = TRUE; @@ -135,9 +135,14 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) } if (!found) + { s = Stream_New(NULL, size); + } else + { + Stream_EnsureCapacity(s, size); Stream_Pointer(s) = Stream_Buffer(s); + } s->pool = pool; s->count = 1; diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index c80e8c9a3..380fcbda5 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -29,9 +29,14 @@ void Stream_EnsureCapacity(wStream* s, size_t size) { if (s->capacity < size) { + size_t position; + + position = Stream_GetPosition(s); + s->capacity = size; s->buffer = (BYTE*) realloc(s->buffer, size); - s->pointer = s->buffer; + + Stream_SetPosition(s, position); } } From c49c235c932f1c1187fb2b089a12a31b403ac381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 00:36:16 -0400 Subject: [PATCH 048/144] libwinpr-utils: fix stream pool --- libfreerdp/core/message.c | 2 +- winpr/libwinpr/utils/collections/StreamPool.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 3ccea28d3..0c27bd5e2 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -31,7 +31,7 @@ #include <winpr/stream.h> #include <winpr/collections.h> -//#define WITH_STREAM_POOL 1 +#define WITH_STREAM_POOL 1 /* Update */ diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index 69e0049bf..fe5e3bc27 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -44,7 +44,7 @@ void StreamPool_ShiftUsed(wStreamPool* pool, int index, int count) } else if (count < 0) { - MoveMemory(&pool->uArray[index], &pool->uArray[index - count], (pool->uSize + count) * sizeof(wStream*)); + MoveMemory(&pool->uArray[index], &pool->uArray[index - count], (pool->uSize - index) * sizeof(wStream*)); pool->uSize += count; } } @@ -101,7 +101,7 @@ void StreamPool_ShiftAvailable(wStreamPool* pool, int index, int count) } else if (count < 0) { - MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize + count) * sizeof(wStream*)); + MoveMemory(&pool->aArray[index], &pool->aArray[index - count], (pool->aSize - index) * sizeof(wStream*)); pool->aSize += count; } } @@ -113,6 +113,7 @@ void StreamPool_ShiftAvailable(wStreamPool* pool, int index, int count) wStream* StreamPool_Take(wStreamPool* pool, size_t size) { int index; + int foundIndex; wStream* s = NULL; BOOL found = FALSE; @@ -128,7 +129,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) if (s->capacity >= size) { - StreamPool_ShiftAvailable(pool, index, -1); + foundIndex = index; found = TRUE; break; } @@ -140,6 +141,8 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) } else { + StreamPool_ShiftAvailable(pool, foundIndex, -1); + Stream_EnsureCapacity(s, size); Stream_Pointer(s) = Stream_Buffer(s); } From e585fd9ac16072059d0c7ca8ab9c2ab4f00ea3ef Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Tue, 30 Apr 2013 08:14:24 -0700 Subject: [PATCH 049/144] Android: Added support for TS Gateway --- .../Android/FreeRDPCore/jni/android_cliprdr.c | 2 +- .../Android/FreeRDPCore/jni/android_freerdp.c | 33 ++++- .../Android/FreeRDPCore/jni/android_freerdp.h | 1 + .../jni/generated/android_freerdp_jni.c | 6 + ..._freerdp_freerdpcore_services_LibFreeRDP.h | 8 ++ .../FreeRDPCore/res/values-es/strings.xml | 3 + .../FreeRDPCore/res/values-fr/strings.xml | 3 + .../FreeRDPCore/res/values/strings.xml | 3 + .../FreeRDPCore/res/xml/advanced_settings.xml | 11 +- .../FreeRDPCore/res/xml/gateway_settings.xml | 20 +++ .../freerdpcore/domain/ManualBookmark.java | 136 +++++++++++++++++- .../presentation/BookmarkActivity.java | 66 ++++++++- .../freerdpcore/services/BookmarkDB.java | 11 +- .../freerdpcore/services/LibFreeRDP.java | 11 ++ .../services/ManualBookmarkGateway.java | 29 +++- 15 files changed, 333 insertions(+), 10 deletions(-) create mode 100644 client/Android/FreeRDPCore/res/xml/gateway_settings.xml diff --git a/client/Android/FreeRDPCore/jni/android_cliprdr.c b/client/Android/FreeRDPCore/jni/android_cliprdr.c index 1c62d2b4c..f34014de5 100644 --- a/client/Android/FreeRDPCore/jni/android_cliprdr.c +++ b/client/Android/FreeRDPCore/jni/android_cliprdr.c @@ -586,7 +586,7 @@ void android_process_cliprdr_event(freerdp* inst, wMessage* event) break; default: - DEBUG_ANDROID("unknown event type %d", event->event_type); + DEBUG_ANDROID("unknown event type %d", GetMessageType(event->id)); break; } } diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 10aa20926..51a6a4695 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -652,6 +652,37 @@ JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass settings->RedirectClipboard = enable ? TRUE : FALSE; } +JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, + jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain) +{ + freerdp* inst = (freerdp*)instance; + rdpSettings * settings = inst->settings; + + const jbyte *gatewayhostname = (*env)->GetStringUTFChars(env, jgatewayhostname, NULL); + const jbyte *gatewayusername = (*env)->GetStringUTFChars(env, jgatewayusername, NULL); + const jbyte *gatewaypassword = (*env)->GetStringUTFChars(env, jgatewaypassword, NULL); + const jbyte *gatewaydomain = (*env)->GetStringUTFChars(env, jgatewaydomain, NULL); + + DEBUG_ANDROID("gatewayhostname: %s", (char*) gatewayhostname); + DEBUG_ANDROID("gatewayport: %d", port); + DEBUG_ANDROID("gatewayusername: %s", (char*) gatewayusername); + DEBUG_ANDROID("gatewaypassword: %s", (char*) gatewaypassword); + DEBUG_ANDROID("gatewaydomain: %s", (char*) gatewaydomain); + + settings->GatewayHostname = strdup(gatewayhostname); + settings->GatewayPort = port; + settings->GatewayUsername = strdup(gatewayusername); + settings->GatewayPassword = strdup(gatewaypassword); + settings->GatewayDomain = strdup(gatewaydomain); + settings->GatewayUsageMethod = TRUE; + settings->GatewayUseSameCredentials = FALSE; + + (*env)->ReleaseStringUTFChars(env, jgatewayhostname, gatewayhostname); + (*env)->ReleaseStringUTFChars(env, jgatewayusername, gatewayusername); + (*env)->ReleaseStringUTFChars(env, jgatewaypassword, gatewaypassword); + (*env)->ReleaseStringUTFChars(env, jgatewaydomain, gatewaydomain); +} + void copy_pixel_buffer(UINT8* dstBuf, UINT8* srcBuf, int x, int y, int width, int height, int wBuf, int hBuf, int bpp) { int i, j; @@ -737,7 +768,7 @@ JNIEXPORT void JNICALL jni_freerdp_send_key_event( android_push_event(inst, event); - DEBUG_ANDROID("send_key_event: %d, %d", scancode, flags); + DEBUG_ANDROID("send_key_event: %d, %d", (int)scancode, flags); } JNIEXPORT void JNICALL jni_freerdp_send_unicodekey_event( diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.h b/client/Android/FreeRDPCore/jni/android_freerdp.h index f4c660b3d..ad96bc398 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.h +++ b/client/Android/FreeRDPCore/jni/android_freerdp.h @@ -46,6 +46,7 @@ JNIEXPORT void JNICALL jni_freerdp_set_performance_flags(JNIEnv *env, jclass cls JNIEXPORT void JNICALL jni_freerdp_set_advanced_settings(JNIEnv *env, jclass cls, jint instance, jstring jRemoteProgram, jstring jWorkDir); JNIEXPORT void JNICALL jni_freerdp_set_drive_redirection(JNIEnv *env, jclass cls, jint instance, jstring jpath); JNIEXPORT void JNICALL jni_freerdp_set_clipboard_redirection(JNIEnv *env, jclass cls, jint instance, jboolean enable); +JNIEXPORT void JNICALL jni_freerdp_set_gateway_info(JNIEnv *env, jclass cls, jint instance, jstring jgatewayhostname, jint port, jstring jgatewayusername, jstring jgatewaypassword, jstring jgatewaydomain); JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, jint instance, jstring jdirectory); JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height); JNIEXPORT void JNICALL jni_freerdp_send_cursor_event(JNIEnv *env, jclass cls, jint instance, jint x, jint y, jint flags); diff --git a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c index 861a9087a..1aa889abe 100644 --- a/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c +++ b/client/Android/FreeRDPCore/jni/generated/android_freerdp_jni.c @@ -82,6 +82,12 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ jni_freerdp_set_drive_redirection(env, cls, inst, path); } +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info + (JNIEnv *env, jclass cls, jint inst, jstring hostname, jint port, jstring username, jstring password, jstring domain) +{ + jni_freerdp_set_gateway_info(env, cls, inst, hostname, port, username, password, domain); +} + JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1update_1graphics( JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height) { diff --git a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h index 08188f700..1e6be8dff 100644 --- a/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h +++ b/client/Android/FreeRDPCore/jni/generated/com_freerdp_freerdpcore_services_LibFreeRDP.h @@ -95,6 +95,14 @@ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_ JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1drive_1redirection (JNIEnv *, jclass, jint, jstring); +/* + * Class: com_freerdp_freerdpcore_services_LibFreeRDP + * Method: freerdp_set_gateway_info + * Signature: (ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1set_1gateway_1info + (JNIEnv *, jclass, jint, jstring, jint, jstring, jstring, jstring); + /* * Class: com_freerdp_freerdpcore_services_LibFreeRDP * Method: freerdp_update_graphics diff --git a/client/Android/FreeRDPCore/res/values-es/strings.xml b/client/Android/FreeRDPCore/res/values-es/strings.xml index 93a16bdbf..cf9b933a9 100644 --- a/client/Android/FreeRDPCore/res/values-es/strings.xml +++ b/client/Android/FreeRDPCore/res/values-es/strings.xml @@ -105,6 +105,9 @@ <string name="settings_enable_3g_settings">Configuracion 3G</string> <string name="settings_screen_3g">Pantalla 3G</string> <string name="settings_performance_3g">Rendimiento 3G</string> + <string name="settings_cat_gateway">Gateway</string> + <string name="settings_enable_gateway_settings">Enable Gateway</string> + <string name="settings_gateway_settings">Gateway Settings</string> <string name="settings_redirect_sdcard">Redirect SDCard</string> <string name="settings_security">Seguridad</string> <string-array name="security_array"> diff --git a/client/Android/FreeRDPCore/res/values-fr/strings.xml b/client/Android/FreeRDPCore/res/values-fr/strings.xml index a55366019..3e0f1711f 100644 --- a/client/Android/FreeRDPCore/res/values-fr/strings.xml +++ b/client/Android/FreeRDPCore/res/values-fr/strings.xml @@ -104,6 +104,9 @@ <string name="settings_enable_3g_settings">"Paramètres 3G"</string> <string name="settings_screen_3g">"Écran 3G"</string> <string name="settings_performance_3g">"Performance 3G"</string> + <string name="settings_cat_gateway">Gateway</string> + <string name="settings_enable_gateway_settings">Enable Gateway</string> + <string name="settings_gateway_settings">Gateway Settings</string> <string name="settings_redirect_sdcard">"Redirect SDCard"</string> <string name="settings_security">"Securité"</string> <string-array name="security_array"> diff --git a/client/Android/FreeRDPCore/res/values/strings.xml b/client/Android/FreeRDPCore/res/values/strings.xml index 774e981d8..6110afd5d 100644 --- a/client/Android/FreeRDPCore/res/values/strings.xml +++ b/client/Android/FreeRDPCore/res/values/strings.xml @@ -105,6 +105,9 @@ <string name="settings_enable_3g_settings">3G Settings</string> <string name="settings_screen_3g">3G Screen</string> <string name="settings_performance_3g">3G Performance</string> + <string name="settings_cat_gateway">Gateway</string> + <string name="settings_enable_gateway_settings">Enable Gateway</string> + <string name="settings_gateway_settings">Gateway Settings</string> <string name="settings_redirect_sdcard">Redirect SDCard</string> <string name="settings_security">Security</string> <string-array name="security_array"> diff --git a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml index 7fdabd5e6..61cd61d19 100644 --- a/client/Android/FreeRDPCore/res/xml/advanced_settings.xml +++ b/client/Android/FreeRDPCore/res/xml/advanced_settings.xml @@ -12,8 +12,15 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="Advanced"> - <CheckBoxPreference android:key="bookmark.enable_3g_settings" android:title="@string/settings_enable_3g_settings" /> - + <CheckBoxPreference android:key="bookmark.enable_gateway_settings" android:title="@string/settings_enable_gateway_settings" /> + <PreferenceScreen android:key="bookmark.gateway_settings" android:title="@string/settings_gateway_settings"> + <intent android:action="android.intent.action.VIEW" + android:targetPackage="*" + android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity" + android:data="preferences://gateway_settings" /> + </PreferenceScreen> + + <CheckBoxPreference android:key="bookmark.enable_3g_settings" android:title="@string/settings_enable_3g_settings" /> <PreferenceScreen android:key="bookmark.screen_3g" android:title="@string/settings_screen_3g"> <intent android:action="android.intent.action.VIEW" android:targetPackage="*" diff --git a/client/Android/FreeRDPCore/res/xml/gateway_settings.xml b/client/Android/FreeRDPCore/res/xml/gateway_settings.xml new file mode 100644 index 000000000..207871251 --- /dev/null +++ b/client/Android/FreeRDPCore/res/xml/gateway_settings.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* + Credential Settings Layout + + Copyright 2013 Felix Long + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + --> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto"> + <PreferenceCategory android:title="@string/settings_cat_gateway"> + <EditTextPreference android:key="bookmark.gateway_hostname" android:title="@string/settings_hostname" android:summary="Name or address of the target computer"/> + <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.gateway_port" android:title="@string/settings_port" android:summary="Gateway Port on the target computer" android:numeric="integer" android:inputType="number" freerdp:bounds_min="10" freerdp:bounds_max="65535" freerdp:bounds_default="443" /> + <EditTextPreference android:key="bookmark.gateway_username" android:title="@string/settings_username"/> + <EditTextPreference android:key="bookmark.gateway_password" android:title="@string/settings_password" android:inputType="textPassword" /> + <EditTextPreference android:key="bookmark.gateway_domain" android:title="@string/settings_domain" android:summary="Optional"/> + </PreferenceCategory> +</PreferenceScreen> diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java index 81d9b717c..b8e3da862 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/domain/ManualBookmark.java @@ -15,14 +15,111 @@ import android.os.Parcelable; public class ManualBookmark extends BookmarkBase { + // Gateway Settings class + public static class GatewaySettings implements Parcelable + { + private String hostname; + private int port; + private String username; + private String password; + private String domain; + + public GatewaySettings() { + hostname = ""; + port = 443; + username = ""; + password = ""; + domain = ""; + } + + public GatewaySettings(Parcel parcel) { + hostname = parcel.readString(); + port = parcel.readInt(); + username = parcel.readString(); + password = parcel.readString(); + domain = parcel.readString(); + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public String getHostname() { + return hostname; + } + + public void setPort(int port) { + this.port = port; + } + + public int getPort() { + return port; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getUsername() { + return username; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return password; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getDomain() { + return domain; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) + { + out.writeString(hostname); + out.writeInt(port); + out.writeString(username); + out.writeString(password); + out.writeString(domain); + } + + public static final Parcelable.Creator<GatewaySettings> CREATOR = new Parcelable.Creator<GatewaySettings>() + { + public GatewaySettings createFromParcel(Parcel in) { + return new GatewaySettings(in); + } + + @Override + public GatewaySettings[] newArray(int size) { + return new GatewaySettings[size]; + } + }; + } + private String hostname; private int port; + private boolean enableGatewaySettings; + private GatewaySettings gatewaySettings; private void init() { type = TYPE_MANUAL; hostname = ""; - port = 3389; + port = 3389; + enableGatewaySettings = false; + gatewaySettings = new GatewaySettings(); } public ManualBookmark(Parcel parcel) @@ -31,6 +128,9 @@ public class ManualBookmark extends BookmarkBase type = TYPE_MANUAL; hostname = parcel.readString(); port = parcel.readInt(); + + enableGatewaySettings = (parcel.readInt() == 1 ? true : false); + gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader()); } public ManualBookmark() { @@ -53,7 +153,27 @@ public class ManualBookmark extends BookmarkBase public int getPort() { return port; } + + public boolean getEnableGatewaySettings() + { + return enableGatewaySettings; + } + + public void setEnableGatewaySettings(boolean enableGatewaySettings) + { + this.enableGatewaySettings = enableGatewaySettings; + } + + public GatewaySettings getGatewaySettings() + { + return gatewaySettings; + } + public void setGatewaySettings(GatewaySettings gatewaySettings) + { + this.gatewaySettings = gatewaySettings; + } + public static final Parcelable.Creator<ManualBookmark> CREATOR = new Parcelable.Creator<ManualBookmark>() { public ManualBookmark createFromParcel(Parcel in) { @@ -77,6 +197,8 @@ public class ManualBookmark extends BookmarkBase super.writeToParcel(out, flags); out.writeString(hostname); out.writeInt(port); + out.writeInt(enableGatewaySettings ? 1 : 0); + out.writeParcelable(gatewaySettings, flags); } @Override @@ -87,6 +209,12 @@ public class ManualBookmark extends BookmarkBase SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putString("bookmark.hostname", hostname); editor.putInt("bookmark.port", port); + editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings); + editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname()); + editor.putInt("bookmark.gateway_port", gatewaySettings.getPort()); + editor.putString("bookmark.gateway_username", gatewaySettings.getUsername()); + editor.putString("bookmark.gateway_password", gatewaySettings.getPassword()); + editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain()); editor.commit(); } @@ -97,6 +225,12 @@ public class ManualBookmark extends BookmarkBase hostname = sharedPrefs.getString("bookmark.hostname", ""); port = sharedPrefs.getInt("bookmark.port", 3389); + enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false); + gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", "")); + gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443)); + gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", "")); + gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", "")); + gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", "")); } // Cloneable diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java index 4d938f419..dbff71478 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java @@ -45,6 +45,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private static final int PREFERENCES_ADVANCED = 5; private static final int PREFERENCES_SCREEN3G = 6; private static final int PREFERENCES_PERFORMANCE3G = 7; + private static final int PREFERENCES_GATEWAY = 8; // bookmark needs to be static because the activity is started for each subview // (we have to do this because Android has a bug where the style for Preferences @@ -112,6 +113,13 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref if(bookmark == null) bookmark = new ManualBookmark(); + // hide gateway settings if we edit a non-manual bookmark + if (current_preferences == PREFERENCES_ADVANCED && bookmark.getType() != ManualBookmark.TYPE_MANUAL) + { + getPreferenceScreen().removePreference(findPreference("bookmark.enable_gateway")); + getPreferenceScreen().removePreference(findPreference("bookmark.gateway")); + } + // update preferences from bookmark bookmark.writeToSharedPreferences(getPreferenceManager().getSharedPreferences()); @@ -155,6 +163,11 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref addPreferencesFromResource(R.xml.credentials_settings); current_preferences = PREFERENCES_CREDENTIALS; } + else if (getIntent().getData().toString().equals("preferences://gateway_settings")) + { + addPreferencesFromResource(R.xml.gateway_settings); + current_preferences = PREFERENCES_GATEWAY; + } else { addPreferencesFromResource(R.xml.bookmark_settings); @@ -230,7 +243,8 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref "bookmark.performance", "bookmark.advanced", "bookmark.screen_3g", - "bookmark.performance_3g" + "bookmark.performance_3g", + "bookmark.gateway_settings" }; for (int i = 0; i < prefKeys.length; ++i) @@ -264,6 +278,10 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref case PREFERENCES_SCREEN3G: screenSettingsChanged(sharedPreferences, key); break; + + case PREFERENCES_GATEWAY: + gatewaySettingsChanged(sharedPreferences, key); + break; } } @@ -291,6 +309,10 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref case PREFERENCES_SCREEN3G: initScreenSettings3G(sharedPreferences); break; + + case PREFERENCES_GATEWAY: + initGatewaySettings(sharedPreferences); + break; } } @@ -332,6 +354,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void initAdvancedSettings(SharedPreferences sharedPreferences) { + advancedSettingsChanged(sharedPreferences, "bookmark.enable_gateway_settings"); advancedSettingsChanged(sharedPreferences, "bookmark.enable_3g_settings"); advancedSettingsChanged(sharedPreferences, "bookmark.security"); advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g"); @@ -341,7 +364,12 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void advancedSettingsChanged(SharedPreferences sharedPreferences, String key) { - if (key.equals("bookmark.enable_3g_settings")) + if (key.equals("bookmark.enable_gateway_settings")) + { + boolean enabled = sharedPreferences.getBoolean(key, false); + findPreference("bookmark.gateway_settings").setEnabled(enabled); + } + else if (key.equals("bookmark.enable_3g_settings")) { boolean enabled = sharedPreferences.getBoolean(key, false); findPreference("bookmark.screen_3g").setEnabled(enabled); @@ -441,6 +469,40 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 600))); } + private void initGatewaySettings(SharedPreferences sharedPreferences) + { + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password"); + gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain"); + } + + private void gatewaySettingsChanged(SharedPreferences sharedPreferences, String key) + { + if (key.equals("bookmark.gateway_hostname")) + { + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + else if (key.equals("bookmark.gateway_port")) + { + findPreference(key).setSummary(String.valueOf(sharedPreferences.getInt(key, 443))); + } + else if (key.equals("bookmark.gateway_username")) + { + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + else if (key.equals("bookmark.gateway_password")) + { + if (sharedPreferences.getString(key, "").length() == 0) + findPreference(key).setSummary(getResources().getString(R.string.settings_password_empty)); + else + findPreference(key).setSummary(getResources().getString(R.string.settings_password_present)); + } + else if (key.equals("bookmark.gateway_domain")) + findPreference(key).setSummary(sharedPreferences.getString(key, "")); + } + private boolean verifySettings(SharedPreferences sharedPreferences) { boolean verifyFailed = false; diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java index 61022b470..e54cc1502 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/BookmarkDB.java @@ -22,7 +22,7 @@ import android.database.sqlite.SQLiteOpenHelper; public class BookmarkDB extends SQLiteOpenHelper { - private static final int DB_VERSION = 2; + private static final int DB_VERSION = 3; private static final String DB_NAME = "bookmarks.db"; public static final String ID = BaseColumns._ID; @@ -130,6 +130,13 @@ public class BookmarkDB extends SQLiteOpenHelper + "screen_settings INTEGER NOT NULL, " + "performance_flags INTEGER NOT NULL, " + + "enable_gateway_settings INTEGER DEFAULT 0, " + + "gateway_hostname TEXT, " + + "gateway_port INTEGER DEFAULT 443, " + + "gateway_username TEXT, " + + "gateway_password TEXT, " + + "gateway_domain TEXT, " + + "enable_3g_settings INTEGER DEFAULT 0, " + "screen_3g INTEGER NOT NULL, " + "performance_3g INTEGER NOT NULL, " @@ -138,7 +145,7 @@ public class BookmarkDB extends SQLiteOpenHelper + "remote_program TEXT, " + "work_dir TEXT, " + "console_mode INTEGER, " - + + "FOREIGN KEY(screen_settings) REFERENCES tbl_screen_settings(" + ID + "), " + "FOREIGN KEY(performance_flags) REFERENCES tbl_performance_flags(" + ID + "), " + "FOREIGN KEY(screen_3g) REFERENCES tbl_screen_settings(" + ID + "), " diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java index 455d0a379..54de217c9 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -42,6 +42,9 @@ public class LibFreeRDP private static native void freerdp_set_clipboard_redirection(int inst, boolean enable); private static native void freerdp_set_drive_redirection(int inst, String path); + private static native void freerdp_set_gateway_info(int inst, String gatewayhostname, int port, + String gatewayusername, String gatewaypassword, String gatewaydomain); + private static native boolean freerdp_update_graphics(int inst, Bitmap bitmap, int x, int y, int width, int height); @@ -155,6 +158,14 @@ public class LibFreeRDP // always enable clipboard redirection freerdp_set_clipboard_redirection(inst, true); + // Gateway enabled? + if (bookmark.getType() == BookmarkBase.TYPE_MANUAL && bookmark.<ManualBookmark>get().getEnableGatewaySettings()) + { + ManualBookmark.GatewaySettings gatewaySettings = bookmark.<ManualBookmark>get().getGatewaySettings(); + freerdp_set_gateway_info(inst, gatewaySettings.getHostname(), gatewaySettings.getPort(), + gatewaySettings.getUsername(), gatewaySettings.getPassword(), gatewaySettings.getDomain()); + } + return true; } diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java index 6b07850ac..146631544 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/services/ManualBookmarkGateway.java @@ -39,12 +39,26 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { ManualBookmark bm = (ManualBookmark)bookmark; columns.put("hostname", bm.getHostname()); columns.put("port", bm.getPort()); + + // gateway settings + columns.put("enable_gateway_settings", bm.getEnableGatewaySettings()); + columns.put("gateway_hostname", bm.getGatewaySettings().getHostname()); + columns.put("gateway_port", bm.getGatewaySettings().getPort()); + columns.put("gateway_username", bm.getGatewaySettings().getUsername()); + columns.put("gateway_password", bm.getGatewaySettings().getPassword()); + columns.put("gateway_domain", bm.getGatewaySettings().getDomain()); } @Override protected void addBookmarkSpecificColumns(ArrayList<String> columns) { columns.add("hostname"); columns.add("port"); + columns.add("enable_gateway_settings"); + columns.add("gateway_hostname"); + columns.add("gateway_port"); + columns.add("gateway_username"); + columns.add("gateway_password"); + columns.add("gateway_domain"); } @Override @@ -52,8 +66,11 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { ManualBookmark bm = (ManualBookmark)bookmark; bm.setHostname(cursor.getString(cursor.getColumnIndex("hostname"))); bm.setPort(cursor.getInt(cursor.getColumnIndex("port"))); - } + bm.setEnableGatewaySettings(cursor.getInt(cursor.getColumnIndex("enable_gateway_settings")) == 0 ? false : true); + readGatewaySettings(bm, cursor); + } + public BookmarkBase findByLabelOrHostname(String pattern) { if(pattern.length() == 0) @@ -84,4 +101,14 @@ public class ManualBookmarkGateway extends BookmarkBaseGateway { cursor.close(); return bookmarks; } + + private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor) + { + ManualBookmark.GatewaySettings gatewaySettings = bookmark.getGatewaySettings(); + gatewaySettings.setHostname(cursor.getString(cursor.getColumnIndex("gateway_hostname"))); + gatewaySettings.setPort(cursor.getInt(cursor.getColumnIndex("gateway_port"))); + gatewaySettings.setUsername(cursor.getString(cursor.getColumnIndex("gateway_username"))); + gatewaySettings.setPassword(cursor.getString(cursor.getColumnIndex("gateway_password"))); + gatewaySettings.setDomain(cursor.getString(cursor.getColumnIndex("gateway_domain"))); + } } From 946d7ec58915eb9e8754bd769634ebc25ba5f49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 11:26:33 -0400 Subject: [PATCH 050/144] libfreerdp-core: fix compression with stream pool --- libfreerdp/core/fastpath.c | 35 +++++++++++++++----------- libfreerdp/core/message.c | 2 +- libfreerdp/core/rdp.c | 51 ++++++++++++++++++++------------------ 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 505b66b76..6e9741a99 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -299,15 +299,18 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) UINT32 rlen; rdpRdp* rdp; int next_pos; + BYTE* buffer; + wStream* cs; UINT32 totalSize; BYTE updateCode; BYTE fragmentation; BYTE compression; BYTE compressionFlags; - wStream* comp_stream; + rdpTransport* transport; status = 0; rdp = fastpath->rdp; + transport = fastpath->rdp->transport; fastpath_read_update_header(s, &updateCode, &fragmentation, &compression); @@ -321,18 +324,22 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (Stream_GetRemainingLength(s) < size) return -1; + cs = s; next_pos = Stream_GetPosition(s) + size; - comp_stream = s; if (compressionFlags & PACKET_COMPRESSED) { if (decompress_rdp(rdp->mppc_dec, s->pointer, size, compressionFlags, &roff, &rlen)) { - comp_stream = stream_new(0); - comp_stream->buffer = rdp->mppc_dec->history_buf + roff; - comp_stream->pointer = comp_stream->buffer; - comp_stream->capacity = rlen; - size = comp_stream->capacity; + size = rlen; + buffer = rdp->mppc_dec->history_buf + roff; + + cs = StreamPool_Take(transport->ReceivePool, size); + + Stream_SetPosition(cs, 0); + Stream_Write(cs, buffer, size); + Stream_SealLength(cs); + Stream_SetPosition(cs, 0); } else { @@ -350,15 +357,13 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) } totalSize = size; - status = fastpath_recv_update(fastpath, updateCode, totalSize, comp_stream); + status = fastpath_recv_update(fastpath, updateCode, totalSize, cs); if (status < 0) return -1; } else { - rdpTransport* transport = fastpath->rdp->transport; - if (fragmentation == FASTPATH_FRAGMENT_FIRST) { if (fastpath->fragmentation != -1) @@ -381,7 +386,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) fastpath->updateData = StreamPool_Take(transport->ReceivePool, size); Stream_SetPosition(fastpath->updateData, 0); - Stream_Copy(fastpath->updateData, comp_stream, size); + Stream_Copy(fastpath->updateData, cs, size); } else if (fragmentation == FASTPATH_FRAGMENT_NEXT) { @@ -405,7 +410,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) Stream_EnsureCapacity(fastpath->updateData, totalSize); - Stream_Copy(fastpath->updateData, comp_stream, size); + Stream_Copy(fastpath->updateData, cs, size); } else if (fragmentation == FASTPATH_FRAGMENT_LAST) { @@ -429,7 +434,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) Stream_EnsureCapacity(fastpath->updateData, totalSize); - Stream_Copy(fastpath->updateData, comp_stream, size); + Stream_Copy(fastpath->updateData, cs, size); Stream_SealLength(fastpath->updateData); Stream_SetPosition(fastpath->updateData, 0); @@ -445,8 +450,8 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) Stream_SetPosition(s, next_pos); - if (comp_stream != s) - free(comp_stream); + if (cs != s) + Stream_Release(cs); return status; } diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 0c27bd5e2..3ccea28d3 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -31,7 +31,7 @@ #include <winpr/stream.h> #include <winpr/collections.h> -#define WITH_STREAM_POOL 1 +//#define WITH_STREAM_POOL 1 /* Update */ diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 5f328b2fd..6e9534ce5 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -80,7 +80,7 @@ static const char* const DATA_PDU_TYPE_STRINGS[] = BOOL rdp_read_security_header(wStream* s, UINT16* flags) { /* Basic Security Header */ - if(Stream_GetRemainingLength(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; stream_read_UINT16(s, *flags); /* flags */ Stream_Seek(s, 2); /* flagsHi (unused) */ @@ -262,13 +262,13 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id return TRUE; } - if(Stream_GetRemainingLength(s) < 5) + if (Stream_GetRemainingLength(s) < 5) return FALSE; per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */ per_read_integer16(s, channel_id, 0); /* channelId */ Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */ - if(!per_read_length(s, length)) /* userData (OCTET_STRING) */ + if (!per_read_length(s, length)) /* userData (OCTET_STRING) */ return FALSE; if (*length > Stream_GetRemainingLength(s)) return FALSE; @@ -504,18 +504,19 @@ BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s) int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) { BYTE type; + UINT32 roff; + UINT32 rlen; + wStream* cs; + BYTE* buffer; UINT16 length; UINT32 share_id; BYTE compressed_type; UINT16 compressed_len; - UINT32 roff; - UINT32 rlen; - wStream* comp_stream; if (!rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len)) return -1; - comp_stream = s; + cs = s; if (compressed_type & PACKET_COMPRESSED) { @@ -524,18 +525,23 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) fprintf(stderr, "decompress_rdp: not enough bytes for compressed_len=%d\n", compressed_len); return -1; } + if (decompress_rdp(rdp->mppc_dec, s->pointer, compressed_len - 18, compressed_type, &roff, &rlen)) { - comp_stream = stream_new(0); - comp_stream->buffer = rdp->mppc_dec->history_buf + roff; - comp_stream->pointer = comp_stream->buffer; - comp_stream->capacity = rlen; + buffer = rdp->mppc_dec->history_buf + roff; + cs = StreamPool_Take(rdp->transport->ReceivePool, rlen); + + Stream_SetPosition(cs, 0); + Stream_Write(cs, buffer, rlen); + Stream_SealLength(cs); + Stream_SetPosition(cs, 0); } else { fprintf(stderr, "decompress_rdp() failed\n"); return -1; } + Stream_Seek(s, compressed_len - 18); } @@ -548,17 +554,17 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) switch (type) { case DATA_PDU_TYPE_UPDATE: - if (!update_recv(rdp->update, comp_stream)) + if (!update_recv(rdp->update, cs)) return -1; break; case DATA_PDU_TYPE_CONTROL: - if (!rdp_recv_server_control_pdu(rdp, comp_stream)) + if (!rdp_recv_server_control_pdu(rdp, cs)) return -1; break; case DATA_PDU_TYPE_POINTER: - if (!update_recv_pointer(rdp->update, comp_stream)) + if (!update_recv_pointer(rdp->update, cs)) return -1; break; @@ -566,7 +572,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; case DATA_PDU_TYPE_SYNCHRONIZE: - if (!rdp_recv_synchronize_pdu(rdp, comp_stream)) + if (!rdp_recv_synchronize_pdu(rdp, cs)) return -1; break; @@ -574,7 +580,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; case DATA_PDU_TYPE_PLAY_SOUND: - if (!update_recv_play_sound(rdp->update, comp_stream)) + if (!update_recv_play_sound(rdp->update, cs)) return -1; break; @@ -588,7 +594,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; case DATA_PDU_TYPE_SAVE_SESSION_INFO: - if(!rdp_recv_save_session_info(rdp, comp_stream)) + if (!rdp_recv_save_session_info(rdp, cs)) return -1; break; @@ -596,7 +602,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; case DATA_PDU_TYPE_FONT_MAP: - if(!rdp_recv_font_map_pdu(rdp, comp_stream)) + if (!rdp_recv_font_map_pdu(rdp, cs)) return -1; break; @@ -616,7 +622,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; case DATA_PDU_TYPE_SET_ERROR_INFO: - if (!rdp_recv_set_error_info_data_pdu(rdp, comp_stream)) + if (!rdp_recv_set_error_info_data_pdu(rdp, cs)) return -1; break; @@ -639,11 +645,8 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) break; } - if (comp_stream != s) - { - stream_detach(comp_stream); - stream_free(comp_stream); - } + if (cs != s) + Stream_Release(cs); return 0; } From 3b71f172dc412cd50f9e323fa36b389361c0617f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 12:20:03 -0400 Subject: [PATCH 051/144] libfreerdp-core: enable stream pool by default --- libfreerdp/core/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 3ccea28d3..0c27bd5e2 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -31,7 +31,7 @@ #include <winpr/stream.h> #include <winpr/collections.h> -//#define WITH_STREAM_POOL 1 +#define WITH_STREAM_POOL 1 /* Update */ From 601b0c7f8c8d8118665d7f9a232e574e7d74002f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 15:18:26 -0400 Subject: [PATCH 052/144] wfreerdp: update client interface --- client/Windows/wf_interface.c | 15 +++++++++++++++ client/Windows/wf_interface.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/client/Windows/wf_interface.c b/client/Windows/wf_interface.c index 09c465e88..1f22fb34e 100644 --- a/client/Windows/wf_interface.c +++ b/client/Windows/wf_interface.c @@ -829,6 +829,21 @@ int freerdp_client_stop(wfInfo* wfi) return 0; } +HANDLE freerdp_client_get_thread(wfInfo* cfi) +{ + return cfi->thread; +} + +freerdp* freerdp_client_get_instance(wfInfo* cfi) +{ + return cfi->instance; +} + +rdpClient* freerdp_client_get_interface(wfInfo* cfi) +{ + return cfi->client; +} + int freerdp_client_focus_in(wfInfo* wfi) { PostThreadMessage(wfi->mainThreadId, WM_SETFOCUS, 0, 1); diff --git a/client/Windows/wf_interface.h b/client/Windows/wf_interface.h index 16891db82..fc5031d59 100644 --- a/client/Windows/wf_interface.h +++ b/client/Windows/wf_interface.h @@ -129,6 +129,10 @@ FREERDP_API int freerdp_client_global_uninit(); FREERDP_API int freerdp_client_start(wfInfo* cfi); FREERDP_API int freerdp_client_stop(wfInfo* cfi); +FREERDP_API HANDLE freerdp_client_get_thread(wfInfo* cfi); +FREERDP_API freerdp* freerdp_client_get_instance(wfInfo* cfi); +FREERDP_API rdpClient* freerdp_client_get_interface(wfInfo* cfi); + FREERDP_API int freerdp_client_focus_in(wfInfo* cfi); FREERDP_API int freerdp_client_focus_out(wfInfo* cfi); From e88b59c32c4bdfab4b819d84b40693920f229367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 17:16:38 -0400 Subject: [PATCH 053/144] libfreerdp-core: improve async-transport mode --- client/X11/xf_interface.c | 8 +++--- libfreerdp/core/tcp.c | 15 ++++++++++- libfreerdp/core/tcp.h | 4 +++ libfreerdp/core/transport.c | 50 ++++++++++++++++++++++++++---------- libfreerdp/core/transport.h | 1 + winpr/include/winpr/synch.h | 2 ++ winpr/libwinpr/synch/event.c | 25 ++++++++++++++++++ 7 files changed, 87 insertions(+), 18 deletions(-) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 775f428a1..ce4c26d01 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -106,9 +106,9 @@ void xf_sw_end_paint(rdpContext* context) xfi = ((xfContext*) context)->xfi; gdi = context->gdi; - if (xfi->remote_app != TRUE) + if (!xfi->remote_app) { - if (xfi->complex_regions != TRUE) + if (!xfi->complex_regions) { if (gdi->primary->hdc->hwnd->invalid->null) return; @@ -183,7 +183,7 @@ void xf_sw_desktop_resize(rdpContext* context) xf_lock_x11(xfi, TRUE); - if (xfi->fullscreen != TRUE) + if (!xfi->fullscreen) { rdpGdi* gdi = context->gdi; gdi_resize(gdi, xfi->width, xfi->height); @@ -293,7 +293,7 @@ void xf_hw_desktop_resize(rdpContext* context) xf_lock_x11(xfi, TRUE); - if (xfi->fullscreen != TRUE) + if (!xfi->fullscreen) { xfi->width = settings->DesktopWidth; xfi->height = settings->DesktopHeight; diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index cb63b4241..a9331106a 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -134,6 +134,8 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, UINT16 port) if (tcp->sockfd < 0) return FALSE; + SetEventFileDescriptor(tcp->event, tcp->sockfd); + tcp_get_ip_address(tcp); tcp_get_mac_address(tcp); @@ -248,6 +250,15 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp) return TRUE; } +HANDLE tcp_get_event_handle(rdpTcp* tcp) +{ +#ifndef _WIN32 + return tcp->event; +#else + return (HANDLE) tcp->wsa_event; +#endif +} + rdpTcp* tcp_new(rdpSettings* settings) { rdpTcp* tcp; @@ -260,6 +271,7 @@ rdpTcp* tcp_new(rdpSettings* settings) tcp->sockfd = -1; tcp->settings = settings; + tcp->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, tcp->sockfd); } return tcp; @@ -267,8 +279,9 @@ rdpTcp* tcp_new(rdpSettings* settings) void tcp_free(rdpTcp* tcp) { - if (tcp != NULL) + if (tcp) { + CloseHandle(tcp->event); free(tcp); } } diff --git a/libfreerdp/core/tcp.h b/libfreerdp/core/tcp.h index baede4524..539d77673 100644 --- a/libfreerdp/core/tcp.h +++ b/libfreerdp/core/tcp.h @@ -26,6 +26,8 @@ #include <freerdp/types.h> #include <freerdp/settings.h> +#include <winpr/crt.h> +#include <winpr/synch.h> #include <winpr/stream.h> #ifndef MSG_NOSIGNAL @@ -43,6 +45,7 @@ struct rdp_tcp #ifdef _WIN32 WSAEVENT wsa_event; #endif + HANDLE event; }; BOOL tcp_connect(rdpTcp* tcp, const char* hostname, UINT16 port); @@ -53,6 +56,7 @@ int tcp_wait_read(rdpTcp* tcp); int tcp_wait_write(rdpTcp* tcp); BOOL tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking); BOOL tcp_set_keep_alive_mode(rdpTcp* tcp); +HANDLE tcp_get_event_handle(rdpTcp* tcp); rdpTcp* tcp_new(rdpSettings* settings); void tcp_free(rdpTcp* tcp); diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index a2a2b7e8f..51f5d9108 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -568,6 +568,7 @@ int transport_write(rdpTransport* transport, wStream* s) return status; } + void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount) { void* pfd; @@ -612,6 +613,30 @@ void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount) } } +void transport_get_read_handles(rdpTransport* transport, HANDLE* events, DWORD* count) +{ + events[*count] = tcp_get_event_handle(transport->TcpIn); + (*count)++; + + if (transport->SplitInputOutput) + { + events[*count] = tcp_get_event_handle(transport->TcpOut); + (*count)++; + } + + if (transport->ReceiveEvent) + { + events[*count] = transport->ReceiveEvent; + (*count)++; + } + + if (transport->GatewayEvent) + { + events[*count] = transport->GatewayEvent; + (*count)++; + } +} + int transport_check_fds(rdpTransport** ptransport) { int pos; @@ -763,22 +788,26 @@ static void* transport_client_thread(void* arg) { DWORD status; DWORD nCount; - HANDLE events[3]; - HANDLE ReadEvent; + HANDLE events[32]; freerdp* instance; rdpTransport* transport; transport = (rdpTransport*) arg; instance = (freerdp*) transport->settings->instance; - ReadEvent = CreateFileDescriptorEvent(NULL, TRUE, FALSE, transport->TcpIn->sockfd); + /** + * Ugly temporary hack to start thread after connection + */ - nCount = 0; - events[nCount++] = transport->stopEvent; - events[nCount++] = ReadEvent; + Sleep(2000); while (1) { + nCount = 0; + events[nCount++] = transport->stopEvent; + + transport_get_read_handles(transport, (HANDLE*) &events, &nCount); + status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0) @@ -786,15 +815,10 @@ static void* transport_client_thread(void* arg) break; } - if (WaitForSingleObject(ReadEvent, 0) == WAIT_OBJECT_0) - { - if (!freerdp_check_fds(instance)) - break; - } + if (!freerdp_check_fds(instance)) + break; } - CloseHandle(ReadEvent); - return NULL; } diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 67a2e2783..831291c1b 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -92,6 +92,7 @@ int transport_write(rdpTransport* transport, wStream* s); void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount); int transport_check_fds(rdpTransport** ptransport); BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking); +void transport_get_read_handles(rdpTransport* transport, HANDLE* events, DWORD* count); wStream* transport_receive_pool_take(rdpTransport* transport); int transport_receive_pool_return(rdpTransport* transport, wStream* pdu); diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h index dd9bd13b4..c9bb0ad39 100644 --- a/winpr/include/winpr/synch.h +++ b/winpr/include/winpr/synch.h @@ -273,6 +273,8 @@ WINPR_API HANDLE CreateWaitObjectEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, #endif WINPR_API int GetEventFileDescriptor(HANDLE hEvent); +WINPR_API int SetEventFileDescriptor(HANDLE hEvent, int FileDescriptor); + WINPR_API void* GetEventWaitObject(HANDLE hEvent); #ifdef __cplusplus diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 7298cb56c..8eb8a4aec 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -273,6 +273,31 @@ int GetEventFileDescriptor(HANDLE hEvent) #endif } +/* + * Set inner file descriptor for usage with select() + * This file descriptor is not usable on Windows + */ + +int SetEventFileDescriptor(HANDLE hEvent, int FileDescriptor) +{ +#ifndef _WIN32 + ULONG Type; + PVOID Object; + WINPR_EVENT* event; + + if (!winpr_Handle_GetInfo(hEvent, &Type, &Object)) + return -1; + + event = (WINPR_EVENT*) Object; + + event->pipe_fd[0] = FileDescriptor; + + return 0; +#else + return -1; +#endif +} + /** * Returns platform-specific wait object as a void pointer * From 8b617cd794a9fc46dccbdd3c1819c5cdc37a54bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 30 Apr 2013 18:25:18 -0400 Subject: [PATCH 054/144] libfreerdp-core: synchronize transport thread --- libfreerdp/core/freerdp.c | 9 ++++++--- libfreerdp/core/transport.c | 19 +++++++++++++------ libfreerdp/core/transport.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 6533f89a0..68b4c9569 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -73,7 +73,7 @@ BOOL freerdp_connect(freerdp* instance) extension_load_and_init_plugins(rdp->extension); extension_pre_connect(rdp->extension); - if (status != TRUE) + if (!status) { if (!connectErrorCode) { @@ -84,6 +84,7 @@ BOOL freerdp_connect(freerdp* instance) } status = rdp_client_connect(rdp); + /* --authonly tests the connection without a UI */ if (instance->settings->AuthenticationOnly) { @@ -105,7 +106,7 @@ BOOL freerdp_connect(freerdp* instance) IFCALLRET(instance->PostConnect, status, instance); update_post_connect(instance->update); - if (status != TRUE) + if (!status) { fprintf(stderr, "freerdp_post_connect failed\n"); @@ -156,7 +157,9 @@ BOOL freerdp_connect(freerdp* instance) { connectErrorCode = UNDEFINEDCONNECTERROR; } - + + SetEvent(rdp->transport->connectedEvent); + return status; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 51f5d9108..77bac1541 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -795,17 +795,20 @@ static void* transport_client_thread(void* arg) transport = (rdpTransport*) arg; instance = (freerdp*) transport->settings->instance; - /** - * Ugly temporary hack to start thread after connection - */ - - Sleep(2000); - while (1) { nCount = 0; events[nCount++] = transport->stopEvent; + events[nCount] = transport->connectedEvent; + + status = WaitForMultipleObjects(nCount + 1, events, FALSE, INFINITE); + + if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0) + { + break; + } + transport_get_read_handles(transport, (HANDLE*) &events, &nCount); status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); @@ -845,6 +848,8 @@ rdpTransport* transport_new(rdpSettings* settings) transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0); transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + /* buffers for blocking read/write */ transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0); transport->SendStream = stream_new(BUFFER_SIZE); @@ -872,6 +877,8 @@ void transport_free(rdpTransport* transport) stream_free(transport->SendStream); CloseHandle(transport->ReceiveEvent); + CloseHandle(transport->connectedEvent); + if (transport->TlsIn) tls_free(transport->TlsIn); diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 831291c1b..072ca7b9f 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -70,6 +70,7 @@ struct rdp_transport BOOL blocking; BOOL SplitInputOutput; wStreamPool* ReceivePool; + HANDLE connectedEvent; HANDLE stopEvent; HANDLE thread; BOOL async; From b4cac741363328d2ec4b4f8b04801993fb495d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 18:15:55 -0400 Subject: [PATCH 055/144] xfreerdp-server: fix RemoteFX encoding --- channels/audin/client/audin_main.c | 2 +- channels/audin/server/audin.c | 9 ++-- channels/cliprdr/client/cliprdr_format.c | 2 +- channels/drive/client/drive_file.c | 14 +++--- channels/drive/client/drive_main.c | 12 ++--- channels/parallel/client/parallel_main.c | 2 +- channels/rdpdr/client/rdpdr_main.c | 2 +- channels/rdpsnd/server/rdpsnd.c | 4 +- channels/serial/client/serial_main.c | 2 +- channels/server/channels.c | 6 +-- .../smartcard/client/smartcard_operations.c | 2 +- channels/tsmf/client/tsmf_ifman.c | 18 +++---- libfreerdp/codec/nsc_encode.c | 4 +- libfreerdp/codec/rfx.c | 12 ++--- libfreerdp/codec/rfx_encode.c | 6 +-- libfreerdp/core/channel.c | 2 +- libfreerdp/core/fastpath.c | 43 ++++++++++++++--- libfreerdp/core/surface.c | 4 +- libfreerdp/core/transport.c | 6 +-- libfreerdp/core/update.c | 7 +-- libfreerdp/utils/rail.c | 4 +- libfreerdp/utils/svc_plugin.c | 2 +- server/Mac/mf_peer.c | 2 +- server/Sample/sfreerdp.c | 4 +- server/Windows/wf_update.c | 2 +- server/X11/xf_peer.c | 7 +-- winpr/include/winpr/stream.h | 9 ++-- winpr/libwinpr/utils/stream.c | 47 ++++++------------- 28 files changed, 126 insertions(+), 110 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 50c8f1387..bf409e043 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -175,7 +175,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w /* Store the agreed format in the corresponding index */ callback->formats[callback->formats_count++] = format; /* Put the format to output buffer */ - stream_check_size(out, 18 + format.cbSize); + Stream_EnsureRemainingCapacity(out, 18 + format.cbSize); stream_write(out, fm, 18 + format.cbSize); } } diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index c5d00bc9d..88b8e8f77 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -111,7 +111,9 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) nAvgBytesPerSec = audin->context.server_formats[i].nSamplesPerSec * audin->context.server_formats[i].nChannels * audin->context.server_formats[i].wBitsPerSample / 8; - stream_check_size(s, 18); + + Stream_EnsureRemainingCapacity(s, 18); + stream_write_UINT16(s, audin->context.server_formats[i].wFormatTag); stream_write_UINT16(s, audin->context.server_formats[i].nChannels); stream_write_UINT32(s, audin->context.server_formats[i].nSamplesPerSec); @@ -119,9 +121,10 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) stream_write_UINT16(s, audin->context.server_formats[i].nBlockAlign); stream_write_UINT16(s, audin->context.server_formats[i].wBitsPerSample); stream_write_UINT16(s, audin->context.server_formats[i].cbSize); + if (audin->context.server_formats[i].cbSize) { - stream_check_size(s, audin->context.server_formats[i].cbSize); + Stream_EnsureRemainingCapacity(s, audin->context.server_formats[i].cbSize); stream_write(s, audin->context.server_formats[i].data, audin->context.server_formats[i].cbSize); } @@ -333,7 +336,7 @@ static void* audin_server_thread_func(void* arg) if (bytes_returned == 0) break; - stream_check_size(s, (int) bytes_returned); + Stream_EnsureRemainingCapacity(s, (int) bytes_returned); if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s), Stream_Capacity(s), &bytes_returned) == FALSE) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 373c2abcd..4fa404675 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -87,7 +87,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS if (!cliprdr->use_long_format_names) name_length = 32; - stream_extend(body, Stream_Capacity(body) + 4 + name_length); + Stream_EnsureRemainingCapacity(body, Stream_Capacity(body) + 4 + name_length); stream_write_UINT32(body, cb_event->formats[i]); stream_write(body, name, name_length); diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 8c1006eed..9d4f35195 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -391,7 +391,7 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w case FileBasicInformation: /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */ stream_write_UINT32(output, 36); /* Length */ - stream_check_size(output, 36); + Stream_EnsureRemainingCapacity(output, 36); stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ @@ -403,7 +403,7 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w case FileStandardInformation: /* http://msdn.microsoft.com/en-us/library/cc232088.aspx */ stream_write_UINT32(output, 22); /* Length */ - stream_check_size(output, 22); + Stream_EnsureRemainingCapacity(output, 22); stream_write_UINT64(output, st.st_size); /* AllocationSize */ stream_write_UINT64(output, st.st_size); /* EndOfFile */ stream_write_UINT32(output, st.st_nlink); /* NumberOfLinks */ @@ -415,7 +415,7 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w case FileAttributeTagInformation: /* http://msdn.microsoft.com/en-us/library/cc232093.aspx */ stream_write_UINT32(output, 8); /* Length */ - stream_check_size(output, 8); + Stream_EnsureRemainingCapacity(output, 8); stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ stream_write_UINT32(output, 0); /* ReparseTag */ break; @@ -616,7 +616,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT case FileDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232097.aspx */ stream_write_UINT32(output, 64 + length); /* Length */ - stream_check_size(output, 64 + length); + Stream_EnsureRemainingCapacity(output, 64 + length); stream_write_UINT32(output, 0); /* NextEntryOffset */ stream_write_UINT32(output, 0); /* FileIndex */ stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -633,7 +633,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT case FileFullDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232068.aspx */ stream_write_UINT32(output, 68 + length); /* Length */ - stream_check_size(output, 68 + length); + Stream_EnsureRemainingCapacity(output, 68 + length); stream_write_UINT32(output, 0); /* NextEntryOffset */ stream_write_UINT32(output, 0); /* FileIndex */ stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -651,7 +651,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT case FileBothDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232095.aspx */ stream_write_UINT32(output, 93 + length); /* Length */ - stream_check_size(output, 93 + length); + Stream_EnsureRemainingCapacity(output, 93 + length); stream_write_UINT32(output, 0); /* NextEntryOffset */ stream_write_UINT32(output, 0); /* FileIndex */ stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -672,7 +672,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT case FileNamesInformation: /* http://msdn.microsoft.com/en-us/library/cc232077.aspx */ stream_write_UINT32(output, 12 + length); /* Length */ - stream_check_size(output, 12 + length); + Stream_EnsureRemainingCapacity(output, 12 + length); stream_write_UINT32(output, 0); /* NextEntryOffset */ stream_write_UINT32(output, 0); /* FileIndex */ stream_write_UINT32(output, length); /* FileNameLength */ diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 015e1f125..1c728543a 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -267,7 +267,7 @@ static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp) if (Length > 0) { - stream_check_size(irp->output, (int) Length); + Stream_EnsureRemainingCapacity(irp->output, (int) Length); stream_write(irp->output, buffer, Length); } @@ -405,7 +405,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */ length = ConvertToUnicode(CP_UTF8, 0, volumeLabel, -1, &outStr, 0) * 2; stream_write_UINT32(output, 17 + length); /* Length */ - stream_check_size(output, 17 + length); + Stream_EnsureRemainingCapacity(output, 17 + length); stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ #ifdef ANDROID stream_write_UINT32(output, svfst.f_fsid.__val[0]); /* VolumeSerialNumber */ @@ -422,7 +422,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* case FileFsSizeInformation: /* http://msdn.microsoft.com/en-us/library/cc232107.aspx */ stream_write_UINT32(output, 24); /* Length */ - stream_check_size(output, 24); + Stream_EnsureRemainingCapacity(output, 24); stream_write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ stream_write_UINT64(output, svfst.f_bavail); /* AvailableAllocationUnits */ stream_write_UINT32(output, 1); /* SectorsPerAllocationUnit */ @@ -433,7 +433,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */ length = ConvertToUnicode(CP_UTF8, 0, diskType, -1, &outStr, 0) * 2; stream_write_UINT32(output, 12 + length); /* Length */ - stream_check_size(output, 12 + length); + Stream_EnsureRemainingCapacity(output, 12 + length); stream_write_UINT32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | @@ -451,7 +451,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* case FileFsFullSizeInformation: /* http://msdn.microsoft.com/en-us/library/cc232104.aspx */ stream_write_UINT32(output, 32); /* Length */ - stream_check_size(output, 32); + Stream_EnsureRemainingCapacity(output, 32); stream_write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ stream_write_UINT64(output, svfst.f_bavail); /* CallerAvailableAllocationUnits */ stream_write_UINT64(output, svfst.f_bfree); /* AvailableAllocationUnits */ @@ -462,7 +462,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* case FileFsDeviceInformation: /* http://msdn.microsoft.com/en-us/library/cc232109.aspx */ stream_write_UINT32(output, 8); /* Length */ - stream_check_size(output, 8); + Stream_EnsureRemainingCapacity(output, 8); stream_write_UINT32(output, FILE_DEVICE_DISK); /* DeviceType */ stream_write_UINT32(output, 0); /* Characteristics */ break; diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index f785475da..449c0f384 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -157,7 +157,7 @@ static void parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp) if (Length > 0) { - stream_check_size(irp->output, Length); + Stream_EnsureRemainingCapacity(irp->output, Length); stream_write(irp->output, buffer, Length); } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 662aa0624..2efac7afa 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -176,7 +176,7 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use (device->type == RDPDR_DTYP_SMARTCARD) || user_loggedon) { data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data)); - stream_check_size(data_out, 20 + data_len); + Stream_EnsureRemainingCapacity(data_out, 20 + data_len); stream_write_UINT32(data_out, device->type); /* deviceType */ stream_write_UINT32(data_out, device->id); /* deviceID */ diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index 4c2f88caf..6beb25d77 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -224,7 +224,7 @@ static void* rdpsnd_server_thread_func(void* arg) if (bytes_returned == 0) break; - stream_check_size(s, (int) bytes_returned); + Stream_EnsureRemainingCapacity(s, (int) bytes_returned); if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s), Stream_Capacity(s), &bytes_returned) == FALSE) @@ -414,7 +414,7 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) Stream_SetPosition(s, 0); /* Wave PDU */ - stream_check_size(s, size + fill_size); + Stream_EnsureRemainingCapacity(s, size + fill_size); stream_write_UINT32(s, 0); /* bPad */ stream_write(s, src + 4, size - 4); diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index ec6e5abea..dd9848559 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -193,7 +193,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp) if (Length > 0) { - stream_check_size(irp->output, Length); + Stream_EnsureRemainingCapacity(irp->output, Length); stream_write(irp->output, buffer, Length); } diff --git a/channels/server/channels.c b/channels/server/channels.c index e7a41f912..ddea61d95 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -206,7 +206,7 @@ static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int return; Stream_SetPosition(channel->receive_data, 0); - stream_check_size(channel->receive_data, (int) channel->dvc_total_length); + Stream_EnsureRemainingCapacity(channel->receive_data, (int) channel->dvc_total_length); stream_write(channel->receive_data, Stream_Pointer(s), length); } @@ -356,7 +356,7 @@ static void wts_write_drdynvc_create_request(wStream *s, UINT32 ChannelId, const wts_write_drdynvc_header(s, CREATE_REQUEST_PDU, ChannelId); len = strlen(ChannelName) + 1; - stream_check_size(s, (int) len); + Stream_EnsureRemainingCapacity(s, (int) len); stream_write(s, ChannelName, len); } @@ -367,7 +367,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* Stream_SetPosition(channel->receive_data, 0); } - stream_check_size(channel->receive_data, size); + Stream_EnsureRemainingCapacity(channel->receive_data, size); stream_write(channel->receive_data, data, size); if (flags & CHANNEL_FLAG_LAST) diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index fe2603202..0c9fe71a6 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -1395,7 +1395,7 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) // Stream_Seek(irp->input, 4); /* rpce len */ /* [MS-RDPESC] 3.2.5.1 Sending Outgoing Messages */ - stream_extend(irp->output, 2048); + Stream_EnsureRemainingCapacity(irp->output, 2048); irp_result_pos = Stream_GetPosition(irp->output); diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index aeee1c591..5de7dea13 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -44,7 +44,7 @@ int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman) stream_read_UINT32(ifman->input, CapabilityValue); DEBUG_DVC("server CapabilityValue %d", CapabilityValue); - stream_check_size(ifman->output, 8); + Stream_EnsureRemainingCapacity(ifman->output, 8); stream_write_UINT32(ifman->output, 1); /* CapabilityValue */ stream_write_UINT32(ifman->output, 0); /* Result */ @@ -61,7 +61,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) UINT32 numHostCapabilities; pos = Stream_GetPosition(ifman->output); - stream_check_size(ifman->output, ifman->input_size + 4); + Stream_EnsureRemainingCapacity(ifman->output, ifman->input_size + 4); stream_copy(ifman->output, ifman->input, ifman->input_size); Stream_SetPosition(ifman->output, pos); @@ -117,7 +117,7 @@ int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman) if (FormatSupported) DEBUG_DVC("format ok."); - stream_check_size(ifman->output, 12); + Stream_EnsureRemainingCapacity(ifman->output, 12); stream_write_UINT32(ifman->output, FormatSupported); stream_write_UINT32(ifman->output, PlatformCookie); stream_write_UINT32(ifman->output, 0); /* Result */ @@ -191,7 +191,7 @@ int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman) { DEBUG_DVC(""); - stream_check_size(ifman->output, 8); + Stream_EnsureRemainingCapacity(ifman->output, 8); stream_write_UINT32(ifman->output, 1); /* TopologyReady */ stream_write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; @@ -243,7 +243,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) pexisted = 0; - stream_check_size(ifman->output, 4); + Stream_EnsureRemainingCapacity(ifman->output, 4); stream_write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; @@ -489,7 +489,7 @@ int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) } DEBUG_DVC("StreamId %d", StreamId); - stream_check_size(ifman->output, 16); + Stream_EnsureRemainingCapacity(ifman->output, 16); stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ stream_write_UINT32(ifman->output, StreamId); /* StreamId */ stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */ @@ -512,7 +512,7 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman) else DEBUG_WARN("unknown presentation id"); - stream_check_size(ifman->output, 16); + Stream_EnsureRemainingCapacity(ifman->output, 16); stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ stream_write_UINT32(ifman->output, 0); /* StreamId */ stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */ @@ -573,7 +573,7 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) else DEBUG_WARN("unknown presentation id"); - stream_check_size(ifman->output, 16); + Stream_EnsureRemainingCapacity(ifman->output, 16); stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ stream_write_UINT32(ifman->output, 0); /* StreamId */ stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */ @@ -587,7 +587,7 @@ int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman) { DEBUG_DVC(""); - stream_check_size(ifman->output, 16); + Stream_EnsureRemainingCapacity(ifman->output, 16); stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ stream_write_UINT32(ifman->output, 0); /* StreamId */ stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */ diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index 36c1988e9..d47fb6670 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -349,7 +349,7 @@ void nsc_compose_message(NSC_CONTEXT* context, wStream* s, PROFILER_EXIT(context->priv->prof_nsc_rle_compress_data); /* Assemble the NSCodec message into stream */ - stream_check_size(s, 20); + Stream_EnsureRemainingCapacity(s, 20); stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[0]); /* LumaPlaneByteCount (4 bytes) */ stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[1]); /* OrangeChromaPlaneByteCount (4 bytes) */ stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[2]); /* GreenChromaPlaneByteCount (4 bytes) */ @@ -362,7 +362,7 @@ void nsc_compose_message(NSC_CONTEXT* context, wStream* s, { if (context->nsc_stream.PlaneByteCount[i] > 0) { - stream_check_size(s, (int) context->nsc_stream.PlaneByteCount[i]); + Stream_EnsureRemainingCapacity(s, (int) context->nsc_stream.PlaneByteCount[i]); stream_write(s, context->priv->plane_buf[i], context->nsc_stream.PlaneByteCount[i]); } } diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index cb9b4dcb4..9044ca563 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -942,7 +942,7 @@ static void rfx_compose_message_context(RFX_CONTEXT* context, wStream* s) void rfx_compose_message_header(RFX_CONTEXT* context, wStream* s) { - stream_check_size(s, 12 + 10 + 12 + 13); + Stream_EnsureRemainingCapacity(s, 12 + 10 + 12 + 13); rfx_compose_message_sync(context, s); rfx_compose_message_context(context, s); @@ -954,7 +954,7 @@ void rfx_compose_message_header(RFX_CONTEXT* context, wStream* s) static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, wStream* s) { - stream_check_size(s, 14); + Stream_EnsureRemainingCapacity(s, 14); stream_write_UINT16(s, WBT_FRAME_BEGIN); /* CodecChannelT.blockType */ stream_write_UINT32(s, 14); /* CodecChannelT.blockLen */ @@ -973,7 +973,7 @@ static void rfx_compose_message_region(RFX_CONTEXT* context, wStream* s, int i; size = 15 + num_rects * 8; - stream_check_size(s, size); + Stream_EnsureRemainingCapacity(s, size); stream_write_UINT16(s, WBT_REGION); /* CodecChannelT.blockType */ stream_write_UINT32(s, size); /* set CodecChannelT.blockLen later */ @@ -1004,7 +1004,7 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, int CrLen = 0; int start_pos, end_pos; - stream_check_size(s, 19); + Stream_EnsureRemainingCapacity(s, 19); start_pos = Stream_GetPosition(s); stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */ @@ -1077,7 +1077,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, numTiles = numTilesX * numTilesY; size = 22 + numQuants * 5; - stream_check_size(s, size); + Stream_EnsureRemainingCapacity(s, size); start_pos = Stream_GetPosition(s); stream_write_UINT16(s, WBT_EXTENSION); /* CodecChannelT.blockType */ @@ -1127,7 +1127,7 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, static void rfx_compose_message_frame_end(RFX_CONTEXT* context, wStream* s) { - stream_check_size(s, 8); + Stream_EnsureRemainingCapacity(s, 8); stream_write_UINT16(s, WBT_FRAME_END); /* CodecChannelT.blockType */ stream_write_UINT32(s, 8); /* CodecChannelT.blockLen */ diff --git a/libfreerdp/codec/rfx_encode.c b/libfreerdp/codec/rfx_encode.c index 030d9fe04..b59570bec 100644 --- a/libfreerdp/codec/rfx_encode.c +++ b/libfreerdp/codec/rfx_encode.c @@ -242,18 +242,18 @@ void rfx_encode_rgb(RFX_CONTEXT* context, const BYTE* rgb_data, int width, int h PROFILER_EXIT(context->priv->prof_rfx_rgb_to_ycbcr); /* Ensure the buffer is reasonably large enough */ - stream_check_size(data_out, 4096); + Stream_EnsureRemainingCapacity(data_out, 4096); rfx_encode_component(context, y_quants, pSrcDst[0], Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), y_size); Stream_Seek(data_out, *y_size); - stream_check_size(data_out, 4096); + Stream_EnsureRemainingCapacity(data_out, 4096); rfx_encode_component(context, cb_quants, pSrcDst[1], Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cb_size); Stream_Seek(data_out, *cb_size); - stream_check_size(data_out, 4096); + Stream_EnsureRemainingCapacity(data_out, 4096); rfx_encode_component(context, cr_quants, pSrcDst[2], Stream_Pointer(data_out), Stream_GetRemainingLength(data_out), cr_size); Stream_Seek(data_out, *cr_size); diff --git a/libfreerdp/core/channel.c b/libfreerdp/core/channel.c index 8342d0d62..307427dd8 100644 --- a/libfreerdp/core/channel.c +++ b/libfreerdp/core/channel.c @@ -80,7 +80,7 @@ BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channel_id, BYTE* data, int size) stream_write_UINT32(s, size); stream_write_UINT32(s, flags); - stream_check_size(s, chunk_size); + Stream_EnsureCapacity(s, chunk_size); stream_write(s, data, chunk_size); rdp_send(rdp, s, channel_id); diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 6e9741a99..f8f92cde0 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -96,7 +96,7 @@ UINT16 fastpath_read_header(rdpFastPath* fastpath, wStream* s) stream_read_BYTE(s, header); - if (fastpath != NULL) + if (fastpath) { fastpath->encryptionFlags = (header & 0xC0) >> 6; fastpath->numberEvents = (header & 0x3C) >> 2; @@ -133,7 +133,7 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length) stream_read_BYTE(s, header); - if (fastpath != NULL) + if (fastpath) { fastpath->encryptionFlags = (header & 0xC0) >> 6; fastpath->numberEvents = (header & 0x3C) >> 2; @@ -157,6 +157,7 @@ static BOOL fastpath_recv_orders(rdpFastPath* fastpath, wStream* s) { if (!update_recv_order(update, s)) return FALSE; + numberOrders--; } @@ -500,6 +501,7 @@ static BOOL fastpath_recv_input_event_scancode(rdpFastPath* fastpath, wStream* s stream_read_BYTE(s, code); /* keyCode (1 byte) */ flags = 0; + if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE)) flags |= KBD_FLAGS_RELEASE; else @@ -567,6 +569,7 @@ static BOOL fastpath_recv_input_event_unicode(rdpFastPath* fastpath, wStream* s, stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ flags = 0; + if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE)) flags |= KBD_FLAGS_RELEASE; else @@ -650,14 +653,16 @@ static UINT32 fastpath_get_sec_bytes(rdpRdp* rdp) { UINT32 sec_bytes; + sec_bytes = 0; + if (rdp->do_crypt) { sec_bytes = 8; + if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS) sec_bytes += 4; } - else - sec_bytes = 0; + return sec_bytes; } @@ -669,14 +674,20 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev rdp = fastpath->rdp; s = transport_send_stream_init(rdp->transport, 256); + Stream_Seek(s, 3); /* fpInputHeader, length1 and length2 */ - if (rdp->do_crypt) { + + if (rdp->do_crypt) + { rdp->sec_flags |= SEC_ENCRYPT; + if (rdp->do_secure_checksum) rdp->sec_flags |= SEC_SECURE_CHECKSUM; } + Stream_Seek(s, fastpath_get_sec_bytes(rdp)); stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ + return s; } @@ -690,6 +701,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) rdp = fastpath->rdp; length = Stream_GetPosition(s); + if (length >= (2 << 14)) { fprintf(stderr, "Maximum FastPath PDU length is 32767\n"); @@ -698,6 +710,7 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) eventHeader = FASTPATH_INPUT_ACTION_FASTPATH; eventHeader |= (1 << 2); /* numberEvents */ + if (rdp->sec_flags & SEC_ENCRYPT) eventHeader |= (FASTPATH_INPUT_ENCRYPTED << 6); if (rdp->sec_flags & SEC_SECURE_CHECKSUM) @@ -706,8 +719,9 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) Stream_SetPosition(s, 0); stream_write_BYTE(s, eventHeader); sec_bytes = fastpath_get_sec_bytes(fastpath->rdp); + /* - * We always encode length in two bytes, eventhough we could use + * We always encode length in two bytes, even though we could use * only one byte if length <= 0x7F. It is just easier that way, * because we can leave room for fixed-length header, store all * the data first and then store the header. @@ -721,16 +735,19 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) fpInputEvents = Stream_Pointer(s) + sec_bytes; fpInputEvents_length = length - 3 - sec_bytes; + if (rdp->sec_flags & SEC_SECURE_CHECKSUM) security_salted_mac_signature(rdp, fpInputEvents, fpInputEvents_length, TRUE, Stream_Pointer(s)); else security_mac_signature(rdp, fpInputEvents, fpInputEvents_length, Stream_Pointer(s)); + security_encrypt(fpInputEvents, fpInputEvents_length, rdp); } rdp->sec_flags = 0; Stream_SetPosition(s, length); + if (transport_write(fastpath->rdp->transport, s) < 0) return FALSE; @@ -740,10 +757,13 @@ BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s) wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) { wStream* s; + s = transport_send_stream_init(fastpath->rdp->transport, FASTPATH_MAX_PACKET_SIZE); + Stream_Seek(s, 3); /* fpOutputHeader, length1 and length2 */ Stream_Seek(s, fastpath_get_sec_bytes(fastpath->rdp)); Stream_Seek(s, 3); /* updateHeader, size */ + return s; } @@ -783,7 +803,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s try_comp = rdp->settings->CompressionEnabled; comp_update = stream_new(0); - for (fragment = 0; totalLength > 0 || fragment == 0; fragment++) + for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) { stream_get_mark(s, holdp); ls = s; @@ -792,6 +812,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s comp_flags = 0; header_bytes = 6 + sec_bytes; pdu_data_bytes = dlen; + if (try_comp) { if (compress_rdp(rdp->mppc_enc, ls->pointer + header_bytes, dlen)) @@ -808,7 +829,9 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s } } else + { fprintf(stderr, "fastpath_send_update_pdu: mppc_encode failed\n"); + } } totalLength -= dlen; @@ -821,8 +844,10 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s stream_get_mark(ls, bm); header = 0; + if (sec_bytes > 0) header |= (FASTPATH_OUTPUT_ENCRYPTED << 6); + stream_write_BYTE(ls, header); /* fpOutputHeader (1 byte) */ stream_write_BYTE(ls, 0x80 | (pduLength >> 8)); /* length1 */ stream_write_BYTE(ls, pduLength & 0xFF); /* length2 */ @@ -839,7 +864,9 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s bytes_to_crypt = pdu_data_bytes + 4; } else + { bytes_to_crypt = pdu_data_bytes + 3; + } stream_write_UINT16(ls, pdu_data_bytes); @@ -851,10 +878,12 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s /* does this work ? */ ptr_to_crypt = bm + 3 + sec_bytes; ptr_sig = bm + 3; + if (rdp->sec_flags & SEC_SECURE_CHECKSUM) security_salted_mac_signature(rdp, ptr_to_crypt, bytes_to_crypt, TRUE, ptr_sig); else security_mac_signature(rdp, ptr_to_crypt, bytes_to_crypt, ptr_sig); + security_encrypt(ptr_to_crypt, bytes_to_crypt, rdp); } diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 909e722ff..3da81f25b 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -136,7 +136,7 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s) void update_write_surfcmd_surface_bits_header(wStream* s, SURFACE_BITS_COMMAND* cmd) { - stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH); + Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH); stream_write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS); @@ -154,7 +154,7 @@ void update_write_surfcmd_surface_bits_header(wStream* s, SURFACE_BITS_COMMAND* void update_write_surfcmd_frame_marker(wStream* s, UINT16 frameAction, UINT32 frameId) { - stream_check_size(s, SURFCMD_FRAME_MARKER_LENGTH); + Stream_EnsureRemainingCapacity(s, SURFCMD_FRAME_MARKER_LENGTH); stream_write_UINT16(s, CMDTYPE_FRAME_MARKER); diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 77bac1541..f364b60c1 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -53,7 +53,7 @@ static void* transport_client_thread(void* arg); wStream* transport_recv_stream_init(rdpTransport* transport, int size) { wStream* s = transport->ReceiveStream; - stream_check_size(s, size); + Stream_EnsureCapacity(s, size); Stream_SetPosition(s, 0); return s; } @@ -61,7 +61,7 @@ wStream* transport_recv_stream_init(rdpTransport* transport, int size) wStream* transport_send_stream_init(rdpTransport* transport, int size) { wStream* s = transport->SendStream; - stream_check_size(s, size); + Stream_EnsureCapacity(s, size); Stream_SetPosition(s, 0); return s; } @@ -498,7 +498,7 @@ static int transport_read_nonblocking(rdpTransport* transport) { int status; - stream_check_size(transport->ReceiveBuffer, 32 * 1024); + Stream_EnsureCapacity(transport->ReceiveBuffer, 32 * 1024); status = transport_read(transport, transport->ReceiveBuffer); if (status <= 0) diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 44eee1bcd..d5565cbbc 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -511,7 +511,7 @@ static void update_send_surface_command(rdpContext* context, wStream* s) rdpRdp* rdp = context->rdp; update = fastpath_update_pdu_init(rdp->fastpath); - stream_check_size(update, Stream_GetPosition(s)); + Stream_EnsureRemainingCapacity(update, Stream_GetPosition(s)); stream_write(update, stream_get_head(s), Stream_GetPosition(s)); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update); } @@ -522,7 +522,7 @@ static void update_send_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* rdpRdp* rdp = context->rdp; s = fastpath_update_pdu_init(rdp->fastpath); - stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surface_bits_command->bitmapDataLength); + Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surface_bits_command->bitmapDataLength); update_write_surfcmd_surface_bits_header(s, surface_bits_command); stream_write(s, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s); @@ -610,7 +610,7 @@ static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDAT static void update_write_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) { - stream_check_size(s, 15 + (int) pointer_color->lengthAndMask + (int) pointer_color->lengthXorMask); + Stream_EnsureRemainingCapacity(s, 15 + (int) pointer_color->lengthAndMask + (int) pointer_color->lengthXorMask); stream_write_UINT16(s, pointer_color->cacheIndex); stream_write_UINT16(s, pointer_color->xPos); @@ -674,6 +674,7 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < numberOfAreas * 4 * 2) return FALSE; + areas = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * numberOfAreas); for (index = 0; index < numberOfAreas; index++) diff --git a/libfreerdp/utils/rail.c b/libfreerdp/utils/rail.c index 162d95ef6..ba5529729 100644 --- a/libfreerdp/utils/rail.c +++ b/libfreerdp/utils/rail.c @@ -68,7 +68,7 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) void rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) { - stream_check_size(s, 2 + unicode_string->length); + Stream_EnsureRemainingCapacity(s, 2 + unicode_string->length); stream_write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ stream_write(s, unicode_string->string, unicode_string->length); /* string */ } @@ -77,7 +77,7 @@ void rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_st { if (unicode_string->length > 0) { - stream_check_size(s, unicode_string->length); + Stream_EnsureRemainingCapacity(s, unicode_string->length); stream_write(s, unicode_string->string, unicode_string->length); /* string */ } } diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index 9dc0c9405..f201aec95 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -122,7 +122,7 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3 } data_in = plugin->data_in; - stream_check_size(data_in, (int) dataLength); + Stream_EnsureRemainingCapacity(data_in, (int) dataLength); stream_write(data_in, pData, dataLength); if (dataFlags & CHANNEL_FLAG_LAST) diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index 21e52a85a..9743162d0 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -133,7 +133,7 @@ void mf_peer_rfx_update(freerdp_peer* client) s = mfp->s; - stream_clear(s); + Stream_Clear(s); Stream_SetPosition(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 370d1993d..47731ae48 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -104,7 +104,7 @@ static void test_peer_init(freerdp_peer* client) static wStream* test_peer_stream_init(testPeerContext* context) { - stream_clear(context->s); + Stream_Clear(context->s); Stream_SetPosition(context->s, 0); return context->s; } @@ -425,7 +425,7 @@ static void* tf_debug_channel_thread_func(void* arg) if (bytes_returned == 0) break; - stream_check_size(s, bytes_returned); + Stream_EnsureRemainingCapacity(s, bytes_returned); if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s), Stream_Capacity(s), &bytes_returned) == FALSE) diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 2e5c2b3c3..28c4b2bb1 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -134,7 +134,7 @@ void wf_update_encode(wfInfo* wfi) //printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height); - stream_clear(wfi->s); + Stream_Clear(wfi->s); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, pDataBits, width, height, stride); diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index da973296a..227ccee48 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -287,7 +287,8 @@ void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context) rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); - context->s = stream_new(65536); + context->s = Stream_New(NULL, 65536); + Stream_Clear(context->s); } void xf_peer_context_free(freerdp_peer* client, xfPeerContext* context) @@ -325,7 +326,7 @@ void xf_peer_init(freerdp_peer* client) wStream* xf_peer_stream_init(xfPeerContext* context) { - stream_clear(context->s); + Stream_Clear(context->s); Stream_SetPosition(context->s, 0); return context->s; } @@ -409,7 +410,7 @@ void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int heigh cmd->width = width; cmd->height = height; cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = stream_get_head(s); + cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); } diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index cc9396959..5095496f9 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -43,6 +43,7 @@ struct _wStream typedef struct _wStream wStream; WINPR_API void Stream_EnsureCapacity(wStream* s, size_t size); +WINPR_API void Stream_EnsureRemainingCapacity(wStream* s, size_t size); WINPR_API wStream* Stream_New(BYTE* buffer, size_t size); WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); @@ -197,6 +198,8 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); #define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer) #define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer)) +#define Stream_Clear(_s) memset(_s->buffer, 0, _s->capacity) + /* Deprecated STREAM API */ WINPR_API wStream* stream_new(int size); @@ -204,16 +207,12 @@ WINPR_API void stream_free(wStream* stream); #define stream_attach(_s, _buf, _size) do { \ _s->capacity = _size; \ - _s->length = _size; \ + _s->length = _size; \ _s->buffer = _buf; \ _s->pointer = _buf; } while (0) #define stream_detach(_s) memset(_s, 0, sizeof(wStream)) -#define stream_clear(_s) memset(_s->buffer, 0, _s->capacity) WINPR_API void stream_extend(wStream* stream, int request_size); -#define stream_check_size(_s, _n) \ - while (_s->pointer - _s->buffer + (_n) > _s->capacity) \ - stream_extend(_s, _n) #define stream_get_mark(_s,_mark) _mark = _s->pointer #define stream_set_mark(_s,_mark) _s->pointer = _mark diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 380fcbda5..dc42af9c8 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -30,16 +30,28 @@ void Stream_EnsureCapacity(wStream* s, size_t size) if (s->capacity < size) { size_t position; + size_t old_capacity; + + old_capacity = s->capacity; + s->capacity = size; + s->length = size; position = Stream_GetPosition(s); - s->capacity = size; - s->buffer = (BYTE*) realloc(s->buffer, size); + s->buffer = (BYTE*) realloc(s->buffer, s->capacity); + + ZeroMemory(&s->buffer[old_capacity], s->capacity - old_capacity); Stream_SetPosition(s, position); } } +void Stream_EnsureRemainingCapacity(wStream* s, size_t size) +{ + if (Stream_GetPosition(s) + size > Stream_Capacity(s)) + Stream_EnsureCapacity(s, Stream_Capacity(s) + size); +} + wStream* Stream_New(BYTE* buffer, size_t size) { wStream* s; @@ -110,6 +122,7 @@ wStream* stream_new(int size) ZeroMemory(stream->buffer, size); stream->pointer = stream->buffer; stream->capacity = size; + stream->length = size; } } @@ -135,33 +148,3 @@ void stream_free(wStream* stream) free(stream); } } - -/** - * This function is used to extend the size of an existing stream. - * It will infact extend the attached buffer, fill the newly allocated region with 0, and reset the current - * stream position. - * If the stream did not have a buffer attached, a new one will be allocated and attached. - * - * @param stream [in/out] pointer to the STREAM structure that needs to be extended. - * @param request_size [in] Number of bytes to add to the existing stream. - * If the value is < the existing size, then the existing size is doubled. - */ -void stream_extend(wStream* stream, int request_size) -{ - int pos; - int original_size; - int increased_size; - - pos = Stream_GetPosition(stream); - original_size = stream->capacity; - increased_size = (request_size > original_size ? request_size : original_size); - stream->capacity += increased_size; - - if (original_size == 0) - stream->buffer = (BYTE*) malloc(stream->capacity); - else - stream->buffer = (BYTE*) realloc(stream->buffer, stream->capacity); - - memset(stream->buffer + original_size, 0, increased_size); - Stream_SetPosition(stream, pos); -} From 9383892d1671258e192521ecf5c5e1f1a2c2cb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 18:54:42 -0400 Subject: [PATCH 056/144] xfreerdp-server: make use of winpr synch and thread apis --- server/X11/xf_encode.c | 34 +++++++--------------------------- server/X11/xf_encode.h | 2 +- server/X11/xf_peer.c | 35 ++++++++++++++++++++--------------- server/X11/xf_peer.h | 7 ++++--- 4 files changed, 32 insertions(+), 46 deletions(-) diff --git a/server/X11/xf_encode.c b/server/X11/xf_encode.c index 3f3096c57..5d51de829 100644 --- a/server/X11/xf_encode.c +++ b/server/X11/xf_encode.c @@ -65,13 +65,11 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int #endif } -void* xf_monitor_updates(void* param) +void* xf_monitor_thread(void* param) { - int fds; xfInfo* xfi; + HANDLE event; XEvent xevent; - fd_set rfds_set; - int select_status; xfPeerContext* xfp; freerdp_peer* client; UINT32 wait_interval; @@ -83,31 +81,13 @@ void* xf_monitor_updates(void* param) xfp = (xfPeerContext*) client->context; xfi = xfp->info; - fds = xfi->xfds; wait_interval = 1000000 / xfp->fps; ZeroMemory(&timeout, sizeof(struct timeval)); - while (1) + event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds); + + while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0) { - /* check if we should terminate */ - pthread_testcancel(); - - FD_ZERO(&rfds_set); - FD_SET(fds, &rfds_set); - - timeout.tv_sec = 0; - timeout.tv_usec = wait_interval; - select_status = select(fds + 1, &rfds_set, NULL, NULL, &timeout); - - if (select_status == -1) - { - fprintf(stderr, "select failed\n"); - } - else if (select_status == 0) - { - - } - while (XPending(xfi->display) > 0) { ZeroMemory(&xevent, sizeof(xevent)); @@ -122,9 +102,9 @@ void* xf_monitor_updates(void* param) width = notify->area.width; height = notify->area.height; - pthread_mutex_lock(&(xfp->mutex)); + WaitForSingleObject(xfp->mutex, INFINITE); gdi_InvalidateRegion(xfp->hdc, x, y, width, height); - pthread_mutex_unlock(&(xfp->mutex)); + ReleaseMutex(xfp->mutex); xf_xdamage_subtract_region(xfp, x, y, width, height); } diff --git a/server/X11/xf_encode.h b/server/X11/xf_encode.h index f84b3f48e..229dbce61 100644 --- a/server/X11/xf_encode.h +++ b/server/X11/xf_encode.h @@ -27,6 +27,6 @@ XImage* xf_snapshot(xfPeerContext* xfp, int x, int y, int width, int height); void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height); -void* xf_monitor_updates(void* param); +void* xf_monitor_thread(void* param); #endif /* __XF_ENCODE_H */ diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 227ccee48..b1cd77304 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -125,7 +125,7 @@ void xf_xdamage_init(xfInfo* xfi) #endif -void xf_xshm_init(xfInfo* xfi) +int xf_xshm_init(xfInfo* xfi) { xfi->fb_shm_info.shmid = -1; xfi->fb_shm_info.shmaddr = (char*) -1; @@ -136,7 +136,7 @@ void xf_xshm_init(xfInfo* xfi) if (!xfi->fb_image) { fprintf(stderr, "XShmCreateImage failed\n"); - return; + return -1; } xfi->fb_shm_info.shmid = shmget(IPC_PRIVATE, @@ -145,7 +145,7 @@ void xf_xshm_init(xfInfo* xfi) if (xfi->fb_shm_info.shmid == -1) { fprintf(stderr, "shmget failed\n"); - return; + return -1; } xfi->fb_shm_info.readOnly = False; @@ -155,7 +155,7 @@ void xf_xshm_init(xfInfo* xfi) if (xfi->fb_shm_info.shmaddr == ((char*) -1)) { fprintf(stderr, "shmat failed\n"); - return; + return -1; } XShmAttach(xfi->display, &(xfi->fb_shm_info)); @@ -169,6 +169,8 @@ void xf_xshm_init(xfInfo* xfi) xfi->fb_pixmap = XShmCreatePixmap(xfi->display, xfi->root_window, xfi->fb_image->data, &(xfi->fb_shm_info), xfi->fb_image->width, xfi->fb_image->height, xfi->fb_image->depth); + + return 0; } xfInfo* xf_info_init() @@ -191,7 +193,7 @@ xfInfo* xf_info_init() * To see if your X11 server supports shared pixmaps, use: * xdpyinfo -ext MIT-SHM | grep "shared pixmaps" */ - xfi->use_xshm = FALSE; + xfi->use_xshm = TRUE; setenv("DISPLAY", ":0", 1); /* Set DISPLAY variable if not already set */ @@ -268,7 +270,13 @@ xfInfo* xf_info_init() #endif if (xfi->use_xshm) - xf_xshm_init(xfi); + { + if (xf_xshm_init(xfi) < 0) + xfi->use_xshm = FALSE; + } + + if (xfi->use_xshm) + printf("Using X Shared Memory Extension (XShm)\n"); xfi->bytesPerPixel = 4; @@ -313,7 +321,6 @@ void xf_peer_init(freerdp_peer* client) xfp = (xfPeerContext*) client->context; xfp->fps = 16; - xfp->thread = 0; xfp->activations = 0; xfp->queue = MessageQueue_New(); @@ -321,7 +328,7 @@ void xf_peer_init(freerdp_peer* client) xfi = xfp->info; xfp->hdc = gdi_CreateDC(xfi->clrconv, xfi->bpp); - pthread_mutex_init(&(xfp->mutex), NULL); + xfp->mutex = CreateMutex(NULL, FALSE, NULL); } wStream* xf_peer_stream_init(xfPeerContext* context) @@ -334,7 +341,9 @@ wStream* xf_peer_stream_init(xfPeerContext* context) void xf_peer_live_rfx(freerdp_peer* client) { xfPeerContext* xfp = (xfPeerContext*) client->context; - pthread_create(&(xfp->thread), 0, xf_monitor_updates, (void*) client); + + xfp->monitorThread = CreateThread(NULL, 0, + (LPTHREAD_START_ROUTINE) xf_monitor_thread, (void*) client, 0, NULL); } void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height) @@ -443,14 +452,14 @@ BOOL xf_peer_check_fds(freerdp_peer* client) region = xfp->hdc->hwnd->invalid; - pthread_mutex_lock(&(xfp->mutex)); + WaitForSingleObject(xfp->mutex, INFINITE); if ((region->w * region->h) > 0) xf_peer_rfx_update(client, region->x, region->y, region->w, region->h); region->null = 1; - pthread_mutex_unlock(&(xfp->mutex)); + ReleaseMutex(xfp->mutex); return TRUE; } @@ -663,10 +672,6 @@ static void* xf_peer_main_loop(void* arg) client->Disconnect(client); - pthread_cancel(xfp->thread); - - pthread_join(xfp->thread, NULL); - freerdp_peer_context_free(client); freerdp_peer_free(client); diff --git a/server/X11/xf_peer.h b/server/X11/xf_peer.h index 53135baa2..b4bf3f2cd 100644 --- a/server/X11/xf_peer.h +++ b/server/X11/xf_peer.h @@ -21,6 +21,8 @@ #define __XF_PEER_H #include <winpr/crt.h> +#include <winpr/synch.h> +#include <winpr/thread.h> #include <winpr/stream.h> #include <winpr/collections.h> @@ -50,11 +52,10 @@ struct xf_peer_context HGDI_DC hdc; xfInfo* info; int activations; - pthread_t thread; BOOL activated; - pthread_mutex_t mutex; + HANDLE monitorThread; + HANDLE mutex; RFX_CONTEXT* rfx_context; - pthread_t frame_rate_thread; wMessageQueue* queue; }; From d46dfabcfb034929033348f500787448516399b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 19:12:29 -0400 Subject: [PATCH 057/144] xfreerdp-server: move update thread to new source files --- server/X11/CMakeLists.txt | 2 + server/X11/xf_encode.c | 50 ---------------------- server/X11/xf_encode.h | 2 - server/X11/xf_peer.c | 6 ++- server/X11/xf_update.c | 87 +++++++++++++++++++++++++++++++++++++++ server/X11/xf_update.h | 28 +++++++++++++ server/X11/xfreerdp.h | 1 + 7 files changed, 123 insertions(+), 53 deletions(-) create mode 100644 server/X11/xf_update.c create mode 100644 server/X11/xf_update.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 2128d8f31..acf1e12da 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -28,6 +28,8 @@ set(${MODULE_PREFIX}_SRCS xf_input.h xf_encode.c xf_encode.h + xf_update.c + xf_update.h xf_interface.c xf_interface.h xfreerdp.h) diff --git a/server/X11/xf_encode.c b/server/X11/xf_encode.c index 5d51de829..2ef4cddd2 100644 --- a/server/X11/xf_encode.c +++ b/server/X11/xf_encode.c @@ -27,7 +27,6 @@ #include <sys/signal.h> #include <winpr/crt.h> -#include <winpr/synch.h> #include "xf_encode.h" @@ -64,52 +63,3 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None); #endif } - -void* xf_monitor_thread(void* param) -{ - xfInfo* xfi; - HANDLE event; - XEvent xevent; - xfPeerContext* xfp; - freerdp_peer* client; - UINT32 wait_interval; - struct timeval timeout; - int x, y, width, height; - XDamageNotifyEvent* notify; - - client = (freerdp_peer*) param; - xfp = (xfPeerContext*) client->context; - xfi = xfp->info; - - wait_interval = 1000000 / xfp->fps; - ZeroMemory(&timeout, sizeof(struct timeval)); - - event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds); - - while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0) - { - while (XPending(xfi->display) > 0) - { - ZeroMemory(&xevent, sizeof(xevent)); - XNextEvent(xfi->display, &xevent); - - if (xevent.type == xfi->xdamage_notify_event) - { - notify = (XDamageNotifyEvent*) &xevent; - - x = notify->area.x; - y = notify->area.y; - width = notify->area.width; - height = notify->area.height; - - WaitForSingleObject(xfp->mutex, INFINITE); - gdi_InvalidateRegion(xfp->hdc, x, y, width, height); - ReleaseMutex(xfp->mutex); - - xf_xdamage_subtract_region(xfp, x, y, width, height); - } - } - } - - return NULL; -} diff --git a/server/X11/xf_encode.h b/server/X11/xf_encode.h index 229dbce61..f137900d2 100644 --- a/server/X11/xf_encode.h +++ b/server/X11/xf_encode.h @@ -20,13 +20,11 @@ #ifndef __XF_ENCODE_H #define __XF_ENCODE_H -#include <pthread.h> #include "xfreerdp.h" #include "xf_peer.h" XImage* xf_snapshot(xfPeerContext* xfp, int x, int y, int width, int height); void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height); -void* xf_monitor_thread(void* param); #endif /* __XF_ENCODE_H */ diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index b1cd77304..bd1a989a8 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -44,6 +44,7 @@ #include "xf_input.h" #include "xf_encode.h" +#include "xf_update.h" #include "makecert.h" @@ -279,6 +280,7 @@ xfInfo* xf_info_init() printf("Using X Shared Memory Extension (XShm)\n"); xfi->bytesPerPixel = 4; + xfi->activePeerCount = 0; freerdp_keyboard_init(0); @@ -343,7 +345,7 @@ void xf_peer_live_rfx(freerdp_peer* client) xfPeerContext* xfp = (xfPeerContext*) client->context; xfp->monitorThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) xf_monitor_thread, (void*) client, 0, NULL); + (LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL); } void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height) @@ -521,6 +523,8 @@ BOOL xf_peer_activate(freerdp_peer* client) rfx_context_reset(xfp->rfx_context); xfp->activated = TRUE; + xfp->info->activePeerCount++; + xf_peer_live_rfx(client); return TRUE; diff --git a/server/X11/xf_update.c b/server/X11/xf_update.c new file mode 100644 index 000000000..6e404d004 --- /dev/null +++ b/server/X11/xf_update.c @@ -0,0 +1,87 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Graphical Updates + * + * 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/synch.h> +#include <winpr/sysinfo.h> + +#include "xf_peer.h" +#include "xf_encode.h" + +#include "xf_update.h" + +void* xf_update_thread(void* param) +{ + xfInfo* xfi; + HANDLE event; + XEvent xevent; + DWORD beg, end; + DWORD diff, rate; + xfPeerContext* xfp; + freerdp_peer* client; + int x, y, width, height; + XDamageNotifyEvent* notify; + + client = (freerdp_peer*) param; + xfp = (xfPeerContext*) client->context; + xfi = xfp->info; + + rate = 1000 / xfp->fps; + + event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds); + + while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0) + { + beg = GetTickCount(); + + while (XPending(xfi->display) > 0) + { + ZeroMemory(&xevent, sizeof(xevent)); + XNextEvent(xfi->display, &xevent); + + if (xevent.type == xfi->xdamage_notify_event) + { + notify = (XDamageNotifyEvent*) &xevent; + + x = notify->area.x; + y = notify->area.y; + width = notify->area.width; + height = notify->area.height; + + WaitForSingleObject(xfp->mutex, INFINITE); + gdi_InvalidateRegion(xfp->hdc, x, y, width, height); + ReleaseMutex(xfp->mutex); + + xf_xdamage_subtract_region(xfp, x, y, width, height); + } + } + + end = GetTickCount(); + diff = end - beg; + + if (diff < rate) + Sleep(rate - diff); + } + + return NULL; +} diff --git a/server/X11/xf_update.h b/server/X11/xf_update.h new file mode 100644 index 000000000..9e3c27342 --- /dev/null +++ b/server/X11/xf_update.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Graphical Updates + * + * 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 __XF_UPDATE_H +#define __XF_UPDATE_H + +#include "xfreerdp.h" + +void* xf_update_thread(void* param); + +#endif /* __XF_UPDATE_H */ + diff --git a/server/X11/xfreerdp.h b/server/X11/xfreerdp.h index f0ca84f19..8e8a16896 100644 --- a/server/X11/xfreerdp.h +++ b/server/X11/xfreerdp.h @@ -60,6 +60,7 @@ struct xf_info int bytesPerPixel; HCLRCONV clrconv; BOOL use_xshm; + int activePeerCount; XImage* fb_image; Pixmap fb_pixmap; From 0b57157065a615b3c2665c211930aad758ba8376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 22:15:21 -0400 Subject: [PATCH 058/144] xfreerdp-server: fix XShm auto-detection and fallback --- server/X11/xf_peer.c | 73 +++++++++++++++++------------------------- server/X11/xf_peer.h | 4 +-- server/X11/xf_update.c | 2 ++ server/X11/xfreerdp.h | 3 +- 4 files changed, 36 insertions(+), 46 deletions(-) diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index bd1a989a8..d2c65b882 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -54,31 +54,11 @@ void xf_xdamage_init(xfInfo* xfi) { - Bool pixmaps; int damage_event; int damage_error; int major, minor; XGCValues values; - if (xfi->use_xshm) - { - if (XShmQueryExtension(xfi->display) != False) - { - XShmQueryVersion(xfi->display, &major, &minor, &pixmaps); - - if (pixmaps != True) - { - fprintf(stderr, "XShmQueryVersion failed\n"); - return; - } - } - else - { - fprintf(stderr, "XShmQueryExtension failed\n"); - return; - } - } - if (XDamageQueryExtension(xfi->display, &damage_event, &damage_error) == 0) { fprintf(stderr, "XDamageQueryExtension failed\n"); @@ -128,6 +108,25 @@ void xf_xdamage_init(xfInfo* xfi) int xf_xshm_init(xfInfo* xfi) { + Bool pixmaps; + int major, minor; + + if (XShmQueryExtension(xfi->display) != False) + { + XShmQueryVersion(xfi->display, &major, &minor, &pixmaps); + + if (pixmaps != True) + { + fprintf(stderr, "XShmQueryVersion failed\n"); + return -1; + } + } + else + { + fprintf(stderr, "XShmQueryExtension failed\n"); + return -1; + } + xfi->fb_shm_info.shmid = -1; xfi->fb_shm_info.shmaddr = (char*) -1; @@ -244,7 +243,7 @@ xfInfo* xf_info_init() vis = XGetVisualInfo(xfi->display, VisualClassMask | VisualScreenMask, &template, &vi_count); - if (vis == NULL) + if (!vis) { fprintf(stderr, "XGetVisualInfo failed\n"); exit(1); @@ -266,10 +265,6 @@ xfInfo* xf_info_init() XSelectInput(xfi->display, xfi->root_window, SubstructureNotifyMask); -#ifdef WITH_XDAMAGE - xf_xdamage_init(xfi); -#endif - if (xfi->use_xshm) { if (xf_xshm_init(xfi) < 0) @@ -279,6 +274,10 @@ xfInfo* xf_info_init() if (xfi->use_xshm) printf("Using X Shared Memory Extension (XShm)\n"); +#ifdef WITH_XDAMAGE + xf_xdamage_init(xfi); +#endif + xfi->bytesPerPixel = 4; xfi->activePeerCount = 0; @@ -305,7 +304,7 @@ void xf_peer_context_free(freerdp_peer* client, xfPeerContext* context) { if (context) { - stream_free(context->s); + Stream_Free(context->s, TRUE); rfx_context_free(context->rfx_context); } } @@ -333,21 +332,6 @@ void xf_peer_init(freerdp_peer* client) xfp->mutex = CreateMutex(NULL, FALSE, NULL); } -wStream* xf_peer_stream_init(xfPeerContext* context) -{ - Stream_Clear(context->s); - Stream_SetPosition(context->s, 0); - return context->s; -} - -void xf_peer_live_rfx(freerdp_peer* client) -{ - xfPeerContext* xfp = (xfPeerContext*) client->context; - - xfp->monitorThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL); -} - void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height) { wStream* s; @@ -367,7 +351,9 @@ void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int heigh if (width * height <= 0) return; - s = xf_peer_stream_init(xfp); + s = xfp->s; + Stream_Clear(s); + Stream_SetPosition(s, 0); if (xfi->use_xshm) { @@ -525,7 +511,8 @@ BOOL xf_peer_activate(freerdp_peer* client) xfp->info->activePeerCount++; - xf_peer_live_rfx(client); + xfp->monitorThread = CreateThread(NULL, 0, + (LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL); return TRUE; } diff --git a/server/X11/xf_peer.h b/server/X11/xf_peer.h index b4bf3f2cd..9003071c9 100644 --- a/server/X11/xf_peer.h +++ b/server/X11/xf_peer.h @@ -51,12 +51,12 @@ struct xf_peer_context wStream* s; HGDI_DC hdc; xfInfo* info; + HANDLE mutex; + HANDLE event; int activations; BOOL activated; HANDLE monitorThread; - HANDLE mutex; RFX_CONTEXT* rfx_context; - wMessageQueue* queue; }; diff --git a/server/X11/xf_update.c b/server/X11/xf_update.c index 6e404d004..f760055bf 100644 --- a/server/X11/xf_update.c +++ b/server/X11/xf_update.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include <X11/Xlib.h> + #include <winpr/crt.h> #include <winpr/synch.h> #include <winpr/sysinfo.h> diff --git a/server/X11/xfreerdp.h b/server/X11/xfreerdp.h index 8e8a16896..ea16b2520 100644 --- a/server/X11/xfreerdp.h +++ b/server/X11/xfreerdp.h @@ -25,9 +25,10 @@ #include <freerdp/api.h> #include <freerdp/freerdp.h> #include <freerdp/listener.h> - #include <freerdp/codec/color.h> +#include <X11/Xlib.h> + #ifdef WITH_XSHM #include <X11/extensions/XShm.h> #endif From 030fad3a65a1e2cba9d2d648fdfc7aa9c4e0dd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 22:38:32 -0400 Subject: [PATCH 059/144] xfreerdp-server: offload encoding of frames to a different thread --- server/X11/xf_encode.c | 84 ++++++++++++++++++++++++++++++++++ server/X11/xf_encode.h | 1 + server/X11/xf_peer.c | 101 +++++++---------------------------------- server/X11/xf_peer.h | 3 +- server/X11/xf_update.c | 12 +++-- 5 files changed, 111 insertions(+), 90 deletions(-) diff --git a/server/X11/xf_encode.c b/server/X11/xf_encode.c index 2ef4cddd2..54830f5cf 100644 --- a/server/X11/xf_encode.c +++ b/server/X11/xf_encode.c @@ -22,6 +22,7 @@ #endif #include <X11/Xlib.h> +#include <X11/Xutil.h> #include <sys/select.h> #include <sys/signal.h> @@ -63,3 +64,86 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None); #endif } + +int xf_update_encode(freerdp_peer* client, int x, int y, int width, int height) +{ + wStream* s; + BYTE* data; + xfInfo* xfi; + RFX_RECT rect; + XImage* image; + rdpUpdate* update; + xfPeerContext* xfp; + SURFACE_BITS_COMMAND* cmd; + + update = client->update; + xfp = (xfPeerContext*) client->context; + cmd = &update->surface_bits_command; + xfi = xfp->info; + + if (width * height <= 0) + { + cmd->bitmapDataLength = 0; + return -1; + } + + s = xfp->s; + Stream_Clear(s); + Stream_SetPosition(s, 0); + + if (xfi->use_xshm) + { + /** + * Passing an offset source rectangle to rfx_compose_message() + * leads to protocol errors, so offset the data pointer instead. + */ + + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + + image = xf_snapshot(xfp, x, y, width, height); + + data = (BYTE*) image->data; + data = &data[(y * image->bytes_per_line) + (x * image->bits_per_pixel / 8)]; + + rfx_compose_message(xfp->rfx_context, s, &rect, 1, data, + width, height, image->bytes_per_line); + + cmd->destLeft = x; + cmd->destTop = y; + cmd->destRight = x + width; + cmd->destBottom = y + height; + } + else + { + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + + image = xf_snapshot(xfp, x, y, width, height); + + data = (BYTE*) image->data; + + rfx_compose_message(xfp->rfx_context, s, &rect, 1, data, + width, height, image->bytes_per_line); + + cmd->destLeft = x; + cmd->destTop = y; + cmd->destRight = x + width; + cmd->destBottom = y + height; + + XDestroyImage(image); + } + + cmd->bpp = 32; + cmd->codecID = client->settings->RemoteFxCodecId; + cmd->width = width; + cmd->height = height; + cmd->bitmapDataLength = Stream_GetPosition(s); + cmd->bitmapData = Stream_Buffer(s); + + return 0; +} diff --git a/server/X11/xf_encode.h b/server/X11/xf_encode.h index f137900d2..fb7d98562 100644 --- a/server/X11/xf_encode.h +++ b/server/X11/xf_encode.h @@ -26,5 +26,6 @@ XImage* xf_snapshot(xfPeerContext* xfp, int x, int y, int width, int height); void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height); +int xf_update_encode(freerdp_peer* client, int x, int y, int width, int height); #endif /* __XF_ENCODE_H */ diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index d2c65b882..6ff3c74b9 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -298,6 +298,9 @@ void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context) context->s = Stream_New(NULL, 65536); Stream_Clear(context->s); + + context->updateReadyEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + context->updateSentEvent = CreateEvent(NULL, TRUE, FALSE, NULL); } void xf_peer_context_free(freerdp_peer* client, xfPeerContext* context) @@ -332,84 +335,16 @@ void xf_peer_init(freerdp_peer* client) xfp->mutex = CreateMutex(NULL, FALSE, NULL); } -void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height) +void xf_peer_send_update(freerdp_peer* client) { - wStream* s; - BYTE* data; - xfInfo* xfi; - RFX_RECT rect; - XImage* image; rdpUpdate* update; - xfPeerContext* xfp; SURFACE_BITS_COMMAND* cmd; update = client->update; - xfp = (xfPeerContext*) client->context; cmd = &update->surface_bits_command; - xfi = xfp->info; - if (width * height <= 0) - return; - - s = xfp->s; - Stream_Clear(s); - Stream_SetPosition(s, 0); - - if (xfi->use_xshm) - { - /** - * Passing an offset source rectangle to rfx_compose_message() - * leads to protocol errors, so offset the data pointer instead. - */ - - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - - image = xf_snapshot(xfp, x, y, width, height); - - data = (BYTE*) image->data; - data = &data[(y * image->bytes_per_line) + (x * image->bits_per_pixel / 8)]; - - rfx_compose_message(xfp->rfx_context, s, &rect, 1, data, - width, height, image->bytes_per_line); - - cmd->destLeft = x; - cmd->destTop = y; - cmd->destRight = x + width; - cmd->destBottom = y + height; - } - else - { - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - - image = xf_snapshot(xfp, x, y, width, height); - - data = (BYTE*) image->data; - - rfx_compose_message(xfp->rfx_context, s, &rect, 1, data, - width, height, image->bytes_per_line); - - cmd->destLeft = x; - cmd->destTop = y; - cmd->destRight = x + width; - cmd->destBottom = y + height; - - XDestroyImage(image); - } - - cmd->bpp = 32; - cmd->codecID = client->settings->RemoteFxCodecId; - cmd->width = width; - cmd->height = height; - cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = Stream_Buffer(s); - - update->SurfaceBits(update->context, cmd); + if (cmd->bitmapDataLength) + update->SurfaceBits(update->context, cmd); } BOOL xf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) @@ -418,7 +353,7 @@ BOOL xf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) HANDLE event; xfPeerContext* xfp = (xfPeerContext*) client->context; - event = MessageQueue_Event(xfp->queue); + event = xfp->updateReadyEvent; fds = GetEventFileDescriptor(event); rfds[*rcount] = (void*) (long) fds; (*rcount)++; @@ -429,25 +364,21 @@ BOOL xf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount) BOOL xf_peer_check_fds(freerdp_peer* client) { xfInfo* xfi; - HGDI_RGN region; xfPeerContext* xfp; xfp = (xfPeerContext*) client->context; xfi = xfp->info; - if (!xfp->activated) - return TRUE; + if (WaitForSingleObject(xfp->updateReadyEvent, 0) == WAIT_OBJECT_0) + { + if (!xfp->activated) + return TRUE; - region = xfp->hdc->hwnd->invalid; + xf_peer_send_update(client); - WaitForSingleObject(xfp->mutex, INFINITE); - - if ((region->w * region->h) > 0) - xf_peer_rfx_update(client, region->x, region->y, region->w, region->h); - - region->null = 1; - - ReleaseMutex(xfp->mutex); + ResetEvent(xfp->updateReadyEvent); + SetEvent(xfp->updateSentEvent); + } return TRUE; } @@ -572,9 +503,9 @@ static void* xf_peer_main_loop(void* arg) void* rfds[32]; fd_set rfds_set; rdpSettings* settings; - freerdp_peer* client = (freerdp_peer*) arg; xfPeerContext* xfp; struct timeval timeout; + freerdp_peer* client = (freerdp_peer*) arg; ZeroMemory(rfds, sizeof(rfds)); ZeroMemory(&timeout, sizeof(struct timeval)); diff --git a/server/X11/xf_peer.h b/server/X11/xf_peer.h index 9003071c9..9b30b96a4 100644 --- a/server/X11/xf_peer.h +++ b/server/X11/xf_peer.h @@ -52,10 +52,11 @@ struct xf_peer_context HGDI_DC hdc; xfInfo* info; HANDLE mutex; - HANDLE event; int activations; BOOL activated; HANDLE monitorThread; + HANDLE updateReadyEvent; + HANDLE updateSentEvent; RFX_CONTEXT* rfx_context; wMessageQueue* queue; }; diff --git a/server/X11/xf_update.c b/server/X11/xf_update.c index f760055bf..d375f8b5e 100644 --- a/server/X11/xf_update.c +++ b/server/X11/xf_update.c @@ -70,11 +70,15 @@ void* xf_update_thread(void* param) width = notify->area.width; height = notify->area.height; - WaitForSingleObject(xfp->mutex, INFINITE); - gdi_InvalidateRegion(xfp->hdc, x, y, width, height); - ReleaseMutex(xfp->mutex); + if (xf_update_encode(client, x, y, width, height) >= 0) + { + xf_xdamage_subtract_region(xfp, x, y, width, height); - xf_xdamage_subtract_region(xfp, x, y, width, height); + SetEvent(xfp->updateReadyEvent); + + WaitForSingleObject(xfp->updateSentEvent, INFINITE); + ResetEvent(xfp->updateSentEvent); + } } } From 54096f7b9b2858794a0bd1a9c9138198785b25cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 1 May 2013 23:03:05 -0400 Subject: [PATCH 060/144] xfreerdp-server: add xinerama code --- server/X11/CMakeLists.txt | 24 ++++++++++++++ server/X11/xf_monitors.c | 68 +++++++++++++++++++++++++++++++++++++++ server/X11/xf_monitors.h | 28 ++++++++++++++++ server/X11/xf_peer.c | 3 ++ 4 files changed, 123 insertions(+) create mode 100644 server/X11/xf_monitors.c create mode 100644 server/X11/xf_monitors.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index acf1e12da..34381ae85 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -30,6 +30,8 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_update.c xf_update.h + xf_monitors.c + xf_monitors.h xf_interface.c xf_interface.h xfreerdp.h) @@ -55,10 +57,18 @@ set(XSHM_FEATURE_TYPE "RECOMMENDED") set(XSHM_FEATURE_PURPOSE "X11 shared memory") set(XSHM_FEATURE_DESCRIPTION "X11 shared memory extension") +set(XINERAMA_FEATURE_TYPE "RECOMMENDED") +set(XINERAMA_FEATURE_PURPOSE "multi-monitor") +set(XINERAMA_FEATURE_DESCRIPTION "X11 multi-monitor extension") + set(XTEST_FEATURE_TYPE "RECOMMENDED") set(XTEST_FEATURE_PURPOSE "X11 input event injection") set(XTEST_FEATURE_DESCRIPTION "X11 input event injection extension") +set(XCURSOR_FEATURE_TYPE "RECOMMENDED") +set(XCURSOR_FEATURE_PURPOSE "cursor") +set(XCURSOR_FEATURE_DESCRIPTION "X11 cursor extension") + set(XFIXES_FEATURE_TYPE "RECOMMENDED") set(XFIXES_FEATURE_PURPOSE "X11 region") set(XFIXES_FEATURE_DESCRIPTION "X11 region fix extension") @@ -72,6 +82,8 @@ find_feature(XShm ${XSHM_FEATURE_TYPE} ${XSHM_FEATURE_PURPOSE} ${XSHM_FEATURE_DE find_feature(XTest ${XTEST_FEATURE_TYPE} ${XTEST_FEATURE_PURPOSE} ${XTEST_FEATURE_DESCRIPTION}) find_feature(Xfixes ${XFIXES_FEATURE_TYPE} ${XFIXES_FEATURE_PURPOSE} ${XFIXES_FEATURE_DESCRIPTION}) find_feature(Xdamage ${XDAMAGE_FEATURE_TYPE} ${XDAMAGE_FEATURE_PURPOSE} ${XDAMAGE_FEATURE_DESCRIPTION}) +find_feature(Xcursor ${XCURSOR_FEATURE_TYPE} ${XCURSOR_FEATURE_PURPOSE} ${XCURSOR_FEATURE_DESCRIPTION}) +find_feature(Xinerama ${XINERAMA_FEATURE_TYPE} ${XINERAMA_FEATURE_PURPOSE} ${XINERAMA_FEATURE_DESCRIPTION}) if(WITH_XSHM) add_definitions(-DWITH_XSHM) @@ -84,6 +96,18 @@ if(WITH_XEXT) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XEXT_LIBRARIES}) endif() +if(WITH_XINERAMA) + add_definitions(-DWITH_XINERAMA) + include_directories(${XINERAMA_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XINERAMA_LIBRARIES}) +endif() + +if(WITH_XCURSOR) + add_definitions(-DWITH_XCURSOR) + include_directories(${XCURSOR_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XCURSOR_LIBRARIES}) +endif() + if(WITH_XDAMAGE) add_definitions(-DWITH_XDAMAGE) include_directories(${XDAMAGE_INCLUDE_DIRS}) diff --git a/server/X11/xf_monitors.c b/server/X11/xf_monitors.c new file mode 100644 index 000000000..2bf5d51f1 --- /dev/null +++ b/server/X11/xf_monitors.c @@ -0,0 +1,68 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Monitors + * + * 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 <X11/Xlib.h> +#include <X11/Xutil.h> + +#ifdef WITH_XINERAMA +#include <X11/extensions/Xinerama.h> +#endif + +#include "xf_monitors.h" + +int xf_list_monitors(xfInfo* xfi) +{ +#ifdef WITH_XINERAMAZ + int i, nmonitors = 0; + int ignored, ignored2; + XineramaScreenInfo* screen = NULL; + + if (XineramaQueryExtension(xfi->display, &ignored, &ignored2)) + { + if (XineramaIsActive(xfi->display)) + { + screen = XineramaQueryScreens(xfi->display, &nmonitors); + + for (i = 0; i < nmonitors; i++) + { + printf(" %s [%d] %dx%d\t+%d+%d\n", + (i == 0) ? "*" : " ", i, + screen[i].width, screen[i].height, + screen[i].x_org, screen[i].y_org); + } + + XFree(screen); + } + } +#else + Screen* screen; + + screen = ScreenOfDisplay(xfi->display, DefaultScreen(xfi->display)); + printf(" * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0); +#endif + + return 0; +} + diff --git a/server/X11/xf_monitors.h b/server/X11/xf_monitors.h new file mode 100644 index 000000000..8487c3327 --- /dev/null +++ b/server/X11/xf_monitors.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Monitors + * + * 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 XFREERDP_SERVER_MONITORS_H +#define XFREERDP_SERVER_MONITORS_H + +#include "xfreerdp.h" + +int xf_list_monitors(xfInfo* xfi); + +#endif /* XFREERDP_SERVER_MONITORS_H */ + diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 6ff3c74b9..b9d747ce2 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -45,6 +45,7 @@ #include "xf_input.h" #include "xf_encode.h" #include "xf_update.h" +#include "xf_monitors.h" #include "makecert.h" @@ -208,6 +209,8 @@ xfInfo* xf_info_init() exit(1); } + xf_list_monitors(xfi); + xfi->xfds = ConnectionNumber(xfi->display); xfi->number = DefaultScreen(xfi->display); xfi->screen = ScreenOfDisplay(xfi->display, xfi->number); From 9bf924929c78cc76f534494c2f0b0a72db27ad7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 2 May 2013 01:34:54 -0400 Subject: [PATCH 061/144] xfreerdp-server: use libwinpr-input for keyboard mapping --- server/X11/CMakeLists.txt | 4 +++- server/X11/xf_cursor.c | 35 ++++++++++++++++++++++++++++++++++ server/X11/xf_cursor.h | 28 +++++++++++++++++++++++++++ server/X11/xf_input.c | 12 ++++++++++-- winpr/include/winpr/input.h | 1 + winpr/libwinpr/input/keycode.c | 31 ++++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 server/X11/xf_cursor.c create mode 100644 server/X11/xf_cursor.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 34381ae85..261576500 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -30,6 +30,8 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_update.c xf_update.h + xf_cursor.c + xf_cursor.h xf_monitors.c xf_monitors.h xf_interface.c @@ -137,7 +139,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE winpr - MODULES winpr-sspi) + MODULES winpr-sspi winpr-crt winpr-utils winpr-input winpr-sysinfo) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-makecert-tool) diff --git a/server/X11/xf_cursor.c b/server/X11/xf_cursor.c new file mode 100644 index 000000000..ca5917a02 --- /dev/null +++ b/server/X11/xf_cursor.c @@ -0,0 +1,35 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Cursor + * + * 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 <X11/Xlib.h> +#include <X11/Xutil.h> + +#ifdef WITH_XCURSOR +#include <X11/Xcursor/Xcursor.h> +#endif + +#include <winpr/crt.h> + +#include "xf_cursor.h" + + diff --git a/server/X11/xf_cursor.h b/server/X11/xf_cursor.h new file mode 100644 index 000000000..1c8c19652 --- /dev/null +++ b/server/X11/xf_cursor.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Cursor + * + * 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 XFREERDP_SERVER_CURSOR_H +#define XFREERDP_SERVER_CURSOR_H + +#include "xfreerdp.h" + + + +#endif /* XFREERDP_SERVER_CURSOR_H */ + diff --git a/server/X11/xf_input.c b/server/X11/xf_input.c index feac6ebf5..14d55fca7 100644 --- a/server/X11/xf_input.c +++ b/server/X11/xf_input.c @@ -25,6 +25,9 @@ #include <freerdp/locale/keyboard.h> +#include <winpr/crt.h> +#include <winpr/input.h> + #include "xf_peer.h" #include "xf_input.h" @@ -37,7 +40,8 @@ void xf_input_synchronize_event(rdpInput* input, UINT32 flags) void xf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) { #ifdef WITH_XTEST - unsigned int keycode; + DWORD vkcode; + DWORD keycode; BOOL extended = FALSE; xfPeerContext* xfp = (xfPeerContext*) input->context; xfInfo* xfi = xfp->info; @@ -45,7 +49,11 @@ void xf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) if (flags & KBD_FLAGS_EXTENDED) extended = TRUE; - keycode = freerdp_keyboard_get_x11_keycode_from_rdp_scancode(code, extended); + if (extended) + code |= KBDEXT; + + vkcode = GetVirtualKeyCodeFromVirtualScanCode(code, 4); + keycode = GetKeycodeFromVirtualKeyCode(vkcode, KEYCODE_TYPE_EVDEV); if (keycode != 0) { diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 6ca12d302..6779f30fa 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -874,6 +874,7 @@ WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeybo #define KEYCODE_TYPE_EVDEV 0x00000002 WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags); +WINPR_API DWORD GetKeycodeFromVirtualKeyCode(DWORD keycode, DWORD dwFlags); #ifdef __cplusplus } diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 63960a152..295fe3b1b 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -584,3 +584,34 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags) return vkcode; } + +DWORD GetKeycodeFromVirtualKeyCode(DWORD vkcode, DWORD dwFlags) +{ + int index; + DWORD keycode = 0; + + if (dwFlags & KEYCODE_TYPE_APPLE) + { + for (index = 0; index < 256; index++) + { + if (vkcode == KEYCODE_TO_VKCODE_APPLE[index]) + { + keycode = index; + break; + } + } + } + else if (dwFlags & KEYCODE_TYPE_EVDEV) + { + for (index = 0; index < 256; index++) + { + if (vkcode == KEYCODE_TO_VKCODE_EVDEV[index]) + { + keycode = index; + break; + } + } + } + + return keycode; +} From ed85b93a41921ba54cfe5167c5971dc7cbc44036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 2 May 2013 01:50:50 -0400 Subject: [PATCH 062/144] xfreerdp-server: register for XFixes cursor change events --- server/X11/xf_cursor.c | 20 ++++++++++++++++++++ server/X11/xf_cursor.h | 3 +-- server/X11/xf_peer.c | 3 +++ server/X11/xf_update.c | 6 ++++++ server/X11/xfreerdp.h | 4 ++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/server/X11/xf_cursor.c b/server/X11/xf_cursor.c index ca5917a02..ebd523f29 100644 --- a/server/X11/xf_cursor.c +++ b/server/X11/xf_cursor.c @@ -28,8 +28,28 @@ #include <X11/Xcursor/Xcursor.h> #endif +#ifdef WITH_XFIXES +#include <X11/extensions/Xfixes.h> +#endif + #include <winpr/crt.h> #include "xf_cursor.h" +int xf_cursor_init(xfInfo* xfi) +{ + int event; + int error; + if (!XFixesQueryExtension(xfi->display, &event, &error)) + { + fprintf(stderr, "XFixesQueryExtension failed\n"); + return -1; + } + + xfi->xfixes_notify_event = event + XFixesCursorNotify; + + XFixesSelectCursorInput(xfi->display, DefaultRootWindow(xfi->display), XFixesDisplayCursorNotifyMask); + + return 0; +} diff --git a/server/X11/xf_cursor.h b/server/X11/xf_cursor.h index 1c8c19652..64c95c312 100644 --- a/server/X11/xf_cursor.h +++ b/server/X11/xf_cursor.h @@ -22,7 +22,6 @@ #include "xfreerdp.h" - +int xf_cursor_init(xfInfo* xfi); #endif /* XFREERDP_SERVER_CURSOR_H */ - diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index b9d747ce2..c1e6387f9 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -43,6 +43,7 @@ #include <freerdp/locale/keyboard.h> #include "xf_input.h" +#include "xf_cursor.h" #include "xf_encode.h" #include "xf_update.h" #include "xf_monitors.h" @@ -281,6 +282,8 @@ xfInfo* xf_info_init() xf_xdamage_init(xfi); #endif + xf_cursor_init(xfi); + xfi->bytesPerPixel = 4; xfi->activePeerCount = 0; diff --git a/server/X11/xf_update.c b/server/X11/xf_update.c index d375f8b5e..33dd426b3 100644 --- a/server/X11/xf_update.c +++ b/server/X11/xf_update.c @@ -80,6 +80,12 @@ void* xf_update_thread(void* param) ResetEvent(xfp->updateSentEvent); } } + else if (xevent.type == xfi->xfixes_notify_event) + { + XFixesCursorImage* ci = XFixesGetCursorImage(xfi->display); + + XFree(ci); + } } end = GetTickCount(); diff --git a/server/X11/xfreerdp.h b/server/X11/xfreerdp.h index ea16b2520..db6231893 100644 --- a/server/X11/xfreerdp.h +++ b/server/X11/xfreerdp.h @@ -74,6 +74,10 @@ struct xf_info int xdamage_notify_event; XserverRegion xdamage_region; #endif + +#ifdef WITH_XFIXES + int xfixes_notify_event; +#endif }; struct xf_server From e79515fcb7c89e107af22109045c61175df9d75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 2 May 2013 02:10:01 -0400 Subject: [PATCH 063/144] xfreerdp-server: link to xrandr --- server/X11/CMakeLists.txt | 11 +++++++++++ server/X11/xf_peer.c | 5 ----- server/X11/xf_peer.h | 3 --- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 261576500..2af6f8f2e 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -75,6 +75,10 @@ set(XFIXES_FEATURE_TYPE "RECOMMENDED") set(XFIXES_FEATURE_PURPOSE "X11 region") set(XFIXES_FEATURE_DESCRIPTION "X11 region fix extension") +set(XRANDR_FEATURE_TYPE "RECOMMENDED") +set(XRANDR_FEATURE_PURPOSE "X11 resize, rotate and reflect") +set(XRANDR_FEATURE_DESCRIPTION "X11 resize, rotate and reflect extension") + set(XDAMAGE_FEATURE_TYPE "RECOMMENDED") set(XDAMAGE_FEATURE_PURPOSE "X11 region damage") set(XDAMAGE_FEATURE_DESCRIPTION "X11 region damage extension") @@ -83,6 +87,7 @@ find_feature(Xext ${XEXT_FEATURE_TYPE} ${XEXT_FEATURE_PURPOSE} ${XEXT_FEATURE_DE find_feature(XShm ${XSHM_FEATURE_TYPE} ${XSHM_FEATURE_PURPOSE} ${XSHM_FEATURE_DESCRIPTION}) find_feature(XTest ${XTEST_FEATURE_TYPE} ${XTEST_FEATURE_PURPOSE} ${XTEST_FEATURE_DESCRIPTION}) find_feature(Xfixes ${XFIXES_FEATURE_TYPE} ${XFIXES_FEATURE_PURPOSE} ${XFIXES_FEATURE_DESCRIPTION}) +find_feature(XRandR ${XRANDR_FEATURE_TYPE} ${XRANDR_FEATURE_PURPOSE} ${XRANDR_FEATURE_DESCRIPTION}) find_feature(Xdamage ${XDAMAGE_FEATURE_TYPE} ${XDAMAGE_FEATURE_PURPOSE} ${XDAMAGE_FEATURE_DESCRIPTION}) find_feature(Xcursor ${XCURSOR_FEATURE_TYPE} ${XCURSOR_FEATURE_PURPOSE} ${XCURSOR_FEATURE_DESCRIPTION}) find_feature(Xinerama ${XINERAMA_FEATURE_TYPE} ${XINERAMA_FEATURE_PURPOSE} ${XINERAMA_FEATURE_DESCRIPTION}) @@ -129,6 +134,12 @@ if(WITH_XTEST) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XTEST_LIBRARIES}) endif() +if(WITH_XRANDR) + add_definitions(-DWITH_XRANDR) + include_directories(${XRANDR_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XRANDR_LIBRARIES}) +endif() + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${X11_LIBRARIES}) set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index c1e6387f9..28316c87e 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -331,12 +331,7 @@ void xf_peer_init(freerdp_peer* client) xfp = (xfPeerContext*) client->context; xfp->fps = 16; - xfp->activations = 0; - - xfp->queue = MessageQueue_New(); - xfi = xfp->info; - xfp->hdc = gdi_CreateDC(xfi->clrconv, xfi->bpp); xfp->mutex = CreateMutex(NULL, FALSE, NULL); } diff --git a/server/X11/xf_peer.h b/server/X11/xf_peer.h index 9b30b96a4..e6febd68d 100644 --- a/server/X11/xf_peer.h +++ b/server/X11/xf_peer.h @@ -49,16 +49,13 @@ struct xf_peer_context int fps; wStream* s; - HGDI_DC hdc; xfInfo* info; HANDLE mutex; - int activations; BOOL activated; HANDLE monitorThread; HANDLE updateReadyEvent; HANDLE updateSentEvent; RFX_CONTEXT* rfx_context; - wMessageQueue* queue; }; void xf_peer_accepted(freerdp_listener* instance, freerdp_peer* client); From f59780c08bbd94871f661180737395342c18684f Mon Sep 17 00:00:00 2001 From: martijn-m <martijnmiegielsen@gmail.com> Date: Thu, 2 May 2013 14:14:21 +0300 Subject: [PATCH 064/144] Dutch translation v2 Optimized: 'Credentials' translated --- .../FreeRDPCore/res/values-nl/strings.xml | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 client/Android/FreeRDPCore/res/values-nl/strings.xml diff --git a/client/Android/FreeRDPCore/res/values-nl/strings.xml b/client/Android/FreeRDPCore/res/values-nl/strings.xml new file mode 100644 index 000000000..5dfbf0c24 --- /dev/null +++ b/client/Android/FreeRDPCore/res/values-nl/strings.xml @@ -0,0 +1,175 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<resources> + <!-- Button labels --> + <string name="yes">Ja</string> + <string name="no">Nee</string> + <string name="cancel">Annuleren</string> + <string name="cont">Doorgaan</string> + <string name="login">Inloggen</string> + <string name="logout">Uitloggen</string> + <!-- Home menu items --> + <string name="menu_exit">Sluiten</string> + <string name="menu_about">Over</string> + <string name="menu_help">Help</string> + <string name="menu_new_bookmark">Nieuwe connectie</string> + <string name="menu_app_settings">Instellingen</string> + <!-- Bookmark menu items --> + <string name="menu_title_bookmark">Connectie</string> + <string name="menu_connect">Verbinden</string> + <string name="menu_edit">Bewerken</string> + <string name="menu_delete">Verwijderen</string> + <!-- Session menu items --> + <string name="menu_sys_keyboard">Toetsenbord</string> + <string name="menu_ext_keyboard">Functietoetsen</string> + <string name="menu_touch_pointer">Touch Pointer</string> + <string name="menu_home">home</string> + <string name="menu_disconnect">Verbinding verbreken</string> + <!-- List section headers --> + <string name="section_bookmarks">Handmatige connecties</string> + <string name="section_active_sessions">Actieve sessies</string> + <!-- Search strings --> + <string name="search_hint">Verbinden met computer</string> + <!-- List placeholder labels --> + <string name="list_placeholder_login">Login</string> + <string name="list_placeholder_no_servers">Geen servers</string> + <string name="list_placeholder_connecting">Verbinden ...</string> + <string name="list_placeholder_disconnecting">Verbinding verbreken ...</string> + <string name="list_placeholder_connection_error">Connectie verloren</string> + <string name="list_placeholder_wrong_password">Ongeldig wachtwoord</string> + <string name="list_placeholder_invalid_username">Ongeldige gebruikersnaam</string> + <string name="list_placeholder_add_bookmark">Connectie toevoegen</string> + <!-- Bookmark settings strings --> + <string name="settings_cat_host">Host</string> + <string name="settings_label">Label</string> + <string name="settings_hostname">Host</string> + <string name="settings_port">Poort</string> + <string name="settings_cat_credentials">Inloggegevens</string> + <string name="settings_credentials">Inloggegevens</string> + <string name="settings_username">Gebruikersnaam</string> + <string name="settings_password">Wachtwoord</string> + <string name="settings_domain">Domein</string> + <string name="settings_cat_settings">Instellingen</string> + <string name="settings_screen">Scherm</string> + <string name="settings_cat_screen">Scherminstellingen</string> + <string name="settings_colors">Kleuren</string> + <string-array name="colors_array"> + <item>Hoge kleuren (16 Bit)</item> + <item>Ware kleuren (24 Bit)</item> + <item>Hoogste kwaliteit (32 Bit)</item> + </string-array> + <string-array name="colors_values_array"> + <item>16</item> + <item>24</item> + <item>32</item> + </string-array> + <string name="settings_resolution">Resolutie</string> + <string name="resolution_automatic">Automatisch</string> + <string name="resolution_custom">Aangepast</string> + <string-array name="resolutions_array"> + <item>Automatisch</item> + <item>Aangepast</item> + <item>640x480</item> + <item>720x480</item> + <item>800x600</item> + <item>1024x768</item> + <item>1280x1024</item> + <item>1440x900</item> + <item>1920x1080</item> + <item>1920x1200</item> + </string-array> + <string-array name="resolutions_values_array"> + <item>Automatisch</item> + <item>Aangepast</item> + <item>640x480</item> + <item>720x480</item> + <item>800x600</item> + <item>1024x768</item> + <item>1280x1024</item> + <item>1440x900</item> + <item>1920x1080</item> + <item>1920x1200</item> + </string-array> + <string name="settings_width">Breedte</string> + <string name="settings_height">Hoogte</string> + <string name="settings_performance">Prestatie</string> + <string name="settings_cat_performance">Prestatieinstellingen</string> + <string name="settings_perf_remotefx">RemoteFX</string> + <string name="settings_perf_wallpaper">Bureaublad achtergrond</string> + <string name="settings_perf_font_smoothing">Lettertype Smoothing</string> + <string name="settings_perf_desktop_composition">Bureaublad compositie</string> + <string name="settings_perf_full_window_drag">Inhoud van het venster weergeven tijdens slepen</string> + <string name="settings_perf_menu_animation">Menu animatie</string> + <string name="settings_perf_theming">Visuele stijlen</string> + <string name="settings_advanced">Geavanceerd</string> + <string name="settings_cat_advanced">Geavanceerde instellingen</string> + <string name="settings_enable_3g_settings">3G Instellingen</string> + <string name="settings_screen_3g">3G Scherm</string> + <string name="settings_performance_3g">3G Prestatie</string> + <string name="settings_security">Beveiliging</string> + <string-array name="security_array"> + <item>Automatisch</item> + <item>RDP</item> + <item>TLS</item> + <item>NLA</item> + </string-array> + <string-array name="security_values_array"> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + </string-array> + <string name="settings_remote_program">Extern programma</string> + <string name="settings_work_dir">Werkmap</string> + <string name="settings_console_mode">Console modus</string> + <!-- App settings strings --> + <string name="settings_password_present">*******</string> + <string name="settings_password_empty">Niet ingesteld</string> + <string name="settings_cat_ui">Gebruikersinterface</string> + <string name="settings_ui_hide_status_bar">Verberg statusbalk</string> + <string name="settings_ui_hide_zoom_controls">Verberg Zoom Controls</string> + <string name="settings_ui_swap_mouse_buttons">Wissel muisknoppen</string> + <string name="settings_ui_invert_scrolling">Scrollen omkeren</string> + <string name="settings_ui_auto_scroll_touchpointer">Touch Pointer Auto Scroll</string> + <string name="settings_ui_ask_on_exit">Toon dialoog bij sluiten</string> + <string name="settings_cat_power">Energiebesparing</string> + <string name="settings_power_disconnect_timeout">Sluit inactieve ingen</string> + <string name="settings_cat_security">Beveiliging</string> + <string name="settings_security_accept_certificates">Accepteer alle certificaten</string> + <string name="settings_security_clear_certificate_cache">Certificaat cache opschonen</string> + <string name="settings_description_after_minutes">na %1$d minuten</string> + <string name="settings_description_disabled">Uitgeschakeld</string> + <!-- Activity titles --> + <string name="title_bookmark_settings">Connectie instellingen</string> + <string name="title_application_settings">Instellingen</string> + <string name="title_home">aFreeRDP - FreeRDP voor Android</string> + <string name="title_create_shortcut">RDP verbinding</string> + <string name="title_help">Help</string> + <string name="title_about">Over</string> + <!-- Error message strings --> + <string name="error_bookmark_incomplete_title">Annuleren zonder opslaan?</string> + <string name="error_bookmark_incomplete">Druk op "Annuleren" om af te breken!\nKlik op "Doorgaan" om de verplichte velden op te geven!</string> + <string name="error_connection_failure">Fout bij het verbinden met de server!</string> + <!-- Info message strings --> + <string name="info_capabilities_changed">De scherm instellingen zijn veranderd omdat de server de door u opgegeven instellingen niet ondersteunt!</string> + <string name="info_reset_success">Certificaat cache is verwijderd!</string> + <string name="info_reset_failed">Fout bij het verwijderderen van certificaat cache!</string> + <!-- Dialog strings --> + <string name="dlg_title_verify_certificate">Controleer certificaat</string> + <string name="dlg_msg_verify_certificate">De identiteit van de externe computer niet kan worden geverifieerd. Wilt u toch verbinden?</string> + <string name="dlg_title_credentials">Vul uw gegevens in</string> + <string name="dlg_title_create_shortcut">Snelkoppeling maken</string> + <string name="dlg_msg_create_shortcut">Snelkoppeling naam:</string> + <string name="dlg_msg_connecting">Verbinden ...</string> + <string name="dlg_msg_logging_in">Aanmelden ...</string> + <string name="dlg_title_about">Over aFreeRDP</string> + <string name="dlg_msg_about">Versie: %1$s\n\u00A9 2012 Thinstuff Technologies GmbH</string> + <string name="dlg_title_create_bookmark_after_qc">Connectie instellingen opslaan?</string> + <string name="dlg_msg_create_bookmark_after_qc">Uw connectie instellingen zijn niet opgeslagen! Wilt u deze opslaan?</string> + <string name="dlg_title_save_bookmark">Verbinding opslaan?</string> + <string name="dlg_save_bookmark">Wilt u alle wijzigingen opslaan?</string> + <string name="dlg_dont_show_again">Niet opnieuw vragen</string> + <string name="dlg_title_exit">Toepassing sluiten?</string> + <string name="dlg_msg_exit">Weet u zeker dat u de applicatie wilt sluiten?</string> + <string name="dlg_title_clear_cert_cache">Verwijder certificaten?</string> + <string name="dlg_msg_clear_cert_cache">Weet u zeker dat u al uw cache certificaten wilt verwijderen?</string> +</resources> From 351acdd4077054e7d3674ee9b4b793a9bc38f462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 3 May 2013 23:29:04 -0400 Subject: [PATCH 065/144] cmake: added PAM detection script --- cmake/FindPAM.cmake | 40 ++++++++++++++++++++++++++++++++++++++++ server/.gitignore | 1 + 2 files changed, 41 insertions(+) create mode 100644 cmake/FindPAM.cmake diff --git a/cmake/FindPAM.cmake b/cmake/FindPAM.cmake new file mode 100644 index 000000000..1fdaa6cae --- /dev/null +++ b/cmake/FindPAM.cmake @@ -0,0 +1,40 @@ +# - Try to find the PAM libraries +# Once done this will define +# +# PAM_FOUND - system has pam +# PAM_INCLUDE_DIR - the pam include directory +# PAM_LIBRARIES - libpam library + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FIND_QUIETLY TRUE) +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) +find_library(PAM_LIBRARY pam) +find_library(DL_LIBRARY dl) + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FOUND TRUE) + if (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) + else (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY}) + endif (DL_LIBRARY) + + if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + set(HAVE_PAM_PAM_APPL_H 1) + endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +if (PAM_FOUND) + if (NOT PAM_FIND_QUIETLY) + message(STATUS "Found PAM: ${PAM_LIBRARIES}") + endif (NOT PAM_FIND_QUIETLY) +else (PAM_FOUND) + if (PAM_FIND_REQUIRED) + message(FATAL_ERROR "PAM was not found") + endif(PAM_FIND_REQUIRED) +endif (PAM_FOUND) + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY) + diff --git a/server/.gitignore b/server/.gitignore index d18fe8fe7..e8786806f 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1,2 +1,3 @@ WaykServer +xrdp-ng From 43fe216179de0655af29a03857cc296ec7654589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 5 May 2013 15:01:13 -0400 Subject: [PATCH 066/144] cmake: include xrdp-ng if present --- server/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 0d54cf7e5..265706ba5 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -36,6 +36,12 @@ else() endif() if(WITH_WAYK) - add_subdirectory(WaykServer) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/WaykServer") + add_subdirectory(WaykServer) + endif() +endif() + +if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/xrdp-ng") + add_subdirectory("xrdp-ng") endif() From b5901d01a16cd29d60bb84f3f391c80c699c8f4b Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Mon, 6 May 2013 03:09:08 -0700 Subject: [PATCH 067/144] Android: Unregister settings changed listener --- .../com/freerdp/freerdpcore/presentation/BookmarkActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java index dbff71478..004a716e7 100644 --- a/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java +++ b/client/Android/FreeRDPCore/src/com/freerdp/freerdpcore/presentation/BookmarkActivity.java @@ -526,6 +526,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref private void finishAndResetBookmark() { bookmark = null; + getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); finish(); } @@ -536,6 +537,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref if (current_preferences != PREFERENCES_BOOKMARK) { super.onBackPressed(); + getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); return; } From 95c5ea86b09ae74eb9744d75eebe22efc2f4f1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 6 May 2013 22:27:19 -0400 Subject: [PATCH 068/144] libfreerdp-core: start implementing server-side drawing orders --- libfreerdp/core/orders.c | 60 ++++++++++++++++++++++++++++++++++++++-- libfreerdp/core/orders.h | 1 + libfreerdp/core/update.c | 30 +++++++++++++++++++- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 277287032..21e6c7f74 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -154,6 +154,7 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, lsi8); *coord += lsi8; } @@ -161,9 +162,27 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) { if (Stream_GetRemainingLength(s) < 2) return FALSE; + stream_read_UINT16(s, lsi16); *coord = lsi16; } + + return TRUE; +} + +static INLINE BOOL update_write_coord(wStream* s, INT32 coord) +{ + stream_write_UINT16(s, coord); + return TRUE; +} + +static INLINE BOOL update_write_coord_delta(wStream* s, INT32 prevCoord, INT32 nextCoord) +{ + INT8 lsi8; + + lsi8 = nextCoord - prevCoord; + stream_write_BYTE(s, lsi8); + return TRUE; } @@ -623,23 +642,59 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFFFF00) | byte; } - if (orderInfo->fieldFlags & ORDER_FIELD_06) { + if (orderInfo->fieldFlags & ORDER_FIELD_06) + { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFF00FF) | (byte << 8); } - if (orderInfo->fieldFlags & ORDER_FIELD_07) { + if (orderInfo->fieldFlags & ORDER_FIELD_07) + { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, byte); opaque_rect->color = (opaque_rect->color & 0xFF00FFFF) | (byte << 16); } + + return TRUE; +} + +BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect) +{ + BYTE byte; + + orderInfo->fieldFlags = 0; + + orderInfo->fieldFlags |= ORDER_FIELD_01; + update_write_coord(s, opaque_rect->nLeftRect); + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, opaque_rect->nTopRect); + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, opaque_rect->nWidth); + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, opaque_rect->nHeight); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + byte = opaque_rect->color & 0x000000FF; + stream_write_BYTE(s, byte); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + byte = (opaque_rect->color & 0x0000FF00) >> 8; + stream_write_BYTE(s, byte); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + byte = (opaque_rect->color & 0x00FF0000) >> 16; + stream_write_BYTE(s, byte); + return TRUE; } @@ -722,6 +777,7 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { BYTE byte; + ORDER_FIELD_COORD(1, multi_opaque_rect->nLeftRect); ORDER_FIELD_COORD(2, multi_opaque_rect->nTopRect); ORDER_FIELD_COORD(3, multi_opaque_rect->nWidth); diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index d8f807394..e892a40ea 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -192,6 +192,7 @@ BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* d BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt); BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); +BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid); BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt); BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index d5565cbbc..f2001f5e6 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -22,6 +22,7 @@ #endif #include <winpr/crt.h> +#include <winpr/print.h> #include <winpr/thread.h> #include <winpr/collections.h> @@ -57,6 +58,7 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s) { if (!update_recv_order(update, s)) return FALSE; + numberOrders--; } @@ -592,6 +594,31 @@ static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) +{ + wStream* s; + BYTE *bm, *em; + ORDER_INFO orderInfo; + rdpRdp* rdp = context->rdp; + + orderInfo.fieldFlags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 5); + update_write_opaque_rect_order(s, &orderInfo, opaque_rect); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_BYTE(s, ORDER_TYPE_OPAQUE_RECT); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) { wStream* s; @@ -721,6 +748,7 @@ void update_register_server_callbacks(rdpUpdate* update) update->SurfaceFrameMarker = update_send_surface_frame_marker; update->SurfaceCommand = update_send_surface_command; update->primary->ScrBlt = update_send_scrblt; + update->primary->OpaqueRect = update_send_opaque_rect; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; update->pointer->PointerNew = update_send_pointer_new; @@ -745,7 +773,7 @@ rdpUpdate* update_new(rdpRdp* rdp) update = (rdpUpdate*) malloc(sizeof(rdpUpdate)); - if (update != NULL) + if (update) { OFFSCREEN_DELETE_LIST* deleteList; From e048147bde613de3cbf01f566f0d21d184704bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 6 May 2013 23:21:12 -0400 Subject: [PATCH 069/144] libfreerdp-core: start implement server-side bitmap cache v2 --- libfreerdp/core/orders.c | 139 +++++++++++++++++++++++++++++++++++++++ libfreerdp/core/orders.h | 1 + libfreerdp/core/update.c | 27 ++++++++ 3 files changed, 167 insertions(+) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 21e6c7f74..7e3e152ed 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -135,6 +135,15 @@ static const BYTE CBR2_BPP[] = 0, 0, 0, 8, 16, 24, 32 }; +static const BYTE BPP_CBR2[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0 +}; + static const BYTE CBR23_BPP[] = { 0, 0, 0, 8, 16, 24, 32 @@ -248,6 +257,29 @@ static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) { *value = (byte & 0x7F); } + + return TRUE; +} + +static INLINE BOOL update_write_2byte_unsigned(wStream* s, UINT32 value) +{ + BYTE byte; + + if (value > 0x7FFF) + return FALSE; + + if (value >= 0x7F) + { + byte = ((value & 0x7F00) >> 8); + stream_write_BYTE(s, byte); + byte = (value & 0xFF); + stream_write_BYTE(s, byte); + } + else + { + stream_write_BYTE(s, value); + } + return TRUE; } @@ -324,6 +356,50 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value) default: break; } + + return TRUE; +} + +static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value) +{ + BYTE byte; + + if (value <= 0x3F) + { + stream_write_BYTE(s, value); + } + else if (value <= 0x3FFF) + { + byte = (value >> 8) & 0x3F; + stream_write_BYTE(s, byte); + byte = (value & 0xFF); + stream_write_BYTE(s, byte); + } + else if (value <= 0x3FFFFF) + { + byte = (value >> 16) & 0x3F; + stream_write_BYTE(s, byte); + byte = (value >> 8) & 0xFF; + stream_write_BYTE(s, byte); + byte = (value & 0xFF); + stream_write_BYTE(s, byte); + } + else if (value <= 0x3FFFFF) + { + byte = (value >> 24) & 0x3F; + stream_write_BYTE(s, byte); + byte = (value >> 16) & 0xFF; + stream_write_BYTE(s, byte); + byte = (value >> 8) & 0xFF; + stream_write_BYTE(s, byte); + byte = (value & 0xFF); + stream_write_BYTE(s, byte); + } + else + { + return FALSE; + } + return TRUE; } @@ -1200,6 +1276,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ { if (Stream_GetRemainingLength(s) < 8) return FALSE; + stream_read_UINT32(s, cache_bitmap_v2_order->key1); /* key1 (4 bytes) */ stream_read_UINT32(s, cache_bitmap_v2_order->key2); /* key2 (4 bytes) */ } @@ -1208,6 +1285,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ { if (!update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapWidth)) /* bitmapWidth */ return FALSE; + cache_bitmap_v2_order->bitmapHeight = cache_bitmap_v2_order->bitmapWidth; } else @@ -1240,6 +1318,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) return FALSE; + stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); } @@ -1247,10 +1326,70 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ { if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) return FALSE; + stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); } + cache_bitmap_v2_order->compressed = compressed; + + return TRUE; +} + +BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2, BOOL compressed, UINT16* flags) +{ + BYTE bitsPerPixelId; + + bitsPerPixelId = BPP_CBR2[cache_bitmap_v2->bitmapBpp]; + + *flags = (cache_bitmap_v2->cacheId & 0x0003) | + (bitsPerPixelId << 3) | ((cache_bitmap_v2->flags << 7) & 0xFF80); + + if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT) + { + stream_write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ + stream_write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ + } + + if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH) + { + if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */ + return FALSE; + } + else + { + if (!update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */ + !update_write_2byte_unsigned(s, cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */ + return FALSE; + } + + if (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) || /* bitmapLength */ + !update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex)) /* cacheIndex */ + return FALSE; + + if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE) + cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX; + + if (compressed) + { + if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) + { + stream_write_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ + stream_write_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ + stream_write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ + stream_write_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ + cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize; + } + + Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength); + } + else + { + Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength); + } + + cache_bitmap_v2->compressed = compressed; + return TRUE; } diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index e892a40ea..3b95c2915 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -214,6 +214,7 @@ BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags); BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16 flags); +BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16* flags); BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, BOOL compressed, UINT16 flags); BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags); BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index f2001f5e6..5ecfc455a 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -619,6 +619,32 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) +{ + wStream* s; + UINT16 flags; + BYTE *bm, *em; + rdpRdp* rdp = context->rdp; + + flags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 8); + update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, FALSE, &flags); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_UINT16(s, 0); /* orderLength (2 bytes) */ + stream_write_UINT16(s, 0); /* extraFlags (2 bytes) */ + stream_write_BYTE(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) { wStream* s; @@ -749,6 +775,7 @@ void update_register_server_callbacks(rdpUpdate* update) update->SurfaceCommand = update_send_surface_command; update->primary->ScrBlt = update_send_scrblt; update->primary->OpaqueRect = update_send_opaque_rect; + update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; update->pointer->PointerNew = update_send_pointer_new; From 544f5997bc27e9bb381c0b02ccaa7231e72f4f15 Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Tue, 7 May 2013 12:05:21 +0200 Subject: [PATCH 070/144] iOS: Got rid of device UID --- .../BookmarkGatewaySettingsController.h | 13 ++ .../BookmarkGatewaySettingsController.m | 122 ++++++++++++++++++ client/iOS/Controllers/EncryptionController.m | 9 +- 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 client/iOS/Controllers/BookmarkGatewaySettingsController.h create mode 100644 client/iOS/Controllers/BookmarkGatewaySettingsController.m diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.h b/client/iOS/Controllers/BookmarkGatewaySettingsController.h new file mode 100644 index 000000000..9a5d02d25 --- /dev/null +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.h @@ -0,0 +1,13 @@ +// +// BookmarkGatewaySettingsController.h +// FreeRDP +// +// Created by Thinstuff Developer on 4/30/13. +// +// + +#import <UIKit/UIKit.h> + +@interface BookmarkGatewaySettingsController : UITableViewController + +@end diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.m b/client/iOS/Controllers/BookmarkGatewaySettingsController.m new file mode 100644 index 000000000..ef9463add --- /dev/null +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.m @@ -0,0 +1,122 @@ +// +// BookmarkGatewaySettingsController.m +// FreeRDP +// +// Created by Thinstuff Developer on 4/30/13. +// +// + +#import "BookmarkGatewaySettingsController.h" + +@interface BookmarkGatewaySettingsController () + +@end + +@implementation BookmarkGatewaySettingsController + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ +#warning Potentially incomplete method implementation. + // Return the number of sections. + return 0; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ +#warning Incomplete method implementation. + // Return the number of rows in the section. + return 0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + + // Configure the cell... + + return cell; +} + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } + else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +{ +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Navigation logic may go here. Create and push another view controller. + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + [detailViewController release]; + */ +} + +@end diff --git a/client/iOS/Controllers/EncryptionController.m b/client/iOS/Controllers/EncryptionController.m index 089e87a44..4c8982e62 100644 --- a/client/iOS/Controllers/EncryptionController.m +++ b/client/iOS/Controllers/EncryptionController.m @@ -9,6 +9,7 @@ #import "EncryptionController.h" #import "SFHFKeychainUtils.h" +#import "TSXAdditions.h" @interface EncryptionController (Private) @@ -109,7 +110,13 @@ static EncryptionController* _shared_encryption_controller = nil; - (NSString*)keychainDefaultPassword { - return [[UIDevice currentDevice] uniqueIdentifier]; + NSString* password = [[NSUserDefaults standardUserDefaults] stringForKey:@"UUID"]; + if ([password length] == 0) + { + password = [NSString stringWithUUID]; + [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"]; + } + return password; } #pragma mark - From cc188b5796505bdb22c53457a185ca5904c20c75 Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Tue, 7 May 2013 12:38:25 +0200 Subject: [PATCH 071/144] iOS: Remove verification data when UUID is created --- client/iOS/Controllers/EncryptionController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/client/iOS/Controllers/EncryptionController.m b/client/iOS/Controllers/EncryptionController.m index 4c8982e62..0f1ae7987 100644 --- a/client/iOS/Controllers/EncryptionController.m +++ b/client/iOS/Controllers/EncryptionController.m @@ -115,6 +115,7 @@ static EncryptionController* _shared_encryption_controller = nil; { password = [NSString stringWithUUID]; [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"UUID"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TSXMasterPasswordVerification"]; } return password; } From 10bdf155e9cd2556bb933f36b510448215b30849 Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Tue, 7 May 2013 07:01:04 -0700 Subject: [PATCH 072/144] libfreerdp-core: Limit multifrag max size to 0xFFFF --- docs/README.ios | 8 ++++++++ libfreerdp/core/capabilities.c | 2 -- libfreerdp/core/settings.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/README.ios b/docs/README.ios index 38f6a24a7..ad7a045be 100644 --- a/docs/README.ios +++ b/docs/README.ios @@ -52,6 +52,14 @@ If you want to specify an output directory add CONFIGURATION_BUILD_DIR=<output-p * If using XCode choose "Open Other" from the welcome screen, browse to the FreeRDP root directory and select FreeRDP.xcodeproj. +* If you switch between platforms (OS and SIMULATOR) please remove CMakeCache.txt and CMakeFiles/ before calling cmake again. + Otherwise build errors might occur (this seems to be a bug with cmake or the cmake scripts). To switch between platforms do: + + rm CMakeCache.txt + rm -rf CMakeFiles/ + + before you run a new cmake command with the desired platform. + cmake variables =============== diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index a927b3cc2..d36737b06 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -2195,8 +2195,6 @@ BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdp return FALSE; stream_read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ - if (settings->MultifragMaxRequestSize < multifragMaxRequestSize) - settings->MultifragMaxRequestSize = multifragMaxRequestSize; return TRUE; } diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 8411b4b88..1ed7d27f8 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -375,7 +375,7 @@ rdpSettings* freerdp_settings_new(void* instance) settings->VirtualChannelChunkSize = CHANNEL_CHUNK_LENGTH; - settings->MultifragMaxRequestSize = 0x200000; + settings->MultifragMaxRequestSize = 0xFFFF; settings->GatewayUseSameCredentials = TRUE; From 230380184d919dd3a7f0d5d09777e32f0c1ba6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 11:41:32 -0400 Subject: [PATCH 073/144] libfreerdp-core: add server-side Memblt and CacheGlyph --- libfreerdp/core/orders.c | 132 ++++++++++++++++++++++++++++++++++++--- libfreerdp/core/orders.h | 2 + libfreerdp/core/update.c | 57 ++++++++++++++++- 3 files changed, 180 insertions(+), 11 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 7e3e152ed..15f5b8e3e 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -271,13 +271,14 @@ static INLINE BOOL update_write_2byte_unsigned(wStream* s, UINT32 value) if (value >= 0x7F) { byte = ((value & 0x7F00) >> 8); - stream_write_BYTE(s, byte); + stream_write_BYTE(s, byte | 0x80); byte = (value & 0xFF); stream_write_BYTE(s, byte); } else { - stream_write_BYTE(s, value); + byte = (value & 0x7F); + stream_write_BYTE(s, byte); } return TRUE; @@ -301,12 +302,52 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value) { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, byte); *value = (*value << 8) | byte; } if (negative) *value *= -1; + + return TRUE; +} + +static INLINE BOOL update_write_2byte_signed(wStream* s, INT32 value) +{ + BYTE byte; + BOOL negative = FALSE; + + if (value < 0) + { + negative = TRUE; + value *= -1; + } + + if (value > 0x3FFF) + return FALSE; + + if (value >= 0x3F) + { + byte = ((value & 0x3F00) >> 8); + + if (negative) + byte |= 0x40; + + stream_write_BYTE(s, byte | 0x80); + byte = (value & 0xFF); + stream_write_BYTE(s, byte); + } + else + { + byte = (value & 0x3F); + + if (negative) + byte |= 0x40; + + stream_write_BYTE(s, byte); + } + return TRUE; } @@ -968,6 +1009,43 @@ BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* m memblt->colorIndex = (memblt->cacheId >> 8); memblt->cacheId = (memblt->cacheId & 0xFF); + + return TRUE; +} + +BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt) +{ + UINT16 cacheId; + + cacheId = (memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8); + + orderInfo->fieldFlags |= ORDER_FIELD_01; + stream_write_UINT16(s, memblt->cacheId); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, memblt->nLeftRect); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, memblt->nTopRect); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, memblt->nWidth); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + update_write_coord(s, memblt->nHeight); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + stream_write_BYTE(s, memblt->bRop); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + update_write_coord(s, memblt->nXSrc); + + orderInfo->fieldFlags |= ORDER_FIELD_08; + update_write_coord(s, memblt->nYSrc); + + orderInfo->fieldFlags |= ORDER_FIELD_09; + stream_write_UINT16(s, memblt->cacheIndex); + return TRUE; } @@ -1506,18 +1584,18 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or return TRUE; } -BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, UINT16 flags) +BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16 flags) { int i; GLYPH_DATA_V2* glyph; - cache_glyph_v2_order->cacheId = (flags & 0x000F); - cache_glyph_v2_order->flags = (flags & 0x00F0) >> 4; - cache_glyph_v2_order->cGlyphs = (flags & 0xFF00) >> 8; + cache_glyph_v2->cacheId = (flags & 0x000F); + cache_glyph_v2->flags = (flags & 0x00F0) >> 4; + cache_glyph_v2->cGlyphs = (flags & 0xFF00) >> 8; - for (i = 0; i < (int) cache_glyph_v2_order->cGlyphs; i++) + for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++) { - glyph = &cache_glyph_v2_order->glyphData[i]; + glyph = &cache_glyph_v2->glyphData[i]; if (Stream_GetRemainingLength(s) < 1) return FALSE; @@ -1544,7 +1622,43 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl if (flags & CG_GLYPH_UNICODE_PRESENT) { - return stream_skip(s, cache_glyph_v2_order->cGlyphs * 2); + return stream_skip(s, cache_glyph_v2->cGlyphs * 2); + } + + return TRUE; +} + +BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags) +{ + int i; + GLYPH_DATA_V2* glyph; + + *flags = (cache_glyph_v2->cacheId & 0x000F) | + ((cache_glyph_v2->flags & 0x000F) << 4) | + ((cache_glyph_v2->cGlyphs & 0x00FF) << 8); + + for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++) + { + glyph = &cache_glyph_v2->glyphData[i]; + + stream_write_BYTE(s, glyph->cacheIndex); + + if (!update_write_2byte_signed(s, glyph->x) || + !update_write_2byte_signed(s, glyph->y) || + !update_write_2byte_unsigned(s, glyph->cx) || + !update_write_2byte_unsigned(s, glyph->cy)) + { + return FALSE; + } + + glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; + glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; + stream_write(s, glyph->aj, glyph->cb); + } + + if (*flags & CG_GLYPH_UNICODE_PRESENT) + { + Stream_Zero(s, cache_glyph_v2->cGlyphs * 2); } return TRUE; diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 3b95c2915..598333c85 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -202,6 +202,7 @@ BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, M BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to); BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline); BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt); +BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt); BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt); BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap); BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index); @@ -219,6 +220,7 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags); BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags); BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, UINT16 flags); +BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags); BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags); BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 5ecfc455a..56882c077 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -619,6 +619,31 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) +{ + wStream* s; + BYTE *bm, *em; + ORDER_INFO orderInfo; + rdpRdp* rdp = context->rdp; + + orderInfo.fieldFlags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 5); + update_write_memblt_order(s, &orderInfo, memblt); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_BYTE(s, ORDER_TYPE_MEMBLT); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) { wStream* s; @@ -637,14 +662,40 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, 0); /* orderLength (2 bytes) */ - stream_write_UINT16(s, 0); /* extraFlags (2 bytes) */ + stream_write_UINT16(s, (em - bm) - 13); /* orderLength (2 bytes) */ + stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ stream_write_BYTE(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) +{ + wStream* s; + UINT16 flags; + BYTE *bm, *em; + rdpRdp* rdp = context->rdp; + + flags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 8); + update_write_cache_glyph_v2_order(s, cache_glyph_v2, &flags); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_UINT16(s, (em - bm) - 13); /* orderLength (2 bytes) */ + stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ + stream_write_BYTE(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) { wStream* s; @@ -775,7 +826,9 @@ void update_register_server_callbacks(rdpUpdate* update) update->SurfaceCommand = update_send_surface_command; update->primary->ScrBlt = update_send_scrblt; update->primary->OpaqueRect = update_send_opaque_rect; + update->primary->MemBlt = update_send_memblt; update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; + update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; update->pointer->PointerNew = update_send_pointer_new; From afefc7a57f0c13c7faa2e3ed45f9f80081df1023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 12:45:52 -0400 Subject: [PATCH 074/144] libfreerdp-core: added server-side PatBlt and ScrBlt --- libfreerdp/core/orders.c | 203 +++++++++++++++++++++++++++++++++++++++ libfreerdp/core/orders.h | 3 + libfreerdp/core/update.c | 72 ++++++++++++-- 3 files changed, 269 insertions(+), 9 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 15f5b8e3e..b799c1f8d 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -201,12 +201,28 @@ static INLINE BOOL update_read_color(wStream* s, UINT32* color) if (Stream_GetRemainingLength(s) < 3) return FALSE; + stream_read_BYTE(s, byte); *color = byte; stream_read_BYTE(s, byte); *color |= (byte << 8); stream_read_BYTE(s, byte); *color |= (byte << 16); + + return TRUE; +} + +static INLINE BOOL update_write_color(wStream* s, UINT32 color) +{ + BYTE byte; + + byte = (color & 0xFF); + stream_write_BYTE(s, byte); + byte = ((color >> 8) & 0xFF); + stream_write_BYTE(s, byte); + byte = ((color >> 16) & 0xFF); + stream_write_BYTE(s, byte); + return TRUE; } @@ -495,6 +511,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, brush->x); } @@ -502,6 +519,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, brush->y); } @@ -509,6 +527,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, brush->style); } @@ -516,6 +535,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, brush->hatch); } @@ -533,6 +553,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag { if (Stream_GetRemainingLength(s) < 7) return FALSE; + brush->data = (BYTE*) brush->p8x8; stream_read_BYTE(s, brush->data[7]); stream_read_BYTE(s, brush->data[6]); @@ -543,6 +564,55 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag stream_read_BYTE(s, brush->data[1]); brush->data[0] = brush->hatch; } + + return TRUE; +} + +static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags) +{ + if (fieldFlags & ORDER_FIELD_01) + { + stream_write_BYTE(s, brush->x); + } + + if (fieldFlags & ORDER_FIELD_02) + { + stream_write_BYTE(s, brush->y); + } + + if (fieldFlags & ORDER_FIELD_03) + { + stream_write_BYTE(s, brush->style); + } + + if (fieldFlags & ORDER_FIELD_04) + { + stream_write_BYTE(s, brush->hatch); + } + + if (brush->style & CACHED_BRUSH) + { + brush->index = brush->hatch; + + brush->bpp = BMF_BPP[brush->style & 0x0F]; + + if (brush->bpp == 0) + brush->bpp = 1; + } + + if (fieldFlags & ORDER_FIELD_05) + { + brush->data = (BYTE*) brush->p8x8; + stream_write_BYTE(s, brush->data[7]); + stream_write_BYTE(s, brush->data[6]); + stream_write_BYTE(s, brush->data[5]); + stream_write_BYTE(s, brush->data[4]); + stream_write_BYTE(s, brush->data[3]); + stream_write_BYTE(s, brush->data[2]); + stream_write_BYTE(s, brush->data[1]); + brush->data[0] = brush->hatch; + } + return TRUE; } @@ -734,6 +804,41 @@ BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* p return update_read_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7); } +BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt) +{ + orderInfo->fieldFlags = 0; + + orderInfo->fieldFlags |= ORDER_FIELD_01; + update_write_coord(s, patblt->nLeftRect); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, patblt->nTopRect); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, patblt->nWidth); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, patblt->nHeight); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + stream_write_BYTE(s, patblt->bRop); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + update_write_coord(s, patblt->backColor); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + update_write_coord(s, patblt->foreColor); + + orderInfo->fieldFlags |= ORDER_FIELD_08; + orderInfo->fieldFlags |= ORDER_FIELD_09; + orderInfo->fieldFlags |= ORDER_FIELD_10; + orderInfo->fieldFlags |= ORDER_FIELD_11; + orderInfo->fieldFlags |= ORDER_FIELD_12; + update_write_brush(s, &patblt->brush, orderInfo->fieldFlags >> 7); + + return TRUE; +} + BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt) { ORDER_FIELD_COORD(1, scrblt->nLeftRect); @@ -743,6 +848,35 @@ BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* s ORDER_FIELD_BYTE(5, scrblt->bRop); ORDER_FIELD_COORD(6, scrblt->nXSrc); ORDER_FIELD_COORD(7, scrblt->nYSrc); + + return TRUE; +} + +BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt) +{ + orderInfo->fieldFlags = 0; + + orderInfo->fieldFlags |= ORDER_FIELD_01; + update_write_coord(s, scrblt->nLeftRect); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, scrblt->nTopRect); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, scrblt->nWidth); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, scrblt->nHeight); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + stream_write_BYTE(s, scrblt->bRop); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + update_write_coord(s, scrblt->nXSrc); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + update_write_coord(s, scrblt->nYSrc); + return TRUE; } @@ -1109,13 +1243,82 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE { if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, glyph_index->cbData); if (Stream_GetRemainingLength(s) < glyph_index->cbData) return FALSE; + memcpy(glyph_index->data, s->pointer, glyph_index->cbData); Stream_Seek(s, glyph_index->cbData); } + + return TRUE; +} + +BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index) +{ + orderInfo->fieldFlags = 0; + + orderInfo->fieldFlags |= ORDER_FIELD_01; + stream_write_BYTE(s, glyph_index->cacheId); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + stream_write_BYTE(s, glyph_index->flAccel); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + stream_write_BYTE(s, glyph_index->ulCharInc); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + stream_write_BYTE(s, glyph_index->fOpRedundant); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + update_write_color(s, glyph_index->backColor); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + update_write_color(s, glyph_index->foreColor); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + stream_write_UINT16(s, glyph_index->bkLeft); + + orderInfo->fieldFlags |= ORDER_FIELD_08; + stream_write_UINT16(s, glyph_index->bkTop); + + orderInfo->fieldFlags |= ORDER_FIELD_09; + stream_write_UINT16(s, glyph_index->bkRight); + + orderInfo->fieldFlags |= ORDER_FIELD_10; + stream_write_UINT16(s, glyph_index->bkBottom); + + orderInfo->fieldFlags |= ORDER_FIELD_11; + stream_write_UINT16(s, glyph_index->opLeft); + + orderInfo->fieldFlags |= ORDER_FIELD_12; + stream_write_UINT16(s, glyph_index->opTop); + + orderInfo->fieldFlags |= ORDER_FIELD_13; + stream_write_UINT16(s, glyph_index->opRight); + + orderInfo->fieldFlags |= ORDER_FIELD_14; + stream_write_UINT16(s, glyph_index->opBottom); + + orderInfo->fieldFlags |= ORDER_FIELD_15; + orderInfo->fieldFlags |= ORDER_FIELD_16; + orderInfo->fieldFlags |= ORDER_FIELD_17; + orderInfo->fieldFlags |= ORDER_FIELD_18; + orderInfo->fieldFlags |= ORDER_FIELD_19; + update_write_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14); + + orderInfo->fieldFlags |= ORDER_FIELD_20; + stream_write_UINT16(s, glyph_index->x); + + orderInfo->fieldFlags |= ORDER_FIELD_21; + stream_write_UINT16(s, glyph_index->y); + + orderInfo->fieldFlags |= ORDER_FIELD_22; + stream_write_BYTE(s, glyph_index->cbData); + Stream_Write(s, glyph_index->data, glyph_index->cbData); + return TRUE; } diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 598333c85..482600e21 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -190,7 +190,9 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s); BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt); BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); +BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt); +BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt); BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid); @@ -206,6 +208,7 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt); BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap); BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index); +BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index); BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index); BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph); BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 56882c077..1fe28985e 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -571,25 +571,52 @@ static void update_send_desktop_resize(rdpContext* context) rdp_server_reactivate(context->rdp); } +static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) +{ + wStream* s; + BYTE *bm, *em; + ORDER_INFO orderInfo; + rdpRdp* rdp = context->rdp; + + orderInfo.fieldFlags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 5); + update_write_patblt_order(s, &orderInfo, patblt); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_BYTE(s, ORDER_TYPE_PATBLT); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { wStream* s; + BYTE *bm, *em; + ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.fieldFlags = 0; s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + Stream_Seek(s, 5); + update_write_scrblt_order(s, &orderInfo, scrblt); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ stream_write_BYTE(s, ORDER_TYPE_SCRBLT); /* orderType (1 byte) */ - stream_write_BYTE(s, 0x7F); /* fieldFlags (variable) */ - - stream_write_UINT16(s, scrblt->nLeftRect); - stream_write_UINT16(s, scrblt->nTopRect); - stream_write_UINT16(s, scrblt->nWidth); - stream_write_UINT16(s, scrblt->nHeight); - stream_write_BYTE(s, scrblt->bRop); - stream_write_UINT16(s, scrblt->nXSrc); - stream_write_UINT16(s, scrblt->nYSrc); + stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } @@ -644,6 +671,31 @@ static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) +{ + wStream* s; + BYTE *bm, *em; + ORDER_INFO orderInfo; + rdpRdp* rdp = context->rdp; + + orderInfo.fieldFlags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 5); + update_write_glyph_index_order(s, &orderInfo, glyph_index); + em = Stream_Pointer(s); + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_BYTE(s, ORDER_TYPE_GLYPH_INDEX); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) { wStream* s; @@ -824,9 +876,11 @@ void update_register_server_callbacks(rdpUpdate* update) update->SurfaceBits = update_send_surface_bits; update->SurfaceFrameMarker = update_send_surface_frame_marker; update->SurfaceCommand = update_send_surface_command; + update->primary->PatBlt = update_send_patblt; update->primary->ScrBlt = update_send_scrblt; update->primary->OpaqueRect = update_send_opaque_rect; update->primary->MemBlt = update_send_memblt; + update->primary->GlyphIndex = update_send_glyph_index; update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; update->pointer->PointerSystem = update_send_pointer_system; From fe42b77118ed9f68f866973aac7f8b5dbccfbbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 15:33:52 -0400 Subject: [PATCH 075/144] libfreerdp-core: improve server-side primary order header construction --- include/freerdp/primary.h | 1 + libfreerdp/core/orders.c | 19 ++++++++++-- libfreerdp/core/orders.h | 3 ++ libfreerdp/core/update.c | 62 +++++++++++++++++++++++++++++---------- 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index add5a4b64..c65c55aa5 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -73,6 +73,7 @@ typedef struct rdp_brush rdpBrush; struct _ORDER_INFO { + BYTE controlFlags; UINT32 orderType; UINT32 fieldFlags; rdpBounds bounds; diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index b799c1f8d..e50ab582c 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -99,7 +99,7 @@ static const char* const ALTSEC_DRAWING_ORDER_STRINGS[] = #endif /* WITH_DEBUG_ORDERS */ -static const BYTE PRIMARY_DRAWING_ORDER_FIELD_BYTES[] = +const BYTE PRIMARY_DRAWING_ORDER_FIELD_BYTES[] = { DSTBLT_ORDER_FIELD_BYTES, PATBLT_ORDER_FIELD_BYTES, @@ -1126,6 +1126,7 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE return update_read_delta_points(s, polyline->points, polyline->numPoints, polyline->xStart, polyline->yStart); } + return TRUE; } @@ -1154,7 +1155,7 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* cacheId = (memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8); orderInfo->fieldFlags |= ORDER_FIELD_01; - stream_write_UINT16(s, memblt->cacheId); + stream_write_UINT16(s, cacheId); orderInfo->fieldFlags |= ORDER_FIELD_02; update_write_coord(s, memblt->nLeftRect); @@ -2188,6 +2189,20 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi return TRUE; } +BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes) +{ + int i; + BYTE byte; + + for (i = fieldBytes - 1; i >= 0; i--) + { + byte = (fieldFlags << (i * 8)) & 0xFF; + stream_write_BYTE(s, byte); + } + + return TRUE; +} + BOOL update_read_bounds(wStream* s, rdpBounds* bounds) { BYTE flags; diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 482600e21..c741b8a2b 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -188,6 +188,9 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s); +BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes); +BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes); + BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt); BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 1fe28985e..3ab71efd9 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -43,6 +43,8 @@ static const char* const UPDATE_TYPE_STRINGS[] = }; */ +extern const BYTE PRIMARY_DRAWING_ORDER_FIELD_BYTES[]; + BOOL update_recv_orders(rdpUpdate* update, wStream* s) { UINT16 numberOrders; @@ -600,22 +602,29 @@ static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { wStream* s; BYTE *bm, *em; + int headerLength; ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; + orderInfo.orderType = ORDER_TYPE_SCRBLT; orderInfo.fieldFlags = 0; + + headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); - Stream_Seek(s, 5); + Stream_Seek(s, headerLength); update_write_scrblt_order(s, &orderInfo, scrblt); em = Stream_Pointer(s); Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_BYTE(s, ORDER_TYPE_SCRBLT); /* orderType (1 byte) */ - stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -625,22 +634,29 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq { wStream* s; BYTE *bm, *em; + int headerLength; ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; + orderInfo.orderType = ORDER_TYPE_OPAQUE_RECT; orderInfo.fieldFlags = 0; + + headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); - Stream_Seek(s, 5); + Stream_Seek(s, headerLength); update_write_opaque_rect_order(s, &orderInfo, opaque_rect); em = Stream_Pointer(s); Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_BYTE(s, ORDER_TYPE_OPAQUE_RECT); /* orderType (1 byte) */ - stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -650,22 +666,30 @@ static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { wStream* s; BYTE *bm, *em; + int headerLength; ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; + orderInfo.orderType = ORDER_TYPE_MEMBLT; orderInfo.fieldFlags = 0; + + headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); - Stream_Seek(s, 5); + Stream_Seek(s, headerLength); update_write_memblt_order(s, &orderInfo, memblt); em = Stream_Pointer(s); Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_BYTE(s, ORDER_TYPE_MEMBLT); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -675,22 +699,30 @@ static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp { wStream* s; BYTE *bm, *em; + int headerLength; ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; + orderInfo.orderType = ORDER_TYPE_GLYPH_INDEX; orderInfo.fieldFlags = 0; + + headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); - Stream_Seek(s, 5); + Stream_Seek(s, headerLength); update_write_glyph_index_order(s, &orderInfo, glyph_index); em = Stream_Pointer(s); Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_BYTE(s, ORDER_TYPE_GLYPH_INDEX); /* orderType (1 byte) */ + stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -708,7 +740,7 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD bm = Stream_Pointer(s); Stream_Seek(s, 8); - update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, FALSE, &flags); + update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed, &flags); em = Stream_Pointer(s); Stream_Pointer(s) = bm; From 8446c617241c784271e34aa92543d4c52e1ec4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 17:40:54 -0400 Subject: [PATCH 076/144] libfreerdp-core: improve primary order encoding --- libfreerdp/core/orders.c | 89 ++++++++++++++++++++++++++-------------- libfreerdp/core/update.c | 35 ++++++++++------ 2 files changed, 81 insertions(+), 43 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index e50ab582c..5005d57a7 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -1507,6 +1507,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap { if (Stream_GetRemainingLength(s) < 9) return FALSE; + stream_read_BYTE(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ stream_read_BYTE(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ @@ -1520,8 +1521,10 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0) { BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap_order->bitmapComprHdr); + if (Stream_GetRemainingLength(s) < 8) return FALSE; + stream_read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ cache_bitmap_order->bitmapLength -= 8; } @@ -1540,80 +1543,82 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap stream_get_mark(s, cache_bitmap_order->bitmapDataStream); Stream_Seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */ } + cache_bitmap_order->compressed = compressed; + return TRUE; } -BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16 flags) +BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2, BOOL compressed, UINT16 flags) { BYTE bitsPerPixelId; - cache_bitmap_v2_order->cacheId = flags & 0x0003; - cache_bitmap_v2_order->flags = (flags & 0xFF80) >> 7; + cache_bitmap_v2->cacheId = flags & 0x0003; + cache_bitmap_v2->flags = (flags & 0xFF80) >> 7; bitsPerPixelId = (flags & 0x0078) >> 3; - cache_bitmap_v2_order->bitmapBpp = CBR2_BPP[bitsPerPixelId]; + cache_bitmap_v2->bitmapBpp = CBR2_BPP[bitsPerPixelId]; - if (cache_bitmap_v2_order->flags & CBR2_PERSISTENT_KEY_PRESENT) + if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT) { if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, cache_bitmap_v2_order->key1); /* key1 (4 bytes) */ - stream_read_UINT32(s, cache_bitmap_v2_order->key2); /* key2 (4 bytes) */ + stream_read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ + stream_read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ } - if (cache_bitmap_v2_order->flags & CBR2_HEIGHT_SAME_AS_WIDTH) + if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH) { - if (!update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapWidth)) /* bitmapWidth */ + if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth)) /* bitmapWidth */ return FALSE; - cache_bitmap_v2_order->bitmapHeight = cache_bitmap_v2_order->bitmapWidth; + cache_bitmap_v2->bitmapHeight = cache_bitmap_v2->bitmapWidth; } else { - if (!update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapWidth) || /* bitmapWidth */ - !update_read_2byte_unsigned(s, &cache_bitmap_v2_order->bitmapHeight)) /* bitmapHeight */ + if (!update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapWidth) || /* bitmapWidth */ + !update_read_2byte_unsigned(s, &cache_bitmap_v2->bitmapHeight)) /* bitmapHeight */ return FALSE; } - if (!update_read_4byte_unsigned(s, &cache_bitmap_v2_order->bitmapLength) || /* bitmapLength */ - !update_read_2byte_unsigned(s, &cache_bitmap_v2_order->cacheIndex)) /* cacheIndex */ + if (!update_read_4byte_unsigned(s, &cache_bitmap_v2->bitmapLength) || /* bitmapLength */ + !update_read_2byte_unsigned(s, &cache_bitmap_v2->cacheIndex)) /* cacheIndex */ return FALSE; - if (cache_bitmap_v2_order->flags & CBR2_DO_NOT_CACHE) - cache_bitmap_v2_order->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX; + if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE) + cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX; if (compressed) { - if (!(cache_bitmap_v2_order->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) + if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) { if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT16(s, cache_bitmap_v2_order->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2_order->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2_order->cbScanWidth); /* cbScanWidth (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2_order->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ - cache_bitmap_v2_order->bitmapLength = cache_bitmap_v2_order->cbCompMainBodySize; + stream_read_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ + stream_read_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ + stream_read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ + stream_read_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ + cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize; } - if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); - Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); + stream_get_mark(s, cache_bitmap_v2->bitmapDataStream); + Stream_Seek(s, cache_bitmap_v2->bitmapLength); } else { - if (Stream_GetRemainingLength(s) < cache_bitmap_v2_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_v2_order->bitmapDataStream); - Stream_Seek(s, cache_bitmap_v2_order->bitmapLength); + stream_get_mark(s, cache_bitmap_v2->bitmapDataStream); + Stream_Seek(s, cache_bitmap_v2->bitmapLength); } - cache_bitmap_v2_order->compressed = compressed; + cache_bitmap_v2->compressed = compressed; return TRUE; } @@ -2186,6 +2191,7 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi stream_read_BYTE(s, byte); *fieldFlags |= byte << (i * 8); } + return TRUE; } @@ -2194,11 +2200,31 @@ BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fi int i; BYTE byte; - for (i = fieldBytes - 1; i >= 0; i--) + if (fieldBytes == 1) { - byte = (fieldFlags << (i * 8)) & 0xFF; + byte = fieldFlags & 0xFF; stream_write_BYTE(s, byte); } + else if (fieldBytes == 2) + { + byte = fieldFlags & 0xFF; + stream_write_BYTE(s, byte); + byte = (fieldFlags >> 8) & 0xFF; + stream_write_BYTE(s, byte); + } + else if (fieldBytes == 3) + { + byte = fieldFlags & 0xFF; + stream_write_BYTE(s, byte); + byte = (fieldFlags >> 8) & 0xFF; + stream_write_BYTE(s, byte); + byte = (fieldFlags >> 16) & 0xFF; + stream_write_BYTE(s, byte); + } + else + { + return FALSE; + } return TRUE; } @@ -2452,6 +2478,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) if (Stream_GetRemainingLength(s) < 5) return FALSE; + stream_read_UINT16(s, orderLength); /* orderLength (2 bytes) */ stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ stream_read_BYTE(s, orderType); /* orderType (1 byte) */ diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 3ab71efd9..9aef1587b 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -577,22 +577,29 @@ static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) { wStream* s; BYTE *bm, *em; + int headerLength; ORDER_INFO orderInfo; rdpRdp* rdp = context->rdp; + orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; + orderInfo.orderType = ORDER_TYPE_PATBLT; orderInfo.fieldFlags = 0; + + headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); - Stream_Seek(s, 5); + Stream_Seek(s, headerLength); update_write_patblt_order(s, &orderInfo, patblt); em = Stream_Pointer(s); Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_BYTE(s, ORDER_TYPE_PATBLT); /* orderType (1 byte) */ - stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ + stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -687,7 +694,6 @@ static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ - stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -720,7 +726,6 @@ static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ - stream_write_BYTE(s, orderInfo.fieldFlags); /* fieldFlags (variable) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -731,23 +736,26 @@ static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) { wStream* s; - UINT16 flags; BYTE *bm, *em; + UINT16 extraFlags; + INT16 orderLength; rdpRdp* rdp = context->rdp; - flags = 0; + extraFlags = 0; s = fastpath_update_pdu_init(rdp->fastpath); bm = Stream_Pointer(s); Stream_Seek(s, 8); - update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed, &flags); + update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags); em = Stream_Pointer(s); + orderLength = (em - bm) - 13 - 2; + Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, (em - bm) - 13); /* orderLength (2 bytes) */ - stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ + stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + stream_write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ stream_write_BYTE(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ Stream_Pointer(s) = em; @@ -759,6 +767,7 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER wStream* s; UINT16 flags; BYTE *bm, *em; + INT16 orderLength; rdpRdp* rdp = context->rdp; flags = 0; @@ -769,10 +778,12 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER update_write_cache_glyph_v2_order(s, cache_glyph_v2, &flags); em = Stream_Pointer(s); + orderLength = (em - bm) - 13 - 2; + Stream_Pointer(s) = bm; stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, (em - bm) - 13); /* orderLength (2 bytes) */ + stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ stream_write_BYTE(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ Stream_Pointer(s) = em; From c1f8f3746d9bf293b4d588587ddd94399ad68d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 18:44:22 -0400 Subject: [PATCH 077/144] libfreerdp-core: implement server-side cache glyph v1/v2 --- libfreerdp/core/orders.c | 53 ++++++++++++++++++++++++++++++++++------ libfreerdp/core/orders.h | 1 + libfreerdp/core/update.c | 30 +++++++++++++++++++++++ 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 5005d57a7..d0c006b05 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -585,14 +585,9 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFla stream_write_BYTE(s, brush->style); } - if (fieldFlags & ORDER_FIELD_04) - { - stream_write_BYTE(s, brush->hatch); - } - if (brush->style & CACHED_BRUSH) { - brush->index = brush->hatch; + brush->hatch = brush->index; brush->bpp = BMF_BPP[brush->style & 0x0F]; @@ -600,6 +595,11 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFla brush->bpp = 1; } + if (fieldFlags & ORDER_FIELD_04) + { + stream_write_BYTE(s, brush->hatch); + } + if (fieldFlags & ORDER_FIELD_05) { brush->data = (BYTE*) brush->p8x8; @@ -1793,6 +1793,44 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or return TRUE; } +BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags) +{ + int i; + INT16 lsi16; + GLYPH_DATA* glyph; + + stream_write_BYTE(s, cache_glyph->cacheId); /* cacheId (1 byte) */ + stream_write_BYTE(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ + + for (i = 0; i < (int) cache_glyph->cGlyphs; i++) + { + glyph = &cache_glyph->glyphData[i]; + + stream_write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */ + + lsi16 = glyph->x; + stream_write_UINT16(s, lsi16); /* x (2 bytes) */ + + lsi16 = glyph->y; + stream_write_UINT16(s, lsi16); /* y (2 bytes) */ + + stream_write_UINT16(s, glyph->cx); /* cx (2 bytes) */ + stream_write_UINT16(s, glyph->cy); /* cy (2 bytes) */ + + glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; + glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; + + Stream_Write(s, glyph->aj, glyph->cb); + } + + if (*flags & CG_GLYPH_UNICODE_PRESENT) + { + Stream_Zero(s, cache_glyph->cGlyphs * 2); + } + + return TRUE; +} + BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16 flags) { int i; @@ -1862,7 +1900,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; - stream_write(s, glyph->aj, glyph->cb); + Stream_Write(s, glyph->aj, glyph->cb); } if (*flags & CG_GLYPH_UNICODE_PRESENT) @@ -2197,7 +2235,6 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes) { - int i; BYTE byte; if (fieldBytes == 1) diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index c741b8a2b..97dfa59b2 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -225,6 +225,7 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, BOOL compressed, UINT16 flags); BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags); BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags); +BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16* flags); BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, UINT16 flags); BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags); BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 9aef1587b..e9144beb5 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -762,6 +762,35 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); } +static void update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph) +{ + wStream* s; + UINT16 flags; + BYTE *bm, *em; + INT16 orderLength; + rdpRdp* rdp = context->rdp; + + flags = 0; + s = fastpath_update_pdu_init(rdp->fastpath); + bm = Stream_Pointer(s); + + Stream_Seek(s, 8); + update_write_cache_glyph_v2_order(s, cache_glyph, &flags); + em = Stream_Pointer(s); + + orderLength = (em - bm) - 13 - 2; + + Stream_Pointer(s) = bm; + stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ + stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ + stream_write_BYTE(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ + Stream_Pointer(s) = em; + + fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); +} + static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) { wStream* s; @@ -925,6 +954,7 @@ void update_register_server_callbacks(rdpUpdate* update) update->primary->MemBlt = update_send_memblt; update->primary->GlyphIndex = update_send_glyph_index; update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; + update->secondary->CacheGlyph = update_send_cache_glyph; update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; From 787a542f9eea96f975daef8d358c3af720d935cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 22:35:33 -0400 Subject: [PATCH 078/144] libfreerdp-core: fix cache glyph sending --- libfreerdp/core/update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index e9144beb5..21d8f92c1 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -775,7 +775,7 @@ static void update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cach bm = Stream_Pointer(s); Stream_Seek(s, 8); - update_write_cache_glyph_v2_order(s, cache_glyph, &flags); + update_write_cache_glyph_order(s, cache_glyph, &flags); em = Stream_Pointer(s); orderLength = (em - bm) - 13 - 2; From 8c5dcabcfbc82bfb46c3c6715e91293f24a499b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 7 May 2013 23:41:39 -0400 Subject: [PATCH 079/144] libfreerdp-core: partially fix server-side bitmap caching --- libfreerdp/core/orders.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index d0c006b05..128285626 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -374,9 +374,11 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; + stream_read_BYTE(s, byte); count = (byte & 0xC0) >> 6; + if (Stream_GetRemainingLength(s) < count) return FALSE; @@ -428,14 +430,14 @@ static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value) else if (value <= 0x3FFF) { byte = (value >> 8) & 0x3F; - stream_write_BYTE(s, byte); + stream_write_BYTE(s, byte | 0x40); byte = (value & 0xFF); stream_write_BYTE(s, byte); } else if (value <= 0x3FFFFF) { byte = (value >> 16) & 0x3F; - stream_write_BYTE(s, byte); + stream_write_BYTE(s, byte | 0x80); byte = (value >> 8) & 0xFF; stream_write_BYTE(s, byte); byte = (value & 0xFF); @@ -444,7 +446,7 @@ static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value) else if (value <= 0x3FFFFF) { byte = (value >> 24) & 0x3F; - stream_write_BYTE(s, byte); + stream_write_BYTE(s, byte | 0xC0); byte = (value >> 16) & 0xFF; stream_write_BYTE(s, byte); byte = (value >> 8) & 0xFF; @@ -1650,13 +1652,13 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache return FALSE; } + if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE) + cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX; + if (!update_write_4byte_unsigned(s, cache_bitmap_v2->bitmapLength) || /* bitmapLength */ !update_write_2byte_unsigned(s, cache_bitmap_v2->cacheIndex)) /* cacheIndex */ return FALSE; - if (cache_bitmap_v2->flags & CBR2_DO_NOT_CACHE) - cache_bitmap_v2->cacheIndex = BITMAP_CACHE_WAITING_LIST_INDEX; - if (compressed) { if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) From 935aa5e2eabbfebf52f551f67f7d9986399c8775 Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Wed, 8 May 2013 14:50:29 +0200 Subject: [PATCH 080/144] iOS: Added TS Gateway support --- .../AdvancedBookmarkEditorController.m | 85 +++++-- .../BookmarkGatewaySettingsController.h | 30 ++- .../BookmarkGatewaySettingsController.m | 238 +++++++++++++----- .../Controllers/CredentialsEditorController.m | 6 + .../Controllers/PerformanceEditorController.m | 6 + client/iOS/Defaults.plist | 12 + client/iOS/Models/RDPSession.m | 12 + libfreerdp/core/gateway/tsg.h | 4 +- 8 files changed, 297 insertions(+), 96 deletions(-) diff --git a/client/iOS/Controllers/AdvancedBookmarkEditorController.m b/client/iOS/Controllers/AdvancedBookmarkEditorController.m index 17b9750ba..a0357d9e6 100644 --- a/client/iOS/Controllers/AdvancedBookmarkEditorController.m +++ b/client/iOS/Controllers/AdvancedBookmarkEditorController.m @@ -13,6 +13,7 @@ #import "EditorSelectionController.h" #import "ScreenSelectionController.h" #import "PerformanceEditorController.h" +#import "BookmarkGatewaySettingsController.h" @interface AdvancedBookmarkEditorController () @@ -68,7 +69,7 @@ switch (section) { case SECTION_ADVANCED_SETTINGS: // advanced settings - return 7; + return 9; default: break; } @@ -100,23 +101,29 @@ { switch([indexPath row]) { - case 0: // 3G Settings + case 0: // Enable/Disable TSG Settings cellType = TableCellIdentifierYesNo; break; - case 1: // 3G screen/color depth - cellType = TableCellIdentifierSelection; - break; - case 2: // 3G performance settings + case 1: // TS Gateway Settings cellType = TableCellIdentifierSubEditor; break; - case 3: // security mode + case 2: // 3G Settings + cellType = TableCellIdentifierYesNo; + break; + case 3: // 3G screen/color depth cellType = TableCellIdentifierSelection; break; - case 4: // remote program - case 5: // work dir + case 4: // 3G performance settings + cellType = TableCellIdentifierSubEditor; + break; + case 5: // security mode + cellType = TableCellIdentifierSelection; + break; + case 6: // remote program + case 7: // work dir cellType = TableCellIdentifierText; break; - case 6: // console mode + case 8: // console mode cellType = TableCellIdentifierYesNo; break; default: @@ -153,6 +160,24 @@ switch(indexPath.row) { case 0: + { + EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; + [[flagCell label] setText:NSLocalizedString(@"Enable TS Gateway", @"'Enable TS Gateway': Bookmark enable TSG settings")]; + [[flagCell toggle] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[flagCell toggle] setOn:[_params boolForKey:@"enable_tsg_settings"]]; + [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; + break; + } + case 1: + { + BOOL enable_tsg_settings = [_params boolForKey:@"enable_tsg_settings"]; + EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; + [[editCell label] setText:NSLocalizedString(@"TS Gateway Settings", @"'TS Gateway Settings': Bookmark TS Gateway Settings")]; + [[editCell label] setEnabled:enable_tsg_settings]; + [editCell setSelectionStyle:enable_tsg_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; + break; + } + case 2: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"3G Settings", @"'3G Settings': Bookmark enable 3G settings")]; @@ -161,7 +186,7 @@ [[flagCell toggle] addTarget:self action:@selector(toggleSettingValue:) forControlEvents:UIControlEventValueChanged]; break; } - case 1: + case 3: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"3G Screen", @"'3G Screen': Bookmark 3G Screen settings")]; @@ -172,8 +197,8 @@ [[selCell selection] setEnabled:enable_3G_settings]; [selCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; - } - case 2: + } + case 4: { EditSubEditTableViewCell* editCell = (EditSubEditTableViewCell*)cell; [[editCell label] setText:NSLocalizedString(@"3G Performance", @"'3G Performance': Bookmark 3G Performance Settings")]; @@ -181,14 +206,14 @@ [editCell setSelectionStyle:enable_3G_settings ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone]; break; } - case 3: + case 5: { EditSelectionTableViewCell* selCell = (EditSelectionTableViewCell*)cell; [[selCell label] setText:NSLocalizedString(@"Security", @"'Security': Bookmark protocl security settings")]; [[selCell selection] setText:ProtocolSecurityDescription([_params intForKey:@"security"])]; break; } - case 4: + case 6: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Remote Program", @"'Remote Program': Bookmark remote program settings")]; @@ -198,7 +223,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 5: + case 7: { EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; [[textCell label] setText:NSLocalizedString(@"Working Directory", @"'Working Directory': Bookmark working directory settings")]; @@ -208,7 +233,7 @@ [self adjustEditTextTableViewCell:textCell]; break; } - case 6: + case 8: { EditFlagTableViewCell* flagCell = (EditFlagTableViewCell*)cell; [[flagCell label] setText:NSLocalizedString(@"Console Mode", @"'Console Mode': Bookmark console mode settings")]; @@ -233,14 +258,18 @@ switch ([indexPath row]) { case 1: + if ([_params boolForKey:@"enable_tsg_settings"]) + viewCtrl = [[[BookmarkGatewaySettingsController alloc] initWithBookmark:_bookmark] autorelease]; + break; + case 3: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[ScreenSelectionController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 2: + case 4: if ([_params boolForKey:@"enable_3g_settings"]) viewCtrl = [[[PerformanceEditorController alloc] initWithConnectionParams:_params keyPath:@"settings_3g"] autorelease]; break; - case 3: + case 5: viewCtrl = [[[EditorSelectionController alloc] initWithConnectionParams:_params entries:[NSArray arrayWithObject:@"security"] selections:[NSArray arrayWithObject:SelectionForSecuritySetting()]] autorelease]; break; default: @@ -267,13 +296,13 @@ switch(textField.tag) { // update remote program/work dir settings - case GET_TAG(SECTION_ADVANCED_SETTINGS, 4): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): { [_params setValue:[textField text] forKey:@"remote_program"]; break; } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 5): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 7): { [_params setValue:[textField text] forKey:@"working_dir"]; break; @@ -293,12 +322,22 @@ switch(valueSwitch.tag) { case GET_TAG(SECTION_ADVANCED_SETTINGS, 0): - [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_tsg_settings"]; NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; break; + } + + case GET_TAG(SECTION_ADVANCED_SETTINGS, 2): + { + [_params setBool:[valueSwitch isOn] forKey:@"enable_3g_settings"]; + NSArray* indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:SECTION_ADVANCED_SETTINGS], [NSIndexPath indexPathForRow:2 inSection:SECTION_ADVANCED_SETTINGS], nil]; + [[self tableView] reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; + break; + } - case GET_TAG(SECTION_ADVANCED_SETTINGS, 6): + case GET_TAG(SECTION_ADVANCED_SETTINGS, 8): [_params setBool:[valueSwitch isOn] forKey:@"console"]; break; diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.h b/client/iOS/Controllers/BookmarkGatewaySettingsController.h index 9a5d02d25..e2c8d5c01 100644 --- a/client/iOS/Controllers/BookmarkGatewaySettingsController.h +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.h @@ -1,13 +1,25 @@ -// -// BookmarkGatewaySettingsController.h -// FreeRDP -// -// Created by Thinstuff Developer on 4/30/13. -// -// +/* + Controller to edit ts gateway bookmark settings + + Copyright 2013 Thinstuff Technologies GmbH, Author: Martin Fleisz + + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ -#import <UIKit/UIKit.h> +#import "EditorBaseController.h" -@interface BookmarkGatewaySettingsController : UITableViewController +@class ComputerBookmark; +@class ConnectionParams; + +@interface BookmarkGatewaySettingsController : EditorBaseController +{ +@private + ComputerBookmark* _bookmark; + ConnectionParams* _params; +} + +// init for the given bookmark +- (id)initWithBookmark:(ComputerBookmark*)bookmark; @end diff --git a/client/iOS/Controllers/BookmarkGatewaySettingsController.m b/client/iOS/Controllers/BookmarkGatewaySettingsController.m index ef9463add..586ead7c2 100644 --- a/client/iOS/Controllers/BookmarkGatewaySettingsController.m +++ b/client/iOS/Controllers/BookmarkGatewaySettingsController.m @@ -7,6 +7,12 @@ // #import "BookmarkGatewaySettingsController.h" +#import "Bookmark.h" +#import "Utils.h" +#import "EditorSelectionController.h" + +#define SECTION_TSGATEWAY_SETTINGS 0 +#define SECTION_COUNT 1 @interface BookmarkGatewaySettingsController () @@ -14,11 +20,13 @@ @implementation BookmarkGatewaySettingsController -- (id)initWithStyle:(UITableViewStyle)style +- (id)initWithBookmark:(ComputerBookmark*)bookmark { - self = [super initWithStyle:style]; - if (self) { - // Custom initialization + if ((self = [super initWithStyle:UITableViewStyleGrouped])) + { + // set additional settings state according to bookmark data + _bookmark = [bookmark retain]; + _params = [bookmark params]; } return self; } @@ -26,97 +34,203 @@ - (void)viewDidLoad { [super viewDidLoad]; - - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; + [self setTitle:NSLocalizedString(@"TS Gateway Settings", @"TS Gateway Settings title")]; } -- (void)didReceiveMemoryWarning +- (void)viewWillAppear:(BOOL)animated { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + [super viewWillAppear:animated]; + + // we need to reload the table view data here to have up-to-date data for the + // advanced settings accessory items (like for resolution/color mode settings) + [[self tableView] reloadData]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. // Return the number of sections. - return 0; + return SECTION_COUNT; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. // Return the number of rows in the section. + switch (section) + { + case SECTION_TSGATEWAY_SETTINGS: // ts gateway settings + return 5; + default: + break; + } + return 0; } +// set section headers +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + switch(section) + { + case SECTION_TSGATEWAY_SETTINGS: + return NSLocalizedString(@"TS Gateway", @"'TS Gateway': ts gateway settings header"); + } + return @"unknown"; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + // determine the required cell type + NSString* cellType = nil; + switch([indexPath section]) + { + case SECTION_TSGATEWAY_SETTINGS: // advanced settings + { + switch([indexPath row]) + { + case 0: // hostname + case 1: // port + case 2: // username + case 4: // domain + cellType = TableCellIdentifierText; + break; + case 3: // password + cellType = TableCellIdentifierSecretText; + break; + default: + break; + } + break; + } + } + NSAssert(cellType != nil, @"Couldn't determine cell type"); + + // get the table view cell + UITableViewCell *cell = [self tableViewCellFromIdentifier:cellType]; + NSAssert(cell, @"Invalid cell"); - // Configure the cell... + // set cell values + switch([indexPath section]) + { + // advanced settings + case SECTION_TSGATEWAY_SETTINGS: + [self initGatewaySettings:indexPath cell:cell]; + break; + + default: + break; + } return cell; } -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +// updates server settings in the UI +- (void)initGatewaySettings:(NSIndexPath*)indexPath cell:(UITableViewCell*)cell { - // Return NO if you do not want the specified item to be editable. - return YES; + EditTextTableViewCell* textCell = (EditTextTableViewCell*)cell; + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + switch([indexPath row]) + { + case 0: + { + [[textCell label] setText:NSLocalizedString(@"Host", @"'Host': Bookmark hostname")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_hostname"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 1: + { + int port = [_params intForKey:@"tsg_port"]; + if (port == 0) port = 443; + [[textCell label] setText:NSLocalizedString(@"Port", @"'Port': Bookmark port")]; + [[textCell textfield] setText:[NSString stringWithFormat:@"%d", port]]; + [[textCell textfield] setKeyboardType:UIKeyboardTypeNumberPad]; + break; + } + case 2: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Username", @"'Username': Bookmark username")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_username"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 3: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Password", @"'Password': Bookmark password")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_password"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + case 4: + { + [[textCell textfield] setTag:GET_TAG_FROM_PATH(indexPath)]; + [[textCell label] setText:NSLocalizedString(@"Domain", @"'Domain': Bookmark domain")]; + [[textCell textfield] setText:[_params StringForKey:@"tsg_domain"]]; + [[textCell textfield] setPlaceholder:NSLocalizedString(@"not set", @"not set placeholder")]; + break; + } + default: + NSLog(@"Invalid row index in settings table!"); + break; + } + + [self adjustEditTextTableViewCell:textCell]; } -*/ -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath + +#pragma mark - +#pragma mark Text Field delegate + +- (BOOL)textFieldShouldReturn:(UITextField*)textField { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } + [textField resignFirstResponder]; + return NO; } -*/ -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +- (BOOL)textFieldShouldEndEditing:(UITextField *)textField { + switch(textField.tag) + { + // update server settings + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 0): + [_params setValue:[textField text] forKey:@"tsg_hostname"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 1): + [_params setInt:[[textField text] intValue] forKey:@"tsg_port"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 2): + [_params setValue:[textField text] forKey:@"tsg_username"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 3): + [_params setValue:[textField text] forKey:@"tsg_password"]; + break; + + case GET_TAG(SECTION_TSGATEWAY_SETTINGS, 4): + [_params setValue:[textField text] forKey:@"tsg_domain"]; + break; + + default: + break; + } + return YES; } -*/ -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ - -#pragma mark - Table view delegate - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Navigation logic may go here. Create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - [detailViewController release]; - */ -} @end diff --git a/client/iOS/Controllers/CredentialsEditorController.m b/client/iOS/Controllers/CredentialsEditorController.m index 21e328ad5..a029ad3b6 100644 --- a/client/iOS/Controllers/CredentialsEditorController.m +++ b/client/iOS/Controllers/CredentialsEditorController.m @@ -56,6 +56,12 @@ return YES; } +- (void)dealloc +{ + [super dealloc]; + [_bookmark release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Controllers/PerformanceEditorController.m b/client/iOS/Controllers/PerformanceEditorController.m index 104b13c13..2e1d4e0eb 100644 --- a/client/iOS/Controllers/PerformanceEditorController.m +++ b/client/iOS/Controllers/PerformanceEditorController.m @@ -56,6 +56,12 @@ return key; } +- (void)dealloc +{ + [super dealloc]; + [_params release]; +} + #pragma mark - #pragma mark Table view data source diff --git a/client/iOS/Defaults.plist b/client/iOS/Defaults.plist index a60e3be19..801082384 100644 --- a/client/iOS/Defaults.plist +++ b/client/iOS/Defaults.plist @@ -65,6 +65,18 @@ <string></string> <key>console</key> <false/> + <key>enable_tsg_settings</key> + <false/> + <key>tsg_hostname</key> + <string></string> + <key>tsg_port</key> + <integer>443</integer> + <key>tsg_username</key> + <string></string> + <key>tsg_password</key> + <string></string> + <key>tsg_domain</key> + <string></string> </dict> <key>ui.auto_scroll_touchpointer</key> <true/> diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index 6144637d1..d43f27959 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -164,6 +164,18 @@ NSString* TSXSessionDidFailToConnectNotification = @"TSXSessionDidFailToConnect" break; } + // ts gateway settings + if ([_params boolForKey:@"enable_tsg_settings"]) + { + settings->GatewayHostname = strdup([_params UTF8StringForKey:@"tsg_hostname"]); + settings->GatewayPort = [_params intForKey:@"tsg_port"]; + settings->GatewayUsername = strdup([_params UTF8StringForKey:@"tsg_username"]); + settings->GatewayPassword = strdup([_params UTF8StringForKey:@"tsg_password"]); + settings->GatewayDomain = strdup([_params UTF8StringForKey:@"tsg_domain"]); + settings->GatewayUsageMethod = TRUE; + settings->GatewayUseSameCredentials = FALSE; + } + // Remote keyboard layout settings->KeyboardLayout = 0x409; diff --git a/libfreerdp/core/gateway/tsg.h b/libfreerdp/core/gateway/tsg.h index 40ba028a1..23b10155b 100644 --- a/libfreerdp/core/gateway/tsg.h +++ b/libfreerdp/core/gateway/tsg.h @@ -61,8 +61,8 @@ struct rdp_tsg LPWSTR MachineName; TSG_STATE state; BOOL PendingPdu; - BOOL BytesRead; - BOOL BytesAvailable; + UINT32 BytesRead; + UINT32 BytesAvailable; UINT32 StubOffset; UINT32 StubLength; rdpSettings* settings; From c55f3d6426cf16f9d9e31253e019675f2702a598 Mon Sep 17 00:00:00 2001 From: Martin Fleisz <mfleisz@thinstuff.at> Date: Wed, 8 May 2013 17:29:52 +0200 Subject: [PATCH 081/144] iOS: Encrypt TS Gateway passwords --- client/iOS/Models/ConnectionParams.m | 37 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/client/iOS/Models/ConnectionParams.m b/client/iOS/Models/ConnectionParams.m index 030216af7..3d1a8605a 100644 --- a/client/iOS/Models/ConnectionParams.m +++ b/client/iOS/Models/ConnectionParams.m @@ -28,16 +28,21 @@ _connection_params = [dict mutableDeepCopy]; - if ([[_connection_params objectForKey:@"password"] isKindOfClass:[NSData class]]) - { - NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:@"password"]]; - - [self setValue:plaintext_password forKey:@"password"]; - } + [self decryptPasswordForKey:@"password"]; + [self decryptPasswordForKey:@"tsg_password"]; return self; } +- (void)decryptPasswordForKey:(NSString*)key +{ + if ([[_connection_params objectForKey:key] isKindOfClass:[NSData class]]) + { + NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:key]]; + [self setValue:plaintext_password forKey:key]; + } +} + - (id)initWithBaseDefaultParameters { return [self initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]]; @@ -89,19 +94,23 @@ [serializable_params setObject:[_connection_params objectForKey:k] forKey:k]; if ([serializable_params objectForKey:@"password"] != nil) - { - NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[serializable_params objectForKey:@"password"]]; - - if (encrypted_password) - [serializable_params setObject:encrypted_password forKey:@"password"]; - else - [serializable_params removeObjectForKey:@"password"]; - } + [self serializeDecryptedForKey:@"password" forParams:serializable_params]; + if ([serializable_params objectForKey:@"tsg_password"] != nil) + [self serializeDecryptedForKey:@"tsg_password" forParams:serializable_params]; [coder encodeObject:serializable_params forKey:@"connectionParams"]; [serializable_params release]; } +- (void)serializeDecryptedForKey:(NSString*)key forParams:(NSMutableDictionary*)params +{ + NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[params objectForKey:key]]; + + if (encrypted_password) + [params setObject:encrypted_password forKey:key]; + else + [params removeObjectForKey:key]; +} #pragma mark - #pragma mark NSKeyValueCoding From 64df210a1d50c3aa618b1de8ad108b9826699321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 15:25:24 -0400 Subject: [PATCH 082/144] libfreerdp-core: fix messy merge --- libfreerdp/core/fastpath.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index a02e8d9f1..ea4452730 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -722,12 +722,8 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu } eventHeader = FASTPATH_INPUT_ACTION_FASTPATH; -<<<<<<< HEAD eventHeader |= (1 << 2); /* numberEvents */ -======= - eventHeader |= (iNumEvents << 2); /* numberEvents */ ->>>>>>> f1672948ff0b5f6a9d3cda658a18104df3c3d1e4 if (rdp->sec_flags & SEC_ENCRYPT) eventHeader |= (FASTPATH_INPUT_ENCRYPTED << 6); if (rdp->sec_flags & SEC_SECURE_CHECKSUM) From 5b92413843abd7ba60bfa6b3fbdeda567ca41587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 16:09:16 -0400 Subject: [PATCH 083/144] freerdp: purge deprecated stream utils --- channels/audin/client/audin_main.c | 48 +- channels/audin/server/audin.c | 66 +- channels/cliprdr/client/cliprdr_format.c | 18 +- channels/cliprdr/client/cliprdr_main.c | 34 +- channels/drdynvc/client/drdynvc_main.c | 48 +- channels/drdynvc/client/dvcman.c | 2 +- channels/drive/client/drive_file.c | 146 ++-- channels/drive/client/drive_main.c | 114 +-- channels/parallel/client/parallel_main.c | 28 +- channels/printer/client/printer_main.c | 36 +- channels/rail/client/rail_main.c | 2 +- channels/rail/client/rail_orders.c | 138 ++-- channels/rdpdr/client/irp.c | 20 +- channels/rdpdr/client/rdpdr_capabilities.c | 48 +- channels/rdpdr/client/rdpdr_main.c | 60 +- channels/rdpsnd/client/rdpsnd_main.c | 110 +-- channels/rdpsnd/server/rdpsnd.c | 112 +-- channels/serial/client/serial_main.c | 40 +- channels/serial/client/serial_tty.c | 88 +-- channels/server/channels.c | 28 +- channels/smartcard/client/smartcard_main.c | 4 +- .../smartcard/client/smartcard_operations.c | 316 ++++---- channels/tsmf/client/tsmf_codec.c | 46 +- channels/tsmf/client/tsmf_ifman.c | 114 +-- channels/tsmf/client/tsmf_main.c | 24 +- client/X11/xf_cliprdr.c | 16 +- cunit/test_rfx.c | 6 +- libfreerdp/codec/nsc.c | 6 +- libfreerdp/codec/nsc_encode.c | 16 +- libfreerdp/codec/rfx.c | 212 +++--- libfreerdp/core/activation.c | 82 +- libfreerdp/core/capabilities.c | 716 +++++++++--------- libfreerdp/core/certificate.c | 38 +- libfreerdp/core/channel.c | 14 +- libfreerdp/core/connection.c | 8 +- libfreerdp/core/fastpath.c | 54 +- libfreerdp/core/gcc.c | 208 ++--- libfreerdp/core/info.c | 122 +-- libfreerdp/core/input.c | 78 +- libfreerdp/core/license.c | 66 +- libfreerdp/core/mcs.c | 6 +- libfreerdp/core/nego.c | 74 +- libfreerdp/core/nla.c | 6 +- libfreerdp/core/orders.c | 456 +++++------ libfreerdp/core/peer.c | 2 +- libfreerdp/core/rdp.c | 62 +- libfreerdp/core/redirection.c | 24 +- libfreerdp/core/surface.c | 54 +- libfreerdp/core/timezone.c | 52 +- libfreerdp/core/tpdu.c | 16 +- libfreerdp/core/tpkt.c | 8 +- libfreerdp/core/update.c | 198 ++--- libfreerdp/core/window.c | 106 +-- libfreerdp/crypto/ber.c | 68 +- libfreerdp/crypto/der.c | 18 +- libfreerdp/crypto/er.c | 68 +- libfreerdp/crypto/per.c | 68 +- libfreerdp/utils/rail.c | 26 +- libfreerdp/utils/svc_plugin.c | 2 +- winpr/include/winpr/stream.h | 78 +- 60 files changed, 2332 insertions(+), 2392 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index bf409e043..88d6e3e19 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -94,13 +94,13 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w UINT32 Version; AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - stream_read_UINT32(s, Version); + Stream_Read_UINT32(s, Version); DEBUG_DVC("Version=%d", Version); out = stream_new(5); - stream_write_BYTE(out, MSG_SNDIN_VERSION); - stream_write_UINT32(out, Version); + Stream_Write_UINT8(out, MSG_SNDIN_VERSION); + Stream_Write_UINT32(out, Version); error = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); stream_free(out); @@ -128,7 +128,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w audinFormat format; UINT32 cbSizeFormatsPacket; - stream_read_UINT32(s, NumFormats); + Stream_Read_UINT32(s, NumFormats); DEBUG_DVC("NumFormats %d", NumFormats); if ((NumFormats < 1) || (NumFormats > 1000)) { @@ -147,13 +147,13 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w for (i = 0; i < NumFormats; i++) { stream_get_mark(s, fm); - stream_read_UINT16(s, format.wFormatTag); - stream_read_UINT16(s, format.nChannels); - stream_read_UINT32(s, format.nSamplesPerSec); + Stream_Read_UINT16(s, format.wFormatTag); + Stream_Read_UINT16(s, format.nChannels); + Stream_Read_UINT32(s, format.nSamplesPerSec); Stream_Seek_UINT32(s); /* nAvgBytesPerSec */ - stream_read_UINT16(s, format.nBlockAlign); - stream_read_UINT16(s, format.wBitsPerSample); - stream_read_UINT16(s, format.cbSize); + Stream_Read_UINT16(s, format.nBlockAlign); + Stream_Read_UINT16(s, format.wBitsPerSample); + Stream_Read_UINT16(s, format.cbSize); format.data = Stream_Pointer(s); Stream_Seek(s, format.cbSize); @@ -176,7 +176,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w callback->formats[callback->formats_count++] = format; /* Put the format to output buffer */ Stream_EnsureRemainingCapacity(out, 18 + format.cbSize); - stream_write(out, fm, 18 + format.cbSize); + Stream_Write(out, fm, 18 + format.cbSize); } } @@ -185,9 +185,9 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w cbSizeFormatsPacket = Stream_GetPosition(out); Stream_SetPosition(out, 0); - stream_write_BYTE(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */ - stream_write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */ - stream_write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */ + Stream_Write_UINT8(out, MSG_SNDIN_FORMATS); /* Header (1 byte) */ + Stream_Write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */ + Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */ error = callback->channel->Write(callback->channel, cbSizeFormatsPacket, stream_get_head(out), NULL); stream_free(out); @@ -202,8 +202,8 @@ static int audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCall AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; out = stream_new(5); - stream_write_BYTE(out, MSG_SNDIN_FORMATCHANGE); - stream_write_UINT32(out, NewFormat); + Stream_Write_UINT8(out, MSG_SNDIN_FORMATCHANGE); + Stream_Write_UINT32(out, NewFormat); error = callback->channel->Write(callback->channel, 5, stream_get_head(out), NULL); stream_free(out); @@ -217,8 +217,8 @@ static int audin_send_open_reply_pdu(IWTSVirtualChannelCallback* pChannelCallbac AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; out = stream_new(5); - stream_write_BYTE(out, MSG_SNDIN_OPEN_REPLY); - stream_write_UINT32(out, Result); + Stream_Write_UINT8(out, MSG_SNDIN_OPEN_REPLY); + Stream_Write_UINT32(out, Result); error = callback->channel->Write(callback->channel, 5, stream_get_head(out), NULL); stream_free(out); @@ -237,8 +237,8 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data) return FALSE; out = stream_new(size + 1); - stream_write_BYTE(out, MSG_SNDIN_DATA); - stream_write(out, data, size); + Stream_Write_UINT8(out, MSG_SNDIN_DATA); + Stream_Write(out, data, size); error = callback->channel->Write(callback->channel, Stream_GetPosition(out), stream_get_head(out), NULL); stream_free(out); @@ -253,8 +253,8 @@ static int audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wStr UINT32 initialFormat; UINT32 FramesPerPacket; - stream_read_UINT32(s, FramesPerPacket); - stream_read_UINT32(s, initialFormat); + Stream_Read_UINT32(s, FramesPerPacket); + Stream_Read_UINT32(s, initialFormat); DEBUG_DVC("FramesPerPacket=%d initialFormat=%d", FramesPerPacket, initialFormat); @@ -286,7 +286,7 @@ static int audin_process_format_change(IWTSVirtualChannelCallback* pChannelCallb UINT32 NewFormat; audinFormat* format; - stream_read_UINT32(s, NewFormat); + Stream_Read_UINT32(s, NewFormat); DEBUG_DVC("NewFormat=%d", NewFormat); @@ -320,7 +320,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, s = stream_new(0); stream_attach(s, pBuffer, cbSize); - stream_read_BYTE(s, MessageId); + Stream_Read_UINT8(s, MessageId); DEBUG_DVC("MessageId=0x%x", MessageId); diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 88b8e8f77..cfd595848 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -76,8 +76,8 @@ static void audin_server_select_format(audin_server_context* context, int client static void audin_server_send_version(audin_server* audin, wStream* s) { - stream_write_BYTE(s, MSG_SNDIN_VERSION); - stream_write_UINT32(s, 1); /* Version (4 bytes) */ + Stream_Write_UINT8(s, MSG_SNDIN_VERSION); + Stream_Write_UINT32(s, 1); /* Version (4 bytes) */ WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); } @@ -88,7 +88,7 @@ static BOOL audin_server_recv_version(audin_server* audin, wStream* s, UINT32 le if (length < 4) return FALSE; - stream_read_UINT32(s, Version); + Stream_Read_UINT32(s, Version); if (Version < 1) return FALSE; @@ -102,9 +102,9 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) UINT32 nAvgBytesPerSec; Stream_SetPosition(s, 0); - stream_write_BYTE(s, MSG_SNDIN_FORMATS); - stream_write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */ - stream_write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */ + Stream_Write_UINT8(s, MSG_SNDIN_FORMATS); + Stream_Write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */ + Stream_Write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */ for (i = 0; i < audin->context.num_server_formats; i++) { @@ -114,18 +114,18 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) Stream_EnsureRemainingCapacity(s, 18); - stream_write_UINT16(s, audin->context.server_formats[i].wFormatTag); - stream_write_UINT16(s, audin->context.server_formats[i].nChannels); - stream_write_UINT32(s, audin->context.server_formats[i].nSamplesPerSec); - stream_write_UINT32(s, nAvgBytesPerSec); - stream_write_UINT16(s, audin->context.server_formats[i].nBlockAlign); - stream_write_UINT16(s, audin->context.server_formats[i].wBitsPerSample); - stream_write_UINT16(s, audin->context.server_formats[i].cbSize); + Stream_Write_UINT16(s, audin->context.server_formats[i].wFormatTag); + Stream_Write_UINT16(s, audin->context.server_formats[i].nChannels); + Stream_Write_UINT32(s, audin->context.server_formats[i].nSamplesPerSec); + Stream_Write_UINT32(s, nAvgBytesPerSec); + Stream_Write_UINT16(s, audin->context.server_formats[i].nBlockAlign); + Stream_Write_UINT16(s, audin->context.server_formats[i].wBitsPerSample); + Stream_Write_UINT16(s, audin->context.server_formats[i].cbSize); if (audin->context.server_formats[i].cbSize) { Stream_EnsureRemainingCapacity(s, audin->context.server_formats[i].cbSize); - stream_write(s, audin->context.server_formats[i].data, + Stream_Write(s, audin->context.server_formats[i].data, audin->context.server_formats[i].cbSize); } } @@ -140,7 +140,7 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le if (length < 8) return FALSE; - stream_read_UINT32(s, audin->context.num_client_formats); /* NumFormats (4 bytes) */ + Stream_Read_UINT32(s, audin->context.num_client_formats); /* NumFormats (4 bytes) */ Stream_Seek_UINT32(s); /* cbSizeFormatsPacket (4 bytes) */ length -= 8; @@ -159,13 +159,13 @@ static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le return FALSE; } - stream_read_UINT16(s, audin->context.client_formats[i].wFormatTag); - stream_read_UINT16(s, audin->context.client_formats[i].nChannels); - stream_read_UINT32(s, audin->context.client_formats[i].nSamplesPerSec); + Stream_Read_UINT16(s, audin->context.client_formats[i].wFormatTag); + Stream_Read_UINT16(s, audin->context.client_formats[i].nChannels); + Stream_Read_UINT32(s, audin->context.client_formats[i].nSamplesPerSec); Stream_Seek_UINT32(s); /* nAvgBytesPerSec */ - stream_read_UINT16(s, audin->context.client_formats[i].nBlockAlign); - stream_read_UINT16(s, audin->context.client_formats[i].wBitsPerSample); - stream_read_UINT16(s, audin->context.client_formats[i].cbSize); + Stream_Read_UINT16(s, audin->context.client_formats[i].nBlockAlign); + Stream_Read_UINT16(s, audin->context.client_formats[i].wBitsPerSample); + Stream_Read_UINT16(s, audin->context.client_formats[i].cbSize); if (audin->context.client_formats[i].cbSize > 0) { Stream_Seek(s, audin->context.client_formats[i].cbSize); @@ -185,21 +185,21 @@ static void audin_server_send_open(audin_server* audin, wStream* s) audin->opened = TRUE; Stream_SetPosition(s, 0); - stream_write_BYTE(s, MSG_SNDIN_OPEN); - stream_write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */ - stream_write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */ + Stream_Write_UINT8(s, MSG_SNDIN_OPEN); + Stream_Write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */ + Stream_Write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */ /* * [MS-RDPEAI] 3.2.5.1.6 * The second format specify the format that SHOULD be used to capture data from * the actual audio input device. */ - stream_write_UINT16(s, 1); /* wFormatTag = PCM */ - stream_write_UINT16(s, 2); /* nChannels */ - stream_write_UINT32(s, 44100); /* nSamplesPerSec */ - stream_write_UINT32(s, 44100 * 2 * 2); /* nAvgBytesPerSec */ - stream_write_UINT16(s, 4); /* nBlockAlign */ - stream_write_UINT16(s, 16); /* wBitsPerSample */ - stream_write_UINT16(s, 0); /* cbSize */ + Stream_Write_UINT16(s, 1); /* wFormatTag = PCM */ + Stream_Write_UINT16(s, 2); /* nChannels */ + Stream_Write_UINT32(s, 44100); /* nSamplesPerSec */ + Stream_Write_UINT32(s, 44100 * 2 * 2); /* nAvgBytesPerSec */ + Stream_Write_UINT16(s, 4); /* nBlockAlign */ + Stream_Write_UINT16(s, 16); /* wBitsPerSample */ + Stream_Write_UINT16(s, 0); /* cbSize */ WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); } @@ -211,7 +211,7 @@ static BOOL audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 if (length < 4) return FALSE; - stream_read_UINT32(s, Result); + Stream_Read_UINT32(s, Result); IFCALL(audin->context.OpenResult, &audin->context, Result); @@ -346,7 +346,7 @@ static void* audin_server_thread_func(void* arg) if (bytes_returned < 1) continue; - stream_read_BYTE(s, MessageId); + Stream_Read_UINT8(s, MessageId); bytes_returned--; switch (MessageId) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 4fa404675..1f19c005b 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -53,7 +53,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS if (cb_event->raw_format_data) { s = cliprdr_packet_new(CB_FORMAT_LIST, 0, cb_event->raw_format_data_size); - stream_write(s, cb_event->raw_format_data, cb_event->raw_format_data_size); + Stream_Write(s, cb_event->raw_format_data, cb_event->raw_format_data_size); } else { @@ -89,12 +89,12 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS Stream_EnsureRemainingCapacity(body, Stream_Capacity(body) + 4 + name_length); - stream_write_UINT32(body, cb_event->formats[i]); - stream_write(body, name, name_length); + Stream_Write_UINT32(body, cb_event->formats[i]); + Stream_Write(body, name, name_length); } s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body)); - stream_write(s, stream_get_head(body), Stream_Capacity(body)); + Stream_Write(s, stream_get_head(body), Stream_Capacity(body)); stream_free(body); } @@ -137,7 +137,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT { format_name = &cliprdr->format_names[i]; - stream_read_UINT32(s, format_name->id); + Stream_Read_UINT32(s, format_name->id); if (ascii) { @@ -179,7 +179,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3 } format_name = &cliprdr->format_names[cliprdr->num_format_names++]; - stream_read_UINT32(s, format_name->id); + Stream_Read_UINT32(s, format_name->id); format_name->name = NULL; format_name->length = 0; @@ -309,7 +309,7 @@ void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UIN cb_event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL); - stream_read_UINT32(s, cb_event->format); + Stream_Read_UINT32(s, cb_event->format); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event); } @@ -322,7 +322,7 @@ void cliprdr_process_format_data_response_event(cliprdrPlugin* cliprdr, RDP_CB_D if (cb_event->size > 0) { s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, CB_RESPONSE_OK, cb_event->size); - stream_write(s, cb_event->data, cb_event->size); + Stream_Write(s, cb_event->data, cb_event->size); } else { @@ -339,7 +339,7 @@ void cliprdr_process_format_data_request_event(cliprdrPlugin* cliprdr, RDP_CB_DA DEBUG_CLIPRDR("Sending Format Data Request"); s = cliprdr_packet_new(CB_FORMAT_DATA_REQUEST, 0, 4); - stream_write_UINT32(s, cb_event->format); + Stream_Write_UINT32(s, cb_event->format); cliprdr_packet_send(cliprdr, s); } diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 8b5c4ebed..2358aef15 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -58,8 +58,8 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen) wStream* s; s = stream_new(dataLen + 8); - stream_write_UINT16(s, msgType); - stream_write_UINT16(s, msgFlags); + Stream_Write_UINT16(s, msgType); + Stream_Write_UINT16(s, msgFlags); /* Write actual length after the entire packet has been constructed. */ Stream_Seek(s, 4); @@ -74,7 +74,7 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s) pos = Stream_GetPosition(s); dataLen = pos - 8; Stream_SetPosition(s, 4); - stream_write_UINT32(s, dataLen); + Stream_Write_UINT32(s, dataLen); Stream_SetPosition(s, pos); svc_plugin_send((rdpSvcPlugin*) cliprdr, s); @@ -106,8 +106,8 @@ static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* UINT32 version; UINT32 generalFlags; - stream_read_UINT32(s, version); /* version (4 bytes) */ - stream_read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */ + Stream_Read_UINT32(s, version); /* version (4 bytes) */ + Stream_Read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */ DEBUG_CLIPRDR("Version: %d", version); @@ -137,15 +137,15 @@ static void cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT16 UINT16 cCapabilitiesSets; UINT16 capabilitySetType; - stream_read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */ + Stream_Read_UINT16(s, cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */ Stream_Seek_UINT16(s); /* pad1 (2 bytes) */ DEBUG_CLIPRDR("cCapabilitiesSets %d", cCapabilitiesSets); for (i = 0; i < cCapabilitiesSets; i++) { - stream_read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */ - stream_read_UINT16(s, lengthCapability); /* lengthCapability (2 bytes) */ + Stream_Read_UINT16(s, capabilitySetType); /* capabilitySetType (2 bytes) */ + Stream_Read_UINT16(s, lengthCapability); /* lengthCapability (2 bytes) */ switch (capabilitySetType) { @@ -171,12 +171,12 @@ static void cliprdr_send_clip_caps(cliprdrPlugin* cliprdr) flags = CB_USE_LONG_FORMAT_NAMES; - stream_write_UINT16(s, 1); /* cCapabilitiesSets */ - stream_write_UINT16(s, 0); /* pad1 */ - stream_write_UINT16(s, CB_CAPSTYPE_GENERAL); /* capabilitySetType */ - stream_write_UINT16(s, CB_CAPSTYPE_GENERAL_LEN); /* lengthCapability */ - stream_write_UINT32(s, CB_CAPS_VERSION_2); /* version */ - stream_write_UINT32(s, flags); /* generalFlags */ + Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */ + Stream_Write_UINT16(s, 0); /* pad1 */ + Stream_Write_UINT16(s, CB_CAPSTYPE_GENERAL); /* capabilitySetType */ + Stream_Write_UINT16(s, CB_CAPSTYPE_GENERAL_LEN); /* lengthCapability */ + Stream_Write_UINT32(s, CB_CAPS_VERSION_2); /* version */ + Stream_Write_UINT32(s, flags); /* generalFlags */ cliprdr_packet_send(cliprdr, s); } @@ -200,9 +200,9 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s) UINT32 dataLen; cliprdrPlugin* cliprdr = (cliprdrPlugin*) plugin; - stream_read_UINT16(s, msgType); - stream_read_UINT16(s, msgFlags); - stream_read_UINT32(s, dataLen); + Stream_Read_UINT16(s, msgType); + Stream_Read_UINT16(s, msgFlags); + Stream_Read_UINT32(s, dataLen); DEBUG_CLIPRDR("msgType: %s (%d), msgFlags: %d dataLen: %d", CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen); diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index f1d47df8e..fbf571351 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -62,17 +62,17 @@ static int drdynvc_write_variable_uint(wStream* stream, UINT32 val) if (val <= 0xFF) { cb = 0; - stream_write_BYTE(stream, val); + Stream_Write_UINT8(stream, val); } else if (val <= 0xFFFF) { cb = 1; - stream_write_UINT16(stream, val); + Stream_Write_UINT16(stream, val); } else { cb = 2; - stream_write_UINT32(stream, val); + Stream_Write_UINT32(stream, val); } return cb; @@ -100,7 +100,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN { pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - stream_write_BYTE(data_out, 0x40 | cbChId); + Stream_Write_UINT8(data_out, 0x40 | cbChId); Stream_SetPosition(data_out, pos); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); } @@ -108,9 +108,9 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN { pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - stream_write_BYTE(data_out, 0x30 | cbChId); + Stream_Write_UINT8(data_out, 0x30 | cbChId); Stream_SetPosition(data_out, pos); - stream_write(data_out, data, data_size); + Stream_Write(data_out, data, data_size); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); } else @@ -119,10 +119,10 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN cbLen = drdynvc_write_variable_uint(data_out, data_size); pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - stream_write_BYTE(data_out, 0x20 | cbChId | (cbLen << 2)); + Stream_Write_UINT8(data_out, 0x20 | cbChId | (cbLen << 2)); Stream_SetPosition(data_out, pos); chunk_len = CHANNEL_CHUNK_LENGTH - pos; - stream_write(data_out, data, chunk_len); + Stream_Write(data_out, data, chunk_len); data += chunk_len; data_size -= chunk_len; error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); @@ -135,13 +135,13 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, 0); - stream_write_BYTE(data_out, 0x30 | cbChId); + Stream_Write_UINT8(data_out, 0x30 | cbChId); Stream_SetPosition(data_out, pos); chunk_len = data_size; if (chunk_len > CHANNEL_CHUNK_LENGTH - pos) chunk_len = CHANNEL_CHUNK_LENGTH - pos; - stream_write(data_out, data, chunk_len); + Stream_Write(data_out, data, chunk_len); data += chunk_len; data_size -= chunk_len; error = svc_plugin_send((rdpSvcPlugin*)drdynvc, data_out); @@ -180,19 +180,19 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in DEBUG_DVC("Sp=%d cbChId=%d", Sp, cbChId); Stream_Seek(s, 1); /* pad */ - stream_read_UINT16(s, drdynvc->version); + Stream_Read_UINT16(s, drdynvc->version); if (drdynvc->version == 2) { - stream_read_UINT16(s, drdynvc->PriorityCharge0); - stream_read_UINT16(s, drdynvc->PriorityCharge1); - stream_read_UINT16(s, drdynvc->PriorityCharge2); - stream_read_UINT16(s, drdynvc->PriorityCharge3); + Stream_Read_UINT16(s, drdynvc->PriorityCharge0); + Stream_Read_UINT16(s, drdynvc->PriorityCharge1); + Stream_Read_UINT16(s, drdynvc->PriorityCharge2); + Stream_Read_UINT16(s, drdynvc->PriorityCharge3); } data_out = stream_new(4); - stream_write_UINT16(data_out, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */ - stream_write_UINT16(data_out, drdynvc->version); + Stream_Write_UINT16(data_out, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */ + Stream_Write_UINT16(data_out, drdynvc->version); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); if (error != CHANNEL_RC_OK) @@ -213,15 +213,15 @@ static UINT32 drdynvc_read_variable_uint(wStream* stream, int cbLen) switch (cbLen) { case 0: - stream_read_BYTE(stream, val); + Stream_Read_UINT8(stream, val); break; case 1: - stream_read_UINT16(stream, val); + Stream_Read_UINT16(stream, val); break; default: - stream_read_UINT32(stream, val); + Stream_Read_UINT32(stream, val); break; } @@ -242,19 +242,19 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); data_out = stream_new(pos + 4); - stream_write_BYTE(data_out, 0x10 | cbChId); + Stream_Write_UINT8(data_out, 0x10 | cbChId); Stream_SetPosition(s, 1); stream_copy(data_out, s, pos - 1); if (error == 0) { DEBUG_DVC("channel created"); - stream_write_UINT32(data_out, 0); + Stream_Write_UINT32(data_out, 0); } else { DEBUG_DVC("no listener"); - stream_write_UINT32(data_out, (UINT32)(-1)); + Stream_Write_UINT32(data_out, (UINT32)(-1)); } error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); @@ -317,7 +317,7 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s) int cbChId; drdynvcPlugin* drdynvc = (drdynvcPlugin*) plugin; - stream_read_BYTE(s, value); + Stream_Read_UINT8(s, value); Cmd = (value & 0xf0) >> 4; Sp = (value & 0x0c) >> 2; cbChId = (value & 0x03) >> 0; diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index accef0c47..62b6fd58c 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -453,7 +453,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C return 1; } - stream_write(channel->dvc_data, data, data_size); + Stream_Write(channel->dvc_data, data, data_size); if (Stream_GetPosition(channel->dvc_data) >= Stream_Capacity(channel->dvc_data)) { diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 9d4f35195..a34efd20e 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -382,7 +382,7 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w if (STAT(file->fullpath, &st) != 0) { - stream_write_UINT32(output, 0); /* Length */ + Stream_Write_UINT32(output, 0); /* Length */ return FALSE; } @@ -390,38 +390,38 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w { case FileBasicInformation: /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */ - stream_write_UINT32(output, 36); /* Length */ + Stream_Write_UINT32(output, 36); /* Length */ Stream_EnsureRemainingCapacity(output, 36); - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ - stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ + Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ /* Reserved(4), MUST NOT be added! */ break; case FileStandardInformation: /* http://msdn.microsoft.com/en-us/library/cc232088.aspx */ - stream_write_UINT32(output, 22); /* Length */ + Stream_Write_UINT32(output, 22); /* Length */ Stream_EnsureRemainingCapacity(output, 22); - stream_write_UINT64(output, st.st_size); /* AllocationSize */ - stream_write_UINT64(output, st.st_size); /* EndOfFile */ - stream_write_UINT32(output, st.st_nlink); /* NumberOfLinks */ - stream_write_BYTE(output, file->delete_pending ? 1 : 0); /* DeletePending */ - stream_write_BYTE(output, file->is_dir ? 1 : 0); /* Directory */ + Stream_Write_UINT64(output, st.st_size); /* AllocationSize */ + Stream_Write_UINT64(output, st.st_size); /* EndOfFile */ + Stream_Write_UINT32(output, st.st_nlink); /* NumberOfLinks */ + Stream_Write_UINT8(output, file->delete_pending ? 1 : 0); /* DeletePending */ + Stream_Write_UINT8(output, file->is_dir ? 1 : 0); /* Directory */ /* Reserved(2), MUST NOT be added! */ break; case FileAttributeTagInformation: /* http://msdn.microsoft.com/en-us/library/cc232093.aspx */ - stream_write_UINT32(output, 8); /* Length */ + Stream_Write_UINT32(output, 8); /* Length */ Stream_EnsureRemainingCapacity(output, 8); - stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_UINT32(output, 0); /* ReparseTag */ + Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ + Stream_Write_UINT32(output, 0); /* ReparseTag */ break; default: - stream_write_UINT32(output, 0); /* Length */ + Stream_Write_UINT32(output, 0); /* Length */ DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass); return FALSE; } @@ -449,9 +449,9 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */ Stream_Seek_UINT64(input); /* CreationTime */ Stream_Seek_UINT64(input); /* LastAccessTime */ - stream_read_UINT64(input, LastWriteTime); + Stream_Read_UINT64(input, LastWriteTime); Stream_Seek_UINT64(input); /* ChangeTime */ - stream_read_UINT32(input, FileAttributes); + Stream_Read_UINT32(input, FileAttributes); if (FSTAT(file->fd, &st) != 0) return FALSE; @@ -485,7 +485,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN /* http://msdn.microsoft.com/en-us/library/cc232067.aspx */ case FileAllocationInformation: /* http://msdn.microsoft.com/en-us/library/cc232076.aspx */ - stream_read_UINT64(input, size); + Stream_Read_UINT64(input, size); if (ftruncate(file->fd, size) != 0) return FALSE; break; @@ -494,7 +494,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN /* http://msdn.microsoft.com/en-us/library/cc232098.aspx */ /* http://msdn.microsoft.com/en-us/library/cc241371.aspx */ if (Length) - stream_read_BYTE(input, file->delete_pending); + Stream_Read_UINT8(input, file->delete_pending); else file->delete_pending = 1; break; @@ -503,7 +503,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN /* http://msdn.microsoft.com/en-us/library/cc232085.aspx */ Stream_Seek_BYTE(input); /* ReplaceIfExists */ Stream_Seek_BYTE(input); /* RootDirectory */ - stream_read_UINT32(input, FileNameLength); + Stream_Read_UINT32(input, FileNameLength); status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(input), FileNameLength / 2, &s, 0, NULL, NULL); @@ -550,8 +550,8 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT if (!file->dir) { - stream_write_UINT32(output, 0); /* Length */ - stream_write_BYTE(output, 0); /* Padding */ + Stream_Write_UINT32(output, 0); /* Length */ + Stream_Write_UINT8(output, 0); /* Padding */ return FALSE; } @@ -589,8 +589,8 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT if (ent == NULL) { DEBUG_SVC(" pattern %s not found.", file->pattern); - stream_write_UINT32(output, 0); /* Length */ - stream_write_BYTE(output, 0); /* Padding */ + Stream_Write_UINT32(output, 0); /* Length */ + Stream_Write_UINT8(output, 0); /* Padding */ return FALSE; } @@ -615,73 +615,73 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT { case FileDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232097.aspx */ - stream_write_UINT32(output, 64 + length); /* Length */ + Stream_Write_UINT32(output, 64 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 64 + length); - stream_write_UINT32(output, 0); /* NextEntryOffset */ - stream_write_UINT32(output, 0); /* FileIndex */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ - stream_write_UINT64(output, st.st_size); /* EndOfFile */ - stream_write_UINT64(output, st.st_size); /* AllocationSize */ - stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_UINT32(output, length); /* FileNameLength */ - stream_write(output, ent_path, length); + Stream_Write_UINT32(output, 0); /* NextEntryOffset */ + Stream_Write_UINT32(output, 0); /* FileIndex */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ + Stream_Write_UINT64(output, st.st_size); /* EndOfFile */ + Stream_Write_UINT64(output, st.st_size); /* AllocationSize */ + Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ + Stream_Write_UINT32(output, length); /* FileNameLength */ + Stream_Write(output, ent_path, length); break; case FileFullDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232068.aspx */ - stream_write_UINT32(output, 68 + length); /* Length */ + Stream_Write_UINT32(output, 68 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 68 + length); - stream_write_UINT32(output, 0); /* NextEntryOffset */ - stream_write_UINT32(output, 0); /* FileIndex */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ - stream_write_UINT64(output, st.st_size); /* EndOfFile */ - stream_write_UINT64(output, st.st_size); /* AllocationSize */ - stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_UINT32(output, length); /* FileNameLength */ - stream_write_UINT32(output, 0); /* EaSize */ - stream_write(output, ent_path, length); + Stream_Write_UINT32(output, 0); /* NextEntryOffset */ + Stream_Write_UINT32(output, 0); /* FileIndex */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ + Stream_Write_UINT64(output, st.st_size); /* EndOfFile */ + Stream_Write_UINT64(output, st.st_size); /* AllocationSize */ + Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ + Stream_Write_UINT32(output, length); /* FileNameLength */ + Stream_Write_UINT32(output, 0); /* EaSize */ + Stream_Write(output, ent_path, length); break; case FileBothDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232095.aspx */ - stream_write_UINT32(output, 93 + length); /* Length */ + Stream_Write_UINT32(output, 93 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 93 + length); - stream_write_UINT32(output, 0); /* NextEntryOffset */ - stream_write_UINT32(output, 0); /* FileIndex */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ - stream_write_UINT64(output, st.st_size); /* EndOfFile */ - stream_write_UINT64(output, st.st_size); /* AllocationSize */ - stream_write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_UINT32(output, length); /* FileNameLength */ - stream_write_UINT32(output, 0); /* EaSize */ - stream_write_BYTE(output, 0); /* ShortNameLength */ + Stream_Write_UINT32(output, 0); /* NextEntryOffset */ + Stream_Write_UINT32(output, 0); /* FileIndex */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ + Stream_Write_UINT64(output, st.st_size); /* EndOfFile */ + Stream_Write_UINT64(output, st.st_size); /* AllocationSize */ + Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ + Stream_Write_UINT32(output, length); /* FileNameLength */ + Stream_Write_UINT32(output, 0); /* EaSize */ + Stream_Write_UINT8(output, 0); /* ShortNameLength */ /* Reserved(1), MUST NOT be added! */ - stream_write_zero(output, 24); /* ShortName */ - stream_write(output, ent_path, length); + Stream_Write_zero(output, 24); /* ShortName */ + Stream_Write(output, ent_path, length); break; case FileNamesInformation: /* http://msdn.microsoft.com/en-us/library/cc232077.aspx */ - stream_write_UINT32(output, 12 + length); /* Length */ + Stream_Write_UINT32(output, 12 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 12 + length); - stream_write_UINT32(output, 0); /* NextEntryOffset */ - stream_write_UINT32(output, 0); /* FileIndex */ - stream_write_UINT32(output, length); /* FileNameLength */ - stream_write(output, ent_path, length); + Stream_Write_UINT32(output, 0); /* NextEntryOffset */ + Stream_Write_UINT32(output, 0); /* FileIndex */ + Stream_Write_UINT32(output, length); /* FileNameLength */ + Stream_Write(output, ent_path, length); break; default: - stream_write_UINT32(output, 0); /* Length */ - stream_write_BYTE(output, 0); /* Padding */ + Stream_Write_UINT32(output, 0); /* Length */ + Stream_Write_UINT8(output, 0); /* Padding */ DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass); ret = FALSE; break; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 1c728543a..1206d1fc2 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -127,11 +127,11 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp) UINT32 CreateOptions; UINT32 PathLength; - stream_read_UINT32(irp->input, DesiredAccess); + Stream_Read_UINT32(irp->input, DesiredAccess); Stream_Seek(irp->input, 16); /* AllocationSize(8), FileAttributes(4), SharedAccess(4) */ - stream_read_UINT32(irp->input, CreateDisposition); - stream_read_UINT32(irp->input, CreateOptions); - stream_read_UINT32(irp->input, PathLength); + Stream_Read_UINT32(irp->input, CreateDisposition); + Stream_Read_UINT32(irp->input, CreateOptions); + Stream_Read_UINT32(irp->input, PathLength); status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); @@ -186,8 +186,8 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp) DEBUG_SVC("%s(%d) created.", file->fullpath, file->id); } - stream_write_UINT32(irp->output, FileId); - stream_write_BYTE(irp->output, Information); + Stream_Write_UINT32(irp->output, FileId); + Stream_Write_UINT8(irp->output, Information); free(path); @@ -214,7 +214,7 @@ static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp) drive_file_free(file); } - stream_write_zero(irp->output, 5); /* Padding(5) */ + Stream_Write_zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } @@ -226,8 +226,8 @@ static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp) UINT64 Offset; BYTE* buffer = NULL; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); file = drive_get_file_by_id(disk, irp->FileId); @@ -263,12 +263,12 @@ static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp) } } - stream_write_UINT32(irp->output, Length); + Stream_Write_UINT32(irp->output, Length); if (Length > 0) { Stream_EnsureRemainingCapacity(irp->output, (int) Length); - stream_write(irp->output, buffer, Length); + Stream_Write(irp->output, buffer, Length); } free(buffer); @@ -282,8 +282,8 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp) UINT32 Length; UINT64 Offset; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); Stream_Seek(irp->input, 20); /* Padding */ file = drive_get_file_by_id(disk, irp->FileId); @@ -314,8 +314,8 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp) DEBUG_SVC("write %llu-%llu to %s(%d).", Offset, Offset + Length, file->fullpath, file->id); } - stream_write_UINT32(irp->output, Length); - stream_write_BYTE(irp->output, 0); /* Padding */ + Stream_Write_UINT32(irp->output, Length); + Stream_Write_UINT8(irp->output, 0); /* Padding */ irp->Complete(irp); } @@ -325,7 +325,7 @@ static void drive_process_irp_query_information(DRIVE_DEVICE* disk, IRP* irp) DRIVE_FILE* file; UINT32 FsInformationClass; - stream_read_UINT32(irp->input, FsInformationClass); + Stream_Read_UINT32(irp->input, FsInformationClass); file = drive_get_file_by_id(disk, irp->FileId); @@ -355,8 +355,8 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp) UINT32 FsInformationClass; UINT32 Length; - stream_read_UINT32(irp->input, FsInformationClass); - stream_read_UINT32(irp->input, Length); + Stream_Read_UINT32(irp->input, FsInformationClass); + Stream_Read_UINT32(irp->input, Length); Stream_Seek(irp->input, 24); /* Padding */ file = drive_get_file_by_id(disk, irp->FileId); @@ -378,7 +378,7 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp) DEBUG_SVC("FsInformationClass %d on %s(%d) ok.", FsInformationClass, file->fullpath, file->id); } - stream_write_UINT32(irp->output, Length); + Stream_Write_UINT32(irp->output, Length); irp->Complete(irp); } @@ -394,7 +394,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* WCHAR* outStr = NULL; int length; - stream_read_UINT32(irp->input, FsInformationClass); + Stream_Read_UINT32(irp->input, FsInformationClass); STATVFS(disk->path, &svfst); STAT(disk->path, &st); @@ -404,72 +404,72 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* case FileFsVolumeInformation: /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */ length = ConvertToUnicode(CP_UTF8, 0, volumeLabel, -1, &outStr, 0) * 2; - stream_write_UINT32(output, 17 + length); /* Length */ + Stream_Write_UINT32(output, 17 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 17 + length); - stream_write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ + Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ #ifdef ANDROID - stream_write_UINT32(output, svfst.f_fsid.__val[0]); /* VolumeSerialNumber */ + Stream_Write_UINT32(output, svfst.f_fsid.__val[0]); /* VolumeSerialNumber */ #else - stream_write_UINT32(output, svfst.f_fsid); /* VolumeSerialNumber */ + Stream_Write_UINT32(output, svfst.f_fsid); /* VolumeSerialNumber */ #endif - stream_write_UINT32(output, length); /* VolumeLabelLength */ - stream_write_BYTE(output, 0); /* SupportsObjects */ + Stream_Write_UINT32(output, length); /* VolumeLabelLength */ + Stream_Write_UINT8(output, 0); /* SupportsObjects */ /* Reserved(1), MUST NOT be added! */ - stream_write(output, outStr, length); /* VolumeLabel (Unicode) */ + Stream_Write(output, outStr, length); /* VolumeLabel (Unicode) */ free(outStr); break; case FileFsSizeInformation: /* http://msdn.microsoft.com/en-us/library/cc232107.aspx */ - stream_write_UINT32(output, 24); /* Length */ + Stream_Write_UINT32(output, 24); /* Length */ Stream_EnsureRemainingCapacity(output, 24); - stream_write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ - stream_write_UINT64(output, svfst.f_bavail); /* AvailableAllocationUnits */ - stream_write_UINT32(output, 1); /* SectorsPerAllocationUnit */ - stream_write_UINT32(output, svfst.f_bsize); /* BytesPerSector */ + Stream_Write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ + Stream_Write_UINT64(output, svfst.f_bavail); /* AvailableAllocationUnits */ + Stream_Write_UINT32(output, 1); /* SectorsPerAllocationUnit */ + Stream_Write_UINT32(output, svfst.f_bsize); /* BytesPerSector */ break; case FileFsAttributeInformation: /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */ length = ConvertToUnicode(CP_UTF8, 0, diskType, -1, &outStr, 0) * 2; - stream_write_UINT32(output, 12 + length); /* Length */ + Stream_Write_UINT32(output, 12 + length); /* Length */ Stream_EnsureRemainingCapacity(output, 12 + length); - stream_write_UINT32(output, + Stream_Write_UINT32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK); /* FileSystemAttributes */ #ifdef ANDROID - stream_write_UINT32(output, 255); /* MaximumComponentNameLength */ + Stream_Write_UINT32(output, 255); /* MaximumComponentNameLength */ #else - stream_write_UINT32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */ + Stream_Write_UINT32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */ #endif - stream_write_UINT32(output, length); /* FileSystemNameLength */ - stream_write(output, outStr, length); /* FileSystemName (Unicode) */ + Stream_Write_UINT32(output, length); /* FileSystemNameLength */ + Stream_Write(output, outStr, length); /* FileSystemName (Unicode) */ free(outStr); break; case FileFsFullSizeInformation: /* http://msdn.microsoft.com/en-us/library/cc232104.aspx */ - stream_write_UINT32(output, 32); /* Length */ + Stream_Write_UINT32(output, 32); /* Length */ Stream_EnsureRemainingCapacity(output, 32); - stream_write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ - stream_write_UINT64(output, svfst.f_bavail); /* CallerAvailableAllocationUnits */ - stream_write_UINT64(output, svfst.f_bfree); /* AvailableAllocationUnits */ - stream_write_UINT32(output, 1); /* SectorsPerAllocationUnit */ - stream_write_UINT32(output, svfst.f_bsize); /* BytesPerSector */ + Stream_Write_UINT64(output, svfst.f_blocks); /* TotalAllocationUnits */ + Stream_Write_UINT64(output, svfst.f_bavail); /* CallerAvailableAllocationUnits */ + Stream_Write_UINT64(output, svfst.f_bfree); /* AvailableAllocationUnits */ + Stream_Write_UINT32(output, 1); /* SectorsPerAllocationUnit */ + Stream_Write_UINT32(output, svfst.f_bsize); /* BytesPerSector */ break; case FileFsDeviceInformation: /* http://msdn.microsoft.com/en-us/library/cc232109.aspx */ - stream_write_UINT32(output, 8); /* Length */ + Stream_Write_UINT32(output, 8); /* Length */ Stream_EnsureRemainingCapacity(output, 8); - stream_write_UINT32(output, FILE_DEVICE_DISK); /* DeviceType */ - stream_write_UINT32(output, 0); /* Characteristics */ + Stream_Write_UINT32(output, FILE_DEVICE_DISK); /* DeviceType */ + Stream_Write_UINT32(output, 0); /* Characteristics */ break; default: irp->IoStatus = STATUS_UNSUCCESSFUL; - stream_write_UINT32(output, 0); /* Length */ + Stream_Write_UINT32(output, 0); /* Length */ DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass); break; } @@ -484,10 +484,10 @@ static void drive_process_irp_silent_ignore(DRIVE_DEVICE* disk, IRP* irp) UINT32 FsInformationClass; wStream* output = irp->output; - stream_read_UINT32(irp->input, FsInformationClass); + Stream_Read_UINT32(irp->input, FsInformationClass); DEBUG_SVC("FsInformationClass %d in drive_process_irp_silent_ignore", FsInformationClass); - stream_write_UINT32(output, 0); /* Length */ + Stream_Write_UINT32(output, 0); /* Length */ irp->Complete(irp); } @@ -501,9 +501,9 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp) UINT32 PathLength; UINT32 FsInformationClass; - stream_read_UINT32(irp->input, FsInformationClass); - stream_read_BYTE(irp->input, InitialQuery); - stream_read_UINT32(irp->input, PathLength); + Stream_Read_UINT32(irp->input, FsInformationClass); + Stream_Read_UINT8(irp->input, InitialQuery); + Stream_Read_UINT32(irp->input, PathLength); Stream_Seek(irp->input, 23); /* Padding */ status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), @@ -517,7 +517,7 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp) if (file == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; - stream_write_UINT32(irp->output, 0); /* Length */ + Stream_Write_UINT32(irp->output, 0); /* Length */ DEBUG_WARN("FileId %d not valid.", irp->FileId); } else if (!drive_file_query_directory(file, FsInformationClass, InitialQuery, path, irp->output)) @@ -545,7 +545,7 @@ static void drive_process_irp_directory_control(DRIVE_DEVICE* disk, IRP* irp) default: DEBUG_WARN("MinorFunction 0x%X not supported", irp->MinorFunction); irp->IoStatus = STATUS_NOT_SUPPORTED; - stream_write_UINT32(irp->output, 0); /* Length */ + Stream_Write_UINT32(irp->output, 0); /* Length */ irp->Complete(irp); break; } @@ -553,7 +553,7 @@ static void drive_process_irp_directory_control(DRIVE_DEVICE* disk, IRP* irp) static void drive_process_irp_device_control(DRIVE_DEVICE* disk, IRP* irp) { - stream_write_UINT32(irp->output, 0); /* OutputBufferLength */ + Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */ irp->Complete(irp); } @@ -713,7 +713,7 @@ void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* disk->device.data = stream_new(length + 1); for (i = 0; i <= length; i++) - stream_write_BYTE(disk->device.data, name[i] < 0 ? '_' : name[i]); + Stream_Write_UINT8(disk->device.data, name[i] < 0 ? '_' : name[i]); disk->path = path; disk->files = list_new(); diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 449c0f384..8e3e00a85 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -78,7 +78,7 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) Stream_Seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ - stream_read_UINT32(irp->input, PathLength); + Stream_Read_UINT32(irp->input, PathLength); status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); @@ -105,8 +105,8 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) DEBUG_SVC("%s(%d) created", parallel->path, parallel->file); } - stream_write_UINT32(irp->output, parallel->id); - stream_write_BYTE(irp->output, 0); + Stream_Write_UINT32(irp->output, parallel->id); + Stream_Write_UINT8(irp->output, 0); free(path); @@ -120,7 +120,7 @@ static void parallel_process_irp_close(PARALLEL_DEVICE* parallel, IRP* irp) else DEBUG_SVC("%s(%d) closed", parallel->path, parallel->id); - stream_write_zero(irp->output, 5); /* Padding(5) */ + Stream_Write_zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } @@ -132,8 +132,8 @@ static void parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp) ssize_t status; BYTE* buffer = NULL; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); buffer = (BYTE*) malloc(Length); @@ -153,12 +153,12 @@ static void parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp) DEBUG_SVC("read %llu-%llu from %d", Offset, Offset + Length, parallel->id); } - stream_write_UINT32(irp->output, Length); + Stream_Write_UINT32(irp->output, Length); if (Length > 0) { Stream_EnsureRemainingCapacity(irp->output, Length); - stream_write(irp->output, buffer, Length); + Stream_Write(irp->output, buffer, Length); } free(buffer); @@ -173,8 +173,8 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) UINT64 Offset; ssize_t status; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); Stream_Seek(irp->input, 20); /* Padding */ DEBUG_SVC("Length %u Offset %llu", Length, Offset); @@ -198,8 +198,8 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) len -= status; } - stream_write_UINT32(irp->output, Length); - stream_write_BYTE(irp->output, 0); /* Padding */ + Stream_Write_UINT32(irp->output, Length); + Stream_Write_UINT8(irp->output, 0); /* Padding */ irp->Complete(irp); } @@ -207,7 +207,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) static void parallel_process_irp_device_control(PARALLEL_DEVICE* parallel, IRP* irp) { DEBUG_SVC("in"); - stream_write_UINT32(irp->output, 0); /* OutputBufferLength */ + Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */ irp->Complete(irp); } @@ -322,7 +322,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) parallel->device.data = stream_new(length + 1); for (i = 0; i <= length; i++) - stream_write_BYTE(parallel->device.data, name[i] < 0 ? '_' : name[i]); + Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]); parallel->path = path; diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 3703877db..607bf1ca0 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -68,13 +68,13 @@ static void printer_process_irp_create(PRINTER_DEVICE* printer_dev, IRP* irp) if (printjob) { - stream_write_UINT32(irp->output, printjob->id); /* FileId */ + Stream_Write_UINT32(irp->output, printjob->id); /* FileId */ DEBUG_SVC("printjob id: %d", printjob->id); } else { - stream_write_UINT32(irp->output, 0); /* FileId */ + Stream_Write_UINT32(irp->output, 0); /* FileId */ irp->IoStatus = STATUS_PRINT_QUEUE_FULL; DEBUG_WARN("error creating print job."); @@ -103,7 +103,7 @@ static void printer_process_irp_close(PRINTER_DEVICE* printer_dev, IRP* irp) DEBUG_SVC("printjob id %d closed.", irp->FileId); } - stream_write_zero(irp->output, 4); /* Padding(4) */ + Stream_Write_zero(irp->output, 4); /* Padding(4) */ irp->Complete(irp); } @@ -114,8 +114,8 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) UINT64 Offset; rdpPrintJob* printjob = NULL; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); Stream_Seek(irp->input, 20); /* Padding */ if (printer_dev->printer) @@ -135,8 +135,8 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) DEBUG_SVC("printjob id %d written %d bytes.", irp->FileId, Length); } - stream_write_UINT32(irp->output, Length); - stream_write_BYTE(irp->output, 0); /* Padding */ + Stream_Write_UINT32(irp->output, Length); + Stream_Write_UINT8(irp->output, 0); /* Padding */ irp->Complete(irp); } @@ -261,20 +261,20 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen); - stream_write_UINT32(printer_dev->device.data, Flags); - stream_write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */ - stream_write_UINT32(printer_dev->device.data, 0); /* PnPNameLen */ - stream_write_UINT32(printer_dev->device.data, DriverNameLen + 2); - stream_write_UINT32(printer_dev->device.data, PrintNameLen + 2); - stream_write_UINT32(printer_dev->device.data, CachedFieldsLen); - stream_write(printer_dev->device.data, DriverName, DriverNameLen); - stream_write_UINT16(printer_dev->device.data, 0); - stream_write(printer_dev->device.data, PrintName, PrintNameLen); - stream_write_UINT16(printer_dev->device.data, 0); + Stream_Write_UINT32(printer_dev->device.data, Flags); + Stream_Write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */ + Stream_Write_UINT32(printer_dev->device.data, 0); /* PnPNameLen */ + Stream_Write_UINT32(printer_dev->device.data, DriverNameLen + 2); + Stream_Write_UINT32(printer_dev->device.data, PrintNameLen + 2); + Stream_Write_UINT32(printer_dev->device.data, CachedFieldsLen); + Stream_Write(printer_dev->device.data, DriverName, DriverNameLen); + Stream_Write_UINT16(printer_dev->device.data, 0); + Stream_Write(printer_dev->device.data, PrintName, PrintNameLen); + Stream_Write_UINT16(printer_dev->device.data, 0); if (CachedFieldsLen > 0) { - stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen); + Stream_Write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen); } free(DriverName); diff --git a/channels/rail/client/rail_main.c b/channels/rail/client/rail_main.c index f3477cfac..3b2fcbda3 100644 --- a/channels/rail/client/rail_main.c +++ b/channels/rail/client/rail_main.c @@ -44,7 +44,7 @@ void rail_send_channel_data(void* rail_object, void* data, size_t length) railPlugin* plugin = (railPlugin*) rail_object; s = stream_new(length); - stream_write(s, data, length); + Stream_Write(s, data, length); svc_plugin_send((rdpSvcPlugin*) plugin, s); } diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index c280c81d2..d7185bd78 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -92,15 +92,15 @@ BOOL rail_read_pdu_header(wStream* s, UINT16* orderType, UINT16* orderLength) { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, *orderType); /* orderType (2 bytes) */ - stream_read_UINT16(s, *orderLength); /* orderLength (2 bytes) */ + Stream_Read_UINT16(s, *orderType); /* orderType (2 bytes) */ + Stream_Read_UINT16(s, *orderLength); /* orderLength (2 bytes) */ return TRUE; } void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength) { - stream_write_UINT16(s, orderType); /* orderType (2 bytes) */ - stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, orderType); /* orderType (2 bytes) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ } wStream* rail_pdu_init(int length) @@ -131,8 +131,8 @@ void rail_send_pdu(rdpRailOrder* rail_order, wStream* s, UINT16 orderType) void rail_write_high_contrast(wStream* s, HIGH_CONTRAST* high_contrast) { high_contrast->colorSchemeLength = high_contrast->colorScheme.length + 2; - stream_write_UINT32(s, high_contrast->flags); /* flags (4 bytes) */ - stream_write_UINT32(s, high_contrast->colorSchemeLength); /* colorSchemeLength (4 bytes) */ + Stream_Write_UINT32(s, high_contrast->flags); /* flags (4 bytes) */ + Stream_Write_UINT32(s, high_contrast->colorSchemeLength); /* colorSchemeLength (4 bytes) */ rail_write_unicode_string(s, &high_contrast->colorScheme); /* colorScheme */ } @@ -140,7 +140,7 @@ BOOL rail_read_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake) { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */ + Stream_Read_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */ return TRUE; } @@ -148,9 +148,9 @@ BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* exec { if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT16(s, exec_result->flags); /* flags (2 bytes) */ - stream_read_UINT16(s, exec_result->execResult); /* execResult (2 bytes) */ - stream_read_UINT32(s, exec_result->rawResult); /* rawResult (4 bytes) */ + Stream_Read_UINT16(s, exec_result->flags); /* flags (2 bytes) */ + Stream_Read_UINT16(s, exec_result->execResult); /* execResult (2 bytes) */ + Stream_Read_UINT32(s, exec_result->rawResult); /* rawResult (4 bytes) */ Stream_Seek_UINT16(s); /* padding (2 bytes) */ return rail_read_unicode_string(s, &exec_result->exeOrFile); /* exeOrFile */ } @@ -161,8 +161,8 @@ BOOL rail_read_server_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam) if (Stream_GetRemainingLength(s) < 5) return FALSE; - stream_read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */ - stream_read_BYTE(s, body); /* body (1 byte) */ + Stream_Read_UINT32(s, sysparam->param); /* systemParam (4 bytes) */ + Stream_Read_UINT8(s, body); /* body (1 byte) */ switch (sysparam->param) { @@ -184,15 +184,15 @@ BOOL rail_read_server_minmaxinfo_order(wStream* s, RAIL_MINMAXINFO_ORDER* minmax { if (Stream_GetRemainingLength(s) < 20) return FALSE; - stream_read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->minTrackHeight); /* minTrackHeight (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */ - stream_read_UINT16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */ + Stream_Read_UINT32(s, minmaxinfo->windowId); /* windowId (4 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxWidth); /* maxWidth (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxHeight); /* maxHeight (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxPosX); /* maxPosX (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxPosY); /* maxPosY (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->minTrackWidth); /* minTrackWidth (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->minTrackHeight); /* minTrackHeight (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxTrackWidth); /* maxTrackWidth (2 bytes) */ + Stream_Read_UINT16(s, minmaxinfo->maxTrackHeight); /* maxTrackHeight (2 bytes) */ return TRUE; } @@ -201,14 +201,14 @@ BOOL rail_read_server_localmovesize_order(wStream* s, RAIL_LOCALMOVESIZE_ORDER* UINT16 isMoveSizeStart; if (Stream_GetRemainingLength(s) < 12) return FALSE; - stream_read_UINT32(s, localmovesize->windowId); /* windowId (4 bytes) */ + Stream_Read_UINT32(s, localmovesize->windowId); /* windowId (4 bytes) */ - stream_read_UINT16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */ + Stream_Read_UINT16(s, isMoveSizeStart); /* isMoveSizeStart (2 bytes) */ localmovesize->isMoveSizeStart = (isMoveSizeStart != 0) ? TRUE : FALSE; - stream_read_UINT16(s, localmovesize->moveSizeType); /* moveSizeType (2 bytes) */ - stream_read_UINT16(s, localmovesize->posX); /* posX (2 bytes) */ - stream_read_UINT16(s, localmovesize->posY); /* posY (2 bytes) */ + Stream_Read_UINT16(s, localmovesize->moveSizeType); /* moveSizeType (2 bytes) */ + Stream_Read_UINT16(s, localmovesize->posX); /* posX (2 bytes) */ + Stream_Read_UINT16(s, localmovesize->posY); /* posY (2 bytes) */ return TRUE; } @@ -216,8 +216,8 @@ BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER { if (Stream_GetRemainingLength(s) < 516) return FALSE; - stream_read_UINT32(s, get_appid_resp->windowId); /* windowId (4 bytes) */ - stream_read(s, &get_appid_resp->applicationIdBuffer[0], 512); /* applicationId (256 UNICODE chars) */ + Stream_Read_UINT32(s, get_appid_resp->windowId); /* windowId (4 bytes) */ + Stream_Read(s, &get_appid_resp->applicationIdBuffer[0], 512); /* applicationId (256 UNICODE chars) */ get_appid_resp->applicationId.length = 512; get_appid_resp->applicationId.string = &get_appid_resp->applicationIdBuffer[0]; @@ -228,26 +228,26 @@ BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_i { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */ + Stream_Read_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */ return TRUE; } void rail_write_handshake_order(wStream* s, RAIL_HANDSHAKE_ORDER* handshake) { - stream_write_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */ + Stream_Write_UINT32(s, handshake->buildNumber); /* buildNumber (4 bytes) */ } void rail_write_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER* client_status) { - stream_write_UINT32(s, client_status->flags); /* flags (4 bytes) */ + Stream_Write_UINT32(s, client_status->flags); /* flags (4 bytes) */ } void rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec) { - stream_write_UINT16(s, exec->flags); /* flags (2 bytes) */ - stream_write_UINT16(s, exec->exeOrFile.length); /* exeOrFileLength (2 bytes) */ - stream_write_UINT16(s, exec->workingDir.length); /* workingDirLength (2 bytes) */ - stream_write_UINT16(s, exec->arguments.length); /* argumentsLength (2 bytes) */ + Stream_Write_UINT16(s, exec->flags); /* flags (2 bytes) */ + Stream_Write_UINT16(s, exec->exeOrFile.length); /* exeOrFileLength (2 bytes) */ + Stream_Write_UINT16(s, exec->workingDir.length); /* workingDirLength (2 bytes) */ + Stream_Write_UINT16(s, exec->arguments.length); /* argumentsLength (2 bytes) */ rail_write_unicode_string_value(s, &exec->exeOrFile); /* exeOrFile */ rail_write_unicode_string_value(s, &exec->workingDir); /* workingDir */ rail_write_unicode_string_value(s, &exec->arguments); /* arguments */ @@ -256,49 +256,49 @@ void rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec) void rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam) { BYTE body; - stream_write_UINT32(s, sysparam->param); /* systemParam (4 bytes) */ + Stream_Write_UINT32(s, sysparam->param); /* systemParam (4 bytes) */ switch (sysparam->param) { case SPI_SET_DRAG_FULL_WINDOWS: body = sysparam->dragFullWindows; - stream_write_BYTE(s, body); + Stream_Write_UINT8(s, body); break; case SPI_SET_KEYBOARD_CUES: body = sysparam->keyboardCues; - stream_write_BYTE(s, body); + Stream_Write_UINT8(s, body); break; case SPI_SET_KEYBOARD_PREF: body = sysparam->keyboardPref; - stream_write_BYTE(s, body); + Stream_Write_UINT8(s, body); break; case SPI_SET_MOUSE_BUTTON_SWAP: body = sysparam->mouseButtonSwap; - stream_write_BYTE(s, body); + Stream_Write_UINT8(s, body); break; case SPI_SET_WORK_AREA: - stream_write_UINT16(s, sysparam->workArea.left); /* left (2 bytes) */ - stream_write_UINT16(s, sysparam->workArea.top); /* top (2 bytes) */ - stream_write_UINT16(s, sysparam->workArea.right); /* right (2 bytes) */ - stream_write_UINT16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, sysparam->workArea.left); /* left (2 bytes) */ + Stream_Write_UINT16(s, sysparam->workArea.top); /* top (2 bytes) */ + Stream_Write_UINT16(s, sysparam->workArea.right); /* right (2 bytes) */ + Stream_Write_UINT16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */ break; case SPI_DISPLAY_CHANGE: - stream_write_UINT16(s, sysparam->displayChange.left); /* left (2 bytes) */ - stream_write_UINT16(s, sysparam->displayChange.top); /* top (2 bytes) */ - stream_write_UINT16(s, sysparam->displayChange.right); /* right (2 bytes) */ - stream_write_UINT16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, sysparam->displayChange.left); /* left (2 bytes) */ + Stream_Write_UINT16(s, sysparam->displayChange.top); /* top (2 bytes) */ + Stream_Write_UINT16(s, sysparam->displayChange.right); /* right (2 bytes) */ + Stream_Write_UINT16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */ break; case SPI_TASKBAR_POS: - stream_write_UINT16(s, sysparam->taskbarPos.left); /* left (2 bytes) */ - stream_write_UINT16(s, sysparam->taskbarPos.top); /* top (2 bytes) */ - stream_write_UINT16(s, sysparam->taskbarPos.right); /* right (2 bytes) */ - stream_write_UINT16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, sysparam->taskbarPos.left); /* left (2 bytes) */ + Stream_Write_UINT16(s, sysparam->taskbarPos.top); /* top (2 bytes) */ + Stream_Write_UINT16(s, sysparam->taskbarPos.right); /* right (2 bytes) */ + Stream_Write_UINT16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */ break; case SPI_SET_HIGH_CONTRAST: @@ -311,49 +311,49 @@ void rail_write_client_activate_order(wStream* s, RAIL_ACTIVATE_ORDER* activate) { BYTE enabled; - stream_write_UINT32(s, activate->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT32(s, activate->windowId); /* windowId (4 bytes) */ enabled = activate->enabled; - stream_write_BYTE(s, enabled); /* enabled (1 byte) */ + Stream_Write_UINT8(s, enabled); /* enabled (1 byte) */ } void rail_write_client_sysmenu_order(wStream* s, RAIL_SYSMENU_ORDER* sysmenu) { - stream_write_UINT32(s, sysmenu->windowId); /* windowId (4 bytes) */ - stream_write_UINT16(s, sysmenu->left); /* left (2 bytes) */ - stream_write_UINT16(s, sysmenu->top); /* top (2 bytes) */ + Stream_Write_UINT32(s, sysmenu->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT16(s, sysmenu->left); /* left (2 bytes) */ + Stream_Write_UINT16(s, sysmenu->top); /* top (2 bytes) */ } void rail_write_client_syscommand_order(wStream* s, RAIL_SYSCOMMAND_ORDER* syscommand) { - stream_write_UINT32(s, syscommand->windowId); /* windowId (4 bytes) */ - stream_write_UINT16(s, syscommand->command); /* command (2 bytes) */ + Stream_Write_UINT32(s, syscommand->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT16(s, syscommand->command); /* command (2 bytes) */ } void rail_write_client_notify_event_order(wStream* s, RAIL_NOTIFY_EVENT_ORDER* notify_event) { - stream_write_UINT32(s, notify_event->windowId); /* windowId (4 bytes) */ - stream_write_UINT32(s, notify_event->notifyIconId); /* notifyIconId (4 bytes) */ - stream_write_UINT32(s, notify_event->message); /* notifyIconId (4 bytes) */ + Stream_Write_UINT32(s, notify_event->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT32(s, notify_event->notifyIconId); /* notifyIconId (4 bytes) */ + Stream_Write_UINT32(s, notify_event->message); /* notifyIconId (4 bytes) */ } void rail_write_client_window_move_order(wStream* s, RAIL_WINDOW_MOVE_ORDER* window_move) { - stream_write_UINT32(s, window_move->windowId); /* windowId (4 bytes) */ - stream_write_UINT16(s, window_move->left); /* left (2 bytes) */ - stream_write_UINT16(s, window_move->top); /* top (2 bytes) */ - stream_write_UINT16(s, window_move->right); /* right (2 bytes) */ - stream_write_UINT16(s, window_move->bottom); /* bottom (2 bytes) */ + Stream_Write_UINT32(s, window_move->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT16(s, window_move->left); /* left (2 bytes) */ + Stream_Write_UINT16(s, window_move->top); /* top (2 bytes) */ + Stream_Write_UINT16(s, window_move->right); /* right (2 bytes) */ + Stream_Write_UINT16(s, window_move->bottom); /* bottom (2 bytes) */ } void rail_write_client_get_appid_req_order(wStream* s, RAIL_GET_APPID_REQ_ORDER* get_appid_req) { - stream_write_UINT32(s, get_appid_req->windowId); /* windowId (4 bytes) */ + Stream_Write_UINT32(s, get_appid_req->windowId); /* windowId (4 bytes) */ } void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info) { - stream_write_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */ + Stream_Write_UINT32(s, langbar_info->languageBarStatus); /* languageBarStatus (4 bytes) */ } BOOL rail_recv_handshake_order(rdpRailOrder* rail_order, wStream* s) diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c index 5fb3d74ae..50649e4a6 100644 --- a/channels/rdpdr/client/irp.c +++ b/channels/rdpdr/client/irp.c @@ -53,7 +53,7 @@ static void irp_complete(IRP* irp) pos = Stream_GetPosition(irp->output); Stream_SetPosition(irp->output, 12); - stream_write_UINT32(irp->output, irp->IoStatus); + Stream_Write_UINT32(irp->output, irp->IoStatus); Stream_SetPosition(irp->output, pos); svc_plugin_send(irp->devman->plugin, irp->output); @@ -68,7 +68,7 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in) UINT32 DeviceId; DEVICE* device; - stream_read_UINT32(data_in, DeviceId); + Stream_Read_UINT32(data_in, DeviceId); device = devman_get_device_by_id(devman, DeviceId); if (device == NULL) @@ -82,17 +82,17 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in) irp->device = device; irp->devman = devman; - stream_read_UINT32(data_in, irp->FileId); - stream_read_UINT32(data_in, irp->CompletionId); - stream_read_UINT32(data_in, irp->MajorFunction); - stream_read_UINT32(data_in, irp->MinorFunction); + Stream_Read_UINT32(data_in, irp->FileId); + Stream_Read_UINT32(data_in, irp->CompletionId); + Stream_Read_UINT32(data_in, irp->MajorFunction); + Stream_Read_UINT32(data_in, irp->MinorFunction); irp->input = data_in; irp->output = stream_new(256); - stream_write_UINT16(irp->output, RDPDR_CTYP_CORE); - stream_write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION); - stream_write_UINT32(irp->output, DeviceId); - stream_write_UINT32(irp->output, irp->CompletionId); + Stream_Write_UINT16(irp->output, RDPDR_CTYP_CORE); + Stream_Write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION); + Stream_Write_UINT32(irp->output, DeviceId); + Stream_Write_UINT32(irp->output, irp->CompletionId); Stream_Seek_UINT32(irp->output); /* IoStatus */ irp->Complete = irp_complete; diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index 8dcaf747c..ff4640259 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -35,9 +35,9 @@ /* Output device redirection capability set header */ static void rdpdr_write_capset_header(wStream* data_out, UINT16 capabilityType, UINT16 capabilityLength, UINT32 version) { - stream_write_UINT16(data_out, capabilityType); - stream_write_UINT16(data_out, capabilityLength); - stream_write_UINT32(data_out, version); + Stream_Write_UINT16(data_out, capabilityType); + Stream_Write_UINT16(data_out, capabilityLength); + Stream_Write_UINT32(data_out, version); } /* Output device direction general capability set */ @@ -45,16 +45,16 @@ static void rdpdr_write_general_capset(rdpdrPlugin* rdpdr, wStream* data_out) { rdpdr_write_capset_header(data_out, CAP_GENERAL_TYPE, 44, GENERAL_CAPABILITY_VERSION_02); - stream_write_UINT32(data_out, 0); /* osType, ignored on receipt */ - stream_write_UINT32(data_out, 0); /* osVersion, unused and must be set to zero */ - stream_write_UINT16(data_out, 1); /* protocolMajorVersion, must be set to 1 */ - stream_write_UINT16(data_out, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */ - stream_write_UINT32(data_out, 0x0000FFFF); /* ioCode1 */ - stream_write_UINT32(data_out, 0); /* ioCode2, must be set to zero, reserved for future use */ - stream_write_UINT32(data_out, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */ - stream_write_UINT32(data_out, ENABLE_ASYNCIO); /* extraFlags1 */ - stream_write_UINT32(data_out, 0); /* extraFlags2, must be set to zero, reserved for future use */ - stream_write_UINT32(data_out, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */ + Stream_Write_UINT32(data_out, 0); /* osType, ignored on receipt */ + Stream_Write_UINT32(data_out, 0); /* osVersion, unused and must be set to zero */ + Stream_Write_UINT16(data_out, 1); /* protocolMajorVersion, must be set to 1 */ + Stream_Write_UINT16(data_out, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */ + Stream_Write_UINT32(data_out, 0x0000FFFF); /* ioCode1 */ + Stream_Write_UINT32(data_out, 0); /* ioCode2, must be set to zero, reserved for future use */ + Stream_Write_UINT32(data_out, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */ + Stream_Write_UINT32(data_out, ENABLE_ASYNCIO); /* extraFlags1 */ + Stream_Write_UINT32(data_out, 0); /* extraFlags2, must be set to zero, reserved for future use */ + Stream_Write_UINT32(data_out, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */ } /* Process device direction general capability set */ @@ -62,7 +62,7 @@ static void rdpdr_process_general_capset(rdpdrPlugin* rdpdr, wStream* data_in) { UINT16 capabilityLength; - stream_read_UINT16(data_in, capabilityLength); + Stream_Read_UINT16(data_in, capabilityLength); Stream_Seek(data_in, capabilityLength - 4); } @@ -77,7 +77,7 @@ static void rdpdr_process_printer_capset(rdpdrPlugin* rdpdr, wStream* data_in) { UINT16 capabilityLength; - stream_read_UINT16(data_in, capabilityLength); + Stream_Read_UINT16(data_in, capabilityLength); Stream_Seek(data_in, capabilityLength - 4); } @@ -92,7 +92,7 @@ static void rdpdr_process_port_capset(rdpdrPlugin* rdpdr, wStream* data_in) { UINT16 capabilityLength; - stream_read_UINT16(data_in, capabilityLength); + Stream_Read_UINT16(data_in, capabilityLength); Stream_Seek(data_in, capabilityLength - 4); } @@ -107,7 +107,7 @@ static void rdpdr_process_drive_capset(rdpdrPlugin* rdpdr, wStream* data_in) { UINT16 capabilityLength; - stream_read_UINT16(data_in, capabilityLength); + Stream_Read_UINT16(data_in, capabilityLength); Stream_Seek(data_in, capabilityLength - 4); } @@ -122,7 +122,7 @@ static void rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* data_in) { UINT16 capabilityLength; - stream_read_UINT16(data_in, capabilityLength); + Stream_Read_UINT16(data_in, capabilityLength); Stream_Seek(data_in, capabilityLength - 4); } @@ -132,12 +132,12 @@ void rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* data_in) UINT16 numCapabilities; UINT16 capabilityType; - stream_read_UINT16(data_in, numCapabilities); + Stream_Read_UINT16(data_in, numCapabilities); Stream_Seek(data_in, 2); /* pad (2 bytes) */ for(i = 0; i < numCapabilities; i++) { - stream_read_UINT16(data_in, capabilityType); + Stream_Read_UINT16(data_in, capabilityType); switch (capabilityType) { @@ -174,11 +174,11 @@ void rdpdr_send_capability_response(rdpdrPlugin* rdpdr) data_out = stream_new(256); - stream_write_UINT16(data_out, RDPDR_CTYP_CORE); - stream_write_UINT16(data_out, PAKID_CORE_CLIENT_CAPABILITY); + Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); + Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_CAPABILITY); - stream_write_UINT16(data_out, 5); /* numCapabilities */ - stream_write_UINT16(data_out, 0); /* pad */ + Stream_Write_UINT16(data_out, 5); /* numCapabilities */ + Stream_Write_UINT16(data_out, 0); /* pad */ rdpdr_write_general_capset(rdpdr, data_out); rdpdr_write_printer_capset(rdpdr, data_out); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 2efac7afa..b099d1b5a 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -66,9 +66,9 @@ static void rdpdr_process_connect(rdpSvcPlugin* plugin) static void rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr, wStream* data_in) { - stream_read_UINT16(data_in, rdpdr->versionMajor); - stream_read_UINT16(data_in, rdpdr->versionMinor); - stream_read_UINT32(data_in, rdpdr->clientID); + Stream_Read_UINT16(data_in, rdpdr->versionMajor); + Stream_Read_UINT16(data_in, rdpdr->versionMinor); + Stream_Read_UINT32(data_in, rdpdr->clientID); DEBUG_SVC("version %d.%d clientID %d", rdpdr->versionMajor, rdpdr->versionMinor, rdpdr->clientID); } @@ -79,12 +79,12 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) data_out = stream_new(12); - stream_write_UINT16(data_out, RDPDR_CTYP_CORE); - stream_write_UINT16(data_out, PAKID_CORE_CLIENTID_CONFIRM); + Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); + Stream_Write_UINT16(data_out, PAKID_CORE_CLIENTID_CONFIRM); - stream_write_UINT16(data_out, rdpdr->versionMajor); - stream_write_UINT16(data_out, rdpdr->versionMinor); - stream_write_UINT32(data_out, (UINT32) rdpdr->clientID); + Stream_Write_UINT16(data_out, rdpdr->versionMajor); + Stream_Write_UINT16(data_out, rdpdr->versionMinor); + Stream_Write_UINT32(data_out, (UINT32) rdpdr->clientID); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); } @@ -102,14 +102,14 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) data_out = stream_new(16 + computerNameLenW + 2); - stream_write_UINT16(data_out, RDPDR_CTYP_CORE); - stream_write_UINT16(data_out, PAKID_CORE_CLIENT_NAME); + Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); + Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_NAME); - stream_write_UINT32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */ - stream_write_UINT32(data_out, 0); /* codePage, must be set to zero */ - stream_write_UINT32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */ - stream_write(data_out, computerNameW, computerNameLenW); - stream_write_UINT16(data_out, 0); /* null terminator */ + Stream_Write_UINT32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */ + Stream_Write_UINT32(data_out, 0); /* codePage, must be set to zero */ + Stream_Write_UINT32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */ + Stream_Write(data_out, computerNameW, computerNameLenW); + Stream_Write_UINT16(data_out, 0); /* null terminator */ free(computerNameW); @@ -122,9 +122,9 @@ static void rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr, wStream* d UINT16 versionMinor; UINT32 clientID; - stream_read_UINT16(data_in, versionMajor); - stream_read_UINT16(data_in, versionMinor); - stream_read_UINT32(data_in, clientID); + Stream_Read_UINT16(data_in, versionMajor); + Stream_Read_UINT16(data_in, versionMinor); + Stream_Read_UINT32(data_in, clientID); if (versionMajor != rdpdr->versionMajor || versionMinor != rdpdr->versionMinor) { @@ -154,8 +154,8 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use data_out = stream_new(256); - stream_write_UINT16(data_out, RDPDR_CTYP_CORE); - stream_write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE); + Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); + Stream_Write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE); count_pos = Stream_GetPosition(data_out); count = 0; @@ -178,8 +178,8 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data)); Stream_EnsureRemainingCapacity(data_out, 20 + data_len); - stream_write_UINT32(data_out, device->type); /* deviceType */ - stream_write_UINT32(data_out, device->id); /* deviceID */ + Stream_Write_UINT32(data_out, device->type); /* deviceType */ + Stream_Write_UINT32(data_out, device->id); /* deviceID */ strncpy((char*) Stream_Pointer(data_out), device->name, 8); for (i = 0; i < 8; i++) @@ -187,15 +187,15 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use stream_peek_BYTE(data_out, c); if (c > 0x7F) - stream_write_BYTE(data_out, '_'); + Stream_Write_UINT8(data_out, '_'); else Stream_Seek_BYTE(data_out); } - stream_write_UINT32(data_out, data_len); + Stream_Write_UINT32(data_out, data_len); if (data_len > 0) - stream_write(data_out, Stream_Buffer(device->data), data_len); + Stream_Write(data_out, Stream_Buffer(device->data), data_len); count++; @@ -206,7 +206,7 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use pos = Stream_GetPosition(data_out); Stream_SetPosition(data_out, count_pos); - stream_write_UINT32(data_out, count); + Stream_Write_UINT32(data_out, count); Stream_SetPosition(data_out, pos); Stream_SealLength(data_out); @@ -235,8 +235,8 @@ static void rdpdr_process_receive(rdpSvcPlugin* plugin, wStream* data_in) UINT32 status; rdpdrPlugin* rdpdr = (rdpdrPlugin*) plugin; - stream_read_UINT16(data_in, component); - stream_read_UINT16(data_in, packetID); + Stream_Read_UINT16(data_in, component); + Stream_Read_UINT16(data_in, packetID); if (component == RDPDR_CTYP_CORE) { @@ -268,8 +268,8 @@ static void rdpdr_process_receive(rdpSvcPlugin* plugin, wStream* data_in) case PAKID_CORE_DEVICE_REPLY: /* connect to a specific resource */ - stream_read_UINT32(data_in, deviceID); - stream_read_UINT32(data_in, status); + Stream_Read_UINT32(data_in, deviceID); + Stream_Read_UINT32(data_in, status); DEBUG_SVC("RDPDR_CTYP_CORE / PAKID_CORE_DEVICE_REPLY (deviceID=%d status=0x%08X)", deviceID, status); break; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 30fe201d6..82747fc90 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -127,11 +127,11 @@ void rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd) wStream* pdu; pdu = stream_new(8); - stream_write_BYTE(pdu, SNDC_QUALITYMODE); /* msgType */ - stream_write_BYTE(pdu, 0); /* bPad */ - stream_write_UINT16(pdu, 4); /* BodySize */ - stream_write_UINT16(pdu, HIGH_QUALITY); /* wQualityMode */ - stream_write_UINT16(pdu, 0); /* Reserved */ + Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */ + Stream_Write_UINT8(pdu, 0); /* bPad */ + Stream_Write_UINT16(pdu, 4); /* BodySize */ + Stream_Write_UINT16(pdu, HIGH_QUALITY); /* wQualityMode */ + Stream_Write_UINT16(pdu, 0); /* Reserved */ svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu); } @@ -219,33 +219,33 @@ void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) pdu = stream_new(length); - stream_write_BYTE(pdu, SNDC_FORMATS); /* msgType */ - stream_write_BYTE(pdu, 0); /* bPad */ - stream_write_UINT16(pdu, length - 4); /* BodySize */ + Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */ + Stream_Write_UINT8(pdu, 0); /* bPad */ + Stream_Write_UINT16(pdu, length - 4); /* BodySize */ - stream_write_UINT32(pdu, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */ - stream_write_UINT32(pdu, dwVolume); /* dwVolume */ - stream_write_UINT32(pdu, 0); /* dwPitch */ - stream_write_UINT16(pdu, 0); /* wDGramPort */ - stream_write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */ - stream_write_BYTE(pdu, 0); /* cLastBlockConfirmed */ - stream_write_UINT16(pdu, 6); /* wVersion */ - stream_write_BYTE(pdu, 0); /* bPad */ + Stream_Write_UINT32(pdu, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */ + Stream_Write_UINT32(pdu, dwVolume); /* dwVolume */ + Stream_Write_UINT32(pdu, 0); /* dwPitch */ + Stream_Write_UINT16(pdu, 0); /* wDGramPort */ + Stream_Write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */ + Stream_Write_UINT8(pdu, 0); /* cLastBlockConfirmed */ + Stream_Write_UINT16(pdu, 6); /* wVersion */ + Stream_Write_UINT8(pdu, 0); /* bPad */ for (index = 0; index < (int) wNumberOfFormats; index++) { clientFormat = &rdpsnd->ClientFormats[index]; - stream_write_UINT16(pdu, clientFormat->wFormatTag); - stream_write_UINT16(pdu, clientFormat->nChannels); - stream_write_UINT32(pdu, clientFormat->nSamplesPerSec); - stream_write_UINT32(pdu, clientFormat->nAvgBytesPerSec); - stream_write_UINT16(pdu, clientFormat->nBlockAlign); - stream_write_UINT16(pdu, clientFormat->wBitsPerSample); - stream_write_UINT16(pdu, clientFormat->cbSize); + Stream_Write_UINT16(pdu, clientFormat->wFormatTag); + Stream_Write_UINT16(pdu, clientFormat->nChannels); + Stream_Write_UINT32(pdu, clientFormat->nSamplesPerSec); + Stream_Write_UINT32(pdu, clientFormat->nAvgBytesPerSec); + Stream_Write_UINT16(pdu, clientFormat->nBlockAlign); + Stream_Write_UINT16(pdu, clientFormat->wBitsPerSample); + Stream_Write_UINT16(pdu, clientFormat->cbSize); if (clientFormat->cbSize > 0) - stream_write(pdu, clientFormat->data, clientFormat->cbSize); + Stream_Write(pdu, clientFormat->data, clientFormat->cbSize); } svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu); @@ -266,9 +266,9 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) Stream_Seek_UINT32(s); /* dwVolume */ Stream_Seek_UINT32(s); /* dwPitch */ Stream_Seek_UINT16(s); /* wDGramPort */ - stream_read_UINT16(s, wNumberOfFormats); - stream_read_BYTE(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */ - stream_read_UINT16(s, wVersion); /* wVersion */ + Stream_Read_UINT16(s, wNumberOfFormats); + Stream_Read_UINT8(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */ + Stream_Read_UINT16(s, wVersion); /* wVersion */ Stream_Seek_BYTE(s); /* bPad */ rdpsnd->NumberOfServerFormats = wNumberOfFormats; @@ -278,16 +278,16 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) { format = &rdpsnd->ServerFormats[index]; - stream_read_UINT16(s, format->wFormatTag); /* wFormatTag */ - stream_read_UINT16(s, format->nChannels); /* nChannels */ - stream_read_UINT32(s, format->nSamplesPerSec); /* nSamplesPerSec */ - stream_read_UINT32(s, format->nAvgBytesPerSec); /* nAvgBytesPerSec */ - stream_read_UINT16(s, format->nBlockAlign); /* nBlockAlign */ - stream_read_UINT16(s, format->wBitsPerSample); /* wBitsPerSample */ - stream_read_UINT16(s, format->cbSize); /* cbSize */ + Stream_Read_UINT16(s, format->wFormatTag); /* wFormatTag */ + Stream_Read_UINT16(s, format->nChannels); /* nChannels */ + Stream_Read_UINT32(s, format->nSamplesPerSec); /* nSamplesPerSec */ + Stream_Read_UINT32(s, format->nAvgBytesPerSec); /* nAvgBytesPerSec */ + Stream_Read_UINT16(s, format->nBlockAlign); /* nBlockAlign */ + Stream_Read_UINT16(s, format->wBitsPerSample); /* wBitsPerSample */ + Stream_Read_UINT16(s, format->cbSize); /* cbSize */ format->data = (BYTE*) malloc(format->cbSize); - stream_read(s, format->data, format->cbSize); + Stream_Read(s, format->data, format->cbSize); } rdpsnd_select_supported_audio_formats(rdpsnd); @@ -303,11 +303,11 @@ void rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, U wStream* pdu; pdu = stream_new(8); - stream_write_BYTE(pdu, SNDC_TRAINING); /* msgType */ - stream_write_BYTE(pdu, 0); /* bPad */ - stream_write_UINT16(pdu, 4); /* BodySize */ - stream_write_UINT16(pdu, wTimeStamp); - stream_write_UINT16(pdu, wPackSize); + Stream_Write_UINT8(pdu, SNDC_TRAINING); /* msgType */ + Stream_Write_UINT8(pdu, 0); /* bPad */ + Stream_Write_UINT16(pdu, 4); /* BodySize */ + Stream_Write_UINT16(pdu, wTimeStamp); + Stream_Write_UINT16(pdu, wPackSize); svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu); } @@ -317,8 +317,8 @@ static void rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, wStream* s) UINT16 wTimeStamp; UINT16 wPackSize; - stream_read_UINT16(s, wTimeStamp); - stream_read_UINT16(s, wPackSize); + Stream_Read_UINT16(s, wTimeStamp); + Stream_Read_UINT16(s, wPackSize); rdpsnd_send_training_confirm_pdu(rdpsnd, wTimeStamp, wPackSize); } @@ -330,11 +330,11 @@ static void rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 B rdpsnd->expectingWave = TRUE; - stream_read_UINT16(s, rdpsnd->wTimeStamp); - stream_read_UINT16(s, wFormatNo); - stream_read_BYTE(s, rdpsnd->cBlockNo); + Stream_Read_UINT16(s, rdpsnd->wTimeStamp); + Stream_Read_UINT16(s, wFormatNo); + Stream_Read_UINT8(s, rdpsnd->cBlockNo); Stream_Seek(s, 3); /* bPad */ - stream_read(s, rdpsnd->waveData, 4); + Stream_Read(s, rdpsnd->waveData, 4); rdpsnd->waveDataSize = BodySize - 8; @@ -368,12 +368,12 @@ void rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, BYTE wStream* pdu; pdu = stream_new(8); - stream_write_BYTE(pdu, SNDC_WAVECONFIRM); - stream_write_BYTE(pdu, 0); - stream_write_UINT16(pdu, 4); - stream_write_UINT16(pdu, wTimeStamp); - stream_write_BYTE(pdu, cConfirmedBlockNo); /* cConfirmedBlockNo */ - stream_write_BYTE(pdu, 0); /* bPad */ + Stream_Write_UINT8(pdu, SNDC_WAVECONFIRM); + Stream_Write_UINT8(pdu, 0); + Stream_Write_UINT16(pdu, 4); + Stream_Write_UINT16(pdu, wTimeStamp); + Stream_Write_UINT8(pdu, cConfirmedBlockNo); /* cConfirmedBlockNo */ + Stream_Write_UINT8(pdu, 0); /* bPad */ svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu); } @@ -458,7 +458,7 @@ static void rdpsnd_recv_volume_pdu(rdpsndPlugin* rdpsnd, wStream* s) { UINT32 dwVolume; - stream_read_UINT32(s, dwVolume); + Stream_Read_UINT32(s, dwVolume); DEBUG_SVC("dwVolume 0x%X", dwVolume); if (rdpsnd->device) @@ -480,9 +480,9 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s) return; } - stream_read_BYTE(s, msgType); /* msgType */ + Stream_Read_UINT8(s, msgType); /* msgType */ Stream_Seek_BYTE(s); /* bPad */ - stream_read_UINT16(s, BodySize); + Stream_Read_UINT16(s, BodySize); //fprintf(stderr, "msgType %d BodySize %d\n", msgType, BodySize); diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index 6beb25d77..644ca5d01 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -61,42 +61,42 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s) UINT16 i; BOOL status; - stream_write_BYTE(s, SNDC_FORMATS); - stream_write_BYTE(s, 0); + Stream_Write_UINT8(s, SNDC_FORMATS); + Stream_Write_UINT8(s, 0); Stream_Seek_UINT16(s); - stream_write_UINT32(s, 0); /* dwFlags */ - stream_write_UINT32(s, 0); /* dwVolume */ - stream_write_UINT32(s, 0); /* dwPitch */ - stream_write_UINT16(s, 0); /* wDGramPort */ - stream_write_UINT16(s, rdpsnd->context.num_server_formats); /* wNumberOfFormats */ - stream_write_BYTE(s, rdpsnd->context.block_no); /* cLastBlockConfirmed */ - stream_write_UINT16(s, 0x06); /* wVersion */ - stream_write_BYTE(s, 0); /* bPad */ + Stream_Write_UINT32(s, 0); /* dwFlags */ + Stream_Write_UINT32(s, 0); /* dwVolume */ + Stream_Write_UINT32(s, 0); /* dwPitch */ + Stream_Write_UINT16(s, 0); /* wDGramPort */ + Stream_Write_UINT16(s, rdpsnd->context.num_server_formats); /* wNumberOfFormats */ + Stream_Write_UINT8(s, rdpsnd->context.block_no); /* cLastBlockConfirmed */ + Stream_Write_UINT16(s, 0x06); /* wVersion */ + Stream_Write_UINT8(s, 0); /* bPad */ for (i = 0; i < rdpsnd->context.num_server_formats; i++) { - stream_write_UINT16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */ - stream_write_UINT16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */ - stream_write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */ + Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */ + Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */ + Stream_Write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */ - stream_write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec * + Stream_Write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec * rdpsnd->context.server_formats[i].nChannels * rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */ - stream_write_UINT16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */ - stream_write_UINT16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */ - stream_write_UINT16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */ + Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */ + Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */ + Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */ if (rdpsnd->context.server_formats[i].cbSize > 0) { - stream_write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize); + Stream_Write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize); } } pos = Stream_GetPosition(s); Stream_SetPosition(s, 2); - stream_write_UINT16(s, pos - 4); + Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); @@ -110,8 +110,8 @@ static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, wStream* s) UINT16 timestamp = 0; BYTE confirmBlockNum = 0; - stream_read_UINT16(s, timestamp); - stream_read_BYTE(s, confirmBlockNum); + Stream_Read_UINT16(s, timestamp); + Stream_Read_UINT8(s, confirmBlockNum); Stream_Seek_BYTE(s); // padding } @@ -120,7 +120,7 @@ static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s) //unhandled for now UINT16 quality; - stream_read_UINT16(s, quality); + Stream_Read_UINT16(s, quality); Stream_Seek_UINT16(s); // reserved fprintf(stderr, "Client requested sound quality: %#0X\n", quality); @@ -134,13 +134,13 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s) BYTE lastblock; - stream_read_UINT32(s, flags); /* dwFlags */ - stream_read_UINT32(s, vol); /* dwVolume */ - stream_read_UINT32(s, pitch); /* dwPitch */ - stream_read_UINT16(s, udpPort); /* wDGramPort */ - stream_read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */ - stream_read_BYTE(s, lastblock); /* cLastBlockConfirmed */ - stream_read_UINT16(s, version); /* wVersion */ + Stream_Read_UINT32(s, flags); /* dwFlags */ + Stream_Read_UINT32(s, vol); /* dwVolume */ + Stream_Read_UINT32(s, pitch); /* dwPitch */ + Stream_Read_UINT16(s, udpPort); /* wDGramPort */ + Stream_Read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */ + Stream_Read_UINT8(s, lastblock); /* cLastBlockConfirmed */ + Stream_Read_UINT16(s, version); /* wVersion */ Stream_Seek_BYTE(s); /* bPad */ if (rdpsnd->context.num_client_formats > 0) @@ -150,13 +150,13 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s) for (i = 0; i < rdpsnd->context.num_client_formats; i++) { - stream_read_UINT16(s, rdpsnd->context.client_formats[i].wFormatTag); - stream_read_UINT16(s, rdpsnd->context.client_formats[i].nChannels); - stream_read_UINT32(s, rdpsnd->context.client_formats[i].nSamplesPerSec); - stream_read_UINT32(s, rdpsnd->context.client_formats[i].nAvgBytesPerSec); - stream_read_UINT16(s, rdpsnd->context.client_formats[i].nBlockAlign); - stream_read_UINT16(s, rdpsnd->context.client_formats[i].wBitsPerSample); - stream_read_UINT16(s, rdpsnd->context.client_formats[i].cbSize); + Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].wFormatTag); + Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].nChannels); + Stream_Read_UINT32(s, rdpsnd->context.client_formats[i].nSamplesPerSec); + Stream_Read_UINT32(s, rdpsnd->context.client_formats[i].nAvgBytesPerSec); + Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].nBlockAlign); + Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].wBitsPerSample); + Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].cbSize); if (rdpsnd->context.client_formats[i].cbSize > 0) { @@ -231,9 +231,9 @@ static void* rdpsnd_server_thread_func(void* arg) break; } - stream_read_BYTE(s, msgType); + Stream_Read_UINT8(s, msgType); Stream_Seek_BYTE(s); /* bPad */ - stream_read_UINT16(s, BodySize); + Stream_Read_UINT16(s, BodySize); switch (msgType) { @@ -400,26 +400,26 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) /* WaveInfo PDU */ Stream_SetPosition(s, 0); - stream_write_BYTE(s, SNDC_WAVE); /* msgType */ - stream_write_BYTE(s, 0); /* bPad */ - stream_write_UINT16(s, size + fill_size + 8); /* BodySize */ + Stream_Write_UINT8(s, SNDC_WAVE); /* msgType */ + Stream_Write_UINT8(s, 0); /* bPad */ + Stream_Write_UINT16(s, size + fill_size + 8); /* BodySize */ - stream_write_UINT16(s, 0); /* wTimeStamp */ - stream_write_UINT16(s, rdpsnd->context.selected_client_format); /* wFormatNo */ - stream_write_BYTE(s, rdpsnd->context.block_no); /* cBlockNo */ + Stream_Write_UINT16(s, 0); /* wTimeStamp */ + Stream_Write_UINT16(s, rdpsnd->context.selected_client_format); /* wFormatNo */ + Stream_Write_UINT8(s, rdpsnd->context.block_no); /* cBlockNo */ Stream_Seek(s, 3); /* bPad */ - stream_write(s, src, 4); + Stream_Write(s, src, 4); WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); /* Wave PDU */ Stream_EnsureRemainingCapacity(s, size + fill_size); - stream_write_UINT32(s, 0); /* bPad */ - stream_write(s, src + 4, size - 4); + Stream_Write_UINT32(s, 0); /* bPad */ + Stream_Write(s, src + 4, size - 4); if (fill_size > 0) - stream_write_zero(s, fill_size); + Stream_Write_zero(s, fill_size); status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); @@ -465,16 +465,16 @@ static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, i rdpsnd_server* rdpsnd = (rdpsnd_server*) context; wStream* s = rdpsnd->rdpsnd_pdu; - stream_write_BYTE(s, SNDC_SETVOLUME); - stream_write_BYTE(s, 0); + Stream_Write_UINT8(s, SNDC_SETVOLUME); + Stream_Write_UINT8(s, 0); Stream_Seek_UINT16(s); - stream_write_UINT16(s, left); - stream_write_UINT16(s, right); + Stream_Write_UINT16(s, left); + Stream_Write_UINT16(s, right); pos = Stream_GetPosition(s); Stream_SetPosition(s, 2); - stream_write_UINT16(s, pos - 4); + Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); @@ -500,13 +500,13 @@ static BOOL rdpsnd_server_close(rdpsnd_server_context* context) rdpsnd->context.selected_client_format = -1; - stream_write_BYTE(s, SNDC_CLOSE); - stream_write_BYTE(s, 0); + Stream_Write_UINT8(s, SNDC_CLOSE); + Stream_Write_UINT8(s, 0); Stream_Seek_UINT16(s); pos = Stream_GetPosition(s); Stream_SetPosition(s, 2); - stream_write_UINT16(s, pos - 4); + Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index dd9848559..5adb1aebd 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -92,7 +92,7 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp) Stream_Seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ - stream_read_UINT32(irp->input, PathLength); + Stream_Read_UINT32(irp->input, PathLength); status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(irp->input), PathLength / 2, &path, 0, NULL, NULL); @@ -117,8 +117,8 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp) DEBUG_SVC("%s(%d) created.", serial->path, FileId); } - stream_write_UINT32(irp->output, FileId); - stream_write_BYTE(irp->output, 0); + Stream_Write_UINT32(irp->output, FileId); + Stream_Write_UINT8(irp->output, 0); free(path); @@ -144,7 +144,7 @@ static void serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp) serial->tty = NULL; } - stream_write_zero(irp->output, 5); /* Padding(5) */ + Stream_Write_zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } @@ -156,8 +156,8 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp) UINT64 Offset; BYTE* buffer = NULL; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); DEBUG_SVC("length %u offset %llu", Length, Offset); @@ -189,12 +189,12 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp) } } - stream_write_UINT32(irp->output, Length); + Stream_Write_UINT32(irp->output, Length); if (Length > 0) { Stream_EnsureRemainingCapacity(irp->output, Length); - stream_write(irp->output, buffer, Length); + Stream_Write(irp->output, buffer, Length); } free(buffer); @@ -208,8 +208,8 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp) UINT32 Length; UINT64 Offset; - stream_read_UINT32(irp->input, Length); - stream_read_UINT64(irp->input, Offset); + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); Stream_Seek(irp->input, 20); /* Padding */ DEBUG_SVC("length %u offset %llu", Length, Offset); @@ -235,8 +235,8 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp) DEBUG_SVC("write %llu-%llu to %s(%d).", Offset, Offset + Length, serial->path, tty->id); } - stream_write_UINT32(irp->output, Length); - stream_write_BYTE(irp->output, 0); /* Padding */ + Stream_Write_UINT32(irp->output, Length); + Stream_Write_UINT8(irp->output, 0); /* Padding */ irp->Complete(irp); } @@ -251,9 +251,9 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp) DEBUG_SVC("[in] pending size %d", list_size(serial->pending_irps)); - stream_read_UINT32(irp->input, InputBufferLength); - stream_read_UINT32(irp->input, OutputBufferLength); - stream_read_UINT32(irp->input, IoControlCode); + Stream_Read_UINT32(irp->input, InputBufferLength); + Stream_Read_UINT32(irp->input, OutputBufferLength); + Stream_Read_UINT32(irp->input, IoControlCode); Stream_Seek(irp->input, 20); /* Padding */ tty = serial->tty; @@ -420,7 +420,7 @@ static void serial_abort_single_io(SERIAL_DEVICE* serial, UINT32 file_id, UINT32 /* Process a SINGLE FileId and MajorFunction */ list_remove(serial->pending_irps, irp); irp->IoStatus = io_status; - stream_write_UINT32(irp->output, 0); + Stream_Write_UINT32(irp->output, 0); irp->Complete(irp); SetEvent(serial->in_event); @@ -454,7 +454,7 @@ static void serial_check_for_events(SERIAL_DEVICE* serial) DEBUG_SVC("got event result %u", result); irp->IoStatus = STATUS_SUCCESS; - stream_write_UINT32(irp->output, result); + Stream_Write_UINT32(irp->output, result); irp->Complete(irp); prev = irp; @@ -479,7 +479,7 @@ void serial_get_timeouts(SERIAL_DEVICE* serial, IRP* irp, UINT32* timeout, UINT3 UINT32 pos; pos = Stream_GetPosition(irp->input); - stream_read_UINT32(irp->input, Length); + Stream_Read_UINT32(irp->input, Length); Stream_SetPosition(irp->input, pos); DEBUG_SVC("length read %u", Length); @@ -584,7 +584,7 @@ static void __serial_check_fds(SERIAL_DEVICE* serial) DEBUG_SVC("got event result %u", result); irp->IoStatus = STATUS_SUCCESS; - stream_write_UINT32(irp->output, result); + Stream_Write_UINT32(irp->output, result); irp->Complete(irp); irp_completed = TRUE; } @@ -706,7 +706,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) serial->device.data = stream_new(len + 1); for (i = 0; i <= len; i++) - stream_write_BYTE(serial->device.data, name[i] < 0 ? '_' : name[i]); + Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]); serial->path = path; serial->queue = Queue_New(TRUE, -1, -1); diff --git a/channels/serial/client/serial_tty.c b/channels/serial/client/serial_tty.c index 51a7ca76a..23445b2ca 100644 --- a/channels/serial/client/serial_tty.c +++ b/channels/serial/client/serial_tty.c @@ -95,27 +95,27 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, switch (IoControlCode) { case IOCTL_SERIAL_SET_BAUD_RATE: - stream_read_UINT32(input, tty->baud_rate); + Stream_Read_UINT32(input, tty->baud_rate); tty_set_termios(tty); DEBUG_SVC("SERIAL_SET_BAUD_RATE %d", tty->baud_rate); break; case IOCTL_SERIAL_GET_BAUD_RATE: length = 4; - stream_write_UINT32(output, tty->baud_rate); + Stream_Write_UINT32(output, tty->baud_rate); DEBUG_SVC("SERIAL_GET_BAUD_RATE %d", tty->baud_rate); break; case IOCTL_SERIAL_SET_QUEUE_SIZE: - stream_read_UINT32(input, tty->queue_in_size); - stream_read_UINT32(input, tty->queue_out_size); + Stream_Read_UINT32(input, tty->queue_in_size); + Stream_Read_UINT32(input, tty->queue_out_size); DEBUG_SVC("SERIAL_SET_QUEUE_SIZE in %d out %d", tty->queue_in_size, tty->queue_out_size); break; case IOCTL_SERIAL_SET_LINE_CONTROL: - stream_read_BYTE(input, tty->stop_bits); - stream_read_BYTE(input, tty->parity); - stream_read_BYTE(input, tty->word_length); + Stream_Read_UINT8(input, tty->stop_bits); + Stream_Read_UINT8(input, tty->parity); + Stream_Read_UINT8(input, tty->word_length); tty_set_termios(tty); DEBUG_SVC("SERIAL_SET_LINE_CONTROL stop %d parity %d word %d", tty->stop_bits, tty->parity, tty->word_length); @@ -124,62 +124,62 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, case IOCTL_SERIAL_GET_LINE_CONTROL: DEBUG_SVC("SERIAL_GET_LINE_CONTROL"); length = 3; - stream_write_BYTE(output, tty->stop_bits); - stream_write_BYTE(output, tty->parity); - stream_write_BYTE(output, tty->word_length); + Stream_Write_UINT8(output, tty->stop_bits); + Stream_Write_UINT8(output, tty->parity); + Stream_Write_UINT8(output, tty->word_length); break; case IOCTL_SERIAL_IMMEDIATE_CHAR: DEBUG_SVC("SERIAL_IMMEDIATE_CHAR"); - stream_read_BYTE(input, immediate); + Stream_Read_UINT8(input, immediate); tty_write_data(tty, &immediate, 1); break; case IOCTL_SERIAL_CONFIG_SIZE: DEBUG_SVC("SERIAL_CONFIG_SIZE"); length = 4; - stream_write_UINT32(output, 0); + Stream_Write_UINT32(output, 0); break; case IOCTL_SERIAL_GET_CHARS: DEBUG_SVC("SERIAL_GET_CHARS"); length = 6; - stream_write(output, tty->chars, 6); + Stream_Write(output, tty->chars, 6); break; case IOCTL_SERIAL_SET_CHARS: DEBUG_SVC("SERIAL_SET_CHARS"); - stream_read(input, tty->chars, 6); + Stream_Read(input, tty->chars, 6); tty_set_termios(tty); break; case IOCTL_SERIAL_GET_HANDFLOW: length = 16; tty_get_termios(tty); - stream_write_UINT32(output, tty->control); - stream_write_UINT32(output, tty->xonoff); - stream_write_UINT32(output, tty->onlimit); - stream_write_UINT32(output, tty->offlimit); + Stream_Write_UINT32(output, tty->control); + Stream_Write_UINT32(output, tty->xonoff); + Stream_Write_UINT32(output, tty->onlimit); + Stream_Write_UINT32(output, tty->offlimit); DEBUG_SVC("IOCTL_SERIAL_GET_HANDFLOW %X %X %X %X", tty->control, tty->xonoff, tty->onlimit, tty->offlimit); break; case IOCTL_SERIAL_SET_HANDFLOW: - stream_read_UINT32(input, tty->control); - stream_read_UINT32(input, tty->xonoff); - stream_read_UINT32(input, tty->onlimit); - stream_read_UINT32(input, tty->offlimit); + Stream_Read_UINT32(input, tty->control); + Stream_Read_UINT32(input, tty->xonoff); + Stream_Read_UINT32(input, tty->onlimit); + Stream_Read_UINT32(input, tty->offlimit); DEBUG_SVC("IOCTL_SERIAL_SET_HANDFLOW %X %X %X %X", tty->control, tty->xonoff, tty->onlimit, tty->offlimit); tty_set_termios(tty); break; case IOCTL_SERIAL_SET_TIMEOUTS: - stream_read_UINT32(input, tty->read_interval_timeout); - stream_read_UINT32(input, tty->read_total_timeout_multiplier); - stream_read_UINT32(input, tty->read_total_timeout_constant); - stream_read_UINT32(input, tty->write_total_timeout_multiplier); - stream_read_UINT32(input, tty->write_total_timeout_constant); + Stream_Read_UINT32(input, tty->read_interval_timeout); + Stream_Read_UINT32(input, tty->read_total_timeout_multiplier); + Stream_Read_UINT32(input, tty->read_total_timeout_constant); + Stream_Read_UINT32(input, tty->write_total_timeout_multiplier); + Stream_Read_UINT32(input, tty->write_total_timeout_constant); /* http://www.codeproject.com/KB/system/chaiyasit_t.aspx, see 'ReadIntervalTimeout' section http://msdn.microsoft.com/en-us/library/ms885171.aspx */ @@ -201,21 +201,21 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, tty->read_total_timeout_multiplier, tty->read_total_timeout_constant); length = 20; - stream_write_UINT32(output, tty->read_interval_timeout); - stream_write_UINT32(output, tty->read_total_timeout_multiplier); - stream_write_UINT32(output, tty->read_total_timeout_constant); - stream_write_UINT32(output, tty->write_total_timeout_multiplier); - stream_write_UINT32(output, tty->write_total_timeout_constant); + Stream_Write_UINT32(output, tty->read_interval_timeout); + Stream_Write_UINT32(output, tty->read_total_timeout_multiplier); + Stream_Write_UINT32(output, tty->read_total_timeout_constant); + Stream_Write_UINT32(output, tty->write_total_timeout_multiplier); + Stream_Write_UINT32(output, tty->write_total_timeout_constant); break; case IOCTL_SERIAL_GET_WAIT_MASK: DEBUG_SVC("SERIAL_GET_WAIT_MASK %X", tty->wait_mask); length = 4; - stream_write_UINT32(output, tty->wait_mask); + Stream_Write_UINT32(output, tty->wait_mask); break; case IOCTL_SERIAL_SET_WAIT_MASK: - stream_read_UINT32(input, tty->wait_mask); + Stream_Read_UINT32(input, tty->wait_mask); DEBUG_SVC("SERIAL_SET_WAIT_MASK %X", tty->wait_mask); break; @@ -270,19 +270,19 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, #endif DEBUG_SVC("SERIAL_GET_MODEMSTATUS %X", modemstate); length = 4; - stream_write_UINT32(output, modemstate); + Stream_Write_UINT32(output, modemstate); break; case IOCTL_SERIAL_GET_COMMSTATUS: length = 18; - stream_write_UINT32(output, 0); /* Errors */ - stream_write_UINT32(output, 0); /* Hold reasons */ + Stream_Write_UINT32(output, 0); /* Errors */ + Stream_Write_UINT32(output, 0); /* Hold reasons */ result = 0; #ifdef TIOCINQ ioctl(tty->fd, TIOCINQ, &result); #endif - stream_write_UINT32(output, result); /* Amount in in queue */ + Stream_Write_UINT32(output, result); /* Amount in in queue */ if (result) DEBUG_SVC("SERIAL_GET_COMMSTATUS in queue %d", result); @@ -290,15 +290,15 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, #ifdef TIOCOUTQ ioctl(tty->fd, TIOCOUTQ, &result); #endif - stream_write_UINT32(output, result); /* Amount in out queue */ + Stream_Write_UINT32(output, result); /* Amount in out queue */ DEBUG_SVC("SERIAL_GET_COMMSTATUS out queue %d", result); - stream_write_BYTE(output, 0); /* EofReceived */ - stream_write_BYTE(output, 0); /* WaitForImmediate */ + Stream_Write_UINT8(output, 0); /* EofReceived */ + Stream_Write_UINT8(output, 0); /* WaitForImmediate */ break; case IOCTL_SERIAL_PURGE: - stream_read_UINT32(input, purge_mask); + Stream_Read_UINT32(input, purge_mask); DEBUG_SVC("SERIAL_PURGE purge_mask %X", purge_mask); /* See http://msdn.microsoft.com/en-us/library/ms901431.aspx @@ -327,7 +327,7 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, if (serial_tty_get_event(tty, &result)) { DEBUG_SVC("WAIT end event = %X", result); - stream_write_UINT32(output, result); + Stream_Write_UINT32(output, result); break; } ret = STATUS_PENDING; @@ -363,7 +363,7 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, /* Write OutputBufferLength */ pos = Stream_GetPosition(output); Stream_SetPosition(output, 16); - stream_write_UINT32(output, length); + Stream_Write_UINT32(output, length); Stream_SetPosition(output, pos); return ret; diff --git a/channels/server/channels.c b/channels/server/channels.c index ddea61d95..740e7ca2a 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -136,19 +136,19 @@ static int wts_read_variable_uint(wStream* s, int cbLen, UINT32* val) case 0: if (Stream_GetRemainingLength(s) < 1) return 0; - stream_read_BYTE(s, *val); + Stream_Read_UINT8(s, *val); return 1; case 1: if (Stream_GetRemainingLength(s) < 2) return 0; - stream_read_UINT16(s, *val); + Stream_Read_UINT16(s, *val); return 2; default: if (Stream_GetRemainingLength(s) < 4) return 0; - stream_read_UINT32(s, *val); + Stream_Read_UINT32(s, *val); return 4; } } @@ -161,7 +161,7 @@ static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, UINT return; Stream_Seek_BYTE(channel->receive_data); /* Pad (1 byte) */ - stream_read_UINT16(channel->receive_data, Version); + Stream_Read_UINT16(channel->receive_data, Version); DEBUG_DVC("Version: %d", Version); @@ -175,7 +175,7 @@ static void wts_read_drdynvc_create_response(rdpPeerChannel* channel, wStream* s if (length < 4) return; - stream_read_UINT32(s, CreationStatus); + Stream_Read_UINT32(s, CreationStatus); if ((INT32) CreationStatus < 0) { @@ -207,7 +207,7 @@ static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int Stream_SetPosition(channel->receive_data, 0); Stream_EnsureRemainingCapacity(channel->receive_data, (int) channel->dvc_total_length); - stream_write(channel->receive_data, Stream_Pointer(s), length); + Stream_Write(channel->receive_data, Stream_Pointer(s), length); } static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 length) @@ -221,7 +221,7 @@ static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le return; } - stream_write(channel->receive_data, Stream_Pointer(s), length); + Stream_Write(channel->receive_data, Stream_Pointer(s), length); if (Stream_GetPosition(channel->receive_data) >= (int) channel->dvc_total_length) { @@ -257,7 +257,7 @@ static void wts_read_drdynvc_pdu(rdpPeerChannel* channel) return; Stream_SetPosition(channel->receive_data, 0); - stream_read_BYTE(channel->receive_data, value); + Stream_Read_UINT8(channel->receive_data, value); length--; Cmd = (value & 0xf0) >> 4; @@ -323,17 +323,17 @@ static int wts_write_variable_uint(wStream* stream, UINT32 val) if (val <= 0xFF) { cb = 0; - stream_write_BYTE(stream, val); + Stream_Write_UINT8(stream, val); } else if (val <= 0xFFFF) { cb = 1; - stream_write_UINT16(stream, val); + Stream_Write_UINT16(stream, val); } else { cb = 3; - stream_write_UINT32(stream, val); + Stream_Write_UINT32(stream, val); } return cb; @@ -357,7 +357,7 @@ static void wts_write_drdynvc_create_request(wStream *s, UINT32 ChannelId, const wts_write_drdynvc_header(s, CREATE_REQUEST_PDU, ChannelId); len = strlen(ChannelName) + 1; Stream_EnsureRemainingCapacity(s, (int) len); - stream_write(s, ChannelName, len); + Stream_Write(s, ChannelName, len); } static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* data, int size, int flags, int total_size) @@ -368,7 +368,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* } Stream_EnsureRemainingCapacity(channel->receive_data, size); - stream_write(channel->receive_data, data, size); + Stream_Write(channel->receive_data, data, size); if (flags & CHANNEL_FLAG_LAST) { @@ -803,7 +803,7 @@ BOOL WTSVirtualChannelWrite( if (written > Length) written = Length; - stream_write(s, Buffer, written); + Stream_Write(s, Buffer, written); item->length = Stream_GetPosition(s); stream_detach(s); Length -= written; diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 86c2c5021..3d20cb982 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -222,7 +222,7 @@ static void smartcard_irp_complete(IRP* irp) pos = Stream_GetPosition(irp->output); Stream_SetPosition(irp->output, 12); - stream_write_UINT32(irp->output, irp->IoStatus); + Stream_Write_UINT32(irp->output, irp->IoStatus); Stream_SetPosition(irp->output, pos); /* Begin TS Client defect workaround. */ @@ -328,7 +328,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) smartcard->device.data = stream_new(length + 1); for (i = 0; i <= length; i++) - stream_write_BYTE(smartcard->device.data, name[i] < 0 ? '_' : name[i]); + Stream_Write_UINT8(smartcard->device.data, name[i] < 0 ? '_' : name[i]); smartcard->path = path; diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index 0c9fe71a6..a54b754a4 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -124,7 +124,7 @@ static void smartcard_output_alignment(IRP* irp, UINT32 seed) UINT32 add = (seed - (size % seed)) % seed; if (add > 0) - stream_write_zero(irp->output, add); + Stream_Write_zero(irp->output, add); } static void smartcard_output_repos(IRP* irp, UINT32 written) @@ -132,12 +132,12 @@ static void smartcard_output_repos(IRP* irp, UINT32 written) UINT32 add = (4 - (written % 4)) % 4; if (add > 0) - stream_write_zero(irp->output, add); + Stream_Write_zero(irp->output, add); } static UINT32 smartcard_output_return(IRP* irp, UINT32 status) { - stream_write_zero(irp->output, 256); + Stream_Write_zero(irp->output, 256); return status; } @@ -145,18 +145,18 @@ static void smartcard_output_buffer_limit(IRP* irp, char* buffer, unsigned int l { int header = (length < 0) ? (0) : ((length > highLimit) ? (highLimit) : (length)); - stream_write_UINT32(irp->output, header); + Stream_Write_UINT32(irp->output, header); if (length <= 0) { - stream_write_UINT32(irp->output, 0); + Stream_Write_UINT32(irp->output, 0); } else { if (header < length) length = header; - stream_write(irp->output, buffer, length); + Stream_Write(irp->output, buffer, length); smartcard_output_repos(irp, length); } } @@ -170,8 +170,8 @@ static void smartcard_output_buffer_start_limit(IRP* irp, int length, int highLi { int header = (length < 0) ? (0) : ((length > highLimit) ? (highLimit) : (length)); - stream_write_UINT32(irp->output, header); - stream_write_UINT32(irp->output, 0x00000001); /* Magic DWORD - any non zero */ + Stream_Write_UINT32(irp->output, header); + Stream_Write_UINT32(irp->output, 0x00000001); /* Magic DWORD - any non zero */ } static void smartcard_output_buffer_start(IRP* irp, int length) @@ -187,7 +187,7 @@ static UINT32 smartcard_input_string(IRP* irp, char** dest, UINT32 dataLength, B bufferSize = wide ? (2 * dataLength) : dataLength; buffer = malloc(bufferSize + 2); /* reserve 2 bytes for the '\0' */ - stream_read(irp->input, buffer, bufferSize); + Stream_Read(irp->input, buffer, bufferSize); if (wide) { @@ -220,7 +220,7 @@ static void smartcard_input_reader_name(IRP* irp, char** dest, BOOL wide) UINT32 dataLength; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, dataLength); + Stream_Read_UINT32(irp->input, dataLength); DEBUG_SCARD("datalength %d", dataLength); smartcard_input_repos(irp, smartcard_input_string(irp, dest, dataLength, wide)); @@ -229,7 +229,7 @@ static void smartcard_input_reader_name(IRP* irp, char** dest, BOOL wide) static void smartcard_input_skip_linked(IRP* irp) { UINT32 len; - stream_read_UINT32(irp->input, len); + Stream_Read_UINT32(irp->input, len); if (len > 0) { @@ -268,21 +268,21 @@ static UINT32 handle_EstablishContext(IRP* irp) SCARDCONTEXT hContext = -1; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, len); + Stream_Read_UINT32(irp->input, len); if (len != 8) return SCARD_F_INTERNAL_ERROR; Stream_Seek_UINT32(irp->input); - stream_read_UINT32(irp->input, scope); + Stream_Read_UINT32(irp->input, scope); status = SCardEstablishContext(scope, NULL, NULL, &hContext); - stream_write_UINT32(irp->output, 4); // cbContext - stream_write_UINT32(irp->output, -1); // ReferentID + Stream_Write_UINT32(irp->output, 4); // cbContext + Stream_Write_UINT32(irp->output, -1); // ReferentID - stream_write_UINT32(irp->output, 4); - stream_write_UINT32(irp->output, hContext); + Stream_Write_UINT32(irp->output, 4); + Stream_Write_UINT32(irp->output, hContext); /* TODO: store hContext in allowed context list */ @@ -296,10 +296,10 @@ static UINT32 handle_ReleaseContext(IRP* irp) SCARDCONTEXT hContext = -1; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, len); + Stream_Read_UINT32(irp->input, len); Stream_Seek(irp->input, 0x10); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); status = SCardReleaseContext(hContext); @@ -319,7 +319,7 @@ static UINT32 handle_IsValidContext(IRP* irp) SCARDCONTEXT hContext; Stream_Seek(irp->input, 0x1C); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); status = SCardIsValidContext(hContext); @@ -343,15 +343,15 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) int pos, poslen1, poslen2; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, len); + Stream_Read_UINT32(irp->input, len); Stream_Seek(irp->input, 0x1c); - stream_read_UINT32(irp->input, len); + Stream_Read_UINT32(irp->input, len); if (len != 4) return SCARD_F_INTERNAL_ERROR; - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); /* ignore rest of [MS-RDPESC] 2.2.2.4 ListReaders_Call */ @@ -376,7 +376,7 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) poslen1 = Stream_GetPosition(irp->output); Stream_Seek_UINT32(irp->output); - stream_write_UINT32(irp->output, 0x01760650); + Stream_Write_UINT32(irp->output, 0x01760650); poslen2 = Stream_GetPosition(irp->output); Stream_Seek_UINT32(irp->output); @@ -400,9 +400,9 @@ static UINT32 handle_ListReaders(IRP* irp, BOOL wide) pos = Stream_GetPosition(irp->output); Stream_SetPosition(irp->output, poslen1); - stream_write_UINT32(irp->output, dataLength); + Stream_Write_UINT32(irp->output, dataLength); Stream_SetPosition(irp->output, poslen2); - stream_write_UINT32(irp->output, dataLength); + Stream_Write_UINT32(irp->output, dataLength); Stream_SetPosition(irp->output, pos); @@ -428,12 +428,12 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) SCARD_READERSTATE *readerStates, *cur; Stream_Seek(irp->input, 0x18); - stream_read_UINT32(irp->input, dwTimeout); - stream_read_UINT32(irp->input, readerCount); + Stream_Read_UINT32(irp->input, dwTimeout); + Stream_Read_UINT32(irp->input, readerCount); Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); Stream_Seek(irp->input, 4); @@ -459,10 +459,10 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) * convert to host endian or fix the headers to * request the order we want */ - stream_read_UINT32(irp->input, cur->dwCurrentState); - stream_read_UINT32(irp->input, cur->dwEventState); - stream_read_UINT32(irp->input, cur->cbAtr); - stream_read(irp->input, cur->rgbAtr, 32); + Stream_Read_UINT32(irp->input, cur->dwCurrentState); + Stream_Read_UINT32(irp->input, cur->dwEventState); + Stream_Read_UINT32(irp->input, cur->cbAtr); + Stream_Read(irp->input, cur->rgbAtr, 32); Stream_Seek(irp->input, 4); @@ -477,7 +477,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) UINT32 dataLength; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, dataLength); + Stream_Read_UINT32(irp->input, dataLength); smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide)); DEBUG_SCARD(" \"%s\"", cur->szReader ? cur->szReader : "NULL"); @@ -501,9 +501,9 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) else DEBUG_SCARD("Success"); - stream_write_UINT32(irp->output, readerCount); - stream_write_UINT32(irp->output, 0x00084dd8); - stream_write_UINT32(irp->output, readerCount); + Stream_Write_UINT32(irp->output, readerCount); + Stream_Write_UINT32(irp->output, 0x00084dd8); + Stream_Write_UINT32(irp->output, readerCount); for (i = 0; i < readerCount; i++) { @@ -515,12 +515,12 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) (unsigned) cur->dwEventState); /* TODO: do byte conversions if necessary */ - stream_write_UINT32(irp->output, cur->dwCurrentState); - stream_write_UINT32(irp->output, cur->dwEventState); - stream_write_UINT32(irp->output, cur->cbAtr); - stream_write(irp->output, cur->rgbAtr, 32); + Stream_Write_UINT32(irp->output, cur->dwCurrentState); + Stream_Write_UINT32(irp->output, cur->dwEventState); + Stream_Write_UINT32(irp->output, cur->cbAtr); + Stream_Write(irp->output, cur->rgbAtr, 32); - stream_write_zero(irp->output, 4); + Stream_Write_zero(irp->output, 4); free((void *)cur->szReader); } @@ -537,7 +537,7 @@ static UINT32 handle_Cancel(IRP *irp) SCARDCONTEXT hContext; Stream_Seek(irp->input, 0x1C); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); status = SCardCancel(hContext); @@ -562,13 +562,13 @@ static UINT32 handle_Connect(IRP* irp, BOOL wide) SCARDHANDLE hCard; Stream_Seek(irp->input, 0x1c); - stream_read_UINT32(irp->input, dwShareMode); - stream_read_UINT32(irp->input, dwPreferredProtocol); + Stream_Read_UINT32(irp->input, dwShareMode); + Stream_Read_UINT32(irp->input, dwPreferredProtocol); smartcard_input_reader_name(irp, &readerName, wide); Stream_Seek(irp->input, 4); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); DEBUG_SCARD("(context: 0x%08x, share: 0x%08x, proto: 0x%08x, reader: \"%s\")", (unsigned) hContext, (unsigned) dwShareMode, @@ -582,13 +582,13 @@ static UINT32 handle_Connect(IRP* irp, BOOL wide) else DEBUG_SCARD("Success 0x%08x", (unsigned) hCard); - stream_write_UINT32(irp->output, 0x00000000); - stream_write_UINT32(irp->output, 0x00000000); - stream_write_UINT32(irp->output, 0x00000004); - stream_write_UINT32(irp->output, 0x016Cff34); - stream_write_UINT32(irp->output, dwActiveProtocol); - stream_write_UINT32(irp->output, 0x00000004); - stream_write_UINT32(irp->output, hCard); + Stream_Write_UINT32(irp->output, 0x00000000); + Stream_Write_UINT32(irp->output, 0x00000000); + Stream_Write_UINT32(irp->output, 0x00000004); + Stream_Write_UINT32(irp->output, 0x016Cff34); + Stream_Write_UINT32(irp->output, dwActiveProtocol); + Stream_Write_UINT32(irp->output, 0x00000004); + Stream_Write_UINT32(irp->output, hCard); smartcard_output_alignment(irp, 8); @@ -607,14 +607,14 @@ static UINT32 handle_Reconnect(IRP* irp) DWORD dwActiveProtocol = 0; Stream_Seek(irp->input, 0x20); - stream_read_UINT32(irp->input, dwShareMode); - stream_read_UINT32(irp->input, dwPreferredProtocol); - stream_read_UINT32(irp->input, dwInitialization); + Stream_Read_UINT32(irp->input, dwShareMode); + Stream_Read_UINT32(irp->input, dwPreferredProtocol); + Stream_Read_UINT32(irp->input, dwInitialization); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, share: 0x%08x, proto: 0x%08x, init: 0x%08x)", (unsigned) hContext, (unsigned) hCard, @@ -628,7 +628,7 @@ static UINT32 handle_Reconnect(IRP* irp) else DEBUG_SCARD("Success (proto: 0x%08x)", (unsigned) dwActiveProtocol); - stream_write_UINT32(irp->output, dwActiveProtocol); + Stream_Write_UINT32(irp->output, dwActiveProtocol); smartcard_output_alignment(irp, 8); return status; @@ -642,11 +642,11 @@ static UINT32 handle_Disconnect(IRP* irp) DWORD dwDisposition = 0; Stream_Seek(irp->input, 0x20); - stream_read_UINT32(irp->input, dwDisposition); + Stream_Read_UINT32(irp->input, dwDisposition); Stream_Seek(irp->input, 4); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); Stream_Seek(irp->input, 4); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); DEBUG_SCARD("(context: 0x%08x, hcard: 0x%08x, disposition: 0x%08x)", (unsigned) hContext, (unsigned) hCard, (unsigned) dwDisposition); @@ -669,7 +669,7 @@ static UINT32 handle_BeginTransaction(IRP* irp) SCARDCONTEXT hCard; Stream_Seek(irp->input, 0x30); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); status = SCardBeginTransaction(hCard); @@ -690,10 +690,10 @@ static UINT32 handle_EndTransaction(IRP* irp) DWORD dwDisposition = 0; Stream_Seek(irp->input, 0x20); - stream_read_UINT32(irp->input, dwDisposition); + Stream_Read_UINT32(irp->input, dwDisposition); Stream_Seek(irp->input, 0x0C); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); status = SCardEndTransaction(hCard, dwDisposition); @@ -725,7 +725,7 @@ static UINT32 handle_State(IRP* irp) Stream_Seek_UINT32(irp->input); /* atrLen */ Stream_Seek(irp->input, 0x0c); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); Stream_Seek(irp->input, 0x04); #ifdef SCARD_AUTOALLOCATE @@ -757,12 +757,12 @@ static UINT32 handle_State(IRP* irp) state = smartcard_map_state(state); - stream_write_UINT32(irp->output, state); - stream_write_UINT32(irp->output, protocol); - stream_write_UINT32(irp->output, atrLen); - stream_write_UINT32(irp->output, 0x00000001); - stream_write_UINT32(irp->output, atrLen); - stream_write(irp->output, pbAtr, atrLen); + Stream_Write_UINT32(irp->output, state); + Stream_Write_UINT32(irp->output, protocol); + Stream_Write_UINT32(irp->output, atrLen); + Stream_Write_UINT32(irp->output, 0x00000001); + Stream_Write_UINT32(irp->output, atrLen); + Stream_Write(irp->output, pbAtr, atrLen); smartcard_output_repos(irp, atrLen); smartcard_output_alignment(irp, 8); @@ -793,10 +793,10 @@ static DWORD handle_Status(IRP *irp, BOOL wide) #endif Stream_Seek(irp->input, 0x24); - stream_read_UINT32(irp->input, readerLen); - stream_read_UINT32(irp->input, atrLen); + Stream_Read_UINT32(irp->input, readerLen); + Stream_Read_UINT32(irp->input, atrLen); Stream_Seek(irp->input, 0x0c); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); Stream_Seek(irp->input, 0x4); atrLen = MAX_ATR_SIZE; @@ -831,18 +831,18 @@ static DWORD handle_Status(IRP *irp, BOOL wide) state = smartcard_map_state(state); poslen1 = Stream_GetPosition(irp->output); - stream_write_UINT32(irp->output, readerLen); - stream_write_UINT32(irp->output, 0x00020000); - stream_write_UINT32(irp->output, state); - stream_write_UINT32(irp->output, protocol); - stream_write(irp->output, pbAtr, atrLen); + Stream_Write_UINT32(irp->output, readerLen); + Stream_Write_UINT32(irp->output, 0x00020000); + Stream_Write_UINT32(irp->output, state); + Stream_Write_UINT32(irp->output, protocol); + Stream_Write(irp->output, pbAtr, atrLen); if (atrLen < 32) - stream_write_zero(irp->output, 32 - atrLen); - stream_write_UINT32(irp->output, atrLen); + Stream_Write_zero(irp->output, 32 - atrLen); + Stream_Write_UINT32(irp->output, atrLen); poslen2 = Stream_GetPosition(irp->output); - stream_write_UINT32(irp->output, readerLen); + Stream_Write_UINT32(irp->output, readerLen); dataLength = smartcard_output_string(irp, readerName, wide); dataLength += smartcard_output_string(irp, "\0", wide); @@ -850,9 +850,9 @@ static DWORD handle_Status(IRP *irp, BOOL wide) pos = Stream_GetPosition(irp->output); Stream_SetPosition(irp->output, poslen1); - stream_write_UINT32(irp->output,dataLength); + Stream_Write_UINT32(irp->output,dataLength); Stream_SetPosition(irp->output, poslen2); - stream_write_UINT32(irp->output,dataLength); + Stream_Write_UINT32(irp->output,dataLength); Stream_SetPosition(irp->output, pos); smartcard_output_alignment(irp, 8); @@ -877,32 +877,32 @@ static UINT32 handle_Transmit(IRP* irp) BYTE *sendBuf = NULL, *recvBuf = NULL; Stream_Seek(irp->input, 0x14); - stream_read_UINT32(irp->input, map[0]); + Stream_Read_UINT32(irp->input, map[0]); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, map[1]); + Stream_Read_UINT32(irp->input, map[1]); - stream_read_UINT32(irp->input, pioSendPci.dwProtocol); - stream_read_UINT32(irp->input, pioSendPci.cbPciLength); + Stream_Read_UINT32(irp->input, pioSendPci.dwProtocol); + Stream_Read_UINT32(irp->input, pioSendPci.cbPciLength); - stream_read_UINT32(irp->input, map[2]); - stream_read_UINT32(irp->input, cbSendLength); - stream_read_UINT32(irp->input, map[3]); - stream_read_UINT32(irp->input, map[4]); - stream_read_UINT32(irp->input, map[5]); - stream_read_UINT32(irp->input, cbRecvLength); + Stream_Read_UINT32(irp->input, map[2]); + Stream_Read_UINT32(irp->input, cbSendLength); + Stream_Read_UINT32(irp->input, map[3]); + Stream_Read_UINT32(irp->input, map[4]); + Stream_Read_UINT32(irp->input, map[5]); + Stream_Read_UINT32(irp->input, cbRecvLength); if (map[0] & SCARD_INPUT_LINKED) smartcard_input_skip_linked(irp); Stream_Seek(irp->input, 4); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); if (map[2] & SCARD_INPUT_LINKED) { /* sendPci */ - stream_read_UINT32(irp->input, linkedLen); + Stream_Read_UINT32(irp->input, linkedLen); - stream_read_UINT32(irp->input, pioSendPci.dwProtocol); + Stream_Read_UINT32(irp->input, pioSendPci.dwProtocol); Stream_Seek(irp->input, linkedLen - 4); smartcard_input_repos(irp, linkedLen); @@ -912,10 +912,10 @@ static UINT32 handle_Transmit(IRP* irp) if (map[3] & SCARD_INPUT_LINKED) { /* send buffer */ - stream_read_UINT32(irp->input, linkedLen); + Stream_Read_UINT32(irp->input, linkedLen); sendBuf = malloc(linkedLen); - stream_read(irp->input, sendBuf, linkedLen); + Stream_Read(irp->input, sendBuf, linkedLen); smartcard_input_repos(irp, linkedLen); } @@ -925,18 +925,18 @@ static UINT32 handle_Transmit(IRP* irp) if (map[4] & SCARD_INPUT_LINKED) { /* recvPci */ - stream_read_UINT32(irp->input, linkedLen); + Stream_Read_UINT32(irp->input, linkedLen); - stream_read_UINT32(irp->input, pioRecvPci.dwProtocol); + Stream_Read_UINT32(irp->input, pioRecvPci.dwProtocol); Stream_Seek(irp->input, linkedLen - 4); smartcard_input_repos(irp, linkedLen); - stream_read_UINT32(irp->input, map[6]); + Stream_Read_UINT32(irp->input, map[6]); if (map[6] & SCARD_INPUT_LINKED) { /* not sure what this is */ - stream_read_UINT32(irp->input, linkedLen); + Stream_Read_UINT32(irp->input, linkedLen); Stream_Seek(irp->input, linkedLen); smartcard_input_repos(irp, linkedLen); @@ -964,7 +964,7 @@ static UINT32 handle_Transmit(IRP* irp) { DEBUG_SCARD("Success (%d bytes)", (int) cbRecvLength); - stream_write_UINT32(irp->output, 0); /* pioRecvPci 0x00; */ + Stream_Write_UINT32(irp->output, 0); /* pioRecvPci 0x00; */ smartcard_output_buffer_start(irp, cbRecvLength); /* start of recvBuf output */ @@ -994,18 +994,18 @@ static UINT32 handle_Control(IRP* irp) DWORD outBufferSize; Stream_Seek(irp->input, 0x14); - stream_read_UINT32(irp->input, map[0]); + Stream_Read_UINT32(irp->input, map[0]); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, map[1]); - stream_read_UINT32(irp->input, controlCode); - stream_read_UINT32(irp->input, recvLength); - stream_read_UINT32(irp->input, map[2]); + Stream_Read_UINT32(irp->input, map[1]); + Stream_Read_UINT32(irp->input, controlCode); + Stream_Read_UINT32(irp->input, recvLength); + Stream_Read_UINT32(irp->input, map[2]); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, outBufferSize); + Stream_Read_UINT32(irp->input, outBufferSize); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, hContext); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); /* Translate Windows SCARD_CTL_CODE's to corresponding local code */ if (WIN_CTL_DEVICE_TYPE(controlCode) == WIN_FILE_DEVICE_SMARTCARD) @@ -1018,14 +1018,14 @@ static UINT32 handle_Control(IRP* irp) if (map[2] & SCARD_INPUT_LINKED) { /* read real input size */ - stream_read_UINT32(irp->input, recvLength); + Stream_Read_UINT32(irp->input, recvLength); recvBuffer = malloc(recvLength); if (!recvBuffer) return smartcard_output_return(irp, SCARD_E_NO_MEMORY); - stream_read(irp->input, recvBuffer, recvLength); + Stream_Read(irp->input, recvBuffer, recvLength); } nBytesReturned = outBufferSize; @@ -1042,13 +1042,13 @@ static UINT32 handle_Control(IRP* irp) else DEBUG_SCARD("Success (out: %u bytes)", (unsigned) nBytesReturned); - stream_write_UINT32(irp->output, (UINT32) nBytesReturned); - stream_write_UINT32(irp->output, 0x00000004); - stream_write_UINT32(irp->output, nBytesReturned); + Stream_Write_UINT32(irp->output, (UINT32) nBytesReturned); + Stream_Write_UINT32(irp->output, 0x00000004); + Stream_Write_UINT32(irp->output, nBytesReturned); if (nBytesReturned > 0) { - stream_write(irp->output, sendBuffer, nBytesReturned); + Stream_Write(irp->output, sendBuffer, nBytesReturned); smartcard_output_repos(irp, nBytesReturned); } @@ -1070,11 +1070,11 @@ static UINT32 handle_GetAttrib(IRP* irp) BYTE* pbAttr = NULL; Stream_Seek(irp->input, 0x20); - stream_read_UINT32(irp->input, dwAttrId); + Stream_Read_UINT32(irp->input, dwAttrId); Stream_Seek(irp->input, 0x4); - stream_read_UINT32(irp->input, dwAttrLen); + Stream_Read_UINT32(irp->input, dwAttrLen); Stream_Seek(irp->input, 0xC); - stream_read_UINT32(irp->input, hCard); + Stream_Read_UINT32(irp->input, hCard); DEBUG_SCARD("hcard: 0x%08x, attrib: 0x%08x (%d bytes)", (unsigned) hCard, (unsigned) dwAttrId, (int) dwAttrLen); @@ -1148,21 +1148,21 @@ static UINT32 handle_GetAttrib(IRP* irp) { DEBUG_SCARD("Success (%d bytes)", (int) dwAttrLen); - stream_write_UINT32(irp->output, dwAttrLen); - stream_write_UINT32(irp->output, 0x00000200); - stream_write_UINT32(irp->output, dwAttrLen); + Stream_Write_UINT32(irp->output, dwAttrLen); + Stream_Write_UINT32(irp->output, 0x00000200); + Stream_Write_UINT32(irp->output, dwAttrLen); if (!pbAttr) { - stream_write_zero(irp->output, dwAttrLen); + Stream_Write_zero(irp->output, dwAttrLen); } else { - stream_write(irp->output, pbAttr, dwAttrLen); + Stream_Write(irp->output, pbAttr, dwAttrLen); } smartcard_output_repos(irp, dwAttrLen); /* align to multiple of 4 */ - stream_write_UINT32(irp->output, 0); + Stream_Write_UINT32(irp->output, 0); } smartcard_output_alignment(irp, 8); @@ -1210,8 +1210,8 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) SERVER_SCARD_ATRMASK* pAtrMasks = NULL; Stream_Seek(irp->input, 0x2C); - stream_read_UINT32(irp->input, hContext); - stream_read_UINT32(irp->input, atrMaskCount); + Stream_Read_UINT32(irp->input, hContext); + Stream_Read_UINT32(irp->input, atrMaskCount); pAtrMasks = malloc(atrMaskCount * sizeof(SERVER_SCARD_ATRMASK)); @@ -1220,12 +1220,12 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) for (i = 0; i < atrMaskCount; i++) { - stream_read_UINT32(irp->input, pAtrMasks[i].cbAtr); - stream_read(irp->input, pAtrMasks[i].rgbAtr, 36); - stream_read(irp->input, pAtrMasks[i].rgbMask, 36); + Stream_Read_UINT32(irp->input, pAtrMasks[i].cbAtr); + Stream_Read(irp->input, pAtrMasks[i].rgbAtr, 36); + Stream_Read(irp->input, pAtrMasks[i].rgbMask, 36); } - stream_read_UINT32(irp->input, readerCount); + Stream_Read_UINT32(irp->input, readerCount); readerStates = malloc(readerCount * sizeof(SCARD_READERSTATE)); ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE)); @@ -1244,10 +1244,10 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) * convert to host endian or fix the headers to * request the order we want */ - stream_read_UINT32(irp->input, cur->dwCurrentState); - stream_read_UINT32(irp->input, cur->dwEventState); - stream_read_UINT32(irp->input, cur->cbAtr); - stream_read(irp->input, cur->rgbAtr, 32); + Stream_Read_UINT32(irp->input, cur->dwCurrentState); + Stream_Read_UINT32(irp->input, cur->dwEventState); + Stream_Read_UINT32(irp->input, cur->cbAtr); + Stream_Read(irp->input, cur->rgbAtr, 32); Stream_Seek(irp->input, 4); @@ -1263,7 +1263,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) UINT32 dataLength; Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, dataLength); + Stream_Read_UINT32(irp->input, dataLength); smartcard_input_repos(irp, smartcard_input_string(irp, (char **) &cur->szReader, dataLength, wide)); DEBUG_SCARD(" \"%s\"", cur->szReader ? cur->szReader : "NULL"); @@ -1306,18 +1306,18 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) } } - stream_write_UINT32(irp->output, readerCount); - stream_write_UINT32(irp->output, 0x00084dd8); - stream_write_UINT32(irp->output, readerCount); + Stream_Write_UINT32(irp->output, readerCount); + Stream_Write_UINT32(irp->output, 0x00084dd8); + Stream_Write_UINT32(irp->output, readerCount); for (i = 0, rsCur = readerStates; i < readerCount; i++, rsCur++) { - stream_write_UINT32(irp->output, cur->dwCurrentState); - stream_write_UINT32(irp->output, cur->dwEventState); - stream_write_UINT32(irp->output, cur->cbAtr); - stream_write(irp->output, cur->rgbAtr, 32); + Stream_Write_UINT32(irp->output, cur->dwCurrentState); + Stream_Write_UINT32(irp->output, cur->dwEventState); + Stream_Write_UINT32(irp->output, cur->cbAtr); + Stream_Write(irp->output, cur->rgbAtr, 32); - stream_write_zero(irp->output, 4); + Stream_Write_zero(irp->output, 4); free((void*) cur->szReader); } @@ -1335,7 +1335,7 @@ BOOL smartcard_async_op(IRP* irp) /* peek ahead */ Stream_Seek(irp->input, 8); - stream_read_UINT32(irp->input, ioctl_code); + Stream_Read_UINT32(irp->input, ioctl_code); Stream_Rewind(irp->input, 12); switch (ioctl_code) @@ -1384,9 +1384,9 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) /* MS-RPCE, Sections 2.2.6.1 and 2.2.6.2. */ - stream_read_UINT32(irp->input, output_len); - stream_read_UINT32(irp->input, input_len); - stream_read_UINT32(irp->input, ioctl_code); + Stream_Read_UINT32(irp->input, output_len); + Stream_Read_UINT32(irp->input, input_len); + Stream_Read_UINT32(irp->input, ioctl_code); Stream_Seek(irp->input, 20); /* padding */ @@ -1399,20 +1399,20 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) irp_result_pos = Stream_GetPosition(irp->output); - stream_write_UINT32(irp->output, 0x00000000); /* MS-RDPEFS + Stream_Write_UINT32(irp->output, 0x00000000); /* MS-RDPEFS * OutputBufferLength * will be updated * later in this * function. */ /* [MS-RPCE] 2.2.6.1 */ - stream_write_UINT32(irp->output, 0x00081001); /* len 8, LE, v1 */ - stream_write_UINT32(irp->output, 0xcccccccc); /* filler */ + Stream_Write_UINT32(irp->output, 0x00081001); /* len 8, LE, v1 */ + Stream_Write_UINT32(irp->output, 0xcccccccc); /* filler */ output_len_pos = Stream_GetPosition(irp->output); Stream_Seek(irp->output, 4); /* size */ - stream_write_UINT32(irp->output, 0x0); /* filler */ + Stream_Write_UINT32(irp->output, 0x0); /* filler */ result_pos = Stream_GetPosition(irp->output); Stream_Seek(irp->output, 4); /* result */ @@ -1532,16 +1532,16 @@ void smartcard_device_control(SMARTCARD_DEVICE* scard, IRP* irp) pos = Stream_GetPosition(irp->output); stream_len = pos - irp_result_pos - 4; /* Value of OutputBufferLength */ Stream_SetPosition(irp->output, irp_result_pos); - stream_write_UINT32(irp->output, stream_len); + Stream_Write_UINT32(irp->output, stream_len); Stream_SetPosition(irp->output, output_len_pos); /* Remove the effect of the MS-RPCE Common Type Header and Private * Header (Sections 2.2.6.1 and 2.2.6.2). */ - stream_write_UINT32(irp->output, stream_len - header_lengths); + Stream_Write_UINT32(irp->output, stream_len - header_lengths); Stream_SetPosition(irp->output, result_pos); - stream_write_UINT32(irp->output, result); + Stream_Write_UINT32(irp->output, result); Stream_SetPosition(irp->output, pos); diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index 80a19b2e0..63f06e72e 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -290,9 +290,9 @@ static UINT32 tsmf_codec_parse_BITMAPINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wSt UINT32 biWidth; UINT32 biHeight; - stream_read_UINT32(s, biSize); - stream_read_UINT32(s, biWidth); - stream_read_UINT32(s, biHeight); + Stream_Read_UINT32(s, biSize); + Stream_Read_UINT32(s, biWidth); + Stream_Read_UINT32(s, biHeight); Stream_Seek(s, 28); if (mediatype->Width == 0) @@ -315,16 +315,16 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wSt /* VIDEOINFOHEADER2.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */ Stream_Seek_UINT32(s); Stream_Seek_UINT32(s); - stream_read_UINT32(s, mediatype->Width); - stream_read_UINT32(s, mediatype->Height); + Stream_Read_UINT32(s, mediatype->Width); + Stream_Read_UINT32(s, mediatype->Height); /* VIDEOINFOHEADER2.rcTarget */ Stream_Seek(s, 16); /* VIDEOINFOHEADER2.dwBitRate */ - stream_read_UINT32(s, mediatype->BitRate); + Stream_Read_UINT32(s, mediatype->BitRate); /* VIDEOINFOHEADER2.dwBitErrorRate */ Stream_Seek_UINT32(s); /* VIDEOINFOHEADER2.AvgTimePerFrame */ - stream_read_UINT64(s, AvgTimePerFrame); + Stream_Read_UINT64(s, AvgTimePerFrame); mediatype->SamplesPerSecond.Numerator = 1000000; mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL); /* Remaining fields before bmiHeader */ @@ -351,16 +351,16 @@ typedef struct tagVIDEOINFOHEADER { /* VIDEOINFOHEADER.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */ Stream_Seek_UINT32(s); Stream_Seek_UINT32(s); - stream_read_UINT32(s, mediatype->Width); - stream_read_UINT32(s, mediatype->Height); + Stream_Read_UINT32(s, mediatype->Width); + Stream_Read_UINT32(s, mediatype->Height); /* VIDEOINFOHEADER.rcTarget */ Stream_Seek(s, 16); /* VIDEOINFOHEADER.dwBitRate */ - stream_read_UINT32(s, mediatype->BitRate); + Stream_Read_UINT32(s, mediatype->BitRate); /* VIDEOINFOHEADER.dwBitErrorRate */ Stream_Seek_UINT32(s); /* VIDEOINFOHEADER.AvgTimePerFrame */ - stream_read_UINT64(s, AvgTimePerFrame); + Stream_Read_UINT64(s, AvgTimePerFrame); mediatype->SamplesPerSecond.Numerator = 1000000; mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL); @@ -421,7 +421,7 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) Stream_Seek(s, 16); /* cbFormat */ - stream_read_UINT32(s, cbFormat); + Stream_Read_UINT32(s, cbFormat); DEBUG_DVC("cbFormat %d", cbFormat); #ifdef WITH_DEBUG_DVC @@ -434,14 +434,14 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) /* http://msdn.microsoft.com/en-us/library/aa473808.aspx */ Stream_Seek(s, 8); /* dwSize and ? */ - stream_read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */ - stream_read_UINT32(s, mediatype->Height); /* videoInfo.dwHeight */ + Stream_Read_UINT32(s, mediatype->Width); /* videoInfo.dwWidth */ + Stream_Read_UINT32(s, mediatype->Height); /* videoInfo.dwHeight */ Stream_Seek(s, 32); /* videoInfo.FramesPerSecond */ - stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator); - stream_read_UINT32(s, mediatype->SamplesPerSecond.Denominator); + Stream_Read_UINT32(s, mediatype->SamplesPerSecond.Numerator); + Stream_Read_UINT32(s, mediatype->SamplesPerSecond.Denominator); Stream_Seek(s, 80); - stream_read_UINT32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */ + Stream_Read_UINT32(s, mediatype->BitRate); /* compressedInfo.AvgBitrate */ Stream_Seek(s, 36); if (cbFormat > 176) @@ -455,14 +455,14 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) /* http://msdn.microsoft.com/en-us/library/dd757720.aspx */ Stream_Seek_UINT16(s); - stream_read_UINT16(s, mediatype->Channels); - stream_read_UINT32(s, mediatype->SamplesPerSecond.Numerator); + Stream_Read_UINT16(s, mediatype->Channels); + Stream_Read_UINT32(s, mediatype->SamplesPerSecond.Numerator); mediatype->SamplesPerSecond.Denominator = 1; - stream_read_UINT32(s, mediatype->BitRate); + Stream_Read_UINT32(s, mediatype->BitRate); mediatype->BitRate *= 8; - stream_read_UINT16(s, mediatype->BlockAlign); - stream_read_UINT16(s, mediatype->BitsPerSample); - stream_read_UINT16(s, mediatype->ExtraDataSize); + Stream_Read_UINT16(s, mediatype->BlockAlign); + Stream_Read_UINT16(s, mediatype->BitsPerSample); + Stream_Read_UINT16(s, mediatype->ExtraDataSize); if (mediatype->ExtraDataSize > 0) mediatype->ExtraData = Stream_Pointer(s); diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 5de7dea13..ae0d5b4d9 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -41,12 +41,12 @@ int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman) { UINT32 CapabilityValue; - stream_read_UINT32(ifman->input, CapabilityValue); + Stream_Read_UINT32(ifman->input, CapabilityValue); DEBUG_DVC("server CapabilityValue %d", CapabilityValue); Stream_EnsureRemainingCapacity(ifman->output, 8); - stream_write_UINT32(ifman->output, 1); /* CapabilityValue */ - stream_write_UINT32(ifman->output, 0); /* Result */ + Stream_Write_UINT32(ifman->output, 1); /* CapabilityValue */ + Stream_Write_UINT32(ifman->output, 0); /* Result */ return 0; } @@ -65,25 +65,25 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) stream_copy(ifman->output, ifman->input, ifman->input_size); Stream_SetPosition(ifman->output, pos); - stream_read_UINT32(ifman->output, numHostCapabilities); + Stream_Read_UINT32(ifman->output, numHostCapabilities); for (i = 0; i < numHostCapabilities; i++) { - stream_read_UINT32(ifman->output, CapabilityType); - stream_read_UINT32(ifman->output, cbCapabilityLength); + Stream_Read_UINT32(ifman->output, CapabilityType); + Stream_Read_UINT32(ifman->output, cbCapabilityLength); pos = Stream_GetPosition(ifman->output); switch (CapabilityType) { case 1: /* Protocol version request */ - stream_read_UINT32(ifman->output, v); + Stream_Read_UINT32(ifman->output, v); DEBUG_DVC("server protocol version %d", v); break; case 2: /* Supported platform */ stream_peek_UINT32(ifman->output, v); DEBUG_DVC("server supported platform %d", v); /* Claim that we support both MF and DShow platforms. */ - stream_write_UINT32(ifman->output, + Stream_Write_UINT32(ifman->output, MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW); break; default: @@ -92,7 +92,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) } Stream_SetPosition(ifman->output, pos + cbCapabilityLength); } - stream_write_UINT32(ifman->output, 0); /* Result */ + Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; @@ -105,9 +105,9 @@ int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman) UINT32 PlatformCookie; UINT32 FormatSupported = 1; - stream_read_UINT32(ifman->input, PlatformCookie); + Stream_Read_UINT32(ifman->input, PlatformCookie); Stream_Seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */ - stream_read_UINT32(ifman->input, numMediaType); + Stream_Read_UINT32(ifman->input, numMediaType); DEBUG_DVC("PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType); @@ -118,9 +118,9 @@ int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman) DEBUG_DVC("format ok."); Stream_EnsureRemainingCapacity(ifman->output, 12); - stream_write_UINT32(ifman->output, FormatSupported); - stream_write_UINT32(ifman->output, PlatformCookie); - stream_write_UINT32(ifman->output, 0); /* Result */ + Stream_Write_UINT32(ifman->output, FormatSupported); + Stream_Write_UINT32(ifman->output, PlatformCookie); + Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; @@ -174,7 +174,7 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) } else { - stream_read_UINT32(ifman->input, StreamId); + Stream_Read_UINT32(ifman->input, StreamId); Stream_Seek_UINT32(ifman->input); /* numMediaType */ stream = tsmf_stream_new(presentation, StreamId); @@ -192,8 +192,8 @@ int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman) DEBUG_DVC(""); Stream_EnsureRemainingCapacity(ifman->output, 8); - stream_write_UINT32(ifman->output, 1); /* TopologyReady */ - stream_write_UINT32(ifman->output, 0); /* Result */ + Stream_Write_UINT32(ifman->output, 1); /* TopologyReady */ + Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; @@ -217,7 +217,7 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) } else { - stream_read_UINT32(ifman->input, StreamId); + Stream_Read_UINT32(ifman->input, StreamId); stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) tsmf_stream_free(stream); @@ -244,7 +244,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) pexisted = 0; Stream_EnsureRemainingCapacity(ifman->output, 4); - stream_write_UINT32(ifman->output, 0); /* Result */ + Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; @@ -264,9 +264,9 @@ int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) UINT32 muted; Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, newVolume); + Stream_Read_UINT32(ifman->input, newVolume); DEBUG_DVC("on stream volume: new volume=[%d]", newVolume); - stream_read_UINT32(ifman->input, muted); + Stream_Read_UINT32(ifman->input, muted); DEBUG_DVC("on stream volume: muted=[%d]", muted); tsmf_presentation_volume_changed(presentation, newVolume, muted); } @@ -294,9 +294,9 @@ int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman) UINT32 changedChannel; Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, channelVolume); + Stream_Read_UINT32(ifman->input, channelVolume); DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume); - stream_read_UINT32(ifman->input, changedChannel); + Stream_Read_UINT32(ifman->input, changedChannel); DEBUG_DVC("on stream volume: changed channel=[%d]", changedChannel); } @@ -330,17 +330,17 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, numGeometryInfo); + Stream_Read_UINT32(ifman->input, numGeometryInfo); pos = Stream_GetPosition(ifman->input); Stream_Seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */ - stream_read_UINT32(ifman->input, Width); - stream_read_UINT32(ifman->input, Height); - stream_read_UINT32(ifman->input, Left); - stream_read_UINT32(ifman->input, Top); + Stream_Read_UINT32(ifman->input, Width); + Stream_Read_UINT32(ifman->input, Height); + Stream_Read_UINT32(ifman->input, Left); + Stream_Read_UINT32(ifman->input, Top); Stream_SetPosition(ifman->input, pos + numGeometryInfo); - stream_read_UINT32(ifman->input, cbVisibleRect); + Stream_Read_UINT32(ifman->input, cbVisibleRect); num_rects = cbVisibleRect / 16; DEBUG_DVC("numGeometryInfo %d Width %d Height %d Left %d Top %d cbVisibleRect %d num_rects %d", @@ -359,13 +359,13 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) for (i = 0; i < num_rects; i++) { - stream_read_UINT16(ifman->input, rects[i].y); /* Top */ + Stream_Read_UINT16(ifman->input, rects[i].y); /* Top */ Stream_Seek_UINT16(ifman->input); - stream_read_UINT16(ifman->input, rects[i].x); /* Left */ + Stream_Read_UINT16(ifman->input, rects[i].x); /* Left */ Stream_Seek_UINT16(ifman->input); - stream_read_UINT16(ifman->input, rects[i].height); /* Bottom */ + Stream_Read_UINT16(ifman->input, rects[i].height); /* Bottom */ Stream_Seek_UINT16(ifman->input); - stream_read_UINT16(ifman->input, rects[i].width); /* Right */ + Stream_Read_UINT16(ifman->input, rects[i].width); /* Right */ Stream_Seek_UINT16(ifman->input); rects[i].width -= rects[i].x; rects[i].height -= rects[i].y; @@ -408,14 +408,14 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) UINT32 cbData; Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, StreamId); + Stream_Read_UINT32(ifman->input, StreamId); Stream_Seek_UINT32(ifman->input); /* numSample */ - stream_read_UINT64(ifman->input, SampleStartTime); - stream_read_UINT64(ifman->input, SampleEndTime); - stream_read_UINT64(ifman->input, ThrottleDuration); + Stream_Read_UINT64(ifman->input, SampleStartTime); + Stream_Read_UINT64(ifman->input, SampleEndTime); + Stream_Read_UINT64(ifman->input, ThrottleDuration); Stream_Seek_UINT32(ifman->input); /* SampleFlags */ - stream_read_UINT32(ifman->input, SampleExtensions); - stream_read_UINT32(ifman->input, cbData); + Stream_Read_UINT32(ifman->input, SampleExtensions); + Stream_Read_UINT32(ifman->input, cbData); DEBUG_DVC("MessageId %d StreamId %d SampleStartTime %d SampleEndTime %d " "ThrottleDuration %d SampleExtensions %d cbData %d", @@ -453,7 +453,7 @@ int tsmf_ifman_on_flush(TSMF_IFMAN* ifman) TSMF_PRESENTATION* presentation; Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, StreamId); + Stream_Read_UINT32(ifman->input, StreamId); DEBUG_DVC("StreamId %d", StreamId); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); @@ -479,7 +479,7 @@ int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); - stream_read_UINT32(ifman->input, StreamId); + Stream_Read_UINT32(ifman->input, StreamId); if (presentation) { @@ -490,10 +490,10 @@ int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) DEBUG_DVC("StreamId %d", StreamId); Stream_EnsureRemainingCapacity(ifman->output, 16); - stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ - stream_write_UINT32(ifman->output, StreamId); /* StreamId */ - stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */ - stream_write_UINT32(ifman->output, 0); /* cbData */ + Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ + Stream_Write_UINT32(ifman->output, StreamId); /* StreamId */ + Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */ + Stream_Write_UINT32(ifman->output, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; @@ -513,10 +513,10 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman) DEBUG_WARN("unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 16); - stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ - stream_write_UINT32(ifman->output, 0); /* StreamId */ - stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */ - stream_write_UINT32(ifman->output, 0); /* cbData */ + Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ + Stream_Write_UINT32(ifman->output, 0); /* StreamId */ + Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */ + Stream_Write_UINT32(ifman->output, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; @@ -574,10 +574,10 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) DEBUG_WARN("unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 16); - stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ - stream_write_UINT32(ifman->output, 0); /* StreamId */ - stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */ - stream_write_UINT32(ifman->output, 0); /* cbData */ + Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ + Stream_Write_UINT32(ifman->output, 0); /* StreamId */ + Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */ + Stream_Write_UINT32(ifman->output, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; @@ -588,10 +588,10 @@ int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman) DEBUG_DVC(""); Stream_EnsureRemainingCapacity(ifman->output, 16); - stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ - stream_write_UINT32(ifman->output, 0); /* StreamId */ - stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */ - stream_write_UINT32(ifman->output, 0); /* cbData */ + Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ + Stream_Write_UINT32(ifman->output, 0); /* StreamId */ + Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */ + Stream_Write_UINT32(ifman->output, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 3d00688ba..2f6617c79 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -82,12 +82,12 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback; s = stream_new(32); - stream_write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY); - stream_write_UINT32(s, message_id); - stream_write_UINT32(s, PLAYBACK_ACK); /* FunctionId */ - stream_write_UINT32(s, callback->stream_id); /* StreamId */ - stream_write_UINT64(s, duration); /* DataDuration */ - stream_write_UINT64(s, data_size); /* cbData */ + Stream_Write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY); + Stream_Write_UINT32(s, message_id); + Stream_Write_UINT32(s, PLAYBACK_ACK); /* FunctionId */ + Stream_Write_UINT32(s, callback->stream_id); /* StreamId */ + Stream_Write_UINT64(s, duration); /* DataDuration */ + Stream_Write_UINT64(s, data_size); /* cbData */ DEBUG_DVC("response size %d", (int) Stream_GetPosition(s)); status = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); @@ -141,9 +141,9 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, output = stream_new(256); Stream_Seek(output, 8); - stream_read_UINT32(input, InterfaceId); - stream_read_UINT32(input, MessageId); - stream_read_UINT32(input, FunctionId); + Stream_Read_UINT32(input, InterfaceId); + Stream_Read_UINT32(input, MessageId); + Stream_Read_UINT32(input, FunctionId); DEBUG_DVC("cbSize=%d InterfaceId=0x%X MessageId=0x%X FunctionId=0x%X", cbSize, InterfaceId, MessageId, FunctionId); @@ -183,7 +183,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, case SET_CHANNEL_PARAMS: memcpy(callback->presentation_id, Stream_Pointer(input), 16); Stream_Seek(input, 16); - stream_read_UINT32(input, callback->stream_id); + Stream_Read_UINT32(input, callback->stream_id); DEBUG_DVC("SET_CHANNEL_PARAMS StreamId=%d", callback->stream_id); ifman.output_pending = TRUE; status = 0; @@ -319,8 +319,8 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, /* Response packet does not have FunctionId */ length = Stream_GetPosition(output); Stream_SetPosition(output, 0); - stream_write_UINT32(output, ifman.output_interface_id); - stream_write_UINT32(output, MessageId); + Stream_Write_UINT32(output, ifman.output_interface_id); + Stream_Write_UINT32(output, MessageId); DEBUG_DVC("response size %d", length); status = callback->channel->Write(callback->channel, length, stream_get_head(output), NULL); diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 7fdd936fc..96670aa57 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -931,8 +931,8 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) s = stream_new(0); stream_attach(s, data, size); Stream_Seek(s, 14); - stream_read_UINT16(s, bpp); - stream_read_UINT32(s, ncolors); + Stream_Read_UINT16(s, bpp); + Stream_Read_UINT32(s, ncolors); offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0); stream_detach(s); stream_free(s); @@ -940,12 +940,12 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) DEBUG_X11_CLIPRDR("offset=%d bpp=%d ncolors=%d", offset, bpp, ncolors); s = stream_new(14 + size); - stream_write_BYTE(s, 'B'); - stream_write_BYTE(s, 'M'); - stream_write_UINT32(s, 14 + size); - stream_write_UINT32(s, 0); - stream_write_UINT32(s, offset); - stream_write(s, data, size); + Stream_Write_UINT8(s, 'B'); + Stream_Write_UINT8(s, 'M'); + Stream_Write_UINT32(s, 14 + size); + Stream_Write_UINT32(s, 0); + Stream_Write_UINT32(s, offset); + Stream_Write(s, data, size); cb->data = stream_get_head(s); cb->data_length = Stream_GetPosition(s); diff --git a/cunit/test_rfx.c b/cunit/test_rfx.c index dcf848ded..86eff82b0 100644 --- a/cunit/test_rfx.c +++ b/cunit/test_rfx.c @@ -307,9 +307,9 @@ void test_decode(void) wStream* s; s = stream_new(sizeof(y_data) + sizeof(cb_data) + sizeof(cr_data)); - stream_write(s, y_data, sizeof(y_data)); - stream_write(s, cb_data, sizeof(cb_data)); - stream_write(s, cr_data, sizeof(cr_data)); + Stream_Write(s, y_data, sizeof(y_data)); + Stream_Write(s, cb_data, sizeof(cb_data)); + Stream_Write(s, cr_data, sizeof(cr_data)); Stream_SetPosition(s, 0); context = rfx_context_new(); diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 89a9e26ac..2db011ac7 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -174,10 +174,10 @@ static void nsc_stream_initialize(NSC_CONTEXT* context, wStream* s) int i; for (i = 0; i < 4; i++) - stream_read_UINT32(s, context->nsc_stream.PlaneByteCount[i]); + Stream_Read_UINT32(s, context->nsc_stream.PlaneByteCount[i]); - stream_read_BYTE(s, context->nsc_stream.ColorLossLevel); - stream_read_BYTE(s, context->nsc_stream.ChromaSubSamplingLevel); + Stream_Read_UINT8(s, context->nsc_stream.ColorLossLevel); + Stream_Read_UINT8(s, context->nsc_stream.ChromaSubSamplingLevel); Stream_Seek(s, 2); context->nsc_stream.Planes = Stream_Pointer(s); diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index d47fb6670..143e44dc5 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -350,20 +350,20 @@ void nsc_compose_message(NSC_CONTEXT* context, wStream* s, /* Assemble the NSCodec message into stream */ Stream_EnsureRemainingCapacity(s, 20); - stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[0]); /* LumaPlaneByteCount (4 bytes) */ - stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[1]); /* OrangeChromaPlaneByteCount (4 bytes) */ - stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[2]); /* GreenChromaPlaneByteCount (4 bytes) */ - stream_write_UINT32(s, context->nsc_stream.PlaneByteCount[3]); /* AlphaPlaneByteCount (4 bytes) */ - stream_write_BYTE(s, context->nsc_stream.ColorLossLevel); /* ColorLossLevel (1 byte) */ - stream_write_BYTE(s, context->nsc_stream.ChromaSubSamplingLevel); /* ChromaSubsamplingLevel (1 byte) */ - stream_write_UINT16(s, 0); /* Reserved (2 bytes) */ + Stream_Write_UINT32(s, context->nsc_stream.PlaneByteCount[0]); /* LumaPlaneByteCount (4 bytes) */ + Stream_Write_UINT32(s, context->nsc_stream.PlaneByteCount[1]); /* OrangeChromaPlaneByteCount (4 bytes) */ + Stream_Write_UINT32(s, context->nsc_stream.PlaneByteCount[2]); /* GreenChromaPlaneByteCount (4 bytes) */ + Stream_Write_UINT32(s, context->nsc_stream.PlaneByteCount[3]); /* AlphaPlaneByteCount (4 bytes) */ + Stream_Write_UINT8(s, context->nsc_stream.ColorLossLevel); /* ColorLossLevel (1 byte) */ + Stream_Write_UINT8(s, context->nsc_stream.ChromaSubSamplingLevel); /* ChromaSubsamplingLevel (1 byte) */ + Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */ for (i = 0; i < 4; i++) { if (context->nsc_stream.PlaneByteCount[i] > 0) { Stream_EnsureRemainingCapacity(s, (int) context->nsc_stream.PlaneByteCount[i]); - stream_write(s, context->priv->plane_buf[i], context->nsc_stream.PlaneByteCount[i]); + Stream_Write(s, context->priv->plane_buf[i], context->nsc_stream.PlaneByteCount[i]); } } } diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 9044ca563..b94b6fbbf 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -335,7 +335,7 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s) DEBUG_WARN("RfxSync packet too small"); return FALSE; } - stream_read_UINT32(s, magic); /* magic (4 bytes), 0xCACCACCA */ + Stream_Read_UINT32(s, magic); /* magic (4 bytes), 0xCACCACCA */ if (magic != WF_MAGIC) { @@ -343,7 +343,7 @@ static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s) return FALSE; } - stream_read_UINT16(s, context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */ + Stream_Read_UINT16(s, context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */ if (context->version != WF_VERSION_1_0) { @@ -364,7 +364,7 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s) DEBUG_WARN("RfxCodecVersion packet too small"); return FALSE; } - stream_read_BYTE(s, numCodecs); /* numCodecs (1 byte), must be set to 0x01 */ + Stream_Read_UINT8(s, numCodecs); /* numCodecs (1 byte), must be set to 0x01 */ if (numCodecs != 1) { @@ -379,8 +379,8 @@ static BOOL rfx_process_message_codec_versions(RFX_CONTEXT* context, wStream* s) } /* RFX_CODEC_VERSIONT */ - stream_read_BYTE(s, context->codec_id); /* codecId (1 byte) */ - stream_read_BYTE(s, context->codec_version); /* version (2 bytes) */ + Stream_Read_UINT8(s, context->codec_id); /* codecId (1 byte) */ + Stream_Read_UINT8(s, context->codec_version); /* version (2 bytes) */ DEBUG_RFX("id %d version 0x%X.", context->codec_id, context->codec_version); return TRUE; @@ -397,7 +397,7 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) return FALSE; } - stream_read_BYTE(s, numChannels); /* numChannels (1 byte), must bet set to 0x01 */ + Stream_Read_UINT8(s, numChannels); /* numChannels (1 byte), must bet set to 0x01 */ /* In RDVH sessions, numChannels will represent the number of virtual monitors * configured and does not always be set to 0x01 as [MS-RDPRFX] said. @@ -415,9 +415,9 @@ static BOOL rfx_process_message_channels(RFX_CONTEXT* context, wStream* s) } /* RFX_CHANNELT */ - stream_read_BYTE(s, channelId); /* channelId (1 byte) */ - stream_read_UINT16(s, context->width); /* width (2 bytes) */ - stream_read_UINT16(s, context->height); /* height (2 bytes) */ + Stream_Read_UINT8(s, channelId); /* channelId (1 byte) */ + Stream_Read_UINT16(s, context->width); /* width (2 bytes) */ + Stream_Read_UINT16(s, context->height); /* height (2 bytes) */ /* Now, only the first monitor can be used, therefore the other channels will be ignored. */ Stream_Seek(s, 5 * (numChannels - 1)); @@ -439,9 +439,9 @@ static BOOL rfx_process_message_context(RFX_CONTEXT* context, wStream* s) return FALSE; } - stream_read_BYTE(s, ctxId); /* ctxId (1 byte), must be set to 0x00 */ - stream_read_UINT16(s, tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */ - stream_read_UINT16(s, properties); /* properties (2 bytes) */ + Stream_Read_UINT8(s, ctxId); /* ctxId (1 byte), must be set to 0x00 */ + Stream_Read_UINT16(s, tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */ + Stream_Read_UINT16(s, properties); /* properties (2 bytes) */ DEBUG_RFX("ctxId %d tileSize %d properties 0x%X.", ctxId, tileSize, properties); @@ -482,8 +482,8 @@ static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context, RFX_MESSAGE* m DEBUG_WARN("RfxMessageFrameBegin packet too small"); return FALSE; } - stream_read_UINT32(s, frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */ - stream_read_UINT16(s, numRegions); /* numRegions (2 bytes) */ + Stream_Read_UINT32(s, frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */ + Stream_Read_UINT16(s, numRegions); /* numRegions (2 bytes) */ DEBUG_RFX("RFX_FRAME_BEGIN: frameIdx:%d numRegions:%d", frameIdx, numRegions); return TRUE; @@ -505,7 +505,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag } Stream_Seek_BYTE(s); /* regionFlags (1 byte) */ - stream_read_UINT16(s, message->num_rects); /* numRects (2 bytes) */ + Stream_Read_UINT16(s, message->num_rects); /* numRects (2 bytes) */ if (message->num_rects < 1) { @@ -528,10 +528,10 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag for (i = 0; i < message->num_rects; i++) { /* RFX_RECT */ - stream_read_UINT16(s, message->rects[i].x); /* x (2 bytes) */ - stream_read_UINT16(s, message->rects[i].y); /* y (2 bytes) */ - stream_read_UINT16(s, message->rects[i].width); /* width (2 bytes) */ - stream_read_UINT16(s, message->rects[i].height); /* height (2 bytes) */ + Stream_Read_UINT16(s, message->rects[i].x); /* x (2 bytes) */ + Stream_Read_UINT16(s, message->rects[i].y); /* y (2 bytes) */ + Stream_Read_UINT16(s, message->rects[i].width); /* width (2 bytes) */ + Stream_Read_UINT16(s, message->rects[i].height); /* height (2 bytes) */ DEBUG_RFX("rect %d (%d %d %d %d).", i, message->rects[i].x, message->rects[i].y, message->rects[i].width, message->rects[i].height); @@ -554,14 +554,14 @@ static BOOL rfx_process_message_tile(RFX_CONTEXT* context, RFX_TILE* tile, wStre } /* RFX_TILE */ - stream_read_BYTE(s, quantIdxY); /* quantIdxY (1 byte) */ - stream_read_BYTE(s, quantIdxCb); /* quantIdxCb (1 byte) */ - stream_read_BYTE(s, quantIdxCr); /* quantIdxCr (1 byte) */ - stream_read_UINT16(s, xIdx); /* xIdx (2 bytes) */ - stream_read_UINT16(s, yIdx); /* yIdx (2 bytes) */ - stream_read_UINT16(s, YLen); /* YLen (2 bytes) */ - stream_read_UINT16(s, CbLen); /* CbLen (2 bytes) */ - stream_read_UINT16(s, CrLen); /* CrLen (2 bytes) */ + Stream_Read_UINT8(s, quantIdxY); /* quantIdxY (1 byte) */ + Stream_Read_UINT8(s, quantIdxCb); /* quantIdxCb (1 byte) */ + Stream_Read_UINT8(s, quantIdxCr); /* quantIdxCr (1 byte) */ + Stream_Read_UINT16(s, xIdx); /* xIdx (2 bytes) */ + Stream_Read_UINT16(s, yIdx); /* yIdx (2 bytes) */ + Stream_Read_UINT16(s, YLen); /* YLen (2 bytes) */ + Stream_Read_UINT16(s, CbLen); /* CbLen (2 bytes) */ + Stream_Read_UINT16(s, CrLen); /* CrLen (2 bytes) */ DEBUG_RFX("quantIdxY:%d quantIdxCb:%d quantIdxCr:%d xIdx:%d yIdx:%d YLen:%d CbLen:%d CrLen:%d", quantIdxY, quantIdxCb, quantIdxCr, xIdx, yIdx, YLen, CbLen, CrLen); @@ -609,7 +609,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa return FALSE; } - stream_read_UINT16(s, subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */ + Stream_Read_UINT16(s, subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */ if (subtype != CBT_TILESET) { @@ -620,7 +620,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa Stream_Seek_UINT16(s); /* idx (2 bytes), must be set to 0x0000 */ Stream_Seek_UINT16(s); /* properties (2 bytes) */ - stream_read_BYTE(s, context->num_quants); /* numQuant (1 byte) */ + Stream_Read_UINT8(s, context->num_quants); /* numQuant (1 byte) */ Stream_Seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */ if (context->num_quants < 1) @@ -629,7 +629,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa return TRUE; } - stream_read_UINT16(s, message->num_tiles); /* numTiles (2 bytes) */ + Stream_Read_UINT16(s, message->num_tiles); /* numTiles (2 bytes) */ if (message->num_tiles < 1) { @@ -637,7 +637,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa return TRUE; } - stream_read_UINT32(s, tilesDataSize); /* tilesDataSize (4 bytes) */ + Stream_Read_UINT32(s, tilesDataSize); /* tilesDataSize (4 bytes) */ if (context->quants != NULL) context->quants = (UINT32*) realloc((void*) context->quants, context->num_quants * 10 * sizeof(UINT32)); @@ -655,19 +655,19 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa for (i = 0; i < context->num_quants; i++) { /* RFX_CODEC_QUANT */ - stream_read_BYTE(s, quant); + Stream_Read_UINT8(s, quant); *quants++ = (quant & 0x0F); *quants++ = (quant >> 4); - stream_read_BYTE(s, quant); + Stream_Read_UINT8(s, quant); *quants++ = (quant & 0x0F); *quants++ = (quant >> 4); - stream_read_BYTE(s, quant); + Stream_Read_UINT8(s, quant); *quants++ = (quant & 0x0F); *quants++ = (quant >> 4); - stream_read_BYTE(s, quant); + Stream_Read_UINT8(s, quant); *quants++ = (quant & 0x0F); *quants++ = (quant >> 4); - stream_read_BYTE(s, quant); + Stream_Read_UINT8(s, quant); *quants++ = (quant & 0x0F); *quants++ = (quant >> 4); @@ -698,8 +698,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa return FALSE; } - stream_read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */ - stream_read_UINT32(s, blockLen); /* blockLen (4 bytes) */ + Stream_Read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */ + Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */ if (Stream_GetRemainingLength(s) < blockLen - 6) { @@ -764,8 +764,8 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length while (Stream_GetRemainingLength(s) > 6) { /* RFX_BLOCKT */ - stream_read_UINT16(s, blockType); /* blockType (2 bytes) */ - stream_read_UINT32(s, blockLen); /* blockLen (4 bytes) */ + Stream_Read_UINT16(s, blockType); /* blockType (2 bytes) */ + Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */ DEBUG_RFX("blockType 0x%X blockLen %d", blockType, blockLen); @@ -886,41 +886,41 @@ void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message) static void rfx_compose_message_sync(RFX_CONTEXT* context, wStream* s) { - stream_write_UINT16(s, WBT_SYNC); /* BlockT.blockType */ - stream_write_UINT32(s, 12); /* BlockT.blockLen */ - stream_write_UINT32(s, WF_MAGIC); /* magic */ - stream_write_UINT16(s, WF_VERSION_1_0); /* version */ + Stream_Write_UINT16(s, WBT_SYNC); /* BlockT.blockType */ + Stream_Write_UINT32(s, 12); /* BlockT.blockLen */ + Stream_Write_UINT32(s, WF_MAGIC); /* magic */ + Stream_Write_UINT16(s, WF_VERSION_1_0); /* version */ } static void rfx_compose_message_codec_versions(RFX_CONTEXT* context, wStream* s) { - stream_write_UINT16(s, WBT_CODEC_VERSIONS); /* BlockT.blockType */ - stream_write_UINT32(s, 10); /* BlockT.blockLen */ - stream_write_BYTE(s, 1); /* numCodecs */ - stream_write_BYTE(s, 1); /* codecs.codecId */ - stream_write_UINT16(s, WF_VERSION_1_0); /* codecs.version */ + Stream_Write_UINT16(s, WBT_CODEC_VERSIONS); /* BlockT.blockType */ + Stream_Write_UINT32(s, 10); /* BlockT.blockLen */ + Stream_Write_UINT8(s, 1); /* numCodecs */ + Stream_Write_UINT8(s, 1); /* codecs.codecId */ + Stream_Write_UINT16(s, WF_VERSION_1_0); /* codecs.version */ } static void rfx_compose_message_channels(RFX_CONTEXT* context, wStream* s) { - stream_write_UINT16(s, WBT_CHANNELS); /* BlockT.blockType */ - stream_write_UINT32(s, 12); /* BlockT.blockLen */ - stream_write_BYTE(s, 1); /* numChannels */ - stream_write_BYTE(s, 0); /* Channel.channelId */ - stream_write_UINT16(s, context->width); /* Channel.width */ - stream_write_UINT16(s, context->height); /* Channel.height */ + Stream_Write_UINT16(s, WBT_CHANNELS); /* BlockT.blockType */ + Stream_Write_UINT32(s, 12); /* BlockT.blockLen */ + Stream_Write_UINT8(s, 1); /* numChannels */ + Stream_Write_UINT8(s, 0); /* Channel.channelId */ + Stream_Write_UINT16(s, context->width); /* Channel.width */ + Stream_Write_UINT16(s, context->height); /* Channel.height */ } static void rfx_compose_message_context(RFX_CONTEXT* context, wStream* s) { UINT16 properties; - stream_write_UINT16(s, WBT_CONTEXT); /* CodecChannelT.blockType */ - stream_write_UINT32(s, 13); /* CodecChannelT.blockLen */ - stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ - stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ - stream_write_BYTE(s, 0); /* ctxId */ - stream_write_UINT16(s, CT_TILE_64x64); /* tileSize */ + Stream_Write_UINT16(s, WBT_CONTEXT); /* CodecChannelT.blockType */ + Stream_Write_UINT32(s, 13); /* CodecChannelT.blockLen */ + Stream_Write_UINT8(s, 1); /* CodecChannelT.codecId */ + Stream_Write_UINT8(s, 0); /* CodecChannelT.channelId */ + Stream_Write_UINT8(s, 0); /* ctxId */ + Stream_Write_UINT16(s, CT_TILE_64x64); /* tileSize */ /* properties */ properties = context->flags; /* flags */ @@ -928,7 +928,7 @@ static void rfx_compose_message_context(RFX_CONTEXT* context, wStream* s) properties |= (CLW_XFORM_DWT_53_A << 5); /* xft */ properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3) << 9); /* et */ properties |= (SCALAR_QUANTIZATION << 13); /* qt */ - stream_write_UINT16(s, properties); + Stream_Write_UINT16(s, properties); /* properties in tilesets: note that this has different format from the one in TS_RFX_CONTEXT */ properties = 1; /* lt */ @@ -956,12 +956,12 @@ static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, wStream* s) { Stream_EnsureRemainingCapacity(s, 14); - stream_write_UINT16(s, WBT_FRAME_BEGIN); /* CodecChannelT.blockType */ - stream_write_UINT32(s, 14); /* CodecChannelT.blockLen */ - stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ - stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ - stream_write_UINT32(s, context->frame_idx); /* frameIdx */ - stream_write_UINT16(s, 1); /* numRegions */ + Stream_Write_UINT16(s, WBT_FRAME_BEGIN); /* CodecChannelT.blockType */ + Stream_Write_UINT32(s, 14); /* CodecChannelT.blockLen */ + Stream_Write_UINT8(s, 1); /* CodecChannelT.codecId */ + Stream_Write_UINT8(s, 0); /* CodecChannelT.channelId */ + Stream_Write_UINT32(s, context->frame_idx); /* frameIdx */ + Stream_Write_UINT16(s, 1); /* numRegions */ context->frame_idx++; } @@ -975,23 +975,23 @@ static void rfx_compose_message_region(RFX_CONTEXT* context, wStream* s, size = 15 + num_rects * 8; Stream_EnsureRemainingCapacity(s, size); - stream_write_UINT16(s, WBT_REGION); /* CodecChannelT.blockType */ - stream_write_UINT32(s, size); /* set CodecChannelT.blockLen later */ - stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ - stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ - stream_write_BYTE(s, 1); /* regionFlags */ - stream_write_UINT16(s, num_rects); /* numRects */ + Stream_Write_UINT16(s, WBT_REGION); /* CodecChannelT.blockType */ + Stream_Write_UINT32(s, size); /* set CodecChannelT.blockLen later */ + Stream_Write_UINT8(s, 1); /* CodecChannelT.codecId */ + Stream_Write_UINT8(s, 0); /* CodecChannelT.channelId */ + Stream_Write_UINT8(s, 1); /* regionFlags */ + Stream_Write_UINT16(s, num_rects); /* numRects */ for (i = 0; i < num_rects; i++) { - stream_write_UINT16(s, rects[i].x); - stream_write_UINT16(s, rects[i].y); - stream_write_UINT16(s, rects[i].width); - stream_write_UINT16(s, rects[i].height); + Stream_Write_UINT16(s, rects[i].x); + Stream_Write_UINT16(s, rects[i].y); + Stream_Write_UINT16(s, rects[i].width); + Stream_Write_UINT16(s, rects[i].height); } - stream_write_UINT16(s, CBT_REGION); /* regionType */ - stream_write_UINT16(s, 1); /* numTilesets */ + Stream_Write_UINT16(s, CBT_REGION); /* regionType */ + Stream_Write_UINT16(s, 1); /* numTilesets */ } static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, @@ -1007,13 +1007,13 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, Stream_EnsureRemainingCapacity(s, 19); start_pos = Stream_GetPosition(s); - stream_write_UINT16(s, CBT_TILE); /* BlockT.blockType */ + Stream_Write_UINT16(s, CBT_TILE); /* BlockT.blockType */ Stream_Seek_UINT32(s); /* set BlockT.blockLen later */ - stream_write_BYTE(s, quantIdxY); - stream_write_BYTE(s, quantIdxCb); - stream_write_BYTE(s, quantIdxCr); - stream_write_UINT16(s, xIdx); - stream_write_UINT16(s, yIdx); + Stream_Write_UINT8(s, quantIdxY); + Stream_Write_UINT8(s, quantIdxCb); + Stream_Write_UINT8(s, quantIdxCr); + Stream_Write_UINT16(s, xIdx); + Stream_Write_UINT16(s, yIdx); Stream_Seek(s, 6); /* YLen, CbLen, CrLen */ @@ -1027,11 +1027,11 @@ static void rfx_compose_message_tile(RFX_CONTEXT* context, wStream* s, end_pos = Stream_GetPosition(s); Stream_SetPosition(s, start_pos + 2); - stream_write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */ + Stream_Write_UINT32(s, 19 + YLen + CbLen + CrLen); /* BlockT.blockLen */ Stream_SetPosition(s, start_pos + 13); - stream_write_UINT16(s, YLen); - stream_write_UINT16(s, CbLen); - stream_write_UINT16(s, CrLen); + Stream_Write_UINT16(s, YLen); + Stream_Write_UINT16(s, CbLen); + Stream_Write_UINT16(s, CrLen); Stream_SetPosition(s, end_pos); } @@ -1080,22 +1080,22 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, Stream_EnsureRemainingCapacity(s, size); start_pos = Stream_GetPosition(s); - stream_write_UINT16(s, WBT_EXTENSION); /* CodecChannelT.blockType */ + Stream_Write_UINT16(s, WBT_EXTENSION); /* CodecChannelT.blockType */ Stream_Seek_UINT32(s); /* set CodecChannelT.blockLen later */ - stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ - stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ - stream_write_UINT16(s, CBT_TILESET); /* subtype */ - stream_write_UINT16(s, 0); /* idx */ - stream_write_UINT16(s, context->properties); /* properties */ - stream_write_BYTE(s, numQuants); /* numQuants */ - stream_write_BYTE(s, 0x40); /* tileSize */ - stream_write_UINT16(s, numTiles); /* numTiles */ + Stream_Write_UINT8(s, 1); /* CodecChannelT.codecId */ + Stream_Write_UINT8(s, 0); /* CodecChannelT.channelId */ + Stream_Write_UINT16(s, CBT_TILESET); /* subtype */ + Stream_Write_UINT16(s, 0); /* idx */ + Stream_Write_UINT16(s, context->properties); /* properties */ + Stream_Write_UINT8(s, numQuants); /* numQuants */ + Stream_Write_UINT8(s, 0x40); /* tileSize */ + Stream_Write_UINT16(s, numTiles); /* numTiles */ Stream_Seek_UINT32(s); /* set tilesDataSize later */ quantValsPtr = quantVals; for (i = 0; i < numQuants * 5; i++) { - stream_write_BYTE(s, quantValsPtr[0] + (quantValsPtr[1] << 4)); + Stream_Write_UINT8(s, quantValsPtr[0] + (quantValsPtr[1] << 4)); quantValsPtr += 2; } @@ -1118,9 +1118,9 @@ static void rfx_compose_message_tileset(RFX_CONTEXT* context, wStream* s, end_pos = Stream_GetPosition(s); Stream_SetPosition(s, start_pos + 2); - stream_write_UINT32(s, size); /* CodecChannelT.blockLen */ + Stream_Write_UINT32(s, size); /* CodecChannelT.blockLen */ Stream_SetPosition(s, start_pos + 18); - stream_write_UINT32(s, tilesDataSize); + Stream_Write_UINT32(s, tilesDataSize); Stream_SetPosition(s, end_pos); } @@ -1129,10 +1129,10 @@ static void rfx_compose_message_frame_end(RFX_CONTEXT* context, wStream* s) { Stream_EnsureRemainingCapacity(s, 8); - stream_write_UINT16(s, WBT_FRAME_END); /* CodecChannelT.blockType */ - stream_write_UINT32(s, 8); /* CodecChannelT.blockLen */ - stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ - stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ + Stream_Write_UINT16(s, WBT_FRAME_END); /* CodecChannelT.blockType */ + Stream_Write_UINT32(s, 8); /* CodecChannelT.blockLen */ + Stream_Write_UINT8(s, 1); /* CodecChannelT.codecId */ + Stream_Write_UINT8(s, 0); /* CodecChannelT.channelId */ } static void rfx_compose_message_data(RFX_CONTEXT* context, wStream* s, diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index a6118c118..617537a3e 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -36,8 +36,8 @@ static const char* const CTRLACTION_STRINGS[] = void rdp_write_synchronize_pdu(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, SYNCMSGTYPE_SYNC); /* messageType (2 bytes) */ - stream_write_UINT16(s, settings->PduSource); /* targetUser (2 bytes) */ + Stream_Write_UINT16(s, SYNCMSGTYPE_SYNC); /* messageType (2 bytes) */ + Stream_Write_UINT16(s, settings->PduSource); /* targetUser (2 bytes) */ } BOOL rdp_recv_synchronize_pdu(rdpRdp* rdp, wStream* s) @@ -73,7 +73,7 @@ BOOL rdp_recv_client_synchronize_pdu(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ + Stream_Read_UINT16(s, messageType); /* messageType (2 bytes) */ if (messageType != SYNCMSGTYPE_SYNC) return FALSE; @@ -100,7 +100,7 @@ BOOL rdp_recv_control_pdu(wStream* s, UINT16* action) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT16(s, *action); /* action (2 bytes) */ + Stream_Read_UINT16(s, *action); /* action (2 bytes) */ Stream_Seek_UINT16(s); /* grantId (2 bytes) */ Stream_Seek_UINT32(s); /* controlId (4 bytes) */ @@ -109,9 +109,9 @@ BOOL rdp_recv_control_pdu(wStream* s, UINT16* action) void rdp_write_client_control_pdu(wStream* s, UINT16 action) { - stream_write_UINT16(s, action); /* action (2 bytes) */ - stream_write_UINT16(s, 0); /* grantId (2 bytes) */ - stream_write_UINT32(s, 0); /* controlId (4 bytes) */ + Stream_Write_UINT16(s, action); /* action (2 bytes) */ + Stream_Write_UINT16(s, 0); /* grantId (2 bytes) */ + Stream_Write_UINT32(s, 0); /* controlId (4 bytes) */ } BOOL rdp_recv_server_control_pdu(rdpRdp* rdp, wStream* s) @@ -142,9 +142,9 @@ BOOL rdp_send_server_control_cooperate_pdu(rdpRdp* rdp) s = rdp_data_pdu_init(rdp); - stream_write_UINT16(s, CTRLACTION_COOPERATE); /* action (2 bytes) */ - stream_write_UINT16(s, 0); /* grantId (2 bytes) */ - stream_write_UINT32(s, 0); /* controlId (4 bytes) */ + Stream_Write_UINT16(s, CTRLACTION_COOPERATE); /* action (2 bytes) */ + Stream_Write_UINT16(s, 0); /* grantId (2 bytes) */ + Stream_Write_UINT32(s, 0); /* controlId (4 bytes) */ return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id); } @@ -155,9 +155,9 @@ BOOL rdp_send_server_control_granted_pdu(rdpRdp* rdp) s = rdp_data_pdu_init(rdp); - stream_write_UINT16(s, CTRLACTION_GRANTED_CONTROL); /* action (2 bytes) */ - stream_write_UINT16(s, rdp->mcs->user_id); /* grantId (2 bytes) */ - stream_write_UINT32(s, 0x03EA); /* controlId (4 bytes) */ + Stream_Write_UINT16(s, CTRLACTION_GRANTED_CONTROL); /* action (2 bytes) */ + Stream_Write_UINT16(s, rdp->mcs->user_id); /* grantId (2 bytes) */ + Stream_Write_UINT32(s, 0x03EA); /* controlId (4 bytes) */ return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id); } @@ -174,25 +174,25 @@ BOOL rdp_send_client_control_pdu(rdpRdp* rdp, UINT16 action) void rdp_write_persistent_list_entry(wStream* s, UINT32 key1, UINT32 key2) { - stream_write_UINT32(s, key1); /* key1 (4 bytes) */ - stream_write_UINT32(s, key2); /* key2 (4 bytes) */ + Stream_Write_UINT32(s, key1); /* key1 (4 bytes) */ + Stream_Write_UINT32(s, key2); /* key2 (4 bytes) */ } void rdp_write_client_persistent_key_list_pdu(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 0); /* numEntriesCache0 (2 bytes) */ - stream_write_UINT16(s, 0); /* numEntriesCache1 (2 bytes) */ - stream_write_UINT16(s, 0); /* numEntriesCache2 (2 bytes) */ - stream_write_UINT16(s, 0); /* numEntriesCache3 (2 bytes) */ - stream_write_UINT16(s, 0); /* numEntriesCache4 (2 bytes) */ - stream_write_UINT16(s, 0); /* totalEntriesCache0 (2 bytes) */ - stream_write_UINT16(s, 0); /* totalEntriesCache1 (2 bytes) */ - stream_write_UINT16(s, 0); /* totalEntriesCache2 (2 bytes) */ - stream_write_UINT16(s, 0); /* totalEntriesCache3 (2 bytes) */ - stream_write_UINT16(s, 0); /* totalEntriesCache4 (2 bytes) */ - stream_write_BYTE(s, PERSIST_FIRST_PDU | PERSIST_LAST_PDU); /* bBitMask (1 byte) */ - stream_write_BYTE(s, 0); /* pad1 (1 byte) */ - stream_write_UINT16(s, 0); /* pad3 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numEntriesCache0 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numEntriesCache1 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numEntriesCache2 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numEntriesCache3 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numEntriesCache4 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalEntriesCache0 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalEntriesCache1 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalEntriesCache2 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalEntriesCache3 (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalEntriesCache4 (2 bytes) */ + Stream_Write_UINT8(s, PERSIST_FIRST_PDU | PERSIST_LAST_PDU); /* bBitMask (1 byte) */ + Stream_Write_UINT8(s, 0); /* pad1 (1 byte) */ + Stream_Write_UINT16(s, 0); /* pad3 (2 bytes) */ /* entries */ } @@ -217,10 +217,10 @@ BOOL rdp_recv_client_font_list_pdu(wStream* s) void rdp_write_client_font_list_pdu(wStream* s, UINT16 flags) { - stream_write_UINT16(s, 0); /* numberFonts (2 bytes) */ - stream_write_UINT16(s, 0); /* totalNumFonts (2 bytes) */ - stream_write_UINT16(s, flags); /* listFlags (2 bytes) */ - stream_write_UINT16(s, 50); /* entrySize (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numberFonts (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalNumFonts (2 bytes) */ + Stream_Write_UINT16(s, flags); /* listFlags (2 bytes) */ + Stream_Write_UINT16(s, 50); /* entrySize (2 bytes) */ } BOOL rdp_send_client_font_list_pdu(rdpRdp* rdp, UINT16 flags) @@ -267,10 +267,10 @@ BOOL rdp_send_server_font_map_pdu(rdpRdp* rdp) s = rdp_data_pdu_init(rdp); - stream_write_UINT16(s, 0); /* numberEntries (2 bytes) */ - stream_write_UINT16(s, 0); /* totalNumEntries (2 bytes) */ - stream_write_UINT16(s, FONTLIST_FIRST | FONTLIST_LAST); /* mapFlags (2 bytes) */ - stream_write_UINT16(s, 4); /* entrySize (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numberEntries (2 bytes) */ + Stream_Write_UINT16(s, 0); /* totalNumEntries (2 bytes) */ + Stream_Write_UINT16(s, FONTLIST_FIRST | FONTLIST_LAST); /* mapFlags (2 bytes) */ + Stream_Write_UINT16(s, 4); /* entrySize (2 bytes) */ return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_MAP, rdp->mcs->user_id); } @@ -288,10 +288,10 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s) do { if(Stream_GetRemainingLength(s) < 4) break; - stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ + Stream_Read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ if(Stream_GetRemainingLength(s) < 2) break; - stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ + Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ if(Stream_GetRemainingLength(s) < lengthSourceDescriptor) break; Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */ @@ -317,9 +317,9 @@ BOOL rdp_send_deactivate_all(rdpRdp* rdp) s = rdp_pdu_init(rdp); - stream_write_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ - stream_write_UINT16(s, 1); /* lengthSourceDescriptor (2 bytes) */ - stream_write_BYTE(s, 0); /* sourceDescriptor (should be 0x00) */ + Stream_Write_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ + Stream_Write_UINT16(s, 1); /* lengthSourceDescriptor (2 bytes) */ + Stream_Write_UINT8(s, 0); /* sourceDescriptor (should be 0x00) */ return rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id); } diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 011dafa5e..9b1afa408 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -114,14 +114,14 @@ GUID CODEC_GUID_JPEG = void rdp_read_capability_set_header(wStream* s, UINT16* length, UINT16* type) { - stream_read_UINT16(s, *type); /* capabilitySetType */ - stream_read_UINT16(s, *length); /* lengthCapability */ + Stream_Read_UINT16(s, *type); /* capabilitySetType */ + Stream_Read_UINT16(s, *length); /* lengthCapability */ } void rdp_write_capability_set_header(wStream* s, UINT16 length, UINT16 type) { - stream_write_UINT16(s, type); /* capabilitySetType */ - stream_write_UINT16(s, length); /* lengthCapability */ + Stream_Write_UINT16(s, type); /* capabilitySetType */ + Stream_Write_UINT16(s, length); /* lengthCapability */ } BYTE* rdp_capability_set_start(wStream* s) @@ -129,7 +129,7 @@ BYTE* rdp_capability_set_start(wStream* s) BYTE* header; stream_get_mark(s, header); - stream_write_zero(s, CAPSET_HEADER_LENGTH); + Stream_Write_zero(s, CAPSET_HEADER_LENGTH); return header; } @@ -166,8 +166,8 @@ BOOL rdp_read_general_capability_set(wStream* s, UINT16 length, rdpSettings* set if (settings->ServerMode) { - stream_read_UINT16(s, settings->OsMajorType); /* osMajorType (2 bytes) */ - stream_read_UINT16(s, settings->OsMinorType); /* osMinorType (2 bytes) */ + Stream_Read_UINT16(s, settings->OsMajorType); /* osMajorType (2 bytes) */ + Stream_Read_UINT16(s, settings->OsMinorType); /* osMinorType (2 bytes) */ } else { @@ -178,12 +178,12 @@ BOOL rdp_read_general_capability_set(wStream* s, UINT16 length, rdpSettings* set Stream_Seek_UINT16(s); /* protocolVersion (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ Stream_Seek_UINT16(s); /* generalCompressionTypes (2 bytes) */ - stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ Stream_Seek_UINT16(s); /* updateCapabilityFlag (2 bytes) */ Stream_Seek_UINT16(s); /* remoteUnshareFlag (2 bytes) */ Stream_Seek_UINT16(s); /* generalCompressionLevel (2 bytes) */ - stream_read_BYTE(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ - stream_read_BYTE(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ + Stream_Read_UINT8(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ + Stream_Read_UINT8(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ if (!(extraFlags & FASTPATH_OUTPUT_SUPPORTED)) settings->FastPathOutput = FALSE; @@ -222,17 +222,17 @@ void rdp_write_general_capability_set(wStream* s, rdpSettings* settings) if (settings->SaltedChecksum) extraFlags |= ENC_SALTED_CHECKSUM; - stream_write_UINT16(s, settings->OsMajorType); /* osMajorType (2 bytes) */ - stream_write_UINT16(s, settings->OsMinorType); /* osMinorType (2 bytes) */ - stream_write_UINT16(s, CAPS_PROTOCOL_VERSION); /* protocolVersion (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ - stream_write_UINT16(s, 0); /* generalCompressionTypes (2 bytes) */ - stream_write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - stream_write_UINT16(s, 0); /* updateCapabilityFlag (2 bytes) */ - stream_write_UINT16(s, 0); /* remoteUnshareFlag (2 bytes) */ - stream_write_UINT16(s, 0); /* generalCompressionLevel (2 bytes) */ - stream_write_BYTE(s, settings->RefreshRect); /* refreshRectSupport (1 byte) */ - stream_write_BYTE(s, settings->SuppressOutput); /* suppressOutputSupport (1 byte) */ + Stream_Write_UINT16(s, settings->OsMajorType); /* osMajorType (2 bytes) */ + Stream_Write_UINT16(s, settings->OsMinorType); /* osMinorType (2 bytes) */ + Stream_Write_UINT16(s, CAPS_PROTOCOL_VERSION); /* protocolVersion (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ + Stream_Write_UINT16(s, 0); /* generalCompressionTypes (2 bytes) */ + Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Write_UINT16(s, 0); /* updateCapabilityFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* remoteUnshareFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* generalCompressionLevel (2 bytes) */ + Stream_Write_UINT8(s, settings->RefreshRect); /* refreshRectSupport (1 byte) */ + Stream_Write_UINT8(s, settings->SuppressOutput); /* suppressOutputSupport (1 byte) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_GENERAL); } @@ -256,17 +256,17 @@ BOOL rdp_print_general_capability_set(wStream* s, UINT16 length) fprintf(stderr, "GeneralCapabilitySet (length %d):\n", length); - stream_read_UINT16(s, osMajorType); /* osMajorType (2 bytes) */ - stream_read_UINT16(s, osMinorType); /* osMinorType (2 bytes) */ - stream_read_UINT16(s, protocolVersion); /* protocolVersion (2 bytes) */ - stream_read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ - stream_read_UINT16(s, generalCompressionTypes); /* generalCompressionTypes (2 bytes) */ - stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - stream_read_UINT16(s, updateCapabilityFlag); /* updateCapabilityFlag (2 bytes) */ - stream_read_UINT16(s, remoteUnshareFlag); /* remoteUnshareFlag (2 bytes) */ - stream_read_UINT16(s, generalCompressionLevel); /* generalCompressionLevel (2 bytes) */ - stream_read_BYTE(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ - stream_read_BYTE(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ + Stream_Read_UINT16(s, osMajorType); /* osMajorType (2 bytes) */ + Stream_Read_UINT16(s, osMinorType); /* osMinorType (2 bytes) */ + Stream_Read_UINT16(s, protocolVersion); /* protocolVersion (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ + Stream_Read_UINT16(s, generalCompressionTypes); /* generalCompressionTypes (2 bytes) */ + Stream_Read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Read_UINT16(s, updateCapabilityFlag); /* updateCapabilityFlag (2 bytes) */ + Stream_Read_UINT16(s, remoteUnshareFlag); /* remoteUnshareFlag (2 bytes) */ + Stream_Read_UINT16(s, generalCompressionLevel); /* generalCompressionLevel (2 bytes) */ + Stream_Read_UINT8(s, refreshRectSupport); /* refreshRectSupport (1 byte) */ + Stream_Read_UINT8(s, suppressOutputSupport); /* suppressOutputSupport (1 byte) */ fprintf(stderr, "\tosMajorType: 0x%04X\n", osMajorType); fprintf(stderr, "\tosMinorType: 0x%04X\n", osMinorType); @@ -302,17 +302,17 @@ BOOL rdp_read_bitmap_capability_set(wStream* s, UINT16 length, rdpSettings* sett if (length < 28) return FALSE; - stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ + Stream_Read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ Stream_Seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */ Stream_Seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */ Stream_Seek_UINT16(s); /* receive8BitsPerPixel (2 bytes) */ - stream_read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */ - stream_read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */ + Stream_Read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */ + Stream_Read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */ Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ - stream_read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ + Stream_Read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ Stream_Seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */ Stream_Seek_BYTE(s); /* highColorFlags (1 byte) */ - stream_read_BYTE(s, drawingFlags); /* drawingFlags (1 byte) */ + Stream_Read_UINT8(s, drawingFlags); /* drawingFlags (1 byte) */ Stream_Seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */ @@ -361,19 +361,19 @@ void rdp_write_bitmap_capability_set(wStream* s, rdpSettings* settings) desktopResizeFlag = settings->DesktopResize; - stream_write_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ - stream_write_UINT16(s, 1); /* receive1BitPerPixel (2 bytes) */ - stream_write_UINT16(s, 1); /* receive4BitsPerPixel (2 bytes) */ - stream_write_UINT16(s, 1); /* receive8BitsPerPixel (2 bytes) */ - stream_write_UINT16(s, settings->DesktopWidth); /* desktopWidth (2 bytes) */ - stream_write_UINT16(s, settings->DesktopHeight); /* desktopHeight (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ - stream_write_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ - stream_write_UINT16(s, 1); /* bitmapCompressionFlag (2 bytes) */ - stream_write_BYTE(s, 0); /* highColorFlags (1 byte) */ - stream_write_BYTE(s, drawingFlags); /* drawingFlags (1 byte) */ - stream_write_UINT16(s, 1); /* multipleRectangleSupport (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsB (2 bytes) */ + Stream_Write_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ + Stream_Write_UINT16(s, 1); /* receive1BitPerPixel (2 bytes) */ + Stream_Write_UINT16(s, 1); /* receive4BitsPerPixel (2 bytes) */ + Stream_Write_UINT16(s, 1); /* receive8BitsPerPixel (2 bytes) */ + Stream_Write_UINT16(s, settings->DesktopWidth); /* desktopWidth (2 bytes) */ + Stream_Write_UINT16(s, settings->DesktopHeight); /* desktopHeight (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ + Stream_Write_UINT16(s, 1); /* bitmapCompressionFlag (2 bytes) */ + Stream_Write_UINT8(s, 0); /* highColorFlags (1 byte) */ + Stream_Write_UINT8(s, drawingFlags); /* drawingFlags (1 byte) */ + Stream_Write_UINT16(s, 1); /* multipleRectangleSupport (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsB (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP); } @@ -399,19 +399,19 @@ BOOL rdp_print_bitmap_capability_set(wStream* s, UINT16 length) if (length < 28) return FALSE; - stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ - stream_read_UINT16(s, receive1BitPerPixel); /* receive1BitPerPixel (2 bytes) */ - stream_read_UINT16(s, receive4BitsPerPixel); /* receive4BitsPerPixel (2 bytes) */ - stream_read_UINT16(s, receive8BitsPerPixel); /* receive8BitsPerPixel (2 bytes) */ - stream_read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */ - stream_read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */ - stream_read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ - stream_read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ - stream_read_UINT16(s, bitmapCompressionFlag); /* bitmapCompressionFlag (2 bytes) */ - stream_read_BYTE(s, highColorFlags); /* highColorFlags (1 byte) */ - stream_read_BYTE(s, drawingFlags); /* drawingFlags (1 byte) */ - stream_read_UINT16(s, multipleRectangleSupport); /* multipleRectangleSupport (2 bytes) */ - stream_read_UINT16(s, pad2OctetsB); /* pad2OctetsB (2 bytes) */ + Stream_Read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ + Stream_Read_UINT16(s, receive1BitPerPixel); /* receive1BitPerPixel (2 bytes) */ + Stream_Read_UINT16(s, receive4BitsPerPixel); /* receive4BitsPerPixel (2 bytes) */ + Stream_Read_UINT16(s, receive8BitsPerPixel); /* receive8BitsPerPixel (2 bytes) */ + Stream_Read_UINT16(s, desktopWidth); /* desktopWidth (2 bytes) */ + Stream_Read_UINT16(s, desktopHeight); /* desktopHeight (2 bytes) */ + Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ + Stream_Read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ + Stream_Read_UINT16(s, bitmapCompressionFlag); /* bitmapCompressionFlag (2 bytes) */ + Stream_Read_UINT8(s, highColorFlags); /* highColorFlags (1 byte) */ + Stream_Read_UINT8(s, drawingFlags); /* drawingFlags (1 byte) */ + Stream_Read_UINT16(s, multipleRectangleSupport); /* multipleRectangleSupport (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsB); /* pad2OctetsB (2 bytes) */ fprintf(stderr, "\tpreferredBitsPerPixel: 0x%04X\n", preferredBitsPerPixel); fprintf(stderr, "\treceive1BitPerPixel: 0x%04X\n", receive1BitPerPixel); @@ -455,10 +455,10 @@ BOOL rdp_read_order_capability_set(wStream* s, UINT16 length, rdpSettings* setti Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ Stream_Seek_UINT16(s); /* maximumOrderLevel (2 bytes) */ Stream_Seek_UINT16(s); /* numberFonts (2 bytes) */ - stream_read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ - stream_read(s, orderSupport, 32); /* orderSupport (32 bytes) */ + Stream_Read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ + Stream_Read(s, orderSupport, 32); /* orderSupport (32 bytes) */ Stream_Seek_UINT16(s); /* textFlags (2 bytes) */ - stream_read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ + Stream_Read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ Stream_Seek_UINT32(s); /* pad4OctetsB (4 bytes) */ Stream_Seek_UINT32(s); /* desktopSaveSize (4 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsC (2 bytes) */ @@ -509,23 +509,23 @@ void rdp_write_order_capability_set(wStream* s, rdpSettings* settings) orderFlags |= ORDER_FLAGS_EXTRA_SUPPORT; } - stream_write_zero(s, 16); /* terminalDescriptor (16 bytes) */ - stream_write_UINT32(s, 0); /* pad4OctetsA (4 bytes) */ - stream_write_UINT16(s, 1); /* desktopSaveXGranularity (2 bytes) */ - stream_write_UINT16(s, 20); /* desktopSaveYGranularity (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ - stream_write_UINT16(s, 1); /* maximumOrderLevel (2 bytes) */ - stream_write_UINT16(s, 0); /* numberFonts (2 bytes) */ - stream_write_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ - stream_write(s, settings->OrderSupport, 32); /* orderSupport (32 bytes) */ - stream_write_UINT16(s, 0); /* textFlags (2 bytes) */ - stream_write_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ - stream_write_UINT32(s, 0); /* pad4OctetsB (4 bytes) */ - stream_write_UINT32(s, 230400); /* desktopSaveSize (4 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsC (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsD (2 bytes) */ - stream_write_UINT16(s, 0); /* textANSICodePage (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsE (2 bytes) */ + Stream_Write_zero(s, 16); /* terminalDescriptor (16 bytes) */ + Stream_Write_UINT32(s, 0); /* pad4OctetsA (4 bytes) */ + Stream_Write_UINT16(s, 1); /* desktopSaveXGranularity (2 bytes) */ + Stream_Write_UINT16(s, 20); /* desktopSaveYGranularity (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ + Stream_Write_UINT16(s, 1); /* maximumOrderLevel (2 bytes) */ + Stream_Write_UINT16(s, 0); /* numberFonts (2 bytes) */ + Stream_Write_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ + Stream_Write(s, settings->OrderSupport, 32); /* orderSupport (32 bytes) */ + Stream_Write_UINT16(s, 0); /* textFlags (2 bytes) */ + Stream_Write_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ + Stream_Write_UINT32(s, 0); /* pad4OctetsB (4 bytes) */ + Stream_Write_UINT32(s, 230400); /* desktopSaveSize (4 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsC (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsD (2 bytes) */ + Stream_Write_UINT16(s, 0); /* textANSICodePage (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsE (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_ORDER); } @@ -555,23 +555,23 @@ BOOL rdp_print_order_capability_set(wStream* s, UINT16 length) if (length < 88) return FALSE; - stream_read(s, terminalDescriptor, 16); /* terminalDescriptor (16 bytes) */ - stream_read_UINT32(s, pad4OctetsA); /* pad4OctetsA (4 bytes) */ - stream_read_UINT16(s, desktopSaveXGranularity); /* desktopSaveXGranularity (2 bytes) */ - stream_read_UINT16(s, desktopSaveYGranularity); /* desktopSaveYGranularity (2 bytes) */ - stream_read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ - stream_read_UINT16(s, maximumOrderLevel); /* maximumOrderLevel (2 bytes) */ - stream_read_UINT16(s, numberFonts); /* numberFonts (2 bytes) */ - stream_read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ - stream_read(s, orderSupport, 32); /* orderSupport (32 bytes) */ - stream_read_UINT16(s, textFlags); /* textFlags (2 bytes) */ - stream_read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ - stream_read_UINT32(s, pad4OctetsB); /* pad4OctetsB (4 bytes) */ - stream_read_UINT32(s, desktopSaveSize); /* desktopSaveSize (4 bytes) */ - stream_read_UINT16(s, pad2OctetsC); /* pad2OctetsC (2 bytes) */ - stream_read_UINT16(s, pad2OctetsD); /* pad2OctetsD (2 bytes) */ - stream_read_UINT16(s, textANSICodePage); /* textANSICodePage (2 bytes) */ - stream_read_UINT16(s, pad2OctetsE); /* pad2OctetsE (2 bytes) */ + Stream_Read(s, terminalDescriptor, 16); /* terminalDescriptor (16 bytes) */ + Stream_Read_UINT32(s, pad4OctetsA); /* pad4OctetsA (4 bytes) */ + Stream_Read_UINT16(s, desktopSaveXGranularity); /* desktopSaveXGranularity (2 bytes) */ + Stream_Read_UINT16(s, desktopSaveYGranularity); /* desktopSaveYGranularity (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ + Stream_Read_UINT16(s, maximumOrderLevel); /* maximumOrderLevel (2 bytes) */ + Stream_Read_UINT16(s, numberFonts); /* numberFonts (2 bytes) */ + Stream_Read_UINT16(s, orderFlags); /* orderFlags (2 bytes) */ + Stream_Read(s, orderSupport, 32); /* orderSupport (32 bytes) */ + Stream_Read_UINT16(s, textFlags); /* textFlags (2 bytes) */ + Stream_Read_UINT16(s, orderSupportExFlags); /* orderSupportExFlags (2 bytes) */ + Stream_Read_UINT32(s, pad4OctetsB); /* pad4OctetsB (4 bytes) */ + Stream_Read_UINT32(s, desktopSaveSize); /* desktopSaveSize (4 bytes) */ + Stream_Read_UINT16(s, pad2OctetsC); /* pad2OctetsC (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsD); /* pad2OctetsD (2 bytes) */ + Stream_Read_UINT16(s, textANSICodePage); /* textANSICodePage (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsE); /* pad2OctetsE (2 bytes) */ fprintf(stderr, "\tpad4OctetsA: 0x%08X\n", pad4OctetsA); fprintf(stderr, "\tdesktopSaveXGranularity: 0x%04X\n", desktopSaveXGranularity); @@ -673,24 +673,24 @@ void rdp_write_bitmap_cache_capability_set(wStream* s, rdpSettings* settings) bpp = (settings->ColorDepth + 7) / 8; - stream_write_UINT32(s, 0); /* pad1 (4 bytes) */ - stream_write_UINT32(s, 0); /* pad2 (4 bytes) */ - stream_write_UINT32(s, 0); /* pad3 (4 bytes) */ - stream_write_UINT32(s, 0); /* pad4 (4 bytes) */ - stream_write_UINT32(s, 0); /* pad5 (4 bytes) */ - stream_write_UINT32(s, 0); /* pad6 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad1 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad2 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad3 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad4 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad5 (4 bytes) */ + Stream_Write_UINT32(s, 0); /* pad6 (4 bytes) */ size = bpp * 256; - stream_write_UINT16(s, 200); /* Cache0Entries (2 bytes) */ - stream_write_UINT16(s, size); /* Cache0MaximumCellSize (2 bytes) */ + Stream_Write_UINT16(s, 200); /* Cache0Entries (2 bytes) */ + Stream_Write_UINT16(s, size); /* Cache0MaximumCellSize (2 bytes) */ size = bpp * 1024; - stream_write_UINT16(s, 600); /* Cache1Entries (2 bytes) */ - stream_write_UINT16(s, size); /* Cache1MaximumCellSize (2 bytes) */ + Stream_Write_UINT16(s, 600); /* Cache1Entries (2 bytes) */ + Stream_Write_UINT16(s, size); /* Cache1MaximumCellSize (2 bytes) */ size = bpp * 4096; - stream_write_UINT16(s, 1000); /* Cache2Entries (2 bytes) */ - stream_write_UINT16(s, size); /* Cache2MaximumCellSize (2 bytes) */ + Stream_Write_UINT16(s, 1000); /* Cache2Entries (2 bytes) */ + Stream_Write_UINT16(s, size); /* Cache2MaximumCellSize (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE); } @@ -711,18 +711,18 @@ BOOL rdp_print_bitmap_cache_capability_set(wStream* s, UINT16 length) if (length < 40) return FALSE; - stream_read_UINT32(s, pad1); /* pad1 (4 bytes) */ - stream_read_UINT32(s, pad2); /* pad2 (4 bytes) */ - stream_read_UINT32(s, pad3); /* pad3 (4 bytes) */ - stream_read_UINT32(s, pad4); /* pad4 (4 bytes) */ - stream_read_UINT32(s, pad5); /* pad5 (4 bytes) */ - stream_read_UINT32(s, pad6); /* pad6 (4 bytes) */ - stream_read_UINT16(s, Cache0Entries); /* Cache0Entries (2 bytes) */ - stream_read_UINT16(s, Cache0MaximumCellSize); /* Cache0MaximumCellSize (2 bytes) */ - stream_read_UINT16(s, Cache1Entries); /* Cache1Entries (2 bytes) */ - stream_read_UINT16(s, Cache1MaximumCellSize); /* Cache1MaximumCellSize (2 bytes) */ - stream_read_UINT16(s, Cache2Entries); /* Cache2Entries (2 bytes) */ - stream_read_UINT16(s, Cache2MaximumCellSize); /* Cache2MaximumCellSize (2 bytes) */ + Stream_Read_UINT32(s, pad1); /* pad1 (4 bytes) */ + Stream_Read_UINT32(s, pad2); /* pad2 (4 bytes) */ + Stream_Read_UINT32(s, pad3); /* pad3 (4 bytes) */ + Stream_Read_UINT32(s, pad4); /* pad4 (4 bytes) */ + Stream_Read_UINT32(s, pad5); /* pad5 (4 bytes) */ + Stream_Read_UINT32(s, pad6); /* pad6 (4 bytes) */ + Stream_Read_UINT16(s, Cache0Entries); /* Cache0Entries (2 bytes) */ + Stream_Read_UINT16(s, Cache0MaximumCellSize); /* Cache0MaximumCellSize (2 bytes) */ + Stream_Read_UINT16(s, Cache1Entries); /* Cache1Entries (2 bytes) */ + Stream_Read_UINT16(s, Cache1MaximumCellSize); /* Cache1MaximumCellSize (2 bytes) */ + Stream_Read_UINT16(s, Cache2Entries); /* Cache2Entries (2 bytes) */ + Stream_Read_UINT16(s, Cache2MaximumCellSize); /* Cache2MaximumCellSize (2 bytes) */ fprintf(stderr, "\tpad1: 0x%08X\n", pad1); fprintf(stderr, "\tpad2: 0x%08X\n", pad2); @@ -774,10 +774,10 @@ void rdp_write_control_capability_set(wStream* s, rdpSettings* settings) header = rdp_capability_set_start(s); - stream_write_UINT16(s, 0); /* controlFlags (2 bytes) */ - stream_write_UINT16(s, 0); /* remoteDetachFlag (2 bytes) */ - stream_write_UINT16(s, 2); /* controlInterest (2 bytes) */ - stream_write_UINT16(s, 2); /* detachInterest (2 bytes) */ + Stream_Write_UINT16(s, 0); /* controlFlags (2 bytes) */ + Stream_Write_UINT16(s, 0); /* remoteDetachFlag (2 bytes) */ + Stream_Write_UINT16(s, 2); /* controlInterest (2 bytes) */ + Stream_Write_UINT16(s, 2); /* detachInterest (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_CONTROL); } @@ -794,10 +794,10 @@ BOOL rdp_print_control_capability_set(wStream* s, UINT16 length) if (length < 12) return FALSE; - stream_read_UINT16(s, controlFlags); /* controlFlags (2 bytes) */ - stream_read_UINT16(s, remoteDetachFlag); /* remoteDetachFlag (2 bytes) */ - stream_read_UINT16(s, controlInterest); /* controlInterest (2 bytes) */ - stream_read_UINT16(s, detachInterest); /* detachInterest (2 bytes) */ + Stream_Read_UINT16(s, controlFlags); /* controlFlags (2 bytes) */ + Stream_Read_UINT16(s, remoteDetachFlag); /* remoteDetachFlag (2 bytes) */ + Stream_Read_UINT16(s, controlInterest); /* controlInterest (2 bytes) */ + Stream_Read_UINT16(s, detachInterest); /* detachInterest (2 bytes) */ fprintf(stderr, "\tcontrolFlags: 0x%04X\n", controlFlags); fprintf(stderr, "\tremoteDetachFlag: 0x%04X\n", remoteDetachFlag); @@ -841,10 +841,10 @@ void rdp_write_window_activation_capability_set(wStream* s, rdpSettings* setting header = rdp_capability_set_start(s); - stream_write_UINT16(s, 0); /* helpKeyFlag (2 bytes) */ - stream_write_UINT16(s, 0); /* helpKeyIndexFlag (2 bytes) */ - stream_write_UINT16(s, 0); /* helpExtendedKeyFlag (2 bytes) */ - stream_write_UINT16(s, 0); /* windowManagerKeyFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* helpKeyFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* helpKeyIndexFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* helpExtendedKeyFlag (2 bytes) */ + Stream_Write_UINT16(s, 0); /* windowManagerKeyFlag (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_ACTIVATION); } @@ -861,10 +861,10 @@ BOOL rdp_print_window_activation_capability_set(wStream* s, UINT16 length) if (length < 12) return FALSE; - stream_read_UINT16(s, helpKeyFlag); /* helpKeyFlag (2 bytes) */ - stream_read_UINT16(s, helpKeyIndexFlag); /* helpKeyIndexFlag (2 bytes) */ - stream_read_UINT16(s, helpExtendedKeyFlag); /* helpExtendedKeyFlag (2 bytes) */ - stream_read_UINT16(s, windowManagerKeyFlag); /* windowManagerKeyFlag (2 bytes) */ + Stream_Read_UINT16(s, helpKeyFlag); /* helpKeyFlag (2 bytes) */ + Stream_Read_UINT16(s, helpKeyIndexFlag); /* helpKeyIndexFlag (2 bytes) */ + Stream_Read_UINT16(s, helpExtendedKeyFlag); /* helpExtendedKeyFlag (2 bytes) */ + Stream_Read_UINT16(s, windowManagerKeyFlag); /* windowManagerKeyFlag (2 bytes) */ fprintf(stderr, "\thelpKeyFlag: 0x%04X\n", helpKeyFlag); fprintf(stderr, "\thelpKeyIndexFlag: 0x%04X\n", helpKeyIndexFlag); @@ -891,9 +891,9 @@ BOOL rdp_read_pointer_capability_set(wStream* s, UINT16 length, rdpSettings* set if (length < 10) return FALSE; - stream_read_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ - stream_read_UINT16(s, colorPointerCacheSize); /* colorPointerCacheSize (2 bytes) */ - stream_read_UINT16(s, pointerCacheSize); /* pointerCacheSize (2 bytes) */ + Stream_Read_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ + Stream_Read_UINT16(s, colorPointerCacheSize); /* colorPointerCacheSize (2 bytes) */ + Stream_Read_UINT16(s, pointerCacheSize); /* pointerCacheSize (2 bytes) */ if (colorPointerFlag == FALSE) settings->ColorPointerFlag = FALSE; @@ -921,12 +921,12 @@ void rdp_write_pointer_capability_set(wStream* s, rdpSettings* settings) colorPointerFlag = (settings->ColorPointerFlag) ? 1 : 0; - stream_write_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ - stream_write_UINT16(s, settings->PointerCacheSize); /* colorPointerCacheSize (2 bytes) */ + Stream_Write_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ + Stream_Write_UINT16(s, settings->PointerCacheSize); /* colorPointerCacheSize (2 bytes) */ if (settings->LargePointerFlag) { - stream_write_UINT16(s, settings->PointerCacheSize); /* pointerCacheSize (2 bytes) */ + Stream_Write_UINT16(s, settings->PointerCacheSize); /* pointerCacheSize (2 bytes) */ } rdp_capability_set_finish(s, header, CAPSET_TYPE_POINTER); @@ -943,9 +943,9 @@ BOOL rdp_print_pointer_capability_set(wStream* s, UINT16 length) fprintf(stderr, "PointerCapabilitySet (length %d):\n", length); - stream_read_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ - stream_read_UINT16(s, colorPointerCacheSize); /* colorPointerCacheSize (2 bytes) */ - stream_read_UINT16(s, pointerCacheSize); /* pointerCacheSize (2 bytes) */ + Stream_Read_UINT16(s, colorPointerFlag); /* colorPointerFlag (2 bytes) */ + Stream_Read_UINT16(s, colorPointerCacheSize); /* colorPointerCacheSize (2 bytes) */ + Stream_Read_UINT16(s, pointerCacheSize); /* pointerCacheSize (2 bytes) */ fprintf(stderr, "\tcolorPointerFlag: 0x%04X\n", colorPointerFlag); fprintf(stderr, "\tcolorPointerCacheSize: 0x%04X\n", colorPointerCacheSize); @@ -989,8 +989,8 @@ void rdp_write_share_capability_set(wStream* s, rdpSettings* settings) nodeId = (settings->ServerMode) ? 0x03EA : 0; - stream_write_UINT16(s, nodeId); /* nodeId (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, nodeId); /* nodeId (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_SHARE); } @@ -1005,8 +1005,8 @@ BOOL rdp_print_share_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT16(s, nodeId); /* nodeId (2 bytes) */ - stream_read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ + Stream_Read_UINT16(s, nodeId); /* nodeId (2 bytes) */ + Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ fprintf(stderr, "\tnodeId: 0x%04X\n", nodeId); fprintf(stderr, "\tpad2Octets: 0x%04X\n", pad2Octets); @@ -1046,8 +1046,8 @@ void rdp_write_color_cache_capability_set(wStream* s, rdpSettings* settings) header = rdp_capability_set_start(s); - stream_write_UINT16(s, 6); /* colorTableCacheSize (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, 6); /* colorTableCacheSize (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_COLOR_CACHE); } @@ -1062,8 +1062,8 @@ BOOL rdp_print_color_cache_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT16(s, colorTableCacheSize); /* colorTableCacheSize (2 bytes) */ - stream_read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ + Stream_Read_UINT16(s, colorTableCacheSize); /* colorTableCacheSize (2 bytes) */ + Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ fprintf(stderr, "\tcolorTableCacheSize: 0x%04X\n", colorTableCacheSize); fprintf(stderr, "\tpad2Octets: 0x%04X\n", pad2Octets); @@ -1086,7 +1086,7 @@ BOOL rdp_read_sound_capability_set(wStream* s, UINT16 length, rdpSettings* setti if (length < 8) return FALSE; - stream_read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ + Stream_Read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ settings->SoundBeepsEnabled = (soundFlags & SOUND_BEEPS_FLAG) ? TRUE : FALSE; @@ -1110,8 +1110,8 @@ void rdp_write_sound_capability_set(wStream* s, rdpSettings* settings) soundFlags = (settings->SoundBeepsEnabled) ? SOUND_BEEPS_FLAG : 0; - stream_write_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ + Stream_Write_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_SOUND); } @@ -1126,8 +1126,8 @@ BOOL rdp_print_sound_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ - stream_read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ + Stream_Read_UINT16(s, soundFlags); /* soundFlags (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ fprintf(stderr, "\tsoundFlags: 0x%04X\n", soundFlags); fprintf(stderr, "\tpad2OctetsA: 0x%04X\n", pad2OctetsA); @@ -1150,15 +1150,15 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti if (length < 88) return FALSE; - stream_read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ + Stream_Read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ if (settings->ServerMode) { - stream_read_UINT32(s, settings->KeyboardLayout); /* keyboardLayout (4 bytes) */ - stream_read_UINT32(s, settings->KeyboardType); /* keyboardType (4 bytes) */ - stream_read_UINT32(s, settings->KeyboardSubType); /* keyboardSubType (4 bytes) */ - stream_read_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ + Stream_Read_UINT32(s, settings->KeyboardLayout); /* keyboardLayout (4 bytes) */ + Stream_Read_UINT32(s, settings->KeyboardType); /* keyboardType (4 bytes) */ + Stream_Read_UINT32(s, settings->KeyboardSubType); /* keyboardSubType (4 bytes) */ + Stream_Read_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ } else { @@ -1211,13 +1211,13 @@ void rdp_write_input_capability_set(wStream* s, rdpSettings* settings) inputFlags |= INPUT_FLAG_FASTPATH_INPUT2; } - stream_write_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ - stream_write_UINT32(s, settings->KeyboardLayout); /* keyboardLayout (4 bytes) */ - stream_write_UINT32(s, settings->KeyboardType); /* keyboardType (4 bytes) */ - stream_write_UINT32(s, settings->KeyboardSubType); /* keyboardSubType (4 bytes) */ - stream_write_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ - stream_write_zero(s, 64); /* imeFileName (64 bytes) */ + Stream_Write_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2OctetsA (2 bytes) */ + Stream_Write_UINT32(s, settings->KeyboardLayout); /* keyboardLayout (4 bytes) */ + Stream_Write_UINT32(s, settings->KeyboardType); /* keyboardType (4 bytes) */ + Stream_Write_UINT32(s, settings->KeyboardSubType); /* keyboardSubType (4 bytes) */ + Stream_Write_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ + Stream_Write_zero(s, 64); /* imeFileName (64 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_INPUT); } @@ -1236,12 +1236,12 @@ BOOL rdp_print_input_capability_set(wStream* s, UINT16 length) if (length < 88) return FALSE; - stream_read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ - stream_read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ - stream_read_UINT32(s, keyboardLayout); /* keyboardLayout (4 bytes) */ - stream_read_UINT32(s, keyboardType); /* keyboardType (4 bytes) */ - stream_read_UINT32(s, keyboardSubType); /* keyboardSubType (4 bytes) */ - stream_read_UINT32(s, keyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ + Stream_Read_UINT16(s, inputFlags); /* inputFlags (2 bytes) */ + Stream_Read_UINT16(s, pad2OctetsA); /* pad2OctetsA (2 bytes) */ + Stream_Read_UINT32(s, keyboardLayout); /* keyboardLayout (4 bytes) */ + Stream_Read_UINT32(s, keyboardType); /* keyboardType (4 bytes) */ + Stream_Read_UINT32(s, keyboardSubType); /* keyboardSubType (4 bytes) */ + Stream_Read_UINT32(s, keyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ Stream_Seek(s, 64); /* imeFileName (64 bytes) */ fprintf(stderr, "\tinputFlags: 0x%04X\n", inputFlags); @@ -1286,8 +1286,8 @@ void rdp_write_font_capability_set(wStream* s, rdpSettings* settings) header = rdp_capability_set_start(s); - stream_write_UINT16(s, FONTSUPPORT_FONTLIST); /* fontSupportFlags (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, FONTSUPPORT_FONTLIST); /* fontSupportFlags (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_FONT); } @@ -1300,10 +1300,10 @@ BOOL rdp_print_font_capability_set(wStream* s, UINT16 length) fprintf(stderr, "FontCapabilitySet (length %d):\n", length); if (length > 4) - stream_read_UINT16(s, fontSupportFlags); /* fontSupportFlags (2 bytes) */ + Stream_Read_UINT16(s, fontSupportFlags); /* fontSupportFlags (2 bytes) */ if (length > 6) - stream_read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ + Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ fprintf(stderr, "\tfontSupportFlags: 0x%04X\n", fontSupportFlags); fprintf(stderr, "\tpad2Octets: 0x%04X\n", pad2Octets); @@ -1342,7 +1342,7 @@ void rdp_write_brush_capability_set(wStream* s, rdpSettings* settings) header = rdp_capability_set_start(s); - stream_write_UINT32(s, BRUSH_COLOR_FULL); /* brushSupportLevel (4 bytes) */ + Stream_Write_UINT32(s, BRUSH_COLOR_FULL); /* brushSupportLevel (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BRUSH); } @@ -1356,7 +1356,7 @@ BOOL rdp_print_brush_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT32(s, brushSupportLevel); /* brushSupportLevel (4 bytes) */ + Stream_Read_UINT32(s, brushSupportLevel); /* brushSupportLevel (4 bytes) */ fprintf(stderr, "\tbrushSupportLevel: 0x%08X\n", brushSupportLevel); @@ -1370,8 +1370,8 @@ BOOL rdp_print_brush_capability_set(wStream* s, UINT16 length) */ void rdp_read_cache_definition(wStream* s, GLYPH_CACHE_DEFINITION* cache_definition) { - stream_read_UINT16(s, cache_definition->cacheEntries); /* cacheEntries (2 bytes) */ - stream_read_UINT16(s, cache_definition->cacheMaximumCellSize); /* cacheMaximumCellSize (2 bytes) */ + Stream_Read_UINT16(s, cache_definition->cacheEntries); /* cacheEntries (2 bytes) */ + Stream_Read_UINT16(s, cache_definition->cacheMaximumCellSize); /* cacheMaximumCellSize (2 bytes) */ } /** @@ -1381,8 +1381,8 @@ void rdp_read_cache_definition(wStream* s, GLYPH_CACHE_DEFINITION* cache_definit */ void rdp_write_cache_definition(wStream* s, GLYPH_CACHE_DEFINITION* cache_definition) { - stream_write_UINT16(s, cache_definition->cacheEntries); /* cacheEntries (2 bytes) */ - stream_write_UINT16(s, cache_definition->cacheMaximumCellSize); /* cacheMaximumCellSize (2 bytes) */ + Stream_Write_UINT16(s, cache_definition->cacheEntries); /* cacheEntries (2 bytes) */ + Stream_Write_UINT16(s, cache_definition->cacheMaximumCellSize); /* cacheMaximumCellSize (2 bytes) */ } /** @@ -1402,7 +1402,7 @@ BOOL rdp_read_glyph_cache_capability_set(wStream* s, UINT16 length, rdpSettings* Stream_Seek(s, 40); /* glyphCache (40 bytes) */ Stream_Seek_UINT32(s); /* fragCache (4 bytes) */ - stream_read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ + Stream_Read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ settings->GlyphSupportLevel = glyphSupportLevel; @@ -1436,9 +1436,9 @@ void rdp_write_glyph_cache_capability_set(wStream* s, rdpSettings* settings) rdp_write_cache_definition(s, &(settings->GlyphCache[9])); /* glyphCache9 (4 bytes) */ rdp_write_cache_definition(s, settings->FragCache); /* fragCache (4 bytes) */ - stream_write_UINT16(s, settings->GlyphSupportLevel); /* glyphSupportLevel (2 bytes) */ + Stream_Write_UINT16(s, settings->GlyphSupportLevel); /* glyphSupportLevel (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_GLYPH_CACHE); } @@ -1468,8 +1468,8 @@ BOOL rdp_print_glyph_cache_capability_set(wStream* s, UINT16 length) rdp_read_cache_definition(s, &glyphCache[9]); /* glyphCache9 (4 bytes) */ rdp_read_cache_definition(s, &fragCache); /* fragCache (4 bytes) */ - stream_read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ - stream_read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ + Stream_Read_UINT16(s, glyphSupportLevel); /* glyphSupportLevel (2 bytes) */ + Stream_Read_UINT16(s, pad2Octets); /* pad2Octets (2 bytes) */ fprintf(stderr, "\tglyphCache0: Entries: %d MaximumCellSize: %d\n", glyphCache[0].cacheEntries, glyphCache[0].cacheMaximumCellSize); fprintf(stderr, "\tglyphCache1: Entries: %d MaximumCellSize: %d\n", glyphCache[1].cacheEntries, glyphCache[1].cacheMaximumCellSize); @@ -1503,9 +1503,9 @@ BOOL rdp_read_offscreen_bitmap_cache_capability_set(wStream* s, UINT16 length, r if (length < 12) return FALSE; - stream_read_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ - stream_read_UINT16(s, settings->OffscreenCacheSize); /* offscreenCacheSize (2 bytes) */ - stream_read_UINT16(s, settings->OffscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ + Stream_Read_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ + Stream_Read_UINT16(s, settings->OffscreenCacheSize); /* offscreenCacheSize (2 bytes) */ + Stream_Read_UINT16(s, settings->OffscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ if (offscreenSupportLevel & TRUE) settings->OffscreenSupportLevel = TRUE; @@ -1530,9 +1530,9 @@ void rdp_write_offscreen_bitmap_cache_capability_set(wStream* s, rdpSettings* se if (settings->OffscreenSupportLevel) offscreenSupportLevel = TRUE; - stream_write_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ - stream_write_UINT16(s, settings->OffscreenCacheSize); /* offscreenCacheSize (2 bytes) */ - stream_write_UINT16(s, settings->OffscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ + Stream_Write_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ + Stream_Write_UINT16(s, settings->OffscreenCacheSize); /* offscreenCacheSize (2 bytes) */ + Stream_Write_UINT16(s, settings->OffscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_OFFSCREEN_CACHE); } @@ -1548,9 +1548,9 @@ BOOL rdp_print_offscreen_bitmap_cache_capability_set(wStream* s, UINT16 length) if (length < 12) return FALSE; - stream_read_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ - stream_read_UINT16(s, offscreenCacheSize); /* offscreenCacheSize (2 bytes) */ - stream_read_UINT16(s, offscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ + Stream_Read_UINT32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ + Stream_Read_UINT16(s, offscreenCacheSize); /* offscreenCacheSize (2 bytes) */ + Stream_Read_UINT16(s, offscreenCacheEntries); /* offscreenCacheEntries (2 bytes) */ fprintf(stderr, "\toffscreenSupportLevel: 0x%08X\n", offscreenSupportLevel); fprintf(stderr, "\toffscreenCacheSize: 0x%04X\n", offscreenCacheSize); @@ -1574,7 +1574,7 @@ BOOL rdp_read_bitmap_cache_host_support_capability_set(wStream* s, UINT16 length if (length < 8) return FALSE; - stream_read_BYTE(s, cacheVersion); /* cacheVersion (1 byte) */ + Stream_Read_UINT8(s, cacheVersion); /* cacheVersion (1 byte) */ Stream_Seek_BYTE(s); /* pad1 (1 byte) */ Stream_Seek_UINT16(s); /* pad2 (2 bytes) */ @@ -1597,9 +1597,9 @@ void rdp_write_bitmap_cache_host_support_capability_set(wStream* s, rdpSettings* header = rdp_capability_set_start(s); - stream_write_BYTE(s, BITMAP_CACHE_V2); /* cacheVersion (1 byte) */ - stream_write_BYTE(s, 0); /* pad1 (1 byte) */ - stream_write_UINT16(s, 0); /* pad2 (2 bytes) */ + Stream_Write_UINT8(s, BITMAP_CACHE_V2); /* cacheVersion (1 byte) */ + Stream_Write_UINT8(s, 0); /* pad1 (1 byte) */ + Stream_Write_UINT16(s, 0); /* pad2 (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_HOST_SUPPORT); } @@ -1615,9 +1615,9 @@ BOOL rdp_print_bitmap_cache_host_support_capability_set(wStream* s, UINT16 lengt if (length < 8) return FALSE; - stream_read_BYTE(s, cacheVersion); /* cacheVersion (1 byte) */ - stream_read_BYTE(s, pad1); /* pad1 (1 byte) */ - stream_read_UINT16(s, pad2); /* pad2 (2 bytes) */ + Stream_Read_UINT8(s, cacheVersion); /* cacheVersion (1 byte) */ + Stream_Read_UINT8(s, pad1); /* pad1 (1 byte) */ + Stream_Read_UINT16(s, pad2); /* pad2 (2 bytes) */ fprintf(stderr, "\tcacheVersion: 0x%02X\n", cacheVersion); fprintf(stderr, "\tpad1: 0x%02X\n", pad1); @@ -1635,7 +1635,7 @@ void rdp_read_bitmap_cache_cell_info(wStream* s, BITMAP_CACHE_V2_CELL_INFO* cell * is used to indicate a persistent bitmap cache. */ - stream_read_UINT32(s, info); + Stream_Read_UINT32(s, info); cellInfo->numEntries = (info & 0x7FFFFFFF); cellInfo->persistent = (info & 0x80000000) ? 1 : 0; @@ -1651,7 +1651,7 @@ void rdp_write_bitmap_cache_cell_info(wStream* s, BITMAP_CACHE_V2_CELL_INFO* cel */ info = (cellInfo->numEntries | (cellInfo->persistent << 31)); - stream_write_UINT32(s, info); + Stream_Write_UINT32(s, info); } /** @@ -1699,15 +1699,15 @@ void rdp_write_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings) if (settings->BitmapCachePersistEnabled) cacheFlags |= PERSISTENT_KEYS_EXPECTED_FLAG; - stream_write_UINT16(s, cacheFlags); /* cacheFlags (2 bytes) */ - stream_write_BYTE(s, 0); /* pad2 (1 byte) */ - stream_write_BYTE(s, settings->BitmapCacheV2NumCells); /* numCellCaches (1 byte) */ + Stream_Write_UINT16(s, cacheFlags); /* cacheFlags (2 bytes) */ + Stream_Write_UINT8(s, 0); /* pad2 (1 byte) */ + Stream_Write_UINT8(s, settings->BitmapCacheV2NumCells); /* numCellCaches (1 byte) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[0]); /* bitmapCache0CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[1]); /* bitmapCache1CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[2]); /* bitmapCache2CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[3]); /* bitmapCache3CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[4]); /* bitmapCache4CellInfo (4 bytes) */ - stream_write_zero(s, 12); /* pad3 (12 bytes) */ + Stream_Write_zero(s, 12); /* pad3 (12 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_V2); } @@ -1724,9 +1724,9 @@ BOOL rdp_print_bitmap_cache_v2_capability_set(wStream* s, UINT16 length) if (length < 40) return FALSE; - stream_read_UINT16(s, cacheFlags); /* cacheFlags (2 bytes) */ - stream_read_BYTE(s, pad2); /* pad2 (1 byte) */ - stream_read_BYTE(s, numCellCaches); /* numCellCaches (1 byte) */ + Stream_Read_UINT16(s, cacheFlags); /* cacheFlags (2 bytes) */ + Stream_Read_UINT8(s, pad2); /* pad2 (1 byte) */ + Stream_Read_UINT8(s, numCellCaches); /* numCellCaches (1 byte) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[0]); /* bitmapCache0CellInfo (4 bytes) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[1]); /* bitmapCache1CellInfo (4 bytes) */ rdp_read_bitmap_cache_cell_info(s, &bitmapCacheV2CellInfo[2]); /* bitmapCache2CellInfo (4 bytes) */ @@ -1762,10 +1762,10 @@ BOOL rdp_read_virtual_channel_capability_set(wStream* s, UINT16 length, rdpSetti if (length < 8) return FALSE; - stream_read_UINT32(s, flags); /* flags (4 bytes) */ + Stream_Read_UINT32(s, flags); /* flags (4 bytes) */ if (length > 8) - stream_read_UINT32(s, VCChunkSize); /* VCChunkSize (4 bytes) */ + Stream_Read_UINT32(s, VCChunkSize); /* VCChunkSize (4 bytes) */ else VCChunkSize = 1600; @@ -1791,8 +1791,8 @@ void rdp_write_virtual_channel_capability_set(wStream* s, rdpSettings* settings) flags = VCCAPS_NO_COMPR; - stream_write_UINT32(s, flags); /* flags (4 bytes) */ - stream_write_UINT32(s, settings->VirtualChannelChunkSize); /* VCChunkSize (4 bytes) */ + Stream_Write_UINT32(s, flags); /* flags (4 bytes) */ + Stream_Write_UINT32(s, settings->VirtualChannelChunkSize); /* VCChunkSize (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_VIRTUAL_CHANNEL); } @@ -1807,10 +1807,10 @@ BOOL rdp_print_virtual_channel_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT32(s, flags); /* flags (4 bytes) */ + Stream_Read_UINT32(s, flags); /* flags (4 bytes) */ if (length > 8) - stream_read_UINT32(s, VCChunkSize); /* VCChunkSize (4 bytes) */ + Stream_Read_UINT32(s, VCChunkSize); /* VCChunkSize (4 bytes) */ else VCChunkSize = 1600; @@ -1835,9 +1835,9 @@ BOOL rdp_read_draw_nine_grid_cache_capability_set(wStream* s, UINT16 length, rdp if (length < 12) return FALSE; - stream_read_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ - stream_read_UINT16(s, settings->DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ - stream_read_UINT16(s, settings->DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ + Stream_Read_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ + Stream_Read_UINT16(s, settings->DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ + Stream_Read_UINT16(s, settings->DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ if ((drawNineGridSupportLevel & DRAW_NINEGRID_SUPPORTED) || (drawNineGridSupportLevel & DRAW_NINEGRID_SUPPORTED_V2)) @@ -1862,35 +1862,35 @@ void rdp_write_draw_nine_grid_cache_capability_set(wStream* s, rdpSettings* sett drawNineGridSupportLevel = (settings->DrawNineGridEnabled) ? DRAW_NINEGRID_SUPPORTED_V2 : DRAW_NINEGRID_NO_SUPPORT; - stream_write_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ - stream_write_UINT16(s, settings->DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ - stream_write_UINT16(s, settings->DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ + Stream_Write_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ + Stream_Write_UINT16(s, settings->DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ + Stream_Write_UINT16(s, settings->DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_DRAW_NINE_GRID_CACHE); } void rdp_write_gdiplus_cache_entries(wStream* s, UINT16 gce, UINT16 bce, UINT16 pce, UINT16 ice, UINT16 ace) { - stream_write_UINT16(s, gce); /* gdipGraphicsCacheEntries (2 bytes) */ - stream_write_UINT16(s, bce); /* gdipBrushCacheEntries (2 bytes) */ - stream_write_UINT16(s, pce); /* gdipPenCacheEntries (2 bytes) */ - stream_write_UINT16(s, ice); /* gdipImageCacheEntries (2 bytes) */ - stream_write_UINT16(s, ace); /* gdipImageAttributesCacheEntries (2 bytes) */ + Stream_Write_UINT16(s, gce); /* gdipGraphicsCacheEntries (2 bytes) */ + Stream_Write_UINT16(s, bce); /* gdipBrushCacheEntries (2 bytes) */ + Stream_Write_UINT16(s, pce); /* gdipPenCacheEntries (2 bytes) */ + Stream_Write_UINT16(s, ice); /* gdipImageCacheEntries (2 bytes) */ + Stream_Write_UINT16(s, ace); /* gdipImageAttributesCacheEntries (2 bytes) */ } void rdp_write_gdiplus_cache_chunk_size(wStream* s, UINT16 gccs, UINT16 obccs, UINT16 opccs, UINT16 oiaccs) { - stream_write_UINT16(s, gccs); /* gdipGraphicsCacheChunkSize (2 bytes) */ - stream_write_UINT16(s, obccs); /* gdipObjectBrushCacheChunkSize (2 bytes) */ - stream_write_UINT16(s, opccs); /* gdipObjectPenCacheChunkSize (2 bytes) */ - stream_write_UINT16(s, oiaccs); /* gdipObjectImageAttributesCacheChunkSize (2 bytes) */ + Stream_Write_UINT16(s, gccs); /* gdipGraphicsCacheChunkSize (2 bytes) */ + Stream_Write_UINT16(s, obccs); /* gdipObjectBrushCacheChunkSize (2 bytes) */ + Stream_Write_UINT16(s, opccs); /* gdipObjectPenCacheChunkSize (2 bytes) */ + Stream_Write_UINT16(s, oiaccs); /* gdipObjectImageAttributesCacheChunkSize (2 bytes) */ } void rdp_write_gdiplus_image_cache_properties(wStream* s, UINT16 oiccs, UINT16 oicts, UINT16 oicms) { - stream_write_UINT16(s, oiccs); /* gdipObjectImageCacheChunkSize (2 bytes) */ - stream_write_UINT16(s, oicts); /* gdipObjectImageCacheTotalSize (2 bytes) */ - stream_write_UINT16(s, oicms); /* gdipObjectImageCacheMaxSize (2 bytes) */ + Stream_Write_UINT16(s, oiccs); /* gdipObjectImageCacheChunkSize (2 bytes) */ + Stream_Write_UINT16(s, oicts); /* gdipObjectImageCacheTotalSize (2 bytes) */ + Stream_Write_UINT16(s, oicms); /* gdipObjectImageCacheMaxSize (2 bytes) */ } BOOL rdp_print_draw_nine_grid_cache_capability_set(wStream* s, UINT16 length) @@ -1904,9 +1904,9 @@ BOOL rdp_print_draw_nine_grid_cache_capability_set(wStream* s, UINT16 length) if (length < 12) return FALSE; - stream_read_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ - stream_read_UINT16(s, DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ - stream_read_UINT16(s, DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ + Stream_Read_UINT32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ + Stream_Read_UINT16(s, DrawNineGridCacheSize); /* drawNineGridCacheSize (2 bytes) */ + Stream_Read_UINT16(s, DrawNineGridCacheEntries); /* drawNineGridCacheEntries (2 bytes) */ return TRUE; } @@ -1927,9 +1927,9 @@ BOOL rdp_read_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length, rdpSe if (length < 40) return FALSE; - stream_read_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */ + Stream_Read_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */ Stream_Seek_UINT32(s); /* GdipVersion (4 bytes) */ - stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */ + Stream_Read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */ Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */ Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ @@ -1961,9 +1961,9 @@ void rdp_write_draw_gdiplus_cache_capability_set(wStream* s, rdpSettings* settin drawGDIPlusSupportLevel = (settings->DrawGdiPlusEnabled) ? DRAW_GDIPLUS_SUPPORTED : DRAW_GDIPLUS_DEFAULT; drawGdiplusCacheLevel = (settings->DrawGdiPlusEnabled) ? DRAW_GDIPLUS_CACHE_LEVEL_ONE : DRAW_GDIPLUS_CACHE_LEVEL_DEFAULT; - stream_write_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */ - stream_write_UINT32(s, 0); /* GdipVersion (4 bytes) */ - stream_write_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */ + Stream_Write_UINT32(s, drawGDIPlusSupportLevel); /* drawGDIPlusSupportLevel (4 bytes) */ + Stream_Write_UINT32(s, 0); /* GdipVersion (4 bytes) */ + Stream_Write_UINT32(s, drawGdiplusCacheLevel); /* drawGdiplusCacheLevel (4 bytes) */ rdp_write_gdiplus_cache_entries(s, 10, 5, 5, 10, 2); /* GdipCacheEntries (10 bytes) */ rdp_write_gdiplus_cache_chunk_size(s, 512, 2048, 1024, 64); /* GdipCacheChunkSize (8 bytes) */ rdp_write_gdiplus_image_cache_properties(s, 4096, 256, 128); /* GdipImageCacheProperties (6 bytes) */ @@ -1982,9 +1982,9 @@ BOOL rdp_print_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length) if (length < 40) return FALSE; - stream_read_UINT32(s, drawGdiPlusSupportLevel); /* drawGdiPlusSupportLevel (4 bytes) */ - stream_read_UINT32(s, GdipVersion); /* GdipVersion (4 bytes) */ - stream_read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiPlusCacheLevel (4 bytes) */ + Stream_Read_UINT32(s, drawGdiPlusSupportLevel); /* drawGdiPlusSupportLevel (4 bytes) */ + Stream_Read_UINT32(s, GdipVersion); /* GdipVersion (4 bytes) */ + Stream_Read_UINT32(s, drawGdiplusCacheLevel); /* drawGdiPlusCacheLevel (4 bytes) */ Stream_Seek(s, 10); /* GdipCacheEntries (10 bytes) */ Stream_Seek(s, 8); /* GdipCacheChunkSize (8 bytes) */ Stream_Seek(s, 6); /* GdipImageCacheProperties (6 bytes) */ @@ -2007,7 +2007,7 @@ BOOL rdp_read_remote_programs_capability_set(wStream* s, UINT16 length, rdpSetti if (length < 8) return FALSE; - stream_read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ + Stream_Read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ if ((railSupportLevel & RAIL_LEVEL_SUPPORTED) == 0) { @@ -2039,7 +2039,7 @@ void rdp_write_remote_programs_capability_set(wStream* s, rdpSettings* settings) if (settings->RemoteAppLanguageBarSupported) railSupportLevel |= RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED; - stream_write_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ + Stream_Write_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_RAIL); } @@ -2053,7 +2053,7 @@ BOOL rdp_print_remote_programs_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ + Stream_Read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */ fprintf(stderr, "\trailSupportLevel: 0x%08X\n", railSupportLevel); @@ -2096,9 +2096,9 @@ void rdp_write_window_list_capability_set(wStream* s, rdpSettings* settings) wndSupportLevel = WINDOW_LEVEL_SUPPORTED_EX; - stream_write_UINT32(s, wndSupportLevel); /* wndSupportLevel (4 bytes) */ - stream_write_BYTE(s, settings->RemoteAppNumIconCaches); /* numIconCaches (1 byte) */ - stream_write_UINT16(s, settings->RemoteAppNumIconCacheEntries); /* numIconCacheEntries (2 bytes) */ + Stream_Write_UINT32(s, wndSupportLevel); /* wndSupportLevel (4 bytes) */ + Stream_Write_UINT8(s, settings->RemoteAppNumIconCaches); /* numIconCaches (1 byte) */ + Stream_Write_UINT16(s, settings->RemoteAppNumIconCacheEntries); /* numIconCacheEntries (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_WINDOW); } @@ -2114,9 +2114,9 @@ BOOL rdp_print_window_list_capability_set(wStream* s, UINT16 length) if (length < 11) return FALSE; - stream_read_UINT32(s, wndSupportLevel); /* wndSupportLevel (4 bytes) */ - stream_read_BYTE(s, numIconCaches); /* numIconCaches (1 byte) */ - stream_read_UINT16(s, numIconCacheEntries); /* numIconCacheEntries (2 bytes) */ + Stream_Read_UINT32(s, wndSupportLevel); /* wndSupportLevel (4 bytes) */ + Stream_Read_UINT8(s, numIconCaches); /* numIconCaches (1 byte) */ + Stream_Read_UINT16(s, numIconCacheEntries); /* numIconCacheEntries (2 bytes) */ fprintf(stderr, "\twndSupportLevel: 0x%08X\n", wndSupportLevel); fprintf(stderr, "\tnumIconCaches: 0x%02X\n", numIconCaches); @@ -2159,7 +2159,7 @@ void rdp_write_desktop_composition_capability_set(wStream* s, rdpSettings* setti compDeskSupportLevel = (settings->AllowDesktopComposition) ? COMPDESK_SUPPORTED : COMPDESK_NOT_SUPPORTED; - stream_write_UINT16(s, compDeskSupportLevel); /* compDeskSupportLevel (2 bytes) */ + Stream_Write_UINT16(s, compDeskSupportLevel); /* compDeskSupportLevel (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_COMP_DESK); } @@ -2173,7 +2173,7 @@ BOOL rdp_print_desktop_composition_capability_set(wStream* s, UINT16 length) if (length < 6) return FALSE; - stream_read_UINT16(s, compDeskSupportLevel); /* compDeskSupportLevel (2 bytes) */ + Stream_Read_UINT16(s, compDeskSupportLevel); /* compDeskSupportLevel (2 bytes) */ fprintf(stderr, "\tcompDeskSupportLevel: 0x%04X\n", compDeskSupportLevel); @@ -2195,7 +2195,7 @@ BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdp if (length < 8) return FALSE; - stream_read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ + Stream_Read_UINT32(s, multifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ return TRUE; } @@ -2213,7 +2213,7 @@ void rdp_write_multifragment_update_capability_set(wStream* s, rdpSettings* sett header = rdp_capability_set_start(s); - stream_write_UINT32(s, settings->MultifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ + Stream_Write_UINT32(s, settings->MultifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_MULTI_FRAGMENT_UPDATE); } @@ -2227,7 +2227,7 @@ BOOL rdp_print_multifragment_update_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT32(s, maxRequestSize); /* maxRequestSize (4 bytes) */ + Stream_Read_UINT32(s, maxRequestSize); /* maxRequestSize (4 bytes) */ fprintf(stderr, "\tmaxRequestSize: 0x%04X\n", maxRequestSize); @@ -2268,7 +2268,7 @@ void rdp_write_large_pointer_capability_set(wStream* s, rdpSettings* settings) largePointerSupportFlags = (settings->LargePointerFlag) ? LARGE_POINTER_FLAG_96x96 : 0; - stream_write_UINT16(s, largePointerSupportFlags); /* largePointerSupportFlags (2 bytes) */ + Stream_Write_UINT16(s, largePointerSupportFlags); /* largePointerSupportFlags (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_LARGE_POINTER); } @@ -2282,7 +2282,7 @@ BOOL rdp_print_large_pointer_capability_set(wStream* s, UINT16 length) if (length < 6) return FALSE; - stream_read_UINT16(s, largePointerSupportFlags); /* largePointerSupportFlags (2 bytes) */ + Stream_Read_UINT16(s, largePointerSupportFlags); /* largePointerSupportFlags (2 bytes) */ fprintf(stderr, "\tlargePointerSupportFlags: 0x%04X\n", largePointerSupportFlags); @@ -2328,8 +2328,8 @@ void rdp_write_surface_commands_capability_set(wStream* s, rdpSettings* settings SURFCMDS_SET_SURFACE_BITS | SURFCMDS_STREAM_SURFACE_BITS; - stream_write_UINT32(s, cmdFlags); /* cmdFlags (4 bytes) */ - stream_write_UINT32(s, 0); /* reserved (4 bytes) */ + Stream_Write_UINT32(s, cmdFlags); /* cmdFlags (4 bytes) */ + Stream_Write_UINT32(s, 0); /* reserved (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_SURFACE_COMMANDS); } @@ -2344,8 +2344,8 @@ BOOL rdp_print_surface_commands_capability_set(wStream* s, UINT16 length) if (length < 12) return FALSE; - stream_read_UINT32(s, cmdFlags); /* cmdFlags (4 bytes) */ - stream_read_UINT32(s, reserved); /* reserved (4 bytes) */ + Stream_Read_UINT32(s, cmdFlags); /* cmdFlags (4 bytes) */ + Stream_Read_UINT32(s, reserved); /* reserved (4 bytes) */ fprintf(stderr, "\tcmdFlags: 0x%08X\n", cmdFlags); fprintf(stderr, "\treserved: 0x%08X\n", reserved); @@ -2357,7 +2357,7 @@ void rdp_read_bitmap_codec_guid(wStream* s, GUID* guid) { BYTE g[16]; - stream_read(s, g, 16); + Stream_Read(s, g, 16); guid->Data1 = (g[3] << 24) | (g[2] << 16) | (g[1] << 8) | g[0]; guid->Data2 = (g[5] << 8) | g[4]; @@ -2393,7 +2393,7 @@ void rdp_write_bitmap_codec_guid(wStream* s, GUID* guid) g[14] = guid->Data4[6]; g[15] = guid->Data4[7]; - stream_write(s, g, 16); + Stream_Write(s, g, 16); } void rdp_print_bitmap_codec_guid(GUID* guid) @@ -2441,7 +2441,7 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting if (length < 5) return FALSE; - stream_read_BYTE(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ + Stream_Read_UINT8(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ remainingLength = length - 5; if (settings->ServerMode) @@ -2462,12 +2462,12 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting { if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status)) { - stream_read_BYTE(s, settings->RemoteFxCodecId); + Stream_Read_UINT8(s, settings->RemoteFxCodecId); settings->RemoteFxCodec = TRUE; } else if (UuidEqual(&codecGuid, &CODEC_GUID_NSCODEC, &rpc_status)) { - stream_read_BYTE(s, settings->NSCodecId); + Stream_Read_UINT8(s, settings->NSCodecId); settings->NSCodec = TRUE; } else @@ -2480,7 +2480,7 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting Stream_Seek_BYTE(s); /* codecID (1 byte) */ } - stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ + Stream_Read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ remainingLength -= 19; if (remainingLength < codecPropertiesLength) @@ -2491,7 +2491,7 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status)) { Stream_Seek_UINT32(s); /* length */ - stream_read_UINT32(s, settings->RemoteFxCaptureFlags); /* captureFlags */ + Stream_Read_UINT32(s, settings->RemoteFxCaptureFlags); /* captureFlags */ Stream_Rewind(s, 8); if (settings->RemoteFxCaptureFlags & CARDP_CAPS_CAPTURE_NON_CAC) @@ -2523,41 +2523,41 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings captureFlags = settings->RemoteFxOnly ? 0 : CARDP_CAPS_CAPTURE_NON_CAC; codecMode = settings->RemoteFxCodecMode; - stream_write_UINT16(s, 49); /* codecPropertiesLength */ + Stream_Write_UINT16(s, 49); /* codecPropertiesLength */ /* TS_RFX_CLNT_CAPS_CONTAINER */ - stream_write_UINT32(s, 49); /* length */ - stream_write_UINT32(s, captureFlags); /* captureFlags */ - stream_write_UINT32(s, 37); /* capsLength */ + Stream_Write_UINT32(s, 49); /* length */ + Stream_Write_UINT32(s, captureFlags); /* captureFlags */ + Stream_Write_UINT32(s, 37); /* capsLength */ /* TS_RFX_CAPS */ - stream_write_UINT16(s, CBY_CAPS); /* blockType */ - stream_write_UINT32(s, 8); /* blockLen */ - stream_write_UINT16(s, 1); /* numCapsets */ + Stream_Write_UINT16(s, CBY_CAPS); /* blockType */ + Stream_Write_UINT32(s, 8); /* blockLen */ + Stream_Write_UINT16(s, 1); /* numCapsets */ /* TS_RFX_CAPSET */ - stream_write_UINT16(s, CBY_CAPSET); /* blockType */ - stream_write_UINT32(s, 29); /* blockLen */ - stream_write_BYTE(s, 0x01); /* codecId (MUST be set to 0x01) */ - stream_write_UINT16(s, CLY_CAPSET); /* capsetType */ - stream_write_UINT16(s, 2); /* numIcaps */ - stream_write_UINT16(s, 8); /* icapLen */ + Stream_Write_UINT16(s, CBY_CAPSET); /* blockType */ + Stream_Write_UINT32(s, 29); /* blockLen */ + Stream_Write_UINT8(s, 0x01); /* codecId (MUST be set to 0x01) */ + Stream_Write_UINT16(s, CLY_CAPSET); /* capsetType */ + Stream_Write_UINT16(s, 2); /* numIcaps */ + Stream_Write_UINT16(s, 8); /* icapLen */ /* TS_RFX_ICAP (RLGR1) */ - stream_write_UINT16(s, CLW_VERSION_1_0); /* version */ - stream_write_UINT16(s, CT_TILE_64x64); /* tileSize */ - stream_write_BYTE(s, codecMode); /* flags */ - stream_write_BYTE(s, CLW_COL_CONV_ICT); /* colConvBits */ - stream_write_BYTE(s, CLW_XFORM_DWT_53_A); /* transformBits */ - stream_write_BYTE(s, CLW_ENTROPY_RLGR1); /* entropyBits */ + Stream_Write_UINT16(s, CLW_VERSION_1_0); /* version */ + Stream_Write_UINT16(s, CT_TILE_64x64); /* tileSize */ + Stream_Write_UINT8(s, codecMode); /* flags */ + Stream_Write_UINT8(s, CLW_COL_CONV_ICT); /* colConvBits */ + Stream_Write_UINT8(s, CLW_XFORM_DWT_53_A); /* transformBits */ + Stream_Write_UINT8(s, CLW_ENTROPY_RLGR1); /* entropyBits */ /* TS_RFX_ICAP (RLGR3) */ - stream_write_UINT16(s, CLW_VERSION_1_0); /* version */ - stream_write_UINT16(s, CT_TILE_64x64); /* tileSize */ - stream_write_BYTE(s, codecMode); /* flags */ - stream_write_BYTE(s, CLW_COL_CONV_ICT); /* colConvBits */ - stream_write_BYTE(s, CLW_XFORM_DWT_53_A); /* transformBits */ - stream_write_BYTE(s, CLW_ENTROPY_RLGR3); /* entropyBits */ + Stream_Write_UINT16(s, CLW_VERSION_1_0); /* version */ + Stream_Write_UINT16(s, CT_TILE_64x64); /* tileSize */ + Stream_Write_UINT8(s, codecMode); /* flags */ + Stream_Write_UINT8(s, CLW_COL_CONV_ICT); /* colConvBits */ + Stream_Write_UINT8(s, CLW_XFORM_DWT_53_A); /* transformBits */ + Stream_Write_UINT8(s, CLW_ENTROPY_RLGR3); /* entropyBits */ } /** @@ -2567,18 +2567,18 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings */ void rdp_write_nsc_client_capability_container(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 3); /* codecPropertiesLength */ + Stream_Write_UINT16(s, 3); /* codecPropertiesLength */ /* TS_NSCODEC_CAPABILITYSET */ - stream_write_BYTE(s, 1); /* fAllowDynamicFidelity */ - stream_write_BYTE(s, 1); /* fAllowSubsampling */ - stream_write_BYTE(s, 3); /* colorLossLevel */ + Stream_Write_UINT8(s, 1); /* fAllowDynamicFidelity */ + Stream_Write_UINT8(s, 1); /* fAllowSubsampling */ + Stream_Write_UINT8(s, 3); /* colorLossLevel */ } void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 1); /* codecPropertiesLength */ - stream_write_BYTE(s, settings->JpegQuality); + Stream_Write_UINT16(s, 1); /* codecPropertiesLength */ + Stream_Write_UINT8(s, settings->JpegQuality); } /** @@ -2588,14 +2588,14 @@ void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* setting */ void rdp_write_rfx_server_capability_container(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 4); /* codecPropertiesLength */ - stream_write_UINT32(s, 0); /* reserved */ + Stream_Write_UINT16(s, 4); /* codecPropertiesLength */ + Stream_Write_UINT32(s, 0); /* reserved */ } void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 1); /* codecPropertiesLength */ - stream_write_BYTE(s, 75); + Stream_Write_UINT16(s, 1); /* codecPropertiesLength */ + Stream_Write_UINT8(s, 75); } /** @@ -2605,8 +2605,8 @@ void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* setting */ void rdp_write_nsc_server_capability_container(wStream* s, rdpSettings* settings) { - stream_write_UINT16(s, 4); /* codecPropertiesLength */ - stream_write_UINT32(s, 0); /* reserved */ + Stream_Write_UINT16(s, 4); /* codecPropertiesLength */ + Stream_Write_UINT32(s, 0); /* reserved */ } /** @@ -2637,7 +2637,7 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) if (settings->RemoteFxImageCodec) bitmapCodecCount++; - stream_write_BYTE(s, bitmapCodecCount); + Stream_Write_UINT8(s, bitmapCodecCount); if (settings->RemoteFxCodec) { @@ -2645,12 +2645,12 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) if (settings->ServerMode) { - stream_write_BYTE(s, 0); /* codecID is defined by the client */ + Stream_Write_UINT8(s, 0); /* codecID is defined by the client */ rdp_write_rfx_server_capability_container(s, settings); } else { - stream_write_BYTE(s, RDP_CODEC_ID_REMOTEFX); /* codecID */ + Stream_Write_UINT8(s, RDP_CODEC_ID_REMOTEFX); /* codecID */ rdp_write_rfx_client_capability_container(s, settings); } } @@ -2661,12 +2661,12 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) if (settings->ServerMode) { - stream_write_BYTE(s, 0); /* codecID is defined by the client */ + Stream_Write_UINT8(s, 0); /* codecID is defined by the client */ rdp_write_nsc_server_capability_container(s, settings); } else { - stream_write_BYTE(s, RDP_CODEC_ID_NSCODEC); /* codecID */ + Stream_Write_UINT8(s, RDP_CODEC_ID_NSCODEC); /* codecID */ rdp_write_nsc_client_capability_container(s, settings); } } @@ -2677,12 +2677,12 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) if (settings->ServerMode) { - stream_write_BYTE(s, 0); /* codecID is defined by the client */ + Stream_Write_UINT8(s, 0); /* codecID is defined by the client */ rdp_write_jpeg_server_capability_container(s, settings); } else { - stream_write_BYTE(s, RDP_CODEC_ID_JPEG); /* codecID */ + Stream_Write_UINT8(s, RDP_CODEC_ID_JPEG); /* codecID */ rdp_write_jpeg_client_capability_container(s, settings); } } @@ -2693,12 +2693,12 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) if (settings->ServerMode) { - stream_write_BYTE(s, 0); /* codecID is defined by the client */ + Stream_Write_UINT8(s, 0); /* codecID is defined by the client */ rdp_write_rfx_server_capability_container(s, settings); } else { - stream_write_BYTE(s, RDP_CODEC_ID_IMAGE_REMOTEFX); /* codecID */ + Stream_Write_UINT8(s, RDP_CODEC_ID_IMAGE_REMOTEFX); /* codecID */ rdp_write_rfx_client_capability_container(s, settings); } } @@ -2719,7 +2719,7 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) if (length < 5) return FALSE; - stream_read_BYTE(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ + Stream_Read_UINT8(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ remainingLength = length - 5; fprintf(stderr, "\tbitmapCodecCount: %d\n", bitmapCodecCount); @@ -2730,7 +2730,7 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) return FALSE; rdp_read_bitmap_codec_guid(s, &codecGuid); /* codecGuid (16 bytes) */ - stream_read_BYTE(s, codecId); /* codecId (1 byte) */ + Stream_Read_UINT8(s, codecId); /* codecId (1 byte) */ fprintf(stderr, "\tcodecGuid: 0x"); rdp_print_bitmap_codec_guid(&codecGuid); @@ -2738,7 +2738,7 @@ BOOL rdp_print_bitmap_codecs_capability_set(wStream* s, UINT16 length) fprintf(stderr, "\tcodecId: %d\n", codecId); - stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ + Stream_Read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ fprintf(stderr, "\tcodecPropertiesLength: %d\n", codecPropertiesLength); remainingLength -= 19; @@ -2769,7 +2769,7 @@ BOOL rdp_read_frame_acknowledge_capability_set(wStream* s, UINT16 length, rdpSet if (settings->ServerMode) { - stream_read_UINT32(s, settings->FrameAcknowledge); /* (4 bytes) */ + Stream_Read_UINT32(s, settings->FrameAcknowledge); /* (4 bytes) */ } else { @@ -2792,7 +2792,7 @@ void rdp_write_frame_acknowledge_capability_set(wStream* s, rdpSettings* setting header = rdp_capability_set_start(s); frame_acknowledge = settings->FrameAcknowledge; - stream_write_UINT32(s, frame_acknowledge); /* (4 bytes) */ + Stream_Write_UINT32(s, frame_acknowledge); /* (4 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_FRAME_ACKNOWLEDGE); } @@ -2806,7 +2806,7 @@ BOOL rdp_print_frame_acknowledge_capability_set(wStream* s, UINT16 length) if (length < 8) return FALSE; - stream_read_UINT32(s, frameAcknowledge); /* frameAcknowledge (4 bytes) */ + Stream_Read_UINT32(s, frameAcknowledge); /* frameAcknowledge (4 bytes) */ fprintf(stderr, "\tframeAcknowledge: 0x%08X\n", frameAcknowledge); @@ -2820,7 +2820,7 @@ BOOL rdp_read_bitmap_cache_v3_codec_id_capability_set(wStream* s, UINT16 length, if (length < 5) return FALSE; - stream_read_BYTE(s, bitmapCacheV3CodecId); /* bitmapCacheV3CodecId (1 byte) */ + Stream_Read_UINT8(s, bitmapCacheV3CodecId); /* bitmapCacheV3CodecId (1 byte) */ return TRUE; } @@ -2830,7 +2830,7 @@ void rdp_write_bitmap_cache_v3_codec_id_capability_set(wStream* s, rdpSettings* BYTE* header; header = rdp_capability_set_start(s); - stream_write_BYTE(s, settings->BitmapCacheV3CodecId); + Stream_Write_UINT8(s, settings->BitmapCacheV3CodecId); rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_V3_CODEC_ID); } @@ -2843,7 +2843,7 @@ BOOL rdp_print_bitmap_cache_v3_codec_id_capability_set(wStream* s, UINT16 length if (length < 5) return FALSE; - stream_read_BYTE(s, bitmapCacheV3CodecId); /* bitmapCacheV3CodecId (1 byte) */ + Stream_Read_UINT8(s, bitmapCacheV3CodecId); /* bitmapCacheV3CodecId (1 byte) */ fprintf(stderr, "\tbitmapCacheV3CodecId: 0x%02X\n", bitmapCacheV3CodecId); @@ -3304,14 +3304,14 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ - stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ - stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ + Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ + Stream_Read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ if (!stream_skip(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */ return FALSE; - stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ + Stream_Read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* capabilitySets */ @@ -3332,16 +3332,16 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) UINT16 numberCapabilities; UINT16 lengthCombinedCapabilities; - stream_write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ - stream_write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ + Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ + Stream_Write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ stream_get_mark(s, lm); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ - stream_write(s, "RDP", 4); /* sourceDescriptor */ + Stream_Write(s, "RDP", 4); /* sourceDescriptor */ stream_get_mark(s, bm); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ numberCapabilities = 14; rdp_write_general_capability_set(s, settings); @@ -3369,10 +3369,10 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); - stream_write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ stream_set_mark(s, bm); /* go back to numberCapabilities */ - stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ + Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); @@ -3383,7 +3383,7 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) stream_set_mark(s, em); - stream_write_UINT32(s, 0); /* sessionId */ + Stream_Write_UINT32(s, 0); /* sessionId */ } BOOL rdp_send_demand_active(rdpRdp* rdp) @@ -3425,14 +3425,14 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s) Stream_Seek_UINT32(s); /* shareId (4 bytes) */ Stream_Seek_UINT16(s); /* originatorId (2 bytes) */ - stream_read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ - stream_read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ + Stream_Read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ if (Stream_GetRemainingLength(s) < lengthSourceDescriptor + 4) return FALSE; Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor */ - stream_read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ + Stream_Read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ return rdp_read_capability_sets(s, rdp->settings, numberCapabilities); @@ -3447,17 +3447,17 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) lengthSourceDescriptor = sizeof(SOURCE_DESCRIPTOR); - stream_write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ - stream_write_UINT16(s, 0x03EA); /* originatorId (2 bytes) */ - stream_write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */ + Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ + Stream_Write_UINT16(s, 0x03EA); /* originatorId (2 bytes) */ + Stream_Write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */ stream_get_mark(s, lm); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ - stream_write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */ + Stream_Write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */ stream_get_mark(s, bm); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ /* Capability Sets */ numberCapabilities = 15; @@ -3554,10 +3554,10 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); - stream_write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ + Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ stream_set_mark(s, bm); /* go back to numberCapabilities */ - stream_write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ + Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index 603811da1..524ac4356 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -250,7 +250,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) goto error1; info->ModulusLength = modulus_length; info->Modulus = (BYTE*) malloc(info->ModulusLength); - stream_read(s, info->Modulus, info->ModulusLength); + Stream_Read(s, info->Modulus, info->ModulusLength); error++; if(!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */ @@ -258,7 +258,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) error++; if(Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4) goto error2; - stream_read(s, &info->exponent[4 - exponent_length], exponent_length); + Stream_Read(s, &info->exponent[4 - exponent_length], exponent_length); crypto_reverse(info->Modulus, info->ModulusLength); crypto_reverse(info->exponent, 4); @@ -327,7 +327,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w if(Stream_GetRemainingLength(s) < 20) return FALSE; - stream_read(s, magic, 4); + Stream_Read(s, magic, 4); if (memcmp(magic, "RSA1", 4) != 0) { @@ -335,17 +335,17 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w return FALSE; } - stream_read_UINT32(s, keylen); - stream_read_UINT32(s, bitlen); - stream_read_UINT32(s, datalen); - stream_read(s, certificate->cert_info.exponent, 4); + Stream_Read_UINT32(s, keylen); + Stream_Read_UINT32(s, bitlen); + Stream_Read_UINT32(s, datalen); + Stream_Read(s, certificate->cert_info.exponent, 4); modlen = keylen - 8; if(Stream_GetRemainingLength(s) < modlen + 8) // count padding return FALSE; certificate->cert_info.ModulusLength = modlen; certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength); - stream_read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength); + Stream_Read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength); /* 8 bytes of zero padding */ Stream_Seek(s, 8); @@ -365,7 +365,7 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific crypto_md5_update(md5ctx, sigdata, sigdatalen); crypto_md5_final(md5ctx, md5hash); - stream_read(s, encsig, siglen); + Stream_Read(s, encsig, siglen); /* Last 8 bytes shall be all zero. */ @@ -430,8 +430,8 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate /* -4, because we need to include dwVersion */ sigdata = Stream_Pointer(s) - 4; - stream_read_UINT32(s, dwSigAlgId); - stream_read_UINT32(s, dwKeyAlgId); + Stream_Read_UINT32(s, dwSigAlgId); + Stream_Read_UINT32(s, dwKeyAlgId); if (!(dwSigAlgId == SIGNATURE_ALG_RSA && dwKeyAlgId == KEY_EXCHANGE_ALG_RSA)) { @@ -439,7 +439,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; } - stream_read_UINT16(s, wPublicKeyBlobType); + Stream_Read_UINT16(s, wPublicKeyBlobType); if (wPublicKeyBlobType != BB_RSA_KEY_BLOB) { @@ -447,7 +447,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; } - stream_read_UINT16(s, wPublicKeyBlobLen); + Stream_Read_UINT16(s, wPublicKeyBlobLen); if(Stream_GetRemainingLength(s) < wPublicKeyBlobLen) return FALSE; @@ -461,7 +461,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; sigdatalen = Stream_Pointer(s) - sigdata; - stream_read_UINT16(s, wSignatureBlobType); + Stream_Read_UINT16(s, wSignatureBlobType); if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB) { @@ -469,7 +469,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; } - stream_read_UINT16(s, wSignatureBlobLen); + Stream_Read_UINT16(s, wSignatureBlobLen); if(Stream_GetRemainingLength(s) < wSignatureBlobLen) return FALSE; @@ -505,7 +505,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, numCertBlobs); /* numCertBlobs */ + Stream_Read_UINT32(s, numCertBlobs); /* numCertBlobs */ certificate->x509_cert_chain = certificate_new_x509_certificate_chain(numCertBlobs); @@ -513,14 +513,14 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, certLength); + Stream_Read_UINT32(s, certLength); if(Stream_GetRemainingLength(s) < certLength) return FALSE; DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength); certificate->x509_cert_chain->array[i].data = (BYTE*) malloc(certLength); - stream_read(s, certificate->x509_cert_chain->array[i].data, certLength); + Stream_Read(s, certificate->x509_cert_chain->array[i].data, certLength); certificate->x509_cert_chain->array[i].length = certLength; if (numCertBlobs - i == 2) @@ -574,7 +574,7 @@ int certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serve s = stream_new(0); stream_attach(s, server_cert, length); - stream_read_UINT32(s, dwVersion); /* dwVersion (4 bytes) */ + Stream_Read_UINT32(s, dwVersion); /* dwVersion (4 bytes) */ switch (dwVersion & CERT_CHAIN_VERSION_MASK) { diff --git a/libfreerdp/core/channel.c b/libfreerdp/core/channel.c index 307427dd8..648f78d83 100644 --- a/libfreerdp/core/channel.c +++ b/libfreerdp/core/channel.c @@ -78,10 +78,10 @@ BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channel_id, BYTE* data, int size) flags |= CHANNEL_FLAG_SHOW_PROTOCOL; } - stream_write_UINT32(s, size); - stream_write_UINT32(s, flags); + Stream_Write_UINT32(s, size); + Stream_Write_UINT32(s, flags); Stream_EnsureCapacity(s, chunk_size); - stream_write(s, data, chunk_size); + Stream_Write(s, data, chunk_size); rdp_send(rdp, s, channel_id); @@ -102,8 +102,8 @@ BOOL freerdp_channel_process(freerdp* instance, wStream* s, UINT16 channel_id) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, length); - stream_read_UINT32(s, flags); + Stream_Read_UINT32(s, length); + Stream_Read_UINT32(s, flags); chunk_length = Stream_GetRemainingLength(s); IFCALL(instance->ReceiveChannelData, instance, @@ -120,8 +120,8 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, length); - stream_read_UINT32(s, flags); + Stream_Read_UINT32(s, length); + Stream_Read_UINT32(s, flags); chunk_length = Stream_GetRemainingLength(s); IFCALL(client->ReceiveChannelData, client, diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index bc1637b6e..1f42291da 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -285,8 +285,8 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) rdp_write_security_header(s, SEC_EXCHANGE_PKT); length = key_len + 8; - stream_write_UINT32(s, length); - stream_write(s, crypt_client_random, length); + Stream_Write_UINT32(s, length); + Stream_Write(s, crypt_client_random, length); if (transport_write(rdp->mcs->transport, s) < 0) { @@ -351,7 +351,7 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, rand_len); + Stream_Read_UINT32(s, rand_len); if(Stream_GetRemainingLength(s) < rand_len + 8) /* include 8 bytes of padding */ return FALSE; @@ -364,7 +364,7 @@ static BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s) } memset(crypt_client_random, 0, sizeof(crypt_client_random)); - stream_read(s, crypt_client_random, rand_len); + Stream_Read(s, crypt_client_random, rand_len); /* 8 zero bytes of padding */ Stream_Seek(s, 8); mod = rdp->settings->RdpServerRsaKey->Modulus; diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index ea4452730..e85f7f3c6 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -77,7 +77,7 @@ UINT16 fastpath_header_length(wStream* s) BYTE length1; Stream_Seek_BYTE(s); - stream_read_BYTE(s, length1); + Stream_Read_UINT8(s, length1); Stream_Rewind(s, 2); return ((length1 & 0x80) != 0 ? 3 : 2); @@ -94,7 +94,7 @@ UINT16 fastpath_read_header(rdpFastPath* fastpath, wStream* s) BYTE header; UINT16 length; - stream_read_BYTE(s, header); + Stream_Read_UINT8(s, header); if (fastpath) { @@ -111,7 +111,7 @@ static INLINE void fastpath_read_update_header(wStream* s, BYTE* updateCode, BYT { BYTE updateHeader; - stream_read_BYTE(s, updateHeader); + Stream_Read_UINT8(s, updateHeader); *updateCode = updateHeader & 0x0F; *fragmentation = (updateHeader >> 4) & 0x03; *compression = (updateHeader >> 6) & 0x03; @@ -124,14 +124,14 @@ static INLINE void fastpath_write_update_header(wStream* s, BYTE updateCode, BYT updateHeader |= updateCode & 0x0F; updateHeader |= (fragmentation & 0x03) << 4; updateHeader |= (compression & 0x03) << 6; - stream_write_BYTE(s, updateHeader); + Stream_Write_UINT8(s, updateHeader); } BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16 *length) { BYTE header; - stream_read_BYTE(s, header); + Stream_Read_UINT8(s, header); if (fastpath) { @@ -151,7 +151,7 @@ static BOOL fastpath_recv_orders(rdpFastPath* fastpath, wStream* s) rdpUpdate* update = fastpath->rdp->update; UINT16 numberOrders; - stream_read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ + Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ while (numberOrders > 0) { @@ -173,7 +173,7 @@ static BOOL fastpath_recv_update_common(rdpFastPath* fastpath, wStream* s) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, updateType); /* updateType (2 bytes) */ + Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ switch (updateType) { @@ -317,11 +317,11 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) fastpath_read_update_header(s, &updateCode, &fragmentation, &compression); if (compression == FASTPATH_OUTPUT_COMPRESSION_USED) - stream_read_BYTE(s, compressionFlags); + Stream_Read_UINT8(s, compressionFlags); else compressionFlags = 0; - stream_read_UINT16(s, size); + Stream_Read_UINT16(s, size); if (Stream_GetRemainingLength(s) < size) return -1; @@ -483,7 +483,7 @@ static BOOL fastpath_read_input_event_header(wStream* s, BYTE* eventFlags, BYTE* if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, eventHeader); /* eventHeader (1 byte) */ + Stream_Read_UINT8(s, eventHeader); /* eventHeader (1 byte) */ *eventFlags = (eventHeader & 0x1F); *eventCode = (eventHeader >> 5); @@ -499,7 +499,7 @@ static BOOL fastpath_recv_input_event_scancode(rdpFastPath* fastpath, wStream* s if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, code); /* keyCode (1 byte) */ + Stream_Read_UINT8(s, code); /* keyCode (1 byte) */ flags = 0; @@ -525,9 +525,9 @@ static BOOL fastpath_recv_input_event_mouse(rdpFastPath* fastpath, wStream* s, B if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ - stream_read_UINT16(s, xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ + Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ IFCALL(fastpath->rdp->input->MouseEvent, fastpath->rdp->input, pointerFlags, xPos, yPos); @@ -543,9 +543,9 @@ static BOOL fastpath_recv_input_event_mousex(rdpFastPath* fastpath, wStream* s, if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ - stream_read_UINT16(s, xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ + Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ IFCALL(fastpath->rdp->input->ExtendedMouseEvent, fastpath->rdp->input, pointerFlags, xPos, yPos); @@ -567,7 +567,7 @@ static BOOL fastpath_recv_input_event_unicode(rdpFastPath* fastpath, wStream* s, if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ + Stream_Read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ flags = 0; @@ -638,7 +638,7 @@ int fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s) if (Stream_GetRemainingLength(s) < 1) return -1; - stream_read_BYTE(s, fastpath->numberEvents); /* eventHeader (1 byte) */ + Stream_Read_UINT8(s, fastpath->numberEvents); /* eventHeader (1 byte) */ } for (i = 0; i < fastpath->numberEvents; i++) @@ -699,7 +699,7 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev rdp = fastpath->rdp; s = fastpath_input_pdu_init_header(fastpath); - stream_write_BYTE(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ + Stream_Write_UINT8(s, eventFlags | (eventCode << 5)); /* eventHeader (1 byte) */ return s; } @@ -730,7 +730,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu eventHeader |= (FASTPATH_INPUT_SECURE_CHECKSUM << 6); Stream_SetPosition(s, 0); - stream_write_BYTE(s, eventHeader); + Stream_Write_UINT8(s, eventHeader); sec_bytes = fastpath_get_sec_bytes(fastpath->rdp); /* @@ -739,7 +739,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu * because we can leave room for fixed-length header, store all * the data first and then store the header. */ - stream_write_UINT16_be(s, 0x8000 | length); + Stream_Write_UINT16_BE(s, 0x8000 | length); if (sec_bytes > 0) { @@ -866,9 +866,9 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s if (sec_bytes > 0) header |= (FASTPATH_OUTPUT_ENCRYPTED << 6); - stream_write_BYTE(ls, header); /* fpOutputHeader (1 byte) */ - stream_write_BYTE(ls, 0x80 | (pduLength >> 8)); /* length1 */ - stream_write_BYTE(ls, pduLength & 0xFF); /* length2 */ + Stream_Write_UINT8(ls, header); /* fpOutputHeader (1 byte) */ + Stream_Write_UINT8(ls, 0x80 | (pduLength >> 8)); /* length1 */ + Stream_Write_UINT8(ls, pduLength & 0xFF); /* length2 */ if (sec_bytes > 0) Stream_Seek(ls, sec_bytes); @@ -878,7 +878,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s /* extra byte if compressed */ if (ls == comp_update) { - stream_write_BYTE(ls, cflags); + Stream_Write_UINT8(ls, cflags); bytes_to_crypt = pdu_data_bytes + 4; } else @@ -886,7 +886,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s bytes_to_crypt = pdu_data_bytes + 3; } - stream_write_UINT16(ls, pdu_data_bytes); + Stream_Write_UINT16(ls, pdu_data_bytes); stream_attach(update, bm, pduLength); Stream_Seek(update, pduLength); diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 02afcb0b6..95e33c70e 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -456,8 +456,8 @@ BOOL gcc_read_user_data_header(wStream* s, UINT16* type, UINT16* length) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, *type); /* type */ - stream_read_UINT16(s, *length); /* length */ + Stream_Read_UINT16(s, *type); /* type */ + Stream_Read_UINT16(s, *length); /* length */ if (Stream_GetRemainingLength(s) < *length - 4) return FALSE; @@ -475,8 +475,8 @@ BOOL gcc_read_user_data_header(wStream* s, UINT16* type, UINT16* length) void gcc_write_user_data_header(wStream* s, UINT16 type, UINT16 length) { - stream_write_UINT16(s, type); /* type */ - stream_write_UINT16(s, length); /* length */ + Stream_Write_UINT16(s, type); /* type */ + Stream_Write_UINT16(s, length); /* length */ } /** @@ -501,15 +501,15 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 128) return FALSE; - stream_read_UINT32(s, version); /* version */ + Stream_Read_UINT32(s, version); /* version */ settings->RdpVersion = (version == RDP_VERSION_4 ? 4 : 7); - stream_read_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ - stream_read_UINT16(s, settings->DesktopHeight); /* DesktopHeight */ - stream_read_UINT16(s, colorDepth); /* ColorDepth */ + Stream_Read_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ + Stream_Read_UINT16(s, settings->DesktopHeight); /* DesktopHeight */ + Stream_Read_UINT16(s, colorDepth); /* ColorDepth */ Stream_Seek_UINT16(s); /* SASSequence (Secure Access Sequence) */ - stream_read_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */ - stream_read_UINT32(s, settings->ClientBuild); /* ClientBuild */ + Stream_Read_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */ + Stream_Read_UINT32(s, settings->ClientBuild); /* ClientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 32 / 2, &str, 0, NULL, NULL); @@ -519,9 +519,9 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe free(str); str = NULL; - stream_read_UINT32(s, settings->KeyboardType); /* KeyboardType */ - stream_read_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ - stream_read_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ + Stream_Read_UINT32(s, settings->KeyboardType); /* KeyboardType */ + Stream_Read_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ + Stream_Read_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ Stream_Seek(s, 64); /* imeFileName */ @@ -538,7 +538,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe { if (blockLength < 2) break; - stream_read_UINT16(s, postBeta2ColorDepth); /* postBeta2ColorDepth */ + Stream_Read_UINT16(s, postBeta2ColorDepth); /* postBeta2ColorDepth */ blockLength -= 2; if (blockLength < 2) @@ -553,17 +553,17 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 2) break; - stream_read_UINT16(s, highColorDepth); /* highColorDepth */ + Stream_Read_UINT16(s, highColorDepth); /* highColorDepth */ blockLength -= 2; if (blockLength < 2) break; - stream_read_UINT16(s, supportedColorDepths); /* supportedColorDepths */ + Stream_Read_UINT16(s, supportedColorDepths); /* supportedColorDepths */ blockLength -= 2; if (blockLength < 2) break; - stream_read_UINT16(s, settings->EarlyCapabilityFlags); /* earlyCapabilityFlags */ + Stream_Read_UINT16(s, settings->EarlyCapabilityFlags); /* earlyCapabilityFlags */ blockLength -= 2; if (blockLength < 64) @@ -577,7 +577,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 1) break; - stream_read_BYTE(s, settings->PerformanceFlags); /* connectionType */ + Stream_Read_UINT8(s, settings->PerformanceFlags); /* connectionType */ blockLength -= 1; if (blockLength < 1) @@ -587,7 +587,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 4) break; - stream_read_UINT32(s, serverSelectedProtocol); /* serverSelectedProtocol */ + Stream_Read_UINT32(s, serverSelectedProtocol); /* serverSelectedProtocol */ blockLength -= 4; if (settings->SelectedProtocol != serverSelectedProtocol) @@ -675,13 +675,13 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) clientNameLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientHostname, -1, &clientName, 0); clientDigProductIdLength = ConvertToUnicode(CP_UTF8, 0, settings->ClientProductId, -1, &clientDigProductId, 0); - stream_write_UINT32(s, version); /* Version */ - stream_write_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ - stream_write_UINT16(s, settings->DesktopHeight); /* DesktopHeight */ - stream_write_UINT16(s, RNS_UD_COLOR_8BPP); /* ColorDepth, ignored because of postBeta2ColorDepth */ - stream_write_UINT16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */ - stream_write_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */ - stream_write_UINT32(s, settings->ClientBuild); /* ClientBuild */ + Stream_Write_UINT32(s, version); /* Version */ + Stream_Write_UINT16(s, settings->DesktopWidth); /* DesktopWidth */ + Stream_Write_UINT16(s, settings->DesktopHeight); /* DesktopHeight */ + Stream_Write_UINT16(s, RNS_UD_COLOR_8BPP); /* ColorDepth, ignored because of postBeta2ColorDepth */ + Stream_Write_UINT16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */ + Stream_Write_UINT32(s, settings->KeyboardLayout); /* KeyboardLayout */ + Stream_Write_UINT32(s, settings->ClientBuild); /* ClientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ @@ -691,19 +691,19 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) clientName[clientNameLength-1] = 0; } - stream_write(s, clientName, (clientNameLength * 2)); - stream_write_zero(s, 32 - (clientNameLength * 2)); + Stream_Write(s, clientName, (clientNameLength * 2)); + Stream_Write_zero(s, 32 - (clientNameLength * 2)); free(clientName); - stream_write_UINT32(s, settings->KeyboardType); /* KeyboardType */ - stream_write_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ - stream_write_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ + Stream_Write_UINT32(s, settings->KeyboardType); /* KeyboardType */ + Stream_Write_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ + Stream_Write_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ - stream_write_zero(s, 64); /* imeFileName */ + Stream_Write_zero(s, 64); /* imeFileName */ - stream_write_UINT16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */ - stream_write_UINT16(s, 1); /* clientProductID */ - stream_write_UINT32(s, 0); /* serialNumber (should be initialized to 0) */ + Stream_Write_UINT16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */ + Stream_Write_UINT16(s, 1); /* clientProductID */ + Stream_Write_UINT32(s, 0); /* serialNumber (should be initialized to 0) */ highColorDepth = MIN(settings->ColorDepth, 24); @@ -727,10 +727,10 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION; } - stream_write_UINT16(s, highColorDepth); /* highColorDepth */ - stream_write_UINT16(s, supportedColorDepths); /* supportedColorDepths */ + Stream_Write_UINT16(s, highColorDepth); /* highColorDepth */ + Stream_Write_UINT16(s, supportedColorDepths); /* supportedColorDepths */ - stream_write_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */ + Stream_Write_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */ /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 31 characters) */ if (clientDigProductIdLength >= 32) @@ -738,14 +738,14 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) clientDigProductIdLength = 32; clientDigProductId[clientDigProductIdLength-1] = 0; } - stream_write(s, clientDigProductId, (clientDigProductIdLength * 2) ); - stream_write_zero(s, 64 - (clientDigProductIdLength * 2) ); + Stream_Write(s, clientDigProductId, (clientDigProductIdLength * 2) ); + Stream_Write_zero(s, 64 - (clientDigProductIdLength * 2) ); free(clientDigProductId); - stream_write_BYTE(s, connectionType); /* connectionType */ - stream_write_BYTE(s, 0); /* pad1octet */ + Stream_Write_UINT8(s, connectionType); /* connectionType */ + Stream_Write_UINT8(s, 0); /* pad1octet */ - stream_write_UINT32(s, settings->SelectedProtocol); /* serverSelectedProtocol */ + Stream_Write_UINT32(s, settings->SelectedProtocol); /* serverSelectedProtocol */ } BOOL gcc_read_server_core_data(wStream* s, rdpSettings* settings) @@ -755,8 +755,8 @@ BOOL gcc_read_server_core_data(wStream* s, rdpSettings* settings) if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, version); /* version */ - stream_read_UINT32(s, clientRequestedProtocols); /* clientRequestedProtocols */ + Stream_Read_UINT32(s, version); /* version */ + Stream_Read_UINT32(s, clientRequestedProtocols); /* clientRequestedProtocols */ if (version == RDP_VERSION_4 && settings->RdpVersion > 4) settings->RdpVersion = 4; @@ -770,8 +770,8 @@ void gcc_write_server_core_data(wStream* s, rdpSettings* settings) { gcc_write_user_data_header(s, SC_CORE, 12); - stream_write_UINT32(s, settings->RdpVersion == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS); - stream_write_UINT32(s, settings->RequestedProtocols); /* clientRequestedProtocols */ + Stream_Write_UINT32(s, settings->RdpVersion == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS); + Stream_Write_UINT32(s, settings->RequestedProtocols); /* clientRequestedProtocols */ } /** @@ -788,9 +788,9 @@ BOOL gcc_read_client_security_data(wStream* s, rdpSettings* settings, UINT16 blo if (settings->DisableEncryption) { - stream_read_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */ + Stream_Read_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */ if (settings->EncryptionMethods == 0) - stream_read_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */ + Stream_Read_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */ } else { @@ -812,14 +812,14 @@ void gcc_write_client_security_data(wStream* s, rdpSettings* settings) if (settings->DisableEncryption) { - stream_write_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */ - stream_write_UINT32(s, 0); /* extEncryptionMethods */ + Stream_Write_UINT32(s, settings->EncryptionMethods); /* encryptionMethods */ + Stream_Write_UINT32(s, 0); /* extEncryptionMethods */ } else { /* French locale, disable encryption */ - stream_write_UINT32(s, 0); /* encryptionMethods */ - stream_write_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */ + Stream_Write_UINT32(s, 0); /* encryptionMethods */ + Stream_Write_UINT32(s, settings->EncryptionMethods); /* extEncryptionMethods */ } } @@ -830,8 +830,8 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */ - stream_read_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */ + Stream_Read_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */ + Stream_Read_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */ if (settings->EncryptionMethods == 0 && settings->EncryptionLevel == 0) { @@ -844,8 +844,8 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, settings->ServerRandomLength); /* serverRandomLen */ - stream_read_UINT32(s, settings->ServerCertificateLength); /* serverCertLen */ + Stream_Read_UINT32(s, settings->ServerRandomLength); /* serverRandomLen */ + Stream_Read_UINT32(s, settings->ServerCertificateLength); /* serverCertLen */ if (Stream_GetRemainingLength(s) < settings->ServerRandomLength + settings->ServerCertificateLength) return FALSE; @@ -854,7 +854,7 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) { /* serverRandom */ settings->ServerRandom = (BYTE*) malloc(settings->ServerRandomLength); - stream_read(s, settings->ServerRandom, settings->ServerRandomLength); + Stream_Read(s, settings->ServerRandom, settings->ServerRandomLength); } else { @@ -865,7 +865,7 @@ BOOL gcc_read_server_security_data(wStream* s, rdpSettings* settings) { /* serverCertificate */ settings->ServerCertificate = (BYTE*) malloc(settings->ServerCertificateLength); - stream_read(s, settings->ServerCertificate, settings->ServerCertificateLength); + Stream_Read(s, settings->ServerCertificate, settings->ServerCertificateLength); certificate_free(settings->RdpServerCertificate); settings->RdpServerCertificate = certificate_new(); @@ -999,8 +999,8 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) gcc_write_user_data_header(s, SC_SECURITY, headerLen); - stream_write_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */ - stream_write_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */ + Stream_Write_UINT32(s, settings->EncryptionMethods); /* encryptionMethod */ + Stream_Write_UINT32(s, settings->EncryptionLevel); /* encryptionLevel */ if (settings->EncryptionMethods == ENCRYPTION_METHOD_NONE && settings->EncryptionLevel == ENCRYPTION_LEVEL_NONE) @@ -1008,35 +1008,35 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) return; } - stream_write_UINT32(s, serverRandomLen); /* serverRandomLen */ - stream_write_UINT32(s, serverCertLen); /* serverCertLen */ + Stream_Write_UINT32(s, serverRandomLen); /* serverRandomLen */ + Stream_Write_UINT32(s, serverCertLen); /* serverCertLen */ settings->ServerRandomLength = serverRandomLen; settings->ServerRandom = (BYTE*) malloc(serverRandomLen); crypto_nonce(settings->ServerRandom, serverRandomLen); - stream_write(s, settings->ServerRandom, serverRandomLen); + Stream_Write(s, settings->ServerRandom, serverRandomLen); sigData = Stream_Pointer(s); - stream_write_UINT32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */ - stream_write_UINT32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */ - stream_write_UINT32(s, KEY_EXCHANGE_ALG_RSA); /* dwKeyAlgId */ - stream_write_UINT16(s, BB_RSA_KEY_BLOB); /* wPublicKeyBlobType */ + Stream_Write_UINT32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */ + Stream_Write_UINT32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */ + Stream_Write_UINT32(s, KEY_EXCHANGE_ALG_RSA); /* dwKeyAlgId */ + Stream_Write_UINT16(s, BB_RSA_KEY_BLOB); /* wPublicKeyBlobType */ - stream_write_UINT16(s, wPublicKeyBlobLen); /* wPublicKeyBlobLen */ - stream_write(s, "RSA1", 4); /* magic */ - stream_write_UINT32(s, keyLen + 8); /* keylen */ - stream_write_UINT32(s, keyLen * 8); /* bitlen */ - stream_write_UINT32(s, keyLen - 1); /* datalen */ + Stream_Write_UINT16(s, wPublicKeyBlobLen); /* wPublicKeyBlobLen */ + Stream_Write(s, "RSA1", 4); /* magic */ + Stream_Write_UINT32(s, keyLen + 8); /* keylen */ + Stream_Write_UINT32(s, keyLen * 8); /* bitlen */ + Stream_Write_UINT32(s, keyLen - 1); /* datalen */ - stream_write(s, settings->RdpServerRsaKey->exponent, expLen); - stream_write(s, settings->RdpServerRsaKey->Modulus, keyLen); - stream_write_zero(s, 8); + Stream_Write(s, settings->RdpServerRsaKey->exponent, expLen); + Stream_Write(s, settings->RdpServerRsaKey->Modulus, keyLen); + Stream_Write_zero(s, 8); sigDataLen = Stream_Pointer(s) - sigData; - stream_write_UINT16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */ - stream_write_UINT16(s, keyLen + 8); /* wSignatureBlobLen */ + Stream_Write_UINT16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */ + Stream_Write_UINT16(s, keyLen + 8); /* wSignatureBlobLen */ memcpy(signature, initial_signature, sizeof(initial_signature)); @@ -1047,8 +1047,8 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) crypto_rsa_private_encrypt(signature, sizeof(signature), TSSK_KEY_LENGTH, tssk_modulus, tssk_privateExponent, encryptedSignature); - stream_write(s, encryptedSignature, sizeof(encryptedSignature)); - stream_write_zero(s, 8); + Stream_Write(s, encryptedSignature, sizeof(encryptedSignature)); + Stream_Write_zero(s, 8); } /** @@ -1065,7 +1065,7 @@ BOOL gcc_read_client_network_data(wStream* s, rdpSettings* settings, UINT16 bloc if (blockLength < 4) return FALSE; - stream_read_UINT32(s, settings->ChannelCount); /* channelCount */ + Stream_Read_UINT32(s, settings->ChannelCount); /* channelCount */ if (blockLength < 4 + settings->ChannelCount * 12) return FALSE; if (settings->ChannelCount > 16) @@ -1075,8 +1075,8 @@ BOOL gcc_read_client_network_data(wStream* s, rdpSettings* settings, UINT16 bloc for (i = 0; i < settings->ChannelCount; i++) { /* CHANNEL_DEF */ - stream_read(s, settings->ChannelDefArray[i].Name, 8); /* name (8 bytes) */ - stream_read_UINT32(s, settings->ChannelDefArray[i].options); /* options (4 bytes) */ + Stream_Read(s, settings->ChannelDefArray[i].Name, 8); /* name (8 bytes) */ + Stream_Read_UINT32(s, settings->ChannelDefArray[i].options); /* options (4 bytes) */ settings->ChannelDefArray[i].ChannelId = MCS_GLOBAL_CHANNEL_ID + 1 + i; } @@ -1100,14 +1100,14 @@ void gcc_write_client_network_data(wStream* s, rdpSettings* settings) length = settings->ChannelCount * 12 + 8; gcc_write_user_data_header(s, CS_NET, length); - stream_write_UINT32(s, settings->ChannelCount); /* channelCount */ + Stream_Write_UINT32(s, settings->ChannelCount); /* channelCount */ /* channelDefArray */ for (i = 0; i < settings->ChannelCount; i++) { /* CHANNEL_DEF */ - stream_write(s, settings->ChannelDefArray[i].Name, 8); /* name (8 bytes) */ - stream_write_UINT32(s, settings->ChannelDefArray[i].options); /* options (4 bytes) */ + Stream_Write(s, settings->ChannelDefArray[i].Name, 8); /* name (8 bytes) */ + Stream_Write_UINT32(s, settings->ChannelDefArray[i].options); /* options (4 bytes) */ } } } @@ -1121,8 +1121,8 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings) if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, MCSChannelId); /* MCSChannelId */ - stream_read_UINT16(s, channelCount); /* channelCount */ + Stream_Read_UINT16(s, MCSChannelId); /* MCSChannelId */ + Stream_Read_UINT16(s, channelCount); /* channelCount */ if (channelCount != settings->ChannelCount) { @@ -1135,7 +1135,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings) for (i = 0; i < channelCount; i++) { - stream_read_UINT16(s, channelId); /* channelId */ + Stream_Read_UINT16(s, channelId); /* channelId */ settings->ChannelDefArray[i].ChannelId = channelId; } @@ -1151,16 +1151,16 @@ void gcc_write_server_network_data(wStream* s, rdpSettings* settings) gcc_write_user_data_header(s, SC_NET, 8 + settings->ChannelCount * 2 + (settings->ChannelCount % 2 == 1 ? 2 : 0)); - stream_write_UINT16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */ - stream_write_UINT16(s, settings->ChannelCount); /* channelCount */ + Stream_Write_UINT16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */ + Stream_Write_UINT16(s, settings->ChannelCount); /* channelCount */ for (i = 0; i < settings->ChannelCount; i++) { - stream_write_UINT16(s, settings->ChannelDefArray[i].ChannelId); + Stream_Write_UINT16(s, settings->ChannelDefArray[i].ChannelId); } if (settings->ChannelCount % 2 == 1) - stream_write_UINT16(s, 0); + Stream_Write_UINT16(s, 0); } /** @@ -1177,13 +1177,13 @@ BOOL gcc_read_client_cluster_data(wStream* s, rdpSettings* settings, UINT16 bloc if (blockLength < 4) return FALSE; - stream_read_UINT32(s, flags); /* flags */ + Stream_Read_UINT32(s, flags); /* flags */ if ((flags & REDIRECTED_SESSIONID_FIELD_VALID)) { if(blockLength < 8) return FALSE; - stream_read_UINT32(s, settings->RedirectedSessionId); /* redirectedSessionID */ + Stream_Read_UINT32(s, settings->RedirectedSessionId); /* redirectedSessionID */ } return TRUE; @@ -1207,8 +1207,8 @@ void gcc_write_client_cluster_data(wStream* s, rdpSettings* settings) if (settings->ConsoleSession || settings->RedirectedSessionId) flags |= REDIRECTED_SESSIONID_FIELD_VALID; - stream_write_UINT32(s, flags); /* flags */ - stream_write_UINT32(s, settings->RedirectedSessionId); /* redirectedSessionID */ + Stream_Write_UINT32(s, flags); /* flags */ + Stream_Write_UINT32(s, settings->RedirectedSessionId); /* redirectedSessionID */ } /** @@ -1242,8 +1242,8 @@ void gcc_write_client_monitor_data(wStream* s, rdpSettings* settings) length = (20 * settings->MonitorCount) + 12; gcc_write_user_data_header(s, CS_MONITOR, length); - stream_write_UINT32(s, 0); /* flags */ - stream_write_UINT32(s, settings->MonitorCount); /* monitorCount */ + Stream_Write_UINT32(s, 0); /* flags */ + Stream_Write_UINT32(s, settings->MonitorCount); /* monitorCount */ for (i = 0; i < settings->MonitorCount; i++) { @@ -1253,11 +1253,11 @@ void gcc_write_client_monitor_data(wStream* s, rdpSettings* settings) bottom = settings->MonitorDefArray[i].y + settings->MonitorDefArray[i].height - 1; flags = settings->MonitorDefArray[i].is_primary ? MONITOR_PRIMARY : 0; - stream_write_UINT32(s, left); /* left */ - stream_write_UINT32(s, top); /* top */ - stream_write_UINT32(s, right); /* right */ - stream_write_UINT32(s, bottom); /* bottom */ - stream_write_UINT32(s, flags); /* flags */ + Stream_Write_UINT32(s, left); /* left */ + Stream_Write_UINT32(s, top); /* top */ + Stream_Write_UINT32(s, right); /* right */ + Stream_Write_UINT32(s, bottom); /* bottom */ + Stream_Write_UINT32(s, flags); /* flags */ } } } diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 8eadd9fea..a792d2322 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -56,10 +56,10 @@ BOOL rdp_read_server_auto_reconnect_cookie(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 4+4+4+16) return FALSE; - stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ - stream_read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ - stream_read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ - stream_read(s, autoReconnectCookie->arcRandomBits, 16); /* arcRandomBits (16 bytes) */ + Stream_Read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ + Stream_Read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ + Stream_Read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ + Stream_Read(s, autoReconnectCookie->arcRandomBits, 16); /* arcRandomBits (16 bytes) */ return TRUE; } @@ -78,10 +78,10 @@ BOOL rdp_read_client_auto_reconnect_cookie(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 28) return FALSE; - stream_read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ - stream_read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ - stream_read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ - stream_read(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */ + Stream_Read_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ + Stream_Read_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ + Stream_Read_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ + Stream_Read(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */ return TRUE; } @@ -98,10 +98,10 @@ void rdp_write_client_auto_reconnect_cookie(wStream* s, rdpSettings* settings) ARC_CS_PRIVATE_PACKET* autoReconnectCookie; autoReconnectCookie = settings->ClientAutoReconnectCookie; - stream_write_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ - stream_write_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ - stream_write_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ - stream_write(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */ + Stream_Write_UINT32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */ + Stream_Write_UINT32(s, autoReconnectCookie->version); /* version (4 bytes) */ + Stream_Write_UINT32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */ + Stream_Write(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */ } /** @@ -120,8 +120,8 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, clientAddressFamily); /* clientAddressFamily */ - stream_read_UINT16(s, cbClientAddress); /* cbClientAddress */ + Stream_Read_UINT16(s, clientAddressFamily); /* clientAddressFamily */ + Stream_Read_UINT16(s, cbClientAddress); /* cbClientAddress */ settings->IPv6Enabled = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? TRUE : FALSE); @@ -133,7 +133,7 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, cbClientDir); /* cbClientDir */ + Stream_Read_UINT16(s, cbClientDir); /* cbClientDir */ if (Stream_GetRemainingLength(s) < cbClientDir) return FALSE; @@ -150,9 +150,9 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings) if (Stream_GetRemainingLength(s) < 10) return FALSE; Stream_Seek_UINT32(s); /* clientSessionId, should be set to 0 */ - stream_read_UINT32(s, settings->PerformanceFlags); /* performanceFlags */ + Stream_Read_UINT32(s, settings->PerformanceFlags); /* performanceFlags */ - stream_read_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */ + Stream_Read_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */ if (cbAutoReconnectLen > 0) return rdp_read_client_auto_reconnect_cookie(s, settings); /* autoReconnectCookie */ @@ -187,26 +187,26 @@ void rdp_write_extended_info_packet(wStream* s, rdpSettings* settings) cbAutoReconnectLen = (int) settings->ClientAutoReconnectCookie->cbLen; - stream_write_UINT16(s, clientAddressFamily); /* clientAddressFamily */ + Stream_Write_UINT16(s, clientAddressFamily); /* clientAddressFamily */ - stream_write_UINT16(s, cbClientAddress + 2); /* cbClientAddress */ + Stream_Write_UINT16(s, cbClientAddress + 2); /* cbClientAddress */ if (cbClientAddress > 0) - stream_write(s, clientAddress, cbClientAddress); /* clientAddress */ - stream_write_UINT16(s, 0); + Stream_Write(s, clientAddress, cbClientAddress); /* clientAddress */ + Stream_Write_UINT16(s, 0); - stream_write_UINT16(s, cbClientDir + 2); /* cbClientDir */ + Stream_Write_UINT16(s, cbClientDir + 2); /* cbClientDir */ if (cbClientDir > 0) - stream_write(s, clientDir, cbClientDir); /* clientDir */ - stream_write_UINT16(s, 0); + Stream_Write(s, clientDir, cbClientDir); /* clientDir */ + Stream_Write_UINT16(s, 0); rdp_write_client_time_zone(s, settings); /* clientTimeZone */ - stream_write_UINT32(s, 0); /* clientSessionId, should be set to 0 */ - stream_write_UINT32(s, settings->PerformanceFlags); /* performanceFlags */ + Stream_Write_UINT32(s, 0); /* clientSessionId, should be set to 0 */ + Stream_Write_UINT32(s, settings->PerformanceFlags); /* performanceFlags */ - stream_write_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */ + Stream_Write_UINT16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */ if (cbAutoReconnectLen > 0) rdp_write_client_auto_reconnect_cookie(s, settings); /* autoReconnectCookie */ @@ -238,18 +238,18 @@ BOOL rdp_read_info_packet(wStream* s, rdpSettings* settings) return FALSE; Stream_Seek_UINT32(s); /* CodePage */ - stream_read_UINT32(s, flags); /* flags */ + Stream_Read_UINT32(s, flags); /* flags */ settings->AutoLogonEnabled = ((flags & INFO_AUTOLOGON) ? TRUE : FALSE); settings->RemoteApplicationMode = ((flags & INFO_RAIL) ? TRUE : FALSE); settings->RemoteConsoleAudio = ((flags & INFO_REMOTECONSOLEAUDIO) ? TRUE : FALSE); settings->CompressionEnabled = ((flags & INFO_COMPRESSION) ? TRUE : FALSE); - stream_read_UINT16(s, cbDomain); /* cbDomain */ - stream_read_UINT16(s, cbUserName); /* cbUserName */ - stream_read_UINT16(s, cbPassword); /* cbPassword */ - stream_read_UINT16(s, cbAlternateShell); /* cbAlternateShell */ - stream_read_UINT16(s, cbWorkingDir); /* cbWorkingDir */ + Stream_Read_UINT16(s, cbDomain); /* cbDomain */ + Stream_Read_UINT16(s, cbUserName); /* cbUserName */ + Stream_Read_UINT16(s, cbPassword); /* cbPassword */ + Stream_Read_UINT16(s, cbAlternateShell); /* cbAlternateShell */ + Stream_Read_UINT16(s, cbWorkingDir); /* cbWorkingDir */ if (Stream_GetRemainingLength(s) < cbDomain + 2) return FALSE; @@ -382,34 +382,34 @@ void rdp_write_info_packet(wStream* s, rdpSettings* settings) cbWorkingDir = ConvertToUnicode(CP_UTF8, 0, settings->ShellWorkingDirectory, -1, &workingDir, 0) * 2; - stream_write_UINT32(s, 0); /* CodePage */ - stream_write_UINT32(s, flags); /* flags */ + Stream_Write_UINT32(s, 0); /* CodePage */ + Stream_Write_UINT32(s, flags); /* flags */ - stream_write_UINT16(s, cbDomain); /* cbDomain */ - stream_write_UINT16(s, cbUserName); /* cbUserName */ - stream_write_UINT16(s, cbPassword); /* cbPassword */ - stream_write_UINT16(s, cbAlternateShell); /* cbAlternateShell */ - stream_write_UINT16(s, cbWorkingDir); /* cbWorkingDir */ + Stream_Write_UINT16(s, cbDomain); /* cbDomain */ + Stream_Write_UINT16(s, cbUserName); /* cbUserName */ + Stream_Write_UINT16(s, cbPassword); /* cbPassword */ + Stream_Write_UINT16(s, cbAlternateShell); /* cbAlternateShell */ + Stream_Write_UINT16(s, cbWorkingDir); /* cbWorkingDir */ if (cbDomain > 0) - stream_write(s, domain, cbDomain); - stream_write_UINT16(s, 0); + Stream_Write(s, domain, cbDomain); + Stream_Write_UINT16(s, 0); if (cbUserName > 0) - stream_write(s, userName, cbUserName); - stream_write_UINT16(s, 0); + Stream_Write(s, userName, cbUserName); + Stream_Write_UINT16(s, 0); if (cbPassword > 0) - stream_write(s, password, cbPassword); - stream_write_UINT16(s, 0); + Stream_Write(s, password, cbPassword); + Stream_Write_UINT16(s, 0); if (cbAlternateShell > 0) - stream_write(s, alternateShell, cbAlternateShell); - stream_write_UINT16(s, 0); + Stream_Write(s, alternateShell, cbAlternateShell); + Stream_Write_UINT16(s, 0); if (cbWorkingDir > 0) - stream_write(s, workingDir, cbWorkingDir); - stream_write_UINT16(s, 0); + Stream_Write(s, workingDir, cbWorkingDir); + Stream_Write_UINT16(s, 0); free(domain); free(userName); @@ -491,9 +491,9 @@ BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < (4 + 52 + 4 + 512 + 4)) return FALSE; - stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ + Stream_Read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ Stream_Seek(s, 52); /* domain (52 bytes) */ - stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ + Stream_Read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ Stream_Seek(s, 512); /* userName (512 bytes) */ Stream_Seek_UINT32(s); /* sessionId (4 bytes) */ @@ -511,8 +511,8 @@ BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s) Stream_Seek_UINT16(s); /* version (2 bytes) */ Stream_Seek_UINT32(s); /* size (4 bytes) */ Stream_Seek_UINT32(s); /* sessionId (4 bytes) */ - stream_read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ - stream_read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ + Stream_Read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */ + Stream_Read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */ Stream_Seek(s, 558); /* pad */ if (Stream_GetRemainingLength(s) < cbDomain+cbUserName) @@ -542,8 +542,8 @@ BOOL rdp_recv_logon_error_info(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */ - stream_read_UINT32(s, errorNotificationType); /* errorNotificationType (4 bytes) */ + Stream_Read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */ + Stream_Read_UINT32(s, errorNotificationType); /* errorNotificationType (4 bytes) */ IFCALL(rdp->instance->LogonErrorInfo, rdp->instance, errorNotificationData, errorNotificationType); @@ -559,8 +559,8 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, Length); /* The total size in bytes of this structure */ - stream_read_UINT32(s, fieldsPresent); /* fieldsPresent (4 bytes) */ + Stream_Read_UINT16(s, Length); /* The total size in bytes of this structure */ + Stream_Read_UINT32(s, fieldsPresent); /* fieldsPresent (4 bytes) */ /* logonFields */ @@ -569,7 +569,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ + Stream_Read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ if (rdp_read_server_auto_reconnect_cookie(s, rdp->settings) == FALSE) return FALSE; @@ -580,7 +580,7 @@ BOOL rdp_recv_logon_info_extended(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ + Stream_Read_UINT32(s, cbFieldData); /* cbFieldData (4 bytes) */ if (rdp_recv_logon_error_info(rdp, s) == FALSE) return FALSE; @@ -600,7 +600,7 @@ BOOL rdp_recv_save_session_info(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, infoType); /* infoType (4 bytes) */ + Stream_Read_UINT32(s, infoType); /* infoType (4 bytes) */ //fprintf(stderr, "%s\n", INFO_TYPE_LOGON_STRINGS[infoType]); diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 0f7d5edaf..848a66505 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -31,14 +31,14 @@ void rdp_write_client_input_pdu_header(wStream* s, UINT16 number) { - stream_write_UINT16(s, 1); /* numberEvents (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, 1); /* numberEvents (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ } void rdp_write_input_event_header(wStream* s, UINT32 time, UINT16 type) { - stream_write_UINT32(s, time); /* eventTime (4 bytes) */ - stream_write_UINT16(s, type); /* messageType (2 bytes) */ + Stream_Write_UINT32(s, time); /* eventTime (4 bytes) */ + Stream_Write_UINT16(s, type); /* messageType (2 bytes) */ } wStream* rdp_client_input_pdu_init(rdpRdp* rdp, UINT16 type) @@ -57,8 +57,8 @@ void rdp_send_client_input_pdu(rdpRdp* rdp, wStream* s) void input_write_synchronize_event(wStream* s, UINT32 flags) { - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ - stream_write_UINT32(s, flags); /* toggleFlags (4 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT32(s, flags); /* toggleFlags (4 bytes) */ } void input_send_synchronize_event(rdpInput* input, UINT32 flags) @@ -73,9 +73,9 @@ void input_send_synchronize_event(rdpInput* input, UINT32 flags) void input_write_keyboard_event(wStream* s, UINT16 flags, UINT16 code) { - stream_write_UINT16(s, flags); /* keyboardFlags (2 bytes) */ - stream_write_UINT16(s, code); /* keyCode (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, flags); /* keyboardFlags (2 bytes) */ + Stream_Write_UINT16(s, code); /* keyCode (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ } void input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) @@ -90,9 +90,9 @@ void input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) void input_write_unicode_keyboard_event(wStream* s, UINT16 flags, UINT16 code) { - stream_write_UINT16(s, flags); /* keyboardFlags (2 bytes) */ - stream_write_UINT16(s, code); /* unicodeCode (2 bytes) */ - stream_write_UINT16(s, 0); /* pad2Octets (2 bytes) */ + Stream_Write_UINT16(s, flags); /* keyboardFlags (2 bytes) */ + Stream_Write_UINT16(s, code); /* unicodeCode (2 bytes) */ + Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ } void input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) @@ -119,9 +119,9 @@ void input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 cod void input_write_mouse_event(wStream* s, UINT16 flags, UINT16 x, UINT16 y) { - stream_write_UINT16(s, flags); /* pointerFlags (2 bytes) */ - stream_write_UINT16(s, x); /* xPos (2 bytes) */ - stream_write_UINT16(s, y); /* yPos (2 bytes) */ + Stream_Write_UINT16(s, flags); /* pointerFlags (2 bytes) */ + Stream_Write_UINT16(s, x); /* xPos (2 bytes) */ + Stream_Write_UINT16(s, y); /* yPos (2 bytes) */ } void input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) @@ -136,9 +136,9 @@ void input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) void input_write_extended_mouse_event(wStream* s, UINT16 flags, UINT16 x, UINT16 y) { - stream_write_UINT16(s, flags); /* pointerFlags (2 bytes) */ - stream_write_UINT16(s, x); /* xPos (2 bytes) */ - stream_write_UINT16(s, y); /* yPos (2 bytes) */ + Stream_Write_UINT16(s, flags); /* pointerFlags (2 bytes) */ + Stream_Write_UINT16(s, x); /* xPos (2 bytes) */ + Stream_Write_UINT16(s, y); /* yPos (2 bytes) */ } void input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) @@ -185,7 +185,7 @@ void input_send_fastpath_keyboard_event(rdpInput* input, UINT16 flags, UINT16 co eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0; eventFlags |= (flags & KBD_FLAGS_EXTENDED) ? FASTPATH_INPUT_KBDFLAGS_EXTENDED : 0; s = fastpath_input_pdu_init(rdp->fastpath, eventFlags, FASTPATH_INPUT_EVENT_SCANCODE); - stream_write_BYTE(s, code); /* keyCode (1 byte) */ + Stream_Write_UINT8(s, code); /* keyCode (1 byte) */ fastpath_send_input_pdu(rdp->fastpath, s); } @@ -197,7 +197,7 @@ void input_send_fastpath_unicode_keyboard_event(rdpInput* input, UINT16 flags, U eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0; s = fastpath_input_pdu_init(rdp->fastpath, eventFlags, FASTPATH_INPUT_EVENT_UNICODE); - stream_write_UINT16(s, code); /* unicodeCode (2 bytes) */ + Stream_Write_UINT16(s, code); /* unicodeCode (2 bytes) */ fastpath_send_input_pdu(rdp->fastpath, s); } @@ -230,21 +230,21 @@ void input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates, UI s = fastpath_input_pdu_init_header(rdp->fastpath); /* send a tab up like mstsc.exe */ eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; - stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ - stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + Stream_Write_UINT8(s, eventFlags); /* Key Release event (1 byte) */ + Stream_Write_UINT8(s, 0x0f); /* keyCode (1 byte) */ /* send the toggle key states */ eventFlags = (toggleStates & 0x1F) | FASTPATH_INPUT_EVENT_SYNC << 5; - stream_write_BYTE(s, eventFlags); /* toggle state (1 byte) */ + Stream_Write_UINT8(s, eventFlags); /* toggle state (1 byte) */ /* send another tab up like mstsc.exe */ eventFlags = FASTPATH_INPUT_KBDFLAGS_RELEASE | FASTPATH_INPUT_EVENT_SCANCODE << 5; - stream_write_BYTE(s, eventFlags); /* Key Release event (1 byte) */ - stream_write_BYTE(s, 0x0f); /* keyCode (1 byte) */ + Stream_Write_UINT8(s, eventFlags); /* Key Release event (1 byte) */ + Stream_Write_UINT8(s, 0x0f); /* keyCode (1 byte) */ /* finish with a mouse pointer position like mstsc.exe */ eventFlags = 0 | FASTPATH_INPUT_EVENT_MOUSE << 5; - stream_write_BYTE(s, eventFlags); /* Mouse Pointer event (1 byte) */ + Stream_Write_UINT8(s, eventFlags); /* Mouse Pointer event (1 byte) */ input_write_extended_mouse_event(s, PTR_FLAGS_MOVE, x, y); fastpath_send_multiple_input_pdu(rdp->fastpath, s, 4); @@ -258,7 +258,7 @@ static BOOL input_recv_sync_event(rdpInput* input, wStream* s) return FALSE; Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ - stream_read_UINT32(s, toggleFlags); /* toggleFlags (4 bytes) */ + Stream_Read_UINT32(s, toggleFlags); /* toggleFlags (4 bytes) */ IFCALL(input->SynchronizeEvent, input, toggleFlags); @@ -272,8 +272,8 @@ static BOOL input_recv_keyboard_event(rdpInput* input, wStream* s) if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ - stream_read_UINT16(s, keyCode); /* keyCode (2 bytes) */ + Stream_Read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ + Stream_Read_UINT16(s, keyCode); /* keyCode (2 bytes) */ Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ IFCALL(input->KeyboardEvent, input, keyboardFlags, keyCode); @@ -288,8 +288,8 @@ static BOOL input_recv_unicode_keyboard_event(rdpInput* input, wStream* s) if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ - stream_read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ + Stream_Read_UINT16(s, keyboardFlags); /* keyboardFlags (2 bytes) */ + Stream_Read_UINT16(s, unicodeCode); /* unicodeCode (2 bytes) */ Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* @@ -317,9 +317,9 @@ static BOOL input_recv_mouse_event(rdpInput* input, wStream* s) if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ - stream_read_UINT16(s, xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ + Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ IFCALL(input->MouseEvent, input, pointerFlags, xPos, yPos); @@ -333,9 +333,9 @@ static BOOL input_recv_extended_mouse_event(rdpInput* input, wStream* s) if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ - stream_read_UINT16(s, xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointerFlags); /* pointerFlags (2 bytes) */ + Stream_Read_UINT16(s, xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, yPos); /* yPos (2 bytes) */ IFCALL(input->ExtendedMouseEvent, input, pointerFlags, xPos, yPos); @@ -350,7 +350,7 @@ static BOOL input_recv_event(rdpInput* input, wStream* s) return FALSE; Stream_Seek(s, 4); /* eventTime (4 bytes), ignored by the server */ - stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ + Stream_Read_UINT16(s, messageType); /* messageType (2 bytes) */ switch (messageType) { @@ -396,7 +396,7 @@ BOOL input_recv(rdpInput* input, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, numberEvents); /* numberEvents (2 bytes) */ + Stream_Read_UINT16(s, numberEvents); /* numberEvents (2 bytes) */ Stream_Seek(s, 2); /* pad2Octets (2 bytes) */ /* Each input event uses 6 exactly bytes. */ diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index 71711fb60..16a8f2f05 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -129,9 +129,9 @@ BOOL license_read_preamble(wStream* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsg if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_BYTE(s, *bMsgType); /* bMsgType (1 byte) */ - stream_read_BYTE(s, *flags); /* flags (1 byte) */ - stream_read_UINT16(s, *wMsgSize); /* wMsgSize (2 bytes) */ + Stream_Read_UINT8(s, *bMsgType); /* bMsgType (1 byte) */ + Stream_Read_UINT8(s, *flags); /* flags (1 byte) */ + Stream_Read_UINT16(s, *wMsgSize); /* wMsgSize (2 bytes) */ return TRUE; } @@ -148,9 +148,9 @@ BOOL license_read_preamble(wStream* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsg void license_write_preamble(wStream* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSize) { /* preamble (4 bytes) */ - stream_write_BYTE(s, bMsgType); /* bMsgType (1 byte) */ - stream_write_BYTE(s, flags); /* flags (1 byte) */ - stream_write_UINT16(s, wMsgSize); /* wMsgSize (2 bytes) */ + Stream_Write_UINT8(s, bMsgType); /* bMsgType (1 byte) */ + Stream_Write_UINT8(s, flags); /* flags (1 byte) */ + Stream_Write_UINT16(s, wMsgSize); /* wMsgSize (2 bytes) */ } /** @@ -466,17 +466,17 @@ BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */ + Stream_Read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */ - stream_read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */ + Stream_Read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */ if (Stream_GetRemainingLength(s) < productInfo->cbCompanyName + 4) return FALSE; productInfo->pbCompanyName = (BYTE*) malloc(productInfo->cbCompanyName); - stream_read(s, productInfo->pbCompanyName, productInfo->cbCompanyName); + Stream_Read(s, productInfo->pbCompanyName, productInfo->cbCompanyName); - stream_read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */ + Stream_Read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */ if (Stream_GetRemainingLength(s) < productInfo->cbProductId) { @@ -486,7 +486,7 @@ BOOL license_read_product_info(wStream* s, PRODUCT_INFO* productInfo) } productInfo->pbProductId = (BYTE*) malloc(productInfo->cbProductId); - stream_read(s, productInfo->pbProductId, productInfo->cbProductId); + Stream_Read(s, productInfo->pbProductId, productInfo->cbProductId); return TRUE; } @@ -543,8 +543,8 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, wBlobType); /* wBlobType (2 bytes) */ - stream_read_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ + Stream_Read_UINT16(s, wBlobType); /* wBlobType (2 bytes) */ + Stream_Read_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ if (Stream_GetRemainingLength(s) < blob->length) return FALSE; @@ -564,7 +564,7 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) blob->type = wBlobType; blob->data = (BYTE*) malloc(blob->length); - stream_read(s, blob->data, blob->length); /* blobData */ + Stream_Read(s, blob->data, blob->length); /* blobData */ return TRUE; } @@ -577,11 +577,11 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) void license_write_binary_blob(wStream* s, LICENSE_BLOB* blob) { - stream_write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ - stream_write_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ + Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ + Stream_Write_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ if (blob->length > 0) - stream_write(s, blob->data, blob->length); /* blobData */ + Stream_Write(s, blob->data, blob->length); /* blobData */ } void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blob, UINT32 ModulusLength) @@ -596,13 +596,13 @@ void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blo return; } - stream_write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ - stream_write_UINT16(s, length); /* wBlobLen (2 bytes) */ + Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ + Stream_Write_UINT16(s, length); /* wBlobLen (2 bytes) */ if (blob->length > 0) - stream_write(s, blob->data, blob->length); /* blobData */ + Stream_Write(s, blob->data, blob->length); /* blobData */ - stream_write_zero(s, length - blob->length); + Stream_Write_zero(s, length - blob->length); } /** @@ -652,7 +652,7 @@ BOOL license_read_scope_list(wStream* s, SCOPE_LIST* scopeList) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */ + Stream_Read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */ scopeList->count = scopeCount; scopeList->array = (LICENSE_BLOB*) malloc(sizeof(LICENSE_BLOB) * scopeCount); @@ -725,7 +725,7 @@ BOOL license_read_license_request_packet(rdpLicense* license, wStream* s) if (Stream_GetRemainingLength(s) < 32) return FALSE; - stream_read(s, license->ServerRandom, 32); + Stream_Read(s, license->ServerRandom, 32); /* ProductInfo */ if (!license_read_product_info(s, license->ProductInfo)) @@ -784,7 +784,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */ + Stream_Read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */ /* EncryptedPlatformChallenge */ license->EncryptedPlatformChallenge->type = BB_ANY_BLOB; @@ -794,7 +794,7 @@ BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s) if (Stream_GetRemainingLength(s) < 16) return FALSE; - stream_read(s, MacData, 16); /* MACData (16 bytes) */ + Stream_Read(s, MacData, 16); /* MACData (16 bytes) */ license_decrypt_platform_challenge(license); @@ -859,8 +859,8 @@ BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, dwErrorCode); /* dwErrorCode (4 bytes) */ - stream_read_UINT32(s, dwStateTransition); /* dwStateTransition (4 bytes) */ + Stream_Read_UINT32(s, dwErrorCode); /* dwErrorCode (4 bytes) */ + Stream_Read_UINT32(s, dwStateTransition); /* dwStateTransition (4 bytes) */ if (!license_read_binary_blob(s, license->ErrorInfo)) /* bbErrorInfo */ return FALSE; @@ -914,9 +914,9 @@ void license_write_new_license_request_packet(rdpLicense* license, wStream* s) PlatformId = CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT; - stream_write_UINT32(s, PreferredKeyExchangeAlg); /* PreferredKeyExchangeAlg (4 bytes) */ - stream_write_UINT32(s, PlatformId); /* PlatformId (4 bytes) */ - stream_write(s, license->ClientRandom, 32); /* ClientRandom (32 bytes) */ + Stream_Write_UINT32(s, PreferredKeyExchangeAlg); /* PreferredKeyExchangeAlg (4 bytes) */ + Stream_Write_UINT32(s, PlatformId); /* PlatformId (4 bytes) */ + Stream_Write(s, license->ClientRandom, 32); /* ClientRandom (32 bytes) */ license_write_encrypted_premaster_secret_blob(s, license->EncryptedPremasterSecret, license->ModulusLength); /* EncryptedPremasterSecret */ license_write_binary_blob(s, license->ClientUserName); /* ClientUserName */ license_write_binary_blob(s, license->ClientMachineName); /* ClientMachineName */ @@ -990,7 +990,7 @@ void license_write_platform_challenge_response_packet(rdpLicense* license, wStre { license_write_binary_blob(s, license->EncryptedPlatformChallenge); /* EncryptedPlatformChallengeResponse */ license_write_binary_blob(s, license->EncryptedHardwareId); /* EncryptedHWID */ - stream_write(s, macData, 16); /* MACData */ + Stream_Write(s, macData, 16); /* MACData */ } /** @@ -1062,8 +1062,8 @@ BOOL license_send_valid_client_error_packet(rdpLicense* license) DEBUG_LICENSE("Sending Error Alert Packet"); - stream_write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */ - stream_write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */ + Stream_Write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */ + Stream_Write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */ license_write_binary_blob(s, license->ErrorInfo); diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 486a35fd7..ea83878e1 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -296,7 +296,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) length = Stream_GetPosition(tmps); ber_write_sequence_tag(s, length); - stream_write(s, stream_get_head(tmps), length); + Stream_Write(s, stream_get_head(tmps), length); stream_free(tmps); } @@ -414,7 +414,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) length = Stream_GetPosition(tmps); /* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */ ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length); - stream_write(s, stream_get_head(tmps), length); + Stream_Write(s, stream_get_head(tmps), length); stream_free(tmps); } @@ -441,7 +441,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) length = Stream_GetPosition(tmps); ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length); - stream_write(s, stream_get_head(tmps), length); + Stream_Write(s, stream_get_head(tmps), length); stream_free(tmps); } diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index d04e8bece..11dfbb9a0 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -277,15 +277,15 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego) } s = transport_send_stream_init(nego->transport, cbSize); - stream_write_UINT32(s, cbSize); /* cbSize */ - stream_write_UINT32(s, 0); /* Flags */ - stream_write_UINT32(s, PRECONNECTION_PDU_V2); /* Version */ - stream_write_UINT32(s, nego->preconnection_id); /* Id */ - stream_write_UINT16(s, cchPCB); /* cchPCB */ + Stream_Write_UINT32(s, cbSize); /* cbSize */ + Stream_Write_UINT32(s, 0); /* Flags */ + Stream_Write_UINT32(s, PRECONNECTION_PDU_V2); /* Version */ + Stream_Write_UINT32(s, nego->preconnection_id); /* Id */ + Stream_Write_UINT16(s, cchPCB); /* cchPCB */ if (wszPCB) { - stream_write(s, wszPCB, cchPCB * 2); /* wszPCB */ + Stream_Write(s, wszPCB, cchPCB * 2); /* wszPCB */ free(wszPCB); } @@ -497,7 +497,7 @@ int nego_recv(rdpTransport* transport, wStream* s, void* extra) { /* rdpNegData (optional) */ - stream_read_BYTE(s, type); /* Type */ + Stream_Read_UINT8(s, type); /* Type */ switch (type) { @@ -578,7 +578,7 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) /* Optional routingToken or cookie, ending with CR+LF */ while (Stream_GetRemainingLength(s) > 0) { - stream_read_BYTE(s, c); + Stream_Read_UINT8(s, c); if (c != '\x0D') continue; @@ -597,7 +597,7 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) { /* rdpNegData (optional) */ - stream_read_BYTE(s, type); /* Type */ + Stream_Read_UINT8(s, type); /* Type */ if (type != TYPE_RDP_NEG_REQ) { @@ -651,9 +651,9 @@ BOOL nego_send_negotiation_request(rdpNego* nego) if (nego->RoutingToken) { - stream_write(s, nego->RoutingToken, nego->RoutingTokenLength); - stream_write_BYTE(s, 0x0D); /* CR */ - stream_write_BYTE(s, 0x0A); /* LF */ + Stream_Write(s, nego->RoutingToken, nego->RoutingTokenLength); + Stream_Write_UINT8(s, 0x0D); /* CR */ + Stream_Write_UINT8(s, 0x0A); /* LF */ length += nego->RoutingTokenLength + 2; } else if (nego->cookie) @@ -663,10 +663,10 @@ BOOL nego_send_negotiation_request(rdpNego* nego) if (cookie_length > (int) nego->cookie_max_length) cookie_length = nego->cookie_max_length; - stream_write(s, "Cookie: mstshash=", 17); - stream_write(s, (BYTE*) nego->cookie, cookie_length); - stream_write_BYTE(s, 0x0D); /* CR */ - stream_write_BYTE(s, 0x0A); /* LF */ + Stream_Write(s, "Cookie: mstshash=", 17); + Stream_Write(s, (BYTE*) nego->cookie, cookie_length); + Stream_Write_UINT8(s, 0x0D); /* CR */ + Stream_Write_UINT8(s, 0x0A); /* LF */ length += cookie_length + 19; } @@ -675,10 +675,10 @@ BOOL nego_send_negotiation_request(rdpNego* nego) if ((nego->requested_protocols > PROTOCOL_RDP) || (nego->sendNegoData)) { /* RDP_NEG_DATA must be present for TLS and NLA */ - stream_write_BYTE(s, TYPE_RDP_NEG_REQ); - stream_write_BYTE(s, 0); /* flags, must be set to zero */ - stream_write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ - stream_write_UINT32(s, nego->requested_protocols); /* requestedProtocols */ + Stream_Write_UINT8(s, TYPE_RDP_NEG_REQ); + Stream_Write_UINT8(s, 0); /* flags, must be set to zero */ + Stream_Write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ + Stream_Write_UINT32(s, nego->requested_protocols); /* requestedProtocols */ length += 8; } @@ -707,9 +707,9 @@ void nego_process_negotiation_request(rdpNego* nego, wStream* s) DEBUG_NEGO("RDP_NEG_REQ"); - stream_read_BYTE(s, flags); - stream_read_UINT16(s, length); - stream_read_UINT32(s, nego->requested_protocols); + Stream_Read_UINT8(s, flags); + Stream_Read_UINT16(s, length); + Stream_Read_UINT32(s, nego->requested_protocols); DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols); @@ -735,9 +735,9 @@ void nego_process_negotiation_response(rdpNego* nego, wStream* s) return; } - stream_read_BYTE(s, nego->flags); - stream_read_UINT16(s, length); - stream_read_UINT32(s, nego->selected_protocol); + Stream_Read_UINT8(s, nego->flags); + Stream_Read_UINT16(s, length); + Stream_Read_UINT32(s, nego->selected_protocol); nego->state = NEGO_STATE_FINAL; } @@ -756,9 +756,9 @@ void nego_process_negotiation_failure(rdpNego* nego, wStream* s) DEBUG_NEGO("RDP_NEG_FAILURE"); - stream_read_BYTE(s, flags); - stream_read_UINT16(s, length); - stream_read_UINT32(s, failureCode); + Stream_Read_UINT8(s, flags); + Stream_Read_UINT16(s, length); + Stream_Read_UINT32(s, failureCode); switch (failureCode) { @@ -816,23 +816,23 @@ BOOL nego_send_negotiation_response(rdpNego* nego) if (nego->selected_protocol > PROTOCOL_RDP) { /* RDP_NEG_DATA must be present for TLS and NLA */ - stream_write_BYTE(s, TYPE_RDP_NEG_RSP); - stream_write_BYTE(s, EXTENDED_CLIENT_DATA_SUPPORTED); /* flags */ - stream_write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ - stream_write_UINT32(s, nego->selected_protocol); /* selectedProtocol */ + Stream_Write_UINT8(s, TYPE_RDP_NEG_RSP); + Stream_Write_UINT8(s, EXTENDED_CLIENT_DATA_SUPPORTED); /* flags */ + Stream_Write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ + Stream_Write_UINT32(s, nego->selected_protocol); /* selectedProtocol */ length += 8; } else if (!settings->RdpSecurity) { - stream_write_BYTE(s, TYPE_RDP_NEG_FAILURE); - stream_write_BYTE(s, 0); /* flags */ - stream_write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ + Stream_Write_UINT8(s, TYPE_RDP_NEG_FAILURE); + Stream_Write_UINT8(s, 0); /* flags */ + Stream_Write_UINT16(s, 8); /* RDP_NEG_DATA length (8) */ /* * TODO: Check for other possibilities, * like SSL_NOT_ALLOWED_BY_SERVER. */ fprintf(stderr, "nego_send_negotiation_response: client supports only Standard RDP Security\n"); - stream_write_UINT32(s, SSL_REQUIRED_BY_SERVER); + Stream_Write_UINT32(s, SSL_REQUIRED_BY_SERVER); length += 8; status = FALSE; } diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 5bbdcf0f0..9d6eee2fb 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -1173,7 +1173,7 @@ int credssp_recv(rdpCredssp* credssp) Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->negoToken, length); - stream_read(s, credssp->negoToken.pvBuffer, length); + Stream_Read(s, credssp->negoToken.pvBuffer, length); credssp->negoToken.cbBuffer = length; } @@ -1184,7 +1184,7 @@ int credssp_recv(rdpCredssp* credssp) Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->authInfo, length); - stream_read(s, credssp->authInfo.pvBuffer, length); + Stream_Read(s, credssp->authInfo.pvBuffer, length); credssp->authInfo.cbBuffer = length; } @@ -1195,7 +1195,7 @@ int credssp_recv(rdpCredssp* credssp) Stream_GetRemainingLength(s) < length) return -1; sspi_SecBufferAlloc(&credssp->pubKeyAuth, length); - stream_read(s, credssp->pubKeyAuth.pvBuffer, length); + Stream_Read(s, credssp->pubKeyAuth.pvBuffer, length); credssp->pubKeyAuth.cbBuffer = length; } diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 128285626..014e97fc5 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -164,7 +164,7 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, lsi8); + Stream_Read_UINT8(s, lsi8); *coord += lsi8; } else @@ -172,7 +172,7 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, lsi16); + Stream_Read_UINT16(s, lsi16); *coord = lsi16; } @@ -181,7 +181,7 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) static INLINE BOOL update_write_coord(wStream* s, INT32 coord) { - stream_write_UINT16(s, coord); + Stream_Write_UINT16(s, coord); return TRUE; } @@ -190,7 +190,7 @@ static INLINE BOOL update_write_coord_delta(wStream* s, INT32 prevCoord, INT32 n INT8 lsi8; lsi8 = nextCoord - prevCoord; - stream_write_BYTE(s, lsi8); + Stream_Write_UINT8(s, lsi8); return TRUE; } @@ -202,11 +202,11 @@ static INLINE BOOL update_read_color(wStream* s, UINT32* color) if (Stream_GetRemainingLength(s) < 3) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color = byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= (byte << 16); return TRUE; @@ -217,11 +217,11 @@ static INLINE BOOL update_write_color(wStream* s, UINT32 color) BYTE byte; byte = (color & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = ((color >> 8) & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = ((color >> 16) & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); return TRUE; } @@ -230,11 +230,11 @@ static INLINE void update_read_colorref(wStream* s, UINT32* color) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color = byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= (byte << 16); Stream_Seek_BYTE(s); } @@ -243,11 +243,11 @@ static INLINE void update_read_color_quad(wStream* s, UINT32* color) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color = (byte << 16); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *color |= byte; Stream_Seek_BYTE(s); } @@ -258,7 +258,7 @@ static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x80) { @@ -266,7 +266,7 @@ static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) return FALSE; *value = (byte & 0x7F) << 8; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= byte; } else @@ -287,14 +287,14 @@ static INLINE BOOL update_write_2byte_unsigned(wStream* s, UINT32 value) if (value >= 0x7F) { byte = ((value & 0x7F00) >> 8); - stream_write_BYTE(s, byte | 0x80); + Stream_Write_UINT8(s, byte | 0x80); byte = (value & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else { byte = (value & 0x7F); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } return TRUE; @@ -308,7 +308,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); negative = (byte & 0x40) ? TRUE : FALSE; @@ -319,7 +319,7 @@ static INLINE BOOL update_read_2byte_signed(wStream* s, INT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value = (*value << 8) | byte; } @@ -350,9 +350,9 @@ static INLINE BOOL update_write_2byte_signed(wStream* s, INT32 value) if (negative) byte |= 0x40; - stream_write_BYTE(s, byte | 0x80); + Stream_Write_UINT8(s, byte | 0x80); byte = (value & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else { @@ -361,7 +361,7 @@ static INLINE BOOL update_write_2byte_signed(wStream* s, INT32 value) if (negative) byte |= 0x40; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } return TRUE; @@ -375,7 +375,7 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); count = (byte & 0xC0) >> 6; @@ -390,25 +390,25 @@ static INLINE BOOL update_read_4byte_unsigned(wStream* s, UINT32* value) case 1: *value = (byte & 0x3F) << 8; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= byte; break; case 2: *value = (byte & 0x3F) << 16; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= byte; break; case 3: *value = (byte & 0x3F) << 24; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= (byte << 16); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value |= byte; break; @@ -425,34 +425,34 @@ static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value) if (value <= 0x3F) { - stream_write_BYTE(s, value); + Stream_Write_UINT8(s, value); } else if (value <= 0x3FFF) { byte = (value >> 8) & 0x3F; - stream_write_BYTE(s, byte | 0x40); + Stream_Write_UINT8(s, byte | 0x40); byte = (value & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else if (value <= 0x3FFFFF) { byte = (value >> 16) & 0x3F; - stream_write_BYTE(s, byte | 0x80); + Stream_Write_UINT8(s, byte | 0x80); byte = (value >> 8) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (value & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else if (value <= 0x3FFFFF) { byte = (value >> 24) & 0x3F; - stream_write_BYTE(s, byte | 0xC0); + Stream_Write_UINT8(s, byte | 0xC0); byte = (value >> 16) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (value >> 8) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (value & 0xFF); - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else { @@ -468,7 +468,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x40) *value = (byte | ~0x3F); @@ -479,7 +479,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value) { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *value = (*value << 8) | byte; } return TRUE; @@ -489,10 +489,10 @@ static INLINE void update_read_glyph_delta(wStream* s, UINT16* value) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte == 0x80) - stream_read_UINT16(s, *value); + Stream_Read_UINT16(s, *value); else *value = (byte & 0x3F); } @@ -501,7 +501,7 @@ static INLINE void update_seek_glyph_delta(wStream* s) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x80) Stream_Seek_BYTE(s); @@ -514,7 +514,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, brush->x); + Stream_Read_UINT8(s, brush->x); } if (fieldFlags & ORDER_FIELD_02) @@ -522,7 +522,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, brush->y); + Stream_Read_UINT8(s, brush->y); } if (fieldFlags & ORDER_FIELD_03) @@ -530,7 +530,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, brush->style); + Stream_Read_UINT8(s, brush->style); } if (fieldFlags & ORDER_FIELD_04) @@ -538,7 +538,7 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, brush->hatch); + Stream_Read_UINT8(s, brush->hatch); } if (brush->style & CACHED_BRUSH) @@ -557,13 +557,13 @@ static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlag return FALSE; brush->data = (BYTE*) brush->p8x8; - stream_read_BYTE(s, brush->data[7]); - stream_read_BYTE(s, brush->data[6]); - stream_read_BYTE(s, brush->data[5]); - stream_read_BYTE(s, brush->data[4]); - stream_read_BYTE(s, brush->data[3]); - stream_read_BYTE(s, brush->data[2]); - stream_read_BYTE(s, brush->data[1]); + Stream_Read_UINT8(s, brush->data[7]); + Stream_Read_UINT8(s, brush->data[6]); + Stream_Read_UINT8(s, brush->data[5]); + Stream_Read_UINT8(s, brush->data[4]); + Stream_Read_UINT8(s, brush->data[3]); + Stream_Read_UINT8(s, brush->data[2]); + Stream_Read_UINT8(s, brush->data[1]); brush->data[0] = brush->hatch; } @@ -574,17 +574,17 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFla { if (fieldFlags & ORDER_FIELD_01) { - stream_write_BYTE(s, brush->x); + Stream_Write_UINT8(s, brush->x); } if (fieldFlags & ORDER_FIELD_02) { - stream_write_BYTE(s, brush->y); + Stream_Write_UINT8(s, brush->y); } if (fieldFlags & ORDER_FIELD_03) { - stream_write_BYTE(s, brush->style); + Stream_Write_UINT8(s, brush->style); } if (brush->style & CACHED_BRUSH) @@ -599,19 +599,19 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFla if (fieldFlags & ORDER_FIELD_04) { - stream_write_BYTE(s, brush->hatch); + Stream_Write_UINT8(s, brush->hatch); } if (fieldFlags & ORDER_FIELD_05) { brush->data = (BYTE*) brush->p8x8; - stream_write_BYTE(s, brush->data[7]); - stream_write_BYTE(s, brush->data[6]); - stream_write_BYTE(s, brush->data[5]); - stream_write_BYTE(s, brush->data[4]); - stream_write_BYTE(s, brush->data[3]); - stream_write_BYTE(s, brush->data[2]); - stream_write_BYTE(s, brush->data[1]); + Stream_Write_UINT8(s, brush->data[7]); + Stream_Write_UINT8(s, brush->data[6]); + Stream_Write_UINT8(s, brush->data[5]); + Stream_Write_UINT8(s, brush->data[4]); + Stream_Write_UINT8(s, brush->data[3]); + Stream_Write_UINT8(s, brush->data[2]); + Stream_Write_UINT8(s, brush->data[1]); brush->data[0] = brush->hatch; } @@ -713,7 +713,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ - stream_read_BYTE(s, TARGET); \ + Stream_Read_UINT8(s, TARGET); \ } \ } while(0) @@ -725,8 +725,8 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int fprintf(stderr, "%s: error reading %s or %s\n", __FUNCTION__, #TARGET1, #TARGET2); \ return FALSE; \ } \ - stream_read_BYTE(s, TARGET1); \ - stream_read_BYTE(s, TARGET2); \ + Stream_Read_UINT8(s, TARGET1); \ + Stream_Read_UINT8(s, TARGET2); \ } \ } while(0) @@ -738,7 +738,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ - stream_read_UINT16(s, TARGET); \ + Stream_Read_UINT16(s, TARGET); \ } \ } while(0) #define ORDER_FIELD_UINT32(NO, TARGET) \ @@ -749,7 +749,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int fprintf(stderr, "%s: error reading %s\n", __FUNCTION__, #TARGET); \ return FALSE; \ } \ - stream_read_UINT32(s, TARGET); \ + Stream_Read_UINT32(s, TARGET); \ } \ } while(0) @@ -775,7 +775,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int fprintf(stderr, "%s: error reading length %s\n", __FUNCTION__, #TARGET_LEN); \ return FALSE; \ }\ - stream_read_UINT16(s, TARGET_LEN); \ + Stream_Read_UINT16(s, TARGET_LEN); \ if (!stream_skip(s, TARGET_LEN)) { \ fprintf(stderr, "%s: error skipping %d bytes\n", __FUNCTION__, TARGET_LEN); \ return FALSE; \ @@ -823,7 +823,7 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* update_write_coord(s, patblt->nHeight); orderInfo->fieldFlags |= ORDER_FIELD_05; - stream_write_BYTE(s, patblt->bRop); + Stream_Write_UINT8(s, patblt->bRop); orderInfo->fieldFlags |= ORDER_FIELD_06; update_write_coord(s, patblt->backColor); @@ -871,7 +871,7 @@ BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* update_write_coord(s, scrblt->nHeight); orderInfo->fieldFlags |= ORDER_FIELD_05; - stream_write_BYTE(s, scrblt->bRop); + Stream_Write_UINT8(s, scrblt->bRop); orderInfo->fieldFlags |= ORDER_FIELD_06; update_write_coord(s, scrblt->nXSrc); @@ -896,7 +896,7 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFFFF00) | byte; } @@ -905,7 +905,7 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); opaque_rect->color = (opaque_rect->color & 0xFFFF00FF) | (byte << 8); } @@ -914,7 +914,7 @@ BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_REC if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); opaque_rect->color = (opaque_rect->color & 0xFF00FFFF) | (byte << 16); } @@ -938,15 +938,15 @@ BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RE orderInfo->fieldFlags |= ORDER_FIELD_05; byte = opaque_rect->color & 0x000000FF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); orderInfo->fieldFlags |= ORDER_FIELD_06; byte = (opaque_rect->color & 0x0000FF00) >> 8; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); orderInfo->fieldFlags |= ORDER_FIELD_07; byte = (opaque_rect->color & 0x00FF0000) >> 16; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); return TRUE; } @@ -974,7 +974,7 @@ BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DST { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, multi_dstblt->cbData); + Stream_Read_UINT16(s, multi_dstblt->cbData); return update_read_delta_rects(s, multi_dstblt->rectangles, multi_dstblt->numRectangles); } return TRUE; @@ -999,7 +999,7 @@ BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PAT { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, multi_patblt->cbData); + Stream_Read_UINT16(s, multi_patblt->cbData); if (!update_read_delta_rects(s, multi_patblt->rectangles, multi_patblt->numRectangles)) return FALSE; } @@ -1021,7 +1021,7 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, multi_scrblt->cbData); + Stream_Read_UINT16(s, multi_scrblt->cbData); return update_read_delta_rects(s, multi_scrblt->rectangles, multi_scrblt->numRectangles); } return TRUE; @@ -1040,7 +1040,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFFFF00) | byte; } @@ -1048,7 +1048,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFFFF00FF) | (byte << 8); } @@ -1056,7 +1056,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); multi_opaque_rect->color = (multi_opaque_rect->color & 0xFF00FFFF) | (byte << 16); } @@ -1066,7 +1066,7 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, multi_opaque_rect->cbData); + Stream_Read_UINT16(s, multi_opaque_rect->cbData); return update_read_delta_rects(s, multi_opaque_rect->rectangles, multi_opaque_rect->numRectangles); } return TRUE; @@ -1119,7 +1119,7 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, polyline->cbData); + Stream_Read_UINT8(s, polyline->cbData); if (polyline->points == NULL) polyline->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * polyline->numPoints); @@ -1157,7 +1157,7 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* cacheId = (memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8); orderInfo->fieldFlags |= ORDER_FIELD_01; - stream_write_UINT16(s, cacheId); + Stream_Write_UINT16(s, cacheId); orderInfo->fieldFlags |= ORDER_FIELD_02; update_write_coord(s, memblt->nLeftRect); @@ -1172,7 +1172,7 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* update_write_coord(s, memblt->nHeight); orderInfo->fieldFlags |= ORDER_FIELD_06; - stream_write_BYTE(s, memblt->bRop); + Stream_Write_UINT8(s, memblt->bRop); orderInfo->fieldFlags |= ORDER_FIELD_07; update_write_coord(s, memblt->nXSrc); @@ -1181,7 +1181,7 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* update_write_coord(s, memblt->nYSrc); orderInfo->fieldFlags |= ORDER_FIELD_09; - stream_write_UINT16(s, memblt->cacheIndex); + Stream_Write_UINT16(s, memblt->cacheIndex); return TRUE; } @@ -1247,7 +1247,7 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, glyph_index->cbData); + Stream_Read_UINT8(s, glyph_index->cbData); if (Stream_GetRemainingLength(s) < glyph_index->cbData) return FALSE; @@ -1264,16 +1264,16 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_IND orderInfo->fieldFlags = 0; orderInfo->fieldFlags |= ORDER_FIELD_01; - stream_write_BYTE(s, glyph_index->cacheId); + Stream_Write_UINT8(s, glyph_index->cacheId); orderInfo->fieldFlags |= ORDER_FIELD_02; - stream_write_BYTE(s, glyph_index->flAccel); + Stream_Write_UINT8(s, glyph_index->flAccel); orderInfo->fieldFlags |= ORDER_FIELD_03; - stream_write_BYTE(s, glyph_index->ulCharInc); + Stream_Write_UINT8(s, glyph_index->ulCharInc); orderInfo->fieldFlags |= ORDER_FIELD_04; - stream_write_BYTE(s, glyph_index->fOpRedundant); + Stream_Write_UINT8(s, glyph_index->fOpRedundant); orderInfo->fieldFlags |= ORDER_FIELD_05; update_write_color(s, glyph_index->backColor); @@ -1282,28 +1282,28 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_IND update_write_color(s, glyph_index->foreColor); orderInfo->fieldFlags |= ORDER_FIELD_07; - stream_write_UINT16(s, glyph_index->bkLeft); + Stream_Write_UINT16(s, glyph_index->bkLeft); orderInfo->fieldFlags |= ORDER_FIELD_08; - stream_write_UINT16(s, glyph_index->bkTop); + Stream_Write_UINT16(s, glyph_index->bkTop); orderInfo->fieldFlags |= ORDER_FIELD_09; - stream_write_UINT16(s, glyph_index->bkRight); + Stream_Write_UINT16(s, glyph_index->bkRight); orderInfo->fieldFlags |= ORDER_FIELD_10; - stream_write_UINT16(s, glyph_index->bkBottom); + Stream_Write_UINT16(s, glyph_index->bkBottom); orderInfo->fieldFlags |= ORDER_FIELD_11; - stream_write_UINT16(s, glyph_index->opLeft); + Stream_Write_UINT16(s, glyph_index->opLeft); orderInfo->fieldFlags |= ORDER_FIELD_12; - stream_write_UINT16(s, glyph_index->opTop); + Stream_Write_UINT16(s, glyph_index->opTop); orderInfo->fieldFlags |= ORDER_FIELD_13; - stream_write_UINT16(s, glyph_index->opRight); + Stream_Write_UINT16(s, glyph_index->opRight); orderInfo->fieldFlags |= ORDER_FIELD_14; - stream_write_UINT16(s, glyph_index->opBottom); + Stream_Write_UINT16(s, glyph_index->opBottom); orderInfo->fieldFlags |= ORDER_FIELD_15; orderInfo->fieldFlags |= ORDER_FIELD_16; @@ -1313,13 +1313,13 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_IND update_write_brush(s, &glyph_index->brush, orderInfo->fieldFlags >> 14); orderInfo->fieldFlags |= ORDER_FIELD_20; - stream_write_UINT16(s, glyph_index->x); + Stream_Write_UINT16(s, glyph_index->x); orderInfo->fieldFlags |= ORDER_FIELD_21; - stream_write_UINT16(s, glyph_index->y); + Stream_Write_UINT16(s, glyph_index->y); orderInfo->fieldFlags |= ORDER_FIELD_22; - stream_write_BYTE(s, glyph_index->cbData); + Stream_Write_UINT8(s, glyph_index->cbData); Stream_Write(s, glyph_index->data, glyph_index->cbData); return TRUE; @@ -1346,7 +1346,7 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, fast_index->cbData); + Stream_Read_UINT8(s, fast_index->cbData); if (Stream_GetRemainingLength(s) < fast_index->cbData) return FALSE; @@ -1381,7 +1381,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, fast_glyph->cbData); + Stream_Read_UINT8(s, fast_glyph->cbData); if (Stream_GetRemainingLength(s) < fast_glyph->cbData) return FALSE; @@ -1411,7 +1411,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); - stream_read(s, glyph->aj, glyph->cb); + Stream_Read(s, glyph->aj, glyph->cb); } s->pointer = phold + fast_glyph->cbData; @@ -1432,7 +1432,7 @@ BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, polygon_sc->cbData); + Stream_Read_UINT8(s, polygon_sc->cbData); if (polygon_sc->points == NULL) polygon_sc->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * polygon_sc->numPoints); @@ -1462,7 +1462,7 @@ BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ { if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, polygon_cb->cbData); + Stream_Read_UINT8(s, polygon_cb->cbData); if (polygon_cb->points == NULL) polygon_cb->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * polygon_cb->numPoints); @@ -1510,13 +1510,13 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if (Stream_GetRemainingLength(s) < 9) return FALSE; - stream_read_BYTE(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ - stream_read_BYTE(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ - stream_read_BYTE(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */ - stream_read_BYTE(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */ - stream_read_UINT16(s, cache_bitmap_order->bitmapLength); /* bitmapLength (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_order->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT8(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */ + Stream_Read_UINT16(s, cache_bitmap_order->bitmapLength); /* bitmapLength (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_order->cacheIndex); /* cacheIndex (2 bytes) */ if (compressed) { @@ -1527,7 +1527,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ + Stream_Read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ cache_bitmap_order->bitmapLength -= 8; } @@ -1566,8 +1566,8 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ - stream_read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ } if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH) @@ -1598,10 +1598,10 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ - stream_read_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize; } @@ -1636,8 +1636,8 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache if (cache_bitmap_v2->flags & CBR2_PERSISTENT_KEY_PRESENT) { - stream_write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ - stream_write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ + Stream_Write_UINT32(s, cache_bitmap_v2->key1); /* key1 (4 bytes) */ + Stream_Write_UINT32(s, cache_bitmap_v2->key2); /* key2 (4 bytes) */ } if (cache_bitmap_v2->flags & CBR2_HEIGHT_SAME_AS_WIDTH) @@ -1663,10 +1663,10 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache { if (!(cache_bitmap_v2->flags & CBR2_NO_BITMAP_COMPRESSION_HDR)) { - stream_write_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ - stream_write_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ - stream_write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ - stream_write_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ + Stream_Write_UINT16(s, cache_bitmap_v2->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ + Stream_Write_UINT16(s, cache_bitmap_v2->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ + Stream_Write_UINT16(s, cache_bitmap_v2->cbScanWidth); /* cbScanWidth (2 bytes) */ + Stream_Write_UINT16(s, cache_bitmap_v2->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize; } @@ -1695,19 +1695,19 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ if (Stream_GetRemainingLength(s) < 21) return FALSE; - stream_read_UINT16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */ - stream_read_UINT32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */ - stream_read_UINT32(s, cache_bitmap_v3_order->key2); /* key2 (4 bytes) */ + Stream_Read_UINT16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v3_order->key2); /* key2 (4 bytes) */ bitmapData = &cache_bitmap_v3_order->bitmapData; - stream_read_BYTE(s, bitmapData->bpp); + Stream_Read_UINT8(s, bitmapData->bpp); Stream_Seek_BYTE(s); /* reserved1 (1 byte) */ Stream_Seek_BYTE(s); /* reserved2 (1 byte) */ - stream_read_BYTE(s, bitmapData->codecID); /* codecID (1 byte) */ - stream_read_UINT16(s, bitmapData->width); /* width (2 bytes) */ - stream_read_UINT16(s, bitmapData->height); /* height (2 bytes) */ - stream_read_UINT32(s, bitmapData->length); /* length (4 bytes) */ + Stream_Read_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */ + Stream_Read_UINT16(s, bitmapData->width); /* width (2 bytes) */ + Stream_Read_UINT16(s, bitmapData->height); /* height (2 bytes) */ + Stream_Read_UINT32(s, bitmapData->length); /* length (4 bytes) */ if (Stream_GetRemainingLength(s) < bitmapData->length) return FALSE; @@ -1716,7 +1716,7 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ else bitmapData->data = (BYTE*) realloc(bitmapData->data, bitmapData->length); - stream_read(s, bitmapData->data, bitmapData->length); + Stream_Read(s, bitmapData->data, bitmapData->length); return TRUE; } @@ -1728,8 +1728,8 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca if (Stream_GetRemainingLength(s) < 3) return FALSE; - stream_read_BYTE(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */ - stream_read_UINT16(s, cache_color_table_order->numberColors); /* numberColors (2 bytes) */ + Stream_Read_UINT8(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */ + Stream_Read_UINT16(s, cache_color_table_order->numberColors); /* numberColors (2 bytes) */ if (cache_color_table_order->numberColors != 256) { @@ -1759,8 +1759,8 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_BYTE(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */ - stream_read_BYTE(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */ + Stream_Read_UINT8(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */ + Stream_Read_UINT8(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */ for (i = 0; i < (int) cache_glyph_order->cGlyphs; i++) { @@ -1769,13 +1769,13 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or if (Stream_GetRemainingLength(s) < 10) return FALSE; - stream_read_UINT16(s, glyph->cacheIndex); - stream_read_UINT16(s, lsi16); + Stream_Read_UINT16(s, glyph->cacheIndex); + Stream_Read_UINT16(s, lsi16); glyph->x = lsi16; - stream_read_UINT16(s, lsi16); + Stream_Read_UINT16(s, lsi16); glyph->y = lsi16; - stream_read_UINT16(s, glyph->cx); - stream_read_UINT16(s, glyph->cy); + Stream_Read_UINT16(s, glyph->cx); + Stream_Read_UINT16(s, glyph->cy); glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; @@ -1784,7 +1784,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); - stream_read(s, glyph->aj, glyph->cb); + Stream_Read(s, glyph->aj, glyph->cb); } if (flags & CG_GLYPH_UNICODE_PRESENT) @@ -1801,23 +1801,23 @@ BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph, INT16 lsi16; GLYPH_DATA* glyph; - stream_write_BYTE(s, cache_glyph->cacheId); /* cacheId (1 byte) */ - stream_write_BYTE(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ + Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */ + Stream_Write_UINT8(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ for (i = 0; i < (int) cache_glyph->cGlyphs; i++) { glyph = &cache_glyph->glyphData[i]; - stream_write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */ lsi16 = glyph->x; - stream_write_UINT16(s, lsi16); /* x (2 bytes) */ + Stream_Write_UINT16(s, lsi16); /* x (2 bytes) */ lsi16 = glyph->y; - stream_write_UINT16(s, lsi16); /* y (2 bytes) */ + Stream_Write_UINT16(s, lsi16); /* y (2 bytes) */ - stream_write_UINT16(s, glyph->cx); /* cx (2 bytes) */ - stream_write_UINT16(s, glyph->cy); /* cy (2 bytes) */ + Stream_Write_UINT16(s, glyph->cx); /* cx (2 bytes) */ + Stream_Write_UINT16(s, glyph->cy); /* cy (2 bytes) */ glyph->cb = ((glyph->cx + 7) / 8) * glyph->cy; glyph->cb += ((glyph->cb % 4) > 0) ? 4 - (glyph->cb % 4) : 0; @@ -1849,7 +1849,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, glyph->cacheIndex); + Stream_Read_UINT8(s, glyph->cacheIndex); if (!update_read_2byte_signed(s, &glyph->x) || !update_read_2byte_signed(s, &glyph->y) || @@ -1866,7 +1866,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl return FALSE; glyph->aj = (BYTE*) malloc(glyph->cb); - stream_read(s, glyph->aj, glyph->cb); + Stream_Read(s, glyph->aj, glyph->cb); } if (flags & CG_GLYPH_UNICODE_PRESENT) @@ -1890,7 +1890,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g { glyph = &cache_glyph_v2->glyphData[i]; - stream_write_BYTE(s, glyph->cacheIndex); + Stream_Write_UINT8(s, glyph->cacheIndex); if (!update_write_2byte_signed(s, glyph->x) || !update_write_2byte_signed(s, glyph->y) || @@ -1932,7 +1932,7 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp) for (x = 0; x < 8; x++) { if ((x % 4) == 0) - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); index = ((byte >> ((3 - (x % 4)) * 2)) & 0x03); @@ -1955,15 +1955,15 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_BYTE(s, cache_brush_order->index); /* cacheEntry (1 byte) */ + Stream_Read_UINT8(s, cache_brush_order->index); /* cacheEntry (1 byte) */ - stream_read_BYTE(s, iBitmapFormat); /* iBitmapFormat (1 byte) */ + Stream_Read_UINT8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */ cache_brush_order->bpp = BMF_BPP[iBitmapFormat]; - stream_read_BYTE(s, cache_brush_order->cx); /* cx (1 byte) */ - stream_read_BYTE(s, cache_brush_order->cy); /* cy (1 byte) */ - stream_read_BYTE(s, cache_brush_order->style); /* style (1 byte) */ - stream_read_BYTE(s, cache_brush_order->length); /* iBytes (1 byte) */ + Stream_Read_UINT8(s, cache_brush_order->cx); /* cx (1 byte) */ + Stream_Read_UINT8(s, cache_brush_order->cy); /* cy (1 byte) */ + Stream_Read_UINT8(s, cache_brush_order->style); /* style (1 byte) */ + Stream_Read_UINT8(s, cache_brush_order->length); /* iBytes (1 byte) */ if ((cache_brush_order->cx == 8) && (cache_brush_order->cy == 8)) { @@ -1983,7 +1983,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or for (i = 7; i >= 0; i--) { - stream_read_BYTE(s, cache_brush_order->data[i]); + Stream_Read_UINT8(s, cache_brush_order->data[i]); } } else @@ -2011,7 +2011,7 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or for (i = 7; i >= 0; i--) { - stream_read(s, &cache_brush_order->data[i * scanline], scanline); + Stream_Read(s, &cache_brush_order->data[i * scanline], scanline); } } } @@ -2030,12 +2030,12 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM if (Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, flags); /* flags (2 bytes) */ + Stream_Read_UINT16(s, flags); /* flags (2 bytes) */ create_offscreen_bitmap->id = flags & 0x7FFF; deleteListPresent = (flags & 0x8000) ? TRUE : FALSE; - stream_read_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */ - stream_read_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ + Stream_Read_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */ + Stream_Read_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ deleteList = &(create_offscreen_bitmap->deleteList); if (deleteListPresent) @@ -2043,7 +2043,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM int i; if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, deleteList->cIndices); + Stream_Read_UINT16(s, deleteList->cIndices); if (deleteList->cIndices > deleteList->sIndices) { @@ -2056,7 +2056,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM for (i = 0; i < (int) deleteList->cIndices; i++) { - stream_read_UINT16(s, deleteList->indices[i]); + Stream_Read_UINT16(s, deleteList->indices[i]); } } else @@ -2070,7 +2070,7 @@ BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_s { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ + Stream_Read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ return TRUE; } @@ -2080,15 +2080,15 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM if (Stream_GetRemainingLength(s) < 19) return FALSE; - stream_read_BYTE(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ - stream_read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ + Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ + Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ nineGridInfo = &(create_nine_grid_bitmap->nineGridInfo); - stream_read_UINT32(s, nineGridInfo->flFlags); /* flFlags (4 bytes) */ - stream_read_UINT16(s, nineGridInfo->ulLeftWidth); /* ulLeftWidth (2 bytes) */ - stream_read_UINT16(s, nineGridInfo->ulRightWidth); /* ulRightWidth (2 bytes) */ - stream_read_UINT16(s, nineGridInfo->ulTopHeight); /* ulTopHeight (2 bytes) */ - stream_read_UINT16(s, nineGridInfo->ulBottomHeight); /* ulBottomHeight (2 bytes) */ + Stream_Read_UINT32(s, nineGridInfo->flFlags); /* flFlags (4 bytes) */ + Stream_Read_UINT16(s, nineGridInfo->ulLeftWidth); /* ulLeftWidth (2 bytes) */ + Stream_Read_UINT16(s, nineGridInfo->ulRightWidth); /* ulRightWidth (2 bytes) */ + Stream_Read_UINT16(s, nineGridInfo->ulTopHeight); /* ulTopHeight (2 bytes) */ + Stream_Read_UINT16(s, nineGridInfo->ulBottomHeight); /* ulBottomHeight (2 bytes) */ update_read_colorref(s, &nineGridInfo->crTransparent); /* crTransparent (4 bytes) */ return TRUE; } @@ -2097,7 +2097,7 @@ BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, frame_marker->action); /* action (4 bytes) */ + Stream_Read_UINT32(s, frame_marker->action); /* action (4 bytes) */ return TRUE; } @@ -2105,20 +2105,20 @@ BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER { if (Stream_GetRemainingLength(s) < 10) // 8 + 2 at least return FALSE; - stream_read_BYTE(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */ - stream_read_BYTE(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */ - stream_read_UINT16(s, stream_bitmap_first->bitmapType); /* bitmapType (2 bytes) */ - stream_read_UINT16(s, stream_bitmap_first->bitmapWidth); /* bitmapWidth (2 bytes) */ - stream_read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */ + Stream_Read_UINT8(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */ + Stream_Read_UINT8(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */ + Stream_Read_UINT16(s, stream_bitmap_first->bitmapType); /* bitmapType (2 bytes) */ + Stream_Read_UINT16(s, stream_bitmap_first->bitmapWidth); /* bitmapWidth (2 bytes) */ + Stream_Read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */ if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2) { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */ + Stream_Read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */ } else { if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */ + Stream_Read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */ } FIELD_SKIP_BUFFER16(s, stream_bitmap_first->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */ @@ -2129,8 +2129,8 @@ BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* { if (Stream_GetRemainingLength(s) < 5) return FALSE; - stream_read_BYTE(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */ - stream_read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */ + Stream_Read_UINT8(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */ + Stream_Read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */ FIELD_SKIP_BUFFER16(s, stream_bitmap_next->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */ return TRUE; } @@ -2140,9 +2140,9 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* if (Stream_GetRemainingLength(s) < 11) return FALSE; Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ - stream_read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */ - stream_read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ - stream_read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ return stream_skip(s, draw_gdiplus_first->cbSize); /* emfRecords */ } @@ -2161,9 +2161,9 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw if (Stream_GetRemainingLength(s) < 11) return FALSE; Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ - stream_read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */ - stream_read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ - stream_read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ return stream_skip(s, draw_gdiplus_end->cbSize); /* emfRecords */ } @@ -2172,11 +2172,11 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F { if (Stream_GetRemainingLength(s) < 11) return FALSE; - stream_read_BYTE(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */ - stream_read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */ - stream_read_UINT16(s, draw_gdiplus_cache_first->cacheIndex); /* cacheIndex (2 bytes) */ - stream_read_UINT16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */ - stream_read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */ + Stream_Read_UINT8(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */ return stream_skip(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */ } @@ -2185,9 +2185,9 @@ BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NE { if (Stream_GetRemainingLength(s) < 7) return FALSE; - stream_read_BYTE(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */ - stream_read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */ - stream_read_UINT16(s, draw_gdiplus_cache_next->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT8(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheIndex); /* cacheIndex (2 bytes) */ FIELD_SKIP_BUFFER16(s, draw_gdiplus_cache_next->cbSize); /* cbSize(2 bytes) + emfRecords */ return TRUE; @@ -2197,11 +2197,11 @@ BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END { if (Stream_GetRemainingLength(s) < 11) return FALSE; - stream_read_BYTE(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */ - stream_read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */ - stream_read_UINT16(s, draw_gdiplus_cache_end->cacheIndex); /* cacheIndex (2 bytes) */ - stream_read_UINT16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */ - stream_read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */ + Stream_Read_UINT8(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */ + Stream_Read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */ return stream_skip(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */ } @@ -2228,7 +2228,7 @@ BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fi *fieldFlags = 0; for (i = 0; i < fieldBytes; i++) { - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *fieldFlags |= byte << (i * 8); } @@ -2242,23 +2242,23 @@ BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fi if (fieldBytes == 1) { byte = fieldFlags & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else if (fieldBytes == 2) { byte = fieldFlags & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (fieldFlags >> 8) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else if (fieldBytes == 3) { byte = fieldFlags & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (fieldFlags >> 8) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); byte = (fieldFlags >> 16) & 0xFF; - stream_write_BYTE(s, byte); + Stream_Write_UINT8(s, byte); } else { @@ -2274,7 +2274,7 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, flags); /* field flags */ + Stream_Read_UINT8(s, flags); /* field flags */ if (flags & BOUND_LEFT) { @@ -2331,7 +2331,7 @@ BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) orderInfo = &(primary->order_info); if (flags & ORDER_TYPE_CHANGE) - stream_read_BYTE(s, orderInfo->orderType); /* orderType (1 byte) */ + Stream_Read_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */ if (orderInfo->orderType >= PRIMARY_DRAWING_ORDER_COUNT) { @@ -2518,9 +2518,9 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) if (Stream_GetRemainingLength(s) < 5) return FALSE; - stream_read_UINT16(s, orderLength); /* orderLength (2 bytes) */ - stream_read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - stream_read_BYTE(s, orderType); /* orderType (1 byte) */ + Stream_Read_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Read_UINT8(s, orderType); /* orderType (1 byte) */ next = s->pointer + ((INT16) orderLength) + 7; @@ -2707,7 +2707,7 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, controlFlags); /* controlFlags (1 byte) */ + Stream_Read_UINT8(s, controlFlags); /* controlFlags (1 byte) */ if (!(controlFlags & ORDER_STANDARD)) return update_recv_altsec_order(update, s, controlFlags); diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index ca017e9ac..7592b3069 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -137,7 +137,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE: if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, client->ack_frame_id); + Stream_Read_UINT32(s, client->ack_frame_id); break; case DATA_PDU_TYPE_REFRESH_RECT: diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 6e9534ce5..b079e5b6d 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -82,7 +82,7 @@ BOOL rdp_read_security_header(wStream* s, UINT16* flags) /* Basic Security Header */ if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, *flags); /* flags */ + Stream_Read_UINT16(s, *flags); /* flags */ Stream_Seek(s, 2); /* flagsHi (unused) */ return TRUE; } @@ -97,8 +97,8 @@ BOOL rdp_read_security_header(wStream* s, UINT16* flags) void rdp_write_security_header(wStream* s, UINT16 flags) { /* Basic Security Header */ - stream_write_UINT16(s, flags); /* flags */ - stream_write_UINT16(s, 0); /* flagsHi (unused) */ + Stream_Write_UINT16(s, flags); /* flags */ + Stream_Write_UINT16(s, 0); /* flagsHi (unused) */ } BOOL rdp_read_share_control_header(wStream* s, UINT16* length, UINT16* type, UINT16* channel_id) @@ -107,16 +107,16 @@ BOOL rdp_read_share_control_header(wStream* s, UINT16* length, UINT16* type, UIN return FALSE; /* Share Control Header */ - stream_read_UINT16(s, *length); /* totalLength */ + Stream_Read_UINT16(s, *length); /* totalLength */ if (*length - 2 > Stream_GetRemainingLength(s)) return FALSE; - stream_read_UINT16(s, *type); /* pduType */ + Stream_Read_UINT16(s, *type); /* pduType */ *type &= 0x0F; /* type is in the 4 least significant bits */ if (*length > 4) - stream_read_UINT16(s, *channel_id); /* pduSource */ + Stream_Read_UINT16(s, *channel_id); /* pduSource */ else *channel_id = 0; /* Windows XP can send such short DEACTIVATE_ALL PDUs. */ @@ -128,9 +128,9 @@ void rdp_write_share_control_header(wStream* s, UINT16 length, UINT16 type, UINT length -= RDP_PACKET_HEADER_MAX_LENGTH; /* Share Control Header */ - stream_write_UINT16(s, length); /* totalLength */ - stream_write_UINT16(s, type | 0x10); /* pduType */ - stream_write_UINT16(s, channel_id); /* pduSource */ + Stream_Write_UINT16(s, length); /* totalLength */ + Stream_Write_UINT16(s, type | 0x10); /* pduType */ + Stream_Write_UINT16(s, channel_id); /* pduSource */ } BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* share_id, @@ -140,13 +140,13 @@ BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* return FALSE; /* Share Data Header */ - stream_read_UINT32(s, *share_id); /* shareId (4 bytes) */ + Stream_Read_UINT32(s, *share_id); /* shareId (4 bytes) */ Stream_Seek_BYTE(s); /* pad1 (1 byte) */ Stream_Seek_BYTE(s); /* streamId (1 byte) */ - stream_read_UINT16(s, *length); /* uncompressedLength (2 bytes) */ - stream_read_BYTE(s, *type); /* pduType2, Data PDU Type (1 byte) */ - stream_read_BYTE(s, *compressed_type); /* compressedType (1 byte) */ - stream_read_UINT16(s, *compressed_len); /* compressedLength (2 bytes) */ + Stream_Read_UINT16(s, *length); /* uncompressedLength (2 bytes) */ + Stream_Read_UINT8(s, *type); /* pduType2, Data PDU Type (1 byte) */ + Stream_Read_UINT8(s, *compressed_type); /* compressedType (1 byte) */ + Stream_Read_UINT16(s, *compressed_len); /* compressedLength (2 bytes) */ return TRUE; } @@ -157,13 +157,13 @@ void rdp_write_share_data_header(wStream* s, UINT16 length, BYTE type, UINT32 sh length -= RDP_SHARE_DATA_HEADER_LENGTH; /* Share Data Header */ - stream_write_UINT32(s, share_id); /* shareId (4 bytes) */ - stream_write_BYTE(s, 0); /* pad1 (1 byte) */ - stream_write_BYTE(s, STREAM_LOW); /* streamId (1 byte) */ - stream_write_UINT16(s, length); /* uncompressedLength (2 bytes) */ - stream_write_BYTE(s, type); /* pduType2, Data PDU Type (1 byte) */ - stream_write_BYTE(s, 0); /* compressedType (1 byte) */ - stream_write_UINT16(s, 0); /* compressedLength (2 bytes) */ + Stream_Write_UINT32(s, share_id); /* shareId (4 bytes) */ + Stream_Write_UINT8(s, 0); /* pad1 (1 byte) */ + Stream_Write_UINT8(s, STREAM_LOW); /* streamId (1 byte) */ + Stream_Write_UINT16(s, length); /* uncompressedLength (2 bytes) */ + Stream_Write_UINT8(s, type); /* pduType2, Data PDU Type (1 byte) */ + Stream_Write_UINT8(s, 0); /* compressedType (1 byte) */ + Stream_Write_UINT16(s, 0); /* compressedLength (2 bytes) */ } static int rdp_security_stream_init(rdpRdp* rdp, wStream* s) @@ -305,7 +305,7 @@ void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id) mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0); per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */ per_write_integer16(s, channel_id, 0); /* channelId */ - stream_write_BYTE(s, 0x70); /* dataPriority + segmentation */ + Stream_Write_UINT8(s, 0x70); /* dataPriority + segmentation */ /* * We always encode length in two bytes, eventhough we could use * only one byte if length <= 0x7F. It is just easier that way, @@ -313,7 +313,7 @@ void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id) * the data first and then store the header. */ length = (length - RDP_PACKET_HEADER_MAX_LENGTH) | 0x8000; - stream_write_UINT16_be(s, length); /* userData (OCTET_STRING) */ + Stream_Write_UINT16_BE(s, length); /* userData (OCTET_STRING) */ } static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) @@ -335,8 +335,8 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) data = s->pointer + 12; length = length - (data - s->buffer); - stream_write_UINT16(s, 0x10); /* length */ - stream_write_BYTE(s, 0x1); /* TSFIPS_VERSION 1*/ + Stream_Write_UINT16(s, 0x10); /* length */ + Stream_Write_UINT8(s, 0x1); /* TSFIPS_VERSION 1*/ /* handle padding */ pad = 8 - (length % 8); @@ -346,7 +346,7 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) if (pad) memset(data+length, 0, pad); - stream_write_BYTE(s, pad); + Stream_Write_UINT8(s, pad); security_hmac_signature(data, length, s->pointer, rdp); Stream_Seek(s, 8); @@ -487,7 +487,7 @@ BOOL rdp_recv_set_error_info_data_pdu(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, rdp->errorInfo); /* errorInfo (4 bytes) */ + Stream_Read_UINT32(s, rdp->errorInfo); /* errorInfo (4 bytes) */ if (rdp->errorInfo != ERRINFO_SUCCESS) { @@ -695,9 +695,9 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) if (Stream_GetRemainingLength(s) < 12) return FALSE; - stream_read_UINT16(s, len); /* 0x10 */ - stream_read_BYTE(s, version); /* 0x1 */ - stream_read_BYTE(s, pad); + Stream_Read_UINT16(s, len); /* 0x10 */ + Stream_Read_UINT8(s, version); /* 0x1 */ + Stream_Read_UINT8(s, pad); sig = s->pointer; Stream_Seek(s, 8); /* signature */ @@ -724,7 +724,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read(s, wmac, sizeof(wmac)); + Stream_Read(s, wmac, sizeof(wmac)); length -= sizeof(wmac); if (!security_decrypt(s->pointer, length, rdp)) return FALSE; diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 16896d771..fc1240d78 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -66,13 +66,13 @@ BOOL rdp_string_read_length32(wStream* s, rdpString* string) if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, string->length); + Stream_Read_UINT32(s, string->length); if(Stream_GetRemainingLength(s) < string->length) return FALSE; string->unicode = (char*) malloc(string->length); - stream_read(s, string->unicode, string->length); + Stream_Read(s, string->unicode, string->length); ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) string->unicode, string->length / 2, &string->ascii, 0, NULL, NULL); @@ -96,10 +96,10 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 12) return FALSE; - stream_read_UINT16(s, flags); /* flags (2 bytes) */ - stream_read_UINT16(s, length); /* length (2 bytes) */ - stream_read_UINT32(s, redirection->sessionID); /* sessionID (4 bytes) */ - stream_read_UINT32(s, redirection->flags); /* redirFlags (4 bytes) */ + Stream_Read_UINT16(s, flags); /* flags (2 bytes) */ + Stream_Read_UINT16(s, length); /* length (2 bytes) */ + Stream_Read_UINT32(s, redirection->sessionID); /* sessionID (4 bytes) */ + Stream_Read_UINT32(s, redirection->flags); /* redirFlags (4 bytes) */ DEBUG_REDIR("flags: 0x%04X, length:%d, sessionID:0x%08X", flags, length, redirection->sessionID); @@ -118,12 +118,12 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) { if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, redirection->LoadBalanceInfoLength); + Stream_Read_UINT32(s, redirection->LoadBalanceInfoLength); if (Stream_GetRemainingLength(s) < redirection->LoadBalanceInfoLength) return FALSE; redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength); - stream_read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); + Stream_Read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); #ifdef WITH_DEBUG_REDIR DEBUG_REDIR("loadBalanceInfo:"); winpr_HexDump(redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); @@ -149,9 +149,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) /* Note: length (hopefully) includes double zero termination */ if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, redirection->PasswordCookieLength); + Stream_Read_UINT32(s, redirection->PasswordCookieLength); redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength); - stream_read(s, redirection->PasswordCookie, redirection->PasswordCookieLength); + Stream_Read(s, redirection->PasswordCookie, redirection->PasswordCookieLength); #ifdef WITH_DEBUG_REDIR DEBUG_REDIR("password_cookie:"); @@ -188,9 +188,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, targetNetAddressesLength); + Stream_Read_UINT32(s, targetNetAddressesLength); - stream_read_UINT32(s, redirection->targetNetAddressesCount); + Stream_Read_UINT32(s, redirection->targetNetAddressesCount); count = redirection->targetNetAddressesCount; redirection->targetNetAddresses = (rdpString*) malloc(count * sizeof(rdpString)); diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 3da81f25b..8e7031cf7 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -33,16 +33,16 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3 if (Stream_GetRemainingLength(s) < 20) return -1; - stream_read_UINT16(s, cmd->destLeft); - stream_read_UINT16(s, cmd->destTop); - stream_read_UINT16(s, cmd->destRight); - stream_read_UINT16(s, cmd->destBottom); - stream_read_BYTE(s, cmd->bpp); + Stream_Read_UINT16(s, cmd->destLeft); + Stream_Read_UINT16(s, cmd->destTop); + Stream_Read_UINT16(s, cmd->destRight); + Stream_Read_UINT16(s, cmd->destBottom); + Stream_Read_UINT8(s, cmd->bpp); Stream_Seek(s, 2); /* reserved1, reserved2 */ - stream_read_BYTE(s, cmd->codecID); - stream_read_UINT16(s, cmd->width); - stream_read_UINT16(s, cmd->height); - stream_read_UINT32(s, cmd->bitmapDataLength); + Stream_Read_UINT8(s, cmd->codecID); + Stream_Read_UINT16(s, cmd->width); + Stream_Read_UINT16(s, cmd->height); + Stream_Read_UINT32(s, cmd->bitmapDataLength); if (Stream_GetRemainingLength(s) < cmd->bitmapDataLength) return -1; @@ -63,7 +63,7 @@ static void update_send_frame_acknowledge(rdpRdp* rdp, UINT32 frameId) wStream* s; s = rdp_data_pdu_init(rdp); - stream_write_UINT32(s, frameId); + Stream_Write_UINT32(s, frameId); rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->user_id); } @@ -74,8 +74,8 @@ static int update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s, UINT3 if (Stream_GetRemainingLength(s) < 6) return -1; - stream_read_UINT16(s, marker->frameAction); - stream_read_UINT32(s, marker->frameId); + Stream_Read_UINT16(s, marker->frameAction); + Stream_Read_UINT32(s, marker->frameId); IFCALL(update->SurfaceFrameMarker, update->context, marker); @@ -101,7 +101,7 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s) { stream_get_mark(s, mark); - stream_read_UINT16(s, cmdType); + Stream_Read_UINT16(s, cmdType); size -= 2; switch (cmdType) @@ -138,26 +138,26 @@ void update_write_surfcmd_surface_bits_header(wStream* s, SURFACE_BITS_COMMAND* { Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH); - stream_write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS); + Stream_Write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS); - stream_write_UINT16(s, cmd->destLeft); - stream_write_UINT16(s, cmd->destTop); - stream_write_UINT16(s, cmd->destRight); - stream_write_UINT16(s, cmd->destBottom); - stream_write_BYTE(s, cmd->bpp); - stream_write_UINT16(s, 0); /* reserved1, reserved2 */ - stream_write_BYTE(s, cmd->codecID); - stream_write_UINT16(s, cmd->width); - stream_write_UINT16(s, cmd->height); - stream_write_UINT32(s, cmd->bitmapDataLength); + Stream_Write_UINT16(s, cmd->destLeft); + Stream_Write_UINT16(s, cmd->destTop); + Stream_Write_UINT16(s, cmd->destRight); + Stream_Write_UINT16(s, cmd->destBottom); + Stream_Write_UINT8(s, cmd->bpp); + Stream_Write_UINT16(s, 0); /* reserved1, reserved2 */ + Stream_Write_UINT8(s, cmd->codecID); + Stream_Write_UINT16(s, cmd->width); + Stream_Write_UINT16(s, cmd->height); + Stream_Write_UINT32(s, cmd->bitmapDataLength); } void update_write_surfcmd_frame_marker(wStream* s, UINT16 frameAction, UINT32 frameId) { Stream_EnsureRemainingCapacity(s, SURFCMD_FRAME_MARKER_LENGTH); - stream_write_UINT16(s, CMDTYPE_FRAME_MARKER); + Stream_Write_UINT16(s, CMDTYPE_FRAME_MARKER); - stream_write_UINT16(s, frameAction); - stream_write_UINT32(s, frameId); + Stream_Write_UINT16(s, frameAction); + Stream_Write_UINT32(s, frameId); } diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 85718f129..8a654fe34 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -34,14 +34,14 @@ void rdp_read_system_time(wStream* s, SYSTEM_TIME* system_time) { - stream_read_UINT16(s, system_time->wYear); /* wYear, must be set to 0 */ - stream_read_UINT16(s, system_time->wMonth); /* wMonth */ - stream_read_UINT16(s, system_time->wDayOfWeek); /* wDayOfWeek */ - stream_read_UINT16(s, system_time->wDay); /* wDay */ - stream_read_UINT16(s, system_time->wHour); /* wHour */ - stream_read_UINT16(s, system_time->wMinute); /* wMinute */ - stream_read_UINT16(s, system_time->wSecond); /* wSecond */ - stream_read_UINT16(s, system_time->wMilliseconds); /* wMilliseconds */ + Stream_Read_UINT16(s, system_time->wYear); /* wYear, must be set to 0 */ + Stream_Read_UINT16(s, system_time->wMonth); /* wMonth */ + Stream_Read_UINT16(s, system_time->wDayOfWeek); /* wDayOfWeek */ + Stream_Read_UINT16(s, system_time->wDay); /* wDay */ + Stream_Read_UINT16(s, system_time->wHour); /* wHour */ + Stream_Read_UINT16(s, system_time->wMinute); /* wMinute */ + Stream_Read_UINT16(s, system_time->wSecond); /* wSecond */ + Stream_Read_UINT16(s, system_time->wMilliseconds); /* wMilliseconds */ } /** @@ -53,14 +53,14 @@ void rdp_read_system_time(wStream* s, SYSTEM_TIME* system_time) void rdp_write_system_time(wStream* s, SYSTEM_TIME* system_time) { - stream_write_UINT16(s, system_time->wYear); /* wYear, must be set to 0 */ - stream_write_UINT16(s, system_time->wMonth); /* wMonth */ - stream_write_UINT16(s, system_time->wDayOfWeek); /* wDayOfWeek */ - stream_write_UINT16(s, system_time->wDay); /* wDay */ - stream_write_UINT16(s, system_time->wHour); /* wHour */ - stream_write_UINT16(s, system_time->wMinute); /* wMinute */ - stream_write_UINT16(s, system_time->wSecond); /* wSecond */ - stream_write_UINT16(s, system_time->wMilliseconds); /* wMilliseconds */ + Stream_Write_UINT16(s, system_time->wYear); /* wYear, must be set to 0 */ + Stream_Write_UINT16(s, system_time->wMonth); /* wMonth */ + Stream_Write_UINT16(s, system_time->wDayOfWeek); /* wDayOfWeek */ + Stream_Write_UINT16(s, system_time->wDay); /* wDay */ + Stream_Write_UINT16(s, system_time->wHour); /* wHour */ + Stream_Write_UINT16(s, system_time->wMinute); /* wMinute */ + Stream_Write_UINT16(s, system_time->wSecond); /* wSecond */ + Stream_Write_UINT16(s, system_time->wMilliseconds); /* wMilliseconds */ DEBUG_TIMEZONE("Time: y=%d,m=%d,dow=%d,d=%d, %02d:%02d:%02d.%03d", system_time->wYear, system_time->wMonth, system_time->wDayOfWeek, system_time->wDay, system_time->wHour, system_time->wMinute, @@ -84,7 +84,7 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) clientTimeZone = settings->ClientTimeZone; - stream_read_UINT32(s, clientTimeZone->bias); /* Bias */ + Stream_Read_UINT32(s, clientTimeZone->bias); /* Bias */ /* standardName (64 bytes) */ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL); @@ -94,7 +94,7 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) str = NULL; rdp_read_system_time(s, &clientTimeZone->standardDate); /* StandardDate */ - stream_read_UINT32(s, clientTimeZone->standardBias); /* StandardBias */ + Stream_Read_UINT32(s, clientTimeZone->standardBias); /* StandardBias */ /* daylightName (64 bytes) */ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), 64 / 2, &str, 0, NULL, NULL); @@ -103,7 +103,7 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) free(str); rdp_read_system_time(s, &clientTimeZone->daylightDate); /* DaylightDate */ - stream_read_UINT32(s, clientTimeZone->daylightBias); /* DaylightBias */ + Stream_Read_UINT32(s, clientTimeZone->daylightBias); /* DaylightBias */ return TRUE; } @@ -136,11 +136,11 @@ void rdp_write_client_time_zone(wStream* s, rdpSettings* settings) daylightNameLength = 62; /* Bias */ - stream_write_UINT32(s, clientTimeZone->bias); + Stream_Write_UINT32(s, clientTimeZone->bias); /* standardName (64 bytes) */ - stream_write(s, standardName, standardNameLength); - stream_write_zero(s, 64 - standardNameLength); + Stream_Write(s, standardName, standardNameLength); + Stream_Write_zero(s, 64 - standardNameLength); /* StandardDate */ rdp_write_system_time(s, &clientTimeZone->standardDate); @@ -149,19 +149,19 @@ void rdp_write_client_time_zone(wStream* s, rdpSettings* settings) /* Note that StandardBias is ignored if no valid standardDate is provided. */ /* StandardBias */ - stream_write_UINT32(s, clientTimeZone->standardBias); + Stream_Write_UINT32(s, clientTimeZone->standardBias); DEBUG_TIMEZONE("StandardBias=%d", clientTimeZone->standardBias); /* daylightName (64 bytes) */ - stream_write(s, daylightName, daylightNameLength); - stream_write_zero(s, 64 - daylightNameLength); + Stream_Write(s, daylightName, daylightNameLength); + Stream_Write_zero(s, 64 - daylightNameLength); /* DaylightDate */ rdp_write_system_time(s, &clientTimeZone->daylightDate); /* Note that DaylightBias is ignored if no valid daylightDate is provided. */ /* DaylightBias */ - stream_write_UINT32(s, clientTimeZone->daylightBias); + Stream_Write_UINT32(s, clientTimeZone->daylightBias); DEBUG_TIMEZONE("DaylightBias=%d", clientTimeZone->daylightBias); free(standardName); diff --git a/libfreerdp/core/tpdu.c b/libfreerdp/core/tpdu.c index d9d6a2e87..c7ac70a63 100644 --- a/libfreerdp/core/tpdu.c +++ b/libfreerdp/core/tpdu.c @@ -71,8 +71,8 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li) if(Stream_GetRemainingLength(s) < 3) return FALSE; - stream_read_BYTE(s, *li); /* LI */ - stream_read_BYTE(s, *code); /* Code */ + Stream_Read_UINT8(s, *li); /* LI */ + Stream_Read_UINT8(s, *code); /* Code */ if (*code == X224_TPDU_DATA) { @@ -98,18 +98,18 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li) void tpdu_write_header(wStream* s, UINT16 length, BYTE code) { - stream_write_BYTE(s, length); /* LI */ - stream_write_BYTE(s, code); /* code */ + Stream_Write_UINT8(s, length); /* LI */ + Stream_Write_UINT8(s, code); /* code */ if (code == X224_TPDU_DATA) { - stream_write_BYTE(s, 0x80); /* EOT */ + Stream_Write_UINT8(s, 0x80); /* EOT */ } else { - stream_write_UINT16(s, 0); /* DST-REF */ - stream_write_UINT16(s, 0); /* SRC-REF */ - stream_write_BYTE(s, 0); /* Class 0 */ + Stream_Write_UINT16(s, 0); /* DST-REF */ + Stream_Write_UINT16(s, 0); /* SRC-REF */ + Stream_Write_UINT8(s, 0); /* Class 0 */ } } diff --git a/libfreerdp/core/tpkt.c b/libfreerdp/core/tpkt.c index 4f0bdd524..cfd40bf6a 100644 --- a/libfreerdp/core/tpkt.c +++ b/libfreerdp/core/tpkt.c @@ -91,7 +91,7 @@ UINT16 tpkt_read_header(wStream* s) if (version == 3) { Stream_Seek(s, 2); - stream_read_UINT16_be(s, length); + Stream_Read_UINT16_BE(s, length); } else { @@ -110,7 +110,7 @@ UINT16 tpkt_read_header(wStream* s) void tpkt_write_header(wStream* s, UINT16 length) { - stream_write_BYTE(s, 3); /* version */ - stream_write_BYTE(s, 0); /* reserved */ - stream_write_UINT16_be(s, length); /* length */ + Stream_Write_UINT8(s, 3); /* version */ + Stream_Write_UINT8(s, 0); /* reserved */ + Stream_Write_UINT16_BE(s, length); /* length */ } diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 21d8f92c1..beec0b7cc 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -53,7 +53,7 @@ BOOL update_recv_orders(rdpUpdate* update, wStream* s) return FALSE; Stream_Seek_UINT16(s); /* pad2OctetsA (2 bytes) */ - stream_read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ + Stream_Read_UINT16(s, numberOrders); /* numberOrders (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */ while (numberOrders > 0) @@ -72,24 +72,24 @@ BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data) if (Stream_GetRemainingLength(s) < 18) return FALSE; - stream_read_UINT16(s, bitmap_data->destLeft); - stream_read_UINT16(s, bitmap_data->destTop); - stream_read_UINT16(s, bitmap_data->destRight); - stream_read_UINT16(s, bitmap_data->destBottom); - stream_read_UINT16(s, bitmap_data->width); - stream_read_UINT16(s, bitmap_data->height); - stream_read_UINT16(s, bitmap_data->bitsPerPixel); - stream_read_UINT16(s, bitmap_data->flags); - stream_read_UINT16(s, bitmap_data->bitmapLength); + Stream_Read_UINT16(s, bitmap_data->destLeft); + Stream_Read_UINT16(s, bitmap_data->destTop); + Stream_Read_UINT16(s, bitmap_data->destRight); + Stream_Read_UINT16(s, bitmap_data->destBottom); + Stream_Read_UINT16(s, bitmap_data->width); + Stream_Read_UINT16(s, bitmap_data->height); + Stream_Read_UINT16(s, bitmap_data->bitsPerPixel); + Stream_Read_UINT16(s, bitmap_data->flags); + Stream_Read_UINT16(s, bitmap_data->bitmapLength); if (bitmap_data->flags & BITMAP_COMPRESSION) { if (!(bitmap_data->flags & NO_BITMAP_COMPRESSION_HDR)) { - stream_read_UINT16(s, bitmap_data->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ - stream_read_UINT16(s, bitmap_data->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ - stream_read_UINT16(s, bitmap_data->cbScanWidth); /* cbScanWidth (2 bytes) */ - stream_read_UINT16(s, bitmap_data->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ + Stream_Read_UINT16(s, bitmap_data->cbCompFirstRowSize); /* cbCompFirstRowSize (2 bytes) */ + Stream_Read_UINT16(s, bitmap_data->cbCompMainBodySize); /* cbCompMainBodySize (2 bytes) */ + Stream_Read_UINT16(s, bitmap_data->cbScanWidth); /* cbScanWidth (2 bytes) */ + Stream_Read_UINT16(s, bitmap_data->cbUncompressedSize); /* cbUncompressedSize (2 bytes) */ bitmap_data->bitmapLength = bitmap_data->cbCompMainBodySize; } @@ -115,7 +115,7 @@ BOOL update_read_bitmap(rdpUpdate* update, wStream* s, BITMAP_UPDATE* bitmap_upd if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, bitmap_update->number); /* numberRectangles (2 bytes) */ + Stream_Read_UINT16(s, bitmap_update->number); /* numberRectangles (2 bytes) */ if (bitmap_update->number > bitmap_update->count) { @@ -150,7 +150,7 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_ return FALSE; Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ - stream_read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */ + Stream_Read_UINT32(s, palette_update->number); /* numberColors (4 bytes), must be set to 256 */ if (palette_update->number > 256) palette_update->number = 256; @@ -163,9 +163,9 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s, PALETTE_UPDATE* palette_ { entry = &palette_update->entries[i]; - stream_read_BYTE(s, entry->blue); - stream_read_BYTE(s, entry->green); - stream_read_BYTE(s, entry->red); + Stream_Read_UINT8(s, entry->blue); + Stream_Read_UINT8(s, entry->green); + Stream_Read_UINT8(s, entry->red); } return TRUE; } @@ -185,8 +185,8 @@ BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound) if (Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, play_sound->duration); /* duration (4 bytes) */ - stream_read_UINT32(s, play_sound->frequency); /* frequency (4 bytes) */ + Stream_Read_UINT32(s, play_sound->duration); /* duration (4 bytes) */ + Stream_Read_UINT32(s, play_sound->frequency); /* frequency (4 bytes) */ return TRUE; } @@ -205,8 +205,8 @@ BOOL update_read_pointer_position(wStream* s, POINTER_POSITION_UPDATE* pointer_p if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, pointer_position->xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, pointer_position->yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointer_position->xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, pointer_position->yPos); /* yPos (2 bytes) */ return TRUE; } @@ -215,7 +215,7 @@ BOOL update_read_pointer_system(wStream* s, POINTER_SYSTEM_UPDATE* pointer_syste if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, pointer_system->type); /* systemPointerType (4 bytes) */ + Stream_Read_UINT32(s, pointer_system->type); /* systemPointerType (4 bytes) */ return TRUE; } @@ -224,13 +224,13 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) if (Stream_GetRemainingLength(s) < 14) return FALSE; - stream_read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */ - stream_read_UINT16(s, pointer_color->xPos); /* xPos (2 bytes) */ - stream_read_UINT16(s, pointer_color->yPos); /* yPos (2 bytes) */ - stream_read_UINT16(s, pointer_color->width); /* width (2 bytes) */ - stream_read_UINT16(s, pointer_color->height); /* height (2 bytes) */ - stream_read_UINT16(s, pointer_color->lengthAndMask); /* lengthAndMask (2 bytes) */ - stream_read_UINT16(s, pointer_color->lengthXorMask); /* lengthXorMask (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->xPos); /* xPos (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->yPos); /* yPos (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->width); /* width (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->height); /* height (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->lengthAndMask); /* lengthAndMask (2 bytes) */ + Stream_Read_UINT16(s, pointer_color->lengthXorMask); /* lengthXorMask (2 bytes) */ /** * There does not seem to be any documentation on why @@ -253,7 +253,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) else pointer_color->xorMaskData = realloc(pointer_color->xorMaskData, pointer_color->lengthXorMask); - stream_read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask); + Stream_Read(s, pointer_color->xorMaskData, pointer_color->lengthXorMask); } if (pointer_color->lengthAndMask > 0) @@ -266,7 +266,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) else pointer_color->andMaskData = realloc(pointer_color->andMaskData, pointer_color->lengthAndMask); - stream_read(s, pointer_color->andMaskData, pointer_color->lengthAndMask); + Stream_Read(s, pointer_color->andMaskData, pointer_color->lengthAndMask); } if (Stream_GetRemainingLength(s) > 0) @@ -280,7 +280,7 @@ BOOL update_read_pointer_new(wStream* s, POINTER_NEW_UPDATE* pointer_new) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ + Stream_Read_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ return update_read_pointer_color(s, &pointer_new->colorPtrAttr); /* colorPtrAttr */ } @@ -289,7 +289,7 @@ BOOL update_read_pointer_cached(wStream* s, POINTER_CACHED_UPDATE* pointer_cache if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */ return TRUE; } @@ -302,7 +302,7 @@ BOOL update_recv_pointer(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < 2 + 2) return FALSE; - stream_read_UINT16(s, messageType); /* messageType (2 bytes) */ + Stream_Read_UINT16(s, messageType); /* messageType (2 bytes) */ Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ switch (messageType) @@ -351,7 +351,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, updateType); /* updateType (2 bytes) */ + Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ //fprintf(stderr, "%s Update Data PDU\n", UPDATE_TYPE_STRINGS[updateType]); @@ -455,15 +455,15 @@ static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* area { int i; - stream_write_BYTE(s, count); /* numberOfAreas (1 byte) */ + Stream_Write_UINT8(s, count); /* numberOfAreas (1 byte) */ Stream_Seek(s, 3); /* pad3Octets (3 bytes) */ for (i = 0; i < count; i++) { - stream_write_UINT16(s, areas[i].left); /* left (2 bytes) */ - stream_write_UINT16(s, areas[i].top); /* top (2 bytes) */ - stream_write_UINT16(s, areas[i].right); /* right (2 bytes) */ - stream_write_UINT16(s, areas[i].bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, areas[i].left); /* left (2 bytes) */ + Stream_Write_UINT16(s, areas[i].top); /* top (2 bytes) */ + Stream_Write_UINT16(s, areas[i].right); /* right (2 bytes) */ + Stream_Write_UINT16(s, areas[i].bottom); /* bottom (2 bytes) */ } } @@ -483,15 +483,15 @@ static void update_send_refresh_rect(rdpContext* context, BYTE count, RECTANGLE_ static void update_write_suppress_output(wStream* s, BYTE allow, RECTANGLE_16* area) { - stream_write_BYTE(s, allow); /* allowDisplayUpdates (1 byte) */ + Stream_Write_UINT8(s, allow); /* allowDisplayUpdates (1 byte) */ Stream_Seek(s, 3); /* pad3Octets (3 bytes) */ if (allow > 0) { - stream_write_UINT16(s, area->left); /* left (2 bytes) */ - stream_write_UINT16(s, area->top); /* top (2 bytes) */ - stream_write_UINT16(s, area->right); /* right (2 bytes) */ - stream_write_UINT16(s, area->bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, area->left); /* left (2 bytes) */ + Stream_Write_UINT16(s, area->top); /* top (2 bytes) */ + Stream_Write_UINT16(s, area->right); /* right (2 bytes) */ + Stream_Write_UINT16(s, area->bottom); /* bottom (2 bytes) */ } } @@ -516,7 +516,7 @@ static void update_send_surface_command(rdpContext* context, wStream* s) update = fastpath_update_pdu_init(rdp->fastpath); Stream_EnsureRemainingCapacity(update, Stream_GetPosition(s)); - stream_write(update, stream_get_head(s), Stream_GetPosition(s)); + Stream_Write(update, stream_get_head(s), Stream_GetPosition(s)); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update); } @@ -528,7 +528,7 @@ static void update_send_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* s = fastpath_update_pdu_init(rdp->fastpath); Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH + (int) surface_bits_command->bitmapDataLength); update_write_surfcmd_surface_bits_header(s, surface_bits_command); - stream_write(s, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength); + Stream_Write(s, surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, s); } @@ -550,7 +550,7 @@ static void update_send_frame_acknowledge(rdpContext* context, UINT32 frameId) if (rdp->settings->ReceivedCapabilities[CAPSET_TYPE_FRAME_ACKNOWLEDGE]) { s = rdp_data_pdu_init(rdp); - stream_write_UINT32(s, frameId); + Stream_Write_UINT32(s, frameId); rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FRAME_ACKNOWLEDGE, rdp->mcs->user_id); } } @@ -561,7 +561,7 @@ static void update_send_synchronize(rdpContext* context) rdpRdp* rdp = context->rdp; s = fastpath_update_pdu_init(rdp->fastpath); - stream_write_zero(s, 2); /* pad2Octets (2 bytes) */ + Stream_Write_zero(s, 2); /* pad2Octets (2 bytes) */ fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SYNCHRONIZE, s); } @@ -595,9 +595,9 @@ static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) em = Stream_Pointer(s); Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -627,9 +627,9 @@ static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) em = Stream_Pointer(s); Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -659,9 +659,9 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq em = Stream_Pointer(s); Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -691,9 +691,9 @@ static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) em = Stream_Pointer(s); Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -723,9 +723,9 @@ static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp em = Stream_Pointer(s); Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - stream_write_BYTE(s, orderInfo.orderType); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ + Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); Stream_Pointer(s) = em; @@ -752,11 +752,11 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD orderLength = (em - bm) - 13 - 2; Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ - stream_write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - stream_write_BYTE(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -781,11 +781,11 @@ static void update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cach orderLength = (em - bm) - 13 - 2; Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ - stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ - stream_write_BYTE(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -810,11 +810,11 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER orderLength = (em - bm) - 13 - 2; Stream_Pointer(s) = bm; - stream_write_UINT16(s, 1); /* numberOrders (2 bytes) */ - stream_write_BYTE(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ - stream_write_UINT16(s, orderLength); /* orderLength (2 bytes) */ - stream_write_UINT16(s, flags); /* extraFlags (2 bytes) */ - stream_write_BYTE(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ + Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ Stream_Pointer(s) = em; fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); @@ -840,21 +840,21 @@ static void update_write_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer { Stream_EnsureRemainingCapacity(s, 15 + (int) pointer_color->lengthAndMask + (int) pointer_color->lengthXorMask); - stream_write_UINT16(s, pointer_color->cacheIndex); - stream_write_UINT16(s, pointer_color->xPos); - stream_write_UINT16(s, pointer_color->yPos); - stream_write_UINT16(s, pointer_color->width); - stream_write_UINT16(s, pointer_color->height); - stream_write_UINT16(s, pointer_color->lengthAndMask); - stream_write_UINT16(s, pointer_color->lengthXorMask); + Stream_Write_UINT16(s, pointer_color->cacheIndex); + Stream_Write_UINT16(s, pointer_color->xPos); + Stream_Write_UINT16(s, pointer_color->yPos); + Stream_Write_UINT16(s, pointer_color->width); + Stream_Write_UINT16(s, pointer_color->height); + Stream_Write_UINT16(s, pointer_color->lengthAndMask); + Stream_Write_UINT16(s, pointer_color->lengthXorMask); if (pointer_color->lengthXorMask > 0) - stream_write(s, pointer_color->xorMaskData, pointer_color->lengthXorMask); + Stream_Write(s, pointer_color->xorMaskData, pointer_color->lengthXorMask); if (pointer_color->lengthAndMask > 0) - stream_write(s, pointer_color->andMaskData, pointer_color->lengthAndMask); + Stream_Write(s, pointer_color->andMaskData, pointer_color->lengthAndMask); - stream_write_BYTE(s, 0); /* pad (1 byte) */ + Stream_Write_UINT8(s, 0); /* pad (1 byte) */ } static void update_send_pointer_color(rdpContext* context, POINTER_COLOR_UPDATE* pointer_color) @@ -873,7 +873,7 @@ static void update_send_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* poi rdpRdp* rdp = context->rdp; s = fastpath_update_pdu_init(rdp->fastpath); - stream_write_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ + Stream_Write_UINT16(s, pointer_new->xorBpp); /* xorBpp (2 bytes) */ update_write_pointer_color(s, &pointer_new->colorPtrAttr); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_POINTER, s); } @@ -884,7 +884,7 @@ static void update_send_pointer_cached(rdpContext* context, POINTER_CACHED_UPDAT rdpRdp* rdp = context->rdp; s = fastpath_update_pdu_init(rdp->fastpath); - stream_write_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Write_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */ fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_CACHED, s); } @@ -897,7 +897,7 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_BYTE(s, numberOfAreas); + Stream_Read_UINT8(s, numberOfAreas); Stream_Seek(s, 3); /* pad3Octects */ if (Stream_GetRemainingLength(s) < numberOfAreas * 4 * 2) @@ -907,10 +907,10 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) for (index = 0; index < numberOfAreas; index++) { - stream_read_UINT16(s, areas[index].left); - stream_read_UINT16(s, areas[index].top); - stream_read_UINT16(s, areas[index].right); - stream_read_UINT16(s, areas[index].bottom); + Stream_Read_UINT16(s, areas[index].left); + Stream_Read_UINT16(s, areas[index].top); + Stream_Read_UINT16(s, areas[index].right); + Stream_Read_UINT16(s, areas[index].bottom); } IFCALL(update->RefreshRect, update->context, numberOfAreas, areas); @@ -927,7 +927,7 @@ BOOL update_read_suppress_output(rdpUpdate* update, wStream* s) if (Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_BYTE(s, allowDisplayUpdates); + Stream_Read_UINT8(s, allowDisplayUpdates); Stream_Seek(s, 3); /* pad3Octects */ if (allowDisplayUpdates > 0 && Stream_GetRemainingLength(s) < 8) diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index 44fd08e1b..7422f5b1f 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -32,25 +32,25 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info) { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT16(s, icon_info->cacheEntry); /* cacheEntry (2 bytes) */ - stream_read_BYTE(s, icon_info->cacheId); /* cacheId (1 byte) */ - stream_read_BYTE(s, icon_info->bpp); /* bpp (1 byte) */ - stream_read_UINT16(s, icon_info->width); /* width (2 bytes) */ - stream_read_UINT16(s, icon_info->height); /* height (2 bytes) */ + Stream_Read_UINT16(s, icon_info->cacheEntry); /* cacheEntry (2 bytes) */ + Stream_Read_UINT8(s, icon_info->cacheId); /* cacheId (1 byte) */ + Stream_Read_UINT8(s, icon_info->bpp); /* bpp (1 byte) */ + Stream_Read_UINT16(s, icon_info->width); /* width (2 bytes) */ + Stream_Read_UINT16(s, icon_info->height); /* height (2 bytes) */ /* cbColorTable is only present when bpp is 1, 2 or 4 */ if (icon_info->bpp == 1 || icon_info->bpp == 2 || icon_info->bpp == 4) { if(Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, icon_info->cbColorTable); /* cbColorTable (2 bytes) */ + Stream_Read_UINT16(s, icon_info->cbColorTable); /* cbColorTable (2 bytes) */ } else { icon_info->cbColorTable = 0; } if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT16(s, icon_info->cbBitsMask); /* cbBitsMask (2 bytes) */ - stream_read_UINT16(s, icon_info->cbBitsColor); /* cbBitsColor (2 bytes) */ + Stream_Read_UINT16(s, icon_info->cbBitsMask); /* cbBitsMask (2 bytes) */ + Stream_Read_UINT16(s, icon_info->cbBitsColor); /* cbBitsColor (2 bytes) */ if(Stream_GetRemainingLength(s) < icon_info->cbBitsMask + icon_info->cbBitsColor) return FALSE; @@ -60,21 +60,21 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info) icon_info->bitsMask = (BYTE*) malloc(icon_info->cbBitsMask); else icon_info->bitsMask = (BYTE*) realloc(icon_info->bitsMask, icon_info->cbBitsMask); - stream_read(s, icon_info->bitsMask, icon_info->cbBitsMask); + Stream_Read(s, icon_info->bitsMask, icon_info->cbBitsMask); /* colorTable */ if (icon_info->colorTable == NULL) icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable); else icon_info->colorTable = (BYTE*) realloc(icon_info->colorTable, icon_info->cbColorTable); - stream_read(s, icon_info->colorTable, icon_info->cbColorTable); + Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable); /* bitsColor */ if (icon_info->bitsColor == NULL) icon_info->bitsColor = (BYTE*) malloc(icon_info->cbBitsColor); else icon_info->bitsColor = (BYTE*) realloc(icon_info->bitsColor, icon_info->cbBitsColor); - stream_read(s, icon_info->bitsColor, icon_info->cbBitsColor); + Stream_Read(s, icon_info->bitsColor, icon_info->cbBitsColor); return TRUE; } @@ -82,8 +82,8 @@ BOOL update_read_cached_icon_info(wStream* s, CACHED_ICON_INFO* cached_icon_info { if(Stream_GetRemainingLength(s) < 3) return FALSE; - stream_read_UINT16(s, cached_icon_info->cacheEntry); /* cacheEntry (2 bytes) */ - stream_read_BYTE(s, cached_icon_info->cacheId); /* cacheId (1 byte) */ + Stream_Read_UINT16(s, cached_icon_info->cacheEntry); /* cacheEntry (2 bytes) */ + Stream_Read_UINT8(s, cached_icon_info->cacheId); /* cacheId (1 byte) */ return TRUE; } @@ -91,8 +91,8 @@ BOOL update_read_notify_icon_infotip(wStream* s, NOTIFY_ICON_INFOTIP* notify_ico { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, notify_icon_infotip->timeout); /* timeout (4 bytes) */ - stream_read_UINT32(s, notify_icon_infotip->flags); /* infoFlags (4 bytes) */ + Stream_Read_UINT32(s, notify_icon_infotip->timeout); /* timeout (4 bytes) */ + Stream_Read_UINT32(s, notify_icon_infotip->flags); /* infoFlags (4 bytes) */ return rail_read_unicode_string(s, ¬ify_icon_infotip->text) && /* infoTipText */ rail_read_unicode_string(s, ¬ify_icon_infotip->title); /* title */ } @@ -105,21 +105,21 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, window_state->ownerWindowId); /* ownerWindowId (4 bytes) */ + Stream_Read_UINT32(s, window_state->ownerWindowId); /* ownerWindowId (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE) { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, window_state->style); /* style (4 bytes) */ - stream_read_UINT32(s, window_state->extendedStyle); /* extendedStyle (4 bytes) */ + Stream_Read_UINT32(s, window_state->style); /* style (4 bytes) */ + Stream_Read_UINT32(s, window_state->extendedStyle); /* extendedStyle (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW) { if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, window_state->showState); /* showState (1 byte) */ + Stream_Read_UINT8(s, window_state->showState); /* showState (1 byte) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE) { @@ -131,59 +131,59 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, window_state->clientOffsetX); /* clientOffsetX (4 bytes) */ - stream_read_UINT32(s, window_state->clientOffsetY); /* clientOffsetY (4 bytes) */ + Stream_Read_UINT32(s, window_state->clientOffsetX); /* clientOffsetX (4 bytes) */ + Stream_Read_UINT32(s, window_state->clientOffsetY); /* clientOffsetY (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, window_state->clientAreaWidth); /* clientAreaWidth (4 bytes) */ - stream_read_UINT32(s, window_state->clientAreaHeight); /* clientAreaHeight (4 bytes) */ + Stream_Read_UINT32(s, window_state->clientAreaWidth); /* clientAreaWidth (4 bytes) */ + Stream_Read_UINT32(s, window_state->clientAreaHeight); /* clientAreaHeight (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) { if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, window_state->RPContent); /* RPContent (1 byte) */ + Stream_Read_UINT8(s, window_state->RPContent); /* RPContent (1 byte) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, window_state->rootParentHandle);/* rootParentHandle (4 bytes) */ + Stream_Read_UINT32(s, window_state->rootParentHandle);/* rootParentHandle (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, window_state->windowOffsetX); /* windowOffsetX (4 bytes) */ - stream_read_UINT32(s, window_state->windowOffsetY); /* windowOffsetY (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowOffsetX); /* windowOffsetX (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowOffsetY); /* windowOffsetY (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, window_state->windowClientDeltaX); /* windowClientDeltaX (4 bytes) */ - stream_read_UINT32(s, window_state->windowClientDeltaY); /* windowClientDeltaY (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowClientDeltaX); /* windowClientDeltaX (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowClientDeltaY); /* windowClientDeltaY (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) { if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, window_state->windowWidth); /* windowWidth (4 bytes) */ - stream_read_UINT32(s, window_state->windowHeight); /* windowHeight (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowWidth); /* windowWidth (4 bytes) */ + Stream_Read_UINT32(s, window_state->windowHeight); /* windowHeight (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { if(Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, window_state->numWindowRects); /* numWindowRects (2 bytes) */ + Stream_Read_UINT16(s, window_state->numWindowRects); /* numWindowRects (2 bytes) */ size = sizeof(RECTANGLE_16) * window_state->numWindowRects; window_state->windowRects = (RECTANGLE_16*) malloc(size); @@ -194,10 +194,10 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI /* windowRects */ for (i = 0; i < (int) window_state->numWindowRects; i++) { - stream_read_UINT16(s, window_state->windowRects[i].left); /* left (2 bytes) */ - stream_read_UINT16(s, window_state->windowRects[i].top); /* top (2 bytes) */ - stream_read_UINT16(s, window_state->windowRects[i].right); /* right (2 bytes) */ - stream_read_UINT16(s, window_state->windowRects[i].bottom); /* bottom (2 bytes) */ + Stream_Read_UINT16(s, window_state->windowRects[i].left); /* left (2 bytes) */ + Stream_Read_UINT16(s, window_state->windowRects[i].top); /* top (2 bytes) */ + Stream_Read_UINT16(s, window_state->windowRects[i].right); /* right (2 bytes) */ + Stream_Read_UINT16(s, window_state->windowRects[i].bottom); /* bottom (2 bytes) */ } } @@ -205,15 +205,15 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, window_state->visibleOffsetX); /* visibleOffsetX (4 bytes) */ - stream_read_UINT32(s, window_state->visibleOffsetY); /* visibleOffsetY (4 bytes) */ + Stream_Read_UINT32(s, window_state->visibleOffsetX); /* visibleOffsetX (4 bytes) */ + Stream_Read_UINT32(s, window_state->visibleOffsetY); /* visibleOffsetY (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { if(Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, window_state->numVisibilityRects); /* numVisibilityRects (2 bytes) */ + Stream_Read_UINT16(s, window_state->numVisibilityRects); /* numVisibilityRects (2 bytes) */ size = sizeof(RECTANGLE_16) * window_state->numVisibilityRects; window_state->visibilityRects = (RECTANGLE_16*) malloc(size); @@ -224,10 +224,10 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI /* visibilityRects */ for (i = 0; i < (int) window_state->numVisibilityRects; i++) { - stream_read_UINT16(s, window_state->visibilityRects[i].left); /* left (2 bytes) */ - stream_read_UINT16(s, window_state->visibilityRects[i].top); /* top (2 bytes) */ - stream_read_UINT16(s, window_state->visibilityRects[i].right); /* right (2 bytes) */ - stream_read_UINT16(s, window_state->visibilityRects[i].bottom); /* bottom (2 bytes) */ + Stream_Read_UINT16(s, window_state->visibilityRects[i].left); /* left (2 bytes) */ + Stream_Read_UINT16(s, window_state->visibilityRects[i].top); /* top (2 bytes) */ + Stream_Read_UINT16(s, window_state->visibilityRects[i].right); /* right (2 bytes) */ + Stream_Read_UINT16(s, window_state->visibilityRects[i].bottom); /* bottom (2 bytes) */ } } return TRUE; @@ -258,7 +258,7 @@ BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_I if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ + Stream_Read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ if (orderInfo->fieldFlags & WINDOW_ORDER_ICON) { @@ -299,7 +299,7 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_VERSION) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */ + Stream_Read_UINT32(s, notify_icon_state->version); /* version (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP) { @@ -315,7 +315,7 @@ BOOL update_read_notification_icon_state_order(wStream* s, WINDOW_ORDER_INFO* or if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_STATE) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, notify_icon_state->state); /* state (4 bytes) */ + Stream_Read_UINT32(s, notify_icon_state->state); /* state (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_ICON) { @@ -342,8 +342,8 @@ BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WIN if(Stream_GetRemainingLength(s) < 8) return FALSE; - stream_read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ - stream_read_UINT32(s, orderInfo->notifyIconId); /* notifyIconId (4 bytes) */ + Stream_Read_UINT32(s, orderInfo->windowId); /* windowId (4 bytes) */ + Stream_Read_UINT32(s, orderInfo->notifyIconId); /* notifyIconId (4 bytes) */ if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED) { @@ -373,14 +373,14 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND) { if(Stream_GetRemainingLength(s) < 4) return FALSE; - stream_read_UINT32(s, monitored_desktop->activeWindowId); /* activeWindowId (4 bytes) */ + Stream_Read_UINT32(s, monitored_desktop->activeWindowId); /* activeWindowId (4 bytes) */ } if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER) { if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, monitored_desktop->numWindowIds); /* numWindowIds (1 byte) */ + Stream_Read_UINT8(s, monitored_desktop->numWindowIds); /* numWindowIds (1 byte) */ if(Stream_GetRemainingLength(s) < 4 * monitored_desktop->numWindowIds) return FALSE; @@ -395,7 +395,7 @@ BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* /* windowIds */ for (i = 0; i < (int) monitored_desktop->numWindowIds; i++) { - stream_read_UINT32(s, monitored_desktop->windowIds[i]); + Stream_Read_UINT32(s, monitored_desktop->windowIds[i]); } } return TRUE; @@ -434,8 +434,8 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) if(Stream_GetRemainingLength(s) < 6) return FALSE; - stream_read_UINT16(s, orderSize); /* orderSize (2 bytes) */ - stream_read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */ + Stream_Read_UINT16(s, orderSize); /* orderSize (2 bytes) */ + Stream_Read_UINT32(s, window->orderInfo.fieldFlags); /* FieldsPresentFlags (4 bytes) */ if (window->orderInfo.fieldFlags & WINDOW_ORDER_TYPE_WINDOW) return update_recv_window_info_order(update, s, &window->orderInfo); diff --git a/libfreerdp/crypto/ber.c b/libfreerdp/crypto/ber.c index 17bf37d1e..2f7b67965 100644 --- a/libfreerdp/crypto/ber.c +++ b/libfreerdp/crypto/ber.c @@ -32,7 +32,7 @@ BOOL ber_read_length(wStream* s, int* length) if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x80) { @@ -42,9 +42,9 @@ BOOL ber_read_length(wStream* s, int* length) return FALSE; if (byte == 1) - stream_read_BYTE(s, *length); + Stream_Read_UINT8(s, *length); else if (byte == 2) - stream_read_UINT16_be(s, *length); + Stream_Read_UINT16_BE(s, *length); else return FALSE; } @@ -65,13 +65,13 @@ int ber_write_length(wStream* s, int length) { if (length > 0x7F) { - stream_write_BYTE(s, 0x82); - stream_write_UINT16_be(s, length); + Stream_Write_UINT8(s, 0x82); + Stream_Write_UINT16_BE(s, length); return 3; } else { - stream_write_BYTE(s, length); + Stream_Write_UINT8(s, length); return 1; } } @@ -105,7 +105,7 @@ BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc) if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != (BER_CLASS_UNIV | BER_PC(pc) | (BER_TAG_MASK & tag))) return FALSE; @@ -122,7 +122,7 @@ BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc) void ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc) { - stream_write_BYTE(s, (BER_CLASS_UNIV | BER_PC(pc)) | (BER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (BER_CLASS_UNIV | BER_PC(pc)) | (BER_TAG_MASK & tag)); } /** @@ -140,14 +140,14 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length) { if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK)) return FALSE; if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != tag) return FALSE; @@ -158,7 +158,7 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, int* length) { if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag))) return FALSE; @@ -180,13 +180,13 @@ void ber_write_application_tag(wStream* s, BYTE tag, int length) { if (tag > 30) { - stream_write_BYTE(s, (BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK); - stream_write_BYTE(s, tag); + Stream_Write_UINT8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK); + Stream_Write_UINT8(s, tag); ber_write_length(s, length); } else { - stream_write_BYTE(s, (BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag)); ber_write_length(s, length); } } @@ -197,7 +197,7 @@ BOOL ber_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag))) { @@ -210,7 +210,7 @@ BOOL ber_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) int ber_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc) { - stream_write_BYTE(s, (BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag)); return ber_write_length(s, length) + 1; } @@ -225,7 +225,7 @@ BOOL ber_read_sequence_tag(wStream* s, int* length) if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((BER_CLASS_UNIV | BER_CONSTRUCT) | (BER_TAG_SEQUENCE_OF))) return FALSE; @@ -241,7 +241,7 @@ BOOL ber_read_sequence_tag(wStream* s, int* length) int ber_write_sequence_tag(wStream* s, int length) { - stream_write_BYTE(s, (BER_CLASS_UNIV | BER_CONSTRUCT) | (BER_TAG_MASK & BER_TAG_SEQUENCE)); + Stream_Write_UINT8(s, (BER_CLASS_UNIV | BER_CONSTRUCT) | (BER_TAG_MASK & BER_TAG_SEQUENCE)); return ber_write_length(s, length) + 1; } @@ -266,7 +266,7 @@ BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) if (length != 1 || Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *enumerated); + Stream_Read_UINT8(s, *enumerated); /* check that enumerated value falls within expected range */ if (*enumerated + 1 > count) @@ -279,7 +279,7 @@ void ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count) { ber_write_universal_tag(s, BER_TAG_ENUMERATED, FALSE); ber_write_length(s, 1); - stream_write_BYTE(s, enumerated); + Stream_Write_UINT8(s, enumerated); } BOOL ber_read_bit_string(wStream* s, int* length, BYTE* padding) @@ -290,7 +290,7 @@ BOOL ber_read_bit_string(wStream* s, int* length, BYTE* padding) if(Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *padding); + Stream_Read_UINT8(s, *padding); return TRUE; } @@ -305,7 +305,7 @@ void ber_write_octet_string(wStream* s, const BYTE* oct_str, int length) { ber_write_universal_tag(s, BER_TAG_OCTET_STRING, FALSE); ber_write_length(s, length); - stream_write(s, oct_str, length); + Stream_Write(s, oct_str, length); } BOOL ber_read_octet_string_tag(wStream* s, int* length) @@ -345,7 +345,7 @@ BOOL ber_read_BOOL(wStream* s, BOOL* value) if (length != 1 || Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, v); + Stream_Read_UINT8(s, v); *value = (v ? TRUE : FALSE); return TRUE; } @@ -360,7 +360,7 @@ void ber_write_BOOL(wStream* s, BOOL value) { ber_write_universal_tag(s, BER_TAG_BOOLEAN, FALSE); ber_write_length(s, 1); - stream_write_BYTE(s, (value == TRUE) ? 0xFF : 0); + Stream_Write_UINT8(s, (value == TRUE) ? 0xFF : 0); } BOOL ber_read_integer(wStream* s, UINT32* value) @@ -380,22 +380,22 @@ BOOL ber_read_integer(wStream* s, UINT32* value) if (length == 1) { - stream_read_BYTE(s, *value); + Stream_Read_UINT8(s, *value); } else if (length == 2) { - stream_read_UINT16_be(s, *value); + Stream_Read_UINT16_BE(s, *value); } else if (length == 3) { BYTE byte; - stream_read_BYTE(s, byte); - stream_read_UINT16_be(s, *value); + Stream_Read_UINT8(s, byte); + Stream_Read_UINT16_BE(s, *value); *value += (byte << 16); } else if (length == 4) { - stream_read_UINT32_be(s, *value); + Stream_Read_UINT32_BE(s, *value); } else if (length == 8) { @@ -424,26 +424,26 @@ int ber_write_integer(wStream* s, UINT32 value) if (value <= 0xFF) { ber_write_length(s, 1); - stream_write_BYTE(s, value); + Stream_Write_UINT8(s, value); return 2; } else if (value < 0xFF80) { ber_write_length(s, 2); - stream_write_UINT16_be(s, value); + Stream_Write_UINT16_BE(s, value); return 3; } else if (value < 0xFF8000) { ber_write_length(s, 3); - stream_write_BYTE(s, (value >> 16)); - stream_write_UINT16_be(s, (value & 0xFFFF)); + Stream_Write_UINT8(s, (value >> 16)); + Stream_Write_UINT16_BE(s, (value & 0xFFFF)); return 4; } else if (value <= 0xFFFFFFFF) { ber_write_length(s, 4); - stream_write_UINT32_be(s, value); + Stream_Write_UINT32_BE(s, value); return 5; } diff --git a/libfreerdp/crypto/der.c b/libfreerdp/crypto/der.c index 1cc5eb770..2f69fa6a0 100644 --- a/libfreerdp/crypto/der.c +++ b/libfreerdp/crypto/der.c @@ -39,19 +39,19 @@ int der_write_length(wStream* s, int length) { if (length > 0x7F && length <= 0xFF) { - stream_write_BYTE(s, 0x81); - stream_write_BYTE(s, length); + Stream_Write_UINT8(s, 0x81); + Stream_Write_UINT8(s, length); return 2; } else if (length > 0xFF) { - stream_write_BYTE(s, 0x82); - stream_write_UINT16_be(s, length); + Stream_Write_UINT8(s, 0x82); + Stream_Write_UINT16_BE(s, length); return 3; } else { - stream_write_BYTE(s, length); + Stream_Write_UINT8(s, length); return 1; } } @@ -73,13 +73,13 @@ int der_skip_contextual_tag(int length) int der_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc) { - stream_write_BYTE(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)); return der_write_length(s, length) + 1; } void der_write_universal_tag(wStream* s, BYTE tag, BOOL pc) { - stream_write_BYTE(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag)); } int der_skip_octet_string(int length) @@ -91,7 +91,7 @@ void der_write_octet_string(wStream* s, BYTE* oct_str, int length) { der_write_universal_tag(s, ER_TAG_OCTET_STRING, FALSE); der_write_length(s, length); - stream_write(s, oct_str, length); + Stream_Write(s, oct_str, length); } int der_skip_sequence_tag(int length) @@ -101,7 +101,7 @@ int der_skip_sequence_tag(int length) int der_write_sequence_tag(wStream* s, int length) { - stream_write_BYTE(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE)); + Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE)); return der_write_length(s, length) + 1; } diff --git a/libfreerdp/crypto/er.c b/libfreerdp/crypto/er.c index 47fa748e1..04d0c1ca6 100644 --- a/libfreerdp/crypto/er.c +++ b/libfreerdp/crypto/er.c @@ -32,16 +32,16 @@ void er_read_length(wStream* s, int* length) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x80) { byte &= ~(0x80); if (byte == 1) - stream_read_BYTE(s, *length); + Stream_Read_UINT8(s, *length); if (byte == 2) - stream_read_UINT16_be(s, *length); + Stream_Read_UINT16_BE(s, *length); } else { @@ -90,7 +90,7 @@ BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != (ER_CLASS_UNIV | ER_PC(pc) | (ER_TAG_MASK & tag))) return FALSE; @@ -107,7 +107,7 @@ BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc) void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc) { - stream_write_BYTE(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag)); } /** @@ -123,12 +123,12 @@ BOOL er_read_application_tag(wStream* s, BYTE tag, int* length) if (tag > 30) { - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((ER_CLASS_APPL | ER_CONSTRUCT) | ER_TAG_MASK)) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != tag) return FALSE; @@ -137,7 +137,7 @@ BOOL er_read_application_tag(wStream* s, BYTE tag, int* length) } else { - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((ER_CLASS_APPL | ER_CONSTRUCT) | (ER_TAG_MASK & tag))) return FALSE; @@ -159,13 +159,13 @@ void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag) { if (tag > 30) { - stream_write_BYTE(s, (ER_CLASS_APPL | ER_CONSTRUCT) | ER_TAG_MASK); - stream_write_BYTE(s, tag); + Stream_Write_UINT8(s, (ER_CLASS_APPL | ER_CONSTRUCT) | ER_TAG_MASK); + Stream_Write_UINT8(s, tag); er_write_length(s, length, flag); } else { - stream_write_BYTE(s, (ER_CLASS_APPL | ER_CONSTRUCT) | (ER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (ER_CLASS_APPL | ER_CONSTRUCT) | (ER_TAG_MASK & tag)); er_write_length(s, length, flag); } } @@ -174,7 +174,7 @@ BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag))) { @@ -189,7 +189,7 @@ BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc) int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag) { - stream_write_BYTE(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)); + Stream_Write_UINT8(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)); return er_write_length(s, length, flag) + 1; } @@ -202,7 +202,7 @@ BOOL er_read_sequence_tag(wStream* s, int* length) { BYTE byte; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte != ((ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_SEQUENCE_OF))) return FALSE; @@ -220,7 +220,7 @@ BOOL er_read_sequence_tag(wStream* s, int* length) int er_write_sequence_tag(wStream* s, int length, BOOL flag) { - stream_write_BYTE(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE)); + Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE)); return er_write_length(s, length, flag) + 1; } @@ -242,7 +242,7 @@ BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) er_read_length(s, &length); if (length == 1) - stream_read_BYTE(s, *enumerated); + Stream_Read_UINT8(s, *enumerated); else return FALSE; @@ -257,14 +257,14 @@ void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag) { er_write_universal_tag(s, ER_TAG_ENUMERATED, FALSE); er_write_length(s, 1, flag); - stream_write_BYTE(s, enumerated); + Stream_Write_UINT8(s, enumerated); } BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding) { er_read_universal_tag(s, ER_TAG_BIT_STRING, FALSE); er_read_length(s, length); - stream_read_BYTE(s, *padding); + Stream_Read_UINT8(s, *padding); return TRUE; } @@ -273,7 +273,7 @@ BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag) { er_write_universal_tag(s, ER_TAG_BIT_STRING, FALSE); er_write_length(s, length, flag); - stream_write_BYTE(s, padding); + Stream_Write_UINT8(s, padding); return TRUE; } @@ -297,7 +297,7 @@ void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag) { er_write_universal_tag(s, ER_TAG_OCTET_STRING, FALSE); er_write_length(s, length, flag); - stream_write(s, oct_str, length); + Stream_Write(s, oct_str, length); } int er_write_octet_string_tag(wStream* s, int length, BOOL flag) @@ -328,7 +328,7 @@ BOOL er_read_BOOL(wStream* s, BOOL* value) er_read_length(s, &length); if (length != 1) return FALSE; - stream_read_BYTE(s, v); + Stream_Read_UINT8(s, v); *value = (v ? TRUE : FALSE); return TRUE; } @@ -343,7 +343,7 @@ void er_write_BOOL(wStream* s, BOOL value) { er_write_universal_tag(s, ER_TAG_BOOLEAN, FALSE); er_write_length(s, 1, FALSE); - stream_write_BYTE(s, (value == TRUE) ? 0xFF : 0); + Stream_Write_UINT8(s, (value == TRUE) ? 0xFF : 0); } BOOL er_read_integer(wStream* s, UINT32* value) @@ -360,20 +360,28 @@ BOOL er_read_integer(wStream* s, UINT32* value) } if (length == 1) - stream_read_BYTE(s, *value); + { + Stream_Read_UINT8(s, *value); + } else if (length == 2) - stream_read_UINT16_be(s, *value); + { + Stream_Read_UINT16_BE(s, *value); + } else if (length == 3) { BYTE byte; - stream_read_BYTE(s, byte); - stream_read_UINT16_be(s, *value); + Stream_Read_UINT8(s, byte); + Stream_Read_UINT16_BE(s, *value); *value += (byte << 16); } else if (length == 4) - stream_read_UINT32_be(s, *value); + { + Stream_Read_UINT32_BE(s, *value); + } else + { return FALSE; + } return TRUE; } @@ -391,19 +399,19 @@ int er_write_integer(wStream* s, INT32 value) if (value <= 127 && value >= -128) { er_write_length(s, 1, FALSE); - stream_write_BYTE(s, value); + Stream_Write_UINT8(s, value); return 2; } else if (value <= 32767 && value >= -32768) { er_write_length(s, 2, FALSE); - stream_write_UINT16_be(s, value); + Stream_Write_UINT16_BE(s, value); return 3; } else { er_write_length(s, 4, FALSE); - stream_write_UINT32_be(s, value); + Stream_Write_UINT32_BE(s, value); return 5; } diff --git a/libfreerdp/crypto/per.c b/libfreerdp/crypto/per.c index 00960b249..6eaebea0c 100644 --- a/libfreerdp/crypto/per.c +++ b/libfreerdp/crypto/per.c @@ -37,7 +37,7 @@ BOOL per_read_length(wStream* s, UINT16* length) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); if (byte & 0x80) { @@ -46,7 +46,7 @@ BOOL per_read_length(wStream* s, UINT16* length) byte &= ~(0x80); *length = (byte << 8); - stream_read_BYTE(s, byte); + Stream_Read_UINT8(s, byte); *length += byte; } else @@ -66,9 +66,9 @@ BOOL per_read_length(wStream* s, UINT16* length) void per_write_length(wStream* s, int length) { if (length > 0x7F) - stream_write_UINT16_be(s, (length | 0x8000)); + Stream_Write_UINT16_BE(s, (length | 0x8000)); else - stream_write_BYTE(s, length); + Stream_Write_UINT8(s, length); } /** @@ -83,7 +83,7 @@ BOOL per_read_choice(wStream* s, BYTE* choice) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *choice); + Stream_Read_UINT8(s, *choice); return TRUE; } @@ -95,7 +95,7 @@ BOOL per_read_choice(wStream* s, BYTE* choice) void per_write_choice(wStream* s, BYTE choice) { - stream_write_BYTE(s, choice); + Stream_Write_UINT8(s, choice); } /** @@ -110,7 +110,7 @@ BOOL per_read_selection(wStream* s, BYTE* selection) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *selection); + Stream_Read_UINT8(s, *selection); return TRUE; } @@ -122,7 +122,7 @@ BOOL per_read_selection(wStream* s, BYTE* selection) void per_write_selection(wStream* s, BYTE selection) { - stream_write_BYTE(s, selection); + Stream_Write_UINT8(s, selection); } /** @@ -137,7 +137,7 @@ BOOL per_read_number_of_sets(wStream* s, BYTE* number) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *number); + Stream_Read_UINT8(s, *number); return TRUE; } @@ -149,7 +149,7 @@ BOOL per_read_number_of_sets(wStream* s, BYTE* number) void per_write_number_of_sets(wStream* s, BYTE number) { - stream_write_BYTE(s, number); + Stream_Write_UINT8(s, number); } /** @@ -178,7 +178,7 @@ void per_write_padding(wStream* s, int length) int i; for (i = 0; i < length; i++) - stream_write_BYTE(s, 0); + Stream_Write_UINT8(s, 0); } /** @@ -199,9 +199,9 @@ BOOL per_read_integer(wStream* s, UINT32* integer) return FALSE; if (length == 1) - stream_read_BYTE(s, *integer); + Stream_Read_UINT8(s, *integer); else if (length == 2) - stream_read_UINT16_be(s, *integer); + Stream_Read_UINT16_BE(s, *integer); else return FALSE; @@ -219,17 +219,17 @@ void per_write_integer(wStream* s, UINT32 integer) if (integer <= 0xFF) { per_write_length(s, 1); - stream_write_BYTE(s, integer); + Stream_Write_UINT8(s, integer); } else if (integer <= 0xFFFF) { per_write_length(s, 2); - stream_write_UINT16_be(s, integer); + Stream_Write_UINT16_BE(s, integer); } else if (integer <= 0xFFFFFFFF) { per_write_length(s, 4); - stream_write_UINT32_be(s, integer); + Stream_Write_UINT32_BE(s, integer); } } @@ -246,7 +246,7 @@ BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16_be(s, *integer); + Stream_Read_UINT16_BE(s, *integer); if (*integer + min > 0xFFFF) return FALSE; @@ -265,7 +265,7 @@ BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min) void per_write_integer16(wStream* s, UINT16 integer, UINT16 min) { - stream_write_UINT16_be(s, integer - min); + Stream_Write_UINT16_BE(s, integer - min); } /** @@ -281,7 +281,7 @@ BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) if (Stream_GetRemainingLength(s) < 1) return FALSE; - stream_read_BYTE(s, *enumerated); + Stream_Read_UINT8(s, *enumerated); /* check that enumerated value falls within expected range */ if (*enumerated + 1 > count) @@ -300,7 +300,7 @@ BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count) void per_write_enumerated(wStream* s, BYTE enumerated, BYTE count) { - stream_write_BYTE(s, enumerated); + Stream_Write_UINT8(s, enumerated); } /** @@ -325,14 +325,14 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6]) if (Stream_GetRemainingLength(s) < length) return FALSE; - stream_read_BYTE(s, t12); /* first two tuples */ + Stream_Read_UINT8(s, t12); /* first two tuples */ a_oid[0] = (t12 >> 4); a_oid[1] = (t12 & 0x0F); - stream_read_BYTE(s, a_oid[2]); /* tuple 3 */ - stream_read_BYTE(s, a_oid[3]); /* tuple 4 */ - stream_read_BYTE(s, a_oid[4]); /* tuple 5 */ - stream_read_BYTE(s, a_oid[5]); /* tuple 6 */ + Stream_Read_UINT8(s, a_oid[2]); /* tuple 3 */ + Stream_Read_UINT8(s, a_oid[3]); /* tuple 4 */ + Stream_Read_UINT8(s, a_oid[4]); /* tuple 5 */ + Stream_Read_UINT8(s, a_oid[5]); /* tuple 6 */ if ((a_oid[0] == oid[0]) && (a_oid[1] == oid[1]) && (a_oid[2] == oid[2]) && (a_oid[3] == oid[3]) && @@ -355,12 +355,12 @@ BOOL per_read_object_identifier(wStream* s, BYTE oid[6]) void per_write_object_identifier(wStream* s, BYTE oid[6]) { BYTE t12 = (oid[0] << 4) & (oid[1] & 0x0F); - stream_write_BYTE(s, 5); /* length */ - stream_write_BYTE(s, t12); /* first two tuples */ - stream_write_BYTE(s, oid[2]); /* tuple 3 */ - stream_write_BYTE(s, oid[3]); /* tuple 4 */ - stream_write_BYTE(s, oid[4]); /* tuple 5 */ - stream_write_BYTE(s, oid[5]); /* tuple 6 */ + Stream_Write_UINT8(s, 5); /* length */ + Stream_Write_UINT8(s, t12); /* first two tuples */ + Stream_Write_UINT8(s, oid[2]); /* tuple 3 */ + Stream_Write_UINT8(s, oid[3]); /* tuple 4 */ + Stream_Write_UINT8(s, oid[4]); /* tuple 5 */ + Stream_Write_UINT8(s, oid[5]); /* tuple 6 */ } /** @@ -375,7 +375,7 @@ void per_write_string(wStream* s, BYTE* str, int length) int i; for (i = 0; i < length; i++) - stream_write_BYTE(s, str[i]); + Stream_Write_UINT8(s, str[i]); } /** @@ -432,7 +432,7 @@ void per_write_octet_string(wStream* s, BYTE* oct_str, int length, int min) per_write_length(s, mlength); for (i = 0; i < length; i++) - stream_write_BYTE(s, oct_str[i]); + Stream_Write_UINT8(s, oct_str[i]); } /** @@ -487,6 +487,6 @@ void per_write_numeric_string(wStream* s, BYTE* num_str, int length, int min) c2 = (c2 - 0x30) % 10; num = (c1 << 4) | c2; - stream_write_BYTE(s, num); /* string */ + Stream_Write_UINT8(s, num); /* string */ } } diff --git a/libfreerdp/utils/rail.c b/libfreerdp/utils/rail.c index ba5529729..00c0460f8 100644 --- a/libfreerdp/utils/rail.c +++ b/libfreerdp/utils/rail.c @@ -51,7 +51,7 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) if (Stream_GetRemainingLength(s) < 2) return FALSE; - stream_read_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ + Stream_Read_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ if (Stream_GetRemainingLength(s) < unicode_string->length) return FALSE; @@ -61,7 +61,7 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) else unicode_string->string = (BYTE*) realloc(unicode_string->string, unicode_string->length); - stream_read(s, unicode_string->string, unicode_string->length); + Stream_Read(s, unicode_string->string, unicode_string->length); return TRUE; } @@ -69,8 +69,8 @@ BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) void rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string) { Stream_EnsureRemainingCapacity(s, 2 + unicode_string->length); - stream_write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ - stream_write(s, unicode_string->string, unicode_string->length); /* string */ + Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */ + Stream_Write(s, unicode_string->string, unicode_string->length); /* string */ } void rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string) @@ -78,24 +78,24 @@ void rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_st if (unicode_string->length > 0) { Stream_EnsureRemainingCapacity(s, unicode_string->length); - stream_write(s, unicode_string->string, unicode_string->length); /* string */ + Stream_Write(s, unicode_string->string, unicode_string->length); /* string */ } } void rail_read_rectangle_16(wStream* s, RECTANGLE_16* rectangle_16) { - stream_read_UINT16(s, rectangle_16->left); /* left (2 bytes) */ - stream_read_UINT16(s, rectangle_16->top); /* top (2 bytes) */ - stream_read_UINT16(s, rectangle_16->right); /* right (2 bytes) */ - stream_read_UINT16(s, rectangle_16->bottom); /* bottom (2 bytes) */ + Stream_Read_UINT16(s, rectangle_16->left); /* left (2 bytes) */ + Stream_Read_UINT16(s, rectangle_16->top); /* top (2 bytes) */ + Stream_Read_UINT16(s, rectangle_16->right); /* right (2 bytes) */ + Stream_Read_UINT16(s, rectangle_16->bottom); /* bottom (2 bytes) */ } void rail_write_rectangle_16(wStream* s, RECTANGLE_16* rectangle_16) { - stream_write_UINT16(s, rectangle_16->left); /* left (2 bytes) */ - stream_write_UINT16(s, rectangle_16->top); /* top (2 bytes) */ - stream_write_UINT16(s, rectangle_16->right); /* right (2 bytes) */ - stream_write_UINT16(s, rectangle_16->bottom); /* bottom (2 bytes) */ + Stream_Write_UINT16(s, rectangle_16->left); /* left (2 bytes) */ + Stream_Write_UINT16(s, rectangle_16->top); /* top (2 bytes) */ + Stream_Write_UINT16(s, rectangle_16->right); /* right (2 bytes) */ + Stream_Write_UINT16(s, rectangle_16->bottom); /* bottom (2 bytes) */ } void* rail_clone_order(UINT32 event_type, void* order) diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index f201aec95..bd4bf9f03 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -123,7 +123,7 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3 data_in = plugin->data_in; Stream_EnsureRemainingCapacity(data_in, (int) dataLength); - stream_write(data_in, pData, dataLength); + Stream_Write(data_in, pData, dataLength); if (dataFlags & CHANNEL_FLAG_LAST) { diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index 5095496f9..67718a63e 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -69,10 +69,10 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); _s->pointer += 4; } while (0) #define Stream_Read_UINT32_BE(_s, _v) do { _v = \ - (((uint32)(*(_s->pointer))) << 24) + \ - (((uint32)(*(_s->pointer + 1))) << 16) + \ - (((uint32)(*(_s->pointer + 2))) << 8) + \ - (((uint32)(*(_s->pointer + 3)))); \ + (((UINT32)(*(_s->pointer))) << 24) + \ + (((UINT32)(*(_s->pointer + 1))) << 16) + \ + (((UINT32)(*(_s->pointer + 2))) << 8) + \ + (((UINT32)(*(_s->pointer + 3)))); \ _s->pointer += 4; } while (0) #define Stream_Read_UINT64(_s, _v) do { _v = \ @@ -218,56 +218,7 @@ WINPR_API void stream_extend(wStream* stream, int request_size); #define stream_set_mark(_s,_mark) _s->pointer = _mark #define stream_get_head(_s) _s->buffer -#define stream_read_BYTE(_s, _v) do { _v = *_s->pointer++; } while (0) -#define stream_read_UINT16(_s, _v) do { _v = \ - (UINT16)(*_s->pointer) + \ - (UINT16)(((UINT16)(*(_s->pointer + 1))) << 8); \ - _s->pointer += 2; } while (0) -#define stream_read_UINT32(_s, _v) do { _v = \ - (UINT32)(*_s->pointer) + \ - (((UINT32)(*(_s->pointer + 1))) << 8) + \ - (((UINT32)(*(_s->pointer + 2))) << 16) + \ - (((UINT32)(*(_s->pointer + 3))) << 24); \ - _s->pointer += 4; } while (0) -#define stream_read_UINT64(_s, _v) do { _v = \ - (UINT64)(*_s->pointer) + \ - (((UINT64)(*(_s->pointer + 1))) << 8) + \ - (((UINT64)(*(_s->pointer + 2))) << 16) + \ - (((UINT64)(*(_s->pointer + 3))) << 24) + \ - (((UINT64)(*(_s->pointer + 4))) << 32) + \ - (((UINT64)(*(_s->pointer + 5))) << 40) + \ - (((UINT64)(*(_s->pointer + 6))) << 48) + \ - (((UINT64)(*(_s->pointer + 7))) << 56); \ - _s->pointer += 8; } while (0) -#define stream_read(_s, _b, _n) do { \ - memcpy(_b, (_s->pointer), (_n)); \ - _s->pointer += (_n); \ - } while (0) - -#define stream_write_BYTE(_s, _v) do { \ - *_s->pointer++ = (BYTE)(_v); } while (0) -#define stream_write_UINT16(_s, _v) do { \ - *_s->pointer++ = (_v) & 0xFF; \ - *_s->pointer++ = ((_v) >> 8) & 0xFF; } while (0) -#define stream_write_UINT32(_s, _v) do { \ - *_s->pointer++ = (_v) & 0xFF; \ - *_s->pointer++ = ((_v) >> 8) & 0xFF; \ - *_s->pointer++ = ((_v) >> 16) & 0xFF; \ - *_s->pointer++ = ((_v) >> 24) & 0xFF; } while (0) -#define stream_write_UINT64(_s, _v) do { \ - *_s->pointer++ = (UINT64)(_v) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 8) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 16) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 24) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 32) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 40) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 48) & 0xFF; \ - *_s->pointer++ = ((UINT64)(_v) >> 56) & 0xFF; } while (0) -#define stream_write(_s, _b, _n) do { \ - memcpy(_s->pointer, (_b), (_n)); \ - _s->pointer += (_n); \ - } while (0) -#define stream_write_zero(_s, _n) do { \ +#define Stream_Write_zero(_s, _n) do { \ memset(_s->pointer, '\0', (_n)); \ _s->pointer += (_n); \ } while (0) @@ -303,25 +254,6 @@ WINPR_API void stream_extend(wStream* stream, int request_size); #define Stream_Seek_UINT32(_s) Stream_Seek(_s, 4) #define Stream_Seek_UINT64(_s) Stream_Seek(_s, 8) -#define stream_read_UINT16_be(_s, _v) do { _v = \ - (((UINT16)(*_s->pointer)) << 8) + \ - (UINT16)(*(_s->pointer + 1)); \ - _s->pointer += 2; } while (0) -#define stream_read_UINT32_be(_s, _v) do { _v = \ - (((UINT32)(*(_s->pointer))) << 24) + \ - (((UINT32)(*(_s->pointer + 1))) << 16) + \ - (((UINT32)(*(_s->pointer + 2))) << 8) + \ - (((UINT32)(*(_s->pointer + 3)))); \ - _s->pointer += 4; } while (0) - -#define stream_write_UINT16_be(_s, _v) do { \ - *_s->pointer++ = ((_v) >> 8) & 0xFF; \ - *_s->pointer++ = (_v) & 0xFF; } while (0) -#define stream_write_UINT32_be(_s, _v) do { \ - stream_write_UINT16_be(_s, ((_v) >> 16 & 0xFFFF)); \ - stream_write_UINT16_be(_s, ((_v) & 0xFFFF)); \ - } while (0) - #define stream_copy(_dst, _src, _n) do { \ memcpy(_dst->pointer, _src->pointer, _n); \ _dst->pointer += _n; \ From fd230443c5b046d218887c6fe97823107006f7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 16:27:21 -0400 Subject: [PATCH 084/144] freerdp: purge old stream utils --- channels/audin/client/audin_main.c | 12 ++-- channels/audin/server/audin.c | 10 +-- channels/cliprdr/client/cliprdr_format.c | 4 +- channels/drdynvc/client/drdynvc_main.c | 2 +- channels/drive/client/drive_file.c | 6 +- channels/drive/client/drive_main.c | 2 +- channels/parallel/client/parallel_main.c | 2 +- channels/printer/client/printer_main.c | 2 +- channels/rdpdr/client/rdpdr_main.c | 4 +- channels/rdpsnd/client/rdpsnd_main.c | 8 +-- channels/rdpsnd/server/rdpsnd.c | 22 +++--- channels/sample/client/sample_main.c | 2 +- channels/serial/client/serial_main.c | 2 +- channels/server/channels.c | 16 ++--- .../smartcard/client/smartcard_operations.c | 14 ++-- channels/tsmf/client/tsmf_codec.c | 4 +- channels/tsmf/client/tsmf_ifman.c | 4 +- channels/tsmf/client/tsmf_main.c | 4 +- client/X11/xf_cliprdr.c | 2 +- cunit/test_nsc.c | 4 +- cunit/test_rfx.c | 6 +- libfreerdp/codec/rfx.c | 4 +- libfreerdp/core/capabilities.c | 72 +++++++++---------- libfreerdp/core/certificate.c | 2 +- libfreerdp/core/connection.c | 4 +- libfreerdp/core/fastpath.c | 8 +-- libfreerdp/core/gcc.c | 12 ++-- libfreerdp/core/license.c | 2 +- libfreerdp/core/mcs.c | 22 +++--- libfreerdp/core/nego.c | 20 +++--- libfreerdp/core/orders.c | 30 ++++---- libfreerdp/core/rdp.c | 8 +-- libfreerdp/core/surface.c | 2 +- libfreerdp/core/timezone.c | 4 +- libfreerdp/core/tpkt.c | 4 +- libfreerdp/core/transport.c | 2 +- libfreerdp/core/update.c | 10 +-- server/Mac/mf_peer.c | 2 +- server/Sample/sfreerdp.c | 10 +-- server/Windows/wf_update.c | 2 +- winpr/include/winpr/stream.h | 49 +------------ 41 files changed, 179 insertions(+), 222 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 88d6e3e19..5c857645e 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -101,7 +101,7 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w out = stream_new(5); Stream_Write_UINT8(out, MSG_SNDIN_VERSION); Stream_Write_UINT32(out, Version); - error = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); + error = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL); stream_free(out); return error; @@ -146,7 +146,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w /* SoundFormats (variable) */ for (i = 0; i < NumFormats; i++) { - stream_get_mark(s, fm); + Stream_GetPointer(s, fm); Stream_Read_UINT16(s, format.wFormatTag); Stream_Read_UINT16(s, format.nChannels); Stream_Read_UINT32(s, format.nSamplesPerSec); @@ -189,7 +189,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w Stream_Write_UINT32(out, callback->formats_count); /* NumFormats (4 bytes) */ Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */ - error = callback->channel->Write(callback->channel, cbSizeFormatsPacket, stream_get_head(out), NULL); + error = callback->channel->Write(callback->channel, cbSizeFormatsPacket, Stream_Buffer(out), NULL); stream_free(out); return error; @@ -204,7 +204,7 @@ static int audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCall out = stream_new(5); Stream_Write_UINT8(out, MSG_SNDIN_FORMATCHANGE); Stream_Write_UINT32(out, NewFormat); - error = callback->channel->Write(callback->channel, 5, stream_get_head(out), NULL); + error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL); stream_free(out); return error; @@ -219,7 +219,7 @@ static int audin_send_open_reply_pdu(IWTSVirtualChannelCallback* pChannelCallbac out = stream_new(5); Stream_Write_UINT8(out, MSG_SNDIN_OPEN_REPLY); Stream_Write_UINT32(out, Result); - error = callback->channel->Write(callback->channel, 5, stream_get_head(out), NULL); + error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL); stream_free(out); return error; @@ -239,7 +239,7 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data) out = stream_new(size + 1); Stream_Write_UINT8(out, MSG_SNDIN_DATA); Stream_Write(out, data, size); - error = callback->channel->Write(callback->channel, Stream_GetPosition(out), stream_get_head(out), NULL); + error = callback->channel->Write(callback->channel, Stream_GetPosition(out), Stream_Buffer(out), NULL); stream_free(out); return (error == 0 ? TRUE : FALSE); diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index cfd595848..fb7358227 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -78,7 +78,7 @@ static void audin_server_send_version(audin_server* audin, wStream* s) { Stream_Write_UINT8(s, MSG_SNDIN_VERSION); Stream_Write_UINT32(s, 1); /* Version (4 bytes) */ - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_version(audin_server* audin, wStream* s, UINT32 length) @@ -130,7 +130,7 @@ static void audin_server_send_formats(audin_server* audin, wStream* s) } } - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 length) @@ -201,7 +201,7 @@ static void audin_server_send_open(audin_server* audin, wStream* s) Stream_Write_UINT16(s, 16); /* wBitsPerSample */ Stream_Write_UINT16(s, 0); /* cbSize */ - WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(audin->audin_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); } static BOOL audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32 length) @@ -330,7 +330,7 @@ static void* audin_server_thread_func(void* arg) Stream_SetPosition(s, 0); - if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(audin->audin_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) @@ -338,7 +338,7 @@ static void* audin_server_thread_func(void* arg) Stream_EnsureRemainingCapacity(s, (int) bytes_returned); - if (WTSVirtualChannelRead(audin->audin_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(audin->audin_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) break; } diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 1f19c005b..e4b196499 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -94,7 +94,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS } s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body)); - Stream_Write(s, stream_get_head(body), Stream_Capacity(body)); + Stream_Write(s, Stream_Buffer(body), Stream_Capacity(body)); stream_free(body); } @@ -160,7 +160,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, wStream* s, UINT3 BYTE* end_mark; CLIPRDR_FORMAT_NAME* format_name; - stream_get_mark(s, end_mark); + Stream_GetPointer(s, end_mark); end_mark += length; cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) malloc(sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats); diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index fbf571351..92db87375 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -244,7 +244,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb data_out = stream_new(pos + 4); Stream_Write_UINT8(data_out, 0x10 | cbChId); Stream_SetPosition(s, 1); - stream_copy(data_out, s, pos - 1); + Stream_Copy(data_out, s, pos - 1); if (error == 0) { diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index a34efd20e..3a31c479c 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -501,8 +501,8 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN case FileRenameInformation: /* http://msdn.microsoft.com/en-us/library/cc232085.aspx */ - Stream_Seek_BYTE(input); /* ReplaceIfExists */ - Stream_Seek_BYTE(input); /* RootDirectory */ + Stream_Seek_UINT8(input); /* ReplaceIfExists */ + Stream_Seek_UINT8(input); /* RootDirectory */ Stream_Read_UINT32(input, FileNameLength); status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(input), @@ -665,7 +665,7 @@ BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYT Stream_Write_UINT32(output, 0); /* EaSize */ Stream_Write_UINT8(output, 0); /* ShortNameLength */ /* Reserved(1), MUST NOT be added! */ - Stream_Write_zero(output, 24); /* ShortName */ + Stream_Zero(output, 24); /* ShortName */ Stream_Write(output, ent_path, length); break; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 1206d1fc2..b6fa5f09f 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -214,7 +214,7 @@ static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp) drive_file_free(file); } - Stream_Write_zero(irp->output, 5); /* Padding(5) */ + Stream_Zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 8e3e00a85..95b90afe1 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -120,7 +120,7 @@ static void parallel_process_irp_close(PARALLEL_DEVICE* parallel, IRP* irp) else DEBUG_SVC("%s(%d) closed", parallel->path, parallel->id); - Stream_Write_zero(irp->output, 5); /* Padding(5) */ + Stream_Zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 607bf1ca0..d5a1dee30 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -103,7 +103,7 @@ static void printer_process_irp_close(PRINTER_DEVICE* printer_dev, IRP* irp) DEBUG_SVC("printjob id %d closed.", irp->FileId); } - Stream_Write_zero(irp->output, 4); /* Padding(4) */ + Stream_Zero(irp->output, 4); /* Padding(4) */ irp->Complete(irp); } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index b099d1b5a..84ed6a046 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -184,12 +184,12 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use for (i = 0; i < 8; i++) { - stream_peek_BYTE(data_out, c); + Stream_Peek_UINT8(data_out, c); if (c > 0x7F) Stream_Write_UINT8(data_out, '_'); else - Stream_Seek_BYTE(data_out); + Stream_Seek_UINT8(data_out); } Stream_Write_UINT32(data_out, data_len); diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 82747fc90..8a215b473 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -269,7 +269,7 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) Stream_Read_UINT16(s, wNumberOfFormats); Stream_Read_UINT8(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */ Stream_Read_UINT16(s, wVersion); /* wVersion */ - Stream_Seek_BYTE(s); /* bPad */ + Stream_Seek_UINT8(s); /* bPad */ rdpsnd->NumberOfServerFormats = wNumberOfFormats; rdpsnd->ServerFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * wNumberOfFormats); @@ -399,9 +399,9 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s) * part of the preceding Wave Info PDU. */ - CopyMemory(stream_get_head(s), rdpsnd->waveData, 4); + CopyMemory(Stream_Buffer(s), rdpsnd->waveData, 4); - data = stream_get_head(s); + data = Stream_Buffer(s); size = Stream_Capacity(s); wave = (RDPSND_WAVE*) malloc(sizeof(RDPSND_WAVE)); @@ -481,7 +481,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s) } Stream_Read_UINT8(s, msgType); /* msgType */ - Stream_Seek_BYTE(s); /* bPad */ + Stream_Seek_UINT8(s); /* bPad */ Stream_Read_UINT16(s, BodySize); //fprintf(stderr, "msgType %d BodySize %d\n", msgType, BodySize); diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index 644ca5d01..c888f4823 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -98,7 +98,7 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s) Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; @@ -112,7 +112,7 @@ static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, wStream* s) BYTE confirmBlockNum = 0; Stream_Read_UINT16(s, timestamp); Stream_Read_UINT8(s, confirmBlockNum); - Stream_Seek_BYTE(s); // padding + Stream_Seek_UINT8(s); // padding } static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s) @@ -141,7 +141,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s) Stream_Read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */ Stream_Read_UINT8(s, lastblock); /* cLastBlockConfirmed */ Stream_Read_UINT16(s, version); /* wVersion */ - Stream_Seek_BYTE(s); /* bPad */ + Stream_Seek_UINT8(s); /* bPad */ if (rdpsnd->context.num_client_formats > 0) { @@ -218,7 +218,7 @@ static void* rdpsnd_server_thread_func(void* arg) Stream_SetPosition(s, 0); - if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) @@ -226,13 +226,13 @@ static void* rdpsnd_server_thread_func(void* arg) Stream_EnsureRemainingCapacity(s, (int) bytes_returned); - if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) break; } Stream_Read_UINT8(s, msgType); - Stream_Seek_BYTE(s); /* bPad */ + Stream_Seek_UINT8(s); /* bPad */ Stream_Read_UINT16(s, BodySize); switch (msgType) @@ -410,7 +410,7 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) Stream_Seek(s, 3); /* bPad */ Stream_Write(s, src, 4); - WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); /* Wave PDU */ @@ -419,9 +419,9 @@ static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) Stream_Write(s, src + 4, size - 4); if (fill_size > 0) - Stream_Write_zero(s, fill_size); + Stream_Zero(s, fill_size); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); rdpsnd->out_pending_frames = 0; @@ -476,7 +476,7 @@ static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, i Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; @@ -508,7 +508,7 @@ static BOOL rdpsnd_server_close(rdpsnd_server_context* context) Stream_SetPosition(s, 2); Stream_Write_UINT16(s, pos - 4); Stream_SetPosition(s, pos); - status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); Stream_SetPosition(s, 0); return status; diff --git a/channels/sample/client/sample_main.c b/channels/sample/client/sample_main.c index 9d6c90e54..417b4a0e8 100644 --- a/channels/sample/client/sample_main.c +++ b/channels/sample/client/sample_main.c @@ -70,7 +70,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in) if (bytes > 0) { data_out = stream_new(bytes); - stream_copy(data_out, data_in, bytes); + Stream_Copy(data_out, data_in, bytes); /* svc_plugin_send takes ownership of data_out, that is why we do not free it */ diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 5adb1aebd..cfc946285 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -144,7 +144,7 @@ static void serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp) serial->tty = NULL; } - Stream_Write_zero(irp->output, 5); /* Padding(5) */ + Stream_Zero(irp->output, 5); /* Padding(5) */ irp->Complete(irp); } diff --git a/channels/server/channels.c b/channels/server/channels.c index 740e7ca2a..57c3a5ab9 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -160,7 +160,7 @@ static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, UINT if (length < 3) return; - Stream_Seek_BYTE(channel->receive_data); /* Pad (1 byte) */ + Stream_Seek_UINT8(channel->receive_data); /* Pad (1 byte) */ Stream_Read_UINT16(channel->receive_data, Version); DEBUG_DVC("Version: %d", Version); @@ -225,7 +225,7 @@ static void wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le if (Stream_GetPosition(channel->receive_data) >= (int) channel->dvc_total_length) { - wts_queue_receive_data(channel, stream_get_head(channel->receive_data), channel->dvc_total_length); + wts_queue_receive_data(channel, Stream_Buffer(channel->receive_data), channel->dvc_total_length); channel->dvc_total_length = 0; } } @@ -344,8 +344,8 @@ static void wts_write_drdynvc_header(wStream *s, BYTE Cmd, UINT32 ChannelId) BYTE* bm; int cbChId; - stream_get_mark(s, bm); - Stream_Seek_BYTE(s); + Stream_GetPointer(s, bm); + Stream_Seek_UINT8(s); cbChId = wts_write_variable_uint(s, ChannelId); *bm = ((Cmd & 0x0F) << 4) | cbChId; } @@ -382,7 +382,7 @@ static void WTSProcessChannelData(rdpPeerChannel* channel, int channelId, BYTE* } else { - wts_queue_receive_data(channel, stream_get_head(channel->receive_data), Stream_GetPosition(channel->receive_data)); + wts_queue_receive_data(channel, Stream_Buffer(channel->receive_data), Stream_GetPosition(channel->receive_data)); } Stream_SetPosition(channel->receive_data, 0); } @@ -576,7 +576,7 @@ void* WTSVirtualChannelOpenEx( s = stream_new(64); wts_write_drdynvc_create_request(s, channel->channel_id, pVirtualName); - WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); stream_free(s); DEBUG_DVC("ChannelId %d.%s (total %d)", channel->channel_id, pVirtualName, list_size(vcm->dvc_channel_list)); @@ -784,7 +784,7 @@ BOOL WTSVirtualChannelWrite( item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize); stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize); - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); cbChId = wts_write_variable_uint(s, channel->channel_id); if (first && (Length > (UINT32) Stream_GetRemainingLength(s))) @@ -847,7 +847,7 @@ BOOL WTSVirtualChannelClose( { s = stream_new(8); wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id); - WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), Stream_GetPosition(s), NULL); + WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); stream_free(s); } } diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index a54b754a4..d75b1d3d9 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -124,7 +124,7 @@ static void smartcard_output_alignment(IRP* irp, UINT32 seed) UINT32 add = (seed - (size % seed)) % seed; if (add > 0) - Stream_Write_zero(irp->output, add); + Stream_Zero(irp->output, add); } static void smartcard_output_repos(IRP* irp, UINT32 written) @@ -132,12 +132,12 @@ static void smartcard_output_repos(IRP* irp, UINT32 written) UINT32 add = (4 - (written % 4)) % 4; if (add > 0) - Stream_Write_zero(irp->output, add); + Stream_Zero(irp->output, add); } static UINT32 smartcard_output_return(IRP* irp, UINT32 status) { - Stream_Write_zero(irp->output, 256); + Stream_Zero(irp->output, 256); return status; } @@ -520,7 +520,7 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) Stream_Write_UINT32(irp->output, cur->cbAtr); Stream_Write(irp->output, cur->rgbAtr, 32); - Stream_Write_zero(irp->output, 4); + Stream_Zero(irp->output, 4); free((void *)cur->szReader); } @@ -838,7 +838,7 @@ static DWORD handle_Status(IRP *irp, BOOL wide) Stream_Write(irp->output, pbAtr, atrLen); if (atrLen < 32) - Stream_Write_zero(irp->output, 32 - atrLen); + Stream_Zero(irp->output, 32 - atrLen); Stream_Write_UINT32(irp->output, atrLen); poslen2 = Stream_GetPosition(irp->output); @@ -1154,7 +1154,7 @@ static UINT32 handle_GetAttrib(IRP* irp) if (!pbAttr) { - Stream_Write_zero(irp->output, dwAttrLen); + Stream_Zero(irp->output, dwAttrLen); } else { @@ -1317,7 +1317,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) Stream_Write_UINT32(irp->output, cur->cbAtr); Stream_Write(irp->output, cur->rgbAtr, 32); - Stream_Write_zero(irp->output, 4); + Stream_Zero(irp->output, 4); free((void*) cur->szReader); } diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index 63f06e72e..2b0af5031 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -520,9 +520,9 @@ BOOL tsmf_codec_check_media_type(wStream* s) BOOL ret; TS_AM_MEDIA_TYPE mediatype; - stream_get_mark(s, m); + Stream_GetPointer(s, m); ret = tsmf_codec_parse_media_type(&mediatype, s); - stream_set_mark(s, m); + Stream_SetPointer(s, m); return ret; } diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index ae0d5b4d9..11bd7a03e 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -62,7 +62,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) pos = Stream_GetPosition(ifman->output); Stream_EnsureRemainingCapacity(ifman->output, ifman->input_size + 4); - stream_copy(ifman->output, ifman->input, ifman->input_size); + Stream_Copy(ifman->output, ifman->input, ifman->input_size); Stream_SetPosition(ifman->output, pos); Stream_Read_UINT32(ifman->output, numHostCapabilities); @@ -80,7 +80,7 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) DEBUG_DVC("server protocol version %d", v); break; case 2: /* Supported platform */ - stream_peek_UINT32(ifman->output, v); + Stream_Peek_UINT32(ifman->output, v); DEBUG_DVC("server supported platform %d", v); /* Claim that we support both MF and DShow platforms. */ Stream_Write_UINT32(ifman->output, diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 2f6617c79..bde4055e9 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -90,7 +90,7 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, Stream_Write_UINT64(s, data_size); /* cbData */ DEBUG_DVC("response size %d", (int) Stream_GetPosition(s)); - status = callback->channel->Write(callback->channel, Stream_GetPosition(s), stream_get_head(s), NULL); + status = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL); if (status) { @@ -323,7 +323,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, Stream_Write_UINT32(output, MessageId); DEBUG_DVC("response size %d", length); - status = callback->channel->Write(callback->channel, length, stream_get_head(output), NULL); + status = callback->channel->Write(callback->channel, length, Stream_Buffer(output), NULL); if (status) { DEBUG_WARN("response error %d", status); diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 96670aa57..a0f2e6762 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -947,7 +947,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) Stream_Write_UINT32(s, offset); Stream_Write(s, data, size); - cb->data = stream_get_head(s); + cb->data = Stream_Buffer(s); cb->data_length = Stream_GetPosition(s); stream_detach(s); stream_free(s); diff --git a/cunit/test_nsc.c b/cunit/test_nsc.c index a59240c43..4ec74aa64 100644 --- a/cunit/test_nsc.c +++ b/cunit/test_nsc.c @@ -366,8 +366,8 @@ void test_nsc_encode(void) Stream_SetPosition(enc_stream, 0); nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3); } - /*winpr_HexDump(stream_get_head(enc_stream), Stream_GetPosition(enc_stream));*/ - nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), Stream_GetPosition(enc_stream)); + /*winpr_HexDump(Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream));*/ + nsc_process_message(context, 32, 64, 64, Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream)); /*winpr_HexDump(context->bmpdata, 64 * 64 * 4);*/ stream_free(enc_stream); diff --git a/cunit/test_rfx.c b/cunit/test_rfx.c index 86eff82b0..ce7a959c8 100644 --- a/cunit/test_rfx.c +++ b/cunit/test_rfx.c @@ -352,11 +352,11 @@ void test_encode(void) //dump_buffer(context->priv->cb_g_buffer, 4096); /*printf("*** Y ***\n"); - winpr_HexDump(stream_get_head(enc_stream), y_size); + winpr_HexDump(Stream_Buffer(enc_stream), y_size); printf("*** Cb ***\n"); - winpr_HexDump(stream_get_head(enc_stream) + y_size, cb_size); + winpr_HexDump(Stream_Buffer(enc_stream) + y_size, cb_size); printf("*** Cr ***\n"); - winpr_HexDump(stream_get_head(enc_stream) + y_size + cb_size, cr_size);*/ + winpr_HexDump(Stream_Buffer(enc_stream) + y_size + cb_size, cr_size);*/ Stream_SetPosition(enc_stream, 0); rfx_decode_rgb(context, enc_stream, diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index b94b6fbbf..30f4c756e 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -504,7 +504,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag return FALSE; } - Stream_Seek_BYTE(s); /* regionFlags (1 byte) */ + Stream_Seek_UINT8(s); /* regionFlags (1 byte) */ Stream_Read_UINT16(s, message->num_rects); /* numRects (2 bytes) */ if (message->num_rects < 1) @@ -621,7 +621,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa Stream_Seek_UINT16(s); /* properties (2 bytes) */ Stream_Read_UINT8(s, context->num_quants); /* numQuant (1 byte) */ - Stream_Seek_BYTE(s); /* tileSize (1 byte), must be set to 0x40 */ + Stream_Seek_UINT8(s); /* tileSize (1 byte), must be set to 0x40 */ if (context->num_quants < 1) { diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 9b1afa408..1f96f7ecc 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -128,8 +128,8 @@ BYTE* rdp_capability_set_start(wStream* s) { BYTE* header; - stream_get_mark(s, header); - Stream_Write_zero(s, CAPSET_HEADER_LENGTH); + Stream_GetPointer(s, header); + Stream_Zero(s, CAPSET_HEADER_LENGTH); return header; } @@ -141,10 +141,10 @@ void rdp_capability_set_finish(wStream* s, BYTE* header, UINT16 type) footer = s->pointer; length = footer - header; - stream_set_mark(s, header); + Stream_SetPointer(s, header); rdp_write_capability_set_header(s, length, type); - stream_set_mark(s, footer); + Stream_SetPointer(s, footer); } /** @@ -311,7 +311,7 @@ BOOL rdp_read_bitmap_capability_set(wStream* s, UINT16 length, rdpSettings* sett Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */ Stream_Read_UINT16(s, desktopResizeFlag); /* desktopResizeFlag (2 bytes) */ Stream_Seek_UINT16(s); /* bitmapCompressionFlag (2 bytes) */ - Stream_Seek_BYTE(s); /* highColorFlags (1 byte) */ + Stream_Seek_UINT8(s); /* highColorFlags (1 byte) */ Stream_Read_UINT8(s, drawingFlags); /* drawingFlags (1 byte) */ Stream_Seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */ Stream_Seek_UINT16(s); /* pad2OctetsB (2 bytes) */ @@ -509,7 +509,7 @@ void rdp_write_order_capability_set(wStream* s, rdpSettings* settings) orderFlags |= ORDER_FLAGS_EXTRA_SUPPORT; } - Stream_Write_zero(s, 16); /* terminalDescriptor (16 bytes) */ + Stream_Zero(s, 16); /* terminalDescriptor (16 bytes) */ Stream_Write_UINT32(s, 0); /* pad4OctetsA (4 bytes) */ Stream_Write_UINT16(s, 1); /* desktopSaveXGranularity (2 bytes) */ Stream_Write_UINT16(s, 20); /* desktopSaveYGranularity (2 bytes) */ @@ -1217,7 +1217,7 @@ void rdp_write_input_capability_set(wStream* s, rdpSettings* settings) Stream_Write_UINT32(s, settings->KeyboardType); /* keyboardType (4 bytes) */ Stream_Write_UINT32(s, settings->KeyboardSubType); /* keyboardSubType (4 bytes) */ Stream_Write_UINT32(s, settings->KeyboardFunctionKey); /* keyboardFunctionKeys (4 bytes) */ - Stream_Write_zero(s, 64); /* imeFileName (64 bytes) */ + Stream_Zero(s, 64); /* imeFileName (64 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_INPUT); } @@ -1575,7 +1575,7 @@ BOOL rdp_read_bitmap_cache_host_support_capability_set(wStream* s, UINT16 length return FALSE; Stream_Read_UINT8(s, cacheVersion); /* cacheVersion (1 byte) */ - Stream_Seek_BYTE(s); /* pad1 (1 byte) */ + Stream_Seek_UINT8(s); /* pad1 (1 byte) */ Stream_Seek_UINT16(s); /* pad2 (2 bytes) */ if (cacheVersion & BITMAP_CACHE_V2) @@ -1668,8 +1668,8 @@ BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, UINT16 length, rdpSetti return FALSE; Stream_Seek_UINT16(s); /* cacheFlags (2 bytes) */ - Stream_Seek_BYTE(s); /* pad2 (1 byte) */ - Stream_Seek_BYTE(s); /* numCellCaches (1 byte) */ + Stream_Seek_UINT8(s); /* pad2 (1 byte) */ + Stream_Seek_UINT8(s); /* numCellCaches (1 byte) */ Stream_Seek(s, 4); /* bitmapCache0CellInfo (4 bytes) */ Stream_Seek(s, 4); /* bitmapCache1CellInfo (4 bytes) */ Stream_Seek(s, 4); /* bitmapCache2CellInfo (4 bytes) */ @@ -1707,7 +1707,7 @@ void rdp_write_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings) rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[2]); /* bitmapCache2CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[3]); /* bitmapCache3CellInfo (4 bytes) */ rdp_write_bitmap_cache_cell_info(s, &settings->BitmapCacheV2CellInfo[4]); /* bitmapCache4CellInfo (4 bytes) */ - Stream_Write_zero(s, 12); /* pad3 (12 bytes) */ + Stream_Zero(s, 12); /* pad3 (12 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_V2); } @@ -2074,7 +2074,7 @@ BOOL rdp_read_window_list_capability_set(wStream* s, UINT16 length, rdpSettings* return FALSE; Stream_Seek_UINT32(s); /* wndSupportLevel (4 bytes) */ - Stream_Seek_BYTE(s); /* numIconCaches (1 byte) */ + Stream_Seek_UINT8(s); /* numIconCaches (1 byte) */ Stream_Seek_UINT16(s); /* numIconCacheEntries (2 bytes) */ return TRUE; @@ -2472,12 +2472,12 @@ BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSetting } else { - Stream_Seek_BYTE(s); /* codecID (1 byte) */ + Stream_Seek_UINT8(s); /* codecID (1 byte) */ } } else { - Stream_Seek_BYTE(s); /* codecID (1 byte) */ + Stream_Seek_UINT8(s); /* codecID (1 byte) */ } Stream_Read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ @@ -2858,7 +2858,7 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei while (numberCapabilities > 0) { - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); rdp_read_capability_set_header(s, &length, &type); @@ -3030,7 +3030,7 @@ BOOL rdp_print_capability_sets(wStream* s, UINT16 numberCapabilities, BOOL recei type, (int) (s->pointer - bm), (int) (em - bm)); } - stream_set_mark(s, em); + Stream_SetPointer(s, em); numberCapabilities--; } @@ -3045,12 +3045,12 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa UINT16 length; BYTE *bm, *em; - stream_get_mark(s, mark); + Stream_GetPointer(s, mark); count = numberCapabilities; while (numberCapabilities > 0) { - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); rdp_read_capability_set_header(s, &length, &type); @@ -3221,16 +3221,16 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa type, (int) (s->pointer - bm), (int) (em - bm)); } - stream_set_mark(s, em); + Stream_SetPointer(s, em); numberCapabilities--; } #ifdef WITH_DEBUG_CAPABILITIES - stream_get_mark(s, em); - stream_set_mark(s, mark); + Stream_GetPointer(s, em); + Stream_SetPointer(s, mark); numberCapabilities = count; rdp_print_capability_sets(s, numberCapabilities, TRUE); - stream_set_mark(s, em); + Stream_SetPointer(s, em); #endif return TRUE; @@ -3335,11 +3335,11 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ Stream_Write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ - stream_get_mark(s, lm); + Stream_GetPointer(s, lm); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ Stream_Write(s, "RDP", 4); /* sourceDescriptor */ - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ @@ -3365,23 +3365,23 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) rdp_write_bitmap_cache_host_support_capability_set(s, settings); } - stream_get_mark(s, em); + Stream_GetPointer(s, em); - stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */ + Stream_SetPointer(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - stream_set_mark(s, bm); /* go back to numberCapabilities */ + Stream_SetPointer(s, bm); /* go back to numberCapabilities */ Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); - stream_set_mark(s, bm); + Stream_SetPointer(s, bm); Stream_Seek_UINT16(s); #endif - stream_set_mark(s, em); + Stream_SetPointer(s, em); Stream_Write_UINT32(s, 0); /* sessionId */ } @@ -3451,11 +3451,11 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) Stream_Write_UINT16(s, 0x03EA); /* originatorId (2 bytes) */ Stream_Write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */ - stream_get_mark(s, lm); + Stream_GetPointer(s, lm); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ Stream_Write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */ - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ @@ -3550,23 +3550,23 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) } } - stream_get_mark(s, em); + Stream_GetPointer(s, em); - stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */ + Stream_SetPointer(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - stream_set_mark(s, bm); /* go back to numberCapabilities */ + Stream_SetPointer(s, bm); /* go back to numberCapabilities */ Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); - stream_set_mark(s, bm); + Stream_SetPointer(s, bm); Stream_Seek_UINT16(s); #endif - stream_set_mark(s, em); + Stream_SetPointer(s, em); } BOOL rdp_send_confirm_active(rdpRdp* rdp) diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index 524ac4356..5ca4a29b3 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -234,7 +234,7 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) { if(Stream_GetRemainingLength(s) < 1) goto error1; - stream_peek_BYTE(s, padding); + Stream_Peek_UINT8(s, padding); if (padding == 0) { diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 1f42291da..8d7008149 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -528,12 +528,12 @@ BOOL rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s) width = rdp->settings->DesktopWidth; height = rdp->settings->DesktopHeight; - stream_get_mark(s, mark); + Stream_GetPointer(s, mark); if (!rdp_recv_demand_active(rdp, s)) { UINT16 channelId; - stream_set_mark(s, mark); + Stream_SetPointer(s, mark); rdp_recv_get_active_header(rdp, s, &channelId); /* Was Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); * but the headers aren't always that length, diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index e85f7f3c6..0fa0c1d19 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -76,7 +76,7 @@ UINT16 fastpath_header_length(wStream* s) { BYTE length1; - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); Stream_Read_UINT8(s, length1); Stream_Rewind(s, 2); @@ -823,7 +823,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) { - stream_get_mark(s, holdp); + Stream_GetPointer(s, holdp); ls = s; dlen = MIN(maxLength, totalLength); cflags = 0; @@ -860,7 +860,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s else fragmentation = (fragment == 0) ? FASTPATH_FRAGMENT_FIRST : FASTPATH_FRAGMENT_NEXT; - stream_get_mark(ls, bm); + Stream_GetPointer(ls, bm); header = 0; if (sec_bytes > 0) @@ -912,7 +912,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s } /* Reserve 6 + sec_bytes bytes for the next fragment header, if any. */ - stream_set_mark(s, holdp + dlen); + Stream_SetPointer(s, holdp + dlen); } stream_detach(update); diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 95e33c70e..c98dd299c 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -582,7 +582,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpSettings* settings, UINT16 blockLe if (blockLength < 1) break; - Stream_Seek_BYTE(s); /* pad1octet */ + Stream_Seek_UINT8(s); /* pad1octet */ blockLength -= 1; if (blockLength < 4) @@ -692,14 +692,14 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) } Stream_Write(s, clientName, (clientNameLength * 2)); - Stream_Write_zero(s, 32 - (clientNameLength * 2)); + Stream_Zero(s, 32 - (clientNameLength * 2)); free(clientName); Stream_Write_UINT32(s, settings->KeyboardType); /* KeyboardType */ Stream_Write_UINT32(s, settings->KeyboardSubType); /* KeyboardSubType */ Stream_Write_UINT32(s, settings->KeyboardFunctionKey); /* KeyboardFunctionKey */ - Stream_Write_zero(s, 64); /* imeFileName */ + Stream_Zero(s, 64); /* imeFileName */ Stream_Write_UINT16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */ Stream_Write_UINT16(s, 1); /* clientProductID */ @@ -739,7 +739,7 @@ void gcc_write_client_core_data(wStream* s, rdpSettings* settings) clientDigProductId[clientDigProductIdLength-1] = 0; } Stream_Write(s, clientDigProductId, (clientDigProductIdLength * 2) ); - Stream_Write_zero(s, 64 - (clientDigProductIdLength * 2) ); + Stream_Zero(s, 64 - (clientDigProductIdLength * 2) ); free(clientDigProductId); Stream_Write_UINT8(s, connectionType); /* connectionType */ @@ -1031,7 +1031,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) Stream_Write(s, settings->RdpServerRsaKey->exponent, expLen); Stream_Write(s, settings->RdpServerRsaKey->Modulus, keyLen); - Stream_Write_zero(s, 8); + Stream_Zero(s, 8); sigDataLen = Stream_Pointer(s) - sigData; @@ -1048,7 +1048,7 @@ void gcc_write_server_security_data(wStream* s, rdpSettings* settings) tssk_modulus, tssk_privateExponent, encryptedSignature); Stream_Write(s, encryptedSignature, sizeof(encryptedSignature)); - Stream_Write_zero(s, 8); + Stream_Zero(s, 8); } /** diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index 16a8f2f05..3cb8259a4 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -602,7 +602,7 @@ void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blo if (blob->length > 0) Stream_Write(s, blob->data, blob->length); /* blobData */ - Stream_Write_zero(s, length - blob->length); + Stream_Zero(s, length - blob->length); } /** diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index ea83878e1..776a4e42f 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -296,7 +296,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) length = Stream_GetPosition(tmps); ber_write_sequence_tag(s, length); - Stream_Write(s, stream_get_head(tmps), length); + Stream_Write(s, Stream_Buffer(tmps), length); stream_free(tmps); } @@ -414,7 +414,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) length = Stream_GetPosition(tmps); /* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */ ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length); - Stream_Write(s, stream_get_head(tmps), length); + Stream_Write(s, Stream_Buffer(tmps), length); stream_free(tmps); } @@ -441,7 +441,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) length = Stream_GetPosition(tmps); ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length); - Stream_Write(s, stream_get_head(tmps), length); + Stream_Write(s, Stream_Buffer(tmps), length); stream_free(tmps); } @@ -468,17 +468,17 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) length = Stream_GetPosition(gcc_CCrq) + 7; s = transport_send_stream_init(mcs->transport, 1024); - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek(s, 7); mcs_write_connect_initial(s, mcs, gcc_CCrq); - stream_get_mark(s, em); + Stream_GetPointer(s, em); length = (em - bm); - stream_set_mark(s, bm); + Stream_SetPointer(s, bm); tpkt_write_header(s, length); tpdu_write_data(s); - stream_set_mark(s, em); + Stream_SetPointer(s, em); status = transport_write(mcs->transport, s); @@ -547,17 +547,17 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) length = Stream_GetPosition(gcc_CCrsp) + 7; s = transport_send_stream_init(mcs->transport, 1024); - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek(s, 7); mcs_write_connect_response(s, mcs, gcc_CCrsp); - stream_get_mark(s, em); + Stream_GetPointer(s, em); length = (em - bm); - stream_set_mark(s, bm); + Stream_SetPointer(s, bm); tpkt_write_header(s, length); tpdu_write_data(s); - stream_set_mark(s, em); + Stream_SetPointer(s, em); ret = transport_write(mcs->transport, s); diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 11dfbb9a0..48f3dbc1e 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -583,12 +583,12 @@ BOOL nego_read_request(rdpNego* nego, wStream* s) if (c != '\x0D') continue; - stream_peek_BYTE(s, c); + Stream_Peek_UINT8(s, c); if (c != '\x0A') continue; - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); break; } } @@ -646,7 +646,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego) s = transport_send_stream_init(nego->transport, 256); length = TPDU_CONNECTION_REQUEST_LENGTH; - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek(s, length); if (nego->RoutingToken) @@ -682,11 +682,11 @@ BOOL nego_send_negotiation_request(rdpNego* nego) length += 8; } - stream_get_mark(s, em); - stream_set_mark(s, bm); + Stream_GetPointer(s, em); + Stream_SetPointer(s, bm); tpkt_write_header(s, length); tpdu_write_connection_request(s, length - 5); - stream_set_mark(s, em); + Stream_SetPointer(s, em); if (transport_write(nego->transport, s) < 0) return FALSE; @@ -810,7 +810,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego) s = transport_send_stream_init(nego->transport, 256); length = TPDU_CONNECTION_CONFIRM_LENGTH; - stream_get_mark(s, bm); + Stream_GetPointer(s, bm); Stream_Seek(s, length); if (nego->selected_protocol > PROTOCOL_RDP) @@ -837,11 +837,11 @@ BOOL nego_send_negotiation_response(rdpNego* nego) status = FALSE; } - stream_get_mark(s, em); - stream_set_mark(s, bm); + Stream_GetPointer(s, em); + Stream_SetPointer(s, bm); tpkt_write_header(s, length); tpdu_write_connection_confirm(s, length - 5); - stream_set_mark(s, em); + Stream_SetPointer(s, em); if (transport_write(nego->transport, s) < 0) return FALSE; diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 014e97fc5..effb2833f 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -236,7 +236,7 @@ static INLINE void update_read_colorref(wStream* s, UINT32* color) *color |= (byte << 8); Stream_Read_UINT8(s, byte); *color |= (byte << 16); - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); } static INLINE void update_read_color_quad(wStream* s, UINT32* color) @@ -249,7 +249,7 @@ static INLINE void update_read_color_quad(wStream* s, UINT32* color) *color |= (byte << 8); Stream_Read_UINT8(s, byte); *color |= byte; - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); } static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) @@ -504,7 +504,7 @@ static INLINE void update_seek_glyph_delta(wStream* s) Stream_Read_UINT8(s, byte); if (byte & 0x80) - Stream_Seek_BYTE(s); + Stream_Seek_UINT8(s); } static INLINE BOOL update_read_brush(wStream* s, rdpBrush* brush, BYTE fieldFlags) @@ -632,7 +632,7 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; - stream_get_mark(s, zeroBits); + Stream_GetPointer(s, zeroBits); Stream_Seek(s, zeroBitsSize); memset(rectangles, 0, sizeof(DELTA_RECT) * (number + 1)); @@ -683,7 +683,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; - stream_get_mark(s, zeroBits); + Stream_GetPointer(s, zeroBits); Stream_Seek(s, zeroBitsSize); memset(points, 0, sizeof(DELTA_POINT) * number); @@ -1511,7 +1511,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap return FALSE; Stream_Read_UINT8(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ - Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ Stream_Read_UINT8(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ Stream_Read_UINT8(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */ Stream_Read_UINT8(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */ @@ -1534,7 +1534,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_order->bitmapDataStream); + Stream_GetPointer(s, cache_bitmap_order->bitmapDataStream); Stream_Seek(s, cache_bitmap_order->bitmapLength); } else @@ -1542,7 +1542,7 @@ BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_order->bitmapDataStream); + Stream_GetPointer(s, cache_bitmap_order->bitmapDataStream); Stream_Seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */ } @@ -1608,7 +1608,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_v2->bitmapDataStream); + Stream_GetPointer(s, cache_bitmap_v2->bitmapDataStream); Stream_Seek(s, cache_bitmap_v2->bitmapLength); } else @@ -1616,7 +1616,7 @@ BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_ if (Stream_GetRemainingLength(s) < cache_bitmap_v2->bitmapLength) return FALSE; - stream_get_mark(s, cache_bitmap_v2->bitmapDataStream); + Stream_GetPointer(s, cache_bitmap_v2->bitmapDataStream); Stream_Seek(s, cache_bitmap_v2->bitmapLength); } @@ -1702,8 +1702,8 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ bitmapData = &cache_bitmap_v3_order->bitmapData; Stream_Read_UINT8(s, bitmapData->bpp); - Stream_Seek_BYTE(s); /* reserved1 (1 byte) */ - Stream_Seek_BYTE(s); /* reserved2 (1 byte) */ + Stream_Seek_UINT8(s); /* reserved1 (1 byte) */ + Stream_Seek_UINT8(s); /* reserved2 (1 byte) */ Stream_Read_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */ Stream_Read_UINT16(s, bitmapData->width); /* width (2 bytes) */ Stream_Read_UINT16(s, bitmapData->height); /* height (2 bytes) */ @@ -2139,7 +2139,7 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* { if (Stream_GetRemainingLength(s) < 11) return FALSE; - Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ @@ -2151,7 +2151,7 @@ BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* dr { if (Stream_GetRemainingLength(s) < 3) return FALSE; - Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize); /* cbSize(2 bytes) + emfRecords */ return TRUE; } @@ -2160,7 +2160,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw { if (Stream_GetRemainingLength(s) < 11) return FALSE; - Stream_Seek_BYTE(s); /* pad1Octet (1 byte) */ + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index b079e5b6d..3e28673aa 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -141,8 +141,8 @@ BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* /* Share Data Header */ Stream_Read_UINT32(s, *share_id); /* shareId (4 bytes) */ - Stream_Seek_BYTE(s); /* pad1 (1 byte) */ - Stream_Seek_BYTE(s); /* streamId (1 byte) */ + Stream_Seek_UINT8(s); /* pad1 (1 byte) */ + Stream_Seek_UINT8(s); /* streamId (1 byte) */ Stream_Read_UINT16(s, *length); /* uncompressedLength (2 bytes) */ Stream_Read_UINT8(s, *type); /* pduType2, Data PDU Type (1 byte) */ Stream_Read_UINT8(s, *compressed_type); /* compressedType (1 byte) */ @@ -807,7 +807,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) { while (Stream_GetRemainingLength(s) > 3) { - stream_get_mark(s, nextp); + Stream_GetPointer(s, nextp); if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource)) return -1; @@ -840,7 +840,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) fprintf(stderr, "incorrect PDU type: 0x%04X\n", pduType); break; } - stream_set_mark(s, nextp); + Stream_SetPointer(s, nextp); } } diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 8e7031cf7..3de41339f 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -99,7 +99,7 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s) while (size > 2) { - stream_get_mark(s, mark); + Stream_GetPointer(s, mark); Stream_Read_UINT16(s, cmdType); size -= 2; diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 8a654fe34..95f06a356 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -140,7 +140,7 @@ void rdp_write_client_time_zone(wStream* s, rdpSettings* settings) /* standardName (64 bytes) */ Stream_Write(s, standardName, standardNameLength); - Stream_Write_zero(s, 64 - standardNameLength); + Stream_Zero(s, 64 - standardNameLength); /* StandardDate */ rdp_write_system_time(s, &clientTimeZone->standardDate); @@ -154,7 +154,7 @@ void rdp_write_client_time_zone(wStream* s, rdpSettings* settings) /* daylightName (64 bytes) */ Stream_Write(s, daylightName, daylightNameLength); - Stream_Write_zero(s, 64 - daylightNameLength); + Stream_Zero(s, 64 - daylightNameLength); /* DaylightDate */ rdp_write_system_time(s, &clientTimeZone->daylightDate); diff --git a/libfreerdp/core/tpkt.c b/libfreerdp/core/tpkt.c index cfd40bf6a..5689d62e4 100644 --- a/libfreerdp/core/tpkt.c +++ b/libfreerdp/core/tpkt.c @@ -67,7 +67,7 @@ BOOL tpkt_verify_header(wStream* s) { BYTE version; - stream_peek_BYTE(s, version); + Stream_Peek_UINT8(s, version); if (version == 3) return TRUE; @@ -86,7 +86,7 @@ UINT16 tpkt_read_header(wStream* s) BYTE version; UINT16 length; - stream_peek_BYTE(s, version); + Stream_Peek_UINT8(s, version); if (version == 3) { diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index f364b60c1..b064ec10a 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -717,7 +717,7 @@ int transport_check_fds(rdpTransport** ptransport) if (length == 0) { fprintf(stderr, "transport_check_fds: protocol error, not a TPKT or Fast Path header.\n"); - winpr_HexDump(stream_get_head(transport->ReceiveBuffer), pos); + winpr_HexDump(Stream_Buffer(transport->ReceiveBuffer), pos); return -1; } diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index beec0b7cc..a4d23d4e1 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -94,7 +94,7 @@ BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data) } bitmap_data->compressed = TRUE; - stream_get_mark(s, bitmap_data->bitmapDataStream); + Stream_GetPointer(s, bitmap_data->bitmapDataStream); Stream_Seek(s, bitmap_data->bitmapLength); } else @@ -102,7 +102,7 @@ BOOL update_read_bitmap_data(wStream* s, BITMAP_DATA* bitmap_data) if (Stream_GetRemainingLength(s) < bitmap_data->bitmapLength) return FALSE; bitmap_data->compressed = FALSE; - stream_get_mark(s, bitmap_data->bitmapDataStream); + Stream_GetPointer(s, bitmap_data->bitmapDataStream); Stream_Seek(s, bitmap_data->bitmapLength); } return TRUE; @@ -270,7 +270,7 @@ BOOL update_read_pointer_color(wStream* s, POINTER_COLOR_UPDATE* pointer_color) } if (Stream_GetRemainingLength(s) > 0) - Stream_Seek_BYTE(s); /* pad (1 byte) */ + Stream_Seek_UINT8(s); /* pad (1 byte) */ return TRUE; } @@ -516,7 +516,7 @@ static void update_send_surface_command(rdpContext* context, wStream* s) update = fastpath_update_pdu_init(rdp->fastpath); Stream_EnsureRemainingCapacity(update, Stream_GetPosition(s)); - Stream_Write(update, stream_get_head(s), Stream_GetPosition(s)); + Stream_Write(update, Stream_Buffer(s), Stream_GetPosition(s)); fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SURFCMDS, update); } @@ -561,7 +561,7 @@ static void update_send_synchronize(rdpContext* context) rdpRdp* rdp = context->rdp; s = fastpath_update_pdu_init(rdp->fastpath); - Stream_Write_zero(s, 2); /* pad2Octets (2 bytes) */ + Stream_Zero(s, 2); /* pad2Octets (2 bytes) */ fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_SYNCHRONIZE, s); } diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index 9743162d0..f56f6a5d7 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -161,7 +161,7 @@ void mf_peer_rfx_update(freerdp_peer* client) cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = stream_get_head(s); + cmd->bitmapData = Stream_Buffer(s); //send diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 47731ae48..4062abf05 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -180,7 +180,7 @@ static void test_peer_draw_background(freerdp_peer* client) cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = stream_get_head(s); + cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); free(rgb_data); @@ -279,7 +279,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y) cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = stream_get_head(s); + cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); } @@ -306,7 +306,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y) cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = Stream_GetPosition(s); - cmd->bitmapData = stream_get_head(s); + cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); context->icon_x = x; @@ -419,7 +419,7 @@ static void* tf_debug_channel_thread_func(void* arg) Stream_SetPosition(s, 0); - if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(context->debug_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) { if (bytes_returned == 0) @@ -427,7 +427,7 @@ static void* tf_debug_channel_thread_func(void* arg) Stream_EnsureRemainingCapacity(s, bytes_returned); - if (WTSVirtualChannelRead(context->debug_channel, 0, stream_get_head(s), + if (WTSVirtualChannelRead(context->debug_channel, 0, Stream_Buffer(s), Stream_Capacity(s), &bytes_returned) == FALSE) { /* should not happen */ diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 28c4b2bb1..091b4e7eb 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -150,7 +150,7 @@ void wf_update_encode(wfInfo* wfi) cmd->width = width; cmd->height = height; cmd->bitmapDataLength = Stream_GetPosition(wfi->s); - cmd->bitmapData = stream_get_head(wfi->s); + cmd->bitmapData = Stream_Buffer(wfi->s); } void wf_update_peer_send(wfInfo* wfi, wfPeerContext* context) diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index 67718a63e..041fe0d71 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -195,6 +195,9 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); #define Stream_GetPosition(_s) (_s->pointer - _s->buffer) #define Stream_SetPosition(_s, _p) _s->pointer = _s->buffer + (_p) +#define Stream_GetPointer(_s, _p) _p = _s->pointer +#define Stream_SetPointer(_s, _p) _s->pointer = _p + #define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer) #define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer)) @@ -214,52 +217,6 @@ WINPR_API void stream_free(wStream* stream); WINPR_API void stream_extend(wStream* stream, int request_size); -#define stream_get_mark(_s,_mark) _mark = _s->pointer -#define stream_set_mark(_s,_mark) _s->pointer = _mark -#define stream_get_head(_s) _s->buffer - -#define Stream_Write_zero(_s, _n) do { \ - memset(_s->pointer, '\0', (_n)); \ - _s->pointer += (_n); \ - } while (0) -#define stream_set_byte(_s, _v, _n) do { \ - memset(_s->pointer, _v, (_n)); \ - _s->pointer += (_n); \ - } while (0) - -#define stream_peek_BYTE(_s, _v) do { _v = *_s->pointer; } while (0) -#define stream_peek_UINT16(_s, _v) do { _v = \ - (UINT16)(*_s->pointer) + \ - (((UINT16)(*(_s->pointer + 1))) << 8); \ - } while (0) -#define stream_peek_UINT32(_s, _v) do { _v = \ - (UINT32)(*_s->pointer) + \ - (((UINT32)(*(_s->pointer + 1))) << 8) + \ - (((UINT32)(*(_s->pointer + 2))) << 16) + \ - (((UINT32)(*(_s->pointer + 3))) << 24); \ - } while (0) -#define stream_peek_UINT64(_s, _v) do { _v = \ - (UINT64)(*_s->pointer) + \ - (((UINT64)(*(_s->pointer + 1))) << 8) + \ - (((UINT64)(*(_s->pointer + 2))) << 16) + \ - (((UINT64)(*(_s->pointer + 3))) << 24) + \ - (((UINT64)(*(_s->pointer + 4))) << 32) + \ - (((UINT64)(*(_s->pointer + 5))) << 40) + \ - (((UINT64)(*(_s->pointer + 6))) << 48) + \ - (((UINT64)(*(_s->pointer + 7))) << 56); \ - } while (0) - -#define Stream_Seek_BYTE(_s) Stream_Seek(_s, 1) -#define Stream_Seek_UINT16(_s) Stream_Seek(_s, 2) -#define Stream_Seek_UINT32(_s) Stream_Seek(_s, 4) -#define Stream_Seek_UINT64(_s) Stream_Seek(_s, 8) - -#define stream_copy(_dst, _src, _n) do { \ - memcpy(_dst->pointer, _src->pointer, _n); \ - _dst->pointer += _n; \ - _src->pointer += _n; \ - } while (0) - static INLINE BOOL stream_skip(wStream* s, size_t sz) { if (Stream_GetRemainingLength(s) < sz) return FALSE; From fdf3ddcf9e55cc432c229c43f7cbba34063b40dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 17:48:30 -0400 Subject: [PATCH 085/144] freerdp: purge deprecated stream utils --- channels/audin/client/audin_main.c | 26 ++++--- channels/audin/server/audin.c | 4 +- channels/cliprdr/client/cliprdr_format.c | 4 +- channels/cliprdr/client/cliprdr_main.c | 4 +- channels/drdynvc/client/drdynvc_main.c | 10 +-- channels/drdynvc/client/dvcman.c | 10 +-- channels/drive/client/drive_main.c | 2 +- channels/parallel/client/parallel_main.c | 2 +- channels/printer/client/printer_main.c | 2 +- channels/rail/client/rail_main.c | 4 +- channels/rail/client/rail_orders.c | 24 +++---- channels/rdpdr/client/irp.c | 6 +- channels/rdpdr/client/rdpdr_capabilities.c | 2 +- channels/rdpdr/client/rdpdr_main.c | 8 +-- channels/rdpsnd/client/rdpsnd_main.c | 12 ++-- channels/rdpsnd/server/rdpsnd.c | 8 +-- channels/sample/client/sample_main.c | 4 +- channels/serial/client/serial_main.c | 2 +- channels/server/channels.c | 25 ++++--- channels/smartcard/client/smartcard_main.c | 2 +- channels/tsmf/client/tsmf_main.c | 15 ++-- client/X11/xf_cliprdr.c | 11 ++- cunit/test_mcs.c | 2 +- cunit/test_rfx.c | 4 +- libfreerdp/codec/nsc.c | 6 +- libfreerdp/codec/rfx.c | 8 +-- libfreerdp/core/capabilities.c | 2 +- libfreerdp/core/certificate.c | 79 ++++++++++++---------- libfreerdp/core/fastpath.c | 18 +++-- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gcc.c | 2 +- libfreerdp/core/mcs.c | 28 ++++---- libfreerdp/core/nla.c | 23 +++---- libfreerdp/core/orders.c | 16 ++--- libfreerdp/core/redirection.c | 6 +- libfreerdp/core/tpdu.c | 2 +- libfreerdp/core/transport.c | 4 +- libfreerdp/crypto/ber.c | 2 +- libfreerdp/utils/svc_plugin.c | 10 +-- server/Mac/mf_peer.c | 4 +- server/Sample/sfreerdp.c | 10 +-- server/Windows/wf_update.c | 2 +- winpr/include/winpr/stream.h | 42 +++++------- winpr/libwinpr/utils/stream.c | 62 ----------------- 44 files changed, 221 insertions(+), 300 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 5c857645e..1b1604490 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -98,11 +98,11 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w DEBUG_DVC("Version=%d", Version); - out = stream_new(5); + out = Stream_New(NULL, 5); Stream_Write_UINT8(out, MSG_SNDIN_VERSION); Stream_Write_UINT32(out, Version); error = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL); - stream_free(out); + Stream_Free(out, TRUE); return error; } @@ -140,7 +140,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w callback->formats = (audinFormat*) malloc(NumFormats * sizeof(audinFormat)); ZeroMemory(callback->formats, NumFormats * sizeof(audinFormat)); - out = stream_new(9); + out = Stream_New(NULL, 9); Stream_Seek(out, 9); /* SoundFormats (variable) */ @@ -190,7 +190,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */ error = callback->channel->Write(callback->channel, cbSizeFormatsPacket, Stream_Buffer(out), NULL); - stream_free(out); + Stream_Free(out, TRUE); return error; } @@ -201,11 +201,11 @@ static int audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCall wStream* out; AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - out = stream_new(5); + out = Stream_New(NULL, 5); Stream_Write_UINT8(out, MSG_SNDIN_FORMATCHANGE); Stream_Write_UINT32(out, NewFormat); error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL); - stream_free(out); + Stream_Free(out, TRUE); return error; } @@ -216,11 +216,11 @@ static int audin_send_open_reply_pdu(IWTSVirtualChannelCallback* pChannelCallbac wStream* out; AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - out = stream_new(5); + out = Stream_New(NULL, 5); Stream_Write_UINT8(out, MSG_SNDIN_OPEN_REPLY); Stream_Write_UINT32(out, Result); error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL); - stream_free(out); + Stream_Free(out, TRUE); return error; } @@ -236,11 +236,11 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data) if (error != 0) return FALSE; - out = stream_new(size + 1); + out = Stream_New(NULL, size + 1); Stream_Write_UINT8(out, MSG_SNDIN_DATA); Stream_Write(out, data, size); error = callback->channel->Write(callback->channel, Stream_GetPosition(out), Stream_Buffer(out), NULL); - stream_free(out); + Stream_Free(out, TRUE); return (error == 0 ? TRUE : FALSE); } @@ -317,8 +317,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s; BYTE MessageId; - s = stream_new(0); - stream_attach(s, pBuffer, cbSize); + s = Stream_New(pBuffer, cbSize); Stream_Read_UINT8(s, MessageId); @@ -348,8 +347,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, break; } - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); return error; } diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index fb7358227..564630d8c 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -314,7 +314,7 @@ static void* audin_server_thread_func(void* arg) break; } - s = stream_new(4096); + s = Stream_New(NULL, 4096); if (ready) { @@ -381,7 +381,7 @@ static void* audin_server_thread_func(void* arg) } } - stream_free(s); + Stream_Free(s, TRUE); WTSVirtualChannelClose(audin->audin_channel); audin->audin_channel = NULL; diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index e4b196499..023bbf8e1 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -57,7 +57,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS } else { - wStream* body = stream_new(0); + wStream* body = Stream_New(NULL, 64); for (i = 0; i < cb_event->num_formats; i++) { @@ -95,7 +95,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body)); Stream_Write(s, Stream_Buffer(body), Stream_Capacity(body)); - stream_free(body); + Stream_Free(body, TRUE); } cliprdr_packet_send(cliprdr, s); diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 2358aef15..91935d4a9 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -57,7 +57,7 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen) { wStream* s; - s = stream_new(dataLen + 8); + s = Stream_New(NULL, dataLen + 8); Stream_Write_UINT16(s, msgType); Stream_Write_UINT16(s, msgFlags); /* Write actual length after the entire packet has been constructed. */ @@ -238,7 +238,7 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s) break; } - stream_free(s); + Stream_Free(s, TRUE); } static void cliprdr_process_event(rdpSvcPlugin* plugin, wMessage* event) diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 92db87375..692e0ddd3 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -92,7 +92,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN if (drdynvc->channel_error != CHANNEL_RC_OK) return 1; - data_out = stream_new(CHANNEL_CHUNK_LENGTH); + data_out = Stream_New(NULL, CHANNEL_CHUNK_LENGTH); Stream_SetPosition(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); @@ -129,7 +129,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN while (error == CHANNEL_RC_OK && data_size > 0) { - data_out = stream_new(CHANNEL_CHUNK_LENGTH); + data_out = Stream_New(NULL, CHANNEL_CHUNK_LENGTH); Stream_SetPosition(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); @@ -190,7 +190,7 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in Stream_Read_UINT16(s, drdynvc->PriorityCharge3); } - data_out = stream_new(4); + data_out = Stream_New(NULL, 4); Stream_Write_UINT16(data_out, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */ Stream_Write_UINT16(data_out, drdynvc->version); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); @@ -241,7 +241,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); - data_out = stream_new(pos + 4); + data_out = Stream_New(NULL, pos + 4); Stream_Write_UINT8(data_out, 0x10 | cbChId); Stream_SetPosition(s, 1); Stream_Copy(data_out, s, pos - 1); @@ -346,7 +346,7 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s) break; } - stream_free(s); + Stream_Free(s, TRUE); } static void drdynvc_process_connect(rdpSvcPlugin* plugin) diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index 62b6fd58c..3b1cf5faa 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -398,7 +398,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI if (channel->dvc_data) { - stream_free(channel->dvc_data); + Stream_Free(channel->dvc_data, TRUE); channel->dvc_data = NULL; } @@ -422,9 +422,9 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI } if (channel->dvc_data) - stream_free(channel->dvc_data); + Stream_Free(channel->dvc_data, TRUE); - channel->dvc_data = stream_new(length); + channel->dvc_data = Stream_New(NULL, length); return 0; } @@ -448,7 +448,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C if (Stream_GetPosition(channel->dvc_data) + data_size > (UINT32) Stream_Capacity(channel->dvc_data)) { DEBUG_WARN("data exceeding declared length!"); - stream_free(channel->dvc_data); + Stream_Free(channel->dvc_data, TRUE); channel->dvc_data = NULL; return 1; } @@ -459,7 +459,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C { error = channel->channel_callback->OnDataReceived(channel->channel_callback, Stream_Capacity(channel->dvc_data), Stream_Buffer(channel->dvc_data)); - stream_free(channel->dvc_data); + Stream_Free(channel->dvc_data, TRUE); channel->dvc_data = NULL; } } diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index b6fa5f09f..d4baee68c 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -710,7 +710,7 @@ void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* disk->device.Free = drive_free; length = strlen(name); - disk->device.data = stream_new(length + 1); + disk->device.data = Stream_New(NULL, length + 1); for (i = 0; i <= length; i++) Stream_Write_UINT8(disk->device.data, name[i] < 0 ? '_' : name[i]); diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 95b90afe1..6e35c1ee9 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -319,7 +319,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) parallel->device.Free = parallel_free; length = strlen(name); - parallel->device.data = stream_new(length + 1); + parallel->device.data = Stream_New(NULL, length + 1); for (i = 0; i <= length; i++) Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]); diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index d5a1dee30..0ecd3e8c6 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -259,7 +259,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, &DriverName, 0) * 2; PrintNameLen = ConvertToUnicode(CP_UTF8, 0, printer->name, -1, &PrintName, 0) * 2; - printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen); + printer_dev->device.data = Stream_New(NULL, 28 + DriverNameLen + PrintNameLen + CachedFieldsLen); Stream_Write_UINT32(printer_dev->device.data, Flags); Stream_Write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */ diff --git a/channels/rail/client/rail_main.c b/channels/rail/client/rail_main.c index 3b2fcbda3..717cbabea 100644 --- a/channels/rail/client/rail_main.c +++ b/channels/rail/client/rail_main.c @@ -43,7 +43,7 @@ void rail_send_channel_data(void* rail_object, void* data, size_t length) wStream* s = NULL; railPlugin* plugin = (railPlugin*) rail_object; - s = stream_new(length); + s = Stream_New(NULL, length); Stream_Write(s, data, length); svc_plugin_send((rdpSvcPlugin*) plugin, s); @@ -89,7 +89,7 @@ static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s) { railPlugin* rail = (railPlugin*) plugin; rail_order_recv(rail->rail_order, s); - stream_free(s); + Stream_Free(s, TRUE); } static void rail_process_addin_args(rdpRailOrder* rail_order, rdpSettings* settings) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index d7185bd78..737e2a4a0 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -106,7 +106,7 @@ void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength) wStream* rail_pdu_init(int length) { wStream* s; - s = stream_new(length + RAIL_PDU_HEADER_LENGTH); + s = Stream_New(NULL, length + RAIL_PDU_HEADER_LENGTH); Stream_Seek(s, RAIL_PDU_HEADER_LENGTH); return s; } @@ -513,7 +513,7 @@ void rail_send_handshake_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH); rail_write_handshake_order(s, &rail_order->handshake); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_HANDSHAKE); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_status_order(rdpRailOrder* rail_order) @@ -522,7 +522,7 @@ void rail_send_client_status_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH); rail_write_client_status_order(s, &rail_order->client_status); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_CLIENT_STATUS); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_exec_order(rdpRailOrder* rail_order) @@ -538,7 +538,7 @@ void rail_send_client_exec_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_EXEC_ORDER_LENGTH); rail_write_client_exec_order(s, &rail_order->exec); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_EXEC); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_sysparam_order(rdpRailOrder* rail_order) @@ -571,7 +571,7 @@ void rail_send_client_sysparam_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8); rail_write_client_sysparam_order(s, &rail_order->sysparam); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSPARAM); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_sysparams_order(rdpRailOrder* rail_order) @@ -625,7 +625,7 @@ void rail_send_client_activate_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH); rail_write_client_activate_order(s, &rail_order->activate); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_ACTIVATE); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_sysmenu_order(rdpRailOrder* rail_order) @@ -634,7 +634,7 @@ void rail_send_client_sysmenu_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH); rail_write_client_sysmenu_order(s, &rail_order->sysmenu); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSMENU); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_syscommand_order(rdpRailOrder* rail_order) @@ -643,7 +643,7 @@ void rail_send_client_syscommand_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH); rail_write_client_syscommand_order(s, &rail_order->syscommand); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSCOMMAND); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_notify_event_order(rdpRailOrder* rail_order) @@ -652,7 +652,7 @@ void rail_send_client_notify_event_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH); rail_write_client_notify_event_order(s, &rail_order->notify_event); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_NOTIFY_EVENT); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_window_move_order(rdpRailOrder* rail_order) @@ -661,7 +661,7 @@ void rail_send_client_window_move_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH); rail_write_client_window_move_order(s, &rail_order->window_move); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_WINDOW_MOVE); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_get_appid_req_order(rdpRailOrder* rail_order) @@ -670,7 +670,7 @@ void rail_send_client_get_appid_req_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH); rail_write_client_get_appid_req_order(s, &rail_order->get_appid_req); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_GET_APPID_REQ); - stream_free(s) ; + Stream_Free(s, TRUE); } void rail_send_client_langbar_info_order(rdpRailOrder* rail_order) @@ -679,7 +679,7 @@ void rail_send_client_langbar_info_order(rdpRailOrder* rail_order) s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH); rail_write_langbar_info_order(s, &rail_order->langbar_info); rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_LANGBAR_INFO); - stream_free(s); + Stream_Free(s, TRUE); } rdpRailOrder* rail_order_new() diff --git a/channels/rdpdr/client/irp.c b/channels/rdpdr/client/irp.c index 50649e4a6..e2cdd6a98 100644 --- a/channels/rdpdr/client/irp.c +++ b/channels/rdpdr/client/irp.c @@ -39,8 +39,8 @@ static void irp_free(IRP* irp) { DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId); - stream_free(irp->input); - stream_free(irp->output); + Stream_Free(irp->input, TRUE); + Stream_Free(irp->output, TRUE); _aligned_free(irp); } @@ -88,7 +88,7 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in) Stream_Read_UINT32(data_in, irp->MinorFunction); irp->input = data_in; - irp->output = stream_new(256); + irp->output = Stream_New(NULL, 256); Stream_Write_UINT16(irp->output, RDPDR_CTYP_CORE); Stream_Write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION); Stream_Write_UINT32(irp->output, DeviceId); diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index ff4640259..025977c92 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -172,7 +172,7 @@ void rdpdr_send_capability_response(rdpdrPlugin* rdpdr) { wStream* data_out; - data_out = stream_new(256); + data_out = Stream_New(NULL, 256); Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_CAPABILITY); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 84ed6a046..bcf19df82 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -77,7 +77,7 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) { wStream* data_out; - data_out = stream_new(12); + data_out = Stream_New(NULL, 12); Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); Stream_Write_UINT16(data_out, PAKID_CORE_CLIENTID_CONFIRM); @@ -100,7 +100,7 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2; - data_out = stream_new(16 + computerNameLenW + 2); + data_out = Stream_New(NULL, 16 + computerNameLenW + 2); Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_NAME); @@ -152,7 +152,7 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use DEVICE* device; LIST_ITEM* item; - data_out = stream_new(256); + data_out = Stream_New(NULL, 256); Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE); Stream_Write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE); @@ -294,7 +294,7 @@ static void rdpdr_process_receive(rdpSvcPlugin* plugin, wStream* data_in) DEBUG_WARN("RDPDR component: 0x%02X packetID: 0x%02X", component, packetID); } - stream_free(data_in); + Stream_Free(data_in, TRUE); } static void rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 8a215b473..d7ee92927 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -126,7 +126,7 @@ void rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd) { wStream* pdu; - pdu = stream_new(8); + pdu = Stream_New(NULL, 8); Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */ Stream_Write_UINT8(pdu, 0); /* bPad */ Stream_Write_UINT16(pdu, 4); /* BodySize */ @@ -217,7 +217,7 @@ void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) for (index = 0; index < (int) wNumberOfFormats; index++) length += (18 + rdpsnd->ClientFormats[index].cbSize); - pdu = stream_new(length); + pdu = Stream_New(NULL, length); Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */ Stream_Write_UINT8(pdu, 0); /* bPad */ @@ -302,7 +302,7 @@ void rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, U { wStream* pdu; - pdu = stream_new(8); + pdu = Stream_New(NULL, 8); Stream_Write_UINT8(pdu, SNDC_TRAINING); /* msgType */ Stream_Write_UINT8(pdu, 0); /* bPad */ Stream_Write_UINT16(pdu, 4); /* BodySize */ @@ -367,7 +367,7 @@ void rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, BYTE { wStream* pdu; - pdu = stream_new(8); + pdu = Stream_New(NULL, 8); Stream_Write_UINT8(pdu, SNDC_WAVECONFIRM); Stream_Write_UINT8(pdu, 0); Stream_Write_UINT16(pdu, 4); @@ -476,7 +476,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s) if (rdpsnd->expectingWave) { rdpsnd_recv_wave_pdu(rdpsnd, s); - stream_free(s); + Stream_Free(s, TRUE); return; } @@ -513,7 +513,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s) break; } - stream_free(s); + Stream_Free(s, TRUE); } static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlugin* device) diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index c888f4823..57a9593a2 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -203,7 +203,7 @@ static void* rdpsnd_server_thread_func(void* arg) events[1] = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd); } - s = stream_new(4096); + s = Stream_New(NULL, 4096); rdpsnd_server_send_formats(rdpsnd, s); @@ -256,7 +256,7 @@ static void* rdpsnd_server_thread_func(void* arg) } } - stream_free(s); + Stream_Free(s, TRUE); return NULL; } @@ -269,7 +269,7 @@ static BOOL rdpsnd_server_initialize(rdpsnd_server_context* context) if (rdpsnd->rdpsnd_channel != NULL) { - rdpsnd->rdpsnd_pdu = stream_new(4096); + rdpsnd->rdpsnd_pdu = Stream_New(NULL, 4096); rdpsnd->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); @@ -545,7 +545,7 @@ void rdpsnd_server_context_free(rdpsnd_server_context* context) WTSVirtualChannelClose(rdpsnd->rdpsnd_channel); if (rdpsnd->rdpsnd_pdu) - stream_free(rdpsnd->rdpsnd_pdu); + Stream_Free(rdpsnd->rdpsnd_pdu, TRUE); if (rdpsnd->out_buffer) free(rdpsnd->out_buffer); diff --git a/channels/sample/client/sample_main.c b/channels/sample/client/sample_main.c index 417b4a0e8..92024693f 100644 --- a/channels/sample/client/sample_main.c +++ b/channels/sample/client/sample_main.c @@ -69,7 +69,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in) if (bytes > 0) { - data_out = stream_new(bytes); + data_out = Stream_New(NULL, bytes); Stream_Copy(data_out, data_in, bytes); /* svc_plugin_send takes ownership of data_out, that is why we do not free it */ @@ -80,7 +80,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in) svc_plugin_send(plugin, data_out); } - stream_free(data_in); + Stream_Free(data_in, TRUE); } static void sample_process_connect(rdpSvcPlugin* plugin) diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index cfc946285..df4700e9f 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -703,7 +703,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) serial->device.Free = serial_free; len = strlen(name); - serial->device.data = stream_new(len + 1); + serial->device.data = Stream_New(NULL, len + 1); for (i = 0; i <= len; i++) Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]); diff --git a/channels/server/channels.c b/channels/server/channels.c index 57c3a5ab9..18facafd5 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -564,7 +564,7 @@ void* WTSVirtualChannelOpenEx( channel->vcm = vcm; channel->client = client; channel->channel_type = RDP_PEER_CHANNEL_TYPE_DVC; - channel->receive_data = stream_new(client->settings->VirtualChannelChunkSize); + channel->receive_data = Stream_New(NULL, client->settings->VirtualChannelChunkSize); channel->receive_event = CreateEvent(NULL, TRUE, FALSE, NULL); channel->receive_queue = list_new(); channel->mutex = CreateMutex(NULL, FALSE, NULL); @@ -574,10 +574,10 @@ void* WTSVirtualChannelOpenEx( list_enqueue(vcm->dvc_channel_list, channel); ReleaseMutex(vcm->mutex); - s = stream_new(64); + s = Stream_New(NULL, 64); wts_write_drdynvc_create_request(s, channel->channel_id, pVirtualName); WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); - stream_free(s); + Stream_Free(s, TRUE); DEBUG_DVC("ChannelId %d.%s (total %d)", channel->channel_id, pVirtualName, list_size(vcm->dvc_channel_list)); } @@ -612,7 +612,7 @@ void* WTSVirtualChannelOpenEx( channel->channel_id = client->settings->ChannelDefArray[i].ChannelId; channel->index = i; channel->channel_type = RDP_PEER_CHANNEL_TYPE_SVC; - channel->receive_data = stream_new(client->settings->VirtualChannelChunkSize); + channel->receive_data = Stream_New(NULL, client->settings->VirtualChannelChunkSize); channel->receive_event = CreateEvent(NULL, TRUE, FALSE, NULL); channel->receive_queue = list_new(); channel->mutex = CreateMutex(NULL, FALSE, NULL); @@ -773,7 +773,6 @@ BOOL WTSVirtualChannelWrite( } else { - s = stream_new(0); first = TRUE; while (Length > 0) @@ -781,8 +780,8 @@ BOOL WTSVirtualChannelWrite( item = (wts_data_item*) malloc(sizeof(wts_data_item)); ZeroMemory(item, sizeof(wts_data_item)); - item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize); - stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize); + s = Stream_New(NULL, channel->client->settings->VirtualChannelChunkSize); + item->buffer = Stream_Buffer(s); Stream_Seek_UINT8(s); cbChId = wts_write_variable_uint(s, channel->channel_id); @@ -805,18 +804,18 @@ BOOL WTSVirtualChannelWrite( Stream_Write(s, Buffer, written); item->length = Stream_GetPosition(s); - stream_detach(s); + Stream_Free(s, FALSE); + Length -= written; Buffer += written; wts_queue_send_item(channel->vcm->drdynvc_channel, item); } - - stream_free(s); } if (pBytesWritten != NULL) *pBytesWritten = Length; + return TRUE; } @@ -845,15 +844,15 @@ BOOL WTSVirtualChannelClose( if (channel->dvc_open_state == DVC_OPEN_STATE_SUCCEEDED) { - s = stream_new(8); + s = Stream_New(NULL, 8); wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id); WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL); - stream_free(s); + Stream_Free(s, TRUE); } } if (channel->receive_data) - stream_free(channel->receive_data); + Stream_Free(channel->receive_data, TRUE); if (channel->receive_event) CloseHandle(channel->receive_event); diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 3d20cb982..fa4dd0b3d 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -325,7 +325,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) smartcard->device.Free = smartcard_free; length = strlen(smartcard->device.name); - smartcard->device.data = stream_new(length + 1); + smartcard->device.data = Stream_New(NULL, length + 1); for (i = 0; i <= length; i++) Stream_Write_UINT8(smartcard->device.data, name[i] < 0 ? '_' : name[i]); diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index bde4055e9..a479c42df 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -81,7 +81,7 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, int status; TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback; - s = stream_new(32); + s = Stream_New(NULL, 32); Stream_Write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY); Stream_Write_UINT32(s, message_id); Stream_Write_UINT32(s, PLAYBACK_ACK); /* FunctionId */ @@ -97,7 +97,7 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, DEBUG_WARN("response error %d", status); } - stream_free(s); + Stream_Free(s, TRUE); } BOOL tsmf_push_event(IWTSVirtualChannelCallback* pChannelCallback, wMessage* event) @@ -136,9 +136,9 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, DEBUG_WARN("invalid size. cbSize=%d", cbSize); return 1; } - input = stream_new(0); - stream_attach(input, (BYTE*) pBuffer, cbSize); - output = stream_new(256); + + input = Stream_New((BYTE*) pBuffer, cbSize); + output = Stream_New(NULL, 256); Stream_Seek(output, 8); Stream_Read_UINT32(input, InterfaceId); @@ -282,8 +282,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, break; } - stream_detach(input); - stream_free(input); + Stream_Free(input, FALSE); input = NULL; ifman.input = NULL; @@ -330,7 +329,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, } } - stream_free(output); + Stream_Free(output, TRUE); return status; } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index a0f2e6762..430f52ff6 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -928,18 +928,16 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) return; } - s = stream_new(0); - stream_attach(s, data, size); + s = Stream_New(data, size); Stream_Seek(s, 14); Stream_Read_UINT16(s, bpp); Stream_Read_UINT32(s, ncolors); offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); DEBUG_X11_CLIPRDR("offset=%d bpp=%d ncolors=%d", offset, bpp, ncolors); - s = stream_new(14 + size); + s = Stream_New(NULL, 14 + size); Stream_Write_UINT8(s, 'B'); Stream_Write_UINT8(s, 'M'); Stream_Write_UINT32(s, 14 + size); @@ -949,8 +947,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size) cb->data = Stream_Buffer(s); cb->data_length = Stream_GetPosition(s); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); } static void xf_cliprdr_process_html(clipboardContext* cb, BYTE* data, int size) diff --git a/cunit/test_mcs.c b/cunit/test_mcs.c index f9a0e9dba..b33d7fa71 100644 --- a/cunit/test_mcs.c +++ b/cunit/test_mcs.c @@ -111,5 +111,5 @@ void test_mcs_write_connect_initial(void) ASSERT_STREAM(s, (BYTE*) mcs_connect_initial_expected, sizeof(mcs_connect_initial_expected)); - stream_free(s); + Stream_Free(s, TRUE); } diff --git a/cunit/test_rfx.c b/cunit/test_rfx.c index ce7a959c8..aae5b2472 100644 --- a/cunit/test_rfx.c +++ b/cunit/test_rfx.c @@ -321,7 +321,7 @@ void test_decode(void) sizeof(cr_data), test_quantization_values, decode_buffer); rfx_context_free(context); - stream_free(s); + Stream_Free(s, TRUE); dump_ppm_image(decode_buffer); } @@ -410,7 +410,7 @@ void test_message(void) } } rfx_message_free(context, message); - stream_free(s); + Stream_Free(s, TRUE); } rfx_context_free(context); diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 2db011ac7..ba435a0c8 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -329,14 +329,12 @@ void nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, { wStream* s; - s = stream_new(0); - stream_attach(s, data, length); + s = Stream_New(data, length); context->bpp = bpp; context->width = width; context->height = height; nsc_context_initialize(context, s); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); /* RLE decode */ PROFILER_ENTER(context->priv->prof_nsc_rle_decompress_data); diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 30f4c756e..afd9e5ecc 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -758,8 +758,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE)); ZeroMemory(message, sizeof(RFX_MESSAGE)); - s = stream_new(0); - stream_attach(s, data, length); + s = Stream_New(data, length); while (Stream_GetRemainingLength(s) > 6) { @@ -789,7 +788,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length /* RFX_CODEC_CHANNELT */ /* codecId (1 byte) must be set to 0x01 */ /* channelId (1 byte) must be set to 0x00 */ - if (!stream_skip(s, 2)) + if (!Stream_SafeSeek(s, 2)) { DEBUG_WARN("rfx_process_message: unable to skip RFX_CODEC_CHANNELT"); break; @@ -838,8 +837,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length Stream_SetPosition(s, pos); } - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); return message; } diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 1f96f7ecc..8080f9e2e 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -3308,7 +3308,7 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ Stream_Read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - if (!stream_skip(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */ + if (!Stream_SafeSeek(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */ return FALSE; Stream_Read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index 5ca4a29b3..6a28ab3b2 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -160,110 +160,115 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) int exponent_length; int error = 0; - s = stream_new(0); - stream_attach(s, cert->data, cert->length); + s = Stream_New(cert->data, cert->length); info->Modulus = 0; - if(!ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */ goto error1; error++; - if(!ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */ goto error1; error++; - if(!ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */ + if (!ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */ goto error1; error++; - if(!ber_read_integer(s, &version)) /* version (INTEGER) */ + if (!ber_read_integer(s, &version)) /* version (INTEGER) */ goto error1; error++; version++; /* serialNumber */ - if(!ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */ + if (!ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */ goto error1; error++; /* signature */ - if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* AlgorithmIdentifier (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */ goto error1; error++; /* issuer */ - if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Name (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */ goto error1; error++; /* validity */ - if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Validity (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Validity (SEQUENCE) */ goto error1; error++; /* subject */ - if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Name (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */ goto error1; error++; /* subjectPublicKeyInfo */ - if(!ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */ goto error1; error++; /* subjectPublicKeyInfo::AlgorithmIdentifier */ - if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* AlgorithmIdentifier (SEQUENCE) */ + if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */ goto error1; error++; /* subjectPublicKeyInfo::subjectPublicKey */ - if(!ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */ + if (!ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */ goto error1; error++; /* RSAPublicKey (SEQUENCE) */ - if(!ber_read_sequence_tag(s, &length)) /* SEQUENCE */ + if (!ber_read_sequence_tag(s, &length)) /* SEQUENCE */ goto error1; error++; - if(!ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */ + if (!ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */ goto error1; error++; /* skip zero padding, if any */ do { - if(Stream_GetRemainingLength(s) < 1) + if (Stream_GetRemainingLength(s) < 1) goto error1; + Stream_Peek_UINT8(s, padding); if (padding == 0) { - if(!stream_skip(s, 1)) + if (!Stream_SafeSeek(s, 1)) goto error1; + modulus_length--; } } while (padding == 0); + error++; - if(Stream_GetRemainingLength(s) < modulus_length) + if (Stream_GetRemainingLength(s) < modulus_length) goto error1; + info->ModulusLength = modulus_length; info->Modulus = (BYTE*) malloc(info->ModulusLength); Stream_Read(s, info->Modulus, info->ModulusLength); error++; - if(!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */ + if (!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */ goto error2; + error++; - if(Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4) + + if (Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4) goto error2; + Stream_Read(s, &info->exponent[4 - exponent_length], exponent_length); crypto_reverse(info->Modulus, info->ModulusLength); crypto_reverse(info->exponent, 4); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); return TRUE; error2: @@ -271,8 +276,7 @@ error2: info->Modulus = 0; error1: fprintf(stderr, "error reading when reading certificate: part=%s error=%d\n", certificate_read_errors[error], error); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); return FALSE; } @@ -325,7 +329,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w UINT32 datalen; UINT32 modlen; - if(Stream_GetRemainingLength(s) < 20) + if (Stream_GetRemainingLength(s) < 20) return FALSE; Stream_Read(s, magic, 4); @@ -341,7 +345,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w Stream_Read(s, certificate->cert_info.exponent, 4); modlen = keylen - 8; - if(Stream_GetRemainingLength(s) < modlen + 8) // count padding + if (Stream_GetRemainingLength(s) < modlen + 8) // count padding return FALSE; certificate->cert_info.ModulusLength = modlen; certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength); @@ -425,7 +429,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate BYTE* sigdata; int sigdatalen; - if(Stream_GetRemainingLength(s) < 12) + if (Stream_GetRemainingLength(s) < 12) return FALSE; /* -4, because we need to include dwVersion */ @@ -448,7 +452,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate } Stream_Read_UINT16(s, wPublicKeyBlobLen); - if(Stream_GetRemainingLength(s) < wPublicKeyBlobLen) + if (Stream_GetRemainingLength(s) < wPublicKeyBlobLen) return FALSE; if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen)) @@ -457,7 +461,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate return FALSE; } - if(Stream_GetRemainingLength(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; sigdatalen = Stream_Pointer(s) - sigdata; @@ -470,7 +474,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate } Stream_Read_UINT16(s, wSignatureBlobLen); - if(Stream_GetRemainingLength(s) < wSignatureBlobLen) + if (Stream_GetRemainingLength(s) < wSignatureBlobLen) return FALSE; if (wSignatureBlobLen != 72) @@ -503,7 +507,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, DEBUG_CERTIFICATE("Server X.509 Certificate Chain"); - if(Stream_GetRemainingLength(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; Stream_Read_UINT32(s, numCertBlobs); /* numCertBlobs */ @@ -511,10 +515,12 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, for (i = 0; i < (int) numCertBlobs; i++) { - if(Stream_GetRemainingLength(s) < 4) + if (Stream_GetRemainingLength(s) < 4) return FALSE; + Stream_Read_UINT32(s, certLength); - if(Stream_GetRemainingLength(s) < certLength) + + if (Stream_GetRemainingLength(s) < certLength) return FALSE; DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength); @@ -571,8 +577,7 @@ int certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serve if (length < 4) return -1; - s = stream_new(0); - stream_attach(s, server_cert, length); + s = Stream_New(server_cert, length); Stream_Read_UINT32(s, dwVersion); /* dwVersion (4 bytes) */ @@ -592,7 +597,7 @@ int certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serve break; } - free(s); + Stream_Free(s, FALSE); return status; } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 0fa0c1d19..2987b67c9 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -196,7 +196,7 @@ static BOOL fastpath_recv_update_synchronize(rdpFastPath* fastpath, wStream* s) { /* server 2008 can send invalid synchronize packet with missing padding, so don't return FALSE even if the packet is invalid */ - stream_skip(s, 2); /* size (2 bytes), MUST be set to zero */ + Stream_SafeSeek(s, 2); /* size (2 bytes), MUST be set to zero */ return TRUE; } @@ -813,13 +813,13 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s result = TRUE; rdp = fastpath->rdp; + update = comp_update = ls = NULL; + try_comp = rdp->settings->CompressionEnabled; + sec_bytes = fastpath_get_sec_bytes(rdp); maxLength = FASTPATH_MAX_PACKET_SIZE - (6 + sec_bytes); totalLength = Stream_GetPosition(s) - (6 + sec_bytes); Stream_SetPosition(s, 0); - update = stream_new(0); - try_comp = rdp->settings->CompressionEnabled; - comp_update = stream_new(0); for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) { @@ -842,7 +842,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s comp_flags = FASTPATH_OUTPUT_COMPRESSION_USED; header_bytes = 7 + sec_bytes; bm = (BYTE*) (rdp->mppc_enc->outputBuffer - header_bytes); - stream_attach(comp_update, bm, pdu_data_bytes + header_bytes); + comp_update = Stream_New(bm, pdu_data_bytes + header_bytes); ls = comp_update; } } @@ -888,7 +888,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s Stream_Write_UINT16(ls, pdu_data_bytes); - stream_attach(update, bm, pduLength); + update = Stream_New(bm, pduLength); Stream_Seek(update, pduLength); if (sec_bytes > 0) @@ -915,10 +915,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s Stream_SetPointer(s, holdp + dlen); } - stream_detach(update); - stream_detach(comp_update); - stream_free(update); - stream_free(comp_update); + Stream_Free(update, FALSE); + Stream_Free(comp_update, FALSE); return result; } diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index f0394c2da..20a739d04 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -124,7 +124,7 @@ BOOL freerdp_connect(freerdp* instance) rdpUpdate* update; pcap_record record; - s = stream_new(1024); + s = Stream_New(NULL, 1024); instance->update->pcap_rfx = pcap_open(instance->settings->PlayRemoteFxFile, FALSE); if (instance->update->pcap_rfx) diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index c98dd299c..b43785170 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -1140,7 +1140,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings) } if (channelCount % 2 == 1) - return stream_skip(s, 2); /* padding */ + return Stream_SafeSeek(s, 2); /* padding */ return TRUE; } diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 776a4e42f..29682e7d5 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -284,7 +284,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) int length; wStream* tmps; - tmps = stream_new(Stream_Capacity(s)); + tmps = Stream_New(NULL, Stream_Capacity(s)); ber_write_integer(tmps, domainParameters->maxChannelIds); ber_write_integer(tmps, domainParameters->maxUserIds); ber_write_integer(tmps, domainParameters->maxTokenIds); @@ -297,7 +297,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters) length = Stream_GetPosition(tmps); ber_write_sequence_tag(s, length); Stream_Write(s, Stream_Buffer(tmps), length); - stream_free(tmps); + Stream_Free(tmps, TRUE); } /** @@ -388,7 +388,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) int length; wStream* tmps; - tmps = stream_new(Stream_Capacity(s)); + tmps = Stream_New(NULL, Stream_Capacity(s)); /* callingDomainSelector (OCTET_STRING) */ ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector)); @@ -415,7 +415,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data) /* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */ ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length); Stream_Write(s, Stream_Buffer(tmps), length); - stream_free(tmps); + Stream_Free(tmps, TRUE); } /** @@ -431,7 +431,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) int length; wStream* tmps; - tmps = stream_new(Stream_Capacity(s)); + tmps = Stream_New(NULL, Stream_Capacity(s)); ber_write_enumerated(tmps, 0, MCS_Result_enum_length); ber_write_integer(tmps, 0); /* calledConnectId */ mcs->domainParameters = mcs->targetParameters; @@ -442,7 +442,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) length = Stream_GetPosition(tmps); ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length); Stream_Write(s, Stream_Buffer(tmps), length); - stream_free(tmps); + Stream_Free(tmps, TRUE); } /** @@ -460,10 +460,10 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) wStream* client_data; int status; - client_data = stream_new(512); + client_data = Stream_New(NULL, 512); gcc_write_client_data_blocks(client_data, mcs->transport->settings); - gcc_CCrq = stream_new(512); + gcc_CCrq = Stream_New(NULL, 512); gcc_write_conference_create_request(gcc_CCrq, client_data); length = Stream_GetPosition(gcc_CCrq) + 7; @@ -482,8 +482,8 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) status = transport_write(mcs->transport, s); - stream_free(gcc_CCrq); - stream_free(client_data); + Stream_Free(gcc_CCrq, TRUE); + Stream_Free(client_data, TRUE); return (status < 0 ? FALSE : TRUE); } @@ -539,10 +539,10 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) wStream* gcc_CCrsp; wStream* server_data; - server_data = stream_new(512); + server_data = Stream_New(NULL, 512); gcc_write_server_data_blocks(server_data, mcs->transport->settings); - gcc_CCrsp = stream_new(512); + gcc_CCrsp = Stream_New(NULL, 512); gcc_write_conference_create_response(gcc_CCrsp, server_data); length = Stream_GetPosition(gcc_CCrsp) + 7; @@ -561,8 +561,8 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) ret = transport_write(mcs->transport, s); - stream_free(gcc_CCrsp); - stream_free(server_data); + Stream_Free(gcc_CCrsp, TRUE); + Stream_Free(server_data, TRUE); return (ret < 0) ? FALSE : TRUE; } diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 9d6eee2fb..1d7de7288 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -891,8 +891,7 @@ void credssp_read_ts_credentials(rdpCredssp* credssp, PSecBuffer ts_credentials) int length; int ts_password_creds_length; - s = stream_new(0); - stream_attach(s, ts_credentials->pvBuffer, ts_credentials->cbBuffer); + s = Stream_New(ts_credentials->pvBuffer, ts_credentials->cbBuffer); /* TSCredentials (SEQUENCE) */ ber_read_sequence_tag(s, &length); @@ -907,8 +906,7 @@ void credssp_read_ts_credentials(rdpCredssp* credssp, PSecBuffer ts_credentials) credssp_read_ts_password_creds(credssp, s); - stream_detach(s); - stream_free(s); + Stream_Free(s, FALSE); } void credssp_write_ts_credentials(rdpCredssp* credssp, wStream* s) @@ -945,14 +943,13 @@ void credssp_encode_ts_credentials(rdpCredssp* credssp) wStream* s; int length; - s = stream_new(0); length = credssp_skip_ts_credentials(credssp); sspi_SecBufferAlloc(&credssp->ts_credentials, length); - stream_attach(s, credssp->ts_credentials.pvBuffer, length); + s = Stream_New(credssp->ts_credentials.pvBuffer, length); credssp_write_ts_credentials(credssp, s); - stream_detach(s); - stream_free(s); + + Stream_Free(s, FALSE); } SECURITY_STATUS credssp_encrypt_ts_credentials(rdpCredssp* credssp) @@ -1091,7 +1088,7 @@ void credssp_send(rdpCredssp* credssp) length = nego_tokens_length + pub_key_auth_length + auth_info_length; ts_request_length = credssp_skip_ts_request(length); - s = stream_new(ts_request_length); + s = Stream_New(NULL, ts_request_length); /* TSRequest */ length = der_get_content_length(ts_request_length); @@ -1129,7 +1126,7 @@ void credssp_send(rdpCredssp* credssp) } transport_write(credssp->transport, s); - stream_free(s); + Stream_Free(s, TRUE); } /** @@ -1145,7 +1142,7 @@ int credssp_recv(rdpCredssp* credssp) int status; UINT32 version; - s = stream_new(4096); + s = Stream_New(NULL, 4096); status = transport_read(credssp->transport, s); Stream_Length(s) = status; @@ -1153,7 +1150,7 @@ int credssp_recv(rdpCredssp* credssp) if (status < 0) { fprintf(stderr, "credssp_recv() error: %d\n", status); - stream_free(s); + Stream_Free(s, TRUE); return -1; } @@ -1199,7 +1196,7 @@ int credssp_recv(rdpCredssp* credssp) credssp->pubKeyAuth.cbBuffer = length; } - stream_free(s); + Stream_Free(s, TRUE); return 0; } diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index effb2833f..832f5b920 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -776,7 +776,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int return FALSE; \ }\ Stream_Read_UINT16(s, TARGET_LEN); \ - if (!stream_skip(s, TARGET_LEN)) { \ + if (!Stream_SafeSeek(s, TARGET_LEN)) { \ fprintf(stderr, "%s: error skipping %d bytes\n", __FUNCTION__, TARGET_LEN); \ return FALSE; \ } \ @@ -1389,7 +1389,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ memcpy(fast_glyph->data, s->pointer, fast_glyph->cbData); phold = s->pointer; - if (!stream_skip(s, 1)) + if (!Stream_SafeSeek(s, 1)) return FALSE; if (fast_glyph->cbData > 1) @@ -1789,7 +1789,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or if (flags & CG_GLYPH_UNICODE_PRESENT) { - return stream_skip(s, cache_glyph_order->cGlyphs * 2); + return Stream_SafeSeek(s, cache_glyph_order->cGlyphs * 2); } return TRUE; @@ -1871,7 +1871,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl if (flags & CG_GLYPH_UNICODE_PRESENT) { - return stream_skip(s, cache_glyph_v2->cGlyphs * 2); + return Stream_SafeSeek(s, cache_glyph_v2->cGlyphs * 2); } return TRUE; @@ -2144,7 +2144,7 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ - return stream_skip(s, draw_gdiplus_first->cbSize); /* emfRecords */ + return Stream_SafeSeek(s, draw_gdiplus_first->cbSize); /* emfRecords */ } BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next) @@ -2165,7 +2165,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */ - return stream_skip(s, draw_gdiplus_end->cbSize); /* emfRecords */ + return Stream_SafeSeek(s, draw_gdiplus_end->cbSize); /* emfRecords */ } BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first) @@ -2178,7 +2178,7 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F Stream_Read_UINT16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */ - return stream_skip(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */ + return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */ } BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next) @@ -2203,7 +2203,7 @@ BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END Stream_Read_UINT16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */ - return stream_skip(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */ + return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */ } BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes) diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index fc1240d78..433731df4 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -204,7 +204,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) } } - if (!stream_skip(s, 8)) /* pad (8 bytes) */ + if (!Stream_SafeSeek(s, 8)) /* pad (8 bytes) */ return FALSE; if (redirection->flags & LB_NOREDIRECT) @@ -220,9 +220,9 @@ BOOL rdp_recv_redirection_packet(rdpRdp* rdp, wStream* s) BOOL rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, wStream* s) { - return stream_skip(s, 2) && /* pad2Octets (2 bytes) */ + return Stream_SafeSeek(s, 2) && /* pad2Octets (2 bytes) */ rdp_recv_server_redirection_pdu(rdp, s) && - stream_skip(s, 1); /* pad2Octets (1 byte) */ + Stream_SafeSeek(s, 1); /* pad2Octets (1 byte) */ } rdpRedirection* redirection_new() diff --git a/libfreerdp/core/tpdu.c b/libfreerdp/core/tpdu.c index c7ac70a63..a701c11d7 100644 --- a/libfreerdp/core/tpdu.c +++ b/libfreerdp/core/tpdu.c @@ -84,7 +84,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li) /* DST-REF (2 bytes) */ /* SRC-REF (2 bytes) */ /* Class 0 (1 byte) */ - return stream_skip(s, 5); + return Stream_SafeSeek(s, 5); } return TRUE; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index b064ec10a..ed812474f 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -852,7 +852,7 @@ rdpTransport* transport_new(rdpSettings* settings) /* buffers for blocking read/write */ transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0); - transport->SendStream = stream_new(BUFFER_SIZE); + transport->SendStream = Stream_New(NULL, BUFFER_SIZE); transport->blocking = TRUE; @@ -874,7 +874,7 @@ void transport_free(rdpTransport* transport) StreamPool_Free(transport->ReceivePool); - stream_free(transport->SendStream); + Stream_Free(transport->SendStream, TRUE); CloseHandle(transport->ReceiveEvent); CloseHandle(transport->connectedEvent); diff --git a/libfreerdp/crypto/ber.c b/libfreerdp/crypto/ber.c index 2f7b67965..3809f6dfc 100644 --- a/libfreerdp/crypto/ber.c +++ b/libfreerdp/crypto/ber.c @@ -375,7 +375,7 @@ BOOL ber_read_integer(wStream* s, UINT32* value) if (value == NULL) { // even if we don't care the integer value, check the announced size - return stream_skip(s, length); + return Stream_SafeSeek(s, length); } if (length == 1) diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index bd4bf9f03..ba961b8d7 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -116,9 +116,9 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3 if (dataFlags & CHANNEL_FLAG_FIRST) { if (plugin->data_in != NULL) - stream_free(plugin->data_in); + Stream_Free(plugin->data_in, TRUE); - plugin->data_in = stream_new(totalLength); + plugin->data_in = Stream_New(NULL, totalLength); } data_in = plugin->data_in; @@ -167,7 +167,7 @@ static void svc_plugin_open_event(UINT32 openHandle, UINT32 event, void* pData, break; case CHANNEL_EVENT_WRITE_COMPLETE: - stream_free((wStream*) pData); + Stream_Free((wStream*) pData, TRUE); break; case CHANNEL_EVENT_USER: @@ -247,7 +247,7 @@ static void svc_plugin_process_terminated(rdpSvcPlugin* plugin) if (plugin->data_in) { - stream_free(plugin->data_in); + Stream_Free(plugin->data_in, TRUE); plugin->data_in = NULL; } @@ -315,7 +315,7 @@ int svc_plugin_send(rdpSvcPlugin* plugin, wStream* data_out) if (status != CHANNEL_RC_OK) { - stream_free(data_out); + Stream_Free(data_out, TRUE); fprintf(stderr, "svc_plugin_send: VirtualChannelWrite failed %d\n", status); } diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index f56f6a5d7..019efb0eb 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -184,7 +184,7 @@ void mf_peer_context_new(freerdp_peer* client, mfPeerContext* context) //context->nsc_context = nsc_context_new(); //nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8); - context->s = stream_new(0xFFFF); + context->s = Stream_New(NULL, 0xFFFF); //#ifdef WITH_SERVER_CHANNELS context->vcm = WTSCreateVirtualChannelManager(client); @@ -203,7 +203,7 @@ void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context) dispatch_suspend(info_timer); - stream_free(context->s); + Stream_Free(context->s, TRUE); rfx_context_free(context->rfx_context); //nsc_context_free(context->nsc_context); diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 4062abf05..aaf65a802 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -55,7 +55,7 @@ void test_peer_context_new(freerdp_peer* client, testPeerContext* context) context->nsc_context = nsc_context_new(); nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_R8G8B8); - context->s = stream_new(65536); + context->s = Stream_New(NULL, 65536); context->icon_x = -1; context->icon_y = -1; @@ -74,7 +74,7 @@ void test_peer_context_free(freerdp_peer* client, testPeerContext* context) CloseHandle(context->debug_channel_thread); } - stream_free(context->s); + Stream_Free(context->s, TRUE); free(context->icon_data); free(context->bg_data); @@ -362,7 +362,7 @@ void tf_peer_dump_rfx(freerdp_peer* client) rdpPcap* pcap_rfx; pcap_record record; - s = stream_new(512); + s = Stream_New(NULL, 512); update = client->update; client->update->pcap_rfx = pcap_open(test_pcap_file, FALSE); pcap_rfx = client->update->pcap_rfx; @@ -406,7 +406,7 @@ static void* tf_debug_channel_thread_func(void* arg) context->event = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd); } - s = stream_new(4096); + s = Stream_New(NULL, 4096); WTSVirtualChannelWrite(context->debug_channel, (BYTE*) "test1", 5, NULL); @@ -440,7 +440,7 @@ static void* tf_debug_channel_thread_func(void* arg) printf("got %d bytes\n", bytes_returned); } - stream_free(s); + Stream_Free(s, TRUE); return 0; } diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 091b4e7eb..c8e8dc796 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -203,7 +203,7 @@ void wf_update_encoder_reset(wfInfo* wfi) wfi->rfx_context->width = wfi->servscreen_width; wfi->rfx_context->height = wfi->servscreen_height; rfx_context_set_pixel_format(wfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); - wfi->s = stream_new(0xFFFF); + wfi->s = Stream_New(NULL, 0xFFFF); } wf_info_invalidate_full_screen(wfi); diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index 041fe0d71..b7e2fe874 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -187,40 +187,34 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); _src->pointer += _n; \ } while (0) -#define Stream_Pointer(_s) _s->pointer -#define Stream_Buffer(_s) _s->buffer -#define Stream_Length(_s) _s->length -#define Stream_Capacity(_s) _s->capacity +#define Stream_Buffer(_s) _s->buffer +#define Stream_GetBuffer(_s, _b) _b = _s->buffer +#define Stream_SetBuffer(_s, _b) _s->buffer = _b + +#define Stream_Pointer(_s) _s->pointer +#define Stream_GetPointer(_s, _p) _p = _s->pointer +#define Stream_SetPointer(_s, _p) _s->pointer = _p + +#define Stream_Length(_s) _s->length +#define Stream_GetLength(_s, _l) _l = _s->length +#define Stream_SetLength(_s, _l) _s->length = _l + +#define Stream_Capacity(_s) _s->capacity +#define Stream_GetCapacity(_s, _c) _c = _s->capacity +#define Stream_SetCapacity(_s, _c) _s->capacity = _c #define Stream_GetPosition(_s) (_s->pointer - _s->buffer) #define Stream_SetPosition(_s, _p) _s->pointer = _s->buffer + (_p) -#define Stream_GetPointer(_s, _p) _p = _s->pointer -#define Stream_SetPointer(_s, _p) _s->pointer = _p - #define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer) #define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer)) #define Stream_Clear(_s) memset(_s->buffer, 0, _s->capacity) -/* Deprecated STREAM API */ - -WINPR_API wStream* stream_new(int size); -WINPR_API void stream_free(wStream* stream); - -#define stream_attach(_s, _buf, _size) do { \ - _s->capacity = _size; \ - _s->length = _size; \ - _s->buffer = _buf; \ - _s->pointer = _buf; } while (0) -#define stream_detach(_s) memset(_s, 0, sizeof(wStream)) - -WINPR_API void stream_extend(wStream* stream, int request_size); - -static INLINE BOOL stream_skip(wStream* s, size_t sz) { - if (Stream_GetRemainingLength(s) < sz) +static INLINE BOOL Stream_SafeSeek(wStream* s, size_t size) { + if (Stream_GetRemainingLength(s) < size) return FALSE; - Stream_Seek(s, sz); + Stream_Seek(s, size); return TRUE; } diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index dc42af9c8..1ebb41688 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -86,65 +86,3 @@ void Stream_Free(wStream* s, BOOL bFreeBuffer) free(s); } } - -/* Deprecated STREAM API */ - -/** - * Allocates and initializes a STREAM structure. - * STREAM are used to ease data access in read and write operations. - * They consist of a buffer containing the data we want to access, and an offset associated to it, and keeping - * track of the 'current' position in the stream. A list of functions can then be used to read/write different - * type of data to/from it. - * @see stream.h for the list of data access functions. - * - * @param size [in] - size of the buffer that will ba allocated to the stream. - * If 0, there will be no buffer attached to the stream. The caller - * then needs to call stream_attach() to link an existing buffer to this stream. - * Caution: calling stream_attach() on a stream with an existing buffer will result - * in this buffer being lost, and possible memory leak. - * - * @return A pointer to an allocated and initialized STREAM structure. - * This pointer need to be deallocated using the stream_free() function. - */ -wStream* stream_new(int size) -{ - wStream* stream; - - stream = malloc(sizeof(wStream)); - ZeroMemory(stream, sizeof(wStream)); - - if (stream != NULL) - { - if (size != 0) - { - size = size > 0 ? size : 0x400; - stream->buffer = (BYTE*) malloc(size); - ZeroMemory(stream->buffer, size); - stream->pointer = stream->buffer; - stream->capacity = size; - stream->length = size; - } - } - - return stream; -} - -/** - * This function is used to deallocate a stream that was allocated using stream_new(). - * Caution: the buffer linked to the stream will be deallocated in the process. If this buffer was attached - * using the stream_attach() function, the stream_detach() function needs to be called before calling stream_free() - * otherwise it will be freed in the process. - * - * @param stream [in] - Pointer to the STREAM structure that needs to be deallocated. - * This pointer is invalid on return. - */ -void stream_free(wStream* stream) -{ - if (stream != NULL) - { - if (stream->buffer != NULL) - free(stream->buffer); - - free(stream); - } -} From d11752aa4b725da123d5800c33191a560f092785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 18:29:41 -0400 Subject: [PATCH 086/144] libwinpr-utils: started endianness utility macros --- winpr/include/winpr/endian.h | 133 +++++++++++++++++++++++++++++++++++ winpr/include/winpr/stream.h | 1 + 2 files changed, 134 insertions(+) create mode 100644 winpr/include/winpr/endian.h diff --git a/winpr/include/winpr/endian.h b/winpr/include/winpr/endian.h new file mode 100644 index 000000000..2c03826b8 --- /dev/null +++ b/winpr/include/winpr/endian.h @@ -0,0 +1,133 @@ +/* + * WinPR: Windows Portable Runtime + * Endianness Macros + * + * 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_ENDIAN_H +#define WINPR_ENDIAN_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/platform.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define Data_Read_UINT8_NE(_d, _v) do { _v = \ + *_d; } while (0) + +#define Data_Read_UINT8(_d, _v) do { _v = \ + *_d; } while (0) + +#define Data_Read_UINT16_NE(_d, _v) do { _v = \ + *((UINT16*) _d); } while (0) + +#define Data_Read_UINT16(_d, _v) do { _v = \ + (UINT16)(*_d) + \ + (((UINT16)(*(_d))) << 8); \ + } while (0) + +#define Data_Read_UINT16_BE(_d, _v) do { _v = \ + (((UINT16)(*_d)) << 8) + \ + (UINT16)(*(_d + 1)); \ + } while (0) + +#define Data_Read_UINT32_NE(_d, _v) do { _v = \ + *((UINT32*) _d); } while (0) + +#define Data_Read_UINT32(_d, _v) do { _v = \ + (UINT32)(*_d) + \ + (((UINT32)(*(_d + 1))) << 8) + \ + (((UINT32)(*(_d + 2))) << 16) + \ + (((UINT32)(*(_d + 3))) << 24); \ + } while (0) + +#define Data_Read_UINT32_BE(_d, _v) do { _v = \ + (((UINT32)(*(_d))) << 24) + \ + (((UINT32)(*(_d + 1))) << 16) + \ + (((UINT32)(*(_d + 2))) << 8) + \ + (((UINT32)(*(_d + 3)))); \ + } while (0) + +#define Data_Read_UINT64_NE(_d, _v) do { _v = \ + *((UINT64*) _d); } while (0) + +#define Data_Read_UINT64(_d, _v) do { _v = \ + (UINT64)(*_d) + \ + (((UINT64)(*(_d + 1))) << 8) + \ + (((UINT64)(*(_d + 2))) << 16) + \ + (((UINT64)(*(_d + 3))) << 24) + \ + (((UINT64)(*(_d + 4))) << 32) + \ + (((UINT64)(*(_d + 5))) << 40) + \ + (((UINT64)(*(_d + 6))) << 48) + \ + (((UINT64)(*(_d + 7))) << 56); \ + } while (0) + +#define Data_Write_UINT8_NE(_d, _v) do { \ + *((UINT8*) _d) = v; } while (0) + +#define Data_Write_UINT8(_d, _v) do { \ + *_d = (UINT8)(_v); } while (0) + +#define Data_Write_UINT16_NE(_d, _v) do { \ + *((UINT16*) _d) = v; } while (0) + +#define Data_Write_UINT16(_d, _v) do { \ + *(_d) = (_v) & 0xFF; \ + *(_d + 1) = ((_v) >> 8) & 0xFF; \ + } while (0) + +#define Data_Write_UINT16_BE(_d, _v) do { \ + *(_d) = ((_v) >> 8) & 0xFF; \ + *(_d + 1) = (_v) & 0xFF; \ + } while (0) + +#define Data_Write_UINT32_NE(_d, _v) do { \ + *((UINT32*) _d) = v; } while (0) + +#define Data_Write_UINT32(_d, _v) do { \ + *(_d) = (_v) & 0xFF; \ + *(_d + 1) = ((_v) >> 8) & 0xFF; \ + *(_d + 2) = ((_v) >> 16) & 0xFF; \ + *(_d + 3) = ((_v) >> 24) & 0xFF; \ + } while (0) + +#define Data_Write_UINT32_BE(_d, _v) do { \ + Data_Write_UINT16_BE(_d, ((_v) >> 16 & 0xFFFF)); \ + Data_Write_UINT16_BE(_d + 2, ((_v) & 0xFFFF)); \ + } while (0) + +#define Data_Write_UINT64_NE(_d, _v) do { \ + *((UINT64*) _d) = v; } while (0) + +#define Data_Write_UINT64(_d, _v) do { \ + *(_d) = (UINT64)(_v) & 0xFF; \ + *(_d + 1) = ((UINT64)(_v) >> 8) & 0xFF; \ + *(_d + 2) = ((UINT64)(_v) >> 16) & 0xFF; \ + *(_d + 3) = ((UINT64)(_v) >> 24) & 0xFF; \ + *(_d + 4) = ((UINT64)(_v) >> 32) & 0xFF; \ + *(_d + 5) = ((UINT64)(_v) >> 40) & 0xFF; \ + *(_d + 6) = ((UINT64)(_v) >> 48) & 0xFF; \ + *(_d + 7) = ((UINT64)(_v) >> 56) & 0xFF; \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_ENDIAN_H */ diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h index b7e2fe874..0232841ad 100644 --- a/winpr/include/winpr/stream.h +++ b/winpr/include/winpr/stream.h @@ -23,6 +23,7 @@ #include <winpr/winpr.h> #include <winpr/wtypes.h> +#include <winpr/endian.h> #ifdef __cplusplus extern "C" { From 73e6b5efc9531bded19e2c63f912aaf509e56b57 Mon Sep 17 00:00:00 2001 From: Hardening <rdp.effort@gmail.com> Date: Mon, 6 May 2013 22:57:39 +0200 Subject: [PATCH 087/144] Misc fixes in HTTP parsing * HTTP headers are case insensitive (see RFC2616 4.2 for details) * Check errors when parsing status line * treat LWS around the colon in headers --- libfreerdp/core/gateway/http.c | 79 ++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index 9c2ee81fb..335df36e4 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -24,6 +24,7 @@ #include <winpr/crt.h> #include <winpr/print.h> #include <winpr/stream.h> +#include <winpr/string.h> #include "http.h" @@ -280,31 +281,36 @@ void http_request_free(HttpRequest* http_request) } } -void http_response_parse_header_status_line(HttpResponse* http_response, char* status_line) +BOOL http_response_parse_header_status_line(HttpResponse* http_response, char* status_line) { char* separator; char* status_code; char* reason_phrase; separator = strchr(status_line, ' '); + if (!separator) + return FALSE; status_code = separator + 1; separator = strchr(status_code, ' '); + if (!separator) + return FALSE; reason_phrase = separator + 1; *separator = '\0'; http_response->StatusCode = atoi(status_code); http_response->ReasonPhrase = _strdup(reason_phrase); *separator = ' '; + return TRUE; } void http_response_parse_header_field(HttpResponse* http_response, char* name, char* value) { - if (strcmp(name, "Content-Length") == 0) + if (_stricmp(name, "Content-Length") == 0) { http_response->ContentLength = atoi(value); } - else if (strcmp(name, "Authorization") == 0) + else if (_stricmp(name, "Authorization") == 0) { char* separator; @@ -320,7 +326,7 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c *separator = ' '; } } - else if (strcmp(name, "WWW-Authenticate") == 0) + else if (_stricmp(name, "WWW-Authenticate") == 0) { char* separator; @@ -348,36 +354,63 @@ void http_response_parse_header_field(HttpResponse* http_response, char* name, c } } -void http_response_parse_header(HttpResponse* http_response) +BOOL http_response_parse_header(HttpResponse* http_response) { int count; char* line; char* name; char* value; - char* separator; + char* colon_pos; + char* end_of_header; + char end_of_header_char; + char c; - http_response_parse_header_status_line(http_response, http_response->lines[0]); + if (!http_response_parse_header_status_line(http_response, http_response->lines[0])) + return FALSE; for (count = 1; count < http_response->count; count++) { line = http_response->lines[count]; - separator = strstr(line, ": "); + /** + * name end_of_header + * | | + * v v + * <header name> : <header value> + * ^ ^ + * | | + * colon_pos value + */ + colon_pos = strchr(line, ':'); + if ((colon_pos == NULL) || (colon_pos == line)) + return FALSE; - if (separator == NULL) - continue; - - separator[0] = '\0'; - separator[1] = '\0'; + /* retrieve the position just after header name */ + for(end_of_header = colon_pos; end_of_header != line; end_of_header--) + { + c = end_of_header[-1]; + if (c != ' ' && c != '\t' && c != ':') + break; + } + if (end_of_header == line) + return FALSE; + end_of_header_char = *end_of_header; + *end_of_header = '\0'; name = line; - value = separator + 2; + + /* eat space and tabs before header value */ + for (value = colon_pos + 1; *value; value++) + { + if ((*value != ' ') && (*value != '\t')) + break; + } http_response_parse_header_field(http_response, name, value); - separator[0] = ':'; - separator[1] = ' '; + *end_of_header = end_of_header_char; } + return TRUE; } void http_response_print(HttpResponse* http_response) @@ -435,11 +468,7 @@ HttpResponse* http_response_recv(rdpTls* tls) header_end = strstr((char*) buffer, "\r\n\r\n"); - if (header_end) - { - header_end += 2; - } - else + if (!header_end) { fprintf(stderr, "http_response_recv: invalid response:\n"); winpr_HexDump(buffer, status); @@ -447,6 +476,8 @@ HttpResponse* http_response_recv(rdpTls* tls) return NULL; } + header_end += 2; + if (header_end != NULL) { int count; @@ -478,7 +509,11 @@ HttpResponse* http_response_recv(rdpTls* tls) count++; } - http_response_parse_header(http_response); + if (!http_response_parse_header(http_response)) + { + http_response_free(http_response); + return NULL; + } if (http_response->ContentLength > 0) { From 1b28ef597664d093f6ce47a327dfe075046436c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 19:44:51 -0400 Subject: [PATCH 088/144] winpr: fix endian.h --- winpr/include/winpr/endian.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winpr/include/winpr/endian.h b/winpr/include/winpr/endian.h index 2c03826b8..9d9834076 100644 --- a/winpr/include/winpr/endian.h +++ b/winpr/include/winpr/endian.h @@ -85,7 +85,7 @@ extern "C" { *_d = (UINT8)(_v); } while (0) #define Data_Write_UINT16_NE(_d, _v) do { \ - *((UINT16*) _d) = v; } while (0) + *((UINT16*) _d) = _v; } while (0) #define Data_Write_UINT16(_d, _v) do { \ *(_d) = (_v) & 0xFF; \ @@ -98,7 +98,7 @@ extern "C" { } while (0) #define Data_Write_UINT32_NE(_d, _v) do { \ - *((UINT32*) _d) = v; } while (0) + *((UINT32*) _d) = _v; } while (0) #define Data_Write_UINT32(_d, _v) do { \ *(_d) = (_v) & 0xFF; \ @@ -113,7 +113,7 @@ extern "C" { } while (0) #define Data_Write_UINT64_NE(_d, _v) do { \ - *((UINT64*) _d) = v; } while (0) + *((UINT64*) _d) = _v; } while (0) #define Data_Write_UINT64(_d, _v) do { \ *(_d) = (UINT64)(_v) & 0xFF; \ From 91a55ae7411ddc666b3bd2cba123edacc8eb4c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 21:51:16 -0400 Subject: [PATCH 089/144] xfreerdp: integrate corey's multitouch code --- client/X11/CMakeLists.txt | 13 ++ client/X11/xf_event.c | 43 +++++- client/X11/xf_input.c | 308 ++++++++++++++++++++++++++++++++++++++ client/X11/xf_input.h | 41 +++++ client/X11/xf_interface.c | 86 ++++++++++- client/X11/xf_interface.h | 1 + client/X11/xf_window.c | 68 +-------- client/X11/xfreerdp.h | 9 ++ 8 files changed, 497 insertions(+), 72 deletions(-) create mode 100644 client/X11/xf_input.c create mode 100644 client/X11/xf_input.h diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 96f4ec419..7ccad8f37 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -30,6 +30,8 @@ set(${MODULE_PREFIX}_SRCS xf_tsmf.h xf_event.c xf_event.h + xf_input.c + xf_input.h xf_cliprdr.c xf_cliprdr.h xf_monitor.c @@ -99,12 +101,17 @@ set(XI_FEATURE_TYPE "RECOMMENDED") set(XI_FEATURE_PURPOSE "input") set(XI_FEATURE_DESCRIPTION "X11 input extension") +set(XRENDER_FEATURE_TYPE "RECOMMENDED") +set(XRENDER_FEATURE_PURPOSE "rendering") +set(XRENDER_FEATURE_DESCRIPTION "X11 render extension") + find_feature(XShm ${XSHM_FEATURE_TYPE} ${XSHM_FEATURE_PURPOSE} ${XSHM_FEATURE_DESCRIPTION}) find_feature(Xinerama ${XINERAMA_FEATURE_TYPE} ${XINERAMA_FEATURE_PURPOSE} ${XINERAMA_FEATURE_DESCRIPTION}) find_feature(Xext ${XEXT_FEATURE_TYPE} ${XEXT_FEATURE_PURPOSE} ${XEXT_FEATURE_DESCRIPTION}) find_feature(Xcursor ${XCURSOR_FEATURE_TYPE} ${XCURSOR_FEATURE_PURPOSE} ${XCURSOR_FEATURE_DESCRIPTION}) find_feature(Xv ${XV_FEATURE_TYPE} ${XV_FEATURE_PURPOSE} ${XV_FEATURE_DESCRIPTION}) find_feature(Xi ${XI_FEATURE_TYPE} ${XI_FEATURE_PURPOSE} ${XI_FEATURE_DESCRIPTION}) +find_feature(Xrender ${XRENDER_FEATURE_TYPE} ${XRENDER_FEATURE_PURPOSE} ${XRENDER_FEATURE_DESCRIPTION}) if(WITH_XINERAMA) add_definitions(-DWITH_XINERAMA) @@ -136,6 +143,12 @@ if(WITH_XI) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XI_LIBRARIES}) endif() +if(WITH_XRENDER) + add_definitions(-DWITH_XRENDER) + include_directories(${XRENDER_INCLUDE_DIRS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XRENDER_LIBRARIES}) +endif() + include_directories(${CMAKE_SOURCE_DIR}/resources) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index f8ebbf110..d6226ca67 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -29,6 +29,7 @@ #include "xf_rail.h" #include "xf_window.h" #include "xf_cliprdr.h" +#include "xf_input.h" #include "xf_event.h" @@ -95,7 +96,15 @@ static BOOL xf_event_Expose(xfInfo* xfi, XEvent* event, BOOL app) if (!app) { - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + if (xfi->scale != 1.0) + { + xf_draw_screen_scaled(xfi); + } + else + { + XCopyArea(xfi->display, xfi->primary, + xfi->window->handle, xfi->gc, x, y, w, h, x, y); + } } else { @@ -151,6 +160,13 @@ static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) x, y, &x, &y, &childWindow); } + if (xfi->scale != 1.0) + { + /* Take scaling in to consideration */ + x = (int) (x * (1.0 / xfi->scale)); + y = (int) (y * (1.0 / xfi->scale)); + } + input->MouseEvent(input, PTR_FLAGS_MOVE, x, y); if (xfi->fullscreen) @@ -254,6 +270,13 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) x, y, &x, &y, &childWindow); } + if (xfi->scale != 1.0) + { + /* Take scaling in to consideration */ + x = (int) (x * (1.0 / xfi->scale)); + y = (int) (y * (1.0 / xfi->scale)); + } + if (extended) input->ExtendedMouseEvent(input, flags, x, y); else @@ -337,6 +360,13 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) x, y, &x, &y, &childWindow); } + if (xfi->scale != 1.0) + { + /* Take scaling in to consideration */ + x = (int) (x * (1.0 / xfi->scale)); + y = (int) (y * (1.0 / xfi->scale)); + } + if (extended) input->ExtendedMouseEvent(input, flags, x, y); else @@ -523,6 +553,15 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app) rdpWindow* window; rdpRail* rail = ((rdpContext*) xfi->context)->rail; + if (xfi->width != event->xconfigure.width) + { + xfi->scale = (double) event->xconfigure.width / (double) xfi->originalWidth; + xfi->currentWidth = event->xconfigure.width; + xfi->currentHeight = event->xconfigure.width; + + xf_draw_screen_scaled(xfi); + } + window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window); if (window != NULL) @@ -977,6 +1016,8 @@ BOOL xf_event_process(freerdp* instance, XEvent* event) break; } + xf_input_handle_event(xfi, event); + XSync(xfi->display, FALSE); return status; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c new file mode 100644 index 000000000..c90cb38f4 --- /dev/null +++ b/client/X11/xf_input.c @@ -0,0 +1,308 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Input + * + * Copyright 2013 Corey Clayton <can.of.tuna@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 + +#ifdef WITH_XI +#include <X11/extensions/XInput2.h> +#endif + +#include <math.h> + +#include "xf_input.h" + +#ifdef WITH_XI + +#define MAX_CONTACTS 2 + +typedef struct touch_contact +{ + int id; + int count; + double pos_x; + double pos_y; + double last_x; + double last_y; + +} touchContact; + +touchContact contacts[MAX_CONTACTS]; + +int active_contacts; +XIDeviceEvent lastEvent; +double firstDist = -1.0; +double lastDist; +double z_vector; +int xinput_opcode; +int scale_cnt; + +int xf_input_init(xfInfo* xfi, Window window) +{ + int i, j; + int ndevices; + int major = 2; + int minor = 2; + Status xstatus; + XIEventMask evmask; + XIDeviceInfo* info; + int opcode, event, error; + unsigned char mask[XIMaskLen(XI_LASTEVENT)]; + + active_contacts = 0; + ZeroMemory(contacts, sizeof(touchContact) * MAX_CONTACTS); + + if (!XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error)) + { + printf("XInput extension not available.\n"); + return -1; + } + + xfi->XInputOpcode = opcode; + + XIQueryVersion(xfi->display, &major, &minor); + + if (major * 1000 + minor < 2002) + { + printf("Server does not support XI 2.2\n"); + return -1; + } + + info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices); + + for (i = 0; i < ndevices; i++) + { + XIDeviceInfo* dev = &info[i]; + + for (j = 0; j < dev->num_classes; j++) + { + XIAnyClassInfo* class = dev->classes[j]; + //XITouchClassInfo* t = (XITouchClassInfo*) class; + + if (class->type != XITouchClass) + continue; + + //printf("%s %s touch device, supporting %d touches.\n", + // dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); + } + } + + evmask.mask = mask; + evmask.mask_len = sizeof(mask); + ZeroMemory(mask, sizeof(mask)); + evmask.deviceid = XIAllDevices; + + XISetMask(mask, XI_TouchBegin); + XISetMask(mask, XI_TouchUpdate); + XISetMask(mask, XI_TouchEnd); + + xstatus = XISelectEvents(xfi->display, window, &evmask, 1); + + return -1; +} + +BOOL xf_input_is_duplicate(XIDeviceEvent* event) +{ + if ( (lastEvent.time == event->time) && + (lastEvent.detail == event->detail) && + (lastEvent.event_x == event->event_x) && + (lastEvent.event_y == event->event_y) ) + { + return TRUE; + } + + return FALSE; +} + +void xf_input_save_last_event(XIDeviceEvent* event) +{ + lastEvent.time = event->time; + lastEvent.detail = event->detail; + lastEvent.event_x = event->event_x; + lastEvent.event_y = event->event_y; +} + +void xf_input_detect_pinch(xfInfo* xfi) +{ + double dist; + double zoom; + double delta; + + if (active_contacts != 2) + { + firstDist = -1.0; + return; + } + + /* first calculate the distance */ + dist = sqrt(pow(contacts[1].pos_x - contacts[0].last_x, 2.0) + + pow(contacts[1].pos_y - contacts[0].last_y, 2.0)); + + /* if this is the first 2pt touch */ + if (firstDist <= 0) + { + firstDist = dist; + lastDist = firstDist; + scale_cnt = 0; + z_vector = 0; + } + else + { + delta = lastDist - dist; + + /* compare the current distance to the first one */ + zoom = (dist / firstDist); + + z_vector += delta; + //printf("d: %.2f\n", delta); + + lastDist = dist; + + if (z_vector > 10) + { + xfi->scale -= 0.05; + + if (xfi->scale < 0.5) + xfi->scale = 0.5; + + XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + + z_vector = 0; + } + + if (z_vector < -10) + { + xfi->scale += 0.05; + + if (xfi->scale > 1.5) + xfi->scale = 1.5; + + XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + + z_vector = 0; + } + } +} + +#endif + +int xf_input_handle_event(xfInfo* xfi, XEvent* event) +{ +#ifdef WITH_XI + XGenericEventCookie* cookie = &event->xcookie; + + XGetEventData(xfi->display, cookie); + + if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) + { + switch(cookie->evtype) + { + case XI_TouchBegin: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_begin(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + case XI_TouchUpdate: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_update(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + case XI_TouchEnd: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_end(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + default: + printf("unhandled xi type= %d\n", cookie->evtype); + break; + } + } + + XFreeEventData(xfi->display,cookie); +#endif + return 0; +} + +#ifdef WITH_XI +void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event) +{ + int i; + + for (i = 0; i < MAX_CONTACTS; i++) + { + if (contacts[i].id == 0) + { + contacts[i].id = event->detail; + contacts[i].count = 1; + contacts[i].pos_x = event->event_x; + contacts[i].pos_y = event->event_y; + + active_contacts++; + break; + } + } +} + +void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event) +{ + int i; + + for (i = 0; i < MAX_CONTACTS; i++) + { + if (contacts[i].id == event->detail) + { + contacts[i].count++; + contacts[i].last_x = contacts[i].pos_x; + contacts[i].last_y = contacts[i].pos_y; + contacts[i].pos_x = event->event_x; + contacts[i].pos_y = event->event_y; + + xf_input_detect_pinch(xfi); + + break; + } + } +} + +void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) +{ + int i; + + for (i = 0; i < MAX_CONTACTS; i++) + { + if (contacts[i].id == event->detail) + { + contacts[i].id = 0; + contacts[i].count = 0; + //contacts[i].pos_x = (int)event->event_x; + //contacts[i].pos_y = (int)event->event_y; + + active_contacts--; + break; + } + } +} + +#endif diff --git a/client/X11/xf_input.h b/client/X11/xf_input.h new file mode 100644 index 000000000..6c540fef5 --- /dev/null +++ b/client/X11/xf_input.h @@ -0,0 +1,41 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Input + * + * Copyright 2013 Corey Clayton <can.of.tuna@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 __XF_INPUT_H +#define __XF_INPUT_H + +#include "xf_interface.h" +#include "xfreerdp.h" + +#ifdef WITH_XI +#include <X11/extensions/XInput2.h> +#endif + +int xf_input_init(xfInfo* xfi, Window win); +int xf_input_handle_event(xfInfo* xfi, XEvent* event); + +#ifdef WITH_XI + +void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event); +void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event); +void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event); + +#endif + +#endif diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 1ffa502ba..c1d5f87e7 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -32,6 +32,14 @@ #include <X11/extensions/Xinerama.h> #endif +#ifdef WITH_XI +#include <X11/extensions/XInput2.h> +#endif + +#ifdef WITH_XRENDER +#include <X11/extensions/Xrender.h> +#endif + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -79,6 +87,35 @@ static long xv_port = 0; static const size_t password_size = 512; +void xf_draw_screen_scaled(xfInfo* xfi) +{ + XTransform transform; + Picture windowPicture; + Picture primaryPicture; + XRenderPictureAttributes pa; + XRenderPictFormat* picFormat; + + picFormat = XRenderFindStandardFormat(xfi->display, PictStandardRGB24); + pa.subwindow_mode = IncludeInferiors; + primaryPicture = XRenderCreatePicture(xfi->display, xfi->primary, picFormat, CPSubwindowMode, &pa); + windowPicture = XRenderCreatePicture(xfi->display, xfi->window->handle, picFormat, CPSubwindowMode, &pa); + + transform.matrix[0][0] = XDoubleToFixed(1); + transform.matrix[0][1] = XDoubleToFixed(0); + transform.matrix[0][2] = XDoubleToFixed(0); + + transform.matrix[1][0] = XDoubleToFixed(0); + transform.matrix[1][1] = XDoubleToFixed(1); + transform.matrix[1][2] = XDoubleToFixed(0); + + transform.matrix[2][0] = XDoubleToFixed(0); + transform.matrix[2][1] = XDoubleToFixed(0); + transform.matrix[2][2] = XDoubleToFixed(xfi->scale); + + XRenderSetPictureTransform(xfi->display, primaryPicture, &transform); + XRenderComposite(xfi->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, 0, 0, xfi->currentWidth, xfi->currentHeight); +} + void xf_context_new(freerdp* instance, rdpContext* context) { context->channels = freerdp_channels_new(); @@ -121,7 +158,15 @@ void xf_sw_end_paint(rdpContext* context) xf_lock_x11(xfi, FALSE); XPutImage(xfi->display, xfi->primary, xfi->gc, xfi->image, x, y, x, y, w, h); - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + + if (xfi->scale != 1.0) + { + xf_draw_screen_scaled(xfi); + } + else + { + XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + } xf_unlock_x11(xfi, FALSE); } @@ -147,7 +192,15 @@ void xf_sw_end_paint(rdpContext* context) h = cinvalid[i].h; XPutImage(xfi->display, xfi->primary, xfi->gc, xfi->image, x, y, x, y, w, h); - XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + + if (xfi->scale != 1.0) + { + xf_draw_screen_scaled(xfi); + } + else + { + XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc, x, y, w, h, x, y); + } } XFlush(xfi->display); @@ -231,7 +284,14 @@ void xf_hw_end_paint(rdpContext* context) xf_lock_x11(xfi, FALSE); - XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + if (xfi->scale != 1.0) + { + xf_draw_screen_scaled(xfi); + } + else + { + XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + } xf_unlock_x11(xfi, FALSE); } @@ -256,7 +316,14 @@ void xf_hw_end_paint(rdpContext* context) w = cinvalid[i].w; h = cinvalid[i].h; - XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + if (xfi->scale != 1.0) + { + xf_draw_screen_scaled(xfi); + } + else + { + XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w, h, x, y); + } } XFlush(xfi->display); @@ -768,6 +835,12 @@ BOOL xf_post_connect(freerdp* instance) } } + xfi->originalWidth = settings->DesktopWidth; + xfi->originalHeight = settings->DesktopHeight; + xfi->currentWidth = xfi->originalWidth; + xfi->currentHeight = xfi->originalWidth; + xfi->scale = 1.0; + xfi->width = settings->DesktopWidth; xfi->height = settings->DesktopHeight; @@ -1481,6 +1554,11 @@ rdpClient* freerdp_client_get_interface(cfInfo* cfi) return cfi->client; } +double freerdp_client_get_scale(xfInfo* xfi) +{ + return xfi->scale; +} + xfInfo* freerdp_client_new(int argc, char** argv) { int index; diff --git a/client/X11/xf_interface.h b/client/X11/xf_interface.h index c27e7948f..6707f4be7 100644 --- a/client/X11/xf_interface.h +++ b/client/X11/xf_interface.h @@ -55,6 +55,7 @@ FREERDP_API int freerdp_client_stop(cfInfo* cfi); FREERDP_API freerdp* freerdp_client_get_instance(cfInfo* cfi); FREERDP_API HANDLE freerdp_client_get_thread(cfInfo* cfi); FREERDP_API rdpClient* freerdp_client_get_interface(cfInfo* cfi); +FREERDP_API double freerdp_client_get_scale(xfInfo* xfi); FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv); FREERDP_API void freerdp_client_free(cfInfo* cfi); diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index bb9e1c95b..79427f5b0 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -44,6 +44,7 @@ #ifdef WITH_XI #include <X11/extensions/XInput2.h> +#include "xf_input.h" #endif #ifdef WITH_DEBUG_X11 @@ -325,73 +326,6 @@ static void xf_SetWindowPID(xfInfo* xfi, xfWindow* window, pid_t pid) 32, PropModeReplace, (unsigned char *)&pid, 1); } -int xf_input_init(xfInfo* xfi, Window window) -{ - int i, j; - int ndevices; - int major = 2; - int minor = 2; - Status xstatus; - XIEventMask evmask; - XIDeviceInfo* info; - int opcode, event, error; - XIGrabModifiers mods = { 1 }; - unsigned char mask[XIMaskLen(XI_LASTEVENT)]; - - if (!XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error)) - { - printf("XInput extension not available.\n"); - return -1; - } - - XIQueryVersion(xfi->display, &major, &minor); - - if (major * 1000 + minor < 2002) - { - printf("Server does not support XI 2.2\n"); - return -1; - } - - info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices); - - for (i = 0; i < ndevices; i++) - { - XIDeviceInfo* dev = &info[i]; - - for (j = 0; j < dev->num_classes; j++) - { - XIAnyClassInfo* class = dev->classes[j]; - XITouchClassInfo* t = (XITouchClassInfo*) class; - - if (class->type != XITouchClass) - continue; - - printf("%s %s touch device, supporting %d touches.\n", - dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); - } - } - - evmask.mask = mask; - evmask.mask_len = sizeof(mask); - ZeroMemory(mask, sizeof(mask)); - evmask.deviceid = XIAllDevices; - - XISetMask(mask, XI_TouchBegin); - XISetMask(mask, XI_TouchUpdate); - XISetMask(mask, XI_TouchEnd); - - xstatus = XISelectEvents(xfi->display, window, &evmask, 1); - //XIClearMask(mask, XI_TouchOwnership); - - mods.modifiers = XIAnyModifier; - - //XIGrabTouchBegin(xfi->display, XIAllMasterDevices, window, XINoOwnerEvents, &evmask, 1, &mods); - - XSync(xfi->display, False); - - return -1; -} - xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, BOOL decorations) { xfWindow* window; diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 9f79c07d3..392436c7f 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -114,6 +114,13 @@ struct xf_info UINT16 frame_x2; UINT16 frame_y2; + double scale; + int originalWidth; + int originalHeight; + int currentWidth; + int currentHeight; + int XInputOpcode; + BOOL focused; BOOL mouse_active; BOOL suppress_output; @@ -204,6 +211,8 @@ enum XF_EXIT_CODE void xf_lock_x11(xfInfo* xfi, BOOL display); void xf_unlock_x11(xfInfo* xfi, BOOL display); +void xf_draw_screen_scaled(xfInfo* xfi); + DWORD xf_exit_code_from_disconnect_reason(DWORD reason); #endif /* __XFREERDP_H */ From 99c821357d41dfc6b7d0f9e9d40d132ab6925ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 22:14:16 -0400 Subject: [PATCH 090/144] freerdp: add /multitouch option --- client/common/cmdline.c | 11 +++++++++++ include/freerdp/settings.h | 4 +++- libfreerdp/common/settings.c | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index b3b900153..92cc70f33 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -89,6 +89,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "smartcard", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect smartcard device" }, { "printer", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect printer device" }, { "usb", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect USB device" }, + { "multitouch", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect multitouch input" }, { "echo", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "echo", "Echo channel" }, { "fonts", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Smooth fonts (ClearType)" }, { "aero", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueFalse, -1, NULL, "Desktop composition" }, @@ -568,6 +569,16 @@ int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT free(p); } + CommandLineSwitchCase(arg, "multitouch") + { + char* p[1]; + int count = 1; + + settings->MultiTouchInput = TRUE; + + p[0] = "rdpei"; + freerdp_client_add_dynamic_channel(settings, count, p); + } CommandLineSwitchCase(arg, "echo") { char* p[1]; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 6c76735b2..035c9c7f1 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -675,6 +675,7 @@ typedef struct _RDPDR_PARALLEL RDPDR_PARALLEL; #define FreeRDP_ImeFileName 2628 #define FreeRDP_UnicodeInput 2629 #define FreeRDP_FastPathInput 2630 +#define FreeRDP_MultiTouchInput 2631 #define FreeRDP_BrushSupportLevel 2688 #define FreeRDP_GlyphSupportLevel 2752 #define FreeRDP_GlyphCache 2753 @@ -1097,7 +1098,8 @@ struct rdp_settings ALIGN64 char* ImeFileName; /* 2628 */ ALIGN64 BOOL UnicodeInput; /* 2629 */ ALIGN64 BOOL FastPathInput; /* 2630 */ - UINT64 padding2688[2688 - 2631]; /* 2631 */ + ALIGN64 BOOL MultiTouchInput; /* 2631 */ + UINT64 padding2688[2688 - 2632]; /* 2632 */ /* Brush Capabilities */ ALIGN64 UINT32 BrushSupportLevel; /* 2688 */ diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index 421d9af44..ca3a14e42 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -645,6 +645,10 @@ BOOL freerdp_get_param_bool(rdpSettings* settings, int id) return settings->FastPathInput; break; + case FreeRDP_MultiTouchInput: + return settings->MultiTouchInput; + break; + case FreeRDP_SoundBeepsEnabled: return settings->SoundBeepsEnabled; break; @@ -1081,6 +1085,10 @@ int freerdp_set_param_bool(rdpSettings* settings, int id, BOOL param) settings->FastPathInput = param; break; + case FreeRDP_MultiTouchInput: + settings->MultiTouchInput = param; + break; + case FreeRDP_SoundBeepsEnabled: settings->SoundBeepsEnabled = param; break; From e3a4d125cd5981752961a33b8a17b6295c569fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 8 May 2013 23:18:42 -0400 Subject: [PATCH 091/144] channels/rdpei: start implementing multitouch --- channels/rdpei/client/CMakeLists.txt | 6 +- channels/rdpei/client/rdpei_common.c | 590 +++++++++++++++++++++++++++ channels/rdpei/client/rdpei_common.h | 27 ++ channels/rdpei/client/rdpei_main.c | 75 +++- channels/rdpei/client/rdpei_main.h | 13 + 5 files changed, 708 insertions(+), 3 deletions(-) create mode 100644 channels/rdpei/client/rdpei_common.c create mode 100644 channels/rdpei/client/rdpei_common.h diff --git a/channels/rdpei/client/CMakeLists.txt b/channels/rdpei/client/CMakeLists.txt index 8ad191ccc..b3aacdcb2 100644 --- a/channels/rdpei/client/CMakeLists.txt +++ b/channels/rdpei/client/CMakeLists.txt @@ -1,7 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Implementation # FreeRDP cmake build script # -# Copyright 2012 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"); # you may not use this file except in compliance with the License. @@ -19,7 +19,9 @@ define_channel_client("rdpei") set(${MODULE_PREFIX}_SRCS rdpei_main.c - rdpei_main.h) + rdpei_main.h + rdpei_common.c + rdpei_common.h) include_directories(..) diff --git a/channels/rdpei/client/rdpei_common.c b/channels/rdpei/client/rdpei_common.c new file mode 100644 index 000000000..c81237c36 --- /dev/null +++ b/channels/rdpei/client/rdpei_common.c @@ -0,0 +1,590 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Input Virtual Channel Extension + * + * 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/stream.h> + +#include "rdpei_common.h" + +BOOL rdpei_read_2byte_unsigned(wStream* s, UINT32* value) +{ + BYTE byte; + + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + Stream_Read_UINT8(s, byte); + + if (byte & 0x80) + { + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + *value = (byte & 0x7F) << 8; + Stream_Read_UINT8(s, byte); + *value |= byte; + } + else + { + *value = (byte & 0x7F); + } + + return TRUE; +} + +BOOL rdpei_write_2byte_unsigned(wStream* s, UINT32 value) +{ + BYTE byte; + + if (value > 0x7FFF) + return FALSE; + + if (value >= 0x7F) + { + byte = ((value & 0x7F00) >> 8); + Stream_Write_UINT8(s, byte | 0x80); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else + { + byte = (value & 0x7F); + Stream_Write_UINT8(s, byte); + } + + return TRUE; +} + +BOOL rdpei_read_2byte_signed(wStream* s, INT32* value) +{ + BYTE byte; + BOOL negative; + + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + Stream_Read_UINT8(s, byte); + + negative = (byte & 0x40) ? TRUE : FALSE; + + *value = (byte & 0x3F); + + if (byte & 0x80) + { + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + Stream_Read_UINT8(s, byte); + *value = (*value << 8) | byte; + } + + if (negative) + *value *= -1; + + return TRUE; +} + +BOOL rdpei_write_2byte_signed(wStream* s, INT32 value) +{ + BYTE byte; + BOOL negative = FALSE; + + if (value < 0) + { + negative = TRUE; + value *= -1; + } + + if (value > 0x3FFF) + return FALSE; + + if (value >= 0x3F) + { + byte = ((value & 0x3F00) >> 8); + + if (negative) + byte |= 0x40; + + Stream_Write_UINT8(s, byte | 0x80); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else + { + byte = (value & 0x3F); + + if (negative) + byte |= 0x40; + + Stream_Write_UINT8(s, byte); + } + + return TRUE; +} + +BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value) +{ + BYTE byte; + BYTE count; + + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + Stream_Read_UINT8(s, byte); + + count = (byte & 0xC0) >> 6; + + if (Stream_GetRemainingLength(s) < count) + return FALSE; + + switch (count) + { + case 0: + *value = (byte & 0x3F); + break; + + case 1: + *value = (byte & 0x3F) << 8; + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 2: + *value = (byte & 0x3F) << 16; + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 3: + *value = (byte & 0x3F) << 24; + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + default: + break; + } + + return TRUE; +} + +BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value) +{ + BYTE byte; + + if (value <= 0x3F) + { + Stream_Write_UINT8(s, value); + } + else if (value <= 0x3FFF) + { + byte = (value >> 8) & 0x3F; + Stream_Write_UINT8(s, byte | 0x40); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x3FFFFF) + { + byte = (value >> 16) & 0x3F; + Stream_Write_UINT8(s, byte | 0x80); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x3FFFFF) + { + byte = (value >> 24) & 0x3F; + Stream_Write_UINT8(s, byte | 0xC0); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else + { + return FALSE; + } + + return TRUE; +} + +BOOL rdpei_read_4byte_signed(wStream* s, INT32* value) +{ + BYTE byte; + BYTE count; + BOOL negative; + + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + Stream_Read_UINT8(s, byte); + + count = (byte & 0xC0) >> 6; + negative = (byte & 0x20); + + if (Stream_GetRemainingLength(s) < count) + return FALSE; + + switch (count) + { + case 0: + *value = (byte & 0x1F); + break; + + case 1: + *value = (byte & 0x1F) << 8; + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 2: + *value = (byte & 0x1F) << 16; + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 3: + *value = (byte & 0x1F) << 24; + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + default: + break; + } + + if (negative) + *value *= -1; + + return TRUE; +} + +BOOL rdpei_write_4byte_signed(wStream* s, INT32 value) +{ + BYTE byte; + BOOL negative = FALSE; + + if (value < 0) + { + negative = TRUE; + value *= -1; + } + + if (value <= 0x1F) + { + byte = value & 0x1F; + + if (negative) + byte |= 0x20; + + Stream_Write_UINT8(s, value); + } + else if (value <= 0x1FFF) + { + byte = (value >> 8) & 0x1F; + + if (negative) + byte |= 0x20; + + Stream_Write_UINT8(s, byte | 0x40); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFF) + { + byte = (value >> 16) & 0x1F; + + if (negative) + byte |= 0x20; + + Stream_Write_UINT8(s, byte | 0x80); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFF) + { + byte = (value >> 24) & 0x1F; + + if (negative) + byte |= 0x20; + + Stream_Write_UINT8(s, byte | 0xC0); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else + { + return FALSE; + } + + return TRUE; +} + +BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) +{ + BYTE byte; + BYTE count; + + if (Stream_GetRemainingLength(s) < 1) + return FALSE; + + Stream_Read_UINT8(s, byte); + + count = (byte & 0xE0) >> 5; + + if (Stream_GetRemainingLength(s) < count) + return FALSE; + + switch (count) + { + case 0: + *value = (byte & 0x1F); + break; + + case 1: + *value = (byte & 0x1F) << 8; + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 2: + *value = (byte & 0x1F) << 16; + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 3: + *value = (byte & 0x1F) << 24; + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 4: + *value = (byte & 0x1F) << 32; + Stream_Read_UINT8(s, byte); + *value |= (byte << 24); + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 5: + *value = (byte & 0x1F) << 40; + Stream_Read_UINT8(s, byte); + *value |= (byte << 32); + Stream_Read_UINT8(s, byte); + *value |= (byte << 24); + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 6: + *value = (byte & 0x1F) << 48; + Stream_Read_UINT8(s, byte); + *value |= (byte << 40); + Stream_Read_UINT8(s, byte); + *value |= (byte << 32); + Stream_Read_UINT8(s, byte); + *value |= (byte << 24); + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + case 7: + *value = (byte & 0x1F) << 56; + Stream_Read_UINT8(s, byte); + *value |= (byte << 48); + Stream_Read_UINT8(s, byte); + *value |= (byte << 40); + Stream_Read_UINT8(s, byte); + *value |= (byte << 32); + Stream_Read_UINT8(s, byte); + *value |= (byte << 24); + Stream_Read_UINT8(s, byte); + *value |= (byte << 16); + Stream_Read_UINT8(s, byte); + *value |= (byte << 8); + Stream_Read_UINT8(s, byte); + *value |= byte; + break; + + default: + break; + } + + return TRUE; +} + +BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) +{ + BYTE byte; + BYTE count; + + if (value <= 0x1F) + { + count = 0; + byte = value & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + } + else if (value <= 0x1FFF) + { + count = 1; + byte = (value >> 8) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFF) + { + count = 2; + byte = (value >> 16) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFF) + { + count = 3; + byte = (value >> 24) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFFFF) + { + count = 4; + byte = (value >> 32) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 24) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFFFFFF) + { + count = 5; + byte = (value >> 40) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 32) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 24) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFFFFFFFF) + { + count = 6; + byte = (value >> 48) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 40) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 32) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 24) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else if (value <= 0x1FFFFFFFFFFFFF) + { + count = 7; + byte = (value >> 56) & 0x1F; + Stream_Write_UINT8(s, byte | (count << 5)); + byte = (value >> 48) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 40) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 32) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 24) & 0x1F; + Stream_Write_UINT8(s, byte); + byte = (value >> 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value >> 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (value & 0xFF); + Stream_Write_UINT8(s, byte); + } + else + { + return FALSE; + } + + return TRUE; +} diff --git a/channels/rdpei/client/rdpei_common.h b/channels/rdpei/client/rdpei_common.h new file mode 100644 index 000000000..0ed59b0a8 --- /dev/null +++ b/channels/rdpei/client/rdpei_common.h @@ -0,0 +1,27 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Input Virtual Channel Extension + * + * 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 FREERDP_CHANNEL_RDPEI_CLIENT_COMMON_H +#define FREERDP_CHANNEL_RDPEI_CLIENT_COMMON_H + +#include <winpr/crt.h> +#include <winpr/stream.h> + +#endif /* FREERDP_CHANNEL_RDPEI_CLIENT_COMMON_H */ + diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 2f866d7ab..130ccf50e 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -26,11 +26,12 @@ #include <string.h> #include <winpr/crt.h> +#include <winpr/stream.h> #include <winpr/cmdline.h> #include <freerdp/addin.h> -#include <winpr/stream.h> +#include "rdpei_common.h" #include "rdpei_main.h" @@ -61,11 +62,83 @@ struct _RDPEI_PLUGIN RDPEI_LISTENER_CALLBACK* listener_callback; }; +const char* RDPEI_EVENTID_STRINGS[] = +{ + "", + "EVENTID_SC_READY", + "EVENTID_CS_READY", + "EVENTID_TOUCH", + "EVENTID_SUSPEND_TOUCH", + "EVENTID_RESUME_TOUCH", + "EVENTID_DISMISS_HOVERING_CONTACT" +}; + +int rdpei_recv_sc_ready_pdu(wStream* s) +{ + UINT32 protocolVersion; + + Stream_Read_UINT32(s, protocolVersion); /* protocolVersion (4 bytes) */ + + if (protocolVersion != RDPINPUT_PROTOCOL_V1) + { + printf("Unknown [MS-RDPEI] protocolVersion: 0x%08X\n", protocolVersion); + return -1; + } + + return 0; +} + +int rdpei_recv_pdu(wStream* s) +{ + UINT16 eventId; + UINT32 pduLength; + + Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */ + Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */ + + printf("rdpei_recv_pdu: eventId: %d (%s) length: %d\n", + eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); + + switch (eventId) + { + case EVENTID_SC_READY: + rdpei_recv_sc_ready_pdu(s); + break; + + case EVENTID_CS_READY: + break; + + case EVENTID_TOUCH: + break; + + case EVENTID_SUSPEND_TOUCH: + break; + + case EVENTID_RESUME_TOUCH: + break; + + case EVENTID_DISMISS_HOVERING_CONTACT: + break; + + default: + break; + } + + return 0; +} + static int rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer) { + wStream* s; int status = 0; //RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback; + s = Stream_New(pBuffer, cbSize); + + status = rdpei_recv_pdu(s); + + Stream_Free(s, FALSE); + return status; } diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index ca233b3a8..20e207f94 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -29,6 +29,19 @@ #include <freerdp/addin.h> #include <freerdp/utils/debug.h> +/* Protocol Version */ + +#define RDPINPUT_PROTOCOL_V1 0x00010000 + +/* Input Event Ids */ + +#define EVENTID_SC_READY 0x0001 +#define EVENTID_CS_READY 0x0002 +#define EVENTID_TOUCH 0x0003 +#define EVENTID_SUSPEND_TOUCH 0x0004 +#define EVENTID_RESUME_TOUCH 0x0005 +#define EVENTID_DISMISS_HOVERING_CONTACT 0x0006 + #ifdef WITH_DEBUG_DVC #define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) #else From 335d13d65fee7e717e99caca911c28671de9a043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 00:21:33 -0400 Subject: [PATCH 092/144] channels/rdpei: implement client pdus --- channels/rdpei/client/rdpei_common.c | 1 + channels/rdpei/client/rdpei_common.h | 11 ++ channels/rdpei/client/rdpei_main.c | 155 ++++++++++++++++++++++++--- channels/rdpei/client/rdpei_main.h | 42 ++++++++ 4 files changed, 195 insertions(+), 14 deletions(-) diff --git a/channels/rdpei/client/rdpei_common.c b/channels/rdpei/client/rdpei_common.c index c81237c36..e0b758a04 100644 --- a/channels/rdpei/client/rdpei_common.c +++ b/channels/rdpei/client/rdpei_common.c @@ -32,6 +32,7 @@ BOOL rdpei_read_2byte_unsigned(wStream* s, UINT32* value) if (Stream_GetRemainingLength(s) < 1) return FALSE; + Stream_Read_UINT8(s, byte); if (byte & 0x80) diff --git a/channels/rdpei/client/rdpei_common.h b/channels/rdpei/client/rdpei_common.h index 0ed59b0a8..293919f67 100644 --- a/channels/rdpei/client/rdpei_common.h +++ b/channels/rdpei/client/rdpei_common.h @@ -23,5 +23,16 @@ #include <winpr/crt.h> #include <winpr/stream.h> +BOOL rdpei_read_2byte_unsigned(wStream* s, UINT32* value); +BOOL rdpei_write_2byte_unsigned(wStream* s, UINT32 value); +BOOL rdpei_read_2byte_signed(wStream* s, INT32* value); +BOOL rdpei_write_2byte_signed(wStream* s, INT32 value); +BOOL rdpei_read_4byte_unsigned(wStream* s, UINT32* value); +BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value); +BOOL rdpei_read_4byte_signed(wStream* s, INT32* value); +BOOL rdpei_write_4byte_signed(wStream* s, INT32 value); +BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value); +BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value); + #endif /* FREERDP_CHANNEL_RDPEI_CLIENT_COMMON_H */ diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 130ccf50e..bf1198e1c 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -73,7 +73,130 @@ const char* RDPEI_EVENTID_STRINGS[] = "EVENTID_DISMISS_HOVERING_CONTACT" }; -int rdpei_recv_sc_ready_pdu(wStream* s) +int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, UINT32 pduLength) +{ + int status; + + Stream_SetPosition(s, 0); + Stream_Write_UINT16(s, eventId); /* eventId (2 bytes) */ + Stream_Write_UINT32(s, pduLength); /* pduLength (4 bytes) */ + Stream_SetPosition(s, Stream_Length(s)); + + printf("rdpei_send_pdu: eventId: %d (%s) length: %d\n", + eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); + + status = callback->channel->Write(callback->channel, + Stream_Length(s), Stream_Buffer(s), NULL); + + return status; +} + +int rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) +{ + int status; + wStream* s; + UINT32 flags; + UINT32 pduLength; + UINT16 maxTouchContacts; + + flags = 0; + flags |= READY_FLAGS_SHOW_TOUCH_VISUALS; + //flags |= READY_FLAGS_DISABLE_TIMESTAMP_INJECTION; + + maxTouchContacts = 10; + + pduLength = RDPINPUT_HEADER_LENGTH + 10; + s = Stream_New(NULL, pduLength); + Stream_Seek(s, RDPINPUT_HEADER_LENGTH); + + Stream_Write_UINT32(s, flags); /* flags (4 bytes) */ + Stream_Write_UINT32(s, RDPINPUT_PROTOCOL_V1); /* protocolVersion (4 bytes) */ + Stream_Write_UINT16(s, maxTouchContacts); /* maxTouchContacts (2 bytes) */ + + Stream_SealLength(s); + + status = rdpei_send_pdu(callback, s, EVENTID_CS_READY, pduLength); + Stream_Free(s, TRUE); + + return status; +} + +int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) +{ + int index; + RDPINPUT_CONTACT_DATA* contact; + + rdpei_write_2byte_unsigned(s, frame->contactCount); + rdpei_write_8byte_unsigned(s, frame->frameOffset); + + Stream_EnsureRemainingCapacity(s, frame->contactCount * 32); + + for (index = 0; index < frame->contactCount; index++) + { + contact = &frame->contacts[index]; + + Stream_Write_UINT8(s, contact->contactId); + rdpei_write_2byte_unsigned(s, contact->fieldsPresent); + rdpei_write_4byte_signed(s, contact->x); + rdpei_write_4byte_signed(s, contact->y); + rdpei_write_4byte_unsigned(s, contact->contactFlags); + + if (contact->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT) + { + rdpei_write_2byte_signed(s, contact->contactRectLeft); + rdpei_write_2byte_signed(s, contact->contactRectTop); + rdpei_write_2byte_signed(s, contact->contactRectRight); + rdpei_write_2byte_signed(s, contact->contactRectBottom); + } + + if (contact->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT) + { + rdpei_write_4byte_unsigned(s, contact->orientation); + } + + if (contact->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT) + { + rdpei_write_4byte_unsigned(s, contact->pressure); + } + } + + return 0; +} + +int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback) +{ + int status; + wStream* s; + UINT32 pduLength; + UINT32 encodeTime; + UINT16 frameCount; + RDPINPUT_TOUCH_FRAME frame; + RDPINPUT_CONTACT_DATA contact; + + encodeTime = 123; + frameCount = 1; + + frame.contactCount = 1; + frame.contacts = &contact; + + s = Stream_New(NULL, 512); + Stream_Seek(s, RDPINPUT_HEADER_LENGTH); + + rdpei_write_4byte_unsigned(s, encodeTime); + rdpei_write_2byte_unsigned(s, frameCount); + + rdpei_write_touch_frame(s, &frame); + + Stream_SealLength(s); + pduLength = Stream_Length(s); + + status = rdpei_send_pdu(callback, s, EVENTID_TOUCH, pduLength); + Stream_Free(s, TRUE); + + return status; +} + +int rdpei_recv_sc_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) { UINT32 protocolVersion; @@ -88,7 +211,17 @@ int rdpei_recv_sc_ready_pdu(wStream* s) return 0; } -int rdpei_recv_pdu(wStream* s) +int rdpei_recv_suspend_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +{ + return 0; +} + +int rdpei_recv_resume_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +{ + return 0; +} + +int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 eventId; UINT32 pduLength; @@ -102,22 +235,16 @@ int rdpei_recv_pdu(wStream* s) switch (eventId) { case EVENTID_SC_READY: - rdpei_recv_sc_ready_pdu(s); - break; - - case EVENTID_CS_READY: - break; - - case EVENTID_TOUCH: + rdpei_recv_sc_ready_pdu(callback, s); + rdpei_send_cs_ready_pdu(callback); break; case EVENTID_SUSPEND_TOUCH: + rdpei_recv_suspend_touch_pdu(callback, s); break; case EVENTID_RESUME_TOUCH: - break; - - case EVENTID_DISMISS_HOVERING_CONTACT: + rdpei_recv_resume_touch_pdu(callback, s); break; default: @@ -131,11 +258,11 @@ static int rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, { wStream* s; int status = 0; - //RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback; + RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback; s = Stream_New(pBuffer, cbSize); - status = rdpei_recv_pdu(s); + status = rdpei_recv_pdu(callback, s); Stream_Free(s, FALSE); diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 20e207f94..42247ec39 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -29,10 +29,52 @@ #include <freerdp/addin.h> #include <freerdp/utils/debug.h> +#define RDPINPUT_HEADER_LENGTH 6 + +#define CONTACT_DATA_CONTACTRECT_PRESENT 0x0001 +#define CONTACT_DATA_ORIENTATION_PRESENT 0x0002 +#define CONTACT_DATA_PRESSURE_PRESENT 0x0004 + +#define CONTACT_FLAG_DOWN 0x0001 +#define CONTACT_FLAG_UPDATE 0x0002 +#define CONTACT_FLAG_UP 0x0004 +#define CONTACT_FLAG_INRANGE 0x0008 +#define CONTACT_FLAG_INCONTACT 0x0010 +#define CONTACT_FLAG_CANCELED 0x0020 + +struct _RDPINPUT_CONTACT_DATA +{ + UINT32 contactId; + UINT32 fieldsPresent; + INT32 x; + INT32 y; + UINT32 contactFlags; + INT32 contactRectLeft; + INT32 contactRectTop; + INT32 contactRectRight; + INT32 contactRectBottom; + UINT32 orientation; + UINT32 pressure; +}; +typedef struct _RDPINPUT_CONTACT_DATA RDPINPUT_CONTACT_DATA; + +struct _RDPINPUT_TOUCH_FRAME +{ + UINT32 contactCount; + UINT64 frameOffset; + RDPINPUT_CONTACT_DATA* contacts; +}; +typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME; + /* Protocol Version */ #define RDPINPUT_PROTOCOL_V1 0x00010000 +/* Client Ready Flags */ + +#define READY_FLAGS_SHOW_TOUCH_VISUALS 0x00000001 +#define READY_FLAGS_DISABLE_TIMESTAMP_INJECTION 0x00000002 + /* Input Event Ids */ #define EVENTID_SC_READY 0x0001 From 16186ac4879e2daec92dbb7612dc71c9ac9a82e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 00:52:37 -0400 Subject: [PATCH 093/144] channels/rdpei: define message interface ids --- client/X11/xf_input.c | 156 ++++++++++++++++++++++++++++---------- client/X11/xf_input.h | 9 +-- client/X11/xf_interface.c | 5 ++ include/freerdp/message.h | 20 +++++ 4 files changed, 143 insertions(+), 47 deletions(-) diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index c90cb38f4..5ab5ce6f3 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -205,47 +205,8 @@ void xf_input_detect_pinch(xfInfo* xfi) #endif -int xf_input_handle_event(xfInfo* xfi, XEvent* event) -{ #ifdef WITH_XI - XGenericEventCookie* cookie = &event->xcookie; - XGetEventData(xfi->display, cookie); - - if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) - { - switch(cookie->evtype) - { - case XI_TouchBegin: - if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_begin(xfi, cookie->data); - xf_input_save_last_event(cookie->data); - break; - - case XI_TouchUpdate: - if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_update(xfi, cookie->data); - xf_input_save_last_event(cookie->data); - break; - - case XI_TouchEnd: - if (xf_input_is_duplicate(cookie->data) == FALSE) - xf_input_touch_end(xfi, cookie->data); - xf_input_save_last_event(cookie->data); - break; - - default: - printf("unhandled xi type= %d\n", cookie->evtype); - break; - } - } - - XFreeEventData(xfi->display,cookie); -#endif - return 0; -} - -#ifdef WITH_XI void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event) { int i; @@ -306,3 +267,120 @@ void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) } #endif + +int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) +{ +#ifdef WITH_XI + XGenericEventCookie* cookie = &event->xcookie; + + XGetEventData(xfi->display, cookie); + + if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) + { + switch (cookie->evtype) + { + case XI_TouchBegin: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_begin(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + case XI_TouchUpdate: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_update(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + case XI_TouchEnd: + if (xf_input_is_duplicate(cookie->data) == FALSE) + xf_input_touch_end(xfi, cookie->data); + xf_input_save_last_event(cookie->data); + break; + + default: + printf("unhandled xi type= %d\n", cookie->evtype); + break; + } + } + + XFreeEventData(xfi->display,cookie); +#endif + return 0; +} + +#ifdef WITH_XI + +int xf_input_touch_begin_remote(xfInfo* xfi, XIDeviceEvent* event) +{ + return 0; +} + +int xf_input_touch_update_remote(xfInfo* xfi, XIDeviceEvent* event) +{ + return 0; +} + +int xf_input_touch_end_remote(xfInfo* xfi, XIDeviceEvent* event) +{ + return 0; +} + +#endif + +int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) +{ +#ifdef WITH_XI + XGenericEventCookie* cookie = &event->xcookie; + + XGetEventData(xfi->display, cookie); + + if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode)) + { + switch (cookie->evtype) + { + case XI_TouchBegin: + xf_input_touch_begin_remote(xfi, cookie->data); + break; + + case XI_TouchUpdate: + xf_input_touch_update_remote(xfi, cookie->data); + break; + + case XI_TouchEnd: + xf_input_touch_end_remote(xfi, cookie->data); + break; + + default: + break; + } + } + + XFreeEventData(xfi->display,cookie); +#endif + return 0; +} + +void xf_process_rdpei_event(xfInfo* xfi, wMessage* event) +{ + switch (GetMessageType(event->id)) + { + case RdpeiChannel_ServerReady: + break; + + case RdpeiChannel_SuspendTouch: + break; + + case RdpeiChannel_ResumeTouch: + break; + } +} + +int xf_input_handle_event(xfInfo* xfi, XEvent* event) +{ + if (xfi->settings->MultiTouchInput) + { + return xf_input_handle_event_remote(xfi, event); + } + + return xf_input_handle_event_local(xfi, event); +} diff --git a/client/X11/xf_input.h b/client/X11/xf_input.h index 6c540fef5..85428ae6c 100644 --- a/client/X11/xf_input.h +++ b/client/X11/xf_input.h @@ -29,13 +29,6 @@ int xf_input_init(xfInfo* xfi, Window win); int xf_input_handle_event(xfInfo* xfi, XEvent* event); - -#ifdef WITH_XI - -void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event); -void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event); -void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event); - -#endif +void xf_process_rdpei_event(xfInfo* xfi, wMessage* event); #endif diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index c1d5f87e7..236125650 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -77,6 +77,7 @@ #include "xf_rail.h" #include "xf_tsmf.h" #include "xf_event.h" +#include "xf_input.h" #include "xf_cliprdr.h" #include "xf_monitor.h" #include "xf_graphics.h" @@ -1024,6 +1025,10 @@ void xf_process_channel_event(rdpChannels* channels, freerdp* instance) xf_process_cliprdr_event(xfi, event); break; + case RdpeiChannel_Class: + xf_process_rdpei_event(xfi, event); + break; + default: break; } diff --git a/include/freerdp/message.h b/include/freerdp/message.h index 754802ba2..e275849b4 100644 --- a/include/freerdp/message.h +++ b/include/freerdp/message.h @@ -324,5 +324,25 @@ #define FREERDP_RAIL_CHANNEL_CLIENT_GET_APP_ID_REQUEST MakeMessageId(RailChannel, ClientGetAppIdRequest) #define FREERDP_RAIL_CHANNEL_SERVER_GET_APP_ID_RESPONSE MakeMessageId(RailChannel, ServerGetAppIdResponse) +/** + * MultiTouch Input Channel Extension (MS-RDPEDI) + */ + +#define RdpeiChannel_Class (Channel_Base + 5) + +#define RdpeiChannel_ServerReady 1 +#define RdpeiChannel_ClientReady 2 +#define RdpeiChannel_TouchEvent 3 +#define RdpeiChannel_SuspendTouch 4 +#define RdpeiChannel_ResumeTouch 5 +#define RdpeiChannel_DismissHoveringContact 6 + +#define FREERDP_RDPEI_CHANNEL_SERVER_READY MakeMessageId(RdpeiChannel, ServerReady) +#define FREERDP_RDPEI_CHANNEL_CLIENT_READY MakeMessageId(RdpeiChannel, ClientReady) +#define FREERDP_RDPEI_CHANNEL_TOUCH_EVENT MakeMessageId(RdpeiChannel, TouchEvent) +#define FREERDP_RDPEI_CHANNEL_SUSPEND_TOUCH MakeMessageId(RdpeiChannel, SuspendTouch) +#define FREERDP_RDPEI_CHANNEL_RESUME_TOUCH MakeMessageId(RdpeiChannel, ResumeTouch) +#define FREERDP_RDPEI_CHANNEL_DISMISS_HOVERING_CONTACT MakeMessageId(RdpeiChannel, DismissHoveringContact) + #endif /* FREERDP_CORE_MESSAGE_H */ From 565d50d486c10464e244091e6b8c5dad0b85ee0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 14:33:39 -0400 Subject: [PATCH 094/144] libfreerdp-core: fix server-side patblt --- libfreerdp/core/orders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 832f5b920..5fae374f3 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -826,10 +826,10 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* Stream_Write_UINT8(s, patblt->bRop); orderInfo->fieldFlags |= ORDER_FIELD_06; - update_write_coord(s, patblt->backColor); + update_write_color(s, patblt->backColor); orderInfo->fieldFlags |= ORDER_FIELD_07; - update_write_coord(s, patblt->foreColor); + update_write_color(s, patblt->foreColor); orderInfo->fieldFlags |= ORDER_FIELD_08; orderInfo->fieldFlags |= ORDER_FIELD_09; From 69ece7423650063a5e04222bded8613853489b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 15:30:21 -0400 Subject: [PATCH 095/144] xfreerdp: fix Xrender detection --- client/X11/xf_interface.c | 9 ++++++++ client/X11/xf_interface.h | 1 + cmake/FindXrender.cmake | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 cmake/FindXrender.cmake diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 236125650..7e0d185bd 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1564,6 +1564,15 @@ double freerdp_client_get_scale(xfInfo* xfi) return xfi->scale; } +void freerdp_client_reset_scale(xfInfo* xfi) +{ + xfi->scale = 1.0; + + XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale); + xf_draw_screen_scaled(xfi); +} + xfInfo* freerdp_client_new(int argc, char** argv) { int index; diff --git a/client/X11/xf_interface.h b/client/X11/xf_interface.h index 6707f4be7..34c2c2870 100644 --- a/client/X11/xf_interface.h +++ b/client/X11/xf_interface.h @@ -56,6 +56,7 @@ FREERDP_API freerdp* freerdp_client_get_instance(cfInfo* cfi); FREERDP_API HANDLE freerdp_client_get_thread(cfInfo* cfi); FREERDP_API rdpClient* freerdp_client_get_interface(cfInfo* cfi); FREERDP_API double freerdp_client_get_scale(xfInfo* xfi); +FREERDP_API void freerdp_client_reset_scale(xfInfo* xfi); FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv); FREERDP_API void freerdp_client_free(cfInfo* cfi); diff --git a/cmake/FindXrender.cmake b/cmake/FindXrender.cmake new file mode 100644 index 000000000..3fe4a0172 --- /dev/null +++ b/cmake/FindXrender.cmake @@ -0,0 +1,44 @@ +# - Find Xrender +# Find the Xrender libraries +# +# This module defines the following variables: +# Xrender_FOUND - true if Xrender_INCLUDE_DIR & Xrender_LIBRARY are found +# Xrender_LIBRARIES - Set when Xrender_LIBRARY is found +# Xrender_INCLUDE_DIRS - Set when Xrender_INCLUDE_DIR is found +# +# Xrender_INCLUDE_DIR - where to find Xrendernput2.h, etc. +# Xrender_LIBRARY - the Xrender library +# + +#============================================================================= +# Copyright 2013 Corey Clayton <can.of.tuna@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. +#============================================================================= + +find_path(Xrender_INCLUDE_DIR NAMES X11/extensions/Xrender.h + DOC "The Xrender include directory") + +find_library(Xrender_LIBRARY NAMES Xrender + DOC "The Xrender library") + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xrender DEFAULT_MSG Xrender_LIBRARY Xrender_INCLUDE_DIR) + +if(Xrender_FOUND) +set(XRENDER_LIBRARIES ${Xrender_LIBRARY}) +set(XRENDER_INCLUDE_DIRS ${Xrender_INCLUDE_DIR}) +endif() + +mark_as_advanced(Xrender_INCLUDE_DIR Xrender_LIBRARY) + From 841c710e1c272a7b15b4175d110c5e3e2a176dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 16:30:28 -0400 Subject: [PATCH 096/144] libfreerdp-core: server-side update combining --- include/freerdp/update.h | 4 + libfreerdp/core/fastpath.c | 13 ++ libfreerdp/core/fastpath.h | 1 + libfreerdp/core/orders.c | 18 +++ libfreerdp/core/peer.c | 3 + libfreerdp/core/update.c | 236 +++++++++++++++++++++++-------------- 6 files changed, 187 insertions(+), 88 deletions(-) diff --git a/include/freerdp/update.h b/include/freerdp/update.h index 047a4ec17..254f101a1 100644 --- a/include/freerdp/update.h +++ b/include/freerdp/update.h @@ -206,6 +206,10 @@ struct rdp_update BOOL asynchronous; rdpUpdateProxy* proxy; wMessageQueue* queue; + + wStream* us; + UINT16 numberOrders; + BOOL combineUpdates; }; #endif /* FREERDP_UPDATE_H */ diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 2987b67c9..281bd6221 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -785,6 +785,19 @@ wStream* fastpath_update_pdu_init(rdpFastPath* fastpath) return s; } +wStream* fastpath_update_pdu_init_new(rdpFastPath* fastpath) +{ + wStream* s; + + s = Stream_New(NULL, FASTPATH_MAX_PACKET_SIZE); + + Stream_Seek(s, 3); /* fpOutputHeader, length1 and length2 */ + Stream_Seek(s, fastpath_get_sec_bytes(fastpath->rdp)); + Stream_Seek(s, 3); /* updateHeader, size */ + + return s; +} + BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s) { rdpRdp* rdp; diff --git a/libfreerdp/core/fastpath.h b/libfreerdp/core/fastpath.h index 3207576da..243196959 100644 --- a/libfreerdp/core/fastpath.h +++ b/libfreerdp/core/fastpath.h @@ -116,6 +116,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iEv BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s); wStream* fastpath_update_pdu_init(rdpFastPath* fastpath); +wStream* fastpath_update_pdu_init_new(rdpFastPath* fastpath); BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s); BOOL fastpath_send_surfcmd_frame_marker(rdpFastPath* fastpath, UINT16 frameAction, UINT32 frameId); diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 5fae374f3..7559f280c 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -810,6 +810,8 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* { orderInfo->fieldFlags = 0; + Stream_EnsureRemainingCapacity(s, 64); + orderInfo->fieldFlags |= ORDER_FIELD_01; update_write_coord(s, patblt->nLeftRect); @@ -858,6 +860,8 @@ BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* { orderInfo->fieldFlags = 0; + Stream_EnsureRemainingCapacity(s, 32); + orderInfo->fieldFlags |= ORDER_FIELD_01; update_write_coord(s, scrblt->nLeftRect); @@ -925,6 +929,8 @@ BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RE { BYTE byte; + Stream_EnsureRemainingCapacity(s, 32); + orderInfo->fieldFlags = 0; orderInfo->fieldFlags |= ORDER_FIELD_01; @@ -1154,6 +1160,8 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* { UINT16 cacheId; + Stream_EnsureRemainingCapacity(s, 32); + cacheId = (memblt->cacheId & 0xFF) | ((memblt->colorIndex & 0xFF) << 8); orderInfo->fieldFlags |= ORDER_FIELD_01; @@ -1263,6 +1271,8 @@ BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_IND { orderInfo->fieldFlags = 0; + Stream_EnsureRemainingCapacity(s, 64); + orderInfo->fieldFlags |= ORDER_FIELD_01; Stream_Write_UINT8(s, glyph_index->cacheId); @@ -1629,6 +1639,8 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache { BYTE bitsPerPixelId; + Stream_EnsureRemainingCapacity(s, 64); + bitsPerPixelId = BPP_CBR2[cache_bitmap_v2->bitmapBpp]; *flags = (cache_bitmap_v2->cacheId & 0x0003) | @@ -1670,10 +1682,12 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache cache_bitmap_v2->bitmapLength = cache_bitmap_v2->cbCompMainBodySize; } + Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength); Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength); } else { + Stream_EnsureRemainingCapacity(s, cache_bitmap_v2->bitmapLength); Stream_Write(s, cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapLength); } @@ -1801,6 +1815,8 @@ BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph, INT16 lsi16; GLYPH_DATA* glyph; + Stream_EnsureRemainingCapacity(s, 2 + cache_glyph->cGlyphs * 32); + Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */ Stream_Write_UINT8(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ @@ -1882,6 +1898,8 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g int i; GLYPH_DATA_V2* glyph; + Stream_EnsureRemainingCapacity(s, cache_glyph_v2->cGlyphs * 32); + *flags = (cache_glyph_v2->cacheId & 0x000F) | ((cache_glyph_v2->flags & 0x000F) << 4) | ((cache_glyph_v2->cGlyphs & 0x00FF) << 8); diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 7592b3069..5e61a9f17 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -380,6 +380,9 @@ void freerdp_peer_context_new(freerdp_peer* client) client->context->rdp = rdp; client->context->peer = client; + client->context->input = client->input; + client->context->update = client->update; + client->context->settings = client->settings; client->update->context = client->context; client->input->context = client->context; diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index a4d23d4e1..bb076dcd5 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -443,12 +443,48 @@ void update_post_connect(rdpUpdate* update) static void update_begin_paint(rdpContext* context) { + wStream* s; + rdpUpdate* update = context->update; + if (update->us) + update->EndPaint(context); + + s = fastpath_update_pdu_init_new(context->rdp->fastpath); + Stream_SealLength(s); + Stream_Seek(s, 2); /* numberOrders (2 bytes) */ + + update->combineUpdates = TRUE; + update->numberOrders = 0; + update->us = s; } static void update_end_paint(rdpContext* context) { + wStream* s; + int headerLength; + rdpUpdate* update = context->update; + if (!update->us) + return; + + s = update->us; + headerLength = Stream_Length(s); + Stream_SealLength(s); + + Stream_SetPosition(s, headerLength); + Stream_Write_UINT16(s, update->numberOrders); /* numberOrders (2 bytes) */ + Stream_SetPosition(s, Stream_Length(s)); + + if (update->numberOrders > 0) + { + fastpath_send_update_pdu(context->rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + } + + update->combineUpdates = FALSE; + update->numberOrders = 0; + update->us = NULL; + + Stream_Free(s, TRUE); } static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* areas) @@ -576,248 +612,272 @@ static void update_send_desktop_resize(rdpContext* context) static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) { wStream* s; - BYTE *bm, *em; + int bm, em; int headerLength; ORDER_INFO orderInfo; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; orderInfo.orderType = ORDER_TYPE_PATBLT; orderInfo.fieldFlags = 0; - headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + s = update->us; + bm = Stream_GetPosition(s); + Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); - update_write_patblt_order(s, &orderInfo, patblt); - em = Stream_Pointer(s); - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + update_write_patblt_order(s, &orderInfo, patblt); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { wStream* s; - BYTE *bm, *em; + int bm, em; int headerLength; ORDER_INFO orderInfo; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; orderInfo.orderType = ORDER_TYPE_SCRBLT; orderInfo.fieldFlags = 0; - headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + s = update->us; + bm = Stream_GetPosition(s); + Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); - update_write_scrblt_order(s, &orderInfo, scrblt); - em = Stream_Pointer(s); - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + update_write_scrblt_order(s, &orderInfo, scrblt); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) { wStream* s; - BYTE *bm, *em; + int bm, em; int headerLength; ORDER_INFO orderInfo; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; orderInfo.orderType = ORDER_TYPE_OPAQUE_RECT; orderInfo.fieldFlags = 0; - headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + s = update->us; + bm = Stream_GetPosition(s); + Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); - update_write_opaque_rect_order(s, &orderInfo, opaque_rect); - em = Stream_Pointer(s); - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + update_write_opaque_rect_order(s, &orderInfo, opaque_rect); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { wStream* s; - BYTE *bm, *em; + int bm, em; int headerLength; ORDER_INFO orderInfo; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; orderInfo.orderType = ORDER_TYPE_MEMBLT; orderInfo.fieldFlags = 0; - headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + s = update->us; + bm = Stream_GetPosition(s); + Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); - update_write_memblt_order(s, &orderInfo, memblt); - em = Stream_Pointer(s); - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + update_write_memblt_order(s, &orderInfo, memblt); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) { wStream* s; - BYTE *bm, *em; + int bm, em; int headerLength; ORDER_INFO orderInfo; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; orderInfo.orderType = ORDER_TYPE_GLYPH_INDEX; orderInfo.fieldFlags = 0; - headerLength = 4 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + s = update->us; + bm = Stream_GetPosition(s); + Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); - update_write_glyph_index_order(s, &orderInfo, glyph_index); - em = Stream_Pointer(s); - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + update_write_glyph_index_order(s, &orderInfo, glyph_index); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) { wStream* s; - BYTE *bm, *em; + int bm, em; + int headerLength; UINT16 extraFlags; INT16 orderLength; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; extraFlags = 0; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + headerLength = 6; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); - Stream_Seek(s, 8); update_write_cache_bitmap_v2_order(s, cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags); - em = Stream_Pointer(s); + em = Stream_GetPosition(s); - orderLength = (em - bm) - 13 - 2; + orderLength = (em - bm) - 13; - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ Stream_Write_UINT8(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; + + /** + * temporary workaround to avoid PDUs exceeding maximum size + */ + + update->EndPaint(context); + update->BeginPaint(context); } static void update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph) { wStream* s; UINT16 flags; - BYTE *bm, *em; + int bm, em; + int headerLength; INT16 orderLength; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; flags = 0; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + headerLength = 6; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); - Stream_Seek(s, 8); update_write_cache_glyph_order(s, cache_glyph, &flags); - em = Stream_Pointer(s); + em = Stream_GetPosition(s); - orderLength = (em - bm) - 13 - 2; + orderLength = (em - bm) - 13; - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2) { wStream* s; UINT16 flags; - BYTE *bm, *em; + int bm, em; + int headerLength; INT16 orderLength; - rdpRdp* rdp = context->rdp; + rdpUpdate* update = context->update; flags = 0; - s = fastpath_update_pdu_init(rdp->fastpath); - bm = Stream_Pointer(s); + headerLength = 6; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); - Stream_Seek(s, 8); update_write_cache_glyph_v2_order(s, cache_glyph_v2, &flags); - em = Stream_Pointer(s); + em = Stream_GetPosition(s); - orderLength = (em - bm) - 13 - 2; + orderLength = (em - bm) - 13; - Stream_Pointer(s) = bm; - Stream_Write_UINT16(s, 1); /* numberOrders (2 bytes) */ + Stream_SetPosition(s, bm); Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */ - Stream_Pointer(s) = em; + Stream_SetPosition(s, em); - fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_ORDERS, s); + update->numberOrders++; } static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) From 645dfd7d6318bafcbf6c1f1535b3ffa08fa9401f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 19:41:32 -0400 Subject: [PATCH 097/144] libfreerdp-core: start encoding server-side bounds --- include/freerdp/primary.h | 7 +- include/freerdp/update.h | 2 + libfreerdp/core/orders.c | 55 ++++++++++ libfreerdp/core/orders.h | 3 + libfreerdp/core/update.c | 220 +++++++++++++++++++++++++------------- 5 files changed, 207 insertions(+), 80 deletions(-) diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index c65c55aa5..8cb1d716a 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -73,14 +73,11 @@ typedef struct rdp_brush rdpBrush; struct _ORDER_INFO { - BYTE controlFlags; + UINT32 controlFlags; UINT32 orderType; UINT32 fieldFlags; + UINT32 boundsFlags; rdpBounds bounds; - INT32 deltaBoundLeft; - INT32 deltaBoundTop; - INT32 deltaBoundRight; - INT32 deltaBoundBottom; BOOL deltaCoordinates; }; typedef struct _ORDER_INFO ORDER_INFO; diff --git a/include/freerdp/update.h b/include/freerdp/update.h index 254f101a1..db6f36bb9 100644 --- a/include/freerdp/update.h +++ b/include/freerdp/update.h @@ -210,6 +210,8 @@ struct rdp_update wStream* us; UINT16 numberOrders; BOOL combineUpdates; + rdpBounds currentBounds; + rdpBounds previousBounds; }; #endif /* FREERDP_UPDATE_H */ diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 7559f280c..4f3996a87 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2292,6 +2292,7 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds) if (Stream_GetRemainingLength(s) < 1) return FALSE; + Stream_Read_UINT8(s, flags); /* field flags */ if (flags & BOUND_LEFT) @@ -2337,6 +2338,60 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds) if (!update_read_coord(s, &bounds->bottom, TRUE)) return FALSE; } + + return TRUE; +} + +BOOL update_write_bounds(wStream* s, ORDER_INFO* orderInfo) +{ + if (!(orderInfo->controlFlags & ORDER_BOUNDS)) + return TRUE; + + if (orderInfo->controlFlags & ORDER_ZERO_BOUNDS_DELTAS) + return TRUE; + + Stream_Write_UINT8(s, orderInfo->boundsFlags); /* field flags */ + + if (orderInfo->boundsFlags & BOUND_LEFT) + { + if (!update_write_coord(s, orderInfo->bounds.left)) + return FALSE; + } + else if (orderInfo->boundsFlags & BOUND_DELTA_LEFT) + { + + } + + if (orderInfo->boundsFlags & BOUND_TOP) + { + if (!update_write_coord(s, orderInfo->bounds.top)) + return FALSE; + } + else if (orderInfo->boundsFlags & BOUND_DELTA_TOP) + { + + } + + if (orderInfo->boundsFlags & BOUND_RIGHT) + { + if (!update_write_coord(s, orderInfo->bounds.right)) + return FALSE; + } + else if (orderInfo->boundsFlags & BOUND_DELTA_RIGHT) + { + + } + + if (orderInfo->boundsFlags & BOUND_BOTTOM) + { + if (!update_write_coord(s, orderInfo->bounds.bottom)) + return FALSE; + } + else if (orderInfo->boundsFlags & BOUND_DELTA_BOTTOM) + { + + } + return TRUE; } diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 97dfa59b2..21db4d74d 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -191,6 +191,9 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s); BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes); BOOL update_write_field_flags(wStream* s, UINT32 fieldFlags, BYTE flags, BYTE fieldBytes); +BOOL update_read_bounds(wStream* s, rdpBounds* bounds); +BOOL update_write_bounds(wStream* s, ORDER_INFO* orderInfo); + BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt); BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index bb076dcd5..c9fd3d76b 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -487,6 +487,130 @@ static void update_end_paint(rdpContext* context) Stream_Free(s, TRUE); } +static void update_set_bounds(rdpContext* context, rdpBounds* bounds) +{ + rdpUpdate* update = context->update; + + CopyMemory(&update->previousBounds, &update->currentBounds, sizeof(rdpBounds)); + + if (!bounds) + ZeroMemory(&update->currentBounds, sizeof(rdpBounds)); + else + CopyMemory(&update->currentBounds, bounds, sizeof(rdpBounds)); +} + +BOOL update_bounds_is_null(rdpBounds* bounds) +{ + if ((bounds->left == 0) && (bounds->top == 0) && + (bounds->right == 0) && (bounds->bottom == 0)) + return TRUE; + + return FALSE; +} + +BOOL update_bounds_equals(rdpBounds* bounds1, rdpBounds* bounds2) +{ + if ((bounds1->left == bounds2->left) && (bounds1->top == bounds2->top) && + (bounds1->right == bounds2->right) && (bounds1->bottom == bounds2->bottom)) + return TRUE; + + return FALSE; +} + +int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo) +{ + int length = 0; + rdpUpdate* update = context->update; + + orderInfo->boundsFlags = 0; + + if (update_bounds_is_null(&update->currentBounds)) + return 0; + + orderInfo->controlFlags |= ORDER_BOUNDS; + + if (update_bounds_equals(&update->previousBounds, &update->currentBounds)) + { + orderInfo->controlFlags |= ORDER_ZERO_BOUNDS_DELTAS; + return 0; + } + else + { + length += 1; + + if (update->previousBounds.left != update->currentBounds.left) + { + orderInfo->bounds.left = update->currentBounds.left; + orderInfo->boundsFlags |= BOUND_LEFT; + length += 2; + } + + if (update->previousBounds.top != update->currentBounds.top) + { + orderInfo->bounds.top = update->currentBounds.top; + orderInfo->boundsFlags |= BOUND_TOP; + length += 2; + } + + if (update->previousBounds.right != update->currentBounds.right) + { + orderInfo->bounds.right = update->currentBounds.right; + orderInfo->boundsFlags |= BOUND_RIGHT; + length += 2; + } + + if (update->previousBounds.bottom != update->currentBounds.bottom) + { + orderInfo->bounds.bottom = update->currentBounds.bottom; + orderInfo->boundsFlags |= BOUND_BOTTOM; + length += 2; + } + } + + return length; +} + +int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo, UINT32 orderType) +{ + int length = 1; + + orderInfo->fieldFlags = 0; + orderInfo->orderType = orderType; + + orderInfo->controlFlags = ORDER_STANDARD; + + orderInfo->controlFlags |= ORDER_TYPE_CHANGE; + length += 1; + + length += PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]; + + length += update_prepare_bounds(context, orderInfo); + + return length; +} + +int update_write_order_info(rdpContext* context, wStream* s, ORDER_INFO* orderInfo, int offset) +{ + int position; + + position = Stream_GetPosition(s); + Stream_SetPosition(s, offset); + + Stream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */ + + if (orderInfo->controlFlags & ORDER_TYPE_CHANGE) + Stream_Write_UINT8(s, orderInfo->orderType); /* orderType (1 byte) */ + + update_write_field_flags(s, orderInfo->fieldFlags, orderInfo->controlFlags, + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo->orderType]); + + update_write_bounds(s, orderInfo); + + Stream_SetPosition(s, position); + + return 0; +} + static void update_write_refresh_rect(wStream* s, BYTE count, RECTANGLE_16* areas) { int i; @@ -612,32 +736,21 @@ static void update_send_desktop_resize(rdpContext* context) static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) { wStream* s; - int bm, em; + int offset; int headerLength; ORDER_INFO orderInfo; rdpUpdate* update = context->update; - orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; - orderInfo.orderType = ORDER_TYPE_PATBLT; - orderInfo.fieldFlags = 0; - - headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT); s = update->us; - bm = Stream_GetPosition(s); + offset = Stream_GetPosition(s); Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); update_write_patblt_order(s, &orderInfo, patblt); - em = Stream_GetPosition(s); - - Stream_SetPosition(s, bm); - Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ - update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, - PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_SetPosition(s, em); + update_write_order_info(context, s, &orderInfo, offset); update->numberOrders++; } @@ -645,32 +758,21 @@ static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) { wStream* s; - int bm, em; + int offset; int headerLength; ORDER_INFO orderInfo; rdpUpdate* update = context->update; - orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; - orderInfo.orderType = ORDER_TYPE_SCRBLT; - orderInfo.fieldFlags = 0; - - headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT); s = update->us; - bm = Stream_GetPosition(s); + offset = Stream_GetPosition(s); Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); update_write_scrblt_order(s, &orderInfo, scrblt); - em = Stream_GetPosition(s); - - Stream_SetPosition(s, bm); - Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ - update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, - PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_SetPosition(s, em); + update_write_order_info(context, s, &orderInfo, offset); update->numberOrders++; } @@ -678,32 +780,21 @@ static void update_send_scrblt(rdpContext* context, SCRBLT_ORDER* scrblt) static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) { wStream* s; - int bm, em; + int offset; int headerLength; ORDER_INFO orderInfo; rdpUpdate* update = context->update; - orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; - orderInfo.orderType = ORDER_TYPE_OPAQUE_RECT; - orderInfo.fieldFlags = 0; - - headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT); s = update->us; - bm = Stream_GetPosition(s); + offset = Stream_GetPosition(s); Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); update_write_opaque_rect_order(s, &orderInfo, opaque_rect); - em = Stream_GetPosition(s); - - Stream_SetPosition(s, bm); - Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ - update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, - PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_SetPosition(s, em); + update_write_order_info(context, s, &orderInfo, offset); update->numberOrders++; } @@ -711,32 +802,21 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { wStream* s; - int bm, em; + int offset; int headerLength; ORDER_INFO orderInfo; rdpUpdate* update = context->update; - orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; - orderInfo.orderType = ORDER_TYPE_MEMBLT; - orderInfo.fieldFlags = 0; - - headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT); s = update->us; - bm = Stream_GetPosition(s); + offset = Stream_GetPosition(s); Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); update_write_memblt_order(s, &orderInfo, memblt); - em = Stream_GetPosition(s); - - Stream_SetPosition(s, bm); - Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ - update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, - PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_SetPosition(s, em); + update_write_order_info(context, s, &orderInfo, offset); update->numberOrders++; } @@ -744,32 +824,21 @@ static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index) { wStream* s; - int bm, em; + int offset; int headerLength; ORDER_INFO orderInfo; rdpUpdate* update = context->update; - orderInfo.controlFlags = ORDER_STANDARD | ORDER_TYPE_CHANGE; - orderInfo.orderType = ORDER_TYPE_GLYPH_INDEX; - orderInfo.fieldFlags = 0; - - headerLength = 2 + PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]; + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX); s = update->us; - bm = Stream_GetPosition(s); + offset = Stream_GetPosition(s); Stream_EnsureRemainingCapacity(s, headerLength); Stream_Seek(s, headerLength); update_write_glyph_index_order(s, &orderInfo, glyph_index); - em = Stream_GetPosition(s); - - Stream_SetPosition(s, bm); - Stream_Write_UINT8(s, orderInfo.controlFlags); /* controlFlags (1 byte) */ - Stream_Write_UINT8(s, orderInfo.orderType); /* orderType (1 byte) */ - update_write_field_flags(s, orderInfo.fieldFlags, orderInfo.controlFlags, - PRIMARY_DRAWING_ORDER_FIELD_BYTES[orderInfo.orderType]); - Stream_SetPosition(s, em); + update_write_order_info(context, s, &orderInfo, offset); update->numberOrders++; } @@ -1003,6 +1072,7 @@ void update_register_server_callbacks(rdpUpdate* update) { update->BeginPaint = update_begin_paint; update->EndPaint = update_end_paint; + update->SetBounds = update_set_bounds; update->Synchronize = update_send_synchronize; update->DesktopResize = update_send_desktop_resize; update->SurfaceBits = update_send_surface_bits; From c4312088298fba7e8a37400654f7f554c7ec6eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 9 May 2013 21:04:41 -0400 Subject: [PATCH 098/144] libfreerdp-core: handle sending compressed bitmaps --- libfreerdp/core/update.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index c9fd3d76b..b5e9a08ea 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -847,6 +847,7 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD { wStream* s; int bm, em; + BYTE orderType; int headerLength; UINT16 extraFlags; INT16 orderLength; @@ -855,6 +856,9 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD extraFlags = 0; headerLength = 6; + orderType = cache_bitmap_v2->compressed ? + ORDER_TYPE_BITMAP_COMPRESSED_V2 : ORDER_TYPE_BITMAP_UNCOMPRESSED_V2; + s = update->us; bm = Stream_GetPosition(s); @@ -870,7 +874,7 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ - Stream_Write_UINT8(s, ORDER_TYPE_BITMAP_UNCOMPRESSED_V2); /* orderType (1 byte) */ + Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */ Stream_SetPosition(s, em); update->numberOrders++; From 089bfbea2cad47ca13d57c0dcc2ce137b763e085 Mon Sep 17 00:00:00 2001 From: Daryl Poe <daryl.poe@hp.com> Date: Fri, 10 May 2013 13:57:22 -0600 Subject: [PATCH 099/144] handle drdynv version 3 --- channels/drdynvc/client/drdynvc_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index a6b062692..e1970e3d5 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -182,7 +182,10 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in stream_seek(s, 1); /* pad */ stream_read_UINT16(s, drdynvc->version); - if (drdynvc->version == 2) + /* RDP8 servers offer version 3, though Microsoft forgot to document it + * in their early documents. It behaves the same as version 2. + */ + if ((drdynvc->version == 2) || (drdynvc->version == 3)) { stream_read_UINT16(s, drdynvc->PriorityCharge0); stream_read_UINT16(s, drdynvc->PriorityCharge1); From ba0b4ee524e99c5b259d4022e58c57798680b653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 10 May 2013 16:39:16 -0400 Subject: [PATCH 100/144] libfreerdp-client: load rdpdr when rdpsnd is loaded --- channels/client/channels.c | 2 +- client/common/cmdline.c | 1 + libfreerdp/utils/svc_plugin.c | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index 82ee13e1c..a9ef88907 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -833,7 +833,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve if (!name) { - DEBUG_CHANNELS("unknown event_class %d", event->event_class); + DEBUG_CHANNELS("unknown event_class %d", GetMessageClass(event->id)); freerdp_event_free(event); return 1; } diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 92cc70f33..1055ea827 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1661,6 +1661,7 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings) if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) || (freerdp_dynamic_channel_collection_find(settings, "tsmf"))) { + settings->DeviceRedirection = TRUE; /* rdpsnd requires rdpdr to be registered */ settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */ } diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index ba961b8d7..f0869a6c6 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -326,7 +326,8 @@ int svc_plugin_send_event(rdpSvcPlugin* plugin, wMessage* event) { UINT32 status = 0; - DEBUG_SVC("event_type %d", event->event_type); + DEBUG_SVC("event class: %d type: %d", + GetMessageClass(event->id), GetMessageType(event->id)); status = plugin->channel_entry_points.pVirtualChannelEventPush(plugin->open_handle, event); From 9c0a41c16d61544a5596aec5ba1543c5a8c6b56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 10 May 2013 16:56:24 -0400 Subject: [PATCH 101/144] xfreerdp: disable scaling by default --- client/X11/xf_input.c | 5 ++++- client/X11/xfreerdp.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 5ab5ce6f3..2b81bfe99 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -382,5 +382,8 @@ int xf_input_handle_event(xfInfo* xfi, XEvent* event) return xf_input_handle_event_remote(xfi, event); } - return xf_input_handle_event_local(xfi, event); + if (xfi->enableScaling) + return xf_input_handle_event_local(xfi, event); + + return 0; } diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 392436c7f..916ca0425 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -120,6 +120,7 @@ struct xf_info int currentWidth; int currentHeight; int XInputOpcode; + BOOL enableScaling; BOOL focused; BOOL mouse_active; From 929b3b307647ef48c520dd5ee915724f2ef4865f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 10 May 2013 17:36:27 -0400 Subject: [PATCH 102/144] channels/tsmf: implement set source video rect (0x116) --- channels/tsmf/client/tsmf_constants.h | 1 + channels/tsmf/client/tsmf_ifman.c | 41 +++++++++++++++++++++++++++ channels/tsmf/client/tsmf_ifman.h | 1 + channels/tsmf/client/tsmf_main.c | 4 +++ 4 files changed, 47 insertions(+) diff --git a/channels/tsmf/client/tsmf_constants.h b/channels/tsmf/client/tsmf_constants.h index 107372992..4e3a666a5 100644 --- a/channels/tsmf/client/tsmf_constants.h +++ b/channels/tsmf/client/tsmf_constants.h @@ -67,6 +67,7 @@ #define NOTIFY_PREROLL 0x00000113 #define UPDATE_GEOMETRY_INFO 0x00000114 #define REMOVE_STREAM 0x00000115 +#define SET_SOURCE_VIDEO_RECT 0x00000116 /* Supported platform */ #define MMREDIR_CAPABILITY_PLATFORM_MF 0x00000001 diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 11bd7a03e..3ca998fb6 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -230,6 +230,47 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) return status; } +float tsmf_stream_read_float(wStream* s) +{ + float fValue; + UINT32 iValue; + + Stream_Read_UINT32(s, iValue); + CopyMemory(&fValue, &iValue, 4); + + return fValue; +} + +int tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman) +{ + int status = 0; + float Left, Top; + float Right, Bottom; + TSMF_PRESENTATION* presentation; + + DEBUG_DVC(""); + + presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); + Stream_Seek(ifman->input, 16); + + if (!presentation) + { + status = 1; + } + else + { + Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */ + Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */ + Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */ + Bottom = tsmf_stream_read_float(ifman->input); /* Bottom (4 bytes) */ + + DEBUG_DVC("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f", + Left, Top, Right, Bottom); + } + + return status; +} + int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; diff --git a/channels/tsmf/client/tsmf_ifman.h b/channels/tsmf/client/tsmf_ifman.h index 8d3fbc2a5..56ae4c5e7 100644 --- a/channels/tsmf/client/tsmf_ifman.h +++ b/channels/tsmf/client/tsmf_ifman.h @@ -45,6 +45,7 @@ int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman); int tsmf_ifman_add_stream(TSMF_IFMAN* ifman); int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman); int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman); +int tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman); int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman); int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman); int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman); diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index a479c42df..e449e5935 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -213,6 +213,10 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, status = tsmf_ifman_remove_stream(&ifman); break; + case SET_SOURCE_VIDEO_RECT: + status = tsmf_ifman_set_source_video_rect(&ifman); + break; + case SHUTDOWN_PRESENTATION_REQ: status = tsmf_ifman_shutdown_presentation(&ifman); break; From b4151bff2fc7072da164beaef79771c22dfe6897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 10 May 2013 17:51:09 -0400 Subject: [PATCH 103/144] xfreerdp: fix building with Xi --- client/X11/xf_input.c | 27 +++++++++++++-------------- client/X11/xf_input.h | 3 ++- client/X11/xf_window.c | 3 ++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 2b81bfe99..27214855b 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -203,10 +203,6 @@ void xf_input_detect_pinch(xfInfo* xfi) } } -#endif - -#ifdef WITH_XI - void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event) { int i; @@ -266,11 +262,8 @@ void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) } } -#endif - int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) { -#ifdef WITH_XI XGenericEventCookie* cookie = &event->xcookie; XGetEventData(xfi->display, cookie); @@ -304,12 +297,10 @@ int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) } XFreeEventData(xfi->display,cookie); -#endif + return 0; } -#ifdef WITH_XI - int xf_input_touch_begin_remote(xfInfo* xfi, XIDeviceEvent* event) { return 0; @@ -325,11 +316,8 @@ int xf_input_touch_end_remote(xfInfo* xfi, XIDeviceEvent* event) return 0; } -#endif - int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) { -#ifdef WITH_XI XGenericEventCookie* cookie = &event->xcookie; XGetEventData(xfi->display, cookie); @@ -356,10 +344,19 @@ int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) } XFreeEventData(xfi->display,cookie); -#endif + return 0; } +#else + +int xf_input_init(xfInfo* xfi, Window window) +{ + return 0; +} + +#endif + void xf_process_rdpei_event(xfInfo* xfi, wMessage* event) { switch (GetMessageType(event->id)) @@ -377,6 +374,7 @@ void xf_process_rdpei_event(xfInfo* xfi, wMessage* event) int xf_input_handle_event(xfInfo* xfi, XEvent* event) { +#ifdef WITH_XI if (xfi->settings->MultiTouchInput) { return xf_input_handle_event_remote(xfi, event); @@ -384,6 +382,7 @@ int xf_input_handle_event(xfInfo* xfi, XEvent* event) if (xfi->enableScaling) return xf_input_handle_event_local(xfi, event); +#endif return 0; } diff --git a/client/X11/xf_input.h b/client/X11/xf_input.h index 85428ae6c..9803193bd 100644 --- a/client/X11/xf_input.h +++ b/client/X11/xf_input.h @@ -27,7 +27,8 @@ #include <X11/extensions/XInput2.h> #endif -int xf_input_init(xfInfo* xfi, Window win); +int xf_input_init(xfInfo* xfi, Window window); + int xf_input_handle_event(xfInfo* xfi, XEvent* event); void xf_process_rdpei_event(xfInfo* xfi, wMessage* event); diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 79427f5b0..780125455 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -44,9 +44,10 @@ #ifdef WITH_XI #include <X11/extensions/XInput2.h> -#include "xf_input.h" #endif +#include "xf_input.h" + #ifdef WITH_DEBUG_X11 #define DEBUG_X11(fmt, ...) DEBUG_CLASS(X11, fmt, ## __VA_ARGS__) #else From 268004d0c9d284472d41d5b9f4e1814a2264917b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 13:42:53 -0400 Subject: [PATCH 104/144] libfreerdp-core: start implementing server-side alternate secondary drawing orders --- libfreerdp/core/orders.c | 54 ++++++++++++++++++++++++++++++++++++ libfreerdp/core/orders.h | 2 ++ libfreerdp/core/update.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 4f3996a87..945944e27 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2048,6 +2048,7 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM if (Stream_GetRemainingLength(s) < 6) return FALSE; + Stream_Read_UINT16(s, flags); /* flags (2 bytes) */ create_offscreen_bitmap->id = flags & 0x7FFF; deleteListPresent = (flags & 0x8000) ? TRUE : FALSE; @@ -2056,11 +2057,14 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM Stream_Read_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ deleteList = &(create_offscreen_bitmap->deleteList); + if (deleteListPresent) { int i; + if (Stream_GetRemainingLength(s) < 2) return FALSE; + Stream_Read_UINT16(s, deleteList->cIndices); if (deleteList->cIndices > deleteList->sIndices) @@ -2081,6 +2085,44 @@ BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITM { deleteList->cIndices = 0; } + + return TRUE; +} + +BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) +{ + UINT16 flags; + BOOL deleteListPresent; + OFFSCREEN_DELETE_LIST* deleteList; + + deleteList = &(create_offscreen_bitmap->deleteList); + + Stream_EnsureRemainingCapacity(s, 8 + deleteList->cIndices * 2); + + flags = create_offscreen_bitmap->id & 0x7FFF; + + deleteListPresent = (deleteList->cIndices > 0) ? TRUE : FALSE; + + if (deleteListPresent) + flags |= 0x8000; + + Stream_Write_UINT16(s, flags); /* flags (2 bytes) */ + + Stream_Write_UINT16(s, create_offscreen_bitmap->cx); /* cx (2 bytes) */ + Stream_Write_UINT16(s, create_offscreen_bitmap->cy); /* cy (2 bytes) */ + + if (deleteListPresent) + { + int i; + + Stream_Write_UINT16(s, deleteList->cIndices); + + for (i = 0; i < (int) deleteList->cIndices; i++) + { + Stream_Write_UINT16(s, deleteList->indices[i]); + } + } + return TRUE; } @@ -2088,7 +2130,18 @@ BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_s { if (Stream_GetRemainingLength(s) < 2) return FALSE; + Stream_Read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ + + return TRUE; +} + +BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface) +{ + Stream_EnsureRemainingCapacity(s, 2); + + Stream_Write_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ + return TRUE; } @@ -2098,6 +2151,7 @@ BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITM if (Stream_GetRemainingLength(s) < 19) return FALSE; + Stream_Read_UINT8(s, create_nine_grid_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ Stream_Read_UINT16(s, create_nine_grid_bitmap->bitmapId); /* bitmapId (2 bytes) */ diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 21db4d74d..29c2ae077 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -234,7 +234,9 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_g BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags); BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); +BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); +BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap); BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker); BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index b5e9a08ea..ec634a257 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -953,6 +953,64 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER update->numberOrders++; } +static void update_send_create_offscreen_bitmap_order(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) +{ + wStream* s; + int bm, em; + BYTE orderType; + BYTE controlFlags; + int headerLength; + rdpUpdate* update = context->update; + + headerLength = 1; + orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP; + controlFlags = ORDER_SECONDARY | (orderType << 2); + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_create_offscreen_bitmap_order(s, create_offscreen_bitmap); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + +static void update_send_switch_surface_order(rdpContext* context, SWITCH_SURFACE_ORDER* switch_surface) +{ + wStream* s; + int bm, em; + BYTE orderType; + BYTE controlFlags; + int headerLength; + rdpUpdate* update = context->update; + + headerLength = 1; + orderType = ORDER_TYPE_SWITCH_SURFACE; + controlFlags = ORDER_SECONDARY | (orderType << 2); + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_switch_surface_order(s, switch_surface); + em = Stream_GetPosition(s); + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + static void update_send_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_system) { wStream* s; @@ -1090,6 +1148,8 @@ void update_register_server_callbacks(rdpUpdate* update) update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; update->secondary->CacheGlyph = update_send_cache_glyph; update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; + update->altsec->CreateOffscreenBitmap = update_send_create_offscreen_bitmap_order; + update->altsec->SwitchSurface = update_send_switch_surface_order; update->pointer->PointerSystem = update_send_pointer_system; update->pointer->PointerColor = update_send_pointer_color; update->pointer->PointerNew = update_send_pointer_new; From c9ebd98e00f74fed37420e2e320dae618e0f7b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 17:46:13 -0400 Subject: [PATCH 105/144] libfreerdp-core: stub and implement many new server-side graphical orders --- libfreerdp/core/orders.c | 505 ++++++++++++++++++++++++++++++++++----- libfreerdp/core/orders.h | 33 ++- libfreerdp/core/update.c | 202 ++++++++++++++++ 3 files changed, 684 insertions(+), 56 deletions(-) diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 945944e27..d87996f8a 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -149,11 +149,29 @@ static const BYTE CBR23_BPP[] = 0, 0, 0, 8, 16, 24, 32 }; +static const BYTE BPP_CBR23[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0 +}; + static const BYTE BMF_BPP[] = { 0, 1, 0, 8, 16, 24, 32 }; +static const BYTE BPP_BMF[] = +{ + 0, 1, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0 +}; + static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta) { INT8 lsi8; @@ -252,6 +270,18 @@ static INLINE void update_read_color_quad(wStream* s, UINT32* color) Stream_Seek_UINT8(s); } +static INLINE void update_write_color_quad(wStream* s, UINT32 color) +{ + BYTE byte; + + byte = (color << 16) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = (color << 8) & 0xFF; + Stream_Write_UINT8(s, byte); + byte = color & 0xFF; + Stream_Write_UINT8(s, byte); +} + static INLINE BOOL update_read_2byte_unsigned(wStream* s, UINT32* value) { BYTE byte; @@ -794,6 +824,30 @@ BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* d return TRUE; } +BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt) +{ + orderInfo->fieldFlags = 0; + + Stream_EnsureRemainingCapacity(s, 64); + + orderInfo->fieldFlags |= ORDER_FIELD_01; + update_write_coord(s, dstblt->nLeftRect); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, dstblt->nTopRect); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, dstblt->nWidth); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, dstblt->nHeight); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + Stream_Write_UINT8(s, dstblt->bRop); + + return TRUE; +} + BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt) { ORDER_FIELD_COORD(1, patblt->nLeftRect); @@ -967,6 +1021,11 @@ BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NI return TRUE; } +BOOL update_write_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid) +{ + return TRUE; +} + BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt) { ORDER_FIELD_COORD(1, multi_dstblt->nLeftRect); @@ -986,6 +1045,11 @@ BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DST return TRUE; } +BOOL update_write_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt) +{ + return TRUE; +} + BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt) { ORDER_FIELD_COORD(1, multi_patblt->nLeftRect); @@ -1012,6 +1076,11 @@ BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PAT return TRUE; } +BOOL update_write_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt) +{ + return TRUE; +} + BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt) { ORDER_FIELD_COORD(1, multi_scrblt->nLeftRect); @@ -1033,6 +1102,11 @@ BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCR return TRUE; } +BOOL update_write_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt) +{ + return TRUE; +} + BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { BYTE byte; @@ -1078,6 +1152,10 @@ BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULT return TRUE; } +BOOL update_write_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) +{ + return TRUE; +} BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid) { @@ -1095,6 +1173,11 @@ BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, M return TRUE; } +BOOL update_write_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid) +{ + return TRUE; +} + BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to) { ORDER_FIELD_UINT16(1, line_to->backMode); @@ -1110,6 +1193,45 @@ BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* return TRUE; } +BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to) +{ + Stream_EnsureRemainingCapacity(s, 32); + + orderInfo->fieldFlags = 0; + + orderInfo->fieldFlags |= ORDER_FIELD_01; + Stream_Write_UINT16(s, line_to->backMode); + + orderInfo->fieldFlags |= ORDER_FIELD_02; + update_write_coord(s, line_to->nXStart); + + orderInfo->fieldFlags |= ORDER_FIELD_03; + update_write_coord(s, line_to->nYStart); + + orderInfo->fieldFlags |= ORDER_FIELD_04; + update_write_coord(s, line_to->nXEnd); + + orderInfo->fieldFlags |= ORDER_FIELD_05; + update_write_coord(s, line_to->nYEnd); + + orderInfo->fieldFlags |= ORDER_FIELD_06; + update_write_color(s, line_to->backColor); + + orderInfo->fieldFlags |= ORDER_FIELD_07; + Stream_Write_UINT8(s, line_to->bRop2); + + orderInfo->fieldFlags |= ORDER_FIELD_08; + Stream_Write_UINT8(s, line_to->penStyle); + + orderInfo->fieldFlags |= ORDER_FIELD_09; + Stream_Write_UINT8(s, line_to->penWidth); + + orderInfo->fieldFlags |= ORDER_FIELD_10; + update_write_color(s, line_to->penColor); + + return TRUE; +} + BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline) { UINT16 word; @@ -1138,6 +1260,11 @@ BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDE return TRUE; } +BOOL update_write_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline) +{ + return TRUE; +} + BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt) { ORDER_FIELD_UINT16(1, memblt->cacheId); @@ -1216,6 +1343,11 @@ BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* return TRUE; } +BOOL update_write_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt) +{ + return TRUE; +} + BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap) { ORDER_FIELD_UINT32(1, save_bitmap->savedBitmapPosition); @@ -1227,6 +1359,11 @@ BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMA return TRUE; } +BOOL update_write_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap) +{ + return TRUE; +} + BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index) { ORDER_FIELD_BYTE(1, glyph_index->cacheId); @@ -1366,6 +1503,11 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ return TRUE; } +BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index) +{ + return TRUE; +} + BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph) { BYTE* phold; @@ -1429,6 +1571,11 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ return TRUE; } +BOOL update_write_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph) +{ + return TRUE; +} + BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc) { ORDER_FIELD_COORD(1, polygon_sc->xStart); @@ -1454,6 +1601,11 @@ BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ return TRUE; } +BOOL update_write_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc) +{ + return TRUE; +} + BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb) { ORDER_FIELD_COORD(1, polygon_cb->xStart); @@ -1488,6 +1640,11 @@ BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ return TRUE; } +BOOL update_write_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb) +{ + return TRUE; +} + BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc) { ORDER_FIELD_COORD(1, ellipse_sc->leftRect); @@ -1500,6 +1657,11 @@ BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ return TRUE; } +BOOL update_write_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc) +{ + return TRUE; +} + BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb) { ORDER_FIELD_COORD(1, ellipse_cb->leftRect); @@ -1513,50 +1675,91 @@ BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ return update_read_brush(s, &ellipse_cb->brush, orderInfo->fieldFlags >> 8); } +BOOL update_write_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb) +{ + return TRUE; +} + /* Secondary Drawing Orders */ -BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags) +BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16 flags) { if (Stream_GetRemainingLength(s) < 9) return FALSE; - Stream_Read_UINT8(s, cache_bitmap_order->cacheId); /* cacheId (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap->cacheId); /* cacheId (1 byte) */ Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ - Stream_Read_UINT8(s, cache_bitmap_order->bitmapWidth); /* bitmapWidth (1 byte) */ - Stream_Read_UINT8(s, cache_bitmap_order->bitmapHeight); /* bitmapHeight (1 byte) */ - Stream_Read_UINT8(s, cache_bitmap_order->bitmapBpp); /* bitmapBpp (1 byte) */ - Stream_Read_UINT16(s, cache_bitmap_order->bitmapLength); /* bitmapLength (2 bytes) */ - Stream_Read_UINT16(s, cache_bitmap_order->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT8(s, cache_bitmap->bitmapWidth); /* bitmapWidth (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap->bitmapHeight); /* bitmapHeight (1 byte) */ + Stream_Read_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ + Stream_Read_UINT16(s, cache_bitmap->bitmapLength); /* bitmapLength (2 bytes) */ + Stream_Read_UINT16(s, cache_bitmap->cacheIndex); /* cacheIndex (2 bytes) */ if (compressed) { if ((flags & NO_BITMAP_COMPRESSION_HDR) == 0) { - BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap_order->bitmapComprHdr); + BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap->bitmapComprHdr); if (Stream_GetRemainingLength(s) < 8) return FALSE; Stream_Read(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ - cache_bitmap_order->bitmapLength -= 8; + cache_bitmap->bitmapLength -= 8; } - if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap->bitmapLength) return FALSE; - Stream_GetPointer(s, cache_bitmap_order->bitmapDataStream); - Stream_Seek(s, cache_bitmap_order->bitmapLength); + Stream_GetPointer(s, cache_bitmap->bitmapDataStream); + Stream_Seek(s, cache_bitmap->bitmapLength); } else { - if (Stream_GetRemainingLength(s) < cache_bitmap_order->bitmapLength) + if (Stream_GetRemainingLength(s) < cache_bitmap->bitmapLength) return FALSE; - Stream_GetPointer(s, cache_bitmap_order->bitmapDataStream); - Stream_Seek(s, cache_bitmap_order->bitmapLength); /* bitmapDataStream */ + Stream_GetPointer(s, cache_bitmap->bitmapDataStream); + Stream_Seek(s, cache_bitmap->bitmapLength); /* bitmapDataStream */ } - cache_bitmap_order->compressed = compressed; + cache_bitmap->compressed = compressed; + + return TRUE; +} + +BOOL update_write_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap, BOOL compressed, UINT16* flags) +{ + *flags = NO_BITMAP_COMPRESSION_HDR; + + Stream_EnsureRemainingCapacity(s, 64 + cache_bitmap->bitmapLength); + + if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0) + cache_bitmap->bitmapLength += 8; + + Stream_Write_UINT8(s, cache_bitmap->cacheId); /* cacheId (1 byte) */ + Stream_Write_UINT8(s, 0); /* pad1Octet (1 byte) */ + Stream_Write_UINT8(s, cache_bitmap->bitmapWidth); /* bitmapWidth (1 byte) */ + Stream_Write_UINT8(s, cache_bitmap->bitmapHeight); /* bitmapHeight (1 byte) */ + Stream_Write_UINT8(s, cache_bitmap->bitmapBpp); /* bitmapBpp (1 byte) */ + Stream_Write_UINT16(s, cache_bitmap->bitmapLength); /* bitmapLength (2 bytes) */ + Stream_Write_UINT16(s, cache_bitmap->cacheIndex); /* cacheIndex (2 bytes) */ + + if (compressed) + { + if ((*flags & NO_BITMAP_COMPRESSION_HDR) == 0) + { + BYTE* bitmapComprHdr = (BYTE*) &(cache_bitmap->bitmapComprHdr); + Stream_Write(s, bitmapComprHdr, 8); /* bitmapComprHdr (8 bytes) */ + cache_bitmap->bitmapLength -= 8; + } + + Stream_Write(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength); + } + else + { + Stream_Write(s, cache_bitmap->bitmapDataStream, cache_bitmap->bitmapLength); + } return TRUE; } @@ -1639,7 +1842,7 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache { BYTE bitsPerPixelId; - Stream_EnsureRemainingCapacity(s, 64); + Stream_EnsureRemainingCapacity(s, 64 + cache_bitmap_v2->bitmapLength); bitsPerPixelId = BPP_CBR2[cache_bitmap_v2->bitmapBpp]; @@ -1696,24 +1899,25 @@ BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache return TRUE; } -BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, BOOL compressed, UINT16 flags) +BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3, UINT16 flags) { BYTE bitsPerPixelId; BITMAP_DATA_EX* bitmapData; - cache_bitmap_v3_order->cacheId = flags & 0x00000003; - cache_bitmap_v3_order->flags = (flags & 0x0000FF80) >> 7; + cache_bitmap_v3->cacheId = flags & 0x00000003; + cache_bitmap_v3->flags = (flags & 0x0000FF80) >> 7; bitsPerPixelId = (flags & 0x00000078) >> 3; - cache_bitmap_v3_order->bpp = CBR23_BPP[bitsPerPixelId]; + cache_bitmap_v3->bpp = CBR23_BPP[bitsPerPixelId]; if (Stream_GetRemainingLength(s) < 21) return FALSE; - Stream_Read_UINT16(s, cache_bitmap_v3_order->cacheIndex); /* cacheIndex (2 bytes) */ - Stream_Read_UINT32(s, cache_bitmap_v3_order->key1); /* key1 (4 bytes) */ - Stream_Read_UINT32(s, cache_bitmap_v3_order->key2); /* key2 (4 bytes) */ - bitmapData = &cache_bitmap_v3_order->bitmapData; + Stream_Read_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */ + Stream_Read_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */ + + bitmapData = &cache_bitmap_v3->bitmapData; Stream_Read_UINT8(s, bitmapData->bpp); Stream_Seek_UINT8(s); /* reserved1 (1 byte) */ @@ -1725,16 +1929,50 @@ BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_ if (Stream_GetRemainingLength(s) < bitmapData->length) return FALSE; + if (bitmapData->data == NULL) bitmapData->data = (BYTE*) malloc(bitmapData->length); else bitmapData->data = (BYTE*) realloc(bitmapData->data, bitmapData->length); Stream_Read(s, bitmapData->data, bitmapData->length); + return TRUE; } -BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags) +BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3, UINT16* flags) +{ + BYTE bitsPerPixelId; + BITMAP_DATA_EX* bitmapData; + + bitmapData = &cache_bitmap_v3->bitmapData; + + Stream_EnsureRemainingCapacity(s, 64 + bitmapData->length); + + bitsPerPixelId = BPP_CBR23[cache_bitmap_v3->bpp]; + + *flags = (cache_bitmap_v3->cacheId & 0x00000003) | + ((cache_bitmap_v3->flags << 7) & 0x0000FF80) | + ((bitsPerPixelId << 3) & 0x00000078); + + Stream_Write_UINT16(s, cache_bitmap_v3->cacheIndex); /* cacheIndex (2 bytes) */ + Stream_Write_UINT32(s, cache_bitmap_v3->key1); /* key1 (4 bytes) */ + Stream_Write_UINT32(s, cache_bitmap_v3->key2); /* key2 (4 bytes) */ + + Stream_Write_UINT8(s, bitmapData->bpp); + Stream_Write_UINT8(s, 0); /* reserved1 (1 byte) */ + Stream_Write_UINT8(s, 0); /* reserved2 (1 byte) */ + Stream_Write_UINT8(s, bitmapData->codecID); /* codecID (1 byte) */ + Stream_Write_UINT16(s, bitmapData->width); /* width (2 bytes) */ + Stream_Write_UINT16(s, bitmapData->height); /* height (2 bytes) */ + Stream_Write_UINT32(s, bitmapData->length); /* length (4 bytes) */ + + Stream_Write(s, bitmapData->data, bitmapData->length); + + return TRUE; +} + +BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16 flags) { int i; UINT32* colorTable; @@ -1742,21 +1980,21 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca if (Stream_GetRemainingLength(s) < 3) return FALSE; - Stream_Read_UINT8(s, cache_color_table_order->cacheIndex); /* cacheIndex (1 byte) */ - Stream_Read_UINT16(s, cache_color_table_order->numberColors); /* numberColors (2 bytes) */ + Stream_Read_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */ + Stream_Read_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */ - if (cache_color_table_order->numberColors != 256) + if (cache_color_table->numberColors != 256) { /* This field MUST be set to 256 */ return FALSE; } - if (Stream_GetRemainingLength(s) < cache_color_table_order->numberColors * 4) + if (Stream_GetRemainingLength(s) < cache_color_table->numberColors * 4) return FALSE; - colorTable = (UINT32*) &cache_color_table_order->colorTable; + colorTable = (UINT32*) &cache_color_table->colorTable; - for (i = 0; i < (int) cache_color_table_order->numberColors; i++) + for (i = 0; i < (int) cache_color_table->numberColors; i++) { update_read_color_quad(s, &colorTable[i]); } @@ -1764,6 +2002,29 @@ BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* ca return TRUE; } +BOOL update_write_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags) +{ + int i; + UINT32* colorTable; + + if (cache_color_table->numberColors != 256) + return FALSE; + + Stream_EnsureRemainingCapacity(s, 16 + (256 * 4)); + + Stream_Write_UINT8(s, cache_color_table->cacheIndex); /* cacheIndex (1 byte) */ + Stream_Write_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */ + + colorTable = (UINT32*) &cache_color_table->colorTable; + + for (i = 0; i < (int) cache_color_table->numberColors; i++) + { + update_write_color_quad(s, colorTable[i]); + } + + return TRUE; +} + BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags) { int i; @@ -1960,10 +2221,16 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp) } } } + return TRUE; } -BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags) +BOOL update_compress_brush(wStream* s, BYTE* input, BYTE bpp) +{ + return FALSE; +} + +BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, UINT16 flags) { int i; int size; @@ -1973,25 +2240,25 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or if (Stream_GetRemainingLength(s) < 6) return FALSE; - Stream_Read_UINT8(s, cache_brush_order->index); /* cacheEntry (1 byte) */ + Stream_Read_UINT8(s, cache_brush->index); /* cacheEntry (1 byte) */ Stream_Read_UINT8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */ - cache_brush_order->bpp = BMF_BPP[iBitmapFormat]; + cache_brush->bpp = BMF_BPP[iBitmapFormat]; - Stream_Read_UINT8(s, cache_brush_order->cx); /* cx (1 byte) */ - Stream_Read_UINT8(s, cache_brush_order->cy); /* cy (1 byte) */ - Stream_Read_UINT8(s, cache_brush_order->style); /* style (1 byte) */ - Stream_Read_UINT8(s, cache_brush_order->length); /* iBytes (1 byte) */ + Stream_Read_UINT8(s, cache_brush->cx); /* cx (1 byte) */ + Stream_Read_UINT8(s, cache_brush->cy); /* cy (1 byte) */ + Stream_Read_UINT8(s, cache_brush->style); /* style (1 byte) */ + Stream_Read_UINT8(s, cache_brush->length); /* iBytes (1 byte) */ - if ((cache_brush_order->cx == 8) && (cache_brush_order->cy == 8)) + if ((cache_brush->cx == 8) && (cache_brush->cy == 8)) { - size = (cache_brush_order->bpp == 1) ? 8 : 8 * 8 * cache_brush_order->bpp; + size = (cache_brush->bpp == 1) ? 8 : 8 * 8 * cache_brush->bpp; - if (cache_brush_order->bpp == 1) + if (cache_brush->bpp == 1) { - if (cache_brush_order->length != 8) + if (cache_brush->length != 8) { - fprintf(stderr, "incompatible 1bpp brush of length:%d\n", cache_brush_order->length); + fprintf(stderr, "incompatible 1bpp brush of length:%d\n", cache_brush->length); return TRUE; // should be FALSE ? } @@ -2001,35 +2268,102 @@ BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_or for (i = 7; i >= 0; i--) { - Stream_Read_UINT8(s, cache_brush_order->data[i]); + Stream_Read_UINT8(s, cache_brush->data[i]); } } else { - if ((iBitmapFormat == BMF_8BPP) && (cache_brush_order->length == 20)) + if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20)) compressed = TRUE; - else if ((iBitmapFormat == BMF_16BPP) && (cache_brush_order->length == 24)) + else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24)) compressed = TRUE; - else if ((iBitmapFormat == BMF_32BPP) && (cache_brush_order->length == 32)) + else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32)) compressed = TRUE; if (compressed != FALSE) { /* compressed brush */ - if (!update_decompress_brush(s, cache_brush_order->data, cache_brush_order->bpp)) + if (!update_decompress_brush(s, cache_brush->data, cache_brush->bpp)) return FALSE; } else { /* uncompressed brush */ - int scanline = (cache_brush_order->bpp / 8) * 8; + int scanline = (cache_brush->bpp / 8) * 8; if (Stream_GetRemainingLength(s) < scanline * 8) return FALSE; for (i = 7; i >= 0; i--) { - Stream_Read(s, &cache_brush_order->data[i * scanline], scanline); + Stream_Read(s, &cache_brush->data[i * scanline], scanline); + } + } + } + } + + return TRUE; +} + +BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush, UINT16* flags) +{ + int i; + int size; + BYTE iBitmapFormat; + BOOL compressed = FALSE; + + Stream_EnsureRemainingCapacity(s, 64); + + iBitmapFormat = BPP_BMF[cache_brush->bpp]; + + Stream_Write_UINT8(s, cache_brush->index); /* cacheEntry (1 byte) */ + Stream_Write_UINT8(s, iBitmapFormat); /* iBitmapFormat (1 byte) */ + + Stream_Write_UINT8(s, cache_brush->cx); /* cx (1 byte) */ + Stream_Write_UINT8(s, cache_brush->cy); /* cy (1 byte) */ + Stream_Write_UINT8(s, cache_brush->style); /* style (1 byte) */ + Stream_Write_UINT8(s, cache_brush->length); /* iBytes (1 byte) */ + + if ((cache_brush->cx == 8) && (cache_brush->cy == 8)) + { + size = (cache_brush->bpp == 1) ? 8 : 8 * 8 * cache_brush->bpp; + + if (cache_brush->bpp == 1) + { + if (cache_brush->length != 8) + { + fprintf(stderr, "incompatible 1bpp brush of length:%d\n", cache_brush->length); + return FALSE; + } + + for (i = 7; i >= 0; i--) + { + Stream_Write_UINT8(s, cache_brush->data[i]); + } + } + else + { + if ((iBitmapFormat == BMF_8BPP) && (cache_brush->length == 20)) + compressed = TRUE; + else if ((iBitmapFormat == BMF_16BPP) && (cache_brush->length == 24)) + compressed = TRUE; + else if ((iBitmapFormat == BMF_32BPP) && (cache_brush->length == 32)) + compressed = TRUE; + + if (compressed != FALSE) + { + /* compressed brush */ + if (!update_compress_brush(s, cache_brush->data, cache_brush->bpp)) + return FALSE; + } + else + { + /* uncompressed brush */ + int scanline = (cache_brush->bpp / 8) * 8; + + for (i = 7; i >= 0; i--) + { + Stream_Write(s, &cache_brush->data[i * scanline], scanline); } } } @@ -2173,27 +2507,44 @@ BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker return TRUE; } +BOOL update_write_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker) +{ + return TRUE; +} + BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first) { if (Stream_GetRemainingLength(s) < 10) // 8 + 2 at least return FALSE; + Stream_Read_UINT8(s, stream_bitmap_first->bitmapFlags); /* bitmapFlags (1 byte) */ Stream_Read_UINT8(s, stream_bitmap_first->bitmapBpp); /* bitmapBpp (1 byte) */ Stream_Read_UINT16(s, stream_bitmap_first->bitmapType); /* bitmapType (2 bytes) */ Stream_Read_UINT16(s, stream_bitmap_first->bitmapWidth); /* bitmapWidth (2 bytes) */ Stream_Read_UINT16(s, stream_bitmap_first->bitmapHeight); /* bitmapHeigth (2 bytes) */ - if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2) { + if (stream_bitmap_first->bitmapFlags & STREAM_BITMAP_V2) + { if (Stream_GetRemainingLength(s) < 4) return FALSE; + Stream_Read_UINT32(s, stream_bitmap_first->bitmapSize); /* bitmapSize (4 bytes) */ - } else { + } + else + { if (Stream_GetRemainingLength(s) < 2) return FALSE; + Stream_Read_UINT16(s, stream_bitmap_first->bitmapSize); /* bitmapSize (2 bytes) */ } FIELD_SKIP_BUFFER16(s, stream_bitmap_first->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */ + + return TRUE; +} + +BOOL update_write_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first) +{ return TRUE; } @@ -2201,9 +2552,16 @@ BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* { if (Stream_GetRemainingLength(s) < 5) return FALSE; + Stream_Read_UINT8(s, stream_bitmap_next->bitmapFlags); /* bitmapFlags (1 byte) */ Stream_Read_UINT16(s, stream_bitmap_next->bitmapType); /* bitmapType (2 bytes) */ FIELD_SKIP_BUFFER16(s, stream_bitmap_next->bitmapBlockSize); /* bitmapBlockSize(2 bytes) + bitmapBlock */ + + return TRUE; +} + +BOOL update_write_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next) +{ return TRUE; } @@ -2211,6 +2569,7 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* { if (Stream_GetRemainingLength(s) < 11) return FALSE; + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_first->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */ @@ -2219,12 +2578,24 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* return Stream_SafeSeek(s, draw_gdiplus_first->cbSize); /* emfRecords */ } +BOOL update_write_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first) +{ + return TRUE; +} + BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next) { if (Stream_GetRemainingLength(s) < 3) return FALSE; + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ FIELD_SKIP_BUFFER16(s, draw_gdiplus_next->cbSize); /* cbSize(2 bytes) + emfRecords */ + + return TRUE; +} + +BOOL update_write_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next) +{ return TRUE; } @@ -2232,6 +2603,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw { if (Stream_GetRemainingLength(s) < 11) return FALSE; + Stream_Seek_UINT8(s); /* pad1Octet (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_end->cbSize); /* cbSize (2 bytes) */ Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */ @@ -2240,10 +2612,16 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw return Stream_SafeSeek(s, draw_gdiplus_end->cbSize); /* emfRecords */ } +BOOL update_write_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end) +{ + return TRUE; +} + BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first) { if (Stream_GetRemainingLength(s) < 11) return FALSE; + Stream_Read_UINT8(s, draw_gdiplus_cache_first->flags); /* flags (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheType); /* cacheType (2 bytes) */ Stream_Read_UINT16(s, draw_gdiplus_cache_first->cacheIndex); /* cacheIndex (2 bytes) */ @@ -2253,22 +2631,34 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */ } +BOOL update_write_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first) +{ + return TRUE; +} + BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next) { if (Stream_GetRemainingLength(s) < 7) return FALSE; + Stream_Read_UINT8(s, draw_gdiplus_cache_next->flags); /* flags (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheType); /* cacheType (2 bytes) */ Stream_Read_UINT16(s, draw_gdiplus_cache_next->cacheIndex); /* cacheIndex (2 bytes) */ FIELD_SKIP_BUFFER16(s, draw_gdiplus_cache_next->cbSize); /* cbSize(2 bytes) + emfRecords */ - return TRUE; + return TRUE; +} + +BOOL update_write_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next) +{ + return TRUE; } BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end) { if (Stream_GetRemainingLength(s) < 11) return FALSE; + Stream_Read_UINT8(s, draw_gdiplus_cache_end->flags); /* flags (1 byte) */ Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheType); /* cacheType (2 bytes) */ Stream_Read_UINT16(s, draw_gdiplus_cache_end->cacheIndex); /* cacheIndex (2 bytes) */ @@ -2278,6 +2668,11 @@ BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */ } +BOOL update_write_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end) +{ + return TRUE; +} + BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes) { int i; @@ -2685,7 +3080,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) break; case ORDER_TYPE_BITMAP_COMPRESSED_V3: - if (!update_read_cache_bitmap_v3_order(s, &(secondary->cache_bitmap_v3_order), TRUE, extraFlags)) + if (!update_read_cache_bitmap_v3_order(s, &(secondary->cache_bitmap_v3_order), extraFlags)) return FALSE; IFCALL(secondary->CacheBitmapV3, context, &(secondary->cache_bitmap_v3_order)); break; diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index 29c2ae077..7860694fa 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -195,6 +195,7 @@ BOOL update_read_bounds(wStream* s, rdpBounds* bounds); BOOL update_write_bounds(wStream* s, ORDER_INFO* orderInfo); BOOL update_read_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt); +BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, DSTBLT_ORDER* dstblt); BOOL update_read_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER* patblt); BOOL update_read_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* scrblt); @@ -202,50 +203,80 @@ BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, SCRBLT_ORDER* BOOL update_read_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, OPAQUE_RECT_ORDER* opaque_rect); BOOL update_read_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid); +BOOL update_write_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, DRAW_NINE_GRID_ORDER* draw_nine_grid); BOOL update_read_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt); +BOOL update_write_multi_dstblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DSTBLT_ORDER* multi_dstblt); BOOL update_read_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt); +BOOL update_write_multi_patblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_PATBLT_ORDER* multi_patblt); BOOL update_read_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt); +BOOL update_write_multi_scrblt_order(wStream* s, ORDER_INFO* orderInfo, MULTI_SCRBLT_ORDER* multi_scrblt); BOOL update_read_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect); +BOOL update_write_multi_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect); BOOL update_read_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid); +BOOL update_write_multi_draw_nine_grid_order(wStream* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid); BOOL update_read_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to); +BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, LINE_TO_ORDER* line_to); BOOL update_read_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline); +BOOL update_write_polyline_order(wStream* s, ORDER_INFO* orderInfo, POLYLINE_ORDER* polyline); BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt); BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* memblt); BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt); +BOOL update_write_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER* mem3blt); BOOL update_read_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap); +BOOL update_write_save_bitmap_order(wStream* s, ORDER_INFO* orderInfo, SAVE_BITMAP_ORDER* save_bitmap); BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index); BOOL update_write_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDEX_ORDER* glyph_index); BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index); +BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ORDER* fast_index); BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph); +BOOL update_write_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph); BOOL update_read_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc); +BOOL update_write_polygon_sc_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_SC_ORDER* polygon_sc); BOOL update_read_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb); +BOOL update_write_polygon_cb_order(wStream* s, ORDER_INFO* orderInfo, POLYGON_CB_ORDER* polygon_cb); BOOL update_read_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc); +BOOL update_write_ellipse_sc_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_SC_ORDER* ellipse_sc); BOOL update_read_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb); +BOOL update_write_ellipse_cb_order(wStream* s, ORDER_INFO* orderInfo, ELLIPSE_CB_ORDER* ellipse_cb); BOOL update_read_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16 flags); +BOOL update_write_cache_bitmap_order(wStream* s, CACHE_BITMAP_ORDER* cache_bitmap_order, BOOL compressed, UINT16* flags); BOOL update_read_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16 flags); BOOL update_write_cache_bitmap_v2_order(wStream* s, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order, BOOL compressed, UINT16* flags); -BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, BOOL compressed, UINT16 flags); +BOOL update_read_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, UINT16 flags); +BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order, UINT16* flags); BOOL update_read_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16 flags); +BOOL update_write_cache_color_table_order(wStream* s, CACHE_COLOR_TABLE_ORDER* cache_color_table_order, UINT16* flags); BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16 flags); BOOL update_write_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_order, UINT16* flags); BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order, UINT16 flags); BOOL update_write_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags); BOOL update_read_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16 flags); +BOOL update_write_cache_brush_order(wStream* s, CACHE_BRUSH_ORDER* cache_brush_order, UINT16* flags); BOOL update_read_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); BOOL update_write_create_offscreen_bitmap_order(wStream* s, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); BOOL update_write_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* switch_surface); BOOL update_read_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap); +BOOL update_write_create_nine_grid_bitmap_order(wStream* s, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap); BOOL update_read_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker); +BOOL update_write_frame_marker_order(wStream* s, FRAME_MARKER_ORDER* frame_marker); BOOL update_read_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first); +BOOL update_write_stream_bitmap_first_order(wStream* s, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first); BOOL update_read_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next); +BOOL update_write_stream_bitmap_next_order(wStream* s, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next); BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first); +BOOL update_write_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first); BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next); +BOOL update_write_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next); BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end); +BOOL update_write_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end); BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first); +BOOL update_write_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first); BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next); +BOOL update_write_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next); BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end); +BOOL update_write_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end); #endif /* __ORDERS_H */ diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index ec634a257..9984791d2 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -733,6 +733,28 @@ static void update_send_desktop_resize(rdpContext* context) rdp_server_reactivate(context->rdp); } +static void update_send_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt) +{ + wStream* s; + int offset; + int headerLength; + ORDER_INFO orderInfo; + rdpUpdate* update = context->update; + + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT); + + s = update->us; + offset = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_dstblt_order(s, &orderInfo, dstblt); + update_write_order_info(context, s, &orderInfo, offset); + + update->numberOrders++; +} + static void update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) { wStream* s; @@ -799,6 +821,28 @@ static void update_send_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaq update->numberOrders++; } +static void update_send_line_to(rdpContext* context, LINE_TO_ORDER* line_to) +{ + wStream* s; + int offset; + int headerLength; + ORDER_INFO orderInfo; + rdpUpdate* update = context->update; + + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO); + + s = update->us; + offset = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_line_to_order(s, &orderInfo, line_to); + update_write_order_info(context, s, &orderInfo, offset); + + update->numberOrders++; +} + static void update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) { wStream* s; @@ -843,6 +887,50 @@ static void update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp update->numberOrders++; } +static void update_send_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitmap) +{ + wStream* s; + int bm, em; + BYTE orderType; + int headerLength; + UINT16 extraFlags; + INT16 orderLength; + rdpUpdate* update = context->update; + + extraFlags = 0; + headerLength = 6; + + orderType = cache_bitmap->compressed ? + ORDER_TYPE_CACHE_BITMAP_COMPRESSED : ORDER_TYPE_BITMAP_UNCOMPRESSED; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_cache_bitmap_order(s, cache_bitmap, cache_bitmap->compressed, &extraFlags); + em = Stream_GetPosition(s); + + orderLength = (em - bm) - 13; + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; + + /** + * temporary workaround to avoid PDUs exceeding maximum size + */ + + update->EndPaint(context); + update->BeginPaint(context); +} + static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2) { wStream* s; @@ -887,6 +975,81 @@ static void update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD update->BeginPaint(context); } +static void update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3) +{ + wStream* s; + int bm, em; + BYTE orderType; + int headerLength; + UINT16 extraFlags; + INT16 orderLength; + rdpUpdate* update = context->update; + + extraFlags = 0; + headerLength = 6; + orderType = ORDER_TYPE_BITMAP_COMPRESSED_V3; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_cache_bitmap_v3_order(s, cache_bitmap_v3, &extraFlags); + em = Stream_GetPosition(s); + + orderLength = (em - bm) - 13; + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; + + /** + * temporary workaround to avoid PDUs exceeding maximum size + */ + + update->EndPaint(context); + update->BeginPaint(context); +} + +static void update_send_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cache_color_table) +{ + wStream* s; + UINT16 flags; + int bm, em; + int headerLength; + INT16 orderLength; + rdpUpdate* update = context->update; + + flags = 0; + headerLength = 6; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_cache_color_table_order(s, cache_color_table, &flags); + em = Stream_GetPosition(s); + + orderLength = (em - bm) - 13; + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, ORDER_TYPE_CACHE_COLOR_TABLE); /* orderType (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + static void update_send_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph) { wStream* s; @@ -953,6 +1116,39 @@ static void update_send_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER update->numberOrders++; } +static void update_send_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush) +{ + wStream* s; + UINT16 flags; + int bm, em; + int headerLength; + INT16 orderLength; + rdpUpdate* update = context->update; + + flags = 0; + headerLength = 6; + + s = update->us; + bm = Stream_GetPosition(s); + + Stream_EnsureRemainingCapacity(s, headerLength); + Stream_Seek(s, headerLength); + + update_write_cache_brush_order(s, cache_brush, &flags); + em = Stream_GetPosition(s); + + orderLength = (em - bm) - 13; + + Stream_SetPosition(s, bm); + Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY | ORDER_TYPE_CHANGE); /* controlFlags (1 byte) */ + Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */ + Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */ + Stream_Write_UINT8(s, ORDER_TYPE_CACHE_BRUSH); /* orderType (1 byte) */ + Stream_SetPosition(s, em); + + update->numberOrders++; +} + static void update_send_create_offscreen_bitmap_order(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) { wStream* s; @@ -1140,14 +1336,20 @@ void update_register_server_callbacks(rdpUpdate* update) update->SurfaceBits = update_send_surface_bits; update->SurfaceFrameMarker = update_send_surface_frame_marker; update->SurfaceCommand = update_send_surface_command; + update->primary->DstBlt = update_send_dstblt; update->primary->PatBlt = update_send_patblt; update->primary->ScrBlt = update_send_scrblt; update->primary->OpaqueRect = update_send_opaque_rect; + update->primary->LineTo = update_send_line_to; update->primary->MemBlt = update_send_memblt; update->primary->GlyphIndex = update_send_glyph_index; + update->secondary->CacheBitmap = update_send_cache_bitmap; update->secondary->CacheBitmapV2 = update_send_cache_bitmap_v2; + update->secondary->CacheBitmapV3 = update_send_cache_bitmap_v3; + update->secondary->CacheColorTable = update_send_cache_color_table; update->secondary->CacheGlyph = update_send_cache_glyph; update->secondary->CacheGlyphV2 = update_send_cache_glyph_v2; + update->secondary->CacheBrush = update_send_cache_brush; update->altsec->CreateOffscreenBitmap = update_send_create_offscreen_bitmap_order; update->altsec->SwitchSurface = update_send_switch_surface_order; update->pointer->PointerSystem = update_send_pointer_system; From b18ffa2c889f83c65be14f4f92f2879d7db651bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 19:08:08 -0400 Subject: [PATCH 106/144] libfreerdp-client: internal channels code cleanup --- channels/client/channels.c | 163 +++++++++++++++++++------------------ 1 file changed, 84 insertions(+), 79 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index a9ef88907..c35a8f7b0 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -67,15 +67,15 @@ * from the main thread. */ -struct rdp_library_data +struct rdp_channel_client_data { PVIRTUALCHANNELENTRY entry; /* the one and only exported function */ PCHANNEL_INIT_EVENT_FN init_event_proc; void* init_handle; }; -typedef struct rdp_library_data rdpLibraryData; +typedef struct rdp_channel_client_data CHANNEL_CLIENT_DATA; -struct rdp_channel_data +struct rdp_channel_open_data { char name[CHANNEL_NAME_LEN + 1]; int open_handle; @@ -83,7 +83,7 @@ struct rdp_channel_data int flags; /* 0 nothing 1 init 2 open */ PCHANNEL_OPEN_EVENT_FN open_event_proc; }; -typedef struct rdp_channel_data rdpChannelData; +typedef struct rdp_channel_open_data CHANNEL_OPEN_DATA; struct _CHANNEL_OPEN_EVENT { @@ -94,12 +94,17 @@ struct _CHANNEL_OPEN_EVENT }; typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT; -typedef struct rdp_init_handle rdpInitHandle; +/** + * pInitHandle: handle that identifies the client connection + * Obtained by the client with VirtualChannelInit + * Used by the client with VirtualChannelOpen + */ -struct rdp_init_handle +struct rdp_channel_init_data { rdpChannels* channels; }; +typedef struct rdp_channel_init_data CHANNEL_INIT_DATA; struct rdp_channels { @@ -112,14 +117,14 @@ struct rdp_channels * ie, no two threads can access index 0, ... */ - int libraryDataCount; - rdpLibraryData libraryDataList[CHANNEL_MAX_COUNT]; + int clientDataCount; + CHANNEL_CLIENT_DATA clientDataList[CHANNEL_MAX_COUNT]; - int channelDataCount; - rdpChannelData channelDataList[CHANNEL_MAX_COUNT]; + int openDataCount; + CHANNEL_OPEN_DATA openDataList[CHANNEL_MAX_COUNT]; - int initHandleCount; - rdpInitHandle initHandleList[CHANNEL_MAX_COUNT]; + int initDataCount; + CHANNEL_INIT_DATA initDataList[CHANNEL_MAX_COUNT]; /* control for entry into MyVirtualChannelInit */ int can_call_init; @@ -161,9 +166,9 @@ static rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* p while (channels) { - for (j = 0; j < channels->channelDataCount; j++) + for (j = 0; j < channels->openDataCount; j++) { - if (channels->channelDataList[j].open_handle == open_handle) + if (channels->openDataList[j].open_handle == open_handle) { *pindex = j; found = TRUE; @@ -210,14 +215,14 @@ static rdpChannels* freerdp_channels_find_by_instance(freerdp* instance) } /* returns rdpChannelData for the channel name passed in */ -static rdpChannelData* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex) +static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex) { int index; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* lchannel_data; - for (index = 0; index < channels->channelDataCount; index++) + for (index = 0; index < channels->openDataCount; index++) { - lchannel_data = &channels->channelDataList[index]; + lchannel_data = &channels->openDataList[index]; if (strcmp(channel_name, lchannel_data->name) == 0) { @@ -293,9 +298,9 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF int index; rdpChannel* channel; rdpChannels* channels; - rdpLibraryData* llib; - PCHANNEL_DEF lchannel_def; - rdpChannelData* lchannel_data; + PCHANNEL_DEF pChannelDef; + CHANNEL_OPEN_DATA* pChannelOpenData; + CHANNEL_CLIENT_DATA* pChannelClientData; if (!ppInitHandle) { @@ -305,10 +310,10 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF channels = g_init_channels; - channels->initHandleList[channels->initHandleCount].channels = channels; - *ppInitHandle = &channels->initHandleList[channels->initHandleCount]; + channels->initDataList[channels->initDataCount].channels = channels; + *ppInitHandle = &channels->initDataList[channels->initDataCount]; - channels->initHandleCount++; + channels->initDataCount++; DEBUG_CHANNELS("enter"); @@ -318,7 +323,7 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; } - if (channels->channelDataCount + channelCount >= CHANNEL_MAX_COUNT) + if (channels->openDataCount + channelCount >= CHANNEL_MAX_COUNT) { DEBUG_CHANNELS("error too many channels"); return CHANNEL_RC_TOO_MANY_CHANNELS; @@ -343,36 +348,36 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF for (index = 0; index < channelCount; index++) { - lchannel_def = &pChannel[index]; + pChannelDef = &pChannel[index]; - if (freerdp_channels_find_channel_data_by_name(channels, lchannel_def->name, 0) != 0) + if (freerdp_channels_find_channel_data_by_name(channels, pChannelDef->name, 0) != 0) { DEBUG_CHANNELS("error channel already used"); return CHANNEL_RC_BAD_CHANNEL; } } - llib = &channels->libraryDataList[channels->libraryDataCount]; - llib->init_event_proc = pChannelInitEventProc; - llib->init_handle = *ppInitHandle; - channels->libraryDataCount++; + pChannelClientData = &channels->clientDataList[channels->clientDataCount]; + pChannelClientData->init_event_proc = pChannelInitEventProc; + pChannelClientData->init_handle = *ppInitHandle; + channels->clientDataCount++; for (index = 0; index < channelCount; index++) { - lchannel_def = &pChannel[index]; - lchannel_data = &channels->channelDataList[channels->channelDataCount]; + pChannelDef = &pChannel[index]; + pChannelOpenData = &channels->openDataList[channels->openDataCount]; - lchannel_data->open_handle = g_open_handle_sequence++; + pChannelOpenData->open_handle = g_open_handle_sequence++; - lchannel_data->flags = 1; /* init */ - strncpy(lchannel_data->name, lchannel_def->name, CHANNEL_NAME_LEN); - lchannel_data->options = lchannel_def->options; + pChannelOpenData->flags = 1; /* init */ + strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); + pChannelOpenData->options = pChannelDef->options; if (channels->settings->ChannelCount < 16) { channel = channels->settings->ChannelDefArray + channels->settings->ChannelCount; - strncpy(channel->Name, lchannel_def->name, 7); - channel->options = lchannel_def->options; + strncpy(channel->Name, pChannelDef->name, 7); + channel->options = pChannelDef->options; channels->settings->ChannelCount++; } else @@ -380,7 +385,7 @@ static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF DEBUG_CHANNELS("warning more than 16 channels"); } - channels->channelDataCount++; + channels->openDataCount++; } return CHANNEL_RC_OK; @@ -395,11 +400,11 @@ static UINT32 FREERDP_CC MyVirtualChannelOpen(void* pInitHandle, UINT32* pOpenHa { int index; rdpChannels* channels; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; DEBUG_CHANNELS("enter"); - channels = ((rdpInitHandle*) pInitHandle)->channels; + channels = ((CHANNEL_INIT_DATA*) pInitHandle)->channels; if (!pOpenHandle) { @@ -419,23 +424,23 @@ static UINT32 FREERDP_CC MyVirtualChannelOpen(void* pInitHandle, UINT32* pOpenHa return CHANNEL_RC_NOT_CONNECTED; } - lchannel_data = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index); + pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index); - if (!lchannel_data) + if (!pChannelOpenData) { DEBUG_CHANNELS("error channel name"); return CHANNEL_RC_UNKNOWN_CHANNEL_NAME; } - if (lchannel_data->flags == 2) + if (pChannelOpenData->flags == 2) { DEBUG_CHANNELS("error channel already open"); return CHANNEL_RC_ALREADY_OPEN; } - lchannel_data->flags = 2; /* open */ - lchannel_data->open_event_proc = pChannelOpenEventProc; - *pOpenHandle = lchannel_data->open_handle; + pChannelOpenData->flags = 2; /* open */ + pChannelOpenData->open_event_proc = pChannelOpenEventProc; + *pOpenHandle = pChannelOpenData->open_handle; return CHANNEL_RC_OK; } @@ -448,7 +453,7 @@ static UINT32 FREERDP_CC MyVirtualChannelClose(UINT32 openHandle) { int index; rdpChannels* channels; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; DEBUG_CHANNELS("enter"); @@ -460,15 +465,15 @@ static UINT32 FREERDP_CC MyVirtualChannelClose(UINT32 openHandle) return CHANNEL_RC_BAD_CHANNEL_HANDLE; } - lchannel_data = &channels->channelDataList[index]; + pChannelOpenData = &channels->openDataList[index]; - if (lchannel_data->flags != 2) + if (pChannelOpenData->flags != 2) { DEBUG_CHANNELS("error not open"); return CHANNEL_RC_NOT_OPEN; } - lchannel_data->flags = 0; + pChannelOpenData->flags = 0; return CHANNEL_RC_OK; } @@ -477,9 +482,9 @@ static UINT32 FREERDP_CC MyVirtualChannelClose(UINT32 openHandle) static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData) { int index; - CHANNEL_OPEN_EVENT* item; rdpChannels* channels; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_EVENT* item; + CHANNEL_OPEN_DATA* pChannelOpenData; channels = freerdp_channels_find_by_open_handle(openHandle, &index); @@ -507,9 +512,9 @@ static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, U return CHANNEL_RC_ZERO_LENGTH; } - lchannel_data = &channels->channelDataList[index]; + pChannelOpenData = &channels->openDataList[index]; - if (lchannel_data->flags != 2) + if (pChannelOpenData->flags != 2) { DEBUG_CHANNELS("error not open"); return CHANNEL_RC_NOT_OPEN; @@ -536,7 +541,7 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, wMessage* { int index; rdpChannels* channels; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; channels = freerdp_channels_find_by_open_handle(openHandle, &index); @@ -558,9 +563,9 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, wMessage* return CHANNEL_RC_NULL_DATA; } - lchannel_data = &channels->channelDataList[index]; + pChannelOpenData = &channels->openDataList[index]; - if (lchannel_data->flags != 2) + if (pChannelOpenData->flags != 2) { DEBUG_CHANNELS("error not open"); return CHANNEL_RC_NOT_OPEN; @@ -636,17 +641,17 @@ void freerdp_channels_free(rdpChannels* channels) int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, void* entry, void* data) { int status; - rdpLibraryData* lib; CHANNEL_ENTRY_POINTS_EX ep; + CHANNEL_CLIENT_DATA* pChannelClientData; - if (channels->libraryDataCount + 1 >= CHANNEL_MAX_COUNT) + if (channels->clientDataCount + 1 >= CHANNEL_MAX_COUNT) { fprintf(stderr, "error: too many channels\n"); return 1; } - lib = &channels->libraryDataList[channels->libraryDataCount]; - lib->entry = (PVIRTUALCHANNELENTRY) entry; + pChannelClientData = &channels->clientDataList[channels->clientDataCount]; + pChannelClientData->entry = (PVIRTUALCHANNELENTRY) entry; ep.cbSize = sizeof(ep); ep.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000; @@ -665,7 +670,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v WaitForSingleObject(g_mutex_init, INFINITE); g_init_channels = channels; - status = lib->entry((PCHANNEL_ENTRY_POINTS) &ep); + status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); g_init_channels = NULL; ReleaseMutex(g_mutex_init); @@ -711,14 +716,14 @@ int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, c int freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance) { int index; - rdpLibraryData* llib; + CHANNEL_CLIENT_DATA* llib; DEBUG_CHANNELS("enter"); channels->instance = instance; - for (index = 0; index < channels->libraryDataCount; index++) + for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->libraryDataList[index]; + llib = &channels->clientDataList[index]; if (llib->init_event_proc != 0) llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_INITIALIZED, 0, 0); @@ -737,17 +742,17 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) int index; char* hostname; int hostname_len; - rdpLibraryData* llib; + CHANNEL_CLIENT_DATA* llib; channels->is_connected = 1; hostname = instance->settings->ServerHostname; hostname_len = strlen(hostname); - DEBUG_CHANNELS("hostname [%s] channels->num_libs [%d]", hostname, channels->libraryDataCount); + DEBUG_CHANNELS("hostname [%s] channels->num_libs [%d]", hostname, channels->clientDataCount); - for (index = 0; index < channels->libraryDataCount; index++) + for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->libraryDataList[index]; + llib = &channels->clientDataList[index]; if (llib->init_event_proc != 0) llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_CONNECTED, hostname, hostname_len); @@ -757,7 +762,7 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) } /** - * data comming from the server to the client + * data coming from the server to the client * called only from main thread */ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int data_size, int flags, int total_size) @@ -765,7 +770,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat int index; rdpChannel* channel; rdpChannels* channels; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* lchannel_data; channels = freerdp_channels_find_by_instance(instance); @@ -810,7 +815,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve { int index; const char* name = NULL; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* lchannel_data; switch (GetMessageClass(event->id)) { @@ -865,7 +870,7 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan wMessage* event; rdpChannel* channel; CHANNEL_OPEN_EVENT* item; - rdpChannelData* lchannel_data; + CHANNEL_OPEN_DATA* lchannel_data; while (MessageQueue_Peek(channels->MsgPipe->Out, &message, TRUE)) { @@ -879,7 +884,7 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan if (!item) break; - lchannel_data = &channels->channelDataList[item->Index]; + lchannel_data = &channels->openDataList[item->Index]; channel = freerdp_channels_find_channel_by_name(channels, instance->settings, lchannel_data->name, &item->Index); @@ -983,16 +988,16 @@ wMessage* freerdp_channels_pop_event(rdpChannels* channels) void freerdp_channels_close(rdpChannels* channels, freerdp* instance) { int index; - rdpLibraryData* llib; + CHANNEL_CLIENT_DATA* llib; DEBUG_CHANNELS("closing"); channels->is_connected = 0; freerdp_channels_check_fds(channels, instance); /* tell all libraries we are shutting down */ - for (index = 0; index < channels->libraryDataCount; index++) + for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->libraryDataList[index]; + llib = &channels->clientDataList[index]; if (llib->init_event_proc != 0) llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_TERMINATED, 0, 0); From 2f02ad3b68c21256ae6fff23399fe95157fba6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 19:52:24 -0400 Subject: [PATCH 107/144] libfreerdp-client: split channels code into multiple files --- channels/client/CMakeLists.txt | 7 +- channels/client/channels.c | 381 +++++---------------------------- channels/client/channels.h | 115 ++++++++++ channels/client/init.c | 133 ++++++++++++ channels/client/init.h | 28 +++ channels/client/open.c | 99 +++++++++ channels/client/open.h | 30 +++ 7 files changed, 464 insertions(+), 329 deletions(-) create mode 100644 channels/client/channels.h create mode 100644 channels/client/init.c create mode 100644 channels/client/init.h create mode 100644 channels/client/open.c create mode 100644 channels/client/open.h diff --git a/channels/client/CMakeLists.txt b/channels/client/CMakeLists.txt index d1726657d..6aa60777a 100644 --- a/channels/client/CMakeLists.txt +++ b/channels/client/CMakeLists.txt @@ -23,7 +23,12 @@ set(${MODULE_PREFIX}_SRCS tables.h addin.c addin.h - channels.c) + init.c + init.h + open.c + open.h + channels.c + channels.h) list(REMOVE_DUPLICATES CHANNEL_STATIC_CLIENT_ENTRIES) diff --git a/channels/client/channels.c b/channels/client/channels.c index c35a8f7b0..2b646e1bb 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -44,14 +44,10 @@ #include <winpr/collections.h> #include "addin.h" +#include "init.h" +#include "open.h" -#ifdef WITH_DEBUG_CHANNELS -#define DEBUG_CHANNELS(fmt, ...) DEBUG_CLASS(CHANNELS, fmt, ## __VA_ARGS__) -#else -#define DEBUG_CHANNELS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) -#endif - -#define CHANNEL_MAX_COUNT 30 +#include "channels.h" /** * MS compatible plugin interface @@ -67,93 +63,21 @@ * from the main thread. */ -struct rdp_channel_client_data -{ - PVIRTUALCHANNELENTRY entry; /* the one and only exported function */ - PCHANNEL_INIT_EVENT_FN init_event_proc; - void* init_handle; -}; -typedef struct rdp_channel_client_data CHANNEL_CLIENT_DATA; - -struct rdp_channel_open_data -{ - char name[CHANNEL_NAME_LEN + 1]; - int open_handle; - int options; - int flags; /* 0 nothing 1 init 2 open */ - PCHANNEL_OPEN_EVENT_FN open_event_proc; -}; -typedef struct rdp_channel_open_data CHANNEL_OPEN_DATA; - -struct _CHANNEL_OPEN_EVENT -{ - void* Data; - UINT32 DataLength; - void* UserData; - int Index; -}; -typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT; - -/** - * pInitHandle: handle that identifies the client connection - * Obtained by the client with VirtualChannelInit - * Used by the client with VirtualChannelOpen - */ - -struct rdp_channel_init_data -{ - rdpChannels* channels; -}; -typedef struct rdp_channel_init_data CHANNEL_INIT_DATA; - -struct rdp_channels -{ - /** - * Only the main thread alters these arrays, before any - * library thread is allowed in(post_connect is called) - * so no need to use mutex locking - * After post_connect, each library thread can only access it's - * own array items - * ie, no two threads can access index 0, ... - */ - - int clientDataCount; - CHANNEL_CLIENT_DATA clientDataList[CHANNEL_MAX_COUNT]; - - int openDataCount; - CHANNEL_OPEN_DATA openDataList[CHANNEL_MAX_COUNT]; - - int initDataCount; - CHANNEL_INIT_DATA initDataList[CHANNEL_MAX_COUNT]; - - /* control for entry into MyVirtualChannelInit */ - int can_call_init; - rdpSettings* settings; - - /* true once freerdp_channels_post_connect is called */ - int is_connected; - - /* used for locating the channels for a given instance */ - freerdp* instance; - - wMessagePipe* MsgPipe; -}; - /** * The current channel manager reference passes from VirtualChannelEntry to * VirtualChannelInit for the pInitHandle. */ -static rdpChannels* g_init_channels; +extern rdpChannels* g_init_channels; static wArrayList* g_ChannelsList = NULL; /* To generate unique sequence for all open handles */ -static int g_open_handle_sequence; +int g_open_handle_sequence; /* For locking the global resources */ static HANDLE g_mutex_init; -static rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex) +rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex) { int i, j; BOOL found = FALSE; @@ -168,7 +92,7 @@ static rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* p { for (j = 0; j < channels->openDataCount; j++) { - if (channels->openDataList[j].open_handle == open_handle) + if (channels->openDataList[j].OpenHandle == open_handle) { *pindex = j; found = TRUE; @@ -187,7 +111,7 @@ static rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* p return (found) ? channels : NULL; } -static rdpChannels* freerdp_channels_find_by_instance(freerdp* instance) +rdpChannels* freerdp_channels_find_by_instance(freerdp* instance) { int index; BOOL found = FALSE; @@ -214,22 +138,21 @@ static rdpChannels* freerdp_channels_find_by_instance(freerdp* instance) return (found) ? channels : NULL; } -/* returns rdpChannelData for the channel name passed in */ -static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex) +CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex) { int index; - CHANNEL_OPEN_DATA* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; for (index = 0; index < channels->openDataCount; index++) { - lchannel_data = &channels->openDataList[index]; + pChannelOpenData = &channels->openDataList[index]; - if (strcmp(channel_name, lchannel_data->name) == 0) + if (strcmp(channel_name, pChannelOpenData->name) == 0) { if (pindex != 0) *pindex = index; - return lchannel_data; + return pChannelOpenData; } } @@ -237,7 +160,7 @@ static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels } /* returns rdpChannel for the channel id passed in */ -static rdpChannel* freerdp_channels_find_channel_by_id(rdpChannels* channels, rdpSettings* settings, int channel_id, int* pindex) +rdpChannel* freerdp_channels_find_channel_by_id(rdpChannels* channels, rdpSettings* settings, int channel_id, int* pindex) { int index; int count; @@ -262,7 +185,7 @@ static rdpChannel* freerdp_channels_find_channel_by_id(rdpChannels* channels, rd } /* returns rdpChannel for the channel name passed in */ -static rdpChannel* freerdp_channels_find_channel_by_name(rdpChannels* channels, +rdpChannel* freerdp_channels_find_channel_by_name(rdpChannels* channels, rdpSettings* settings, const char* channel_name, int* pindex) { int index; @@ -287,199 +210,7 @@ static rdpChannel* freerdp_channels_find_channel_by_name(rdpChannels* channels, return NULL; } -/** - * must be called by same thread that calls freerdp_chanman_load_plugin - * according to MS docs - * only called from main thread - */ -static UINT32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, - int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) -{ - int index; - rdpChannel* channel; - rdpChannels* channels; - PCHANNEL_DEF pChannelDef; - CHANNEL_OPEN_DATA* pChannelOpenData; - CHANNEL_CLIENT_DATA* pChannelClientData; - - if (!ppInitHandle) - { - DEBUG_CHANNELS("error bad init handle"); - return CHANNEL_RC_BAD_INIT_HANDLE; - } - - channels = g_init_channels; - - channels->initDataList[channels->initDataCount].channels = channels; - *ppInitHandle = &channels->initDataList[channels->initDataCount]; - - channels->initDataCount++; - - DEBUG_CHANNELS("enter"); - - if (!channels->can_call_init) - { - DEBUG_CHANNELS("error not in entry"); - return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; - } - - if (channels->openDataCount + channelCount >= CHANNEL_MAX_COUNT) - { - DEBUG_CHANNELS("error too many channels"); - return CHANNEL_RC_TOO_MANY_CHANNELS; - } - - if (!pChannel) - { - DEBUG_CHANNELS("error bad channel"); - return CHANNEL_RC_BAD_CHANNEL; - } - - if (channels->is_connected) - { - DEBUG_CHANNELS("error already connected"); - return CHANNEL_RC_ALREADY_CONNECTED; - } - - if (versionRequested != VIRTUAL_CHANNEL_VERSION_WIN2000) - { - DEBUG_CHANNELS("warning version"); - } - - for (index = 0; index < channelCount; index++) - { - pChannelDef = &pChannel[index]; - - if (freerdp_channels_find_channel_data_by_name(channels, pChannelDef->name, 0) != 0) - { - DEBUG_CHANNELS("error channel already used"); - return CHANNEL_RC_BAD_CHANNEL; - } - } - - pChannelClientData = &channels->clientDataList[channels->clientDataCount]; - pChannelClientData->init_event_proc = pChannelInitEventProc; - pChannelClientData->init_handle = *ppInitHandle; - channels->clientDataCount++; - - for (index = 0; index < channelCount; index++) - { - pChannelDef = &pChannel[index]; - pChannelOpenData = &channels->openDataList[channels->openDataCount]; - - pChannelOpenData->open_handle = g_open_handle_sequence++; - - pChannelOpenData->flags = 1; /* init */ - strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); - pChannelOpenData->options = pChannelDef->options; - - if (channels->settings->ChannelCount < 16) - { - channel = channels->settings->ChannelDefArray + channels->settings->ChannelCount; - strncpy(channel->Name, pChannelDef->name, 7); - channel->options = pChannelDef->options; - channels->settings->ChannelCount++; - } - else - { - DEBUG_CHANNELS("warning more than 16 channels"); - } - - channels->openDataCount++; - } - - return CHANNEL_RC_OK; -} - -/** - * can be called from any thread - * thread safe because no 2 threads can have the same channel name registered - */ -static UINT32 FREERDP_CC MyVirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, - char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) -{ - int index; - rdpChannels* channels; - CHANNEL_OPEN_DATA* pChannelOpenData; - - DEBUG_CHANNELS("enter"); - - channels = ((CHANNEL_INIT_DATA*) pInitHandle)->channels; - - if (!pOpenHandle) - { - DEBUG_CHANNELS("error bad channel handle"); - return CHANNEL_RC_BAD_CHANNEL_HANDLE; - } - - if (!pChannelOpenEventProc) - { - DEBUG_CHANNELS("error bad proc"); - return CHANNEL_RC_BAD_PROC; - } - - if (!channels->is_connected) - { - DEBUG_CHANNELS("error not connected"); - return CHANNEL_RC_NOT_CONNECTED; - } - - pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index); - - if (!pChannelOpenData) - { - DEBUG_CHANNELS("error channel name"); - return CHANNEL_RC_UNKNOWN_CHANNEL_NAME; - } - - if (pChannelOpenData->flags == 2) - { - DEBUG_CHANNELS("error channel already open"); - return CHANNEL_RC_ALREADY_OPEN; - } - - pChannelOpenData->flags = 2; /* open */ - pChannelOpenData->open_event_proc = pChannelOpenEventProc; - *pOpenHandle = pChannelOpenData->open_handle; - - return CHANNEL_RC_OK; -} - -/** - * can be called from any thread - * thread safe because no 2 threads can have the same openHandle - */ -static UINT32 FREERDP_CC MyVirtualChannelClose(UINT32 openHandle) -{ - int index; - rdpChannels* channels; - CHANNEL_OPEN_DATA* pChannelOpenData; - - DEBUG_CHANNELS("enter"); - - channels = freerdp_channels_find_by_open_handle(openHandle, &index); - - if ((channels == NULL) || (index < 0) || (index >= CHANNEL_MAX_COUNT)) - { - DEBUG_CHANNELS("error bad channels"); - return CHANNEL_RC_BAD_CHANNEL_HANDLE; - } - - pChannelOpenData = &channels->openDataList[index]; - - if (pChannelOpenData->flags != 2) - { - DEBUG_CHANNELS("error not open"); - return CHANNEL_RC_NOT_OPEN; - } - - pChannelOpenData->flags = 0; - - return CHANNEL_RC_OK; -} - -/* can be called from any thread */ -static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData) +UINT32 FreeRDP_VirtualChannelWrite(UINT32 openHandle, void* pData, UINT32 dataLength, void* pUserData) { int index; rdpChannels* channels; @@ -537,7 +268,7 @@ static UINT32 FREERDP_CC MyVirtualChannelWrite(UINT32 openHandle, void* pData, U return CHANNEL_RC_OK; } -static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, wMessage* event) +UINT32 FreeRDP_VirtualChannelEventPush(UINT32 openHandle, wMessage* event) { int index; rdpChannels* channels; @@ -596,7 +327,6 @@ static UINT32 FREERDP_CC MyVirtualChannelEventPush(UINT32 openHandle, wMessage* */ int freerdp_channels_global_init(void) { - g_init_channels = NULL; g_open_handle_sequence = 1; g_mutex_init = CreateMutex(NULL, FALSE, NULL); @@ -655,16 +385,16 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v ep.cbSize = sizeof(ep); ep.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000; - ep.pVirtualChannelInit = MyVirtualChannelInit; - ep.pVirtualChannelOpen = MyVirtualChannelOpen; - ep.pVirtualChannelClose = MyVirtualChannelClose; - ep.pVirtualChannelWrite = MyVirtualChannelWrite; + ep.pVirtualChannelInit = FreeRDP_VirtualChannelInit; + ep.pVirtualChannelOpen = FreeRDP_VirtualChannelOpen; + ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; + ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; ep.pExtendedData = data; - ep.pVirtualChannelEventPush = MyVirtualChannelEventPush; + ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; - /* enable MyVirtualChannelInit */ - channels->can_call_init = 1; + /* enable VirtualChannelInit */ + channels->can_call_init = TRUE; channels->settings = settings; WaitForSingleObject(g_mutex_init, INFINITE); @@ -676,8 +406,8 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v ReleaseMutex(g_mutex_init); /* disable MyVirtualChannelInit */ - channels->settings = 0; - channels->can_call_init = 0; + channels->settings = NULL; + channels->can_call_init = FALSE; if (!status) { @@ -716,17 +446,17 @@ int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, c int freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance) { int index; - CHANNEL_CLIENT_DATA* llib; + CHANNEL_CLIENT_DATA* pChannelClientData; DEBUG_CHANNELS("enter"); channels->instance = instance; for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->clientDataList[index]; + pChannelClientData = &channels->clientDataList[index]; - if (llib->init_event_proc != 0) - llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_INITIALIZED, 0, 0); + if (pChannelClientData->pChannelInitEventProc) + pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_INITIALIZED, 0, 0); } return 0; @@ -742,7 +472,7 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) int index; char* hostname; int hostname_len; - CHANNEL_CLIENT_DATA* llib; + CHANNEL_CLIENT_DATA* pChannelClientData; channels->is_connected = 1; hostname = instance->settings->ServerHostname; @@ -752,10 +482,10 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->clientDataList[index]; + pChannelClientData = &channels->clientDataList[index]; - if (llib->init_event_proc != 0) - llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_CONNECTED, hostname, hostname_len); + if (pChannelClientData->pChannelInitEventProc != 0) + pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostname_len); } return 0; @@ -770,7 +500,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat int index; rdpChannel* channel; rdpChannels* channels; - CHANNEL_OPEN_DATA* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; channels = freerdp_channels_find_by_instance(instance); @@ -788,17 +518,17 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat return 1; } - lchannel_data = freerdp_channels_find_channel_data_by_name(channels, channel->Name, &index); + pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, channel->Name, &index); - if (!lchannel_data) + if (!pChannelOpenData) { DEBUG_CHANNELS("could not find channel name"); return 1; } - if (lchannel_data->open_event_proc != 0) + if (pChannelOpenData->pChannelOpenEventProc != 0) { - lchannel_data->open_event_proc(lchannel_data->open_handle, + pChannelOpenData->pChannelOpenEventProc(pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, data_size, total_size, flags); } @@ -815,7 +545,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve { int index; const char* name = NULL; - CHANNEL_OPEN_DATA* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; switch (GetMessageClass(event->id)) { @@ -843,18 +573,18 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve return 1; } - lchannel_data = freerdp_channels_find_channel_data_by_name(channels, name, &index); + pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, name, &index); - if (!lchannel_data) + if (!pChannelOpenData) { DEBUG_CHANNELS("could not find channel name %s", name); freerdp_event_free(event); return 1; } - if (lchannel_data->open_event_proc) + if (pChannelOpenData->pChannelOpenEventProc) { - lchannel_data->open_event_proc(lchannel_data->open_handle, CHANNEL_EVENT_USER, + pChannelOpenData->pChannelOpenEventProc(pChannelOpenData->OpenHandle, CHANNEL_EVENT_USER, event, sizeof(wMessage), sizeof(wMessage), 0); } @@ -870,7 +600,7 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan wMessage* event; rdpChannel* channel; CHANNEL_OPEN_EVENT* item; - CHANNEL_OPEN_DATA* lchannel_data; + CHANNEL_OPEN_DATA* pChannelOpenData; while (MessageQueue_Peek(channels->MsgPipe->Out, &message, TRUE)) { @@ -884,17 +614,17 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan if (!item) break; - lchannel_data = &channels->openDataList[item->Index]; + pChannelOpenData = &channels->openDataList[item->Index]; channel = freerdp_channels_find_channel_by_name(channels, instance->settings, - lchannel_data->name, &item->Index); + pChannelOpenData->name, &item->Index); if (channel) instance->SendChannelData(instance, channel->ChannelId, item->Data, item->DataLength); - if (lchannel_data->open_event_proc) + if (pChannelOpenData->pChannelOpenEventProc) { - lchannel_data->open_event_proc(lchannel_data->open_handle, + pChannelOpenData->pChannelOpenEventProc(pChannelOpenData->OpenHandle, CHANNEL_EVENT_WRITE_COMPLETE, item->UserData, item->DataLength, item->DataLength, 0); } @@ -988,7 +718,7 @@ wMessage* freerdp_channels_pop_event(rdpChannels* channels) void freerdp_channels_close(rdpChannels* channels, freerdp* instance) { int index; - CHANNEL_CLIENT_DATA* llib; + CHANNEL_CLIENT_DATA* pChannelClientData; DEBUG_CHANNELS("closing"); channels->is_connected = 0; @@ -997,14 +727,9 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance) /* tell all libraries we are shutting down */ for (index = 0; index < channels->clientDataCount; index++) { - llib = &channels->clientDataList[index]; + pChannelClientData = &channels->clientDataList[index]; - if (llib->init_event_proc != 0) - llib->init_event_proc(llib->init_handle, CHANNEL_EVENT_TERMINATED, 0, 0); + if (pChannelClientData->pChannelInitEventProc) + pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0); } } - -/* Local variables: */ -/* c-basic-offset: 8 */ -/* c-file-style: "linux" */ -/* End: */ diff --git a/channels/client/channels.h b/channels/client/channels.h new file mode 100644 index 000000000..f91299dd2 --- /dev/null +++ b/channels/client/channels.h @@ -0,0 +1,115 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Client Channels + * + * 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 FREERDP_PRIVATE_CLIENT_CHANNELS +#define FREERDP_PRIVATE_CLIENT_CHANNELS + +#include <winpr/crt.h> +#include <winpr/synch.h> +#include <winpr/collections.h> + +#include <freerdp/freerdp.h> +#include <freerdp/constants.h> + +#include <freerdp/svc.h> +#include <freerdp/addin.h> +#include <freerdp/utils/event.h> +#include <freerdp/utils/debug.h> +#include <freerdp/client/channels.h> +#include <freerdp/channels/channels.h> + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CHANNEL_MAX_COUNT 30 + +struct rdp_channel_client_data +{ + PVIRTUALCHANNELENTRY entry; + PCHANNEL_INIT_EVENT_FN pChannelInitEventProc; + void* pInitHandle; +}; +typedef struct rdp_channel_client_data CHANNEL_CLIENT_DATA; + +struct rdp_channel_open_data +{ + char name[8]; + int OpenHandle; + int options; + int flags; /* 0 nothing 1 init 2 open */ + PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc; +}; +typedef struct rdp_channel_open_data CHANNEL_OPEN_DATA; + +struct _CHANNEL_OPEN_EVENT +{ + void* Data; + UINT32 DataLength; + void* UserData; + int Index; +}; +typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT; + +/** + * pInitHandle: handle that identifies the client connection + * Obtained by the client with VirtualChannelInit + * Used by the client with VirtualChannelOpen + */ + +struct rdp_channel_init_data +{ + rdpChannels* channels; +}; +typedef struct rdp_channel_init_data CHANNEL_INIT_DATA; + +struct rdp_channels +{ + int clientDataCount; + CHANNEL_CLIENT_DATA clientDataList[CHANNEL_MAX_COUNT]; + + int openDataCount; + CHANNEL_OPEN_DATA openDataList[CHANNEL_MAX_COUNT]; + + int initDataCount; + CHANNEL_INIT_DATA initDataList[CHANNEL_MAX_COUNT]; + + /* control for entry into MyVirtualChannelInit */ + int can_call_init; + rdpSettings* settings; + + /* true once freerdp_channels_post_connect is called */ + int is_connected; + + /* used for locating the channels for a given instance */ + freerdp* instance; + + wMessagePipe* MsgPipe; +}; + +#ifdef WITH_DEBUG_CHANNELS +#define DEBUG_CHANNELS(fmt, ...) DEBUG_CLASS(CHANNELS, fmt, ## __VA_ARGS__) +#else +#define DEBUG_CHANNELS(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#endif + +rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex); +CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex); + +#endif /* FREERDP_PRIVATE_CLIENT_CHANNELS */ diff --git a/channels/client/init.c b/channels/client/init.c new file mode 100644 index 000000000..01db33e17 --- /dev/null +++ b/channels/client/init.c @@ -0,0 +1,133 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Client Channels + * + * 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 "channels.h" + +#include "init.h" + +rdpChannels* g_init_channels; +extern int g_open_handle_sequence; + +/** + * must be called by same thread that calls freerdp_chanman_load_plugin + * according to MS docs. only called from main thread + */ + +UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, + int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) +{ + int index; + rdpChannel* channel; + rdpChannels* channels; + PCHANNEL_DEF pChannelDef; + CHANNEL_OPEN_DATA* pChannelOpenData; + CHANNEL_CLIENT_DATA* pChannelClientData; + + if (!ppInitHandle) + { + DEBUG_CHANNELS("error bad init handle"); + return CHANNEL_RC_BAD_INIT_HANDLE; + } + + channels = g_init_channels; + + channels->initDataList[channels->initDataCount].channels = channels; + *ppInitHandle = &channels->initDataList[channels->initDataCount]; + + channels->initDataCount++; + + DEBUG_CHANNELS("enter"); + + if (!channels->can_call_init) + { + DEBUG_CHANNELS("error not in entry"); + return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; + } + + if (channels->openDataCount + channelCount >= CHANNEL_MAX_COUNT) + { + DEBUG_CHANNELS("error too many channels"); + return CHANNEL_RC_TOO_MANY_CHANNELS; + } + + if (!pChannel) + { + DEBUG_CHANNELS("error bad channel"); + return CHANNEL_RC_BAD_CHANNEL; + } + + if (channels->is_connected) + { + DEBUG_CHANNELS("error already connected"); + return CHANNEL_RC_ALREADY_CONNECTED; + } + + if (versionRequested != VIRTUAL_CHANNEL_VERSION_WIN2000) + { + DEBUG_CHANNELS("warning version"); + } + + for (index = 0; index < channelCount; index++) + { + pChannelDef = &pChannel[index]; + + if (freerdp_channels_find_channel_data_by_name(channels, pChannelDef->name, 0) != 0) + { + DEBUG_CHANNELS("error channel already used"); + return CHANNEL_RC_BAD_CHANNEL; + } + } + + pChannelClientData = &channels->clientDataList[channels->clientDataCount]; + pChannelClientData->pChannelInitEventProc = pChannelInitEventProc; + pChannelClientData->pInitHandle = *ppInitHandle; + channels->clientDataCount++; + + for (index = 0; index < channelCount; index++) + { + pChannelDef = &pChannel[index]; + pChannelOpenData = &channels->openDataList[channels->openDataCount]; + + pChannelOpenData->OpenHandle = g_open_handle_sequence++; + + pChannelOpenData->flags = 1; /* init */ + strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); + pChannelOpenData->options = pChannelDef->options; + + if (channels->settings->ChannelCount < 16) + { + channel = channels->settings->ChannelDefArray + channels->settings->ChannelCount; + strncpy(channel->Name, pChannelDef->name, 7); + channel->options = pChannelDef->options; + channels->settings->ChannelCount++; + } + else + { + DEBUG_CHANNELS("warning more than 16 channels"); + } + + channels->openDataCount++; + } + + return CHANNEL_RC_OK; +} diff --git a/channels/client/init.h b/channels/client/init.h new file mode 100644 index 000000000..a5dccc133 --- /dev/null +++ b/channels/client/init.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Client Channels + * + * 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 FREERDP_PRIVATE_CLIENT_CHANNELS_INIT +#define FREERDP_PRIVATE_CLIENT_CHANNELS_INIT + +#include "channels.h" + +UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, + int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc); + +#endif /* FREERDP_PRIVATE_CLIENT_CHANNELS_INIT */ diff --git a/channels/client/open.c b/channels/client/open.c new file mode 100644 index 000000000..e8de91ead --- /dev/null +++ b/channels/client/open.c @@ -0,0 +1,99 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Client Channels + * + * 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. + */ + +#include "open.h" + +UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, + char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) +{ + int index; + rdpChannels* channels; + CHANNEL_OPEN_DATA* pChannelOpenData; + + DEBUG_CHANNELS("enter"); + + channels = ((CHANNEL_INIT_DATA*) pInitHandle)->channels; + + if (!pOpenHandle) + { + DEBUG_CHANNELS("error bad channel handle"); + return CHANNEL_RC_BAD_CHANNEL_HANDLE; + } + + if (!pChannelOpenEventProc) + { + DEBUG_CHANNELS("error bad proc"); + return CHANNEL_RC_BAD_PROC; + } + + if (!channels->is_connected) + { + DEBUG_CHANNELS("error not connected"); + return CHANNEL_RC_NOT_CONNECTED; + } + + pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index); + + if (!pChannelOpenData) + { + DEBUG_CHANNELS("error channel name"); + return CHANNEL_RC_UNKNOWN_CHANNEL_NAME; + } + + if (pChannelOpenData->flags == 2) + { + DEBUG_CHANNELS("error channel already open"); + return CHANNEL_RC_ALREADY_OPEN; + } + + pChannelOpenData->flags = 2; /* open */ + pChannelOpenData->pChannelOpenEventProc = pChannelOpenEventProc; + *pOpenHandle = pChannelOpenData->OpenHandle; + + return CHANNEL_RC_OK; +} + +UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle) +{ + int index; + rdpChannels* channels; + CHANNEL_OPEN_DATA* pChannelOpenData; + + DEBUG_CHANNELS("enter"); + + channels = freerdp_channels_find_by_open_handle(openHandle, &index); + + if ((channels == NULL) || (index < 0) || (index >= CHANNEL_MAX_COUNT)) + { + DEBUG_CHANNELS("error bad channels"); + return CHANNEL_RC_BAD_CHANNEL_HANDLE; + } + + pChannelOpenData = &channels->openDataList[index]; + + if (pChannelOpenData->flags != 2) + { + DEBUG_CHANNELS("error not open"); + return CHANNEL_RC_NOT_OPEN; + } + + pChannelOpenData->flags = 0; + + return CHANNEL_RC_OK; +} diff --git a/channels/client/open.h b/channels/client/open.h new file mode 100644 index 000000000..4bb525d53 --- /dev/null +++ b/channels/client/open.h @@ -0,0 +1,30 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Client Channels + * + * 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 FREERDP_PRIVATE_CLIENT_CHANNELS_OPEN +#define FREERDP_PRIVATE_CLIENT_CHANNELS_OPEN + +#include "channels.h" + +UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, + char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc); + +UINT32 FreeRDP_VirtualChannelClose(UINT32 openHandle); + +#endif /* FREERDP_PRIVATE_CLIENT_CHANNELS_OPEN */ From 608f00b7dfa9952f0b5301a8a6b5c17204d4bab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 20:40:48 -0400 Subject: [PATCH 108/144] libfreerdp-client: propagate and export pInterface extended channel pointer --- channels/client/channels.c | 43 +++++++++++++++++------------ channels/client/channels.h | 6 ++-- channels/client/init.c | 26 ++++++++--------- channels/client/open.c | 10 +++++-- include/freerdp/channels/channels.h | 2 ++ include/freerdp/svc.h | 3 +- 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index 2b646e1bb..baf75835b 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -67,7 +67,8 @@ * The current channel manager reference passes from VirtualChannelEntry to * VirtualChannelInit for the pInitHandle. */ -extern rdpChannels* g_init_channels; + +CHANNEL_INIT_DATA g_ChannelInitData; static wArrayList* g_ChannelsList = NULL; @@ -138,7 +139,7 @@ rdpChannels* freerdp_channels_find_by_instance(freerdp* instance) return (found) ? channels : NULL; } -CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex) +CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpChannels* channels, const char* channel_name) { int index; CHANNEL_OPEN_DATA* pChannelOpenData; @@ -148,12 +149,7 @@ CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* chann pChannelOpenData = &channels->openDataList[index]; if (strcmp(channel_name, pChannelOpenData->name) == 0) - { - if (pindex != 0) - *pindex = index; - return pChannelOpenData; - } } return NULL; @@ -390,6 +386,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; + ep.pInterface = NULL; ep.pExtendedData = data; ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; @@ -399,9 +396,11 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v WaitForSingleObject(g_mutex_init, INFINITE); - g_init_channels = channels; + g_ChannelInitData.channels = channels; + g_ChannelInitData.pInterface = ep.pInterface; status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); - g_init_channels = NULL; + g_ChannelInitData.channels = NULL; + g_ChannelInitData.pInterface = NULL; ReleaseMutex(g_mutex_init); @@ -471,12 +470,12 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) { int index; char* hostname; - int hostname_len; + int hostnameLength; CHANNEL_CLIENT_DATA* pChannelClientData; channels->is_connected = 1; hostname = instance->settings->ServerHostname; - hostname_len = strlen(hostname); + hostnameLength = strlen(hostname); DEBUG_CHANNELS("hostname [%s] channels->num_libs [%d]", hostname, channels->clientDataCount); @@ -484,8 +483,8 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) { pChannelClientData = &channels->clientDataList[index]; - if (pChannelClientData->pChannelInitEventProc != 0) - pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostname_len); + if (pChannelClientData->pChannelInitEventProc) + pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength); } return 0; @@ -518,7 +517,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat return 1; } - pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, channel->Name, &index); + pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, channel->Name); if (!pChannelOpenData) { @@ -526,7 +525,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat return 1; } - if (pChannelOpenData->pChannelOpenEventProc != 0) + if (pChannelOpenData->pChannelOpenEventProc) { pChannelOpenData->pChannelOpenEventProc(pChannelOpenData->OpenHandle, CHANNEL_EVENT_DATA_RECEIVED, data, data_size, total_size, flags); @@ -543,7 +542,6 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat */ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* event) { - int index; const char* name = NULL; CHANNEL_OPEN_DATA* pChannelOpenData; @@ -573,7 +571,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve return 1; } - pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, name, &index); + pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name); if (!pChannelOpenData) { @@ -661,6 +659,17 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r return TRUE; } +void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name) +{ + rdpChannels* channels; + CHANNEL_OPEN_DATA* pChannelOpenData; + + channels = instance->context->channels; + pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name); + + return pChannelOpenData->pInterface; +} + HANDLE freerdp_channels_get_event_handle(freerdp* instance) { HANDLE event = NULL; diff --git a/channels/client/channels.h b/channels/client/channels.h index f91299dd2..fa2032427 100644 --- a/channels/client/channels.h +++ b/channels/client/channels.h @@ -53,7 +53,8 @@ struct rdp_channel_open_data char name[8]; int OpenHandle; int options; - int flags; /* 0 nothing 1 init 2 open */ + int flags; + void* pInterface; PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc; }; typedef struct rdp_channel_open_data CHANNEL_OPEN_DATA; @@ -76,6 +77,7 @@ typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT; struct rdp_channel_init_data { rdpChannels* channels; + void* pInterface; }; typedef struct rdp_channel_init_data CHANNEL_INIT_DATA; @@ -110,6 +112,6 @@ struct rdp_channels #endif rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex); -CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex); +CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpChannels* channels, const char* channel_name); #endif /* FREERDP_PRIVATE_CLIENT_CHANNELS */ diff --git a/channels/client/init.c b/channels/client/init.c index 01db33e17..68e8e535c 100644 --- a/channels/client/init.c +++ b/channels/client/init.c @@ -25,21 +25,18 @@ #include "init.h" -rdpChannels* g_init_channels; extern int g_open_handle_sequence; - -/** - * must be called by same thread that calls freerdp_chanman_load_plugin - * according to MS docs. only called from main thread - */ +extern CHANNEL_INIT_DATA g_ChannelInitData; UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) { int index; + void* pInterface; rdpChannel* channel; rdpChannels* channels; PCHANNEL_DEF pChannelDef; + CHANNEL_INIT_DATA* pChannelInitData; CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_CLIENT_DATA* pChannelClientData; @@ -49,13 +46,16 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, return CHANNEL_RC_BAD_INIT_HANDLE; } - channels = g_init_channels; - - channels->initDataList[channels->initDataCount].channels = channels; - *ppInitHandle = &channels->initDataList[channels->initDataCount]; + channels = g_ChannelInitData.channels; + pInterface = g_ChannelInitData.pInterface; + pChannelInitData = &(channels->initDataList[channels->initDataCount]); + *ppInitHandle = pChannelInitData; channels->initDataCount++; + pChannelInitData->channels = channels; + pChannelInitData->pInterface = pInterface; + DEBUG_CHANNELS("enter"); if (!channels->can_call_init) @@ -91,7 +91,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, { pChannelDef = &pChannel[index]; - if (freerdp_channels_find_channel_data_by_name(channels, pChannelDef->name, 0) != 0) + if (freerdp_channels_find_channel_open_data_by_name(channels, pChannelDef->name) != 0) { DEBUG_CHANNELS("error channel already used"); return CHANNEL_RC_BAD_CHANNEL; @@ -114,7 +114,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); pChannelOpenData->options = pChannelDef->options; - if (channels->settings->ChannelCount < 16) + if (channels->settings->ChannelCount < CHANNEL_MAX_COUNT) { channel = channels->settings->ChannelDefArray + channels->settings->ChannelCount; strncpy(channel->Name, pChannelDef->name, 7); @@ -123,7 +123,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, } else { - DEBUG_CHANNELS("warning more than 16 channels"); + DEBUG_CHANNELS("warning more than %d channels", CHANNEL_MAX_COUNT); } channels->openDataCount++; diff --git a/channels/client/open.c b/channels/client/open.c index e8de91ead..1233fb964 100644 --- a/channels/client/open.c +++ b/channels/client/open.c @@ -22,13 +22,16 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc) { - int index; + void* pInterface; rdpChannels* channels; + CHANNEL_INIT_DATA* pChannelInitData; CHANNEL_OPEN_DATA* pChannelOpenData; DEBUG_CHANNELS("enter"); - channels = ((CHANNEL_INIT_DATA*) pInitHandle)->channels; + pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle; + channels = pChannelInitData->channels; + pInterface = pChannelInitData->pInterface; if (!pOpenHandle) { @@ -48,7 +51,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, return CHANNEL_RC_NOT_CONNECTED; } - pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index); + pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, pChannelName); if (!pChannelOpenData) { @@ -63,6 +66,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle, } pChannelOpenData->flags = 2; /* open */ + pChannelOpenData->pInterface = pInterface; pChannelOpenData->pChannelOpenEventProc = pChannelOpenEventProc; *pOpenHandle = pChannelOpenData->OpenHandle; diff --git a/include/freerdp/channels/channels.h b/include/freerdp/channels/channels.h index 052b90931..86508742a 100644 --- a/include/freerdp/channels/channels.h +++ b/include/freerdp/channels/channels.h @@ -48,6 +48,8 @@ FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* inst FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels); FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance); +FREERDP_API void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name); + FREERDP_API HANDLE freerdp_channels_get_event_handle(freerdp* instance); FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance); diff --git a/include/freerdp/svc.h b/include/freerdp/svc.h index c09307fd9..1fa39f630 100644 --- a/include/freerdp/svc.h +++ b/include/freerdp/svc.h @@ -35,9 +35,10 @@ struct _CHANNEL_DEF { - char name[CHANNEL_NAME_LEN + 1]; + char name[8]; UINT32 options; }; + typedef struct _CHANNEL_DEF CHANNEL_DEF; typedef CHANNEL_DEF* PCHANNEL_DEF; typedef CHANNEL_DEF** PPCHANNEL_DEF; From 8e151409bea3ea6156a2546aba55fc055f01a815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sun, 12 May 2013 21:23:12 -0400 Subject: [PATCH 109/144] libfreerdp-client: export and register successfully interface pointer for channel --- channels/client/channels.c | 12 +++++------- channels/client/init.c | 4 +++- channels/cliprdr/client/cliprdr_main.c | 19 +++++++++++++------ client/X11/xf_cliprdr.c | 5 +++-- include/freerdp/channels/channels.h | 2 +- include/freerdp/svc.h | 6 ++++-- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index baf75835b..b5d3add8b 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -68,6 +68,7 @@ * VirtualChannelInit for the pInitHandle. */ +void* g_pInterface; CHANNEL_INIT_DATA g_ChannelInitData; static wArrayList* g_ChannelsList = NULL; @@ -386,7 +387,9 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; - ep.pInterface = NULL; + g_pInterface = NULL; + ep.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER; + ep.ppInterface = &g_pInterface; ep.pExtendedData = data; ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; @@ -397,10 +400,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v WaitForSingleObject(g_mutex_init, INFINITE); g_ChannelInitData.channels = channels; - g_ChannelInitData.pInterface = ep.pInterface; status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); - g_ChannelInitData.channels = NULL; - g_ChannelInitData.pInterface = NULL; ReleaseMutex(g_mutex_init); @@ -659,12 +659,10 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r return TRUE; } -void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name) +void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name) { - rdpChannels* channels; CHANNEL_OPEN_DATA* pChannelOpenData; - channels = instance->context->channels; pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name); return pChannelOpenData->pInterface; diff --git a/channels/client/init.c b/channels/client/init.c index 68e8e535c..f88867a6a 100644 --- a/channels/client/init.c +++ b/channels/client/init.c @@ -26,6 +26,8 @@ #include "init.h" extern int g_open_handle_sequence; + +extern void* g_pInterface; extern CHANNEL_INIT_DATA g_ChannelInitData; UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, @@ -47,7 +49,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, } channels = g_ChannelInitData.channels; - pInterface = g_ChannelInitData.pInterface; + pInterface = g_pInterface; pChannelInitData = &(channels->initDataList[channels->initDataCount]); *ppInitHandle = pChannelInitData; diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 91935d4a9..f83abba7a 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -301,6 +301,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { cliprdrPlugin* _p; CliprdrClientContext* context; + CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx; _p = (cliprdrPlugin*) malloc(sizeof(cliprdrPlugin)); ZeroMemory(_p, sizeof(cliprdrPlugin)); @@ -318,14 +319,20 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) _p->plugin.event_callback = cliprdr_process_event; _p->plugin.terminate_callback = cliprdr_process_terminate; - context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext)); + pEntryPointsEx = (CHANNEL_ENTRY_POINTS_EX*) pEntryPoints; - context->MonitorReady = cliprdr_monitor_ready; - context->FormatList = cliprdr_format_list; - context->DataRequest = cliprdr_data_request; - context->DataResponse = cliprdr_data_response; + if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) && + (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) + { + context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext)); - _p->plugin.channel_entry_points.pInterface = (void*) context; + context->MonitorReady = cliprdr_monitor_ready; + context->FormatList = cliprdr_format_list; + context->DataRequest = cliprdr_data_request; + context->DataResponse = cliprdr_data_response; + + *(pEntryPointsEx->ppInterface) = (void*) context; + } svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints); diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 430f52ff6..d7e0e44f1 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -30,6 +30,7 @@ #include <freerdp/utils/event.h> #include <freerdp/client/cliprdr.h> +#include <freerdp/channels/channels.h> #include "xf_cliprdr.h" @@ -89,7 +90,7 @@ struct clipboard_context int incr_data_length; }; -void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman) +void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels) { int n; UINT32 id; @@ -100,7 +101,7 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman) xfi->clipboard_context = cb; - cb->channels = chanman; + cb->channels = channels; cb->request_index = -1; cb->root_window = DefaultRootWindow(xfi->display); diff --git a/include/freerdp/channels/channels.h b/include/freerdp/channels/channels.h index 86508742a..ffdeb3612 100644 --- a/include/freerdp/channels/channels.h +++ b/include/freerdp/channels/channels.h @@ -48,7 +48,7 @@ FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* inst FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels); FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance); -FREERDP_API void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name); +FREERDP_API void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name); FREERDP_API HANDLE freerdp_channels_get_event_handle(freerdp* instance); FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance); diff --git a/include/freerdp/svc.h b/include/freerdp/svc.h index 1fa39f630..519bd9e40 100644 --- a/include/freerdp/svc.h +++ b/include/freerdp/svc.h @@ -95,6 +95,8 @@ typedef CHANNEL_ENTRY_POINTS* PCHANNEL_ENTRY_POINTS; typedef int (FREERDP_CC * PVIRTUALCHANNELENTRY)(PCHANNEL_ENTRY_POINTS pEntryPoints); +#define FREERDP_CHANNEL_MAGIC_NUMBER 0x46524450 + struct _CHANNEL_ENTRY_POINTS_EX { UINT32 cbSize; @@ -105,9 +107,9 @@ struct _CHANNEL_ENTRY_POINTS_EX PVIRTUALCHANNELWRITE pVirtualChannelWrite; /* Extended Fields */ - + UINT32 MagicNumber; /* identifies FreeRDP */ void* pExtendedData; /* extended initial data */ - void* pInterface; /* channel callback interface */ + void** ppInterface; /* channel callback interface */ PVIRTUALCHANNELEVENTPUSH pVirtualChannelEventPush; }; typedef struct _CHANNEL_ENTRY_POINTS_EX CHANNEL_ENTRY_POINTS_EX; From e72f898956edf64c7b8da4a97fadaa963a8c252d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 13 May 2013 16:07:42 -0400 Subject: [PATCH 110/144] channels/drdynvc: refactor and start exporting interface --- channels/client/channels.c | 2 + channels/client/channels.h | 3 + channels/drdynvc/client/drdynvc_main.c | 44 ++++++-- channels/drdynvc/client/drdynvc_main.h | 1 + channels/drdynvc/client/dvcman.c | 142 ++++++++++++------------- channels/drdynvc/client/dvcman.h | 56 ++++++++++ channels/rdpei/client/rdpei_main.c | 50 ++++++--- channels/rdpei/client/rdpei_main.h | 2 + include/freerdp/client/drdynvc.h | 37 +++++++ include/freerdp/client/rdpei.h | 37 +++++++ include/freerdp/dvc.h | 6 ++ 11 files changed, 285 insertions(+), 95 deletions(-) create mode 100644 include/freerdp/client/drdynvc.h create mode 100644 include/freerdp/client/rdpei.h diff --git a/channels/client/channels.c b/channels/client/channels.c index b5d3add8b..0ee52d9a4 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -487,6 +487,8 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength); } + channels->drdynvc = (DrdynvcClientContext*) freerdp_channels_get_static_channel_interface(channels, "drdynvc"); + return 0; } diff --git a/channels/client/channels.h b/channels/client/channels.h index fa2032427..3a165748d 100644 --- a/channels/client/channels.h +++ b/channels/client/channels.h @@ -32,6 +32,7 @@ #include <freerdp/utils/event.h> #include <freerdp/utils/debug.h> #include <freerdp/client/channels.h> +#include <freerdp/client/drdynvc.h> #include <freerdp/channels/channels.h> #ifdef HAVE_CONFIG_H @@ -103,6 +104,8 @@ struct rdp_channels freerdp* instance; wMessagePipe* MsgPipe; + + DrdynvcClientContext* drdynvc; }; #ifdef WITH_DEBUG_CHANNELS diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index f146ea3a9..d912bef6a 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -234,7 +234,7 @@ static UINT32 drdynvc_read_variable_uint(wStream* stream, int cbLen) static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) { int pos; - int error; + int status; UINT32 ChannelId; wStream* data_out; @@ -242,14 +242,14 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb pos = Stream_GetPosition(s); DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, Stream_Pointer(s)); - error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); + status = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); data_out = Stream_New(NULL, pos + 4); Stream_Write_UINT8(data_out, 0x10 | cbChId); Stream_SetPosition(s, 1); Stream_Copy(data_out, s, pos - 1); - if (error == 0) + if (status == 0) { DEBUG_DVC("channel created"); Stream_Write_UINT32(data_out, 0); @@ -260,11 +260,11 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb Stream_Write_UINT32(data_out, (UINT32)(-1)); } - error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); + status = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); - if (error != CHANNEL_RC_OK) + if (status != CHANNEL_RC_OK) { - DEBUG_WARN("VirtualChannelWrite failed %d", error); + DEBUG_WARN("VirtualChannelWrite failed %d", status); return 1; } @@ -332,18 +332,23 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s) case CAPABILITY_REQUEST_PDU: drdynvc_process_capability_request(drdynvc, Sp, cbChId, s); break; + case CREATE_REQUEST_PDU: drdynvc_process_create_request(drdynvc, Sp, cbChId, s); break; + case DATA_FIRST_PDU: drdynvc_process_data_first(drdynvc, Sp, cbChId, s); break; + case DATA_PDU: drdynvc_process_data(drdynvc, Sp, cbChId, s); break; + case CLOSE_REQUEST_PDU: drdynvc_process_close_request(drdynvc, Sp, cbChId, s); break; + default: DEBUG_WARN("unknown drdynvc cmd 0x%x", Cmd); break; @@ -386,18 +391,30 @@ static void drdynvc_process_terminate(rdpSvcPlugin* plugin) DEBUG_DVC("terminating"); - if (drdynvc->channel_mgr != NULL) + if (drdynvc->channel_mgr) dvcman_free(drdynvc->channel_mgr); free(drdynvc); } +/** + * Channel Client Interface + */ + +int drdynvc_get_version(DrdynvcClientContext* context) +{ + drdynvcPlugin* drdynvc = (drdynvcPlugin*) context->handle; + return drdynvc->version; +} + /* drdynvc is always built-in */ #define VirtualChannelEntry drdynvc_VirtualChannelEntry int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { drdynvcPlugin* _p; + DrdynvcClientContext* context; + CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx; _p = (drdynvcPlugin*) malloc(sizeof(drdynvcPlugin)); ZeroMemory(_p, sizeof(drdynvcPlugin)); @@ -414,6 +431,19 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) _p->plugin.event_callback = drdynvc_process_event; _p->plugin.terminate_callback = drdynvc_process_terminate; + pEntryPointsEx = (CHANNEL_ENTRY_POINTS_EX*) pEntryPoints; + + if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) && + (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) + { + context = (DrdynvcClientContext*) malloc(sizeof(DrdynvcClientContext)); + + context->handle = (void*) _p; + context->GetVersion = drdynvc_get_version; + + *(pEntryPointsEx->ppInterface) = (void*) context; + } + svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints); return 1; diff --git a/channels/drdynvc/client/drdynvc_main.h b/channels/drdynvc/client/drdynvc_main.h index 4cc9a6695..a363324df 100644 --- a/channels/drdynvc/client/drdynvc_main.h +++ b/channels/drdynvc/client/drdynvc_main.h @@ -21,6 +21,7 @@ #define __DRDYNVC_MAIN_H #include <freerdp/types.h> +#include <freerdp/client/drdynvc.h> typedef struct drdynvc_plugin drdynvcPlugin; diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index 3b1cf5faa..accabb56f 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -27,70 +27,14 @@ #include <winpr/crt.h> #include <winpr/synch.h> +#include <winpr/stream.h> #include <freerdp/addin.h> - -#include <winpr/stream.h> #include <freerdp/utils/list.h> #include "drdynvc_types.h" #include "dvcman.h" -#define MAX_PLUGINS 10 - -typedef struct _DVCMAN DVCMAN; - -struct _DVCMAN -{ - IWTSVirtualChannelManager iface; - - drdynvcPlugin* drdynvc; - - const char* plugin_names[MAX_PLUGINS]; - IWTSPlugin* plugins[MAX_PLUGINS]; - int num_plugins; - - IWTSListener* listeners[MAX_PLUGINS]; - int num_listeners; - - LIST* channels; -}; - -typedef struct _DVCMAN_LISTENER DVCMAN_LISTENER; -struct _DVCMAN_LISTENER -{ - IWTSListener iface; - - DVCMAN* dvcman; - char* channel_name; - UINT32 flags; - IWTSListenerCallback* listener_callback; -}; - -typedef struct _DVCMAN_ENTRY_POINTS DVCMAN_ENTRY_POINTS; -struct _DVCMAN_ENTRY_POINTS -{ - IDRDYNVC_ENTRY_POINTS iface; - - DVCMAN* dvcman; - ADDIN_ARGV* args; -}; - -typedef struct _DVCMAN_CHANNEL DVCMAN_CHANNEL; -struct _DVCMAN_CHANNEL -{ - IWTSVirtualChannel iface; - - DVCMAN* dvcman; - DVCMAN_CHANNEL* next; - UINT32 channel_id; - IWTSVirtualChannelCallback* channel_callback; - - wStream* dvc_data; - - HANDLE dvc_chan_mutex; -}; - static int dvcman_get_configuration(IWTSListener* pListener, void** ppPropertyBag) { *ppPropertyBag = NULL; @@ -112,15 +56,17 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr, ZeroMemory(listener, sizeof(DVCMAN_LISTENER)); listener->iface.GetConfiguration = dvcman_get_configuration; + listener->iface.pInterface = NULL; + listener->dvcman = dvcman; listener->channel_name = _strdup(pszChannelName); listener->flags = ulFlags; listener->listener_callback = pListenerCallback; if (ppListener) - *ppListener = (IWTSListener*)listener; + *ppListener = (IWTSListener*) listener; - dvcman->listeners[dvcman->num_listeners++] = (IWTSListener*)listener; + dvcman->listeners[dvcman->num_listeners++] = (IWTSListener*) listener; return 0; } @@ -197,18 +143,53 @@ UINT32 dvcman_get_channel_id(IWTSVirtualChannel * channel) IWTSVirtualChannel* dvcman_find_channel_by_id(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId) { - LIST_ITEM* curr; + int index; + BOOL found = FALSE; + DVCMAN_CHANNEL* channel; DVCMAN* dvcman = (DVCMAN*) pChannelMgr; - for (curr = dvcman->channels->head; curr; curr = curr->next) + ArrayList_Lock(dvcman->channels); + + index = 0; + channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, index++); + + while (channel) { - if (((DVCMAN_CHANNEL*) curr->data)->channel_id == ChannelId) + if (channel->channel_id == ChannelId) { - return (IWTSVirtualChannel*) curr->data; + found = TRUE; + break; + } + + channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, index++); + } + + ArrayList_Unlock(dvcman->channels); + + return (found) ? ((IWTSVirtualChannel*) channel) : NULL; +} + +void* dvcman_get_channel_interface_by_name(IWTSVirtualChannelManager* pChannelMgr, const char* ChannelName) +{ + int i; + BOOL found = FALSE; + void* pInterface = NULL; + DVCMAN_LISTENER* listener; + DVCMAN* dvcman = (DVCMAN*) pChannelMgr; + + for (i = 0; i < dvcman->num_listeners; i++) + { + listener = (DVCMAN_LISTENER*) dvcman->listeners[i]; + + if (strcmp(listener->channel_name, ChannelName) == 0) + { + pInterface = listener->iface.pInterface; + found = TRUE; + break; } } - return NULL; + return (found) ? pInterface : NULL; } IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) @@ -223,7 +204,7 @@ IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) dvcman->iface.FindChannelById = dvcman_find_channel_by_id; dvcman->iface.GetChannelId = dvcman_get_channel_id; dvcman->drdynvc = plugin; - dvcman->channels = list_new(); + dvcman->channels = ArrayList_New(TRUE); return (IWTSVirtualChannelManager*) dvcman; } @@ -238,13 +219,14 @@ int dvcman_load_addin(IWTSVirtualChannelManager* pChannelMgr, ADDIN_ARGV* args) pDVCPluginEntry = (PDVC_PLUGIN_ENTRY) freerdp_load_channel_addin_entry(args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC); - if (pDVCPluginEntry != NULL) + if (pDVCPluginEntry) { entryPoints.iface.RegisterPlugin = dvcman_register_plugin; entryPoints.iface.GetPlugin = dvcman_get_plugin; entryPoints.iface.GetPluginData = dvcman_get_plugin_data; entryPoints.dvcman = (DVCMAN*) pChannelMgr; entryPoints.args = args; + pDVCPluginEntry((IDRDYNVC_ENTRY_POINTS*) &entryPoints); } @@ -262,15 +244,25 @@ static void dvcman_channel_free(DVCMAN_CHANNEL* channel) void dvcman_free(IWTSVirtualChannelManager* pChannelMgr) { int i; + int count; IWTSPlugin* pPlugin; DVCMAN_LISTENER* listener; DVCMAN_CHANNEL* channel; DVCMAN* dvcman = (DVCMAN*) pChannelMgr; - while ((channel = (DVCMAN_CHANNEL*) list_dequeue(dvcman->channels)) != NULL) - dvcman_channel_free(channel); + ArrayList_Lock(dvcman->channels); - list_free(dvcman->channels); + count = ArrayList_Count(dvcman->channels); + + for (i = 0; i < count; i++) + { + channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, i); + dvcman_channel_free(channel); + } + + ArrayList_Unlock(dvcman->channels); + + ArrayList_Free(dvcman->channels); for (i = 0; i < dvcman->num_listeners; i++) { @@ -326,8 +318,7 @@ static int dvcman_close_channel_iface(IWTSVirtualChannel* pChannel) DEBUG_DVC("id=%d", channel->channel_id); - if (list_remove(dvcman->channels, channel) == NULL) - DEBUG_WARN("channel not found"); + ArrayList_Remove(dvcman->channels, channel); dvcman_channel_free(channel); @@ -366,8 +357,9 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel { DEBUG_DVC("listener %s created new channel %d", listener->channel_name, channel->channel_id); + channel->channel_callback = pCallback; - list_add(dvcman->channels, channel); + ArrayList_Add(dvcman->channels, channel); return 0; } @@ -390,7 +382,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId); - if (channel == NULL) + if (!channel) { DEBUG_WARN("ChannelId %d not found!", ChannelId); return 1; @@ -415,7 +407,7 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId); - if (channel == NULL) + if (!channel) { DEBUG_WARN("ChannelId %d not found!", ChannelId); return 1; @@ -436,7 +428,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId); - if (channel == NULL) + if (!channel) { DEBUG_WARN("ChannelId %d not found!", ChannelId); return 1; diff --git a/channels/drdynvc/client/dvcman.h b/channels/drdynvc/client/dvcman.h index c41835a0f..9b181f06a 100644 --- a/channels/drdynvc/client/dvcman.h +++ b/channels/drdynvc/client/dvcman.h @@ -23,8 +23,62 @@ #include <freerdp/dvc.h> #include <freerdp/addin.h> +#include <winpr/collections.h> + #include "drdynvc_main.h" +#define MAX_PLUGINS 32 + +struct _DVCMAN +{ + IWTSVirtualChannelManager iface; + + drdynvcPlugin* drdynvc; + + const char* plugin_names[MAX_PLUGINS]; + IWTSPlugin* plugins[MAX_PLUGINS]; + int num_plugins; + + IWTSListener* listeners[MAX_PLUGINS]; + int num_listeners; + + wArrayList* channels; +}; +typedef struct _DVCMAN DVCMAN; + +struct _DVCMAN_LISTENER +{ + IWTSListener iface; + + DVCMAN* dvcman; + char* channel_name; + UINT32 flags; + IWTSListenerCallback* listener_callback; +}; +typedef struct _DVCMAN_LISTENER DVCMAN_LISTENER; + +struct _DVCMAN_ENTRY_POINTS +{ + IDRDYNVC_ENTRY_POINTS iface; + + DVCMAN* dvcman; + ADDIN_ARGV* args; +}; +typedef struct _DVCMAN_ENTRY_POINTS DVCMAN_ENTRY_POINTS; + +struct _DVCMAN_CHANNEL +{ + IWTSVirtualChannel iface; + + DVCMAN* dvcman; + UINT32 channel_id; + IWTSVirtualChannelCallback* channel_callback; + + wStream* dvc_data; + HANDLE dvc_chan_mutex; +}; +typedef struct _DVCMAN_CHANNEL DVCMAN_CHANNEL; + IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin); int dvcman_load_addin(IWTSVirtualChannelManager* pChannelMgr, ADDIN_ARGV* args); void dvcman_free(IWTSVirtualChannelManager* pChannelMgr); @@ -34,5 +88,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, UINT32 length); int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, BYTE* data, UINT32 data_size); +void* dvcman_get_channel_interface_by_name(IWTSVirtualChannelManager* pChannelMgr, const char* ChannelName); + #endif diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index bf1198e1c..400404d0e 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -35,7 +35,6 @@ #include "rdpei_main.h" -typedef struct _RDPEI_LISTENER_CALLBACK RDPEI_LISTENER_CALLBACK; struct _RDPEI_LISTENER_CALLBACK { IWTSListenerCallback iface; @@ -43,8 +42,8 @@ struct _RDPEI_LISTENER_CALLBACK IWTSPlugin* plugin; IWTSVirtualChannelManager* channel_mgr; }; +typedef struct _RDPEI_LISTENER_CALLBACK RDPEI_LISTENER_CALLBACK; -typedef struct _RDPEI_CHANNEL_CALLBACK RDPEI_CHANNEL_CALLBACK; struct _RDPEI_CHANNEL_CALLBACK { IWTSVirtualChannelCallback iface; @@ -53,14 +52,16 @@ struct _RDPEI_CHANNEL_CALLBACK IWTSVirtualChannelManager* channel_mgr; IWTSVirtualChannel* channel; }; +typedef struct _RDPEI_CHANNEL_CALLBACK RDPEI_CHANNEL_CALLBACK; -typedef struct _RDPEI_PLUGIN RDPEI_PLUGIN; struct _RDPEI_PLUGIN { IWTSPlugin iface; + IWTSListener* listener; RDPEI_LISTENER_CALLBACK* listener_callback; }; +typedef struct _RDPEI_PLUGIN RDPEI_PLUGIN; const char* RDPEI_EVENTID_STRINGS[] = { @@ -305,32 +306,47 @@ static int rdpei_on_new_channel_connection(IWTSListenerCallback* pListenerCallba static int rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr) { - RDPEI_PLUGIN* echo = (RDPEI_PLUGIN*) pPlugin; + int status; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) pPlugin; DEBUG_DVC(""); - echo->listener_callback = (RDPEI_LISTENER_CALLBACK*) malloc(sizeof(RDPEI_LISTENER_CALLBACK)); - ZeroMemory(echo->listener_callback, sizeof(RDPEI_LISTENER_CALLBACK)); + rdpei->listener_callback = (RDPEI_LISTENER_CALLBACK*) malloc(sizeof(RDPEI_LISTENER_CALLBACK)); + ZeroMemory(rdpei->listener_callback, sizeof(RDPEI_LISTENER_CALLBACK)); - echo->listener_callback->iface.OnNewChannelConnection = rdpei_on_new_channel_connection; - echo->listener_callback->plugin = pPlugin; - echo->listener_callback->channel_mgr = pChannelMgr; + rdpei->listener_callback->iface.OnNewChannelConnection = rdpei_on_new_channel_connection; + rdpei->listener_callback->plugin = pPlugin; + rdpei->listener_callback->channel_mgr = pChannelMgr; - return pChannelMgr->CreateListener(pChannelMgr, "Microsoft::Windows::RDS::Input", 0, - (IWTSListenerCallback*) echo->listener_callback, NULL); + status = pChannelMgr->CreateListener(pChannelMgr, "Microsoft::Windows::RDS::Input", 0, + (IWTSListenerCallback*) rdpei->listener_callback, &(rdpei->listener)); + + rdpei->listener->pInterface = rdpei->iface.pInterface; + + return status; } static int rdpei_plugin_terminated(IWTSPlugin* pPlugin) { - RDPEI_PLUGIN* echo = (RDPEI_PLUGIN*) pPlugin; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) pPlugin; DEBUG_DVC(""); - free(echo); + free(rdpei); return 0; } +/** + * Channel Client Interface + */ + +int rdpei_get_version(RdpeiClientContext* context) +{ + //RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + return 1; +} + #ifdef STATIC_CHANNELS #define DVCPluginEntry rdpei_DVCPluginEntry #endif @@ -339,6 +355,7 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) { int error = 0; RDPEI_PLUGIN* rdpei; + RdpeiClientContext* context; rdpei = (RDPEI_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpei"); @@ -352,6 +369,13 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) rdpei->iface.Disconnected = NULL; rdpei->iface.Terminated = rdpei_plugin_terminated; + context = (RdpeiClientContext*) malloc(sizeof(RdpeiClientContext)); + + context->handle = (void*) rdpei; + context->GetVersion = rdpei_get_version; + + rdpei->iface.pInterface = (void*) context; + error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpei", (IWTSPlugin*) rdpei); } diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 42247ec39..6438762f5 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -29,6 +29,8 @@ #include <freerdp/addin.h> #include <freerdp/utils/debug.h> +#include <freerdp/client/rdpei.h> + #define RDPINPUT_HEADER_LENGTH 6 #define CONTACT_DATA_CONTACTRECT_PRESENT 0x0001 diff --git a/include/freerdp/client/drdynvc.h b/include/freerdp/client/drdynvc.h new file mode 100644 index 000000000..9e84f328d --- /dev/null +++ b/include/freerdp/client/drdynvc.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Dynamic Virtual Channel Extension + * + * 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 FREERDP_CHANNEL_CLIENT_DRDYNVC_H +#define FREERDP_CHANNEL_CLIENT_DRDYNVC_H + +/** + * Client Interface + */ + +typedef struct _drdynvc_client_context DrdynvcClientContext; + +typedef int (*pcDrdynvcGetVersion)(DrdynvcClientContext* context); + +struct _drdynvc_client_context +{ + void* handle; + pcDrdynvcGetVersion GetVersion; +}; + +#endif /* FREERDP_CHANNEL_CLIENT_DRDYNVC_H */ diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h new file mode 100644 index 000000000..a35534c06 --- /dev/null +++ b/include/freerdp/client/rdpei.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Dynamic Virtual Channel Extension + * + * 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 FREERDP_CHANNEL_CLIENT_RDPEI_H +#define FREERDP_CHANNEL_CLIENT_RDPEI_H + +/** + * Client Interface + */ + +typedef struct _rdpei_client_context RdpeiClientContext; + +typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); + +struct _rdpei_client_context +{ + void* handle; + pcRdpeiGetVersion GetVersion; +}; + +#endif /* FREERDP_CHANNEL_CLIENT_RDPEI_H */ diff --git a/include/freerdp/dvc.h b/include/freerdp/dvc.h index f2025a448..a2350bfe8 100644 --- a/include/freerdp/dvc.h +++ b/include/freerdp/dvc.h @@ -67,6 +67,8 @@ struct _IWTSListener /* Retrieves the listener-specific configuration. */ int (*GetConfiguration) (IWTSListener* pListener, void** ppPropertyBag); + + void* pInterface; }; struct _IWTSVirtualChannel @@ -115,6 +117,10 @@ struct _IWTSPlugin /* Notifies the plug-in that the Remote Desktop Connection (RDC) client has terminated. */ int (*Terminated) (IWTSPlugin* pPlugin); + + /* Extended */ + + void* pInterface; }; struct _IWTSListenerCallback From d96249e19fef32455ad0ce8f961a435133ed14f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 13 May 2013 17:39:53 -0400 Subject: [PATCH 111/144] libfreerdp-client: start propagating channels initialization to client --- channels/client/channels.c | 29 +++++++++++++++++++++++ channels/client/channels.h | 2 ++ channels/drdynvc/client/drdynvc_main.c | 32 ++++++-------------------- channels/drdynvc/client/drdynvc_main.h | 27 +++++++++++++++++++++- channels/drdynvc/client/dvcman.c | 4 ++++ channels/rdpei/client/rdpei_main.c | 2 +- client/X11/xf_interface.c | 21 +++++++++++++++-- include/freerdp/client/drdynvc.h | 6 +++++ include/freerdp/client/rdpei.h | 4 ++++ include/freerdp/freerdp.h | 7 ++++++ 10 files changed, 105 insertions(+), 29 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index 0ee52d9a4..6531d2a92 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -438,6 +438,28 @@ int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, c return freerdp_channels_client_load(channels, settings, entry, data); } +int freerdp_drdynvc_on_channel_connected(DrdynvcClientContext* context, const char* name, void* pInterface) +{ + int status = 0; + rdpChannels* channels = (rdpChannels*) context->custom; + freerdp* instance = channels->instance; + + IFCALLRET(instance->OnChannelConnected, status, instance, name, pInterface); + + return status; +} + +int freerdp_drdynvc_on_channel_disconnected(DrdynvcClientContext* context, const char* name, void* pInterface) +{ + int status = 0; + rdpChannels* channels = (rdpChannels*) context->custom; + freerdp* instance = channels->instance; + + IFCALLRET(instance->OnChannelDisconnected, status, instance, name, pInterface); + + return status; +} + /** * go through and inform all the libraries that we are initialized * called only from main thread @@ -489,6 +511,13 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) channels->drdynvc = (DrdynvcClientContext*) freerdp_channels_get_static_channel_interface(channels, "drdynvc"); + if (channels->drdynvc) + { + channels->drdynvc->custom = (void*) channels; + channels->drdynvc->OnChannelConnected = freerdp_drdynvc_on_channel_connected; + channels->drdynvc->OnChannelDisconnected = freerdp_drdynvc_on_channel_disconnected; + } + return 0; } diff --git a/channels/client/channels.h b/channels/client/channels.h index 3a165748d..7e801e59b 100644 --- a/channels/client/channels.h +++ b/channels/client/channels.h @@ -84,6 +84,8 @@ typedef struct rdp_channel_init_data CHANNEL_INIT_DATA; struct rdp_channels { + /* internal */ + int clientDataCount; CHANNEL_CLIENT_DATA clientDataList[CHANNEL_MAX_COUNT]; diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index d912bef6a..a605ba205 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -26,35 +26,15 @@ #include <string.h> #include <winpr/crt.h> +#include <winpr/stream.h> #include <freerdp/constants.h> -#include <winpr/stream.h> #include <freerdp/utils/svc_plugin.h> #include "dvcman.h" #include "drdynvc_types.h" #include "drdynvc_main.h" -#define CREATE_REQUEST_PDU 0x01 -#define DATA_FIRST_PDU 0x02 -#define DATA_PDU 0x03 -#define CLOSE_REQUEST_PDU 0x04 -#define CAPABILITY_REQUEST_PDU 0x05 - -struct drdynvc_plugin -{ - rdpSvcPlugin plugin; - - int version; - int PriorityCharge0; - int PriorityCharge1; - int PriorityCharge2; - int PriorityCharge3; - int channel_error; - - IWTSVirtualChannelManager* channel_mgr; -}; - static int drdynvc_write_variable_uint(wStream* stream, UINT32 val) { int cb; @@ -273,7 +253,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb static int drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) { - int error; + int status; UINT32 Length; UINT32 ChannelId; @@ -281,10 +261,10 @@ static int drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId Length = drdynvc_read_variable_uint(s, Sp); DEBUG_DVC("ChannelId=%d Length=%d", ChannelId, Length); - error = dvcman_receive_channel_data_first(drdynvc->channel_mgr, ChannelId, Length); + status = dvcman_receive_channel_data_first(drdynvc->channel_mgr, ChannelId, Length); - if (error) - return error; + if (status) + return status; return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, Stream_Pointer(s), Stream_GetRemainingLength(s)); @@ -439,6 +419,8 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) context = (DrdynvcClientContext*) malloc(sizeof(DrdynvcClientContext)); context->handle = (void*) _p; + _p->context = context; + context->GetVersion = drdynvc_get_version; *(pEntryPointsEx->ppInterface) = (void*) context; diff --git a/channels/drdynvc/client/drdynvc_main.h b/channels/drdynvc/client/drdynvc_main.h index a363324df..369084a19 100644 --- a/channels/drdynvc/client/drdynvc_main.h +++ b/channels/drdynvc/client/drdynvc_main.h @@ -20,11 +20,36 @@ #ifndef __DRDYNVC_MAIN_H #define __DRDYNVC_MAIN_H -#include <freerdp/types.h> +#include <freerdp/api.h> +#include <freerdp/svc.h> +#include <freerdp/addin.h> #include <freerdp/client/drdynvc.h> +#include <freerdp/utils/svc_plugin.h> + +#define CREATE_REQUEST_PDU 0x01 +#define DATA_FIRST_PDU 0x02 +#define DATA_PDU 0x03 +#define CLOSE_REQUEST_PDU 0x04 +#define CAPABILITY_REQUEST_PDU 0x05 typedef struct drdynvc_plugin drdynvcPlugin; +struct drdynvc_plugin +{ + rdpSvcPlugin plugin; + + DrdynvcClientContext* context; + + int version; + int PriorityCharge0; + int PriorityCharge1; + int PriorityCharge2; + int PriorityCharge3; + int channel_error; + + IWTSVirtualChannelManager* channel_mgr; +}; + int drdynvc_write_data(drdynvcPlugin* plugin, UINT32 ChannelId, BYTE* data, UINT32 data_size); int drdynvc_push_event(drdynvcPlugin* plugin, wMessage* event); diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index accabb56f..f10637689 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -331,6 +331,7 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel int bAccept; DVCMAN_LISTENER* listener; DVCMAN_CHANNEL* channel; + DrdynvcClientContext* context; IWTSVirtualChannelCallback* pCallback; DVCMAN* dvcman = (DVCMAN*) pChannelMgr; @@ -361,6 +362,9 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel channel->channel_callback = pCallback; ArrayList_Add(dvcman->channels, channel); + context = dvcman->drdynvc->context; + IFCALL(context->OnChannelConnected, context, ChannelName, listener->iface.pInterface); + return 0; } else diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 400404d0e..a624d83e0 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -318,7 +318,7 @@ static int rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage rdpei->listener_callback->plugin = pPlugin; rdpei->listener_callback->channel_mgr = pChannelMgr; - status = pChannelMgr->CreateListener(pChannelMgr, "Microsoft::Windows::RDS::Input", 0, + status = pChannelMgr->CreateListener(pChannelMgr, RDPEI_DVC_CHANNEL_NAME, 0, (IWTSListenerCallback*) rdpei->listener_callback, &(rdpei->listener)); rdpei->listener->pInterface = rdpei->iface.pInterface; diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 7e0d185bd..6eee091bf 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -52,6 +52,7 @@ #include <sys/types.h> #include <sys/select.h> +#include <freerdp/freerdp.h> #include <freerdp/constants.h> #include <freerdp/codec/nsc.h> #include <freerdp/codec/rfx.h> @@ -652,6 +653,17 @@ int _xf_error_handler(Display* d, XErrorEvent* ev) return xf_error_handler(d, ev); } +int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface) +{ + //printf("OnChannelConnected: %s\n", name); + return 0; +} + +int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface) +{ + return 0; +} + /** * Callback given to freerdp_connect() to process the pre-connect operations. * It will fill the rdp_freerdp structure (instance) with the appropriate options to use for the connection. @@ -665,6 +677,7 @@ int _xf_error_handler(Display* d, XErrorEvent* ev) BOOL xf_pre_connect(freerdp* instance) { xfInfo* xfi; + rdpChannels* channels; rdpSettings* settings; xfi = ((xfContext*) instance->context)->xfi; @@ -676,13 +689,17 @@ BOOL xf_pre_connect(freerdp* instance) xfi->context->settings = instance->settings; xfi->instance = instance; settings = instance->settings; + channels = instance->context->channels; + + instance->OnChannelConnected = xf_on_channel_connected; + instance->OnChannelDisconnected = xf_on_channel_disconnected; //if (status < 0) // exit(XF_EXIT_PARSE_ARGUMENTS); - freerdp_client_load_addins(instance->context->channels, instance->settings); + freerdp_client_load_addins(channels, instance->settings); - freerdp_channels_pre_connect(xfi->_context->channels, instance); + freerdp_channels_pre_connect(channels, instance); if (settings->AuthenticationOnly) { diff --git a/include/freerdp/client/drdynvc.h b/include/freerdp/client/drdynvc.h index 9e84f328d..bb74ee26e 100644 --- a/include/freerdp/client/drdynvc.h +++ b/include/freerdp/client/drdynvc.h @@ -27,11 +27,17 @@ typedef struct _drdynvc_client_context DrdynvcClientContext; typedef int (*pcDrdynvcGetVersion)(DrdynvcClientContext* context); +typedef int (*pcDrdynvcOnChannelConnected)(DrdynvcClientContext* context, const char* name, void* pInterface); +typedef int (*pcDrdynvcOnChannelDisconnected)(DrdynvcClientContext* context, const char* name, void* pInterface); struct _drdynvc_client_context { void* handle; + void* custom; + pcDrdynvcGetVersion GetVersion; + pcDrdynvcOnChannelConnected OnChannelConnected; + pcDrdynvcOnChannelDisconnected OnChannelDisconnected; }; #endif /* FREERDP_CHANNEL_CLIENT_DRDYNVC_H */ diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h index a35534c06..3ebf41c8a 100644 --- a/include/freerdp/client/rdpei.h +++ b/include/freerdp/client/rdpei.h @@ -24,6 +24,8 @@ * Client Interface */ +#define RDPEI_DVC_CHANNEL_NAME "Microsoft::Windows::RDS::Input" + typedef struct _rdpei_client_context RdpeiClientContext; typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); @@ -31,6 +33,8 @@ typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); struct _rdpei_client_context { void* handle; + void* custom; + pcRdpeiGetVersion GetVersion; }; diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index cef859d5b..1c531d992 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -63,6 +63,9 @@ typedef int (*pLogonErrorInfo)(freerdp* instance, UINT32 data, UINT32 type); typedef int (*pSendChannelData)(freerdp* instance, int channelId, BYTE* data, int size); typedef int (*pReceiveChannelData)(freerdp* instance, int channelId, BYTE* data, int size, int flags, int total_size); +typedef int (*pOnChannelConnected)(freerdp* instance, const char* name, void* pInterface); +typedef int (*pOnChannelDisconnected)(freerdp* instance, const char* name, void* pInterface); + /** * Defines the context for a given instance of RDP connection. * It is embedded in the rdp_freerdp structure, and allocated by a call to freerdp_context_new(). @@ -193,6 +196,10 @@ struct rdp_freerdp Callback for receiving data from a channel. This is called by freerdp_channel_process() (if not NULL). Clients will typically use a function that calls freerdp_channels_data() to perform the needed tasks. */ + + pOnChannelConnected OnChannelConnected; + pOnChannelDisconnected OnChannelDisconnected; + UINT32 paddingE[80 - 66]; /* 66 */ }; From b385e61bc0a05d1ca0af204edc6430a679ee9418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 13 May 2013 19:17:25 -0400 Subject: [PATCH 112/144] xfreerdp-client: start trying to send multitouch events --- channels/rdpei/client/CMakeLists.txt | 5 ++ channels/rdpei/client/rdpei_main.c | 94 +++++++++++++++++++++++----- channels/rdpei/client/rdpei_main.h | 35 ----------- client/X11/CMakeLists.txt | 2 + client/X11/xf_channels.c | 46 ++++++++++++++ client/X11/xf_channels.h | 30 +++++++++ client/X11/xf_input.c | 60 +++++++++++++----- client/X11/xf_interface.c | 12 +--- client/X11/xfreerdp.h | 4 ++ include/freerdp/client/rdpei.h | 41 ++++++++++++ 10 files changed, 252 insertions(+), 77 deletions(-) create mode 100644 client/X11/xf_channels.c create mode 100644 client/X11/xf_channels.h diff --git a/channels/rdpei/client/CMakeLists.txt b/channels/rdpei/client/CMakeLists.txt index b3aacdcb2..b96082550 100644 --- a/channels/rdpei/client/CMakeLists.txt +++ b/channels/rdpei/client/CMakeLists.txt @@ -33,6 +33,11 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp MODULES freerdp-common freerdp-utils) + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE winpr + MODULES winpr-sysinfo) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index a624d83e0..026f73c93 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -27,6 +27,7 @@ #include <winpr/crt.h> #include <winpr/stream.h> +#include <winpr/sysinfo.h> #include <winpr/cmdline.h> #include <freerdp/addin.h> @@ -35,14 +36,7 @@ #include "rdpei_main.h" -struct _RDPEI_LISTENER_CALLBACK -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; -}; -typedef struct _RDPEI_LISTENER_CALLBACK RDPEI_LISTENER_CALLBACK; +#define MAX_CONTACTS 512 struct _RDPEI_CHANNEL_CALLBACK { @@ -54,12 +48,28 @@ struct _RDPEI_CHANNEL_CALLBACK }; typedef struct _RDPEI_CHANNEL_CALLBACK RDPEI_CHANNEL_CALLBACK; +struct _RDPEI_LISTENER_CALLBACK +{ + IWTSListenerCallback iface; + + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + RDPEI_CHANNEL_CALLBACK* channel_callback; +}; +typedef struct _RDPEI_LISTENER_CALLBACK RDPEI_LISTENER_CALLBACK; + struct _RDPEI_PLUGIN { IWTSPlugin iface; IWTSListener* listener; RDPEI_LISTENER_CALLBACK* listener_callback; + + int version; + UINT64 currentFrameTime; + UINT64 previousFrameTime; + RDPINPUT_TOUCH_FRAME frame; + RDPINPUT_CONTACT_DATA contacts[MAX_CONTACTS]; }; typedef struct _RDPEI_PLUGIN RDPEI_PLUGIN; @@ -164,29 +174,24 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) return 0; } -int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback) +int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_FRAME* frame) { int status; wStream* s; UINT32 pduLength; UINT32 encodeTime; UINT16 frameCount; - RDPINPUT_TOUCH_FRAME frame; - RDPINPUT_CONTACT_DATA contact; - encodeTime = 123; + encodeTime = 0; frameCount = 1; - frame.contactCount = 1; - frame.contacts = &contact; - s = Stream_New(NULL, 512); Stream_Seek(s, RDPINPUT_HEADER_LENGTH); rdpei_write_4byte_unsigned(s, encodeTime); rdpei_write_2byte_unsigned(s, frameCount); - rdpei_write_touch_frame(s, &frame); + rdpei_write_touch_frame(s, frame); Stream_SealLength(s); pduLength = Stream_Length(s); @@ -298,6 +303,7 @@ static int rdpei_on_new_channel_connection(IWTSListenerCallback* pListenerCallba callback->plugin = listener_callback->plugin; callback->channel_mgr = listener_callback->channel_mgr; callback->channel = pChannel; + listener_callback->channel_callback = callback; *ppCallback = (IWTSVirtualChannelCallback*) callback; @@ -343,7 +349,53 @@ static int rdpei_plugin_terminated(IWTSPlugin* pPlugin) int rdpei_get_version(RdpeiClientContext* context) { - //RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + return rdpei->version; +} + +int rdpei_begin_frame(RdpeiClientContext* context) +{ + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + + rdpei->frame.contactCount = 0; + rdpei->frame.frameOffset = 0; + + return 1; +} + +int rdpei_end_frame(RdpeiClientContext* context) +{ + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback; + + if (!rdpei->previousFrameTime && !rdpei->currentFrameTime) + { + rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->frame.frameOffset = 0; + } + else + { + rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->frame.frameOffset = rdpei->currentFrameTime - rdpei->previousFrameTime; + } + + rdpei_send_touch_event_pdu(callback, &rdpei->frame); + rdpei->previousFrameTime = rdpei->currentFrameTime; + rdpei->frame.contactCount = 0; + + return 1; +} + +int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact) +{ + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + + if (rdpei->frame.contactCount < MAX_CONTACTS) + { + CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA)); + rdpei->frame.contactCount++; + } + return 1; } @@ -369,10 +421,18 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) rdpei->iface.Disconnected = NULL; rdpei->iface.Terminated = rdpei_plugin_terminated; + rdpei->version = 1; + rdpei->currentFrameTime = 0; + rdpei->previousFrameTime = 0; + rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts; + context = (RdpeiClientContext*) malloc(sizeof(RdpeiClientContext)); context->handle = (void*) rdpei; context->GetVersion = rdpei_get_version; + context->BeginFrame = rdpei_begin_frame; + context->EndFrame = rdpei_end_frame; + context->AddContact = rdpei_add_contact; rdpei->iface.pInterface = (void*) context; diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 6438762f5..5781ee654 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -33,41 +33,6 @@ #define RDPINPUT_HEADER_LENGTH 6 -#define CONTACT_DATA_CONTACTRECT_PRESENT 0x0001 -#define CONTACT_DATA_ORIENTATION_PRESENT 0x0002 -#define CONTACT_DATA_PRESSURE_PRESENT 0x0004 - -#define CONTACT_FLAG_DOWN 0x0001 -#define CONTACT_FLAG_UPDATE 0x0002 -#define CONTACT_FLAG_UP 0x0004 -#define CONTACT_FLAG_INRANGE 0x0008 -#define CONTACT_FLAG_INCONTACT 0x0010 -#define CONTACT_FLAG_CANCELED 0x0020 - -struct _RDPINPUT_CONTACT_DATA -{ - UINT32 contactId; - UINT32 fieldsPresent; - INT32 x; - INT32 y; - UINT32 contactFlags; - INT32 contactRectLeft; - INT32 contactRectTop; - INT32 contactRectRight; - INT32 contactRectBottom; - UINT32 orientation; - UINT32 pressure; -}; -typedef struct _RDPINPUT_CONTACT_DATA RDPINPUT_CONTACT_DATA; - -struct _RDPINPUT_TOUCH_FRAME -{ - UINT32 contactCount; - UINT64 frameOffset; - RDPINPUT_CONTACT_DATA* contacts; -}; -typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME; - /* Protocol Version */ #define RDPINPUT_PROTOCOL_V1 0x00010000 diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 7ccad8f37..f1d8ba08f 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -32,6 +32,8 @@ set(${MODULE_PREFIX}_SRCS xf_event.h xf_input.c xf_input.h + xf_channels.c + xf_channels.h xf_cliprdr.c xf_cliprdr.h xf_monitor.c diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c new file mode 100644 index 000000000..5b95a2db9 --- /dev/null +++ b/client/X11/xf_channels.c @@ -0,0 +1,46 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Client Channels + * + * 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 "xf_channels.h" + +#include "xf_interface.h" +#include "xfreerdp.h" + +int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface) +{ + xfInfo* xfi = ((xfContext*) instance->context)->xfi; + + printf("OnChannelConnected: %s\n", name); + + if (strcmp(name, RDPEI_DVC_CHANNEL_NAME) == 0) + { + xfi->rdpei = (RdpeiClientContext*) pInterface; + } + + return 0; +} + +int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface) +{ + return 0; +} diff --git a/client/X11/xf_channels.h b/client/X11/xf_channels.h new file mode 100644 index 000000000..1aeaf1a66 --- /dev/null +++ b/client/X11/xf_channels.h @@ -0,0 +1,30 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Client Channels + * + * 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 __XF_CHANNELS_H +#define __XF_CHANNELS_H + +#include <freerdp/freerdp.h> +#include <freerdp/client/channels.h> +#include <freerdp/client/rdpei.h> + +int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface); +int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface); + +#endif diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 27214855b..e0e6eafe0 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -94,13 +94,13 @@ int xf_input_init(xfInfo* xfi, Window window) for (j = 0; j < dev->num_classes; j++) { XIAnyClassInfo* class = dev->classes[j]; - //XITouchClassInfo* t = (XITouchClassInfo*) class; + XITouchClassInfo* t = (XITouchClassInfo*) class; if (class->type != XITouchClass) continue; - //printf("%s %s touch device, supporting %d touches.\n", - // dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); + printf("%s %s touch device, supporting %d touches.\n", + dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); } } @@ -257,7 +257,7 @@ void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event) //contacts[i].pos_y = (int)event->event_y; active_contacts--; - break; + break;printf("TouchBegin\n"); } } } @@ -301,18 +301,50 @@ int xf_input_handle_event_local(xfInfo* xfi, XEvent* event) return 0; } -int xf_input_touch_begin_remote(xfInfo* xfi, XIDeviceEvent* event) +char* xf_input_touch_state_string(DWORD flags) { - return 0; + if (flags & CONTACT_FLAG_DOWN) + return "TouchBegin"; + else if (flags & CONTACT_FLAG_UPDATE) + return "TouchUpdate"; + else if (flags & CONTACT_FLAG_UP) + return "TouchEnd"; + else + return "TouchUnknown"; } -int xf_input_touch_update_remote(xfInfo* xfi, XIDeviceEvent* event) +int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) { - return 0; -} + int x, y; + int touchId; + RDPINPUT_CONTACT_DATA contact; + RdpeiClientContext* rdpei = xfi->rdpei; + + if (!rdpei) + return 0; + + touchId = event->detail; + x = (int) event->event_x; + y = (int) event->event_y; + ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA)); + + if ((x < 0) || (y < 0)) + return 0; + + printf("%s: id: %d x: %d y: %d\n", + xf_input_touch_state_string(flags), + touchId, x, y); + + contact.contactId = touchId % 0xFF; + contact.fieldsPresent = 0; + contact.x = x; + contact.y = y; + contact.contactFlags = flags; + + rdpei->BeginFrame(rdpei); + rdpei->AddContact(rdpei, &contact); + rdpei->EndFrame(rdpei); -int xf_input_touch_end_remote(xfInfo* xfi, XIDeviceEvent* event) -{ return 0; } @@ -327,15 +359,15 @@ int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event) switch (cookie->evtype) { case XI_TouchBegin: - xf_input_touch_begin_remote(xfi, cookie->data); + xf_input_touch_remote(xfi, cookie->data, CONTACT_FLAG_DOWN); break; case XI_TouchUpdate: - xf_input_touch_update_remote(xfi, cookie->data); + xf_input_touch_remote(xfi, cookie->data, CONTACT_FLAG_UPDATE); break; case XI_TouchEnd: - xf_input_touch_end_remote(xfi, cookie->data); + xf_input_touch_remote(xfi, cookie->data, CONTACT_FLAG_UP); break; default: diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 6eee091bf..fb1dd9699 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -83,6 +83,7 @@ #include "xf_monitor.h" #include "xf_graphics.h" #include "xf_keyboard.h" +#include "xf_channels.h" #include "xfreerdp.h" @@ -653,17 +654,6 @@ int _xf_error_handler(Display* d, XErrorEvent* ev) return xf_error_handler(d, ev); } -int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface) -{ - //printf("OnChannelConnected: %s\n", name); - return 0; -} - -int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface) -{ - return 0; -} - /** * Callback given to freerdp_connect() to process the pre-connect operations. * It will fill the rdp_freerdp structure (instance) with the appropriate options to use for the connection. diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 916ca0425..3b530a529 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -22,6 +22,7 @@ #include "xf_window.h" #include "xf_monitor.h" +#include "xf_channels.h" struct xf_WorkArea { @@ -162,6 +163,9 @@ struct xf_info Atom WM_STATE; Atom WM_PROTOCOLS; Atom WM_DELETE_WINDOW; + + /* Channels */ + RdpeiClientContext* rdpei; }; void xf_create_window(xfInfo* xfi); diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h index 3ebf41c8a..0a41ac423 100644 --- a/include/freerdp/client/rdpei.h +++ b/include/freerdp/client/rdpei.h @@ -20,6 +20,41 @@ #ifndef FREERDP_CHANNEL_CLIENT_RDPEI_H #define FREERDP_CHANNEL_CLIENT_RDPEI_H +#define CONTACT_DATA_CONTACTRECT_PRESENT 0x0001 +#define CONTACT_DATA_ORIENTATION_PRESENT 0x0002 +#define CONTACT_DATA_PRESSURE_PRESENT 0x0004 + +#define CONTACT_FLAG_DOWN 0x0001 +#define CONTACT_FLAG_UPDATE 0x0002 +#define CONTACT_FLAG_UP 0x0004 +#define CONTACT_FLAG_INRANGE 0x0008 +#define CONTACT_FLAG_INCONTACT 0x0010 +#define CONTACT_FLAG_CANCELED 0x0020 + +struct _RDPINPUT_CONTACT_DATA +{ + UINT32 contactId; + UINT32 fieldsPresent; + INT32 x; + INT32 y; + UINT32 contactFlags; + INT32 contactRectLeft; + INT32 contactRectTop; + INT32 contactRectRight; + INT32 contactRectBottom; + UINT32 orientation; + UINT32 pressure; +}; +typedef struct _RDPINPUT_CONTACT_DATA RDPINPUT_CONTACT_DATA; + +struct _RDPINPUT_TOUCH_FRAME +{ + UINT32 contactCount; + UINT64 frameOffset; + RDPINPUT_CONTACT_DATA* contacts; +}; +typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME; + /** * Client Interface */ @@ -29,6 +64,9 @@ typedef struct _rdpei_client_context RdpeiClientContext; typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); +typedef int (*pcRdpeiBeginFrame)(RdpeiClientContext* context); +typedef int (*pcRdpeiEndFrame)(RdpeiClientContext* context); +typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact); struct _rdpei_client_context { @@ -36,6 +74,9 @@ struct _rdpei_client_context void* custom; pcRdpeiGetVersion GetVersion; + pcRdpeiBeginFrame BeginFrame; + pcRdpeiEndFrame EndFrame; + pcRdpeiAddContact AddContact; }; #endif /* FREERDP_CHANNEL_CLIENT_RDPEI_H */ From c23da2f80b68af0a0d05430819252e280e06f560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 14 May 2013 01:06:25 -0400 Subject: [PATCH 113/144] channels/rdpei: minor improvements --- channels/rdpei/client/rdpei_common.c | 31 ++++++------ channels/rdpei/client/rdpei_main.c | 70 +++++++++++++++++++++------- client/X11/xf_input.c | 27 +++++++---- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/channels/rdpei/client/rdpei_common.c b/channels/rdpei/client/rdpei_common.c index e0b758a04..b1deb8b1d 100644 --- a/channels/rdpei/client/rdpei_common.c +++ b/channels/rdpei/client/rdpei_common.c @@ -480,23 +480,22 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) if (value <= 0x1F) { - count = 0; byte = value & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + Stream_Write_UINT8(s, byte); } else if (value <= 0x1FFF) { - count = 1; byte = (value >> 8) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (1 << 5); + Stream_Write_UINT8(s, byte); byte = (value & 0xFF); Stream_Write_UINT8(s, byte); } else if (value <= 0x1FFFFF) { - count = 2; byte = (value >> 16) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (2 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 8) & 0xFF; Stream_Write_UINT8(s, byte); byte = (value & 0xFF); @@ -504,9 +503,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) } else if (value <= 0x1FFFFF) { - count = 3; byte = (value >> 24) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (3 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 16) & 0xFF; Stream_Write_UINT8(s, byte); byte = (value >> 8) & 0xFF; @@ -516,9 +515,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) } else if (value <= 0x1FFFFFFF) { - count = 4; byte = (value >> 32) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (4 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 24) & 0x1F; Stream_Write_UINT8(s, byte); byte = (value >> 16) & 0xFF; @@ -530,9 +529,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) } else if (value <= 0x1FFFFFFFFF) { - count = 5; byte = (value >> 40) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (5 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 32) & 0x1F; Stream_Write_UINT8(s, byte); byte = (value >> 24) & 0x1F; @@ -546,9 +545,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) } else if (value <= 0x1FFFFFFFFFFF) { - count = 6; byte = (value >> 48) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (6 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 40) & 0x1F; Stream_Write_UINT8(s, byte); byte = (value >> 32) & 0x1F; @@ -564,9 +563,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) } else if (value <= 0x1FFFFFFFFFFFFF) { - count = 7; byte = (value >> 56) & 0x1F; - Stream_Write_UINT8(s, byte | (count << 5)); + byte |= (7 << 5); + Stream_Write_UINT8(s, byte); byte = (value >> 48) & 0x1F; Stream_Write_UINT8(s, byte); byte = (value >> 40) & 0x1F; diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 026f73c93..65baaf430 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -66,6 +66,7 @@ struct _RDPEI_PLUGIN RDPEI_LISTENER_CALLBACK* listener_callback; int version; + int touchIdOffset; UINT64 currentFrameTime; UINT64 previousFrameTime; RDPINPUT_TOUCH_FRAME frame; @@ -93,11 +94,10 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, Stream_Write_UINT32(s, pduLength); /* pduLength (4 bytes) */ Stream_SetPosition(s, Stream_Length(s)); - printf("rdpei_send_pdu: eventId: %d (%s) length: %d\n", - eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); + status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL); - status = callback->channel->Write(callback->channel, - Stream_Length(s), Stream_Buffer(s), NULL); + printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n", + eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); return status; } @@ -137,8 +137,11 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) int index; RDPINPUT_CONTACT_DATA* contact; - rdpei_write_2byte_unsigned(s, frame->contactCount); - rdpei_write_8byte_unsigned(s, frame->frameOffset); + printf("contactCount: %d\n", frame->contactCount); + printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset); + + rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ + rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ Stream_EnsureRemainingCapacity(s, frame->contactCount * 32); @@ -146,27 +149,44 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) { contact = &frame->contacts[index]; - Stream_Write_UINT8(s, contact->contactId); + printf("contact[%d].contactId: %d\n", index, contact->contactId); + printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); + printf("contact[%d].x: %d\n", index, contact->x); + printf("contact[%d].y: %d\n", index, contact->y); + printf("contact[%d].contactFlags: 0x%04X\n", index, contact->contactFlags); + + Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ + + /* fieldsPresent (TWO_BYTE_UNSIGNED_INTEGER) */ rdpei_write_2byte_unsigned(s, contact->fieldsPresent); - rdpei_write_4byte_signed(s, contact->x); - rdpei_write_4byte_signed(s, contact->y); + + rdpei_write_4byte_signed(s, contact->x); /* x (FOUR_BYTE_SIGNED_INTEGER) */ + rdpei_write_4byte_signed(s, contact->y); /* y (FOUR_BYTE_SIGNED_INTEGER) */ + + /* contactFlags (FOUR_BYTE_UNSIGNED_INTEGER) */ rdpei_write_4byte_unsigned(s, contact->contactFlags); if (contact->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT) { + /* contactRectLeft (TWO_BYTE_SIGNED_INTEGER) */ rdpei_write_2byte_signed(s, contact->contactRectLeft); + /* contactRectTop (TWO_BYTE_SIGNED_INTEGER) */ rdpei_write_2byte_signed(s, contact->contactRectTop); + /* contactRectRight (TWO_BYTE_SIGNED_INTEGER) */ rdpei_write_2byte_signed(s, contact->contactRectRight); + /* contactRectBottom (TWO_BYTE_SIGNED_INTEGER) */ rdpei_write_2byte_signed(s, contact->contactRectBottom); } if (contact->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT) { + /* orientation (FOUR_BYTE_UNSIGNED_INTEGER) */ rdpei_write_4byte_unsigned(s, contact->orientation); } if (contact->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT) { + /* pressure (FOUR_BYTE_UNSIGNED_INTEGER) */ rdpei_write_4byte_unsigned(s, contact->pressure); } } @@ -179,17 +199,14 @@ int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_ int status; wStream* s; UINT32 pduLength; - UINT32 encodeTime; - UINT16 frameCount; - encodeTime = 0; - frameCount = 1; + pduLength = 64 + (frame->contactCount * 32); - s = Stream_New(NULL, 512); + s = Stream_New(NULL, pduLength); Stream_Seek(s, RDPINPUT_HEADER_LENGTH); - rdpei_write_4byte_unsigned(s, encodeTime); - rdpei_write_2byte_unsigned(s, frameCount); + rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */ + rdpei_write_2byte_unsigned(s, frame->contactCount); /* TWO_BYTE_UNSIGNED_INTEGER */ rdpei_write_touch_frame(s, frame); @@ -368,6 +385,9 @@ int rdpei_end_frame(RdpeiClientContext* context) RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback; + //if (rdpei->frame.contactCount < 8) + // return 0; + if (!rdpei->previousFrameTime && !rdpei->currentFrameTime) { rdpei->currentFrameTime = (UINT64) GetTickCount64(); @@ -388,10 +408,27 @@ int rdpei_end_frame(RdpeiClientContext* context) int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact) { + RDPINPUT_CONTACT_DATA* previousContact; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; if (rdpei->frame.contactCount < MAX_CONTACTS) { + if (rdpei->frame.contactCount > 0) + { + previousContact = &(rdpei->contacts[rdpei->frame.contactCount - 1]); + + if ((previousContact->x == contact->x) || (previousContact->y == contact->y) || + (previousContact->contactId == contact->contactId)) + { + return 1; + } + } + + if (rdpei->touchIdOffset < 0) + rdpei->touchIdOffset = contact->contactId; + + contact->contactId -= rdpei->touchIdOffset; + CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA)); rdpei->frame.contactCount++; } @@ -422,6 +459,7 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) rdpei->iface.Terminated = rdpei_plugin_terminated; rdpei->version = 1; + rdpei->touchIdOffset = -1; rdpei->currentFrameTime = 0; rdpei->previousFrameTime = 0; rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index e0e6eafe0..a8a442cb6 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -328,20 +328,31 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) y = (int) event->event_y; ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA)); - if ((x < 0) || (y < 0)) - return 0; + //if ((x < 0) || (y < 0)) + // return 0; - printf("%s: id: %d x: %d y: %d\n", - xf_input_touch_state_string(flags), - touchId, x, y); - - contact.contactId = touchId % 0xFF; + contact.contactId = touchId; contact.fieldsPresent = 0; contact.x = x; contact.y = y; contact.contactFlags = flags; - rdpei->BeginFrame(rdpei); + if (flags & CONTACT_FLAG_DOWN) + { + contact.contactFlags |= CONTACT_FLAG_INRANGE; + contact.contactFlags |= CONTACT_FLAG_INCONTACT; + } + else if (flags & CONTACT_FLAG_UPDATE) + { + contact.contactFlags |= CONTACT_FLAG_INRANGE; + contact.contactFlags |= CONTACT_FLAG_INCONTACT; + } + else if (flags & CONTACT_FLAG_UP) + { + //contact.contactFlags |= CONTACT_FLAG_INRANGE; + } + + //rdpei->BeginFrame(rdpei); rdpei->AddContact(rdpei, &contact); rdpei->EndFrame(rdpei); From e6aec6c9362498a6a42d020964ed0c8ffc10a547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 14 May 2013 17:45:52 -0400 Subject: [PATCH 114/144] xfreerdp: initial multitouch functionality --- channels/rdpei/client/rdpei_main.c | 176 +++++++++++++++++++++++++---- channels/rdpei/client/rdpei_main.h | 13 +++ client/X11/xf_event.c | 9 ++ client/X11/xf_input.c | 45 +++++--- include/freerdp/client/rdpei.h | 8 ++ 5 files changed, 210 insertions(+), 41 deletions(-) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 65baaf430..562951bed 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -36,6 +36,26 @@ #include "rdpei_main.h" +/** + * Touch Input + * http://msdn.microsoft.com/en-us/library/windows/desktop/dd562197/ + * + * Windows Touch Input + * http://msdn.microsoft.com/en-us/library/windows/desktop/dd317321/ + * + * Input: Touch injection sample + * http://code.msdn.microsoft.com/windowsdesktop/Touch-Injection-Sample-444d9bf7 + * + * Pointer Input Message Reference + * http://msdn.microsoft.com/en-us/library/hh454916/ + * + * POINTER_INFO Structure + * http://msdn.microsoft.com/en-us/library/hh454907/ + * + * POINTER_TOUCH_INFO Structure + * http://msdn.microsoft.com/en-us/library/hh454910/ + */ + #define MAX_CONTACTS 512 struct _RDPEI_CHANNEL_CALLBACK @@ -66,11 +86,12 @@ struct _RDPEI_PLUGIN RDPEI_LISTENER_CALLBACK* listener_callback; int version; - int touchIdOffset; + UINT16 maxTouchContacts; UINT64 currentFrameTime; UINT64 previousFrameTime; RDPINPUT_TOUCH_FRAME frame; RDPINPUT_CONTACT_DATA contacts[MAX_CONTACTS]; + RDPINPUT_CONTACT_POINT* contactPoints; }; typedef struct _RDPEI_PLUGIN RDPEI_PLUGIN; @@ -108,21 +129,19 @@ int rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) wStream* s; UINT32 flags; UINT32 pduLength; - UINT16 maxTouchContacts; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) callback->plugin; flags = 0; flags |= READY_FLAGS_SHOW_TOUCH_VISUALS; //flags |= READY_FLAGS_DISABLE_TIMESTAMP_INJECTION; - maxTouchContacts = 10; - pduLength = RDPINPUT_HEADER_LENGTH + 10; s = Stream_New(NULL, pduLength); Stream_Seek(s, RDPINPUT_HEADER_LENGTH); Stream_Write_UINT32(s, flags); /* flags (4 bytes) */ Stream_Write_UINT32(s, RDPINPUT_PROTOCOL_V1); /* protocolVersion (4 bytes) */ - Stream_Write_UINT16(s, maxTouchContacts); /* maxTouchContacts (2 bytes) */ + Stream_Write_UINT16(s, rdpei->maxTouchContacts); /* maxTouchContacts (2 bytes) */ Stream_SealLength(s); @@ -132,6 +151,22 @@ int rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) return status; } +void rdpei_print_contact_flags(UINT32 contactFlags) +{ + if (contactFlags & CONTACT_FLAG_DOWN) + printf(" CONTACT_FLAG_DOWN"); + if (contactFlags & CONTACT_FLAG_UPDATE) + printf(" CONTACT_FLAG_UPDATE"); + if (contactFlags & CONTACT_FLAG_UP) + printf(" CONTACT_FLAG_UP"); + if (contactFlags & CONTACT_FLAG_INRANGE) + printf(" CONTACT_FLAG_INRANGE"); + if (contactFlags & CONTACT_FLAG_INCONTACT) + printf(" CONTACT_FLAG_INCONTACT"); + if (contactFlags & CONTACT_FLAG_CANCELED) + printf(" CONTACT_FLAG_CANCELED"); +} + int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) { int index; @@ -153,7 +188,9 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); printf("contact[%d].x: %d\n", index, contact->x); printf("contact[%d].y: %d\n", index, contact->y); - printf("contact[%d].contactFlags: 0x%04X\n", index, contact->contactFlags); + printf("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); + rdpei_print_contact_flags(contact->contactFlags); + printf("\n"); Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ @@ -408,27 +445,10 @@ int rdpei_end_frame(RdpeiClientContext* context) int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact) { - RDPINPUT_CONTACT_DATA* previousContact; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; if (rdpei->frame.contactCount < MAX_CONTACTS) { - if (rdpei->frame.contactCount > 0) - { - previousContact = &(rdpei->contacts[rdpei->frame.contactCount - 1]); - - if ((previousContact->x == contact->x) || (previousContact->y == contact->y) || - (previousContact->contactId == contact->contactId)) - { - return 1; - } - } - - if (rdpei->touchIdOffset < 0) - rdpei->touchIdOffset = contact->contactId; - - contact->contactId -= rdpei->touchIdOffset; - CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA)); rdpei->frame.contactCount++; } @@ -436,6 +456,104 @@ int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contac return 1; } +int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int y) +{ + int i, j; + int contactId = -1; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + + /* Create a new contact point in an empty slot */ + + for (i = 0; i < rdpei->maxTouchContacts; i++) + { + if (!rdpei->contactPoints[i].flags) + { + rdpei->contactPoints[i].flags = 1; + rdpei->contactPoints[i].contactId = i; + rdpei->contactPoints[i].touchDownX = x; + rdpei->contactPoints[i].touchDownX = y; + + for (j = 0; j < MAX_EXTERNAL_IDS; j++) + { + if (!rdpei->contactPoints[i].externalIds[j]) + { + rdpei->contactPoints[i].externalIds[j] = externalId; + rdpei->contactPoints[i].externalIdCount++; + break; + } + } + + contactId = rdpei->contactPoints[i].contactId; + break; + } + } + + return contactId; +} + +int rdpei_contact_update(RdpeiClientContext* context, int externalId) +{ + int i, j; + int contactId = -1; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + + for (i = 0; i < rdpei->maxTouchContacts; i++) + { + if (!rdpei->contactPoints[i].flags) + continue; + + for (j = 0; j < MAX_EXTERNAL_IDS; j++) + { + if (rdpei->contactPoints[i].externalIds[j] == externalId) + { + contactId = rdpei->contactPoints[i].contactId; + break; + } + } + + if (contactId != -1) + break; + } + + return contactId; +} + +int rdpei_contact_end(RdpeiClientContext* context, int externalId) +{ + int i, j; + int contactId = -1; + RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; + + for (i = 0; i < rdpei->maxTouchContacts; i++) + { + if (!rdpei->contactPoints[i].flags) + continue; + + for (j = 0; j < MAX_EXTERNAL_IDS; j++) + { + if (rdpei->contactPoints[i].externalIds[j] == externalId) + { + contactId = rdpei->contactPoints[i].contactId; + rdpei->contactPoints[i].externalIds[j] = 0; + rdpei->contactPoints[i].externalIdCount--; + + if (rdpei->contactPoints[i].externalIdCount < 1) + { + rdpei->contactPoints[i].flags = 0; + rdpei->contactPoints[i].contactId = 0; + } + + break; + } + } + + if (contactId != -1) + break; + } + + return contactId; +} + #ifdef STATIC_CHANNELS #define DVCPluginEntry rdpei_DVCPluginEntry #endif @@ -450,6 +568,8 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) if (rdpei == NULL) { + size_t size; + rdpei = (RDPEI_PLUGIN*) malloc(sizeof(RDPEI_PLUGIN)); ZeroMemory(rdpei, sizeof(RDPEI_PLUGIN)); @@ -459,11 +579,15 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) rdpei->iface.Terminated = rdpei_plugin_terminated; rdpei->version = 1; - rdpei->touchIdOffset = -1; rdpei->currentFrameTime = 0; rdpei->previousFrameTime = 0; rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts; + rdpei->maxTouchContacts = 10; + size = rdpei->maxTouchContacts * sizeof(RDPINPUT_CONTACT_POINT); + rdpei->contactPoints = (RDPINPUT_CONTACT_POINT*) malloc(size); + ZeroMemory(rdpei->contactPoints, size); + context = (RdpeiClientContext*) malloc(sizeof(RdpeiClientContext)); context->handle = (void*) rdpei; @@ -472,6 +596,10 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) context->EndFrame = rdpei_end_frame; context->AddContact = rdpei_add_contact; + context->ContactBegin = rdpei_contact_begin; + context->ContactUpdate = rdpei_contact_update; + context->ContactEnd = rdpei_contact_end; + rdpei->iface.pInterface = (void*) context; error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpei", (IWTSPlugin*) rdpei); diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 5781ee654..8e532bd00 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -51,6 +51,19 @@ #define EVENTID_RESUME_TOUCH 0x0005 #define EVENTID_DISMISS_HOVERING_CONTACT 0x0006 +#define MAX_EXTERNAL_IDS 32 + +struct _RDPINPUT_CONTACT_POINT +{ + UINT32 flags; + UINT32 contactId; + int touchDownX; + int touchDownY; + int externalIdCount; + int externalIds[MAX_EXTERNAL_IDS]; +}; +typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT; + #ifdef WITH_DEBUG_DVC #define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) #else diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index d6226ca67..5af5c232e 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -136,6 +136,9 @@ static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) int x, y; Window childWindow; + if (xfi->settings->MultiTouchInput) + return TRUE; + input = xfi->instance->input; x = event->xmotion.x; y = event->xmotion.y; @@ -186,6 +189,9 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) BOOL extended; rdpInput* input; + if (xfi->settings->MultiTouchInput) + return TRUE; + input = xfi->instance->input; x = 0; @@ -295,6 +301,9 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) BOOL extended; rdpInput* input; + if (xfi->settings->MultiTouchInput) + return TRUE; + input = xfi->instance->input; x = 0; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index a8a442cb6..d34fee12d 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -57,15 +57,17 @@ int scale_cnt; int xf_input_init(xfInfo* xfi, Window window) { int i, j; + int nmasks; int ndevices; int major = 2; int minor = 2; Status xstatus; - XIEventMask evmask; XIDeviceInfo* info; + XIEventMask evmasks[8]; int opcode, event, error; - unsigned char mask[XIMaskLen(XI_LASTEVENT)]; + BYTE masks[8][XIMaskLen(XI_LASTEVENT)]; + nmasks = 0; active_contacts = 0; ZeroMemory(contacts, sizeof(touchContact) * MAX_CONTACTS); @@ -99,21 +101,29 @@ int xf_input_init(xfInfo* xfi, Window window) if (class->type != XITouchClass) continue; - printf("%s %s touch device, supporting %d touches.\n", - dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches); + if (t->mode != XIDirectTouch) + continue; + + if (strcmp(dev->name, "Virtual core pointer") == 0) + continue; + + printf("%s %s touch device (id: %d, mode: %d), supporting %d touches.\n", + dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", + dev->deviceid, t->mode, t->num_touches); + + evmasks[nmasks].mask = masks[nmasks]; + evmasks[nmasks].mask_len = sizeof(masks[0]); + ZeroMemory(masks[nmasks], sizeof(masks[0])); + evmasks[nmasks].deviceid = dev->deviceid; + + XISetMask(masks[nmasks], XI_TouchBegin); + XISetMask(masks[nmasks], XI_TouchUpdate); + XISetMask(masks[nmasks], XI_TouchEnd); + nmasks++; } } - evmask.mask = mask; - evmask.mask_len = sizeof(mask); - ZeroMemory(mask, sizeof(mask)); - evmask.deviceid = XIAllDevices; - - XISetMask(mask, XI_TouchBegin); - XISetMask(mask, XI_TouchUpdate); - XISetMask(mask, XI_TouchEnd); - - xstatus = XISelectEvents(xfi->display, window, &evmask, 1); + xstatus = XISelectEvents(xfi->display, window, evmasks, nmasks); return -1; } @@ -331,7 +341,6 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) //if ((x < 0) || (y < 0)) // return 0; - contact.contactId = touchId; contact.fieldsPresent = 0; contact.x = x; contact.y = y; @@ -339,20 +348,22 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) if (flags & CONTACT_FLAG_DOWN) { + contact.contactId = rdpei->ContactBegin(rdpei, touchId, x, y); contact.contactFlags |= CONTACT_FLAG_INRANGE; contact.contactFlags |= CONTACT_FLAG_INCONTACT; } else if (flags & CONTACT_FLAG_UPDATE) { + contact.contactId = rdpei->ContactUpdate(rdpei, touchId); contact.contactFlags |= CONTACT_FLAG_INRANGE; contact.contactFlags |= CONTACT_FLAG_INCONTACT; } else if (flags & CONTACT_FLAG_UP) { - //contact.contactFlags |= CONTACT_FLAG_INRANGE; + contact.contactId = rdpei->ContactEnd(rdpei, touchId); } - //rdpei->BeginFrame(rdpei); + rdpei->BeginFrame(rdpei); rdpei->AddContact(rdpei, &contact); rdpei->EndFrame(rdpei); diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h index 0a41ac423..37ed03ead 100644 --- a/include/freerdp/client/rdpei.h +++ b/include/freerdp/client/rdpei.h @@ -68,6 +68,10 @@ typedef int (*pcRdpeiBeginFrame)(RdpeiClientContext* context); typedef int (*pcRdpeiEndFrame)(RdpeiClientContext* context); typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact); +typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId, int x, int y); +typedef int (*pcRdpeiContactUpdate)(RdpeiClientContext* context, int externalId); +typedef int (*pcRdpeiContactEnd)(RdpeiClientContext* context, int externalId); + struct _rdpei_client_context { void* handle; @@ -77,6 +81,10 @@ struct _rdpei_client_context pcRdpeiBeginFrame BeginFrame; pcRdpeiEndFrame EndFrame; pcRdpeiAddContact AddContact; + + pcRdpeiContactBegin ContactBegin; + pcRdpeiContactUpdate ContactUpdate; + pcRdpeiContactEnd ContactEnd; }; #endif /* FREERDP_CHANNEL_CLIENT_RDPEI_H */ From c3efeccbd6965a26047184ef41bcdf56eb3f4765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 14 May 2013 19:26:01 -0400 Subject: [PATCH 115/144] xfreerdp: partial cleanup of multitouch code --- channels/rdpei/client/rdpei_main.c | 94 +++++++++++------------------- channels/rdpei/client/rdpei_main.h | 7 +-- client/X11/xf_event.c | 15 +---- client/X11/xf_input.c | 7 +-- include/freerdp/client/rdpei.h | 8 +-- 5 files changed, 40 insertions(+), 91 deletions(-) diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 562951bed..1147fa816 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -117,8 +117,10 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL); +#ifdef WITH_DEBUG_RDPEI printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n", eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); +#endif return status; } @@ -172,8 +174,10 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) int index; RDPINPUT_CONTACT_DATA* contact; +#ifdef WITH_DEBUG_RDPEI printf("contactCount: %d\n", frame->contactCount); printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset); +#endif rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ @@ -184,6 +188,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) { contact = &frame->contacts[index]; +#ifdef WITH_DEBUG_RDPEI printf("contact[%d].contactId: %d\n", index, contact->contactId); printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); printf("contact[%d].x: %d\n", index, contact->x); @@ -191,6 +196,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) printf("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); rdpei_print_contact_flags(contact->contactFlags); printf("\n"); +#endif Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ @@ -243,7 +249,7 @@ int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_ Stream_Seek(s, RDPINPUT_HEADER_LENGTH); rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */ - rdpei_write_2byte_unsigned(s, frame->contactCount); /* TWO_BYTE_UNSIGNED_INTEGER */ + rdpei_write_2byte_unsigned(s, 1); /* TWO_BYTE_UNSIGNED_INTEGER */ rdpei_write_touch_frame(s, frame); @@ -289,8 +295,10 @@ int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */ Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */ +#ifdef WITH_DEBUG_RDPEI printf("rdpei_recv_pdu: eventId: %d (%s) length: %d\n", eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); +#endif switch (eventId) { @@ -407,32 +415,22 @@ int rdpei_get_version(RdpeiClientContext* context) return rdpei->version; } -int rdpei_begin_frame(RdpeiClientContext* context) -{ - RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; - - rdpei->frame.contactCount = 0; - rdpei->frame.frameOffset = 0; - - return 1; -} - -int rdpei_end_frame(RdpeiClientContext* context) +int rdpei_send_frame(RdpeiClientContext* context) { + UINT64 currentTime; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback; - //if (rdpei->frame.contactCount < 8) - // return 0; + currentTime = GetTickCount64(); if (!rdpei->previousFrameTime && !rdpei->currentFrameTime) { - rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->currentFrameTime = currentTime; rdpei->frame.frameOffset = 0; } else { - rdpei->currentFrameTime = (UINT64) GetTickCount64(); + rdpei->currentFrameTime = currentTime; rdpei->frame.frameOffset = rdpei->currentFrameTime - rdpei->previousFrameTime; } @@ -453,12 +451,14 @@ int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contac rdpei->frame.contactCount++; } + rdpei_send_frame(context); + return 1; } -int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int y) +int rdpei_contact_begin(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -470,21 +470,13 @@ int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int { rdpei->contactPoints[i].flags = 1; rdpei->contactPoints[i].contactId = i; - rdpei->contactPoints[i].touchDownX = x; - rdpei->contactPoints[i].touchDownX = y; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (!rdpei->contactPoints[i].externalId) { - if (!rdpei->contactPoints[i].externalIds[j]) - { - rdpei->contactPoints[i].externalIds[j] = externalId; - rdpei->contactPoints[i].externalIdCount++; - break; - } + rdpei->contactPoints[i].externalId = externalId; + contactId = rdpei->contactPoints[i].contactId; + break; } - - contactId = rdpei->contactPoints[i].contactId; - break; } } @@ -493,7 +485,7 @@ int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int int rdpei_contact_update(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -502,17 +494,11 @@ int rdpei_contact_update(RdpeiClientContext* context, int externalId) if (!rdpei->contactPoints[i].flags) continue; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (rdpei->contactPoints[i].externalId == externalId) { - if (rdpei->contactPoints[i].externalIds[j] == externalId) - { - contactId = rdpei->contactPoints[i].contactId; - break; - } - } - - if (contactId != -1) + contactId = rdpei->contactPoints[i].contactId; break; + } } return contactId; @@ -520,7 +506,7 @@ int rdpei_contact_update(RdpeiClientContext* context, int externalId) int rdpei_contact_end(RdpeiClientContext* context, int externalId) { - int i, j; + int i; int contactId = -1; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; @@ -529,26 +515,14 @@ int rdpei_contact_end(RdpeiClientContext* context, int externalId) if (!rdpei->contactPoints[i].flags) continue; - for (j = 0; j < MAX_EXTERNAL_IDS; j++) + if (rdpei->contactPoints[i].externalId == externalId) { - if (rdpei->contactPoints[i].externalIds[j] == externalId) - { - contactId = rdpei->contactPoints[i].contactId; - rdpei->contactPoints[i].externalIds[j] = 0; - rdpei->contactPoints[i].externalIdCount--; - - if (rdpei->contactPoints[i].externalIdCount < 1) - { - rdpei->contactPoints[i].flags = 0; - rdpei->contactPoints[i].contactId = 0; - } - - break; - } - } - - if (contactId != -1) + contactId = rdpei->contactPoints[i].contactId; + rdpei->contactPoints[i].externalId = 0; + rdpei->contactPoints[i].flags = 0; + rdpei->contactPoints[i].contactId = 0; break; + } } return contactId; @@ -592,8 +566,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) context->handle = (void*) rdpei; context->GetVersion = rdpei_get_version; - context->BeginFrame = rdpei_begin_frame; - context->EndFrame = rdpei_end_frame; context->AddContact = rdpei_add_contact; context->ContactBegin = rdpei_contact_begin; diff --git a/channels/rdpei/client/rdpei_main.h b/channels/rdpei/client/rdpei_main.h index 8e532bd00..8c0137ce4 100644 --- a/channels/rdpei/client/rdpei_main.h +++ b/channels/rdpei/client/rdpei_main.h @@ -51,16 +51,11 @@ #define EVENTID_RESUME_TOUCH 0x0005 #define EVENTID_DISMISS_HOVERING_CONTACT 0x0006 -#define MAX_EXTERNAL_IDS 32 - struct _RDPINPUT_CONTACT_POINT { UINT32 flags; UINT32 contactId; - int touchDownX; - int touchDownY; - int externalIdCount; - int externalIds[MAX_EXTERNAL_IDS]; + int externalId; }; typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT; diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 5af5c232e..95b7a423d 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -132,13 +132,10 @@ static BOOL xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) { - rdpInput* input; int x, y; + rdpInput* input; Window childWindow; - if (xfi->settings->MultiTouchInput) - return TRUE; - input = xfi->instance->input; x = event->xmotion.x; y = event->xmotion.y; @@ -184,13 +181,10 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; - Window childWindow; BOOL wheel; BOOL extended; rdpInput* input; - - if (xfi->settings->MultiTouchInput) - return TRUE; + Window childWindow; input = xfi->instance->input; @@ -297,12 +291,9 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; - Window childWindow; BOOL extended; rdpInput* input; - - if (xfi->settings->MultiTouchInput) - return TRUE; + Window childWindow; input = xfi->instance->input; diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index d34fee12d..23bb97fb6 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -338,9 +338,6 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) y = (int) event->event_y; ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA)); - //if ((x < 0) || (y < 0)) - // return 0; - contact.fieldsPresent = 0; contact.x = x; contact.y = y; @@ -348,7 +345,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) if (flags & CONTACT_FLAG_DOWN) { - contact.contactId = rdpei->ContactBegin(rdpei, touchId, x, y); + contact.contactId = rdpei->ContactBegin(rdpei, touchId); contact.contactFlags |= CONTACT_FLAG_INRANGE; contact.contactFlags |= CONTACT_FLAG_INCONTACT; } @@ -363,9 +360,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags) contact.contactId = rdpei->ContactEnd(rdpei, touchId); } - rdpei->BeginFrame(rdpei); rdpei->AddContact(rdpei, &contact); - rdpei->EndFrame(rdpei); return 0; } diff --git a/include/freerdp/client/rdpei.h b/include/freerdp/client/rdpei.h index 37ed03ead..a38c940dc 100644 --- a/include/freerdp/client/rdpei.h +++ b/include/freerdp/client/rdpei.h @@ -64,11 +64,9 @@ typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME; typedef struct _rdpei_client_context RdpeiClientContext; typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); -typedef int (*pcRdpeiBeginFrame)(RdpeiClientContext* context); -typedef int (*pcRdpeiEndFrame)(RdpeiClientContext* context); typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact); -typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId, int x, int y); +typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactUpdate)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactEnd)(RdpeiClientContext* context, int externalId); @@ -78,10 +76,8 @@ struct _rdpei_client_context void* custom; pcRdpeiGetVersion GetVersion; - pcRdpeiBeginFrame BeginFrame; - pcRdpeiEndFrame EndFrame; - pcRdpeiAddContact AddContact; + pcRdpeiAddContact AddContact; pcRdpeiContactBegin ContactBegin; pcRdpeiContactUpdate ContactUpdate; pcRdpeiContactEnd ContactEnd; From 0ee55ddcfecbc22256dc4d69e89bd46c92f9fe79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 14 May 2013 22:01:36 -0400 Subject: [PATCH 116/144] channels/rdpei: fix warnings --- channels/rdpei/client/rdpei_common.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/channels/rdpei/client/rdpei_common.c b/channels/rdpei/client/rdpei_common.c index b1deb8b1d..3f6b3d819 100644 --- a/channels/rdpei/client/rdpei_common.c +++ b/channels/rdpei/client/rdpei_common.c @@ -407,7 +407,7 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) break; case 4: - *value = (byte & 0x1F) << 32; + *value = ((UINT64) (byte & 0x1F)) << 32; Stream_Read_UINT8(s, byte); *value |= (byte << 24); Stream_Read_UINT8(s, byte); @@ -419,9 +419,9 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) break; case 5: - *value = (byte & 0x1F) << 40; + *value = ((UINT64) (byte & 0x1F)) << 40; Stream_Read_UINT8(s, byte); - *value |= (byte << 32); + *value |= (((UINT64) byte) << 32); Stream_Read_UINT8(s, byte); *value |= (byte << 24); Stream_Read_UINT8(s, byte); @@ -433,11 +433,11 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) break; case 6: - *value = (byte & 0x1F) << 48; + *value = ((UINT64) (byte & 0x1F)) << 48; Stream_Read_UINT8(s, byte); - *value |= (byte << 40); + *value |= (((UINT64) byte) << 40); Stream_Read_UINT8(s, byte); - *value |= (byte << 32); + *value |= (((UINT64) byte) << 32); Stream_Read_UINT8(s, byte); *value |= (byte << 24); Stream_Read_UINT8(s, byte); @@ -449,13 +449,13 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) break; case 7: - *value = (byte & 0x1F) << 56; + *value = ((UINT64) (byte & 0x1F)) << 56; Stream_Read_UINT8(s, byte); - *value |= (byte << 48); + *value |= (((UINT64) byte) << 48); Stream_Read_UINT8(s, byte); - *value |= (byte << 40); + *value |= (((UINT64) byte) << 40); Stream_Read_UINT8(s, byte); - *value |= (byte << 32); + *value |= (((UINT64) byte) << 32); Stream_Read_UINT8(s, byte); *value |= (byte << 24); Stream_Read_UINT8(s, byte); @@ -476,7 +476,6 @@ BOOL rdpei_read_8byte_unsigned(wStream* s, UINT64* value) BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) { BYTE byte; - BYTE count; if (value <= 0x1F) { From 9229548cd772fa85161990dd773d85800e370e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 11:39:28 -0400 Subject: [PATCH 117/144] xfreerdp: fix initialization when multitouch hardware is not present --- channels/client/channels.c | 6 +++++- client/X11/xf_input.c | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/channels/client/channels.c b/channels/client/channels.c index 6531d2a92..a9ea2b0dc 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -692,11 +692,15 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name) { + void* pInterface = NULL; CHANNEL_OPEN_DATA* pChannelOpenData; pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name); - return pChannelOpenData->pInterface; + if (pChannelOpenData) + pInterface = pChannelOpenData->pInterface; + + return pInterface; } HANDLE freerdp_channels_get_event_handle(freerdp* instance) diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 23bb97fb6..9db6b4dff 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -68,6 +68,7 @@ int xf_input_init(xfInfo* xfi, Window window) BYTE masks[8][XIMaskLen(XI_LASTEVENT)]; nmasks = 0; + ndevices = 0; active_contacts = 0; ZeroMemory(contacts, sizeof(touchContact) * MAX_CONTACTS); @@ -123,9 +124,10 @@ int xf_input_init(xfInfo* xfi, Window window) } } - xstatus = XISelectEvents(xfi->display, window, evmasks, nmasks); + if (nmasks > 0) + xstatus = XISelectEvents(xfi->display, window, evmasks, nmasks); - return -1; + return 0; } BOOL xf_input_is_duplicate(XIDeviceEvent* event) From 367ebf32a36dddc43b587d5f14de1242d3060ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 12:14:26 -0400 Subject: [PATCH 118/144] freerdp: make use of stream macros to access members --- channels/rail/client/rail_orders.c | 2 +- libfreerdp/core/connection.c | 1 + libfreerdp/core/fastpath.c | 7 ++- libfreerdp/core/freerdp.c | 10 ++-- libfreerdp/core/gateway/rpc_client.c | 2 +- libfreerdp/core/gcc.c | 4 +- libfreerdp/core/license.c | 3 +- libfreerdp/core/mcs.c | 12 +++++ libfreerdp/core/message.c | 5 +- libfreerdp/core/nego.c | 6 +++ libfreerdp/core/nla.c | 9 ++-- libfreerdp/core/orders.c | 17 +++--- libfreerdp/core/rdp.c | 54 +++++++++++-------- libfreerdp/core/transport.c | 52 ++++++++---------- libfreerdp/crypto/per.c | 2 +- server/Sample/sfreerdp.c | 8 +-- winpr/libwinpr/sspi/NTLM/ntlm_message.c | 10 ++-- winpr/libwinpr/utils/collections/StreamPool.c | 4 +- 18 files changed, 117 insertions(+), 91 deletions(-) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 737e2a4a0..e6bb690ec 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -125,7 +125,7 @@ void rail_send_pdu(rdpRailOrder* rail_order, wStream* s, UINT16 orderType) DEBUG_RAIL("Sending %s PDU, length:%d", RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength); - rail_send_channel_data(rail_order->plugin, s->buffer, orderLength); + rail_send_channel_data(rail_order->plugin, Stream_Buffer(s), orderLength); } void rail_write_high_contrast(wStream* s, HIGH_CONTRAST* high_contrast) diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 8d7008149..4b01b9411 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -287,6 +287,7 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) Stream_Write_UINT32(s, length); Stream_Write(s, crypt_client_random, length); + Stream_SealLength(s); if (transport_write(rdp->mcs->transport, s) < 0) { diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 281bd6221..952a11aa9 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -331,7 +331,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s) if (compressionFlags & PACKET_COMPRESSED) { - if (decompress_rdp(rdp->mppc_dec, s->pointer, size, compressionFlags, &roff, &rlen)) + if (decompress_rdp(rdp->mppc_dec, Stream_Pointer(s), size, compressionFlags, &roff, &rlen)) { size = rlen; buffer = rdp->mppc_dec->history_buf + roff; @@ -760,6 +760,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu rdp->sec_flags = 0; Stream_SetPosition(s, length); + Stream_SealLength(s); if (transport_write(fastpath->rdp->transport, s) < 0) return FALSE; @@ -846,7 +847,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s if (try_comp) { - if (compress_rdp(rdp->mppc_enc, ls->pointer + header_bytes, dlen)) + if (compress_rdp(rdp->mppc_enc, Stream_Pointer(ls) + header_bytes, dlen)) { if (rdp->mppc_enc->flags & PACKET_COMPRESSED) { @@ -918,6 +919,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s security_encrypt(ptr_to_crypt, bytes_to_crypt, rdp); } + Stream_SealLength(s); + if (transport_write(fastpath->rdp->transport, update) < 0) { result = FALSE; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 20a739d04..65d91c43b 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -136,19 +136,19 @@ BOOL freerdp_connect(freerdp* instance) { pcap_get_next_record_header(update->pcap_rfx, &record); - s->buffer = (BYTE*) realloc(s->buffer, record.length); - record.data = s->buffer; - s->capacity = record.length; + Stream_Buffer(s) = (BYTE*) realloc(Stream_Buffer(s), record.length); + record.data = Stream_Buffer(s); + Stream_Capacity(s) = record.length; pcap_get_next_record_content(update->pcap_rfx, &record); Stream_SetPosition(s, 0); update->BeginPaint(update->context); - update_recv_surfcmds(update, s->capacity, s); + update_recv_surfcmds(update, Stream_Capacity(s), s); update->EndPaint(update->context); } - free(s->buffer); + free(Stream_Buffer(s)); return TRUE; } } diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 3456b604c..d07ff21d6 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -415,7 +415,7 @@ RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc) if (pdu) { fprintf(stderr, "Receiving PDU (length: %d, CallId: %d)\n", pdu->s->length, pdu->CallId); - winpr_HexDump(pdu->s->buffer, pdu->s->length); + winpr_HexDump(Stream_Buffer(pdu->s), Stream_Length(pdu->s)); fprintf(stderr, "\n"); } #endif diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index b43785170..316f4f968 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -399,7 +399,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpSettings* settings, int length) while (offset < length) { - holdp = s->pointer; + holdp = Stream_Pointer(s); if (!gcc_read_user_data_header(s, &type, &blockLength)) { @@ -438,7 +438,7 @@ BOOL gcc_read_server_data_blocks(wStream* s, rdpSettings* settings, int length) break; } offset += blockLength; - s->pointer = holdp + blockLength; + Stream_Pointer(s) = holdp + blockLength; } return TRUE; diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index 3cb8259a4..77e4088a8 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -203,10 +203,11 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type) #ifdef WITH_DEBUG_LICENSE fprintf(stderr, "Sending %s Packet, length %d\n", LICENSE_MESSAGE_STRINGS[type & 0x1F], wMsgSize); - winpr_HexDump(s->pointer - 4, wMsgSize); + winpr_HexDump(Stream_Pointer(s) - 4, wMsgSize); #endif Stream_SetPosition(s, length); + Stream_SealLength(s); if (transport_write(license->rdp->transport, s) < 0) return FALSE; diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index 29682e7d5..a672e4e27 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -479,6 +479,7 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) tpkt_write_header(s, length); tpdu_write_data(s); Stream_SetPointer(s, em); + Stream_SealLength(s); status = transport_write(mcs->transport, s); @@ -558,6 +559,7 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) tpkt_write_header(s, length); tpdu_write_data(s); Stream_SetPointer(s, em); + Stream_SealLength(s); ret = transport_write(mcs->transport, s); @@ -600,6 +602,8 @@ BOOL mcs_send_erect_domain_request(rdpMcs* mcs) per_write_integer(s, 0); /* subHeight (INTEGER) */ per_write_integer(s, 0); /* subInterval (INTEGER) */ + Stream_SealLength(s); + if (transport_write(mcs->transport, s) < 0) return FALSE; @@ -636,6 +640,8 @@ BOOL mcs_send_attach_user_request(rdpMcs* mcs) mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserRequest, length, 0); + Stream_SealLength(s); + if (transport_write(mcs->transport, s) < 0) return FALSE; @@ -680,6 +686,8 @@ BOOL mcs_send_attach_user_confirm(rdpMcs* mcs) mcs->user_id = MCS_GLOBAL_CHANNEL_ID + 1 + mcs->transport->settings->ChannelCount; per_write_integer16(s, mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */ + Stream_SealLength(s); + transport_write(mcs->transport, s); return TRUE; @@ -724,6 +732,8 @@ BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channel_id) per_write_integer16(s, mcs->user_id, MCS_BASE_CHANNEL_ID); per_write_integer16(s, channel_id, 0); + Stream_SealLength(s); + if (transport_write(mcs->transport, s) < 0) return FALSE; @@ -776,6 +786,8 @@ BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channel_id) per_write_integer16(s, channel_id, 0); /* requested (ChannelId) */ per_write_integer16(s, channel_id, 0); /* channelId */ + Stream_SealLength(s); + transport_write(mcs->transport, s); return TRUE; diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 0c27bd5e2..9eecc0c88 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -154,7 +154,7 @@ static void update_message_SurfaceCommand(rdpContext* context, wStream* s) wParam = (wStream*) malloc(sizeof(wStream)); - wParam->capacity = s->capacity; + wParam->capacity = Stream_Capacity(s); wParam->buffer = (BYTE*) malloc(wParam->capacity); wParam->pointer = wParam->buffer; @@ -1005,8 +1005,7 @@ int update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg, in IFCALL(proxy->SurfaceCommand, msg->context, (wStream*) msg->wParam); { wStream* s = (wStream*) msg->wParam; - free(s->buffer); - free(s); + Stream_Free(s, TRUE); } break; diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 48f3dbc1e..7f43bf18f 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -289,6 +289,8 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego) free(wszPCB); } + Stream_SealLength(s); + if (transport_write(nego->transport, s) < 0) return FALSE; @@ -688,6 +690,8 @@ BOOL nego_send_negotiation_request(rdpNego* nego) tpdu_write_connection_request(s, length - 5); Stream_SetPointer(s, em); + Stream_SealLength(s); + if (transport_write(nego->transport, s) < 0) return FALSE; @@ -843,6 +847,8 @@ BOOL nego_send_negotiation_response(rdpNego* nego) tpdu_write_connection_confirm(s, length - 5); Stream_SetPointer(s, em); + Stream_SealLength(s); + if (transport_write(nego->transport, s) < 0) return FALSE; diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 1d7de7288..8ab89ebd1 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -817,7 +817,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) ber_read_octet_string_tag(s, &length); credssp->identity.DomainLength = (UINT32) length; credssp->identity.Domain = (UINT16*) malloc(length); - CopyMemory(credssp->identity.Domain, s->pointer, credssp->identity.DomainLength); + CopyMemory(credssp->identity.Domain, Stream_Pointer(s), credssp->identity.DomainLength); Stream_Seek(s, credssp->identity.DomainLength); credssp->identity.DomainLength /= 2; @@ -826,7 +826,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) ber_read_octet_string_tag(s, &length); credssp->identity.UserLength = (UINT32) length; credssp->identity.User = (UINT16*) malloc(length); - CopyMemory(credssp->identity.User, s->pointer, credssp->identity.UserLength); + CopyMemory(credssp->identity.User, Stream_Pointer(s), credssp->identity.UserLength); Stream_Seek(s, credssp->identity.UserLength); credssp->identity.UserLength /= 2; @@ -835,7 +835,7 @@ void credssp_read_ts_password_creds(rdpCredssp* credssp, wStream* s) ber_read_octet_string_tag(s, &length); credssp->identity.PasswordLength = (UINT32) length; credssp->identity.Password = (UINT16*) malloc(length); - CopyMemory(credssp->identity.Password, s->pointer, credssp->identity.PasswordLength); + CopyMemory(credssp->identity.Password, Stream_Pointer(s), credssp->identity.PasswordLength); Stream_Seek(s, credssp->identity.PasswordLength); credssp->identity.PasswordLength /= 2; @@ -1125,7 +1125,10 @@ void credssp_send(rdpCredssp* credssp) ber_write_octet_string(s, credssp->pubKeyAuth.pvBuffer, credssp->pubKeyAuth.cbBuffer); } + Stream_SealLength(s); + transport_write(credssp->transport, s); + Stream_Free(s, TRUE); } diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index d87996f8a..dd85fac21 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -1397,7 +1397,7 @@ BOOL update_read_glyph_index_order(wStream* s, ORDER_INFO* orderInfo, GLYPH_INDE if (Stream_GetRemainingLength(s) < glyph_index->cbData) return FALSE; - memcpy(glyph_index->data, s->pointer, glyph_index->cbData); + memcpy(glyph_index->data, Stream_Pointer(s), glyph_index->cbData); Stream_Seek(s, glyph_index->cbData); } @@ -1497,7 +1497,7 @@ BOOL update_read_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX_ if (Stream_GetRemainingLength(s) < fast_index->cbData) return FALSE; - memcpy(fast_index->data, s->pointer, fast_index->cbData); + memcpy(fast_index->data, Stream_Pointer(s), fast_index->cbData); Stream_Seek(s, fast_index->cbData); } return TRUE; @@ -1538,8 +1538,8 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ if (Stream_GetRemainingLength(s) < fast_glyph->cbData) return FALSE; - memcpy(fast_glyph->data, s->pointer, fast_glyph->cbData); - phold = s->pointer; + memcpy(fast_glyph->data, Stream_Pointer(s), fast_glyph->cbData); + phold = Stream_Pointer(s); if (!Stream_SafeSeek(s, 1)) return FALSE; @@ -1566,7 +1566,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ Stream_Read(s, glyph->aj, glyph->cb); } - s->pointer = phold + fast_glyph->cbData; + Stream_Pointer(s) = phold + fast_glyph->cbData; } return TRUE; } @@ -2200,7 +2200,7 @@ BOOL update_decompress_brush(wStream* s, BYTE* output, BYTE bpp) BYTE* palette; int bytesPerPixel; - palette = s->pointer + 16; + palette = Stream_Pointer(s) + 16; bytesPerPixel = ((bpp + 1) / 8); if (Stream_GetRemainingLength(s) < 16) // 64 / 4 @@ -3044,7 +3044,7 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) Stream_Read_UINT16(s, extraFlags); /* extraFlags (2 bytes) */ Stream_Read_UINT8(s, orderType); /* orderType (1 byte) */ - next = s->pointer + ((INT16) orderLength) + 7; + next = Stream_Pointer(s) + ((INT16) orderLength) + 7; #ifdef WITH_DEBUG_ORDERS if (orderType < SECONDARY_DRAWING_ORDER_COUNT) @@ -3116,7 +3116,8 @@ BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flags) break; } - s->pointer = next; + Stream_Pointer(s) = next; + return TRUE; } diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 3e28673aa..1fd072377 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -332,9 +332,9 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) { if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS) { - data = s->pointer + 12; + data = Stream_Pointer(s) + 12; - length = length - (data - s->buffer); + length = length - (data - Stream_Buffer(s)); Stream_Write_UINT16(s, 0x10); /* length */ Stream_Write_UINT8(s, 0x1); /* TSFIPS_VERSION 1*/ @@ -348,20 +348,22 @@ static UINT32 rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length) Stream_Write_UINT8(s, pad); - security_hmac_signature(data, length, s->pointer, rdp); + security_hmac_signature(data, length, Stream_Pointer(s), rdp); Stream_Seek(s, 8); security_fips_encrypt(data, length + pad, rdp); } else { - data = s->pointer + 8; - length = length - (data - s->buffer); + data = Stream_Pointer(s) + 8; + length = length - (data - Stream_Buffer(s)); + if (sec_flags & SEC_SECURE_CHECKSUM) - security_salted_mac_signature(rdp, data, length, TRUE, s->pointer); + security_salted_mac_signature(rdp, data, length, TRUE, Stream_Pointer(s)); else - security_mac_signature(rdp, data, length, s->pointer); + security_mac_signature(rdp, data, length, Stream_Pointer(s)); + Stream_Seek(s, 8); - security_encrypt(s->pointer, length, rdp); + security_encrypt(Stream_Pointer(s), length, rdp); } } @@ -413,13 +415,14 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) rdp_write_header(rdp, s, length, channel_id); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = s->pointer; + sec_hold = Stream_Pointer(s); Stream_Seek(s, sec_bytes); - s->pointer = sec_hold; + Stream_Pointer(s) = sec_hold; length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); + Stream_SealLength(s); if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -439,15 +442,17 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = s->pointer; + sec_hold = Stream_Pointer(s); Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, type, channel_id); - s->pointer = sec_hold; + Stream_Pointer(s) = sec_hold; length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); + Stream_SealLength(s); + if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -466,16 +471,18 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = s->pointer; + sec_hold = Stream_Pointer(s); Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id); rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId); - s->pointer = sec_hold; + Stream_Pointer(s) = sec_hold; length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); + Stream_SealLength(s); + if (transport_write(rdp->transport, s) < 0) return FALSE; @@ -526,7 +533,7 @@ int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s) return -1; } - if (decompress_rdp(rdp->mppc_dec, s->pointer, compressed_len - 18, compressed_type, &roff, &rlen)) + if (decompress_rdp(rdp->mppc_dec, Stream_Pointer(s), compressed_len - 18, compressed_type, &roff, &rlen)) { buffer = rdp->mppc_dec->history_buf + roff; cs = StreamPool_Take(rdp->transport->ReceivePool, rlen); @@ -699,25 +706,25 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) Stream_Read_UINT8(s, version); /* 0x1 */ Stream_Read_UINT8(s, pad); - sig = s->pointer; + sig = Stream_Pointer(s); Stream_Seek(s, 8); /* signature */ length -= 12; - if (!security_fips_decrypt(s->pointer, length, rdp)) + if (!security_fips_decrypt(Stream_Pointer(s), length, rdp)) { fprintf(stderr, "FATAL: cannot decrypt\n"); return FALSE; /* TODO */ } - if (!security_fips_check_signature(s->pointer, length - pad, sig, rdp)) + if (!security_fips_check_signature(Stream_Pointer(s), length - pad, sig, rdp)) { fprintf(stderr, "FATAL: invalid packet signature\n"); return FALSE; /* TODO */ } /* is this what needs adjusting? */ - s->capacity -= pad; + Stream_Capacity(s) -= pad; return TRUE; } @@ -726,13 +733,14 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, int length, UINT16 securityFlags) Stream_Read(s, wmac, sizeof(wmac)); length -= sizeof(wmac); - if (!security_decrypt(s->pointer, length, rdp)) + + if (!security_decrypt(Stream_Pointer(s), length, rdp)) return FALSE; if (securityFlags & SEC_SECURE_CHECKSUM) - security_salted_mac_signature(rdp, s->pointer, length, FALSE, cmac); + security_salted_mac_signature(rdp, Stream_Pointer(s), length, FALSE, cmac); else - security_mac_signature(rdp, s->pointer, length, cmac); + security_mac_signature(rdp, Stream_Pointer(s), length, cmac); if (memcmp(wmac, cmac, sizeof(wmac)) != 0) { @@ -792,7 +800,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) * [MS-RDPBCGR] 2.2.13.2.1 * - no share control header, nor the 2 byte pad */ - s->pointer -= 2; + Stream_Rewind(s, 2); rdp_recv_enhanced_security_redirection_packet(rdp, s); return -1; } diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index ed812474f..e0ea3f0f1 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -406,29 +406,29 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes) int transport_read(rdpTransport* transport, wStream* s) { int status; - int pdu_bytes; - int stream_bytes; + int pduLength; + int streamPosition; int transport_status; - pdu_bytes = 0; + pduLength = 0; transport_status = 0; /* first check if we have header */ - stream_bytes = Stream_GetPosition(s); + streamPosition = Stream_GetPosition(s); - if (stream_bytes < 4) + if (streamPosition < 4) { - status = transport_read_layer(transport, s->buffer + stream_bytes, 4 - stream_bytes); + status = transport_read_layer(transport, Stream_Buffer(s) + streamPosition, 4 - streamPosition); if (status < 0) return status; transport_status += status; - if ((status + stream_bytes) < 4) + if ((status + streamPosition) < 4) return transport_status; - stream_bytes += status; + streamPosition += status; } /* if header is present, read in exactly one PDU */ @@ -436,7 +436,7 @@ int transport_read(rdpTransport* transport, wStream* s) { /* TPKT header */ - pdu_bytes = (s->buffer[2] << 8) | s->buffer[3]; + pduLength = (s->buffer[2] << 8) | s->buffer[3]; } else if (s->buffer[0] == 0x30) { @@ -446,13 +446,13 @@ int transport_read(rdpTransport* transport, wStream* s) { if ((s->buffer[1] & ~(0x80)) == 1) { - pdu_bytes = s->buffer[2]; - pdu_bytes += 3; + pduLength = s->buffer[2]; + pduLength += 3; } else if ((s->buffer[1] & ~(0x80)) == 2) { - pdu_bytes = (s->buffer[2] << 8) | s->buffer[3]; - pdu_bytes += 4; + pduLength = (s->buffer[2] << 8) | s->buffer[3]; + pduLength += 4; } else { @@ -461,8 +461,8 @@ int transport_read(rdpTransport* transport, wStream* s) } else { - pdu_bytes = s->buffer[1]; - pdu_bytes += 2; + pduLength = s->buffer[1]; + pduLength += 2; } } else @@ -470,12 +470,12 @@ int transport_read(rdpTransport* transport, wStream* s) /* Fast-Path Header */ if (s->buffer[1] & 0x80) - pdu_bytes = ((s->buffer[1] & 0x7f) << 8) | s->buffer[2]; + pduLength = ((s->buffer[1] & 0x7F) << 8) | s->buffer[2]; else - pdu_bytes = s->buffer[1]; + pduLength = s->buffer[1]; } - status = transport_read_layer(transport, s->buffer + stream_bytes, pdu_bytes - stream_bytes); + status = transport_read_layer(transport, Stream_Buffer(s) + streamPosition, pduLength - streamPosition); if (status < 0) return status; @@ -484,10 +484,10 @@ int transport_read(rdpTransport* transport, wStream* s) #ifdef WITH_DEBUG_TRANSPORT /* dump when whole PDU is read */ - if (stream_bytes + status >= pdu_bytes) + if (streamPosition + status >= pduLength) { fprintf(stderr, "Local < Remote\n"); - winpr_HexDump(s->buffer, pdu_bytes); + winpr_HexDump(Stream_Buffer(s), pduLength); } #endif @@ -511,8 +511,8 @@ static int transport_read_nonblocking(rdpTransport* transport) int transport_write(rdpTransport* transport, wStream* s) { - int status = -1; int length; + int status = -1; length = Stream_GetPosition(s); Stream_SetPosition(s, 0); @@ -521,7 +521,7 @@ int transport_write(rdpTransport* transport, wStream* s) if (length > 0) { fprintf(stderr, "Local > Remote\n"); - winpr_HexDump(s->buffer, length); + winpr_HexDump(Stream_Buffer(s), length); } #endif @@ -734,14 +734,6 @@ int transport_check_fds(rdpTransport** ptransport) Stream_SealLength(received); Stream_SetPosition(received, 0); - /** - * ReceiveCallback return values: - * - * -1: synchronous failure - * 0: synchronous success - * 1: asynchronous return - */ - recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra); Stream_Release(received); diff --git a/libfreerdp/crypto/per.c b/libfreerdp/crypto/per.c index 6eaebea0c..ab6a409ad 100644 --- a/libfreerdp/crypto/per.c +++ b/libfreerdp/crypto/per.c @@ -402,7 +402,7 @@ BOOL per_read_octet_string(wStream* s, BYTE* oct_str, int length, int min) if (Stream_GetRemainingLength(s) < length) return FALSE; - a_oct_str = s->pointer; + a_oct_str = Stream_Pointer(s); Stream_Seek(s, length); for (i = 0; i < length; i++) diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index aaf65a802..637e634ba 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -376,12 +376,12 @@ void tf_peer_dump_rfx(freerdp_peer* client) { pcap_get_next_record_header(pcap_rfx, &record); - s->buffer = realloc(s->buffer, record.length); - record.data = s->buffer; - s->capacity = record.length; + Stream_Buffer(s) = realloc(Stream_Buffer(s), record.length); + record.data = Stream_Buffer(s); + Stream_Capacity(s) = record.length; pcap_get_next_record_content(pcap_rfx, &record); - s->pointer = s->buffer + s->capacity; + Stream_Pointer(s) = Stream_Buffer(s) + Stream_Capacity(s); if (test_dump_rfx_realtime && test_sleep_tsdiff(&prev_seconds, &prev_useconds, record.header.ts_sec, record.header.ts_usec) == FALSE) break; diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index a753b5029..8b17d6990 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -326,7 +326,7 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu #ifdef WITH_DEBUG_NTLM fprintf(stderr, "NEGOTIATE_MESSAGE (length = %d)\n", length); - winpr_HexDump(s->buffer, length); + winpr_HexDump(Stream_Buffer(s), length); fprintf(stderr, "\n"); if (message->NegotiateFlags & NTLMSSP_NEGOTIATE_VERSION) @@ -610,7 +610,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu buffer->cbBuffer = length; sspi_SecBufferAlloc(&context->ChallengeMessage, length); - CopyMemory(context->ChallengeMessage.pvBuffer, s->buffer, length); + CopyMemory(context->ChallengeMessage.pvBuffer, Stream_Buffer(s), length); #ifdef WITH_DEBUG_NTLM fprintf(stderr, "CHALLENGE_MESSAGE (length = %d)\n", length); @@ -720,7 +720,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer length = Stream_GetPosition(s); sspi_SecBufferAlloc(&context->AuthenticateMessage, length); - CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length); + CopyMemory(context->AuthenticateMessage.pvBuffer, Stream_Buffer(s), length); buffer->cbBuffer = length; Stream_SetPosition(s, PayloadBufferOffset); @@ -1016,7 +1016,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer length = Stream_GetPosition(s); sspi_SecBufferAlloc(&context->AuthenticateMessage, length); - CopyMemory(context->AuthenticateMessage.pvBuffer, s->buffer, length); + CopyMemory(context->AuthenticateMessage.pvBuffer, Stream_Buffer(s), length); buffer->cbBuffer = length; if (context->UseMIC) @@ -1031,7 +1031,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer #ifdef WITH_DEBUG_NTLM fprintf(stderr, "AUTHENTICATE_MESSAGE (length = %d)\n", length); - winpr_HexDump(s->buffer, length); + winpr_HexDump(Stream_Buffer(s), length); fprintf(stderr, "\n"); ntlm_print_negotiate_flags(message->NegotiateFlags); diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index fe5e3bc27..1605c5332 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -127,7 +127,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) { s = pool->aArray[index]; - if (s->capacity >= size) + if (Stream_Capacity(s) >= size) { foundIndex = index; found = TRUE; @@ -247,7 +247,7 @@ wStream* StreamPool_Find(wStreamPool* pool, BYTE* ptr) { s = pool->uArray[index]; - if ((ptr >= s->buffer) && (ptr < (s->buffer + s->capacity))) + if ((ptr >= Stream_Buffer(s)) && (ptr < (Stream_Buffer(s) + Stream_Capacity(s)))) { found = TRUE; break; From 032fd11928bfc90aa93c384398756cee61a2cb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 12:40:56 -0400 Subject: [PATCH 119/144] cmake: check for XITouchClass --- cmake/FindXi.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/FindXi.cmake b/cmake/FindXi.cmake index 80bcdd694..d01f4002b 100644 --- a/cmake/FindXi.cmake +++ b/cmake/FindXi.cmake @@ -28,6 +28,8 @@ # limitations under the License. #============================================================================= +include(CheckSymbolExists) + find_path(XI_INCLUDE_DIR NAMES X11/extensions/XInput2.h DOC "The Xi include directory") @@ -37,6 +39,14 @@ find_library(XI_LIBRARY NAMES Xi include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xi DEFAULT_MSG XI_LIBRARY XI_INCLUDE_DIR) +if(XI_FOUND) + check_symbol_exists(XITouchClass "${XI_INCLUDE_DIR}/X11/extensions/XInput2.h" HAVE_XI_TOUCH_CLASS) + + if (NOT HAVE_XI_TOUCH_CLASS) + set(XI_FOUND 0) + endif() +endif() + if(XI_FOUND) set(XI_LIBRARIES ${XI_LIBRARY}) set(XI_INCLUDE_DIRS ${XI_INCLUDE_DIR}) From 5c37356506cd91f23745385fd7d1731d06301581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 13:17:29 -0400 Subject: [PATCH 120/144] libfreerdp-core: reduce reuse of the same send buffer --- libfreerdp/core/connection.c | 7 ++- libfreerdp/core/license.c | 10 ++++- libfreerdp/core/mcs.c | 87 ++++++++++++++++++++++++------------ libfreerdp/core/nego.c | 15 +++++-- libfreerdp/core/transport.c | 1 - 5 files changed, 84 insertions(+), 36 deletions(-) diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 4b01b9411..2ce41eb11 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -270,7 +270,7 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) } /* encrypt client random */ - memset(crypt_client_random, 0, sizeof(crypt_client_random)); + ZeroMemory(crypt_client_random, sizeof(crypt_client_random)); crypto_nonce(client_random, sizeof(client_random)); key_len = rdp->settings->RdpServerCertificate->cert_info.ModulusLength; mod = rdp->settings->RdpServerCertificate->cert_info.Modulus; @@ -279,7 +279,7 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) /* send crypt client random to server */ length = RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + 4 + key_len + 8; - s = transport_send_stream_init(rdp->mcs->transport, length); + s = Stream_New(NULL, length); rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); rdp_write_security_header(s, SEC_EXCHANGE_PKT); @@ -294,6 +294,8 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) return FALSE; } + Stream_Free(s, TRUE); + /* now calculate encrypt / decrypt and update keys */ if (!security_establish_keys(client_random, rdp)) { @@ -301,6 +303,7 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp) } rdp->do_crypt = TRUE; + if (rdp->settings->SaltedChecksum) rdp->do_secure_checksum = TRUE; diff --git a/libfreerdp/core/license.c b/libfreerdp/core/license.c index 77e4088a8..b98d41e9a 100644 --- a/libfreerdp/core/license.c +++ b/libfreerdp/core/license.c @@ -163,7 +163,7 @@ wStream* license_send_stream_init(rdpLicense* license) { wStream* s; - s = transport_send_stream_init(license->rdp->transport, 4096); + s = Stream_New(NULL, 4096); Stream_Seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH); return s; @@ -212,6 +212,8 @@ BOOL license_send(rdpLicense* license, wStream* s, BYTE type) if (transport_write(license->rdp->transport, s) < 0) return FALSE; + Stream_Free(s, TRUE); + return TRUE; } @@ -578,6 +580,8 @@ BOOL license_read_binary_blob(wStream* s, LICENSE_BLOB* blob) void license_write_binary_blob(wStream* s, LICENSE_BLOB* blob) { + Stream_EnsureRemainingCapacity(s, blob->length + 4); + Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ Stream_Write_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ @@ -597,6 +601,8 @@ void license_write_encrypted_premaster_secret_blob(wStream* s, LICENSE_BLOB* blo return; } + Stream_EnsureRemainingCapacity(s, length + 4); + Stream_Write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ Stream_Write_UINT16(s, length); /* wBlobLen (2 bytes) */ @@ -991,6 +997,8 @@ void license_write_platform_challenge_response_packet(rdpLicense* license, wStre { license_write_binary_blob(s, license->EncryptedPlatformChallenge); /* EncryptedPlatformChallengeResponse */ license_write_binary_blob(s, license->EncryptedHardwareId); /* EncryptedHWID */ + + Stream_EnsureRemainingCapacity(s, 16); Stream_Write(s, macData, 16); /* MACData */ } diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index a672e4e27..a25304594 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -261,6 +261,7 @@ static void mcs_init_domain_parameters(DomainParameters* domainParameters, BOOL mcs_read_domain_parameters(wStream* s, DomainParameters* domainParameters) { int length; + return ber_read_sequence_tag(s, &length) && ber_read_integer(s, &(domainParameters->maxChannelIds)) && @@ -453,12 +454,12 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data) BOOL mcs_send_connect_initial(rdpMcs* mcs) { - wStream* s; + int status; int length; + wStream* s; BYTE *bm, *em; wStream* gcc_CCrq; wStream* client_data; - int status; client_data = Stream_New(NULL, 512); gcc_write_client_data_blocks(client_data, mcs->transport->settings); @@ -467,7 +468,8 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) gcc_write_conference_create_request(gcc_CCrq, client_data); length = Stream_GetPosition(gcc_CCrq) + 7; - s = transport_send_stream_init(mcs->transport, 1024); + s = Stream_New(NULL, 1024 + length); + Stream_GetPointer(s, bm); Stream_Seek(s, 7); @@ -483,6 +485,7 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) status = transport_write(mcs->transport, s); + Stream_Free(s, TRUE); Stream_Free(gcc_CCrq, TRUE); Stream_Free(client_data, TRUE); @@ -533,9 +536,9 @@ BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s) BOOL mcs_send_connect_response(rdpMcs* mcs) { - wStream* s; int length; - int ret; + int status; + wStream* s; BYTE *bm, *em; wStream* gcc_CCrsp; wStream* server_data; @@ -547,7 +550,8 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) gcc_write_conference_create_response(gcc_CCrsp, server_data); length = Stream_GetPosition(gcc_CCrsp) + 7; - s = transport_send_stream_init(mcs->transport, 1024); + s = Stream_New(NULL, length + 1024); + Stream_GetPointer(s, bm); Stream_Seek(s, 7); @@ -561,12 +565,13 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) Stream_SetPointer(s, em); Stream_SealLength(s); - ret = transport_write(mcs->transport, s); + status = transport_write(mcs->transport, s); + Stream_Free(s, TRUE); Stream_Free(gcc_CCrsp, TRUE); Stream_Free(server_data, TRUE); - return (ret < 0) ? FALSE : TRUE; + return (status < 0) ? FALSE : TRUE; } /** @@ -582,6 +587,7 @@ BOOL mcs_recv_erect_domain_request(rdpMcs* mcs, wStream* s) enum DomainMCSPDU MCSPDU; MCSPDU = DomainMCSPDU_ErectDomainRequest; + return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length); } @@ -594,8 +600,10 @@ BOOL mcs_recv_erect_domain_request(rdpMcs* mcs, wStream* s) BOOL mcs_send_erect_domain_request(rdpMcs* mcs) { wStream* s; + int status; UINT16 length = 12; - s = transport_send_stream_init(mcs->transport, length); + + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ErectDomainRequest, length, 0); @@ -604,10 +612,11 @@ BOOL mcs_send_erect_domain_request(rdpMcs* mcs) Stream_SealLength(s); - if (transport_write(mcs->transport, s) < 0) - return FALSE; + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** @@ -623,6 +632,7 @@ BOOL mcs_recv_attach_user_request(rdpMcs* mcs, wStream* s) enum DomainMCSPDU MCSPDU; MCSPDU = DomainMCSPDU_AttachUserRequest; + return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length); } @@ -635,17 +645,20 @@ BOOL mcs_recv_attach_user_request(rdpMcs* mcs, wStream* s) BOOL mcs_send_attach_user_request(rdpMcs* mcs) { wStream* s; + int status; UINT16 length = 8; - s = transport_send_stream_init(mcs->transport, length); + + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserRequest, length, 0); Stream_SealLength(s); - if (transport_write(mcs->transport, s) < 0) - return FALSE; + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** @@ -661,6 +674,7 @@ BOOL mcs_recv_attach_user_confirm(rdpMcs* mcs, wStream* s) enum DomainMCSPDU MCSPDU; MCSPDU = DomainMCSPDU_AttachUserConfirm; + return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length) && per_read_enumerated(s, &result, MCS_Result_enum_length) && /* result */ @@ -676,9 +690,10 @@ BOOL mcs_recv_attach_user_confirm(rdpMcs* mcs, wStream* s) BOOL mcs_send_attach_user_confirm(rdpMcs* mcs) { wStream* s; + int status; UINT16 length = 11; - s = transport_send_stream_init(mcs->transport, length); + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, length, 2); @@ -688,9 +703,11 @@ BOOL mcs_send_attach_user_confirm(rdpMcs* mcs) Stream_SealLength(s); - transport_write(mcs->transport, s); + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** @@ -707,6 +724,7 @@ BOOL mcs_recv_channel_join_request(rdpMcs* mcs, wStream* s, UINT16* channel_id) UINT16 user_id; MCSPDU = DomainMCSPDU_ChannelJoinRequest; + return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length) && per_read_integer16(s, &user_id, MCS_BASE_CHANNEL_ID) && @@ -724,8 +742,10 @@ BOOL mcs_recv_channel_join_request(rdpMcs* mcs, wStream* s, UINT16* channel_id) BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channel_id) { wStream* s; + int status; UINT16 length = 12; - s = transport_send_stream_init(mcs->transport, 12); + + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinRequest, length, 0); @@ -734,10 +754,11 @@ BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channel_id) Stream_SealLength(s); - if (transport_write(mcs->transport, s) < 0) - return FALSE; + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** @@ -776,8 +797,10 @@ BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channel_id) BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channel_id) { wStream* s; + int status; UINT16 length = 15; - s = transport_send_stream_init(mcs->transport, 15); + + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, length, 2); @@ -788,9 +811,11 @@ BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channel_id) Stream_SealLength(s); - transport_write(mcs->transport, s); + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** @@ -801,16 +826,20 @@ BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channel_id) BOOL mcs_send_disconnect_provider_ultimatum(rdpMcs* mcs) { wStream* s; + int status; UINT16 length = 9; - s = transport_send_stream_init(mcs->transport, 9); + + s = Stream_New(NULL, length); mcs_write_domain_mcspdu_header(s, DomainMCSPDU_DisconnectProviderUltimatum, length, 1); per_write_enumerated(s, 0, 0); /* reason */ - transport_write(mcs->transport, s); + status = transport_write(mcs->transport, s); - return TRUE; + Stream_Free(s, TRUE); + + return (status < 0) ? FALSE : TRUE; } /** diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 7f43bf18f..5499ea174 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -276,7 +276,8 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego) cbSize += cchPCB * 2; } - s = transport_send_stream_init(nego->transport, cbSize); + s = Stream_New(NULL, cbSize); + Stream_Write_UINT32(s, cbSize); /* cbSize */ Stream_Write_UINT32(s, 0); /* Flags */ Stream_Write_UINT32(s, PRECONNECTION_PDU_V2); /* Version */ @@ -294,6 +295,8 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego) if (transport_write(nego->transport, s) < 0) return FALSE; + Stream_Free(s, TRUE); + return TRUE; } @@ -646,7 +649,8 @@ BOOL nego_send_negotiation_request(rdpNego* nego) BYTE *bm, *em; int cookie_length; - s = transport_send_stream_init(nego->transport, 256); + s = Stream_New(NULL, 512); + length = TPDU_CONNECTION_REQUEST_LENGTH; Stream_GetPointer(s, bm); Stream_Seek(s, length); @@ -695,6 +699,8 @@ BOOL nego_send_negotiation_request(rdpNego* nego) if (transport_write(nego->transport, s) < 0) return FALSE; + Stream_Free(s, TRUE); + return TRUE; } @@ -812,7 +818,8 @@ BOOL nego_send_negotiation_response(rdpNego* nego) status = TRUE; settings = nego->transport->settings; - s = transport_send_stream_init(nego->transport, 256); + s = Stream_New(NULL, 512); + length = TPDU_CONNECTION_CONFIRM_LENGTH; Stream_GetPointer(s, bm); Stream_Seek(s, length); @@ -852,6 +859,8 @@ BOOL nego_send_negotiation_response(rdpNego* nego) if (transport_write(nego->transport, s) < 0) return FALSE; + Stream_Free(s, TRUE); + if (status) { /* update settings with negotiated protocol security */ diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index e0ea3f0f1..e4ccccc73 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -498,7 +498,6 @@ static int transport_read_nonblocking(rdpTransport* transport) { int status; - Stream_EnsureCapacity(transport->ReceiveBuffer, 32 * 1024); status = transport_read(transport, transport->ReceiveBuffer); if (status <= 0) From fc592a17501cdf0e692ae492d9d0a7750edab135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 14:42:37 -0400 Subject: [PATCH 121/144] libfreerdp-core: replace usage of Stream_GetPointer() by Stream_GetPosition() in potentially unsafe places --- libfreerdp/core/capabilities.c | 107 +++++++++++++++++---------------- libfreerdp/core/mcs.c | 20 +++--- libfreerdp/core/nego.c | 23 ++++--- libfreerdp/core/orders.c | 11 +++- libfreerdp/core/rdp.c | 9 +-- 5 files changed, 89 insertions(+), 81 deletions(-) diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index 8080f9e2e..aedafb560 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -124,27 +124,27 @@ void rdp_write_capability_set_header(wStream* s, UINT16 length, UINT16 type) Stream_Write_UINT16(s, length); /* lengthCapability */ } -BYTE* rdp_capability_set_start(wStream* s) +int rdp_capability_set_start(wStream* s) { - BYTE* header; + int header; - Stream_GetPointer(s, header); + header = Stream_GetPosition(s); Stream_Zero(s, CAPSET_HEADER_LENGTH); return header; } -void rdp_capability_set_finish(wStream* s, BYTE* header, UINT16 type) +void rdp_capability_set_finish(wStream* s, int header, UINT16 type) { + int footer; UINT16 length; - BYTE* footer; - footer = s->pointer; + footer = Stream_GetPosition(s); length = footer - header; - Stream_SetPointer(s, header); + Stream_SetPosition(s, header); rdp_write_capability_set_header(s, length, type); - Stream_SetPointer(s, footer); + Stream_SetPosition(s, footer); } /** @@ -206,7 +206,7 @@ BOOL rdp_read_general_capability_set(wStream* s, UINT16 length, rdpSettings* set void rdp_write_general_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 extraFlags; header = rdp_capability_set_start(s); @@ -344,7 +344,7 @@ BOOL rdp_read_bitmap_capability_set(wStream* s, UINT16 length, rdpSettings* sett void rdp_write_bitmap_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; BYTE drawingFlags = 0; UINT16 desktopResizeFlag; UINT16 preferredBitsPerPixel; @@ -484,7 +484,7 @@ BOOL rdp_read_order_capability_set(wStream* s, UINT16 length, rdpSettings* setti void rdp_write_order_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 orderFlags; UINT16 orderSupportExFlags; UINT16 textANSICodePage; @@ -666,8 +666,8 @@ BOOL rdp_read_bitmap_cache_capability_set(wStream* s, UINT16 length, rdpSettings void rdp_write_bitmap_cache_capability_set(wStream* s, rdpSettings* settings) { int bpp; + int header; UINT16 size; - BYTE* header; header = rdp_capability_set_start(s); @@ -770,7 +770,7 @@ BOOL rdp_read_control_capability_set(wStream* s, UINT16 length, rdpSettings* set void rdp_write_control_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -837,7 +837,7 @@ BOOL rdp_read_window_activation_capability_set(wStream* s, UINT16 length, rdpSet void rdp_write_window_activation_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -914,7 +914,7 @@ BOOL rdp_read_pointer_capability_set(wStream* s, UINT16 length, rdpSettings* set void rdp_write_pointer_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 colorPointerFlag; header = rdp_capability_set_start(s); @@ -982,7 +982,7 @@ BOOL rdp_read_share_capability_set(wStream* s, UINT16 length, rdpSettings* setti void rdp_write_share_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 nodeId; header = rdp_capability_set_start(s); @@ -1042,7 +1042,7 @@ BOOL rdp_read_color_cache_capability_set(wStream* s, UINT16 length, rdpSettings* void rdp_write_color_cache_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -1103,7 +1103,7 @@ BOOL rdp_read_sound_capability_set(wStream* s, UINT16 length, rdpSettings* setti void rdp_write_sound_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 soundFlags; header = rdp_capability_set_start(s); @@ -1198,7 +1198,7 @@ BOOL rdp_read_input_capability_set(wStream* s, UINT16 length, rdpSettings* setti void rdp_write_input_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 inputFlags; header = rdp_capability_set_start(s); @@ -1282,7 +1282,7 @@ BOOL rdp_read_font_capability_set(wStream* s, UINT16 length, rdpSettings* settin void rdp_write_font_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -1338,7 +1338,7 @@ BOOL rdp_read_brush_capability_set(wStream* s, UINT16 length, rdpSettings* setti void rdp_write_brush_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -1419,7 +1419,7 @@ BOOL rdp_read_glyph_cache_capability_set(wStream* s, UINT16 length, rdpSettings* void rdp_write_glyph_cache_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -1522,7 +1522,7 @@ BOOL rdp_read_offscreen_bitmap_cache_capability_set(wStream* s, UINT16 length, r void rdp_write_offscreen_bitmap_cache_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 offscreenSupportLevel = FALSE; header = rdp_capability_set_start(s); @@ -1593,7 +1593,7 @@ BOOL rdp_read_bitmap_cache_host_support_capability_set(wStream* s, UINT16 length void rdp_write_bitmap_cache_host_support_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -1689,7 +1689,7 @@ BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, UINT16 length, rdpSetti void rdp_write_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 cacheFlags; header = rdp_capability_set_start(s); @@ -1784,7 +1784,7 @@ BOOL rdp_read_virtual_channel_capability_set(wStream* s, UINT16 length, rdpSetti void rdp_write_virtual_channel_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 flags; header = rdp_capability_set_start(s); @@ -1855,7 +1855,7 @@ BOOL rdp_read_draw_nine_grid_cache_capability_set(wStream* s, UINT16 length, rdp void rdp_write_draw_nine_grid_cache_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 drawNineGridSupportLevel; header = rdp_capability_set_start(s); @@ -1952,7 +1952,7 @@ BOOL rdp_read_draw_gdiplus_cache_capability_set(wStream* s, UINT16 length, rdpSe void rdp_write_draw_gdiplus_cache_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 drawGDIPlusSupportLevel; UINT32 drawGdiplusCacheLevel; @@ -2029,7 +2029,7 @@ BOOL rdp_read_remote_programs_capability_set(wStream* s, UINT16 length, rdpSetti void rdp_write_remote_programs_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 railSupportLevel; header = rdp_capability_set_start(s); @@ -2089,7 +2089,7 @@ BOOL rdp_read_window_list_capability_set(wStream* s, UINT16 length, rdpSettings* void rdp_write_window_list_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 wndSupportLevel; header = rdp_capability_set_start(s); @@ -2152,7 +2152,7 @@ BOOL rdp_read_desktop_composition_capability_set(wStream* s, UINT16 length, rdpS void rdp_write_desktop_composition_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 compDeskSupportLevel; header = rdp_capability_set_start(s); @@ -2209,7 +2209,7 @@ BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdp void rdp_write_multifragment_update_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); @@ -2261,7 +2261,7 @@ BOOL rdp_read_large_pointer_capability_set(wStream* s, UINT16 length, rdpSetting void rdp_write_large_pointer_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT16 largePointerSupportFlags; header = rdp_capability_set_start(s); @@ -2319,7 +2319,7 @@ BOOL rdp_read_surface_commands_capability_set(wStream* s, UINT16 length, rdpSett void rdp_write_surface_commands_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 cmdFlags; header = rdp_capability_set_start(s); @@ -2618,7 +2618,7 @@ void rdp_write_nsc_server_capability_container(wStream* s, rdpSettings* settings void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; BYTE bitmapCodecCount; header = rdp_capability_set_start(s); @@ -2786,7 +2786,7 @@ BOOL rdp_read_frame_acknowledge_capability_set(wStream* s, UINT16 length, rdpSet void rdp_write_frame_acknowledge_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; UINT32 frame_acknowledge; header = rdp_capability_set_start(s); @@ -2827,10 +2827,11 @@ BOOL rdp_read_bitmap_cache_v3_codec_id_capability_set(wStream* s, UINT16 length, void rdp_write_bitmap_cache_v3_codec_id_capability_set(wStream* s, rdpSettings* settings) { - BYTE* header; + int header; header = rdp_capability_set_start(s); Stream_Write_UINT8(s, settings->BitmapCacheV3CodecId); + rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_V3_CODEC_ID); } @@ -3328,18 +3329,18 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s) void rdp_write_demand_active(wStream* s, rdpSettings* settings) { - BYTE *bm, *em, *lm; + int bm, em, lm; UINT16 numberCapabilities; UINT16 lengthCombinedCapabilities; Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ Stream_Write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ - Stream_GetPointer(s, lm); + lm = Stream_GetPosition(s); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ Stream_Write(s, "RDP", 4); /* sourceDescriptor */ - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ @@ -3365,23 +3366,23 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) rdp_write_bitmap_cache_host_support_capability_set(s, settings); } - Stream_GetPointer(s, em); + em = Stream_GetPosition(s); - Stream_SetPointer(s, lm); /* go back to lengthCombinedCapabilities */ + Stream_SetPosition(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - Stream_SetPointer(s, bm); /* go back to numberCapabilities */ + Stream_SetPosition(s, bm); /* go back to numberCapabilities */ Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); - Stream_SetPointer(s, bm); + Stream_SetPosition(s, bm); Stream_Seek_UINT16(s); #endif - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); Stream_Write_UINT32(s, 0); /* sessionId */ } @@ -3440,7 +3441,7 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s) void rdp_write_confirm_active(wStream* s, rdpSettings* settings) { - BYTE *bm, *em, *lm; + int bm, em, lm; UINT16 numberCapabilities; UINT16 lengthSourceDescriptor; UINT16 lengthCombinedCapabilities; @@ -3451,11 +3452,11 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) Stream_Write_UINT16(s, 0x03EA); /* originatorId (2 bytes) */ Stream_Write_UINT16(s, lengthSourceDescriptor);/* lengthSourceDescriptor (2 bytes) */ - Stream_GetPointer(s, lm); + lm = Stream_GetPosition(s); Stream_Seek_UINT16(s); /* lengthCombinedCapabilities (2 bytes) */ Stream_Write(s, SOURCE_DESCRIPTOR, lengthSourceDescriptor); /* sourceDescriptor */ - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek_UINT16(s); /* numberCapabilities (2 bytes) */ Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */ @@ -3550,23 +3551,23 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) } } - Stream_GetPointer(s, em); + em = Stream_GetPosition(s); - Stream_SetPointer(s, lm); /* go back to lengthCombinedCapabilities */ + Stream_SetPosition(s, lm); /* go back to lengthCombinedCapabilities */ lengthCombinedCapabilities = (em - bm); Stream_Write_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */ - Stream_SetPointer(s, bm); /* go back to numberCapabilities */ + Stream_SetPosition(s, bm); /* go back to numberCapabilities */ Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */ #ifdef WITH_DEBUG_CAPABILITIES Stream_Seek_UINT16(s); rdp_print_capability_sets(s, numberCapabilities, FALSE); - Stream_SetPointer(s, bm); + Stream_SetPosition(s, bm); Stream_Seek_UINT16(s); #endif - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); } BOOL rdp_send_confirm_active(rdpRdp* rdp) diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index a25304594..d5ea0899b 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -457,7 +457,7 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) int status; int length; wStream* s; - BYTE *bm, *em; + int bm, em; wStream* gcc_CCrq; wStream* client_data; @@ -470,17 +470,17 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs) s = Stream_New(NULL, 1024 + length); - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek(s, 7); mcs_write_connect_initial(s, mcs, gcc_CCrq); - Stream_GetPointer(s, em); + em = Stream_GetPosition(s); length = (em - bm); - Stream_SetPointer(s, bm); + Stream_SetPosition(s, bm); tpkt_write_header(s, length); tpdu_write_data(s); - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); Stream_SealLength(s); status = transport_write(mcs->transport, s); @@ -539,7 +539,7 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) int length; int status; wStream* s; - BYTE *bm, *em; + int bm, em; wStream* gcc_CCrsp; wStream* server_data; @@ -552,17 +552,17 @@ BOOL mcs_send_connect_response(rdpMcs* mcs) s = Stream_New(NULL, length + 1024); - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek(s, 7); mcs_write_connect_response(s, mcs, gcc_CCrsp); - Stream_GetPointer(s, em); + em = Stream_GetPosition(s); length = (em - bm); - Stream_SetPointer(s, bm); + Stream_SetPosition(s, bm); tpkt_write_header(s, length); tpdu_write_data(s); - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); Stream_SealLength(s); status = transport_write(mcs->transport, s); diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 5499ea174..a9ff67636 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -646,13 +646,13 @@ BOOL nego_send_negotiation_request(rdpNego* nego) { wStream* s; int length; - BYTE *bm, *em; + int bm, em; int cookie_length; s = Stream_New(NULL, 512); length = TPDU_CONNECTION_REQUEST_LENGTH; - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek(s, length); if (nego->RoutingToken) @@ -688,11 +688,11 @@ BOOL nego_send_negotiation_request(rdpNego* nego) length += 8; } - Stream_GetPointer(s, em); - Stream_SetPointer(s, bm); + em = Stream_GetPosition(s); + Stream_SetPosition(s, bm); tpkt_write_header(s, length); tpdu_write_connection_request(s, length - 5); - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); Stream_SealLength(s); @@ -808,11 +808,10 @@ void nego_process_negotiation_failure(rdpNego* nego, wStream* s) BOOL nego_send_negotiation_response(rdpNego* nego) { - wStream* s; - BYTE* bm; - BYTE* em; int length; + int bm, em; BOOL status; + wStream* s; rdpSettings* settings; status = TRUE; @@ -821,7 +820,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego) s = Stream_New(NULL, 512); length = TPDU_CONNECTION_CONFIRM_LENGTH; - Stream_GetPointer(s, bm); + bm = Stream_GetPosition(s); Stream_Seek(s, length); if (nego->selected_protocol > PROTOCOL_RDP) @@ -848,11 +847,11 @@ BOOL nego_send_negotiation_response(rdpNego* nego) status = FALSE; } - Stream_GetPointer(s, em); - Stream_SetPointer(s, bm); + em = Stream_GetPosition(s); + Stream_SetPosition(s, bm); tpkt_write_header(s, length); tpdu_write_connection_confirm(s, length - 5); - Stream_SetPointer(s, em); + Stream_SetPosition(s, em); Stream_SealLength(s); diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index dd85fac21..6fef8dff2 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -662,10 +662,11 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; + Stream_GetPointer(s, zeroBits); Stream_Seek(s, zeroBitsSize); - memset(rectangles, 0, sizeof(DELTA_RECT) * (number + 1)); + ZeroMemory(rectangles, sizeof(DELTA_RECT) * (number + 1)); for (i = 1; i < number + 1; i++) { @@ -684,7 +685,9 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i return FALSE; } else + { rectangles[i].width = rectangles[i - 1].width; + } if (~flags & 0x10) { @@ -692,13 +695,16 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, i return FALSE; } else + { rectangles[i].height = rectangles[i - 1].height; + } rectangles[i].left = rectangles[i].left + rectangles[i - 1].left; rectangles[i].top = rectangles[i].top + rectangles[i - 1].top; flags <<= 4; } + return TRUE; } @@ -713,10 +719,11 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int if (Stream_GetRemainingLength(s) < zeroBitsSize) return FALSE; + Stream_GetPointer(s, zeroBits); Stream_Seek(s, zeroBitsSize); - memset(points, 0, sizeof(DELTA_POINT) * number); + ZeroMemory(points, sizeof(DELTA_POINT) * number); for (i = 0; i < number; i++) { diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 1fd072377..ea3c978e9 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -772,7 +772,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) UINT16 pduSource; UINT16 channelId; UINT16 securityFlags; - BYTE* nextp; + int nextPosition; if (!rdp_read_header(rdp, s, &length, &channelId)) { @@ -815,12 +815,12 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) { while (Stream_GetRemainingLength(s) > 3) { - Stream_GetPointer(s, nextp); + nextPosition = Stream_GetPosition(s); if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource)) return -1; - nextp += pduLength; + nextPosition += pduLength; rdp->settings->PduSource = pduSource; @@ -848,7 +848,8 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) fprintf(stderr, "incorrect PDU type: 0x%04X\n", pduType); break; } - Stream_SetPointer(s, nextp); + + Stream_SetPosition(s, nextPosition); } } From 202614a1a4fc90e0626a4449f2fd840c1f29959b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 15:54:33 -0400 Subject: [PATCH 122/144] libfreerdp-core: reduce reuse of same pdu buffers --- libfreerdp/core/activation.c | 31 +++++++++--- libfreerdp/core/capabilities.c | 92 ++++++++++++++++++++++++++++++++-- libfreerdp/core/channel.c | 4 +- libfreerdp/core/info.c | 14 ++++-- libfreerdp/core/nego.c | 22 ++++++-- libfreerdp/core/rdp.c | 71 +++++++++++--------------- libfreerdp/core/rdp.h | 4 +- libfreerdp/core/transport.c | 12 ----- libfreerdp/core/transport.h | 1 - 9 files changed, 177 insertions(+), 74 deletions(-) diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 617537a3e..58d80ed82 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -285,17 +285,24 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s) */ if (Stream_GetRemainingLength(s) > 0) { - do { - if(Stream_GetRemainingLength(s) < 4) + do + { + if (Stream_GetRemainingLength(s) < 4) break; + Stream_Read_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ - if(Stream_GetRemainingLength(s) < 2) + + if (Stream_GetRemainingLength(s) < 2) break; + Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */ - if(Stream_GetRemainingLength(s) < lengthSourceDescriptor) + + if (Stream_GetRemainingLength(s) < lengthSourceDescriptor) break; + Stream_Seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */ - } while(0); + } + while(0); } rdp->state = CONNECTION_STATE_CAPABILITY; @@ -304,6 +311,7 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s) { if (rdp_check_fds(rdp) < 0) return FALSE; + if (rdp->disconnect) break; } @@ -314,14 +322,20 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s) BOOL rdp_send_deactivate_all(rdpRdp* rdp) { wStream* s; + BOOL status; - s = rdp_pdu_init(rdp); + s = Stream_New(NULL, 1024); + rdp_init_stream_pdu(rdp, s); Stream_Write_UINT32(s, rdp->settings->ShareId); /* shareId (4 bytes) */ Stream_Write_UINT16(s, 1); /* lengthSourceDescriptor (2 bytes) */ Stream_Write_UINT8(s, 0); /* sourceDescriptor (should be 0x00) */ - return rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id); + status = rdp_send_pdu(rdp, s, PDU_TYPE_DEACTIVATE_ALL, rdp->mcs->user_id); + + Stream_Free(s, TRUE); + + return status; } BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s) @@ -330,11 +344,13 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s) if (!rdp_recv_control_pdu(s, &action)) return FALSE; + if (action == CTRLACTION_REQUEST_CONTROL) { if (!rdp_send_server_control_granted_pdu(rdp)) return FALSE; } + return TRUE; } @@ -342,6 +358,7 @@ BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s) { if (!rdp_recv_client_font_list_pdu(s)) return FALSE; + if (!rdp_send_server_font_map_pdu(rdp)) return FALSE; diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index aedafb560..a5f3f7ee7 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -209,6 +209,8 @@ void rdp_write_general_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 extraFlags; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); extraFlags = LONG_CREDENTIALS_SUPPORTED | NO_BITMAP_COMPRESSION_HDR; @@ -349,6 +351,8 @@ void rdp_write_bitmap_capability_set(wStream* s, rdpSettings* settings) UINT16 desktopResizeFlag; UINT16 preferredBitsPerPixel; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); drawingFlags |= DRAW_ALLOW_SKIP_ALPHA; @@ -489,6 +493,8 @@ void rdp_write_order_capability_set(wStream* s, rdpSettings* settings) UINT16 orderSupportExFlags; UINT16 textANSICodePage; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); /* see [MSDN-CP]: http://msdn.microsoft.com/en-us/library/dd317756 */ @@ -669,6 +675,8 @@ void rdp_write_bitmap_cache_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 size; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); bpp = (settings->ColorDepth + 7) / 8; @@ -772,6 +780,8 @@ void rdp_write_control_capability_set(wStream* s, rdpSettings* settings) { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT16(s, 0); /* controlFlags (2 bytes) */ @@ -839,6 +849,8 @@ void rdp_write_window_activation_capability_set(wStream* s, rdpSettings* setting { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT16(s, 0); /* helpKeyFlag (2 bytes) */ @@ -917,6 +929,8 @@ void rdp_write_pointer_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 colorPointerFlag; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); colorPointerFlag = (settings->ColorPointerFlag) ? 1 : 0; @@ -985,6 +999,8 @@ void rdp_write_share_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 nodeId; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); nodeId = (settings->ServerMode) ? 0x03EA : 0; @@ -1044,6 +1060,8 @@ void rdp_write_color_cache_capability_set(wStream* s, rdpSettings* settings) { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT16(s, 6); /* colorTableCacheSize (2 bytes) */ @@ -1106,6 +1124,8 @@ void rdp_write_sound_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 soundFlags; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); soundFlags = (settings->SoundBeepsEnabled) ? SOUND_BEEPS_FLAG : 0; @@ -1201,6 +1221,8 @@ void rdp_write_input_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 inputFlags; + Stream_EnsureRemainingCapacity(s, 128); + header = rdp_capability_set_start(s); inputFlags = INPUT_FLAG_SCANCODES | INPUT_FLAG_MOUSEX | INPUT_FLAG_UNICODE; @@ -1284,6 +1306,8 @@ void rdp_write_font_capability_set(wStream* s, rdpSettings* settings) { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT16(s, FONTSUPPORT_FONTLIST); /* fontSupportFlags (2 bytes) */ @@ -1340,6 +1364,8 @@ void rdp_write_brush_capability_set(wStream* s, rdpSettings* settings) { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT32(s, BRUSH_COLOR_FULL); /* brushSupportLevel (4 bytes) */ @@ -1421,6 +1447,8 @@ void rdp_write_glyph_cache_capability_set(wStream* s, rdpSettings* settings) { int header; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); /* glyphCache (40 bytes) */ @@ -1525,6 +1553,8 @@ void rdp_write_offscreen_bitmap_cache_capability_set(wStream* s, rdpSettings* se int header; UINT32 offscreenSupportLevel = FALSE; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); if (settings->OffscreenSupportLevel) @@ -1595,6 +1625,8 @@ void rdp_write_bitmap_cache_host_support_capability_set(wStream* s, rdpSettings* { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT8(s, BITMAP_CACHE_V2); /* cacheVersion (1 byte) */ @@ -1692,6 +1724,8 @@ void rdp_write_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 cacheFlags; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); cacheFlags = ALLOW_CACHE_WAITING_LIST_FLAG; @@ -1787,6 +1821,8 @@ void rdp_write_virtual_channel_capability_set(wStream* s, rdpSettings* settings) int header; UINT32 flags; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); flags = VCCAPS_NO_COMPR; @@ -1858,6 +1894,8 @@ void rdp_write_draw_nine_grid_cache_capability_set(wStream* s, rdpSettings* sett int header; UINT32 drawNineGridSupportLevel; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); drawNineGridSupportLevel = (settings->DrawNineGridEnabled) ? DRAW_NINEGRID_SUPPORTED_V2 : DRAW_NINEGRID_NO_SUPPORT; @@ -1956,6 +1994,8 @@ void rdp_write_draw_gdiplus_cache_capability_set(wStream* s, rdpSettings* settin UINT32 drawGDIPlusSupportLevel; UINT32 drawGdiplusCacheLevel; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); drawGDIPlusSupportLevel = (settings->DrawGdiPlusEnabled) ? DRAW_GDIPLUS_SUPPORTED : DRAW_GDIPLUS_DEFAULT; @@ -2032,6 +2072,8 @@ void rdp_write_remote_programs_capability_set(wStream* s, rdpSettings* settings) int header; UINT32 railSupportLevel; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); railSupportLevel = RAIL_LEVEL_SUPPORTED; @@ -2092,6 +2134,8 @@ void rdp_write_window_list_capability_set(wStream* s, rdpSettings* settings) int header; UINT32 wndSupportLevel; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); wndSupportLevel = WINDOW_LEVEL_SUPPORTED_EX; @@ -2155,6 +2199,8 @@ void rdp_write_desktop_composition_capability_set(wStream* s, rdpSettings* setti int header; UINT16 compDeskSupportLevel; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); compDeskSupportLevel = (settings->AllowDesktopComposition) ? COMPDESK_SUPPORTED : COMPDESK_NOT_SUPPORTED; @@ -2211,6 +2257,8 @@ void rdp_write_multifragment_update_capability_set(wStream* s, rdpSettings* sett { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT32(s, settings->MultifragMaxRequestSize); /* MaxRequestSize (4 bytes) */ @@ -2264,6 +2312,8 @@ void rdp_write_large_pointer_capability_set(wStream* s, rdpSettings* settings) int header; UINT16 largePointerSupportFlags; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); largePointerSupportFlags = (settings->LargePointerFlag) ? LARGE_POINTER_FLAG_96x96 : 0; @@ -2322,6 +2372,8 @@ void rdp_write_surface_commands_capability_set(wStream* s, rdpSettings* settings int header; UINT32 cmdFlags; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); cmdFlags = SURFCMDS_FRAME_MARKER | @@ -2520,6 +2572,8 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings UINT32 captureFlags; BYTE codecMode; + Stream_EnsureRemainingCapacity(s, 64); + captureFlags = settings->RemoteFxOnly ? 0 : CARDP_CAPS_CAPTURE_NON_CAC; codecMode = settings->RemoteFxCodecMode; @@ -2567,6 +2621,8 @@ void rdp_write_rfx_client_capability_container(wStream* s, rdpSettings* settings */ void rdp_write_nsc_client_capability_container(wStream* s, rdpSettings* settings) { + Stream_EnsureRemainingCapacity(s, 8); + Stream_Write_UINT16(s, 3); /* codecPropertiesLength */ /* TS_NSCODEC_CAPABILITYSET */ @@ -2577,6 +2633,8 @@ void rdp_write_nsc_client_capability_container(wStream* s, rdpSettings* settings void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* settings) { + Stream_EnsureRemainingCapacity(s, 8); + Stream_Write_UINT16(s, 1); /* codecPropertiesLength */ Stream_Write_UINT8(s, settings->JpegQuality); } @@ -2588,12 +2646,16 @@ void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* setting */ void rdp_write_rfx_server_capability_container(wStream* s, rdpSettings* settings) { + Stream_EnsureRemainingCapacity(s, 8); + Stream_Write_UINT16(s, 4); /* codecPropertiesLength */ Stream_Write_UINT32(s, 0); /* reserved */ } void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* settings) { + Stream_EnsureRemainingCapacity(s, 8); + Stream_Write_UINT16(s, 1); /* codecPropertiesLength */ Stream_Write_UINT8(s, 75); } @@ -2605,6 +2667,8 @@ void rdp_write_jpeg_server_capability_container(wStream* s, rdpSettings* setting */ void rdp_write_nsc_server_capability_container(wStream* s, rdpSettings* settings) { + Stream_EnsureRemainingCapacity(s, 8); + Stream_Write_UINT16(s, 4); /* codecPropertiesLength */ Stream_Write_UINT32(s, 0); /* reserved */ } @@ -2621,6 +2685,8 @@ void rdp_write_bitmap_codecs_capability_set(wStream* s, rdpSettings* settings) int header; BYTE bitmapCodecCount; + Stream_EnsureRemainingCapacity(s, 64); + header = rdp_capability_set_start(s); bitmapCodecCount = 0; @@ -2789,6 +2855,8 @@ void rdp_write_frame_acknowledge_capability_set(wStream* s, rdpSettings* setting int header; UINT32 frame_acknowledge; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); frame_acknowledge = settings->FrameAcknowledge; @@ -2829,6 +2897,8 @@ void rdp_write_bitmap_cache_v3_codec_id_capability_set(wStream* s, rdpSettings* { int header; + Stream_EnsureRemainingCapacity(s, 32); + header = rdp_capability_set_start(s); Stream_Write_UINT8(s, settings->BitmapCacheV3CodecId); @@ -3333,6 +3403,8 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) UINT16 numberCapabilities; UINT16 lengthCombinedCapabilities; + Stream_EnsureRemainingCapacity(s, 64); + Stream_Write_UINT32(s, settings->ShareId); /* shareId (4 bytes) */ Stream_Write_UINT16(s, 4); /* lengthSourceDescriptor (2 bytes) */ @@ -3390,14 +3462,20 @@ void rdp_write_demand_active(wStream* s, rdpSettings* settings) BOOL rdp_send_demand_active(rdpRdp* rdp) { wStream* s; + BOOL status; - s = rdp_pdu_init(rdp); + s = Stream_New(NULL, 4096); + rdp_init_stream_pdu(rdp, s); rdp->settings->ShareId = 0x10000 + rdp->mcs->user_id; rdp_write_demand_active(s, rdp->settings); - return rdp_send_pdu(rdp, s, PDU_TYPE_DEMAND_ACTIVE, rdp->mcs->user_id); + status = rdp_send_pdu(rdp, s, PDU_TYPE_DEMAND_ACTIVE, rdp->mcs->user_id); + + Stream_Free(s, TRUE); + + return status; } BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s) @@ -3573,10 +3651,16 @@ void rdp_write_confirm_active(wStream* s, rdpSettings* settings) BOOL rdp_send_confirm_active(rdpRdp* rdp) { wStream* s; + BOOL status; - s = rdp_pdu_init(rdp); + s = Stream_New(NULL, 4096); + rdp_init_stream_pdu(rdp, s); rdp_write_confirm_active(s, rdp->settings); - return rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id); + status = rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id); + + Stream_Free(s, TRUE); + + return status; } diff --git a/libfreerdp/core/channel.c b/libfreerdp/core/channel.c index 648f78d83..e9b14c27f 100644 --- a/libfreerdp/core/channel.c +++ b/libfreerdp/core/channel.c @@ -118,13 +118,15 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann UINT32 flags; int chunk_length; - if(Stream_GetRemainingLength(s) < 8) + if (Stream_GetRemainingLength(s) < 8) return FALSE; + Stream_Read_UINT32(s, length); Stream_Read_UINT32(s, flags); chunk_length = Stream_GetRemainingLength(s); IFCALL(client->ReceiveChannelData, client, channel_id, Stream_Pointer(s), chunk_length, flags, length); + return TRUE; } diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index a792d2322..cee59322a 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -475,12 +475,20 @@ BOOL rdp_recv_client_info(rdpRdp* rdp, wStream* s) BOOL rdp_send_client_info(rdpRdp* rdp) { wStream* s; + BOOL status; - //rdp->settings->crypt_flags |= SEC_INFO_PKT; rdp->sec_flags |= SEC_INFO_PKT; - s = rdp_send_stream_init(rdp); + + s = Stream_New(NULL, 2048); + rdp_init_stream(rdp, s); + rdp_write_info_packet(s, rdp->settings); - return rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID); + + status = rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID); + + Stream_Free(s, TRUE); + + return status; } BOOL rdp_recv_logon_info_v1(rdpRdp* rdp, wStream* s) diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index a9ff67636..115c1f683 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -467,12 +467,28 @@ void nego_attempt_rdp(rdpNego* nego) BOOL nego_recv_response(rdpNego* nego) { - wStream* s = transport_recv_stream_init(nego->transport, 1024); + int status; + wStream* s; - if (transport_read(nego->transport, s) < 0) + s = Stream_New(NULL, 1024); + + status = transport_read(nego->transport, s); + + if (status < 0) + { + Stream_Free(s, TRUE); return FALSE; + } - return ((nego_recv(nego->transport, s, nego) < 0) ? FALSE : TRUE); + status = nego_recv(nego->transport, s, nego); + + if (status < 0) + { + Stream_Free(s, TRUE); + return FALSE; + } + + return TRUE; } /** diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index ea3c978e9..2f23b895a 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -188,41 +188,43 @@ static int rdp_security_stream_init(rdpRdp* rdp, wStream* s) return 0; } -/** - * Initialize an RDP packet stream.\n - * @param rdp rdp module - * @return - */ +int rdp_init_stream(rdpRdp* rdp, wStream* s) +{ + Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + rdp_security_stream_init(rdp, s); + return 0; +} wStream* rdp_send_stream_init(rdpRdp* rdp) { wStream* s; - s = transport_send_stream_init(rdp->transport, 2048); - Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); - rdp_security_stream_init(rdp, s); - + rdp_init_stream(rdp, s); return s; } -wStream* rdp_pdu_init(rdpRdp* rdp) +int rdp_init_stream_pdu(rdpRdp* rdp, wStream* s) { - wStream* s; - s = transport_send_stream_init(rdp->transport, 2048); Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); rdp_security_stream_init(rdp, s); Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); - return s; + return 0; +} + +int rdp_init_stream_data_pdu(rdpRdp* rdp, wStream* s) +{ + Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); + rdp_security_stream_init(rdp, s); + Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); + Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH); + return 0; } wStream* rdp_data_pdu_init(rdpRdp* rdp) { wStream* s; s = transport_send_stream_init(rdp->transport, 2048); - Stream_Seek(s, RDP_PACKET_HEADER_MAX_LENGTH); - rdp_security_stream_init(rdp, s); - Stream_Seek(s, RDP_SHARE_CONTROL_HEADER_LENGTH); - Stream_Seek(s, RDP_SHARE_DATA_HEADER_LENGTH); + rdp_init_stream_data_pdu(rdp, s); return s; } @@ -264,12 +266,14 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id if (Stream_GetRemainingLength(s) < 5) return FALSE; + per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */ per_read_integer16(s, channel_id, 0); /* channelId */ Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */ if (!per_read_length(s, length)) /* userData (OCTET_STRING) */ return FALSE; + if (*length > Stream_GetRemainingLength(s)) return FALSE; @@ -405,9 +409,9 @@ static UINT32 rdp_get_sec_bytes(rdpRdp* rdp) BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) { + int secm; UINT16 length; UINT32 sec_bytes; - BYTE* sec_hold; length = Stream_GetPosition(s); Stream_SetPosition(s, 0); @@ -415,10 +419,10 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id) rdp_write_header(rdp, s, length, channel_id); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = Stream_Pointer(s); + secm = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); - Stream_Pointer(s) = sec_hold; + Stream_SetPosition(s, secm); length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); @@ -434,7 +438,7 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) { UINT16 length; UINT32 sec_bytes; - BYTE* sec_hold; + int sec_hold; length = Stream_GetPosition(s); Stream_SetPosition(s, 0); @@ -442,12 +446,12 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id) rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = Stream_Pointer(s); + sec_hold = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, type, channel_id); - Stream_Pointer(s) = sec_hold; + Stream_SetPosition(s, sec_hold); length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); @@ -463,7 +467,7 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) { UINT16 length; UINT32 sec_bytes; - BYTE* sec_hold; + int sec_hold; length = Stream_GetPosition(s); Stream_SetPosition(s, 0); @@ -471,13 +475,13 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id) rdp_write_header(rdp, s, length, MCS_GLOBAL_CHANNEL_ID); sec_bytes = rdp_get_sec_bytes(rdp); - sec_hold = Stream_Pointer(s); + sec_hold = Stream_GetPosition(s); Stream_Seek(s, sec_bytes); rdp_write_share_control_header(s, length - sec_bytes, PDU_TYPE_DATA, channel_id); rdp_write_share_data_header(s, length - sec_bytes, type, rdp->settings->ShareId); - Stream_Pointer(s) = sec_hold; + Stream_SetPosition(s, sec_hold); length += rdp_security_stream_out(rdp, s, length); Stream_SetPosition(s, length); @@ -891,21 +895,6 @@ static int rdp_recv_pdu(rdpRdp* rdp, wStream* s) return rdp_recv_fastpath_pdu(rdp, s); } -/** - * Receive an RDP packet.\n - * @param rdp RDP module - */ - -void rdp_recv(rdpRdp* rdp) -{ - wStream* s; - - s = transport_recv_stream_init(rdp->transport, 4096); - transport_read(rdp->transport, s); - - rdp_recv_pdu(rdp, s); -} - static int rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra) { int status = 0; diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index b71413f55..a0f2c9530 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -170,12 +170,13 @@ BOOL rdp_read_share_data_header(wStream* s, UINT16* length, BYTE* type, UINT32* void rdp_write_share_data_header(wStream* s, UINT16 length, BYTE type, UINT32 share_id); +int rdp_init_stream(rdpRdp* rdp, wStream* s); wStream* rdp_send_stream_init(rdpRdp* rdp); BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id); void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id); -wStream* rdp_pdu_init(rdpRdp* rdp); +int rdp_init_stream_pdu(rdpRdp* rdp, wStream* s); BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id); wStream* rdp_data_pdu_init(rdpRdp* rdp); @@ -183,7 +184,6 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id); int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s); BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channel_id); -void rdp_recv(rdpRdp* rdp); int rdp_send_channel_data(rdpRdp* rdp, int channel_id, BYTE* data, int size); diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index e4ccccc73..b1a8f93b8 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -50,14 +50,6 @@ static void* transport_client_thread(void* arg); -wStream* transport_recv_stream_init(rdpTransport* transport, int size) -{ - wStream* s = transport->ReceiveStream; - Stream_EnsureCapacity(s, size); - Stream_SetPosition(s, 0); - return s; -} - wStream* transport_send_stream_init(rdpTransport* transport, int size) { wStream* s = transport->SendStream; @@ -842,7 +834,6 @@ rdpTransport* transport_new(rdpSettings* settings) transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); /* buffers for blocking read/write */ - transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0); transport->SendStream = Stream_New(NULL, BUFFER_SIZE); transport->blocking = TRUE; @@ -860,9 +851,6 @@ void transport_free(rdpTransport* transport) if (transport->ReceiveBuffer) Stream_Release(transport->ReceiveBuffer); - if (transport->ReceiveStream) - Stream_Release(transport->ReceiveStream); - StreamPool_Free(transport->ReceivePool); Stream_Free(transport->SendStream, TRUE); diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 072ca7b9f..777b4d092 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -76,7 +76,6 @@ struct rdp_transport BOOL async; }; -wStream* transport_recv_stream_init(rdpTransport* transport, int size); wStream* transport_send_stream_init(rdpTransport* transport, int size); BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port); void transport_attach(rdpTransport* transport, int sockfd); From 54281cac13efa1e82d617cad460b7433d401538b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 16:22:58 -0400 Subject: [PATCH 123/144] libwinpr-utils: grow stream by a factor of two --- winpr/libwinpr/utils/stream.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 1ebb41688..59285af66 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -31,10 +31,19 @@ void Stream_EnsureCapacity(wStream* s, size_t size) { size_t position; size_t old_capacity; + size_t new_capacity; old_capacity = s->capacity; - s->capacity = size; - s->length = size; + new_capacity = old_capacity; + + do + { + new_capacity *= 2; + } + while (new_capacity < size); + + s->capacity = new_capacity; + s->length = new_capacity; position = Stream_GetPosition(s); From e8c5e6c70b64fa9af359aedd02957f9397d1221b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 18:05:40 -0400 Subject: [PATCH 124/144] libfreerdp-core: send using separate streams, re-enable frame acks --- libfreerdp/core/fastpath.c | 2 +- libfreerdp/core/message.c | 16 ---------------- libfreerdp/core/transport.c | 24 ++++++++++++++++++------ libfreerdp/core/transport.h | 4 ++-- winpr/libwinpr/utils/stream.c | 3 +++ 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 952a11aa9..b8569fc61 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -706,7 +706,7 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNumEvents) { - rdpRdp *rdp; + rdpRdp* rdp; UINT16 length; BYTE eventHeader; int sec_bytes; diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 9eecc0c88..720b13797 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -1520,22 +1520,6 @@ int update_message_queue_process_message(rdpUpdate* update, wMessage* message) if (message->id == WMQ_QUIT) return 0; - /** - * FIXME: - * - * Certain messages like RefreshRect, SuppressOutput and SurfaceFrameAcknowledge - * and not really output but really input events that send a message to the server. - * Right now they will race with other code making use of the transport layer. - */ - - switch (message->id) - { - case FREERDP_UPDATE_REFRESH_RECT: - case FREERDP_UPDATE_SUPPRESS_OUTPUT: - case FREERDP_UPDATE_SURFACE_FRAME_ACKNOWLEDGE: - return 1; - } - msgClass = GetMessageClass(message->id); msgType = GetMessageType(message->id); diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index b1a8f93b8..136d56975 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -52,9 +52,13 @@ static void* transport_client_thread(void* arg); wStream* transport_send_stream_init(rdpTransport* transport, int size) { - wStream* s = transport->SendStream; + wStream* s; + + s = StreamPool_Take(transport->ReceivePool, size); + Stream_EnsureCapacity(s, size); Stream_SetPosition(s, 0); + return s; } @@ -505,6 +509,8 @@ int transport_write(rdpTransport* transport, wStream* s) int length; int status = -1; + WaitForSingleObject(transport->WriteMutex, INFINITE); + length = Stream_GetPosition(s); Stream_SetPosition(s, 0); @@ -556,6 +562,11 @@ int transport_write(rdpTransport* transport, wStream* s) transport->layer = TRANSPORT_LAYER_CLOSED; } + if (s->pool) + Stream_Release(s); + + ReleaseMutex(transport->WriteMutex); + return status; } @@ -833,11 +844,11 @@ rdpTransport* transport_new(rdpSettings* settings) transport->connectedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - /* buffers for blocking read/write */ - transport->SendStream = Stream_New(NULL, BUFFER_SIZE); - transport->blocking = TRUE; + transport->ReadMutex = CreateMutex(NULL, FALSE, NULL); + transport->WriteMutex = CreateMutex(NULL, FALSE, NULL); + transport->layer = TRANSPORT_LAYER_TCP; } @@ -853,9 +864,7 @@ void transport_free(rdpTransport* transport) StreamPool_Free(transport->ReceivePool); - Stream_Free(transport->SendStream, TRUE); CloseHandle(transport->ReceiveEvent); - CloseHandle(transport->connectedEvent); if (transport->TlsIn) @@ -871,6 +880,9 @@ void transport_free(rdpTransport* transport) tsg_free(transport->tsg); + CloseHandle(transport->ReadMutex); + CloseHandle(transport->WriteMutex); + free(transport); } } diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 777b4d092..bb573b6eb 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -60,8 +60,6 @@ struct rdp_transport rdpCredssp* credssp; rdpSettings* settings; UINT32 SleepInterval; - wStream* SendStream; - wStream* ReceiveStream; void* ReceiveExtra; wStream* ReceiveBuffer; TransportRecv ReceiveCallback; @@ -74,6 +72,8 @@ struct rdp_transport HANDLE stopEvent; HANDLE thread; BOOL async; + HANDLE ReadMutex; + HANDLE WriteMutex; }; wStream* transport_send_stream_init(rdpTransport* transport, int size); diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 59285af66..cae3b401e 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -77,6 +77,9 @@ wStream* Stream_New(BYTE* buffer, size_t size) s->pointer = s->buffer; s->capacity = size; s->length = size; + + s->pool = NULL; + s->count = 0; } return s; From 3c2687b7d69298376644497ab38b8c1bcb70df52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 15 May 2013 20:19:26 -0400 Subject: [PATCH 125/144] libfreerdp-crypto: handle EAGAIN with TLS --- libfreerdp/crypto/tls.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index e195031d9..3673e5f9c 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -355,6 +355,18 @@ int tls_read(rdpTls* tls, BYTE* data, int length) status = 0; break; + case SSL_ERROR_SYSCALL: + if (errno == EAGAIN) + { + status = 0; + } + else + { + tls_print_error("SSL_read", tls->ssl, status); + status = -1; + } + break; + default: tls_print_error("SSL_read", tls->ssl, status); status = -1; @@ -403,6 +415,18 @@ int tls_write(rdpTls* tls, BYTE* data, int length) status = 0; break; + case SSL_ERROR_SYSCALL: + if (errno == EAGAIN) + { + status = 0; + } + else + { + tls_print_error("SSL_write", tls->ssl, status); + status = -1; + } + break; + default: tls_print_error("SSL_write", tls->ssl, status); status = -1; @@ -473,7 +497,7 @@ BOOL tls_print_error(char* func, SSL* connection, int value) return FALSE; case SSL_ERROR_SYSCALL: - fprintf(stderr, "%s: I/O error\n", func); + fprintf(stderr, "%s: I/O error: %s (%d)\n", func, strerror(errno), errno); tls_errors(func); return TRUE; From cd8091a31578bb2596db44fd99f42f74682b3505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 14:45:49 -0400 Subject: [PATCH 126/144] freerdp: fix monolithic build with Intel IPP linking --- libfreerdp/CMakeLists.txt | 9 +++++++++ libfreerdp/primitives/CMakeLists.txt | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index b8b6adb28..42c06dd60 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -22,6 +22,15 @@ if(MONOLITHIC_BUILD) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +# Create imported targets for Intel IPP libraries + +if(IPP_FOUND) + foreach(ipp_lib ${IPP_LIBRARIES}) + add_library("${ipp_lib}_imported" STATIC IMPORTED) + set_property(TARGET "${ipp_lib}_imported" PROPERTY IMPORTED_LOCATION "${IPP_LIBRARY_DIRS}/${ipp_lib}") + endforeach() +endif() + set(${MODULE_PREFIX}_SUBMODULES utils common diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index d9db4da17..8aa327c80 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -76,8 +76,6 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVER if(IPP_FOUND) include_directories(${IPP_INCLUDE_DIRS}) foreach(ipp_lib ${IPP_LIBRARIES}) - add_library("${ipp_lib}_imported" STATIC IMPORTED) - set_property(TARGET "${ipp_lib}_imported" PROPERTY IMPORTED_LOCATION "${IPP_LIBRARY_DIRS}/${ipp_lib}") set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} "${ipp_lib}_imported") endforeach() endif() From 72e9087d1f582331d4fcbeb030a5fab6b357045e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 17:32:58 -0400 Subject: [PATCH 127/144] winpr: unify handle types --- winpr/include/winpr/handle.h | 16 ---- winpr/libwinpr/file/file.c | 16 ++-- winpr/libwinpr/handle/CMakeLists.txt | 1 + winpr/libwinpr/handle/handle.c | 17 ++-- winpr/libwinpr/handle/handle.h | 66 +++++++++++++++ winpr/libwinpr/handle/table.c | 120 ++++++++++++--------------- winpr/libwinpr/pipe/CMakeLists.txt | 3 +- winpr/libwinpr/pipe/pipe.c | 21 ++++- winpr/libwinpr/pipe/pipe.h | 41 +++++++++ winpr/libwinpr/synch/event.c | 2 + winpr/libwinpr/synch/mutex.c | 20 +++-- winpr/libwinpr/synch/semaphore.c | 2 + winpr/libwinpr/synch/synch.h | 14 ++++ winpr/libwinpr/synch/wait.c | 8 +- winpr/libwinpr/thread/thread.c | 2 + winpr/libwinpr/thread/thread.h | 6 +- 16 files changed, 246 insertions(+), 109 deletions(-) create mode 100644 winpr/libwinpr/handle/handle.h create mode 100644 winpr/libwinpr/pipe/pipe.h diff --git a/winpr/include/winpr/handle.h b/winpr/include/winpr/handle.h index ef586c223..c418427e8 100644 --- a/winpr/include/winpr/handle.h +++ b/winpr/include/winpr/handle.h @@ -27,26 +27,10 @@ #include <winpr/wtypes.h> #include <winpr/security.h> -#define HANDLE_TYPE_NONE 0 -#define HANDLE_TYPE_THREAD 1 -#define HANDLE_TYPE_EVENT 2 -#define HANDLE_TYPE_MUTEX 3 -#define HANDLE_TYPE_SEMAPHORE 4 -#define HANDLE_TYPE_TIMER 5 -#define HANDLE_TYPE_NAMED_PIPE 6 -#define HANDLE_TYPE_ANONYMOUS_PIPE 7 - #ifdef __cplusplus extern "C" { #endif -WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object); -WINPR_API BOOL winpr_Handle_Remove(HANDLE handle); - -WINPR_API ULONG winpr_Handle_GetType(HANDLE handle); -WINPR_API PVOID winpr_Handle_GetObject(HANDLE handle); -WINPR_API BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject); - #ifndef _WIN32 #define HANDLE_FLAG_INHERIT 0x00000001 diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 16cdabf63..b43cd215c 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -139,6 +139,10 @@ #include <sys/statvfs.h> #endif +#include "../handle/handle.h" + +#include "../pipe/pipe.h" + HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { @@ -166,6 +170,7 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, { ULONG Type; PVOID Object; + WINPR_PIPE* pipe; if (!winpr_Handle_GetInfo(hFile, &Type, &Object)) return FALSE; @@ -173,11 +178,10 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, if (Type == HANDLE_TYPE_ANONYMOUS_PIPE) { int status; - int read_fd; - read_fd = (int) ((ULONG_PTR) Object); + pipe = (WINPR_PIPE*) Object; - status = read(read_fd, lpBuffer, nNumberOfBytesToRead); + status = read(pipe->fd, lpBuffer, nNumberOfBytesToRead); *lpNumberOfBytesRead = status; @@ -204,6 +208,7 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, { ULONG Type; PVOID Object; + WINPR_PIPE* pipe; if (!winpr_Handle_GetInfo(hFile, &Type, &Object)) return FALSE; @@ -211,11 +216,10 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, if (Type == HANDLE_TYPE_ANONYMOUS_PIPE) { int status; - int write_fd; - write_fd = (int) ((ULONG_PTR) Object); + pipe = (WINPR_PIPE*) Object; - status = write(write_fd, lpBuffer, nNumberOfBytesToWrite); + status = write(pipe->fd, lpBuffer, nNumberOfBytesToWrite); *lpNumberOfBytesWritten = status; diff --git a/winpr/libwinpr/handle/CMakeLists.txt b/winpr/libwinpr/handle/CMakeLists.txt index 73b73d336..db25fea70 100644 --- a/winpr/libwinpr/handle/CMakeLists.txt +++ b/winpr/libwinpr/handle/CMakeLists.txt @@ -20,6 +20,7 @@ set(MODULE_PREFIX "WINPR_HANDLE") set(${MODULE_PREFIX}_SRCS handle.c + handle.h table.c) if(MSVC AND (NOT MONOLITHIC_BUILD)) diff --git a/winpr/libwinpr/handle/handle.c b/winpr/libwinpr/handle/handle.c index 1994eae0a..3d23f1f4f 100644 --- a/winpr/libwinpr/handle/handle.c +++ b/winpr/libwinpr/handle/handle.c @@ -27,11 +27,14 @@ #include "../synch/synch.h" #include "../thread/thread.h" +#include "../pipe/pipe.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include "../handle/handle.h" + BOOL CloseHandle(HANDLE hObject) { ULONG Type; @@ -52,7 +55,11 @@ BOOL CloseHandle(HANDLE hObject) } else if (Type == HANDLE_TYPE_MUTEX) { - pthread_mutex_destroy((pthread_mutex_t*) Object); + WINPR_MUTEX* mutex; + + mutex = (WINPR_MUTEX*) Object; + + pthread_mutex_destroy(&mutex->mutex); winpr_Handle_Remove(Object); free(Object); @@ -119,13 +126,13 @@ BOOL CloseHandle(HANDLE hObject) } else if (Type == HANDLE_TYPE_ANONYMOUS_PIPE) { - int pipe_fd; + WINPR_PIPE* pipe; - pipe_fd = (int) ((ULONG_PTR) Object); + pipe = (WINPR_PIPE*) Object; - if (pipe_fd != -1) + if (pipe->fd != -1) { - close(pipe_fd); + close(pipe->fd); } winpr_Handle_Remove(Object); diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h new file mode 100644 index 000000000..afa4caac6 --- /dev/null +++ b/winpr/libwinpr/handle/handle.h @@ -0,0 +1,66 @@ +/** + * WinPR: Windows Portable Runtime + * Handle Management + * + * Copyright 2012 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_HANDLE_PRIVATE_H +#define WINPR_HANDLE_PRIVATE_H + +#include <pthread.h> + +#include <winpr/handle.h> + +#define HANDLE_TYPE_NONE 0 +#define HANDLE_TYPE_THREAD 1 +#define HANDLE_TYPE_EVENT 2 +#define HANDLE_TYPE_MUTEX 3 +#define HANDLE_TYPE_SEMAPHORE 4 +#define HANDLE_TYPE_TIMER 5 +#define HANDLE_TYPE_NAMED_PIPE 6 +#define HANDLE_TYPE_ANONYMOUS_PIPE 7 + +typedef struct _HANDLE_TABLE_ENTRY +{ + ULONG Type; + PVOID Object; +} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY; + +typedef struct _HANDLE_TABLE +{ + LONG Count; + LONG MaxCount; + PHANDLE_TABLE_ENTRY Entries; +} HANDLE_TABLE, *PHANDLE_TABLE; + +#define WINPR_HANDLE_DEF() \ + void* handle + +#define HandleTable_GetInstance() \ + if (g_WinPR_HandleTable.MaxCount < 1) \ + winpr_HandleTable_New() + +extern HANDLE_TABLE g_WinPR_HandleTable; +extern pthread_mutex_t g_WinPR_HandleTable_Mutex; + +WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object); +WINPR_API BOOL winpr_Handle_Remove(HANDLE handle); + +WINPR_API ULONG winpr_Handle_GetType(HANDLE handle); +WINPR_API PVOID winpr_Handle_GetObject(HANDLE handle); +WINPR_API BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject); + +#endif /* WINPR_HANDLE_PRIVATE_H */ diff --git a/winpr/libwinpr/handle/table.c b/winpr/libwinpr/handle/table.c index 40e082c75..73c360445 100644 --- a/winpr/libwinpr/handle/table.c +++ b/winpr/libwinpr/handle/table.c @@ -28,74 +28,58 @@ #include <pthread.h> -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +#include "../handle/handle.h" -typedef struct _HANDLE_TABLE_ENTRY -{ - ULONG Type; - PVOID Object; -} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY; - -typedef struct _HANDLE_TABLE -{ - LONG Count; - LONG MaxCount; - PHANDLE_TABLE_ENTRY Entries; -} HANDLE_TABLE, *PHANDLE_TABLE; - -static HANDLE_TABLE HandleTable = { 0, 0, NULL }; - -#define HandleTable_GetInstance() \ - if (HandleTable.MaxCount < 1) \ - winpr_HandleTable_New() +HANDLE_TABLE g_WinPR_HandleTable = { 0, 0, NULL }; +pthread_mutex_t g_WinPR_HandleTable_Mutex = PTHREAD_MUTEX_INITIALIZER; void winpr_HandleTable_New() { size_t size; - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - if (HandleTable.MaxCount < 1) + if (g_WinPR_HandleTable.MaxCount < 1) { - HandleTable.Count = 0; - HandleTable.MaxCount = 64; + g_WinPR_HandleTable.Count = 0; + g_WinPR_HandleTable.MaxCount = 64; - size = sizeof(HANDLE_TABLE_ENTRY) * HandleTable.MaxCount; + size = sizeof(HANDLE_TABLE_ENTRY) * g_WinPR_HandleTable.MaxCount; - HandleTable.Entries = (PHANDLE_TABLE_ENTRY) malloc(size); - ZeroMemory(HandleTable.Entries, size); + g_WinPR_HandleTable.Entries = (PHANDLE_TABLE_ENTRY) malloc(size); + ZeroMemory(g_WinPR_HandleTable.Entries, size); } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); } void winpr_HandleTable_Grow() { size_t size; - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - HandleTable.MaxCount *= 2; + g_WinPR_HandleTable.MaxCount *= 2; - size = sizeof(HANDLE_TABLE_ENTRY) * HandleTable.MaxCount; + size = sizeof(HANDLE_TABLE_ENTRY) * g_WinPR_HandleTable.MaxCount; - HandleTable.Entries = (PHANDLE_TABLE_ENTRY) realloc(HandleTable.Entries, size); - ZeroMemory((void*) &HandleTable.Entries[HandleTable.MaxCount / 2], size / 2); + g_WinPR_HandleTable.Entries = (PHANDLE_TABLE_ENTRY) realloc(g_WinPR_HandleTable.Entries, size); + ZeroMemory((void*) &g_WinPR_HandleTable.Entries[g_WinPR_HandleTable.MaxCount / 2], size / 2); - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); } void winpr_HandleTable_Free() { - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - HandleTable.Count = 0; - HandleTable.MaxCount = 0; + g_WinPR_HandleTable.Count = 0; + g_WinPR_HandleTable.MaxCount = 0; - free(HandleTable.Entries); - HandleTable.Entries = NULL; + free(g_WinPR_HandleTable.Entries); + g_WinPR_HandleTable.Entries = NULL; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); } HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) @@ -104,24 +88,24 @@ HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) HandleTable_GetInstance(); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - for (index = 0; index < (int) HandleTable.MaxCount; index++) + for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) { - if (HandleTable.Entries[index].Object == NULL) + if (g_WinPR_HandleTable.Entries[index].Object == NULL) { - HandleTable.Count++; + g_WinPR_HandleTable.Count++; - HandleTable.Entries[index].Type = Type; - HandleTable.Entries[index].Object = Object; + g_WinPR_HandleTable.Entries[index].Type = Type; + g_WinPR_HandleTable.Entries[index].Object = Object; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return Object; } } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); /* no available entry was found, the table needs to be grown */ @@ -138,23 +122,23 @@ BOOL winpr_Handle_Remove(HANDLE handle) HandleTable_GetInstance(); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - for (index = 0; index < (int) HandleTable.MaxCount; index++) + for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) { - if (HandleTable.Entries[index].Object == handle) + if (g_WinPR_HandleTable.Entries[index].Object == handle) { - HandleTable.Entries[index].Type = HANDLE_TYPE_NONE; - HandleTable.Entries[index].Object = NULL; - HandleTable.Count--; + g_WinPR_HandleTable.Entries[index].Type = HANDLE_TYPE_NONE; + g_WinPR_HandleTable.Entries[index].Object = NULL; + g_WinPR_HandleTable.Count--; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return TRUE; } } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return FALSE; } @@ -165,18 +149,18 @@ ULONG winpr_Handle_GetType(HANDLE handle) HandleTable_GetInstance(); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - for (index = 0; index < (int) HandleTable.MaxCount; index++) + for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) { - if (HandleTable.Entries[index].Object == handle) + if (g_WinPR_HandleTable.Entries[index].Object == handle) { - pthread_mutex_unlock(&mutex); - return HandleTable.Entries[index].Type; + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); + return g_WinPR_HandleTable.Entries[index].Type; } } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return HANDLE_TYPE_NONE; } @@ -194,22 +178,22 @@ BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) HandleTable_GetInstance(); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - for (index = 0; index < (int) HandleTable.MaxCount; index++) + for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) { - if (HandleTable.Entries[index].Object == handle) + if (g_WinPR_HandleTable.Entries[index].Object == handle) { - *pType = HandleTable.Entries[index].Type; - *pObject = HandleTable.Entries[index].Object; + *pType = g_WinPR_HandleTable.Entries[index].Type; + *pObject = g_WinPR_HandleTable.Entries[index].Object; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return TRUE; } } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return FALSE; } diff --git a/winpr/libwinpr/pipe/CMakeLists.txt b/winpr/libwinpr/pipe/CMakeLists.txt index b5b055828..d30b31cbb 100644 --- a/winpr/libwinpr/pipe/CMakeLists.txt +++ b/winpr/libwinpr/pipe/CMakeLists.txt @@ -19,7 +19,8 @@ set(MODULE_NAME "winpr-pipe") set(MODULE_PREFIX "WINPR_PIPE") set(${MODULE_PREFIX}_SRCS - pipe.c) + pipe.c + pipe.h) if(MSVC AND (NOT MONOLITHIC_BUILD)) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def) diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 14d784beb..6dd510307 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -32,11 +32,17 @@ #ifndef _WIN32 +#include "../handle/handle.h" + +#include "pipe.h" + BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize) { void* ptr; HANDLE handle; int pipe_fd[2]; + WINPR_PIPE* pReadPipe; + WINPR_PIPE* pWritePipe; pipe_fd[0] = -1; pipe_fd[1] = -1; @@ -47,12 +53,19 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP return FALSE; } - ptr = (void*) ((ULONG_PTR) pipe_fd[0]); - handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, ptr); + pReadPipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE)); + pWritePipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE)); + + if (!pReadPipe || !pWritePipe) + return FALSE; + + pReadPipe->fd = pipe_fd[0]; + pWritePipe->fd = pipe_fd[1]; + + handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pReadPipe); *((ULONG_PTR*) hReadPipe) = (ULONG_PTR) handle; - ptr = (void*) ((ULONG_PTR) pipe_fd[1]); - handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, ptr); + handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pWritePipe); *((ULONG_PTR*) hWritePipe) = (ULONG_PTR) handle; return TRUE; diff --git a/winpr/libwinpr/pipe/pipe.h b/winpr/libwinpr/pipe/pipe.h new file mode 100644 index 000000000..f884fdc3f --- /dev/null +++ b/winpr/libwinpr/pipe/pipe.h @@ -0,0 +1,41 @@ +/** + * WinPR: Windows Portable Runtime + * Pipe Functions + * + * Copyright 2012 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_PIPE_PRIVATE_H +#define WINPR_PIPE_PRIVATE_H + +#ifndef _WIN32 + +#include <winpr/pipe.h> + +#include "../handle/handle.h" + +struct winpr_pipe +{ + WINPR_HANDLE_DEF(); + + int fd; +}; +typedef struct winpr_pipe WINPR_PIPE; + +#endif + +#endif /* WINPR_PIPE_PRIVATE_H */ + + diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 8eb8a4aec..a56e53595 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -40,6 +40,8 @@ #include <errno.h> #endif +#include "../handle/handle.h" + CRITICAL_SECTION cs = { NULL, 0, 0, NULL, NULL, 0 }; HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName) diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c index 62c2e2611..e5efded67 100644 --- a/winpr/libwinpr/synch/mutex.c +++ b/winpr/libwinpr/synch/mutex.c @@ -37,19 +37,23 @@ #ifndef _WIN32 +#include "../handle/handle.h" + HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName) { HANDLE handle = NULL; - pthread_mutex_t* pMutex; + WINPR_MUTEX* mutex; - pMutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t)); + mutex = (WINPR_MUTEX*) malloc(sizeof(WINPR_MUTEX)); - if (pMutex) + if (mutex) { - pthread_mutex_init(pMutex, 0); - handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, pMutex); + pthread_mutex_init(&mutex->mutex, 0); + + handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, mutex); + if (bInitialOwner) - pthread_mutex_lock(pMutex); + pthread_mutex_lock(&mutex->mutex); } return handle; @@ -84,13 +88,15 @@ BOOL ReleaseMutex(HANDLE hMutex) { ULONG Type; PVOID Object; + WINPR_MUTEX* mutex; if (!winpr_Handle_GetInfo(hMutex, &Type, &Object)) return FALSE; if (Type == HANDLE_TYPE_MUTEX) { - pthread_mutex_unlock((pthread_mutex_t*) Object); + mutex = (WINPR_MUTEX*) Object; + pthread_mutex_unlock(&mutex->mutex); return TRUE; } diff --git a/winpr/libwinpr/synch/semaphore.c b/winpr/libwinpr/synch/semaphore.c index d0b7f0945..af04911fc 100644 --- a/winpr/libwinpr/synch/semaphore.c +++ b/winpr/libwinpr/synch/semaphore.c @@ -31,6 +31,8 @@ #ifndef _WIN32 +#include "../handle/handle.h" + HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName) { HANDLE handle; diff --git a/winpr/libwinpr/synch/synch.h b/winpr/libwinpr/synch/synch.h index a7c84167e..158f3bcea 100644 --- a/winpr/libwinpr/synch/synch.h +++ b/winpr/libwinpr/synch/synch.h @@ -24,6 +24,8 @@ #ifndef _WIN32 +#include "../handle/handle.h" + #define WINPR_PIPE_SEMAPHORE 1 #if defined __APPLE__ @@ -39,8 +41,18 @@ #define winpr_sem_t sem_t #endif +struct winpr_mutex +{ + WINPR_HANDLE_DEF(); + + pthread_mutex_t mutex; +}; +typedef struct winpr_mutex WINPR_MUTEX; + struct winpr_semaphore { + WINPR_HANDLE_DEF(); + int pipe_fd[2]; winpr_sem_t* sem; }; @@ -48,6 +60,8 @@ typedef struct winpr_semaphore WINPR_SEMAPHORE; struct winpr_event { + WINPR_HANDLE_DEF(); + int pipe_fd[2]; BOOL bAttached; BOOL bManualReset; diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index 441d3ced9..3006fe246 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -41,6 +41,8 @@ #ifndef _WIN32 +#include "../handle/handle.h" + DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { ULONG Type; @@ -70,10 +72,14 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) } else if (Type == HANDLE_TYPE_MUTEX) { + WINPR_MUTEX* mutex; + + mutex = (WINPR_MUTEX*) Object; + if (dwMilliseconds != INFINITE) fprintf(stderr, "WaitForSingleObject: timeout not implemented for mutex wait\n"); - pthread_mutex_lock((pthread_mutex_t*) Object); + pthread_mutex_lock(&mutex->mutex); } else if (Type == HANDLE_TYPE_EVENT) { diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 895c14a1e..5b2ca26e8 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -71,6 +71,8 @@ #include "thread.h" +#include "../handle/handle.h" + /** * TODO: implement thread suspend/resume using pthreads * http://stackoverflow.com/questions/3140867/suspend-pthreads-without-using-condition diff --git a/winpr/libwinpr/thread/thread.h b/winpr/libwinpr/thread/thread.h index 263512fee..c13ff5278 100644 --- a/winpr/libwinpr/thread/thread.h +++ b/winpr/libwinpr/thread/thread.h @@ -22,14 +22,18 @@ #ifndef _WIN32 +#include <pthread.h> + #include <winpr/thread.h> -#include <pthread.h> +#include "../handle/handle.h" typedef void *(*pthread_start_routine)(void*); struct winpr_thread { + WINPR_HANDLE_DEF(); + BOOL started; DWORD dwExitCode; pthread_t thread; From f8b24826da2b3cfcdaf1ac45c3dbd0a1d67cf123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 17:49:41 -0400 Subject: [PATCH 128/144] libwinpr-handle: optimize handle table lookup --- winpr/libwinpr/handle/handle.h | 8 +++++++- winpr/libwinpr/handle/table.c | 24 +++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h index afa4caac6..d69ec2b3b 100644 --- a/winpr/libwinpr/handle/handle.h +++ b/winpr/libwinpr/handle/handle.h @@ -47,7 +47,13 @@ typedef struct _HANDLE_TABLE } HANDLE_TABLE, *PHANDLE_TABLE; #define WINPR_HANDLE_DEF() \ - void* handle + int winpr_Index; + +struct winpr_handle +{ + WINPR_HANDLE_DEF(); +}; +typedef struct winpr_handle WINPR_HANDLE; #define HandleTable_GetInstance() \ if (g_WinPR_HandleTable.MaxCount < 1) \ diff --git a/winpr/libwinpr/handle/table.c b/winpr/libwinpr/handle/table.c index 73c360445..18c114d91 100644 --- a/winpr/libwinpr/handle/table.c +++ b/winpr/libwinpr/handle/table.c @@ -99,6 +99,8 @@ HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) g_WinPR_HandleTable.Entries[index].Type = Type; g_WinPR_HandleTable.Entries[index].Object = Object; + ((WINPR_HANDLE*) Object)->winpr_Index = index; + pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); return Object; @@ -175,27 +177,27 @@ PVOID winpr_Handle_GetObject(HANDLE handle) BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) { int index; + BOOL status = TRUE; HandleTable_GetInstance(); pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) + index = ((WINPR_HANDLE*) handle)->winpr_Index; + + if ((index >= 0) && (index < g_WinPR_HandleTable.MaxCount)) { - if (g_WinPR_HandleTable.Entries[index].Object == handle) - { - *pType = g_WinPR_HandleTable.Entries[index].Type; - *pObject = g_WinPR_HandleTable.Entries[index].Object; - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return TRUE; - } + *pType = g_WinPR_HandleTable.Entries[index].Type; + *pObject = g_WinPR_HandleTable.Entries[index].Object; + } + else + { + status = FALSE; } pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - return FALSE; + return status; } #endif From 23e8af45f0a28330614e7bd0cb44c0ec5543adc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 18:14:37 -0400 Subject: [PATCH 129/144] libwinpr-handle: don't use a centralized handle table as it was a major performance bottleneck --- winpr/libwinpr/handle/handle.h | 26 +----- winpr/libwinpr/handle/table.c | 164 ++------------------------------- 2 files changed, 11 insertions(+), 179 deletions(-) diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h index d69ec2b3b..569dcaa38 100644 --- a/winpr/libwinpr/handle/handle.h +++ b/winpr/libwinpr/handle/handle.h @@ -20,8 +20,6 @@ #ifndef WINPR_HANDLE_PRIVATE_H #define WINPR_HANDLE_PRIVATE_H -#include <pthread.h> - #include <winpr/handle.h> #define HANDLE_TYPE_NONE 0 @@ -33,21 +31,8 @@ #define HANDLE_TYPE_NAMED_PIPE 6 #define HANDLE_TYPE_ANONYMOUS_PIPE 7 -typedef struct _HANDLE_TABLE_ENTRY -{ - ULONG Type; - PVOID Object; -} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY; - -typedef struct _HANDLE_TABLE -{ - LONG Count; - LONG MaxCount; - PHANDLE_TABLE_ENTRY Entries; -} HANDLE_TABLE, *PHANDLE_TABLE; - #define WINPR_HANDLE_DEF() \ - int winpr_Index; + ULONG Type; struct winpr_handle { @@ -55,18 +40,9 @@ struct winpr_handle }; typedef struct winpr_handle WINPR_HANDLE; -#define HandleTable_GetInstance() \ - if (g_WinPR_HandleTable.MaxCount < 1) \ - winpr_HandleTable_New() - -extern HANDLE_TABLE g_WinPR_HandleTable; -extern pthread_mutex_t g_WinPR_HandleTable_Mutex; - WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object); WINPR_API BOOL winpr_Handle_Remove(HANDLE handle); -WINPR_API ULONG winpr_Handle_GetType(HANDLE handle); -WINPR_API PVOID winpr_Handle_GetObject(HANDLE handle); WINPR_API BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject); #endif /* WINPR_HANDLE_PRIVATE_H */ diff --git a/winpr/libwinpr/handle/table.c b/winpr/libwinpr/handle/table.c index 18c114d91..b15db11f2 100644 --- a/winpr/libwinpr/handle/table.c +++ b/winpr/libwinpr/handle/table.c @@ -26,178 +26,34 @@ #ifndef _WIN32 -#include <pthread.h> - #include "../handle/handle.h" -HANDLE_TABLE g_WinPR_HandleTable = { 0, 0, NULL }; -pthread_mutex_t g_WinPR_HandleTable_Mutex = PTHREAD_MUTEX_INITIALIZER; - -void winpr_HandleTable_New() -{ - size_t size; - - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - - if (g_WinPR_HandleTable.MaxCount < 1) - { - g_WinPR_HandleTable.Count = 0; - g_WinPR_HandleTable.MaxCount = 64; - - size = sizeof(HANDLE_TABLE_ENTRY) * g_WinPR_HandleTable.MaxCount; - - g_WinPR_HandleTable.Entries = (PHANDLE_TABLE_ENTRY) malloc(size); - ZeroMemory(g_WinPR_HandleTable.Entries, size); - } - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); -} - -void winpr_HandleTable_Grow() -{ - size_t size; - - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - - g_WinPR_HandleTable.MaxCount *= 2; - - size = sizeof(HANDLE_TABLE_ENTRY) * g_WinPR_HandleTable.MaxCount; - - g_WinPR_HandleTable.Entries = (PHANDLE_TABLE_ENTRY) realloc(g_WinPR_HandleTable.Entries, size); - ZeroMemory((void*) &g_WinPR_HandleTable.Entries[g_WinPR_HandleTable.MaxCount / 2], size / 2); - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); -} - -void winpr_HandleTable_Free() -{ - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - - g_WinPR_HandleTable.Count = 0; - g_WinPR_HandleTable.MaxCount = 0; - - free(g_WinPR_HandleTable.Entries); - g_WinPR_HandleTable.Entries = NULL; - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); -} - HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) { - int index; + WINPR_HANDLE* wHandle; - HandleTable_GetInstance(); + wHandle = (WINPR_HANDLE*) Object; - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); + wHandle->Type = Type; - for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) - { - if (g_WinPR_HandleTable.Entries[index].Object == NULL) - { - g_WinPR_HandleTable.Count++; - - g_WinPR_HandleTable.Entries[index].Type = Type; - g_WinPR_HandleTable.Entries[index].Object = Object; - - ((WINPR_HANDLE*) Object)->winpr_Index = index; - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return Object; - } - } - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - /* no available entry was found, the table needs to be grown */ - - winpr_HandleTable_Grow(); - - /* the next call should now succeed */ - - return winpr_Handle_Insert(Type, Object); + return (HANDLE) wHandle; } BOOL winpr_Handle_Remove(HANDLE handle) { - int index; - - HandleTable_GetInstance(); - - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - - for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) - { - if (g_WinPR_HandleTable.Entries[index].Object == handle) - { - g_WinPR_HandleTable.Entries[index].Type = HANDLE_TYPE_NONE; - g_WinPR_HandleTable.Entries[index].Object = NULL; - g_WinPR_HandleTable.Count--; - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return TRUE; - } - } - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return FALSE; -} - -ULONG winpr_Handle_GetType(HANDLE handle) -{ - int index; - - HandleTable_GetInstance(); - - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); - - for (index = 0; index < (int) g_WinPR_HandleTable.MaxCount; index++) - { - if (g_WinPR_HandleTable.Entries[index].Object == handle) - { - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - return g_WinPR_HandleTable.Entries[index].Type; - } - } - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return HANDLE_TYPE_NONE; -} - -PVOID winpr_Handle_GetObject(HANDLE handle) -{ - HandleTable_GetInstance(); - - return handle; + return TRUE; } BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) { - int index; - BOOL status = TRUE; + WINPR_HANDLE* wHandle; - HandleTable_GetInstance(); + wHandle = (WINPR_HANDLE*) handle; - pthread_mutex_lock(&g_WinPR_HandleTable_Mutex); + *pType = wHandle->Type; + *pObject = handle; - index = ((WINPR_HANDLE*) handle)->winpr_Index; - - if ((index >= 0) && (index < g_WinPR_HandleTable.MaxCount)) - { - *pType = g_WinPR_HandleTable.Entries[index].Type; - *pObject = g_WinPR_HandleTable.Entries[index].Object; - } - else - { - status = FALSE; - } - - pthread_mutex_unlock(&g_WinPR_HandleTable_Mutex); - - return status; + return TRUE; } #endif From c0160b8015c17f5499751f9600bb8b5b50685a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 18:27:26 -0400 Subject: [PATCH 130/144] libwinpr-handle: reduce usage of unneeded handle management functions --- winpr/libwinpr/handle/handle.c | 10 ++++------ winpr/libwinpr/handle/handle.h | 16 +++++++++++++--- winpr/libwinpr/handle/table.c | 28 ---------------------------- winpr/libwinpr/pipe/pipe.c | 8 ++++---- winpr/libwinpr/synch/event.c | 6 ++++-- winpr/libwinpr/synch/mutex.c | 3 ++- winpr/libwinpr/synch/semaphore.c | 3 ++- winpr/libwinpr/thread/thread.c | 3 ++- 8 files changed, 31 insertions(+), 46 deletions(-) diff --git a/winpr/libwinpr/handle/handle.c b/winpr/libwinpr/handle/handle.c index 3d23f1f4f..d198a11a2 100644 --- a/winpr/libwinpr/handle/handle.c +++ b/winpr/libwinpr/handle/handle.c @@ -49,7 +49,7 @@ BOOL CloseHandle(HANDLE hObject) thread = (WINPR_THREAD*) Object; - free(thread); + free(Object); return TRUE; } @@ -60,7 +60,7 @@ BOOL CloseHandle(HANDLE hObject) mutex = (WINPR_MUTEX*) Object; pthread_mutex_destroy(&mutex->mutex); - winpr_Handle_Remove(Object); + free(Object); return TRUE; @@ -85,8 +85,7 @@ BOOL CloseHandle(HANDLE hObject) } } - winpr_Handle_Remove(Object); - free(event); + free(Object); return TRUE; } @@ -119,7 +118,6 @@ BOOL CloseHandle(HANDLE hObject) #endif #endif - winpr_Handle_Remove(Object); free(Object); return TRUE; @@ -135,7 +133,7 @@ BOOL CloseHandle(HANDLE hObject) close(pipe->fd); } - winpr_Handle_Remove(Object); + free(Object); return TRUE; } diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h index 569dcaa38..5011e826d 100644 --- a/winpr/libwinpr/handle/handle.h +++ b/winpr/libwinpr/handle/handle.h @@ -40,9 +40,19 @@ struct winpr_handle }; typedef struct winpr_handle WINPR_HANDLE; -WINPR_API HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object); -WINPR_API BOOL winpr_Handle_Remove(HANDLE handle); +#define WINPR_HANDLE_SET_TYPE(_handle, _type) \ + _handle->Type = _type -WINPR_API BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject); +static inline BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) +{ + WINPR_HANDLE* wHandle; + + wHandle = (WINPR_HANDLE*) handle; + + *pType = wHandle->Type; + *pObject = handle; + + return TRUE; +} #endif /* WINPR_HANDLE_PRIVATE_H */ diff --git a/winpr/libwinpr/handle/table.c b/winpr/libwinpr/handle/table.c index b15db11f2..eb81e2b0c 100644 --- a/winpr/libwinpr/handle/table.c +++ b/winpr/libwinpr/handle/table.c @@ -28,33 +28,5 @@ #include "../handle/handle.h" -HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) -{ - WINPR_HANDLE* wHandle; - - wHandle = (WINPR_HANDLE*) Object; - - wHandle->Type = Type; - - return (HANDLE) wHandle; -} - -BOOL winpr_Handle_Remove(HANDLE handle) -{ - return TRUE; -} - -BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) -{ - WINPR_HANDLE* wHandle; - - wHandle = (WINPR_HANDLE*) handle; - - *pType = wHandle->Type; - *pObject = handle; - - return TRUE; -} - #endif diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 6dd510307..8b2ee59e9 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -62,11 +62,11 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP pReadPipe->fd = pipe_fd[0]; pWritePipe->fd = pipe_fd[1]; - handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pReadPipe); - *((ULONG_PTR*) hReadPipe) = (ULONG_PTR) handle; + WINPR_HANDLE_SET_TYPE(pReadPipe, HANDLE_TYPE_ANONYMOUS_PIPE); + *((ULONG_PTR*) hReadPipe) = (ULONG_PTR) pReadPipe; - handle = winpr_Handle_Insert(HANDLE_TYPE_ANONYMOUS_PIPE, pWritePipe); - *((ULONG_PTR*) hWritePipe) = (ULONG_PTR) handle; + WINPR_HANDLE_SET_TYPE(pWritePipe, HANDLE_TYPE_ANONYMOUS_PIPE); + *((ULONG_PTR*) hWritePipe) = (ULONG_PTR) pWritePipe; return TRUE; } diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index a56e53595..543a1092c 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -80,7 +80,8 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, } #endif - handle = winpr_Handle_Insert(HANDLE_TYPE_EVENT, event); + WINPR_HANDLE_SET_TYPE(event, HANDLE_TYPE_EVENT); + handle = (HANDLE) event; } if (!cs.LockSemaphore) @@ -221,7 +222,8 @@ HANDLE CreateFileDescriptorEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL event->pipe_fd[0] = FileDescriptor; event->pipe_fd[1] = -1; - handle = winpr_Handle_Insert(HANDLE_TYPE_EVENT, event); + WINPR_HANDLE_SET_TYPE(event, HANDLE_TYPE_EVENT); + handle = (HANDLE) event; } return handle; diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c index e5efded67..bc0e3f02b 100644 --- a/winpr/libwinpr/synch/mutex.c +++ b/winpr/libwinpr/synch/mutex.c @@ -50,7 +50,8 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, { pthread_mutex_init(&mutex->mutex, 0); - handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, mutex); + WINPR_HANDLE_SET_TYPE(mutex, HANDLE_TYPE_MUTEX); + handle = (HANDLE) mutex; if (bInitialOwner) pthread_mutex_lock(&mutex->mutex); diff --git a/winpr/libwinpr/synch/semaphore.c b/winpr/libwinpr/synch/semaphore.c index af04911fc..e2d3771fc 100644 --- a/winpr/libwinpr/synch/semaphore.c +++ b/winpr/libwinpr/synch/semaphore.c @@ -73,7 +73,8 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti #endif } - handle = winpr_Handle_Insert(HANDLE_TYPE_SEMAPHORE, (PVOID) semaphore); + WINPR_HANDLE_SET_TYPE(semaphore, HANDLE_TYPE_SEMAPHORE); + handle = (HANDLE) semaphore; return handle; } diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 5b2ca26e8..d24159b6c 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -111,7 +111,8 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize pthread_mutex_init(&thread->mutex, 0); - handle = winpr_Handle_Insert(HANDLE_TYPE_THREAD, (void*) thread); + WINPR_HANDLE_SET_TYPE(thread, HANDLE_TYPE_THREAD); + handle = (HANDLE) thread; if (!(dwCreationFlags & CREATE_SUSPENDED)) winpr_StartThread(thread); From 8a2220a3d9c5ad70b425a33772f14f3dbe956841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 19:27:12 -0400 Subject: [PATCH 131/144] libwinpr-synch: remove unnecessary critical section --- winpr/libwinpr/synch/event.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 543a1092c..173afafb7 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -125,8 +125,6 @@ BOOL SetEvent(HANDLE hEvent) status = FALSE; - EnterCriticalSection(&cs); - if (winpr_Handle_GetInfo(hEvent, &Type, &Object)) { event = (WINPR_EVENT*) Object; @@ -156,8 +154,6 @@ BOOL SetEvent(HANDLE hEvent) #endif } - LeaveCriticalSection(&cs); - return status; } @@ -171,8 +167,6 @@ BOOL ResetEvent(HANDLE hEvent) status = FALSE; - EnterCriticalSection(&cs); - if (winpr_Handle_GetInfo(hEvent, &Type, &Object)) { event = (WINPR_EVENT*) Object; @@ -199,8 +193,6 @@ BOOL ResetEvent(HANDLE hEvent) } } - LeaveCriticalSection(&cs); - return status; } From 92ce43309072e09bf558d91b1291067de67ced40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 16 May 2013 19:56:39 -0400 Subject: [PATCH 132/144] libfreerdp-codec: optimize color conversion a bit --- libfreerdp/codec/color.c | 57 +++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index e7b9790b1..69a237511 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -614,22 +614,61 @@ BYTE* freerdp_image_convert_16bpp(BYTE* srcData, BYTE* dstData, int width, int h src16 = (UINT16*) srcData; dst32 = (UINT32*) dstData; - for (i = width * height; i > 0; i--) + if (clrconv->alpha) { - pixel = *src16; - src16++; - GetBGR16(red, green, blue, pixel); - if (clrconv->alpha) + if (clrconv->invert) { - pixel = (clrconv->invert) ? ARGB32(0xFF, red, green, blue) : ABGR32(0xFF, red, green, blue); + for (i = width * height; i > 0; i--) + { + pixel = *src16; + src16++; + GetBGR16(red, green, blue, pixel); + pixel = ARGB32(0xFF, red, green, blue); + *dst32 = pixel; + dst32++; + } } else { - pixel = (clrconv->invert) ? RGB32(red, green, blue) : BGR32(red, green, blue); + for (i = width * height; i > 0; i--) + { + pixel = *src16; + src16++; + GetBGR16(red, green, blue, pixel); + pixel = ABGR32(0xFF, red, green, blue); + *dst32 = pixel; + dst32++; + } } - *dst32 = pixel; - dst32++; } + else + { + if (clrconv->invert) + { + for (i = width * height; i > 0; i--) + { + pixel = *src16; + src16++; + GetBGR16(red, green, blue, pixel); + pixel = RGB32(red, green, blue); + *dst32 = pixel; + dst32++; + } + } + else + { + for (i = width * height; i > 0; i--) + { + pixel = *src16; + src16++; + GetBGR16(red, green, blue, pixel); + pixel = BGR32(red, green, blue); + *dst32 = pixel; + dst32++; + } + } + } + return dstData; } From a602e4d1deaadf4b03b7e3298d10e3ee661fd623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 17 May 2013 09:25:42 -0400 Subject: [PATCH 133/144] libfreerdp-core: fix pcap rfx playback --- libfreerdp/core/freerdp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 65d91c43b..9b4643ccd 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -124,21 +124,20 @@ BOOL freerdp_connect(freerdp* instance) rdpUpdate* update; pcap_record record; - s = Stream_New(NULL, 1024); - instance->update->pcap_rfx = pcap_open(instance->settings->PlayRemoteFxFile, FALSE); - - if (instance->update->pcap_rfx) - instance->update->play_rfx = TRUE; - update = instance->update; - while (instance->update->play_rfx && pcap_has_next_record(update->pcap_rfx)) + s = StreamPool_Take(rdp->transport->ReceivePool, 0); + instance->update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE); + + if (update->pcap_rfx) + update->play_rfx = TRUE; + + while (update->play_rfx && pcap_has_next_record(update->pcap_rfx)) { pcap_get_next_record_header(update->pcap_rfx, &record); - Stream_Buffer(s) = (BYTE*) realloc(Stream_Buffer(s), record.length); + Stream_EnsureCapacity(s, record.length); record.data = Stream_Buffer(s); - Stream_Capacity(s) = record.length; pcap_get_next_record_content(update->pcap_rfx, &record); Stream_SetPosition(s, 0); @@ -148,7 +147,8 @@ BOOL freerdp_connect(freerdp* instance) update->EndPaint(update->context); } - free(Stream_Buffer(s)); + Stream_Release(s); + return TRUE; } } From 73f782b871291b3fa75ca9a9b84cbccf15c1dedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 17 May 2013 09:29:53 -0400 Subject: [PATCH 134/144] libfreerdp-client: add AudioCapture flag with microphone is in use --- client/common/cmdline.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 1055ea827..55f35eb66 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1665,6 +1665,11 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings) settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */ } + if (freerdp_dynamic_channel_collection_find(settings, "audin")) + { + settings->AudioCapture = TRUE; + } + if (settings->RedirectDrives) { settings->DeviceRedirection = TRUE; From 8095bec3ec07bdbccede923f83ade1da8d02fcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 20 May 2013 15:23:54 -0400 Subject: [PATCH 135/144] channels/drdynvc: call OnChannelDisconnected --- channels/drdynvc/client/dvcman.c | 39 ++++++++++++++++++++++++-------- channels/drdynvc/client/dvcman.h | 3 +++ client/X11/xf_channels.c | 2 -- libfreerdp/core/transport.c | 1 - 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index f10637689..ac897a669 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -335,19 +335,21 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel IWTSVirtualChannelCallback* pCallback; DVCMAN* dvcman = (DVCMAN*) pChannelMgr; + channel = (DVCMAN_CHANNEL*) malloc(sizeof(DVCMAN_CHANNEL)); + ZeroMemory(channel, sizeof(DVCMAN_CHANNEL)); + + channel->dvcman = dvcman; + channel->channel_id = ChannelId; + channel->channel_name = _strdup(ChannelName); + for (i = 0; i < dvcman->num_listeners; i++) { listener = (DVCMAN_LISTENER*) dvcman->listeners[i]; if (strcmp(listener->channel_name, ChannelName) == 0) { - channel = (DVCMAN_CHANNEL*) malloc(sizeof(DVCMAN_CHANNEL)); - ZeroMemory(channel, sizeof(DVCMAN_CHANNEL)); - channel->iface.Write = dvcman_write_channel; channel->iface.Close = dvcman_close_channel_iface; - channel->dvcman = dvcman; - channel->channel_id = ChannelId; channel->dvc_chan_mutex = CreateMutex(NULL, FALSE, NULL); bAccept = 1; @@ -359,7 +361,10 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel DEBUG_DVC("listener %s created new channel %d", listener->channel_name, channel->channel_id); + channel->status = 0; channel->channel_callback = pCallback; + channel->pInterface = listener->iface.pInterface; + ArrayList_Add(dvcman->channels, channel); context = dvcman->drdynvc->context; @@ -370,12 +375,17 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel else { DEBUG_WARN("channel rejected by plugin"); - dvcman_channel_free(channel); + + channel->status = 1; + ArrayList_Add(dvcman->channels, channel); return 1; } } } + channel->status = 1; + ArrayList_Add(dvcman->channels, channel); + return 1; } @@ -383,6 +393,8 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI { DVCMAN_CHANNEL* channel; IWTSVirtualChannel* ichannel; + DrdynvcClientContext* context; + DVCMAN* dvcman = (DVCMAN*) pChannelMgr; channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId); @@ -398,9 +410,18 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI channel->dvc_data = NULL; } - DEBUG_DVC("dvcman_close_channel: channel %d closed", ChannelId); - ichannel = (IWTSVirtualChannel*) channel; - ichannel->Close(ichannel); + if (channel->status == 0) + { + context = dvcman->drdynvc->context; + + IFCALL(context->OnChannelDisconnected, context, channel->channel_name, channel->pInterface); + + DEBUG_DVC("dvcman_close_channel: channel %d closed", ChannelId); + ichannel = (IWTSVirtualChannel*) channel; + ichannel->Close(ichannel); + } + + free(channel->channel_name); return 0; } diff --git a/channels/drdynvc/client/dvcman.h b/channels/drdynvc/client/dvcman.h index 9b181f06a..ca886f3af 100644 --- a/channels/drdynvc/client/dvcman.h +++ b/channels/drdynvc/client/dvcman.h @@ -70,8 +70,11 @@ struct _DVCMAN_CHANNEL { IWTSVirtualChannel iface; + int status; DVCMAN* dvcman; + void* pInterface; UINT32 channel_id; + char* channel_name; IWTSVirtualChannelCallback* channel_callback; wStream* dvc_data; diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index 5b95a2db9..84a70b106 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -30,8 +30,6 @@ int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterfac { xfInfo* xfi = ((xfContext*) instance->context)->xfi; - printf("OnChannelConnected: %s\n", name); - if (strcmp(name, RDPEI_DVC_CHANNEL_NAME) == 0) { xfi->rdpei = (RdpeiClientContext*) pInterface; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 136d56975..ba8f9c800 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -793,7 +793,6 @@ static void* transport_client_thread(void* arg) { nCount = 0; events[nCount++] = transport->stopEvent; - events[nCount] = transport->connectedEvent; status = WaitForMultipleObjects(nCount + 1, events, FALSE, INFINITE); From e9d362b58ea6cb29ae48a65388e80c1991034f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 20 May 2013 15:50:22 -0400 Subject: [PATCH 136/144] channels/printer: fix printer redirection and test with cups-pdf --- channels/printer/client/printer_main.c | 10 ++++++++ channels/rdpsnd/client/rdpsnd_main.c | 5 ++-- client/common/cmdline.c | 33 +++++++++++++++++++------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 0ecd3e8c6..89e2ffb81 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -141,6 +141,12 @@ static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) irp->Complete(irp); } +static void printer_process_irp_device_control(PRINTER_DEVICE* printer_dev, IRP* irp) +{ + Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */ + irp->Complete(irp); +} + static void printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp) { switch (irp->MajorFunction) @@ -157,6 +163,10 @@ static void printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp) printer_process_irp_write(printer_dev, irp); break; + case IRP_MJ_DEVICE_CONTROL: + printer_process_irp_device_control(printer_dev, irp); + break; + default: DEBUG_WARN("MajorFunction 0x%X not supported", irp->MajorFunction); irp->IoStatus = STATUS_NOT_SUPPORTED; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index d7ee92927..e895b9901 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -199,9 +199,10 @@ void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) UINT16 wNumberOfFormats; AUDIO_FORMAT* clientFormat; - if (rdpsnd->device->GetVolume) + if (rdpsnd->device) { - dwVolume = rdpsnd->device->GetVolume(rdpsnd->device); + if (rdpsnd->device->GetVolume) + dwVolume = rdpsnd->device->GetVolume(rdpsnd->device); } else { diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 55f35eb66..a373946dc 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -87,7 +87,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "serial", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, "tty", "Redirect serial device" }, { "parallel", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect parallel device" }, { "smartcard", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect smartcard device" }, - { "printer", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect printer device" }, + { "printer", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect printer device" }, { "usb", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect USB device" }, { "multitouch", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect multitouch input" }, { "echo", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "echo", "Echo channel" }, @@ -291,14 +291,16 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p { RDPDR_PRINTER* printer; - if (count < 2) + if (count < 1) return -1; printer = (RDPDR_PRINTER*) malloc(sizeof(RDPDR_PRINTER)); ZeroMemory(printer, sizeof(RDPDR_PRINTER)); printer->Type = RDPDR_DTYP_PRINT; - printer->Name = _strdup(params[1]); + + if (count > 1) + printer->Name = _strdup(params[1]); if (count > 2) printer->DriverName = _strdup(params[2]); @@ -547,15 +549,28 @@ int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT } CommandLineSwitchCase(arg, "printer") { - char** p; - int count; + if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) + { + char** p; + int count; - p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count); - p[0] = "printer"; + p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count); + p[0] = "printer"; - freerdp_client_add_device_channel(settings, count, p); + freerdp_client_add_device_channel(settings, count, p); - free(p); + free(p); + } + else + { + char* p[1]; + int count; + + count = 1; + p[0] = "printer"; + + freerdp_client_add_device_channel(settings, count, p); + } } CommandLineSwitchCase(arg, "usb") { From 9d3ec97f9ebb8d04aa9b2f247944a1513dec7c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 24 May 2013 18:38:02 -0400 Subject: [PATCH 137/144] freerdp: fix monolithic build with Xcode --- client/X11/xf_interface.c | 2 ++ cmake/FindXrender.cmake | 6 +++--- libfreerdp/CMakeLists.txt | 2 +- libfreerdp/dummy.c | 5 +++++ winpr/libwinpr/CMakeLists.txt | 2 +- winpr/libwinpr/dummy.c | 5 +++++ 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 libfreerdp/dummy.c create mode 100644 winpr/libwinpr/dummy.c diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index fb1dd9699..13ac4d9ac 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -92,6 +92,7 @@ static const size_t password_size = 512; void xf_draw_screen_scaled(xfInfo* xfi) { +#ifdef WITH_XRENDER XTransform transform; Picture windowPicture; Picture primaryPicture; @@ -117,6 +118,7 @@ void xf_draw_screen_scaled(xfInfo* xfi) XRenderSetPictureTransform(xfi->display, primaryPicture, &transform); XRenderComposite(xfi->display, PictOpSrc, primaryPicture, 0, windowPicture, 0, 0, 0, 0, 0, 0, xfi->currentWidth, xfi->currentHeight); +#endif } void xf_context_new(freerdp* instance, rdpContext* context) diff --git a/cmake/FindXrender.cmake b/cmake/FindXrender.cmake index 3fe4a0172..5264604df 100644 --- a/cmake/FindXrender.cmake +++ b/cmake/FindXrender.cmake @@ -36,9 +36,9 @@ include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xrender DEFAULT_MSG Xrender_LIBRARY Xrender_INCLUDE_DIR) if(Xrender_FOUND) -set(XRENDER_LIBRARIES ${Xrender_LIBRARY}) -set(XRENDER_INCLUDE_DIRS ${Xrender_INCLUDE_DIR}) + set(XRENDER_LIBRARIES ${Xrender_LIBRARY}) + set(XRENDER_INCLUDE_DIRS ${Xrender_INCLUDE_DIR}) endif() -mark_as_advanced(Xrender_INCLUDE_DIR Xrender_LIBRARY) +mark_as_advanced(XRENDER_INCLUDE_DIRS XRENDER_LIBRARIES) diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index 42c06dd60..6dccb0771 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -52,7 +52,7 @@ if(MONOLITHIC_BUILD) set(${MODULE_PREFIX}_OBJECTS ${${MODULE_PREFIX}_OBJECTS} "$<TARGET_OBJECTS:${MODULE_NAME}-${${MODULE_PREFIX}_SUBMODULE}>") endforeach() - add_library(${MODULE_NAME} ${${MODULE_PREFIX}_OBJECTS}) + add_library(${MODULE_NAME} dummy.c ${${MODULE_PREFIX}_OBJECTS}) set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION} PREFIX "lib") diff --git a/libfreerdp/dummy.c b/libfreerdp/dummy.c new file mode 100644 index 000000000..b959f9be3 --- /dev/null +++ b/libfreerdp/dummy.c @@ -0,0 +1,5 @@ + +int dummy() +{ + return 0; +} diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index 0a56165ad..fdb2bdac5 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -48,7 +48,7 @@ if(MONOLITHIC_BUILD) set(${MODULE_PREFIX}_OBJECTS ${${MODULE_PREFIX}_OBJECTS} "$<TARGET_OBJECTS:${MODULE_NAME}-${${MODULE_PREFIX}_SUBMODULE}>") endforeach() - add_library(${MODULE_NAME} ${${MODULE_PREFIX}_OBJECTS}) + add_library(${MODULE_NAME} dummy.c ${${MODULE_PREFIX}_OBJECTS}) set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") diff --git a/winpr/libwinpr/dummy.c b/winpr/libwinpr/dummy.c new file mode 100644 index 000000000..b959f9be3 --- /dev/null +++ b/winpr/libwinpr/dummy.c @@ -0,0 +1,5 @@ + +int dummy() +{ + return 0; +} From e45f149db43c2606613fe4cab3f64e5e590b68f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Sat, 25 May 2013 15:49:44 -0400 Subject: [PATCH 138/144] channels/rdpsnd: fix potential uninitialized value --- channels/rdpsnd/client/rdpsnd_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index e895b9901..35ba973d7 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -199,17 +199,15 @@ void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) UINT16 wNumberOfFormats; AUDIO_FORMAT* clientFormat; + dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */ + dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */ + dwVolume = (dwVolumeLeft << 16) | dwVolumeRight; + if (rdpsnd->device) { if (rdpsnd->device->GetVolume) dwVolume = rdpsnd->device->GetVolume(rdpsnd->device); } - else - { - dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */ - dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */ - dwVolume = (dwVolumeLeft << 16) | dwVolumeRight; - } wNumberOfFormats = rdpsnd->NumberOfClientFormats; From 12e5b5fe8d642ebad1e1e018b422aa644edddcae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Mon, 27 May 2013 16:00:24 -0400 Subject: [PATCH 139/144] cmake: bump minimum mac os x version to 10.5 (fixes 32-bit build) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52e3dbd7f..4de506ef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,7 +215,7 @@ if(APPLE) include_directories(/opt/local/include) link_directories(/opt/local/lib) endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.4") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.5") endif() if(WITH_CLANG) set(CMAKE_C_COMPILER "clang") From fc752761288b572ecc1d7668b191c14d35deaadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Tue, 28 May 2013 01:14:20 -0400 Subject: [PATCH 140/144] cmake: add FindNPP.cmake --- CMakeLists.txt | 5 ++ cmake/FindNPP.cmake | 119 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 cmake/FindNPP.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de506ef6..3576f7a4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,6 +292,10 @@ set(IPP_FEATURE_TYPE "OPTIONAL") set(IPP_FEATURE_PURPOSE "performance") set(IPP_FEATURE_DESCRIPTION "Intel Integrated Performance Primitives library") +set(NPP_FEATURE_TYPE "OPTIONAL") +set(NPP_FEATURE_PURPOSE "performance") +set(NPP_FEATURE_DESCRIPTION "NVIDIA Performance Primitives library") + if(WIN32) set(X11_FEATURE_TYPE "DISABLED") set(ZLIB_FEATURE_TYPE "DISABLED") @@ -350,6 +354,7 @@ if(TARGET_ARCH MATCHES "x86|x64") # Intel Performance Primitives find_feature(IPP ${IPP_FEATURE_TYPE} ${IPP_FEATURE_PURPOSE} ${IPP_FEATURE_DESCRIPTION}) endif() + find_feature(NPP ${NPP_FEATURE_TYPE} ${NPP_FEATURE_PURPOSE} ${NPP_FEATURE_DESCRIPTION}) endif() # Installation Paths diff --git a/cmake/FindNPP.cmake b/cmake/FindNPP.cmake new file mode 100644 index 000000000..7b04ee43a --- /dev/null +++ b/cmake/FindNPP.cmake @@ -0,0 +1,119 @@ +############################################################################### +# +# FindNPP.cmake +# +# NPP_LIBRARY_ROOT_DIR -- Path to the NPP dorectory. +# NPP_INCLUDES -- NPP Include directories. +# NPP_LIBRARIES -- NPP libraries. +# NPP_VERSION -- NPP version in format "major.minor.build". +# +# If not found automatically, please set NPP_LIBRARY_ROOT_DIR +# in CMake or set enviroment varivabe $NPP_ROOT +# +# Author: Anatoly Baksheev, Itseez Ltd. +# +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +cmake_policy(PUSH) +cmake_minimum_required(VERSION 2.8.0) +cmake_policy(POP) + +if(NOT "${NPP_LIBRARY_ROOT_DIR}" STREQUAL "${NPP_LIBRARY_ROOT_DIR_INTERNAL}") + unset(NPP_INCLUDES CACHE) + unset(NPP_LIBRARIES CACHE) +endif() + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if (UNIX OR APPLE) + set(NPP_SUFFIX "32") + else() + set(NPP_SUFFIX "-mt") + endif() +else(CMAKE_SIZEOF_VOID_P EQUAL 4) + if (UNIX OR APPLE) + set(NPP_SUFFIX "64") + else() + set(NPP_SUFFIX "-mt-x64") + endif() +endif(CMAKE_SIZEOF_VOID_P EQUAL 4) + +find_path(CUDA_ROOT_DIR "doc/CUDA_Toolkit_Release_Notes.txt" + PATHS "/Developer/NVIDIA" + PATH_SUFFIXES "CUDA-5.0" + DOC "CUDA root directory") + +find_path(NPP_INCLUDES "npp.h" + PATHS "${CUDA_ROOT_DIR}" + PATH_SUFFIXES "include" + DOC "NPP include directory") +mark_as_advanced(NPP_INCLUDES) + +find_library(NPP_LIBRARIES + NAMES "npp" "libnpp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}" + PATHS "${CUDA_ROOT_DIR}" + PATH_SUFFIXES "lib" + DOC "NPP library") +mark_as_advanced(NPP_LIBRARIES) + +if(EXISTS ${NPP_INCLUDES}/nppversion.h) + file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*") + file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*") + file(STRINGS ${NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*") + + string(REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major}) + string(REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor}) + string(REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build}) + + string(REGEX MATCH "[0-9]+" npp_major ${npp_major}) + string(REGEX MATCH "[0-9]+" npp_minor ${npp_minor}) + string(REGEX MATCH "[0-9]+" npp_build ${npp_build}) + set(NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") +endif() + +if(NOT EXISTS ${NPP_LIBRARIES} OR NOT EXISTS ${NPP_INCLUDES}/npp.h) + set(NPP_FOUND FALSE) + message(WARNING "NPP headers/libraries are not found. Please specify NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.") +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(NPP + REQUIRED_VARS + NPP_INCLUDES + NPP_LIBRARIES + NPP_VERSION) + +if(APPLE) + # We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath. + get_filename_component(_cuda_path_to_npp "${NPP_LIBRARIES}" PATH) + if(_cuda_path_to_npp) + list(APPEND NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}") + endif() +endif() + +set(NPP_FOUND TRUE) + +set(NPP_LIBRARY_ROOT_DIR_INTERNAL "${NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time NPP_LIBRARY_ROOT_DIR was set successfully." FORCE) + From 7cf9526a78ed826e67e4254b0859bd53f7a8417e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Wed, 29 May 2013 12:21:54 -0400 Subject: [PATCH 141/144] channels/tsmf: fix set source video rect --- channels/tsmf/client/tsmf_ifman.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 3ca998fb6..59059dbba 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -268,6 +268,8 @@ int tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman) Left, Top, Right, Bottom); } + ifman->output_pending = TRUE; + return status; } From 2a08093e60a7f76c5051387a4e4e3b9a1a046a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Thu, 30 May 2013 19:44:58 -0400 Subject: [PATCH 142/144] libfreerdp-crypto: fix openssl null pointer dereferencing in tls_accept --- libfreerdp/crypto/tls.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 3673e5f9c..920f20488 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -270,23 +270,6 @@ BOOL tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file) return FALSE; } - cert = tls_get_certificate(tls, FALSE); - - if (!cert) - { - fprintf(stderr, "tls_connect: tls_get_certificate failed to return the server certificate.\n"); - return FALSE; - } - - if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength)) - { - fprintf(stderr, "tls_connect: crypto_cert_get_public_key failed to return the server public key.\n"); - tls_free_certificate(cert); - return FALSE; - } - - free(cert); - if (SSL_set_fd(tls->ssl, tls->sockfd) < 1) { fprintf(stderr, "SSL_set_fd failed\n"); @@ -318,6 +301,23 @@ BOOL tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file) } } + cert = tls_get_certificate(tls, FALSE); + + if (!cert) + { + fprintf(stderr, "tls_connect: tls_get_certificate failed to return the server certificate.\n"); + return FALSE; + } + + if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength)) + { + fprintf(stderr, "tls_connect: crypto_cert_get_public_key failed to return the server public key.\n"); + tls_free_certificate(cert); + return FALSE; + } + + free(cert); + fprintf(stderr, "TLS connection accepted\n"); return TRUE; From 12a46784dd7d9b98c81ba2ab5d163e7ec89b25ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 31 May 2013 12:48:40 -0400 Subject: [PATCH 143/144] mfreerdp: integrate benoit's refactored mac client --- CMakeLists.txt | 2 +- client/Mac/.gitignore | 1 + client/Mac/AppDelegate.h | 29 - client/Mac/AppDelegate.m | 38 - client/Mac/CMakeLists.txt | 231 +- client/Mac/Info.plist | 16 +- client/Mac/MRDPRailView.h | 76 - client/Mac/MRDPRailView.m | 930 ------ client/Mac/MRDPRailWindow.h | 24 - client/Mac/MRDPRailWindow.m | 29 - client/Mac/MRDPView.h | 121 +- client/Mac/MRDPView.m | 278 +- client/Mac/MRDPWindow.h | 33 - client/Mac/MRDPWindow.m | 28 - client/Mac/PasswordDialog.h | 10 +- client/Mac/README.txt | 140 - client/Mac/cli/AppDelegate.h | 22 + client/Mac/cli/AppDelegate.m | 32 + client/Mac/cli/CMakeLists.txt | 127 + client/Mac/{ => cli}/FreeRDP.icns | Bin client/Mac/cli/Info.plist | 34 + client/Mac/cli/MacClient2-Info.plist | 32 + client/Mac/cli/MacClient2-Prefix.pch | 7 + client/Mac/{ => cli}/MainMenu.xib | 20 +- client/Mac/cli/en.lproj/Credits.rtf | 29 + client/Mac/cli/en.lproj/InfoPlist.strings | 2 + client/Mac/cli/en.lproj/MainMenu.xib | 3299 +++++++++++++++++++++ client/Mac/cli/main.m | 16 + client/Mac/en.lproj/InfoPlist.strings | 2 + client/Mac/main.m | 4 +- 30 files changed, 4042 insertions(+), 1570 deletions(-) delete mode 100644 client/Mac/AppDelegate.h delete mode 100644 client/Mac/AppDelegate.m delete mode 100644 client/Mac/MRDPRailView.h delete mode 100644 client/Mac/MRDPRailView.m delete mode 100644 client/Mac/MRDPRailWindow.h delete mode 100644 client/Mac/MRDPRailWindow.m delete mode 100644 client/Mac/MRDPWindow.h delete mode 100644 client/Mac/MRDPWindow.m delete mode 100644 client/Mac/README.txt create mode 100644 client/Mac/cli/AppDelegate.h create mode 100644 client/Mac/cli/AppDelegate.m create mode 100644 client/Mac/cli/CMakeLists.txt rename client/Mac/{ => cli}/FreeRDP.icns (100%) create mode 100644 client/Mac/cli/Info.plist create mode 100644 client/Mac/cli/MacClient2-Info.plist create mode 100644 client/Mac/cli/MacClient2-Prefix.pch rename client/Mac/{ => cli}/MainMenu.xib (98%) create mode 100644 client/Mac/cli/en.lproj/Credits.rtf create mode 100644 client/Mac/cli/en.lproj/InfoPlist.strings create mode 100644 client/Mac/cli/en.lproj/MainMenu.xib create mode 100644 client/Mac/cli/main.m create mode 100644 client/Mac/en.lproj/InfoPlist.strings diff --git a/CMakeLists.txt b/CMakeLists.txt index 3576f7a4b..7ee793a52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,8 +312,8 @@ if(APPLE) set(DIRECTFB_FEATURE_TYPE "DISABLED") set(FFMPEG_FEATURE_TYPE "OPTIONAL") set(GSTREAMER_FEATURE_TYPE "OPTIONAL") + set(X11_FEATURE_TYPE "DISABLED") if(IOS) - set(X11_FEATURE_TYPE "DISABLED") set(ALSA_FEATURE_TYPE "DISABLED") set(PULSE_FEATURE_TYPE "DISABLED") set(CUPS_FEATURE_TYPE "DISABLED") diff --git a/client/Mac/.gitignore b/client/Mac/.gitignore index 600769254..334032120 100644 --- a/client/Mac/.gitignore +++ b/client/Mac/.gitignore @@ -1,2 +1,3 @@ *.app +*.framework diff --git a/client/Mac/AppDelegate.h b/client/Mac/AppDelegate.h deleted file mode 100644 index a050c8d6c..000000000 --- a/client/Mac/AppDelegate.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import <Cocoa/Cocoa.h> -#import "MRDPView.h" - -@interface AppDelegate : NSObject <NSApplicationDelegate> - -@property (assign) IBOutlet MRDPView *mrdpView; -@property (assign) IBOutlet NSWindow *window; - -int rdp_connect(void); -@end diff --git a/client/Mac/AppDelegate.m b/client/Mac/AppDelegate.m deleted file mode 100644 index 029d055d1..000000000 --- a/client/Mac/AppDelegate.m +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import "AppDelegate.h" - -@implementation AppDelegate - -@synthesize window = _window; - -@synthesize mrdpView; - -- (void)applicationDidFinishLaunching:(NSNotification*)aNotification -{ - rdp_connect(); -} - -- (void) applicationWillTerminate:(NSNotification*)notification -{ - //[mrdpView releaseResources]; -} - -@end diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 80b03ca62..5b77814a5 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -1,75 +1,57 @@ -project(MacFreeRDP) +project(MacFreeRDP-library) -set(MODULE_NAME "MacFreeRDP") -set(MODULE_PREFIX "FREERDP_CLIENT_MAC") +# add directory for App +add_subdirectory(cli) -set(FRAMEWORK_HEADERS_PATH /System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/) -include_directories(${FRAMEWORK_HEADERS_PATH} /System/Library/Frameworks) - -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4") -set(GUI_TYPE MACOSX_BUNDLE) +set(MODULE_NAME "MacFreeRDP-library") +set(MODULE_PREFIX "FREERDP_CLIENT_MAC-LIB") +# Import libraries find_library(FOUNDATION_LIBRARY Foundation) find_library(COCOA_LIBRARY Cocoa) find_library(APPKIT_LIBRARY AppKit) -set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP") -set(MACOSX_BUNDLE_ICON_FILE "FreeRDP.icns") +set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP-library") set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac") -set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP.Mac") -set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP Version 1.0.1") -set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP") -set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.0.1) -set(MACOSX_BUNDLE_BUNDLE_VERSION 1.0.1) -set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2012. All Rights Reserved.") - -set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu") -set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication") +set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP-library.Mac") +set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP library Version 1.1") +set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP-library") +set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.1.0) +set(MACOSX_BUNDLE_BUNDLE_VERSION 1.1.0) +set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2013. All Rights Reserved.") mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY) set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY}) -set(APP_TYPE MACOSX_BUNDLE) -set(${MODULE_NAME}_XIBS - MainMenu.xib - PasswordDialog.xib) +set(${MODULE_NAME}_RESOURCES "en.lproj/InfoPlist.strings") -set(${MODULE_NAME}_RESOURCES - ${${MODULE_NAME}_XIBS} - ${MACOSX_BUNDLE_ICON_FILE}) +# OS X Interface Builder files +file(GLOB ${MODULE_NAME}_XIBS *.xib) -set(${MODULE_NAME}_HEADERS - AppDelegate.h - MRDPCursor.h - MRDPRailView.h - MRDPRailWindow.h +# Include XIB file in Xcode resources. +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}") + set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${${MODULE_NAME}_XIBS}) +endif("${CMAKE_GENERATOR}" MATCHES "Xcode") + + +add_library(${MODULE_NAME} + SHARED MRDPView.h - MRDPWindow.h - PasswordDialog.h) - -set(${MODULE_NAME}_SOURCES - main.m - AppDelegate.m - MRDPCursor.m - MRDPRailView.m - MRDPRailWindow.m MRDPView.m - MRDPWindow.m - PasswordDialog.m) - -add_executable(${MODULE_NAME} - ${APP_TYPE} - ${${MODULE_NAME}_HEADERS} - ${${MODULE_NAME}_SOURCES} + MRDPCursor.m + PasswordDialog.m ${${MODULE_NAME}_RESOURCES}) -# This is necessary for the xib file part below -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) - -# This allows for automatic xib to nib ibitool -set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOURCES}") - +# configures the framework to always be looked for in the application bundle in the Frameworks sub-folder. +SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/ ) + + set_target_properties( ${MODULE_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH} +) + # Automatic ref counting # temporary turn off for x86_64 build issue # set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) @@ -77,14 +59,90 @@ set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOU # Support for automatic reference counting requires non-fragile abi. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi") +# XCode project architecture to native architecture of build machine +# ----------------------------------------------------------------------------------------------------- +# Issue: Had some issues with FreeRDP project building only 64 bit and +# MacFreeRDP attempting to link to both 32 and 64 for dual target. +# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons: +# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage +# If you know the solutions for 1 and 2, please add below. set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") # Set the info plist to the custom instance -set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) +# MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS}) +set(MODULE_VERSION, 1.1.0) -set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) +set_target_properties(${MODULE_NAME} PROPERTIES + FRAMEWORK TRUE + MACOSX_FRAMEWORK_IDENTIFIER com.awakecoding.${MODULE_NAME} + FRAMEWORK_VERSION 1.1.0 + MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.1.0 + MACOSX_FRAMEWORK_BUNDLE_VERSION 1.1.0 + PUBLIC_HEADER "MRDPView.h" + INSTALL_NAME_DIR "@executable_path/../../Frameworks" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + BUILD_WITH_INSTALL_RPATH 1 +) + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS} freerdp-client) + +# Set a list of the dependent targets used by the application. There should be a way to get this list automatically +# from cmake, but for now I put it down manually. I got the references by calling +# otool -L MacFreeRDP-client + +set(DEPENDENCIES + winpr-asn1 + winpr-heap + winpr-sspi + winpr-bcrypt + winpr-input + winpr-sspicli + winpr-credentials + winpr-interlocked + winpr-synch + winpr-credui + winpr-io + winpr-sysinfo + winpr-crt + winpr-library + winpr-thread + winpr-crypto + winpr-timezone + winpr-dsparse + winpr-path + winpr-utils + winpr-environment + winpr-pipe + winpr-winhttp + winpr-error + winpr-pool + winpr-winsock + winpr-file + winpr-registry + winpr-handle + winpr-rpc + freerdp-utils + freerdp-gdi + freerdp-rail + freerdp-cache + freerdp-codec + freerdp-primitives + freerdp-core + freerdp-crypto + freerdp-client + freerdp-locale + freerdp-common + ) + + +## Modify the install name path of the dependent libraries so that they can be located by the bundling app. +# foreach(LIB ${DEPENDENCIES}) +# set_target_properties(${LIB} PROPERTIES +# INSTALL_NAME_DIR "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents" +# BUILD_WITH_INSTALL_RPATH 1 +# ) +# endforeach() set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp @@ -94,6 +152,67 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHI MODULE winpr MODULES winpr-input winpr-crt winpr-utils) +set_target_properties(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "") target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac") + +# Add a post-build event to copy the dependent libraries in the framework bundle +# Call install_name_tool to reassign the library install name +foreach(LIB ${DEPENDENCIES}) + # message("adding post-build dependency: ${LIB}") + add_custom_command(TARGET ${MODULE_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$<TARGET_FILE:${LIB}>" + "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" + COMMENT "Copying ${LIB} to output directory" + COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/${MODULE_NAME}" + COMMENT Setting install name for ${LIB} + COMMAND "${CMAKE_COMMAND}" -E echo install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/${MODULE_NAME}" + ) +endforeach() + + +# Call install_name_tool to reassign the library install names in dependent libraries +foreach(DEST ${DEPENDENCIES}) +foreach(LIB ${DEPENDENCIES}) + # message("adding post-build dependency: ${LIB}") + add_custom_command(TARGET ${MODULE_NAME} POST_BUILD + COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${DEST}>" + COMMENT Setting install name for ${LIB} in module ${DEST} +) + +# COMMAND "${CMAKE_COMMAND}" -E echo install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" #"@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" #"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${DEST}>" +# ) + +endforeach() +endforeach() + + +# Add post-build NIB file generation in unix makefiles. XCode handles this implicitly. +if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + message(STATUS "Adding post-build NIB file generation event for ${MODULE_NAME}") + + # Make sure we can find the 'ibtool' program. If we can NOT find it we + # skip generation of this project + find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") + if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") + message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with + the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin") + endif() + + # Make sure the 'Resources' Directory is correctly created before we build + add_custom_command (TARGET ${MODULE_NAME} PRE_BUILD + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources) + + # Compile the .xib files using the 'ibtool' program with the destination being the app package + foreach(xib ${${MODULE_NAME}_XIBS}) + get_filename_component(XIB_WE ${xib} NAME_WE) + + add_custom_command (TARGET ${MODULE_NAME} POST_BUILD + COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text + --compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources/${XIB_WE}.nib ${xib} + COMMENT "Compiling ${xib}") + endforeach() + +endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") \ No newline at end of file diff --git a/client/Mac/Info.plist b/client/Mac/Info.plist index 253612c6e..2b552b421 100644 --- a/client/Mac/Info.plist +++ b/client/Mac/Info.plist @@ -3,11 +3,9 @@ <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> - <string>en</string> - <key>CFBundleExecutable</key> - <string></string> + <string>English</string> <key>CFBundleIconFile</key> - <string>FreeRDP</string> + <string></string> <key>CFBundleIdentifier</key> <string>FreeRDP.Mac</string> <key>CFBundleInfoDictionaryVersion</key> @@ -15,20 +13,14 @@ <key>CFBundleName</key> <string></string> <key>CFBundlePackageType</key> - <string>APPL</string> + <string>FMWK</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1</string> - <key>LSMinimumSystemVersion</key> - <string></string> - <key>NSHumanReadableCopyright</key> - <string>Copyright © 2012 FreeRDP Open Source Project.</string> - <key>NSMainNibFile</key> - <string>MainMenu</string> <key>NSPrincipalClass</key> - <string>NSApplication</string> + <string></string> </dict> </plist> diff --git a/client/Mac/MRDPRailView.h b/client/Mac/MRDPRailView.h deleted file mode 100644 index 84d4c55ee..000000000 --- a/client/Mac/MRDPRailView.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import <Cocoa/Cocoa.h> - -#import "freerdp/gdi/gdi.h" -#import "freerdp/rail/rail.h" - -#import "MRDPRailWindow.h" - -@interface MRDPRailView : NSView -{ - freerdp* rdp_instance; - rdpContext* context; - NSBitmapImageRep* bmiRep; - NSPoint savedDragLocation; - char* pixelData; - BOOL mouseInClientArea; - BOOL titleBarClicked; - BOOL gestureEventInProgress; - int width; - int height; - int savedWindowId; - int scrollWheelCount; - - int kdlshift; - int kdrshift; - int kdlctrl; - int kdrctrl; - int kdlalt; - int kdralt; - int kdlmeta; - int kdrmeta; - int kdcapslock; - -@public - BOOL isMoveSizeInProgress; - BOOL saveInitialDragLoc; - BOOL skipMoveWindowOnce; - int localMoveType; -} - -@property (assign) MRDPRailWindow* mrdpRailWindow; -@property (assign) int windowIndex; -@property (assign) BOOL activateWindow; - -- (void) windowDidMove:(NSNotification*) notification; -- (void) updateDisplay; -- (void) setRdpInstance:(freerdp*) instance width:(int) w andHeight:(int) h windowID:(int) windowID; -- (void) setupBmiRep:(int) width :(int) height; -- (void) releaseResources; - -void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window); -void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove); -void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param); -void windows_to_apple_cords(NSRect* r); -void rail_MoveWindow(rdpRail* rail, rdpWindow* window); -void mac_rail_send_activate(int window_id); - -@end diff --git a/client/Mac/MRDPRailView.m b/client/Mac/MRDPRailView.m deleted file mode 100644 index b23c9c3e4..000000000 --- a/client/Mac/MRDPRailView.m +++ /dev/null @@ -1,930 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#include "MRDPRailView.h" - -#define USE_RAIL_CVT - -@implementation MRDPRailView - -@synthesize mrdpRailWindow, windowIndex, activateWindow; - -MRDPRailView* g_mrdpRailView; - -- (void) updateDisplay -{ - BOOL moveWindow = NO; - NSRect srcRectOuter; - NSRect destRectOuter; - - rdpGdi* gdi; - - if ((context == 0) || (context->gdi == 0)) - return; - - if (context->gdi->primary->hdc->hwnd->invalid->null) - return; - - if (context->gdi->drawing != context->gdi->primary) - return; - - gdi = context->gdi; - - srcRectOuter = NSMakeRect(0, 0, self->width, self->height); - destRectOuter = [[self window] frame]; - - // cannot be bigger than our current screen size - NSRect screenSize = [[NSScreen mainScreen] frame]; - - if (destRectOuter.size.width > screenSize.size.width) - { - destRectOuter.size.width = screenSize.size.width; - moveWindow = YES; - } - - if (destRectOuter.size.height > screenSize.size.height) - { - destRectOuter.size.height = screenSize.size.height; - moveWindow = YES; - } - - if (destRectOuter.origin.x + destRectOuter.size.width > width) - destRectOuter.size.width = width - destRectOuter.origin.x; - - [self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height]; - - if (moveWindow) - { - moveWindow = NO; - RAIL_WINDOW_MOVE_ORDER newWndLoc; - apple_to_windowMove(&destRectOuter, &newWndLoc); - newWndLoc.windowId = savedWindowId; - //skipMoveWindowOnce = TRUE; - //mac_send_rail_client_event(g_mrdpRailView->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &newWndLoc); - } - - destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height; - rail_convert_color_space(pixelData, (char *) gdi->primary_buffer, - &destRectOuter, self->width, self->height); - - if (moveWindow) - [self setNeedsDisplayInRect:destRectOuter]; - else - [self setNeedsDisplayInRect:[self frame]]; - - gdi->primary->hdc->hwnd->ninvalid = 0; -} - -/** ********************************************************************* - * called when our view needs to be redrawn - ***********************************************************************/ - -- (void) drawRect:(NSRect)dirtyRect -{ - [bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil]; - - if (pixelData) - { - free(pixelData); - pixelData = NULL; - } - - bmiRep = nil; -} - -/** ********************************************************************* - * become first responder so we can get keyboard and mouse events - ***********************************************************************/ - -- (BOOL)acceptsFirstResponder -{ - return YES; -} - -- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent -{ - return NO; -} - -/** ********************************************************************* - * called when a mouse move event occurs - * - * ideally we want to be called when the mouse moves over NSView client area, - * but in reality we get called any time the mouse moves anywhere on the screen; - * we could use NSTrackingArea class to handle this but this class is available - * on Mac OS X v10.5 and higher; since we want to be compatible with older - * versions, we do this manually. - * - * TODO: here is how it can be done using legacy methods - * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/MouseTrackingEvents/MouseTrackingEvents.html#//apple_ref/doc/uid/10000060i-CH11-SW1 - ***********************************************************************/ - -- (void) mouseMoved:(NSEvent *)event -{ - [super mouseMoved:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - - y = height - y; - - /* send mouse motion event to RDP server */ - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); -} - -/** ********************************************************************* - * called when left mouse button is pressed down - ***********************************************************************/ - -- (void)mouseDown:(NSEvent *) event -{ - [super mouseDown:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - int yPos = (int) (winFrame.size.height - loc.y); - - y = height - y; - - if ((yPos >= 4) && (yPos <= 20)) - titleBarClicked = YES; - else - titleBarClicked = NO; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); -} - -/** ********************************************************************* - * called when left mouse button is released - ***********************************************************************/ - -- (void) mouseUp:(NSEvent *) event -{ - [super mouseUp:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); - titleBarClicked = NO; -} - -/** ********************************************************************* - * called when right mouse button is pressed down - ***********************************************************************/ - -- (void) rightMouseDown:(NSEvent *)event -{ - [super rightMouseDown:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); -} - -/** ********************************************************************* - * called when right mouse button is released - ***********************************************************************/ - -- (void) rightMouseUp:(NSEvent *)event -{ - [super rightMouseUp:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); -} - -/** ********************************************************************* - * called when middle mouse button is pressed - ***********************************************************************/ - -- (void) otherMouseDown:(NSEvent *)event -{ - [super otherMouseDown:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); -} - -/** ********************************************************************* - * called when middle mouse button is released - ***********************************************************************/ - -- (void) otherMouseUp:(NSEvent *)event -{ - [super otherMouseUp:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) (winFrame.origin.x + loc.x); - int y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y); -} - -- (void) scrollWheel:(NSEvent *)event -{ - uint16 flags; - - [super scrollWheel:event]; - - // we get more two finger trackpad scroll events - // than scrollWheel events, so we drop some - - if (gestureEventInProgress) - { - scrollWheelCount++; - - if (scrollWheelCount % 8 != 0) - return; - } - - if ([event scrollingDeltaY] < 0) - { - flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; - } - else - { - flags = PTR_FLAGS_WHEEL | 0x78; - } - - rdp_instance->input->MouseEvent(rdp_instance->input, flags, 0, 0); -} - -/** ********************************************************************* - * called when mouse is moved with left button pressed - * note: invocation order is: mouseDown, mouseDragged, mouseUp - ***********************************************************************/ -- (void) mouseDragged:(NSEvent *)event -{ - [super mouseDragged:event]; - - NSRect winFrame = [[self window] frame]; - NSPoint loc = [event locationInWindow]; - int x = (int) loc.x; - int y = (int) loc.y; - - if (titleBarClicked) - { - // window is being dragged to a new location - int newX = x - savedDragLocation.x; - int newY = y - savedDragLocation.y; - - if ((newX == 0) && (newY == 0)) - return; - - winFrame.origin.x += newX; - winFrame.origin.y += newY; - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_LEFT) - { - // left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff == 0) - return; - - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else - { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_RIGHT) - { - // right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff == 0) - return; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - winFrame.size.width += diff; - [[self window] setFrame:winFrame display:YES]; - - return; - } - - if (localMoveType == RAIL_WMSZ_TOP) - { - // top border resize taking place - int diff = (int) (loc.y - savedDragLocation.y); - - if (diff == 0) - return; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - winFrame.size.height += diff; - [[self window] setFrame:winFrame display:YES]; - - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOM) - { - // bottom border resize taking place - int diff = (int) (loc.y - savedDragLocation.y); - - if (diff == 0) - return; - - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else - { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_TOPLEFT) - { - // top left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff != 0) - { - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else - { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - } - - diff = (int) (loc.y - savedDragLocation.y); - - if (diff != 0) - { - savedDragLocation.y = loc.y; - winFrame.size.height += diff; - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_TOPRIGHT) - { - // top right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff != 0) - winFrame.size.width += diff; - - diff = (int) (loc.y - savedDragLocation.y); - - if (diff != 0) - winFrame.size.height += diff; - - savedDragLocation.x = loc.x; - savedDragLocation.y = loc.y; - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOMLEFT) - { - // bottom left border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff != 0) - { - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.x -= diff; - winFrame.size.width += diff; - } - else - { - winFrame.origin.x += diff; - winFrame.size.width -= diff; - } - } - - diff = (int) (loc.y - savedDragLocation.y); - - if (diff != 0) - { - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else - { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT) - { - // bottom right border resize taking place - int diff = (int) (loc.x - savedDragLocation.x); - - if (diff != 0) - { - savedDragLocation.x = loc.x; - //savedDragLocation.y = loc.y; - winFrame.size.width += diff; - } - - diff = (int) (loc.y - savedDragLocation.y); - - if (diff != 0) - { - if (diff < 0) - { - diff = abs(diff); - winFrame.origin.y -= diff; - winFrame.size.height += diff; - } - else - { - winFrame.origin.y += diff; - winFrame.size.height -= diff; - } - } - - [[self window] setFrame:winFrame display:YES]; - return; - } - - x = (int) (winFrame.origin.x + loc.x); - y = (int) (winFrame.origin.y + loc.y); - y = height - y; - - // send mouse motion event to RDP server - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); -} - -/** ********************************************************************* - * called when a key is pressed - ***********************************************************************/ - -- (void) keyDown:(NSEvent *) event -{ - int key; - USHORT extended; - DWORD vkcode; - DWORD scancode; - - key = [event keyCode] + 8; - - vkcode = GetVirtualKeyCodeFromKeycode(key, KEYCODE_TYPE_APPLE); - scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); - extended = (scancode & KBDEXT) ? KBDEXT : 0; - - rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF); -} - -/** ********************************************************************* - * called when a key is released - ***********************************************************************/ - -- (void) keyUp:(NSEvent *) event -{ - int key; - USHORT extended; - DWORD vkcode; - DWORD scancode; - - key = [event keyCode] + 8; - - vkcode = GetVirtualKeyCodeFromKeycode(key, KEYCODE_TYPE_APPLE); - scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); - extended = (scancode & KBDEXT) ? TRUE : FALSE; - - rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF); -} - -/** ********************************************************************* - * called when shift, control, alt and meta keys are pressed/released - ***********************************************************************/ - -- (void) flagsChanged:(NSEvent *) event -{ - NSUInteger mf = [event modifierFlags]; - - // caps lock - if (mf == 0x10100) { - printf("TODO: caps lock is on\n"); - kdcapslock = 1; - } - if (kdcapslock && (mf == 0x100)) { - kdcapslock = 0; - printf("TODO: caps lock is off\n"); - } - // left shift - if ((kdlshift == 0) && ((mf & 2) != 0)) { - // left shift went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x2a); - kdlshift = 1; - } - if ((kdlshift != 0) && ((mf & 2) == 0)) { - // left shift went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a); - kdlshift = 0; - } - - // right shift - if ((kdrshift == 0) && ((mf & 4) != 0)) { - // right shift went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x36); - kdrshift = 1; - } - if ((kdrshift != 0) && ((mf & 4) == 0)) { - // right shift went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36); - kdrshift = 0; - } - - // left ctrl - if ((kdlctrl == 0) && ((mf & 1) != 0)) { - // left ctrl went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x1d); - kdlctrl = 1; - } - if ((kdlctrl != 0) && ((mf & 1) == 0)) { - // left ctrl went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d); - kdlctrl = 0; - } - - // right ctrl - if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) { - // right ctrl went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x1d); - kdrctrl = 1; - } - if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) { - // right ctrl went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d); - kdrctrl = 0; - } - - // left alt - if ((kdlalt == 0) && ((mf & 0x20) != 0)) { - // left alt went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x38); - kdlalt = 1; - } - if ((kdlalt != 0) && ((mf & 0x20) == 0)) { - // left alt went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38); - kdlalt = 0; - } - - // right alt - if ((kdralt == 0) && ((mf & 0x40) != 0)) { - // right alt went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x38); - kdralt = 1; - } - if ((kdralt != 0) && ((mf & 0x40) == 0)) { - // right alt went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38); - kdralt = 0; - } - - // left meta - if ((kdlmeta == 0) && ((mf & 0x08) != 0)) { - // left meta went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5b); - kdlmeta = 1; - } - if ((kdlmeta != 0) && ((mf & 0x08) == 0)) { - // left meta went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b); - kdlmeta = 0; - } - - // right meta - if ((kdrmeta == 0) && ((mf & 0x10) != 0)) { - // right meta went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5c); - kdrmeta = 1; - } - if ((kdrmeta != 0) && ((mf & 0x10) == 0)) { - // right meta went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5c); - kdrmeta = 0; - } -} - -- (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID -{ - rdp_instance = instance; - context = instance->context; - width = w; - height = h; - savedWindowId = windowID; - - NSRect tr = NSMakeRect(0, 0, - [[NSScreen mainScreen] frame].size.width, - [[NSScreen mainScreen] frame].size.height); - - NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:tr options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways owner:self userInfo:nil]; - - [self addTrackingArea:trackingArea]; - - g_mrdpRailView = self; - - [self becomeFirstResponder]; - [self setAcceptsTouchEvents:YES]; - - // we want to be notified when window resizes.... - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil]; - - // ...moves - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:nil]; - - // ...and becomes the key window - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil]; -} - -- (void) setupBmiRep:(int) frameWidth :(int) frameHeight -{ - struct rgba_data - { - char red; - char green; - char blue; - char alpha; - }; - - if (pixelData) - free(pixelData); - - pixelData = (char *) malloc(frameWidth * frameHeight * sizeof(struct rgba_data)); - bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixelData - pixelsWide:frameWidth - pixelsHigh:frameHeight - bitsPerSample:8 - samplesPerPixel:sizeof(struct rgba_data) - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bitmapFormat:0 - bytesPerRow:frameWidth * sizeof(struct rgba_data) - bitsPerPixel:0]; -} -- (void) beginGestureWithEvent:(NSEvent *)event -{ - gestureEventInProgress = YES; -} - -- (void) endGestureWithEvent:(NSEvent *)event -{ - gestureEventInProgress = NO; -} - -/** - * called when a bordered window changes size - */ - -- (void) windowDidResize:(NSNotification *) notification -{ - // if we are not the source of this notification, just return - if ([notification object] != [self mrdpRailWindow]) - return; - - // let RDP server know that window has moved - RAIL_WINDOW_MOVE_ORDER windowMove; - NSRect r = [[self window] frame]; - - int diffInHeight = [[self window] frame].size.height - [self frame].size.height; - r.size.height -= diffInHeight; - - apple_to_windowMove(&r, &windowMove); - windowMove.windowId = self->savedWindowId; - mac_send_rail_client_event(self->context->channels, RailChannel_ClientWindowMove, &windowMove); -} - -/** - * called when user moves a bordered window - */ - -- (void) windowDidMove:(NSNotification *) notification -{ - // if we are not the source of this notification, just return - if ([notification object] != [self mrdpRailWindow]) - return; - - // let RDP server know that window has moved - RAIL_WINDOW_MOVE_ORDER windowMove; - NSRect r = [[self window] frame]; - - int diffInHeight = [[self window] frame].size.height - [self frame].size.height; - r.size.height -= diffInHeight; - - apple_to_windowMove(&r, &windowMove); - windowMove.windowId = self->savedWindowId; - mac_send_rail_client_event(self->context->channels, RailChannel_ClientWindowMove, &windowMove); -} - -/** - * called when a NSWindow becomes the key window - */ - -- (void) windowDidBecomeKey:(NSNotification *) notification -{ - // if we are not the source of this notification, just return - if ([notification object] != [self mrdpRailWindow]) - return; - - if (![self activateWindow]) - return; - - [[self window] setAcceptsMouseMovedEvents: YES]; - - //if ([self activateWindow]) - mac_rail_send_activate(savedWindowId); - - // set_current_window(windowIndex); // ? code mis-merge? -} - -- (void) releaseResources -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -void rail_cvt_from_rect(char* dest, char* src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect) -{ -} - -/** ********************************************************************* - * color space conversion used specifically in RAIL - ***********************************************************************/ -void rail_convert_color_space(char* destBuf, char* srcBuf, NSRect* destRect, int width, int height) -{ - int i; - int j; - int numRows; - int srcX; - int srcY; - int destX; - int destY; - int pixelsPerRow; - int pixel; - int pixel1; - int pixel2; - int * src32; - int * dest32; - - int destWidth = destRect->size.width; - int destHeight = destRect->size.height; - - if ((!destBuf) || (!srcBuf)) - return; - - numRows = (destRect->origin.y + destHeight > height) ? height - destRect->origin.y : destHeight; - pixelsPerRow = destWidth; - - srcX = destRect->origin.x; - srcY = destRect->origin.y; - destX = 0; - destY = 0; - - for (i = 0; i < numRows; i++) - { - src32 = (int *) (srcBuf + ((srcY + i) * width + srcX) * 4); - dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4); - - for (j = 0; j < pixelsPerRow; j++) - { - pixel = *src32; - pixel1 = (pixel & 0x00ff0000) >> 16; - pixel2 = (pixel & 0x000000ff) << 16; - pixel = (pixel & 0xff00ff00) | pixel1 | pixel2; - - *dest32 = pixel; - - src32++; - dest32++; - } - } - - destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height; - return; -} - -/** - * let RDP server know that window has moved - */ - -void rail_MoveWindow(rdpRail * rail, rdpWindow * window) -{ - if (g_mrdpRailView->isMoveSizeInProgress) - return; - - if (g_mrdpRailView->skipMoveWindowOnce) - { - g_mrdpRailView->skipMoveWindowOnce = NO; - return; - } - - // this rect is based on Windows co-ordinates... - NSRect r; - r.origin.x = window->windowOffsetX; - r.origin.y = window->windowOffsetY; - r.size.width = window->windowWidth; - r.size.height = window->windowHeight; - - windows_to_apple_cords(&r); - [[g_mrdpRailView window] setFrame:r display:YES]; -} - - -void mac_rail_send_activate(int window_id) -{ - RAIL_ACTIVATE_ORDER activate; - - activate.windowId = window_id; - activate.enabled = 1; - - mac_send_rail_client_event(g_mrdpRailView->context->channels, RailChannel_ClientActivate, &activate); -} - -@end - diff --git a/client/Mac/MRDPRailWindow.h b/client/Mac/MRDPRailWindow.h deleted file mode 100644 index 52f1c045a..000000000 --- a/client/Mac/MRDPRailWindow.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import <Cocoa/Cocoa.h> - -@interface MRDPRailWindow : NSWindow - -@end diff --git a/client/Mac/MRDPRailWindow.m b/client/Mac/MRDPRailWindow.m deleted file mode 100644 index f714d610e..000000000 --- a/client/Mac/MRDPRailWindow.m +++ /dev/null @@ -1,29 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import "MRDPRailWindow.h" - -@implementation MRDPRailWindow - -- (BOOL) canBecomeKeyWindow -{ - return YES; -} - -@end diff --git a/client/Mac/MRDPView.h b/client/Mac/MRDPView.h index c15b35641..96b6f2bd0 100644 --- a/client/Mac/MRDPView.h +++ b/client/Mac/MRDPView.h @@ -19,8 +19,12 @@ #import <Cocoa/Cocoa.h> +#ifdef HAVE_RAIL #import "MRDPWindow.h" -#import "freerdp/freerdp.h" +#endif + +/* + #import "freerdp/freerdp.h" #import "freerdp/types.h" #import "freerdp/channels/channels.h" #import "freerdp/gdi/gdi.h" @@ -32,6 +36,9 @@ #import "freerdp/rail/rail.h" #import "freerdp/rail.h" #import "freerdp/utils/rail.h" +*/ + + @interface MRDPView : NSView { @@ -43,17 +50,20 @@ NSTimer* pasteboard_timer; NSRect prevWinPosition; int titleBarHeight; - freerdp* rdp_instance; - rdpContext* rdp_context; + void* rdp_instance; + void* rdp_context; CGContextRef bitmap_context; char* pixel_data; int width; int height; int argc; char** argv; - - /* RemoteApp */ + +#ifdef HAVE_RAIL + // RemoteApp MRDPWindow* currentWindow; +#endif + NSPoint savedDragLocation; BOOL mouseInClientArea; BOOL isRemoteApp; @@ -62,7 +72,7 @@ BOOL skipResizeOnce; BOOL saveInitialDragLoc; BOOL skipMoveWindowOnce; - + /* store state info for some keys */ int kdlshift; int kdrshift; @@ -76,16 +86,17 @@ @public NSWindow* ourMainWindow; - NSPasteboard* pasteboard_rd; - NSPasteboard* pasteboard_wr; + NSPasteboard* pasteboard_rd; /* for reading from clipboard */ + NSPasteboard* pasteboard_wr; /* for writing to clipboard */ int pasteboard_changecount; int pasteboard_format; int is_connected; } +- (int) rdpConnect; - (void) rdpConnectError; - (void) rdpRemoteAppError; -- (void) saveStateInfo :(freerdp *) instance :(rdpContext *) context; +- (void) saveStateInfo :(void *) instance :(void *) context; - (void) onPasteboardTimerFired :(NSTimer *) timer; - (void) releaseResources; - (void) setViewSize : (int) width : (int) height; @@ -95,87 +106,11 @@ @end /* Pointer Flags */ -#define PTR_FLAGS_WHEEL 0x0200 -#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100 -#define PTR_FLAGS_MOVE 0x0800 -#define PTR_FLAGS_DOWN 0x8000 -#define PTR_FLAGS_BUTTON1 0x1000 -#define PTR_FLAGS_BUTTON2 0x2000 -#define PTR_FLAGS_BUTTON3 0x4000 -#define WheelRotationMask 0x01FF - -void mf_Pointer_New(rdpContext* context, rdpPointer* pointer); -void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer); -void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer); -void mf_Pointer_SetNull(rdpContext* context); -void mf_Pointer_SetDefault(rdpContext* context); - -int rdp_connect(void); -BOOL mac_pre_connect(freerdp* instance); -BOOL mac_post_connect(freerdp* instance); -BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain); -void mac_context_new(freerdp* instance, rdpContext* context); -void mac_context_free(freerdp* instance, rdpContext* context); -void mac_set_bounds(rdpContext* context, rdpBounds* bounds); -void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap); -void mac_begin_paint(rdpContext* context); -void mac_end_paint(rdpContext* context); -void mac_save_state_info(freerdp* instance, rdpContext* context); -void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info); -void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info); -int register_fds(int* fds, int count, void* instance); -int invoke_draw_rect(rdpContext* context); -int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data); -int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size); -void process_cliprdr_event(freerdp* instance, wMessage* event); -void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event); -void cliprdr_send_data_request(freerdp* instance, UINT32 format); -void cliprdr_process_cb_monitor_ready_event(freerdp* inst); -void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event); -void cliprdr_process_text(freerdp* instance, BYTE* data, int len); -void cliprdr_send_supported_format_list(freerdp* instance); -int register_channel_fds(int* fds, int count, void* instance); - -void mac_process_rail_event(freerdp* instance, wMessage* event); -void mac_rail_register_callbacks(freerdp* instance, rdpRail* rail); -void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window); -void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window); -void mac_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state); -void mac_rail_SetWindowText(rdpRail* rail, rdpWindow* window); -void mac_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon); -void mac_rail_SetWindowRects(rdpRail* rail, rdpWindow* window); -void mac_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window); -void mac_rail_DestroyWindow(rdpRail* rail, rdpWindow* window); -void mac_process_rail_get_sysparams_event(rdpChannels* channels, wMessage* event); -void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param); -void mac_on_free_rail_client_event(wMessage* event); -void mac_process_rail_server_sysparam_event(rdpChannels* channels, wMessage* event); -void mac_process_rail_exec_result_event(rdpChannels* channels, wMessage* event); -void mac_rail_enable_remoteapp_mode(void); -void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, wMessage* event); -void mac_process_rail_server_localmovesize_event(freerdp* instance, wMessage* event); -void apple_center_window(NSRect* r); -void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove); - -struct mac_context -{ - rdpContext _p; -}; - -struct cursor -{ - rdpPointer* pointer; - BYTE* cursor_data; - void* bmiRep; /* NSBitmapImageRep */ - void* nsCursor; /* NSCursor */ - void* nsImage; /* NSImage */ -}; - -struct rgba_data -{ - char red; - char green; - char blue; - char alpha; -}; - +#define PTR_FLAGS_WHEEL 0x0200 +#define PTR_FLAGS_WHEEL_NEGATIVE 0x0100 +#define PTR_FLAGS_MOVE 0x0800 +#define PTR_FLAGS_DOWN 0x8000 +#define PTR_FLAGS_BUTTON1 0x1000 +#define PTR_FLAGS_BUTTON2 0x2000 +#define PTR_FLAGS_BUTTON3 0x4000 +#define WheelRotationMask 0x01FF diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index db30f5830..8548f01dd 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -51,9 +51,113 @@ #include <freerdp/constants.h> +#import "freerdp/freerdp.h" +#import "freerdp/types.h" +#import "freerdp/channels/channels.h" +#import "freerdp/gdi/gdi.h" +#import "freerdp/graphics.h" +#import "freerdp/utils/event.h" +#import "freerdp/client/cliprdr.h" +#import "freerdp/client/file.h" +#import "freerdp/client/cmdline.h" +#import "freerdp/rail/rail.h" +#import "freerdp/rail.h" +#import "freerdp/utils/rail.h" + +#ifdef HAVE_RAIL +#import "MRDPWindow.h" +#endif + // RAIL_TODO DELETE WHEN DONE TESTING #define MRDP_DRAW_INDIVIDUAL_RECTS + + +/****************************************** + Forward declarations + ******************************************/ + + +void mf_Pointer_New(rdpContext* context, rdpPointer* pointer); +void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer); +void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer); +void mf_Pointer_SetNull(rdpContext* context); +void mf_Pointer_SetDefault(rdpContext* context); +// int rdp_connect(void); +BOOL mac_pre_connect(freerdp* instance); +BOOL mac_post_connect(freerdp* instance); +BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain); +void mac_context_new(freerdp* instance, rdpContext* context); +void mac_context_free(freerdp* instance, rdpContext* context); +void mac_set_bounds(rdpContext* context, rdpBounds* bounds); +void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap); +void mac_begin_paint(rdpContext* context); +void mac_end_paint(rdpContext* context); +void mac_save_state_info(freerdp* instance, rdpContext* context); +void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info); +void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info); +int register_fds(int* fds, int count, void* instance); +int invoke_draw_rect(rdpContext* context); +int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data); +int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size); +void process_cliprdr_event(freerdp* instance, wMessage* event); +void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event); +void cliprdr_send_data_request(freerdp* instance, UINT32 format); +void cliprdr_process_cb_monitor_ready_event(freerdp* inst); +void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event); +void cliprdr_process_text(freerdp* instance, BYTE* data, int len); +void cliprdr_send_supported_format_list(freerdp* instance); +int register_channel_fds(int* fds, int count, void* instance); + +void mac_process_rail_event(freerdp* instance, wMessage* event); +void mac_rail_register_callbacks(freerdp* instance, rdpRail* rail); +void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window); +void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window); +void mac_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state); +void mac_rail_SetWindowText(rdpRail* rail, rdpWindow* window); +void mac_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon); +void mac_rail_SetWindowRects(rdpRail* rail, rdpWindow* window); +void mac_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window); +void mac_rail_DestroyWindow(rdpRail* rail, rdpWindow* window); +void mac_process_rail_get_sysparams_event(rdpChannels* channels, wMessage* event); +void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param); +void mac_on_free_rail_client_event(wMessage* event); +void mac_process_rail_server_sysparam_event(rdpChannels* channels, wMessage* event); +void mac_process_rail_exec_result_event(rdpChannels* channels, wMessage* event); +void mac_rail_enable_remoteapp_mode(void); +void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, wMessage* event); +void mac_process_rail_server_localmovesize_event(freerdp* instance, wMessage* event); +void apple_center_window(NSRect* r); +void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER * windowMove); + +struct mac_context +{ + // *must* have this - do not delete + rdpContext _p; +}; + +struct cursor +{ + rdpPointer* pointer; + BYTE* cursor_data; + void* bmiRep; /* NSBitmapImageRep */ + void* nsCursor; /* NSCursor */ + void* nsImage; /* NSImage */ +}; + +struct rgba_data +{ + char red; + char green; + char blue; + char alpha; +}; + + + + + + @implementation MRDPView MRDPView *g_mrdpview; @@ -71,6 +175,41 @@ const char* error_code_names[] = "RAIL_EXEC_E_SESSION_LOCKED" }; +//int rdp_connect() +- (int) rdpConnect +{ + int status; + freerdp* instance; + + freerdp_channels_global_init(); + + instance = freerdp_new(); + instance->PreConnect = mac_pre_connect; + instance->PostConnect = mac_post_connect; + instance->context_size = sizeof(struct mac_context); + instance->ContextNew = mac_context_new; + instance->ContextFree = mac_context_free; + instance->ReceiveChannelData = receive_channel_data; + instance->Authenticate = mac_authenticate; + freerdp_context_new(instance); + + status = freerdp_connect(instance); + + if (status) + { + freerdp_check_fds(instance); + [g_mrdpview setIs_connected:1]; + return 0; + } + + [g_mrdpview setIs_connected:0]; + [g_mrdpview rdpConnectError]; + + return -1; +} + + + /************************************************************************ methods we override ************************************************************************/ @@ -108,16 +247,19 @@ const char* error_code_names[] = [[self window] setAcceptsMouseMovedEvents:YES]; cursors = [[NSMutableArray alloc] initWithCapacity:10]; - + +#ifdef HAVE_RAIL firstCreateWindow = TRUE; skipResizeOnce = YES; windows = [[NSMutableArray alloc] initWithCapacity:10]; - + +#endif + // setup a mouse tracking area NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveWhenFirstResponder owner:self userInfo:nil]; //[self addTrackingArea:trackingArea]; - + // windows in RemoteApp (RAIL) mode cannot have title bars NSArray * args = [[NSProcessInfo processInfo] arguments]; for (NSString * str in args) @@ -132,6 +274,7 @@ const char* error_code_names[] = [self addTrackingArea:trackingArea]; mouseInClientArea = YES; + } /** ********************************************************************* @@ -170,7 +313,7 @@ const char* error_code_names[] = y = height - y; // send mouse motion event to RDP server - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_MOVE, x, y); } /** ********************************************************************* @@ -190,7 +333,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); } /** ********************************************************************* @@ -210,7 +353,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON1, x, y); } /** ********************************************************************* @@ -230,7 +373,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); } /** ********************************************************************* @@ -250,7 +393,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON2, x, y); } /** ********************************************************************* @@ -270,7 +413,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); } /** ********************************************************************* @@ -290,7 +433,7 @@ const char* error_code_names[] = y = height - y; - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON3, x, y); } - (void) scrollWheel:(NSEvent *)event @@ -318,7 +461,7 @@ const char* error_code_names[] = x += (int) [event deltaX]; y += (int) [event deltaY]; - rdp_instance->input->MouseEvent(rdp_instance->input, flags, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, flags, x, y); } /** ********************************************************************* @@ -337,6 +480,7 @@ const char* error_code_names[] = int x = (int) loc.x; int y = (int) loc.y; +#ifdef HAVE_RAIL // RAIL_TODO delete this if not reqd if ((isRemoteApp) && (isMoveSizeInProgress)) { @@ -356,11 +500,12 @@ const char* error_code_names[] = r.origin.y += newY; [[g_mrdpview window] setFrame:r display:YES]; } - +#endif + y = height - y; // send mouse motion event to RDP server - rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); + ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_MOVE, x, y); } /** ********************************************************************* @@ -383,7 +528,7 @@ const char* error_code_names[] = scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); extended = (scancode & KBDEXT) ? KBDEXT : 0; - rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF); } /** ********************************************************************* @@ -406,7 +551,7 @@ const char* error_code_names[] = scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); extended = (scancode & KBDEXT) ? KBDEXT : 0; - rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF); } /** ********************************************************************* @@ -432,96 +577,96 @@ const char* error_code_names[] = // left shift if ((kdlshift == 0) && ((mf & 2) != 0)) { // left shift went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x2a); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x2a); kdlshift = 1; } if ((kdlshift != 0) && ((mf & 2) == 0)) { // left shift went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x2a); kdlshift = 0; } // right shift if ((kdrshift == 0) && ((mf & 4) != 0)) { // right shift went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x36); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x36); kdrshift = 1; } if ((kdrshift != 0) && ((mf & 4) == 0)) { // right shift went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x36); kdrshift = 0; } // left ctrl if ((kdlctrl == 0) && ((mf & 1) != 0)) { // left ctrl went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x1d); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x1d); kdlctrl = 1; } if ((kdlctrl != 0) && ((mf & 1) == 0)) { // left ctrl went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x1d); kdlctrl = 0; } // right ctrl if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) { // right ctrl went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x1d); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x1d); kdrctrl = 1; } if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) { // right ctrl went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x1d); kdrctrl = 0; } // left alt if ((kdlalt == 0) && ((mf & 0x20) != 0)) { // left alt went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x38); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x38); kdlalt = 1; } if ((kdlalt != 0) && ((mf & 0x20) == 0)) { // left alt went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x38); kdlalt = 0; } // right alt if ((kdralt == 0) && ((mf & 0x40) != 0)) { // right alt went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x38); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x38); kdralt = 1; } if ((kdralt != 0) && ((mf & 0x40) == 0)) { // right alt went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x38); kdralt = 0; } // left meta if ((kdlmeta == 0) && ((mf & 0x08) != 0)) { // left meta went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5b); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x5b); kdlmeta = 1; } if ((kdlmeta != 0) && ((mf & 0x08) == 0)) { // left meta went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x5b); kdlmeta = 0; } // right meta if ((kdrmeta == 0) && ((mf & 0x10) != 0)) { // right meta went down - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5c); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x5c); kdrmeta = 1; } if ((kdrmeta != 0) && ((mf & 0x10) == 0)) { // right meta went up - rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5c); + ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x5c); kdrmeta = 0; } } @@ -536,12 +681,14 @@ const char* error_code_names[] = free(argv[i]); } +#ifdef HAVE_RAIL for (MRDPWindow * w in windows) { [w setWindow:nil]; [w setView:nil]; } - +#endif + if (!is_connected) return; @@ -566,9 +713,11 @@ const char* error_code_names[] = if (!rdp_context) return; +#ifdef HAVE_RAIL if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) return; - +#endif + if(g_mrdpview->bitmap_context) { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; @@ -595,7 +744,7 @@ const char* error_code_names[] = * save state info for use by other methods later on ***********************************************************************/ -- (void) saveStateInfo:(freerdp *) instance :(rdpContext *) context +- (void) saveStateInfo:(void *) instance :(void *) context { rdp_instance = instance; rdp_context = context; @@ -755,9 +904,11 @@ const char* error_code_names[] = [[g_mrdpview window] orderOut:g_mrdpview]; } +#ifdef HAVE_RAIL // RAIL_TODO is this func required - (void) windowDidResize:(NSNotification*) notification { + RAIL_WINDOW_MOVE_ORDER windowMove; printf("RAIL_TODO: MRDPView: windowDidResize() - not yet implemented\n"); @@ -786,8 +937,9 @@ const char* error_code_names[] = printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n", [currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height); - //mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); + //mac_send_rail_client_event(g_mrdpview->((freerdp*)rdp_instance)->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); } +#endif /************************************************************************ * * @@ -801,37 +953,6 @@ const char* error_code_names[] = * @return 0 on success, -1 on failure ***********************************************************************/ -int rdp_connect() -{ - int status; - freerdp* instance; - - freerdp_channels_global_init(); - - instance = freerdp_new(); - instance->PreConnect = mac_pre_connect; - instance->PostConnect = mac_post_connect; - instance->context_size = sizeof(struct mac_context); - instance->ContextNew = mac_context_new; - instance->ContextFree = mac_context_free; - instance->ReceiveChannelData = receive_channel_data; - instance->Authenticate = mac_authenticate; - freerdp_context_new(instance); - - status = freerdp_connect(instance); - - if (status) - { - freerdp_check_fds(instance); - [g_mrdpview setIs_connected:1]; - return 0; - } - - [g_mrdpview setIs_connected:0]; - [g_mrdpview rdpConnectError]; - - return -1; -} /** ********************************************************************* * a callback given to freerdp_connect() to process the pre-connect operations. @@ -1038,12 +1159,14 @@ BOOL mac_post_connect(freerdp* instance) register_channel_fds(fds, rd_count, instance); freerdp_channels_post_connect(instance->context->channels, instance); - + +#ifdef HAVE_RAIL /* setup RemoteApp */ instance->context->rail = rail_new(instance->settings); rail_register_update_callbacks(instance->context->rail, instance->update); mac_rail_register_callbacks(instance, instance->context->rail); - +#endif + /* setup pasteboard (aka clipboard) for copy operations (write only) */ g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard]; @@ -1281,14 +1404,16 @@ void mac_end_paint(rdpContext* context) if (context->gdi->drawing != context->gdi->primary) return; - gdi = g_mrdpview->rdp_context->gdi; + gdi = ((rdpContext*)g_mrdpview->rdp_context)->gdi; +#ifdef HAVE_RAIL if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) { [[g_mrdpview->currentWindow view] updateDisplay]; return; } - +#endif + for (i = 0; i < gdi->primary->hdc->hwnd->ninvalid; i++) { drawRect.origin.x = gdi->primary->hdc->hwnd->cinvalid[i].x; @@ -1333,10 +1458,11 @@ void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, { switch (GetMessageClass(event->id)) { +#ifdef HAVE_RAIL case RailChannel_Class: mac_process_rail_event(instance, event); break; - +#endif case CliprdrChannel_Class: process_cliprdr_event(instance, event); break; @@ -1617,6 +1743,9 @@ void cliprdr_send_supported_format_list(freerdp* instance) freerdp_channels_send_event(instance->context->channels, (wMessage*) event); } + +#ifdef HAVE_RAIL + /**************************************************************************************** * * * * @@ -1715,7 +1844,7 @@ void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window) RAIL_WINDOW_MOVE_ORDER windowMove; apple_to_windowMove(&winFrame, &windowMove); windowMove.windowId = window->windowId; - mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RailChannel_ClientWindowMove, &windowMove); + mac_send_rail_client_event(((freerdp*)g_mrdpview->rdp_instance)->context->channels, RailChannel_ClientWindowMove, &windowMove); } /* create MRDPRailView and add to above window */ @@ -2031,6 +2160,8 @@ void mac_rail_enable_remoteapp_mode() g_mrdpview->isRemoteApp = TRUE; } +#endif + /** * given a rect with 0,0 at the bottom left (apple cords) * convert it to a rect with 0,0 at the top left (windows cords) @@ -2057,6 +2188,7 @@ void apple_center_window(NSRect* r) r->origin.y = (g_mrdpview->height - r->size.height) / 2; } +#ifdef HAVE_RAIL void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove) { windowMove->left = (UINT16) r->origin.x; // x-cord of top left corner @@ -2064,5 +2196,7 @@ void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove) windowMove->right = (UINT16) (windowMove->left + r->size.width); // x-cord of bottom right corner windowMove->bottom = (UINT16) (windowMove->top + r->size.height); // y-cord of bottom right corner } +#endif + @end diff --git a/client/Mac/MRDPWindow.h b/client/Mac/MRDPWindow.h deleted file mode 100644 index 0e7e26b97..000000000 --- a/client/Mac/MRDPWindow.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#import <Foundation/Foundation.h> -#import "MRDPRailView.h" -#import "MRDPRailWindow.h" - -@interface MRDPWindow : NSObject -{ -} - -@property (assign) int windowID; -@property (retain) MRDPRailWindow* window; -@property (retain) MRDPRailView* view; - -@end - diff --git a/client/Mac/MRDPWindow.m b/client/Mac/MRDPWindow.m deleted file mode 100644 index e5e5e402f..000000000 --- a/client/Mac/MRDPWindow.m +++ /dev/null @@ -1,28 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * MacFreeRDP - * - * Copyright 2012 Thomas Goddard - * - * 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. - */ - -#include "MRDPWindow.h" - -@implementation MRDPWindow - -@synthesize windowID; -@synthesize window; -@synthesize view; - -@end diff --git a/client/Mac/PasswordDialog.h b/client/Mac/PasswordDialog.h index d95783ab2..3e22de7dd 100644 --- a/client/Mac/PasswordDialog.h +++ b/client/Mac/PasswordDialog.h @@ -20,7 +20,15 @@ #import <Cocoa/Cocoa.h> @interface PasswordDialog : NSWindowController - +{ +@public + NSTextField* usernameText; + NSTextField* passwordText; + NSTextField* messageLabel; + NSString* serverHostname; + NSString* username; + NSString* password; +} @property (retain) IBOutlet NSTextField* usernameText; @property (retain) IBOutlet NSTextField* passwordText; @property (retain) IBOutlet NSTextField* messageLabel; diff --git a/client/Mac/README.txt b/client/Mac/README.txt deleted file mode 100644 index 39fe93f73..000000000 --- a/client/Mac/README.txt +++ /dev/null @@ -1,140 +0,0 @@ - -------------------------------------------------------------------------- - Building FreeRDP on Mac OS X -------------------------------------------------------------------------- - -Platform: Lion with Xcode 4.3.2 - ------------------- - installing cmake ------------------- - -first install macports by googling for it, the run the following command -sudo port install cmake - ----------------- - installing gcc ----------------- -Click on Xcode->Preferences->Downloads -Click on Components -Click on Install Command line tools - -You will be prompted for your Apple Developer userid and password - ----------------------------------------- - download FreeRDP source code using git ----------------------------------------- - -mkdir ~/projects/A8 -cd ~/projects/A8 -git clone git://github.com/FreeRDP/FreeRDP.git - ------------------- - building FreeRDP ------------------- - -cd ~projects/A8/FreeRDP -cmake -DWITH_MACAUDIO=ON -DCMAKE_INSTALL_PREFIX="</path/to/your/staging/dir>" -make -make install - ------------------------- - creating Xcode project ------------------------- - -Start xcode -Select 'Create a new xcode project' -In 'Choose a template for your new project', click on Mac OS X -> application -Click on 'Cocoa Application' -Click on next -I used the following: -Product Name: Mac -Company Identifier: com.freerdp -Check 'Automatic Reference Counting' -Create the project in your directory of choice - -------------------------------- - Adding files to your projects -------------------------------- - -Add the following files to your project: - -cd ~/projects/A8/FreeRDP/client/Mac/MRDPCursor.h -cd ~/projects/A8/FreeRDP/client/Mac/MRDPCursor.m -cd ~/projects/A8/FreeRDP/client/Mac/MRDPView.h -cd ~/projects/A8/FreeRDP/client/Mac/MRDPView.m - -This is what your AppDelegate.h file should like like - -#import <Cocoa/Cocoa.h> -#import "MRDPView.h" - -@interface AppDelegate : NSObject <NSApplicationDelegate> - -@property (assign) IBOutlet NSWindow *window; -@property (assign) IBOutlet MRDPView *mrdpView; - -int rdp_connect(); - -@end - -This is what your AppDelegate.m file should like like - -#import "AppDelegate.h" - -@implementation AppDelegate - -@synthesize window = _window; -@synthesize mrdpView; - -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification -{ - rdp_connect(); -} - -- (void) applicationWillTerminate:(NSNotification *)notification -{ - [mrdpView releaseResources]; -} - -@end - ----------------------------------- - Modifying your MainMenu.xib file ----------------------------------- - -In your project select MainMenu.xib and drag a NSView object into the main window -Name the class MRDPView -In Interface Builder, select the Application Delegate and tie the mrdpview outlet to the NSView -Set the default size of the main window to 1024x768. This is FreeRDP's default resolution - ----------------------------- - Configuring build settings ----------------------------- - -In Project Navigator, click on Mac -Click on Targets -> Mac -Click on Build Phases -Click on 'Link Binary With Libraries' and click on the + button, then click on the 'Add Other' button to add the following dynamic libraries -~/projects/A8/FreeRDP/libfreerdp-core/libfreerdp-core.dylib -~/projects/A8/FreeRDP/libfreerdp-channels/libfreerdp-channels.dylilb -~/projects/A8/FreeRDP/libfreerdp-utils/libfreerdp-utils.dylib -~/projects/A8/FreeRDP/libfreerdp-codec/libfreerdp-codec.dylib -~/projects/A8/FreeRDP/libfreerdp-cache/libfreerdp-cache.dylib -~/projects/A8/FreeRDP/libfreerdp-gdi/libfreerdp-gdi.dylib - -Click on 'Build Settings' -In 'Search Paths -> Library Search Paths' set the following - Header Search Path Debug: ~/projects/A8/FreeRDP/include - Header Search Path Release: ~/projects/A8/FreeRDP/include - -TODO: in build settings, set strip build product to yes when done debugging - ---------------------------- - To deploy the application ---------------------------- - -in xcode, click on Product->Archive -Click on Distribute button -Select Export As -> application - diff --git a/client/Mac/cli/AppDelegate.h b/client/Mac/cli/AppDelegate.h new file mode 100644 index 000000000..b24cbeeab --- /dev/null +++ b/client/Mac/cli/AppDelegate.h @@ -0,0 +1,22 @@ +// +// AppDelegate.h +// MacClient2 +// +// Created by Benoît et Kathy on 2013-05-08. +// +// + +#import <Cocoa/Cocoa.h> +#import <MacFreeRDP-library/MRDPView.h> + +@interface AppDelegate : NSObject <NSApplicationDelegate> +{ +@public + NSWindow* window; + MRDPView* mrdpView; +} + +@property (assign) IBOutlet NSWindow *window; +@property (assign) IBOutlet MRDPView *mrdpView; + +@end diff --git a/client/Mac/cli/AppDelegate.m b/client/Mac/cli/AppDelegate.m new file mode 100644 index 000000000..8fca18cb7 --- /dev/null +++ b/client/Mac/cli/AppDelegate.m @@ -0,0 +1,32 @@ +// +// AppDelegate.m +// MacClient2 +// +// Created by Benoît et Kathy on 2013-05-08. +// +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (void)dealloc +{ + [super dealloc]; +} + +@synthesize window = window; + +@synthesize mrdpView = mrdpView; + +- (void)applicationDidFinishLaunching:(NSNotification*)aNotification +{ + [mrdpView rdpConnect]; +} + +- (void) applicationWillTerminate:(NSNotification*)notification +{ + [mrdpView releaseResources]; +} + +@end diff --git a/client/Mac/cli/CMakeLists.txt b/client/Mac/cli/CMakeLists.txt new file mode 100644 index 000000000..789bd5cde --- /dev/null +++ b/client/Mac/cli/CMakeLists.txt @@ -0,0 +1,127 @@ +project(MacFreeRDP-client) + +set(MODULE_NAME "MacFreeRDP-client") +set(MODULE_PREFIX "FREERDP_CLIENT_MAC_CLIENT") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4") + +# Import libraries +find_library(FOUNDATION_LIBRARY Foundation) +find_library(COCOA_LIBRARY Cocoa) +find_library(APPKIT_LIBRARY AppKit) +find_library(FREERDP_LIBRARY NAMES MacFreeRDP-library PATHS ${CMAKE_CURRENT_BINARY_DIR}/../${CONFIGURATION}) + +set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP-client") +set(MACOSX_BUNDLE_ICON_FILE "FreeRDP.icns") +set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac") +set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP-client.Mac") +set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP Client Version 1.1.0") +set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP") +set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.1.0) +set(MACOSX_BUNDLE_BUNDLE_VERSION 1.1.0) +set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2012. All Rights Reserved.") + +set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu") +set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication") + +mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY) +set(APP_TYPE MACOSX_BUNDLE) + +# OS X Interface Builder files +file(GLOB ${MODULE_NAME}_XIBS *.xib) + +set(${MODULE_NAME}_RESOURCES ${MACOSX_BUNDLE_ICON_FILE}) + +# Include XIB file in Xcode resources. +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}") + set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${${MODULE_NAME}_XIBS}) +endif("${CMAKE_GENERATOR}" MATCHES "Xcode") + +# Headers +file(GLOB ${MODULE_NAME}_HEADERS *.h) + +# Source +file(GLOB ${MODULE_NAME}_SOURCES *.m) + +add_executable(${MODULE_NAME} + ${APP_TYPE} + ${${MODULE_NAME}_HEADERS} + ${${MODULE_NAME}_SOURCES} + ${${MODULE_NAME}_RESOURCES}) + +# This is necessary for the xib file part below +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) + +# This allows for automatic xib to nib ibitool +set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOURCES}") + +# Automatic ref counting +# temporary turn off for x86_64 build issue +# set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) + +# Support for automatic reference counting requires non-fragile abi. +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -v -fobjc-nonfragile-abi") + +# Tell the compiler where to look for the FreeRDP framework +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -F../") + +# Tell XCode where to look for the MacFreeRDP-library framework +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS + "${XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS} ${CMAKE_CURRENT_BINARY_DIR}/../$(CONFIGURATION)") + + +# XCode project architecture to native architecture of build machine +# ----------------------------------------------------------------------------------------------------- +# Issue: Had some issues with FreeRDP project building only 64 bit and +# MacFreeRDP attempting to link to both 32 and 64 for dual target. +# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons: +# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage +# If you know the solutions for 1 and 2, please add below. +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") + +# Set the info plist to the custom instance +set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) + +# Disable transitive linking +# ${FREERDP_LIBRARY} +target_link_libraries(${MODULE_NAME} ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY} MacFreeRDP-library) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac") + +# Embed the FreeRDP framework into the app bundle +add_custom_command(TARGET ${MODULE_NAME} POST_BUILD + COMMAND mkdir ARGS -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Frameworks + COMMAND ditto ${CMAKE_CURRENT_BINARY_DIR}/../$(CONFIGURATION)/MacFreeRDP-library.framework ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Frameworks/MacFreeRDP-library.framework + COMMAND install_name_tool -change "@executable_path/../../Frameworks/MacFreeRDP-library.framework/Versions/1.1.0/MacFreeRDP-library" "@executable_path/../Frameworks/MacFreeRDP-library.framework/Versions/Current/MacFreeRDP-library" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/MacOS/${MODULE_NAME}" + COMMENT Setting install name for MacFreeRDP-library + + ) + + +# Add post-build NIB file generation in unix makefiles. XCode handles this implicitly. +if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + message(STATUS "Adding post-build NIB file generation event for ${MODULE_NAME}") + + # Make sure we can find the 'ibtool' program. If we can NOT find it we + # skip generation of this project + find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") + if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") + message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with + the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin") + endif() + + # Make sure the 'Resources' Directory is correctly created before we build + add_custom_command (TARGET ${MODULE_NAME} PRE_BUILD + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources) + + # Compile the .xib files using the 'ibtool' program with the destination being the app package + foreach(xib ${${MODULE_NAME}_XIBS}) + get_filename_component(XIB_WE ${xib} NAME_WE) + + add_custom_command (TARGET ${MODULE_NAME} POST_BUILD + COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text + --compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources/${XIB_WE}.nib ${xib} + COMMENT "Compiling ${xib}") + endforeach() + +endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") \ No newline at end of file diff --git a/client/Mac/FreeRDP.icns b/client/Mac/cli/FreeRDP.icns similarity index 100% rename from client/Mac/FreeRDP.icns rename to client/Mac/cli/FreeRDP.icns diff --git a/client/Mac/cli/Info.plist b/client/Mac/cli/Info.plist new file mode 100644 index 000000000..cb6976502 --- /dev/null +++ b/client/Mac/cli/Info.plist @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string></string> + <key>CFBundleIconFile</key> + <string>FreeRDP</string> + <key>CFBundleIdentifier</key> + <string>FreeRDP.Mac</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string></string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSMinimumSystemVersion</key> + <string></string> + <key>NSHumanReadableCopyright</key> + <string>Copyright © 2012 __MyCompanyName__. All rights reserved.</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> diff --git a/client/Mac/cli/MacClient2-Info.plist b/client/Mac/cli/MacClient2-Info.plist new file mode 100644 index 000000000..6efd7bddc --- /dev/null +++ b/client/Mac/cli/MacClient2-Info.plist @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>awakecoding.${PRODUCT_NAME:rfc1034identifier}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSMinimumSystemVersion</key> + <string>${MACOSX_DEPLOYMENT_TARGET}</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> diff --git a/client/Mac/cli/MacClient2-Prefix.pch b/client/Mac/cli/MacClient2-Prefix.pch new file mode 100644 index 000000000..f81d50593 --- /dev/null +++ b/client/Mac/cli/MacClient2-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'MacClient2' target in the 'MacClient2' project +// + +#ifdef __OBJC__ + #import <Cocoa/Cocoa.h> +#endif diff --git a/client/Mac/MainMenu.xib b/client/Mac/cli/MainMenu.xib similarity index 98% rename from client/Mac/MainMenu.xib rename to client/Mac/cli/MainMenu.xib index e535cbe12..90e992462 100755 --- a/client/Mac/MainMenu.xib +++ b/client/Mac/cli/MainMenu.xib @@ -2,10 +2,10 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> <data> <int key="IBDocument.SystemTarget">1070</int> - <string key="IBDocument.SystemVersion">12C60</string> + <string key="IBDocument.SystemVersion">12D78</string> <string key="IBDocument.InterfaceBuilderVersion">3084</string> - <string key="IBDocument.AppKitVersion">1187.34</string> - <string key="IBDocument.HIToolboxVersion">625.00</string> + <string key="IBDocument.AppKitVersion">1187.37</string> + <string key="IBDocument.HIToolboxVersion">626.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.object.0">3084</string> @@ -375,7 +375,7 @@ <reference key="source" ref="976324537"/> <reference key="destination" ref="467991374"/> </object> - <int key="connectionID">565</int> + <int key="connectionID">569</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> @@ -383,7 +383,7 @@ <reference key="source" ref="976324537"/> <reference key="destination" ref="972006081"/> </object> - <int key="connectionID">567</int> + <int key="connectionID">570</int> </object> </array> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -736,7 +736,7 @@ <nil key="activeLocalization"/> <dictionary class="NSMutableDictionary" key="localizations"/> <nil key="sourceID"/> - <int key="maxID">568</int> + <int key="maxID">570</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <array class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -770,6 +770,14 @@ <string key="minorKey">./Classes/MRDPView.h</string> </object> </object> + <object class="IBPartialClassDescription"> + <string key="className">NSLayoutConstraint</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">./Classes/NSLayoutConstraint.h</string> + </object> + </object> </array> </object> <int key="IBDocument.localizationMode">0</int> diff --git a/client/Mac/cli/en.lproj/Credits.rtf b/client/Mac/cli/en.lproj/Credits.rtf new file mode 100644 index 000000000..46576ef21 --- /dev/null +++ b/client/Mac/cli/en.lproj/Credits.rtf @@ -0,0 +1,29 @@ +{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} +{\colortbl;\red255\green255\blue255;} +\paperw9840\paperh8400 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\b\fs24 \cf0 Engineering: +\b0 \ + Some people\ +\ + +\b Human Interface Design: +\b0 \ + Some other people\ +\ + +\b Testing: +\b0 \ + Hopefully not nobody\ +\ + +\b Documentation: +\b0 \ + Whoever\ +\ + +\b With special thanks to: +\b0 \ + Mom\ +} diff --git a/client/Mac/cli/en.lproj/InfoPlist.strings b/client/Mac/cli/en.lproj/InfoPlist.strings new file mode 100644 index 000000000..477b28ff8 --- /dev/null +++ b/client/Mac/cli/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/client/Mac/cli/en.lproj/MainMenu.xib b/client/Mac/cli/en.lproj/MainMenu.xib new file mode 100644 index 000000000..dd4e1905e --- /dev/null +++ b/client/Mac/cli/en.lproj/MainMenu.xib @@ -0,0 +1,3299 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> + <data> + <int key="IBDocument.SystemTarget">1080</int> + <string key="IBDocument.SystemVersion">12D78</string> + <string key="IBDocument.InterfaceBuilderVersion">3084</string> + <string key="IBDocument.AppKitVersion">1187.37</string> + <string key="IBDocument.HIToolboxVersion">626.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="NS.object.0">3084</string> + </object> + <array key="IBDocument.IntegratedClassDependencies"> + <string>IBNSLayoutConstraint</string> + <string>NSCustomObject</string> + <string>NSCustomView</string> + <string>NSMenu</string> + <string>NSMenuItem</string> + <string>NSView</string> + <string>NSWindowTemplate</string> + </array> + <array key="IBDocument.PluginDependencies"> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + </array> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <string key="NS.key.0">PluginDependencyRecalculationVersion</string> + <integer value="1" key="NS.object.0"/> + </object> + <array class="NSMutableArray" key="IBDocument.RootObjects" id="1048"> + <object class="NSCustomObject" id="1021"> + <string key="NSClassName">NSApplication</string> + </object> + <object class="NSCustomObject" id="1014"> + <string key="NSClassName">FirstResponder</string> + </object> + <object class="NSCustomObject" id="1050"> + <string key="NSClassName">NSApplication</string> + </object> + <object class="NSMenu" id="649796088"> + <string key="NSTitle">AMainMenu</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="694149608"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">MacClient2</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <object class="NSCustomResource" key="NSOnImage" id="35465992"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuCheckmark</string> + </object> + <object class="NSCustomResource" key="NSMixedImage" id="502551668"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuMixedState</string> + </object> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="110575045"> + <string key="NSTitle">MacClient2</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="238522557"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">About MacClient2</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="304266470"> + <reference key="NSMenu" ref="110575045"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="609285721"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Preferences…</string> + <string key="NSKeyEquiv">,</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="481834944"> + <reference key="NSMenu" ref="110575045"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1046388886"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Services</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="752062318"> + <string key="NSTitle">Services</string> + <array class="NSMutableArray" key="NSMenuItems"/> + <string key="NSName">_NSServicesMenu</string> + </object> + </object> + <object class="NSMenuItem" id="646227648"> + <reference key="NSMenu" ref="110575045"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="755159360"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Hide MacClient2</string> + <string key="NSKeyEquiv">h</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="342932134"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Hide Others</string> + <string key="NSKeyEquiv">h</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="908899353"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Show All</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1056857174"> + <reference key="NSMenu" ref="110575045"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="632727374"> + <reference key="NSMenu" ref="110575045"/> + <string key="NSTitle">Quit MacClient2</string> + <string key="NSKeyEquiv">q</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + <string key="NSName">_NSAppleMenu</string> + </object> + </object> + <object class="NSMenuItem" id="379814623"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">File</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="720053764"> + <string key="NSTitle">File</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="705341025"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">New</string> + <string key="NSKeyEquiv">n</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="722745758"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Open…</string> + <string key="NSKeyEquiv">o</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1025936716"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Open Recent</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="1065607017"> + <string key="NSTitle">Open Recent</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="759406840"> + <reference key="NSMenu" ref="1065607017"/> + <string key="NSTitle">Clear Menu</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + <string key="NSName">_NSRecentDocumentsMenu</string> + </object> + </object> + <object class="NSMenuItem" id="425164168"> + <reference key="NSMenu" ref="720053764"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="776162233"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Close</string> + <string key="NSKeyEquiv">w</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1023925487"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Save…</string> + <string key="NSKeyEquiv">s</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="579971712"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Revert to Saved</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1010469920"> + <reference key="NSMenu" ref="720053764"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="294629803"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Page Setup...</string> + <string key="NSKeyEquiv">P</string> + <int key="NSKeyEquivModMask">1179648</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSToolTip"/> + </object> + <object class="NSMenuItem" id="49223823"> + <reference key="NSMenu" ref="720053764"/> + <string key="NSTitle">Print…</string> + <string key="NSKeyEquiv">p</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="952259628"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">Edit</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="789758025"> + <string key="NSTitle">Edit</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="1058277027"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Undo</string> + <string key="NSKeyEquiv">z</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="790794224"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Redo</string> + <string key="NSKeyEquiv">Z</string> + <int key="NSKeyEquivModMask">1179648</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1040322652"> + <reference key="NSMenu" ref="789758025"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="296257095"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Cut</string> + <string key="NSKeyEquiv">x</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="860595796"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Copy</string> + <string key="NSKeyEquiv">c</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="29853731"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Paste</string> + <string key="NSKeyEquiv">v</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="82994268"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Paste and Match Style</string> + <string key="NSKeyEquiv">V</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="437104165"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Delete</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="583158037"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Select All</string> + <string key="NSKeyEquiv">a</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="212016141"> + <reference key="NSMenu" ref="789758025"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="892235320"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Find</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="963351320"> + <string key="NSTitle">Find</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="447796847"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Find…</string> + <string key="NSKeyEquiv">f</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">1</int> + </object> + <object class="NSMenuItem" id="738670835"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Find and Replace…</string> + <string key="NSKeyEquiv">f</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">12</int> + </object> + <object class="NSMenuItem" id="326711663"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Find Next</string> + <string key="NSKeyEquiv">g</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">2</int> + </object> + <object class="NSMenuItem" id="270902937"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Find Previous</string> + <string key="NSKeyEquiv">G</string> + <int key="NSKeyEquivModMask">1179648</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">3</int> + </object> + <object class="NSMenuItem" id="159080638"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Use Selection for Find</string> + <string key="NSKeyEquiv">e</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">7</int> + </object> + <object class="NSMenuItem" id="88285865"> + <reference key="NSMenu" ref="963351320"/> + <string key="NSTitle">Jump to Selection</string> + <string key="NSKeyEquiv">j</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="972420730"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Spelling and Grammar</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="769623530"> + <string key="NSTitle">Spelling and Grammar</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="679648819"> + <reference key="NSMenu" ref="769623530"/> + <string key="NSTitle">Show Spelling and Grammar</string> + <string key="NSKeyEquiv">:</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="96193923"> + <reference key="NSMenu" ref="769623530"/> + <string key="NSTitle">Check Document Now</string> + <string key="NSKeyEquiv">;</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="859480356"> + <reference key="NSMenu" ref="769623530"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="948374510"> + <reference key="NSMenu" ref="769623530"/> + <string key="NSTitle">Check Spelling While Typing</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="967646866"> + <reference key="NSMenu" ref="769623530"/> + <string key="NSTitle">Check Grammar With Spelling</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="795346622"> + <reference key="NSMenu" ref="769623530"/> + <string key="NSTitle">Correct Spelling Automatically</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="507821607"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Substitutions</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="698887838"> + <string key="NSTitle">Substitutions</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="65139061"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Show Substitutions</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="19036812"> + <reference key="NSMenu" ref="698887838"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="605118523"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Smart Copy/Paste</string> + <string key="NSKeyEquiv">f</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">1</int> + </object> + <object class="NSMenuItem" id="197661976"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Smart Quotes</string> + <string key="NSKeyEquiv">g</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">2</int> + </object> + <object class="NSMenuItem" id="672708820"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Smart Dashes</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="708854459"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Smart Links</string> + <string key="NSKeyEquiv">G</string> + <int key="NSKeyEquivModMask">1179648</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">3</int> + </object> + <object class="NSMenuItem" id="537092702"> + <reference key="NSMenu" ref="698887838"/> + <string key="NSTitle">Text Replacement</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="288088188"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Transformations</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="579392910"> + <string key="NSTitle">Transformations</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="1060694897"> + <reference key="NSMenu" ref="579392910"/> + <string key="NSTitle">Make Upper Case</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="879586729"> + <reference key="NSMenu" ref="579392910"/> + <string key="NSTitle">Make Lower Case</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="56570060"> + <reference key="NSMenu" ref="579392910"/> + <string key="NSTitle">Capitalize</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="676164635"> + <reference key="NSMenu" ref="789758025"/> + <string key="NSTitle">Speech</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="785027613"> + <string key="NSTitle">Speech</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="731782645"> + <reference key="NSMenu" ref="785027613"/> + <string key="NSTitle">Start Speaking</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="680220178"> + <reference key="NSMenu" ref="785027613"/> + <string key="NSTitle">Stop Speaking</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="302598603"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">Format</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="941447902"> + <string key="NSTitle">Format</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="792887677"> + <reference key="NSMenu" ref="941447902"/> + <string key="NSTitle">Font</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="786677654"> + <string key="NSTitle">Font</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="159677712"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Show Fonts</string> + <string key="NSKeyEquiv">t</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="305399458"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Bold</string> + <string key="NSKeyEquiv">b</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">2</int> + </object> + <object class="NSMenuItem" id="814362025"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Italic</string> + <string key="NSKeyEquiv">i</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">1</int> + </object> + <object class="NSMenuItem" id="330926929"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Underline</string> + <string key="NSKeyEquiv">u</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="533507878"> + <reference key="NSMenu" ref="786677654"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="158063935"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Bigger</string> + <string key="NSKeyEquiv">+</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">3</int> + </object> + <object class="NSMenuItem" id="885547335"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Smaller</string> + <string key="NSKeyEquiv">-</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <int key="NSTag">4</int> + </object> + <object class="NSMenuItem" id="901062459"> + <reference key="NSMenu" ref="786677654"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="767671776"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Kern</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="175441468"> + <string key="NSTitle">Kern</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="252969304"> + <reference key="NSMenu" ref="175441468"/> + <string key="NSTitle">Use Default</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="766922938"> + <reference key="NSMenu" ref="175441468"/> + <string key="NSTitle">Use None</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="677519740"> + <reference key="NSMenu" ref="175441468"/> + <string key="NSTitle">Tighten</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="238351151"> + <reference key="NSMenu" ref="175441468"/> + <string key="NSTitle">Loosen</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="691570813"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Ligatures</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="1058217995"> + <string key="NSTitle">Ligatures</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="706297211"> + <reference key="NSMenu" ref="1058217995"/> + <string key="NSTitle">Use Default</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="568384683"> + <reference key="NSMenu" ref="1058217995"/> + <string key="NSTitle">Use None</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="663508465"> + <reference key="NSMenu" ref="1058217995"/> + <string key="NSTitle">Use All</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="769124883"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Baseline</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="18263474"> + <string key="NSTitle">Baseline</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="257962622"> + <reference key="NSMenu" ref="18263474"/> + <string key="NSTitle">Use Default</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="644725453"> + <reference key="NSMenu" ref="18263474"/> + <string key="NSTitle">Superscript</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1037576581"> + <reference key="NSMenu" ref="18263474"/> + <string key="NSTitle">Subscript</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="941806246"> + <reference key="NSMenu" ref="18263474"/> + <string key="NSTitle">Raise</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1045724900"> + <reference key="NSMenu" ref="18263474"/> + <string key="NSTitle">Lower</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="739652853"> + <reference key="NSMenu" ref="786677654"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="1012600125"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Show Colors</string> + <string key="NSKeyEquiv">C</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="214559597"> + <reference key="NSMenu" ref="786677654"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="596732606"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Copy Style</string> + <string key="NSKeyEquiv">c</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="393423671"> + <reference key="NSMenu" ref="786677654"/> + <string key="NSTitle">Paste Style</string> + <string key="NSKeyEquiv">v</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + <string key="NSName">_NSFontMenu</string> + </object> + </object> + <object class="NSMenuItem" id="215659978"> + <reference key="NSMenu" ref="941447902"/> + <string key="NSTitle">Text</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="446991534"> + <string key="NSTitle">Text</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="875092757"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Align Left</string> + <string key="NSKeyEquiv">{</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="630155264"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Center</string> + <string key="NSKeyEquiv">|</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="945678886"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Justify</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="512868991"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Align Right</string> + <string key="NSKeyEquiv">}</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="163117631"> + <reference key="NSMenu" ref="446991534"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="31516759"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Writing Direction</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="956096989"> + <string key="NSTitle">Writing Direction</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="257099033"> + <reference key="NSMenu" ref="956096989"/> + <bool key="NSIsDisabled">YES</bool> + <string key="NSTitle">Paragraph</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="551969625"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CURlZmF1bHQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="249532473"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CUxlZnQgdG8gUmlnaHQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="607364498"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CVJpZ2h0IHRvIExlZnQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="508151438"> + <reference key="NSMenu" ref="956096989"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="981751889"> + <reference key="NSMenu" ref="956096989"/> + <bool key="NSIsDisabled">YES</bool> + <string key="NSTitle">Selection</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="380031999"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CURlZmF1bHQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="825984362"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CUxlZnQgdG8gUmlnaHQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="560145579"> + <reference key="NSMenu" ref="956096989"/> + <string type="base64-UTF8" key="NSTitle">CVJpZ2h0IHRvIExlZnQ</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="908105787"> + <reference key="NSMenu" ref="446991534"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="644046920"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Show Ruler</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="231811626"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Copy Ruler</string> + <string key="NSKeyEquiv">c</string> + <int key="NSKeyEquivModMask">1310720</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="883618387"> + <reference key="NSMenu" ref="446991534"/> + <string key="NSTitle">Paste Ruler</string> + <string key="NSKeyEquiv">v</string> + <int key="NSKeyEquivModMask">1310720</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="586577488"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">View</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="466310130"> + <string key="NSTitle">View</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="102151532"> + <reference key="NSMenu" ref="466310130"/> + <string key="NSTitle">Show Toolbar</string> + <string key="NSKeyEquiv">t</string> + <int key="NSKeyEquivModMask">1572864</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="237841660"> + <reference key="NSMenu" ref="466310130"/> + <string key="NSTitle">Customize Toolbar…</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + </object> + </object> + <object class="NSMenuItem" id="713487014"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">Window</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="835318025"> + <string key="NSTitle">Window</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="1011231497"> + <reference key="NSMenu" ref="835318025"/> + <string key="NSTitle">Minimize</string> + <string key="NSKeyEquiv">m</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="575023229"> + <reference key="NSMenu" ref="835318025"/> + <string key="NSTitle">Zoom</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="299356726"> + <reference key="NSMenu" ref="835318025"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + <object class="NSMenuItem" id="625202149"> + <reference key="NSMenu" ref="835318025"/> + <string key="NSTitle">Bring All to Front</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + <string key="NSName">_NSWindowsMenu</string> + </object> + </object> + <object class="NSMenuItem" id="448692316"> + <reference key="NSMenu" ref="649796088"/> + <string key="NSTitle">Help</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="992780483"> + <string key="NSTitle">Help</string> + <array class="NSMutableArray" key="NSMenuItems"> + <object class="NSMenuItem" id="105068016"> + <reference key="NSMenu" ref="992780483"/> + <string key="NSTitle">MacClient2 Help</string> + <string key="NSKeyEquiv">?</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> + </array> + <string key="NSName">_NSHelpMenu</string> + </object> + </object> + </array> + <string key="NSName">_NSMainMenu</string> + </object> + <object class="NSWindowTemplate" id="972006081"> + <int key="NSWindowStyleMask">15</int> + <int key="NSWindowBacking">2</int> + <string key="NSWindowRect">{{335, 390}, {480, 360}}</string> + <int key="NSWTFlags">1954021376</int> + <string key="NSWindowTitle">MacClient2</string> + <string key="NSWindowClass">NSWindow</string> + <nil key="NSViewClass"/> + <nil key="NSUserInterfaceItemIdentifier"/> + <object class="NSView" key="NSWindowView" id="439893737"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">256</int> + <array class="NSMutableArray" key="NSSubviews"> + <object class="NSCustomView" id="749477601"> + <reference key="NSNextResponder" ref="439893737"/> + <int key="NSvFlags">268</int> + <string key="NSFrameSize">{480, 360}</string> + <reference key="NSSuperview" ref="439893737"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <string key="NSClassName">MRDPView</string> + </object> + </array> + <string key="NSFrameSize">{480, 360}</string> + <reference key="NSSuperview"/> + <reference key="NSNextKeyView" ref="749477601"/> + </object> + <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> + <string key="NSMaxSize">{10000000000000, 10000000000000}</string> + <bool key="NSWindowIsRestorable">YES</bool> + </object> + <object class="NSCustomObject" id="976324537"> + <string key="NSClassName">AppDelegate</string> + </object> + <object class="NSCustomObject" id="755631768"> + <string key="NSClassName">NSFontManager</string> + </object> + </array> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <array class="NSMutableArray" key="connectionRecords"> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">terminate:</string> + <reference key="source" ref="1050"/> + <reference key="destination" ref="632727374"/> + </object> + <int key="connectionID">449</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">orderFrontStandardAboutPanel:</string> + <reference key="source" ref="1021"/> + <reference key="destination" ref="238522557"/> + </object> + <int key="connectionID">142</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="1021"/> + <reference key="destination" ref="976324537"/> + </object> + <int key="connectionID">495</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performMiniaturize:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1011231497"/> + </object> + <int key="connectionID">37</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">arrangeInFront:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="625202149"/> + </object> + <int key="connectionID">39</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">print:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="49223823"/> + </object> + <int key="connectionID">86</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">runPageLayout:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="294629803"/> + </object> + <int key="connectionID">87</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">clearRecentDocuments:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="759406840"/> + </object> + <int key="connectionID">127</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performClose:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="776162233"/> + </object> + <int key="connectionID">193</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleContinuousSpellChecking:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="948374510"/> + </object> + <int key="connectionID">222</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">undo:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1058277027"/> + </object> + <int key="connectionID">223</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">copy:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="860595796"/> + </object> + <int key="connectionID">224</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">checkSpelling:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="96193923"/> + </object> + <int key="connectionID">225</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">paste:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="29853731"/> + </object> + <int key="connectionID">226</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">stopSpeaking:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="680220178"/> + </object> + <int key="connectionID">227</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">cut:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="296257095"/> + </object> + <int key="connectionID">228</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">showGuessPanel:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="679648819"/> + </object> + <int key="connectionID">230</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">redo:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="790794224"/> + </object> + <int key="connectionID">231</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">selectAll:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="583158037"/> + </object> + <int key="connectionID">232</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">startSpeaking:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="731782645"/> + </object> + <int key="connectionID">233</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">delete:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="437104165"/> + </object> + <int key="connectionID">235</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performZoom:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="575023229"/> + </object> + <int key="connectionID">240</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performFindPanelAction:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="447796847"/> + </object> + <int key="connectionID">241</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">centerSelectionInVisibleArea:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="88285865"/> + </object> + <int key="connectionID">245</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleGrammarChecking:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="967646866"/> + </object> + <int key="connectionID">347</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleSmartInsertDelete:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="605118523"/> + </object> + <int key="connectionID">355</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleAutomaticQuoteSubstitution:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="197661976"/> + </object> + <int key="connectionID">356</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleAutomaticLinkDetection:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="708854459"/> + </object> + <int key="connectionID">357</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">saveDocument:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1023925487"/> + </object> + <int key="connectionID">362</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">revertDocumentToSaved:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="579971712"/> + </object> + <int key="connectionID">364</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">runToolbarCustomizationPalette:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="237841660"/> + </object> + <int key="connectionID">365</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleToolbarShown:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="102151532"/> + </object> + <int key="connectionID">366</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">hide:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="755159360"/> + </object> + <int key="connectionID">367</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">hideOtherApplications:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="342932134"/> + </object> + <int key="connectionID">368</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">unhideAllApplications:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="908899353"/> + </object> + <int key="connectionID">370</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">newDocument:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="705341025"/> + </object> + <int key="connectionID">373</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">openDocument:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="722745758"/> + </object> + <int key="connectionID">374</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">raiseBaseline:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="941806246"/> + </object> + <int key="connectionID">426</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">lowerBaseline:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1045724900"/> + </object> + <int key="connectionID">427</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">copyFont:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="596732606"/> + </object> + <int key="connectionID">428</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">subscript:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1037576581"/> + </object> + <int key="connectionID">429</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">superscript:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="644725453"/> + </object> + <int key="connectionID">430</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">tightenKerning:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="677519740"/> + </object> + <int key="connectionID">431</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">underline:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="330926929"/> + </object> + <int key="connectionID">432</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">orderFrontColorPanel:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1012600125"/> + </object> + <int key="connectionID">433</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">useAllLigatures:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="663508465"/> + </object> + <int key="connectionID">434</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">loosenKerning:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="238351151"/> + </object> + <int key="connectionID">435</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">pasteFont:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="393423671"/> + </object> + <int key="connectionID">436</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">unscript:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="257962622"/> + </object> + <int key="connectionID">437</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">useStandardKerning:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="252969304"/> + </object> + <int key="connectionID">438</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">useStandardLigatures:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="706297211"/> + </object> + <int key="connectionID">439</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">turnOffLigatures:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="568384683"/> + </object> + <int key="connectionID">440</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">turnOffKerning:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="766922938"/> + </object> + <int key="connectionID">441</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleAutomaticSpellingCorrection:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="795346622"/> + </object> + <int key="connectionID">456</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">orderFrontSubstitutionsPanel:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="65139061"/> + </object> + <int key="connectionID">458</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleAutomaticDashSubstitution:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="672708820"/> + </object> + <int key="connectionID">461</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleAutomaticTextReplacement:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="537092702"/> + </object> + <int key="connectionID">463</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">uppercaseWord:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="1060694897"/> + </object> + <int key="connectionID">464</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">capitalizeWord:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="56570060"/> + </object> + <int key="connectionID">467</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">lowercaseWord:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="879586729"/> + </object> + <int key="connectionID">468</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">pasteAsPlainText:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="82994268"/> + </object> + <int key="connectionID">486</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performFindPanelAction:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="326711663"/> + </object> + <int key="connectionID">487</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performFindPanelAction:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="270902937"/> + </object> + <int key="connectionID">488</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performFindPanelAction:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="159080638"/> + </object> + <int key="connectionID">489</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">showHelp:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="105068016"/> + </object> + <int key="connectionID">493</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">alignCenter:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="630155264"/> + </object> + <int key="connectionID">518</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">pasteRuler:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="883618387"/> + </object> + <int key="connectionID">519</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleRuler:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="644046920"/> + </object> + <int key="connectionID">520</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">alignRight:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="512868991"/> + </object> + <int key="connectionID">521</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">copyRuler:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="231811626"/> + </object> + <int key="connectionID">522</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">alignJustified:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="945678886"/> + </object> + <int key="connectionID">523</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">alignLeft:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="875092757"/> + </object> + <int key="connectionID">524</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeBaseWritingDirectionNatural:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="551969625"/> + </object> + <int key="connectionID">525</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeBaseWritingDirectionLeftToRight:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="249532473"/> + </object> + <int key="connectionID">526</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeBaseWritingDirectionRightToLeft:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="607364498"/> + </object> + <int key="connectionID">527</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeTextWritingDirectionNatural:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="380031999"/> + </object> + <int key="connectionID">528</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeTextWritingDirectionLeftToRight:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="825984362"/> + </object> + <int key="connectionID">529</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">makeTextWritingDirectionRightToLeft:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="560145579"/> + </object> + <int key="connectionID">530</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">performFindPanelAction:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="738670835"/> + </object> + <int key="connectionID">535</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">addFontTrait:</string> + <reference key="source" ref="755631768"/> + <reference key="destination" ref="305399458"/> + </object> + <int key="connectionID">421</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">addFontTrait:</string> + <reference key="source" ref="755631768"/> + <reference key="destination" ref="814362025"/> + </object> + <int key="connectionID">422</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">modifyFont:</string> + <reference key="source" ref="755631768"/> + <reference key="destination" ref="885547335"/> + </object> + <int key="connectionID">423</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">orderFrontFontPanel:</string> + <reference key="source" ref="755631768"/> + <reference key="destination" ref="159677712"/> + </object> + <int key="connectionID">424</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">modifyFont:</string> + <reference key="source" ref="755631768"/> + <reference key="destination" ref="158063935"/> + </object> + <int key="connectionID">425</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">mrdpView</string> + <reference key="source" ref="976324537"/> + <reference key="destination" ref="749477601"/> + </object> + <int key="connectionID">549</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">window</string> + <reference key="source" ref="976324537"/> + <reference key="destination" ref="972006081"/> + </object> + <int key="connectionID">550</int> + </object> + </array> + <object class="IBMutableOrderedSet" key="objectRecords"> + <array key="orderedObjects"> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <array key="object" id="0"/> + <reference key="children" ref="1048"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="1021"/> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-1</int> + <reference key="object" ref="1014"/> + <reference key="parent" ref="0"/> + <string key="objectName">First Responder</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-3</int> + <reference key="object" ref="1050"/> + <reference key="parent" ref="0"/> + <string key="objectName">Application</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">29</int> + <reference key="object" ref="649796088"/> + <array class="NSMutableArray" key="children"> + <reference ref="713487014"/> + <reference ref="694149608"/> + <reference ref="952259628"/> + <reference ref="379814623"/> + <reference ref="586577488"/> + <reference ref="302598603"/> + <reference ref="448692316"/> + </array> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">19</int> + <reference key="object" ref="713487014"/> + <array class="NSMutableArray" key="children"> + <reference ref="835318025"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">56</int> + <reference key="object" ref="694149608"/> + <array class="NSMutableArray" key="children"> + <reference ref="110575045"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">217</int> + <reference key="object" ref="952259628"/> + <array class="NSMutableArray" key="children"> + <reference ref="789758025"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">83</int> + <reference key="object" ref="379814623"/> + <array class="NSMutableArray" key="children"> + <reference ref="720053764"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">81</int> + <reference key="object" ref="720053764"/> + <array class="NSMutableArray" key="children"> + <reference ref="1023925487"/> + <reference ref="49223823"/> + <reference ref="722745758"/> + <reference ref="705341025"/> + <reference ref="1025936716"/> + <reference ref="294629803"/> + <reference ref="776162233"/> + <reference ref="425164168"/> + <reference ref="579971712"/> + <reference ref="1010469920"/> + </array> + <reference key="parent" ref="379814623"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">75</int> + <reference key="object" ref="1023925487"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">78</int> + <reference key="object" ref="49223823"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">72</int> + <reference key="object" ref="722745758"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">82</int> + <reference key="object" ref="705341025"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">124</int> + <reference key="object" ref="1025936716"/> + <array class="NSMutableArray" key="children"> + <reference ref="1065607017"/> + </array> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">77</int> + <reference key="object" ref="294629803"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">73</int> + <reference key="object" ref="776162233"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">79</int> + <reference key="object" ref="425164168"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">112</int> + <reference key="object" ref="579971712"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">74</int> + <reference key="object" ref="1010469920"/> + <reference key="parent" ref="720053764"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">125</int> + <reference key="object" ref="1065607017"/> + <array class="NSMutableArray" key="children"> + <reference ref="759406840"/> + </array> + <reference key="parent" ref="1025936716"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">126</int> + <reference key="object" ref="759406840"/> + <reference key="parent" ref="1065607017"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">205</int> + <reference key="object" ref="789758025"/> + <array class="NSMutableArray" key="children"> + <reference ref="437104165"/> + <reference ref="583158037"/> + <reference ref="1058277027"/> + <reference ref="212016141"/> + <reference ref="296257095"/> + <reference ref="29853731"/> + <reference ref="860595796"/> + <reference ref="1040322652"/> + <reference ref="790794224"/> + <reference ref="892235320"/> + <reference ref="972420730"/> + <reference ref="676164635"/> + <reference ref="507821607"/> + <reference ref="288088188"/> + <reference ref="82994268"/> + </array> + <reference key="parent" ref="952259628"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">202</int> + <reference key="object" ref="437104165"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">198</int> + <reference key="object" ref="583158037"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">207</int> + <reference key="object" ref="1058277027"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">214</int> + <reference key="object" ref="212016141"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">199</int> + <reference key="object" ref="296257095"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">203</int> + <reference key="object" ref="29853731"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">197</int> + <reference key="object" ref="860595796"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">206</int> + <reference key="object" ref="1040322652"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">215</int> + <reference key="object" ref="790794224"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">218</int> + <reference key="object" ref="892235320"/> + <array class="NSMutableArray" key="children"> + <reference ref="963351320"/> + </array> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">216</int> + <reference key="object" ref="972420730"/> + <array class="NSMutableArray" key="children"> + <reference ref="769623530"/> + </array> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">200</int> + <reference key="object" ref="769623530"/> + <array class="NSMutableArray" key="children"> + <reference ref="948374510"/> + <reference ref="96193923"/> + <reference ref="679648819"/> + <reference ref="967646866"/> + <reference ref="859480356"/> + <reference ref="795346622"/> + </array> + <reference key="parent" ref="972420730"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">219</int> + <reference key="object" ref="948374510"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">201</int> + <reference key="object" ref="96193923"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">204</int> + <reference key="object" ref="679648819"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">220</int> + <reference key="object" ref="963351320"/> + <array class="NSMutableArray" key="children"> + <reference ref="270902937"/> + <reference ref="88285865"/> + <reference ref="159080638"/> + <reference ref="326711663"/> + <reference ref="447796847"/> + <reference ref="738670835"/> + </array> + <reference key="parent" ref="892235320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">213</int> + <reference key="object" ref="270902937"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">210</int> + <reference key="object" ref="88285865"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">221</int> + <reference key="object" ref="159080638"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">208</int> + <reference key="object" ref="326711663"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">209</int> + <reference key="object" ref="447796847"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">57</int> + <reference key="object" ref="110575045"/> + <array class="NSMutableArray" key="children"> + <reference ref="238522557"/> + <reference ref="755159360"/> + <reference ref="908899353"/> + <reference ref="632727374"/> + <reference ref="646227648"/> + <reference ref="609285721"/> + <reference ref="481834944"/> + <reference ref="304266470"/> + <reference ref="1046388886"/> + <reference ref="1056857174"/> + <reference ref="342932134"/> + </array> + <reference key="parent" ref="694149608"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">58</int> + <reference key="object" ref="238522557"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">134</int> + <reference key="object" ref="755159360"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">150</int> + <reference key="object" ref="908899353"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">136</int> + <reference key="object" ref="632727374"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">144</int> + <reference key="object" ref="646227648"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">129</int> + <reference key="object" ref="609285721"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">143</int> + <reference key="object" ref="481834944"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">236</int> + <reference key="object" ref="304266470"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">131</int> + <reference key="object" ref="1046388886"/> + <array class="NSMutableArray" key="children"> + <reference ref="752062318"/> + </array> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">149</int> + <reference key="object" ref="1056857174"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">145</int> + <reference key="object" ref="342932134"/> + <reference key="parent" ref="110575045"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">130</int> + <reference key="object" ref="752062318"/> + <reference key="parent" ref="1046388886"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">24</int> + <reference key="object" ref="835318025"/> + <array class="NSMutableArray" key="children"> + <reference ref="299356726"/> + <reference ref="625202149"/> + <reference ref="575023229"/> + <reference ref="1011231497"/> + </array> + <reference key="parent" ref="713487014"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">92</int> + <reference key="object" ref="299356726"/> + <reference key="parent" ref="835318025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5</int> + <reference key="object" ref="625202149"/> + <reference key="parent" ref="835318025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">239</int> + <reference key="object" ref="575023229"/> + <reference key="parent" ref="835318025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">23</int> + <reference key="object" ref="1011231497"/> + <reference key="parent" ref="835318025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">295</int> + <reference key="object" ref="586577488"/> + <array class="NSMutableArray" key="children"> + <reference ref="466310130"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">296</int> + <reference key="object" ref="466310130"/> + <array class="NSMutableArray" key="children"> + <reference ref="102151532"/> + <reference ref="237841660"/> + </array> + <reference key="parent" ref="586577488"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">297</int> + <reference key="object" ref="102151532"/> + <reference key="parent" ref="466310130"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">298</int> + <reference key="object" ref="237841660"/> + <reference key="parent" ref="466310130"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">211</int> + <reference key="object" ref="676164635"/> + <array class="NSMutableArray" key="children"> + <reference ref="785027613"/> + </array> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">212</int> + <reference key="object" ref="785027613"/> + <array class="NSMutableArray" key="children"> + <reference ref="680220178"/> + <reference ref="731782645"/> + </array> + <reference key="parent" ref="676164635"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">195</int> + <reference key="object" ref="680220178"/> + <reference key="parent" ref="785027613"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">196</int> + <reference key="object" ref="731782645"/> + <reference key="parent" ref="785027613"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">346</int> + <reference key="object" ref="967646866"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">348</int> + <reference key="object" ref="507821607"/> + <array class="NSMutableArray" key="children"> + <reference ref="698887838"/> + </array> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">349</int> + <reference key="object" ref="698887838"/> + <array class="NSMutableArray" key="children"> + <reference ref="605118523"/> + <reference ref="197661976"/> + <reference ref="708854459"/> + <reference ref="65139061"/> + <reference ref="19036812"/> + <reference ref="672708820"/> + <reference ref="537092702"/> + </array> + <reference key="parent" ref="507821607"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">350</int> + <reference key="object" ref="605118523"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">351</int> + <reference key="object" ref="197661976"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">354</int> + <reference key="object" ref="708854459"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">371</int> + <reference key="object" ref="972006081"/> + <array class="NSMutableArray" key="children"> + <reference ref="439893737"/> + </array> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">372</int> + <reference key="object" ref="439893737"/> + <array class="NSMutableArray" key="children"> + <object class="IBNSLayoutConstraint" id="52232798"> + <reference key="firstItem" ref="749477601"/> + <int key="firstAttribute">6</int> + <int key="relation">0</int> + <reference key="secondItem" ref="439893737"/> + <int key="secondAttribute">6</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="439893737"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="190432589"> + <reference key="firstItem" ref="749477601"/> + <int key="firstAttribute">4</int> + <int key="relation">0</int> + <reference key="secondItem" ref="439893737"/> + <int key="secondAttribute">4</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="439893737"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="234697136"> + <reference key="firstItem" ref="749477601"/> + <int key="firstAttribute">5</int> + <int key="relation">0</int> + <reference key="secondItem" ref="439893737"/> + <int key="secondAttribute">5</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="439893737"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="1040326167"> + <reference key="firstItem" ref="749477601"/> + <int key="firstAttribute">3</int> + <int key="relation">0</int> + <reference key="secondItem" ref="439893737"/> + <int key="secondAttribute">3</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="439893737"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <reference ref="749477601"/> + </array> + <reference key="parent" ref="972006081"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">375</int> + <reference key="object" ref="302598603"/> + <array class="NSMutableArray" key="children"> + <reference ref="941447902"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">376</int> + <reference key="object" ref="941447902"/> + <array class="NSMutableArray" key="children"> + <reference ref="792887677"/> + <reference ref="215659978"/> + </array> + <reference key="parent" ref="302598603"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">377</int> + <reference key="object" ref="792887677"/> + <array class="NSMutableArray" key="children"> + <reference ref="786677654"/> + </array> + <reference key="parent" ref="941447902"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">388</int> + <reference key="object" ref="786677654"/> + <array class="NSMutableArray" key="children"> + <reference ref="159677712"/> + <reference ref="305399458"/> + <reference ref="814362025"/> + <reference ref="330926929"/> + <reference ref="533507878"/> + <reference ref="158063935"/> + <reference ref="885547335"/> + <reference ref="901062459"/> + <reference ref="767671776"/> + <reference ref="691570813"/> + <reference ref="769124883"/> + <reference ref="739652853"/> + <reference ref="1012600125"/> + <reference ref="214559597"/> + <reference ref="596732606"/> + <reference ref="393423671"/> + </array> + <reference key="parent" ref="792887677"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">389</int> + <reference key="object" ref="159677712"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">390</int> + <reference key="object" ref="305399458"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">391</int> + <reference key="object" ref="814362025"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">392</int> + <reference key="object" ref="330926929"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">393</int> + <reference key="object" ref="533507878"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">394</int> + <reference key="object" ref="158063935"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">395</int> + <reference key="object" ref="885547335"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">396</int> + <reference key="object" ref="901062459"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">397</int> + <reference key="object" ref="767671776"/> + <array class="NSMutableArray" key="children"> + <reference ref="175441468"/> + </array> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">398</int> + <reference key="object" ref="691570813"/> + <array class="NSMutableArray" key="children"> + <reference ref="1058217995"/> + </array> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">399</int> + <reference key="object" ref="769124883"/> + <array class="NSMutableArray" key="children"> + <reference ref="18263474"/> + </array> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">400</int> + <reference key="object" ref="739652853"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">401</int> + <reference key="object" ref="1012600125"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">402</int> + <reference key="object" ref="214559597"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">403</int> + <reference key="object" ref="596732606"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">404</int> + <reference key="object" ref="393423671"/> + <reference key="parent" ref="786677654"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">405</int> + <reference key="object" ref="18263474"/> + <array class="NSMutableArray" key="children"> + <reference ref="257962622"/> + <reference ref="644725453"/> + <reference ref="1037576581"/> + <reference ref="941806246"/> + <reference ref="1045724900"/> + </array> + <reference key="parent" ref="769124883"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">406</int> + <reference key="object" ref="257962622"/> + <reference key="parent" ref="18263474"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">407</int> + <reference key="object" ref="644725453"/> + <reference key="parent" ref="18263474"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">408</int> + <reference key="object" ref="1037576581"/> + <reference key="parent" ref="18263474"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">409</int> + <reference key="object" ref="941806246"/> + <reference key="parent" ref="18263474"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">410</int> + <reference key="object" ref="1045724900"/> + <reference key="parent" ref="18263474"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">411</int> + <reference key="object" ref="1058217995"/> + <array class="NSMutableArray" key="children"> + <reference ref="706297211"/> + <reference ref="568384683"/> + <reference ref="663508465"/> + </array> + <reference key="parent" ref="691570813"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">412</int> + <reference key="object" ref="706297211"/> + <reference key="parent" ref="1058217995"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">413</int> + <reference key="object" ref="568384683"/> + <reference key="parent" ref="1058217995"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">414</int> + <reference key="object" ref="663508465"/> + <reference key="parent" ref="1058217995"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">415</int> + <reference key="object" ref="175441468"/> + <array class="NSMutableArray" key="children"> + <reference ref="252969304"/> + <reference ref="766922938"/> + <reference ref="677519740"/> + <reference ref="238351151"/> + </array> + <reference key="parent" ref="767671776"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">416</int> + <reference key="object" ref="252969304"/> + <reference key="parent" ref="175441468"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">417</int> + <reference key="object" ref="766922938"/> + <reference key="parent" ref="175441468"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">418</int> + <reference key="object" ref="677519740"/> + <reference key="parent" ref="175441468"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">419</int> + <reference key="object" ref="238351151"/> + <reference key="parent" ref="175441468"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">420</int> + <reference key="object" ref="755631768"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">450</int> + <reference key="object" ref="288088188"/> + <array class="NSMutableArray" key="children"> + <reference ref="579392910"/> + </array> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">451</int> + <reference key="object" ref="579392910"/> + <array class="NSMutableArray" key="children"> + <reference ref="1060694897"/> + <reference ref="879586729"/> + <reference ref="56570060"/> + </array> + <reference key="parent" ref="288088188"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">452</int> + <reference key="object" ref="1060694897"/> + <reference key="parent" ref="579392910"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">453</int> + <reference key="object" ref="859480356"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">454</int> + <reference key="object" ref="795346622"/> + <reference key="parent" ref="769623530"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">457</int> + <reference key="object" ref="65139061"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">459</int> + <reference key="object" ref="19036812"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">460</int> + <reference key="object" ref="672708820"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">462</int> + <reference key="object" ref="537092702"/> + <reference key="parent" ref="698887838"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">465</int> + <reference key="object" ref="879586729"/> + <reference key="parent" ref="579392910"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">466</int> + <reference key="object" ref="56570060"/> + <reference key="parent" ref="579392910"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">485</int> + <reference key="object" ref="82994268"/> + <reference key="parent" ref="789758025"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">490</int> + <reference key="object" ref="448692316"/> + <array class="NSMutableArray" key="children"> + <reference ref="992780483"/> + </array> + <reference key="parent" ref="649796088"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">491</int> + <reference key="object" ref="992780483"/> + <array class="NSMutableArray" key="children"> + <reference ref="105068016"/> + </array> + <reference key="parent" ref="448692316"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">492</int> + <reference key="object" ref="105068016"/> + <reference key="parent" ref="992780483"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">494</int> + <reference key="object" ref="976324537"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">496</int> + <reference key="object" ref="215659978"/> + <array class="NSMutableArray" key="children"> + <reference ref="446991534"/> + </array> + <reference key="parent" ref="941447902"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">497</int> + <reference key="object" ref="446991534"/> + <array class="NSMutableArray" key="children"> + <reference ref="875092757"/> + <reference ref="630155264"/> + <reference ref="945678886"/> + <reference ref="512868991"/> + <reference ref="163117631"/> + <reference ref="31516759"/> + <reference ref="908105787"/> + <reference ref="644046920"/> + <reference ref="231811626"/> + <reference ref="883618387"/> + </array> + <reference key="parent" ref="215659978"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">498</int> + <reference key="object" ref="875092757"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">499</int> + <reference key="object" ref="630155264"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">500</int> + <reference key="object" ref="945678886"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">501</int> + <reference key="object" ref="512868991"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">502</int> + <reference key="object" ref="163117631"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">503</int> + <reference key="object" ref="31516759"/> + <array class="NSMutableArray" key="children"> + <reference ref="956096989"/> + </array> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">504</int> + <reference key="object" ref="908105787"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">505</int> + <reference key="object" ref="644046920"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">506</int> + <reference key="object" ref="231811626"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">507</int> + <reference key="object" ref="883618387"/> + <reference key="parent" ref="446991534"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">508</int> + <reference key="object" ref="956096989"/> + <array class="NSMutableArray" key="children"> + <reference ref="257099033"/> + <reference ref="551969625"/> + <reference ref="249532473"/> + <reference ref="607364498"/> + <reference ref="508151438"/> + <reference ref="981751889"/> + <reference ref="380031999"/> + <reference ref="825984362"/> + <reference ref="560145579"/> + </array> + <reference key="parent" ref="31516759"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">509</int> + <reference key="object" ref="257099033"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">510</int> + <reference key="object" ref="551969625"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">511</int> + <reference key="object" ref="249532473"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">512</int> + <reference key="object" ref="607364498"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">513</int> + <reference key="object" ref="508151438"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">514</int> + <reference key="object" ref="981751889"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">515</int> + <reference key="object" ref="380031999"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">516</int> + <reference key="object" ref="825984362"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">517</int> + <reference key="object" ref="560145579"/> + <reference key="parent" ref="956096989"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">534</int> + <reference key="object" ref="738670835"/> + <reference key="parent" ref="963351320"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">536</int> + <reference key="object" ref="749477601"/> + <reference key="parent" ref="439893737"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">542</int> + <reference key="object" ref="1040326167"/> + <reference key="parent" ref="439893737"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">544</int> + <reference key="object" ref="234697136"/> + <reference key="parent" ref="439893737"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">545</int> + <reference key="object" ref="190432589"/> + <reference key="parent" ref="439893737"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">546</int> + <reference key="object" ref="52232798"/> + <reference key="parent" ref="439893737"/> + </object> + </array> + </object> + <dictionary class="NSMutableDictionary" key="flattenedProperties"> + <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="112.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="126.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="195.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="196.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="197.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="198.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="199.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="200.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="201.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="202.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="205.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="206.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="207.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="208.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="209.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="210.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="211.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="212.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="213.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="214.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="215.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="216.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="217.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="218.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="219.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="220.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="221.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="236.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="239.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="346.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="371.IBWindowTemplateEditedContentRect">{{380, 496}, {480, 360}}</string> + <integer value="1" key="371.NSWindowTemplate.visibleAtLaunch"/> + <array class="NSMutableArray" key="372.IBNSViewMetadataConstraints"> + <reference ref="1040326167"/> + <reference ref="234697136"/> + <reference ref="190432589"/> + <reference ref="52232798"/> + </array> + <string key="372.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="388.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="389.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="390.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="391.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="392.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="393.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="394.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="395.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="396.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="397.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="398.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="399.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="400.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="401.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="402.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="403.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="404.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="405.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="406.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="407.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="408.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="409.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="410.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="411.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="412.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="413.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="414.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="415.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="416.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="417.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="418.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="462.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="465.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="466.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="485.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="490.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="491.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="492.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="494.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="496.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="497.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="498.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="499.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="500.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="501.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="502.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="503.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="504.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="505.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="506.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="507.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="508.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="509.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="510.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="511.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="512.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="513.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="514.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="515.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="516.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="517.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="534.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <boolean value="NO" key="536.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> + <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="542.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="546.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="72.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="73.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="74.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="75.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="77.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="78.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="79.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="81.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="82.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="83.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + </dictionary> + <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> + <nil key="activeLocalization"/> + <dictionary class="NSMutableDictionary" key="localizations"/> + <nil key="sourceID"/> + <int key="maxID">550</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"/> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes"> + <string key="NSMenuCheckmark">{11, 11}</string> + <string key="NSMenuMixedState">{10, 3}</string> + </dictionary> + <bool key="IBDocument.UseAutolayout">YES</bool> + </data> +</archive> diff --git a/client/Mac/cli/main.m b/client/Mac/cli/main.m new file mode 100644 index 000000000..b1ed1e5f4 --- /dev/null +++ b/client/Mac/cli/main.m @@ -0,0 +1,16 @@ +// +// main.m +// MacClient2 +// +// Created by Benoît et Kathy on 2013-05-08. +// +// + +#import <Cocoa/Cocoa.h> +#import <MacFreeRDP-library/MRDPView.h> + +int main(int argc, char *argv[]) +{ + [MRDPView class]; + return NSApplicationMain(argc, (const char **)argv); +} diff --git a/client/Mac/en.lproj/InfoPlist.strings b/client/Mac/en.lproj/InfoPlist.strings new file mode 100644 index 000000000..477b28ff8 --- /dev/null +++ b/client/Mac/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/client/Mac/main.m b/client/Mac/main.m index 5726f5c03..4cba6cfc1 100644 --- a/client/Mac/main.m +++ b/client/Mac/main.m @@ -19,7 +19,7 @@ #import <Cocoa/Cocoa.h> -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - return NSApplicationMain(argc, (const char**) argv); + return NSApplicationMain(argc, (const char **)argv); } From 69706b507ef6d4492db2932290f57d7ce98e0234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <marcandre.moreau@gmail.com> Date: Fri, 31 May 2013 13:51:50 -0400 Subject: [PATCH 144/144] cmake: fix 32-bit clang with SSE --- CMakeLists.txt | 6 ++++++ client/Mac/CMakeLists.txt | 44 ++++++++------------------------------- cmake/ConfigOptions.cmake | 5 +++-- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ee793a52..ca6e154b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,12 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() endif() +if(CMAKE_COMPILER_IS_CLANG) + if(WITH_SSE2) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3") + endif() +endif() + if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT") diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 5b77814a5..ec8b56eab 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -45,32 +45,17 @@ add_library(${MODULE_NAME} ${${MODULE_NAME}_RESOURCES}) # configures the framework to always be looked for in the application bundle in the Frameworks sub-folder. -SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/ ) +SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/) - set_target_properties( ${MODULE_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH} -) - -# Automatic ref counting -# temporary turn off for x86_64 build issue -# set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) +set_target_properties(${MODULE_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH}) # Support for automatic reference counting requires non-fragile abi. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi") -# XCode project architecture to native architecture of build machine -# ----------------------------------------------------------------------------------------------------- -# Issue: Had some issues with FreeRDP project building only 64 bit and -# MacFreeRDP attempting to link to both 32 and 64 for dual target. -# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons: -# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage -# If you know the solutions for 1 and 2, please add below. set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") -# Set the info plist to the custom instance -# MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist - set(MODULE_VERSION, 1.1.0) set_target_properties(${MODULE_NAME} PROPERTIES @@ -80,10 +65,9 @@ set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.1.0 MACOSX_FRAMEWORK_BUNDLE_VERSION 1.1.0 PUBLIC_HEADER "MRDPView.h" - INSTALL_NAME_DIR "@executable_path/../../Frameworks" - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist - BUILD_WITH_INSTALL_RPATH 1 -) + INSTALL_NAME_DIR "@executable_path/../../Frameworks" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + BUILD_WITH_INSTALL_RPATH 1) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS} freerdp-client) @@ -132,17 +116,7 @@ set(DEPENDENCIES freerdp-crypto freerdp-client freerdp-locale - freerdp-common - ) - - -## Modify the install name path of the dependent libraries so that they can be located by the bundling app. -# foreach(LIB ${DEPENDENCIES}) -# set_target_properties(${LIB} PROPERTIES -# INSTALL_NAME_DIR "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents" -# BUILD_WITH_INSTALL_RPATH 1 -# ) -# endforeach() + freerdp-common) set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE freerdp @@ -215,4 +189,4 @@ if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") COMMENT "Compiling ${xib}") endforeach() -endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") \ No newline at end of file +endif() diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 84032718f..c40e93a0a 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -36,10 +36,11 @@ else() option(WITH_IPP "Use Intel Performance Primitives." OFF) endif() endif() + option(WITH_JPEG "Use JPEG decoding." OFF) -if(APPLE) - option(WITH_CLANG "Build using clang" OFF) +if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_COMPILER_IS_CLANG 1) endif() if(MSVC)