Merge branch 'master' of git://github.com/awakecoding/FreeRDP

Conflicts:
	libfreerdp/core/gateway/tsg.c
	libfreerdp/crypto/tls.c
This commit is contained in:
Benoît LeBlanc 2013-11-04 09:12:26 -05:00
commit ce34923959
152 changed files with 2213 additions and 1066 deletions

2
.gitignore vendored
View File

@ -17,6 +17,8 @@ _CPack_Packages
LICENSE.txt
/external/*
!external/README
*Config.cmake
*ConfigVersion.cmake
*.a.objlist.cmake
*.a.objlist

View File

@ -51,6 +51,7 @@ include(ComplexLibrary)
include(FeatureSummary)
include(CheckCCompilerFlag)
include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers)
# Soname versioning
set(FREERDP_VERSION_MAJOR "1")
@ -551,6 +552,31 @@ if(WITH_SERVER)
add_subdirectory(server)
endif()
# Exporting
if(${CMAKE_VERSION} VERSION_GREATER "2.8.10")
export(PACKAGE freerdp)
set(FREERDP_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/FreeRDP")
set(FREERDP_INCLUDE_DIR "include")
set(FREERDP_MONOLITHIC_BUILD ${MONOLITHIC_BUILD})
configure_package_config_file(FreeRDPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfig.cmake
INSTALL_DESTINATION ${FREERDP_CMAKE_INSTALL_DIR}
PATH_VARS FREERDP_INCLUDE_DIR FREERDP_MONOLITHIC_BUILD)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfigVersion.cmake
VERSION ${FREERDP_VERSION} COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDPConfigVersion.cmake
DESTINATION ${FREERDP_CMAKE_INSTALL_DIR})
install(EXPORT FreeRDPTargets DESTINATION ${FREERDP_CMAKE_INSTALL_DIR})
endif()
# Packaging
set(CMAKE_CPACK_INCLUDE_FILE "CMakeCPack.cmake")

11
FreeRDPConfig.cmake.in Normal file
View File

@ -0,0 +1,11 @@
@PACKAGE_INIT@
set(FreeRDP_VERSION_MAJOR "@FREERDP_VERSION_MAJOR@")
set(FreeRDP_VERSION_MINOR "@FREERDP_VERSION_MINOR@")
set(FreeRDP_VERSION_REVISION "@FREERDP_VERSION_REVISION@")
set(FreeRDP_MONOLITHIC_BUILD "@FREERDP_MONOLITHIC_BUILD@")
set_and_check(FreeRDP_INCLUDE_DIR "@PACKAGE_FREERDP_INCLUDE_DIR@")
include("${CMAKE_CURRENT_LIST_DIR}/FreeRDPTargets.cmake")

View File

@ -34,9 +34,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -39,3 +39,7 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()

View File

@ -39,6 +39,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSLES_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -36,6 +36,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PULSE_LIBRARY})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -29,4 +29,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MODULE freerdp
MODULES freerdp-codec freerdp-utils)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -74,12 +74,12 @@ CHANNEL_INIT_DATA g_ChannelInitData;
static wArrayList* g_ChannelsList = NULL;
/* To generate unique sequence for all open handles */
int g_open_handle_sequence;
int g_open_handle_sequence = 1;
/* For locking the global resources */
static HANDLE g_mutex_init;
static CRITICAL_SECTION g_channels_lock;
rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex)
rdpChannels* freerdp_channels_find_by_open_handle(int OpenHandle, int* pindex)
{
int i, j;
BOOL found = FALSE;
@ -94,7 +94,7 @@ rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex)
{
for (j = 0; j < channels->openDataCount; j++)
{
if (channels->openDataList[j].OpenHandle == open_handle)
if (channels->openDataList[j].OpenHandle == OpenHandle)
{
*pindex = j;
found = TRUE;
@ -324,21 +324,17 @@ UINT32 FreeRDP_VirtualChannelEventPush(UINT32 openHandle, wMessage* event)
*/
int freerdp_channels_global_init(void)
{
g_open_handle_sequence = 1;
g_mutex_init = CreateMutex(NULL, FALSE, NULL);
if (!g_ChannelsList)
{
g_ChannelsList = ArrayList_New(TRUE);
InitializeCriticalSectionAndSpinCount(&g_channels_lock, 4000);
}
return 0;
}
int freerdp_channels_global_uninit(void)
{
/* TODO: free channels list */
CloseHandle(g_mutex_init);
return 0;
}
@ -397,12 +393,12 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
channels->can_call_init = TRUE;
channels->settings = settings;
WaitForSingleObject(g_mutex_init, INFINITE);
EnterCriticalSection(&g_channels_lock);
g_ChannelInitData.channels = channels;
status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep);
ReleaseMutex(g_mutex_init);
LeaveCriticalSection(&g_channels_lock);
/* disable MyVirtualChannelInit */
channels->settings = NULL;
@ -499,16 +495,15 @@ int freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance)
int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
{
int index;
char* hostname;
int hostnameLength;
char* name;
char* hostname;
int hostnameLength;
CHANNEL_CLIENT_DATA* pChannelClientData;
channels->is_connected = 1;
hostname = instance->settings->ServerHostname;
hostnameLength = strlen(hostname);
DEBUG_CHANNELS("hostname [%s] channels->num_libs [%d]", hostname, channels->clientDataCount);
for (index = 0; index < channels->clientDataCount; index++)
{
pChannelClientData = &channels->clientDataList[index];
@ -522,10 +517,16 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
name = (char*) malloc(9);
CopyMemory(name, pChannelOpenData->name, 8);
name[8] = '\0';
EventArgsInit(&e, "freerdp");
e.name = pChannelOpenData->name;
e.name = name;
e.pInterface = pChannelOpenData->pInterface;
PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e);
free(name);
}
}
@ -786,10 +787,12 @@ wMessage* freerdp_channels_pop_event(rdpChannels* channels)
void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
{
int index;
char* name;
CHANNEL_OPEN_DATA* pChannelOpenData;
CHANNEL_CLIENT_DATA* pChannelClientData;
DEBUG_CHANNELS("closing");
channels->is_connected = 0;
freerdp_channels_check_fds(channels, instance);
@ -805,10 +808,16 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
pChannelOpenData = &channels->openDataList[index];
name = (char*) malloc(9);
CopyMemory(name, pChannelOpenData->name, 8);
name[8] = '\0';
EventArgsInit(&e, "freerdp");
e.name = pChannelOpenData->name;
e.name = name;
e.pInterface = pChannelOpenData->pInterface;
PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e);
free(name);
}
/* Emit a quit signal to the internal message pipe. */

View File

@ -37,8 +37,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MODULE winpr
MODULES winpr-crt)
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -32,4 +32,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -39,9 +39,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -38,5 +38,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MODULE winpr
MODULES winpr-synch)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -32,4 +32,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -45,8 +45,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -56,9 +56,7 @@ struct _DRIVE_DEVICE
wListDictionary* files;
HANDLE thread;
HANDLE irpEvent;
HANDLE stopEvent;
PSLIST_HEADER pIrpList;
wMessageQueue* IrpQueue;
DEVMAN* devman;
};
@ -96,17 +94,17 @@ static UINT32 drive_map_posix_err(int fs_errno)
return rc;
}
static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* disk, UINT32 id)
static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* drive, UINT32 id)
{
DRIVE_FILE* file = NULL;
void* key = (void*) (size_t) id;
file = (DRIVE_FILE*) ListDictionary_GetItemValue(disk->files, key);
file = (DRIVE_FILE*) ListDictionary_GetItemValue(drive->files, key);
return file;
}
static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
{
int status;
void* key;
@ -133,7 +131,7 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
FileId = irp->devman->id_sequence++;
file = drive_file_new(disk->path, path, FileId,
file = drive_file_new(drive->path, path, FileId,
DesiredAccess, CreateDisposition, CreateOptions);
if (!file)
@ -154,7 +152,7 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
else
{
key = (void*) (size_t) file->id;
ListDictionary_Add(disk->files, key, file);
ListDictionary_Add(drive->files, key, file);
switch (CreateDisposition)
{
@ -184,12 +182,12 @@ static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_close(DRIVE_DEVICE* drive, IRP* irp)
{
void* key;
DRIVE_FILE* file;
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
key = (void*) (size_t) irp->FileId;
@ -199,7 +197,7 @@ static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp)
}
else
{
ListDictionary_Remove(disk->files, key);
ListDictionary_Remove(drive->files, key);
drive_file_free(file);
}
@ -208,7 +206,7 @@ static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_read(DRIVE_DEVICE* drive, IRP* irp)
{
DRIVE_FILE* file;
UINT32 Length;
@ -218,7 +216,7 @@ static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp)
Stream_Read_UINT32(irp->input, Length);
Stream_Read_UINT64(irp->input, Offset);
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
if (!file)
{
@ -260,7 +258,7 @@ static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_write(DRIVE_DEVICE* drive, IRP* irp)
{
DRIVE_FILE* file;
UINT32 Length;
@ -270,7 +268,7 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
Stream_Read_UINT64(irp->input, Offset);
Stream_Seek(irp->input, 20); /* Padding */
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
if (!file)
{
@ -298,14 +296,14 @@ static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_query_information(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_information(DRIVE_DEVICE* drive, IRP* irp)
{
DRIVE_FILE* file;
UINT32 FsInformationClass;
Stream_Read_UINT32(irp->input, FsInformationClass);
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
if (!file)
{
@ -323,7 +321,7 @@ static void drive_process_irp_query_information(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_set_information(DRIVE_DEVICE* drive, IRP* irp)
{
DRIVE_FILE* file;
UINT32 FsInformationClass;
@ -333,7 +331,7 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp)
Stream_Read_UINT32(irp->input, Length);
Stream_Seek(irp->input, 24); /* Padding */
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
if (!file)
{
@ -353,7 +351,7 @@ static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* irp)
{
UINT32 FsInformationClass;
wStream* output = irp->output;
@ -366,8 +364,8 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP*
Stream_Read_UINT32(irp->input, FsInformationClass);
STATVFS(disk->path, &svfst);
STAT(disk->path, &st);
STATVFS(drive->path, &svfst);
STAT(drive->path, &st);
switch (FsInformationClass)
{
@ -448,7 +446,7 @@ static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP*
/* http://msdn.microsoft.com/en-us/library/cc241518.aspx */
static void drive_process_irp_silent_ignore(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_silent_ignore(DRIVE_DEVICE* drive, IRP* irp)
{
UINT32 FsInformationClass;
wStream* output = irp->output;
@ -460,7 +458,7 @@ static void drive_process_irp_silent_ignore(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_directory(DRIVE_DEVICE* drive, IRP* irp)
{
char* path = NULL;
int status;
@ -480,7 +478,7 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
if (status < 1)
path = (char*) calloc(1, 1);
file = drive_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(drive, irp->FileId);
if (file == NULL)
{
@ -497,12 +495,12 @@ static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void drive_process_irp_directory_control(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_directory_control(DRIVE_DEVICE* drive, IRP* irp)
{
switch (irp->MinorFunction)
{
case IRP_MN_QUERY_DIRECTORY:
drive_process_irp_query_directory(disk, irp);
drive_process_irp_query_directory(drive, irp);
break;
case IRP_MN_NOTIFY_CHANGE_DIRECTORY: /* TODO */
@ -517,56 +515,56 @@ static void drive_process_irp_directory_control(DRIVE_DEVICE* disk, IRP* irp)
}
}
static void drive_process_irp_device_control(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp_device_control(DRIVE_DEVICE* drive, IRP* irp)
{
Stream_Write_UINT32(irp->output, 0); /* OutputBufferLength */
irp->Complete(irp);
}
static void drive_process_irp(DRIVE_DEVICE* disk, IRP* irp)
static void drive_process_irp(DRIVE_DEVICE* drive, IRP* irp)
{
irp->IoStatus = STATUS_SUCCESS;
switch (irp->MajorFunction)
{
case IRP_MJ_CREATE:
drive_process_irp_create(disk, irp);
drive_process_irp_create(drive, irp);
break;
case IRP_MJ_CLOSE:
drive_process_irp_close(disk, irp);
drive_process_irp_close(drive, irp);
break;
case IRP_MJ_READ:
drive_process_irp_read(disk, irp);
drive_process_irp_read(drive, irp);
break;
case IRP_MJ_WRITE:
drive_process_irp_write(disk, irp);
drive_process_irp_write(drive, irp);
break;
case IRP_MJ_QUERY_INFORMATION:
drive_process_irp_query_information(disk, irp);
drive_process_irp_query_information(drive, irp);
break;
case IRP_MJ_SET_INFORMATION:
drive_process_irp_set_information(disk, irp);
drive_process_irp_set_information(drive, irp);
break;
case IRP_MJ_QUERY_VOLUME_INFORMATION:
drive_process_irp_query_volume_information(disk, irp);
drive_process_irp_query_volume_information(drive, irp);
break;
case IRP_MJ_LOCK_CONTROL:
drive_process_irp_silent_ignore(disk, irp);
drive_process_irp_silent_ignore(drive, irp);
break;
case IRP_MJ_DIRECTORY_CONTROL:
drive_process_irp_directory_control(disk, irp);
drive_process_irp_directory_control(drive, irp);
break;
case IRP_MJ_DEVICE_CONTROL:
drive_process_irp_device_control(disk, irp);
drive_process_irp_device_control(drive, irp);
break;
default:
@ -576,77 +574,57 @@ static void drive_process_irp(DRIVE_DEVICE* disk, IRP* irp)
}
}
static void drive_process_irp_list(DRIVE_DEVICE* disk)
{
IRP* irp;
while (1)
{
if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0)
break;
irp = (IRP*) InterlockedPopEntrySList(disk->pIrpList);
if (irp == NULL)
break;
drive_process_irp(disk, irp);
}
}
static void* drive_thread_func(void* arg)
{
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) arg;
HANDLE hdl[] = {disk->irpEvent, disk->stopEvent};
IRP* irp;
wMessage message;
DRIVE_DEVICE* drive = (DRIVE_DEVICE*) arg;
while (1)
{
DWORD rc = WaitForMultipleObjects(2, hdl, FALSE, INFINITE);
if (rc == WAIT_OBJECT_0 + 1)
break;
while (1)
{
if (!MessageQueue_Wait(drive->IrpQueue))
break;
ResetEvent(disk->irpEvent);
drive_process_irp_list(disk);
}
ExitThread(0);
if (!MessageQueue_Peek(drive->IrpQueue, &message, TRUE))
break;
return NULL;
if (message.id == WMQ_QUIT)
break;
irp = (IRP*) message.wParam;
if (irp)
drive_process_irp(drive, irp);
}
ExitThread(0);
return NULL;
}
static void drive_irp_request(DEVICE* device, IRP* irp)
{
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device;
InterlockedPushEntrySList(disk->pIrpList, &(irp->ItemEntry));
SetEvent(disk->irpEvent);
DRIVE_DEVICE* drive = (DRIVE_DEVICE*) device;
MessageQueue_Post(drive->IrpQueue, NULL, 0, (void*) irp, NULL);
}
static void drive_free(DEVICE* device)
{
IRP* irp;
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device;
DRIVE_DEVICE* drive = (DRIVE_DEVICE*) device;
SetEvent(disk->stopEvent);
WaitForSingleObject(disk->thread, INFINITE);
CloseHandle(disk->thread);
CloseHandle(disk->irpEvent);
CloseHandle(disk->stopEvent);
MessageQueue_PostQuit(drive->IrpQueue, 0);
WaitForSingleObject(drive->thread, INFINITE);
while ((irp = (IRP*) InterlockedPopEntrySList(disk->pIrpList)) != NULL)
irp->Discard(irp);
CloseHandle(drive->thread);
_aligned_free(disk->pIrpList);
ListDictionary_Free(drive->files);
ListDictionary_Free(disk->files);
free(disk);
free(drive);
}
void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
{
int i, length;
DRIVE_DEVICE* disk;
DRIVE_DEVICE* drive;
#ifdef WIN32
/*
@ -664,35 +642,31 @@ void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char*
if (name[0] && path[0])
{
disk = (DRIVE_DEVICE*) malloc(sizeof(DRIVE_DEVICE));
ZeroMemory(disk, sizeof(DRIVE_DEVICE));
drive = (DRIVE_DEVICE*) malloc(sizeof(DRIVE_DEVICE));
ZeroMemory(drive, sizeof(DRIVE_DEVICE));
disk->device.type = RDPDR_DTYP_FILESYSTEM;
disk->device.name = name;
disk->device.IRPRequest = drive_irp_request;
disk->device.Free = drive_free;
drive->device.type = RDPDR_DTYP_FILESYSTEM;
drive->device.name = name;
drive->device.IRPRequest = drive_irp_request;
drive->device.Free = drive_free;
length = strlen(name);
disk->device.data = Stream_New(NULL, length + 1);
drive->device.data = Stream_New(NULL, length + 1);
for (i = 0; i <= length; i++)
Stream_Write_UINT8(disk->device.data, name[i] < 0 ? '_' : name[i]);
Stream_Write_UINT8(drive->device.data, name[i] < 0 ? '_' : name[i]);
disk->path = path;
drive->path = path;
disk->files = ListDictionary_New(TRUE);
ListDictionary_Object(disk->files)->fnObjectFree = (OBJECT_FREE_FN) drive_file_free;
drive->files = ListDictionary_New(TRUE);
ListDictionary_Object(drive->files)->fnObjectFree = (OBJECT_FREE_FN) drive_file_free;
disk->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(disk->pIrpList);
drive->IrpQueue = MessageQueue_New();
drive->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, drive, CREATE_SUSPENDED, NULL);
disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, disk, CREATE_SUSPENDED, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) drive);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
ResumeThread(disk->thread);
ResumeThread(drive->thread);
}
}

View File

@ -34,9 +34,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -36,8 +36,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -56,8 +56,6 @@ endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -36,5 +36,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -43,4 +43,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -204,6 +204,9 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
}
}
if (pKeys)
free(pKeys);
pos = Stream_GetPosition(s);
Stream_SetPosition(s, count_pos);
Stream_Write_UINT32(s, count);
@ -289,12 +292,6 @@ static void rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
Stream_Free(s, TRUE);
}
static void rdpdr_process_terminate(rdpdrPlugin* rdpdr)
{
devman_free(rdpdr->devman);
free(rdpdr);
}
/****************************************************************************************/
@ -366,7 +363,7 @@ int rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
return status;
}
static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* plugin,
static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
wStream* data_in;
@ -384,13 +381,13 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* plugin,
if (dataFlags & CHANNEL_FLAG_FIRST)
{
if (plugin->data_in != NULL)
Stream_Free(plugin->data_in, TRUE);
if (rdpdr->data_in != NULL)
Stream_Free(rdpdr->data_in, TRUE);
plugin->data_in = Stream_New(NULL, totalLength);
rdpdr->data_in = Stream_New(NULL, totalLength);
}
data_in = plugin->data_in;
data_in = rdpdr->data_in;
Stream_EnsureRemainingCapacity(data_in, (int) dataLength);
Stream_Write(data_in, pData, dataLength);
@ -401,31 +398,31 @@ static void rdpdr_virtual_channel_event_data_received(rdpdrPlugin* plugin,
fprintf(stderr, "svc_plugin_process_received: read error\n");
}
plugin->data_in = NULL;
rdpdr->data_in = NULL;
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
MessageQueue_Post(plugin->MsgPipe->In, NULL, 0, (void*) data_in, NULL);
MessageQueue_Post(rdpdr->MsgPipe->In, NULL, 0, (void*) data_in, NULL);
}
}
static void rdpdr_virtual_channel_open_event(UINT32 openHandle, UINT32 event,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
rdpdrPlugin* plugin;
rdpdrPlugin* rdpdr;
plugin = (rdpdrPlugin*) rdpdr_get_open_handle_data(openHandle);
rdpdr = (rdpdrPlugin*) rdpdr_get_open_handle_data(openHandle);
if (!plugin)
if (!rdpdr)
{
fprintf(stderr, "svc_plugin_open_event: error no match\n");
fprintf(stderr, "rdpdr_virtual_channel_open_event: error no match\n");
return;
}
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
rdpdr_virtual_channel_event_data_received(plugin, pData, dataLength, totalLength, dataFlags);
rdpdr_virtual_channel_event_data_received(rdpdr, pData, dataLength, totalLength, dataFlags);
break;
case CHANNEL_EVENT_WRITE_COMPLETE:
@ -441,16 +438,16 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
{
wStream* data;
wMessage message;
rdpdrPlugin* plugin = (rdpdrPlugin*) arg;
rdpdrPlugin* rdpdr = (rdpdrPlugin*) arg;
rdpdr_process_connect(plugin);
rdpdr_process_connect(rdpdr);
while (1)
{
if (!MessageQueue_Wait(plugin->MsgPipe->In))
if (!MessageQueue_Wait(rdpdr->MsgPipe->In))
break;
if (MessageQueue_Peek(plugin->MsgPipe->In, &message, TRUE))
if (MessageQueue_Peek(rdpdr->MsgPipe->In, &message, TRUE))
{
if (message.id == WMQ_QUIT)
break;
@ -458,7 +455,7 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
if (message.id == 0)
{
data = (wStream*) message.wParam;
rdpdr_process_receive(plugin, data);
rdpdr_process_receive(rdpdr, data);
}
}
}
@ -467,72 +464,76 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
return NULL;
}
static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* plugin, void* pData, UINT32 dataLength)
static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, void* pData, UINT32 dataLength)
{
UINT32 status;
status = plugin->channelEntryPoints.pVirtualChannelOpen(plugin->InitHandle,
&plugin->OpenHandle, plugin->channelDef.name, rdpdr_virtual_channel_open_event);
status = rdpdr->channelEntryPoints.pVirtualChannelOpen(rdpdr->InitHandle,
&rdpdr->OpenHandle, rdpdr->channelDef.name, rdpdr_virtual_channel_open_event);
rdpdr_add_open_handle_data(plugin->OpenHandle, plugin);
rdpdr_add_open_handle_data(rdpdr->OpenHandle, rdpdr);
if (status != CHANNEL_RC_OK)
{
fprintf(stderr, "svc_plugin_process_connected: open failed: status: %d\n", status);
fprintf(stderr, "rdpdr_virtual_channel_event_connected: open failed: status: %d\n", status);
return;
}
plugin->MsgPipe = MessagePipe_New();
rdpdr->MsgPipe = MessagePipe_New();
plugin->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) plugin, 0, NULL);
rdpdr->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0, NULL);
}
static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* plugin)
static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
{
MessagePipe_PostQuit(plugin->MsgPipe, 0);
WaitForSingleObject(plugin->thread, INFINITE);
MessagePipe_PostQuit(rdpdr->MsgPipe, 0);
WaitForSingleObject(rdpdr->thread, INFINITE);
MessagePipe_Free(plugin->MsgPipe);
CloseHandle(plugin->thread);
MessagePipe_Free(rdpdr->MsgPipe);
CloseHandle(rdpdr->thread);
plugin->channelEntryPoints.pVirtualChannelClose(plugin->OpenHandle);
rdpdr->channelEntryPoints.pVirtualChannelClose(rdpdr->OpenHandle);
if (plugin->data_in)
if (rdpdr->data_in)
{
Stream_Free(plugin->data_in, TRUE);
plugin->data_in = NULL;
Stream_Free(rdpdr->data_in, TRUE);
rdpdr->data_in = NULL;
}
rdpdr_process_terminate(plugin);
if (rdpdr->devman)
{
devman_free(rdpdr->devman);
rdpdr->devman = NULL;
}
rdpdr_remove_open_handle_data(plugin->OpenHandle);
rdpdr_remove_init_handle_data(plugin->InitHandle);
rdpdr_remove_open_handle_data(rdpdr->OpenHandle);
rdpdr_remove_init_handle_data(rdpdr->InitHandle);
}
static void rdpdr_virtual_channel_init_event(void* pInitHandle, UINT32 event, void* pData, UINT32 dataLength)
{
rdpdrPlugin* plugin;
rdpdrPlugin* rdpdr;
plugin = (rdpdrPlugin*) rdpdr_get_init_handle_data(pInitHandle);
rdpdr = (rdpdrPlugin*) rdpdr_get_init_handle_data(pInitHandle);
if (!plugin)
if (!rdpdr)
{
fprintf(stderr, "svc_plugin_init_event: error no match\n");
fprintf(stderr, "rdpdr_virtual_channel_init_event: error no match\n");
return;
}
switch (event)
{
case CHANNEL_EVENT_CONNECTED:
rdpdr_virtual_channel_event_connected(plugin, pData, dataLength);
rdpdr_virtual_channel_event_connected(rdpdr, pData, dataLength);
break;
case CHANNEL_EVENT_DISCONNECTED:
break;
case CHANNEL_EVENT_TERMINATED:
rdpdr_virtual_channel_event_terminated(plugin);
rdpdr_virtual_channel_event_terminated(rdpdr);
break;
}
}
@ -542,24 +543,24 @@ static void rdpdr_virtual_channel_init_event(void* pInitHandle, UINT32 event, vo
int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{
rdpdrPlugin* plugin;
rdpdrPlugin* rdpdr;
plugin = (rdpdrPlugin*) malloc(sizeof(rdpdrPlugin));
ZeroMemory(plugin, sizeof(rdpdrPlugin));
rdpdr = (rdpdrPlugin*) malloc(sizeof(rdpdrPlugin));
ZeroMemory(rdpdr, sizeof(rdpdrPlugin));
plugin->channelDef.options =
rdpdr->channelDef.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
strcpy(plugin->channelDef.name, "rdpdr");
strcpy(rdpdr->channelDef.name, "rdpdr");
CopyMemory(&(plugin->channelEntryPoints), pEntryPoints, pEntryPoints->cbSize);
CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints, pEntryPoints->cbSize);
plugin->channelEntryPoints.pVirtualChannelInit(&plugin->InitHandle,
&plugin->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event);
rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle,
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpdr_virtual_channel_init_event);
rdpdr_add_init_handle_data(plugin->InitHandle, (void*) plugin);
rdpdr_add_init_handle_data(rdpdr->InitHandle, (void*) rdpdr);
return 1;
}

View File

@ -32,4 +32,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -41,9 +41,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -41,9 +41,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -37,6 +37,8 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")
if(WITH_ALSA)
@ -44,7 +46,7 @@ if(WITH_ALSA)
endif()
if(WITH_IOSAUDIO)
add_channel_client_subsystem($(MODULE_PREFIX) $(CHANNEL_NAME) "ios" "")
add_channel_client_subsystem(${MODULE_PREFIX} ${CHANNEL_NAME} "ios" "")
endif()
if(WITH_PULSE)

View File

@ -41,8 +41,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ALSA_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/ALSA")

View File

@ -45,8 +45,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/ios")

View File

@ -45,8 +45,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/Mac")

View File

@ -38,6 +38,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSLES_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -36,8 +36,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PULSE_LIBRARY})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/Pulse")

View File

@ -297,8 +297,15 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s)
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);
if (format->cbSize > 0)
{
format->data = (BYTE*) malloc(format->cbSize);
Stream_Read(s, format->data, format->cbSize);
}
else
{
format->data = NULL;
}
}
rdpsnd_select_supported_audio_formats(rdpsnd);

View File

@ -40,8 +40,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winmm.lib)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/WinMM")

View File

@ -32,4 +32,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Server")

View File

@ -30,8 +30,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MODULE freerdp
MODULES freerdp-utils)
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -34,9 +34,6 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -42,9 +42,6 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PCSC_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -31,7 +31,6 @@
#include <freerdp/utils/list.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/channels/rdpdr.h>
@ -229,7 +228,7 @@ static void smartcard_irp_complete(IRP* irp)
* to be in this file so that "smartcard_irp_request()" can reference it.
*/
DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId);
DEBUG_SCARD("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId);
pos = Stream_GetPosition(irp->output);
Stream_SetPosition(irp->output, 12);
@ -246,8 +245,7 @@ static void smartcard_irp_complete(IRP* irp)
if (!duplicate)
{
svc_plugin_send(irp->devman->plugin, irp->output);
irp->output = NULL;
irp->Complete(irp);
}
/* End TS Client defect workaround. */

View File

@ -47,9 +47,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -36,6 +36,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ALSA_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -31,20 +31,17 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-utils)
if(APPLE)
# For this to work on apple, we need to add some frameworks
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation )
FIND_LIBRARY(COREVIDEO_LIBRARY CoreVideo )
FIND_LIBRARY(COREVIDEODECODE_LIBRARY VideoDecodeAcceleration )
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${FFMPEG_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY} ${COREVIDEODECODE_LIBRARY} )
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
FIND_LIBRARY(COREVIDEO_LIBRARY CoreVideo)
FIND_LIBRARY(COREVIDEODECODE_LIBRARY VideoDecodeAcceleration)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${FFMPEG_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY} ${COREVIDEODECODE_LIBRARY})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
else()
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${FFMPEG_LIBRARIES})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
endif()
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -40,6 +40,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -36,7 +36,4 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PULSE_LIBRARY})
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)

