freerdp: merge with master

This commit is contained in:
Marc-André Moreau 2013-09-16 17:10:27 -04:00
commit 518995a05e
109 changed files with 1814 additions and 336 deletions

View File

@ -158,7 +158,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
endif()
if(CMAKE_COMPILER_IS_CLANG)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Weverything -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-macros -Wno-padded")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-c11-extensions -Wno-gnu")
if(WITH_SSE2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
endif()

View File

@ -163,14 +163,9 @@ static BOOL audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
}
if (WaitForSingleObject(alsa->stopEvent, 0) == WAIT_OBJECT_0)
{
ret = 0;
frames = 0;
}
break;
else
{
ret = alsa->receive(encoded_data, encoded_size, alsa->user_data);
}
alsa->buffer_frames = 0;
@ -182,7 +177,7 @@ static BOOL audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
frames -= cframes;
}
return ret;
return (ret) ? TRUE : FALSE;
}
static void* audin_alsa_thread_func(void* arg)
@ -198,9 +193,6 @@ static void* audin_alsa_thread_func(void* arg)
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
alsa->buffer = (BYTE*) malloc(tbytes_per_frame * alsa->frames_per_packet);
ZeroMemory(alsa->buffer, tbytes_per_frame * alsa->frames_per_packet);
alsa->buffer_frames = 0;
buffer = (BYTE*) malloc(rbytes_per_frame * alsa->frames_per_packet);
ZeroMemory(buffer, rbytes_per_frame * alsa->frames_per_packet);
freerdp_dsp_context_reset_adpcm(alsa->dsp_context);
@ -241,15 +233,11 @@ static void* audin_alsa_thread_func(void* arg)
free(buffer);
free(alsa->buffer);
alsa->buffer = NULL;
if (capture_handle)
snd_pcm_close(capture_handle);
SetEvent(alsa->stopEvent);
DEBUG_DVC("out");
ExitThread(0);
return NULL;
}
@ -258,8 +246,6 @@ static void audin_alsa_free(IAudinDevice* device)
{
AudinALSADevice* alsa = (AudinALSADevice*) device;
SetEvent(alsa->stopEvent);
freerdp_dsp_context_free(alsa->dsp_context);
free(alsa->device_name);
@ -337,6 +323,8 @@ static void audin_alsa_set_format(IAudinDevice* device, audinFormat* format, UIN
static void audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* user_data)
{
int rbytes_per_frame;
int tbytes_per_frame;
AudinALSADevice* alsa = (AudinALSADevice*) device;
DEBUG_DVC("");
@ -344,8 +332,15 @@ static void audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* us
alsa->receive = receive;
alsa->user_data = user_data;
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
alsa->buffer = (BYTE*) malloc(tbytes_per_frame * alsa->frames_per_packet);
ZeroMemory(alsa->buffer, tbytes_per_frame * alsa->frames_per_packet);
alsa->buffer_frames = 0;
alsa->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
alsa->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) audin_alsa_thread_func, alsa, 0, NULL);
alsa->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) audin_alsa_thread_func, alsa, 0, NULL);
}
static void audin_alsa_close(IAudinDevice* device)
@ -355,7 +350,16 @@ static void audin_alsa_close(IAudinDevice* device)
DEBUG_DVC("");
SetEvent(alsa->stopEvent);
WaitForSingleObject(alsa->thread, INFINITE);
CloseHandle(alsa->stopEvent);
CloseHandle(alsa->thread);
if (alsa->buffer)
free(alsa->buffer);
alsa->buffer = NULL;
alsa->stopEvent = NULL;
alsa->thread = NULL;
alsa->receive = NULL;
alsa->user_data = NULL;
}

View File

@ -540,3 +540,4 @@ int freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEnt
return 0;
}

View File

@ -422,7 +422,9 @@ static BOOL audin_server_close(audin_server_context* context)
SetEvent(audin->stopEvent);
WaitForSingleObject(audin->thread, INFINITE);
CloseHandle(audin->thread);
CloseHandle(audin->stopEvent);
audin->thread = NULL;
audin->stopEvent = NULL;
}
if (audin->audin_channel)

View File

@ -182,10 +182,14 @@ FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPSTR pszName, LPSTR pszSub
NativePathCchAppendA(pszSearchPath, cchSearchPath + 1, pszAddinPath);
NativePathCchAppendA(pszSearchPath, cchSearchPath + 1, pszPattern);
free(pszPattern);
cchSearchPath = strlen(pszSearchPath);
hFind = FindFirstFileA(pszSearchPath, &FindData);
free(pszSearchPath);
nAddins = 0;
ppAddins = (FREERDP_ADDIN**) malloc(sizeof(FREERDP_ADDIN*) * 128);
ppAddins[nAddins] = NULL;

View File

@ -631,8 +631,9 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve
/**
* called only from main thread
*/
static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instance)
static int freerdp_channels_process_sync(rdpChannels* channels, freerdp* instance)
{
int rc = TRUE;
wMessage message;
wMessage* event;
rdpChannel* channel;
@ -642,7 +643,10 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan
while (MessageQueue_Peek(channels->MsgPipe->Out, &message, TRUE))
{
if (message.id == WMQ_QUIT)
{
rc = FALSE;
break;
}
if (message.id == 0)
{
@ -677,6 +681,8 @@ static void freerdp_channels_process_sync(rdpChannels* channels, freerdp* instan
*/
}
}
return rc;
}
/**
@ -730,7 +736,7 @@ int freerdp_channels_process_pending_messages(freerdp* instance)
if (WaitForSingleObject(MessageQueue_Event(channels->MsgPipe->Out), 0) == WAIT_OBJECT_0)
{
freerdp_channels_process_sync(channels, instance);
return freerdp_channels_process_sync(channels, instance);
}
return TRUE;
@ -782,4 +788,7 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
if (pChannelClientData->pChannelInitEventProc)
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_TERMINATED, 0, 0);
}
/* Emit a quit signal to the internal message pipe. */
MessagePipe_PostQuit(channels->MsgPipe, 0);
}

View File

@ -61,21 +61,25 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
for (i = 0; i < cb_event->num_formats; i++)
{
const char* name;
int name_length;
int name_length, short_name_length = 32, x;
switch (cb_event->formats[i])
{
case CB_FORMAT_HTML:
name = CFSTR_HTML; name_length = sizeof(CFSTR_HTML);
name = CFSTR_HTML;
name_length = sizeof(CFSTR_HTML);
break;
case CB_FORMAT_PNG:
name = CFSTR_PNG; name_length = sizeof(CFSTR_PNG);
name = CFSTR_PNG;
name_length = sizeof(CFSTR_PNG);
break;
case CB_FORMAT_JPEG:
name = CFSTR_JPEG; name_length = sizeof(CFSTR_JPEG);
name = CFSTR_JPEG;
name_length = sizeof(CFSTR_JPEG);
break;
case CB_FORMAT_GIF:
name = CFSTR_GIF; name_length = sizeof(CFSTR_GIF);
name = CFSTR_GIF;
name_length = sizeof(CFSTR_GIF);
break;
default:
name = "\0\0";
@ -84,12 +88,23 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
}
if (!cliprdr->use_long_format_names)
name_length = 32;
{
x = (name_length > short_name_length) ?
name_length : short_name_length;
Stream_EnsureRemainingCapacity(body, 4 + name_length);
Stream_EnsureRemainingCapacity(body, 4 + short_name_length);
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, x);
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, name_length);
while (x++ < short_name_length)
Stream_Write(body, "\0", 1);
}
else
{
Stream_EnsureRemainingCapacity(body, 4 + name_length);
Stream_Write_UINT32(body, cb_event->formats[i]);
Stream_Write(body, name, name_length);
}
}
Stream_SealLength(body);

View File

@ -117,7 +117,7 @@ static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* disk, UINT32 id)
static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
char* path = NULL;
int status;
UINT32 FileId;
DRIVE_FILE* file;
@ -633,17 +633,18 @@ static void drive_process_irp_list(DRIVE_DEVICE* disk)
static void* drive_thread_func(void* arg)
{
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) arg;
HANDLE hdl[] = {disk->irpEvent, disk->stopEvent};
while (1)
{
WaitForSingleObject(disk->irpEvent, INFINITE);
if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0)
DWORD rc = WaitForMultipleObjects(2, hdl, FALSE, INFINITE);
if (rc == WAIT_OBJECT_0 + 1)
break;
ResetEvent(disk->irpEvent);
drive_process_irp_list(disk);
}
ExitThread(0);
return NULL;
}
@ -664,8 +665,10 @@ static void drive_free(DEVICE* device)
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device;
SetEvent(disk->stopEvent);
WaitForSingleObject(disk->thread, INFINITE);
CloseHandle(disk->thread);
CloseHandle(disk->irpEvent);
CloseHandle(disk->stopEvent);
while ((irp = (IRP*) InterlockedPopEntrySList(disk->pIrpList)) != NULL)
irp->Discard(irp);
@ -727,7 +730,7 @@ void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char*
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
ResumeThread(disk->thread);
ResumeThread(disk->thread);
}
}

View File

@ -137,7 +137,7 @@ static void parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
buffer = (BYTE*) malloc(Length);
status = read(parallel->file, irp->output->pointer, Length);
status = read(parallel->file, buffer, Length);
if (status < 0)
{

View File

@ -200,6 +200,8 @@ static void* printer_thread_func(void* arg)
printer_process_irp(printer_dev, irp);
}
ExitThread(0);
return NULL;
}
@ -219,11 +221,14 @@ static void printer_free(DEVICE* device)
SetEvent(printer_dev->stopEvent);
WaitForSingleObject(printer_dev->thread, INFINITE);
CloseHandle(printer_dev->thread);
while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
irp->Discard(irp);
CloseHandle(printer_dev->thread);
CloseHandle(printer_dev->stopEvent);
CloseHandle(printer_dev->event);
_aligned_free(printer_dev->pIrpList);
if (printer_dev->printer)

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -97,6 +98,7 @@ struct _RDPEI_PLUGIN
RDPINPUT_CONTACT_POINT* contactPoints;
HANDLE event;
HANDLE stopEvent;
HANDLE thread;
CRITICAL_SECTION lock;
@ -156,10 +158,16 @@ static void* rdpei_schedule_thread(void* arg)
DWORD status;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) arg;
RdpeiClientContext* context = (RdpeiClientContext*) rdpei->iface.pInterface;
HANDLE hdl[] = {rdpei->event, rdpei->stopEvent};
assert(NULL != rdpei);
assert(NULL != context);
while (1)
{
status = WaitForSingleObject(rdpei->event, 20);
status = WaitForMultipleObjects(2, hdl, FALSE, 20);
if (status == WAIT_OBJECT_0 + 1)
break;
EnterCriticalSection(&rdpei->lock);
@ -174,6 +182,8 @@ static void* rdpei_schedule_thread(void* arg)
LeaveCriticalSection(&rdpei->lock);
}
ExitThread(0);
return NULL;
}
@ -218,13 +228,6 @@ int rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback)
Stream_SealLength(s);
if (!rdpei->thread)
{
InitializeCriticalSection(&rdpei->lock);
rdpei->event = CreateEvent(NULL, TRUE, FALSE, NULL);
rdpei->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) rdpei_schedule_thread, (void*) rdpei, 0, NULL);
}
status = rdpei_send_pdu(callback, s, EVENTID_CS_READY, pduLength);
Stream_Free(s, TRUE);
@ -488,6 +491,12 @@ static int rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
rdpei->listener->pInterface = rdpei->iface.pInterface;
InitializeCriticalSection(&rdpei->lock);
rdpei->event = CreateEvent(NULL, TRUE, FALSE, NULL);
rdpei->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
rdpei->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
rdpei_schedule_thread, (void*) rdpei, 0, NULL);
return status;
}
@ -497,6 +506,22 @@ static int rdpei_plugin_terminated(IWTSPlugin* pPlugin)
DEBUG_DVC("");
assert(NULL != pPlugin);
SetEvent(rdpei->stopEvent);
EnterCriticalSection(&rdpei->lock);
WaitForSingleObject(rdpei->thread, INFINITE);
CloseHandle(rdpei->stopEvent);
CloseHandle(rdpei->event);
CloseHandle(rdpei->thread);
DeleteCriticalSection(&rdpei->lock);
if (rdpei->listener_callback)
free(rdpei->listener_callback);
free(rdpei);
return 0;

View File

@ -146,8 +146,10 @@ void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
rdpsnd->NumberOfClientFormats = 0;
rdpsnd->ClientFormats = NULL;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
if (!rdpsnd->NumberOfServerFormats)
return;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++)
{
serverFormat = &rdpsnd->ServerFormats[index];
@ -417,7 +419,10 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
wave->wAudioLength = rdpsnd_compute_audio_time_length(format, size);
if (!rdpsnd->device)
{
free(wave);
return;
}
if (rdpsnd->device->WaveDecode)
{
@ -439,6 +444,8 @@ static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
wave->wLocalTimeB = wave->wLocalTimeA + wave->wAudioLength + TIME_DELAY_MS;
rdpsnd->device->WaveConfirm(rdpsnd->device, wave);
}
else
free(wave);
}
static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd)

View File

