parent
0067241d5e
commit
f8120919af
@ -662,12 +662,16 @@ static void encomsp_process_connect(encomspPlugin* encomsp)
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void encomsp_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
BOOL encomsp_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
if (!g_InitHandles)
|
||||
{
|
||||
g_InitHandles = ListDictionary_New(TRUE);
|
||||
if (!g_InitHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
}
|
||||
|
||||
void* encomsp_get_init_handle_data(void* pInitHandle)
|
||||
@ -687,14 +691,18 @@ void encomsp_remove_init_handle_data(void* pInitHandle)
|
||||
}
|
||||
}
|
||||
|
||||
void encomsp_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
BOOL encomsp_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = ListDictionary_New(TRUE);
|
||||
if (!g_OpenHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
}
|
||||
|
||||
void* encomsp_get_open_handle_data(DWORD openHandle)
|
||||
@ -843,7 +851,11 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
status = encomsp->channelEntryPoints.pVirtualChannelOpen(encomsp->InitHandle,
|
||||
&encomsp->OpenHandle, encomsp->channelDef.name, encomsp_virtual_channel_open_event);
|
||||
|
||||
encomsp_add_open_handle_data(encomsp->OpenHandle, encomsp);
|
||||
if (!encomsp_add_open_handle_data(encomsp->OpenHandle, encomsp))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to register open handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -853,9 +865,20 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
}
|
||||
|
||||
encomsp->queue = MessageQueue_New(NULL);
|
||||
if (!encomsp->queue)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create message queue", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
encomsp->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) encomsp_virtual_channel_client_thread, (void*) encomsp, 0, NULL);
|
||||
if (!encomsp->thread)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create thread", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
|
||||
@ -980,7 +1003,5 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
encomsp->channelEntryPoints.pInterface = *(encomsp->channelEntryPoints.ppInterface);
|
||||
encomsp->channelEntryPoints.ppInterface = &(encomsp->channelEntryPoints.pInterface);
|
||||
|
||||
encomsp_add_init_handle_data(encomsp->InitHandle, (void*) encomsp);
|
||||
|
||||
return 1;
|
||||
return encomsp_add_init_handle_data(encomsp->InitHandle, (void*) encomsp) ? 1 : -1;
|
||||
}
|
||||
|
@ -307,7 +307,6 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
if (name[0] && path[0])
|
||||
{
|
||||
parallel = (PARALLEL_DEVICE*) calloc(1, sizeof(PARALLEL_DEVICE));
|
||||
|
||||
if (!parallel)
|
||||
return -1;
|
||||
|
||||
@ -318,6 +317,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
length = strlen(name);
|
||||
parallel->device.data = Stream_New(NULL, length + 1);
|
||||
if (!parallel->device.data)
|
||||
goto error_device_data;
|
||||
|
||||
for (i = 0; i <= length; i++)
|
||||
Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
@ -325,11 +326,23 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
parallel->path = path;
|
||||
|
||||
parallel->queue = MessageQueue_New(NULL);
|
||||
if (!parallel->queue)
|
||||
goto error_queue;
|
||||
|
||||
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);
|
||||
|
||||
parallel->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) parallel_thread_func, (void*) parallel, 0, NULL);
|
||||
if (!parallel->thread)
|
||||
goto error_thread;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error_thread:
|
||||
MessageQueue_Free(parallel->queue);
|
||||
error_queue:
|
||||
Stream_Free(parallel->device.data, TRUE);
|
||||
error_device_data:
|
||||
free(parallel);
|
||||
return -1;
|
||||
}
|
||||
|
@ -62,14 +62,14 @@ int rail_send(railPlugin* rail, wStream* s)
|
||||
return status;
|
||||
}
|
||||
|
||||
void rail_send_channel_data(railPlugin* rail, void* data, size_t length)
|
||||
BOOL rail_send_channel_data(railPlugin* rail, void* data, size_t length)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
|
||||
s = Stream_New(NULL, length);
|
||||
Stream_Write(s, data, length);
|
||||
|
||||
rail_send(rail, s);
|
||||
return rail_send(rail, s) == CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,24 +96,21 @@ int rail_client_execute(RailClientContext* context, RAIL_EXEC_ORDER* exec)
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationWorkingDir, &exec->workingDir); /* ShellWorkingDirectory */
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationArguments, &exec->arguments); /* RemoteApplicationCmdLine */
|
||||
|
||||
rail_send_client_exec_order(rail, exec);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_exec_order(rail, exec) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_client_activate(RailClientContext* context, RAIL_ACTIVATE_ORDER* activate)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_activate_order(rail, activate);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_activate_order(rail, activate) ? 0 : -1;
|
||||
}
|
||||
|
||||
void rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
BOOL rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
wStream* s;
|
||||
int length;
|
||||
BOOL ret;
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
length = RAIL_SYSPARAM_ORDER_LENGTH;
|
||||
@ -139,56 +136,63 @@ void rail_send_client_sysparam(RailClientContext* context, RAIL_SYSPARAM_ORDER*
|
||||
}
|
||||
|
||||
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
|
||||
rail_write_client_sysparam_order(s, sysparam);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
ret = rail_write_client_sysparam_order(s, sysparam) &&
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rail_client_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
BOOL ok = TRUE;
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_HIGH_CONTRAST)
|
||||
{
|
||||
sysparam->param = SPI_SET_HIGH_CONTRAST;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_TASKBAR_POS)
|
||||
{
|
||||
sysparam->param = SPI_TASKBAR_POS;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
|
||||
{
|
||||
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_KEYBOARD_PREF)
|
||||
{
|
||||
sysparam->param = SPI_SET_KEYBOARD_PREF;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
|
||||
{
|
||||
sysparam->param = SPI_SET_DRAG_FULL_WINDOWS;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_KEYBOARD_CUES)
|
||||
{
|
||||
sysparam->param = SPI_SET_KEYBOARD_CUES;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_WORK_AREA)
|
||||
{
|
||||
sysparam->param = SPI_SET_WORK_AREA;
|
||||
rail_send_client_sysparam(context, sysparam);
|
||||
ok &= rail_send_client_sysparam(context, sysparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ok ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_system_param(RailClientContext* context, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
@ -200,18 +204,14 @@ int rail_client_system_command(RailClientContext* context, RAIL_SYSCOMMAND_ORDER
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_syscommand_order(rail, syscommand);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_syscommand_order(rail, syscommand) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_client_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_handshake_order(rail, handshake);
|
||||
|
||||
return 0;
|
||||
return rail_send_handshake_order(rail, handshake) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_handshake(RailClientContext* context, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
@ -223,9 +223,7 @@ int rail_client_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_handshake_ex_order(rail, handshakeEx);
|
||||
|
||||
return 0;
|
||||
return rail_send_handshake_ex_order(rail, handshakeEx) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_handshake_ex(RailClientContext* context, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
@ -237,18 +235,14 @@ int rail_client_notify_event(RailClientContext* context, RAIL_NOTIFY_EVENT_ORDER
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_notify_event_order(rail, notifyEvent);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_notify_event_order(rail, notifyEvent) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_client_window_move(RailClientContext* context, RAIL_WINDOW_MOVE_ORDER* windowMove)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_window_move_order(rail, windowMove);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_window_move_order(rail, windowMove) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_local_move_size(RailClientContext* context, RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
|
||||
@ -265,27 +259,21 @@ int rail_client_information(RailClientContext* context, RAIL_CLIENT_STATUS_ORDER
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_status_order(rail, clientStatus);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_status_order(rail, clientStatus) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_client_system_menu(RailClientContext* context, RAIL_SYSMENU_ORDER* sysmenu)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_sysmenu_order(rail, sysmenu);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_sysmenu_order(rail, sysmenu) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_client_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_langbar_info_order(rail, langBarInfo);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_langbar_info_order(rail, langBarInfo) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_language_bar_info(RailClientContext* context, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
@ -302,9 +290,7 @@ int rail_client_get_appid_request(RailClientContext* context, RAIL_GET_APPID_REQ
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
|
||||
rail_send_client_get_appid_req_order(rail, getAppIdReq);
|
||||
|
||||
return 0;
|
||||
return rail_send_client_get_appid_req_order(rail, getAppIdReq) ? 0 : -1;
|
||||
}
|
||||
|
||||
int rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
|
||||
@ -317,12 +303,16 @@ int rail_server_get_appid_response(RailClientContext* context, RAIL_GET_APPID_RE
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rail_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
BOOL rail_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
if (!g_InitHandles)
|
||||
{
|
||||
g_InitHandles = ListDictionary_New(TRUE);
|
||||
if (!g_InitHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rail_get_init_handle_data(void* pInitHandle)
|
||||
@ -342,14 +332,18 @@ void rail_remove_init_handle_data(void* pInitHandle)
|
||||
}
|
||||
}
|
||||
|
||||
void rail_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
BOOL rail_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = ListDictionary_New(TRUE);
|
||||
if (!g_OpenHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rail_get_open_handle_data(DWORD openHandle)
|
||||
@ -387,10 +381,19 @@ static void rail_virtual_channel_event_data_received(railPlugin* rail,
|
||||
Stream_Free(rail->data_in, TRUE);
|
||||
|
||||
rail->data_in = Stream_New(NULL, totalLength);
|
||||
if (!rail->data_in)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to allocate data_in", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
data_in = rail->data_in;
|
||||
Stream_EnsureRemainingCapacity(data_in, (int) dataLength);
|
||||
if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to grow data_in to %d", __FUNCTION__, dataLength);
|
||||
return;
|
||||
}
|
||||
Stream_Write(data_in, pData, dataLength);
|
||||
|
||||
if (dataFlags & CHANNEL_FLAG_LAST)
|
||||
@ -455,7 +458,11 @@ static void* rail_virtual_channel_client_thread(void* arg)
|
||||
if (message.id == 0)
|
||||
{
|
||||
data = (wStream*) message.wParam;
|
||||
rail_order_recv(rail, data);
|
||||
if (!rail_order_recv(rail, data))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: invalid message, exiting", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -471,7 +478,11 @@ static void rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
status = rail->channelEntryPoints.pVirtualChannelOpen(rail->InitHandle,
|
||||
&rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event);
|
||||
|
||||
rail_add_open_handle_data(rail->OpenHandle, rail);
|
||||
if (!rail_add_open_handle_data(rail->OpenHandle, rail))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to register open handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -481,6 +492,11 @@ static void rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
}
|
||||
|
||||
rail->queue = MessageQueue_New(NULL);
|
||||
if (!rail->queue)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create a message queue", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
rail->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0, NULL);
|
||||
@ -574,6 +590,8 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
||||
{
|
||||
context = (RailClientContext*) calloc(1, sizeof(RailClientContext));
|
||||
if (!context)
|
||||
return FALSE;
|
||||
|
||||
context->handle = (void*) rail;
|
||||
context->custom = NULL;
|
||||
@ -623,7 +641,5 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
rail->channelEntryPoints.pInterface = *(rail->channelEntryPoints.ppInterface);
|
||||
rail->channelEntryPoints.ppInterface = &(rail->channelEntryPoints.pInterface);
|
||||
|
||||
rail_add_init_handle_data(rail->InitHandle, (void*) rail);
|
||||
|
||||
return 1;
|
||||
return rail_add_init_handle_data(rail->InitHandle, (void*) rail) ? 1 : -1;
|
||||
}
|
||||
|
@ -51,6 +51,6 @@ struct rail_plugin
|
||||
typedef struct rail_plugin railPlugin;
|
||||
|
||||
RailClientContext* rail_get_client_interface(railPlugin* rail);
|
||||
void rail_send_channel_data(railPlugin* rail, void* data, size_t length);
|
||||
BOOL rail_send_channel_data(railPlugin* rail, void* data, size_t length);
|
||||
|
||||
#endif /* FREERDP_CHANNEL_CLIENT_RAIL_MAIN_H */
|
||||
|
@ -28,58 +28,30 @@
|
||||
|
||||
#include "rail_orders.h"
|
||||
|
||||
static BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
|
||||
static BOOL rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
{
|
||||
UINT16 new_length;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 2)
|
||||
if (!Stream_EnsureRemainingCapacity(s, 2 + unicode_string->length))
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT16(s, new_length); /* cbString (2 bytes) */
|
||||
|
||||
if (Stream_GetRemainingLength(s) < new_length)
|
||||
return FALSE;
|
||||
|
||||
if (!unicode_string->string)
|
||||
{
|
||||
unicode_string->string = (BYTE*) malloc(new_length);
|
||||
if (!unicode_string->string)
|
||||
return FALSE;
|
||||
unicode_string->length = new_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *new_str;
|
||||
|
||||
new_str = (BYTE*) realloc(unicode_string->string, new_length);
|
||||
if (!new_str)
|
||||
return FALSE;
|
||||
unicode_string->string = new_str;
|
||||
unicode_string->length = new_length;
|
||||
}
|
||||
|
||||
Stream_Read(s, unicode_string->string, unicode_string->length);
|
||||
|
||||
Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
|
||||
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void rail_write_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
{
|
||||
Stream_EnsureRemainingCapacity(s, 2 + unicode_string->length);
|
||||
Stream_Write_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
|
||||
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
|
||||
}
|
||||
|
||||
static void rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
static BOOL rail_write_unicode_string_value(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
{
|
||||
if (unicode_string->length > 0)
|
||||
{
|
||||
Stream_EnsureRemainingCapacity(s, unicode_string->length);
|
||||
if (!Stream_EnsureRemainingCapacity(s, unicode_string->length))
|
||||
return FALSE;
|
||||
|
||||
Stream_Write(s, unicode_string->string, unicode_string->length); /* string */
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
|
||||
BOOL rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
|
||||
{
|
||||
UINT16 orderLength;
|
||||
|
||||
@ -92,15 +64,15 @@ void rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType)
|
||||
WLog_Print(rail->log, WLOG_DEBUG, "Sending %s PDU, length: %d",
|
||||
RAIL_ORDER_TYPE_STRINGS[((orderType & 0xF0) >> 3) + (orderType & 0x0F)], orderLength);
|
||||
|
||||
rail_send_channel_data(rail, Stream_Buffer(s), orderLength);
|
||||
return rail_send_channel_data(rail, Stream_Buffer(s), orderLength);
|
||||
}
|
||||
|
||||
void rail_write_high_contrast(wStream* s, RAIL_HIGH_CONTRAST* highContrast)
|
||||
BOOL rail_write_high_contrast(wStream* s, RAIL_HIGH_CONTRAST* highContrast)
|
||||
{
|
||||
highContrast->colorSchemeLength = highContrast->colorScheme.length + 2;
|
||||
Stream_Write_UINT32(s, highContrast->flags); /* flags (4 bytes) */
|
||||
Stream_Write_UINT32(s, highContrast->colorSchemeLength); /* colorSchemeLength (4 bytes) */
|
||||
rail_write_unicode_string(s, &highContrast->colorScheme); /* colorScheme */
|
||||
return rail_write_unicode_string(s, &highContrast->colorScheme); /* colorScheme */
|
||||
}
|
||||
|
||||
BOOL rail_read_server_exec_result_order(wStream* s, RAIL_EXEC_RESULT_ORDER* execResult)
|
||||
@ -206,20 +178,22 @@ void rail_write_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER* client
|
||||
Stream_Write_UINT32(s, clientStatus->flags); /* flags (4 bytes) */
|
||||
}
|
||||
|
||||
void rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
|
||||
BOOL rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
Stream_Write_UINT16(s, exec->flags); /* flags (2 bytes) */
|
||||
Stream_Write_UINT16(s, exec->exeOrFile.length); /* exeOrFileLength (2 bytes) */
|
||||
Stream_Write_UINT16(s, exec->workingDir.length); /* workingDirLength (2 bytes) */
|
||||
Stream_Write_UINT16(s, exec->arguments.length); /* argumentsLength (2 bytes) */
|
||||
rail_write_unicode_string_value(s, &exec->exeOrFile); /* exeOrFile */
|
||||
rail_write_unicode_string_value(s, &exec->workingDir); /* workingDir */
|
||||
rail_write_unicode_string_value(s, &exec->arguments); /* arguments */
|
||||
|
||||
return rail_write_unicode_string_value(s, &exec->exeOrFile) && /* exeOrFile */
|
||||
rail_write_unicode_string_value(s, &exec->workingDir) && /* workingDir */
|
||||
rail_write_unicode_string_value(s, &exec->arguments); /* arguments */
|
||||
}
|
||||
|
||||
void rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
BOOL rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
BYTE body;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
Stream_Write_UINT32(s, sysparam->param); /* systemParam (4 bytes) */
|
||||
|
||||
@ -267,9 +241,11 @@ void rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
break;
|
||||
|
||||
case SPI_SET_HIGH_CONTRAST:
|
||||
rail_write_high_contrast(s, &sysparam->highContrast);
|
||||
ret = rail_write_high_contrast(s, &sysparam->highContrast);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_write_client_activate_order(wStream* s, RAIL_ACTIVATE_ORDER* activate)
|
||||
@ -513,36 +489,54 @@ BOOL rail_order_recv(railPlugin* rail, wStream* s)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
BOOL rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_handshake_order(s, handshake);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
BOOL rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
s = rail_pdu_init(RAIL_HANDSHAKE_EX_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_handshake_ex_order(s, handshakeEx);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE_EX);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_HANDSHAKE_EX);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
||||
BOOL rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_status_order(s, clientStatus);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_CLIENTSTATUS);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_CLIENTSTATUS);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec)
|
||||
BOOL rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
int length;
|
||||
|
||||
length = RAIL_EXEC_ORDER_LENGTH +
|
||||
@ -550,16 +544,21 @@ void rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec)
|
||||
exec->workingDir.length +
|
||||
exec->arguments.length;
|
||||
|
||||
s = rail_pdu_init(RAIL_EXEC_ORDER_LENGTH);
|
||||
rail_write_client_exec_order(s, exec);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_EXEC);
|
||||
s = rail_pdu_init(length);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
ret = rail_write_client_exec_order(s, exec) &&
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_EXEC);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
BOOL rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
wStream* s;
|
||||
int length;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
length = RAIL_SYSPARAM_ORDER_LENGTH;
|
||||
|
||||
@ -584,115 +583,166 @@ void rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysp
|
||||
}
|
||||
|
||||
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
|
||||
rail_write_client_sysparam_order(s, sysparam);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
ret = rail_write_client_sysparam_order(s, sysparam) &&
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSPARAM);
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
BOOL rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
BOOL ret = TRUE;
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_HIGH_CONTRAST)
|
||||
{
|
||||
sysparam->param = SPI_SET_HIGH_CONTRAST;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_TASKBAR_POS)
|
||||
{
|
||||
sysparam->param = SPI_TASKBAR_POS;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_MOUSE_BUTTON_SWAP)
|
||||
{
|
||||
sysparam->param = SPI_SET_MOUSE_BUTTON_SWAP;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_KEYBOARD_PREF)
|
||||
{
|
||||
sysparam->param = SPI_SET_KEYBOARD_PREF;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_DRAG_FULL_WINDOWS)
|
||||
{
|
||||
sysparam->param = SPI_SET_DRAG_FULL_WINDOWS;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_KEYBOARD_CUES)
|
||||
{
|
||||
sysparam->param = SPI_SET_KEYBOARD_CUES;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
if (sysparam->params & SPI_MASK_SET_WORK_AREA)
|
||||
{
|
||||
sysparam->param = SPI_SET_WORK_AREA;
|
||||
rail_send_client_sysparam_order(rail, sysparam);
|
||||
ret &= rail_send_client_sysparam_order(rail, sysparam);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate)
|
||||
BOOL rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_activate_order(s, activate);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_ACTIVATE);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_ACTIVATE);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu)
|
||||
BOOL rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_sysmenu_order(s, sysmenu);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSMENU);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSMENU);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand)
|
||||
BOOL rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_syscommand_order(s, syscommand);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSCOMMAND);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_SYSCOMMAND);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
||||
BOOL rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_notify_event_order(s, notifyEvent);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_NOTIFY_EVENT);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_NOTIFY_EVENT);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove)
|
||||
BOOL rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_window_move_order(s, windowMove);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_WINDOWMOVE);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_WINDOWMOVE);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
||||
BOOL rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_client_get_appid_req_order(s, getAppIdReq);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_GET_APPID_REQ);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_GET_APPID_REQ);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
BOOL rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
rail_write_langbar_info_order(s, langBarInfo);
|
||||
rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO);
|
||||
ret = rail_send_pdu(rail, s, RDP_RAIL_ORDER_LANGBARINFO);
|
||||
Stream_Free(s, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ BOOL rail_read_server_get_appid_resp_order(wStream* s, RAIL_GET_APPID_RESP_ORDER
|
||||
BOOL rail_read_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
|
||||
|
||||
void rail_write_client_status_order(wStream* s, RAIL_CLIENT_STATUS_ORDER* client_status);
|
||||
void rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec);
|
||||
void rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
BOOL rail_write_client_exec_order(wStream* s, RAIL_EXEC_ORDER* exec);
|
||||
BOOL rail_write_client_sysparam_order(wStream* s, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
void rail_write_client_activate_order(wStream* s, RAIL_ACTIVATE_ORDER* activate);
|
||||
void rail_write_client_sysmenu_order(wStream* s, RAIL_SYSMENU_ORDER* sysmenu);
|
||||
void rail_write_client_syscommand_order(wStream* s, RAIL_SYSCOMMAND_ORDER* syscommand);
|
||||
@ -46,20 +46,20 @@ void rail_write_client_get_appid_req_order(wStream* s, RAIL_GET_APPID_REQ_ORDER*
|
||||
void rail_write_langbar_info_order(wStream* s, RAIL_LANGBAR_INFO_ORDER* langbar_info);
|
||||
|
||||
BOOL rail_order_recv(railPlugin* rail, wStream* s);
|
||||
void rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType);
|
||||
BOOL rail_send_pdu(railPlugin* rail, wStream* s, UINT16 orderType);
|
||||
|
||||
void rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake);
|
||||
void rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
|
||||
void rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus);
|
||||
void rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec);
|
||||
void rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
void rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
void rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate);
|
||||
void rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu);
|
||||
void rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand);
|
||||
void rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
|
||||
void rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove);
|
||||
void rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
|
||||
void rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
|
||||
BOOL rail_send_handshake_order(railPlugin* rail, RAIL_HANDSHAKE_ORDER* handshake);
|
||||
BOOL rail_send_handshake_ex_order(railPlugin* rail, RAIL_HANDSHAKE_EX_ORDER* handshakeEx);
|
||||
BOOL rail_send_client_status_order(railPlugin* rail, RAIL_CLIENT_STATUS_ORDER* clientStatus);
|
||||
BOOL rail_send_client_exec_order(railPlugin* rail, RAIL_EXEC_ORDER* exec);
|
||||
BOOL rail_send_client_sysparam_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
BOOL rail_send_client_sysparams_order(railPlugin* rail, RAIL_SYSPARAM_ORDER* sysparam);
|
||||
BOOL rail_send_client_activate_order(railPlugin* rail, RAIL_ACTIVATE_ORDER* activate);
|
||||
BOOL rail_send_client_sysmenu_order(railPlugin* rail, RAIL_SYSMENU_ORDER* sysmenu);
|
||||
BOOL rail_send_client_syscommand_order(railPlugin* rail, RAIL_SYSCOMMAND_ORDER* syscommand);
|
||||
BOOL rail_send_client_notify_event_order(railPlugin* rail, RAIL_NOTIFY_EVENT_ORDER* notifyEvent);
|
||||
BOOL rail_send_client_window_move_order(railPlugin* rail, RAIL_WINDOW_MOVE_ORDER* windowMove);
|
||||
BOOL rail_send_client_get_appid_req_order(railPlugin* rail, RAIL_GET_APPID_REQ_ORDER* getAppIdReq);
|
||||
BOOL rail_send_client_langbar_info_order(railPlugin* rail, RAIL_LANGBAR_INFO_ORDER* langBarInfo);
|
||||
|
||||
#endif /* __RAIL_ORDERS_H */
|
||||
|
@ -89,6 +89,8 @@ wStream* rail_pdu_init(int length)
|
||||
{
|
||||
wStream* s;
|
||||
s = Stream_New(NULL, length + RAIL_PDU_HEADER_LENGTH);
|
||||
if (!s)
|
||||
return NULL;
|
||||
Stream_Seek(s, RAIL_PDU_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
@ -47,14 +47,17 @@ DEVMAN* devman_new(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
DEVMAN* devman;
|
||||
|
||||
devman = (DEVMAN*) malloc(sizeof(DEVMAN));
|
||||
ZeroMemory(devman, sizeof(DEVMAN));
|
||||
devman = (DEVMAN*) calloc(1, sizeof(DEVMAN));
|
||||
|
||||
devman->plugin = (void*) rdpdr;
|
||||
devman->id_sequence = 1;
|
||||
|
||||
devman->devices = ListDictionary_New(TRUE);
|
||||
|
||||
if (!devman->devices)
|
||||
{
|
||||
free(devman);
|
||||
return NULL;
|
||||
}
|
||||
ListDictionary_ValueObject(devman->devices)->fnObjectFree =
|
||||
(OBJECT_FREE_FN) devman_device_free;
|
||||
|
||||
|
@ -786,12 +786,15 @@ static void rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rdpdr_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
BOOL rdpdr_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
if (!g_InitHandles)
|
||||
{
|
||||
g_InitHandles = ListDictionary_New(TRUE);
|
||||
|
||||
ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
if (!g_InitHandles)
|
||||
return FALSE;
|
||||
}
|
||||
return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rdpdr_get_init_handle_data(void* pInitHandle)
|
||||
@ -811,14 +814,18 @@ void rdpdr_remove_init_handle_data(void* pInitHandle)
|
||||
}
|
||||
}
|
||||
|
||||
void rdpdr_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
BOOL rdpdr_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = ListDictionary_New(TRUE);
|
||||
if (!g_OpenHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rdpdr_get_open_handle_data(DWORD openHandle)
|
||||
@ -973,7 +980,11 @@ static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa
|
||||
status = rdpdr->channelEntryPoints.pVirtualChannelOpen(rdpdr->InitHandle,
|
||||
&rdpdr->OpenHandle, rdpdr->channelDef.name, rdpdr_virtual_channel_open_event);
|
||||
|
||||
rdpdr_add_open_handle_data(rdpdr->OpenHandle, rdpdr);
|
||||
if (!rdpdr_add_open_handle_data(rdpdr->OpenHandle, rdpdr))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to register open handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -983,9 +994,19 @@ static void rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa
|
||||
}
|
||||
|
||||
rdpdr->queue = MessageQueue_New(NULL);
|
||||
if (!rdpdr->queue)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create queue", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
rdpdr->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0, NULL);
|
||||
if (!rdpdr->thread)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create thread", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
|
||||
@ -1094,7 +1115,5 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
return -1;
|
||||
}
|
||||
|
||||
rdpdr_add_init_handle_data(rdpdr->InitHandle, (void*) rdpdr);
|
||||
|
||||
return 1;
|
||||
return rdpdr_add_init_handle_data(rdpdr->InitHandle, (void*) rdpdr) ? 1 : -1;
|
||||
}
|
||||
|
@ -1115,7 +1115,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
||||
gfx->iface.Terminated = rdpgfx_plugin_terminated;
|
||||
|
||||
gfx->SurfaceTable = HashTable_New(TRUE);
|
||||
|
||||
if (!gfx->SurfaceTable)
|
||||
{
|
||||
free (gfx);
|
||||
|
@ -229,27 +229,34 @@ static void openSLDestroyEngine(OPENSL_STREAM *p){
|
||||
|
||||
// open the android audio device for and/or output
|
||||
OPENSL_STREAM *android_OpenAudioDevice(int sr, int outchannels, int bufferframes){
|
||||
|
||||
OPENSL_STREAM *p;
|
||||
p = (OPENSL_STREAM *) calloc(sizeof(OPENSL_STREAM),1);
|
||||
memset(p, 0, sizeof(OPENSL_STREAM));
|
||||
OPENSL_STREAM *p;
|
||||
p = (OPENSL_STREAM *) calloc(sizeof(OPENSL_STREAM), 1);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->queuesize = bufferframes;
|
||||
p->outchannels = outchannels;
|
||||
p->sr = sr;
|
||||
|
||||
if(openSLCreateEngine(p) != SL_RESULT_SUCCESS) {
|
||||
android_CloseAudioDevice(p);
|
||||
return NULL;
|
||||
}
|
||||
p->outchannels = outchannels;
|
||||
p->sr = sr;
|
||||
|
||||
if(openSLPlayOpen(p) != SL_RESULT_SUCCESS) {
|
||||
android_CloseAudioDevice(p);
|
||||
return NULL;
|
||||
}
|
||||
if(openSLCreateEngine(p) != SL_RESULT_SUCCESS)
|
||||
{
|
||||
android_CloseAudioDevice(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(openSLPlayOpen(p) != SL_RESULT_SUCCESS)
|
||||
{
|
||||
android_CloseAudioDevice(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->queue = Queue_New(TRUE, -1, -1);
|
||||
|
||||
if (!p->queue)
|
||||
{
|
||||
android_CloseAudioDevice(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -832,12 +832,16 @@ static void rdpsnd_process_disconnect(rdpsndPlugin* rdpsnd)
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void rdpsnd_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
BOOL rdpsnd_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
if (!g_InitHandles)
|
||||
{
|
||||
g_InitHandles = ListDictionary_New(TRUE);
|
||||
if (!g_InitHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rdpsnd_get_init_handle_data(void* pInitHandle)
|
||||
@ -857,14 +861,18 @@ void rdpsnd_remove_init_handle_data(void* pInitHandle)
|
||||
}
|
||||
}
|
||||
|
||||
void rdpsnd_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
BOOL rdpsnd_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = ListDictionary_New(TRUE);
|
||||
if (!g_OpenHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
}
|
||||
|
||||
void* rdpsnd_get_open_handle_data(DWORD openHandle)
|
||||
@ -1014,7 +1022,11 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID
|
||||
status = plugin->channelEntryPoints.pVirtualChannelOpen(plugin->InitHandle,
|
||||
&plugin->OpenHandle, plugin->channelDef.name, rdpsnd_virtual_channel_open_event);
|
||||
|
||||
rdpsnd_add_open_handle_data(plugin->OpenHandle, plugin);
|
||||
if (!rdpsnd_add_open_handle_data(plugin->OpenHandle, plugin))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to register opened handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -1024,9 +1036,19 @@ static void rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin, LPVOID
|
||||
}
|
||||
|
||||
plugin->MsgPipe = MessagePipe_New();
|
||||
if (!plugin->MsgPipe)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create message pipe", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_virtual_channel_client_thread, (void*) plugin, 0, NULL);
|
||||
if (!plugin->thread)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create thread", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
||||
@ -1130,39 +1152,37 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
|
||||
|
||||
if (rdpsnd)
|
||||
{
|
||||
if (!rdpsnd)
|
||||
return -1;
|
||||
|
||||
#if !defined(_WIN32) && !defined(ANDROID)
|
||||
{
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGIO);
|
||||
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
||||
}
|
||||
{
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGIO);
|
||||
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
rdpsnd->channelDef.options =
|
||||
CHANNEL_OPTION_INITIALIZED |
|
||||
CHANNEL_OPTION_ENCRYPT_RDP;
|
||||
rdpsnd->channelDef.options =
|
||||
CHANNEL_OPTION_INITIALIZED |
|
||||
CHANNEL_OPTION_ENCRYPT_RDP;
|
||||
|
||||
strcpy(rdpsnd->channelDef.name, "rdpsnd");
|
||||
strcpy(rdpsnd->channelDef.name, "rdpsnd");
|
||||
|
||||
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||
|
||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpsnd_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpsnd);
|
||||
return -1;
|
||||
}
|
||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||
|
||||
rdpsnd_add_init_handle_data(rdpsnd->InitHandle, (void*) rdpsnd);
|
||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, rdpsnd_virtual_channel_init_event);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpsnd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return rdpsnd_add_init_handle_data(rdpsnd->InitHandle, (void*) rdpsnd) ? 1 : -1;
|
||||
}
|
||||
|
@ -523,12 +523,16 @@ static void remdesk_process_connect(remdeskPlugin* remdesk)
|
||||
static wListDictionary* g_InitHandles = NULL;
|
||||
static wListDictionary* g_OpenHandles = NULL;
|
||||
|
||||
void remdesk_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
BOOL remdesk_add_init_handle_data(void* pInitHandle, void* pUserData)
|
||||
{
|
||||
if (!g_InitHandles)
|
||||
{
|
||||
g_InitHandles = ListDictionary_New(TRUE);
|
||||
if (!g_InitHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
return ListDictionary_Add(g_InitHandles, pInitHandle, pUserData);
|
||||
}
|
||||
|
||||
void* remdesk_get_init_handle_data(void* pInitHandle)
|
||||
@ -548,14 +552,18 @@ void remdesk_remove_init_handle_data(void* pInitHandle)
|
||||
}
|
||||
}
|
||||
|
||||
void remdesk_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
BOOL remdesk_add_open_handle_data(DWORD openHandle, void* pUserData)
|
||||
{
|
||||
void* pOpenHandle = (void*) (size_t) openHandle;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = ListDictionary_New(TRUE);
|
||||
if (!g_OpenHandles)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
return ListDictionary_Add(g_OpenHandles, pOpenHandle, pUserData);
|
||||
}
|
||||
|
||||
void* remdesk_get_open_handle_data(DWORD openHandle)
|
||||
@ -704,7 +712,11 @@ static void remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO
|
||||
status = remdesk->channelEntryPoints.pVirtualChannelOpen(remdesk->InitHandle,
|
||||
&remdesk->OpenHandle, remdesk->channelDef.name, remdesk_virtual_channel_open_event);
|
||||
|
||||
remdesk_add_open_handle_data(remdesk->OpenHandle, remdesk);
|
||||
if (!remdesk_add_open_handle_data(remdesk->OpenHandle, remdesk))
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to register open handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
@ -714,9 +726,19 @@ static void remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO
|
||||
}
|
||||
|
||||
remdesk->queue = MessageQueue_New(NULL);
|
||||
if (!remdesk->queue)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create message queue", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
remdesk->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) remdesk_virtual_channel_client_thread, (void*) remdesk, 0, NULL);
|
||||
if (!remdesk->thread)
|
||||
{
|
||||
WLog_ERR(TAG, "%s: unable to create thread", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk)
|
||||
@ -837,7 +859,5 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
remdesk->channelEntryPoints.pInterface = *(remdesk->channelEntryPoints.ppInterface);
|
||||
remdesk->channelEntryPoints.ppInterface = &(remdesk->channelEntryPoints.pInterface);
|
||||
|
||||
remdesk_add_init_handle_data(remdesk->InitHandle, (void*) remdesk);
|
||||
|
||||
return 1;
|
||||
return remdesk_add_init_handle_data(remdesk->InitHandle, (void*) remdesk) ? 1 : -1;
|
||||
}
|
||||
|
@ -79,21 +79,28 @@ SMARTCARD_CONTEXT* smartcard_context_new(SMARTCARD_DEVICE* smartcard, SCARDCONTE
|
||||
SMARTCARD_CONTEXT* pContext;
|
||||
|
||||
pContext = (SMARTCARD_CONTEXT*) calloc(1, sizeof(SMARTCARD_CONTEXT));
|
||||
|
||||
if (!pContext)
|
||||
return pContext;
|
||||
|
||||
pContext->smartcard = smartcard;
|
||||
|
||||
pContext->hContext = hContext;
|
||||
|
||||
pContext->IrpQueue = MessageQueue_New(NULL);
|
||||
if (!pContext->IrpQueue)
|
||||
goto error_irpqueue;
|
||||
|
||||
pContext->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) smartcard_context_thread,
|
||||
pContext, 0, NULL);
|
||||
|
||||
if (!pContext->thread)
|
||||
goto error_thread;
|
||||
return pContext;
|
||||
|
||||
error_thread:
|
||||
MessageQueue_Free(pContext->IrpQueue);
|
||||
error_irpqueue:
|
||||
free(pContext);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void smartcard_context_free(SMARTCARD_CONTEXT* pContext)
|
||||
@ -486,7 +493,6 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
path = device->Path;
|
||||
|
||||
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
|
||||
|
||||
if (!smartcard)
|
||||
return -1;
|
||||
|
||||
@ -498,6 +504,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
length = strlen(smartcard->device.name);
|
||||
smartcard->device.data = Stream_New(NULL, length + 1);
|
||||
if (!smartcard->device.data)
|
||||
goto error_device_data;
|
||||
|
||||
Stream_Write(smartcard->device.data, "SCARD", 6);
|
||||
|
||||
@ -518,23 +526,47 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
}
|
||||
|
||||
smartcard->IrpQueue = MessageQueue_New(NULL);
|
||||
if (!smartcard->IrpQueue)
|
||||
goto error_irp_queue;
|
||||
|
||||
smartcard->CompletedIrpQueue = Queue_New(TRUE, -1, -1);
|
||||
if (!smartcard->CompletedIrpQueue)
|
||||
goto error_completed_irp_queue;
|
||||
|
||||
smartcard->rgSCardContextList = ListDictionary_New(TRUE);
|
||||
if (!smartcard->rgSCardContextList)
|
||||
goto error_context_list;
|
||||
|
||||
ListDictionary_ValueObject(smartcard->rgSCardContextList)->fnObjectFree =
|
||||
(OBJECT_FREE_FN) smartcard_context_free;
|
||||
|
||||
smartcard->rgOutstandingMessages = ListDictionary_New(TRUE);
|
||||
if (!smartcard->rgOutstandingMessages)
|
||||
goto error_outstanding_messages;
|
||||
|
||||
smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
|
||||
smartcard, CREATE_SUSPENDED, NULL);
|
||||
if (!smartcard->thread)
|
||||
goto error_thread;
|
||||
|
||||
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) smartcard);
|
||||
|
||||
ResumeThread(smartcard->thread);
|
||||
|
||||
return 0;
|
||||
|
||||
error_thread:
|
||||
ListDictionary_Free(smartcard->rgOutstandingMessages);
|
||||
error_outstanding_messages:
|
||||
ListDictionary_Free(smartcard->rgSCardContextList);
|
||||
error_context_list:
|
||||
Queue_Free(smartcard->CompletedIrpQueue);
|
||||
error_completed_irp_queue:
|
||||
MessageQueue_Free(smartcard->IrpQueue);
|
||||
error_irp_queue:
|
||||
Stream_Free(smartcard->device.data, TRUE);
|
||||
error_device_data:
|
||||
free(smartcard);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,7 @@ static UINT32 smartcard_EstablishContext_Call(SMARTCARD_DEVICE* smartcard, SMART
|
||||
{
|
||||
SMARTCARD_CONTEXT* pContext;
|
||||
void* key = (void*)(size_t) hContext;
|
||||
// TODO: handle return values
|
||||
pContext = smartcard_context_new(smartcard, hContext);
|
||||
ListDictionary_Add(smartcard->rgSCardContextList, key, (void*) pContext);
|
||||
}
|
||||
|
@ -421,7 +421,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
||||
if (!tsmf)
|
||||
{
|
||||
tsmf = (TSMF_PLUGIN*) calloc(1, sizeof(TSMF_PLUGIN));
|
||||
|
||||
if (!tsmf)
|
||||
return -1;
|
||||
|
||||
@ -431,17 +430,14 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
||||
tsmf->iface.Terminated = tsmf_plugin_terminated;
|
||||
|
||||
context = (TsmfClientContext*) calloc(1, sizeof(TsmfClientContext));
|
||||
|
||||
if (!context)
|
||||
{
|
||||
free (tsmf);
|
||||
return -1;
|
||||
}
|
||||
goto error_context;
|
||||
|
||||
context->handle = (void*) tsmf;
|
||||
tsmf->iface.pInterface = (void*) context;
|
||||
|
||||
tsmf_media_init();
|
||||
if (!tsmf_media_init())
|
||||
goto error_init;
|
||||
|
||||
status = pEntryPoints->RegisterPlugin(pEntryPoints, "tsmf", (IWTSPlugin*) tsmf);
|
||||
}
|
||||
@ -452,4 +448,10 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
error_init:
|
||||
free(context);
|
||||
error_context:
|
||||
free(tsmf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -279,7 +279,6 @@ TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCal
|
||||
return NULL;
|
||||
|
||||
presentation = (TSMF_PRESENTATION*) calloc(1, sizeof(TSMF_PRESENTATION));
|
||||
|
||||
if (!presentation)
|
||||
{
|
||||
WLog_ERR(TAG, "calloc failed");
|
||||
@ -290,11 +289,22 @@ TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCal
|
||||
presentation->channel_callback = pChannelCallback;
|
||||
presentation->volume = 5000; /* 50% */
|
||||
presentation->stream_list = ArrayList_New(TRUE);
|
||||
if (presentation->stream_list)
|
||||
goto error_stream_list;
|
||||
|
||||
ArrayList_Object(presentation->stream_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_stream_free;
|
||||
|
||||
ArrayList_Add(presentation_list, presentation);
|
||||
if (ArrayList_Add(presentation_list, presentation) < 0)
|
||||
goto error_add;
|
||||
|
||||
return presentation;
|
||||
|
||||
error_add:
|
||||
ArrayList_Free(presentation->stream_list);
|
||||
error_stream_list:
|
||||
free(presentation);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
static char* guid_to_string(const BYTE* guid, char* str, size_t len)
|
||||
@ -937,7 +947,6 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id)
|
||||
}
|
||||
|
||||
stream = (TSMF_STREAM*) calloc(1, sizeof(TSMF_STREAM));
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
WLog_ERR(TAG, "Calloc failed");
|
||||
@ -947,17 +956,49 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id)
|
||||
stream->stream_id = stream_id;
|
||||
stream->presentation = presentation;
|
||||
stream->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (!stream->stopEvent)
|
||||
goto error_stopEvent;
|
||||
stream->ready = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||
if (!stream->ready)
|
||||
goto error_ready;
|
||||
stream->sample_list = Queue_New(TRUE, -1, -1);
|
||||
if (!stream->sample_list)
|
||||
goto error_sample_list;
|
||||
stream->sample_list->object.fnObjectFree = tsmf_sample_free;
|
||||
stream->sample_ack_list = Queue_New(TRUE, -1, -1);
|
||||
if (!stream->sample_ack_list)
|
||||
goto error_sample_ack_list;
|
||||
stream->sample_ack_list->object.fnObjectFree = tsmf_sample_free;
|
||||
stream->play_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) tsmf_stream_playback_func, stream, 0, NULL);
|
||||
stream->ack_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)tsmf_stream_ack_func, stream, 0, NULL);
|
||||
|
||||
ArrayList_Add(presentation->stream_list, stream);
|
||||
stream->play_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) tsmf_stream_playback_func, stream, 0, NULL);
|
||||
if (!stream->play_thread)
|
||||
goto error_play_thread;
|
||||
stream->ack_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)tsmf_stream_ack_func, stream, 0, NULL);
|
||||
if (!stream->ack_thread)
|
||||
goto error_ack_thread;
|
||||
|
||||
if (ArrayList_Add(presentation->stream_list, stream) < 0)
|
||||
goto error_add;
|
||||
|
||||
return stream;
|
||||
|
||||
error_add:
|
||||
SetEvent(stream->stopEvent);
|
||||
WaitForSingleObject(stream->ack_thread, INFINITE);
|
||||
error_ack_thread:
|
||||
SetEvent(stream->stopEvent);
|
||||
WaitForSingleObject(stream->play_thread, INFINITE);
|
||||
error_play_thread:
|
||||
Queue_Free(stream->sample_ack_list);
|
||||
error_sample_ack_list:
|
||||
Queue_Free(stream->sample_list);
|
||||
error_sample_list:
|
||||
CloseHandle(stream->ready);
|
||||
error_ready:
|
||||
CloseHandle(stream->stopEvent);
|
||||
error_stopEvent:
|
||||
free(stream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TSMF_STREAM *tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stream_id)
|
||||
@ -1151,7 +1192,7 @@ static void tsmf_signal_handler(int s)
|
||||
|
||||
#endif
|
||||
|
||||
void tsmf_media_init(void)
|
||||
BOOL tsmf_media_init(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct sigaction sigtrap;
|
||||
@ -1165,6 +1206,9 @@ void tsmf_media_init(void)
|
||||
if (!presentation_list)
|
||||
{
|
||||
presentation_list = ArrayList_New(TRUE);
|
||||
if (!presentation_list)
|
||||
return FALSE;
|
||||
ArrayList_Object(presentation_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_presentation_free;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ void tsmf_stream_push_sample(TSMF_STREAM *stream, IWTSVirtualChannelCallback *pC
|
||||
UINT32 sample_id, UINT64 start_time, UINT64 end_time, UINT64 duration, UINT32 extensions,
|
||||
UINT32 data_size, BYTE *data);
|
||||
|
||||
void tsmf_media_init(void);
|
||||
BOOL tsmf_media_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1007,7 +1007,7 @@ void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion)
|
||||
region16_uninit(&windowInvalidRegion);
|
||||
}
|
||||
|
||||
void wf_rail_init(wfContext* wfc, RailClientContext* rail)
|
||||
BOOL wf_rail_init(wfContext* wfc, RailClientContext* rail)
|
||||
{
|
||||
rdpContext* context = (rdpContext*) wfc;
|
||||
|
||||
@ -1026,6 +1026,7 @@ void wf_rail_init(wfContext* wfc, RailClientContext* rail)
|
||||
wf_rail_register_update_callbacks(context->update);
|
||||
|
||||
wfc->railWindows = HashTable_New(TRUE);
|
||||
return (wfc->railWindows != NULL);
|
||||
}
|
||||
|
||||
void wf_rail_uninit(wfContext* wfc, RailClientContext* rail)
|
||||
|
@ -41,7 +41,7 @@ struct wf_rail_window
|
||||
char* title;
|
||||
};
|
||||
|
||||
void wf_rail_init(wfContext* wfc, RailClientContext* rail);
|
||||
BOOL wf_rail_init(wfContext* wfc, RailClientContext* rail);
|
||||
void wf_rail_uninit(wfContext* wfc, RailClientContext* rail);
|
||||
|
||||
void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion);
|
||||
|
@ -94,6 +94,8 @@ int xf_event_action_script_init(xfContext* xfc)
|
||||
char command[1024] = { 0 };
|
||||
|
||||
xfc->xevents = ArrayList_New(TRUE);
|
||||
if (!xfc->xevents)
|
||||
return -1;
|
||||
ArrayList_Object(xfc->xevents)->fnObjectFree = free;
|
||||
|
||||
sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript);
|
||||
@ -107,7 +109,8 @@ int xf_event_action_script_init(xfContext* xfc)
|
||||
{
|
||||
strtok(buffer, "\n");
|
||||
xevent = _strdup(buffer);
|
||||
ArrayList_Add(xfc->xevents, xevent);
|
||||
if (ArrayList_Add(xfc->xevents, xevent) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
exitCode = pclose(actionScript);
|
||||
|
@ -64,6 +64,9 @@ int xf_keyboard_action_script_init(xfContext* xfc)
|
||||
return 0;
|
||||
|
||||
xfc->keyCombinations = ArrayList_New(TRUE);
|
||||
if (!xfc->keyCombinations)
|
||||
return 0;
|
||||
|
||||
ArrayList_Object(xfc->keyCombinations)->fnObjectFree = free;
|
||||
|
||||
sprintf_s(command, sizeof(command), "%s key", xfc->actionScript);
|
||||
@ -81,14 +84,13 @@ int xf_keyboard_action_script_init(xfContext* xfc)
|
||||
{
|
||||
strtok(buffer, "\n");
|
||||
keyCombination = _strdup(buffer);
|
||||
ArrayList_Add(xfc->keyCombinations, keyCombination);
|
||||
if (ArrayList_Add(xfc->keyCombinations, keyCombination) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
exitCode = pclose(keyScript);
|
||||
|
||||
xf_event_action_script_init(xfc);
|
||||
|
||||
return 1;
|
||||
return xf_event_action_script_init(xfc);
|
||||
}
|
||||
|
||||
void xf_keyboard_action_script_free(xfContext* xfc)
|
||||
|
@ -871,6 +871,8 @@ int xf_rail_init(xfContext* xfc, RailClientContext* rail)
|
||||
rail->ServerGetAppIdResponse = xf_rail_server_get_appid_response;
|
||||
|
||||
xfc->railWindows = HashTable_New(TRUE);
|
||||
if (!xfc->railWindows)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -375,4 +375,16 @@ typedef struct _RAIL_COMPARTMENT_INFO_ORDER RAIL_COMPARTMENT_INFO_ORDER;
|
||||
#define RDP_RAIL_ORDER_COMPARTMENTINFO 0x0012
|
||||
#define RDP_RAIL_ORDER_HANDSHAKE_EX 0x0013
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FREERDP_RAIL_GLOBAL_H */
|
||||
|
@ -177,10 +177,13 @@ static void nsc_rle_decompress_data(NSC_CONTEXT* context)
|
||||
}
|
||||
}
|
||||
|
||||
static void nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
static BOOL nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 20)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
Stream_Read_UINT32(s, context->PlaneByteCount[i]);
|
||||
|
||||
@ -189,27 +192,35 @@ static void nsc_stream_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
Stream_Seek(s, 2); /* Reserved (2 bytes) */
|
||||
|
||||
context->Planes = Stream_Pointer(s);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
{
|
||||
int i;
|
||||
UINT32 length;
|
||||
UINT32 tempWidth;
|
||||
UINT32 tempHeight;
|
||||
|
||||
nsc_stream_initialize(context, s);
|
||||
if (!nsc_stream_initialize(context, s))
|
||||
return FALSE;
|
||||
length = context->width * context->height * 4;
|
||||
|
||||
if (!context->BitmapData)
|
||||
{
|
||||
context->BitmapData = malloc(length + 16);
|
||||
ZeroMemory(context->BitmapData, length + 16);
|
||||
context->BitmapData = calloc(1, length + 16);
|
||||
if (!context->BitmapData)
|
||||
return FALSE;
|
||||
|
||||
context->BitmapDataLength = length;
|
||||
}
|
||||
else if (length > context->BitmapDataLength)
|
||||
{
|
||||
context->BitmapData = realloc(context->BitmapData, length + 16);
|
||||
void *tmp;
|
||||
tmp = realloc(context->BitmapData, length + 16);
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
context->BitmapData = tmp;
|
||||
context->BitmapDataLength = length;
|
||||
}
|
||||
|
||||
@ -222,7 +233,12 @@ static void nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
if (length > context->priv->PlaneBuffersLength)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
context->priv->PlaneBuffers[i] = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
|
||||
{
|
||||
void * tmp = (BYTE*) realloc(context->priv->PlaneBuffers[i], length);
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
context->priv->PlaneBuffers[i] = tmp;
|
||||
}
|
||||
|
||||
context->priv->PlaneBuffersLength = length;
|
||||
}
|
||||
@ -238,6 +254,8 @@ static void nsc_context_initialize(NSC_CONTEXT* context, wStream* s)
|
||||
context->OrgByteCount[1] = (tempWidth >> 1) * (tempHeight >> 1);
|
||||
context->OrgByteCount[2] = context->OrgByteCount[1];
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void nsc_profiler_print(NSC_CONTEXT* context)
|
||||
@ -263,17 +281,18 @@ NSC_CONTEXT* nsc_context_new(void)
|
||||
NSC_CONTEXT* context;
|
||||
|
||||
context = (NSC_CONTEXT*) calloc(1, sizeof(NSC_CONTEXT));
|
||||
if (!context)
|
||||
return NULL;
|
||||
|
||||
context->priv = (NSC_CONTEXT_PRIV*) calloc(1, sizeof(NSC_CONTEXT_PRIV));
|
||||
if (!context->priv)
|
||||
goto error_priv;
|
||||
|
||||
WLog_Init();
|
||||
|
||||
context->priv->log = WLog_Get("com.freerdp.codec.nsc");
|
||||
WLog_OpenAppender(context->priv->log);
|
||||
|
||||
for (i = 0; i < 5; ++i)
|
||||
{
|
||||
context->priv->PlaneBuffers[i] = NULL;
|
||||
}
|
||||
|
||||
context->BitmapData = NULL;
|
||||
|
||||
@ -281,6 +300,8 @@ NSC_CONTEXT* nsc_context_new(void)
|
||||
context->encode = nsc_encode;
|
||||
|
||||
context->priv->PlanePool = BufferPool_New(TRUE, 0, 16);
|
||||
if (!context->priv->PlanePool)
|
||||
goto error_PlanePool;
|
||||
|
||||
PROFILER_CREATE(context->priv->prof_nsc_rle_decompress_data, "nsc_rle_decompress_data");
|
||||
PROFILER_CREATE(context->priv->prof_nsc_decode, "nsc_decode");
|
||||
@ -295,6 +316,12 @@ NSC_CONTEXT* nsc_context_new(void)
|
||||
NSC_INIT_SIMD(context);
|
||||
|
||||
return context;
|
||||
|
||||
error_PlanePool:
|
||||
free(context->priv);
|
||||
error_priv:
|
||||
free(context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void nsc_context_free(NSC_CONTEXT* context)
|
||||
@ -362,6 +389,7 @@ void nsc_context_set_pixel_format(NSC_CONTEXT* context, RDP_PIXEL_FORMAT pixel_f
|
||||
int nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, UINT16 width, UINT16 height, BYTE* data, UINT32 length)
|
||||
{
|
||||
wStream* s;
|
||||
BOOL ret;
|
||||
|
||||
s = Stream_New(data, length);
|
||||
|
||||
@ -371,9 +399,13 @@ int nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, UINT16 width, UINT16 h
|
||||
context->bpp = bpp;
|
||||
context->width = width;
|
||||
context->height = height;
|
||||
nsc_context_initialize(context, s);
|
||||
|
||||
ret = nsc_context_initialize(context, s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
if (!ret)
|
||||
return -1;
|
||||
|
||||
/* RLE decode */
|
||||
PROFILER_ENTER(context->priv->prof_nsc_rle_decompress_data);
|
||||
nsc_rle_decompress_data(context);
|
||||
|
@ -81,19 +81,30 @@ rdpChannels* freerdp_channels_new(void)
|
||||
rdpChannels* channels;
|
||||
|
||||
channels = (rdpChannels*) calloc(1, sizeof(rdpChannels));
|
||||
|
||||
if (!channels)
|
||||
return NULL;
|
||||
|
||||
channels->queue = MessageQueue_New(NULL);
|
||||
if (!channels->queue)
|
||||
goto error_queue;
|
||||
|
||||
if (!g_OpenHandles)
|
||||
{
|
||||
g_OpenHandles = HashTable_New(TRUE);
|
||||
InitializeCriticalSectionAndSpinCount(&g_channels_lock, 4000);
|
||||
if (!g_OpenHandles)
|
||||
goto error_open_handles;
|
||||
|
||||
if (!InitializeCriticalSectionAndSpinCount(&g_channels_lock, 4000))
|
||||
goto error_open_handles;
|
||||
}
|
||||
|
||||
return channels;
|
||||
|
||||
error_open_handles:
|
||||
MessageQueue_Free(channels->queue);
|
||||
error_queue:
|
||||
free(channels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void freerdp_channels_free(rdpChannels* channels)
|
||||
|
@ -796,6 +796,11 @@ HttpResponse* http_response_new()
|
||||
return NULL;
|
||||
|
||||
response->Authenticates = ListDictionary_New(FALSE);
|
||||
if (!response->Authenticates)
|
||||
{
|
||||
free(response);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ListDictionary_KeyObject(response->Authenticates)->fnObjectEquals = strings_equals_nocase;
|
||||
ListDictionary_KeyObject(response->Authenticates)->fnObjectFree = string_free;
|
||||
|
@ -343,7 +343,7 @@ int rpc_recv_bind_ack_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
|
||||
int rpc_send_rpc_auth_3_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
int status = -1;
|
||||
BYTE* buffer;
|
||||
UINT32 offset;
|
||||
UINT32 length;
|
||||
@ -399,9 +399,10 @@ int rpc_send_rpc_auth_3_pdu(rdpRpc* rpc)
|
||||
length = auth_3_pdu->frag_length;
|
||||
|
||||
clientCall = rpc_client_call_new(auth_3_pdu->call_id, 0);
|
||||
ArrayList_Add(rpc->client->ClientCallList, clientCall);
|
||||
|
||||
status = rpc_in_channel_send_pdu(inChannel, buffer, length);
|
||||
if (ArrayList_Add(rpc->client->ClientCallList, clientCall) >= 0)
|
||||
{
|
||||
status = rpc_in_channel_send_pdu(inChannel, buffer, length);
|
||||
}
|
||||
|
||||
free(auth_3_pdu);
|
||||
free(buffer);
|
||||
|
@ -1048,7 +1048,6 @@ int rpc_client_new(rdpRpc* rpc)
|
||||
return -1;
|
||||
|
||||
client->ClientCallList = ArrayList_New(TRUE);
|
||||
|
||||
if (!client->ClientCallList)
|
||||
return -1;
|
||||
|
||||
|
@ -590,13 +590,15 @@ rdpInput* input_new(rdpRdp* rdp)
|
||||
const wObject cb = { NULL, NULL, NULL, input_free_queued_message, NULL };
|
||||
rdpInput* input;
|
||||
|
||||
input = (rdpInput*) malloc(sizeof(rdpInput));
|
||||
input = (rdpInput*) calloc(1, sizeof(rdpInput));
|
||||
if (!input)
|
||||
return NULL;
|
||||
|
||||
if (input != NULL)
|
||||
input->queue = MessageQueue_New(&cb);
|
||||
if (!input->queue)
|
||||
{
|
||||
ZeroMemory(input, sizeof(rdpInput));
|
||||
|
||||
input->queue = MessageQueue_New(&cb);
|
||||
free(input);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return input;
|
||||
|
@ -327,6 +327,8 @@ BOOL nego_send_preconnection_pdu(rdpNego* nego)
|
||||
}
|
||||
|
||||
s = Stream_New(NULL, cbSize);
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, cbSize); /* cbSize */
|
||||
Stream_Write_UINT32(s, 0); /* Flags */
|
||||
|
@ -331,14 +331,16 @@ static void wts_write_drdynvc_header(wStream* s, BYTE Cmd, UINT32 ChannelId)
|
||||
*bm = ((Cmd & 0x0F) << 4) | cbChId;
|
||||
}
|
||||
|
||||
static void wts_write_drdynvc_create_request(wStream *s, UINT32 ChannelId, const char *ChannelName)
|
||||
static BOOL wts_write_drdynvc_create_request(wStream *s, UINT32 ChannelId, const char *ChannelName)
|
||||
{
|
||||
UINT32 len;
|
||||
|
||||
wts_write_drdynvc_header(s, CREATE_REQUEST_PDU, ChannelId);
|
||||
len = strlen(ChannelName) + 1;
|
||||
Stream_EnsureRemainingCapacity(s, (int) len);
|
||||
if (!Stream_EnsureRemainingCapacity(s, (int) len))
|
||||
return FALSE;
|
||||
Stream_Write(s, ChannelName, len);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void WTSProcessChannelData(rdpPeerChannel* channel, UINT16 channelId, BYTE* data, int size, int flags, int totalSize)
|
||||
@ -687,30 +689,46 @@ HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager));
|
||||
if (!vcm)
|
||||
return NULL;
|
||||
|
||||
if (vcm)
|
||||
vcm->client = client;
|
||||
vcm->rdp = context->rdp;
|
||||
|
||||
vcm->SessionId = g_SessionId++;
|
||||
|
||||
if (!g_ServerHandles)
|
||||
{
|
||||
vcm->client = client;
|
||||
vcm->rdp = context->rdp;
|
||||
|
||||
vcm->SessionId = g_SessionId++;
|
||||
|
||||
g_ServerHandles = HashTable_New(TRUE);
|
||||
if (!g_ServerHandles)
|
||||
g_ServerHandles = HashTable_New(TRUE);
|
||||
|
||||
HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm);
|
||||
|
||||
vcm->queue = MessageQueue_New(NULL);
|
||||
|
||||
vcm->dvc_channel_id_seq = 0;
|
||||
vcm->dynamicVirtualChannels = ArrayList_New(TRUE);
|
||||
|
||||
client->ReceiveChannelData = WTSReceiveChannelData;
|
||||
|
||||
hServer = (HANDLE) vcm;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
if (HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm) < 0)
|
||||
goto error_free;
|
||||
|
||||
vcm->queue = MessageQueue_New(NULL);
|
||||
if (!vcm->queue)
|
||||
goto error_queue;
|
||||
|
||||
vcm->dvc_channel_id_seq = 0;
|
||||
vcm->dynamicVirtualChannels = ArrayList_New(TRUE);
|
||||
if (!vcm->dynamicVirtualChannels)
|
||||
goto error_dynamicVirtualChannels;
|
||||
|
||||
client->ReceiveChannelData = WTSReceiveChannelData;
|
||||
|
||||
hServer = (HANDLE) vcm;
|
||||
|
||||
return hServer;
|
||||
|
||||
error_dynamicVirtualChannels:
|
||||
MessageQueue_Free(vcm->queue);
|
||||
error_queue:
|
||||
HashTable_Remove(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId);
|
||||
error_free:
|
||||
free(vcm);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
HANDLE WINAPI FreeRDP_WTSOpenServerExW(LPWSTR pServerName)
|
||||
@ -936,7 +954,11 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
|
||||
channel->index = index;
|
||||
channel->channelType = RDP_PEER_CHANNEL_TYPE_SVC;
|
||||
channel->receiveData = Stream_New(NULL, client->settings->VirtualChannelChunkSize);
|
||||
if (!channel->receiveData)
|
||||
goto error_receiveData;
|
||||
channel->queue = MessageQueue_New(NULL);
|
||||
if (!channel->queue)
|
||||
goto error_queue;
|
||||
|
||||
mcs->channels[index].handle = channel;
|
||||
}
|
||||
@ -944,6 +966,13 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS
|
||||
hChannelHandle = (HANDLE) channel;
|
||||
|
||||
return hChannelHandle;
|
||||
|
||||
error_queue:
|
||||
Stream_Free(channel->receiveData, TRUE);
|
||||
error_receiveData:
|
||||
free(channel);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HANDLE WINAPI FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags)
|
||||
@ -995,22 +1024,49 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualNam
|
||||
}
|
||||
|
||||
channel = (rdpPeerChannel*) calloc(1, sizeof(rdpPeerChannel));
|
||||
if (!channel)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
channel->vcm = vcm;
|
||||
channel->client = client;
|
||||
channel->channelType = RDP_PEER_CHANNEL_TYPE_DVC;
|
||||
channel->receiveData = Stream_New(NULL, client->settings->VirtualChannelChunkSize);
|
||||
if (!channel->receiveData)
|
||||
goto error_receiveData;
|
||||
channel->queue = MessageQueue_New(NULL);
|
||||
if (!channel->queue)
|
||||
goto error_queue;
|
||||
|
||||
channel->channelId = InterlockedIncrement(&vcm->dvc_channel_id_seq);
|
||||
ArrayList_Add(vcm->dynamicVirtualChannels, channel);
|
||||
if (ArrayList_Add(vcm->dynamicVirtualChannels, channel) < 0)
|
||||
goto error_add;
|
||||
|
||||
s = Stream_New(NULL, 64);
|
||||
wts_write_drdynvc_create_request(s, channel->channelId, pVirtualName);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), &written);
|
||||
if (!s)
|
||||
goto error_s;
|
||||
if (!wts_write_drdynvc_create_request(s, channel->channelId, pVirtualName))
|
||||
goto error_create;
|
||||
if (!WTSVirtualChannelWrite(vcm->drdynvc_channel, (PCHAR) Stream_Buffer(s), Stream_GetPosition(s), &written))
|
||||
goto error_create;
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return channel;
|
||||
|
||||
error_create:
|
||||
Stream_Free(s, TRUE);
|
||||
error_s:
|
||||
ArrayList_Remove(vcm->dynamicVirtualChannels, channel);
|
||||
error_add:
|
||||
MessageQueue_Free(channel->queue);
|
||||
error_queue:
|
||||
Stream_Free(channel->receiveData, TRUE);
|
||||
error_receiveData:
|
||||
free(channel);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL WINAPI FreeRDP_WTSVirtualChannelClose(HANDLE hChannelHandle)
|
||||
|
@ -1933,42 +1933,73 @@ rdpUpdate* update_new(rdpRdp* rdp)
|
||||
{
|
||||
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
|
||||
rdpUpdate* update;
|
||||
OFFSCREEN_DELETE_LIST* deleteList;
|
||||
|
||||
update = (rdpUpdate*) calloc(1, sizeof(rdpUpdate));
|
||||
update = (rdpUpdate *) calloc(1, sizeof(rdpUpdate));
|
||||
if (!update)
|
||||
return NULL;
|
||||
|
||||
if (update)
|
||||
{
|
||||
OFFSCREEN_DELETE_LIST* deleteList;
|
||||
WLog_Init();
|
||||
update->log = WLog_Get("com.freerdp.core.update");
|
||||
|
||||
WLog_Init();
|
||||
update->log = WLog_Get("com.freerdp.core.update");
|
||||
update->bitmap_update.count = 64;
|
||||
update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(update->bitmap_update.count, sizeof(BITMAP_DATA));
|
||||
if (!update->bitmap_update.rectangles)
|
||||
goto error_rectangles;
|
||||
|
||||
update->bitmap_update.count = 64;
|
||||
update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(update->bitmap_update.count, sizeof(BITMAP_DATA));
|
||||
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
|
||||
if (!update->pointer)
|
||||
goto error_pointer;
|
||||
|
||||
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
|
||||
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
|
||||
if (!update->primary)
|
||||
goto error_primary;
|
||||
|
||||
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
|
||||
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
|
||||
if (!update->secondary)
|
||||
goto error_secondary;
|
||||
|
||||
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
|
||||
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
|
||||
if (!update->altsec)
|
||||
goto error_altsec;
|
||||
|
||||
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
|
||||
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
|
||||
if (!update->window)
|
||||
goto error_window;
|
||||
|
||||
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
|
||||
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
|
||||
deleteList->sIndices = 64;
|
||||
deleteList->indices = malloc(deleteList->sIndices * 2);
|
||||
if (!deleteList->indices)
|
||||
goto error_indices;
|
||||
deleteList->cIndices = 0;
|
||||
|
||||
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
|
||||
deleteList->sIndices = 64;
|
||||
deleteList->indices = malloc(deleteList->sIndices * 2);
|
||||
deleteList->cIndices = 0;
|
||||
update->SuppressOutput = update_send_suppress_output;
|
||||
|
||||
update->SuppressOutput = update_send_suppress_output;
|
||||
|
||||
update->initialState = TRUE;
|
||||
|
||||
update->queue = MessageQueue_New(&cb);
|
||||
}
|
||||
update->initialState = TRUE;
|
||||
|
||||
update->queue = MessageQueue_New(&cb);
|
||||
if (!update->queue)
|
||||
goto error_queue;
|
||||
return update;
|
||||
|
||||
error_queue:
|
||||
free(deleteList->indices);
|
||||
error_indices:
|
||||
free(update->window);
|
||||
error_window:
|
||||
free(update->altsec);
|
||||
error_altsec:
|
||||
free(update->secondary);
|
||||
error_secondary:
|
||||
free(update->primary);
|
||||
error_primary:
|
||||
free(update->pointer);
|
||||
error_pointer:
|
||||
free(update->bitmap_update.rectangles);
|
||||
error_rectangles:
|
||||
free(update);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void update_free(rdpUpdate* update)
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("core.window")
|
||||
|
||||
static BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
|
||||
{
|
||||
UINT16 new_len;
|
||||
BYTE *new_str;
|
||||
|
@ -95,9 +95,7 @@ BOOL shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
|
||||
if (!(client->encoder = shadow_encoder_new(client)))
|
||||
goto fail_encoder_new;
|
||||
|
||||
ArrayList_Add(server->clients, (void*) client);
|
||||
|
||||
return TRUE;
|
||||
return ArrayList_Add(server->clients, (void*) client) >= 0;
|
||||
|
||||
fail_encoder_new:
|
||||
CloseHandle(client->encoder);
|
||||
|
@ -53,7 +53,8 @@ int shadow_encoder_create_frame_id(rdpShadowEncoder* encoder)
|
||||
return -1;
|
||||
|
||||
frameId = frame->frameId = ++encoder->frameId;
|
||||
ListDictionary_Add(encoder->frameList, (void*) (size_t) frame->frameId, frame);
|
||||
if (!ListDictionary_Add(encoder->frameList, (void*) (size_t) frame->frameId, frame))
|
||||
return -1;
|
||||
|
||||
return (int) frame->frameId;
|
||||
}
|
||||
@ -135,6 +136,8 @@ int shadow_encoder_init_rfx(rdpShadowEncoder* encoder)
|
||||
encoder->maxFps = 32;
|
||||
encoder->frameId = 0;
|
||||
encoder->frameList = ListDictionary_New(TRUE);
|
||||
if (!encoder->frameList)
|
||||
return -1;
|
||||
encoder->frameAck = settings->SurfaceFrameMarkerEnabled;
|
||||
}
|
||||
|
||||
@ -162,6 +165,8 @@ int shadow_encoder_init_nsc(rdpShadowEncoder* encoder)
|
||||
encoder->maxFps = 32;
|
||||
encoder->frameId = 0;
|
||||
encoder->frameList = ListDictionary_New(TRUE);
|
||||
if (!encoder->frameList)
|
||||
return -1;
|
||||
encoder->frameAck = settings->SurfaceFrameMarkerEnabled;
|
||||
}
|
||||
|
||||
|
@ -205,9 +205,7 @@ BOOL CryptProtectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags)
|
||||
CopyMemory(pMemBlock->pData, pCipherText, pMemBlock->cbData);
|
||||
free(pCipherText);
|
||||
|
||||
ListDictionary_Add(g_ProtectedMemoryBlocks, pData, pMemBlock);
|
||||
|
||||
return TRUE;
|
||||
return ListDictionary_Add(g_ProtectedMemoryBlocks, pData, pMemBlock);
|
||||
}
|
||||
|
||||
BOOL CryptUnprotectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags)
|
||||
|
@ -413,12 +413,13 @@ static HANDLE_OPS namedOps = {
|
||||
};
|
||||
|
||||
|
||||
static void InitWinPRPipeModule()
|
||||
static BOOL InitWinPRPipeModule()
|
||||
{
|
||||
if (g_NamedPipeServerSockets)
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
g_NamedPipeServerSockets = ArrayList_New(FALSE);
|
||||
return g_NamedPipeServerSockets != NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -523,7 +524,9 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
|
||||
if (!lpName)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
InitWinPRPipeModule();
|
||||
if (!InitWinPRPipeModule())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
pNamedPipe = (WINPR_NAMED_PIPE*) calloc(1, sizeof(WINPR_NAMED_PIPE));
|
||||
if (!pNamedPipe)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
@ -625,7 +628,12 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
|
||||
|
||||
baseSocket->serverfd = serverfd;
|
||||
baseSocket->references = 0;
|
||||
ArrayList_Add(g_NamedPipeServerSockets, baseSocket);
|
||||
|
||||
if (ArrayList_Add(g_NamedPipeServerSockets, baseSocket) < 0)
|
||||
{
|
||||
free(baseSocket->name);
|
||||
goto out;
|
||||
}
|
||||
//WLog_DBG(TAG, "created shared socked resource for pipe %p (%s). base serverfd = %d", pNamedPipe, lpName, serverfd);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,8 @@ static BOOL InitializeThreadpool(PTP_POOL pool)
|
||||
goto fail_create_threads;
|
||||
}
|
||||
|
||||
ArrayList_Add(pool->Threads, thread);
|
||||
if (ArrayList_Add(pool->Threads, thread) < 0)
|
||||
goto fail_create_threads;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -259,7 +260,8 @@ BOOL SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ArrayList_Add(ptpp->Threads, thread);
|
||||
if (ArrayList_Add(ptpp->Threads, thread) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
|
@ -337,19 +337,33 @@ PCSC_SCARDCONTEXT* PCSC_EstablishCardContext(SCARDCONTEXT hContext)
|
||||
return NULL;
|
||||
|
||||
pContext->hContext = hContext;
|
||||
InitializeCriticalSectionAndSpinCount(&(pContext->lock), 4000);
|
||||
if (!InitializeCriticalSectionAndSpinCount(&(pContext->lock), 4000))
|
||||
goto error_spinlock;
|
||||
|
||||
if (!g_CardContexts)
|
||||
{
|
||||
g_CardContexts = ListDictionary_New(TRUE);
|
||||
if (!g_CardContexts)
|
||||
goto errors;
|
||||
}
|
||||
|
||||
if (!g_Readers)
|
||||
{
|
||||
g_Readers = ArrayList_New(TRUE);
|
||||
if (!g_Readers)
|
||||
goto errors;
|
||||
ArrayList_Object(g_Readers)->fnObjectFree = (OBJECT_FREE_FN) PCSC_ReaderAliasFree;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_CardContexts, (void*) hContext, (void*) pContext);
|
||||
if (!ListDictionary_Add(g_CardContexts, (void*) hContext, (void*) pContext))
|
||||
goto errors;
|
||||
return pContext;
|
||||
|
||||
errors:
|
||||
DeleteCriticalSection(&(pContext->lock));
|
||||
error_spinlock:
|
||||
free(pContext);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PCSC_ReleaseCardContext(SCARDCONTEXT hContext)
|
||||
@ -552,7 +566,6 @@ PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCARDCONTE
|
||||
}
|
||||
|
||||
pCard = (PCSC_SCARDHANDLE*) calloc(1, sizeof(PCSC_SCARDHANDLE));
|
||||
|
||||
if (!pCard)
|
||||
return NULL;
|
||||
|
||||
@ -561,11 +574,20 @@ PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCARDCONTE
|
||||
pContext->dwCardHandleCount++;
|
||||
|
||||
if (!g_CardHandles)
|
||||
{
|
||||
g_CardHandles = ListDictionary_New(TRUE);
|
||||
if (!g_CardHandles)
|
||||
goto error;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_CardHandles, (void*) hCard, (void*) pCard);
|
||||
if (!ListDictionary_Add(g_CardHandles, (void*) hCard, (void*) pCard))
|
||||
goto error;
|
||||
|
||||
return pCard;
|
||||
|
||||
error:
|
||||
free(pCard);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PCSC_DisconnectCardHandle(SCARDHANDLE hCard)
|
||||
@ -634,8 +656,7 @@ BOOL PCSC_AddReaderNameAlias(char* namePCSC, char* nameWinSCard)
|
||||
|
||||
reader->namePCSC = _strdup(namePCSC);
|
||||
reader->nameWinSCard = _strdup(nameWinSCard);
|
||||
ArrayList_Add(g_Readers, reader);
|
||||
return TRUE;
|
||||
return ArrayList_Add(g_Readers, reader) >= 0;
|
||||
}
|
||||
|
||||
static int PCSC_AtoiWithLength(const char* str, int length)
|
||||
@ -890,12 +911,16 @@ char* PCSC_ConvertReaderNamesToPCSC(const char* names, LPDWORD pcchReaders)
|
||||
return namesPCSC;
|
||||
}
|
||||
|
||||
void PCSC_AddMemoryBlock(SCARDCONTEXT hContext, void* pvMem)
|
||||
BOOL PCSC_AddMemoryBlock(SCARDCONTEXT hContext, void* pvMem)
|
||||
{
|
||||
if (!g_MemoryBlocks)
|
||||
{
|
||||
g_MemoryBlocks = ListDictionary_New(TRUE);
|
||||
if (!g_MemoryBlocks)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ListDictionary_Add(g_MemoryBlocks, pvMem, (void*) hContext);
|
||||
return ListDictionary_Add(g_MemoryBlocks, pvMem, (void*) hContext);
|
||||
}
|
||||
|
||||
void* PCSC_RemoveMemoryBlock(SCARDCONTEXT hContext, void* pvMem)
|
||||
@ -914,7 +939,11 @@ void* PCSC_SCardAllocMemory(SCARDCONTEXT hContext, size_t size)
|
||||
if (!pvMem)
|
||||
return NULL;
|
||||
|
||||
PCSC_AddMemoryBlock(hContext, pvMem);
|
||||
if (!PCSC_AddMemoryBlock(hContext, pvMem))
|
||||
{
|
||||
free(pvMem);
|
||||
return NULL;
|
||||
}
|
||||
return pvMem;
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ exit:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void winpr_StartThread(WINPR_THREAD *thread)
|
||||
static BOOL winpr_StartThread(WINPR_THREAD *thread)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
@ -326,10 +326,17 @@ static void winpr_StartThread(WINPR_THREAD *thread)
|
||||
thread->started = TRUE;
|
||||
reset_event(thread);
|
||||
|
||||
pthread_create(&thread->thread, &attr, thread_launcher, thread);
|
||||
ListDictionary_Add(thread_list, &thread->thread, thread);
|
||||
if (pthread_create(&thread->thread, &attr, thread_launcher, thread))
|
||||
goto error;
|
||||
if (!ListDictionary_Add(thread_list, &thread->thread, thread))
|
||||
goto error;
|
||||
pthread_attr_destroy(&attr);
|
||||
dump_thread(thread);
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
pthread_attr_destroy(&attr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize,
|
||||
@ -353,22 +360,22 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
|
||||
thread->create_stack = winpr_backtrace(20);
|
||||
dump_thread(thread);
|
||||
#endif
|
||||
thread->pipe_fd[0] = -1;
|
||||
thread->pipe_fd[1] = -1;
|
||||
|
||||
#ifdef HAVE_EVENTFD_H
|
||||
thread->pipe_fd[0] = eventfd(0, EFD_NONBLOCK);
|
||||
|
||||
if (thread->pipe_fd[0] < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to create thread");
|
||||
free(thread);
|
||||
return NULL;
|
||||
WLog_ERR(TAG, "failed to create thread pipe fd 0");
|
||||
goto error_pipefd0;
|
||||
}
|
||||
#else
|
||||
if (pipe(thread->pipe_fd) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to create thread");
|
||||
free(thread);
|
||||
return NULL;
|
||||
WLog_ERR(TAG, "failed to create thread pipe");
|
||||
goto error_pipefd0;
|
||||
}
|
||||
|
||||
{
|
||||
@ -380,12 +387,7 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
|
||||
if(pthread_mutex_init(&thread->mutex, 0) != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to initialize thread mutex");
|
||||
if (thread->pipe_fd[0])
|
||||
close(thread->pipe_fd[0]);
|
||||
if (thread->pipe_fd[1])
|
||||
close(thread->pipe_fd[1]);
|
||||
free(thread);
|
||||
return NULL;
|
||||
goto error_mutex;
|
||||
}
|
||||
|
||||
WINPR_HANDLE_SET_TYPE(thread, HANDLE_TYPE_THREAD);
|
||||
@ -397,22 +399,34 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize
|
||||
if (!thread_list)
|
||||
{
|
||||
WLog_ERR(TAG, "Couldn't create global thread list");
|
||||
if (thread->pipe_fd[0])
|
||||
close(thread->pipe_fd[0]);
|
||||
if (thread->pipe_fd[1])
|
||||
close(thread->pipe_fd[1]);
|
||||
free(thread);
|
||||
return NULL;
|
||||
goto error_thread_list;
|
||||
}
|
||||
thread_list->objectKey.fnObjectEquals = thread_compare;
|
||||
}
|
||||
|
||||
if (!(dwCreationFlags & CREATE_SUSPENDED))
|
||||
winpr_StartThread(thread);
|
||||
{
|
||||
if (!winpr_StartThread(thread))
|
||||
goto error_thread_list;
|
||||
}
|
||||
else
|
||||
set_event(thread);
|
||||
{
|
||||
if (!set_event(thread))
|
||||
goto error_thread_list;
|
||||
}
|
||||
|
||||
return handle;
|
||||
|
||||
error_thread_list:
|
||||
pthread_mutex_destroy(&thread->mutex);
|
||||
error_mutex:
|
||||
if (thread->pipe_fd[1] >= 0)
|
||||
close(thread->pipe_fd[1]);
|
||||
if (thread->pipe_fd[0] >= 0)
|
||||
close(thread->pipe_fd[0]);
|
||||
error_pipefd0:
|
||||
free(thread);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cleanup_handle(void *obj)
|
||||
|
@ -52,13 +52,24 @@ wMessagePipe* MessagePipe_New()
|
||||
|
||||
pipe = (wMessagePipe*) malloc(sizeof(wMessagePipe));
|
||||
|
||||
if (pipe)
|
||||
{
|
||||
pipe->In = MessageQueue_New(NULL);
|
||||
pipe->Out = MessageQueue_New(NULL);
|
||||
}
|
||||
if (!pipe)
|
||||
return NULL;
|
||||
|
||||
pipe->In = MessageQueue_New(NULL);
|
||||
if (!pipe->In)
|
||||
goto error_in;
|
||||
|
||||
pipe->Out = MessageQueue_New(NULL);
|
||||
if (!pipe->In)
|
||||
goto error_out;
|
||||
|
||||
return pipe;
|
||||
|
||||
error_out:
|
||||
MessageQueue_Free(pipe->In);
|
||||
error_in:
|
||||
free(pipe);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MessagePipe_Free(wMessagePipe* pipe)
|
||||
|
@ -12,10 +12,13 @@ int TestArrayList(int argc, char* argv[])
|
||||
const int elemsToInsert = 10;
|
||||
|
||||
arrayList = ArrayList_New(TRUE);
|
||||
if (!arrayList)
|
||||
return -1;
|
||||
|
||||
for (index = 0; index < elemsToInsert; index++)
|
||||
{
|
||||
ArrayList_Add(arrayList, (void*) (size_t) index);
|
||||
if (ArrayList_Add(arrayList, (void*) (size_t) index) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
count = ArrayList_Count(arrayList);
|
||||
|
@ -12,10 +12,14 @@ int TestBufferPool(int argc, char* argv[])
|
||||
DWORD DefaultSize = 1234;
|
||||
|
||||
pool = BufferPool_New(TRUE, -1, 16);
|
||||
if (!pool)
|
||||
return -1;
|
||||
|
||||
Buffers[0] = BufferPool_Take(pool, DefaultSize);
|
||||
Buffers[1] = BufferPool_Take(pool, DefaultSize);
|
||||
Buffers[2] = BufferPool_Take(pool, 2048);
|
||||
if (!Buffers[0] || !Buffers[1] || !Buffers[2])
|
||||
return -1;
|
||||
|
||||
BufferSize = BufferPool_GetBufferSize(pool, Buffers[0]);
|
||||
|
||||
|
@ -18,6 +18,8 @@ int test_hash_table_pointer()
|
||||
wHashTable* table;
|
||||
|
||||
table = HashTable_New(TRUE);
|
||||
if (!table)
|
||||
return -1;
|
||||
|
||||
HashTable_Add(table, key1, val1);
|
||||
HashTable_Add(table, key2, val2);
|
||||
@ -147,6 +149,8 @@ int test_hash_table_string()
|
||||
wHashTable* table;
|
||||
|
||||
table = HashTable_New(TRUE);
|
||||
if (!table)
|
||||
return -1;
|
||||
|
||||
table->hash = HashTable_StringHash;
|
||||
table->keyCompare = HashTable_StringCompare;
|
||||
|
@ -18,10 +18,13 @@ int TestListDictionary(int argc, char* argv[])
|
||||
wListDictionary* list;
|
||||
|
||||
list = ListDictionary_New(TRUE);
|
||||
if (!list)
|
||||
return -1;
|
||||
|
||||
ListDictionary_Add(list, key1, val1);
|
||||
ListDictionary_Add(list, key2, val2);
|
||||
ListDictionary_Add(list, key3, val3);
|
||||
if (!ListDictionary_Add(list, key1, val1) ||
|
||||
!ListDictionary_Add(list, key2, val2) ||
|
||||
!ListDictionary_Add(list, key3, val3) )
|
||||
return -1;
|
||||
|
||||
count = ListDictionary_Count(list);
|
||||
|
||||
@ -61,9 +64,10 @@ int TestListDictionary(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
ListDictionary_Add(list, key1, val1);
|
||||
ListDictionary_Add(list, key2, val2);
|
||||
ListDictionary_Add(list, key3, val3);
|
||||
if (!ListDictionary_Add(list, key1, val1) ||
|
||||
!ListDictionary_Add(list, key2, val2) ||
|
||||
!ListDictionary_Add(list, key3, val3))
|
||||
return -1;
|
||||
|
||||
count = ListDictionary_Count(list);
|
||||
|
||||
@ -151,9 +155,9 @@ int TestListDictionary(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
ListDictionary_Add(list, key1, val1);
|
||||
ListDictionary_Add(list, key2, val2);
|
||||
ListDictionary_Add(list, key3, val3);
|
||||
if (!ListDictionary_Add(list, key1, val1) || !ListDictionary_Add(list, key2, val2) ||
|
||||
!ListDictionary_Add(list, key3, val3))
|
||||
return -1;
|
||||
|
||||
ListDictionary_Clear(list);
|
||||
|
||||
|
@ -38,6 +38,8 @@ int TestPubSub(int argc, char* argv[])
|
||||
wPubSub* node;
|
||||
|
||||
node = PubSub_New(TRUE);
|
||||
if (!node)
|
||||
return -1;
|
||||
|
||||
PubSub_AddEventTypes(node, Node_Events, NODE_EVENT_COUNT);
|
||||
|
||||
|
@ -11,6 +11,8 @@ int TestQueue(int argc, char* argv[])
|
||||
wQueue* queue;
|
||||
|
||||
queue = Queue_New(TRUE, -1, -1);
|
||||
if (!queue)
|
||||
return -1;
|
||||
|
||||
for (index = 1; index <= 10; index++)
|
||||
{
|
||||
|
@ -36,12 +36,13 @@
|
||||
|
||||
static wArrayList* g_WindowClasses = NULL;
|
||||
|
||||
void InitializeWindowClasses()
|
||||
BOOL InitializeWindowClasses()
|
||||
{
|
||||
if (g_WindowClasses)
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
g_WindowClasses = ArrayList_New(TRUE);
|
||||
return g_WindowClasses != NULL;
|
||||
}
|
||||
|
||||
WNDCLASSEXA* CloneWindowClass(CONST WNDCLASSEXA* lpwcx)
|
||||
@ -179,13 +180,12 @@ ATOM WINAPI RegisterClassExA(CONST WNDCLASSEXA* lpwcx)
|
||||
{
|
||||
WNDCLASSEXA* _lpwcx;
|
||||
|
||||
InitializeWindowClasses();
|
||||
if (!InitializeWindowClasses())
|
||||
return 0;
|
||||
|
||||
_lpwcx = CloneWindowClass(lpwcx);
|
||||
|
||||
ArrayList_Add(g_WindowClasses, (void*) _lpwcx);
|
||||
|
||||
return 1;
|
||||
return ArrayList_Add(g_WindowClasses, (void*) _lpwcx) >= 0;
|
||||
}
|
||||
|
||||
ATOM WINAPI RegisterClassExW(CONST WNDCLASSEXW* lpwcx)
|
||||
|
Loading…
Reference in New Issue
Block a user