View File

@ -58,9 +58,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH} EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client")

View File

@ -63,7 +63,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(WITH_CLIENT_INTERFACE)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT WinPRTargets)
add_subdirectory(cli)
else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)

View File

@ -204,7 +204,7 @@ if(WITH_IPP)
endif()
if(WITH_CLIENT_INTERFACE)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT FreeRDPTargets)
add_subdirectory(cli)
else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)

View File

@ -728,8 +728,12 @@ static void xf_post_disconnect(freerdp *instance)
assert(NULL != xfc);
assert(NULL != instance->settings);
WaitForSingleObject(xfc->mutex, INFINITE);
CloseHandle(xfc->mutex);
if (xfc->mutex)
{
WaitForSingleObject(xfc->mutex, INFINITE);
CloseHandle(xfc->mutex);
xfc->mutex = NULL;
}
xf_monitors_free(xfc, instance->settings);
}
@ -750,13 +754,41 @@ BOOL xf_pre_connect(freerdp* instance)
rdpSettings* settings;
xfContext* xfc = (xfContext*) instance->context;
xfc->mutex = CreateMutex(NULL, FALSE, NULL);
xfc->settings = instance->settings;
xfc->instance = instance;
settings = instance->settings;
channels = instance->context->channels;
xfc->UseXThreads = TRUE;
if (xfc->UseXThreads)
{
if (!XInitThreads())
{
fprintf(stderr, "warning: XInitThreads() failure\n");
xfc->UseXThreads = FALSE;
}
}
xfc->display = XOpenDisplay(NULL);
if (!xfc->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");
return FALSE;
}
if (xfc->debug)
{
fprintf(stderr, "Enabling X11 debug mode.\n");
XSynchronize(xfc->display, TRUE);
_def_error_handler = XSetErrorHandler(_xf_error_handler);
}
xfc->mutex = CreateMutex(NULL, FALSE, NULL);
PubSub_SubscribeChannelConnected(instance->context->pubSub,
(pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler);
@ -785,33 +817,6 @@ BOOL xf_pre_connect(freerdp* instance)
return TRUE;
}
xfc->UseXThreads = TRUE;
if (xfc->UseXThreads)
{
if (!XInitThreads())
{
fprintf(stderr, "warning: XInitThreads() failure\n");
xfc->UseXThreads = FALSE;
}
}
xfc->display = XOpenDisplay(NULL);
if (!xfc->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");
return FALSE;
}
if (xfc->debug)
{
fprintf(stderr, "Enabling X11 debug mode.\n");
XSynchronize(xfc->display, TRUE);
_def_error_handler = XSetErrorHandler(_xf_error_handler);
}
xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False);
xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False);
xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP", False);
@ -937,6 +942,10 @@ BOOL xf_post_connect(freerdp* instance)
xf_create_window(xfc);
ZeroMemory(&gcv, sizeof(gcv));
if (xfc->modifier_map)
XFreeModifiermap(xfc->modifier_map);
xfc->modifier_map = XGetModifierMapping(xfc->display);
xfc->gc = XCreateGC(xfc->display, xfc->drawable, GCGraphicsExposures, &gcv);
@ -1388,6 +1397,15 @@ void* xf_thread(void* param)
if (!status)
{
if (xfc->mutex)
{
WaitForSingleObject(xfc->mutex, INFINITE);
CloseHandle(xfc->mutex);
xfc->mutex = NULL;
}
xf_monitors_free(xfc, instance->settings);
exit_code = XF_EXIT_CONN_FAILED;
ExitThread(exit_code);
}
@ -1754,6 +1772,7 @@ static int xfreerdp_client_stop(rdpContext* context)
xfContext* xfc = (xfContext*) context;
assert(NULL != context);
if (context->settings->AsyncInput)
{
wMessageQueue* queue;
@ -1828,7 +1847,6 @@ static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
PubSub_SubscribeParamChange(context->pubSub, (pParamChangeEventHandler) xf_ParamChangeEventHandler);
PubSub_SubscribeScalingFactorChange(context->pubSub, (pScalingFactorChangeEventHandler) xf_ScalingFactorChangeEventHandler);
return 0;
}

View File

@ -475,7 +475,9 @@ static BOOL xf_event_MappingNotify(xfContext* xfc, XEvent* event, BOOL app)
{
if (event->xmapping.request == MappingModifier)
{
XFreeModifiermap(xfc->modifier_map);
if (xfc->modifier_map)
XFreeModifiermap(xfc->modifier_map);
xfc->modifier_map = XGetModifierMapping(xfc->display);
}

View File

@ -38,9 +38,14 @@
void xf_kbd_init(xfContext* xfc)
{
xf_kbd_clear(xfc);
xfc->keyboard_layout_id = xfc->instance->settings->KeyboardLayout;
xfc->keyboard_layout_id = freerdp_keyboard_init(xfc->keyboard_layout_id);
xfc->instance->settings->KeyboardLayout = xfc->keyboard_layout_id;
if (xfc->modifier_map)
XFreeModifiermap(xfc->modifier_map);
xfc->modifier_map = XGetModifierMapping(xfc->display);
}

View File

@ -261,10 +261,16 @@ BOOL xf_detect_monitors(xfContext* xfc, rdpSettings* settings)
void xf_monitors_free(xfContext *xfc, rdpSettings *settings)
{
#ifdef WITH_XINERAMA
if(xfc->vscreen.monitors)
if (xfc->vscreen.monitors)
{
free(xfc->vscreen.monitors);
xfc->vscreen.monitors = NULL;
}
#endif
if(settings->MonitorIds)
if (settings->MonitorIds)
{
free(settings->MonitorIds);
settings->MonitorIds = NULL;
}
}

View File

@ -53,9 +53,11 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHI
MODULE winpr
MODULES winpr-crt winpr-utils)
set_target_properties(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Common")

View File

@ -70,12 +70,12 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
void freerdp_client_context_free(rdpContext* context)
{
freerdp* instance = context->instance;
if (instance)
{
freerdp_context_free(instance);
free(instance->pClientEntryPoints);
freerdp_free(instance);
context->instance = NULL;
}
}

View File

@ -321,10 +321,15 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
ZeroMemory(settings, sizeof(rdpSettings));
CommandLineClearArgumentsA(old_args);
status = CommandLineParseArgumentsA(argc, (const char**) argv, old_args, flags, settings,
freerdp_client_old_command_line_pre_filter, NULL);
if (status < 0)
{
free(settings);
return status;
}
arg = old_args;

View File

@ -22,7 +22,8 @@ macro(enable_cmake_compat CMVERSION)
endif()
endmacro()
# Compatibility includes - oder does matter!
# Compatibility includes - order does matter!
enable_cmake_compat(2.8.11)
enable_cmake_compat(2.8.6)
enable_cmake_compat(2.8.3)
enable_cmake_compat(2.8.2)

View File

@ -0,0 +1,31 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "@CVF_VERSION@")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View File

@ -0,0 +1,47 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is equal to the requested version.
# The tweak version component is ignored.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "@CVF_VERSION@")
if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
else()
set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@")
endif()
if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
else()
set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
endif()
if("${REQUESTED_VERSION_NO_TWEAK}" STREQUAL "${CVF_VERSION_NO_TWEAK}")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View File

@ -0,0 +1,46 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
# but only if the requested major version is the same as the current one.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "@CVF_VERSION@")
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(CVF_VERSION_MAJOR "@CVF_VERSION@")
endif()
if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View File