@ -0,0 +1,563 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Server Audio Virtual Channel
*
* Copyright 2012 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/print.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include <winpr/stream.h>
#include <freerdp/codec/dsp.h>
#include <freerdp/channels/wtsvc.h>
#include <freerdp/server/rdpsnd.h>
typedef struct _rdpsnd_server
{
rdpsnd_server_context context;
HANDLE thread;
HANDLE StopEvent;
void* rdpsnd_channel;
wStream* rdpsnd_pdu;
FREERDP_DSP_CONTEXT* dsp_context;
BYTE* out_buffer;
int out_buffer_size;
int out_frames;
int out_pending_frames;
UINT32 src_bytes_per_sample;
UINT32 src_bytes_per_frame;
} rdpsnd_server;
static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, wStream* s)
{
int pos;
UINT16 i;
BOOL status;
Stream_Write_UINT8(s, SNDC_FORMATS);
Stream_Write_UINT8(s, 0);
Stream_Seek_UINT16(s);
Stream_Write_UINT32(s, 0); /* dwFlags */
Stream_Write_UINT32(s, 0); /* dwVolume */
Stream_Write_UINT32(s, 0); /* dwPitch */
Stream_Write_UINT16(s, 0); /* wDGramPort */
Stream_Write_UINT16(s, rdpsnd->context.num_server_formats); /* wNumberOfFormats */
Stream_Write_UINT8(s, rdpsnd->context.block_no); /* cLastBlockConfirmed */
Stream_Write_UINT16(s, 0x06); /* wVersion */
Stream_Write_UINT8(s, 0); /* bPad */
for (i = 0; i < rdpsnd->context.num_server_formats; i++)
{
Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */
Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */
Stream_Write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */
Stream_Write_UINT32(s, rdpsnd->context.server_formats[i].nSamplesPerSec *
rdpsnd->context.server_formats[i].nChannels *
rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */
Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */
Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */
Stream_Write_UINT16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */
if (rdpsnd->context.server_formats[i].cbSize > 0)
{
Stream_Write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize);
}
}
pos = Stream_GetPosition(s);
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
Stream_SetPosition(s, 0);
return status;
}
static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, wStream* s)
{
//unhandled for now
UINT16 timestamp = 0;
BYTE confirmBlockNum = 0;
Stream_Read_UINT16(s, timestamp);
Stream_Read_UINT8(s, confirmBlockNum);
Stream_Seek_UINT8(s); // padding
}
static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, wStream* s)
{
//unhandled for now
UINT16 quality;
Stream_Read_UINT16(s, quality);
Stream_Seek_UINT16(s); // reserved
fprintf(stderr, "Client requested sound quality: %#0X\n", quality);
}
static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, wStream* s)
{
int i, num_known_format = 0;
UINT32 flags, vol, pitch;
UINT16 udpPort, version;
BYTE lastblock;
Stream_Read_UINT32(s, flags); /* dwFlags */
Stream_Read_UINT32(s, vol); /* dwVolume */
Stream_Read_UINT32(s, pitch); /* dwPitch */
Stream_Read_UINT16(s, udpPort); /* wDGramPort */
Stream_Read_UINT16(s, rdpsnd->context.num_client_formats); /* wNumberOfFormats */
Stream_Read_UINT8(s, lastblock); /* cLastBlockConfirmed */
Stream_Read_UINT16(s, version); /* wVersion */
Stream_Seek_UINT8(s); /* bPad */
if (rdpsnd->context.num_client_formats > 0)
{
rdpsnd->context.client_formats = (AUDIO_FORMAT*) malloc(rdpsnd->context.num_client_formats * sizeof(AUDIO_FORMAT));
ZeroMemory(rdpsnd->context.client_formats, sizeof(AUDIO_FORMAT));
for (i = 0; i < rdpsnd->context.num_client_formats; i++)
{
Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].wFormatTag);
Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].nChannels);
Stream_Read_UINT32(s, rdpsnd->context.client_formats[i].nSamplesPerSec);
Stream_Read_UINT32(s, rdpsnd->context.client_formats[i].nAvgBytesPerSec);
Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].nBlockAlign);
Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].wBitsPerSample);
Stream_Read_UINT16(s, rdpsnd->context.client_formats[i].cbSize);
if (rdpsnd->context.client_formats[i].cbSize > 0)
{
Stream_Seek(s, rdpsnd->context.client_formats[i].cbSize);
}
if (rdpsnd->context.client_formats[i].wFormatTag != 0)
{
//lets call this a known format
//TODO: actually look through our own list of known formats
num_known_format++;
}
}
}
if (num_known_format == 0)
{
fprintf(stderr, "Client doesnt support any known formats!\n");
return FALSE;
}
return TRUE;
}
static void* rdpsnd_server_thread_func(void* arg)
{
void* fd;
wStream* s;
void* buffer;
DWORD status;
BYTE msgType;
UINT16 BodySize;
HANDLE events[2];
UINT32 bytes_returned = 0;
rdpsnd_server* rdpsnd = (rdpsnd_server*) arg;
events[0] = rdpsnd->StopEvent;
if (WTSVirtualChannelQuery(rdpsnd->rdpsnd_channel, WTSVirtualFileHandle, &buffer, &bytes_returned) == TRUE)
{
fd = *((void**) buffer);
WTSFreeMemory(buffer);
events[1] = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd);
}
s = Stream_New(NULL, 4096);
rdpsnd_server_send_formats(rdpsnd, s);
while (1)
{
status = WaitForMultipleObjects(2, events, FALSE, INFINITE);
if (WaitForSingleObject(rdpsnd->StopEvent, 0) == WAIT_OBJECT_0)
{
break;
}
Stream_SetPosition(s, 0);
if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, Stream_Buffer(s),
Stream_Capacity(s), &bytes_returned) == FALSE)
{
if (bytes_returned == 0)
break;
Stream_EnsureRemainingCapacity(s, (int) bytes_returned);
if (WTSVirtualChannelRead(rdpsnd->rdpsnd_channel, 0, Stream_Buffer(s),
Stream_Capacity(s), &bytes_returned) == FALSE)
break;
}
Stream_Read_UINT8(s, msgType);
Stream_Seek_UINT8(s); /* bPad */
Stream_Read_UINT16(s, BodySize);
switch (msgType)
{
case SNDC_WAVECONFIRM:
rdpsnd_server_recv_waveconfirm(rdpsnd, s);
break;
case SNDC_QUALITYMODE:
rdpsnd_server_recv_quality_mode(rdpsnd, s);
break;
case SNDC_FORMATS:
if (rdpsnd_server_recv_formats(rdpsnd, s))
{
IFCALL(rdpsnd->context.Activated, &rdpsnd->context);
}
break;
default:
fprintf(stderr, "UNKOWN MESSAGE TYPE!! (%#0X)\n\n", msgType);
break;
}
}
Stream_Free(s, TRUE);
return NULL;
}
static BOOL rdpsnd_server_initialize(rdpsnd_server_context* context)
{
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
rdpsnd->rdpsnd_channel = WTSVirtualChannelOpenEx(context->vcm, "rdpsnd", 0);
if (rdpsnd->rdpsnd_channel != NULL)
{
rdpsnd->rdpsnd_pdu = Stream_New(NULL, 4096);
rdpsnd->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
rdpsnd->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) rdpsnd_server_thread_func, (void*) rdpsnd, 0, NULL);
return TRUE;
}
else
{
return FALSE;
}
}
static void rdpsnd_server_select_format(rdpsnd_server_context* context, int client_format_index)
{
int bs;
int out_buffer_size;
AUDIO_FORMAT *format;
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
if (client_format_index < 0 || client_format_index >= context->num_client_formats)
{
fprintf(stderr, "rdpsnd_server_select_format: index %d is not correct.\n", client_format_index);
return;
}
rdpsnd->src_bytes_per_sample = context->src_format.wBitsPerSample / 8;
rdpsnd->src_bytes_per_frame = rdpsnd->src_bytes_per_sample * context->src_format.nChannels;
context->selected_client_format = client_format_index;
format = &context->client_formats[client_format_index];
if (format->nSamplesPerSec == 0)
{
fprintf(stderr, "Invalid Client Sound Format!!\n\n");
return;
}
if (format->wFormatTag == WAVE_FORMAT_DVI_ADPCM)
{
bs = (format->nBlockAlign - 4 * format->nChannels) * 4;
rdpsnd->out_frames = (format->nBlockAlign * 4 * format->nChannels * 2 / bs + 1) * bs / (format->nChannels * 2);
}
else if (format->wFormatTag == WAVE_FORMAT_ADPCM)
{
bs = (format->nBlockAlign - 7 * format->nChannels) * 2 / format->nChannels + 2;
rdpsnd->out_frames = bs * 4;
}
else
{
rdpsnd->out_frames = 0x4000 / rdpsnd->src_bytes_per_frame;
}
if (format->nSamplesPerSec != context->src_format.nSamplesPerSec)
{
rdpsnd->out_frames = (rdpsnd->out_frames * context->src_format.nSamplesPerSec + format->nSamplesPerSec - 100) / format->nSamplesPerSec;
}
rdpsnd->out_pending_frames = 0;
out_buffer_size = rdpsnd->out_frames * rdpsnd->src_bytes_per_frame;
if (rdpsnd->out_buffer_size < out_buffer_size)
{
rdpsnd->out_buffer = (BYTE*) realloc(rdpsnd->out_buffer, out_buffer_size);
rdpsnd->out_buffer_size = out_buffer_size;
}
freerdp_dsp_context_reset_adpcm(rdpsnd->dsp_context);
}
static BOOL rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
{
int size;
BYTE* src;
int frames;
int fill_size;
BOOL status;
AUDIO_FORMAT* format;
int tbytes_per_frame;
wStream* s = rdpsnd->rdpsnd_pdu;
format = &rdpsnd->context.client_formats[rdpsnd->context.selected_client_format];
tbytes_per_frame = format->nChannels * rdpsnd->src_bytes_per_sample;
if ((format->nSamplesPerSec == rdpsnd->context.src_format.nSamplesPerSec) &&
(format->nChannels == rdpsnd->context.src_format.nChannels))
{
src = rdpsnd->out_buffer;
frames = rdpsnd->out_pending_frames;
}
else
{
rdpsnd->dsp_context->resample(rdpsnd->dsp_context, rdpsnd->out_buffer, rdpsnd->src_bytes_per_sample,
rdpsnd->context.src_format.nChannels, rdpsnd->context.src_format.nSamplesPerSec, rdpsnd->out_pending_frames,
format->nChannels, format->nSamplesPerSec);
frames = rdpsnd->dsp_context->resampled_frames;
src = rdpsnd->dsp_context->resampled_buffer;
}
size = frames * tbytes_per_frame;
if (format->wFormatTag == WAVE_FORMAT_DVI_ADPCM)
{
rdpsnd->dsp_context->encode_ima_adpcm(rdpsnd->dsp_context,
src, size, format->nChannels, format->nBlockAlign);
src = rdpsnd->dsp_context->adpcm_buffer;
size = rdpsnd->dsp_context->adpcm_size;
}
else if (format->wFormatTag == WAVE_FORMAT_ADPCM)
{
rdpsnd->dsp_context->encode_ms_adpcm(rdpsnd->dsp_context,
src, size, format->nChannels, format->nBlockAlign);
src = rdpsnd->dsp_context->adpcm_buffer;
size = rdpsnd->dsp_context->adpcm_size;
}
rdpsnd->context.block_no = (rdpsnd->context.block_no + 1) % 256;
/* Fill to nBlockAlign for the last audio packet */
fill_size = 0;
if ((format->wFormatTag == WAVE_FORMAT_DVI_ADPCM || format->wFormatTag == WAVE_FORMAT_ADPCM) &&
(rdpsnd->out_pending_frames < rdpsnd->out_frames) && ((size % format->nBlockAlign) != 0))
{
fill_size = format->nBlockAlign - (size % format->nBlockAlign);
}
/* WaveInfo PDU */
Stream_SetPosition(s, 0);
Stream_Write_UINT8(s, SNDC_WAVE); /* msgType */
Stream_Write_UINT8(s, 0); /* bPad */
Stream_Write_UINT16(s, size + fill_size + 8); /* BodySize */
Stream_Write_UINT16(s, 0); /* wTimeStamp */
Stream_Write_UINT16(s, rdpsnd->context.selected_client_format); /* wFormatNo */
Stream_Write_UINT8(s, rdpsnd->context.block_no); /* cBlockNo */
Stream_Seek(s, 3); /* bPad */
Stream_Write(s, src, 4);
WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
Stream_SetPosition(s, 0);
/* Wave PDU */
Stream_EnsureRemainingCapacity(s, size + fill_size);
Stream_Write_UINT32(s, 0); /* bPad */
Stream_Write(s, src + 4, size - 4);
if (fill_size > 0)
Stream_Zero(s, fill_size);
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
Stream_SetPosition(s, 0);
rdpsnd->out_pending_frames = 0;
return status;
}
static BOOL rdpsnd_server_send_samples(rdpsnd_server_context* context, const void* buf, int nframes)
{
int cframes;
int cframesize;
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
if (rdpsnd->context.selected_client_format < 0)
return FALSE;
while (nframes > 0)
{
cframes = MIN(nframes, rdpsnd->out_frames - rdpsnd->out_pending_frames);
cframesize = cframes * rdpsnd->src_bytes_per_frame;
CopyMemory(rdpsnd->out_buffer + (rdpsnd->out_pending_frames * rdpsnd->src_bytes_per_frame), buf, cframesize);
buf = (BYTE*) buf + cframesize;
nframes -= cframes;
rdpsnd->out_pending_frames += cframes;
if (rdpsnd->out_pending_frames >= rdpsnd->out_frames)
{
if (!rdpsnd_server_send_audio_pdu(rdpsnd))
return FALSE;
}
}
return TRUE;
}
static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, int right)
{
int pos;
BOOL status;
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
wStream* s = rdpsnd->rdpsnd_pdu;
Stream_Write_UINT8(s, SNDC_SETVOLUME);
Stream_Write_UINT8(s, 0);
Stream_Seek_UINT16(s);
Stream_Write_UINT16(s, left);
Stream_Write_UINT16(s, right);
pos = Stream_GetPosition(s);
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
Stream_SetPosition(s, 0);
return status;
}
static BOOL rdpsnd_server_close(rdpsnd_server_context* context)
{
int pos;
BOOL status;
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
wStream* s = rdpsnd->rdpsnd_pdu;
if (rdpsnd->context.selected_client_format < 0)
return FALSE;
if (rdpsnd->out_pending_frames > 0)
{
if (!rdpsnd_server_send_audio_pdu(rdpsnd))
return FALSE;
}
rdpsnd->context.selected_client_format = -1;
Stream_Write_UINT8(s, SNDC_CLOSE);
Stream_Write_UINT8(s, 0);
Stream_Seek_UINT16(s);
pos = Stream_GetPosition(s);
Stream_SetPosition(s, 2);
Stream_Write_UINT16(s, pos - 4);
Stream_SetPosition(s, pos);
status = WTSVirtualChannelWrite(rdpsnd->rdpsnd_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
Stream_SetPosition(s, 0);
return status;
}
rdpsnd_server_context* rdpsnd_server_context_new(WTSVirtualChannelManager* vcm)
{
rdpsnd_server* rdpsnd;
rdpsnd = (rdpsnd_server*) malloc(sizeof(rdpsnd_server));
ZeroMemory(rdpsnd, sizeof(rdpsnd_server));
rdpsnd->context.vcm = vcm;
rdpsnd->context.selected_client_format = -1;
rdpsnd->context.Initialize = rdpsnd_server_initialize;
rdpsnd->context.SelectFormat = rdpsnd_server_select_format;
rdpsnd->context.SendSamples = rdpsnd_server_send_samples;
rdpsnd->context.SetVolume = rdpsnd_server_set_volume;
rdpsnd->context.Close = rdpsnd_server_close;
rdpsnd->dsp_context = freerdp_dsp_context_new();
return (rdpsnd_server_context*) rdpsnd;
}
void rdpsnd_server_context_free(rdpsnd_server_context* context)
{
rdpsnd_server* rdpsnd = (rdpsnd_server*) context;
SetEvent(rdpsnd->StopEvent);
WaitForSingleObject(rdpsnd->thread, INFINITE);
CloseHandle(rdpsnd->StopEvent);
CloseHandle(rdpsnd->thread);
if (rdpsnd->rdpsnd_channel)
WTSVirtualChannelClose(rdpsnd->rdpsnd_channel);
if (rdpsnd->rdpsnd_pdu)
Stream_Free(rdpsnd->rdpsnd_pdu, TRUE);
if (rdpsnd->out_buffer)
free(rdpsnd->out_buffer);
if (rdpsnd->dsp_context)
freerdp_dsp_context_free(rdpsnd->dsp_context);
if (rdpsnd->context.client_formats)
free(rdpsnd->context.client_formats);
free(rdpsnd);
}

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -346,6 +347,7 @@ void* serial_thread_mfunc(void* arg)
{
SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg;
assert(NULL != serial);
while(1)
{
int sl;
@ -366,6 +368,7 @@ void* serial_thread_mfunc(void* arg)
}
}
ExitThread(0);
return NULL;
}
@ -376,6 +379,7 @@ static void* serial_thread_func(void* arg)
SERIAL_DEVICE* serial = (SERIAL_DEVICE*)arg;
HANDLE ev[] = {serial->stopEvent, Queue_Event(serial->queue), serial->newEvent};
assert(NULL != serial);
while (1)
{
status = WaitForMultipleObjects(3, ev, FALSE, INFINITE);
@ -401,6 +405,7 @@ static void* serial_thread_func(void* arg)
serial_check_fds(serial);
}
ExitThread(0);
return NULL;
}