@ -0,0 +1,248 @@
# - CONFIGURE_PACKAGE_CONFIG_FILE(), WRITE_BASIC_PACKAGE_VERSION_FILE()
#
# CONFIGURE_PACKAGE_CONFIG_FILE(<input> <output> INSTALL_DESTINATION <path>
# [PATH_VARS <var1> <var2> ... <varN>]
# [NO_SET_AND_CHECK_MACRO]
# [NO_CHECK_REQUIRED_COMPONENTS_MACRO])
#
# CONFIGURE_PACKAGE_CONFIG_FILE() should be used instead of the plain
# configure_file() command when creating the <Name>Config.cmake or <Name>-config.cmake
# file for installing a project or library. It helps making the resulting package
# relocatable by avoiding hardcoded paths in the installed Config.cmake file.
#
# In a FooConfig.cmake file there may be code like this to make the
# install destinations know to the using project:
# set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" )
# set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" )
# set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" )
# ...logic to determine installedPrefix from the own location...
# set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" )
# All 4 options shown above are not sufficient, since the first 3 hardcode
# the absolute directory locations, and the 4th case works only if the logic
# to determine the installedPrefix is correct, and if CONFIG_INSTALL_DIR contains
# a relative path, which in general cannot be guaranteed.
# This has the effect that the resulting FooConfig.cmake file would work poorly
# under Windows and OSX, where users are used to choose the install location
# of a binary package at install time, independent from how CMAKE_INSTALL_PREFIX
# was set at build/cmake time.
#
# Using CONFIGURE_PACKAGE_CONFIG_FILE() helps. If used correctly, it makes the
# resulting FooConfig.cmake file relocatable.
# Usage:
# 1. write a FooConfig.cmake.in file as you are used to
# 2. insert a line containing only the string "@PACKAGE_INIT@"
# 3. instead of set(FOO_DIR "@SOME_INSTALL_DIR@"), use set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")
# (this must be after the @PACKAGE_INIT@ line)
# 4. instead of using the normal configure_file(), use CONFIGURE_PACKAGE_CONFIG_FILE()
#
# The <input> and <output> arguments are the input and output file, the same way
# as in configure_file().
#
# The <path> given to INSTALL_DESTINATION must be the destination where the FooConfig.cmake
# file will be installed to. This can either be a relative or absolute path, both work.
#
# The variables <var1> to <varN> given as PATH_VARS are the variables which contain
# install destinations. For each of them the macro will create a helper variable
# PACKAGE_<var...>. These helper variables must be used
# in the FooConfig.cmake.in file for setting the installed location. They are calculated
# by CONFIGURE_PACKAGE_CONFIG_FILE() so that they are always relative to the
# installed location of the package. This works both for relative and also for absolute locations.
# For absolute locations it works only if the absolute location is a subdirectory
# of CMAKE_INSTALL_PREFIX.
#
# By default configure_package_config_file() also generates two helper macros,
# set_and_check() and check_required_components() into the FooConfig.cmake file.
#
# set_and_check() should be used instead of the normal set()
# command for setting directories and file locations. Additionally to setting the
# variable it also checks that the referenced file or directory actually exists
# and fails with a FATAL_ERROR otherwise. This makes sure that the created
# FooConfig.cmake file does not contain wrong references.
# When using the NO_SET_AND_CHECK_MACRO, this macro is not generated into the
# FooConfig.cmake file.
#
# check_required_components(<package_name>) should be called at the end of the
# FooConfig.cmake file if the package supports components.
# This macro checks whether all requested, non-optional components have been found,
# and if this is not the case, sets the Foo_FOUND variable to FALSE, so that the package
# is considered to be not found.
# It does that by testing the Foo_<Component>_FOUND variables for all requested
# required components.
# When using the NO_CHECK_REQUIRED_COMPONENTS option, this macro is not generated
# into the FooConfig.cmake file.
#
# For an example see below the documentation for WRITE_BASIC_PACKAGE_VERSION_FILE().
#
#
# WRITE_BASIC_PACKAGE_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) )
#
# Writes a file for use as <package>ConfigVersion.cmake file to <filename>.
# See the documentation of find_package() for details on this.
# filename is the output filename, it should be in the build tree.
# major.minor.patch is the version number of the project to be installed
# The COMPATIBILITY mode AnyNewerVersion means that the installed package version
# will be considered compatible if it is newer or exactly the same as the requested version.
# This mode should be used for packages which are fully backward compatible,
# also across major versions.
# If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion
# in that the major version number must be the same as requested, e.g. version 2.0 will
# not be considered compatible if 1.0 is requested.
# This mode should be used for packages which guarantee backward compatibility within the
# same major version.
# If ExactVersion is used, then the package is only considered compatible if the requested
# version matches exactly its own version number (not considering the tweak version).
# For example, version 1.2.3 of a package is only considered compatible to requested version 1.2.3.
# This mode is for packages without compatibility guarantees.
# If your project has more elaborated version matching rules, you will need to write your
# own custom ConfigVersion.cmake file instead of using this macro.
#
# Internally, this macro executes configure_file() to create the resulting
# version file. Depending on the COMPATIBLITY, either the file
# BasicConfigVersion-SameMajorVersion.cmake.in or BasicConfigVersion-AnyNewerVersion.cmake.in
# is used. Please note that these two files are internal to CMake and you should
# not call configure_file() on them yourself, but they can be used as starting
# point to create more sophisticted custom ConfigVersion.cmake files.
#
#
# Example using both configure_package_config_file() and write_basic_package_version_file():
# CMakeLists.txt:
# set(INCLUDE_INSTALL_DIR include/ ... CACHE )
# set(LIB_INSTALL_DIR lib/ ... CACHE )
# set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE )
# ...
# include(CMakePackageConfigHelpers)
# configure_package_config_file(FooConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
# INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake
# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
# write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
# VERSION 1.2.3
# COMPATIBILITY SameMajorVersion )
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
# DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake )
#
# With a FooConfig.cmake.in:
# set(FOO_VERSION x.y.z)
# ...
# @PACKAGE_INIT@
# ...
# set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
# set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
#
# check_required_components(Foo)
#=============================================================================
# Copyright 2012 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CMakeParseArguments)
include(WriteBasicConfigVersionFile)
macro(WRITE_BASIC_PACKAGE_VERSION_FILE)
write_basic_config_version_file(${ARGN})
endmacro()
function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
set(oneValueArgs INSTALL_DESTINATION )
set(multiValueArgs PATH_VARS )
cmake_parse_arguments(CCF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CCF_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to CONFIGURE_PACKAGE_CONFIG_FILE(): \"${CCF_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT CCF_INSTALL_DESTINATION)
message(FATAL_ERROR "No INSTALL_DESTINATION given to CONFIGURE_PACKAGE_CONFIG_FILE()")
endif()
if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
set(absInstallDir "${CCF_INSTALL_DESTINATION}")
else()
set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}")
endif()
file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" )
foreach(var ${CCF_PATH_VARS})
if(NOT DEFINED ${var})
message(FATAL_ERROR "Variable ${var} does not exist")
else()
if(IS_ABSOLUTE "${${var}}")
string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}"
PACKAGE_${var} "${${var}}")
else()
set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}")
endif()
endif()
endforeach()
get_filename_component(inputFileName "${_inputFile}" NAME)
set(PACKAGE_INIT "
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was ${inputFileName} ########
get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE)
")
if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+")
# Handle "/usr move" symlinks created by some Linux distros.
set(PACKAGE_INIT "${PACKAGE_INIT}
# Use original install prefix when loaded through a \"/usr move\"
# cross-prefix symbolic link such as /lib -> /usr/lib.
get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH)
get_filename_component(_realOrig \"${absInstallDir}\" REALPATH)
if(_realCurr STREQUAL _realOrig)
set(PACKAGE_PREFIX_DIR \"${CMAKE_INSTALL_PREFIX}\")
endif()
unset(_realOrig)
unset(_realCurr)
")
endif()
if(NOT CCF_NO_SET_AND_CHECK_MACRO)
set(PACKAGE_INIT "${PACKAGE_INIT}
macro(set_and_check _var _file)
set(\${_var} \"\${_file}\")
if(NOT EXISTS \"\${_file}\")
message(FATAL_ERROR \"File or directory \${_file} referenced by variable \${_var} does not exist !\")
endif()
endmacro()
")
endif()
if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO)
set(PACKAGE_INIT "${PACKAGE_INIT}
macro(check_required_components _NAME)
foreach(comp \${\${_NAME}_FIND_COMPONENTS})
if(NOT \${_NAME}_\${comp}_FOUND)
if(\${_NAME}_FIND_REQUIRED_\${comp})
set(\${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()
")
endif()
set(PACKAGE_INIT "${PACKAGE_INIT}
####################################################################################")
configure_file("${_inputFile}" "${_outputFile}" @ONLY)
endfunction()

View File

@ -0,0 +1,50 @@
# WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) )
#
# Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical.
#=============================================================================
# Copyright 2008-2011 Alexander Neundorf, <neundorf@kde.org>
# Copyright 2004-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CMakeParseArguments)
function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
set(options )
set(oneValueArgs VERSION COMPATIBILITY )
set(multiValueArgs )
cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CVF_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"")
endif()
foreach(MODULE_PATH ${CMAKE_MODULE_PATH})
if (${MODULE_PATH} MATCHES "compat_2.8.11")
set(CURRENT_MODULE_PATH ${MODULE_PATH})
endif()
endforeach()
set(versionTemplateFile "${CURRENT_MODULE_PATH}/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in")
if(NOT EXISTS "${versionTemplateFile}")
message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"")
endif()
if("${CVF_VERSION}" STREQUAL "")
message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()")
endif()
configure_file("${versionTemplateFile}" "${_filename}" @ONLY)
endfunction()

View File

@ -24,6 +24,7 @@
#include <freerdp/types.h>
#include <freerdp/update.h>
#include <winpr/wlog.h>
#include <winpr/stream.h>
typedef struct _GLYPH_CACHE GLYPH_CACHE;
@ -56,6 +57,7 @@ struct rdp_glyph_cache
FRAGMENT_CACHE fragCache;
GLYPH_CACHE glyphCache[10];
wLog* log;
rdpContext* context;
rdpSettings* settings;
};

View File

@ -22,6 +22,7 @@
#define FREERDP_CHANNEL_RDPDR_H
#include <winpr/nt.h>
#include <winpr/io.h>
#include <winpr/crt.h>
#include <winpr/file.h>
#include <winpr/synch.h>
@ -262,11 +263,14 @@ enum FSCTL_STRUCTURE
#endif
/* [MS-FSCC] FileFsDeviceInformation.DeviceType */
enum FILE_FS_DEVICE_TYPE
{
FILE_DEVICE_CD_ROM = 0x00000002,
FILE_DEVICE_DISK = 0x00000007
};
#ifndef FILE_DEVICE_CD_ROM
#define FILE_DEVICE_CD_ROM 0x00000002
#endif
#ifndef FILE_DEVICE_DISK
#define FILE_DEVICE_DISK 0x00000007
#endif
/* [MS-FSCC] FileFsDeviceInformation.Characteristics */
enum FILE_FS_DEVICE_FLAG

View File

@ -58,7 +58,6 @@ FREERDP_API BOOL tls_disconnect(rdpTls* tls);
FREERDP_API int tls_read(rdpTls* tls, BYTE* data, int length);
FREERDP_API int tls_write(rdpTls* tls, BYTE* data, int length);
FREERDP_API int tls_read_all(rdpTls* tls, BYTE* data, int length);
FREERDP_API int tls_write_all(rdpTls* tls, BYTE* data, int length);
FREERDP_API int tls_wait_read(rdpTls* tls);

View File

@ -568,22 +568,19 @@ typedef struct _RDPDR_PARALLEL RDPDR_PARALLEL;
#define FreeRDP_PreconnectionBlob 1155
#define FreeRDP_SendPreconnectionPdu 1156
#define FreeRDP_RedirectionFlags 1216
#define FreeRDP_LoadBalanceInfo 1217
#define FreeRDP_LoadBalanceInfoLength 1218
#define FreeRDP_RedirectionUsername 1219
#define FreeRDP_RedirectionUsernameLength 1220
#define FreeRDP_TargetNetAddress 1217
#define FreeRDP_LoadBalanceInfo 1218
#define FreeRDP_LoadBalanceInfoLength 1219
#define FreeRDP_RedirectionUsername 1220
#define FreeRDP_RedirectionDomain 1221
#define FreeRDP_RedirectionDomainLength 1222
#define FreeRDP_RedirectionPassword 1223
#define FreeRDP_RedirectionPasswordLength 1224
#define FreeRDP_RedirectionTargetFQDN 1225
#define FreeRDP_RedirectionTargetFQDNLength 1226
#define FreeRDP_RedirectionTargetNetBiosName 1227
#define FreeRDP_RedirectionTargetNetBiosNameLength 1228
#define FreeRDP_RedirectionTsvUrl 1229
#define FreeRDP_RedirectionTsvUrlLength 1230
#define FreeRDP_TargetNetAddressCount 1231
#define FreeRDP_TargetNetAddresses 1232
#define FreeRDP_RedirectionPassword 1222
#define FreeRDP_RedirectionPasswordLength 1223
#define FreeRDP_RedirectionTargetFQDN 1224
#define FreeRDP_RedirectionTargetNetBiosName 1225
#define FreeRDP_RedirectionTsvUrl 1226
#define FreeRDP_RedirectionTsvUrlLength 1227
#define FreeRDP_TargetNetAddressCount 1228
#define FreeRDP_TargetNetAddresses 1229
#define FreeRDP_Password51 1280
#define FreeRDP_Password51Length 1281
#define FreeRDP_KerberosKdc 1344
@ -922,23 +919,20 @@ struct rdp_settings
/* Server Redirection */
ALIGN64 UINT32 RedirectionFlags; /* 1216 */
ALIGN64 BYTE* LoadBalanceInfo; /* 1217 */
ALIGN64 UINT32 LoadBalanceInfoLength; /* 1218 */
ALIGN64 BYTE* RedirectionUsername; /* 1219 */
ALIGN64 UINT32 RedirectionUsernameLength; /* 1220 */
ALIGN64 BYTE* RedirectionDomain; /* 1221 */
ALIGN64 UINT32 RedirectionDomainLength; /* 1222 */
ALIGN64 BYTE* RedirectionPassword; /* 1223 */
ALIGN64 UINT32 RedirectionPasswordLength; /* 1224 */
ALIGN64 BYTE* RedirectionTargetFQDN; /* 1225 */
ALIGN64 UINT32 RedirectionTargetFQDNLength; /* 1226 */
ALIGN64 BYTE* RedirectionTargetNetBiosName; /* 1227 */
ALIGN64 UINT32 RedirectionTargetNetBiosNameLength; /* 1228 */
ALIGN64 BYTE* RedirectionTsvUrl; /* 1229 */
ALIGN64 UINT32 RedirectionTsvUrlLength; /* 1230 */
ALIGN64 UINT32 TargetNetAddressCount; /* 1231 */
ALIGN64 TARGET_NET_ADDRESS* TargetNetAddresses; /* 1232 */
UINT64 padding1280[1280 - 1233]; /* 1233 */
ALIGN64 char* TargetNetAddress; /* 1217 */
ALIGN64 BYTE* LoadBalanceInfo; /* 1218 */
ALIGN64 UINT32 LoadBalanceInfoLength; /* 1219 */
ALIGN64 char* RedirectionUsername; /* 1220 */
ALIGN64 char* RedirectionDomain; /* 1221 */
ALIGN64 BYTE* RedirectionPassword; /* 1222 */
ALIGN64 UINT32 RedirectionPasswordLength; /* 1223 */
ALIGN64 char* RedirectionTargetFQDN; /* 1224 */
ALIGN64 char* RedirectionTargetNetBiosName; /* 1225 */
ALIGN64 BYTE* RedirectionTsvUrl; /* 1226 */
ALIGN64 UINT32 RedirectionTsvUrlLength; /* 1227 */
ALIGN64 UINT32 TargetNetAddressCount; /* 1228 */
ALIGN64 char** TargetNetAddresses; /* 1229 */
UINT64 padding1280[1280 - 1230]; /* 1230 */
/**
* Security
@ -1331,6 +1325,8 @@ FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_collection_find(rdpSettings* set
FREERDP_API ADDIN_ARGV* freerdp_dynamic_channel_clone(ADDIN_ARGV* channel);
FREERDP_API void freerdp_dynamic_channel_collection_free(rdpSettings* settings);
FREERDP_API void freerdp_target_net_addresses_free(rdpSettings* settings);
FREERDP_API void freerdp_performance_flags_make(rdpSettings* settings);
FREERDP_API void freerdp_performance_flags_split(rdpSettings* settings);

View File

@ -60,7 +60,7 @@ if(MONOLITHIC_BUILD)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} ${PROFILER_LIBRARIES})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT FreeRDPTargets)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")
endif()

View File

@ -43,7 +43,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -58,8 +58,10 @@ void update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
bitmap = offscreen_cache_get(cache->offscreen, mem3blt->cacheIndex);
else
bitmap = bitmap_cache_get(cache->bitmap, (BYTE) mem3blt->cacheId, mem3blt->cacheIndex);
/* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */
if (bitmap == NULL) return;
if (!bitmap)
return;
style = brush->style;
@ -74,7 +76,7 @@ void update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
brush->style = style;
}
void update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitmap)
void update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitmap)
{
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
@ -82,24 +84,24 @@ void update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitm
bitmap = Bitmap_Alloc(context);
Bitmap_SetDimensions(context, bitmap, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight);
Bitmap_SetDimensions(context, bitmap, cacheBitmap->bitmapWidth, cacheBitmap->bitmapHeight);
bitmap->Decompress(context, bitmap,
cache_bitmap->bitmapDataStream, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight,
cache_bitmap->bitmapBpp, cache_bitmap->bitmapLength,
cache_bitmap->compressed, RDP_CODEC_ID_NONE);
cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth, cacheBitmap->bitmapHeight,
cacheBitmap->bitmapBpp, cacheBitmap->bitmapLength,
cacheBitmap->compressed, RDP_CODEC_ID_NONE);
bitmap->New(context, bitmap);
prevBitmap = bitmap_cache_get(cache->bitmap, cache_bitmap->cacheId, cache_bitmap->cacheIndex);
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex);
if (prevBitmap != NULL)
Bitmap_Free(context, prevBitmap);
bitmap_cache_put(cache->bitmap, cache_bitmap->cacheId, cache_bitmap->cacheIndex, bitmap);
bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex, bitmap);
}
void update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
void update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
{
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
@ -107,44 +109,44 @@ void update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cach
bitmap = Bitmap_Alloc(context);
Bitmap_SetDimensions(context, bitmap, cache_bitmap_v2->bitmapWidth, cache_bitmap_v2->bitmapHeight);
Bitmap_SetDimensions(context, bitmap, cacheBitmapV2->bitmapWidth, cacheBitmapV2->bitmapHeight);
if (cache_bitmap_v2->bitmapBpp == 0)
if (cacheBitmapV2->bitmapBpp == 0)
{
/* Workaround for Windows 8 bug where bitmapBpp is not set */
cache_bitmap_v2->bitmapBpp = context->instance->settings->ColorDepth;
cacheBitmapV2->bitmapBpp = context->instance->settings->ColorDepth;
}
bitmap->Decompress(context, bitmap,
cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapWidth, cache_bitmap_v2->bitmapHeight,
cache_bitmap_v2->bitmapBpp, cache_bitmap_v2->bitmapLength,
cache_bitmap_v2->compressed, RDP_CODEC_ID_NONE);
cacheBitmapV2->bitmapDataStream, cacheBitmapV2->bitmapWidth, cacheBitmapV2->bitmapHeight,
cacheBitmapV2->bitmapBpp, cacheBitmapV2->bitmapLength,
cacheBitmapV2->compressed, RDP_CODEC_ID_NONE);
bitmap->New(context, bitmap);
prevBitmap = bitmap_cache_get(cache->bitmap, cache_bitmap_v2->cacheId, cache_bitmap_v2->cacheIndex);
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV2->cacheId, cacheBitmapV2->cacheIndex);
if (prevBitmap != NULL)
Bitmap_Free(context, prevBitmap);
bitmap_cache_put(cache->bitmap, cache_bitmap_v2->cacheId, cache_bitmap_v2->cacheIndex, bitmap);
bitmap_cache_put(cache->bitmap, cacheBitmapV2->cacheId, cacheBitmapV2->cacheIndex, bitmap);
}
void update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
void update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
{
rdpBitmap* bitmap;
rdpBitmap* prevBitmap;
rdpCache* cache = context->cache;
BITMAP_DATA_EX* bitmapData = &cache_bitmap_v3->bitmapData;
BITMAP_DATA_EX* bitmapData = &cacheBitmapV3->bitmapData;
bitmap = Bitmap_Alloc(context);
Bitmap_SetDimensions(context, bitmap, bitmapData->width, bitmapData->height);
if (cache_bitmap_v3->bitmapData.bpp == 0)
if (cacheBitmapV3->bitmapData.bpp == 0)
{
/* Workaround for Windows 8 bug where bitmapBpp is not set */
cache_bitmap_v3->bitmapData.bpp = context->instance->settings->ColorDepth;
cacheBitmapV3->bitmapData.bpp = context->instance->settings->ColorDepth;
}
bitmap->Decompress(context, bitmap,
@ -154,15 +156,15 @@ void update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cach
bitmap->New(context, bitmap);
prevBitmap = bitmap_cache_get(cache->bitmap, cache_bitmap_v3->cacheId, cache_bitmap_v3->cacheIndex);
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV3->cacheId, cacheBitmapV3->cacheIndex);
if (prevBitmap != NULL)
Bitmap_Free(context, prevBitmap);
bitmap_cache_put(cache->bitmap, cache_bitmap_v3->cacheId, cache_bitmap_v3->cacheIndex, bitmap);
bitmap_cache_put(cache->bitmap, cacheBitmapV3->cacheId, cacheBitmapV3->cacheIndex, bitmap);
}
void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap_update)
void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
{
int i;
rdpBitmap* bitmap;
@ -170,7 +172,7 @@ void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap_update)
BOOL reused = TRUE;
rdpCache* cache = context->cache;
if (cache->bitmap->bitmap == NULL)
if (!cache->bitmap->bitmap)
{
cache->bitmap->bitmap = Bitmap_Alloc(context);
cache->bitmap->bitmap->ephemeral = TRUE;
@ -179,9 +181,9 @@ void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap_update)
bitmap = cache->bitmap->bitmap;
for (i = 0; i < (int) bitmap_update->number; i++)
for (i = 0; i < (int) bitmapUpdate->number; i++)
{
bitmap_data = &bitmap_update->rectangles[i];
bitmap_data = &bitmapUpdate->rectangles[i];
bitmap->bpp = bitmap_data->bitsPerPixel;
bitmap->length = bitmap_data->bitmapLength;
@ -209,11 +211,11 @@ void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap_update)
}
}
rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index)
rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index)
{
rdpBitmap* bitmap;
if (id > bitmap_cache->maxCells)
if (id > bitmapCache->maxCells)
{
fprintf(stderr, "get invalid bitmap cell id: %d\n", id);
return NULL;
@ -221,22 +223,22 @@ rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 inde
if (index == BITMAP_CACHE_WAITING_LIST_INDEX)
{
index = bitmap_cache->cells[id].number;
index = bitmapCache->cells[id].number;
}
else if (index > bitmap_cache->cells[id].number)
else if (index > bitmapCache->cells[id].number)
{
fprintf(stderr, "get invalid bitmap index %d in cell id: %d\n", index, id);
return NULL;
}
bitmap = bitmap_cache->cells[id].entries[index];
bitmap = bitmapCache->cells[id].entries[index];
return bitmap;
}
void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index, rdpBitmap* bitmap)
void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index, rdpBitmap* bitmap)
{
if (id > bitmap_cache->maxCells)
if (id > bitmapCache->maxCells)
{
fprintf(stderr, "put invalid bitmap cell id: %d\n", id);
return;
@ -244,15 +246,15 @@ void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id, UINT32 index, rdp
if (index == BITMAP_CACHE_WAITING_LIST_INDEX)
{
index = bitmap_cache->cells[id].number;
index = bitmapCache->cells[id].number;
}
else if (index > bitmap_cache->cells[id].number)
else if (index > bitmapCache->cells[id].number)
{
fprintf(stderr, "put invalid bitmap index %d in cell id: %d\n", index, id);
return;
}
bitmap_cache->cells[id].entries[index] = bitmap;
bitmapCache->cells[id].entries[index] = bitmap;
}
void bitmap_cache_register_callbacks(rdpUpdate* update)
@ -275,60 +277,61 @@ void bitmap_cache_register_callbacks(rdpUpdate* update)
rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
{
int i;
rdpBitmapCache* bitmap_cache;
rdpBitmapCache* bitmapCache;
bitmap_cache = (rdpBitmapCache*) malloc(sizeof(rdpBitmapCache));
ZeroMemory(bitmap_cache, sizeof(rdpBitmapCache));
bitmapCache = (rdpBitmapCache*) malloc(sizeof(rdpBitmapCache));
if (bitmap_cache != NULL)
if (bitmapCache)
{
bitmap_cache->settings = settings;
bitmap_cache->update = ((freerdp*) settings->instance)->update;
bitmap_cache->context = bitmap_cache->update->context;
ZeroMemory(bitmapCache, sizeof(rdpBitmapCache));
bitmap_cache->maxCells = settings->BitmapCacheV2NumCells;
bitmapCache->settings = settings;
bitmapCache->update = ((freerdp*) settings->instance)->update;
bitmapCache->context = bitmapCache->update->context;
bitmap_cache->cells = (BITMAP_V2_CELL*) malloc(sizeof(BITMAP_V2_CELL) * bitmap_cache->maxCells);
ZeroMemory(bitmap_cache->cells, sizeof(BITMAP_V2_CELL) * bitmap_cache->maxCells);
bitmapCache->maxCells = settings->BitmapCacheV2NumCells;
for (i = 0; i < (int) bitmap_cache->maxCells; i++)
bitmapCache->cells = (BITMAP_V2_CELL*) malloc(sizeof(BITMAP_V2_CELL) * bitmapCache->maxCells);
ZeroMemory(bitmapCache->cells, sizeof(BITMAP_V2_CELL) * bitmapCache->maxCells);
for (i = 0; i < (int) bitmapCache->maxCells; i++)
{
bitmap_cache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries;
bitmapCache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries;
/* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */
bitmap_cache->cells[i].entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * (bitmap_cache->cells[i].number + 1));
ZeroMemory(bitmap_cache->cells[i].entries, sizeof(rdpBitmap*) * (bitmap_cache->cells[i].number + 1));
bitmapCache->cells[i].entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * (bitmapCache->cells[i].number + 1));
ZeroMemory(bitmapCache->cells[i].entries, sizeof(rdpBitmap*) * (bitmapCache->cells[i].number + 1));
}
}
return bitmap_cache;
return bitmapCache;
}
void bitmap_cache_free(rdpBitmapCache* bitmap_cache)
void bitmap_cache_free(rdpBitmapCache* bitmapCache)
{
int i, j;
rdpBitmap* bitmap;
if (bitmap_cache != NULL)
if (bitmapCache != NULL)
{
for (i = 0; i < (int) bitmap_cache->maxCells; i++)
for (i = 0; i < (int) bitmapCache->maxCells; i++)
{
for (j = 0; j < (int) bitmap_cache->cells[i].number + 1; j++)
for (j = 0; j < (int) bitmapCache->cells[i].number + 1; j++)
{
bitmap = bitmap_cache->cells[i].entries[j];
bitmap = bitmapCache->cells[i].entries[j];
if (bitmap != NULL)
{
Bitmap_Free(bitmap_cache->context, bitmap);
Bitmap_Free(bitmapCache->context, bitmap);
}
}
free(bitmap_cache->cells[i].entries);
free(bitmapCache->cells[i].entries);
}
if (bitmap_cache->bitmap != NULL)
Bitmap_Free(bitmap_cache->context, bitmap_cache->bitmap);
if (bitmapCache->bitmap)
Bitmap_Free(bitmapCache->context, bitmapCache->bitmap);
free(bitmap_cache->cells);
free(bitmap_cache);
free(bitmapCache->cells);
free(bitmapCache);
}
}

View File

@ -73,48 +73,48 @@ void update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
brush->style = style;
}
static void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
static void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cacheBrush)
{
int length;
void* data = NULL;
rdpCache* cache = context->cache;
length = cache_brush->bpp * 64 / 8;
length = cacheBrush->bpp * 64 / 8;
data = malloc(length);
CopyMemory(data, cache_brush->data, length);
CopyMemory(data, cacheBrush->data, length);
brush_cache_put(cache->brush, cache_brush->index, data, cache_brush->bpp);
brush_cache_put(cache->brush, cacheBrush->index, data, cacheBrush->bpp);
}
void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
void* brush_cache_get(rdpBrushCache* brushCache, UINT32 index, UINT32* bpp)
{
void* entry;
assert(brush);
assert(brushCache);
assert(bpp);
if (*bpp == 1)
{
if (index >= brush->maxMonoEntries)
if (index >= brushCache->maxMonoEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", *bpp, index);
return NULL;
}
*bpp = brush->monoEntries[index].bpp;
entry = brush->monoEntries[index].entry;
*bpp = brushCache->monoEntries[index].bpp;
entry = brushCache->monoEntries[index].entry;
}
else
{
if (index >= brush->maxEntries)
if (index >= brushCache->maxEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", *bpp, index);
return NULL;
}
*bpp = brush->entries[index].bpp;
entry = brush->entries[index].entry;
*bpp = brushCache->entries[index].bpp;
entry = brushCache->entries[index].entry;
}
if (entry == NULL)
@ -126,45 +126,49 @@ void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
return entry;
}
void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp)
void brush_cache_put(rdpBrushCache* brushCache, UINT32 index, void* entry, UINT32 bpp)
{
void* prevEntry;
if (bpp == 1)
{
if (index >= brush->maxMonoEntries)
if (index >= brushCache->maxMonoEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}
prevEntry = brush->monoEntries[index].entry;
prevEntry = brushCache->monoEntries[index].entry;
if (prevEntry != NULL)
free(prevEntry);
brush->monoEntries[index].bpp = bpp;
brush->monoEntries[index].entry = entry;
brushCache->monoEntries[index].bpp = bpp;
brushCache->monoEntries[index].entry = entry;
}
else
{
if (index >= brush->maxEntries)
if (index >= brushCache->maxEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}
prevEntry = brush->entries[index].entry;
prevEntry = brushCache->entries[index].entry;
if (prevEntry != NULL)
free(prevEntry);
brush->entries[index].bpp = bpp;
brush->entries[index].entry = entry;
brushCache->entries[index].bpp = bpp;
brushCache->entries[index].entry = entry;
}
}
@ -184,56 +188,57 @@ void brush_cache_register_callbacks(rdpUpdate* update)
rdpBrushCache* brush_cache_new(rdpSettings* settings)
{
rdpBrushCache* brush;
rdpBrushCache* brushCache;
brush = (rdpBrushCache*) malloc(sizeof(rdpBrushCache));
ZeroMemory(brush, sizeof(rdpBrushCache));
brushCache = (rdpBrushCache*) malloc(sizeof(rdpBrushCache));
if (brush != NULL)
if (brushCache)
{
brush->settings = settings;
ZeroMemory(brushCache, sizeof(rdpBrushCache));
brush->maxEntries = 64;
brush->maxMonoEntries = 64;
brushCache->settings = settings;
brush->entries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brush->maxEntries);
ZeroMemory(brush->entries, sizeof(BRUSH_ENTRY) * brush->maxEntries);
brushCache->maxEntries = 64;
brushCache->maxMonoEntries = 64;
brush->monoEntries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brush->maxMonoEntries);
ZeroMemory(brush->monoEntries, sizeof(BRUSH_ENTRY) * brush->maxMonoEntries);
brushCache->entries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brushCache->maxEntries);
ZeroMemory(brushCache->entries, sizeof(BRUSH_ENTRY) * brushCache->maxEntries);
brushCache->monoEntries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brushCache->maxMonoEntries);
ZeroMemory(brushCache->monoEntries, sizeof(BRUSH_ENTRY) * brushCache->maxMonoEntries);
}
return brush;
return brushCache;
}
void brush_cache_free(rdpBrushCache* brush)
void brush_cache_free(rdpBrushCache* brushCache)
{
int i;
if (brush != NULL)
if (brushCache)
{
if (brush->entries != NULL)
if (brushCache->entries)
{
for (i = 0; i < (int) brush->maxEntries; i++)
for (i = 0; i < (int) brushCache->maxEntries; i++)
{
if (brush->entries[i].entry != NULL)
free(brush->entries[i].entry);
if (brushCache->entries[i].entry != NULL)
free(brushCache->entries[i].entry);
}
free(brush->entries);
free(brushCache->entries);
}
if (brush->monoEntries != NULL)
if (brushCache->monoEntries)
{
for (i = 0; i < (int) brush->maxMonoEntries; i++)
for (i = 0; i < (int) brushCache->maxMonoEntries; i++)
{
if (brush->monoEntries[i].entry != NULL)
free(brush->monoEntries[i].entry);
if (brushCache->monoEntries[i].entry != NULL)
free(brushCache->monoEntries[i].entry);
}
free(brush->monoEntries);
free(brushCache->monoEntries);
}
free(brush);
free(brushCache);
}
}

View File