View File

@ -112,13 +112,16 @@ struct _SMARTCARD_IRP_WORKER
};
typedef struct _SMARTCARD_IRP_WORKER SMARTCARD_IRP_WORKER;
static void smartcard_process_irp_thread_func(SMARTCARD_IRP_WORKER* irpWorker)
static void *smartcard_process_irp_thread_func(SMARTCARD_IRP_WORKER* irpWorker)
{
smartcard_process_irp(irpWorker->smartcard, irpWorker->irp);
CloseHandle(irpWorker->thread);
free(irpWorker);
ExitThread(0);
return NULL;
}
static void* smartcard_thread_func(void* arg)

View File

@ -23,13 +23,11 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <strings.h>
#include <pthread.h>
#include <semaphore.h>
#define BOOL PCSC_BOOL
#include <PCSC/pcsclite.h>
@ -153,6 +151,7 @@ static void smartcard_output_buffer_limit(IRP* irp, char* buffer, unsigned int l
}
else
{
assert(NULL != buffer);
if (header < length)
length = header;
@ -485,6 +484,11 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
(unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
(unsigned) cur->dwEventState);
if (!cur->szReader)
{
DEBUG_WARN("cur->szReader=%p", cur->szReader);
continue;
}
if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
cur->dwCurrentState |= SCARD_STATE_IGNORE;
}
@ -966,15 +970,19 @@ static UINT32 handle_Transmit(IRP* irp)
Stream_Write_UINT32(irp->output, 0); /* pioRecvPci 0x00; */
smartcard_output_buffer_start(irp, cbRecvLength); /* start of recvBuf output */
smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
if (recvBuf)
{
smartcard_output_buffer_start(irp, cbRecvLength); /* start of recvBuf output */
smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
}
}
smartcard_output_alignment(irp, 8);
free(sendBuf);
free(recvBuf);
if (sendBuf)
free(sendBuf);
if (recvBuf)
free(recvBuf);
return status;
}
@ -1032,7 +1040,10 @@ static UINT32 handle_Control(IRP* irp)
sendBuffer = malloc(outBufferSize);
if (!sendBuffer)
{
free(recvBuffer);
return smartcard_output_return(irp, SCARD_E_NO_MEMORY);
}
status = SCardControl(hCard, (DWORD) controlCode, recvBuffer, (DWORD) recvLength,
sendBuffer, (DWORD) outBufferSize, &nBytesReturned);
@ -1231,7 +1242,10 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE));
if (!readerStates)
{
free(pAtrMasks);
return smartcard_output_return(irp, SCARD_E_NO_MEMORY);
}
for (i = 0; i < readerCount; i++)
{
@ -1271,6 +1285,11 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
(unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
(unsigned) cur->dwEventState);
if (!cur->szReader)
{
DEBUG_WARN("cur->szReader=%p", cur->szReader);
continue;
}
if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
cur->dwCurrentState |= SCARD_STATE_IGNORE;
}
@ -1281,6 +1300,8 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
DEBUG_SCARD("Failure: %s (0x%08x)",
pcsc_stringify_error(status), (unsigned) status);
free(readerStates);
free(pAtrMasks);
return smartcard_output_return(irp, status);
}
@ -1310,7 +1331,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
Stream_Write_UINT32(irp->output, 0x00084dd8);
Stream_Write_UINT32(irp->output, readerCount);
for (i = 0, rsCur = readerStates; i < readerCount; i++, rsCur++)
for (i = 0, cur = readerStates; i < readerCount; i++, cur++)
{
Stream_Write_UINT32(irp->output, cur->dwCurrentState);
Stream_Write_UINT32(irp->output, cur->dwEventState);
@ -1325,6 +1346,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
smartcard_output_alignment(irp, 8);
free(readerStates);
free(pAtrMasks);
return status;
}

View File

@ -74,11 +74,11 @@ static BOOL tsmf_alsa_open(ITSMFAudioDevice* audio, const char* device)
if (!device)
{
if (!alsa->device[0])
strcpy(alsa->device, "default");
strncpy(alsa->device, "default", sizeof(alsa->device));
}
else
{
strcpy(alsa->device, device);
strncpy(alsa->device, device, sizeof(alsa->device));
}
return tsmf_alsa_open_device(alsa);

View File

@ -279,6 +279,7 @@ static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, BYTE* da
default:
LLOGLN(urbdrc_debug, ("urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode));
zfree(OutputBuffer);
return -1;
break;
}
@ -1718,6 +1719,7 @@ static int urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, BYTE
break;
default:
fprintf(stderr, "urb_control_feature_request: Error Command %x\n", command);
zfree(out_data);
return -1;
}

View File

@ -485,6 +485,7 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(LIBUSB_DEVICE* libusb_dev)
if (ret < 0)
{
fprintf(stderr, "libusb_get_device_descriptor: ERROR!!\n");
free(descriptor);
return NULL;
}
@ -1543,6 +1544,9 @@ static int func_cancel_xact_request(TRANSFER_REQUEST *request)
{
int status;
if (!request)
return -1;
if ((!request->transfer) || (request->endpoint != request->transfer->endpoint) ||
(request->transfer->endpoint == 0) || (request->submit != 1))
{
@ -1583,6 +1587,8 @@ cancel_retry:
while (request_queue->has_next(request_queue))
{
request = request_queue->get_next(request_queue);
if (!request)
continue;
LLOGLN(libusb_debug, ("%s: CancelId:0x%x RequestId:0x%x endpoint 0x%x!!",
__func__, RequestId, request->RequestId, request->endpoint));

View File

@ -18,6 +18,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -287,6 +288,9 @@ static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, UINT32 M
LLOGLN(10, ("urdbrc_send_virtual_channel_add"));
assert(NULL != channel);
assert(NULL != channel->Write);
InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK);
out_size = 12;
@ -830,7 +834,10 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
transfer_data = (TRANSFER_DATA*) malloc(sizeof(TRANSFER_DATA));
if (transfer_data == NULL)
{
fprintf(stderr, "transfer_data is NULL!!");
return 0;
}
transfer_data->callback = callback;
transfer_data->urbdrc = urbdrc;

View File

@ -64,9 +64,11 @@
</string-array>
<string name="settings_resolution">Resolucion</string>
<string name="resolution_automatic">Automatico</string>
<string name="resolution_fit">Pantalla</string>
<string name="resolution_custom">Manual</string>
<string-array name="resolutions_array">
<item>Automatico</item>
<item>Ajuste a la pantalla</item>
<item>Manual</item>
<item>640x480</item>
<item>720x480</item>
@ -77,9 +79,12 @@
<item>1920x1080</item>
<item>1920x1200</item>
</string-array>
<!-- The strings in resolutions_values_array should not be localized -->
<!-- They are used for text comparison and must remain in english -->
<string-array name="resolutions_values_array">
<item>automatico</item>
<item>manual</item>
<item>automatic</item>
<item>fitscreen</item>
<item>custom</item>
<item>640x480</item>
<item>720x480</item>
<item>800x600</item>
@ -89,6 +94,7 @@
<item>1920x1080</item>
<item>1920x1200</item>
</string-array>
<!-- end protected string section -->
<string name="settings_width">Ancho</string>
<string name="settings_height">Altura</string>
<string name="settings_performance">Rendimiento</string>

View File

@ -63,9 +63,11 @@
</string-array>
<string name="settings_resolution">"Résolution"</string>
<string name="resolution_automatic">"Automatique"</string>
<string name="resolution_fit">"Agrandir la fenêtre"</string>
<string name="resolution_custom">"Personalisé"</string>
<string-array name="resolutions_array">
<item>"Automatique"</item>
<item>"Agrandir la fenêtre"</item>
<item>"Personalisé"</item>
<item>"640x480"</item>
<item>"720x480"</item>
@ -76,18 +78,22 @@
<item>"1920x1080"</item>
<item>"1920x1200"</item>
</string-array>
<!-- The strings in resolutions_values_array should not be localized -->
<!-- They are used for text comparison and must remain in english -->
<string-array name="resolutions_values_array">
<item>"Automatique"</item>
<item>"Personalisé"</item>
<item>"640x480"</item>
<item>"720x480"</item>
<item>"800x600"</item>
<item>"1024x768"</item>
<item>"1280x1024"</item>
<item>"1440x900"</item>
<item>"1920x1080"</item>
<item>"1920x1200"</item>
<item>automatic</item>
<item>fitscreen</item>
<item>custom</item>
<item>640x480</item>
<item>720x480</item>
<item>800x600</item>
<item>1024x768</item>
<item>1280x1024</item>
<item>1440x900</item>
<item>1920x1080</item>
<item>1920x1200</item>
</string-array>
<!-- end protected string section -->
<string name="settings_width">"Largeur"</string>
<string name="settings_height">"Hauteur"</string>
<string name="settings_performance">"Performance"</string>

View File

@ -64,9 +64,11 @@
</string-array>
<string name="settings_resolution">Resolutie</string>
<string name="resolution_automatic">Automatisch</string>
<string name="resolution_fit">Schermvullend</string>
<string name="resolution_custom">Aangepast</string>
<string-array name="resolutions_array">
<item>Automatisch</item>
<item>Schermvullend</item>
<item>Aangepast</item>
<item>640x480</item>
<item>720x480</item>
@ -77,9 +79,12 @@
<item>1920x1080</item>
<item>1920x1200</item>
</string-array>
<!-- The strings in resolutions_values_array should not be localized -->
<!-- They are used for text comparison and must remain in english -->
<string-array name="resolutions_values_array">
<item>Automatisch</item>
<item>Aangepast</item>
<item>automatic</item>
<item>fitscreen</item>
<item>custom</item>
<item>640x480</item>
<item>720x480</item>
<item>800x600</item>
@ -89,6 +94,7 @@
<item>1920x1080</item>
<item>1920x1200</item>
</string-array>
<!-- end protected string section -->
<string name="settings_width">Breedte</string>
<string name="settings_height">Hoogte</string>
<string name="settings_performance">Prestatie</string>

View File

@ -64,9 +64,11 @@
</string-array>
<string name="settings_resolution">Resolution</string>
<string name="resolution_automatic">Automatic</string>
<string name="resolution_fit">Fitscreen</string>
<string name="resolution_custom">Custom</string>
<string-array name="resolutions_array">
<item>Automatic</item>
<item>Fit Screen</item>
<item>Custom</item>
<item>640x480</item>
<item>720x480</item>
@ -79,6 +81,7 @@
</string-array>
<string-array name="resolutions_values_array">
<item>automatic</item>
<item>fitscreen</item>
<item>custom</item>
<item>640x480</item>
<item>720x480</item>

View File

@ -143,6 +143,7 @@ public class BookmarkBase implements Parcelable, Cloneable
// Screen Settings class
public static class ScreenSettings implements Parcelable
{
public static final int FITSCREEN = -2;
public static final int AUTOMATIC = -1;
public static final int CUSTOM = 0;
public static final int PREDEFINED = 1;
@ -174,7 +175,7 @@ public class BookmarkBase implements Parcelable, Cloneable
{
this.resolution = resolution;
if (resolution == AUTOMATIC) {
if (resolution == AUTOMATIC || resolution == FITSCREEN) {
width = 0;
height = 0;
}
@ -194,6 +195,11 @@ public class BookmarkBase implements Parcelable, Cloneable
this.height = height;
this.resolution = CUSTOM;
}
else if (resolution.equalsIgnoreCase("fitscreen"))
{
this.width = this.height = 0;
this.resolution = FITSCREEN;
}
else
{
this.width = this.height = 0;
@ -211,7 +217,7 @@ public class BookmarkBase implements Parcelable, Cloneable
if (isPredefined())
return (width + "x" + height);
return (isAutomatic() ? "automatic" : "custom");
return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic" : "custom");
}
public boolean isPredefined() {
@ -222,6 +228,10 @@ public class BookmarkBase implements Parcelable, Cloneable
return (resolution == AUTOMATIC);
}
public boolean isFitScreen() {
return (resolution == FITSCREEN);
}
public boolean isCustom() {
return (resolution == CUSTOM);
}

View File

@ -343,10 +343,17 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
else if (key.equals("bookmark.resolution") || key.equals("bookmark.colors") || key.equals("bookmark.width") || key.equals("bookmark.height"))
{
String resolution = sharedPreferences.getString("bookmark.resolution", "800x600");
if (resolution.equals("automatic"))
//compare english string from resolutions_values_array array, decode to localized
//text for display
if (resolution.equals("automatic")) {
resolution = getResources().getString(R.string.resolution_automatic);
else if (resolution.equals("custom"))
}
if (resolution.equals("custom")) {
resolution = getResources().getString(R.string.resolution_custom);
}
if (resolution.equals("fitscreen")) {
resolution = getResources().getString(R.string.resolution_fit);
}
resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16);
findPreference("bookmark.screen").setSummary(resolution);
}
@ -451,7 +458,7 @@ public class BookmarkActivity extends PreferenceActivity implements OnSharedPref
ListPreference listPreference = (ListPreference)findPreference(key);
listPreference.setSummary(listPreference.getEntry());
boolean enabled = listPreference.getValue().equals("custom");
boolean enabled = listPreference.getValue().equalsIgnoreCase(getResources().getString(R.string.resolution_custom));
if (key.equals("bookmark.resolution"))
{
findPreference("bookmark.width").setEnabled(enabled);

View File

@ -624,6 +624,10 @@ public class SessionActivity extends Activity
screenSettings.setWidth((int)((float)screenMax * 1.6f));
}
}
if (screenSettings.isFitScreen()) {
screenSettings.setHeight(screen_height);
screenSettings.setWidth(screen_width);
}
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(bookmark.getLabel());

View File

@ -206,9 +206,6 @@ int tfreerdp_run(freerdp* instance)
fd_set wfds_set;
rdpChannels* channels;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
channels = instance->context->channels;
freerdp_connect(instance);
@ -218,6 +215,8 @@ int tfreerdp_run(freerdp* instance)
rcount = 0;
wcount = 0;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -569,7 +569,10 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam)
rdpChannels* channels;
instance = (freerdp*) lpParam;
assert(NULL != instance);
wfc = (wfContext*) instance->context;
assert(NULL != wfc);
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
@ -690,13 +693,13 @@ DWORD WINAPI wf_client_thread(LPVOID lpParam)
}
/* cleanup */
wfc->mainThreadId = 0;
freerdp_channels_close(channels, instance);
freerdp_disconnect(instance);
printf("Main thread exited.\n");
ExitThread(0);
return 0;
}
@ -708,6 +711,7 @@ DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
HHOOK hook_handle;
wfc = (wfContext*) lpParam;
assert(NULL != wfc);
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance, 0);
@ -734,9 +738,9 @@ DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
fprintf(stderr, "failed to install keyboard hook\n");
}
wfc->keyboardThreadId = 0;
printf("Keyboard thread exited.\n");
ExitThread(0);
return (DWORD) NULL;
}
@ -1078,12 +1082,27 @@ int wfreerdp_client_stop(rdpContext* context)
{
wfContext* wfc = (wfContext*) context;
if (wfc->mainThreadId)
if (wfc->thread)
{
PostThreadMessage(wfc->mainThreadId, WM_QUIT, 0, 0);
if (wfc->keyboardThreadId)
WaitForSingleObject(wfc->thread, INFINITE);
CloseHandle(wfc->thread);
wfc->thread = NULL;
wfc->mainThreadId = 0;
}
if (wfc->keyboardThread)
{
PostThreadMessage(wfc->keyboardThreadId, WM_QUIT, 0, 0);
WaitForSingleObject(wfc->keyboardThread, INFINITE);
CloseHandle(wfc->keyboardThread);
wfc->keyboardThread = NULL;
wfc->keyboardThreadId = 0;
}
return 0;
}

View File

@ -11,7 +11,7 @@
LPSTR tmp = NULL;
LPCSTR tr_esc_str(LPCSTR arg)
LPSTR tr_esc_str(LPSTR arg)
{
size_t cs = 0, x, ds;
size_t s;
@ -26,7 +26,8 @@ LPCSTR tr_esc_str(LPCSTR arg)
s--;
/* Prepare a initial buffer with the size of the result string. */
tmp = malloc(s * sizeof(LPCSTR));
if (s)
tmp = (LPSTR)malloc(s * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not allocate string buffer.");
@ -41,7 +42,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
{
case '<':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -54,7 +55,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '>':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -67,7 +68,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '\'':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -82,7 +83,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '"':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -97,7 +98,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '&':
ds += 4;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -154,12 +155,12 @@ int main(int argc, char *argv[])
const COMMAND_LINE_ARGUMENT_A *arg = &args[x];
fprintf(fp, "\t\t\t<varlistentry>\n");
if( COMMAND_LINE_VALUE_REQUIRED == arg->Flags )
fprintf(fp, "\t\t\t\t<term><option>/%s</option> <replaceable>%s</replaceable></term>\n", tr_esc_str(arg->Name), tr_esc_str(arg->Format) );
if ( COMMAND_LINE_VALUE_REQUIRED == arg->Flags)
fprintf(fp, "\t\t\t\t<term><option>/%s</option> <replaceable>%s</replaceable></term>\n", tr_esc_str((LPSTR) arg->Name), tr_esc_str(arg->Format) );
else
fprintf(fp, "\t\t\t\t<term><option>/%s</option></term>\n", tr_esc_str(arg->Name) );
fprintf(fp, "\t\t\t\t<term><option>/%s</option></term>\n", tr_esc_str((LPSTR) arg->Name));
fprintf(fp, "\t\t\t\t<listitem>\n");
fprintf(fp, "\t\t\t\t\t<para>%s</para>\n", tr_esc_str(arg->Text));
fprintf(fp, "\t\t\t\t\t<para>%s</para>\n", tr_esc_str((LPSTR) arg->Text));
fprintf(fp, "\t\t\t\t</listitem>\n");
fprintf(fp, "\t\t\t</varlistentry>\n");

View File

@ -773,12 +773,12 @@ BOOL xf_pre_connect(freerdp* instance)
if (settings->Username == NULL)
{
fprintf(stderr, "--authonly, but no -u username. Please provide one.\n");
exit(1);
return FALSE;
}
if (settings->Password == NULL)
{
fprintf(stderr, "--authonly, but no -p password. Please provide one.\n");
exit(1);
return FALSE;
}
fprintf(stderr, "%s:%d: Authentication only. Don't connect to X.\n", __FILE__, __LINE__);
/* Avoid XWindows initialization and configuration below. */
@ -1224,6 +1224,8 @@ void* xf_update_thread(void* arg)
wMessageQueue* queue;
freerdp* instance = (freerdp*) arg;
assert( NULL != instance);
status = 1;
queue = freerdp_get_message_queue(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
@ -1241,6 +1243,7 @@ void* xf_update_thread(void* arg)
break;
}
ExitThread(0);
return NULL;
}
@ -1253,9 +1256,12 @@ void* xf_input_thread(void* arg)
int pending_status = 1;
int process_status = 1;
freerdp* instance = (freerdp*) arg;
assert(NULL != instance);
xfc = (xfContext*) instance->context;
assert(NULL != xfc);
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds);
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
@ -1288,9 +1294,8 @@ void* xf_input_thread(void* arg)
break;
}
queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
MessageQueue_PostQuit(queue, 0);
ExitThread(0);
return NULL;
}
@ -1301,8 +1306,10 @@ void* xf_channels_thread(void* arg)
HANDLE event;
rdpChannels* channels;
freerdp* instance = (freerdp*) arg;
assert(NULL != instance);
xfc = (xfContext*) instance->context;
assert(NULL != xfc);
channels = instance->context->channels;
event = freerdp_channels_get_event_handle(instance);
@ -1310,9 +1317,13 @@ void* xf_channels_thread(void* arg)
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
{
status = freerdp_channels_process_pending_messages(instance);
if (!status)
break;
xf_process_channel_event(channels, instance);
}
ExitThread(0);
return NULL;
}
@ -1356,6 +1367,7 @@ void* xf_thread(void* param)
input_event = NULL;
instance = (freerdp*) param;
assert(NULL != instance);
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
@ -1364,6 +1376,7 @@ void* xf_thread(void* param)
status = freerdp_connect(instance);
xfc = (xfContext*) instance->context;
assert(NULL != xfc);
/* Connection succeeded. --authonly ? */
if (instance->settings->AuthenticationOnly)
@ -1407,9 +1420,15 @@ void* xf_thread(void* param)
rcount = 0;
wcount = 0;
/*
* win8 and server 2k12 seem to have some timing issue/race condition
* when a initial sync request is send to sync the keyboard inidcators
* sending the sync event twice fixed this problem
*/
if (freerdp_focus_required(instance))
{
xf_kbd_focus_in(xfc);
xf_kbd_focus_in(xfc);
}
if (!async_transport)
@ -1527,6 +1546,10 @@ void* xf_thread(void* param)
}
}
/* Close the channels first. This will signal the internal message pipes
* that the threads should quit. */
freerdp_channels_close(channels, instance);
if (async_update)
{
wMessageQueue* update_queue = freerdp_get_message_queue(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
@ -1535,6 +1558,20 @@ void* xf_thread(void* param)
CloseHandle(update_thread);
}
if (async_input)
{
wMessageQueue* input_queue = freerdp_get_message_queue(instance, FREERDP_INPUT_MESSAGE_QUEUE);
MessageQueue_PostQuit(input_queue, 0);
WaitForSingleObject(input_thread, INFINITE);
CloseHandle(input_thread);
}
if (async_channels)
{
WaitForSingleObject(channels_thread, INFINITE);
CloseHandle(channels_thread);
}
FILE* fin = fopen("/tmp/tsmf.tid", "rt");
if (fin)
@ -1571,7 +1608,6 @@ void* xf_thread(void* param)
if (!exit_code)
exit_code = freerdp_error_info(instance);
freerdp_channels_close(channels, instance);
freerdp_channels_free(channels);
freerdp_disconnect(instance);
gdi_free(instance);
@ -1650,7 +1686,7 @@ void xf_ParamChangeEventHandler(rdpContext* context, ParamChangeEventArgs* e)
}
}
void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
static void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
@ -1668,12 +1704,12 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
xf_transform_window(xfc);
{
ResizeWindowEventArgs e;
ResizeWindowEventArgs ev;
EventArgsInit(&e, "xfreerdp");
e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e);
EventArgsInit(&ev, "xfreerdp");
ev.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
ev.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &ev);
}
xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE);
@ -1683,19 +1719,19 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
* Client Interface
*/
void xfreerdp_client_global_init()
static void xfreerdp_client_global_init()
{
setlocale(LC_ALL, "");
freerdp_handle_signals();
freerdp_channels_global_init();
}
void xfreerdp_client_global_uninit()
static void xfreerdp_client_global_uninit()
{
freerdp_channels_global_uninit();
}
int xfreerdp_client_start(rdpContext* context)
static int xfreerdp_client_start(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
@ -1707,15 +1743,17 @@ int xfreerdp_client_start(rdpContext* context)
return -1;
}
xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, context->instance, 0, NULL);
xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread,
context->instance, 0, NULL);
return 0;
}
int xfreerdp_client_stop(rdpContext* context)
static int xfreerdp_client_stop(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
assert(NULL != context);
if (context->settings->AsyncInput)
{
wMessageQueue* queue;
@ -1729,13 +1767,16 @@ int xfreerdp_client_stop(rdpContext* context)
xfc->disconnect = TRUE;
}
WaitForSingleObject(xfc->thread, INFINITE);
CloseHandle(xfc->thread);
if (xfc->thread)
{
CloseHandle(xfc->thread);
xfc->thread = NULL;
}
return 0;
}
int xfreerdp_client_new(freerdp* instance, rdpContext* context)
static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
{
xfContext* xfc;
rdpSettings* settings;
@ -1791,7 +1832,7 @@ int xfreerdp_client_new(freerdp* instance, rdpContext* context)
return 0;
}
void xfreerdp_client_free(freerdp* instance, rdpContext* context)
static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
{
xfContext* xfc = (xfContext*) context;

View File

@ -998,6 +998,8 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
surface_bits_command->destLeft, surface_bits_command->destTop,
surface_bits_command->width, surface_bits_command->height);
XFree(image);
free(xfc->bmp_codec_nsc);
xfc->bmp_codec_nsc = NULL;
xf_gdi_surface_update_frame(xfc,
surface_bits_command->destLeft, surface_bits_command->destTop,
@ -1026,6 +1028,8 @@ void xf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
surface_bits_command->destLeft, surface_bits_command->destTop,
surface_bits_command->width, surface_bits_command->height);
XFree(image);
free(xfc->bmp_codec_none);
xfc->bmp_codec_none = NULL;
xf_gdi_surface_update_frame(xfc,
surface_bits_command->destLeft, surface_bits_command->destTop,

View File

@ -565,7 +565,7 @@ const char* movetype_names[] =
void xf_process_rail_server_localmovesize_event(xfContext* xfc, rdpChannels* channels, wMessage* event)
{
int x, y;
int x = 0, y = 0;
rdpRail* rail;
int direction = 0;
Window child_window;

View File

@ -832,6 +832,7 @@ void xf_SetWindowIcon(xfContext* xfc, xfWindow* window, rdpIcon* icon)
PropModeReplace, (BYTE*) propdata, propsize);
XFlush(xfc->display);
free(propdata);
}
void xf_SetWindowRects(xfContext* xfc, xfWindow* window, RECTANGLE_16* rects, int nrects)

View File

@ -870,6 +870,8 @@ int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv, int*
detect_status = 0;
CommandLineClearArgumentsA(args);
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, NULL, NULL, NULL);
if (status < 0)
return status;
arg = args;
@ -903,6 +905,8 @@ int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv, int* c
detect_status = 0;
CommandLineClearArgumentsA(args);
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, NULL, NULL, NULL);
if (status < 0)
return status;
arg = args;
@ -945,7 +949,8 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
*flags = COMMAND_LINE_SEPARATOR_COLON;
*flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
}
else
/* Ignore legacy parsing in case there is an error in the command line. */
else if (old_cli_status >= 0)
{
if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1)))
{
@ -966,12 +971,7 @@ int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings*
{
COMMAND_LINE_ARGUMENT_A* arg;
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
{
freerdp_client_print_command_line_help(argc, argv);
return COMMAND_LINE_STATUS_PRINT_HELP;
}
else if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
{
freerdp_client_print_version();
return COMMAND_LINE_STATUS_PRINT_VERSION;
@ -1015,6 +1015,11 @@ int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings*
return COMMAND_LINE_STATUS_PRINT;
}
else if (status < 0)
{
freerdp_client_print_command_line_help(argc, argv);
return COMMAND_LINE_STATUS_PRINT_HELP;
}
return 0;
}
@ -1043,6 +1048,8 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
CommandLineClearArgumentsA(args);
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
if (status < 0)
return status;
}
@ -1153,6 +1160,8 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
{
settings->MonitorIds[i] = atoi(p[i]);
}
free(p);
}
}
CommandLineSwitchCase(arg, "monitor-list")
@ -1624,7 +1633,8 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
}
CommandLineSwitchDefault(arg)
{
fprintf(stderr, "Unknown argument %s\n", __func__, arg->Name);
return COMMAND_LINE_ERROR;
}
CommandLineSwitchEnd(arg)

View File