@ -170,22 +170,22 @@ void update_process_glyph_fragments(rdpContext* context, BYTE* data, UINT32 leng
Glyph_EndDraw(context, bkX, bkY, bkWidth, bkHeight, bgcolor, fgcolor);
}
void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index)
void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex)
{
rdpGlyphCache* glyph_cache;
glyph_cache = context->cache->glyph;
update_process_glyph_fragments(context, glyph_index->data, glyph_index->cbData,
glyph_index->cacheId, glyph_index->ulCharInc, glyph_index->flAccel,
glyph_index->backColor, glyph_index->foreColor, glyph_index->x, glyph_index->y,
glyph_index->bkLeft, glyph_index->bkTop,
glyph_index->bkRight - glyph_index->bkLeft, glyph_index->bkBottom - glyph_index->bkTop,
glyph_index->opLeft, glyph_index->opTop,
glyph_index->opRight - glyph_index->opLeft, glyph_index->opBottom - glyph_index->opTop);
update_process_glyph_fragments(context, glyphIndex->data, glyphIndex->cbData,
glyphIndex->cacheId, glyphIndex->ulCharInc, glyphIndex->flAccel,
glyphIndex->backColor, glyphIndex->foreColor, glyphIndex->x, glyphIndex->y,
glyphIndex->bkLeft, glyphIndex->bkTop,
glyphIndex->bkRight - glyphIndex->bkLeft, glyphIndex->bkBottom - glyphIndex->bkTop,
glyphIndex->opLeft, glyphIndex->opTop,
glyphIndex->opRight - glyphIndex->opLeft, glyphIndex->opBottom - glyphIndex->opTop);
}
void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index)
void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fastIndex)
{
INT32 x, y;
INT32 opLeft, opTop;
@ -194,131 +194,131 @@ void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index)
glyph_cache = context->cache->glyph;
opLeft = fast_index->opLeft;
opTop = fast_index->opTop;
opRight = fast_index->opRight;
opBottom = fast_index->opBottom;
x = fast_index->x;
y = fast_index->y;
opLeft = fastIndex->opLeft;
opTop = fastIndex->opTop;
opRight = fastIndex->opRight;
opBottom = fastIndex->opBottom;
x = fastIndex->x;
y = fastIndex->y;
if (opBottom == -32768)
{
BYTE flags = (BYTE) (opTop & 0x0F);
if (flags & 0x01)
opBottom = fast_index->bkBottom;
opBottom = fastIndex->bkBottom;
if (flags & 0x02)
opRight = fast_index->bkRight;
opRight = fastIndex->bkRight;
if (flags & 0x04)
opTop = fast_index->bkTop;
opTop = fastIndex->bkTop;
if (flags & 0x08)
opLeft = fast_index->bkLeft;
opLeft = fastIndex->bkLeft;
}
if (opLeft == 0)
opLeft = fast_index->bkLeft;
opLeft = fastIndex->bkLeft;
if (opRight == 0)
opRight = fast_index->bkRight;
opRight = fastIndex->bkRight;
if (x == -32768)
x = fast_index->bkLeft;
x = fastIndex->bkLeft;
if (y == -32768)
y = fast_index->bkTop;
y = fastIndex->bkTop;
update_process_glyph_fragments(context, fast_index->data, fast_index->cbData,
fast_index->cacheId, fast_index->ulCharInc, fast_index->flAccel,
fast_index->backColor, fast_index->foreColor, x, y,
fast_index->bkLeft, fast_index->bkTop,
fast_index->bkRight - fast_index->bkLeft, fast_index->bkBottom - fast_index->bkTop,
update_process_glyph_fragments(context, fastIndex->data, fastIndex->cbData,
fastIndex->cacheId, fastIndex->ulCharInc, fastIndex->flAccel,
fastIndex->backColor, fastIndex->foreColor, x, y,
fastIndex->bkLeft, fastIndex->bkTop,
fastIndex->bkRight - fastIndex->bkLeft, fastIndex->bkBottom - fastIndex->bkTop,
opLeft, opTop,
opRight - opLeft, opBottom - opTop);
}
void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph)
void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fastGlyph)
{
INT32 x, y;
rdpGlyph* glyph;
BYTE text_data[2];
INT32 opLeft, opTop;
INT32 opRight, opBottom;
GLYPH_DATA_V2* glyph_data;
GLYPH_DATA_V2* glyphData;
rdpCache* cache = context->cache;
opLeft = fast_glyph->opLeft;
opTop = fast_glyph->opTop;
opRight = fast_glyph->opRight;
opBottom = fast_glyph->opBottom;
x = fast_glyph->x;
y = fast_glyph->y;
opLeft = fastGlyph->opLeft;
opTop = fastGlyph->opTop;
opRight = fastGlyph->opRight;
opBottom = fastGlyph->opBottom;
x = fastGlyph->x;
y = fastGlyph->y;
if (opBottom == -32768)
{
BYTE flags = (BYTE) (opTop & 0x0F);
if (flags & 0x01)
opBottom = fast_glyph->bkBottom;
opBottom = fastGlyph->bkBottom;
if (flags & 0x02)
opRight = fast_glyph->bkRight;
opRight = fastGlyph->bkRight;
if (flags & 0x04)
opTop = fast_glyph->bkTop;
opTop = fastGlyph->bkTop;
if (flags & 0x08)
opLeft = fast_glyph->bkLeft;
opLeft = fastGlyph->bkLeft;
}
if (opLeft == 0)
opLeft = fast_glyph->bkLeft;
opLeft = fastGlyph->bkLeft;
if (opRight == 0)
opRight = fast_glyph->bkRight;
opRight = fastGlyph->bkRight;
if (x == -32768)
x = fast_glyph->bkLeft;
x = fastGlyph->bkLeft;
if (y == -32768)
y = fast_glyph->bkTop;
y = fastGlyph->bkTop;
if (fast_glyph->cbData > 1 && NULL != fast_glyph->glyphData.aj)
if ((fastGlyph->cbData > 1) && (fastGlyph->glyphData.aj))
{
/* got option font that needs to go into cache */
glyph_data = &fast_glyph->glyphData;
glyphData = &fastGlyph->glyphData;
glyph = Glyph_Alloc(context);
glyph->x = glyph_data->x;
glyph->y = glyph_data->y;
glyph->cx = glyph_data->cx;
glyph->cy = glyph_data->cy;
glyph->cb = glyph_data->cb;
glyph->aj = malloc(glyph_data->cb);
CopyMemory(glyph->aj, glyph_data->aj, glyph->cb);
glyph->x = glyphData->x;
glyph->y = glyphData->y;
glyph->cx = glyphData->cx;
glyph->cy = glyphData->cy;
glyph->cb = glyphData->cb;
glyph->aj = malloc(glyphData->cb);
CopyMemory(glyph->aj, glyphData->aj, glyph->cb);
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph);
glyph_cache_put(cache->glyph, fastGlyph->cacheId, fastGlyph->data[0], glyph);
}
text_data[0] = fast_glyph->data[0];
text_data[0] = fastGlyph->data[0];
text_data[1] = 0;
update_process_glyph_fragments(context, text_data, 1,
fast_glyph->cacheId, fast_glyph->ulCharInc, fast_glyph->flAccel,
fast_glyph->backColor, fast_glyph->foreColor, x, y,
fast_glyph->bkLeft, fast_glyph->bkTop,
fast_glyph->bkRight - fast_glyph->bkLeft, fast_glyph->bkBottom - fast_glyph->bkTop,
fastGlyph->cacheId, fastGlyph->ulCharInc, fastGlyph->flAccel,
fastGlyph->backColor, fastGlyph->foreColor, x, y,
fastGlyph->bkLeft, fastGlyph->bkTop,
fastGlyph->bkRight - fastGlyph->bkLeft, fastGlyph->bkBottom - fastGlyph->bkTop,
opLeft, opTop,
opRight - opLeft, opBottom - opTop);
}
void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyph)
{
int i;
rdpGlyph* glyph;
GLYPH_DATA* glyph_data;
rdpCache* cache = context->cache;
for (i = 0; i < (int) cache_glyph->cGlyphs; i++)
for (i = 0; i < (int) cacheGlyph->cGlyphs; i++)
{
glyph_data = &cache_glyph->glyphData[i];
glyph_data = &cacheGlyph->glyphData[i];
glyph = Glyph_Alloc(context);
@ -330,60 +330,62 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
glyph->aj = glyph_data->aj;
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, glyph);
glyph_cache_put(cache->glyph, cacheGlyph->cacheId, glyph_data->cacheIndex, glyph);
}
}
void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cacheGlyphV2)
{
int i;
rdpGlyph* glyph;
GLYPH_DATA_V2* glyph_data;
GLYPH_DATA_V2* glyphData;
rdpCache* cache = context->cache;
for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
for (i = 0; i < (int) cacheGlyphV2->cGlyphs; i++)
{
glyph_data = &cache_glyph_v2->glyphData[i];
glyphData = &cacheGlyphV2->glyphData[i];
glyph = Glyph_Alloc(context);
glyph->x = glyph_data->x;
glyph->y = glyph_data->y;
glyph->cx = glyph_data->cx;
glyph->cy = glyph_data->cy;
glyph->cb = glyph_data->cb;
glyph->aj = glyph_data->aj;
glyph->x = glyphData->x;
glyph->y = glyphData->y;
glyph->cx = glyphData->cx;
glyph->cy = glyphData->cy;
glyph->cb = glyphData->cb;
glyph->aj = glyphData->aj;
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph);
glyph_cache_put(cache->glyph, cacheGlyphV2->cacheId, glyphData->cacheIndex, glyph);
}
}
rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index)
rdpGlyph* glyph_cache_get(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index)
{
rdpGlyph* glyph;
WLog_Print(glyphCache->log, WLOG_DEBUG, "GlyphCacheGet: id: %d index: %d", id, index);
if (id > 9)
{
fprintf(stderr, "invalid glyph cache id: %d\n", id);
return NULL;
}
if (index > glyph_cache->glyphCache[id].number)
if (index > glyphCache->glyphCache[id].number)
{
fprintf(stderr, "index %d out of range for cache id: %d\n", index, id);
return NULL;
}
glyph = glyph_cache->glyphCache[id].entries[index];
glyph = glyphCache->glyphCache[id].entries[index];
if (glyph == NULL)
if (!glyph)
fprintf(stderr, "no glyph found at cache index: %d in cache id: %d\n", index, id);
return glyph;
}
void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGlyph* glyph)
void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyph* glyph)
{
rdpGlyph* prevGlyph;
@ -393,48 +395,67 @@ void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGly
return;
}
if (index > glyph_cache->glyphCache[id].number)
if (index > glyphCache->glyphCache[id].number)
{
fprintf(stderr, "invalid glyph cache index: %d in cache id: %d\n", index, id);
return;
}
prevGlyph = glyph_cache->glyphCache[id].entries[index];
WLog_Print(glyphCache->log, WLOG_DEBUG, "GlyphCachePut: id: %d index: %d", id, index);
if (prevGlyph != NULL)
prevGlyph = glyphCache->glyphCache[id].entries[index];
if (prevGlyph)
{
Glyph_Free(glyph_cache->context, prevGlyph);
if (NULL != prevGlyph->aj)
Glyph_Free(glyphCache->context, prevGlyph);
if (prevGlyph->aj)
free(prevGlyph->aj);
free(prevGlyph);
}
glyph_cache->glyphCache[id].entries[index] = glyph;
glyphCache->glyphCache[id].entries[index] = glyph;
}
void* glyph_cache_fragment_get(rdpGlyphCache* glyph_cache, UINT32 index, UINT32* size)
void* glyph_cache_fragment_get(rdpGlyphCache* glyphCache, UINT32 index, UINT32* size)
{
void* fragment;
fragment = glyph_cache->fragCache.entries[index].fragment;
*size = (BYTE) glyph_cache->fragCache.entries[index].size;
if (index > 255)
{
fprintf(stderr, "invalid glyph cache fragment index: %d\n", index);
return NULL;
}
if (fragment == NULL)
fragment = glyphCache->fragCache.entries[index].fragment;
*size = (BYTE) glyphCache->fragCache.entries[index].size;
WLog_Print(glyphCache->log, WLOG_DEBUG, "GlyphCacheFragmentGet: index: %d size: %d", index, *size);
if (!fragment)
fprintf(stderr, "invalid glyph fragment at index:%d\n", index);
return fragment;
}
void glyph_cache_fragment_put(rdpGlyphCache* glyph_cache, UINT32 index, UINT32 size, void* fragment)
void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index, UINT32 size, void* fragment)
{
void* prevFragment;
prevFragment = glyph_cache->fragCache.entries[index].fragment;
if (index > 255)
{
fprintf(stderr, "invalid glyph cache fragment index: %d\n", index);
return;
}
glyph_cache->fragCache.entries[index].fragment = fragment;
glyph_cache->fragCache.entries[index].size = size;
WLog_Print(glyphCache->log, WLOG_DEBUG, "GlyphCacheFragmentPut: index: %d size: %d", index, size);
if (prevFragment != NULL)
prevFragment = glyphCache->fragCache.entries[index].fragment;
glyphCache->fragCache.entries[index].fragment = fragment;
glyphCache->fragCache.entries[index].size = size;
if (!prevFragment)
free(prevFragment);
}
@ -449,36 +470,40 @@ void glyph_cache_register_callbacks(rdpUpdate* update)
rdpGlyphCache* glyph_cache_new(rdpSettings* settings)
{
rdpGlyphCache* glyph;
rdpGlyphCache* glyphCache;
glyph = (rdpGlyphCache*) malloc(sizeof(rdpGlyphCache));
ZeroMemory(glyph, sizeof(rdpGlyphCache));
glyphCache = (rdpGlyphCache*) malloc(sizeof(rdpGlyphCache));
if (glyph != NULL)
if (glyphCache)
{
int i;
glyph->settings = settings;
glyph->context = ((freerdp*) settings->instance)->update->context;
ZeroMemory(glyphCache, sizeof(rdpGlyphCache));
WLog_Init();
glyphCache->log = WLog_Get("com.freerdp.cache.glyph");
glyphCache->settings = settings;
glyphCache->context = ((freerdp*) settings->instance)->update->context;
for (i = 0; i < 10; i++)
{
glyph->glyphCache[i].number = settings->GlyphCache[i].cacheEntries;
glyph->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize;
glyph->glyphCache[i].entries = (rdpGlyph**) malloc(sizeof(rdpGlyph*) * glyph->glyphCache[i].number);
ZeroMemory(glyph->glyphCache[i].entries, sizeof(rdpGlyph*) * glyph->glyphCache[i].number);
glyphCache->glyphCache[i].number = settings->GlyphCache[i].cacheEntries;
glyphCache->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize;
glyphCache->glyphCache[i].entries = (rdpGlyph**) malloc(sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number);
ZeroMemory(glyphCache->glyphCache[i].entries, sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number);
}
glyph->fragCache.entries = malloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256);
ZeroMemory(glyph->fragCache.entries, sizeof(FRAGMENT_CACHE_ENTRY) * 256);
glyphCache->fragCache.entries = malloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256);
ZeroMemory(glyphCache->fragCache.entries, sizeof(FRAGMENT_CACHE_ENTRY) * 256);
}
return glyph;
return glyphCache;
}
void glyph_cache_free(rdpGlyphCache* glyph_cache)
void glyph_cache_free(rdpGlyphCache* glyphCache)
{
if (glyph_cache != NULL)
if (glyphCache)
{
int i;
void* fragment;
@ -487,33 +512,35 @@ void glyph_cache_free(rdpGlyphCache* glyph_cache)
{
int j;
for (j = 0; j < (int) glyph_cache->glyphCache[i].number; j++)
for (j = 0; j < (int) glyphCache->glyphCache[i].number; j++)
{
rdpGlyph* glyph;
glyph = glyph_cache->glyphCache[i].entries[j];
glyph = glyphCache->glyphCache[i].entries[j];
if (glyph != NULL)
if (glyph)
{
Glyph_Free(glyph_cache->context, glyph);
Glyph_Free(glyphCache->context, glyph);
if (glyph->aj)
free(glyph->aj);
free(glyph);
glyph_cache->glyphCache[i].entries[j] = NULL;
glyphCache->glyphCache[i].entries[j] = NULL;
}
}
free(glyph_cache->glyphCache[i].entries);
glyph_cache->glyphCache[i].entries = NULL;
free(glyphCache->glyphCache[i].entries);
glyphCache->glyphCache[i].entries = NULL;
}
for (i = 0; i < 255; i++)
{
fragment = glyph_cache->fragCache.entries[i].fragment;
fragment = glyphCache->fragCache.entries[i].fragment;
free(fragment);
glyph_cache->fragCache.entries[i].fragment = NULL;
glyphCache->fragCache.entries[i].fragment = NULL;
}
free(glyph_cache->fragCache.entries);
free(glyph_cache);
free(glyphCache->fragCache.entries);
free(glyphCache);
}
}

View File

@ -29,7 +29,7 @@
#include <freerdp/cache/offscreen.h>
void update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
void update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
{
int i;
UINT16 index;
@ -38,55 +38,55 @@ void update_gdi_create_offscreen_bitmap(rdpContext* context, CREATE_OFFSCREEN_BI
bitmap = Bitmap_Alloc(context);
bitmap->width = create_offscreen_bitmap->cx;
bitmap->height = create_offscreen_bitmap->cy;
bitmap->width = createOffscreenBitmap->cx;
bitmap->height = createOffscreenBitmap->cy;
bitmap->New(context, bitmap);
offscreen_cache_delete(cache->offscreen, create_offscreen_bitmap->id);
offscreen_cache_put(cache->offscreen, create_offscreen_bitmap->id, bitmap);
offscreen_cache_delete(cache->offscreen, createOffscreenBitmap->id);
offscreen_cache_put(cache->offscreen, createOffscreenBitmap->id, bitmap);
if(cache->offscreen->currentSurface == create_offscreen_bitmap->id)
if(cache->offscreen->currentSurface == createOffscreenBitmap->id)
Bitmap_SetSurface(context, bitmap, FALSE);
for (i = 0; i < (int) create_offscreen_bitmap->deleteList.cIndices; i++)
for (i = 0; i < (int) createOffscreenBitmap->deleteList.cIndices; i++)
{
index = create_offscreen_bitmap->deleteList.indices[i];
index = createOffscreenBitmap->deleteList.indices[i];
offscreen_cache_delete(cache->offscreen, index);
}
}
void update_gdi_switch_surface(rdpContext* context, SWITCH_SURFACE_ORDER* switch_surface)
void update_gdi_switch_surface(rdpContext* context, SWITCH_SURFACE_ORDER* switchSurface)
{
rdpCache* cache = context->cache;
if (switch_surface->bitmapId == SCREEN_BITMAP_SURFACE)
if (switchSurface->bitmapId == SCREEN_BITMAP_SURFACE)
{
Bitmap_SetSurface(context, NULL, TRUE);
}
else
{
rdpBitmap* bitmap;
bitmap = offscreen_cache_get(cache->offscreen, switch_surface->bitmapId);
bitmap = offscreen_cache_get(cache->offscreen, switchSurface->bitmapId);
Bitmap_SetSurface(context, bitmap, FALSE);
}
cache->offscreen->currentSurface = switch_surface->bitmapId;
cache->offscreen->currentSurface = switchSurface->bitmapId;
}
rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreen_cache, UINT32 index)
rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreenCache, UINT32 index)
{
rdpBitmap* bitmap;
if (index >= offscreen_cache->maxEntries)
if (index >= offscreenCache->maxEntries)
{
fprintf(stderr, "invalid offscreen bitmap index: 0x%04X\n", index);
return NULL;
}
bitmap = offscreen_cache->entries[index];
bitmap = offscreenCache->entries[index];
if (bitmap == NULL)
if (!bitmap)
{
fprintf(stderr, "invalid offscreen bitmap at index: 0x%04X\n", index);
return NULL;
@ -95,34 +95,34 @@ rdpBitmap* offscreen_cache_get(rdpOffscreenCache* offscreen_cache, UINT32 index)
return bitmap;
}
void offscreen_cache_put(rdpOffscreenCache* offscreen, UINT32 index, rdpBitmap* bitmap)
void offscreen_cache_put(rdpOffscreenCache* offscreenCache, UINT32 index, rdpBitmap* bitmap)
{
if (index >= offscreen->maxEntries)
if (index >= offscreenCache->maxEntries)
{
fprintf(stderr, "invalid offscreen bitmap index: 0x%04X\n", index);
return;
}
offscreen_cache_delete(offscreen, index);
offscreen->entries[index] = bitmap;
offscreen_cache_delete(offscreenCache, index);
offscreenCache->entries[index] = bitmap;
}
void offscreen_cache_delete(rdpOffscreenCache* offscreen, UINT32 index)
void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index)
{
rdpBitmap* prevBitmap;
if (index >= offscreen->maxEntries)
if (index >= offscreenCache->maxEntries)
{
fprintf(stderr, "invalid offscreen bitmap index (delete): 0x%04X\n", index);
return;
}
prevBitmap = offscreen->entries[index];
prevBitmap = offscreenCache->entries[index];
if (prevBitmap != NULL)
Bitmap_Free(offscreen->update->context, prevBitmap);
Bitmap_Free(offscreenCache->update->context, prevBitmap);
offscreen->entries[index] = NULL;
offscreenCache->entries[index] = NULL;
}
void offscreen_cache_register_callbacks(rdpUpdate* update)
@ -133,46 +133,47 @@ void offscreen_cache_register_callbacks(rdpUpdate* update)
rdpOffscreenCache* offscreen_cache_new(rdpSettings* settings)
{
rdpOffscreenCache* offscreen_cache;
rdpOffscreenCache* offscreenCache;
offscreen_cache = (rdpOffscreenCache*) malloc(sizeof(rdpOffscreenCache));
ZeroMemory(offscreen_cache, sizeof(rdpOffscreenCache));
offscreenCache = (rdpOffscreenCache*) malloc(sizeof(rdpOffscreenCache));
if (offscreen_cache != NULL)
if (offscreenCache)
{
offscreen_cache->settings = settings;
offscreen_cache->update = ((freerdp*) settings->instance)->update;
ZeroMemory(offscreenCache, sizeof(rdpOffscreenCache));
offscreen_cache->currentSurface = SCREEN_BITMAP_SURFACE;
offscreen_cache->maxSize = 7680;
offscreen_cache->maxEntries = 2000;
offscreenCache->settings = settings;
offscreenCache->update = ((freerdp*) settings->instance)->update;
settings->OffscreenCacheSize = offscreen_cache->maxSize;
settings->OffscreenCacheEntries = offscreen_cache->maxEntries;
offscreenCache->currentSurface = SCREEN_BITMAP_SURFACE;
offscreenCache->maxSize = 7680;
offscreenCache->maxEntries = 2000;
offscreen_cache->entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * offscreen_cache->maxEntries);
ZeroMemory(offscreen_cache->entries, sizeof(rdpBitmap*) * offscreen_cache->maxEntries);
settings->OffscreenCacheSize = offscreenCache->maxSize;
settings->OffscreenCacheEntries = offscreenCache->maxEntries;
offscreenCache->entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * offscreenCache->maxEntries);
ZeroMemory(offscreenCache->entries, sizeof(rdpBitmap*) * offscreenCache->maxEntries);
}
return offscreen_cache;
return offscreenCache;
}
void offscreen_cache_free(rdpOffscreenCache* offscreen_cache)
void offscreen_cache_free(rdpOffscreenCache* offscreenCache)
{
int i;
rdpBitmap* bitmap;
if (offscreen_cache != NULL)
if (offscreenCache)
{
for (i = 0; i < (int) offscreen_cache->maxEntries; i++)
for (i = 0; i < (int) offscreenCache->maxEntries; i++)
{
bitmap = offscreen_cache->entries[i];
bitmap = offscreenCache->entries[i];
if (bitmap != NULL)
Bitmap_Free(offscreen_cache->update->context, bitmap);
if (bitmap)
Bitmap_Free(offscreenCache->update->context, bitmap);
}
free(offscreen_cache->entries);
free(offscreen_cache);
free(offscreenCache->entries);
free(offscreenCache);
}
}

View File