@ -125,6 +125,9 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
}
else if (strcmp(args->argv[0], "rdpdr") == 0)
{
if (args->argc < 2)
return -1;
if ((strcmp(args->argv[1], "disk") == 0) ||
(strcmp(args->argv[1], "drive") == 0))
{
@ -156,11 +159,17 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
}
else if (strcmp(args->argv[0], "rdpsnd") == 0)
{
if (args->argc < 2)
return -1;
freerdp_addin_replace_argument_value(args, args->argv[1], "sys", args->argv[1]);
freerdp_client_add_static_channel(settings, args->argc, args->argv);
}
else if (strcmp(args->argv[0], "rail") == 0)
{
if (args->argc < 2)
return -1;
settings->RemoteApplicationProgram = _strdup(args->argv[1]);
}
else
@ -246,10 +255,9 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
a = p;
}
p = strchr(p, ':');
if (p != NULL)
{
p = strchr(p, ':');
length = p - a;
args->argv[j + 1] = malloc(length + 1);
CopyMemory(args->argv[j + 1], a, length);
@ -279,6 +287,11 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
}
}
for (i=0; i<args->argc; i++)
free(args->argv[i]);
free(args->argv);
free(args);
return (index - old_index);
}
@ -302,6 +315,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
detect_status = 0;
flags = COMMAND_LINE_SEPARATOR_SPACE;
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
settings = (rdpSettings*) malloc(sizeof(rdpSettings));
ZeroMemory(settings, sizeof(rdpSettings));
@ -309,6 +323,8 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
CommandLineClearArgumentsA(old_args);
status = CommandLineParseArgumentsA(argc, (const char**) argv, old_args, flags, settings,
freerdp_client_old_command_line_pre_filter, NULL);
if (status < 0)
return status;
arg = old_args;
@ -370,16 +386,12 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
flags = COMMAND_LINE_SEPARATOR_SPACE;
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
status = CommandLineParseArgumentsA(argc, (const char**) argv, old_args, flags, settings,
freerdp_client_old_command_line_pre_filter, freerdp_client_old_command_line_post_filter);
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
{
freerdp_client_print_command_line_help(argc, argv);
return COMMAND_LINE_STATUS_PRINT_HELP;
}
else if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
{
freerdp_client_print_version();
return COMMAND_LINE_STATUS_PRINT_VERSION;
@ -388,6 +400,15 @@ int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSe
{
return COMMAND_LINE_STATUS_PRINT;
}
else if (status < 0)
{
if (status != COMMAND_LINE_STATUS_PRINT_HELP)
{
}
freerdp_client_print_command_line_help(argc, argv);
return COMMAND_LINE_STATUS_PRINT_HELP;
}
arg = old_args;

View File

@ -456,7 +456,10 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
fseek(fp, 0, SEEK_SET);
if (file_size < 1)
{
fclose(fp);
return FALSE;
}
buffer = (BYTE*) malloc(file_size + 2);
read_size = fread(buffer, file_size, 1, fp);
@ -466,6 +469,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
if (!ferror(fp))
read_size = file_size;
}
fclose(fp);
if (read_size < 1)
{
@ -669,14 +673,19 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~((size_t) file->Username))
{
char* user;
char* domain;
char* user = NULL;
char* domain = NULL;
freerdp_parse_username(file->Username, &user, &domain);
freerdp_set_param_string(settings, FreeRDP_Username, user);
if (domain != NULL)
freerdp_set_param_string(settings, FreeRDP_Domain, domain);
if (user)
free(user);
if(domain)
free(domain);
}
if (~file->ServerPort)

View File

@ -118,7 +118,10 @@ FREERDP_API CryptoCert crypto_cert_read(BYTE* data, UINT32 length);
FREERDP_API char* crypto_cert_fingerprint(X509* xcert);
FREERDP_API char* crypto_cert_subject(X509* xcert);
FREERDP_API char* crypto_cert_subject_common_name(X509* xcert, int* length);
FREERDP_API char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths);
FREERDP_API char** crypto_cert_subject_alt_name(X509* xcert, int* count,
int** lengths);
FREERDP_API void crypto_cert_subject_alt_name_free(int count, int *lengths,
char** alt_name);
FREERDP_API char* crypto_cert_issuer(X509* xcert);
FREERDP_API void crypto_cert_print_info(X509* xcert);
FREERDP_API void crypto_cert_free(CryptoCert cert);

View File

@ -23,7 +23,12 @@
#include <stdio.h>
#define DEBUG_NULL(fmt, ...) do { } while (0)
#define DEBUG_PRINT(_dbg_str, fmt, ...) fprintf(stderr, _dbg_str fmt "\n" , __FUNCTION__, __LINE__, ## __VA_ARGS__)
#define DEBUG_PRINT(_dbg_str, fmt, ...) do { \
fprintf(stderr, _dbg_str, __FUNCTION__, __LINE__); \
fprintf(stderr, fmt, ## __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while( 0 )
#define DEBUG_CLASS(_dbg_class, fmt, ...) DEBUG_PRINT("DBG_" #_dbg_class " %s (%d): ", fmt, ## __VA_ARGS__)
#define DEBUG_WARN(fmt, ...) DEBUG_PRINT("Warning %s (%d): ", fmt, ## __VA_ARGS__)

View File

@ -22,7 +22,7 @@
#endif
#include <stdio.h>
#include <assert.h>
#include <winpr/crt.h>
#include <freerdp/update.h>
@ -73,7 +73,7 @@ void update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
brush->style = style;
}
void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
static void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
{
int length;
void* data = NULL;
@ -91,6 +91,9 @@ void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
{
void* entry;
assert(brush);
assert(bpp);
if (*bpp == 1)
{
if (index >= brush->maxMonoEntries)
@ -132,6 +135,8 @@ void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp
if (index >= brush->maxMonoEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}
@ -148,6 +153,8 @@ void brush_cache_put(rdpBrushCache* brush, UINT32 index, void* entry, UINT32 bpp
if (index >= brush->maxEntries)
{
fprintf(stderr, "invalid brush (%d bpp) index: 0x%04X\n", bpp, index);
if (entry)
free(entry);
return;
}

View File

@ -403,7 +403,8 @@ void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGly
if (prevGlyph != NULL)
{
Glyph_Free(glyph_cache->context, prevGlyph);
free(prevGlyph->aj);
if (NULL != prevGlyph->aj)
free(prevGlyph->aj);
free(prevGlyph);
}
@ -498,12 +499,14 @@ void glyph_cache_free(rdpGlyphCache* glyph_cache)
if (glyph != NULL)
{
Glyph_Free(glyph_cache->context, glyph);
free(glyph->aj);
if (glyph->aj)
free(glyph->aj);
free(glyph);
glyph_cache->glyphCache[i].entries[j] = NULL;
}
}
free(glyph_cache->glyphCache[i].entries);
glyph_cache->glyphCache[i].entries = NULL;
}
for (i = 0; i < 255; i++)

View File

@ -27,7 +27,8 @@
#include <freerdp/cache/palette.h>
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* cache_color_table)
{
UINT32* colorTable;
rdpCache* cache = context->cache;
@ -49,7 +50,6 @@ void* palette_cache_get(rdpPaletteCache* palette_cache, UINT32 index)
}
entry = palette_cache->entries[index].entry;
if (entry == NULL)
{
fprintf(stderr, "invalid color table at index: 0x%04X\n", index);
@ -64,9 +64,14 @@ void palette_cache_put(rdpPaletteCache* palette_cache, UINT32 index, void* entry
if (index >= palette_cache->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);
palette_cache->entries[index].entry = entry;
}
@ -97,6 +102,13 @@ void palette_cache_free(rdpPaletteCache* palette_cache)
{
if (palette_cache != NULL)
{
int i;
for (i=0; i<palette_cache->maxEntries; i++)
{
if (palette_cache->entries[i].entry)
free(palette_cache->entries[i].entry);
}
free(palette_cache->entries);
free(palette_cache);
}

View File

@ -909,7 +909,11 @@ BYTE* freerdp_icon_convert(BYTE* srcData, BYTE* dstData, BYTE* mask, int width,
for (bit = 0; bit < 8; bit++)
if ((bmask & (0x80 >> bit)) == 0)
*(icon + (height - y - 1) * width + x + bit) |= 0xFF000000;
{
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
if (tmp)
*tmp |= 0xFF000000;
}
}
if ((width % 8) != 0)
@ -918,7 +922,11 @@ BYTE* freerdp_icon_convert(BYTE* srcData, BYTE* dstData, BYTE* mask, int width,
for (bit = 0; bit < width % 8; bit++)
if ((bmask & (0x80 >> bit)) == 0)
*(icon + (height - y - 1) * width + x + bit) |= 0xFF000000;
{
UINT32 *tmp = (icon + (height - y - 1) * width + x + bit);
if (tmp)
*tmp |= 0xFF000000;
}
}
/* Skip padding */

View File

@ -112,7 +112,7 @@ static const INT16 ima_step_size_table[] =
};
static UINT16 dsp_decode_ima_adpcm_sample(ADPCM* adpcm,
int channel, BYTE sample)
unsigned int channel, BYTE sample)
{
INT32 ss;
INT32 d;

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -179,8 +180,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
BYTE* src_ptr; /* used while copying compressed data */
BYTE* cptr; /* points to next byte in cbuf */
BYTE cur_byte; /* last byte fetched from cbuf */
int bits_left; /* bits left in d34 for processing */
int cur_bits_left; /* bits left in cur_byte for processing */
unsigned int bits_left; /* bits left in d34 for processing */
unsigned int cur_bits_left; /* bits left in cur_byte for processing */
int tmp;
UINT32 i32;
@ -330,6 +331,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
tmp = 32 - bits_left;
while (tmp)
@ -338,7 +340,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -527,6 +529,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -535,7 +539,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -769,6 +773,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -777,7 +783,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -990,6 +996,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -998,7 +1006,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -1322,6 +1330,8 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -1330,7 +1340,7 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -331,7 +332,13 @@ RFX_CONTEXT* rfx_context_new(BOOL encoder)
void rfx_context_free(RFX_CONTEXT* context)
{
free(context->quants);
assert(NULL != context);
assert(NULL != context->priv);
assert(NULL != context->priv->TilePool);
assert(NULL != context->priv->BufferPool);
if (context->quants)
free(context->quants);
ObjectPool_Free(context->priv->TilePool);
@ -618,7 +625,8 @@ void CALLBACK rfx_process_message_tile_work_callback(PTP_CALLBACK_INSTANCE insta
static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* message, wStream* s)
{
int i;
BOOL rc;
int i, close_cnt;
int pos;
BYTE quant;
RFX_TILE* tile;
@ -712,10 +720,28 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
params = (RFX_TILE_PROCESS_WORK_PARAM*) malloc(sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
params = (RFX_TILE_PROCESS_WORK_PARAM*)
malloc(sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
if (!work_objects)
{
if (params)
free(params);
return FALSE;
}
if (!params)
{
if (work_objects)
free(work_objects);
return FALSE;
}
ZeroMemory(work_objects, sizeof(PTP_WORK) * message->numTiles);
ZeroMemory(params, sizeof(RFX_TILE_PROCESS_WORK_PARAM) * message->numTiles);
}
/* tiles */
close_cnt = 0;
rc = TRUE;
for (i = 0; i < message->numTiles; i++)
{
tile = message->tiles[i] = (RFX_TILE*) ObjectPool_Take(context->priv->TilePool);
@ -724,7 +750,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (Stream_GetRemainingLength(s) < 6)
{
DEBUG_WARN("RfxMessageTileSet packet too small to read tile %d/%d", i, message->numTiles);
return FALSE;
rc = FALSE;
break;
}
Stream_Read_UINT16(s, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
@ -732,8 +759,10 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (Stream_GetRemainingLength(s) < blockLen - 6)
{
DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d", i, message->numTiles, blockLen);
return FALSE;
DEBUG_WARN("RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
i, message->numTiles, blockLen);
rc = FALSE;
break;
}
pos = Stream_GetPosition(s) - 6 + blockLen;
@ -765,6 +794,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = message->tiles[i];
@ -772,6 +803,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
(void*) &params[i], &context->priv->ThreadPoolEnv);
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
@ -783,16 +815,18 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
for (i = 0; i < message->numTiles; i++)
for (i = 0; i < close_cnt; i++)
{
WaitForThreadpoolWorkCallbacks(work_objects[i], FALSE);
CloseThreadpoolWork(work_objects[i]);
}
free(work_objects);
free(params);
}
if (work_objects)
free(work_objects);
if (params)
free(params);
for (i = 0; i < message->numTiles; i++)
{
tile = message->tiles[i];
@ -800,7 +834,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
tile->YData = tile->CbData = tile->CrData = NULL;
}
return TRUE;
return rc;
}
RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length)
@ -1072,7 +1106,7 @@ void CALLBACK rfx_compose_message_tile_work_callback(PTP_CALLBACK_INSTANCE insta
RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
int numRects, BYTE* data, int width, int height, int scanline)
{
int i;
int i, close_cnt;
int xIdx;
int yIdx;
int numTilesX;
@ -1086,6 +1120,9 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
RFX_TILE_COMPOSE_WORK_PARAM* params = NULL;
message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE));
if (!message)
return NULL;
ZeroMemory(message, sizeof(RFX_MESSAGE));
if (context->state == RFX_STATE_SEND_HEADERS)
@ -1116,18 +1153,39 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
numTilesY = (height + 63) / 64;
message->numTiles = numTilesX * numTilesY;
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE) * message->numTiles);
if (message->numTiles)
{
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE*) * message->numTiles);
}
DEBUG_RFX("x: %d y: %d width: %d height: %d scanline: %d BytesPerPixel: %d",
rect->x, rect->y, width, height, scanline, BytesPerPixel);
if (context->priv->UseThreads)
{
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
params = (RFX_TILE_COMPOSE_WORK_PARAM*) malloc(sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
if (message->numTiles)
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
if (!work_objects)
{
free(message);
return NULL;
}
params = (RFX_TILE_COMPOSE_WORK_PARAM*)
malloc(sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
if (!params)
{
if (message->tiles)
free(message->tiles);
free(message);
free(work_objects);
return NULL;
}
ZeroMemory(work_objects, sizeof(PTP_WORK) * message->numTiles);
ZeroMemory(params, sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * message->numTiles);
}
close_cnt = 0;
for (yIdx = 0; yIdx < numTilesY; yIdx++)
{
for (xIdx = 0; xIdx < numTilesX; xIdx++)
@ -1169,6 +1227,8 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = tile;
@ -1176,6 +1236,7 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
(void*) &params[i], &context->priv->ThreadPoolEnv);
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
@ -1186,11 +1247,11 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
message->tilesDataSize = 0;
for (i = 0; i < message->numTiles; i++)
for (i = 0; i < close_cnt; i++)
{
tile = message->tiles[i];
if (context->priv->UseThreads)
if (context->priv->UseThreads && work_objects)
{
WaitForThreadpoolWorkCallbacks(work_objects[i], FALSE);
CloseThreadpoolWork(work_objects[i]);
@ -1199,11 +1260,11 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
message->tilesDataSize += rfx_tile_length(tile);
}
if (context->priv->UseThreads)
{
if (work_objects)
free(work_objects);
if (params)
free(params);
}
return message;
}

View File

@ -143,6 +143,7 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
if (entry)
return entry;
FreeLibrary(library);
return entry;
}

View File

@ -154,6 +154,9 @@ RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings, const char*
{
device = (RDPDR_DEVICE*) settings->DeviceArray[index];
if (NULL == device->Name)
continue;
if (strcmp(device->Name, name) == 0)
return device;
}

View File

@ -147,6 +147,8 @@ static int extension_load_plugins(rdpExtension* extension)
fprintf(stderr, "extension_load_plugins: %s entry returns error.\n", path);
continue;
}
DLCLOSE(han);
}
return 0;

View File

@ -164,7 +164,8 @@ BOOL freerdp_connect(freerdp* instance)
StreamPool_Return(rdp->transport->ReceivePool, s);
}
pcap_close(update->pcap_rfx);
update->pcap_rfx = NULL;
status = TRUE;
goto freerdp_connect_finally;
}
@ -306,6 +307,13 @@ BOOL freerdp_disconnect(freerdp* instance)
IFCALL(instance->PostDisconnect, instance);
if (instance->update->pcap_rfx)
{
instance->update->dump_rfx = FALSE;
pcap_close(instance->update->pcap_rfx);
instance->update->pcap_rfx = NULL;
}
return TRUE;
}

View File