@ -27,30 +27,30 @@
#include <freerdp/cache/palette.h>
static void update_gdi_cache_color_table(rdpContext* context,
CACHE_COLOR_TABLE_ORDER* cache_color_table)
static void update_gdi_cache_color_table(rdpContext* context, CACHE_COLOR_TABLE_ORDER* cacheColorTable)
{
UINT32* colorTable;
rdpCache* cache = context->cache;
colorTable = (UINT32*) malloc(sizeof(UINT32) * 256);
CopyMemory(colorTable, cache_color_table->colorTable, sizeof(UINT32) * 256);
CopyMemory(colorTable, cacheColorTable->colorTable, sizeof(UINT32) * 256);
palette_cache_put(cache->palette, cache_color_table->cacheIndex, (void*) colorTable);
palette_cache_put(cache->palette, cacheColorTable->cacheIndex, (void*) colorTable);
}
void* palette_cache_get(rdpPaletteCache* palette_cache, UINT32 index)
void* palette_cache_get(rdpPaletteCache* paletteCache, UINT32 index)
{
void* entry;
if (index >= palette_cache->maxEntries)
if (index >= paletteCache->maxEntries)
{
fprintf(stderr, "invalid color table index: 0x%04X\n", index);
return NULL;
}
entry = palette_cache->entries[index].entry;
if (entry == NULL)
entry = paletteCache->entries[index].entry;
if (!entry)
{
fprintf(stderr, "invalid color table at index: 0x%04X\n", index);
return NULL;
@ -59,20 +59,22 @@ void* palette_cache_get(rdpPaletteCache* palette_cache, UINT32 index)
return entry;
}
void palette_cache_put(rdpPaletteCache* palette_cache, UINT32 index, void* entry)
void palette_cache_put(rdpPaletteCache* paletteCache, UINT32 index, void* entry)
{
if (index >= palette_cache->maxEntries)
if (index >= paletteCache->maxEntries)
{
fprintf(stderr, "invalid color table index: 0x%04X\n", index);
if (entry)
free(entry);
return;
}
if(NULL == palette_cache->entries[index].entry)
free(palette_cache->entries[index].entry);
if (paletteCache->entries[index].entry)
free(paletteCache->entries[index].entry);
palette_cache->entries[index].entry = entry;
paletteCache->entries[index].entry = entry;
}
void palette_cache_register_callbacks(rdpUpdate* update)
@ -82,34 +84,35 @@ void palette_cache_register_callbacks(rdpUpdate* update)
rdpPaletteCache* palette_cache_new(rdpSettings* settings)
{
rdpPaletteCache* palette_cache;
rdpPaletteCache* paletteCache;
palette_cache = (rdpPaletteCache*) malloc(sizeof(rdpPaletteCache));
ZeroMemory(palette_cache, sizeof(rdpPaletteCache));
paletteCache = (rdpPaletteCache*) malloc(sizeof(rdpPaletteCache));
ZeroMemory(paletteCache, sizeof(rdpPaletteCache));
if (palette_cache != NULL)
if (paletteCache)
{
palette_cache->settings = settings;
palette_cache->maxEntries = 6;
palette_cache->entries = (PALETTE_TABLE_ENTRY*) malloc(sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries);
ZeroMemory(palette_cache->entries, sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries);
paletteCache->settings = settings;
paletteCache->maxEntries = 6;
paletteCache->entries = (PALETTE_TABLE_ENTRY*) malloc(sizeof(PALETTE_TABLE_ENTRY) * paletteCache->maxEntries);
ZeroMemory(paletteCache->entries, sizeof(PALETTE_TABLE_ENTRY) * paletteCache->maxEntries);
}
return palette_cache;
return paletteCache;
}
void palette_cache_free(rdpPaletteCache* palette_cache)
void palette_cache_free(rdpPaletteCache* paletteCache)
{
if (palette_cache != NULL)
if (paletteCache)
{
int i;
for (i=0; i<palette_cache->maxEntries; i++)
for (i = 0; i< paletteCache->maxEntries; i++)
{
if (palette_cache->entries[i].entry)
free(palette_cache->entries[i].entry);
if (paletteCache->entries[i].entry)
free(paletteCache->entries[i].entry);
}
free(palette_cache->entries);
free(palette_cache);
free(paletteCache->entries);
free(paletteCache);
}
}

View File

@ -102,7 +102,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -36,7 +36,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -402,6 +402,19 @@ void freerdp_dynamic_channel_collection_free(rdpSettings* settings)
settings->DynamicChannelCount = 0;
}
void freerdp_target_net_addresses_free(rdpSettings* settings)
{
UINT32 index;
for (index = 0; index < settings->TargetNetAddressCount; index++)
free(settings->TargetNetAddresses[index]);
free(settings->TargetNetAddresses);
settings->TargetNetAddressCount = 0;
settings->TargetNetAddresses = NULL;
}
void freerdp_performance_flags_make(rdpSettings* settings)
{
settings->PerformanceFlags = PERF_FLAG_NONE;
@ -1533,26 +1546,10 @@ UINT32 freerdp_get_param_uint32(rdpSettings* settings, int id)
return settings->LoadBalanceInfoLength;
break;
case FreeRDP_RedirectionUsernameLength:
return settings->RedirectionUsernameLength;
break;
case FreeRDP_RedirectionDomainLength:
return settings->RedirectionDomainLength;
break;
case FreeRDP_RedirectionPasswordLength:
return settings->RedirectionPasswordLength;
break;
case FreeRDP_RedirectionTargetFQDNLength:
return settings->RedirectionTargetFQDNLength;
break;
case FreeRDP_RedirectionTargetNetBiosNameLength:
return settings->RedirectionTargetNetBiosNameLength;
break;
case FreeRDP_RedirectionTsvUrlLength:
return settings->RedirectionTsvUrlLength;
break;
@ -1853,26 +1850,10 @@ int freerdp_set_param_uint32(rdpSettings* settings, int id, UINT32 param)
settings->LoadBalanceInfoLength = param;
break;
case FreeRDP_RedirectionUsernameLength:
settings->RedirectionUsernameLength = param;
break;
case FreeRDP_RedirectionDomainLength:
settings->RedirectionDomainLength = param;
break;
case FreeRDP_RedirectionPasswordLength:
settings->RedirectionPasswordLength = param;
break;
case FreeRDP_RedirectionTargetFQDNLength:
settings->RedirectionTargetFQDNLength = param;
break;
case FreeRDP_RedirectionTargetNetBiosNameLength:
settings->RedirectionTargetNetBiosNameLength = param;
break;
case FreeRDP_RedirectionTsvUrlLength:
settings->RedirectionTsvUrlLength = param;
break;

View File

@ -142,7 +142,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -170,17 +170,25 @@ BOOL rdp_client_connect(rdpRdp* rdp)
{
rdpSettings* settings = rdp->settings;
if (rdp->settingsCopy)
{
freerdp_settings_free(rdp->settingsCopy);
rdp->settingsCopy = NULL;
}
rdp->settingsCopy = freerdp_settings_clone(settings);
nego_init(rdp->nego);
nego_set_target(rdp->nego, settings->ServerHostname, settings->ServerPort);
if (settings->GatewayEnabled)
{
char* user;
char* domain;
char* cookie;
char* user = NULL;
char* domain = NULL;
char* cookie = NULL;
int user_length = 0;
int domain_length;
int cookie_length;
int domain_length = 0;
int cookie_length = 0;
if (settings->Username)
{
@ -209,14 +217,6 @@ BOOL rdp_client_connect(rdpRdp* rdp)
nego_set_cookie(rdp->nego, cookie);
free(cookie);
settings->RdpSecurity = TRUE;
settings->TlsSecurity = FALSE;
settings->NlaSecurity = FALSE;
settings->ExtSecurity = FALSE;
//settings->TlsSecurity = TRUE;
//settings->NlaSecurity = TRUE;
}
else
{
@ -286,92 +286,57 @@ BOOL rdp_client_disconnect(rdpRdp* rdp)
BOOL rdp_client_redirect(rdpRdp* rdp)
{
BOOL status;
rdpSettings* settings = rdp->settings;
rdpRedirection* redirection = rdp->redirection;
rdp_client_disconnect(rdp);
/* FIXME: this is a subset of rdp_free */
/* --> this should really go into rdp.c */
crypto_rc4_free(rdp->rc4_decrypt_key);
rdp->rc4_decrypt_key = NULL ;
crypto_rc4_free(rdp->rc4_encrypt_key);
rdp->rc4_encrypt_key = NULL;
crypto_des3_free(rdp->fips_encrypt);
rdp->fips_encrypt = NULL ;
crypto_des3_free(rdp->fips_decrypt);
rdp->fips_decrypt = NULL ;
crypto_hmac_free(rdp->fips_hmac);
rdp->fips_hmac = NULL ;
rdp_reset(rdp);
free(settings->ServerRandom);
settings->ServerRandom = NULL ;
free(settings->ServerCertificate);
settings->ServerCertificate = NULL ;
free(settings->ClientAddress);
settings->ClientAddress = NULL ;
rdp_redirection_apply_settings(rdp);
mppc_enc_free(rdp->mppc_enc);
mppc_dec_free(rdp->mppc_dec);
mcs_free(rdp->mcs);
nego_free(rdp->nego);
license_free(rdp->license);
transport_free(rdp->transport);
rdp->transport = transport_new(settings);
rdp->license = license_new(rdp);
rdp->nego = nego_new(rdp->transport);
rdp->mcs = mcs_new(rdp->transport);
rdp->mppc_dec = mppc_dec_new();
rdp->mppc_enc = mppc_enc_new(PROTO_RDP_50);
rdp->transport->layer = TRANSPORT_LAYER_TCP;
settings->RedirectedSessionId = redirection->sessionID;
if (redirection->flags & LB_LOAD_BALANCE_INFO)
if (settings->RedirectionFlags & LB_LOAD_BALANCE_INFO)
{
nego_set_routing_token(rdp->nego, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
nego_set_routing_token(rdp->nego, settings->LoadBalanceInfo, settings->LoadBalanceInfoLength);
}
else
{
if (redirection->flags & LB_TARGET_NET_ADDRESS)
if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS)
{
free(settings->ServerHostname);
settings->ServerHostname = _strdup(redirection->targetNetAddress.ascii);
settings->ServerHostname = _strdup(settings->TargetNetAddress);
}
else if (redirection->flags & LB_TARGET_FQDN)
else if (settings->RedirectionFlags & LB_TARGET_FQDN)
{
free(settings->ServerHostname);
settings->ServerHostname = _strdup(redirection->targetFQDN.ascii);
settings->ServerHostname = _strdup(settings->RedirectionTargetFQDN);
}
else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME)
{
free(settings->ServerHostname);
settings->ServerHostname = _strdup(redirection->targetNetBiosName.ascii);
settings->ServerHostname = _strdup(settings->RedirectionTargetNetBiosName);
}
}
if (redirection->flags & LB_USERNAME)
if (settings->RedirectionFlags & LB_USERNAME)
{
free(settings->Username);
settings->Username = _strdup(redirection->username.ascii);
settings->Username = _strdup(settings->RedirectionUsername);
}
if (redirection->flags & LB_DOMAIN)
if (settings->RedirectionFlags & LB_DOMAIN)
{
free(settings->Domain);
settings->Domain = _strdup(redirection->domain.ascii);
settings->Domain = _strdup(settings->RedirectionDomain);
}
if (redirection->flags & LB_PASSWORD)
{
settings->RedirectionPassword = redirection->PasswordCookie;
settings->RedirectionPasswordLength = redirection->PasswordCookieLength;
}
status = rdp_client_connect(rdp);
return rdp_client_connect(rdp);
return status;
}
static BYTE fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
static BOOL rdp_client_establish_keys(rdpRdp* rdp)
{
BYTE* mod;
@ -388,10 +353,17 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp)
}
/* encrypt client random */
if (rdp->settings->ClientRandom) free(rdp->settings->ClientRandom);
if (rdp->settings->ClientRandom)
free(rdp->settings->ClientRandom);
rdp->settings->ClientRandom = malloc(CLIENT_RANDOM_LENGTH);
if (rdp->settings->ClientRandom == NULL) return FALSE;
if (!rdp->settings->ClientRandom)
return FALSE;
ZeroMemory(crypt_client_random, sizeof(crypt_client_random));
crypto_nonce(rdp->settings->ClientRandom, CLIENT_RANDOM_LENGTH);
key_len = rdp->settings->RdpServerCertificate->cert_info.ModulusLength;
mod = rdp->settings->RdpServerCertificate->cert_info.Modulus;
@ -430,7 +402,6 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp)
if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
{
BYTE fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec);
rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec);
@ -511,7 +482,6 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s)
if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
{
BYTE fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec);
rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec);
@ -668,7 +638,7 @@ BOOL rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s)
* so that could result in a bad offset.
*/
if (rdp_recv_out_of_sequence_pdu(rdp, s) != TRUE)
if (!rdp_recv_out_of_sequence_pdu(rdp, s))
return FALSE;
return TRUE;

View File