@ -365,6 +365,12 @@ BOOL http_response_parse_header(HttpResponse* http_response)
char end_of_header_char;
char c;
if (!http_response)
return FALSE;
if (!http_response->lines)
return FALSE;
if (!http_response_parse_header_status_line(http_response, http_response->lines[0]))
return FALSE;
@ -497,7 +503,11 @@ HttpResponse* http_response_recv(rdpTls* tls)
}
http_response->count = count;
http_response->lines = (char**) malloc(sizeof(char*) * http_response->count);
if (count)
{
http_response->lines = (char**) malloc(sizeof(char*) * http_response->count);
ZeroMemory(http_response->lines, sizeof(char*) * http_response->count);
}
count = 0;
line = strtok((char*) buffer, "\r\n");

View File

@ -433,6 +433,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
if (encrypt_status != SEC_E_OK)
{
fprintf(stderr, "EncryptMessage status: 0x%08X\n", encrypt_status);
free(request_pdu);
return -1;
}

View File

@ -295,6 +295,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(packetCapsResponse);
free(versionCaps);
free(packet);
return FALSE;
}
@ -321,6 +324,10 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected CapabilityType: 0x%08X, Expected TSG_CAPABILITY_TYPE_NAP\n",
tsgCaps->capabilityType);
free(tsgCaps);
free(versionCaps);
free(packetCapsResponse);
free(packet);
return FALSE;
}
@ -396,6 +403,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(versionCaps);
free(packetQuarEncResponse);
free(packet);
return FALSE;
}
@ -433,6 +443,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_CAPS_RESPONSE "
"or TSG_PACKET_TYPE_QUARENC_RESPONSE\n", packet->packetId);
free(packet);
return FALSE;
}
@ -562,7 +573,9 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if ((packet->packetId != TSG_PACKET_TYPE_RESPONSE) || (SwitchValue != TSG_PACKET_TYPE_RESPONSE))
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE\n", packet->packetId);
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_RESPONSE\n",
packet->packetId);
free(packet);
return FALSE;
}
@ -577,6 +590,8 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected Packet Response Flags: 0x%08X, Expected TSG_PACKET_TYPE_QUARREQUEST\n",
packetResponse->flags);
free(packet);
free(packetResponse);
return FALSE;
}
@ -599,7 +614,10 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if (SizeValue != packetResponse->responseDataLen)
{
fprintf(stderr, "Unexpected size value: %d, expected: %d\n", SizeValue, packetResponse->responseDataLen);
fprintf(stderr, "Unexpected size value: %d, expected: %d\n",
SizeValue, packetResponse->responseDataLen);
free(packetResponse);
free(packet);
return FALSE;
}
@ -676,6 +694,7 @@ BOOL TsProxyMakeTunnelCallWriteRequest(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSER
BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
BOOL rc = TRUE;
BYTE* buffer;
UINT32 length;
UINT32 offset;
@ -709,7 +728,9 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
if ((packet->packetId != TSG_PACKET_TYPE_MESSAGE_PACKET) || (SwitchValue != TSG_PACKET_TYPE_MESSAGE_PACKET))
{
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET\n", packet->packetId);
fprintf(stderr, "Unexpected PacketId: 0x%08X, Expected TSG_PACKET_TYPE_MESSAGE_PACKET\n",
packet->packetId);
free(packet);
return FALSE;
}
@ -777,12 +798,24 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
break;
default:
fprintf(stderr, "TsProxyMakeTunnelCallReadResponse: unexpected message type: %d\n", SwitchValue);
return FALSE;
fprintf(stderr, "TsProxyMakeTunnelCallReadResponse: unexpected message type: %d\n",
SwitchValue);
rc = FALSE;
break;
}
return TRUE;
if (packet)
{
if (packet->tsgPacket.packetMsgResponse)
{
if (packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage)
free(packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage);
free(packet->tsgPacket.packetMsgResponse);
}
free(packet);
}
return rc;
}
BOOL TsProxyMakeTunnelCall(rdpTsg* tsg, PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext,

View File

@ -279,7 +279,7 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance)
int i;
void* sin_addr;
int peer_sockfd;
freerdp_peer* client;
freerdp_peer* client = NULL;
socklen_t peer_addr_size;
struct sockaddr_storage peer_addr;
rdpListener* listener = (rdpListener*) instance->listener;
@ -306,6 +306,8 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance)
continue;
#endif
perror("accept");
if (client)
free(client);
return FALSE;
}

View File

@ -293,7 +293,10 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
@ -482,13 +485,10 @@ BOOL nego_recv_response(rdpNego* nego)
status = nego_recv(nego->transport, s, nego);
if (status < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
if (status < 0)
return FALSE;
return TRUE;
}
@ -714,7 +714,10 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);
@ -873,7 +876,10 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
Stream_SealLength(s);
if (transport_write(nego->transport, s) < 0)
{
Stream_Free(s, TRUE);
return FALSE;
}
Stream_Free(s, TRUE);

View File

@ -718,7 +718,7 @@ SECURITY_STATUS credssp_decrypt_public_key_echo(rdpCredssp* credssp)
{
int length;
BYTE* buffer;
ULONG pfQOP;
ULONG pfQOP = 0;
BYTE* public_key1;
BYTE* public_key2;
int public_key_length;
@ -1145,7 +1145,10 @@ int credssp_recv(rdpCredssp* credssp)
if(!ber_read_sequence_tag(s, &length) ||
!ber_read_contextual_tag(s, 0, &length, TRUE) ||
!ber_read_integer(s, &version))
{
Stream_Free(s, TRUE);
return -1;
}
/* [1] negoTokens (NegoData) */
if (ber_read_contextual_tag(s, 1, &length, TRUE) != FALSE)
@ -1155,7 +1158,10 @@ int credssp_recv(rdpCredssp* credssp)
!ber_read_contextual_tag(s, 0, &length, TRUE) || /* [0] negoToken */
!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->negoToken, length);
Stream_Read(s, credssp->negoToken.pvBuffer, length);
credssp->negoToken.cbBuffer = length;
@ -1166,7 +1172,10 @@ int credssp_recv(rdpCredssp* credssp)
{
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->authInfo, length);
Stream_Read(s, credssp->authInfo.pvBuffer, length);
credssp->authInfo.cbBuffer = length;
@ -1177,7 +1186,10 @@ int credssp_recv(rdpCredssp* credssp)
{
if(!ber_read_octet_string_tag(s, &length) || /* OCTET STRING */
Stream_GetRemainingLength(s) < length)
{
Stream_Free(s, TRUE);
return -1;
}
sspi_SecBufferAlloc(&credssp->pubKeyAuth, length);
Stream_Read(s, credssp->pubKeyAuth.pvBuffer, length);
credssp->pubKeyAuth.cbBuffer = length;

View File

@ -784,7 +784,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
UINT16 pduType;
UINT16 pduLength;
UINT16 pduSource;
UINT16 channelId;
UINT16 channelId = 0;
UINT16 securityFlags;
int nextPosition;

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -85,6 +86,14 @@ BOOL transport_disconnect(rdpTransport* transport)
status &= tcp_disconnect(transport->TcpIn);
}
if (transport->async)
{
SetEvent(transport->stopEvent);
WaitForSingleObject(transport->thread, INFINITE);
CloseHandle(transport->thread);
CloseHandle(transport->stopEvent);
}
return status;
}
@ -793,8 +802,14 @@ static void* transport_client_thread(void* arg)
rdpTransport* transport;
transport = (rdpTransport*) arg;
assert(NULL != transport);
assert(NULL != transport->settings);
instance = (freerdp*) transport->settings->instance;
assert(NULL != instance);
context = instance->context;
assert(NULL != instance->context);
while (1)
{
@ -803,25 +818,20 @@ static void* transport_client_thread(void* arg)
events[nCount] = transport->connectedEvent;
status = WaitForMultipleObjects(nCount + 1, events, FALSE, INFINITE);
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
{
if (status == WAIT_OBJECT_0)
break;
}
transport_get_read_handles(transport, (HANDLE*) &events, &nCount);
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
{
if (status == WAIT_OBJECT_0)
break;
}
if (!freerdp_check_fds(instance))
break;
}
ExitThread(0);
return NULL;
}

View File

@ -64,10 +64,19 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
/* colorTable */
if (icon_info->colorTable == NULL)
icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
else
{
if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
}
else if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) realloc(icon_info->colorTable, icon_info->cbColorTable);
Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable);
else
{
free(icon_info->colorTable);
icon_info->colorTable = NULL;
}
if (icon_info->colorTable)
Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable);
/* bitsColor */
if (icon_info->bitsColor == NULL)

View File

@ -115,10 +115,16 @@ static void* base64_decode(BYTE* s, int length, int* data_len)
n[3] = base64_decode_char(*p++);
if ((n[0] == -1) || (n[1] == -1))
{
free(data);
return NULL;
}
if ((n[2] == -1) && (n[3] != -1))
{
free(data);
return NULL;
}
q[0] = (n[0] << 2) + (n[1] >> 4);

View File

@ -392,11 +392,31 @@ char* crypto_cert_subject_common_name(X509* xcert, int* length)
return (char*) common_name;
}
FREERDP_API void crypto_cert_subject_alt_name_free(int count, int *lengths,
char** alt_name)
{
int i;
if (lengths)
free(lengths);
if (alt_name)
{
for (i=0; i<count; i++)
{
if (alt_name[i])
OPENSSL_free(alt_name[i]);
}
free(alt_name);
}
}
char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
{
int index;
int length;
char** strings;
int length = 0;
char** strings = NULL;
BYTE* string;
int num_subject_alt_names;
GENERAL_NAMES* subject_alt_names;
@ -409,8 +429,11 @@ char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
return NULL;
num_subject_alt_names = sk_GENERAL_NAME_num(subject_alt_names);
strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int*) * num_subject_alt_names);
if (num_subject_alt_names)
{
strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int) * num_subject_alt_names);
}
for (index = 0; index < num_subject_alt_names; ++index)
{

View File

@ -34,6 +34,13 @@ void er_read_length(wStream* s, int* length)
Stream_Read_UINT8(s, byte);
if (!length)
return;
*length = 0;
if (!s)
return;
if (byte & 0x80)
{
byte &= ~(0x80);
@ -236,7 +243,7 @@ int er_skip_sequence_tag(int length)
BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
{
int length;
int length = 0;
er_read_universal_tag(s, ER_TAG_ENUMERATED, FALSE);
er_read_length(s, &length);
@ -320,7 +327,7 @@ int er_skip_octet_string(int length)
BOOL er_read_BOOL(wStream* s, BOOL* value)
{
int length;
int length = 0;
BYTE v;
if (!er_read_universal_tag(s, ER_TAG_BOOLEAN, FALSE))
@ -348,7 +355,7 @@ void er_write_BOOL(wStream* s, BOOL value)
BOOL er_read_integer(wStream* s, UINT32* value)
{
int length;
int length = 0;
er_read_universal_tag(s, ER_TAG_INTEGER, FALSE);
er_read_length(s, &length);

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <assert.h>
#include <winpr/crt.h>
#include <winpr/sspi.h>
@ -689,6 +691,10 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
free(common_name);
#endif
if (alt_names)
crypto_cert_subject_alt_name_free(alt_names_count, alt_names_lengths,
alt_names);
return verification_status;
}
@ -712,6 +718,9 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
{
int index;
assert(NULL != hostname);
assert(NULL != common_name);
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@ WARNING: CERTIFICATE NAME MISMATCH! @\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
@ -721,11 +730,13 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
fprintf(stderr, "\t%s\n", common_name ? common_name : "no CN found in certificate");
if (alt_names_count > 1)
{
assert(NULL != alt_names);
fprintf(stderr, "Alternative names:\n");
if (alt_names_count > 1)
{
for (index = 0; index < alt_names_count; index++)
{
assert(alt_names[index]);
fprintf(stderr, "\t %s\n", alt_names[index]);
}
}

View File

@ -143,6 +143,9 @@ static int BitBlt_SRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -204,6 +207,9 @@ static int BitBlt_NOTSRCCOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -251,6 +257,9 @@ static int BitBlt_SRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -276,6 +285,9 @@ static int BitBlt_NOTSRCERASE_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -301,6 +313,9 @@ static int BitBlt_SRCINVERT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -326,6 +341,9 @@ static int BitBlt_SRCAND_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -351,6 +369,9 @@ static int BitBlt_SRCPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -379,6 +400,9 @@ static int BitBlt_DSPDxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT16 color16;
HGDI_BITMAP hSrcBmp;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & P) | (~S & D) */
/* DSPDxax, used to draw glyphs */
@ -420,6 +444,9 @@ static int BitBlt_PSDPxax_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT16* patp;
UINT16 color16;
if (!hdcSrc || !hdcDest)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -473,6 +500,9 @@ static int BitBlt_SPna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -548,6 +578,9 @@ static int BitBlt_DSna_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -575,6 +608,9 @@ static int BitBlt_MERGECOPY_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -601,6 +637,9 @@ static int BitBlt_MERGEPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT16* srcp;
UINT16* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -732,6 +771,9 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT16* dstp;
UINT16* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT16*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -754,6 +796,9 @@ static int BitBlt_PATPAINT_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
{
if (!hdcDest)
return 0;
if (hdcSrc != NULL)
{
if (gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc) == 0)
@ -767,6 +812,9 @@ int BitBlt_16bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -160,6 +160,9 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcDest || !hdcSrc)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -221,6 +224,9 @@ static int BitBlt_NOTSRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -268,6 +274,9 @@ static int BitBlt_SRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -293,6 +302,9 @@ static int BitBlt_NOTSRCERASE_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -318,6 +330,9 @@ static int BitBlt_SRCINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -343,6 +358,9 @@ static int BitBlt_SRCAND_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -368,6 +386,9 @@ static int BitBlt_SRCPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -398,6 +419,9 @@ static int BitBlt_DSPDxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32 color32;
HGDI_BITMAP hSrcBmp;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & P) | (~S & D) */
color32 = gdi_get_color_32bpp(hdcDest, hdcDest->textColor);
@ -460,6 +484,9 @@ static int BitBlt_PSDPxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32* patp;
UINT32 color32;
if (!hdcDest || !hdcSrc)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -514,6 +541,9 @@ static int BitBlt_SPDSxax_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
UINT32* patp;
UINT32 color32;
if (!hdcDest || !hdcSrc)
return 1;
/* D = S ^ (P & (D ^ S)) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -567,6 +597,9 @@ static int BitBlt_SPna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -594,6 +627,9 @@ static int BitBlt_DSna_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -670,6 +706,9 @@ static int BitBlt_MERGECOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -697,6 +736,9 @@ static int BitBlt_MERGEPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
UINT32* srcp;
UINT32* dstp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -828,6 +870,9 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
UINT32* dstp;
UINT32* patp;
if (!hdcDest || !hdcSrc)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = (UINT32*) gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -850,6 +895,9 @@ static int BitBlt_PATPAINT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc, int rop)
{
if (!hdcDest)
return 0;
if (hdcSrc != NULL)
{
if (gdi_ClipCoords(hdcDest, &nXDest, &nYDest, &nWidth, &nHeight, &nXSrc, &nYSrc) == 0)
@ -863,6 +911,9 @@ int BitBlt_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeigh
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -88,6 +88,9 @@ static int BitBlt_SRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
if ((hdcDest->selectedObject != hdcSrc->selectedObject) ||
gdi_CopyOverlap(nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc) == 0)
{
@ -149,6 +152,9 @@ static int BitBlt_NOTSRCCOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -196,6 +202,9 @@ static int BitBlt_SRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -221,6 +230,9 @@ static int BitBlt_NOTSRCERASE_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -246,6 +258,9 @@ static int BitBlt_SRCINVERT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -271,6 +286,9 @@ static int BitBlt_SRCAND_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidt
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -296,6 +314,9 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -317,6 +338,9 @@ static int BitBlt_SRCPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
static int BitBlt_DSPDxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HGDI_DC hdcSrc, int nXSrc, int nYSrc)
{
if (!hdcSrc || !hdcDest)
return 1;
/* TODO: Implement 8bpp DSPDxax BitBlt */
return 0;
}
@ -329,6 +353,9 @@ static int BitBlt_PSDPxax_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWid
BYTE* patp;
BYTE color8;
if (!hdcSrc || !hdcDest)
return 1;
/* D = (S & D) | (~S & P) */
if (hdcDest->brush->style == GDI_BS_SOLID)
@ -382,6 +409,9 @@ static int BitBlt_SPna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -461,6 +491,9 @@ static int BitBlt_DSna_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth,
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -487,6 +520,9 @@ static int BitBlt_MERGECOPY_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nW
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -515,6 +551,9 @@ static int BitBlt_MERGEPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int n
BYTE* srcp;
BYTE* dstp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -646,6 +685,9 @@ static int BitBlt_PATPAINT_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
BYTE* dstp;
BYTE* patp;
if (!hdcSrc || !hdcDest)
return 1;
for (y = 0; y < nHeight; y++)
{
srcp = gdi_get_bitmap_pointer(hdcSrc, nXSrc, nYSrc + y);
@ -683,6 +725,9 @@ int BitBlt_8bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight
gdi_InvalidateRegion(hdcDest, nXDest, nYDest, nWidth, nHeight);
if (!hdcDest)
return 1;
switch (rop)
{
case GDI_BLACKNESS:

View File

@ -93,8 +93,11 @@ rdpIconCache* icon_cache_new(rdpRail* rail)
for (i = 0; i < cache->numCaches; i++)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIconCache));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIconCache));
if (cache->numCacheEntries)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIcon));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIcon));
}
}
}

View File

@ -35,56 +35,68 @@
static wMessage* freerdp_cliprdr_event_new(UINT16 event_type)
{
wMessage* event = NULL;
union
{
wMessage* m;
void *v;
} event;
event.m = NULL;
switch (event_type)
{
case CliprdrChannel_MonitorReady:
event = (wMessage*) malloc(sizeof(RDP_CB_MONITOR_READY_EVENT));
ZeroMemory(event, sizeof(RDP_CB_MONITOR_READY_EVENT));
event->id = MakeMessageId(CliprdrChannel, MonitorReady);
event.v = malloc(sizeof(RDP_CB_MONITOR_READY_EVENT));
ZeroMemory(event.v, sizeof(RDP_CB_MONITOR_READY_EVENT));
event.m->id = MakeMessageId(CliprdrChannel, MonitorReady);
break;
case CliprdrChannel_FormatList:
event = (wMessage*) malloc(sizeof(RDP_CB_FORMAT_LIST_EVENT));
ZeroMemory(event, sizeof(RDP_CB_FORMAT_LIST_EVENT));
event->id = MakeMessageId(CliprdrChannel, FormatList);
event.v = malloc(sizeof(RDP_CB_FORMAT_LIST_EVENT));
ZeroMemory(event.v, sizeof(RDP_CB_FORMAT_LIST_EVENT));
event.m->id = MakeMessageId(CliprdrChannel, FormatList);
break;
case CliprdrChannel_DataRequest:
event = (wMessage*) malloc(sizeof(RDP_CB_DATA_REQUEST_EVENT));
ZeroMemory(event, sizeof(RDP_CB_DATA_REQUEST_EVENT));
event->id = MakeMessageId(CliprdrChannel, DataRequest);
event.v = malloc(sizeof(RDP_CB_DATA_REQUEST_EVENT));
ZeroMemory(event.v, sizeof(RDP_CB_DATA_REQUEST_EVENT));
event.m->id = MakeMessageId(CliprdrChannel, DataRequest);
break;
case CliprdrChannel_DataResponse:
event = (wMessage*) malloc(sizeof(RDP_CB_DATA_RESPONSE_EVENT));
ZeroMemory(event, sizeof(RDP_CB_DATA_RESPONSE_EVENT));
event->id = MakeMessageId(CliprdrChannel, DataResponse);
event.v = malloc(sizeof(RDP_CB_DATA_RESPONSE_EVENT));
ZeroMemory(event.v, sizeof(RDP_CB_DATA_RESPONSE_EVENT));
event.m->id = MakeMessageId(CliprdrChannel, DataResponse);
break;
}
return event;
return event.v;
}
static wMessage* freerdp_tsmf_event_new(UINT16 event_type)
{
wMessage* event = NULL;
union
{
void *v;
wMessage* m;
} event;
event.m = NULL;
switch (event_type)
{
case TsmfChannel_VideoFrame:
event = (wMessage*) malloc(sizeof(RDP_VIDEO_FRAME_EVENT));
ZeroMemory(event, sizeof(RDP_VIDEO_FRAME_EVENT));
event.v = malloc(sizeof(RDP_VIDEO_FRAME_EVENT));
ZeroMemory(event.v, sizeof(RDP_VIDEO_FRAME_EVENT));
event.m->id = MakeMessageId(TsmfChannel, VideoFrame);
break;
case TsmfChannel_Redraw:
event = (wMessage*) malloc(sizeof(RDP_REDRAW_EVENT));
ZeroMemory(event, sizeof(RDP_REDRAW_EVENT));
event.v = malloc(sizeof(RDP_REDRAW_EVENT));
ZeroMemory(event.v, sizeof(RDP_REDRAW_EVENT));
event.m->id = MakeMessageId(TsmfChannel, Redraw);
break;
}
return event;
return event.v;
}
static wMessage* freerdp_rail_event_new(UINT16 event_type)

View File

@ -218,4 +218,6 @@ void pcap_close(rdpPcap* pcap)
if (pcap->fp != NULL)
fclose(pcap->fp);
free(pcap);
}

View File

@ -70,7 +70,8 @@ void profiler_print(PROFILER* profiler)
double elapsed_sec = stopwatch_get_elapsed_time_in_seconds(profiler->stopwatch);
double avg_sec = elapsed_sec / (double) profiler->stopwatch->count;
fprintf(stderr, "| %-30.30s| %10lu | %9f | %9f |\n", profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec);
fprintf(stderr, "| %-30.30s| %10lu | %9f | %9f |\n",
profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec);
}
void profiler_print_footer()

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -186,6 +187,8 @@ static void* svc_plugin_thread_func(void* arg)
DEBUG_SVC("in");
assert(NULL != plugin);
IFCALL(plugin->connect_callback, plugin);
while (1)
@ -213,6 +216,8 @@ static void* svc_plugin_thread_func(void* arg)
DEBUG_SVC("out");
ExitThread(0);
return 0;
}

View File

@ -658,8 +658,6 @@ static void* test_peer_mainloop(void* arg)
testPeerContext* context;
freerdp_peer* client = (freerdp_peer*) arg;
memset(rfds, 0, sizeof(rfds));
test_peer_init(client);
/* Initialize the real server settings here */
@ -694,6 +692,7 @@ static void* test_peer_mainloop(void* arg)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");
@ -779,12 +778,11 @@ static void test_server_mainloop(freerdp_listener* instance)
void* rfds[32];
fd_set rfds_set;
memset(rfds, 0, sizeof(rfds));
while (1)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -17,6 +17,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -42,8 +43,6 @@ void* xf_server_thread(void* param)
xfServer* server;
freerdp_listener* listener;
ZeroMemory(rfds, sizeof(rfds));
server = (xfServer*) param;
listener = server->listener;
@ -51,6 +50,7 @@ void* xf_server_thread(void* param)
{
rcount = 0;
ZeroMemory(rfds, sizeof(rfds));
if (listener->GetFileDescriptor(listener, rfds, &rcount) != TRUE)
{
fprintf(stderr, "Failed to get FreeRDP file descriptor\n");
@ -93,7 +93,7 @@ void* xf_server_thread(void* param)
}
}
listener->Close(listener);
ExitThread(0);
return NULL;
}
@ -115,9 +115,13 @@ int freerdp_server_global_uninit()
int freerdp_server_start(xfServer* server)
{
assert(NULL != server);
server->thread = NULL;
if (server->listener->Open(server->listener, NULL, 3389))
{
server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_server_thread, (void*) server, 0, NULL);
server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
xf_server_thread, (void*) server, 0, NULL);
}
return 0;
@ -125,6 +129,17 @@ int freerdp_server_start(xfServer* server)
int freerdp_server_stop(xfServer* server)
{
if (server->thread)
{
/* ATTENTION: Terminate thread kills a thread, assure
* no resources are allocated during thread execution,
* as they will not be freed! */
TerminateThread(server->thread, 0);
WaitForSingleObject(server->thread, INFINITE);
CloseHandle(server->thread);
server->listener->Close(server->listener);
}
return 0;
}

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -175,6 +176,17 @@ int xf_xshm_init(xfInfo* xfi)
return 0;
}
void xf_info_free(xfInfo *info)
{
assert(NULL != info);
if (info->display)
XCloseDisplay(info->display);
freerdp_clrconv_free(info->clrconv);
free(info);
}
xfInfo* xf_info_init()
{
int i;
@ -313,6 +325,11 @@ void xf_peer_context_free(freerdp_peer* client, xfPeerContext* context)
{
if (context)
{
xf_info_free(context->info);
CloseHandle(context->updateReadyEvent);
CloseHandle(context->updateSentEvent);
Stream_Free(context->s, TRUE);
rfx_context_free(context->rfx_context);
}
@ -508,6 +525,8 @@ static void* xf_peer_main_loop(void* arg)
struct timeval timeout;
freerdp_peer* client = (freerdp_peer*) arg;
assert(NULL != client);
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(&timeout, sizeof(struct timeval));
@ -598,6 +617,8 @@ static void* xf_peer_main_loop(void* arg)
freerdp_peer_context_free(client);
freerdp_peer_free(client);
ExitThread(0);
return NULL;
}

View File

@ -53,6 +53,7 @@
#define COMMAND_LINE_SIGIL_DOUBLE_DASH 0x00000008
#define COMMAND_LINE_SIGIL_PLUS_MINUS 0x00000010
#define COMMAND_LINE_SIGIL_ENABLE_DISABLE 0x00000020
#define COMMAND_LINE_SIGIL_NOT_ESCAPED 0x00000040
#define COMMAND_LINE_SEPARATOR_COLON 0x00000100
#define COMMAND_LINE_SEPARATOR_EQUAL 0x00000200

View File

@ -479,9 +479,9 @@ typedef struct _wEventType wEventType;
#define DEFINE_EVENT_END(_name) \
} _name ## EventArgs; \
DEFINE_EVENT_HANDLER(_name); \
DEFINE_EVENT_RAISE(_name); \
DEFINE_EVENT_SUBSCRIBE(_name); \
DEFINE_EVENT_UNSUBSCRIBE(_name);
DEFINE_EVENT_RAISE(_name) \
DEFINE_EVENT_SUBSCRIBE(_name) \
DEFINE_EVENT_UNSUBSCRIBE(_name)
#define DEFINE_EVENT_ENTRY(_name) \
{ #_name, { sizeof( _name ## EventArgs) }, 0, { \

View File

@ -156,7 +156,7 @@
/* Mac OS X (__MACOSX__) */
#if (__APPLE__ && __MACH__)
#if (defined(__APPLE__) && defined(__MACH__))
#ifndef __MACOSX__
#define __MACOSX__ 1
#endif
@ -164,7 +164,7 @@
/* iOS (__IOS__)*/
#if (__APPLE__ && TARGET_OS_IPHONE)
#if (defined(__APPLE__) && defined(TARGET_OS_IPHONE))
#ifndef __IOS__
#define __IOS__ 1
#endif

View File

@ -159,22 +159,23 @@ LPSTR CharUpperA(LPSTR lpsz)
int i;
int length;
length = strlen(lpsz);
if (!lpsz)
return NULL;
length = strlen(lpsz);
if (length < 1)
return (LPSTR) NULL;
if (length == 1)
{
LPSTR pc = NULL;
char c = *lpsz;
if ((c >= 'a') && (c <= 'z'))
c = c - 32;
*pc = c;
*lpsz = c;
return pc;
return lpsz;
}
for (i = 0; i < length; i++)
@ -241,6 +242,9 @@ LPSTR CharLowerA(LPSTR lpsz)
int i;
int length;
if (!lpsz)
return (LPSTR) NULL;
length = strlen(lpsz);
if (length < 1)
@ -248,15 +252,14 @@ LPSTR CharLowerA(LPSTR lpsz)
if (length == 1)
{
LPSTR pc = NULL;
char c = *lpsz;
if ((c >= 'A') && (c <= 'Z'))
c = c + 32;
*pc = c;
*lpsz = c;
return pc;
return lpsz;
}
for (i = 0; i < length; i++)

View File

@ -352,5 +352,11 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
if (status != cbMultiByte)
status = 0;
if ((status <= 0) && allocate)
{
free(*lpMultiByteStr);
*lpMultiByteStr = NULL;
}
return status;
}

View File

@ -23,6 +23,7 @@
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/synch.h>
#include <winpr/handle.h>
#include <winpr/platform.h>
@ -230,7 +231,11 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
status = connect(pNamedPipe->clientfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un));
if (status != 0)
{
close(pNamedPipe->clientfd);
free(pNamedPipe);
return INVALID_HANDLE_VALUE;
}
return hNamedPipe;
}
@ -557,13 +562,13 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
if (lstat(pFileSearch->lpPath, &fileStat) < 0)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* stat error */
}
if (S_ISDIR(fileStat.st_mode) == 0)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* not a directory */
}
@ -573,7 +578,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
if (!pFileSearch->pDir)
{
free(pFileSearch);
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* failed to open directory */
}
@ -592,6 +597,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
}
}
FindClose(pFileSearch);
return INVALID_HANDLE_VALUE;
}
@ -647,13 +653,20 @@ BOOL FindClose(HANDLE hFindFile)
pFileSearch = (WIN32_FILE_SEARCH*) hFindFile;
free(pFileSearch->lpPath);
free(pFileSearch->lpPattern);
closedir(pFileSearch->pDir);
if (pFileSearch)
{
if (pFileSearch->lpPath)
free(pFileSearch->lpPath);
if (pFileSearch->lpPattern)
free(pFileSearch->lpPattern);
if (pFileSearch->pDir)
closedir(pFileSearch->pDir);
free(pFileSearch);
free(pFileSearch);
return TRUE;
}
return TRUE;
return FALSE;
}
BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)