@ -20,12 +20,12 @@
#ifndef __FASTPATH_H
#define __FASTPATH_H
typedef struct rdp_fastpath rdpFastPath;
#include "rdp.h"
#include <winpr/stream.h>
typedef struct rdp_fastpath rdpFastPath;
enum FASTPATH_INPUT_ACTION_TYPE
{
FASTPATH_INPUT_ACTION_FASTPATH = 0x0,

View File

@ -428,6 +428,9 @@ int freerdp_context_new(freerdp* instance)
*/
void freerdp_context_free(freerdp* instance)
{
if (!instance)
return;
if (!instance->context)
return;

View File

@ -210,7 +210,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
UINT32 Pointer;
PTSG_PACKET packet;
UINT32 SwitchValue;
UINT32 MessageSwitchValue;
UINT32 MessageSwitchValue = 0;
UINT32 IsMessagePresent;
UINT32 MsgBytes;
rdpRpc* rpc = tsg->rpc;
@ -340,7 +340,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
tsgCaps->tsgPacket.tsgCapNap.capabilities = *((UINT32*) &buffer[offset]); /* Capabilities */
offset += 4;
switch(MessageSwitchValue)
switch (MessageSwitchValue)
{
case TSG_ASYNC_MESSAGE_CONSENT_MESSAGE:
case TSG_ASYNC_MESSAGE_SERVICE_MESSAGE:
@ -350,23 +350,29 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
offset += 4;
Pointer = *((UINT32*) &buffer[offset]);
offset += 4;
if(Pointer) {
if (Pointer)
{
offset += 4; // MaxCount
offset += 8; // UnicodeString Offset, Length
}
if(MsgBytes > TSG_MESSAGING_MAX_MESSAGE_LENGTH) {
if (MsgBytes > TSG_MESSAGING_MAX_MESSAGE_LENGTH)
{
fprintf(stderr, "Out of Spec Message Length %d", MsgBytes);
return FALSE;
}
offset += MsgBytes;
break;
case TSG_ASYNC_MESSAGE_REAUTH:
rpc_offset_align(&offset, 8);
offset += 8; // UINT64 TunnelContext, not to be confused with
// the ContextHandle TunnelContext below.
break;
default:
fprintf(stderr, "Unexpected Message Type: 0x%X\n", MessageSwitchValue);
fprintf(stderr, "Unexpected Message Type: 0x%X\n", (int) MessageSwitchValue);
return FALSE;
}

View File

@ -139,18 +139,28 @@ BOOL rdp_read_extended_info_packet(wStream* s, rdpSettings* settings)
if (Stream_GetRemainingLength(s) < cbClientAddress)
return FALSE;
if (settings->ClientAddress)
{
free(settings->ClientAddress);
settings->ClientAddress = NULL;
}
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientAddress / 2, &settings->ClientAddress, 0, NULL, NULL);
Stream_Seek(s, cbClientAddress);
if (Stream_GetRemainingLength(s) < 2)
return FALSE;
Stream_Read_UINT16(s, cbClientDir); /* cbClientDir */
if (Stream_GetRemainingLength(s) < cbClientDir)
return FALSE;
if (settings->ClientDir)
{
free(settings->ClientDir);
settings->ClientDir = NULL;
}
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), cbClientDir / 2, &settings->ClientDir, 0, NULL, NULL);
Stream_Seek(s, cbClientDir);
@ -238,10 +248,12 @@ void rdp_write_extended_info_packet(wStream* s, rdpSettings* settings)
clientCookie->logonId = serverCookie->logonId;
hmac = crypto_hmac_new();
crypto_hmac_md5_init(hmac, serverCookie->arcRandomBits, 16);
if (settings->SelectedProtocol == PROTOCOL_RDP)
{
crypto_hmac_update(hmac, (BYTE *) (settings->ClientRandom), 32);
crypto_hmac_update(hmac, (BYTE*) (settings->ClientRandom), 32);
}
else
{

View File

@ -217,6 +217,8 @@ static void update_message_PatBlt(rdpContext* context, PATBLT_ORDER* patBlt)
wParam = (PATBLT_ORDER*) malloc(sizeof(PATBLT_ORDER));
CopyMemory(wParam, patBlt, sizeof(PATBLT_ORDER));
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, PatBlt), (void*) wParam, NULL);
}
@ -272,6 +274,8 @@ static void update_message_MultiPatBlt(rdpContext* context, MULTI_PATBLT_ORDER*
wParam = (MULTI_PATBLT_ORDER*) malloc(sizeof(MULTI_PATBLT_ORDER));
CopyMemory(wParam, multiPatBlt, sizeof(MULTI_PATBLT_ORDER));
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, MultiPatBlt), (void*) wParam, NULL);
}
@ -354,6 +358,8 @@ static void update_message_Mem3Blt(rdpContext* context, MEM3BLT_ORDER* mem3Blt)
wParam = (MEM3BLT_ORDER*) malloc(sizeof(MEM3BLT_ORDER));
CopyMemory(wParam, mem3Blt, sizeof(MEM3BLT_ORDER));
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, Mem3Blt), (void*) wParam, NULL);
}
@ -376,6 +382,8 @@ static void update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* gl
wParam = (GLYPH_INDEX_ORDER*) malloc(sizeof(GLYPH_INDEX_ORDER));
CopyMemory(wParam, glyphIndex, sizeof(GLYPH_INDEX_ORDER));
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, GlyphIndex), (void*) wParam, NULL);
}
@ -398,6 +406,16 @@ static void update_message_FastGlyph(rdpContext* context, FAST_GLYPH_ORDER* fast
wParam = (FAST_GLYPH_ORDER*) malloc(sizeof(FAST_GLYPH_ORDER));
CopyMemory(wParam, fastGlyph, sizeof(FAST_GLYPH_ORDER));
if (wParam->cbData > 1)
{
wParam->glyphData.aj = (BYTE*) malloc(fastGlyph->glyphData.cb);
CopyMemory(wParam->glyphData.aj, fastGlyph->glyphData.aj, fastGlyph->glyphData.cb);
}
else
{
wParam->glyphData.aj = NULL;
}
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, FastGlyph), (void*) wParam, NULL);
}
@ -426,6 +444,8 @@ static void update_message_PolygonCB(rdpContext* context, POLYGON_CB_ORDER* poly
wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numPoints);
CopyMemory(wParam->points, polygonCB, sizeof(DELTA_POINT) * wParam->numPoints);
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, PolygonCB), (void*) wParam, NULL);
}
@ -448,6 +468,8 @@ static void update_message_EllipseCB(rdpContext* context, ELLIPSE_CB_ORDER* elli
wParam = (ELLIPSE_CB_ORDER*) malloc(sizeof(ELLIPSE_CB_ORDER));
CopyMemory(wParam, ellipseCB, sizeof(ELLIPSE_CB_ORDER));
wParam->brush.data = (BYTE*) wParam->brush.p8x8;
MessageQueue_Post(context->update->queue, (void*) context,
MakeMessageId(PrimaryUpdate, EllipseCB), (void*) wParam, NULL);
}
@ -994,6 +1016,7 @@ int update_message_process_update_class(rdpUpdateProxy* proxy, wMessage* msg, in
#endif
}
free(wParam->rectangles);
free(wParam);
}
break;
@ -1159,7 +1182,12 @@ int update_message_process_primary_update_class(rdpUpdateProxy* proxy, wMessage*
case PrimaryUpdate_FastGlyph:
IFCALL(proxy->FastGlyph, msg->context, (FAST_GLYPH_ORDER*) msg->wParam);
free(msg->wParam);
{
FAST_GLYPH_ORDER* wParam = (FAST_GLYPH_ORDER*) msg->wParam;
if (wParam->glyphData.aj)
free(wParam->glyphData.aj);
free(wParam);
}
break;
case PrimaryUpdate_PolygonSC:

View File

@ -43,11 +43,16 @@ static const char* const NEGO_STATE_STRINGS[] =
"NEGO_STATE_FINAL"
};
static const char PROTOCOL_SECURITY_STRINGS[4][4] =
static const char PROTOCOL_SECURITY_STRINGS[9][4] =
{
"RDP",
"TLS",
"NLA",
"UNK",
"UNK",
"UNK",
"UNK",
"UNK",
"EXT"
};
@ -959,13 +964,14 @@ void nego_init(rdpNego* nego)
* @return
*/
rdpNego* nego_new(struct rdp_transport * transport)
rdpNego* nego_new(rdpTransport* transport)
{
rdpNego* nego = (rdpNego*) malloc(sizeof(rdpNego));
if (nego != NULL)
if (nego)
{
ZeroMemory(nego, sizeof(rdpNego));
nego->transport = transport;
nego_init(nego);
}
@ -980,6 +986,7 @@ rdpNego* nego_new(struct rdp_transport * transport)
void nego_free(rdpNego* nego)
{
free(nego->RoutingToken);
free(nego->cookie);
free(nego);
}
@ -1066,8 +1073,10 @@ void nego_enable_ext(rdpNego* nego, BOOL enable_ext)
void nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken, DWORD RoutingTokenLength)
{
nego->RoutingToken = RoutingToken;
free(nego->RoutingToken);
nego->RoutingTokenLength = RoutingTokenLength;
nego->RoutingToken = (BYTE*) malloc(nego->RoutingTokenLength);
CopyMemory(nego->RoutingToken, RoutingToken, nego->RoutingTokenLength);
}
/**

View File

@ -113,6 +113,7 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
{
char* spn;
int length;
rdpTls* tls = NULL;
freerdp* instance;
rdpSettings* settings;
@ -138,8 +139,22 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
(char*) credssp->identity.User, (char*) credssp->identity.Domain, (char*) credssp->identity.Password);
#endif
sspi_SecBufferAlloc(&credssp->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
CopyMemory(credssp->PublicKey.pvBuffer, credssp->transport->TlsIn->PublicKey, credssp->transport->TlsIn->PublicKeyLength);
if (credssp->transport->layer == TRANSPORT_LAYER_TLS)
{
tls = credssp->transport->TlsIn;
}
else if (credssp->transport->layer == TRANSPORT_LAYER_TSG_TLS)
{
tls = credssp->transport->TsgTls;
}
else
{
fprintf(stderr, "Unknown NLA transport layer\n");
return 0;
}
sspi_SecBufferAlloc(&credssp->PublicKey, tls->PublicKeyLength);
CopyMemory(credssp->PublicKey.pvBuffer, tls->PublicKey, tls->PublicKeyLength);
length = sizeof(TERMSRV_SPN_PREFIX) + strlen(settings->ServerHostname);

View File

@ -1356,6 +1356,7 @@ BOOL update_read_memblt_order(wStream* s, ORDER_INFO* orderInfo, MEMBLT_ORDER* m
memblt->colorIndex = (memblt->cacheId >> 8);
memblt->cacheId = (memblt->cacheId & 0xFF);
memblt->bitmap = NULL;
return TRUE;
}
@ -1422,6 +1423,7 @@ BOOL update_read_mem3blt_order(wStream* s, ORDER_INFO* orderInfo, MEM3BLT_ORDER*
ORDER_FIELD_UINT16(16, mem3blt->cacheIndex);
mem3blt->colorIndex = (mem3blt->cacheId >> 8);
mem3blt->cacheId = (mem3blt->cacheId & 0xFF);
mem3blt->bitmap = NULL;
return TRUE;
}
@ -1669,7 +1671,11 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
return FALSE;
if (glyph->aj)
{
free(glyph->aj);
glyph->aj = NULL;
}
glyph->aj = (BYTE*) malloc(glyph->cb);
Stream_Read(s, glyph->aj, glyph->cb);
}

View File

@ -816,7 +816,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
*/
Stream_Rewind(s, 2);
rdp_recv_enhanced_security_redirection_packet(rdp, s);
return -1;
return 1; /* 1 = redirection */
}
}
@ -976,7 +976,9 @@ void rdp_set_blocking_mode(rdpRdp* rdp, BOOL blocking)
int rdp_check_fds(rdpRdp* rdp)
{
return transport_check_fds(&(rdp->transport));
int status;
status = transport_check_fds(rdp->transport);
return status;
}
/**
@ -1028,6 +1030,46 @@ rdpRdp* rdp_new(rdpContext* context)
return rdp;
}
void rdp_reset(rdpRdp* rdp)
{
rdpSettings* settings;
settings = rdp->settings;
crypto_rc4_free(rdp->rc4_decrypt_key);
rdp->rc4_decrypt_key = NULL;
crypto_rc4_free(rdp->rc4_encrypt_key);
rdp->rc4_encrypt_key = NULL;
crypto_des3_free(rdp->fips_encrypt);
rdp->fips_encrypt = NULL;
crypto_des3_free(rdp->fips_decrypt);
rdp->fips_decrypt = NULL;
crypto_hmac_free(rdp->fips_hmac);
rdp->fips_hmac = NULL;
mppc_enc_free(rdp->mppc_enc);
mppc_dec_free(rdp->mppc_dec);
mcs_free(rdp->mcs);
nego_free(rdp->nego);
license_free(rdp->license);
transport_free(rdp->transport);
free(settings->ServerRandom);
settings->ServerRandom = NULL;
free(settings->ServerCertificate);
settings->ServerCertificate = NULL;
free(settings->ClientAddress);
settings->ClientAddress = NULL;
rdp->transport = transport_new(rdp->settings);
rdp->license = license_new(rdp);
rdp->nego = nego_new(rdp->transport);
rdp->mcs = mcs_new(rdp->transport);
rdp->mppc_dec = mppc_dec_new();
rdp->mppc_enc = mppc_enc_new(PROTO_RDP_50);
rdp->transport->layer = TRANSPORT_LAYER_TCP;
}
/**
* Free RDP module.
* @param rdp RDP module to be freed
@ -1035,7 +1077,7 @@ rdpRdp* rdp_new(rdpContext* context)
void rdp_free(rdpRdp* rdp)
{
if (rdp != NULL)
if (rdp)
{
crypto_rc4_free(rdp->rc4_decrypt_key);
crypto_rc4_free(rdp->rc4_encrypt_key);
@ -1043,6 +1085,7 @@ void rdp_free(rdpRdp* rdp)
crypto_des3_free(rdp->fips_decrypt);
crypto_hmac_free(rdp->fips_hmac);
freerdp_settings_free(rdp->settings);
freerdp_settings_free(rdp->settingsCopy);
extension_free(rdp->extension);
transport_free(rdp->transport);
license_free(rdp->license);

View File

@ -121,16 +121,16 @@ struct rdp_rdp
int state;
freerdp* instance;
rdpContext* context;
struct rdp_mcs* mcs;
struct rdp_nego* nego;
struct rdp_input* input;
struct rdp_update* update;
struct rdp_fastpath* fastpath;
struct rdp_license* license;
struct rdp_redirection* redirection;
struct rdp_settings* settings;
struct rdp_transport* transport;
struct rdp_extension* extension;
rdpMcs* mcs;
rdpNego* nego;
rdpInput* input;
rdpUpdate* update;
rdpFastPath* fastpath;
rdpLicense* license;
rdpRedirection* redirection;
rdpSettings* settings;
rdpTransport* transport;
rdpExtension* extension;
struct rdp_mppc_dec* mppc_dec;
struct rdp_mppc_enc* mppc_enc;
struct crypto_rc4_struct* rc4_decrypt_key;
@ -160,6 +160,7 @@ struct rdp_rdp
BOOL resendFocus;
BOOL deactivation_reactivation;
BOOL AwaitCapabilities;
rdpSettings* settingsCopy;
};
BOOL rdp_read_security_header(wStream* s, UINT16* flags);
@ -196,6 +197,7 @@ void rdp_set_blocking_mode(rdpRdp* rdp, BOOL blocking);
int rdp_check_fds(rdpRdp* rdp);
rdpRdp* rdp_new(rdpContext* context);
void rdp_reset(rdpRdp* rdp);
void rdp_free(rdpRdp* rdp);
#ifdef WITH_DEBUG_RDP

View File

@ -61,31 +61,111 @@ void rdp_print_redirection_flags(UINT32 flags)
fprintf(stderr, "}\n");
}
BOOL rdp_string_read_length32(wStream* s, rdpString* string)
BOOL rdp_redirection_read_string(wStream* s, char** str)
{
if(Stream_GetRemainingLength(s) < 4)
UINT32 length;
if (Stream_GetRemainingLength(s) < 4)
{
fprintf(stderr, "rdp_redirection_read_string failure: cannot read length\n");
return FALSE;
}
Stream_Read_UINT32(s, string->length);
Stream_Read_UINT32(s, length);
if(Stream_GetRemainingLength(s) < string->length)
if (Stream_GetRemainingLength(s) < length)
{
fprintf(stderr, "rdp_redirection_read_string failure: incorrect length %d\n", length);
return FALSE;
}
string->unicode = (char*) malloc(string->length);
Stream_Read(s, string->unicode, string->length);
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) string->unicode, string->length / 2, &string->ascii, 0, NULL, NULL);
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s), length / 2, str, 0, NULL, NULL);
Stream_Seek(s, length);
return TRUE;
}
void rdp_string_free(rdpString* string)
int rdp_redirection_apply_settings(rdpRdp* rdp)
{
if (string->unicode != NULL)
free(string->unicode);
rdpSettings* settings = rdp->settings;
rdpRedirection* redirection = rdp->redirection;
if (string->ascii != NULL)
free(string->ascii);
settings->RedirectionFlags = redirection->flags;
settings->RedirectedSessionId = redirection->sessionID;
if (settings->RedirectionFlags & LB_LOAD_BALANCE_INFO)
{
/* LoadBalanceInfo may not contain a null terminator */
free(settings->LoadBalanceInfo);
settings->LoadBalanceInfoLength = redirection->LoadBalanceInfoLength;
settings->LoadBalanceInfo = (BYTE*) malloc(settings->LoadBalanceInfoLength);
CopyMemory(settings->LoadBalanceInfo, redirection->LoadBalanceInfo, settings->LoadBalanceInfoLength);
}
else
{
if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS)
{
free(settings->TargetNetAddress);
settings->TargetNetAddress = _strdup(redirection->TargetNetAddress);
}
else if (settings->RedirectionFlags & LB_TARGET_FQDN)
{
free(settings->RedirectionTargetFQDN);
settings->RedirectionTargetFQDN = _strdup(redirection->TargetFQDN);
}
else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME)
{
free(settings->RedirectionTargetNetBiosName);
settings->RedirectionTargetNetBiosName = _strdup(redirection->TargetNetBiosName);
}
}
if (settings->RedirectionFlags & LB_USERNAME)
{
free(settings->RedirectionUsername);
settings->RedirectionUsername = _strdup(redirection->Username);
}
if (settings->RedirectionFlags & LB_DOMAIN)
{
free(settings->RedirectionDomain);
settings->RedirectionDomain = _strdup(redirection->Domain);
}
if (settings->RedirectionFlags & LB_PASSWORD)
{
/* Password may be a cookie without a null terminator */
free(settings->RedirectionPassword);
settings->RedirectionPasswordLength = redirection->PasswordLength;
settings->RedirectionPassword = (BYTE*) malloc(settings->RedirectionPasswordLength);
CopyMemory(settings->RedirectionPassword, redirection->Password, settings->RedirectionPasswordLength);
}
if (settings->RedirectionFlags & LB_CLIENT_TSV_URL)
{
/* TsvUrl may not contain a null terminator */
free(settings->RedirectionTsvUrl);
settings->RedirectionTsvUrlLength = redirection->TsvUrlLength;
settings->RedirectionTsvUrl = (BYTE*) malloc(settings->RedirectionTsvUrlLength);
CopyMemory(settings->RedirectionTsvUrl, redirection->TsvUrl, settings->RedirectionTsvUrlLength);
}
if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESSES)
{
int i;
freerdp_target_net_addresses_free(settings);
settings->TargetNetAddressCount = redirection->TargetNetAddressesCount;
settings->TargetNetAddresses = (char**) malloc(sizeof(char*) * settings->TargetNetAddressCount);
for (i = 0; i < settings->TargetNetAddressCount; i++)
{
settings->TargetNetAddresses[i] = _strdup(redirection->TargetNetAddresses[i]);
}
}
return 0;
}
BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
@ -96,12 +176,14 @@ 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) */
DEBUG_REDIR("flags: 0x%04X, length:%d, sessionID:0x%08X", flags, length, redirection->sessionID);
WLog_Print(redirection->log, WLOG_DEBUG, "flags: 0x%04X, redirFlags: 0x%04X length: %d, sessionID: 0x%08X",
flags, redirection->flags, length, redirection->sessionID);
#ifdef WITH_DEBUG_REDIR
rdp_print_redirection_flags(redirection->flags);
@ -109,16 +191,17 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
if (redirection->flags & LB_TARGET_NET_ADDRESS)
{
if (!rdp_string_read_length32(s, &redirection->targetNetAddress))
if (!rdp_redirection_read_string(s, &(redirection->TargetNetAddress)))
return FALSE;
DEBUG_REDIR("targetNetAddress: %s", redirection->targetNetAddress.ascii);
}
if (redirection->flags & LB_LOAD_BALANCE_INFO)
{
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
Stream_Read_UINT32(s, redirection->LoadBalanceInfoLength);
if (Stream_GetRemainingLength(s) < redirection->LoadBalanceInfoLength)
return FALSE;
@ -132,16 +215,18 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
if (redirection->flags & LB_USERNAME)
{
if (!rdp_string_read_length32(s, &redirection->username))
if (!rdp_redirection_read_string(s, &(redirection->Username)))
return FALSE;
DEBUG_REDIR("username: %s", redirection->username.ascii);
WLog_Print(redirection->log, WLOG_DEBUG, "Username: %s", redirection->Username);
}
if (redirection->flags & LB_DOMAIN)
{
if (!rdp_string_read_length32(s, &redirection->domain))
if (!rdp_redirection_read_string(s, &(redirection->Domain)))
return FALSE;
DEBUG_REDIR("domain: %s", redirection->domain.ascii);
WLog_Print(redirection->log, WLOG_DEBUG, "Domain: %s", redirection->Domain);
}
if (redirection->flags & LB_PASSWORD)
@ -149,35 +234,50 @@ 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);
redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength);
Stream_Read(s, redirection->PasswordCookie, redirection->PasswordCookieLength);
Stream_Read_UINT32(s, redirection->PasswordLength);
redirection->Password = (BYTE*) malloc(redirection->PasswordLength);
Stream_Read(s, redirection->Password, redirection->PasswordLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("password_cookie:");
winpr_HexDump(redirection->PasswordCookie, redirection->PasswordCookieLength);
DEBUG_REDIR("PasswordCookie:");
winpr_HexDump(redirection->Password, redirection->PasswordLength);
#endif
}
if (redirection->flags & LB_TARGET_FQDN)
{
if (!rdp_string_read_length32(s, &redirection->targetFQDN))
if (!rdp_redirection_read_string(s, &(redirection->TargetFQDN)))
return FALSE;
DEBUG_REDIR("targetFQDN: %s", redirection->targetFQDN.ascii);
WLog_Print(redirection->log, WLOG_DEBUG, "TargetFQDN: %s", redirection->TargetFQDN);
}
if (redirection->flags & LB_TARGET_NETBIOS_NAME)
{
if (!rdp_string_read_length32(s, &redirection->targetNetBiosName))
if (!rdp_redirection_read_string(s, &(redirection->TargetNetBiosName)))
return FALSE;
DEBUG_REDIR("targetNetBiosName: %s", redirection->targetNetBiosName.ascii);
WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetBiosName: %s", redirection->TargetNetBiosName);
}
if (redirection->flags & LB_CLIENT_TSV_URL)
{
if (!rdp_string_read_length32(s, &redirection->tsvUrl))
if (Stream_GetRemainingLength(s) < 4)
return FALSE;
DEBUG_REDIR("tsvUrl: %s", redirection->tsvUrl.ascii);
Stream_Read_UINT32(s, redirection->TsvUrlLength);
if (Stream_GetRemainingLength(s) < redirection->TsvUrlLength)
return FALSE;
redirection->TsvUrl = (BYTE*) malloc(redirection->TsvUrlLength);
Stream_Read(s, redirection->TsvUrl, redirection->TsvUrlLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("TsvUrl:");
winpr_HexDump(redirection->TsvUrl, redirection->TsvUrlLength);
#endif
}
if (redirection->flags & LB_TARGET_NET_ADDRESSES)
@ -188,19 +288,23 @@ 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, redirection->targetNetAddressesCount);
count = redirection->targetNetAddressesCount;
Stream_Read_UINT32(s, redirection->TargetNetAddressesCount);
count = redirection->TargetNetAddressesCount;
redirection->targetNetAddresses = (rdpString*) malloc(count * sizeof(rdpString));
ZeroMemory(redirection->targetNetAddresses, count * sizeof(rdpString));
redirection->TargetNetAddresses = (char**) malloc(count * sizeof(char*));
ZeroMemory(redirection->TargetNetAddresses, count * sizeof(char*));
WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetAddressesCount: %d", redirection->TargetNetAddressesCount);
for (i = 0; i < (int) count; i++)
{
if (!rdp_string_read_length32(s, &redirection->targetNetAddresses[i]))
if (!rdp_redirection_read_string(s, &(redirection->TargetNetAddresses[i])))
return FALSE;
DEBUG_REDIR("targetNetAddresses: %s", (&redirection->targetNetAddresses[i])->ascii);
WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetAddresses[%d]: %s", i, redirection->TargetNetAddresses[i]);
}
}
@ -220,9 +324,9 @@ BOOL rdp_recv_redirection_packet(rdpRdp* rdp, wStream* s)
BOOL rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, wStream* s)
{
return Stream_SafeSeek(s, 2) && /* pad2Octets (2 bytes) */
return Stream_SafeSeek(s, 2) && /* pad2Octets (2 bytes) */
rdp_recv_server_redirection_pdu(rdp, s) &&
Stream_SafeSeek(s, 1); /* pad2Octets (1 byte) */
Stream_SafeSeek(s, 1); /* pad2Octets (1 byte) */
}
rdpRedirection* redirection_new()
@ -231,9 +335,16 @@ rdpRedirection* redirection_new()
redirection = (rdpRedirection*) malloc(sizeof(rdpRedirection));
if (redirection != NULL)
if (redirection)
{
ZeroMemory(redirection, sizeof(rdpRedirection));
WLog_Init();
redirection->log = WLog_Get("com.freerdp.core.redirection");
#ifdef WITH_DEBUG_REDIR
WLog_SetLogLevel(redirection->log, WLOG_TRACE);
#endif
}
return redirection;
@ -241,33 +352,46 @@ rdpRedirection* redirection_new()
void redirection_free(rdpRedirection* redirection)
{
if (redirection != NULL)
if (redirection)
{
rdp_string_free(&redirection->tsvUrl);
rdp_string_free(&redirection->username);
rdp_string_free(&redirection->domain);
rdp_string_free(&redirection->targetFQDN);
rdp_string_free(&redirection->targetNetBiosName);
rdp_string_free(&redirection->targetNetAddress);
if (redirection->TsvUrl)
free(redirection->TsvUrl);
if (redirection->Username)
free(redirection->Username);
if (redirection->Domain)
free(redirection->Domain);
if (redirection->TargetFQDN)
free(redirection->TargetFQDN);
if (redirection->TargetNetBiosName)
free(redirection->TargetNetBiosName);
if (redirection->TargetNetAddress)
free(redirection->TargetNetAddress);
if (redirection->LoadBalanceInfo)
free(redirection->LoadBalanceInfo);
if (redirection->PasswordCookie)
free(redirection->PasswordCookie);
if (redirection->Password)
free(redirection->Password);
if (redirection->targetNetAddresses != NULL)
if (redirection->TargetNetAddresses)
{
int i;
for (i = 0; i < (int) redirection->targetNetAddressesCount; i++)
rdp_string_free(&redirection->targetNetAddresses[i]);
for (i = 0; i < (int) redirection->TargetNetAddressesCount; i++)
{
if (redirection->TargetNetAddresses[i])
free(redirection->TargetNetAddresses[i]);
}
free(redirection->targetNetAddresses);
free(redirection->TargetNetAddresses);
}
free(redirection);
}
}