View File

@ -86,6 +86,9 @@ BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName,
{
LPSTR lpMatch;
if (!lpFileName)
return FALSE;
if (*lpWildcard == '*')
{
/*
@ -314,7 +317,7 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
LPSTR lpY;
size_t cchX;
size_t cchY;
LPSTR lpMatchEnd;
LPSTR lpMatchEnd = NULL;
LPSTR lpSubPattern;
size_t cchSubPattern;
LPSTR lpSubFileName;

View File

@ -48,8 +48,7 @@ BOOL CloseHandle(HANDLE hObject)
WINPR_THREAD* thread;
thread = (WINPR_THREAD*) Object;
free(Object);
free(thread);
return TRUE;
}

View File

@ -33,7 +33,7 @@
* Keyboard Type 4
*/
DWORD KBD4T[128] =
static DWORD KBD4T[128] =
{
KBD4_T00,
KBD4_T01,
@ -165,7 +165,7 @@ DWORD KBD4T[128] =
KBD4_T7F
};
DWORD KBD4X[128] =
static DWORD KBD4X[128] =
{
VK_NONE,
VK_NONE,
@ -301,7 +301,7 @@ DWORD KBD4X[128] =
* Keyboard Type 7
*/
DWORD KBD7T[128] =
static DWORD KBD7T[128] =
{
KBD7_T00,
KBD7_T01,
@ -433,7 +433,7 @@ DWORD KBD7T[128] =
KBD7_T7F
};
DWORD KBD7X[128] =
static DWORD KBD7X[128] =
{
VK_NONE,
VK_NONE,

View File

@ -437,7 +437,7 @@ char* GetVirtualKeyName(DWORD vkcode)
DWORD GetVirtualKeyCodeFromName(const char* vkname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++)
{
@ -453,7 +453,7 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname)
DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++)
{

View File

@ -276,16 +276,22 @@ char* GetCombinedPath(char* basePath, char* subPath)
int length;
HRESULT status;
char* path = NULL;
int basePathLength;
int subPathLength;
char* subPathCpy;
int basePathLength = 0;
int subPathLength = 0;
basePathLength = strlen(basePath);
subPathLength = strlen(subPath);
if (basePath)
basePathLength = strlen(basePath);
if (subPath)
subPathLength = strlen(subPath);
length = basePathLength + subPathLength + 1;
path = (char*) malloc(length + 1);
if (!path)
return NULL;
CopyMemory(path, basePath, basePathLength);
if (basePath)
CopyMemory(path, basePath, basePathLength);
path[basePathLength] = '\0';
PathCchConvertStyleA(path, basePathLength, PATH_STYLE_NATIVE);
@ -293,12 +299,12 @@ char* GetCombinedPath(char* basePath, char* subPath)
if (!subPath)
return path;
subPath = _strdup(subPath);
PathCchConvertStyleA(subPath, subPathLength, PATH_STYLE_NATIVE);
subPathCpy = _strdup(subPath);
PathCchConvertStyleA(subPathCpy, subPathLength, PATH_STYLE_NATIVE);
status = NativePathCchAppendA(path, length + 1, subPath);
status = NativePathCchAppendA(path, length + 1, subPathCpy);
free(subPath);
free(subPathCpy);
return path;
}

View File

@ -35,7 +35,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
MODULE winpr
MODULES winpr-crt winpr-handle winpr-file)
MODULES winpr-crt winpr-synch winpr-handle winpr-file)
if(MONOLITHIC_BUILD)

View File

@ -23,6 +23,7 @@
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/synch.h>
#include <winpr/handle.h>
#include <winpr/pipe.h>
@ -65,7 +66,13 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
pWritePipe = (WINPR_PIPE*) malloc(sizeof(WINPR_PIPE));
if (!pReadPipe || !pWritePipe)
{
if (pReadPipe)
free(pReadPipe);
if (pWritePipe)
free(pWritePipe);
return FALSE;
}
pReadPipe->fd = pipe_fd[0];
pWritePipe->fd = pipe_fd[1];

View File

@ -55,6 +55,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Client NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -68,6 +73,10 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Client NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -120,6 +129,8 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure\n");
CloseHandle(hNamedPipe);
return NULL;
}
@ -136,6 +147,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Server NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -152,6 +167,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Server NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -176,6 +195,9 @@ int TestPipeCreateNamedPipe(int argc, char* argv[])
WaitForSingleObject(ClientThread, INFINITE);
WaitForSingleObject(ServerThread, INFINITE);
CloseHandle(ClientThread);
CloseHandle(ServerThread);
return 0;
}

View File

@ -63,6 +63,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -85,6 +90,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -160,6 +170,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure: %d\n", GetLastError());
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -178,6 +192,12 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -203,6 +223,13 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}

View File

@ -31,8 +31,8 @@
#define WINPR_HKLM_HIVE "/etc/winpr/HKLM.reg"
void reg_print_key(Reg* reg, RegKey* key);
void reg_print_value(Reg* reg, RegVal* value);
static void reg_print_key(Reg* reg, RegKey* key);
static void reg_print_value(Reg* reg, RegVal* value);
struct reg_data_type
{
@ -41,7 +41,7 @@ struct reg_data_type
DWORD type;
};
struct reg_data_type REG_DATA_TYPE_TABLE[] =
static struct reg_data_type REG_DATA_TYPE_TABLE[] =
{
{ "\"", 1, REG_SZ },
{ "dword:", 6, REG_DWORD },
@ -55,7 +55,7 @@ struct reg_data_type REG_DATA_TYPE_TABLE[] =
{ NULL, 0, 0 }
};
char* REG_DATA_TYPE_STRINGS[] =
static char* REG_DATA_TYPE_STRINGS[] =
{
"REG_NONE",
"REG_SZ",
@ -71,7 +71,7 @@ char* REG_DATA_TYPE_STRINGS[] =
"REG_QWORD"
};
void reg_load_start(Reg* reg)
static void reg_load_start(Reg* reg)
{
long int file_size;
@ -79,6 +79,10 @@ void reg_load_start(Reg* reg)
file_size = ftell(reg->fp);
fseek(reg->fp, 0, SEEK_SET);
reg->line = NULL;
reg->next_line = NULL;
reg->buffer = NULL;
if (file_size < 1)
return;
@ -87,24 +91,29 @@ void reg_load_start(Reg* reg)
if (fread(reg->buffer, file_size, 1, reg->fp) != 1)
{
free(reg->buffer);
reg->buffer = NULL;
return;
}
reg->buffer[file_size] = '\n';
reg->buffer[file_size + 1] = '\0';
reg->line = NULL;
reg->next_line = strtok(reg->buffer, "\n");
}
void reg_load_finish(Reg* reg)
static void reg_load_finish(Reg* reg)
{
free(reg->buffer);
reg->buffer = NULL;
reg->line = NULL;
if (!reg)
return;
if (reg->buffer)
{
free(reg->buffer);
reg->buffer = NULL;
}
}
RegVal* reg_load_value(Reg* reg, RegKey* key)
static RegVal* reg_load_value(Reg* reg, RegKey* key)
{
int index;
char* p[5];
@ -181,13 +190,19 @@ RegVal* reg_load_value(Reg* reg, RegKey* key)
return value;
}
BOOL reg_load_has_next_line(Reg* reg)
static BOOL reg_load_has_next_line(Reg* reg)
{
if (!reg)
return 0;
return (reg->next_line != NULL) ? 1 : 0;
}
char* reg_load_get_next_line(Reg* reg)
static char* reg_load_get_next_line(Reg* reg)
{
if (!reg)
return NULL;
reg->line = reg->next_line;
reg->next_line = strtok(NULL, "\n");
reg->line_length = strlen(reg->line);
@ -195,12 +210,12 @@ char* reg_load_get_next_line(Reg* reg)
return reg->line;
}
char* reg_load_peek_next_line(Reg* reg)
static char* reg_load_peek_next_line(Reg* reg)
{
return reg->next_line;
}
void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
static void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
{
char* name;
char* path;
@ -226,7 +241,7 @@ void reg_insert_key(Reg* reg, RegKey* key, RegKey* subkey)
free(path);
}
RegKey* reg_load_key(Reg* reg, RegKey* key)
static RegKey* reg_load_key(Reg* reg, RegKey* key)
{
char* p[2];
int length;
@ -300,7 +315,7 @@ void reg_load(Reg* reg)
reg_load_finish(reg);
}
void reg_unload_value(Reg* reg, RegVal* value)
static void reg_unload_value(Reg* reg, RegVal* value)
{
if (value->type == REG_DWORD)
{
@ -318,7 +333,7 @@ void reg_unload_value(Reg* reg, RegVal* value)
free(value);
}
void reg_unload_key(Reg* reg, RegKey* key)
static void reg_unload_key(Reg* reg, RegKey* key)
{
RegVal* pValue;
RegVal* pValueNext;

View File

@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef REGISTRY_REG_H_
#define REGISTRY_REG_H_
#include <winpr/registry.h>
@ -62,3 +64,6 @@ struct _reg_key
};
Reg* reg_open(BOOL read_only);
void reg_close(Reg *reg);
#endif

View File

@ -143,6 +143,10 @@ void NdrProcessParams(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, NDR_P
for (i = 0; i < numberParams; i++)
{
#ifdef __x86_64__
float tmp;
#endif
arg = pStubMsg->StackTop + params[i].StackOffset;
fmt = (PFORMAT_STRING) &pStubMsg->StubDesc->pFormatTypes[params[i].Type.Offset];
@ -151,7 +155,7 @@ void NdrProcessParams(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, NDR_P
!(params[i].Attributes.IsSimpleRef) &&
((params[i].Type.FormatChar) == FC_FLOAT) && !fpuArgs)
{
float tmp = *(double*) arg;
tmp = *(double*) arg;
arg = (unsigned char*) &tmp;
}
#endif

View File

@ -80,6 +80,8 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
if (pStubMsg->StackTop)
ptr = pStubMsg->StackTop;
}
else
return pFormat;
switch (correlation_operator)
{
@ -110,6 +112,9 @@ PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
break;
}
if (!ptr)
return pFormat;
switch (type)
{
case FC_LONG:

View File

@ -43,20 +43,21 @@ char* NTLM_PACKAGE_NAME = "NTLM";
void ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
{
char *ws = Workstation;
DWORD nSize = 0;
if (!Workstation)
{
GetComputerNameExA(ComputerNameNetBIOS, NULL, &nSize);
Workstation = malloc(nSize);
GetComputerNameExA(ComputerNameNetBIOS, Workstation, &nSize);
ws = malloc(nSize);
GetComputerNameExA(ComputerNameNetBIOS, ws, &nSize);
}
context->Workstation.Length = ConvertToUnicode(CP_UTF8, 0,
Workstation, -1, &context->Workstation.Buffer, 0) - 1;
ws, -1, &context->Workstation.Buffer, 0) - 1;
context->Workstation.Length *= 2;
if (nSize > 0)
if (!Workstation)
free(Workstation);
}
@ -81,22 +82,23 @@ void ntlm_SetContextServicePrincipalNameA(NTLM_CONTEXT* context, char* ServicePr
void ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
{
char *name = TargetName;
DWORD nSize = 0;
if (!TargetName)
{
GetComputerNameExA(ComputerNameDnsHostname, NULL, &nSize);
TargetName = malloc(nSize);
name = malloc(nSize);
GetComputerNameExA(ComputerNameDnsHostname, TargetName, &nSize);
CharUpperA(TargetName);
}
context->TargetName.cbBuffer = ConvertToUnicode(CP_UTF8, 0,
TargetName, -1, (LPWSTR*) &context->TargetName.pvBuffer, 0) - 1;
name, -1, (LPWSTR*) &context->TargetName.pvBuffer, 0) - 1;
context->TargetName.cbBuffer *= 2;
if (nSize > 0)
free(TargetName);
if (!TargetName)
free(name);
}
NTLM_CONTEXT* ntlm_ContextNew()

View File

@ -279,6 +279,7 @@ void ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)
{
fprintf(stderr, "Error: Could not find user in SAM database\n");
}
SamClose(sam);
}
void ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)

View File

@ -650,6 +650,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
message = &context->AUTHENTICATE_MESSAGE;
ZeroMemory(message, sizeof(NTLM_AUTHENTICATE_MESSAGE));
ZeroMemory(&response, sizeof(NTLMv2_RESPONSE));
s = Stream_New(buffer->pvBuffer, buffer->cbBuffer);
@ -799,6 +800,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
winpr_HexDump(context->MessageIntegrityCheck, 16);
fprintf(stderr, "Actual MIC:\n");
winpr_HexDump(message->MessageIntegrityCheck, 16);
Stream_Free(s, FALSE);
return SEC_E_MESSAGE_ALTERED;
}

View File

@ -128,6 +128,7 @@ void sspi_ContextBufferAllocTableNew()
{
size_t size;
ContextBufferAllocTable.entries = NULL;
ContextBufferAllocTable.cEntries = 0;
ContextBufferAllocTable.cMaxEntries = 4;
@ -144,6 +145,8 @@ void sspi_ContextBufferAllocTableGrow()
ContextBufferAllocTable.cMaxEntries *= 2;
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
if (!size)
return;
ContextBufferAllocTable.entries = realloc(ContextBufferAllocTable.entries, size);
ZeroMemory((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], size / 2);

View File

@ -70,12 +70,14 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
if (event->pipe_fd[0] < 0)
{
fprintf(stderr, "CreateEventW: failed to create event\n");
free(event);
return NULL;
}
#else
if (pipe(event->pipe_fd) < 0)
{
fprintf(stderr, "CreateEventW: failed to create event\n");
free(event);
return NULL;
}
#endif

View File

@ -39,6 +39,8 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
WINPR_SEMAPHORE* semaphore;
semaphore = (WINPR_SEMAPHORE*) malloc(sizeof(WINPR_SEMAPHORE));
if (!semaphore)
return NULL;
semaphore->pipe_fd[0] = -1;
semaphore->pipe_fd[0] = -1;
@ -51,13 +53,19 @@ HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lIniti
if (pipe(semaphore->pipe_fd) < 0)
{
fprintf(stderr, "CreateSemaphoreW: failed to create semaphore\n");
free(semaphore);
return NULL;
}
while (lInitialCount > 0)
{
if (write(semaphore->pipe_fd[1], "-", 1) != 1)
return FALSE;
{
close(semaphore->pipe_fd[0]);
close(semaphore->pipe_fd[1]);
free(semaphore);
return NULL;
}
lInitialCount--;
}

View File

@ -30,7 +30,9 @@
#include <time.h>
#ifdef HAVE_UNISTD_H
#define _XOPEN_SOURCE 500
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#endif

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