View File

@ -20,43 +20,41 @@
#ifndef __REDIRECTION_H
#define __REDIRECTION_H
typedef struct rdp_redirection rdpRedirection;
#include "rdp.h"
#include <freerdp/freerdp.h>
#include <freerdp/utils/debug.h>
#include <winpr/wlog.h>
#include <winpr/stream.h>
struct rdp_string
{
char* ascii;
char* unicode;
UINT32 length;
};
typedef struct rdp_string rdpString;
struct rdp_redirection
{
wLog* log;
UINT32 flags;
UINT32 sessionID;
rdpString tsvUrl;
rdpString username;
rdpString domain;
BYTE* PasswordCookie;
DWORD PasswordCookieLength;
rdpString targetFQDN;
BYTE* TsvUrl;
DWORD TsvUrlLength;
char* Username;
char* Domain;
BYTE* Password;
DWORD PasswordLength;
char* TargetFQDN;
BYTE* LoadBalanceInfo;
DWORD LoadBalanceInfoLength;
rdpString targetNetBiosName;
rdpString targetNetAddress;
UINT32 targetNetAddressesCount;
rdpString* targetNetAddresses;
char* TargetNetBiosName;
char* TargetNetAddress;
UINT32 TargetNetAddressesCount;
char** TargetNetAddresses;
};
typedef struct rdp_redirection rdpRedirection;
BOOL rdp_recv_redirection_packet(rdpRdp* rdp, wStream* s);
BOOL rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, wStream* s);
int rdp_redirection_apply_settings(rdpRdp* rdp);
rdpRedirection* redirection_new(void);
void redirection_free(rdpRedirection* redirection);

View File

@ -301,6 +301,9 @@ rdpSettings* freerdp_settings_new(DWORD flags)
ZeroMemory(settings->ClientHostname, 32);
ZeroMemory(settings->ClientProductId, 32);
gethostname(settings->ClientHostname, 31);
settings->ClientHostname[31] = 0;
settings->ColorPointerFlag = TRUE;
settings->LargePointerFlag = TRUE;
settings->PointerCacheSize = 20;
@ -381,9 +384,6 @@ rdpSettings* freerdp_settings_new(DWORD flags)
settings->FastPathOutput = TRUE;
settings->FrameAcknowledge = 2;
gethostname(settings->ClientHostname, 31);
settings->ClientHostname[31] = 0;
settings->MouseMotion = TRUE;
settings->AutoReconnectionEnabled = TRUE;
@ -444,8 +444,8 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
_settings->Username = _strdup(settings->Username); /* 21 */
_settings->Password = _strdup(settings->Password); /* 22 */
_settings->Domain = _strdup(settings->Domain); /* 23 */
_settings->ClientHostname = _strdup(settings->ClientHostname); /* 134 */
_settings->ClientProductId = _strdup(settings->ClientProductId); /* 135 */
//_settings->ClientHostname = _strdup(settings->ClientHostname); /* 134 */
//_settings->ClientProductId = _strdup(settings->ClientProductId); /* 135 */
_settings->AlternateShell = _strdup(settings->AlternateShell); /* 640 */
_settings->ShellWorkingDirectory = _strdup(settings->ShellWorkingDirectory); /* 641 */
_settings->ClientAddress = _strdup(settings->ClientAddress); /* 769 */
@ -515,11 +515,7 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
_settings->PreconnectionId = settings->PreconnectionId; /* 1154 */
_settings->RedirectionFlags = settings->RedirectionFlags; /* 1216 */
_settings->LoadBalanceInfoLength = settings->LoadBalanceInfoLength; /* 1218 */
_settings->RedirectionUsernameLength = settings->RedirectionUsernameLength; /* 1220 */
_settings->RedirectionDomainLength = settings->RedirectionDomainLength; /* 1222 */
_settings->RedirectionPasswordLength = settings->RedirectionPasswordLength; /* 1224 */
_settings->RedirectionTargetFQDNLength = settings->RedirectionTargetFQDNLength; /* 1226 */
_settings->RedirectionTargetNetBiosNameLength = settings->RedirectionTargetNetBiosNameLength; /* 1228 */
_settings->RedirectionTsvUrlLength = settings->RedirectionTsvUrlLength; /* 1230 */
_settings->TargetNetAddressCount = settings->TargetNetAddressCount; /* 1231 */
_settings->Password51Length = settings->Password51Length; /* 1281 */
@ -725,6 +721,16 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings)
_settings->ClientTimeZone = (TIME_ZONE_INFO*) malloc(sizeof(TIME_ZONE_INFO));
CopyMemory(_settings->ClientTimeZone, _settings->ClientTimeZone, sizeof(TIME_ZONE_INFO));
_settings->TargetNetAddressCount = settings->TargetNetAddressCount;
if (settings->TargetNetAddressCount > 0)
{
_settings->TargetNetAddresses = (char**) malloc(sizeof(char*) * settings->TargetNetAddressCount);
for (index = 0; index < settings->TargetNetAddressCount; index++)
_settings->TargetNetAddresses[index] = _strdup(settings->TargetNetAddresses[index]);
}
_settings->DeviceCount = settings->DeviceCount;
_settings->DeviceArraySize = settings->DeviceArraySize;
_settings->DeviceArray = (RDPDR_DEVICE**) malloc(sizeof(RDPDR_DEVICE*) * _settings->DeviceArraySize);
@ -801,6 +807,14 @@ void freerdp_settings_free(rdpSettings* settings)
free(settings->CurrentPath);
free(settings->HomePath);
free(settings->LoadBalanceInfo);
free(settings->TargetNetAddress);
free(settings->RedirectionTargetFQDN);
free(settings->RedirectionTargetNetBiosName);
free(settings->RedirectionUsername);
free(settings->RedirectionDomain);
free(settings->RedirectionPassword);
free(settings->RedirectionTsvUrl);
freerdp_target_net_addresses_free(settings);
freerdp_device_collection_free(settings);
freerdp_static_channel_collection_free(settings);
freerdp_dynamic_channel_collection_free(settings);

View File

@ -79,6 +79,13 @@ void tcp_get_ip_address(rdpTcp * tcp)
tcp->ip_address[sizeof(tcp->ip_address) - 1] = 0;
tcp->settings->IPv6Enabled = 0;
if (tcp->settings->ClientAddress)
{
free(tcp->settings->ClientAddress);
tcp->settings->ClientAddress = NULL;
}
tcp->settings->ClientAddress = _strdup(tcp->ip_address);
}
@ -262,6 +269,9 @@ int tcp_attach(rdpTcp* tcp, int sockfd)
HANDLE tcp_get_event_handle(rdpTcp* tcp)
{
if (!tcp)
return NULL;
#ifndef _WIN32
return tcp->event;
#else

View File

@ -77,7 +77,7 @@ BOOL transport_disconnect(rdpTransport* transport)
if (transport->layer == TRANSPORT_LAYER_TLS)
status &= tls_disconnect(transport->TlsIn);
if (transport->layer == TRANSPORT_LAYER_TSG)
if (transport->layer == TRANSPORT_LAYER_TSG || transport->layer == TRANSPORT_LAYER_TSG_TLS)
{
tsg_disconnect(transport->tsg);
}
@ -88,12 +88,19 @@ BOOL transport_disconnect(rdpTransport* transport)
if (transport->async)
{
SetEvent(transport->stopEvent);
WaitForSingleObject(transport->thread, INFINITE);
if (transport->stopEvent)
{
SetEvent(transport->stopEvent);
WaitForSingleObject(transport->thread, INFINITE);
CloseHandle(transport->thread);
CloseHandle(transport->stopEvent);
CloseHandle(transport->thread);
CloseHandle(transport->stopEvent);
transport->thread = NULL;
transport->stopEvent = NULL;
}
}
return status;
}
@ -106,9 +113,6 @@ BOOL transport_connect_rdp(rdpTransport* transport)
long transport_bio_tsg_callback(BIO* bio, int mode, const char* argp, int argi, long argl, long ret)
{
printf("transport_bio_tsg_callback: mode: %d argp: %p argi: %d argl: %d ret: %d\n",
mode, argp, argi, argl, ret);
return 1;
}
@ -117,13 +121,9 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
int status;
rdpTsg* tsg;
printf("transport_bio_tsg_write: %d\n", num);
tsg = (rdpTsg*) bio->ptr;
status = tsg_write(tsg, (BYTE*) buf, num);
printf("tsg_write: %d\n", status);
BIO_clear_retry_flags(bio);
if (status <= 0)
@ -139,13 +139,9 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
int status;
rdpTsg* tsg;
printf("transport_bio_tsg_read: %d\n", size);
tsg = (rdpTsg*) bio->ptr;
status = tsg_read(bio->ptr, (BYTE*) buf, size);
printf("tsg_read: %d\n", status);
BIO_clear_retry_flags(bio);
if (status <= 0)
@ -153,31 +149,31 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
BIO_set_retry_read(bio);
}
return status;
return status > 0 ? status : -1;
}
static int transport_bio_tsg_puts(BIO* bio, const char* str)
{
printf("transport_bio_tsg_puts: %d\n", strlen(str));
return 1;
}
static int transport_bio_tsg_gets(BIO* bio, char* str, int size)
{
printf("transport_bio_tsg_gets: %d\n", size);
return 1;
}
static long transport_bio_tsg_ctrl(BIO* bio, int cmd, long arg1, void* arg2)
{
printf("transport_bio_tsg_ctrl: cmd: %d arg1: %d arg2: %p\n", cmd, arg1, arg2);
return 1;
if (cmd == BIO_CTRL_FLUSH)
{
return 1;
}
return 0;
}
static int transport_bio_tsg_new(BIO* bio)
{
printf("transport_bio_tsg_new\n");
bio->init = 1;
bio->num = 0;
bio->ptr = NULL;
@ -188,7 +184,6 @@ static int transport_bio_tsg_new(BIO* bio)
static int transport_bio_tsg_free(BIO* bio)
{
printf("transport_bio_tsg_free\n");
return 1;
}
@ -217,28 +212,20 @@ BOOL transport_connect_tls(rdpTransport* transport)
{
if (transport->layer == TRANSPORT_LAYER_TSG)
{
if (!transport->TlsIn)
transport->TlsIn = tls_new(transport->settings);
transport->TsgTls = tls_new(transport->settings);
if (!transport->TlsOut)
transport->TlsOut = transport->TlsIn;
transport->TsgTls->methods = BIO_s_tsg();
transport->TsgTls->tsg = (void*) transport->tsg;
transport->TlsIn->methods = BIO_s_tsg();
transport->TlsIn->tsg = (void*) transport->tsg;
transport->layer = TRANSPORT_LAYER_TSG_TLS;
transport->layer = TRANSPORT_LAYER_TLS;
if (tls_connect(transport->TlsIn) != TRUE)
if (tls_connect(transport->TsgTls) != TRUE)
{
if (!connectErrorCode)
connectErrorCode = TLSCONNECTERROR;
tls_free(transport->TlsIn);
if (transport->TlsIn == transport->TlsOut)
transport->TlsIn = transport->TlsOut = NULL;
else
transport->TlsIn = NULL;
tls_free(transport->TsgTls);
transport->TsgTls = NULL;
return FALSE;
}
@ -278,9 +265,6 @@ BOOL transport_connect_nla(rdpTransport* transport)
freerdp* instance;
rdpSettings* settings;
if (transport->layer == TRANSPORT_LAYER_TSG)
return TRUE;
if (!transport_connect_tls(transport))
return FALSE;
@ -348,15 +332,7 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
BOOL status = FALSE;
rdpSettings* settings = transport->settings;
transport->async = transport->settings->AsyncTransport;
if (transport->async)
{
transport->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
transport->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) transport_client_thread, transport, 0, NULL);
}
transport->async = settings->AsyncTransport;
if (transport->settings->GatewayEnabled)
{
@ -379,6 +355,17 @@ BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 por
transport->TcpOut = transport->TcpIn;
}
if (status)
{
if (transport->async)
{
transport->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
transport->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) transport_client_thread, transport, 0, NULL);
}
}
return status;
}
@ -522,6 +509,9 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
status = tcp_read(transport->TcpIn, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TSG)
status = tsg_read(transport->tsg, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS) {
status = tls_read(transport->TsgTls, data + read, bytes - read);
}
/* blocking means that we can't continue until this is read */
@ -556,6 +546,12 @@ int transport_read(rdpTransport* transport, wStream* s)
pduLength = 0;
transport_status = 0;
if (!transport)
return -1;
if (!s)
return -1;
/* first check if we have header */
streamPosition = Stream_GetPosition(s);
@ -687,6 +683,8 @@ int transport_write(rdpTransport* transport, wStream* s)
status = tcp_write(transport->TcpOut, Stream_Pointer(s), length);
else if (transport->layer == TRANSPORT_LAYER_TSG)
status = tsg_write(transport->tsg, Stream_Pointer(s), length);
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
status = tls_write(transport->TsgTls, Stream_Pointer(s), length);
if (status < 0)
break; /* error occurred */
@ -705,6 +703,8 @@ int transport_write(rdpTransport* transport, wStream* s)
tls_wait_write(transport->TlsOut);
else if (transport->layer == TRANSPORT_LAYER_TCP)
tcp_wait_write(transport->TcpOut);
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
tls_wait_write(transport->TsgTls);
else
USleep(transport->SleepInterval);
}
@ -796,14 +796,16 @@ void transport_get_read_handles(rdpTransport* transport, HANDLE* events, DWORD*
}
}
int transport_check_fds(rdpTransport** ptransport)
int transport_check_fds(rdpTransport* transport)
{
int pos;
int status;
UINT16 length;
int recv_status;
wStream* received;
rdpTransport* transport = *ptransport;
if (!transport)
return -1;
#ifdef _WIN32
WSAResetEvent(transport->TcpIn->wsa_event);
@ -893,22 +895,32 @@ int transport_check_fds(rdpTransport** ptransport)
Stream_SealLength(received);
Stream_SetPosition(received, 0);
/**
* status:
* -1: error
* 0: success
* 1: redirection
*/
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
if (transport == *ptransport)
/* transport might now have been freed by rdp_client_redirect and a new rdp->transport created */
/* so only release if still valid */
Stream_Release(received);
if (recv_status == 1)
{
/**
* Last call to ReceiveCallback resulted in a session redirection,
* which means the current rdpTransport* transport pointer has been freed.
* Return 0 for success, the rest of this function is meant for non-redirected cases.
*/
return 0;
}
Stream_Release(received);
if (recv_status < 0)
status = -1;
if (status < 0)
return status;
/* transport might now have been freed by rdp_client_redirect and a new rdp->transport created */
transport = *ptransport;
}
return 0;
@ -931,7 +943,7 @@ BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
status &= tcp_set_blocking_mode(transport->TcpIn, blocking);
}
if (transport->layer == TRANSPORT_LAYER_TSG)
if (transport->layer == TRANSPORT_LAYER_TSG || transport->layer == TRANSPORT_LAYER_TSG_TLS)
{
tsg_set_blocking_mode(transport->tsg, blocking);
}
@ -1028,8 +1040,6 @@ void transport_free(rdpTransport* transport)
{
if (transport)
{
SetEvent(transport->stopEvent);
if (transport->ReceiveBuffer)
Stream_Release(transport->ReceiveBuffer);
@ -1044,12 +1054,20 @@ void transport_free(rdpTransport* transport)
if (transport->TlsOut != transport->TlsIn)
tls_free(transport->TlsOut);
tcp_free(transport->TcpIn);
transport->TlsIn = NULL;
transport->TlsOut = NULL;
if (transport->TcpIn)
tcp_free(transport->TcpIn);
if (transport->TcpOut != transport->TcpIn)
tcp_free(transport->TcpOut);
transport->TcpIn = NULL;
transport->TcpOut = NULL;
tsg_free(transport->tsg);
transport->tsg = NULL;
CloseHandle(transport->ReadMutex);
CloseHandle(transport->WriteMutex);

View File

@ -59,6 +59,7 @@ struct rdp_transport
rdpTcp* TcpOut;
rdpTls* TlsIn;
rdpTls* TlsOut;
rdpTls* TsgTls;
rdpCredssp* credssp;
rdpSettings* settings;
UINT32 SleepInterval;
@ -93,7 +94,7 @@ BOOL transport_accept_nla(rdpTransport* transport);
int transport_read(rdpTransport* transport, wStream* s);
int transport_write(rdpTransport* transport, wStream* s);
void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount);
int transport_check_fds(rdpTransport** ptransport);
int transport_check_fds(rdpTransport* transport);
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking);
void transport_get_read_handles(rdpTransport* transport, HANDLE* events, DWORD* count);

View File

@ -1612,7 +1612,7 @@ void update_free(rdpUpdate* update)
free(update->primary->polyline.points);
free(update->primary->polygon_sc.points);
if (NULL != update->primary->fast_glyph.glyphData.aj)
if (update->primary->fast_glyph.glyphData.aj)
free(update->primary->fast_glyph.glyphData.aj);
free(update->primary);

View File

@ -66,7 +66,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -99,8 +99,6 @@ SecPkgContext_Bindings* tls_get_channel_bindings(X509* cert)
static void tls_ssl_info_callback(const SSL* ssl, int type, int val)
{
printf("tls_ssl_info_callback: type: %d val: %d\n", type, val);
if (type & SSL_CB_HANDSHAKE_START)
{
@ -373,9 +371,15 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
int error;
int status;
status = tls ? SSL_read(tls->ssl, data, length) : -1;
if (!tls)
return -1;
if (tls && status <= 0)
if (!tls->ssl)
return -1;
status = SSL_read(tls->ssl, data, length);
if (status <= 0)
{
error = SSL_get_error(tls->ssl, status);
@ -414,26 +418,17 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
return status;
}
int tls_read_all(rdpTls* tls, BYTE* data, int length)
{
int status;
do
{
status = tls_read(tls, data, length);
if (status == 0)
tls_wait_read(tls);
}
while (status == 0);
return status;
}
int tls_write(rdpTls* tls, BYTE* data, int length)
{
int error;
int status;
if (!tls)
return -1;
if (!tls->ssl)
return -1;
status = SSL_write(tls->ssl, data, length);
if (status <= 0)
@ -779,7 +774,7 @@ rdpTls* tls_new(rdpSettings* settings)
tls = (rdpTls*) malloc(sizeof(rdpTls));
if (tls != NULL)
if (tls)
{
ZeroMemory(tls, sizeof(rdpTls));
@ -795,7 +790,7 @@ rdpTls* tls_new(rdpSettings* settings)
void tls_free(rdpTls* tls)
{
if (tls != NULL)
if (tls)
{
if (tls->ssl)
{

View File

@ -54,7 +54,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -1036,7 +1036,7 @@ int gdi_init(freerdp* instance, UINT32 flags, BYTE* buffer)
gdi->tile = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL);
gdi->image = gdi_bitmap_new_ex(gdi, 64, 64, 32, NULL);
if (cache == NULL)
if (!cache)
{
cache = cache_new(instance->settings);
instance->context->cache = cache;

View File

@ -90,7 +90,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -89,7 +89,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -40,7 +40,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

View File

@ -64,7 +64,7 @@ if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT FreeRDPTargets)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp")

Some files were not shown because too many files have changed in this diff Show More