From fa4d8fca1be797b03504fd1f53a4c861066e591b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 25 Apr 2012 14:26:35 -0400 Subject: [PATCH 01/64] urbrdc: initial USB redirection support, contributed by Atrust --- channels/drdynvc/CMakeLists.txt | 1 + channels/drdynvc/drdynvc_main.c | 10 +- channels/drdynvc/drdynvc_types.h | 1 + channels/drdynvc/dvcman.c | 55 +- channels/drdynvc/urbdrc/CMakeLists.txt | 45 + channels/drdynvc/urbdrc/data_transfer.c | 2475 +++++++++++++++++ channels/drdynvc/urbdrc/data_transfer.h | 41 + channels/drdynvc/urbdrc/isoch_queue.c | 195 ++ channels/drdynvc/urbdrc/isoch_queue.h | 69 + channels/drdynvc/urbdrc/libusb/CMakeLists.txt | 38 + .../drdynvc/urbdrc/libusb/libusb_udevice.c | 1903 +++++++++++++ .../drdynvc/urbdrc/libusb/libusb_udevice.h | 86 + .../drdynvc/urbdrc/libusb/libusb_udevman.c | 567 ++++ .../drdynvc/urbdrc/libusb/request_queue.c | 188 ++ .../drdynvc/urbdrc/libusb/request_queue.h | 65 + channels/drdynvc/urbdrc/searchman.c | 237 ++ channels/drdynvc/urbdrc/searchman.h | 77 + channels/drdynvc/urbdrc/urbdrc_main.c | 1073 +++++++ channels/drdynvc/urbdrc/urbdrc_main.h | 269 ++ channels/drdynvc/urbdrc/urbdrc_types.h | 355 +++ include/freerdp/dvc.h | 4 + include/freerdp/utils/msusb.h | 148 + libfreerdp-utils/CMakeLists.txt | 3 +- libfreerdp-utils/msusb.c | 368 +++ 24 files changed, 8252 insertions(+), 21 deletions(-) create mode 100644 channels/drdynvc/urbdrc/CMakeLists.txt create mode 100644 channels/drdynvc/urbdrc/data_transfer.c create mode 100644 channels/drdynvc/urbdrc/data_transfer.h create mode 100644 channels/drdynvc/urbdrc/isoch_queue.c create mode 100644 channels/drdynvc/urbdrc/isoch_queue.h create mode 100644 channels/drdynvc/urbdrc/libusb/CMakeLists.txt create mode 100644 channels/drdynvc/urbdrc/libusb/libusb_udevice.c create mode 100644 channels/drdynvc/urbdrc/libusb/libusb_udevice.h create mode 100644 channels/drdynvc/urbdrc/libusb/libusb_udevman.c create mode 100644 channels/drdynvc/urbdrc/libusb/request_queue.c create mode 100644 channels/drdynvc/urbdrc/libusb/request_queue.h create mode 100644 channels/drdynvc/urbdrc/searchman.c create mode 100644 channels/drdynvc/urbdrc/searchman.h create mode 100644 channels/drdynvc/urbdrc/urbdrc_main.c create mode 100644 channels/drdynvc/urbdrc/urbdrc_main.h create mode 100644 channels/drdynvc/urbdrc/urbdrc_types.h create mode 100644 include/freerdp/utils/msusb.h create mode 100644 libfreerdp-utils/msusb.c diff --git a/channels/drdynvc/CMakeLists.txt b/channels/drdynvc/CMakeLists.txt index 1e3cc13f3..e41f6b3bf 100644 --- a/channels/drdynvc/CMakeLists.txt +++ b/channels/drdynvc/CMakeLists.txt @@ -34,4 +34,5 @@ install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) add_subdirectory(tsmf) add_subdirectory(audin) +add_subdirectory(urbdrc) diff --git a/channels/drdynvc/drdynvc_main.c b/channels/drdynvc/drdynvc_main.c index 27ad531b7..42d422d25 100644 --- a/channels/drdynvc/drdynvc_main.c +++ b/channels/drdynvc/drdynvc_main.c @@ -86,7 +86,15 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, uint32 ChannelId, uint8* data, ui stream_set_pos(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); - if (data_size <= CHANNEL_CHUNK_LENGTH - pos) + if(data_size == 0) + { + pos = stream_get_pos(data_out); + stream_set_pos(data_out, 0); + stream_write_uint8(data_out, 0x40 | cbChId); + stream_set_pos(data_out, pos); + error = svc_plugin_send((rdpSvcPlugin*)drdynvc, data_out); + } + else if (data_size <= CHANNEL_CHUNK_LENGTH - pos) { pos = stream_get_pos(data_out); stream_set_pos(data_out, 0); diff --git a/channels/drdynvc/drdynvc_types.h b/channels/drdynvc/drdynvc_types.h index a08a60523..8af592071 100644 --- a/channels/drdynvc/drdynvc_types.h +++ b/channels/drdynvc/drdynvc_types.h @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef WITH_DEBUG_DVC #define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) diff --git a/channels/drdynvc/dvcman.c b/channels/drdynvc/dvcman.c index d24b11489..3aee4ce83 100644 --- a/channels/drdynvc/dvcman.c +++ b/channels/drdynvc/dvcman.c @@ -78,6 +78,8 @@ struct _DVCMAN_CHANNEL IWTSVirtualChannelCallback* channel_callback; STREAM* dvc_data; + + pthread_mutex_t dvc_chan_mutex; }; static int dvcman_get_configuration(IWTSListener* pListener, void** ppPropertyBag) @@ -174,6 +176,28 @@ RDP_PLUGIN_DATA* dvcman_get_plugin_data(IDRDYNVC_ENTRY_POINTS* pEntryPoints) return ((DVCMAN_ENTRY_POINTS*) pEntryPoints)->plugin_data; } +uint32 dvcman_get_channel_id(IWTSVirtualChannel * channel) +{ + return ((DVCMAN_CHANNEL*)channel)->channel_id; +} + +IWTSVirtualChannel* dvcman_find_channel_by_id(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId) +{ + LIST_ITEM* curr; + DVCMAN* dvcman = (DVCMAN*) pChannelMgr; + + for (curr = dvcman->channels->head; curr; curr = curr->next) + { + if (((DVCMAN_CHANNEL*) curr->data)->channel_id == ChannelId) + { + return (IWTSVirtualChannel*)curr->data; + } + } + + return NULL; +} + + IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) { DVCMAN* dvcman; @@ -181,6 +205,8 @@ IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) dvcman = xnew(DVCMAN); dvcman->iface.CreateListener = dvcman_create_listener; dvcman->iface.PushEvent = dvcman_push_event; + dvcman->iface.FindChannelById = dvcman_find_channel_by_id; + dvcman->iface.GetChannelId = dvcman_get_channel_id; dvcman->drdynvc = plugin; dvcman->channels = list_new(); @@ -271,8 +297,13 @@ int dvcman_init(IWTSVirtualChannelManager* pChannelMgr) static int dvcman_write_channel(IWTSVirtualChannel* pChannel, uint32 cbSize, uint8* pBuffer, void* pReserved) { DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*) pChannel; + int error; - return drdynvc_write_data(channel->dvcman->drdynvc, channel->channel_id, pBuffer, cbSize); + pthread_mutex_lock(&channel->dvc_chan_mutex); + error = drdynvc_write_data(channel->dvcman->drdynvc, channel->channel_id, pBuffer, cbSize); + pthread_mutex_unlock(&channel->dvc_chan_mutex); + + return error; } static int dvcman_close_channel_iface(IWTSVirtualChannel* pChannel) @@ -310,6 +341,7 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 Channel channel->iface.Close = dvcman_close_channel_iface; channel->dvcman = dvcman; channel->channel_id = ChannelId; + pthread_mutex_init(&channel->dvc_chan_mutex, NULL); bAccept = 1; pCallback = NULL; @@ -336,28 +368,13 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 Channel return 1; } -static DVCMAN_CHANNEL* dvcman_find_channel_by_id(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId) -{ - LIST_ITEM* curr; - DVCMAN* dvcman = (DVCMAN*) pChannelMgr; - - for (curr = dvcman->channels->head; curr; curr = curr->next) - { - if (((DVCMAN_CHANNEL*) curr->data)->channel_id == ChannelId) - { - return (DVCMAN_CHANNEL*)curr->data; - } - } - - return NULL; -} int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId) { DVCMAN_CHANNEL* channel; IWTSVirtualChannel* ichannel; - channel = dvcman_find_channel_by_id(pChannelMgr, ChannelId); + channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId); if (channel == NULL) { @@ -382,7 +399,7 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, ui { DVCMAN_CHANNEL* channel; - channel = dvcman_find_channel_by_id(pChannelMgr, ChannelId); + channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId); if (channel == NULL) { @@ -403,7 +420,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, uint32 C int error = 0; DVCMAN_CHANNEL* channel; - channel = dvcman_find_channel_by_id(pChannelMgr, ChannelId); + channel = (DVCMAN_CHANNEL*)dvcman_find_channel_by_id(pChannelMgr, ChannelId); if (channel == NULL) { diff --git a/channels/drdynvc/urbdrc/CMakeLists.txt b/channels/drdynvc/urbdrc/CMakeLists.txt new file mode 100644 index 000000000..627bf8704 --- /dev/null +++ b/channels/drdynvc/urbdrc/CMakeLists.txt @@ -0,0 +1,45 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Atrust corp. +# Copyright 2012 Alfred Liu +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(URBDRC_SRCS + searchman.c + searchman.h + isoch_queue.c + isoch_queue.h + data_transfer.c + data_transfer.h + urbdrc_main.c + urbdrc_main.h + urbdrc_types.h +) + +include_directories(..) + +add_library(urbdrc ${URBDRC_SRCS}) +set_target_properties(urbdrc PROPERTIES PREFIX "") + +target_link_libraries(urbdrc udev) +target_link_libraries(urbdrc dbus-glib-1) +target_link_libraries(urbdrc pthread) +target_link_libraries(urbdrc uuid) +target_link_libraries(urbdrc freerdp-utils) + +install(TARGETS urbdrc DESTINATION ${FREERDP_PLUGIN_PATH}) + +add_subdirectory(libusb) + diff --git a/channels/drdynvc/urbdrc/data_transfer.c b/channels/drdynvc/urbdrc/data_transfer.c new file mode 100644 index 000000000..c00c504d0 --- /dev/null +++ b/channels/drdynvc/urbdrc/data_transfer.c @@ -0,0 +1,2475 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "urbdrc_types.h" +#include "data_transfer.h" + + +static void +usb_process_get_port_status(IUDEVICE * pdev, uint8 * OutputBuffer) +{ + int bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB); + switch (bcdUSB){ + case USB_v1_0: + data_write_uint32(OutputBuffer, 0x303); + break; + case USB_v1_1: + data_write_uint32(OutputBuffer, 0x103); + break; + case USB_v2_0: + data_write_uint32(OutputBuffer, 0x503); + break; + default: + data_write_uint32(OutputBuffer, 0x503); + break; + } +} + + +#if ISOCH_FIFO +static int +func_check_isochronous_fds(IUDEVICE * pdev) +{ + ISOCH_CALLBACK_QUEUE * isoch_queue = NULL; + ISOCH_CALLBACK_DATA * isoch = NULL; + URBDRC_CHANNEL_CALLBACK * callback; + uint32 size_temp, process_times = 2; + uint8 * data_temp; + int ret = 0; + + isoch_queue = (ISOCH_CALLBACK_QUEUE *)pdev->get_isoch_queue(pdev); + + while (process_times) + { + process_times--; + if (isoch_queue == NULL || !pdev) + return -1; + pthread_mutex_lock(&isoch_queue->isoch_loading); + if (isoch_queue->head == NULL) + { + pthread_mutex_unlock(&isoch_queue->isoch_loading); + continue; + } + else + { + isoch = isoch_queue->head; + } + if (!isoch || !isoch->out_data) + { + pthread_mutex_unlock(&isoch_queue->isoch_loading); + continue; + } + else + { + callback = (URBDRC_CHANNEL_CALLBACK *)isoch->callback; + size_temp = isoch->out_size; + data_temp = isoch->out_data; + + ret = isoch_queue->unregister_data(isoch_queue, isoch); + if (!ret) + LLOGLN(0, ("isoch_queue_unregister_data: Not found isoch data!!\n")); + pthread_mutex_unlock(&isoch_queue->isoch_loading); + + if (pdev && !pdev->isSigToEnd(pdev)) + { + callback->channel->Write(callback->channel, size_temp, + data_temp, NULL); + zfree(data_temp); + } + + } + + } + return 0; +} +#endif + +static int +urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + IUDEVICE * pdev; + uint32 NumRequestCompletion = 0; + uint32 RequestCompletion = 0; + + LLOGLN(urbdrc_debug, ("urbdrc_process_register_request_callback")); + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + if (data_sizem >= 8) + { + data_read_uint32(data + 0, NumRequestCompletion); /** must be 1 */ + /** RequestCompletion: + * unique Request Completion interface for the client to use */ + data_read_uint32(data + 4, RequestCompletion); + pdev->set_ReqCompletion(pdev, RequestCompletion); + } + else /** Unregister the device */ + { + data_read_uint32(data + 0, RequestCompletion); + if (1)//(pdev->get_ReqCompletion(pdev) == RequestCompletion) + { + /** The wrong driver may also receive this message, So we + * need some time(default 3s) to check the driver or delete + * it */ + sleep(3); + callback->channel->Write(callback->channel, 0, NULL, NULL); + pdev->SigToEnd(pdev); + } + } + + return 0; +} + +static int +urbdrc_process_cancel_request(uint8 * data, uint32 data_sizem, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + IUDEVICE* pdev; + uint32 CancelId; + int error = 0; + + data_read_uint32(data + 0, CancelId); /** RequestId */ + + LLOGLN(urbdrc_debug, ("urbdrc_process_cancel_request: id 0x%x", CancelId)); + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + error = pdev->cancel_transfer_request(pdev, CancelId); + + return error; +} + +static int +urbdrc_process_retract_device_request(uint8 * data, uint32 data_sizem, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + uint32 Reason; + LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request")); + + data_read_uint32(data + 0, Reason); /** Reason */ + + switch (Reason) + { + case UsbRetractReason_BlockedByPolicy: + LLOGLN(urbdrc_debug, ("UsbRetractReason_BlockedByPolicy: now it is not support")); + return -1; + break; + default: + LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request: Unknown Reason %d", Reason)); + return -1; + break; + } + + return 0; +} + +static int +urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + IUDEVICE * pdev; + uint32 out_size; + uint32 InterfaceId; + uint32 IoControlCode; + uint32 InputBufferSize; + uint32 OutputBufferSize; + uint32 RequestId; + uint32 usbd_status = USBD_STATUS_SUCCESS; + uint8 * OutputBuffer; + uint8 * out_data; + int i, offset, success = 0; + + LLOGLN(urbdrc_debug, ("urbdrc_process__io_control")); + + data_read_uint32(data + 0, IoControlCode); + data_read_uint32(data + 4, InputBufferSize); + data_read_uint32(data + 8 + InputBufferSize, OutputBufferSize); + data_read_uint32(data + 12 + InputBufferSize, RequestId); + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + + /** process */ + OutputBuffer = (uint8 *)malloc(OutputBufferSize); + memset(OutputBuffer, 0, OutputBufferSize); + + switch (IoControlCode){ + case IOCTL_INTERNAL_USB_SUBMIT_URB: /** 0x00220003 */ + LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_URB")); + printf(" Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked\n"); + break; + case IOCTL_INTERNAL_USB_RESET_PORT: /** 0x00220007 */ + LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_RESET_PORT")); + break; + case IOCTL_INTERNAL_USB_GET_PORT_STATUS: /** 0x00220013 */ + LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_GET_PORT_STATUS")); + + success = pdev->query_device_port_status(pdev, &usbd_status, + &OutputBufferSize, + OutputBuffer); + + if (success) + { + if (pdev->isExist(pdev) == 0) + { + data_write_uint32(OutputBuffer, 0); + } + else + { + usb_process_get_port_status(pdev, OutputBuffer); + OutputBufferSize = 4; + } + LLOGLN(urbdrc_debug, ("PORT STATUS(fake!):0x%02x%02x%02x%02x", + OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0])); + } + + break; + case IOCTL_INTERNAL_USB_CYCLE_PORT: /** 0x0022001F */ + LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_CYCLE_PORT")); + printf(" Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked\n"); + break; + case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: /** 0x00220027 */ + LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION")); + printf(" Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked\n"); + break; + default: + LLOGLN(urbdrc_debug, ("urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode)); + return -1; + break; + } + + + offset = 28; + out_size = offset + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, USBD_STATUS_SUCCESS); /** HResult */ + data_write_uint32(out_data + 20, OutputBufferSize); /** Information */ + data_write_uint32(out_data + 24, OutputBufferSize); /** OutputBufferSize */ + + for (i=0;iisSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + zfree(OutputBuffer); + + return 0; +} + +static int +urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + IUDEVICE* pdev; + uint32 out_size, IoControlCode, InterfaceId, InputBufferSize; + uint32 OutputBufferSize, RequestId, frames; + uint8 * out_data; + + data_read_uint32(data + 0, IoControlCode); + + LLOGLN(urbdrc_debug, ("urbdrc_process_internal_io_control:0x%x", IoControlCode)); + + data_read_uint32(data + 4, InputBufferSize); + data_read_uint32(data + 8, OutputBufferSize); + data_read_uint32(data + 12, RequestId); + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + /** Fixme: Currently this is a false bustime... */ + urbdrc_get_mstime(frames); + + out_size = 32; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0); /** HResult */ + data_write_uint32(out_data + 20, 4); /** Information */ + data_write_uint32(out_data + 24, 4); /** OutputBufferSize */ + data_write_uint32(out_data + 28, frames); /** OutputBuffer */ + + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + + return 0; +} + +static int +urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice) +{ + IUDEVICE * pdev; + uint32 out_size; + uint32 InterfaceId; + uint32 TextType; + uint32 LocaleId; + uint32 bufferSize = 1024; + uint8 * out_data; + uint8 DeviceDescription[bufferSize]; + int out_offset; + + LLOGLN(urbdrc_debug, ("urbdrc_process_query_device_text")); + + data_read_uint32(data + 0, TextType); + data_read_uint32(data + 4, LocaleId); + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + pdev->control_query_device_text( + pdev, + TextType, + LocaleId, + &bufferSize, + DeviceDescription); + + + InterfaceId = ((STREAM_ID_STUB<<30) | UsbDevice); + + out_offset = 16; + out_size = out_offset + bufferSize; + if(bufferSize != 0) + out_size += 2; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + if (bufferSize != 0) { + data_write_uint32(out_data + 8, (bufferSize/2)+1); /** cchDeviceDescription */ + out_offset = 12; + memcpy(out_data + out_offset, DeviceDescription, bufferSize); + out_offset += bufferSize; + data_write_uint16(out_data + out_offset, 0x0000); + out_offset += 2; + } + else + { + data_write_uint32(out_data + 8, 0); /** cchDeviceDescription */ + out_offset = 12; + } + + data_write_uint32(out_data + out_offset, 0); /** HResult */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + + return 0; +} + + + +static void +func_select_all_interface_for_msconfig(IUDEVICE * pdev, MSUSB_CONFIG_DESCRIPTOR * MsConfig) +{ + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces = MsConfig->MsInterfaces; + uint8 InterfaceNumber, AlternateSetting; + uint32 NumInterfaces = MsConfig->NumInterfaces; + int inum; + + for (inum = 0; inum < NumInterfaces; inum++) + { + InterfaceNumber = MsInterfaces[inum]->InterfaceNumber; + AlternateSetting = MsInterfaces[inum]->AlternateSetting; + pdev->select_interface(pdev, InterfaceNumber, AlternateSetting); + } +} + + + +static int +urb_select_configuration(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + MSUSB_CONFIG_DESCRIPTOR * MsConfig = NULL; + IUDEVICE * pdev = NULL; + uint32 out_size, InterfaceId, RequestId, NumInterfaces, usbd_status = 0; + uint8 ConfigurationDescriptorIsValid; + uint8 * out_data; + int MsOutSize = 0, offset = 0; + + if (transferDir == 0){ + printf("urb_select_configuration: not support transfer out\n"); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + data_read_uint32(data + 0, RequestId); + data_read_uint8(data + 4, ConfigurationDescriptorIsValid); + data_read_uint32(data + 8, NumInterfaces); + offset = 12; + + /** if ConfigurationDescriptorIsValid is zero, then just do nothing.*/ + if (ConfigurationDescriptorIsValid) + { + /* parser data for struct config */ + MsConfig = msusb_msconfig_read(data + offset, data_sizem - offset, NumInterfaces); + /* select config */ + pdev->select_configuration(pdev, MsConfig->bConfigurationValue); + /* select all interface */ + func_select_all_interface_for_msconfig(pdev, MsConfig); + /* complete configuration setup */ + MsConfig = pdev->complete_msconfig_setup(pdev, MsConfig); + } + + if (MsConfig) + MsOutSize = MsConfig->MsOutSize; + + if (MsOutSize > 0) + out_size = 36 + MsOutSize; + else + out_size = 44; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + if (MsOutSize > 0) + { + /** CbTsUrbResult */ + data_write_uint32(out_data + 16, 8 + MsOutSize); + /** TS_URB_RESULT_HEADER Size*/ + data_write_uint16(out_data + 20, 8 + MsOutSize); + } + else + { + data_write_uint32(out_data + 16, 16); + data_write_uint16(out_data + 20, 16); + } + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_SELECT_CONFIGURATION); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + offset = 28; + /** TS_URB_SELECT_CONFIGURATION_RESULT */ + if (MsOutSize > 0) + { + msusb_msconfig_write(MsConfig, out_data, &offset); + } + else + { + data_write_uint32(out_data + offset, 0); /** ConfigurationHandle */ + data_write_uint32(out_data + offset + 4, NumInterfaces); /** NumInterfaces */ + offset += 8; + } + data_write_uint32(out_data + offset, 0); /** HResult */ + data_write_uint32(out_data + offset + 4, 0); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + + +static int +urb_select_interface(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + MSUSB_CONFIG_DESCRIPTOR * MsConfig; + MSUSB_INTERFACE_DESCRIPTOR * MsInterface; + IUDEVICE * pdev; + uint32 out_size, InterfaceId, RequestId, ConfigurationHandle; + uint32 OutputBufferSize; + uint8 InterfaceNumber; + uint8 * out_data; + int out_offset, interface_size; + + if (transferDir == 0){ + printf("urb_select_interface: not support transfer out\n"); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, ConfigurationHandle); + out_offset = 8; + + MsInterface = msusb_msinterface_read(data + out_offset, data_sizem - out_offset, &out_offset); + + data_read_uint32(data + out_offset, OutputBufferSize); + + pdev->select_interface(pdev, MsInterface->InterfaceNumber, MsInterface->AlternateSetting); + + /* replace device's MsInterface */ + MsConfig = pdev->get_MsConfig(pdev); + InterfaceNumber = MsInterface->InterfaceNumber; + msusb_msinterface_replace(MsConfig, InterfaceNumber, MsInterface); + + /* complete configuration setup */ + MsConfig = pdev->complete_msconfig_setup(pdev, MsConfig); + MsInterface = MsConfig->MsInterfaces[InterfaceNumber]; + interface_size = 16 + (MsInterface->NumberOfPipes * 20); + + out_size = 36 + interface_size ; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 8 + interface_size); /** CbTsUrbResult */ + /** TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 8 + interface_size); /** Size */ + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_SELECT_INTERFACE); + data_write_uint32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */ + out_offset = 28; + + /** TS_URB_SELECT_INTERFACE_RESULT */ + msusb_msinterface_write(MsInterface, out_data + out_offset, &out_offset); + + data_write_uint32(out_data + out_offset, 0); /** HResult */ + data_write_uint32(out_data + out_offset + 4, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + return 0; +} + + + +static int +urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir, + int External) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle; + uint32 TransferFlags, OutputBufferSize, usbd_status, Timeout; + uint8 bmRequestType, Request; + uint16 Value, Index, length; + uint8 * buffer; + uint8 * out_data; + int offset, ret; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, PipeHandle); + data_read_uint32(data + 8, TransferFlags); /** TransferFlags */ + + EndpointAddress = (PipeHandle & 0x000000ff); + offset = 12; + Timeout = 2000; + switch (External) + { + case URB_CONTROL_TRANSFER_EXTERNAL: + data_read_uint32(data + offset, Timeout); /** TransferFlags */ + offset += 4; + break; + case URB_CONTROL_TRANSFER_NONEXTERNAL: + break; + } + /** SetupPacket 8 bytes */ + data_read_uint8(data + offset, bmRequestType); + data_read_uint8(data + offset + 1, Request); + data_read_uint16(data + offset + 2, Value); + data_read_uint16(data + offset + 4, Index); + data_read_uint16(data + offset + 6, length); + data_read_uint32(data + offset + 8, OutputBufferSize); + offset += 12; + + if (length != OutputBufferSize){ + LLOGLN(urbdrc_debug, ("urb_control_transfer ERROR: buf != length")); + return -1; + } + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + /** Get Buffer Data */ + if (transferDir == USBD_TRANSFER_DIRECTION_OUT) + memcpy(buffer, data + offset, OutputBufferSize); + + /** process URB_FUNCTION_CONTROL_TRANSFER */ + ret = pdev->control_transfer( + pdev, RequestId, EndpointAddress, TransferFlags, + bmRequestType, + Request, + Value, + Index, + &usbd_status, + &OutputBufferSize, + buffer, + Timeout); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("control_transfer: error num %d!!\n", ret)); + OutputBufferSize = 0; + } + + /** send data */ + offset = 36; + if (transferDir == USBD_TRANSFER_DIRECTION_IN) + out_size = offset + OutputBufferSize; + else + out_size = offset; + + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_CONTROL_TRANSFER); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + return 0; +} + + +static int +urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle; + uint32 TransferFlags, OutputBufferSize, usbd_status = 0; + uint8 * Buffer; + uint8 * out_data; + int offset; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, PipeHandle); + data_read_uint32(data + 8, TransferFlags); /** TransferFlags */ + data_read_uint32(data + 12, OutputBufferSize); + offset = 16; + EndpointAddress = (PipeHandle & 0x000000ff); + + if (transferDir == USBD_TRANSFER_DIRECTION_OUT) + out_size = 36; + else + out_size = 36 + OutputBufferSize; + + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + switch (transferDir) + { + case USBD_TRANSFER_DIRECTION_OUT: + Buffer = data + offset; + break; + case USBD_TRANSFER_DIRECTION_IN: + Buffer = out_data + 36; + break; + } + /** process URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER */ + pdev->bulk_or_interrupt_transfer( + pdev, RequestId, EndpointAddress, + TransferFlags, + &usbd_status, + &OutputBufferSize, + Buffer, + 10000); + + offset = 36; + if (transferDir == USBD_TRANSFER_DIRECTION_IN) + out_size = offset + OutputBufferSize; + else + out_size = offset; + /** send data */ + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (pdev && !pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + + return 0; +} + + +static int +urb_isoch_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 RequestId, InterfaceId, EndpointAddress; + uint32 PipeHandle, TransferFlags, StartFrame, NumberOfPackets; + uint32 ErrorCount, OutputBufferSize, usbd_status = 0; + uint32 RequestField, noAck = 0; + uint32 out_size = 0; + uint8 * iso_buffer = NULL; + uint8 * iso_packets = NULL; + uint8 * out_data = NULL; + int offset, nullBuffer = 0, iso_status; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + if (pdev->isSigToEnd(pdev)) + return 0; + + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + data_read_uint32(data + 0, RequestField); + RequestId = RequestField & 0x7fffffff; + noAck = (RequestField & 0x80000000)>>31; + data_read_uint32(data + 4, PipeHandle); + EndpointAddress = (PipeHandle & 0x000000ff); + data_read_uint32(data + 8, TransferFlags); /** TransferFlags */ + data_read_uint32(data + 12, StartFrame); /** StartFrame */ + data_read_uint32(data + 16, NumberOfPackets); /** NumberOfPackets */ + data_read_uint32(data + 20, ErrorCount); /** ErrorCount */ + offset = 24 + (NumberOfPackets * 12); + data_read_uint32(data + offset, OutputBufferSize); + offset += 4; + + /** send data memory alloc */ + if (transferDir == USBD_TRANSFER_DIRECTION_OUT) { + if (!noAck) { + out_size = 48 + (NumberOfPackets * 12); + out_data = (uint8 *) malloc(out_size); + iso_packets = out_data + 40; + } + } + else { + out_size = 48 + OutputBufferSize + (NumberOfPackets * 12); + out_data = (uint8 *) malloc(out_size); + iso_packets = out_data + 40; + } + + if (out_size) + memset(out_data, 0, out_size); + + switch (transferDir) + { + case USBD_TRANSFER_DIRECTION_OUT: + /** Get Buffer Data */ + //memcpy(iso_buffer, data + offset, OutputBufferSize); + iso_buffer = data + offset; + break; + case USBD_TRANSFER_DIRECTION_IN: + iso_buffer = out_data + 48 + (NumberOfPackets * 12); + break; + } + + LLOGLN(urbdrc_debug, ("urb_isoch_transfer: EndpointAddress: 0x%x, " + "TransferFlags: 0x%x, " "StartFrame: 0x%x, " + "NumberOfPackets: 0x%x, " "OutputBufferSize: 0x%x " + "RequestId: 0x%x", + EndpointAddress, TransferFlags, StartFrame, + NumberOfPackets, OutputBufferSize, RequestId)); + +#if ISOCH_FIFO + ISOCH_CALLBACK_QUEUE * isoch_queue = NULL; + ISOCH_CALLBACK_DATA * isoch = NULL; + if(!noAck) + { + isoch_queue = (ISOCH_CALLBACK_QUEUE *)pdev->get_isoch_queue(pdev); + isoch = isoch_queue->register_data(isoch_queue, callback, pdev); + } +#endif + + iso_status = pdev->isoch_transfer( + pdev, RequestId, EndpointAddress, + TransferFlags, + noAck, + &ErrorCount, + &usbd_status, + &StartFrame, + NumberOfPackets, + iso_packets, + &OutputBufferSize, + iso_buffer, + 2000); + + if(noAck) + { + zfree(out_data); + return 0; + } + + if (iso_status < 0) + nullBuffer = 1; + + + out_size = 48; + if (nullBuffer) + OutputBufferSize = 0; + else + out_size += OutputBufferSize + (NumberOfPackets * 12); + /* fill the send data */ + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + if(OutputBufferSize != 0 && !nullBuffer) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 20 + (NumberOfPackets * 12)); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 20 + (NumberOfPackets * 12)); /** Size */ + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_ISOCH_TRANSFER); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, StartFrame); /** StartFrame */ + if (!nullBuffer) + { + /** NumberOfPackets */ + data_write_uint32(out_data + 32, NumberOfPackets); + data_write_uint32(out_data + 36, ErrorCount); /** ErrorCount */ + offset = 40 + (NumberOfPackets * 12); + } + else + { + data_write_uint32(out_data + 32, 0); /** NumberOfPackets */ + data_write_uint32(out_data + 36, NumberOfPackets); /** ErrorCount */ + offset = 40; + } + + data_write_uint32(out_data + offset, 0); /** HResult */ + data_write_uint32(out_data + offset + 4, OutputBufferSize); /** OutputBufferSize */ + +#if ISOCH_FIFO + if(!noAck){ + pthread_mutex_lock(&isoch_queue->isoch_loading); + isoch->out_data = out_data; + isoch->out_size = out_size; + pthread_mutex_unlock(&isoch_queue->isoch_loading); + } +#else + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); +#endif + + if (nullBuffer) + return -1; + + return 0; +} + +static int +urb_control_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + uint8 func_recipient, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, InterfaceId, RequestId, OutputBufferSize, usbd_status; + uint8 bmRequestType, desc_index, desc_type; + uint16 langId; + uint8 * buffer; + uint8 * out_data; + int ret, offset; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + data_read_uint32(data + 0, RequestId); + data_read_uint8(data + 4, desc_index); + data_read_uint8(data + 5, desc_type); + data_read_uint16(data + 6, langId); + data_read_uint32(data + 8, OutputBufferSize); + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + bmRequestType = func_recipient; + switch (transferDir) + { + case USBD_TRANSFER_DIRECTION_IN: + bmRequestType |= 0x80; + break; + case USBD_TRANSFER_DIRECTION_OUT: + bmRequestType |= 0x00; + offset = 12; + memcpy(buffer, data + offset, OutputBufferSize); + break; + default: + LLOGLN(urbdrc_debug, ("%s: get error transferDir", __func__)); + OutputBufferSize = 0; + usbd_status = USBD_STATUS_STALL_PID; + break; + } + + /** process get usb device descriptor */ + + ret = pdev->control_transfer( + pdev, RequestId, 0, 0, bmRequestType, + 0x06, /* REQUEST_GET_DESCRIPTOR */ + (desc_type << 8) | desc_index, + langId, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + + if (ret < 0) { + LLOGLN(urbdrc_debug, ("%s:get_descriptor: error num %d", __func__, ret)); + OutputBufferSize = 0; + } + + offset = 36; + out_size = offset + OutputBufferSize; + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + return 0; +} + + + + +static int +urb_control_get_status_request(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + uint8 func_recipient, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status; + uint16 Index; + uint8 bmRequestType; + uint8 * buffer; + uint8 * out_data; + int offset, ret; + + if (transferDir == 0){ + LLOGLN(urbdrc_debug, ("urb_control_get_status_request: not support transfer out\n")); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint16(data + 4, Index); /** Index */ + data_read_uint32(data + 8, OutputBufferSize); + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + bmRequestType = func_recipient | 0x80; + + ret = pdev->control_transfer( + pdev, RequestId, 0, 0, bmRequestType, + 0x00, /* REQUEST_GET_STATUS */ + 0, + Index, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d!!\n", __func__, ret)); + OutputBufferSize = 0; + usbd_status = USBD_STATUS_STALL_PID; + } + else{ + usbd_status = USBD_STATUS_SUCCESS; + } + + /** send data */ + offset = 36; + if (transferDir == USBD_TRANSFER_DIRECTION_IN) + out_size = offset + OutputBufferSize; + else + out_size = offset; + + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + + data_write_uint32(out_data + 12, RequestId); /** RequestId, include NoAck*/ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_VENDOR_DEVICE); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + + return 0; +} + +static int +urb_control_vendor_or_class_request(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + uint8 func_type, + uint8 func_recipient, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, TransferFlags, usbd_status; + uint32 OutputBufferSize; + uint8 ReqTypeReservedBits, Request, bmRequestType; + uint16 Value, Index, Padding; + uint8 * buffer; + uint8 * out_data; + int offset, ret; + /** control by vendor command */ + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, TransferFlags); /** TransferFlags */ + data_read_uint8(data + 8, ReqTypeReservedBits); /** ReqTypeReservedBids */ + data_read_uint8(data + 9, Request); /** Request */ + data_read_uint16(data + 10, Value); /** value */ + data_read_uint16(data + 12, Index); /** index */ + data_read_uint16(data + 14, Padding); /** Padding */ + data_read_uint32(data + 16, OutputBufferSize); + offset = 20; + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + /** Get Buffer */ + if (transferDir == USBD_TRANSFER_DIRECTION_OUT) + memcpy(buffer, data + offset, OutputBufferSize); + + /** vendor or class command */ + bmRequestType = func_type | func_recipient; + + if (TransferFlags & USBD_TRANSFER_DIRECTION) + bmRequestType |= 0x80; + + LLOGLN(urbdrc_debug, ("urb_control_vendor_or_class_request: " + "RequestId 0x%x TransferFlags: 0x%x ReqTypeReservedBits: 0x%x " + "Request:0x%x Value: 0x%x Index: 0x%x OutputBufferSize: 0x%x bmRequestType: 0x%x!!", + RequestId, TransferFlags, ReqTypeReservedBits, Request, Value, + Index, OutputBufferSize, bmRequestType)); + + ret = pdev->control_transfer( + pdev, RequestId, 0, 0, bmRequestType, + Request, + Value, + Index, + &usbd_status, + &OutputBufferSize, + buffer, + 2000); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d!!", __func__, ret)); + OutputBufferSize = 0; + usbd_status = USBD_STATUS_STALL_PID; + } + else{ + usbd_status = USBD_STATUS_SUCCESS; + } + + offset = 36; + if (transferDir == USBD_TRANSFER_DIRECTION_IN) + out_size = offset + OutputBufferSize; + else + out_size = offset; + /** send data */ + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if(transferDir == USBD_TRANSFER_DIRECTION_IN && OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + + data_write_uint32(out_data + 12, RequestId); /** RequestId, include NoAck*/ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + data_write_uint16(out_data + 22, URB_FUNCTION_VENDOR_DEVICE); /** Padding, MUST be ignored upon receipt */ + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + return 0; +} + + + +static int +urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status; + uint8 Recipient, InterfaceNumber, Ms_PageIndex; + uint16 Ms_featureDescIndex; + uint8 * out_data; + uint8 * buffer; + int offset, ret; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint8(data + 4, Recipient); /** Recipient */ + Recipient = Recipient && 0x1f; + data_read_uint8(data + 5, InterfaceNumber); /** InterfaceNumber */ + data_read_uint8(data + 6, Ms_PageIndex); /** Ms_PageIndex */ + data_read_uint16(data + 7, Ms_featureDescIndex); /** Ms_featureDescIndex */ + data_read_uint32(data + 12, OutputBufferSize); + offset = 16; + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + switch (transferDir) + { + case USBD_TRANSFER_DIRECTION_OUT: + printf("Function urb_os_feature_descriptor_request: OUT Unchecked\n"); + memcpy(buffer, data + offset, OutputBufferSize); + break; + case USBD_TRANSFER_DIRECTION_IN: + break; + } + + LLOGLN(urbdrc_debug, ("Ms descriptor arg: Recipient:0x%x, " + "InterfaceNumber:0x%x, Ms_PageIndex:0x%x, " + "Ms_featureDescIndex:0x%x, OutputBufferSize:0x%x", + Recipient, InterfaceNumber, Ms_PageIndex, + Ms_featureDescIndex, OutputBufferSize)); + /** get ms string */ + ret = pdev->os_feature_descriptor_request( + pdev, RequestId, Recipient, + InterfaceNumber, + Ms_PageIndex, + Ms_featureDescIndex, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + if (ret < 0) + LLOGLN(urbdrc_debug, ("os_feature_descriptor_request: error num %d", ret)); + + offset = 36; + out_size = offset + OutputBufferSize; + /** send data */ + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + if(OutputBufferSize!=0) + data_write_uint32(out_data + 8, URB_COMPLETION); /** function id */ + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + + zfree(out_data); + return 0; +} + + + + +static int +urb_pipe_request(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir, + int action) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, PipeHandle, EndpointAddress; + uint32 OutputBufferSize, usbd_status = 0; + uint8 * out_data; + int out_offset, ret; + + if (transferDir == 0){ + LLOGLN(urbdrc_debug, ("urb_pipe_request: not support transfer out\n")); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, PipeHandle); /** PipeHandle */ + data_read_uint32(data + 8, OutputBufferSize); + EndpointAddress = (PipeHandle & 0x000000ff); + + + switch (action){ + case PIPE_CANCEL: + LLOGLN(urbdrc_debug, ("urb_pipe_request: PIPE_CANCEL 0x%x ", EndpointAddress)); + + ret = pdev->control_pipe_request( + pdev, RequestId, EndpointAddress, + &usbd_status, + PIPE_CANCEL); + + if (ret < 0) { + LLOGLN(urbdrc_debug, ("PIPE SET HALT: error num %d", ret)); + } + + + break; + case PIPE_RESET: + LLOGLN(urbdrc_debug, ("urb_pipe_request: PIPE_RESET ep 0x%x ", EndpointAddress)); + + ret = pdev->control_pipe_request( + pdev, RequestId, EndpointAddress, + &usbd_status, + PIPE_RESET); + + if (ret < 0) + LLOGLN(urbdrc_debug, ("PIPE RESET: error num %d!!\n", ret)); + + break; + default: + LLOGLN(urbdrc_debug, ("urb_pipe_request action: %d is not support!\n", action)); + break; + } + + + /** send data */ + out_offset = 36; + out_size = out_offset + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0x00000008); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 0x0008); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, 0); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + + + + +static int +urb_get_current_frame_number(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize; + uint32 dummy_frames; + uint8 * out_data; + + if (transferDir == 0){ + LLOGLN(urbdrc_debug, ("urb_get_current_frame_number: not support transfer out\n")); + //exit(1); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, OutputBufferSize); + + /** Fixme: Need to fill actual frame number!!*/ + urbdrc_get_mstime(dummy_frames); + + out_size = 40; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 12); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 12); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_CURRENT_FRAME_NUMBER); + data_write_uint32(out_data + 24, USBD_STATUS_SUCCESS); /** UsbdStatus */ + data_write_uint32(out_data + 28, dummy_frames); /** FrameNumber */ + + data_write_uint32(out_data + 32, 0); /** HResult */ + data_write_uint32(out_data + 36, 0); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + + +/* Unused function for current server */ +static int +urb_control_get_configuration_request(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status; + uint8 * buffer; + uint8 * out_data; + int ret, offset; + + if (transferDir == 0){ + LLOGLN(urbdrc_debug, ("urb_control_get_configuration_request:" + " not support transfer out\n")); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint32(data + 4, OutputBufferSize); + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + ret = pdev->control_transfer( + pdev, RequestId, 0, 0, 0x80 | 0x00, + 0x08, /* REQUEST_GET_CONFIGURATION */ + 0, + 0, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d\n", __func__, ret)); + OutputBufferSize = 0; + } + + + offset = 36; + out_size = offset + OutputBufferSize; + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if (OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 8); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 8); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_CONFIGURATION); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + +/* Unused function for current server */ +static int +urb_control_get_interface_request(URBDRC_CHANNEL_CALLBACK * callback, + uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status; + uint16 interface; + uint8 * buffer; + uint8 * out_data; + int ret, offset; + + if (transferDir == 0){ + LLOGLN(urbdrc_debug, ("urb_control_get_interface_request: not support transfer out\n")); + return -1; + } + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint16(data + 4, interface); + data_read_uint32(data + 8, OutputBufferSize); + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + ret = pdev->control_transfer(pdev, RequestId, 0, 0, 0x80 | 0x01, + 0x0A, /* REQUEST_GET_INTERFACE */ + 0, + interface, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("%s:control_transfer: error num %d\n", __func__, ret)); + OutputBufferSize = 0; + } + + offset = 36; + out_size = offset + OutputBufferSize; + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if (OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 8); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 8); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_INTERFACE); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + +static int +urb_control_feature_request(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + uint8 func_recipient, + uint8 command, + int transferDir) +{ + IUDEVICE * pdev; + uint32 out_size, RequestId, InterfaceId, OutputBufferSize, usbd_status; + uint16 FeatureSelector, Index; + uint8 bmRequestType, bmRequest; + uint8 * buffer; + uint8 * out_data; + int ret, offset; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + + data_read_uint32(data + 0, RequestId); + data_read_uint16(data + 4, FeatureSelector); + data_read_uint16(data + 6, Index); + data_read_uint32(data + 8, OutputBufferSize); + offset = 12; + + out_size = 36 + OutputBufferSize; + out_data = (uint8 *) malloc(out_size); + memset(out_data, 0, out_size); + + buffer = out_data + 36; + + bmRequestType = func_recipient; + switch (transferDir) + { + case USBD_TRANSFER_DIRECTION_OUT: + printf("Function urb_control_feature_request: OUT Unchecked\n"); + memcpy(buffer, data + offset, OutputBufferSize); + bmRequestType |= 0x00; + break; + case USBD_TRANSFER_DIRECTION_IN: + bmRequestType |= 0x80; + break; + } + + switch (command) + { + case URB_SET_FEATURE: + bmRequest = 0x03; /* REQUEST_SET_FEATURE */ + break; + case URB_CLEAR_FEATURE: + bmRequest = 0x01; /* REQUEST_CLEAR_FEATURE */ + break; + default: + printf("urb_control_feature_request: Error Command %x\n", command); + return -1; + } + + ret = pdev->control_transfer( + pdev, RequestId, 0, 0, bmRequestType, bmRequest, + FeatureSelector, + Index, + &usbd_status, + &OutputBufferSize, + buffer, + 1000); + + if (ret < 0){ + LLOGLN(urbdrc_debug, ("feature control transfer: error num %d", ret)); + OutputBufferSize = 0; + } + + offset = 36; + out_size = offset + OutputBufferSize; + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if (OutputBufferSize != 0) + data_write_uint32(out_data + 8, URB_COMPLETION); + else + data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 8); /** CbTsUrbResult */ + /** TsUrbResult TS_URB_RESULT_HEADER */ + data_write_uint16(out_data + 20, 8); /** Size */ + + /** Padding, MUST be ignored upon receipt */ + data_write_uint16(out_data + 22, URB_FUNCTION_GET_INTERFACE); + data_write_uint32(out_data + 24, usbd_status); /** UsbdStatus */ + + data_write_uint32(out_data + 28, 0); /** HResult */ + data_write_uint32(out_data + 32, OutputBufferSize); /** OutputBufferSize */ + + + if (!pdev->isSigToEnd(pdev)) + callback->channel->Write(callback->channel, out_size, out_data, NULL); + zfree(out_data); + return 0; +} + +static int +urbdrc_process_transfer_request(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, + uint32 data_sizem, + uint32 MessageId, + IUDEVMAN * udevman, + uint32 UsbDevice, + int transferDir) +{ + IUDEVICE * pdev; + uint32 CbTsUrb; + uint16 Size; + uint16 URB_Function; + uint32 OutputBufferSize; + int error = 0; + + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) + return 0; + data_read_uint32(data + 0, CbTsUrb); /** CbTsUrb */ + data_read_uint16(data + 4, Size); /** size */ + data_read_uint16(data + 6, URB_Function); + data_read_uint32(data + 4 + CbTsUrb, OutputBufferSize); + + switch (URB_Function) + { + case URB_FUNCTION_SELECT_CONFIGURATION: /** 0x0000 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SELECT_CONFIGURATION")); + error = urb_select_configuration( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_SELECT_INTERFACE: /** 0x0001 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SELECT_INTERFACE")); + error = urb_select_interface( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_ABORT_PIPE: /** 0x0002 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_ABORT_PIPE")); + error = urb_pipe_request( + callback, data + 8, data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + PIPE_CANCEL); + break; + case URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: /** 0x0003 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL")); + error = -1; /** This URB function is obsolete in Windows 2000 + * and later operating systems + * and is not supported by Microsoft. */ + break; + case URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: /** 0x0004 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL")); + error = -1; /** This URB function is obsolete in Windows 2000 + * and later operating systems + * and is not supported by Microsoft. */ + break; + case URB_FUNCTION_GET_FRAME_LENGTH: /** 0x0005 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_FRAME_LENGTH")); + error = -1; /** This URB function is obsolete in Windows 2000 + * and later operating systems + * and is not supported by Microsoft. */ + break; + case URB_FUNCTION_SET_FRAME_LENGTH: /** 0x0006 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FRAME_LENGTH")); + error = -1; /** This URB function is obsolete in Windows 2000 + * and later operating systems + * and is not supported by Microsoft. */ + break; + case URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: /** 0x0007 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_CURRENT_FRAME_NUMBER")); + error = urb_get_current_frame_number( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_CONTROL_TRANSFER: /** 0x0008 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CONTROL_TRANSFER")); + error = urb_control_transfer( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + URB_CONTROL_TRANSFER_NONEXTERNAL); + break; + case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /** 0x0009 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER")); + error = urb_bulk_or_interrupt_transfer( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_ISOCH_TRANSFER: /** 0x000A */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_ISOCH_TRANSFER")); + error = urb_isoch_transfer( + callback, data + 8, data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: /** 0x000B */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x00, + transferDir); + break; + case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: /** 0x000C */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x00, + transferDir); + break; + case URB_FUNCTION_SET_FEATURE_TO_DEVICE: /** 0x000D */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_DEVICE")); + error = urb_control_feature_request(callback, + data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x00, + URB_SET_FEATURE, + transferDir); + break; + case URB_FUNCTION_SET_FEATURE_TO_INTERFACE: /** 0x000E */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_INTERFACE")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x01, + URB_SET_FEATURE, + transferDir); + break; + case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: /** 0x000F */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_ENDPOINT")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x02, + URB_SET_FEATURE, + transferDir); + break; + case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: /** 0x0010 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x00, + URB_CLEAR_FEATURE, + transferDir); + break; + case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: /** 0x0011 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x01, + URB_CLEAR_FEATURE, + transferDir); + break; + case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: /** 0x0012 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x02, + URB_CLEAR_FEATURE, + transferDir); + break; + case URB_FUNCTION_GET_STATUS_FROM_DEVICE: /** 0x0013 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_DEVICE")); + error = urb_control_get_status_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x00, + transferDir); + break; + case URB_FUNCTION_GET_STATUS_FROM_INTERFACE: /** 0x0014 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_INTERFACE")); + error = urb_control_get_status_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x01, + transferDir); + break; + case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: /** 0x0015 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_ENDPOINT")); + error = urb_control_get_status_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x02, + transferDir); + break; + case URB_FUNCTION_RESERVED_0X0016: /** 0x0016 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVED_0X0016")); + error = -1; + break; + case URB_FUNCTION_VENDOR_DEVICE: /** 0x0017 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_DEVICE")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x02 << 5), /* vendor type */ + 0x00, + transferDir); + break; + case URB_FUNCTION_VENDOR_INTERFACE: /** 0x0018 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_INTERFACE")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x02 << 5), /* vendor type */ + 0x01, + transferDir); + break; + case URB_FUNCTION_VENDOR_ENDPOINT: /** 0x0019 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_ENDPOINT")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x02 << 5), /* vendor type */ + 0x02, + transferDir); + break; + case URB_FUNCTION_CLASS_DEVICE: /** 0x001A */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_DEVICE")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x01 << 5), /* class type */ + 0x00, + transferDir); + break; + case URB_FUNCTION_CLASS_INTERFACE: /** 0x001B */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_INTERFACE")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x01 << 5), /* class type */ + 0x01, + transferDir); + break; + case URB_FUNCTION_CLASS_ENDPOINT: /** 0x001C */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_ENDPOINT")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x01 << 5), /* class type */ + 0x02, + transferDir); + break; + case URB_FUNCTION_RESERVE_0X001D: /** 0x001D */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X001D")); + error = -1; + break; + case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: /** 0x001E */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL")); + error = urb_pipe_request( + callback, data + 8, data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + PIPE_RESET); + break; + case URB_FUNCTION_CLASS_OTHER: /** 0x001F */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLASS_OTHER")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x01 << 5), /* class type */ + 0x03, + transferDir); + break; + case URB_FUNCTION_VENDOR_OTHER: /** 0x0020 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_VENDOR_OTHER")); + error = urb_control_vendor_or_class_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + (0x02 << 5), /* vendor type */ + 0x03, + transferDir); + break; + case URB_FUNCTION_GET_STATUS_FROM_OTHER: /** 0x0021 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_STATUS_FROM_OTHER")); + error = urb_control_get_status_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x03, + transferDir); + break; + case URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: /** 0x0022 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CLEAR_FEATURE_TO_OTHER")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x03, + URB_CLEAR_FEATURE, + transferDir); + break; + case URB_FUNCTION_SET_FEATURE_TO_OTHER: /** 0x0023 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_FEATURE_TO_OTHER")); + error = urb_control_feature_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x03, + URB_SET_FEATURE, + transferDir); + break; + case URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: /** 0x0024 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x02, + transferDir); + break; + case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: /** 0x0025 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x02, + transferDir); + break; + case URB_FUNCTION_GET_CONFIGURATION: /** 0x0026 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_CONFIGURATION")); + error = urb_control_get_configuration_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_GET_INTERFACE: /** 0x0027 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_INTERFACE")); + error = urb_control_get_interface_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: /** 0x0028 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x01, + transferDir); + break; + case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: /** 0x0029 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE")); + error = urb_control_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + 0x01, + transferDir); + break; + case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: /** 0x002A */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR")); + error = urb_os_feature_descriptor_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir); + break; + case URB_FUNCTION_RESERVE_0X002B: /** 0x002B */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002B")); + error = -1; + break; + case URB_FUNCTION_RESERVE_0X002C: /** 0x002C */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002C")); + error = -1; + break; + case URB_FUNCTION_RESERVE_0X002D: /** 0x002D */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002D")); + error = -1; + break; + case URB_FUNCTION_RESERVE_0X002E: /** 0x002E */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002E")); + error = -1; + break; + case URB_FUNCTION_RESERVE_0X002F: /** 0x002F */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_RESERVE_0X002F")); + error = -1; + break; + /** USB 2.0 calls start at 0x0030 */ + case URB_FUNCTION_SYNC_RESET_PIPE: /** 0x0030 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_RESET_PIPE")); + error = urb_pipe_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + PIPE_RESET); + error = -9; /** function not support */ + break; + case URB_FUNCTION_SYNC_CLEAR_STALL: /** 0x0031 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_SYNC_CLEAR_STALL")); + error = urb_pipe_request( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + PIPE_RESET); + error = -9; + break; + case URB_FUNCTION_CONTROL_TRANSFER_EX: /** 0x0032 */ + LLOGLN(urbdrc_debug, ("URB_Func: URB_FUNCTION_CONTROL_TRANSFER_EX")); + error = urb_control_transfer( + callback, data + 8, + data_sizem - 8, + MessageId, + udevman, + UsbDevice, + transferDir, + URB_CONTROL_TRANSFER_EXTERNAL); + break; + default: + LLOGLN(urbdrc_debug, ("URB_Func: %x is not found!", URB_Function)); + } + + return error; +} + +void* +urbdrc_process_udev_data_transfer(void* arg) +{ + TRANSFER_DATA* transfer_data = (TRANSFER_DATA*) arg; + URBDRC_CHANNEL_CALLBACK * callback = transfer_data->callback; + uint8 * pBuffer = transfer_data->pBuffer; + uint32 cbSize = transfer_data->cbSize; + uint32 UsbDevice = transfer_data->UsbDevice; + IUDEVMAN * udevman = transfer_data->udevman; + uint32 MessageId; + uint32 FunctionId; + IUDEVICE* pdev; + int error = 0; + pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL || pdev->isSigToEnd(pdev)) + { + if (transfer_data) + { + if (transfer_data->pBuffer) + zfree(transfer_data->pBuffer); + zfree(transfer_data); + } + return 0; + } + + pdev->push_action(pdev); + + /* USB kernel driver detach!! */ + pdev->detach_kernel_driver(pdev); + + data_read_uint32(pBuffer + 0, MessageId); + data_read_uint32(pBuffer + 4, FunctionId); + switch (FunctionId) + { + case CANCEL_REQUEST: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>CANCEL_REQUEST<<0x%X", FunctionId)); + error = urbdrc_process_cancel_request( + pBuffer + 8, + cbSize - 8, + udevman, + UsbDevice); + break; + case REGISTER_REQUEST_CALLBACK: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>REGISTER_REQUEST_CALLBACK<<0x%X", FunctionId)); + error = urbdrc_process_register_request_callback( + callback, + pBuffer + 8, + cbSize - 8, + udevman, + UsbDevice); + break; + case IO_CONTROL: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>IO_CONTROL<<0x%X", FunctionId)); + error = urbdrc_process_io_control( + callback, + pBuffer + 8, + cbSize - 8, + MessageId, + udevman, UsbDevice); + break; + case INTERNAL_IO_CONTROL: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>INTERNAL_IO_CONTROL<<0x%X", FunctionId)); + error = urbdrc_process_internal_io_control( + callback, + pBuffer + 8, + cbSize - 8, + MessageId, + udevman, UsbDevice); + break; + case QUERY_DEVICE_TEXT: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>QUERY_DEVICE_TEXT<<0x%X", FunctionId)); + error = urbdrc_process_query_device_text( + callback, + pBuffer + 8, + cbSize - 8, + MessageId, + udevman, + UsbDevice); + break; + case TRANSFER_IN_REQUEST: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>TRANSFER_IN_REQUEST<<0x%X", FunctionId)); + error = urbdrc_process_transfer_request( + callback, + pBuffer + 8, + cbSize - 8, + MessageId, + udevman, + UsbDevice, + USBD_TRANSFER_DIRECTION_IN); + break; + case TRANSFER_OUT_REQUEST: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>TRANSFER_OUT_REQUEST<<0x%X", FunctionId)); + error = urbdrc_process_transfer_request( + callback, + pBuffer + 8, + cbSize - 8, + MessageId, + udevman, + UsbDevice, + USBD_TRANSFER_DIRECTION_OUT); + break; + case RETRACT_DEVICE: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " >>RETRACT_DEVICE<<0x%X", FunctionId)); + error = urbdrc_process_retract_device_request( + pBuffer + 8, + cbSize - 8, + udevman, + UsbDevice); + break; + default: + LLOGLN(urbdrc_debug, ("urbdrc_process_udev_data_transfer:" + " unknown FunctionId 0x%X", FunctionId)); + error = -1; + break; + } + + if (transfer_data) + { + if (transfer_data->pBuffer) + zfree(transfer_data->pBuffer); + zfree(transfer_data); + } + + if (pdev) + { +#if ISOCH_FIFO + /* check isochronous fds */ + func_check_isochronous_fds(pdev); +#endif + /* close this channel, if device is not found. */ + pdev->complete_action(pdev); + } + else + { + udevman->push_urb(udevman); + return 0; + } + + udevman->push_urb(udevman); + return 0; +} + + diff --git a/channels/drdynvc/urbdrc/data_transfer.h b/channels/drdynvc/urbdrc/data_transfer.h new file mode 100644 index 000000000..eb6af0a93 --- /dev/null +++ b/channels/drdynvc/urbdrc/data_transfer.h @@ -0,0 +1,41 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __DATA_TRANSFER_H +#define __DATA_TRANSFER_H + + +#include "urbdrc_main.h" + + +#define DEVICE_CTX(dev) ((dev)->ctx) +#define HANDLE_CTX(handle) (DEVICE_CTX((handle)->dev)) +#define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle)) +#define ITRANSFER_CTX(transfer) \ + (TRANSFER_CTX(__USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer))) + + + +void* +urbdrc_process_udev_data_transfer(void* arg); + + +#endif + diff --git a/channels/drdynvc/urbdrc/isoch_queue.c b/channels/drdynvc/urbdrc/isoch_queue.c new file mode 100644 index 000000000..fe77739d1 --- /dev/null +++ b/channels/drdynvc/urbdrc/isoch_queue.c @@ -0,0 +1,195 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "isoch_queue.h" + + +static void +isoch_queue_rewind(ISOCH_CALLBACK_QUEUE * queue) +{ + queue->curr = queue->head; +} + +static int +isoch_queue_has_next(ISOCH_CALLBACK_QUEUE * queue) +{ + if (queue->curr == NULL) + return 0; + else + return 1; +} + +static ISOCH_CALLBACK_DATA* +isoch_queue_get_next(ISOCH_CALLBACK_QUEUE * queue) +{ + ISOCH_CALLBACK_DATA* isoch; + + isoch = queue->curr; + queue->curr = (ISOCH_CALLBACK_DATA*)queue->curr->next; + + return isoch; +} + + + + +static ISOCH_CALLBACK_DATA* +isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void * callback, + void * dev) +{ + ISOCH_CALLBACK_DATA* isoch; + + isoch = (ISOCH_CALLBACK_DATA*)malloc(sizeof(ISOCH_CALLBACK_DATA)); + + isoch->prev = NULL; + isoch->next = NULL; + + isoch->out_data = NULL; + isoch->out_size = 0; + isoch->device = dev; + isoch->callback = callback; + + pthread_mutex_lock(&queue->isoch_loading); + if (queue->head == NULL) + { + /* linked queue is empty */ + queue->head = isoch; + queue->tail = isoch; + } + else + { + /* append data to the end of the linked queue */ + queue->tail->next = (void*)isoch; + isoch->prev = (void*)queue->tail; + queue->tail = isoch; + } + queue->isoch_num += 1; + pthread_mutex_unlock(&queue->isoch_loading); + return isoch; +} + + + +static int +isoch_queue_unregister_data(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch) +{ + ISOCH_CALLBACK_DATA* p; + + queue->rewind(queue); + while (queue->has_next(queue) != 0) + { + p = queue->get_next(queue); + + if (p == isoch) /* data exists */ + { + /* set previous data to point to next data */ + + if (isoch->prev != NULL) + { + /* unregistered data is not the head */ + p = (ISOCH_CALLBACK_DATA*)isoch->prev; + p->next = isoch->next; + } + else + { + /* unregistered data is the head, update head */ + queue->head = (ISOCH_CALLBACK_DATA*)isoch->next; + } + + /* set next data to point to previous data */ + + if (isoch->next != NULL) + { + /* unregistered data is not the tail */ + p = (ISOCH_CALLBACK_DATA*)isoch->next; + p->prev = isoch->prev; + } + else + { + /* unregistered data is the tail, update tail */ + queue->tail = (ISOCH_CALLBACK_DATA*)isoch->prev; + } + queue->isoch_num--; + + /* free data info */ + isoch->out_data = NULL; + + if (isoch) zfree(isoch); + + return 1; /* unregistration successful */ + } + } + + /* if we reach this point, the isoch wasn't found */ + return 0; +} + + +void +isoch_queue_free(ISOCH_CALLBACK_QUEUE * queue) +{ + ISOCH_CALLBACK_DATA * isoch; + + pthread_mutex_lock(&queue->isoch_loading); + /** unregister all isochronous data*/ + queue->rewind(queue); + while (queue->has_next(queue)) + { + isoch = queue->get_next(queue); + if (isoch != NULL) + queue->unregister_data(queue, isoch); + } + pthread_mutex_unlock(&queue->isoch_loading); + + pthread_mutex_destroy(&queue->isoch_loading); + + /* free queue */ + if (queue) + zfree(queue); +} + + +ISOCH_CALLBACK_QUEUE* +isoch_queue_new() +{ + ISOCH_CALLBACK_QUEUE * queue; + + queue = (ISOCH_CALLBACK_QUEUE *)malloc(sizeof(ISOCH_CALLBACK_QUEUE)); + queue->isoch_num = 0; + queue->curr = NULL; + queue->head = NULL; + queue->tail = NULL; + + pthread_mutex_init(&queue->isoch_loading, NULL); + + /* load service */ + queue->get_next = isoch_queue_get_next; + queue->has_next = isoch_queue_has_next; + queue->rewind = isoch_queue_rewind; + queue->register_data = isoch_queue_register_data; + queue->unregister_data = isoch_queue_unregister_data; + queue->free = isoch_queue_free; + + return queue; +} diff --git a/channels/drdynvc/urbdrc/isoch_queue.h b/channels/drdynvc/urbdrc/isoch_queue.h new file mode 100644 index 000000000..94b077375 --- /dev/null +++ b/channels/drdynvc/urbdrc/isoch_queue.h @@ -0,0 +1,69 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __ISOCH_QUEUE_H +#define __ISOCH_QUEUE_H + +#include "urbdrc_types.h" + + +typedef struct _ISOCH_CALLBACK_DATA ISOCH_CALLBACK_DATA; +typedef struct _ISOCH_CALLBACK_QUEUE ISOCH_CALLBACK_QUEUE; + + +struct _ISOCH_CALLBACK_DATA +{ + void * inode; + void * prev; + void * next; + void * device; + uint8 * out_data; + uint32 out_size; + void * callback; +}; + + + +struct _ISOCH_CALLBACK_QUEUE +{ + int isoch_num; + ISOCH_CALLBACK_DATA* curr; /* current point */ + ISOCH_CALLBACK_DATA* head; /* head point in linked list */ + ISOCH_CALLBACK_DATA* tail; /* tail point in linked list */ + + pthread_mutex_t isoch_loading; + + /* Isochronous queue service */ + void (*rewind) (ISOCH_CALLBACK_QUEUE * queue); + int (*has_next) (ISOCH_CALLBACK_QUEUE * queue); + int (*unregister_data) (ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch); + ISOCH_CALLBACK_DATA *(*get_next) (ISOCH_CALLBACK_QUEUE * queue); + ISOCH_CALLBACK_DATA *(*register_data) (ISOCH_CALLBACK_QUEUE* queue, + void * callback, void * dev); + void (*free) (ISOCH_CALLBACK_QUEUE * queue); + +}; + + +ISOCH_CALLBACK_QUEUE* isoch_queue_new(); + + + +#endif /* __ISOCH_QUEUE_H */ diff --git a/channels/drdynvc/urbdrc/libusb/CMakeLists.txt b/channels/drdynvc/urbdrc/libusb/CMakeLists.txt new file mode 100644 index 000000000..f3ba9c242 --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/CMakeLists.txt @@ -0,0 +1,38 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Atrust corp. +# Copyright 2012 Alfred Liu +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(LIBUSB_UDEVMAN_SRCS + libusb_udevman.c + libusb_udevice.c + libusb_udevice.h + request_queue.c + request_queue.h +) + +include_directories(..) + +add_library(libusb_udevman ${LIBUSB_UDEVMAN_SRCS}) +set_target_properties(libusb_udevman PROPERTIES PREFIX "") + +target_link_libraries(libusb_udevman udev) +target_link_libraries(libusb_udevman dbus-glib-1) +target_link_libraries(libusb_udevman pthread) +target_link_libraries(libusb_udevman usb-1.0) +target_link_libraries(libusb_udevman freerdp-utils) + +install(TARGETS libusb_udevman DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevice.c b/channels/drdynvc/urbdrc/libusb/libusb_udevice.c new file mode 100644 index 000000000..9b70e9d1d --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/libusb_udevice.c @@ -0,0 +1,1903 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include "libusb_udevice.h" + +#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \ +static _type udev_get_##_arg (IUDEVICE * idev) \ +{ \ + UDEVICE * pdev = (UDEVICE *) idev; \ + return pdev->_arg; \ +} \ +static void udev_set_##_arg (IUDEVICE * idev, _type _t) \ +{ \ + UDEVICE * pdev = (UDEVICE *) idev; \ + pdev->_arg = _t; \ +} + +#define BASIC_POINT_FUNC_DEFINED(_arg, _type) \ +static _type udev_get_p_##_arg (IUDEVICE * idev) \ +{ \ + UDEVICE * pdev = (UDEVICE *) idev; \ + return pdev->_arg; \ +} \ +static void udev_set_p_##_arg (IUDEVICE * idev, _type _t) \ +{ \ + UDEVICE * pdev = (UDEVICE *) idev; \ + pdev->_arg = _t; \ +} + +#define BASIC_STATE_FUNC_REGISTER(_arg, _dev) \ + _dev->iface.get_##_arg = udev_get_##_arg; \ + _dev->iface.set_##_arg = udev_set_##_arg + + +typedef struct _ISO_USER_DATA ISO_USER_DATA; +struct _ISO_USER_DATA +{ + uint8 * IsoPacket; + uint8 * output_data; + int iso_status; + int completed; + uint32 error_count; + int noack; + uint32 start_frame; +}; + +static int +get_next_timeout(libusb_context *ctx, struct timeval *tv, struct timeval *out) +{ + struct timeval timeout; + int r = libusb_get_next_timeout(ctx, &timeout); + if (r) { + /* timeout already expired? */ + if (!timerisset(&timeout)) + return 1; + + /* choose the smallest of next URB timeout or user specified timeout */ + if (timercmp(&timeout, tv, <)) + *out = timeout; + else + *out = *tv; + } else { + *out = *tv; + } + return 0; +} + +/* + * a simple wrapper to implement libusb_handle_events_timeout_completed + * function in libusb library git tree (1.0.9 later) */ +static int +handle_events_completed(libusb_context *ctx, int *completed) +{ + struct timeval tv; + tv.tv_sec = 60; + tv.tv_usec = 0; + +#ifdef HAVE_NEW_LIBUSB + return libusb_handle_events_timeout_completed(ctx, &tv, completed); +#else + int r; + struct timeval poll_timeout; + + r = get_next_timeout(ctx, &tv, &poll_timeout); + +retry: + if (libusb_try_lock_events(ctx) == 0) { + if (completed == NULL || !*completed) { + /* we obtained the event lock: do our own event handling */ + LLOGLN(10, ("doing our own event handling")); + r = libusb_handle_events_locked(ctx, &tv); + } + libusb_unlock_events(ctx); + return r; + } + + /* another thread is doing event handling. wait for thread events that + * notify event completion. */ + libusb_lock_event_waiters(ctx); + + if (completed && *completed) + goto already_done; + + if (!libusb_event_handler_active(ctx)) { + /* we hit a race: whoever was event handling earlier finished in the + * time it took us to reach this point. try the cycle again. */ + libusb_unlock_event_waiters(ctx); + LLOGLN(10, ("event handler was active but went away, retrying")); + goto retry; + } + + LLOGLN(10, ("another thread is doing event handling")); + r = libusb_wait_for_event(ctx, &poll_timeout); + +already_done: + libusb_unlock_event_waiters(ctx); + + if (r < 0) { + return r; + } + else if (r == 1) { + return libusb_handle_events_timeout(ctx, &tv); + } + else + return 0; +#endif /* HAVE_NEW_LIBUSE */ +} + +static void +func_iso_callback(struct libusb_transfer *transfer) +{ + ISO_USER_DATA * iso_user_data = (ISO_USER_DATA *) transfer->user_data; + uint8 * data = iso_user_data->IsoPacket; + int * completed = &iso_user_data->completed; + uint32 offset = 0; + uint32 index = 0; + uint32 i, act_len; + uint8 *b; + + *completed = 1; + /* Fixme: currently fill the dummy frame number, tt needs to be + * filled a real frame number */ + // urbdrc_get_mstime(iso_user_data->start_frame); + if(transfer->status == LIBUSB_TRANSFER_COMPLETED && + !iso_user_data->noack) + { + for (i = 0; i < transfer->num_iso_packets; i++) + { + act_len = transfer->iso_packet_desc[i].actual_length; + data_write_uint32(data + offset, index); + data_write_uint32(data + offset + 4, act_len); + data_write_uint32(data + offset + 8, + transfer->iso_packet_desc[i].status); + offset += 12; + if (transfer->iso_packet_desc[i].status == USBD_STATUS_SUCCESS) + { + b = libusb_get_iso_packet_buffer_simple(transfer, i); + if (act_len > 0) + { + if (iso_user_data->output_data + index != b) + memcpy(iso_user_data->output_data + index, b, act_len); + index += act_len; + } + else{ + //printf("actual length %d \n", act_len); + //exit(EXIT_FAILURE); + } + } + else + { + iso_user_data->error_count++; + //print_transfer_status(transfer->iso_packet_desc[i].status); + } + } + transfer->actual_length = index; + iso_user_data->iso_status = 1; + } + else if(transfer->status == LIBUSB_TRANSFER_COMPLETED && + iso_user_data->noack) + { + /* This situation occurs when we do not need to + * return any packet */ + iso_user_data->iso_status = 1; + } + else{ + //print_status(transfer->status); + iso_user_data->iso_status = -1; + } +} + + +static const LIBUSB_ENDPOINT_DESCEIPTOR* +func_get_ep_desc(LIBUSB_CONFIG_DESCRIPTOR * LibusbConfig, + MSUSB_CONFIG_DESCRIPTOR * MsConfig, + uint32 EndpointAddress) +{ + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + const LIBUSB_INTERFACE * interface; + const LIBUSB_ENDPOINT_DESCEIPTOR * endpoint; + uint8 alt; + int inum, pnum; + + MsInterfaces = MsConfig->MsInterfaces; + interface = LibusbConfig->interface; + for(inum = 0; inum < MsConfig->NumInterfaces; inum++) + { + alt = MsInterfaces[inum]->AlternateSetting; + endpoint = interface[inum].altsetting[alt].endpoint; + + for(pnum = 0; pnum < MsInterfaces[inum]->NumberOfPipes; pnum++) + { + if (endpoint[pnum].bEndpointAddress == EndpointAddress) + { + return &endpoint[pnum]; + } + } + } + return NULL; +} + + + +static void +func_bulk_transfer_cb(struct libusb_transfer *transfer) +{ + int *completed = transfer->user_data; + *completed = 1; + /* caller interprets results and frees transfer */ +} + + + + +static int +func_set_usbd_status(UDEVICE* pdev, uint32* status, int err_result) +{ + switch (err_result) + { + case LIBUSB_SUCCESS: + *status = USBD_STATUS_SUCCESS; + break; + case LIBUSB_ERROR_IO: + *status = USBD_STATUS_STALL_PID; + LLOGLN(10, ("urb_status: LIBUSB_ERROR_IO!!\n")); + break; + case LIBUSB_ERROR_INVALID_PARAM: + *status = USBD_STATUS_INVALID_PARAMETER; + break; + case LIBUSB_ERROR_ACCESS: + *status = USBD_STATUS_NOT_ACCESSED; + break; + case LIBUSB_ERROR_NO_DEVICE: + *status = USBD_STATUS_DEVICE_GONE; + if (pdev){ + if(!(pdev->status & URBDRC_DEVICE_NOT_FOUND)) + { + pdev->status |= URBDRC_DEVICE_NOT_FOUND; + LLOGLN(libusb_debug, ("urb_status: LIBUSB_ERROR_NO_DEVICE!!\n")); + } + } + break; + case LIBUSB_ERROR_NOT_FOUND: + *status = USBD_STATUS_STALL_PID; + break; + case LIBUSB_ERROR_BUSY: + *status = USBD_STATUS_STALL_PID; + break; + case LIBUSB_ERROR_TIMEOUT: + *status = USBD_STATUS_TIMEOUT; + break; + case LIBUSB_ERROR_OVERFLOW: + *status = USBD_STATUS_STALL_PID; + break; + case LIBUSB_ERROR_PIPE: + *status = USBD_STATUS_STALL_PID; + break; + case LIBUSB_ERROR_INTERRUPTED: + *status = USBD_STATUS_STALL_PID; + break; + case LIBUSB_ERROR_NO_MEM: + *status = USBD_STATUS_NO_MEMORY; + break; + case LIBUSB_ERROR_NOT_SUPPORTED: + *status = USBD_STATUS_NOT_SUPPORTED; + break; + case LIBUSB_ERROR_OTHER: + *status = USBD_STATUS_STALL_PID; + break; + default: + *status = USBD_STATUS_SUCCESS; + break; + } + return 0; +} + + + +static void +func_iso_data_init(ISO_USER_DATA * iso_user_data, uint32 numPacket, uint32 buffsize, + uint32 noAck, uint8 * isoPacket, uint8 * buffer) +{ + /* init struct iso_user_data */ + iso_user_data->IsoPacket = isoPacket; + iso_user_data->output_data = buffer; + iso_user_data->error_count = 0; + iso_user_data->completed = 0; + iso_user_data->noack = noAck; + urbdrc_get_mstime(iso_user_data->start_frame); +} + + + +static int +func_config_release_all_interface(LIBUSB_DEVICE_HANDLE *libusb_handle, uint32_t NumInterfaces) +{ + int i, ret; + for (i = 0; i < NumInterfaces; i++) + { + ret = libusb_release_interface (libusb_handle, i); + if (ret < 0){ + printf("config_release_all_interface: error num %d\n", ret); + return -1; + } + } + return 0; +} + + +static int +func_claim_all_interface(LIBUSB_DEVICE_HANDLE *libusb_handle, int NumInterfaces) +{ + int i, ret; + for (i = 0; i < NumInterfaces; i++) + { + ret = libusb_claim_interface (libusb_handle, i); + if (ret < 0){ + printf("claim_all_interface: error num %d\n", ret); + return -1; + } + } + return 0; +} + + + + +/* +static void* +print_transfer_status(enum libusb_transfer_status status) +{ + switch(status) + { + case LIBUSB_TRANSFER_COMPLETED: + //printf("Transfer Status: LIBUSB_TRANSFER_COMPLETED\n"); + break; + case LIBUSB_TRANSFER_ERROR: + printf("Transfer Status: LIBUSB_TRANSFER_ERROR\n"); + break; + case LIBUSB_TRANSFER_TIMED_OUT: + printf("Transfer Status: LIBUSB_TRANSFER_TIMED_OUT\n"); + break; + case LIBUSB_TRANSFER_CANCELLED: + printf("Transfer Status: LIBUSB_TRANSFER_CANCELLED\n"); + break; + case LIBUSB_TRANSFER_STALL: + printf("Transfer Status: LIBUSB_TRANSFER_STALL\n"); + break; + case LIBUSB_TRANSFER_NO_DEVICE: + printf("Transfer Status: LIBUSB_TRANSFER_NO_DEVICE\n"); + break; + case LIBUSB_TRANSFER_OVERFLOW: + printf("Transfer Status: LIBUSB_TRANSFER_OVERFLOW\n"); + break; + default: + printf("Transfer Status: Get unknow error num %d (0x%x)\n", + status, status); + } + return 0; +} + + +static void +print_status(enum libusb_transfer_status status) +{ + switch(status) + { + case LIBUSB_TRANSFER_COMPLETED: + printf("Transfer status: LIBUSB_TRANSFER_COMPLETED\n"); + break; + case LIBUSB_TRANSFER_ERROR: + printf("Transfer status: LIBUSB_TRANSFER_ERROR\n"); + break; + case LIBUSB_TRANSFER_TIMED_OUT: + printf("Transfer status: LIBUSB_TRANSFER_TIMED_OUT\n"); + break; + case LIBUSB_TRANSFER_CANCELLED: + printf("Transfer status: LIBUSB_TRANSFER_CANCELLED\n"); + break; + case LIBUSB_TRANSFER_STALL: + printf("Transfer status: LIBUSB_TRANSFER_STALL\n"); + break; + case LIBUSB_TRANSFER_NO_DEVICE: + printf("Transfer status: LIBUSB_TRANSFER_NO_DEVICE\n"); + break; + case LIBUSB_TRANSFER_OVERFLOW: + printf("Transfer status: LIBUSB_TRANSFER_OVERFLOW\n"); + break; + default: + printf("Transfer status: unknow status %d(0x%x)\n", status, status); + break; + } +} +*/ + + +static LIBUSB_DEVICE* +udev_get_libusb_dev(int bus_number, int dev_number) +{ + ssize_t total_device; + LIBUSB_DEVICE ** libusb_list; + int i; + + total_device = libusb_get_device_list(NULL, &libusb_list); + for (i = 0; i < total_device; i++) + { + if((bus_number == libusb_get_bus_number(libusb_list[i])) && + (dev_number == libusb_get_device_address(libusb_list[i]))) + return libusb_list[i]; + } + libusb_free_device_list(libusb_list, 1); + + return NULL; +} + + + +static LIBUSB_DEVICE_DESCRIPTOR* +udev_new_descript(LIBUSB_DEVICE* libusb_dev) +{ + LIBUSB_DEVICE_DESCRIPTOR* descriptor; + int ret; + + descriptor = (LIBUSB_DEVICE_DESCRIPTOR*)malloc(sizeof(LIBUSB_DEVICE_DESCRIPTOR)); + + ret = libusb_get_device_descriptor(libusb_dev, descriptor); + if (ret<0){ + printf("libusb_get_device_descriptor: ERROR!!\n"); + return NULL; + } + + return descriptor; +} + + + + /* Get HUB handle */ +static int +udev_get_hub_handle(UDEVICE * pdev, uint16 bus_number, uint16 dev_number) +{ + struct udev *udev; + struct udev_enumerate *enumerate; + struct udev_list_entry *devices, *dev_list_entry; + struct udev_device *dev; + LIBUSB_DEVICE* libusb_dev; + int hub_found = 0; + int hub_bus = 0; + int hub_dev = 0; + int error = 0; + + udev = udev_new(); + if (!udev) { + LLOGLN(0, ("%s: Can't create udev", __func__)); + return -1; + } + + enumerate = udev_enumerate_new(udev); + udev_enumerate_add_match_subsystem(enumerate, "usb"); + udev_enumerate_add_match_property(enumerate, "DEVTYPE", "usb_device"); + udev_enumerate_scan_devices(enumerate); + devices = udev_enumerate_get_list_entry(enumerate); + + udev_list_entry_foreach(dev_list_entry, devices) + { + const char * path; + + path = udev_list_entry_get_name(dev_list_entry); + dev = udev_device_new_from_syspath(udev, path); + if (!dev) continue; + int tmp_b = atoi(udev_device_get_property_value(dev,"BUSNUM")); + int tmp_d = atoi(udev_device_get_property_value(dev,"DEVNUM")); + if (bus_number == tmp_b && dev_number == tmp_d) + { + /* get port number */ + char *p1, *p2; + const char * sysfs_path = + udev_device_get_property_value(dev,"DEVPATH"); + + p1 = (char *)sysfs_path; + do{ + p2 = p1 + 1; + p1 = strchr(p2, '.'); + }while(p1 != NULL); + + if ((p2 - sysfs_path) < (strlen(sysfs_path) - 2)) + { + p1 = (char *)sysfs_path; + do{ + + p2 = p1 + 1; + p1 = strchr(p2, '-'); + }while(p1 != NULL); + } + pdev->port_number = atoi(p2); + LLOGLN(libusb_debug, (" Port: %d", pdev->port_number)); + + /* get device path */ + p1 = (char *)sysfs_path; + do{ + p2 = p1 + 1; + p1 = strchr(p2, '/'); + }while(p1 != NULL); + memset(pdev->path, 0, 17); + strcpy(pdev->path, p2); + LLOGLN(libusb_debug, (" DevPath: %s", pdev->path)); + + /* query parent hub info */ + dev = udev_device_get_parent(dev); + if (dev != NULL) + { + hub_found = 1; + hub_bus = atoi(udev_device_get_property_value(dev,"BUSNUM")); + hub_dev = atoi(udev_device_get_property_value(dev,"DEVNUM")); + LLOGLN(libusb_debug, (" Hub BUS/DEV: %d %d", hub_bus, hub_dev)); + } + udev_device_unref(dev); + break; + } + udev_device_unref(dev); + } + udev_enumerate_unref(enumerate); + udev_unref(udev); + + if (!hub_found) + { + LLOGLN(0, ("%s: hub was not found!", __func__)); + return -1; + } + /* Get libusb hub handle */ + libusb_dev = udev_get_libusb_dev(hub_bus, hub_dev); + if (libusb_dev == NULL) + { + LLOGLN(0, ("%s: get hub libusb_dev fail!", __func__)); + return -1; + } + error = libusb_open (libusb_dev, &pdev->hub_handle); + if (error < 0) + { + LLOGLN(0, ("%s: libusb_open error!", __func__)); + return -1; + } + LLOGLN(libusb_debug, ("%s: libusb_open success!", __func__)); + /* Success! */ + return 0; +} + + + + +static int +libusb_udev_select_interface(IUDEVICE * idev, uint8 InterfaceNumber, uint8 AlternateSetting) +{ + MSUSB_CONFIG_DESCRIPTOR * MsConfig; + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + UDEVICE * pdev = (UDEVICE *) idev; + int error = 0, diff = 1; + + MsConfig = pdev->MsConfig; + if (MsConfig) + { + MsInterfaces = MsConfig->MsInterfaces; + if (MsInterfaces && + MsInterfaces[InterfaceNumber]->AlternateSetting == AlternateSetting) + { + diff = 0; + } + } + + if (diff) + { + error = libusb_set_interface_alt_setting (pdev->libusb_handle, + InterfaceNumber, AlternateSetting); + if (error < 0){ + printf("%s: Set interface altsetting get error num %d\n", + __func__, error); + } + } + + return error; +} + + + + +static MSUSB_CONFIG_DESCRIPTOR * +libusb_udev_complete_msconfig_setup(IUDEVICE * idev, MSUSB_CONFIG_DESCRIPTOR * MsConfig) +{ + UDEVICE * pdev = (UDEVICE *) idev; + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + MSUSB_INTERFACE_DESCRIPTOR * MsInterface; + MSUSB_PIPE_DESCRIPTOR ** MsPipes; + MSUSB_PIPE_DESCRIPTOR * MsPipe; + MSUSB_PIPE_DESCRIPTOR ** t_MsPipes; + MSUSB_PIPE_DESCRIPTOR * t_MsPipe; + LIBUSB_CONFIG_DESCRIPTOR * LibusbConfig; + const LIBUSB_INTERFACE * LibusbInterface; + const LIBUSB_INTERFACE_DESCRIPTOR * LibusbAltsetting; + const LIBUSB_ENDPOINT_DESCEIPTOR * LibusbEndpoint; + uint8 LibusbNumEndpoint; + int inum = 0, pnum = 0, MsOutSize = 0; + + LibusbConfig = pdev->LibusbConfig; + if (LibusbConfig->bNumInterfaces != MsConfig->NumInterfaces) + { + printf("Select Configuration: Libusb NumberInterfaces(%d) is different " + "with MsConfig NumberInterfaces(%d)\n", + LibusbConfig->bNumInterfaces, MsConfig->NumInterfaces); + } + + /* replace MsPipes for libusb */ + MsInterfaces = MsConfig->MsInterfaces; + for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + { + MsInterface = MsInterfaces[inum]; + /* get libusb's number of endpoints */ + LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber]; + LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting]; + LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints; + t_MsPipes = (MSUSB_PIPE_DESCRIPTOR **) malloc ( LibusbNumEndpoint * + sizeof(MSUSB_PIPE_DESCRIPTOR *)); + + for (pnum = 0; pnum < LibusbNumEndpoint; pnum++) + { + t_MsPipe = (MSUSB_PIPE_DESCRIPTOR *) malloc (sizeof(MSUSB_PIPE_DESCRIPTOR)); + memset(t_MsPipe, 0, sizeof(MSUSB_PIPE_DESCRIPTOR)); + + if (pnum < MsInterface->NumberOfPipes && MsInterface->MsPipes) + { + MsPipe = MsInterface->MsPipes[pnum]; + t_MsPipe->MaximumPacketSize = MsPipe->MaximumPacketSize; + t_MsPipe->MaximumTransferSize = MsPipe->MaximumTransferSize; + t_MsPipe->PipeFlags = MsPipe->PipeFlags; + } + else + { + t_MsPipe->MaximumPacketSize = 0; + t_MsPipe->MaximumTransferSize = 0xffffffff; + t_MsPipe->PipeFlags = 0; + } + t_MsPipe->PipeHandle = 0; + t_MsPipe->bEndpointAddress = 0; + t_MsPipe->bInterval = 0; + t_MsPipe->PipeType = 0; + t_MsPipe->InitCompleted = 0; + + t_MsPipes[pnum] = t_MsPipe; + } + + msusb_mspipes_replace(MsInterface, t_MsPipes, LibusbNumEndpoint); + } + /* setup configuration */ + MsOutSize = 8; + /* ConfigurationHandle: 4 bytes + * --------------------------------------------------------------- + * ||<<< 1 byte >>>|<<< 1 byte >>>|<<<<<<<<<< 2 byte >>>>>>>>>>>|| + * || bus_number | dev_number | bConfigurationValue || + * --------------------------------------------------------------- + * ***********************/ + MsConfig->ConfigurationHandle = MsConfig->bConfigurationValue | + (pdev->bus_number << 24) | + (pdev->dev_number << 16); + + MsInterfaces = MsConfig->MsInterfaces; + for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + { + MsOutSize += 16; + MsInterface = MsInterfaces[inum]; + /* get libusb's interface */ + LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber]; + LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting]; + /* InterfaceHandle: 4 bytes + * --------------------------------------------------------------- + * ||<<< 1 byte >>>|<<< 1 byte >>>|<<< 1 byte >>>|<<< 1 byte >>>|| + * || bus_number | dev_number | altsetting | interfaceNum || + * --------------------------------------------------------------- + * ***********************/ + MsInterface->InterfaceHandle = LibusbAltsetting->bInterfaceNumber + | (LibusbAltsetting->bAlternateSetting << 8) + | (pdev->dev_number << 16) + | (pdev->bus_number << 24); + + MsInterface->Length = 16 + (MsInterface->NumberOfPipes * 20); + MsInterface->bInterfaceClass = LibusbAltsetting->bInterfaceClass; + MsInterface->bInterfaceSubClass = LibusbAltsetting->bInterfaceSubClass; + MsInterface->bInterfaceProtocol = LibusbAltsetting->bInterfaceProtocol; + MsInterface->InitCompleted = 1; + + MsPipes = MsInterface->MsPipes; + LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints; + for (pnum = 0; pnum < LibusbNumEndpoint; pnum++) + { + MsOutSize += 20; + MsPipe = MsPipes[pnum]; + /* get libusb's endpoint */ + LibusbEndpoint = &LibusbAltsetting->endpoint[pnum]; + /* PipeHandle: 4 bytes + * --------------------------------------------------------------- + * ||<<< 1 byte >>>|<<< 1 byte >>>|<<<<<<<<<< 2 byte >>>>>>>>>>>|| + * || bus_number | dev_number | bEndpointAddress || + * --------------------------------------------------------------- + * ***********************/ + MsPipe->PipeHandle = LibusbEndpoint->bEndpointAddress + | (pdev->dev_number << 16) + | (pdev->bus_number << 24); + /* count endpoint max packet size */ + int max = LibusbEndpoint->wMaxPacketSize & 0x07ff; + uint8 attr = LibusbEndpoint->bmAttributes; + if ((attr & 0x3) == 1 || (attr & 0x3) == 3) + { + max *= (1 + ((LibusbEndpoint->wMaxPacketSize >> 11) & 3)); + } + MsPipe->MaximumPacketSize = max; + MsPipe->bEndpointAddress = LibusbEndpoint->bEndpointAddress; + MsPipe->bInterval = LibusbEndpoint->bInterval; + MsPipe->PipeType = attr & 0x3; + MsPipe->InitCompleted = 1; + } + } + MsConfig->MsOutSize = MsOutSize; + MsConfig->InitCompleted = 1; + + /* replace device's MsConfig */ + if (!(MsConfig == pdev->MsConfig)) + { + msusb_msconfig_free(pdev->MsConfig); + pdev->MsConfig = MsConfig; + } + + return MsConfig; +} + + + +static int +libusb_udev_select_configuration(IUDEVICE * idev, uint32 bConfigurationValue) +{ + UDEVICE * pdev = (UDEVICE *) idev; + MSUSB_CONFIG_DESCRIPTOR * MsConfig = pdev->MsConfig; + LIBUSB_DEVICE_HANDLE * libusb_handle = pdev->libusb_handle; + LIBUSB_DEVICE * libusb_dev = pdev->libusb_dev; + LIBUSB_CONFIG_DESCRIPTOR ** LibusbConfig = &pdev->LibusbConfig; + int ret = 0; + + if (MsConfig->InitCompleted){ + func_config_release_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); + } + /* The configuration value -1 is mean to put the device in unconfigured state. */ + if (bConfigurationValue == 0) + ret = libusb_set_configuration(libusb_handle, -1); + else + ret = libusb_set_configuration(libusb_handle, bConfigurationValue); + + if (ret < 0){ + printf("libusb_set_configuration: ERROR number %d!!\n", ret); + func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); + return -1; + } + else + { + ret = libusb_get_active_config_descriptor (libusb_dev, LibusbConfig); + if (ret < 0){ + printf("libusb_get_config_descriptor_by_value: ERROR number %d!!\n", ret); + func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); + return -1; + } + } + + func_claim_all_interface(libusb_handle, (*LibusbConfig)->bNumInterfaces); + + return 0; +} + + + +static int +libusb_udev_control_pipe_request(IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 *UsbdStatus, + int command) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int error = 0; + /* + pdev->request_queue->register_request(pdev->request_queue, RequestId, NULL, 0); + */ + switch (command){ + case PIPE_CANCEL: + /** cancel bulk or int transfer */ + idev->cancel_all_transfer_request(idev); + + //dummy_wait_s_obj(1); + /** set feature to ep (set halt)*/ + error = libusb_control_transfer(pdev->libusb_handle, + LIBUSB_ENDPOINT_OUT | LIBUSB_RECIPIENT_ENDPOINT, + LIBUSB_REQUEST_SET_FEATURE, + ENDPOINT_HALT, + EndpointAddress, + NULL, + 0, + 1000); + break; + case PIPE_RESET: + idev->cancel_all_transfer_request(idev); + + error = libusb_clear_halt(pdev->libusb_handle, EndpointAddress); + + //func_set_usbd_status(pdev, UsbdStatus, error); + break; + default: + error = -0xff; + break; + } + + *UsbdStatus = 0; + /* + if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) + printf("request_queue_unregister_request: not fount request 0x%x\n", RequestId); + */ + return error; +} + + +static int +libusb_udev_control_query_device_text(IUDEVICE * idev, uint32 TextType, + uint32 LocaleId, + uint32 * BufferSize, + uint8 * Buffer) +{ + UDEVICE * pdev = (UDEVICE *) idev; + LIBUSB_DEVICE_DESCRIPTOR * devDescriptor = pdev->devDescriptor; + char * strDesc = "Generic Usb String"; + char deviceLocation[25]; + uint8 bus_number; + uint8 device_address; + int ret = 0, i = 0; + + switch (TextType){ + case DeviceTextDescription: + ret = libusb_get_string_descriptor (pdev->libusb_handle, + devDescriptor->iProduct, + LocaleId, + Buffer, + *BufferSize); + + for(i = 0; i < ret; i++) + { + Buffer[i] = Buffer[i+2]; + } + ret -= 2; + + if (ret <= 0 || ret < 4){ + LLOGLN(libusb_debug, ("libusb_get_string_descriptor: " + "ERROR num %d, iProduct: %d!", ret, devDescriptor->iProduct)); + memcpy(Buffer, strDesc, strlen(strDesc)); + Buffer[strlen(strDesc)] = '\0'; + *BufferSize = (strlen((char *)Buffer)) * 2; + for (i = strlen((char *)Buffer); i > 0; i--) + { + Buffer[i*2] = Buffer[i]; + Buffer[(i*2)-1] = 0; + } + } + else + { + *BufferSize = ret; + } + + break; + case DeviceTextLocationInformation: + bus_number = libusb_get_bus_number(pdev->libusb_dev); + device_address = libusb_get_device_address(pdev->libusb_dev); + sprintf(deviceLocation, "Port_#%04d.Hub_#%04d", device_address, bus_number); + + for(i=0;irequest_queue->register_request(pdev->request_queue, RequestId, NULL, 0); + */ + memset(ms_string_desc, 0, 0x13); + error = libusb_control_transfer(pdev->libusb_handle, + LIBUSB_ENDPOINT_IN | Recipient, + LIBUSB_REQUEST_GET_DESCRIPTOR, + 0x03ee, + 0, + ms_string_desc, + 0x12, + Timeout); + //printf("Get ms string: result number %d", error); + if (error > 0) + { + uint8 bMS_Vendorcode; + data_read_uint8(ms_string_desc + 16, bMS_Vendorcode); + //printf("bMS_Vendorcode:0x%x", bMS_Vendorcode); + /** get os descriptor */ + error = libusb_control_transfer(pdev->libusb_handle, + LIBUSB_ENDPOINT_IN |LIBUSB_REQUEST_TYPE_VENDOR | Recipient, + bMS_Vendorcode, + (InterfaceNumber << 8) | Ms_PageIndex, + Ms_featureDescIndex, + Buffer, + *BufferSize, + Timeout); + *BufferSize = error; + } + + if (error < 0) + *UsbdStatus = USBD_STATUS_STALL_PID; + else + *UsbdStatus = USBD_STATUS_SUCCESS; + /* + if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) + printf("request_queue_unregister_request: not fount request 0x%x\n", RequestId); + */ + return error; +} + + + +static int +libusb_udev_query_device_descriptor(IUDEVICE * idev, int offset) +{ + UDEVICE * pdev = (UDEVICE *) idev; + switch (offset) + { + case B_LENGTH: + return pdev->devDescriptor->bLength; + case B_DESCRIPTOR_TYPE: + return pdev->devDescriptor->bDescriptorType; + case BCD_USB: + return pdev->devDescriptor->bcdUSB; + case B_DEVICE_CLASS: + return pdev->devDescriptor->bDeviceClass; + case B_DEVICE_SUBCLASS: + return pdev->devDescriptor->bDeviceSubClass; + case B_DEVICE_PROTOCOL: + return pdev->devDescriptor->bDeviceProtocol; + case B_MAX_PACKET_SIZE0: + return pdev->devDescriptor->bMaxPacketSize0; + case ID_VENDOR: + return pdev->devDescriptor->idVendor; + case ID_PRODUCT: + return pdev->devDescriptor->idProduct; + case BCD_DEVICE: + return pdev->devDescriptor->bcdDevice; + case I_MANUFACTURER: + return pdev->devDescriptor->iManufacturer; + case I_PRODUCT: + return pdev->devDescriptor->iProduct; + case I_SERIAL_NUMBER: + return pdev->devDescriptor->iSerialNumber; + case B_NUM_CONFIGURATIONS: + return pdev->devDescriptor->bNumConfigurations; + default: + return 0; + } + return 0; +} + + +static void +libusb_udev_detach_kernel_driver(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int i, err = 0; + if ((pdev->status & URBDRC_DEVICE_DETACH_KERNEL) == 0) + { + for (i = 0; i < pdev->LibusbConfig->bNumInterfaces; i++) + { + err = libusb_kernel_driver_active(pdev->libusb_handle , i); + LLOGLN(libusb_debug, ("libusb_kernel_driver_active = %d\n", err)); + if (err){ + err = libusb_detach_kernel_driver(pdev->libusb_handle , i); + LLOGLN(libusb_debug, ("libusb_detach_kernel_driver = %d\n", err)); + } + } + + pdev->status |= URBDRC_DEVICE_DETACH_KERNEL; + } +} + + +static void +libusb_udev_attach_kernel_driver(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int i, err = 0; + for (i = 0; i < pdev->LibusbConfig->bNumInterfaces && err != LIBUSB_ERROR_NO_DEVICE; i++) + { + err = libusb_release_interface (pdev->libusb_handle, i); + if (err < 0){ + LLOGLN(libusb_debug, ("libusb_release_interface: error num %d = %d", i, err)); + } + if (err != LIBUSB_ERROR_NO_DEVICE) + { + err = libusb_attach_kernel_driver (pdev->libusb_handle , i); + LLOGLN(libusb_debug, ("libusb_attach_kernel_driver if%d = %d", i, err)); + } + } +} + + +static int +libusb_udev_is_composite_device(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return pdev->isCompositeDevice; +} + + +static int +libusb_udev_is_signal_end(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return (pdev->status & URBDRC_DEVICE_SIGNAL_END) ? 1 : 0; +} + +static int +libusb_udev_is_exist(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return (pdev->status & URBDRC_DEVICE_NOT_FOUND) ? 0 : 1; +} + + +static int +libusb_udev_is_channel_closed(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return (pdev->status & URBDRC_DEVICE_CHANNEL_CLOSED) ? 1 : 0; +} + + +static int +libusb_udev_is_already_send(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return (pdev->status & URBDRC_DEVICE_ALREADY_SEND) ? 1 : 0; +} + + +static void +libusb_udev_signal_end(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + pdev->status |= URBDRC_DEVICE_SIGNAL_END; +} + +static void +libusb_udev_channel_closed(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + pdev->status |= URBDRC_DEVICE_CHANNEL_CLOSED; +} + + +static void +libusb_udev_set_already_send(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + pdev->status |= URBDRC_DEVICE_ALREADY_SEND; +} + +static char * +libusb_udev_get_path(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + return pdev->path; +} + +static int +libusb_udev_wait_action_completion(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int error, sval; + while(1) + { + usleep(500000); + error = sem_getvalue(&pdev->sem_id, &sval); + if(sval == 0) + break; + } + return error; +} + +static void +libusb_udev_push_action(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + sem_post(&pdev->sem_id); +} + +static void +libusb_udev_complete_action(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + sem_trywait(&pdev->sem_id); +} + +static int +libusb_udev_wait_for_detach(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int error = 0; + int times = 0; + + while(times < 25) + { + if(pdev->status & URBDRC_DEVICE_SIGNAL_END) + { + error = -1; + break; + } + usleep(200000); + times++; + } + + return error; +} + + +static void +libusb_udev_lock_fifo_isoch(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + pthread_mutex_lock(&pdev->mutex_isoch); +} + +static void +libusb_udev_unlock_fifo_isoch(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + pthread_mutex_unlock(&pdev->mutex_isoch); +} + + +static int +libusb_udev_query_device_port_status(IUDEVICE * idev, uint32 *UsbdStatus, + uint32 * BufferSize, + uint8 * Buffer) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int success = 0, ret; + + if (pdev->hub_handle != NULL) + { + ret = idev->control_transfer(idev, 0xffff, 0, 0, + LIBUSB_ENDPOINT_IN + | LIBUSB_REQUEST_TYPE_CLASS + | LIBUSB_RECIPIENT_OTHER, + LIBUSB_REQUEST_GET_STATUS, + 0, + pdev->port_number, + UsbdStatus, + BufferSize, + Buffer, + 1000); + + if (ret < 0){ + LLOGLN(libusb_debug, ("libusb_control_transfer: error num %d", ret)); + *BufferSize = 0; + } + else{ + LLOGLN(libusb_debug, ("PORT STATUS:0x%02x%02x%02x%02x", + Buffer[3], Buffer[2], Buffer[1], Buffer[0])); + success = 1; + } + } + return success; +} + + +static int +libusb_udev_request_queue_is_none(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + if (pdev->request_queue->request_num == 0) + return 1; + return 0; +} + + +static int +libusb_udev_isoch_transfer(IUDEVICE * idev, uint32 RequestId, uint32 EndpointAddress, + uint32 TransferFlags, + int NoAck, + uint32 *ErrorCount, + uint32 *UrbdStatus, + uint32 *StartFrame, + uint32 NumberOfPackets, + uint8 *IsoPacket, + uint32 *BufferSize, + uint8 *Buffer, + int Timeout) +{ + UDEVICE * pdev = (UDEVICE *) idev; + ISO_USER_DATA iso_user_data; + struct libusb_transfer * iso_transfer = NULL; + uint32 iso_packet_size; + int error = 0, ret = 0, submit = 0; + + + iso_packet_size = *BufferSize / NumberOfPackets; + + iso_transfer = libusb_alloc_transfer(NumberOfPackets); + if (iso_transfer == NULL) { + printf("Error: libusb_alloc_transfer.\n"); + error = -1; + } + + /** process URB_FUNCTION_IOSCH_TRANSFER */ + func_iso_data_init(&iso_user_data, NumberOfPackets, *BufferSize, + NoAck, IsoPacket, Buffer); + /** fill setting */ + libusb_fill_iso_transfer(iso_transfer, + pdev->libusb_handle, + EndpointAddress, + Buffer, + *BufferSize, + NumberOfPackets, + func_iso_callback, + &iso_user_data, + TransferFlags, + 2000); + + libusb_set_iso_packet_lengths(iso_transfer, iso_packet_size); + + if(pdev->status & (URBDRC_DEVICE_SIGNAL_END | URBDRC_DEVICE_NOT_FOUND)) + error = -1; + iso_user_data.iso_status = 0; + if (!(error < 0)) + { + submit = libusb_submit_transfer(iso_transfer); + if (submit < 0) { + LLOGLN(libusb_debug, ("Error: Failed to submit transfer (ret = %d).", submit)); + error = -1; + func_set_usbd_status(pdev, UrbdStatus, ret); + } + } + +#if ISOCH_FIFO + if(!NoAck){ + idev->unlock_fifo_isoch(idev); + } +#endif + + while(pdev && iso_user_data.iso_status == 0 && error >= 0 && submit >= 0) + { + if (pdev->status & URBDRC_DEVICE_NOT_FOUND){ + error = -1; + break; + } + ret = handle_events_completed(NULL, &iso_user_data.completed); + if (ret < 0) { + LLOGLN(libusb_debug, ("Error: libusb_handle_events (ret = %d).", ret)); + error = -1; + break; + } +#if WAIT_COMPLETE_SLEEP + if (iso_user_data.iso_status == 0) + { + usleep(WAIT_COMPLETE_SLEEP); + } +#endif + } + + if (iso_user_data.iso_status < 0) + error = -1; + + *ErrorCount = iso_user_data.error_count; + *StartFrame = iso_user_data.start_frame; + *BufferSize = iso_transfer->actual_length; + libusb_free_transfer(iso_transfer); + + return error; +} + + +static int +libusb_udev_control_transfer(IUDEVICE * idev, uint32 RequestId, uint32 EndpointAddress, + uint32 TransferFlags, + uint8 bmRequestType, + uint8 Request, + uint16 Value, + uint16 Index, + uint32 *UrbdStatus, + uint32 *BufferSize, + uint8 *Buffer, + uint32 Timeout) +{ + UDEVICE * pdev = (UDEVICE *) idev; + int error = 0; + /* + pdev->request_queue->register_request(pdev->request_queue, + RequestId, NULL, 0); + */ + error = libusb_control_transfer(pdev->libusb_handle, + bmRequestType, + Request, + Value, + Index, + Buffer, + *BufferSize, + Timeout); + if (!(error < 0)) + *BufferSize = error; + func_set_usbd_status(pdev, UrbdStatus, error); + /* + if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) + printf("request_queue_unregister_request: not fount request 0x%x\n", RequestId); + */ + return error; +} + + +static int +libusb_udev_bulk_or_interrupt_transfer(IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 TransferFlags, + uint32 *UsbdStatus, + uint32 *BufferSize, + uint8 *Buffer, + uint32 Timeout) +{ + UDEVICE * pdev = (UDEVICE *) idev; + const LIBUSB_ENDPOINT_DESCEIPTOR * ep_desc; + struct libusb_transfer * transfer = NULL; + TRANSFER_REQUEST * request = NULL; + uint32 transfer_type; + int completed = 0, ret = 0, submit = 0; + int transferDir = EndpointAddress & 0x80; + + /** alloc memory for urb transfer */ + transfer = libusb_alloc_transfer(0); + + ep_desc = func_get_ep_desc(pdev->LibusbConfig, pdev->MsConfig, EndpointAddress); + + if(!ep_desc){ + printf("func_get_ep_desc: endpoint 0x%x is not found!!\n", EndpointAddress); + return -1; + } + transfer_type = (ep_desc->bmAttributes) & 0x3; + + LLOGLN(libusb_debug, ("urb_bulk_or_interrupt_transfer: ep:0x%x " + "transfer_type %d flag:%d OutputBufferSize:0x%x", + EndpointAddress, transfer_type, TransferFlags, *BufferSize)); + + switch (transfer_type){ + case BULK_TRANSFER: + /** Bulk Transfer */ + //Timeout = 10000; + break; + case INTERRUPT_TRANSFER: + /** Interrupt Transfer */ + /** Sometime, we may have receive a oversized transfer request, + * it make submit urb return error, so we set the length of + * request to wMaxPacketSize */ + if (*BufferSize != (ep_desc->wMaxPacketSize)) + { + LLOGLN(libusb_debug, ("Interrupt Transfer(%s): " + "BufferSize is different than maxPacketsize(0x%x)", + ((transferDir)?"IN":"OUT"), ep_desc->wMaxPacketSize)); + if((*BufferSize) > (ep_desc->wMaxPacketSize) && + transferDir == USBD_TRANSFER_DIRECTION_IN) + (*BufferSize) = ep_desc->wMaxPacketSize; + } + Timeout = 0; + break; + default: + LLOGLN(0, ("urb_bulk_or_interrupt_transfer:" + " other transfer type 0x%X", transfer_type)); + return -1; + break; + } + + + libusb_fill_bulk_transfer(transfer, + pdev->libusb_handle, + EndpointAddress, + Buffer, + *BufferSize, + func_bulk_transfer_cb, + &completed, + TransferFlags, + Timeout); + + transfer->type = (unsigned char)transfer_type; + + /** Bug fixed in libusb-1.0-8 later: issue of memory crash */ + submit = libusb_submit_transfer(transfer); + if (submit < 0) { + LLOGLN(libusb_debug, ("libusb_bulk_transfer: error num %d", ret)); + func_set_usbd_status(pdev, UsbdStatus, ret); + *BufferSize = 0; + } + else + { + + request = pdev->request_queue->register_request( + pdev->request_queue, + RequestId, + transfer, + EndpointAddress); + request->submit = 1; + } + + if(pdev && *UsbdStatus == 0 && submit >= 0 && + pdev->iface.isSigToEnd((IUDEVICE*)pdev) == 0) + { + while (!completed) { + //ret = libusb_handle_events_check(NULL, &completed); + ret = handle_events_completed(NULL, &completed); + if (ret < 0) { + if (ret == LIBUSB_ERROR_INTERRUPTED) + continue; + libusb_cancel_transfer(transfer); + while (!completed) + { + if (handle_events_completed(NULL, &completed) < 0) + break; +#if WAIT_COMPLETE_SLEEP + if (!completed) + usleep(WAIT_COMPLETE_SLEEP); +#endif + } + break; + } +#if WAIT_COMPLETE_SLEEP + if (!completed) + usleep(WAIT_COMPLETE_SLEEP); +#endif + } + switch (transfer->status) { + case LIBUSB_TRANSFER_COMPLETED: + func_set_usbd_status(pdev, UsbdStatus, 0); + break; + case LIBUSB_TRANSFER_TIMED_OUT: + func_set_usbd_status(pdev, UsbdStatus, LIBUSB_ERROR_TIMEOUT); + break; + case LIBUSB_TRANSFER_STALL: + func_set_usbd_status(pdev, UsbdStatus, LIBUSB_ERROR_PIPE); + break; + case LIBUSB_TRANSFER_OVERFLOW: + func_set_usbd_status(pdev, UsbdStatus, LIBUSB_ERROR_OVERFLOW); + break; + case LIBUSB_TRANSFER_NO_DEVICE: + func_set_usbd_status(pdev, UsbdStatus, LIBUSB_ERROR_NO_DEVICE); + break; + default: + func_set_usbd_status(pdev, UsbdStatus, LIBUSB_ERROR_OTHER); + } + + *BufferSize = transfer->actual_length; + } + LLOGLN(libusb_debug, ("bulk or interrupt Transfer data size : 0x%x", *BufferSize)); + + if (request) + { + if(pdev->request_queue->unregister_request(pdev->request_queue, RequestId)) + printf("request_queue_unregister_request: not fount request 0x%x\n", RequestId); + } + + libusb_free_transfer(transfer); + + return 0; +} + + + +static void +libusb_udev_cancel_all_transfer_request(IUDEVICE * idev) +{ + UDEVICE * pdev = (UDEVICE *) idev; + REQUEST_QUEUE * request_queue = pdev->request_queue; + TRANSFER_REQUEST * request = NULL; + int ret; + pthread_mutex_lock(&request_queue->request_loading); + + request_queue->rewind (request_queue); + while (request_queue->has_next (request_queue)) + { + request = request_queue->get_next (request_queue); + + if (!request || + !request->transfer || + request->endpoint != request->transfer->endpoint || + request->transfer->endpoint == 0 || + request->submit != 1) + { + continue; + } + + ret = libusb_cancel_transfer(request->transfer); + if (ret < 0){ + LLOGLN(libusb_debug, ("libusb_cancel_transfer: error num %d!!\n", ret)); + } + else + { + request->submit = -1; + } + + } + pthread_mutex_unlock(&request_queue->request_loading); +} + + +static int +func_cancel_xact_request(TRANSFER_REQUEST *request) +{ + int ret; + + if (!request->transfer || + request->endpoint != request->transfer->endpoint || + request->transfer->endpoint == 0 || + request->submit != 1) + { + return 0; + } + + ret = libusb_cancel_transfer(request->transfer); + if (ret < 0){ + LLOGLN(0, ("libusb_cancel_transfer: error num %d!!", ret)); + if(ret == LIBUSB_ERROR_NOT_FOUND) + return -1; + } + else + { + LLOGLN(libusb_debug, ("libusb_cancel_transfer: Success num:0x%x!!", + request->RequestId)); + request->submit = -1; + return 1; + } + return 0; +} + + +static int +libusb_udev_cancel_transfer_request(IUDEVICE * idev, uint32 RequestId) +{ + UDEVICE * pdev = (UDEVICE *) idev; + REQUEST_QUEUE * request_queue = pdev->request_queue; + TRANSFER_REQUEST * request = NULL; + int success = 0, retry_times = 0; + +cancel_retry: + pthread_mutex_lock(&request_queue->request_loading); + + request_queue->rewind (request_queue); + while (request_queue->has_next (request_queue)) + { + request = request_queue->get_next (request_queue); + LLOGLN(libusb_debug, ("%s: CancelId:0x%x RequestId:0x%x endpoint 0x%x!!", + __func__, RequestId, request->RequestId, request->endpoint)); + if (request && request->RequestId == RequestId && retry_times <= 10 ) + { + success = func_cancel_xact_request(request); + break; + } + else if(request->transfer && retry_times > 10){ + success = -1; + break; + } + } + pthread_mutex_unlock(&request_queue->request_loading); + if (success == 0 && retry_times < 10){ + retry_times++; + usleep(100000); + LLOGLN(10, ("urbdrc_process_cancel_request: go retry!!")); + goto cancel_retry; + } + else if(success < 0 || retry_times >= 10){ + /** END */ + LLOGLN(libusb_debug, ("urbdrc_process_cancel_request: error go exit!!")); + return -1; + } + LLOGLN(libusb_debug, ("urbdrc_process_cancel_request: success!!")); + + return 0; +} + +BASIC_STATE_FUNC_DEFINED(channel_id, uint32) +BASIC_STATE_FUNC_DEFINED(UsbDevice, uint32) +BASIC_STATE_FUNC_DEFINED(ReqCompletion, uint32) +BASIC_STATE_FUNC_DEFINED(bus_number, uint16) +BASIC_STATE_FUNC_DEFINED(dev_number, uint16) +BASIC_STATE_FUNC_DEFINED(port_number, int) +BASIC_STATE_FUNC_DEFINED(isoch_queue, void *) +BASIC_STATE_FUNC_DEFINED(MsConfig, MSUSB_CONFIG_DESCRIPTOR *) + +BASIC_POINT_FUNC_DEFINED(udev, void *) +BASIC_POINT_FUNC_DEFINED(prev, void *) +BASIC_POINT_FUNC_DEFINED(next, void *) + + + +static void +udev_load_interface(UDEVICE * pdev) +{ + /* load interface */ + + /* Basic */ + BASIC_STATE_FUNC_REGISTER(channel_id, pdev); + BASIC_STATE_FUNC_REGISTER(UsbDevice, pdev); + BASIC_STATE_FUNC_REGISTER(ReqCompletion, pdev); + BASIC_STATE_FUNC_REGISTER(bus_number, pdev); + BASIC_STATE_FUNC_REGISTER(dev_number, pdev); + BASIC_STATE_FUNC_REGISTER(port_number, pdev); + BASIC_STATE_FUNC_REGISTER(isoch_queue, pdev); + BASIC_STATE_FUNC_REGISTER(MsConfig, pdev); + + BASIC_STATE_FUNC_REGISTER(p_udev, pdev); + BASIC_STATE_FUNC_REGISTER(p_prev, pdev); + BASIC_STATE_FUNC_REGISTER(p_next, pdev); + + pdev->iface.isCompositeDevice = libusb_udev_is_composite_device; + pdev->iface.isSigToEnd = libusb_udev_is_signal_end; + pdev->iface.isExist = libusb_udev_is_exist; + pdev->iface.isAlreadySend = libusb_udev_is_already_send; + pdev->iface.isChannelClosed = libusb_udev_is_channel_closed; + pdev->iface.SigToEnd = libusb_udev_signal_end; + pdev->iface.setAlreadySend = libusb_udev_set_already_send; + pdev->iface.setChannelClosed = libusb_udev_channel_closed; + pdev->iface.getPath = libusb_udev_get_path; + + /* Transfer */ + pdev->iface.isoch_transfer = libusb_udev_isoch_transfer; + pdev->iface.control_transfer = libusb_udev_control_transfer; + pdev->iface.bulk_or_interrupt_transfer = libusb_udev_bulk_or_interrupt_transfer; + + pdev->iface.select_interface = libusb_udev_select_interface; + pdev->iface.select_configuration = libusb_udev_select_configuration; + pdev->iface.complete_msconfig_setup = libusb_udev_complete_msconfig_setup; + pdev->iface.control_pipe_request = libusb_udev_control_pipe_request; + pdev->iface.control_query_device_text = libusb_udev_control_query_device_text; + pdev->iface.os_feature_descriptor_request = libusb_udev_os_feature_descriptor_request; + pdev->iface.cancel_all_transfer_request = libusb_udev_cancel_all_transfer_request; + pdev->iface.cancel_transfer_request = libusb_udev_cancel_transfer_request; + pdev->iface.query_device_descriptor = libusb_udev_query_device_descriptor; + pdev->iface.detach_kernel_driver = libusb_udev_detach_kernel_driver; + pdev->iface.attach_kernel_driver = libusb_udev_attach_kernel_driver; + pdev->iface.wait_action_completion = libusb_udev_wait_action_completion; + pdev->iface.push_action = libusb_udev_push_action; + pdev->iface.complete_action = libusb_udev_complete_action; + pdev->iface.lock_fifo_isoch = libusb_udev_lock_fifo_isoch; + pdev->iface.unlock_fifo_isoch = libusb_udev_unlock_fifo_isoch; + pdev->iface.query_device_port_status = libusb_udev_query_device_port_status; + pdev->iface.request_queue_is_none = libusb_udev_request_queue_is_none; + pdev->iface.wait_for_detach = libusb_udev_wait_for_detach; +} + + + + +static IUDEVICE* +udev_init(UDEVICE* pdev, uint16 bus_number, uint16 dev_number) +{ + LIBUSB_DEVICE_DESCRIPTOR* devDescriptor; + LIBUSB_CONFIG_DESCRIPTOR* config_temp; + LIBUSB_INTERFACE_DESCRIPTOR interface_temp; + int ret, num; + + /* Get HUB handle */ + ret = udev_get_hub_handle(pdev, bus_number, dev_number); + if (ret < 0) + { + printf("USB init: Error to get HUB handle!!\n"); + pdev->hub_handle = NULL; + } + + pdev->devDescriptor = udev_new_descript(pdev->libusb_dev); + if (!pdev->devDescriptor) + { + printf("USB init: Error to get device descriptor!!\n"); + zfree(pdev); + return NULL; + } + + num = pdev->devDescriptor->bNumConfigurations; + + ret = libusb_get_active_config_descriptor (pdev->libusb_dev, &pdev->LibusbConfig); + if (ret<0){ + printf("libusb_get_descriptor: ERROR!!ret:%d\n", ret); + zfree(pdev); + return NULL; + } + config_temp = pdev->LibusbConfig; + /* get the first interface and first altsetting */ + interface_temp = config_temp->interface[0].altsetting[0]; + + LLOGLN(0, ("Regist Device: Vid: 0x%04X Pid: 0x%04X" + " InterfaceClass = 0x%X", + pdev->devDescriptor->idVendor, + pdev->devDescriptor->idProduct, + interface_temp.bInterfaceClass)); + /* Denied list */ + switch(interface_temp.bInterfaceClass) + { + case CLASS_RESERVE: + //case CLASS_COMMUNICATION_IF: + //case CLASS_HID: + //case CLASS_PHYSICAL: + case CLASS_MASS_STORAGE: + case CLASS_HUB: + //case CLASS_COMMUNICATION_DATA_IF: + case CLASS_SMART_CARD: + case CLASS_CONTENT_SECURITY: + //case CLASS_WIRELESS_CONTROLLER: + //case CLASS_ELSE_DEVICE: + printf(" Device is not support!!\n"); + zfree(pdev); + return NULL; + default: + break; + } + + /* Check composite device */ + devDescriptor = pdev->devDescriptor; + if(devDescriptor->bNumConfigurations == 1 && + config_temp->bNumInterfaces > 1 && + devDescriptor->bDeviceClass == 0x0) + { + pdev->isCompositeDevice = 1; + } + else if(devDescriptor->bDeviceClass == 0xef && + devDescriptor->bDeviceSubClass == 0x02 && + devDescriptor->bDeviceProtocol == 0x01 ) + { + pdev->isCompositeDevice = 1; + } + else + { + pdev->isCompositeDevice = 0; + } + + /* set device class to first interface class */ + devDescriptor->bDeviceClass = interface_temp.bInterfaceClass; + devDescriptor->bDeviceSubClass = interface_temp.bInterfaceSubClass; + devDescriptor->bDeviceProtocol = interface_temp.bInterfaceProtocol; + + /* initialize pdev */ + pdev->prev = NULL; + pdev->next = NULL; + pdev->bus_number = bus_number; + pdev->dev_number = dev_number; + pdev->status = 0; + pdev->ReqCompletion = 0; + pdev->channel_id = 0xffff; + pdev->request_queue = request_queue_new(); + pdev->isoch_queue = NULL; + sem_init(&pdev->sem_id, 0, 0); + /* set config of windows */ + pdev->MsConfig = msusb_msconfig_new(); + + pthread_mutex_init(&pdev->mutex_isoch, NULL); + + //deb_config_msg(pdev->libusb_dev, config_temp, devDescriptor->bNumConfigurations); + + udev_load_interface(pdev); + + return (IUDEVICE *)pdev; +} + + + +int +udev_new_by_id(uint16 idVendor, uint16 idProduct, IUDEVICE *** devArray) +{ + LIBUSB_DEVICE_DESCRIPTOR * descriptor; + LIBUSB_DEVICE ** libusb_list; + UDEVICE ** array; + uint16 bus_number; + uint16 dev_number; + ssize_t total_device; + int i, ret, num = 0; + + array = (UDEVICE **) malloc (16 * sizeof (UDEVICE *)); + + total_device = libusb_get_device_list(NULL, &libusb_list); + for (i = 0; i < total_device; i++) + { + descriptor = udev_new_descript(libusb_list[i]); + if(descriptor->idVendor == idVendor && + descriptor->idProduct == idProduct) + { + bus_number = 0; + dev_number = 0; + array[num] = (PUDEVICE)malloc(sizeof(UDEVICE)); + array[num]->libusb_dev = libusb_list[i]; + ret = libusb_open (libusb_list[i], &array[num]->libusb_handle); + if (ret < 0){ + printf("libusb_open: ERROR!!\n"); + zfree(descriptor); + zfree(array[num]); + continue; + } + bus_number = libusb_get_bus_number (libusb_list[i]); + dev_number = libusb_get_device_address (libusb_list[i]); + array[num] = (PUDEVICE)udev_init(array[num], bus_number, dev_number); + if (array[num] != NULL) + num++; + } + zfree(descriptor); + } + libusb_free_device_list(libusb_list, 1); + + *devArray = (IUDEVICE **)array; + return num; +} + +IUDEVICE * +udev_new_by_addr(int bus_number, int dev_number) +{ + UDEVICE* pDev; + int ret; + + LLOGLN(10, ("bus:%d dev:%d\n", bus_number, dev_number)); + + pDev = (PUDEVICE)malloc(sizeof(UDEVICE)); + + pDev->libusb_dev = udev_get_libusb_dev(bus_number, dev_number); + if (pDev->libusb_dev == NULL){ + printf("libusb_device_new: ERROR!!\n"); + zfree(pDev); + return NULL; + } + + ret = libusb_open (pDev->libusb_dev, &pDev->libusb_handle); + if (ret < 0){ + printf("libusb_open: ERROR!!\n"); + zfree(pDev); + return NULL; + } + + return udev_init(pDev, bus_number, dev_number); +} diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevice.h b/channels/drdynvc/urbdrc/libusb/libusb_udevice.h new file mode 100644 index 000000000..e75dc18f1 --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/libusb_udevice.h @@ -0,0 +1,86 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __LIBUSB_UDEVICE_H +#define __LIBUSB_UDEVICE_H + +#include + +#include "urbdrc_types.h" +#include "request_queue.h" +#include "urbdrc_main.h" + + + +typedef struct libusb_device LIBUSB_DEVICE; +typedef struct libusb_device_handle LIBUSB_DEVICE_HANDLE; +typedef struct libusb_device_descriptor LIBUSB_DEVICE_DESCRIPTOR; +typedef struct libusb_config_descriptor LIBUSB_CONFIG_DESCRIPTOR; +typedef struct libusb_interface LIBUSB_INTERFACE; +typedef struct libusb_interface_descriptor LIBUSB_INTERFACE_DESCRIPTOR; +typedef struct libusb_endpoint_descriptor LIBUSB_ENDPOINT_DESCEIPTOR; + + +typedef struct _UDEVICE UDEVICE; +struct _UDEVICE +{ + IUDEVICE iface; + + void * udev; + void * prev; + void * next; + + uint32 UsbDevice; /* An unique interface ID */ + uint32 ReqCompletion; /* An unique interface ID */ + uint32 channel_id; + uint16 status; + uint16 bus_number; + uint16 dev_number; + char path[17]; + int port_number; + int isCompositeDevice; + + LIBUSB_DEVICE_HANDLE * libusb_handle; + LIBUSB_DEVICE_HANDLE * hub_handle; + LIBUSB_DEVICE * libusb_dev; + LIBUSB_DEVICE_DESCRIPTOR * devDescriptor; + MSUSB_CONFIG_DESCRIPTOR * MsConfig; + LIBUSB_CONFIG_DESCRIPTOR * LibusbConfig; + + REQUEST_QUEUE * request_queue; + /* Used in isochronous transfer */ + void * isoch_queue; + + pthread_mutex_t mutex_isoch; + sem_t sem_id; +}; +typedef UDEVICE * PUDEVICE; + + +int +udev_new_by_id(uint16_t idVendor, uint16_t idProduct, IUDEVICE ***devArray); +IUDEVICE* +udev_new_by_addr(int bus_number, int dev_number); + +extern int libusb_debug; + +#endif /* __LIBUSB_UDEVICE_H */ diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevman.c b/channels/drdynvc/urbdrc/libusb/libusb_udevman.c new file mode 100644 index 000000000..5e31fb66a --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/libusb_udevman.c @@ -0,0 +1,567 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + + +#include "urbdrc_types.h" +#include "urbdrc_main.h" +#include "libusb_udevice.h" + +int libusb_debug; + +#define BASIC_STATE_FUNC_DEFINED(_arg, _type) \ +static _type udevman_get_##_arg (IUDEVMAN * idevman) \ +{ \ + UDEVMAN * udevman = (UDEVMAN *) idevman; \ + return udevman->_arg; \ +} \ +static void udevman_set_##_arg (IUDEVMAN * idevman, _type _t) \ +{ \ + UDEVMAN * udevman = (UDEVMAN *) idevman; \ + udevman->_arg = _t; \ +} + +#define BASIC_STATE_FUNC_REGISTER(_arg, _man) \ + _man->iface.get_##_arg = udevman_get_##_arg; \ + _man->iface.set_##_arg = udevman_set_##_arg + + +typedef struct _UDEVMAN UDEVMAN; +struct _UDEVMAN +{ + IUDEVMAN iface; + + IUDEVICE* idev; /* iterator device */ + IUDEVICE* head; /* head device in linked list */ + IUDEVICE* tail; /* tail device in linked list */ + + uint32 defUsbDevice; + uint16 flags; + int device_num; + int sem_timeout; + + pthread_mutex_t devman_loading; + sem_t sem_urb_lock; +}; +typedef UDEVMAN * PUDEVMAN; + + + +static void +udevman_rewind(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + udevman->idev = udevman->head; +} + +static int +udevman_has_next(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + if (udevman->idev == NULL) + return 0; + else + return 1; +} + +static IUDEVICE* +udevman_get_next(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + IUDEVICE* pdev; + + pdev = udevman->idev; + udevman->idev = (IUDEVICE*) ((UDEVICE*)udevman->idev)->next; + + return pdev; +} + + +static IUDEVICE* +udevman_get_udevice_by_addr(IUDEVMAN * idevman, int bus_number, int dev_number) +{ + IUDEVICE * pdev; + + idevman->loading_lock(idevman); + idevman->rewind (idevman); + while (idevman->has_next (idevman)) + { + pdev = idevman->get_next (idevman); + if (pdev->get_bus_number(pdev) == bus_number && + pdev->get_dev_number(pdev) == dev_number) + { + idevman->loading_unlock(idevman); + return pdev; + } + } + idevman->loading_unlock(idevman); + LLOGLN(libusb_debug, ("%s: bus:%d dev:%d not exist in udevman", + __func__, bus_number, dev_number)); + return NULL; +} + + + +static int +udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_number, + int UsbDevice, + uint16 idVendor, + uint16 idProduct, + int flag) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + IUDEVICE * pdev = NULL; + IUDEVICE ** devArray; + int i, num, addnum = 0; + + pdev = (IUDEVICE *)udevman_get_udevice_by_addr(idevman, bus_number, dev_number); + if (pdev != NULL) + return 0; + + if (flag == UDEVMAN_FLAG_ADD_BY_ADDR) + { + pdev = udev_new_by_addr(bus_number, dev_number); + if (pdev == NULL) + return 0; + + pdev->set_UsbDevice(pdev, UsbDevice); + idevman->loading_lock(idevman); + if (udevman->head == NULL) + { + /* linked list is empty */ + udevman->head = pdev; + udevman->tail = pdev; + } + else + { + /* append device to the end of the linked list */ + udevman->tail->set_p_next(udevman->tail, pdev); + pdev->set_p_prev(pdev, udevman->tail); + udevman->tail = pdev; + } + udevman->device_num += 1; + idevman->loading_unlock(idevman); + } + else if (flag == UDEVMAN_FLAG_ADD_BY_VID_PID) + { + addnum = 0; + /* register all device that match pid vid */ + num = udev_new_by_id(idVendor, idProduct, &devArray); + for (i = 0; i < num; i++) + { + pdev = devArray[i]; + if (udevman_get_udevice_by_addr(idevman, + pdev->get_bus_number(pdev), + pdev->get_dev_number(pdev)) + != NULL) + { + zfree(pdev); + continue; + } + + pdev->set_UsbDevice(pdev, UsbDevice); + idevman->loading_lock(idevman); + if (udevman->head == NULL) + { + /* linked list is empty */ + udevman->head = pdev; + udevman->tail = pdev; + } + else + { + /* append device to the end of the linked list */ + udevman->tail->set_p_next(udevman->tail, pdev); + pdev->set_p_prev(pdev, udevman->tail); + udevman->tail = pdev; + } + udevman->device_num += 1; + idevman->loading_unlock(idevman); + addnum++; + } + zfree(devArray); + return addnum; + } + else + { + printf("udevman_register_udevice: function error!!"); + return 0; + } + return 1; +} + + +static int +udevman_unregister_udevice(IUDEVMAN * idevman, int bus_number, int dev_number) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + UDEVICE * pdev, * dev; + int ret = 0, err = 0; + + dev = (UDEVICE *)udevman_get_udevice_by_addr(idevman, bus_number, dev_number); + + idevman->loading_lock(idevman); + idevman->rewind(idevman); + while (idevman->has_next(idevman) != 0) + { + pdev = (UDEVICE *)idevman->get_next(idevman); + + if (pdev == dev) /* device exists */ + { + /* set previous device to point to next device */ + + if (dev->prev != NULL) + { + /* unregistered device is not the head */ + pdev = dev->prev; + pdev->next = dev->next; + } + else + { + /* unregistered device is the head, update head */ + udevman->head = (IUDEVICE*)dev->next; + } + + /* set next device to point to previous device */ + + if (dev->next != NULL) + { + /* unregistered device is not the tail */ + pdev = (UDEVICE *)dev->next; + pdev->prev = dev->prev; + } + else + { + /* unregistered device is the tail, update tail */ + udevman->tail = (IUDEVICE*)dev->prev; + } + udevman->device_num--; + + break; + } + } + idevman->loading_unlock(idevman); + + if (dev) + { + /* reset device */ + if (err != LIBUSB_ERROR_NO_DEVICE) + { + ret = libusb_reset_device(dev->libusb_handle); + if (ret<0){ + LLOGLN(10, ("libusb_reset_device: ERROR!!ret:%d\n", ret)); + } + } + + /* release all interface and attach kernel driver */ + dev->iface.attach_kernel_driver((IUDEVICE*)dev); + + if(dev->request_queue) zfree(dev->request_queue); + /* free the config descriptor that send from windows */ + msusb_msconfig_free(dev->MsConfig); + + libusb_close (dev->libusb_handle); + libusb_close (dev->hub_handle); + + sem_destroy(&dev->sem_id); + /* free device info */ + if (dev->devDescriptor) + zfree(dev->devDescriptor); + if (dev) + zfree(dev); + return 1; /* unregistration successful */ + } + + + /* if we reach this point, the device wasn't found */ + return 0; +} + +static void +udevman_parse_device_addr (char *str, int *id1, int *id2, char sign) +{ + char s1[8], *s2; + memset(s1, 0, sizeof(s1)); + + s2 = (strchr(str, sign)) + 1; + strncpy(s1, str, strlen(str) - (strlen(s2)+1)); + + *id1 = atoi(s1); + *id2 = atoi(s2); +} + +static void +udevman_parse_device_pid_vid (char *str, int *id1, int *id2, char sign) +{ + char s1[8], *s2; + memset(s1, 0, sizeof(s1)); + + s2 = (strchr(str, sign)) + 1; + strncpy(s1, str, strlen(str) - (strlen(s2)+1)); + + *id1 = (int) strtol(s1, NULL, 16); + *id2 = (int) strtol(s2, NULL, 16); +} + + +static int +udevman_check_device_exist_by_id(IUDEVMAN * idevman, uint16 idVendor, uint16 idProduct) +{ + if (libusb_open_device_with_vid_pid (NULL, idVendor, idProduct)) + return 1; + + return 0; +} + + +static int +udevman_is_auto_add(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + return (udevman->flags & UDEVMAN_FLAG_ADD_BY_AUTO) ? 1 : 0; +} + + +static IUDEVICE* +udevman_get_udevice_by_UsbDevice_try_again(IUDEVMAN * idevman, uint32 UsbDevice) +{ + UDEVICE * pdev; + idevman->loading_lock(idevman); + idevman->rewind (idevman); + while (idevman->has_next (idevman)) + { + pdev = (UDEVICE *)idevman->get_next (idevman); + if (pdev->UsbDevice == UsbDevice) + { + idevman->loading_unlock(idevman); + return (IUDEVICE *)pdev; + } + } + idevman->loading_unlock(idevman); + return NULL; +} + +static IUDEVICE* +udevman_get_udevice_by_UsbDevice(IUDEVMAN * idevman, uint32 UsbDevice) +{ + UDEVICE * pdev; + idevman->loading_lock(idevman); + idevman->rewind (idevman); + while (idevman->has_next (idevman)) + { + pdev = (UDEVICE *)idevman->get_next (idevman); + if (pdev->UsbDevice == UsbDevice) + { + idevman->loading_unlock(idevman); + return (IUDEVICE *)pdev; + } + } + idevman->loading_unlock(idevman); + /* try again */ + pdev = (UDEVICE *)idevman->get_udevice_by_UsbDevice_try_again(idevman, UsbDevice); + if (pdev) + { + return (IUDEVICE *)pdev; + } + + LLOGLN(libusb_debug, ("udevman_get_udevice_by_UsbDevice: 0x%x ERROR!!\n", + UsbDevice)); + return NULL; +} + + +static void +udevman_loading_lock(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + pthread_mutex_lock(&udevman->devman_loading); +} + +static void +udevman_loading_unlock(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + pthread_mutex_unlock(&udevman->devman_loading); +} + + +static void +udevman_wait_urb(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + sem_wait(&udevman->sem_urb_lock); +} + + +static void +udevman_push_urb(IUDEVMAN * idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + sem_post(&udevman->sem_urb_lock); +} + + +BASIC_STATE_FUNC_DEFINED(defUsbDevice, uint32) +BASIC_STATE_FUNC_DEFINED(device_num, int) +BASIC_STATE_FUNC_DEFINED(sem_timeout, int) + + +static void +udevman_free(IUDEVMAN* idevman) +{ + UDEVMAN * udevman = (UDEVMAN *) idevman; + pthread_mutex_destroy(&udevman->devman_loading); + sem_destroy(&udevman->sem_urb_lock); + + libusb_exit(NULL); + + /* free udevman */ + if (udevman) + zfree(udevman); +} + + +static void +udevman_load_interface(UDEVMAN * udevman) +{ + /* standard */ + udevman->iface.free = udevman_free; + /* manage devices */ + udevman->iface.rewind = udevman_rewind; + udevman->iface.get_next = udevman_get_next; + udevman->iface.has_next = udevman_has_next; + udevman->iface.register_udevice = udevman_register_udevice; + udevman->iface.unregister_udevice = udevman_unregister_udevice; + udevman->iface.get_udevice_by_UsbDevice = udevman_get_udevice_by_UsbDevice; + udevman->iface.get_udevice_by_UsbDevice_try_again = + udevman_get_udevice_by_UsbDevice_try_again; + /* Extension */ + udevman->iface.check_device_exist_by_id = udevman_check_device_exist_by_id; + udevman->iface.isAutoAdd = udevman_is_auto_add; + /* Basic state */ + BASIC_STATE_FUNC_REGISTER(defUsbDevice, udevman); + BASIC_STATE_FUNC_REGISTER(device_num, udevman); + BASIC_STATE_FUNC_REGISTER(sem_timeout, udevman); + /* control semaphore or mutex lock */ + udevman->iface.loading_lock = udevman_loading_lock; + udevman->iface.loading_unlock = udevman_loading_unlock; + udevman->iface.push_urb = udevman_push_urb; + udevman->iface.wait_urb = udevman_wait_urb; +} + + + +int FreeRDPUDEVMANEntry(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints) +{ + UDEVMAN* udevman; + RDP_PLUGIN_DATA * plugin_data = pEntryPoints->plugin_data; + uint32 UsbDevice = BASE_USBDEVICE_NUM; + char * token; + char * message = "id"; + char hardware_id[16]; + int idVendor; + int idProduct; + int bus_number; + int dev_number; + int success = 0; + + libusb_init(NULL); + + udevman = (PUDEVMAN)malloc(sizeof(UDEVMAN)); + udevman->device_num = 0; + udevman->idev = NULL; + udevman->head = NULL; + udevman->tail = NULL; + udevman->sem_timeout = 0; + udevman->flags = UDEVMAN_FLAG_ADD_BY_VID_PID; + + pthread_mutex_init(&udevman->devman_loading, NULL); + sem_init(&udevman->sem_urb_lock, 0, MAX_URB_REQUSET_NUM); + + /* load usb device service management */ + udevman_load_interface(udevman); + + /* set debug flag, to enable Debug message for usb data transfer*/ + if (plugin_data->data[2]) + message = (char *)plugin_data->data[2]; + + if (strstr(message, "id")) + udevman->flags = UDEVMAN_FLAG_ADD_BY_VID_PID; + else if (strstr(message, "addr")) + udevman->flags = UDEVMAN_FLAG_ADD_BY_ADDR; + + if (strstr(message, "auto")) + udevman->flags |= UDEVMAN_FLAG_ADD_BY_AUTO; + libusb_debug = 10; + if (strstr(message, "debug")) + { + libusb_debug = 0; + udevman->flags |= UDEVMAN_FLAG_DEBUG; + } + /* register all usb device */ + token = strtok((char *)plugin_data->data[1], "#"); + while (token) + { + bus_number = 0; + dev_number = 0; + idVendor = 0; + idProduct = 0; + + strcpy(hardware_id, token); + token = strtok(NULL, "#"); + if (udevman->flags & UDEVMAN_FLAG_ADD_BY_VID_PID) + { + udevman_parse_device_pid_vid(hardware_id, &idVendor, + &idProduct, + '_'); + success = udevman->iface.register_udevice((IUDEVMAN *)udevman, + 0, + 0, + UsbDevice, + (uint16) idVendor, + (uint16) idProduct, + UDEVMAN_FLAG_ADD_BY_VID_PID); + } + else if (udevman->flags & UDEVMAN_FLAG_ADD_BY_ADDR) + { + udevman_parse_device_addr(hardware_id, &bus_number, + &dev_number, + '_'); + success = udevman->iface.register_udevice((IUDEVMAN *)udevman, + bus_number, + dev_number, + UsbDevice, + 0, + 0, + UDEVMAN_FLAG_ADD_BY_ADDR); + } + + if (success) + UsbDevice++; + } + + udevman->defUsbDevice = UsbDevice; + + pEntryPoints->pRegisterUDEVMAN(pEntryPoints->plugin, (IUDEVMAN*) udevman); + + return 0; +} diff --git a/channels/drdynvc/urbdrc/libusb/request_queue.c b/channels/drdynvc/urbdrc/libusb/request_queue.c new file mode 100644 index 000000000..e7f897864 --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/request_queue.c @@ -0,0 +1,188 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "request_queue.h" + + + + +TRANSFER_REQUEST* +request_queue_get_next(REQUEST_QUEUE* queue) +{ + TRANSFER_REQUEST* request; + + request = queue->ireq; + queue->ireq = (TRANSFER_REQUEST *)queue->ireq->next; + + return request; +} + +int +request_queue_has_next(REQUEST_QUEUE* queue) +{ + if (queue->ireq == NULL) + return 0; + else + return 1; +} + +TRANSFER_REQUEST* +request_queue_register_request(REQUEST_QUEUE* queue, uint32 RequestId, + struct libusb_transfer * transfer, + uint8 endpoint) +{ + TRANSFER_REQUEST* request; + + request = (TRANSFER_REQUEST*)malloc(sizeof(TRANSFER_REQUEST)); + + request->prev = NULL; + request->next = NULL; + + request->RequestId = RequestId; + request->transfer = transfer; + request->endpoint = endpoint; + request->submit = 0; + pthread_mutex_lock(&queue->request_loading); + if (queue->head == NULL) + { + /* linked queue is empty */ + queue->head = request; + queue->tail = request; + } + else + { + /* append data to the end of the linked queue */ + queue->tail->next = (void*)request; + request->prev = (void*)queue->tail; + queue->tail = request; + } + queue->request_num += 1; + pthread_mutex_unlock(&queue->request_loading); + return request; +} + +void +request_queue_rewind(REQUEST_QUEUE *queue) +{ + queue->ireq = queue->head; +} + +/* Get first*/ +TRANSFER_REQUEST* +request_queue_get_request_by_endpoint(REQUEST_QUEUE *queue, uint8 ep) +{ + TRANSFER_REQUEST * request; + pthread_mutex_lock(&queue->request_loading); + queue->rewind (queue); + while (queue->has_next (queue)) + { + request = queue->get_next (queue); + if (request->endpoint == ep) + { + pthread_mutex_unlock(&queue->request_loading); + return request; + } + } + pthread_mutex_unlock(&queue->request_loading); + printf("request_queue_get_request_by_id: ERROR!!\n"); + return NULL; +} + +int +request_queue_unregister_request(REQUEST_QUEUE *queue, uint32 RequestId) +{ + TRANSFER_REQUEST *request, *request_temp; + pthread_mutex_lock(&queue->request_loading); + queue->rewind(queue); + + while (queue->has_next(queue) != 0) + { + request = queue->get_next(queue); + if (request->RequestId == RequestId) + { + + if (request->prev != NULL) + { + request_temp = (TRANSFER_REQUEST*)request->prev; + request_temp->next = (TRANSFER_REQUEST*)request->next; + } + else + { + queue->head = (TRANSFER_REQUEST*)request->next; + } + + if (request->next != NULL) + { + request_temp = (TRANSFER_REQUEST*)request->next; + request_temp->prev = (TRANSFER_REQUEST*)request->prev; + } + else + { + queue->tail = (TRANSFER_REQUEST*)request->prev; + + } + + queue->request_num--; + + if (request) + { + request->transfer = NULL; + zfree(request); + } + + pthread_mutex_unlock(&queue->request_loading); + + return 0; + } + } + pthread_mutex_unlock(&queue->request_loading); + /* it wasn't found */ + return 1; +} + + +REQUEST_QUEUE* +request_queue_new() +{ + REQUEST_QUEUE* queue; + + queue = (REQUEST_QUEUE*)malloc(sizeof(REQUEST_QUEUE)); + queue->request_num = 0; + queue->ireq = NULL; + queue->head = NULL; + queue->tail = NULL; + + pthread_mutex_init(&queue->request_loading, NULL); + + /* load service */ + queue->get_next = request_queue_get_next; + queue->has_next = request_queue_has_next; + queue->rewind = request_queue_rewind; + queue->register_request = request_queue_register_request; + queue->unregister_request = request_queue_unregister_request; + queue->get_request_by_ep = request_queue_get_request_by_endpoint; + + return queue; +} + diff --git a/channels/drdynvc/urbdrc/libusb/request_queue.h b/channels/drdynvc/urbdrc/libusb/request_queue.h new file mode 100644 index 000000000..0ea275263 --- /dev/null +++ b/channels/drdynvc/urbdrc/libusb/request_queue.h @@ -0,0 +1,65 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __REQUEST_QUEUE_H +#define __REQUEST_QUEUE_H + +#include "urbdrc_types.h" + +typedef struct _TRANSFER_REQUEST TRANSFER_REQUEST; +typedef struct _REQUEST_QUEUE REQUEST_QUEUE; + +struct _TRANSFER_REQUEST +{ + void* request; + void* prev; + void* next; + + uint32 RequestId; + uint8 endpoint; + struct libusb_transfer *transfer; + int submit; +}; + + +struct _REQUEST_QUEUE +{ + int request_num; + TRANSFER_REQUEST* ireq; /* iterator request */ + TRANSFER_REQUEST* head; /* head request in linked queue */ + TRANSFER_REQUEST* tail; /* tail request in linked queue */ + + pthread_mutex_t request_loading; + + /* request queue manager service */ + void (*rewind) (REQUEST_QUEUE *queue); + int (*has_next) (REQUEST_QUEUE* queue); + int (*unregister_request) (REQUEST_QUEUE *queue, uint32 RequestId); + TRANSFER_REQUEST *(*get_next) (REQUEST_QUEUE* queue); + TRANSFER_REQUEST *(*get_request_by_ep) (REQUEST_QUEUE *queue, uint8 ep); + TRANSFER_REQUEST *(*register_request) (REQUEST_QUEUE* queue, + uint32 RequestId, struct libusb_transfer * transfer, uint8 endpoint); +}; + + +REQUEST_QUEUE* request_queue_new(); + + +#endif /* __REQUEST_QUEUE_H */ diff --git a/channels/drdynvc/urbdrc/searchman.c b/channels/drdynvc/urbdrc/searchman.c new file mode 100644 index 000000000..bfb4d56ce --- /dev/null +++ b/channels/drdynvc/urbdrc/searchman.c @@ -0,0 +1,237 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include "searchman.h" + +static void +searchman_rewind(USB_SEARCHMAN* searchman) +{ + searchman->idev = searchman->head; +} + +static int +searchman_has_next(USB_SEARCHMAN* searchman) +{ + if (searchman->idev == NULL) + return 0; + else + return 1; +} + +static USB_SEARCHDEV* +searchman_get_next(USB_SEARCHMAN* searchman) +{ + USB_SEARCHDEV* search; + + search = searchman->idev; + searchman->idev = (USB_SEARCHDEV*)searchman->idev->next; + + return search; +} + + + +static int +searchman_list_add(USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct) +{ + USB_SEARCHDEV* search; + + search = (USB_SEARCHDEV*)malloc(sizeof(USB_SEARCHDEV)); + + search->prev = NULL; + search->next = NULL; + search->idVendor = idVendor; + search->idProduct = idProduct; + + if (searchman->head == NULL) + { + /* linked list is empty */ + searchman->head = search; + searchman->tail = search; + } + else + { + /* append device to the end of the linked list */ + searchman->tail->next = (void*)search; + search->prev = (void*)searchman->tail; + searchman->tail = search; + } + searchman->usb_numbers += 1; + + return 1; +} + + +static int +searchman_list_remove(USB_SEARCHMAN* searchman, uint16 idVendor, + uint16 idProduct) +{ + USB_SEARCHDEV* search; + USB_SEARCHDEV* point; + + searchman_rewind(searchman); + while (searchman_has_next(searchman) != 0) + { + point = searchman_get_next(searchman); + + if (point->idVendor == idVendor && + point->idProduct == idProduct) + { + /* set previous device to point to next device */ + + search = point; + if (search->prev != NULL) + { + /* unregistered device is not the head */ + point = (USB_SEARCHDEV*)search->prev; + point->next = search->next; + } + else + { + /* unregistered device is the head, update head */ + searchman->head = (USB_SEARCHDEV*)search->next; + } + + /* set next device to point to previous device */ + + if (search->next != NULL) + { + /* unregistered device is not the tail */ + point = (USB_SEARCHDEV*)search->next; + point->prev = search->prev; + } + else + { + /* unregistered device is the tail, update tail */ + searchman->tail = (USB_SEARCHDEV*)search->prev; + } + searchman->usb_numbers--; + + free(search); + + return 1; /* unregistration successful */ + } + } + + /* if we reach this point, the device wasn't found */ + return 0; +} + + + +static void +searchman_start(USB_SEARCHMAN* self, void * func) +{ + pthread_t thread; + + /* create search thread */ + pthread_create(&thread, 0, func, self); + pthread_detach(thread); + self->strated = 1; +} + +/* close thread */ +static void +searchman_close(USB_SEARCHMAN* self) +{ + wait_obj_set(self->term_event); +} + + +static void +searchman_list_show(USB_SEARCHMAN* self) +{ + USB_SEARCHDEV* usb; + int num = 0; + + printf("=========== Usb Search List ========= \n"); + self->rewind(self); + while (self->has_next(self)) + { + usb = self->get_next(self); + printf(" USB %d: \n", num++); + printf(" idVendor: 0x%04X \n", usb->idVendor); + printf(" idProduct: 0x%04X \n", usb->idProduct); + } + printf("================= END =============== \n"); +} + + +void +searchman_free(USB_SEARCHMAN* self) +{ + USB_SEARCHDEV * dev; + + while (self->head != NULL) + { + dev = (USB_SEARCHDEV *)self->head; + self->remove (self, dev->idVendor, dev->idProduct); + } + + /* free searchman */ + sem_destroy(&self->sem_term); + wait_obj_free(self->term_event); + free(self); +} + + +USB_SEARCHMAN* +searchman_new(void * urbdrc, uint32 UsbDevice) +{ + USB_SEARCHMAN* searchman; + int ret; + searchman = (USB_SEARCHMAN*)malloc(sizeof(USB_SEARCHMAN)); + + searchman->idev = NULL; + searchman->head = NULL; + searchman->tail = NULL; + searchman->usb_numbers = 0; + searchman->urbdrc = urbdrc; + searchman->UsbDevice = UsbDevice; + + ret = pthread_mutex_init(&searchman->mutex, NULL); + if (ret != 0) + { + printf("searchman mutex initialization: searchman->mutex failed"); + exit(EXIT_FAILURE); + } + + /* load service */ + searchman->add = searchman_list_add; + searchman->remove = searchman_list_remove; + searchman->rewind = searchman_rewind; + searchman->get_next = searchman_get_next; + searchman->has_next = searchman_has_next; + searchman->show = searchman_list_show; + searchman->start = searchman_start; + searchman->close = searchman_close; + searchman->free = searchman_free; + + searchman->strated = 0; + searchman->term_event = wait_obj_new(); + sem_init(&searchman->sem_term, 0, 0); + + return searchman; +} diff --git a/channels/drdynvc/urbdrc/searchman.h b/channels/drdynvc/urbdrc/searchman.h new file mode 100644 index 000000000..0a690d1b8 --- /dev/null +++ b/channels/drdynvc/urbdrc/searchman.h @@ -0,0 +1,77 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SEACH_MAN_H +#define __SEACH_MAN_H + +#include "urbdrc_types.h" +#include + +typedef struct _USB_SEARCHDEV USB_SEARCHDEV; +struct _USB_SEARCHDEV +{ + void * inode; + void * prev; + void * next; + uint16 idVendor; + uint16 idProduct; +}; + +typedef struct _USB_SEARCHMAN USB_SEARCHMAN; +struct _USB_SEARCHMAN +{ + int usb_numbers; + uint32 UsbDevice; + USB_SEARCHDEV * idev; /* iterator device */ + USB_SEARCHDEV * head; /* head device in linked list */ + USB_SEARCHDEV * tail; /* tail device in linked list */ + + pthread_mutex_t mutex; + struct wait_obj * term_event; + sem_t sem_term; + int strated; + + /* for urbdrc channel call back */ + void * urbdrc; + + /* load service */ + void (*rewind) (USB_SEARCHMAN* seachman); + /* show all device in the list */ + void (*show) (USB_SEARCHMAN* self); + /* start searchman */ + void (*start) (USB_SEARCHMAN* self, void * func); + /* close searchman */ + void (*close) (USB_SEARCHMAN* self); + /* add a new usb device for search */ + int (*add) (USB_SEARCHMAN* seachman, uint16 idVendor, uint16 idProduct); + /* remove a usb device from list */ + int (*remove) (USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct); + /* check list has next device*/ + int (*has_next) (USB_SEARCHMAN* seachman); + /* get the device from list*/ + USB_SEARCHDEV* (*get_next) (USB_SEARCHMAN* seachman); + /* free! */ + void (*free) (USB_SEARCHMAN* searchman); +}; + +USB_SEARCHMAN * searchman_new(void * urbdrc, uint32 UsbDevice); + +#endif + diff --git a/channels/drdynvc/urbdrc/urbdrc_main.c b/channels/drdynvc/urbdrc/urbdrc_main.c new file mode 100644 index 000000000..e2e1e8efb --- /dev/null +++ b/channels/drdynvc/urbdrc/urbdrc_main.c @@ -0,0 +1,1073 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "urbdrc_types.h" +#include "dvcman.h" +#include "urbdrc_main.h" +#include "data_transfer.h" +#include "searchman.h" + +int urbdrc_debug = 0; + +static int +func_hardware_id_format(IUDEVICE * pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_SIZE]) +{ + char str[DEVICE_HARDWARE_ID_SIZE]; + int idVendor, idProduct, bcdDevice; + + memset(str, 0, DEVICE_HARDWARE_ID_SIZE); + + idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR); + idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT); + bcdDevice = pdev->query_device_descriptor(pdev, BCD_DEVICE); + + sprintf(str, "USB\\VID_%04X&PID_%04X", idVendor, idProduct); + strcpy(HardwareIds[1], str); + sprintf(str, "%s&REV_%04X", str, bcdDevice); + strcpy(HardwareIds[0], str); + + return 0; +} + + +static int +func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBILITY_ID_SIZE]) +{ + char str[DEVICE_COMPATIBILITY_ID_SIZE]; + int bDeviceClass, bDeviceSubClass, bDeviceProtocol; + + bDeviceClass = pdev->query_device_descriptor(pdev, B_DEVICE_CLASS); + bDeviceSubClass = pdev->query_device_descriptor(pdev, B_DEVICE_SUBCLASS); + bDeviceProtocol = pdev->query_device_descriptor(pdev, B_DEVICE_PROTOCOL); + + if(!(pdev->isCompositeDevice(pdev))){ + sprintf(str, "USB\\Class_%02X", bDeviceClass); + strcpy(CompatibilityIds[2], str); + sprintf(str, "%s&SubClass_%02X", str, bDeviceSubClass); + strcpy(CompatibilityIds[1], str); + sprintf(str, "%s&Prot_%02X", str, bDeviceProtocol); + strcpy(CompatibilityIds[0], str); + } + else{ + sprintf(str, "USB\\DevClass_00"); + strcpy(CompatibilityIds[2], str); + sprintf(str, "%s&SubClass_00", str); + strcpy(CompatibilityIds[1], str); + sprintf(str, "%s&Prot_00", str); + strcpy(CompatibilityIds[0], str); + } + + return 0; +} + + +static void +func_close_udevice(USB_SEARCHMAN * searchman, IUDEVICE * pdev) +{ + URBDRC_PLUGIN * urbdrc = searchman->urbdrc; + int idVendor = 0; + int idProduct = 0; + + pdev->SigToEnd(pdev); + idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR); + idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT); + searchman->add(searchman, (uint16)idVendor, (uint16)idProduct); + + pdev->cancel_all_transfer_request(pdev); + pdev->wait_action_completion(pdev); + +#if ISOCH_FIFO + /* free isoch queue */ + ISOCH_CALLBACK_QUEUE* isoch_queue = pdev->get_isoch_queue(pdev); + if (isoch_queue) + isoch_queue->free(isoch_queue); +#endif + + urbdrc->udevman->unregister_udevice(urbdrc->udevman, + pdev->get_bus_number(pdev), + pdev->get_dev_number(pdev)); + //searchman->show(searchman); +} + + +static int +fun_device_string_send_set(char * out_data, int out_offset, char * str) +{ + int i = 0; + int offset = 0; + + while (str[i]) + { + data_write_uint16(out_data + out_offset + offset, str[i]); /* str */ + i++; + offset += 2; + } + data_write_uint16(out_data + out_offset + offset, 0x0000); /* add "\0" */ + offset += 2; + return offset + out_offset; +} + + +static int +func_container_id_generate(IUDEVICE * pdev, char * strContainerId) +{ + char containerId[17]; + char *p, *path; + int idVendor, idProduct; + + idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR); + idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT); + path = pdev->getPath(pdev); + if (strlen(path) > 8) + p = (path + strlen(path)) - 8; + else + p = path; + + sprintf(containerId, "%04X%04X%s", idVendor, idProduct, p); + /* format */ + sprintf(strContainerId, + "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + containerId[0], containerId[1],containerId[2], containerId[3], + containerId[4], containerId[5], containerId[6], containerId[7], + containerId[8], containerId[9], containerId[10], containerId[11], + containerId[12], containerId[13], containerId[14], containerId[15]); + + return 0; +} + + +static int +func_instance_id_generate(IUDEVICE * pdev, char *strInstanceId) +{ + char instanceId[17]; + + memset(instanceId, 0, 17); + sprintf(instanceId, "\\%s", pdev->getPath(pdev)); + /* format */ + sprintf(strInstanceId, + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + instanceId[0], instanceId[1],instanceId[2], instanceId[3], + instanceId[4], instanceId[5], instanceId[6], instanceId[7], + instanceId[8], instanceId[9], instanceId[10], instanceId[11], + instanceId[12], instanceId[13], instanceId[14], instanceId[15]); + + return 0; +} + + +#if ISOCH_FIFO +static void +func_lock_isoch_mutex(TRANSFER_DATA* transfer_data) +{ + IUDEVMAN * udevman = transfer_data->udevman; + IUDEVICE* pdev; + uint32 FunctionId; + uint32 RequestField; + uint16 URB_Function; + int noAck = 0; + + if (transfer_data->cbSize >= 8) + { + data_read_uint32(transfer_data->pBuffer + 4, FunctionId); + if ((FunctionId == TRANSFER_IN_REQUEST || + FunctionId == TRANSFER_OUT_REQUEST) && + transfer_data->cbSize >= 16) + { + data_read_uint16(transfer_data->pBuffer + 14, URB_Function); + if (URB_Function == URB_FUNCTION_ISOCH_TRANSFER && + transfer_data->cbSize >= 20) + { + data_read_uint32(transfer_data->pBuffer + 16, RequestField); + noAck = (RequestField & 0x80000000)>>31; + + if (!noAck) + { + pdev = udevman->get_udevice_by_UsbDevice(udevman, + transfer_data->UsbDevice); + pdev->lock_fifo_isoch(pdev); + } + } + } + } +} +#endif + + +static int +urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK * callback, + char * data, uint32 data_sizem, uint32 MessageId) +{ + uint32 InterfaceId; + uint32 Version; + uint32 out_size; + char * out_data; + + LLOGLN(10, ("urbdrc_process_capability_request")); + data_read_uint32(data + 0, Version); + + InterfaceId = ((STREAM_ID_NONE<<30) | CAPABILITIES_NEGOTIATOR); + + out_size = 16; + out_data = (char *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /* interface id */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, Version); /* usb protocol version */ + data_write_uint32(out_data + 12, 0x00000000); /* HRESULT */ + callback->channel->Write(callback->channel, out_size, (uint8 *)out_data, NULL); + zfree(out_data); + + return 0; +} + +static int +urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK * callback, char * data, + uint32 data_sizem, + uint32 MessageId) +{ + uint32 InterfaceId; + uint32 out_size; + uint32 MajorVersion; + uint32 MinorVersion; + uint32 Capabilities; + char * out_data; + + LLOGLN(10, ("urbdrc_process_channel_create")); + data_read_uint32(data + 0, MajorVersion); + data_read_uint32(data + 4, MinorVersion); + data_read_uint32(data + 8, Capabilities); + + InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_CHANNEL_NOTIFICATION); + + out_size = 24; + out_data = (char *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /* interface id */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, CHANNEL_CREATED); /* function id */ + data_write_uint32(out_data + 12, MajorVersion); + data_write_uint32(out_data + 16, MinorVersion); + data_write_uint32(out_data + 20, Capabilities); /* capabilities version */ + callback->channel->Write(callback->channel, out_size, (uint8 *)out_data, NULL); + zfree(out_data); + + return 0; +} + + +static int +urdbrc_send_virtual_channel_add(IWTSVirtualChannel * channel, uint32 MessageId) +{ + uint32 out_size; + uint32 InterfaceId; + char * out_data; + + LLOGLN(10, ("urdbrc_send_virtual_channel_add")); + + InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK); + + out_size = 12; + out_data = (char *) malloc(out_size); + memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /* interface */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, ADD_VIRTUAL_CHANNEL); /* function id */ + + channel->Write(channel, out_size, (uint8 *)out_data, NULL); + zfree(out_data); + + return 0; +} + + + +static int +urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK * callback, IUDEVICE* pdev) +{ + uint32 InterfaceId; + char HardwareIds[2][DEVICE_HARDWARE_ID_SIZE]; + char CompatibilityIds[3][DEVICE_COMPATIBILITY_ID_SIZE]; + char * out_data; + char strContainerId[DEVICE_CONTAINER_STR_SIZE]; + char strInstanceId[DEVICE_INSTANCE_STR_SIZE]; + char * composite_str = "USB\\COMPOSITE"; + int size, out_offset, cchCompatIds, bcdUSB; + + LLOGLN(10, ("urdbrc_send_usb_device_add")); + InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK); + + /* USB kernel driver detach!! */ + pdev->detach_kernel_driver(pdev); +#if ISOCH_FIFO + /* create/initial isoch queue */ + pdev->set_isoch_queue(pdev, (void *)isoch_queue_new()); +#endif + + func_hardware_id_format(pdev, HardwareIds); + func_compat_id_format(pdev, CompatibilityIds); + func_instance_id_generate(pdev, strInstanceId); + func_container_id_generate(pdev, strContainerId); + + cchCompatIds = strlen(CompatibilityIds[0])+1 + + strlen(CompatibilityIds[1])+1 + + strlen(CompatibilityIds[2])+2; + + if(pdev->isCompositeDevice(pdev)) + cchCompatIds += strlen(composite_str)+1; + + out_offset = 24; + size = 24; + size += (strlen(strInstanceId)+1)*2 + + (strlen(HardwareIds[0])+1)*2 + 4 + + (strlen(HardwareIds[1])+1)*2 + 2 + + 4 + (cchCompatIds)*2 + + (strlen(strContainerId)+1)*2 + 4 + 28; + + out_data = (char *) malloc(size); + memset(out_data, 0, size); + data_write_uint32(out_data + 0, InterfaceId); /* interface */ + data_write_uint32(out_data + 4, 0); /* message id */ + data_write_uint32(out_data + 8, ADD_DEVICE); /* function id */ + data_write_uint32(out_data + 12, 0x00000001); /* NumUsbDevice */ + data_write_uint32(out_data + 16, pdev->get_UsbDevice(pdev)); /* UsbDevice */ + data_write_uint32(out_data + 20, 0x00000025); /* cchDeviceInstanceId */ + + out_offset = fun_device_string_send_set(out_data, out_offset, strInstanceId); + + data_write_uint32(out_data + out_offset, 0x00000036); /* cchHwIds */ + out_offset += 4; + /* HardwareIds 1 */ + out_offset = fun_device_string_send_set(out_data, out_offset, HardwareIds[0]); + /* HardwareIds 2 */ + out_offset = fun_device_string_send_set(out_data, out_offset, HardwareIds[1]); + data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ + out_offset += 2; + + data_write_uint32(out_data + out_offset, cchCompatIds); /* cchCompatIds */ + out_offset += 4; + /* CompatibilityIds 1 */ + out_offset = fun_device_string_send_set(out_data, out_offset, CompatibilityIds[0]); + /* CompatibilityIds 2 */ + out_offset = fun_device_string_send_set(out_data, out_offset, CompatibilityIds[1]); + /* CompatibilityIds 3 */ + out_offset = fun_device_string_send_set(out_data, out_offset, CompatibilityIds[2]); + + if(pdev->isCompositeDevice(pdev)) + out_offset = fun_device_string_send_set(out_data, out_offset, composite_str); + + data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ + out_offset += 2; + + data_write_uint32(out_data + out_offset, 0x00000027); /* cchContainerId */ + out_offset += 4; + /* ContainerId */ + out_offset = fun_device_string_send_set(out_data, out_offset, strContainerId); + + /* USB_DEVICE_CAPABILITIES 28 bytes */ + data_write_uint32(out_data + out_offset, 0x0000001c); /* CbSize */ + data_write_uint32(out_data + out_offset + 4, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */ + data_write_uint32(out_data + out_offset + 8, 0x600); /* USBDI_Version, 0x500 or 0x600 */ + /* Supported_USB_Version, 0x110,0x110 or 0x200(usb2.0) */ + bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB); + data_write_uint32(out_data + out_offset + 12, bcdUSB); + data_write_uint32(out_data + out_offset + 16, 0x00000000); /* HcdCapabilities, MUST always be zero */ + if (bcdUSB < 0x200) + data_write_uint32(out_data + out_offset + 20, 0x00000000); /* DeviceIsHighSpeed */ + else + data_write_uint32(out_data + out_offset + 20, 0x00000001); /* DeviceIsHighSpeed */ + data_write_uint32(out_data + out_offset + 24, 0x50); /* NoAckIsochWriteJitterBufferSizeInMs, >=10 or <=512 */ + out_offset += 28; + + callback->channel->Write(callback->channel, out_offset, (uint8 *)out_data, NULL); + zfree(out_data); + + return 0; +} + + +static int +urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK * callback, + char * pBuffer, + uint32 cbSize) +{ + uint32 MessageId; + uint32 FunctionId; + + int error = 0; + + data_read_uint32(pBuffer + 0, MessageId); + data_read_uint32(pBuffer + 4, FunctionId); + + switch (FunctionId) + { + case RIM_EXCHANGE_CAPABILITY_REQUEST: + error = urbdrc_process_capability_request(callback, + pBuffer + 8, + cbSize - 8, + MessageId); + break; + default: + LLOGLN(10, ("urbdrc_exchange_capabilities: unknown FunctionId 0x%X", FunctionId)); + error = 1; + break; + } + return error; +} + + + +static void * +urbdrc_search_usb_device(void * arg) +{ + USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) arg; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) searchman->urbdrc; + IUDEVMAN* udevman = urbdrc->udevman; + IWTSVirtualChannelManager * channel_mgr; + IWTSVirtualChannel * dvc_channel; + USB_SEARCHDEV* sdev; + IUDEVICE * pdev = NULL; + struct wait_obj * listobj[2]; + struct wait_obj * mon_fd; + int numobj, timeout; + int busnum, devnum; + int success = 0, error, on_close = 0, found = 0; + + LLOGLN(10, ("urbdrc_search_usb_device: ")); + + channel_mgr = urbdrc->listener_callback->channel_mgr; + + /* init usb monitor */ + struct udev *udev; + struct udev_device *dev; + struct udev_monitor *mon; + + udev = udev_new(); + if (!udev) { + printf("Can't create udev\n"); + return 0; + } + + /* Set up a monitor to monitor usb devices */ + mon = udev_monitor_new_from_netlink(udev, "udev"); + udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", "usb_device"); + udev_monitor_enable_receiving(mon); + /* Get the file descriptor (fd) for the monitor. + This fd will get passed to select() */ + mon_fd = wait_obj_new_with_fd((void *)udev_monitor_get_fd(mon)); + + while (1) + { + LLOGLN(10, ("======= SEARCH ======= ")); + busnum = 0; + devnum = 0; + sdev = NULL; + pdev = NULL; + dvc_channel = NULL; + on_close = 0; + listobj[0] = searchman->term_event; + listobj[1] = mon_fd; + numobj = 2; + wait_obj_select(listobj, numobj, -1); + if (wait_obj_is_set(searchman->term_event)) + { + sem_post(&searchman->sem_term); + return 0; + } + + if (wait_obj_is_set(mon_fd)) + { + dev = udev_monitor_receive_device(mon); + if (dev) { + const char * action = udev_device_get_action(dev); + if (strcmp(action, "add") == 0) + { + int idVendor, idProduct; + success = 0; + found = 0; + idVendor = strtol( + udev_device_get_sysattr_value(dev, "idVendor"), NULL, 16); + idProduct = strtol( + udev_device_get_sysattr_value(dev, "idProduct"), NULL, 16); + if (idVendor < 0 || idProduct < 0) + { + udev_device_unref(dev); + continue; + } + + busnum = atoi(udev_device_get_property_value(dev,"BUSNUM")); + devnum = atoi(udev_device_get_property_value(dev,"DEVNUM")); + + dvc_channel = channel_mgr->FindChannelById(channel_mgr, + urbdrc->first_channel_id); + searchman->rewind(searchman); + while(dvc_channel && searchman->has_next(searchman)) + { + sdev = searchman->get_next(searchman); + if (sdev->idVendor == idVendor && + sdev->idProduct == idProduct) + { + LLOGLN(10, ("Searchman Find Device: %04x:%04x ", + sdev->idVendor, sdev->idProduct)); + found = 1; + break; + } + } + + if (!found && udevman->isAutoAdd(udevman)) + { + LLOGLN(10, ("Auto Find Device: %04x:%04x ", + idVendor, idProduct)); + found = 2; + } + + if (found) + success = udevman->register_udevice(udevman, + busnum, + devnum, + searchman->UsbDevice, + 0, + 0, + UDEVMAN_FLAG_ADD_BY_ADDR); + if (success) + { + searchman->UsbDevice++; + /* when we send the usb device add request, + * we will detach the device driver at same + * time. But, if the time of detach the + * driver and attach driver is too close, + * the system will crash. workaround: we + * wait it for some time to avoid system + * crash. */ + listobj[0] = searchman->term_event; + numobj = 1; + timeout = 4000; /* milliseconds */ + wait_obj_select(listobj, numobj, timeout); + if (wait_obj_is_set(searchman->term_event)) + { + wait_obj_free(mon_fd); + sem_post(&searchman->sem_term); + return 0; + } + error = urdbrc_send_virtual_channel_add(dvc_channel, 0); + if (found == 1) + searchman->remove(searchman, sdev->idVendor, + sdev->idProduct); + } + } + else if (strcmp(action, "remove") == 0) + { + busnum = atoi(udev_device_get_property_value(dev,"BUSNUM")); + devnum = atoi(udev_device_get_property_value(dev,"DEVNUM")); + + usleep(500000); + udevman->loading_lock(udevman); + udevman->rewind(udevman); + while(udevman->has_next(udevman)) + { + pdev = udevman->get_next(udevman); + if (pdev->get_bus_number(pdev) == busnum && + pdev->get_dev_number(pdev) == devnum) + { + dvc_channel = channel_mgr->FindChannelById(channel_mgr, + pdev->get_channel_id(pdev)); + if (dvc_channel == NULL){ + LLOGLN(0, ("SEARCH: dvc_channel %d is NULL!!", + pdev->get_channel_id(pdev))); + func_close_udevice(searchman, pdev); + break; + } + + if (!pdev->isSigToEnd(pdev)) + { + dvc_channel->Write(dvc_channel, 0, NULL, NULL); + pdev->SigToEnd(pdev); + } + on_close = 1; + break; + } + } + udevman->loading_unlock(udevman); + + listobj[0] = searchman->term_event; + numobj = 1; + timeout = 3000; /* milliseconds */ + wait_obj_select(listobj, numobj, timeout); + if (wait_obj_is_set(searchman->term_event)) + { + wait_obj_free(mon_fd); + sem_post(&searchman->sem_term); + return 0; + } + + if(pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) && + !(pdev->isChannelClosed(pdev))) + { + on_close = 0; + dvc_channel->Close(dvc_channel); + } + } + udev_device_unref(dev); + } + else { + printf("No Device from receive_device(). An error occured.\n"); + } + } + } + + wait_obj_free(mon_fd); + sem_post(&searchman->sem_term); + + return 0; +} + + +void * +urbdrc_new_device_create(void * arg) +{ + TRANSFER_DATA* transfer_data = (TRANSFER_DATA*) arg; + URBDRC_CHANNEL_CALLBACK * callback = transfer_data->callback; + IWTSVirtualChannelManager * channel_mgr; + URBDRC_PLUGIN * urbdrc = transfer_data->urbdrc; + USB_SEARCHMAN * searchman = urbdrc->searchman; + uint8 * pBuffer = transfer_data->pBuffer; + //uint32 cbSize = transfer_data->cbSize; + IUDEVMAN * udevman = transfer_data->udevman; + IUDEVICE * pdev = NULL; + uint32 ChannelId = 0; + uint32 MessageId; + uint32 FunctionId; + int i = 0, found = 0; + + channel_mgr = urbdrc->listener_callback->channel_mgr; + ChannelId = channel_mgr->GetChannelId(callback->channel); + + data_read_uint32(pBuffer + 0, MessageId); + data_read_uint32(pBuffer + 4, FunctionId); + + int error = 0; + switch (urbdrc->vchannel_status){ + case INIT_CHANNEL_IN: + urbdrc->first_channel_id = ChannelId; + searchman->start(searchman, urbdrc_search_usb_device); + + for(i=0; i < udevman->get_device_num(udevman); i++) + { + error = urdbrc_send_virtual_channel_add(callback->channel, MessageId); + } + urbdrc->vchannel_status = INIT_CHANNEL_OUT; + break; + case INIT_CHANNEL_OUT: + udevman->loading_lock(udevman); + udevman->rewind(udevman); + while(udevman->has_next(udevman)){ + pdev = udevman->get_next(udevman); + if (!pdev->isAlreadySend(pdev)) + { + found = 1; + pdev->setAlreadySend(pdev); + pdev->set_channel_id(pdev, ChannelId); + break; + } + } + udevman->loading_unlock(udevman); + + if (found && pdev->isAlreadySend(pdev)) + { + /* when we send the usb device add request, we will detach + * the device driver at same time. But, if the time of detach the + * driver and attach driver is too close, the system will crash. + * workaround: we wait it for some time to avoid system crash. */ + error = pdev->wait_for_detach(pdev); + if (error >= 0) + urdbrc_send_usb_device_add(callback, pdev); + } + + break; + default: + LLOGLN(0, ("urbdrc_new_device_create: vchannel_status unknown value %d", + urbdrc->vchannel_status)); + break; + } + + return 0; +} + + + +static int +urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, + char * pBuffer, uint32 cbSize) +{ + URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) callback->plugin; + uint32 MessageId; + uint32 FunctionId; + int i, error = 0; + + data_read_uint32(pBuffer + 0, MessageId); + data_read_uint32(pBuffer + 4, FunctionId); + + switch (FunctionId) + { + case CHANNEL_CREATED: + error = urbdrc_process_channel_create(callback, pBuffer + 8, cbSize - 8, MessageId); + break; + case RIMCALL_RELEASE: + LLOGLN(10, ("urbdrc_process_channel_notification: recv RIMCALL_RELEASE")); + pthread_t thread; + + TRANSFER_DATA* transfer_data; + + transfer_data = (TRANSFER_DATA*)malloc(sizeof(TRANSFER_DATA)); + transfer_data->callback = callback; + transfer_data->urbdrc = urbdrc; + transfer_data->udevman = urbdrc->udevman; + transfer_data->urbdrc = urbdrc; + transfer_data->cbSize = cbSize; + transfer_data->pBuffer = (uint8 *)malloc((cbSize)); + for (i = 0; i < (cbSize); i++) + { + transfer_data->pBuffer[i] = pBuffer[i]; + } + + pthread_create(&thread, 0, urbdrc_new_device_create, transfer_data); + pthread_detach(thread); + break; + default: + LLOGLN(10, ("urbdrc_process_channel_notification: unknown FunctionId 0x%X", FunctionId)); + error = 1; + break; + } + return error; +} + + + + +static int +urbdrc_on_data_received(IWTSVirtualChannelCallback * pChannelCallback, + uint32 cbSize, + uint8 * Buffer) +{ + URBDRC_CHANNEL_CALLBACK * callback = (URBDRC_CHANNEL_CALLBACK *) pChannelCallback; + URBDRC_PLUGIN * urbdrc; + IUDEVMAN * udevman; + uint32 InterfaceTemp; + uint32 InterfaceId; + uint32 Mask; + int error = 0; + char * pBuffer = (char *) Buffer; + + if (callback == NULL) return 0; + if (callback->plugin == NULL) return 0; + urbdrc = (URBDRC_PLUGIN *) callback->plugin; + if (urbdrc->udevman == NULL) return 0; + udevman = (IUDEVMAN *) urbdrc->udevman; + + data_read_uint32(pBuffer + 0, InterfaceTemp); + InterfaceId = (InterfaceTemp & 0x0fffffff); + Mask = ((InterfaceTemp & 0xf0000000)>>30); + LLOGLN(10, ("urbdrc_on_data_received: Size=%d InterfaceId=0x%X Mask=0x%X", cbSize, InterfaceId, Mask)); + + switch (InterfaceId) + { + case CAPABILITIES_NEGOTIATOR: + error = urbdrc_exchange_capabilities(callback, pBuffer + 4, cbSize - 4); + break; + case SERVER_CHANNEL_NOTIFICATION: + error = urbdrc_process_channel_notification(callback, pBuffer + 4, cbSize - 4); + break; + default: + LLOGLN(10, ("urbdrc_on_data_received: InterfaceId 0x%X Start matching devices list", InterfaceId)); + pthread_t thread; + TRANSFER_DATA* transfer_data; + + transfer_data = (TRANSFER_DATA*)malloc(sizeof(TRANSFER_DATA)); + if (transfer_data == NULL) + printf("transfer_data is NULL!!"); + transfer_data->callback = callback; + transfer_data->urbdrc = urbdrc; + transfer_data->udevman = udevman; + transfer_data->cbSize = cbSize - 4; + transfer_data->UsbDevice = InterfaceId; + transfer_data->pBuffer = (uint8 *)malloc((cbSize - 4)); + + memcpy(transfer_data->pBuffer, pBuffer + 4, (cbSize - 4)); + + /* To ensure that not too many urb requests at the same time */ + udevman->wait_urb(udevman); + +#if ISOCH_FIFO + /* lock isoch mutex */ + func_lock_isoch_mutex(transfer_data); +#endif + + error = pthread_create(&thread, 0, urbdrc_process_udev_data_transfer, transfer_data); + if (error < 0) + LLOGLN(0, ("Create Data Transfer Thread got error = %d", error)); + else + pthread_detach(thread); + + //urbdrc_process_udev_data_transfer(transfer_data); + + break; + } + + return 0; +} + +static int +urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) +{ + URBDRC_CHANNEL_CALLBACK * callback = (URBDRC_CHANNEL_CALLBACK *) pChannelCallback; + URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) callback->plugin; + IUDEVMAN * udevman = (IUDEVMAN *) urbdrc->udevman; + USB_SEARCHMAN * searchman = (USB_SEARCHMAN*) urbdrc->searchman; + IUDEVICE * pdev = NULL; + uint32 ChannelId = 0; + int found = 0; + + ChannelId = callback->channel_mgr->GetChannelId(callback->channel); + + LLOGLN(0, ("urbdrc_on_close: channel id %d", ChannelId)); + + udevman->loading_lock(udevman); + udevman->rewind(udevman); + while(udevman->has_next(udevman)) + { + pdev = udevman->get_next(udevman); + if (pdev->get_channel_id(pdev) == ChannelId) + { + found = 1; + break; + } + } + udevman->loading_unlock(udevman); + if (found && pdev && !(pdev->isChannelClosed(pdev))) + { + pdev->setChannelClosed(pdev); + func_close_udevice(searchman, pdev); + } + + zfree(callback); + + LLOGLN(urbdrc_debug, ("urbdrc_on_close: success")); + + return 0; +} + +static int +urbdrc_on_new_channel_connection(IWTSListenerCallback * pListenerCallback, + IWTSVirtualChannel * pChannel, + uint8 * pData, + int * pbAccept, + IWTSVirtualChannelCallback ** ppCallback) +{ + URBDRC_LISTENER_CALLBACK * listener_callback = (URBDRC_LISTENER_CALLBACK *) pListenerCallback; + URBDRC_CHANNEL_CALLBACK * callback; + + LLOGLN(10, ("urbdrc_on_new_channel_connection:")); + callback = (URBDRC_CHANNEL_CALLBACK *) malloc(sizeof(URBDRC_CHANNEL_CALLBACK)); + callback->iface.OnDataReceived = urbdrc_on_data_received; + callback->iface.OnClose = urbdrc_on_close; + callback->plugin = listener_callback->plugin; + callback->channel_mgr = listener_callback->channel_mgr; + callback->channel = pChannel; + *ppCallback = (IWTSVirtualChannelCallback *) callback; + return 0; +} + +static int +urbdrc_plugin_initialize(IWTSPlugin * pPlugin, IWTSVirtualChannelManager * pChannelMgr) +{ + URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) pPlugin; + IUDEVMAN * udevman = NULL; + USB_SEARCHMAN * searchman = NULL; + + LLOGLN(10, ("urbdrc_plugin_initialize:")); + urbdrc->listener_callback = (URBDRC_LISTENER_CALLBACK *) malloc(sizeof(URBDRC_LISTENER_CALLBACK)); + memset(urbdrc->listener_callback, 0, sizeof(URBDRC_LISTENER_CALLBACK)); + + urbdrc->listener_callback->iface.OnNewChannelConnection = urbdrc_on_new_channel_connection; + urbdrc->listener_callback->plugin = pPlugin; + urbdrc->listener_callback->channel_mgr = pChannelMgr; + + /* Init searchman */ + udevman = urbdrc->udevman; + searchman = searchman_new((void *)urbdrc, udevman->get_defUsbDevice(udevman)); + urbdrc->searchman = searchman; + + return pChannelMgr->CreateListener(pChannelMgr, "URBDRC", 0, + (IWTSListenerCallback *) urbdrc->listener_callback, NULL); +} + +static int +urbdrc_plugin_terminated(IWTSPlugin * pPlugin) +{ + URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) pPlugin; + IUDEVMAN* udevman = urbdrc->udevman; + USB_SEARCHMAN* searchman = urbdrc->searchman; + + LLOGLN(10, ("urbdrc_plugin_terminated:")); + + if (searchman) + { + /* close searchman */ + searchman->close(searchman); + /* free searchman */ + if (searchman->strated) + { + struct timespec ts; + ts.tv_sec = time(NULL)+10; + ts.tv_nsec = 0; + sem_timedwait(&searchman->sem_term, &ts); + } + searchman->free(searchman); + searchman = NULL; + } + + if (udevman) + { + udevman->free(udevman); + udevman = NULL; + } + + if (urbdrc->listener_callback) + zfree(urbdrc->listener_callback); + if(urbdrc) + zfree(urbdrc); + return 0; +} + + +static void +urbdrc_register_udevman_plugin(IWTSPlugin* pPlugin, IUDEVMAN* udevman) +{ + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; + + if (urbdrc->udevman) + { + DEBUG_WARN("existing device, abort."); + return; + } + + DEBUG_DVC("device registered."); + + urbdrc->udevman = udevman; +} + + + +static int +urbdrc_load_udevman_plugin(IWTSPlugin* pPlugin, const char* name, RDP_PLUGIN_DATA* data) +{ + char* fullname; + PFREERDP_URBDRC_DEVICE_ENTRY entry; + FREERDP_URBDRC_SERVICE_ENTRY_POINTS entryPoints; + + if (strrchr(name, '.') != NULL) + { + entry = (PFREERDP_URBDRC_DEVICE_ENTRY) freerdp_load_plugin(name, URBDRC_UDEVMAN_EXPORT_FUNC_NAME); + } + else + { + fullname = xzalloc(strlen(name) + 8); + strcpy(fullname, name); + strcat(fullname, "_udevman"); + entry = (PFREERDP_URBDRC_DEVICE_ENTRY) freerdp_load_plugin(fullname, URBDRC_UDEVMAN_EXPORT_FUNC_NAME); + xfree(fullname); + } + + if (entry == NULL) + return false; + + entryPoints.plugin = pPlugin; + entryPoints.pRegisterUDEVMAN = urbdrc_register_udevman_plugin; + entryPoints.plugin_data = data; + + if (entry(&entryPoints) != 0) + { + DEBUG_WARN("%s entry returns error.", name); + return false; + } + + return true; +} + + + + +static int +urbdrc_process_plugin_data(IWTSPlugin* pPlugin, RDP_PLUGIN_DATA* data) +{ + boolean ret; + + if (data->data[0] && (strcmp((char*)data->data[0], "urbdrc") == 0 || strstr((char*) data->data[0], "/urbdrc.") != NULL)) + { + ret = urbdrc_load_udevman_plugin(pPlugin, "libusb", data); + return ret; + } + + return true; +} + + +int +DVCPluginEntry(IDRDYNVC_ENTRY_POINTS * pEntryPoints) +{ + int error = 0; + URBDRC_PLUGIN* urbdrc; + RDP_PLUGIN_DATA* data; + + urbdrc = (URBDRC_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "urbdrc"); + data = pEntryPoints->GetPluginData(pEntryPoints); + + if (urbdrc == NULL) + { + urbdrc = xnew(URBDRC_PLUGIN); + + urbdrc->iface.Initialize = urbdrc_plugin_initialize; + urbdrc->iface.Connected = NULL; + urbdrc->iface.Disconnected = NULL; + urbdrc->iface.Terminated = urbdrc_plugin_terminated; + urbdrc->searchman = NULL; + urbdrc->vchannel_status = INIT_CHANNEL_IN; + + urbdrc_debug = 10; + if (data->data[2] && strstr((char *)data->data[2], "debug")) + urbdrc_debug = 0; + + error = pEntryPoints->RegisterPlugin(pEntryPoints, "urbdrc", (IWTSPlugin *) urbdrc); + } + + if (error == 0) + urbdrc_process_plugin_data((IWTSPlugin*) urbdrc, data); + + return error; +} + diff --git a/channels/drdynvc/urbdrc/urbdrc_main.h b/channels/drdynvc/urbdrc/urbdrc_main.h new file mode 100644 index 000000000..146e8a4fe --- /dev/null +++ b/channels/drdynvc/urbdrc/urbdrc_main.h @@ -0,0 +1,269 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __URBDRC_MAIN_H +#define __URBDRC_MAIN_H + +#include "searchman.h" +#include "isoch_queue.h" + +#define DEVICE_HARDWARE_ID_SIZE 32 +#define DEVICE_COMPATIBILITY_ID_SIZE 36 +#define DEVICE_INSTANCE_STR_SIZE 37 +#define DEVICE_CONTAINER_STR_SIZE 39 + + +typedef struct _IUDEVICE IUDEVICE; +typedef struct _IUDEVMAN IUDEVMAN; + +#define BASIC_DEV_STATE_DEFINED(_arg, _type) \ + _type (*get_##_arg) (IUDEVICE *pdev); \ + void (*set_##_arg) (IUDEVICE *pdev, _type _arg) +#define BASIC_DEVMAN_STATE_DEFINED(_arg, _type) \ + _type (*get_##_arg) (IUDEVMAN *udevman); \ + void (*set_##_arg) (IUDEVMAN *udevman, _type _arg) + + +typedef struct _URBDRC_LISTENER_CALLBACK URBDRC_LISTENER_CALLBACK; +struct _URBDRC_LISTENER_CALLBACK +{ + IWTSListenerCallback iface; + + IWTSPlugin * plugin; + IWTSVirtualChannelManager * channel_mgr; +}; + +typedef struct _URBDRC_CHANNEL_CALLBACK URBDRC_CHANNEL_CALLBACK; +struct _URBDRC_CHANNEL_CALLBACK +{ + IWTSVirtualChannelCallback iface; + + IWTSPlugin * plugin; + IWTSVirtualChannelManager * channel_mgr; + IWTSVirtualChannel * channel; +}; + +typedef struct _URBDRC_PLUGIN URBDRC_PLUGIN; +struct _URBDRC_PLUGIN +{ + IWTSPlugin iface; + + URBDRC_LISTENER_CALLBACK * listener_callback; + + IUDEVMAN * udevman; + USB_SEARCHMAN * searchman; + uint32 first_channel_id; + uint32 vchannel_status; +}; + + +#define URBDRC_UDEVMAN_EXPORT_FUNC_NAME "FreeRDPUDEVMANEntry" + +typedef void (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman); + +struct _FREERDP_URBDRC_SERVICE_ENTRY_POINTS +{ + IWTSPlugin* plugin; + PREGISTERURBDRCSERVICE pRegisterUDEVMAN; + RDP_PLUGIN_DATA* plugin_data; +}; +typedef struct _FREERDP_URBDRC_SERVICE_ENTRY_POINTS FREERDP_URBDRC_SERVICE_ENTRY_POINTS; +typedef FREERDP_URBDRC_SERVICE_ENTRY_POINTS* PFREERDP_URBDRC_SERVICE_ENTRY_POINTS; + +typedef int (*PFREERDP_URBDRC_DEVICE_ENTRY)(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints); + + + + +typedef struct _TRANSFER_DATA TRANSFER_DATA; +struct _TRANSFER_DATA +{ + URBDRC_CHANNEL_CALLBACK * callback; + URBDRC_PLUGIN * urbdrc; + IUDEVMAN * udevman; + uint8 * pBuffer; + uint32 cbSize; + uint32 UsbDevice; +}; + + +struct _IUDEVICE +{ + /* Transfer */ + int (*isoch_transfer) (IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 TransferFlags, + int NoAck, + uint32 *ErrorCount, + uint32 *UrbdStatus, + uint32 *StartFrame, + uint32 NumberOfPackets, + uint8 *IsoPacket, + uint32 *BufferSize, + uint8 *Buffer, + int Timeout); + + int (*control_transfer) (IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 TransferFlags, + uint8 bmRequestType, + uint8 Request, + uint16 Value, + uint16 Index, + uint32 *UrbdStatus, + uint32 *BufferSize, + uint8 *Buffer, + uint32 Timeout); + + int (*bulk_or_interrupt_transfer) (IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 TransferFlags, + uint32 *UsbdStatus, + uint32 *BufferSize, + uint8 *Buffer, + uint32 Timeout); + + + int (*select_configuration) (IUDEVICE * idev, uint32 bConfigurationValue); + + int (*select_interface) (IUDEVICE * idev, uint8 InterfaceNumber, + uint8 AlternateSetting); + + int (*control_pipe_request) (IUDEVICE * idev, uint32 RequestId, + uint32 EndpointAddress, + uint32 *UsbdStatus, + int command); + + int (*control_query_device_text) (IUDEVICE * idev, uint32 TextType, + uint32 LocaleId, + uint32 *BufferSize, + uint8 * Buffer); + + int (*os_feature_descriptor_request) (IUDEVICE * idev, uint32 RequestId, + uint8 Recipient, + uint8 InterfaceNumber, + uint8 Ms_PageIndex, + uint16 Ms_featureDescIndex, + uint32 * UsbdStatus, + uint32 * BufferSize, + uint8* Buffer, + int Timeout); + + void (*cancel_all_transfer_request) (IUDEVICE * idev); + + int (*cancel_transfer_request) (IUDEVICE * idev, uint32 RequestId); + + int (*query_device_descriptor) (IUDEVICE * idev, int offset); + + void (*detach_kernel_driver) (IUDEVICE * idev); + + void (*attach_kernel_driver) (IUDEVICE * idev); + + int (*wait_action_completion) (IUDEVICE * idev); + + void (*push_action) (IUDEVICE * idev); + + void (*complete_action) (IUDEVICE * idev); + + /* Wait for 5 sec */ + int (*wait_for_detach) (IUDEVICE * idev); + + /* FIXME: Currently this is a way of stupid, SHOULD to improve it. + * Isochronous transfer must to FIFO */ + void (*lock_fifo_isoch) (IUDEVICE * idev); + void (*unlock_fifo_isoch) (IUDEVICE * idev); + + int (*query_device_port_status) (IUDEVICE * idev, uint32 *UsbdStatus, + uint32 * BufferSize, + uint8 * Buffer); + + int (*request_queue_is_none) (IUDEVICE * idev); + + MSUSB_CONFIG_DESCRIPTOR * (*complete_msconfig_setup) (IUDEVICE * idev, + MSUSB_CONFIG_DESCRIPTOR * MsConfig); + /* Basic state */ + int (*isCompositeDevice) (IUDEVICE * idev); + int (*isSigToEnd) (IUDEVICE * idev); + int (*isExist) (IUDEVICE * idev); + int (*isAlreadySend) (IUDEVICE * idev); + int (*isChannelClosed) (IUDEVICE * idev); + void (*SigToEnd) (IUDEVICE * idev); + void (*setAlreadySend) (IUDEVICE * idev); + void (*setChannelClosed) (IUDEVICE * idev); + char *(*getPath) (IUDEVICE * idev); + + BASIC_DEV_STATE_DEFINED(channel_id, uint32); + BASIC_DEV_STATE_DEFINED(UsbDevice, uint32); + BASIC_DEV_STATE_DEFINED(ReqCompletion, uint32); + BASIC_DEV_STATE_DEFINED(bus_number, uint16); + BASIC_DEV_STATE_DEFINED(dev_number, uint16); + BASIC_DEV_STATE_DEFINED(port_number, int); + BASIC_DEV_STATE_DEFINED(isoch_queue, void *); + BASIC_DEV_STATE_DEFINED(MsConfig, MSUSB_CONFIG_DESCRIPTOR *); + + BASIC_DEV_STATE_DEFINED(p_udev, void *); + BASIC_DEV_STATE_DEFINED(p_prev, void *); + BASIC_DEV_STATE_DEFINED(p_next, void *); + + /* Control semaphore or mutex lock */ + +}; + + + +struct _IUDEVMAN +{ + /* Standard */ + void (*free) (IUDEVMAN *idevman); + /* Manage devices */ + void (*rewind) (IUDEVMAN *idevman); + int (*has_next) (IUDEVMAN *idevman); + int (*unregister_udevice) (IUDEVMAN* idevman, int bus_number, + int dev_number); + int (*register_udevice) (IUDEVMAN* idevman, int bus_number, + int dev_number, + int UsbDevice, + uint16 idVendor, + uint16 idProduct, + int flag); + IUDEVICE *(*get_next) (IUDEVMAN *idevman); + IUDEVICE *(*get_udevice_by_UsbDevice) (IUDEVMAN * idevman, + uint32 UsbDevice); + IUDEVICE *(*get_udevice_by_UsbDevice_try_again) (IUDEVMAN * idevman, + uint32 UsbDevice); + /* Extension */ + int (*check_device_exist_by_id) (IUDEVMAN * idevman, uint16 idVendor, + uint16 idProduct); + int (*isAutoAdd) (IUDEVMAN * idevman); + /* Basic state */ + BASIC_DEVMAN_STATE_DEFINED(defUsbDevice, uint32); + BASIC_DEVMAN_STATE_DEFINED(device_num, int); + BASIC_DEVMAN_STATE_DEFINED(sem_timeout, int); + /* control semaphore or mutex lock */ + void (*loading_lock) (IUDEVMAN * idevman); + void (*loading_unlock) (IUDEVMAN * idevman); + void (*push_urb) (IUDEVMAN * idevman); + void (*wait_urb) (IUDEVMAN * idevman); +}; + + +#endif /* __URBDRC_MAIN_H */ diff --git a/channels/drdynvc/urbdrc/urbdrc_types.h b/channels/drdynvc/urbdrc/urbdrc_types.h new file mode 100644 index 000000000..38fbb4e1a --- /dev/null +++ b/channels/drdynvc/urbdrc/urbdrc_types.h @@ -0,0 +1,355 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __URBDRC_TYPES_H +#define __URBDRC_TYPES_H + + +#include "config.h" +#include +#include +#include +#include +#include +#include "drdynvc_types.h" + +#include +#include +#include + +#define CAPABILITIES_NEGOTIATOR 0x00000000 +#define CLIENT_DEVICE_SINK 0x00000001 +#define SERVER_CHANNEL_NOTIFICATION 0x00000002 +#define CLIENT_CHANNEL_NOTIFICATION 0x00000003 +#define BASE_USBDEVICE_NUM 0x00000005 + +#define RIMCALL_RELEASE 0x00000001 +#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100 +#define CHANNEL_CREATED 0x00000100 +#define ADD_VIRTUAL_CHANNEL 0x00000100 +#define ADD_DEVICE 0x00000101 + + +#define INIT_CHANNEL_IN 1 +#define INIT_CHANNEL_OUT 0 + + +/* InterfaceClass */ +#define CLASS_RESERVE 0x00 +#define CLASS_AUDIO 0x01 +#define CLASS_COMMUNICATION_IF 0x02 +#define CLASS_HID 0x03 +#define CLASS_PHYSICAL 0x05 +#define CLASS_IMAGE 0x06 +#define CLASS_PRINTER 0x07 +#define CLASS_MASS_STORAGE 0x08 +#define CLASS_HUB 0x09 +#define CLASS_COMMUNICATION_DATA_IF 0x0a +#define CLASS_SMART_CARD 0x0b +#define CLASS_CONTENT_SECURITY 0x0d +#define CLASS_VIDEO 0x0e +#define CLASS_PERSONAL_HEALTHCARE 0x0f +#define CLASS_DIAGNOSTIC 0xdc +#define CLASS_WIRELESS_CONTROLLER 0xe0 +#define CLASS_ELSE_DEVICE 0xef +#define CLASS_DEPENDENCE 0xfe +#define CLASS_VENDOR_DEPENDENCE 0xff + + +/* usb version */ +#define USB_v1_0 0x100 +#define USB_v1_1 0x110 +#define USB_v2_0 0x200 +#define USB_v3_0 0x300 + +#define STREAM_ID_NONE 0x0 +#define STREAM_ID_PROXY 0x1 +#define STREAM_ID_STUB 0x2 + +#define CANCEL_REQUEST 0x00000100 +#define REGISTER_REQUEST_CALLBACK 0x00000101 +#define IO_CONTROL 0x00000102 +#define INTERNAL_IO_CONTROL 0x00000103 +#define QUERY_DEVICE_TEXT 0x00000104 +#define TRANSFER_IN_REQUEST 0x00000105 +#define TRANSFER_OUT_REQUEST 0x00000106 +#define RETRACT_DEVICE 0x00000107 + + +#define IOCONTROL_COMPLETION 0x00000100 +#define URB_COMPLETION 0x00000101 +#define URB_COMPLETION_NO_DATA 0x00000102 + +/* The USB device is to be stopped from being redirected because the + * device is blocked by the server's policy. */ +#define UsbRetractReason_BlockedByPolicy 0x00000001 + + + +enum device_text_type { + DeviceTextDescription = 0, + DeviceTextLocationInformation = 1, +}; + +enum device_descriptor_table { + B_LENGTH = 0, + B_DESCRIPTOR_TYPE = 1, + BCD_USB = 2, + B_DEVICE_CLASS = 4, + B_DEVICE_SUBCLASS = 5, + B_DEVICE_PROTOCOL = 6, + B_MAX_PACKET_SIZE0 = 7, + ID_VENDOR = 8, + ID_PRODUCT = 10, + BCD_DEVICE = 12, + I_MANUFACTURER = 14, + I_PRODUCT = 15, + I_SERIAL_NUMBER = 16, + B_NUM_CONFIGURATIONS = 17 +}; + + +#define PIPE_CANCEL 0 +#define PIPE_RESET 1 + +#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003 +#define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007 +#define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013 +#define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F +#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027 + + + +#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000 +#define URB_FUNCTION_SELECT_INTERFACE 0x0001 +#define URB_FUNCTION_ABORT_PIPE 0x0002 +#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003 +#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004 +#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005 +#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006 +#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007 +#define URB_FUNCTION_CONTROL_TRANSFER 0x0008 +#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 +#define URB_FUNCTION_ISOCH_TRANSFER 0x000A +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B +#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C +#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D +#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E +#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F +#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010 +#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011 +#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012 +#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013 +#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014 +#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015 +#define URB_FUNCTION_RESERVED_0X0016 0x0016 +#define URB_FUNCTION_VENDOR_DEVICE 0x0017 +#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 +#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 +#define URB_FUNCTION_CLASS_DEVICE 0x001A +#define URB_FUNCTION_CLASS_INTERFACE 0x001B +#define URB_FUNCTION_CLASS_ENDPOINT 0x001C +#define URB_FUNCTION_RESERVE_0X001D 0x001D +#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E +#define URB_FUNCTION_CLASS_OTHER 0x001F +#define URB_FUNCTION_VENDOR_OTHER 0x0020 +#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021 +#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022 +#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023 +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024 +#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025 +#define URB_FUNCTION_GET_CONFIGURATION 0x0026 +#define URB_FUNCTION_GET_INTERFACE 0x0027 +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028 +#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029 +#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A +#define URB_FUNCTION_RESERVE_0X002B 0x002B +#define URB_FUNCTION_RESERVE_0X002C 0x002C +#define URB_FUNCTION_RESERVE_0X002D 0x002D +#define URB_FUNCTION_RESERVE_0X002E 0x002E +#define URB_FUNCTION_RESERVE_0X002F 0x002F +// USB 2.0 calls start at 0x0030 +#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030 +#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031 +#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032 + + + + +#define USBD_STATUS_SUCCESS 0x0 +#define USBD_STATUS_PENDING 0x40000000 +#define USBD_STATUS_CANCELED 0xC0010000 + +#define USBD_STATUS_CRC 0xC0000001 +#define USBD_STATUS_BTSTUFF 0xC0000002 +#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003 +#define USBD_STATUS_STALL_PID 0xC0000004 +#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005 +#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006 +#define USBD_STATUS_UNEXPECTED_PID 0xC0000007 +#define USBD_STATUS_DATA_OVERRUN 0xC0000008 +#define USBD_STATUS_DATA_UNDERRUN 0xC0000009 +#define USBD_STATUS_RESERVED1 0xC000000A +#define USBD_STATUS_RESERVED2 0xC000000B +#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C +#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D + +/* unknow */ +#define USBD_STATUS_NO_DATA 0xC000000E + +#define USBD_STATUS_NOT_ACCESSED 0xC000000F +#define USBD_STATUS_FIFO 0xC0000010 +#define USBD_STATUS_XACT_ERROR 0xC0000011 +#define USBD_STATUS_BABBLE_DETECTED 0xC0000012 +#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013 + +#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00 +#define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000 +#define USBD_STATUS_TIMEOUT 0xC0006000 +#define USBD_STATUS_DEVICE_GONE 0xC0007000 + +#define USBD_STATUS_NO_MEMORY 0x80000100 +#define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200 +#define USBD_STATUS_INVALID_PARAMETER 0x80000300 +#define USBD_STATUS_REQUEST_FAILED 0x80000500 +#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600 +#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900 + +// Values for URB TransferFlags Field +// + +/* + Set if data moves device->host +*/ +#define USBD_TRANSFER_DIRECTION 0x00000001 +/* + This bit if not set indicates that a short packet, and hence, + a short transfer is an error condition +*/ +#define USBD_SHORT_TRANSFER_OK 0x00000002 +/* + Subit the iso transfer on the next frame +*/ +#define USBD_START_ISO_TRANSFER_ASAP 0x00000004 +#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008 + + +#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) & USBD_TRANSFER_DIRECTION) + +#define USBD_TRANSFER_DIRECTION_OUT 0 +#define USBD_TRANSFER_DIRECTION_IN 1 + +#define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \ + USBD_TRANSFER_DIRECTION | \ + USBD_START_ISO_TRANSFER_ASAP | \ + USBD_DEFAULT_PIPE_TRANSFER) + + + + +#define ENDPOINT_HALT 0x00 +#define DEVICE_REMOTE_WAKEUP 0x01 + + +/* transfer type */ +#define CONTROL_TRANSFER 0x00 +#define ISOCHRONOUS_TRANSFER 0x01 +#define BULK_TRANSFER 0x02 +#define INTERRUPT_TRANSFER 0x03 + + + +#define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE) +#define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE) +#define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR) +#define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS) +#define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS) +#define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE) +#define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE) + + + +#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 +#define USBD_PF_SHORT_PACKET_OPT 0x00000002 +#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 +#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 + +/* feature request */ +#define URB_SET_FEATURE 0x00 +#define URB_CLEAR_FEATURE 0x01 + +#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 +#define USBD_PF_SHORT_PACKET_OPT 0x00000002 +#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 +#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 + + +#define URB_CONTROL_TRANSFER_EXTERNAL 0x1 +#define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0 + + +#define USBFS_URB_SHORT_NOT_OK 0x01 +#define USBFS_URB_ISO_ASAP 0x02 +#define USBFS_URB_BULK_CONTINUATION 0x04 +#define USBFS_URB_QUEUE_BULK 0x10 + + +#define URBDRC_DEVICE_INITIALIZED 0x01 +#define URBDRC_DEVICE_NOT_FOUND 0x02 +#define URBDRC_DEVICE_SIGNAL_END 0x04 +#define URBDRC_DEVICE_CHANNEL_CLOSED 0x08 +#define URBDRC_DEVICE_ALREADY_SEND 0x10 +#define URBDRC_DEVICE_DETACH_KERNEL 0x20 + + +#define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01 +#define UDEVMAN_FLAG_ADD_BY_ADDR 0x02 +#define UDEVMAN_FLAG_ADD_BY_AUTO 0x04 +#define UDEVMAN_FLAG_DEBUG 0x08 + + +#define MAX_URB_REQUSET_NUM 0x80 + + +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { printf _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { printf _args ; printf("\n"); } } while (0) + + +#define dummy_wait_obj(void) do{ sleep(5); } while(0) +#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0) + +#define ISOCH_FIFO 1 +#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */ + +#define urbdrc_get_mstime(_t) do { \ + struct timeval _tp; \ + gettimeofday(&_tp, 0); \ + _t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \ +} while (0) + + +extern int urbdrc_debug; + +#endif /* __URBDRC_TYPES_H */ diff --git a/include/freerdp/dvc.h b/include/freerdp/dvc.h index dfa487c28..98a382ae7 100644 --- a/include/freerdp/dvc.h +++ b/include/freerdp/dvc.h @@ -92,6 +92,10 @@ struct _IWTSVirtualChannelManager This is a FreeRDP extension to standard MS API. */ int (*PushEvent) (IWTSVirtualChannelManager* pChannelMgr, RDP_EVENT* pEvent); + /* Find the channel or ID to send data to a specific endpoint. */ + uint32 (*GetChannelId) (IWTSVirtualChannel * channel); + IWTSVirtualChannel* (*FindChannelById) (IWTSVirtualChannelManager* pChannelMgr, + uint32 ChannelId); }; struct _IWTSPlugin diff --git a/include/freerdp/utils/msusb.h b/include/freerdp/utils/msusb.h new file mode 100644 index 000000000..f2ef6beaa --- /dev/null +++ b/include/freerdp/utils/msusb.h @@ -0,0 +1,148 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MSCONFIG_H +#define __MSCONFIG_H + +#include +#include +#include + +/* a safer free helper */ +#define zfree(p) do { if (p != NULL) {free(p); p = NULL;} } while (0) + +/* Data maintenance helper only used in URBDRC */ +#define data_read_uint8(_p, _v) do { _v = \ + *((uint8 *) (_p)); \ + } while (0) +#define data_read_uint16(_p, _v) do { _v = \ + ((uint16) (*((uint8 *) (_p)))) + \ + ((uint16) (*(((uint8 *) (_p)) + 1)) << 8); \ + } while (0) +#define data_read_uint32(_p, _v) do { _v = \ + (uint32) (*((uint8 *) (_p))) + \ + ((uint32) (*(((uint8 *) (_p)) + 1)) << 8) + \ + ((uint32) (*(((uint8 *) (_p)) + 2)) << 16) + \ + ((uint32) (*(((uint8 *) (_p)) + 3)) << 24); \ + } while (0) +#define data_read_uint64(_p, _v) do { _v = \ + (uint64) (*((uint8 *) (_p))) + \ + ((uint64) (*(((uint8 *) (_p)) + 1)) << 8) + \ + ((uint64) (*(((uint8 *) (_p)) + 2)) << 16) + \ + ((uint64) (*(((uint8 *) (_p)) + 3)) << 24) + \ + ((uint64) (*(((uint8 *) (_p)) + 4)) << 32) + \ + ((uint64) (*(((uint8 *) (_p)) + 5)) << 40) + \ + ((uint64) (*(((uint8 *) (_p)) + 6)) << 48) + \ + ((uint64) (*(((uint8 *) (_p)) + 7)) << 56); \ + } while (0) + +#define data_write_uint8(_p, _v) do { \ + *((uint8 *) _p) = (uint8) (_v); \ + } while (0) +#define data_write_uint16(_p, _v) do { \ + *((uint8 *) _p) = (uint8) (((uint16) (_v)) & 0xff); \ + *(((uint8 *) _p) + 1) = (uint8) ((((uint16) (_v)) >> 8) & 0xff); \ + } while (0) +#define data_write_uint32(_p, _v) do { \ + *((uint8 *) _p) = (uint8) (((uint32) (_v)) & 0xff); \ + *(((uint8 *) _p) + 1) = (uint8) ((((uint32) (_v)) >> 8) & 0xff); \ + *(((uint8 *) _p) + 2) = (uint8) ((((uint32) (_v)) >> 16) & 0xff); \ + *(((uint8 *) _p) + 3) = (uint8) ((((uint32) (_v)) >> 24) & 0xff); \ + } while (0) +#define data_write_uint64(_p, _v) do { \ + *((uint8 *) _p) = (uint8) (((uint64) (_v)) & 0xff); \ + *(((uint8 *) _p) + 1) = (uint8) ((((uint64) (_v)) >> 8) & 0xff); \ + *(((uint8 *) _p) + 2) = (uint8) ((((uint64) (_v)) >> 16) & 0xff); \ + *(((uint8 *) _p) + 3) = (uint8) ((((uint64) (_v)) >> 24) & 0xff); \ + *(((uint8 *) _p) + 4) = (uint8) ((((uint64) (_v)) >> 32) & 0xff); \ + *(((uint8 *) _p) + 5) = (uint8) ((((uint64) (_v)) >> 40) & 0xff); \ + *(((uint8 *) _p) + 6) = (uint8) ((((uint64) (_v)) >> 48) & 0xff); \ + *(((uint8 *) _p) + 7) = (uint8) ((((uint64) (_v)) >> 56) & 0xff); \ + } while (0) + +typedef struct _MSUSB_INTERFACE_DESCRIPTOR MSUSB_INTERFACE_DESCRIPTOR; +typedef struct _MSUSB_PIPE_DESCRIPTOR MSUSB_PIPE_DESCRIPTOR; +typedef struct _MSUSB_CONFIG_DESCRIPTOR MSUSB_CONFIG_DESCRIPTOR; + +struct _MSUSB_PIPE_DESCRIPTOR +{ + uint16 MaximumPacketSize; + uint32 MaximumTransferSize; + uint32 PipeFlags; + uint32 PipeHandle; + uint8 bEndpointAddress; + uint8 bInterval; + uint8 PipeType; + int InitCompleted; +} __attribute__((packed)); + + +struct _MSUSB_INTERFACE_DESCRIPTOR +{ + uint16 Length; + uint16 NumberOfPipesExpected; + uint8 InterfaceNumber; + uint8 AlternateSetting; + uint32 NumberOfPipes; + uint32 InterfaceHandle; + uint8 bInterfaceClass; + uint8 bInterfaceSubClass; + uint8 bInterfaceProtocol; + MSUSB_PIPE_DESCRIPTOR ** MsPipes; + int InitCompleted; +} __attribute__((packed)); + +struct _MSUSB_CONFIG_DESCRIPTOR +{ + uint16 wTotalLength; + uint8 bConfigurationValue; + uint32 ConfigurationHandle; + uint32 NumInterfaces; + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + int InitCompleted; + int MsOutSize; +} __attribute__((packed)); + + +/* MSUSB_PIPE exported functions */ +void +msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR * MsInterface, MSUSB_PIPE_DESCRIPTOR ** NewMsPipes, uint32 NewNumberOfPipes); + +/* MSUSB_INTERFACE exported functions */ +void +msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR * MsConfig, uint8 InterfaceNumber, MSUSB_INTERFACE_DESCRIPTOR * NewMsInterface); +MSUSB_INTERFACE_DESCRIPTOR * +msusb_msinterface_read(uint8 * data, uint32 data_size, int * offset); +int +msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR * MsInterface, uint8 * data, int * offset); + +/* MSUSB_CONFIG exported functions */ +MSUSB_CONFIG_DESCRIPTOR * +msusb_msconfig_new(); +void +msusb_msconfig_free(MSUSB_CONFIG_DESCRIPTOR * MsConfig); +MSUSB_CONFIG_DESCRIPTOR * +msusb_msconfig_read(uint8 * data, uint32 data_size, uint32 NumInterfaces); +int +msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR * MsConfg, uint8 * data, int * offset); +void +msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR * MsConfg); + +#endif diff --git a/libfreerdp-utils/CMakeLists.txt b/libfreerdp-utils/CMakeLists.txt index a12b5ce2b..1eb5745cd 100644 --- a/libfreerdp-utils/CMakeLists.txt +++ b/libfreerdp-utils/CMakeLists.txt @@ -49,7 +49,8 @@ set(FREERDP_UTILS_SRCS thread.c time.c unicode.c - wait_obj.c) + wait_obj.c + msusb.c) add_library(freerdp-utils ${FREERDP_UTILS_SRCS}) diff --git a/libfreerdp-utils/msusb.c b/libfreerdp-utils/msusb.c new file mode 100644 index 000000000..0c918b8ca --- /dev/null +++ b/libfreerdp-utils/msusb.c @@ -0,0 +1,368 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include + +#include +#include + +static MSUSB_PIPE_DESCRIPTOR * +msusb_mspipe_new() +{ + MSUSB_PIPE_DESCRIPTOR * MsPipe = (MSUSB_PIPE_DESCRIPTOR *)malloc(sizeof(MSUSB_PIPE_DESCRIPTOR)); + memset(MsPipe, 0, sizeof(MSUSB_PIPE_DESCRIPTOR)); + return MsPipe; +} + +static void +msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR ** MsPipes, uint32 NumberOfPipes) +{ + int pnum = 0; + if (MsPipes) + { + for (pnum = 0; pnum < NumberOfPipes && MsPipes[pnum]; pnum++) + { + zfree(MsPipes[pnum]); + } + zfree(MsPipes); + } +} + +void +msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR * MsInterface, MSUSB_PIPE_DESCRIPTOR ** NewMsPipes, uint32 NewNumberOfPipes) +{ + /* free orignal MsPipes */ + msusb_mspipes_free(MsInterface->MsPipes, MsInterface->NumberOfPipes); + /* And replace it */ + MsInterface->MsPipes = NewMsPipes; + MsInterface->NumberOfPipes = NewNumberOfPipes; + +} + +static MSUSB_PIPE_DESCRIPTOR ** +msusb_mspipes_read(uint8 * data, uint32 data_size, uint32 NumberOfPipes, int * offset) +{ + MSUSB_PIPE_DESCRIPTOR ** MsPipes; + int pnum, move = 0; + + MsPipes = (MSUSB_PIPE_DESCRIPTOR **)malloc(NumberOfPipes * + sizeof(MSUSB_PIPE_DESCRIPTOR *)); + + for(pnum = 0;pnum < NumberOfPipes; pnum++) + { + MSUSB_PIPE_DESCRIPTOR * MsPipe = msusb_mspipe_new(); + + data_read_uint16(data + move, MsPipe->MaximumPacketSize); + data_read_uint32(data + move + 4, MsPipe->MaximumTransferSize); + data_read_uint32(data + move + 8, MsPipe->PipeFlags); + move += 12; +/* Already set to zero by memset + MsPipe->PipeHandle = 0; + MsPipe->bEndpointAddress = 0; + MsPipe->bInterval = 0; + MsPipe->PipeType = 0; + MsPipe->InitCompleted = 0; +*/ + + MsPipes[pnum] = MsPipe; + } + *offset += move; + + return MsPipes; +} + +static MSUSB_INTERFACE_DESCRIPTOR * +msusb_msinterface_new() +{ + MSUSB_INTERFACE_DESCRIPTOR * MsInterface = (MSUSB_INTERFACE_DESCRIPTOR *)malloc(sizeof(MSUSB_INTERFACE_DESCRIPTOR)); + memset(MsInterface, 0, sizeof(MSUSB_INTERFACE_DESCRIPTOR)); + return MsInterface; +} + +static void +msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR * MsInterface) +{ + if (MsInterface) + { + msusb_mspipes_free(MsInterface->MsPipes, MsInterface->NumberOfPipes); + MsInterface->MsPipes = NULL; + zfree(MsInterface); + } +} + +static void +msusb_msinterface_free_list(MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces, uint32 NumInterfaces) +{ + int inum = 0; + + if (MsInterfaces) + { + for (inum = 0; inum < NumInterfaces; inum++) + { + msusb_msinterface_free(MsInterfaces[inum]); + } + zfree(MsInterfaces); + } +} + +void +msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR * MsConfig, uint8 InterfaceNumber, MSUSB_INTERFACE_DESCRIPTOR * NewMsInterface) +{ + msusb_msinterface_free(MsConfig->MsInterfaces[InterfaceNumber]); + MsConfig->MsInterfaces[InterfaceNumber] = NewMsInterface; +} + +MSUSB_INTERFACE_DESCRIPTOR * +msusb_msinterface_read(uint8 * data, uint32 data_size, int * offset) +{ + MSUSB_INTERFACE_DESCRIPTOR * MsInterface; + + MsInterface = msusb_msinterface_new(); + + data_read_uint16(data, MsInterface->Length); + data_read_uint16(data + 2, MsInterface->NumberOfPipesExpected); + data_read_uint8(data + 4, MsInterface->InterfaceNumber); + data_read_uint8(data + 5, MsInterface->AlternateSetting); + data_read_uint32(data + 8, MsInterface->NumberOfPipes); + *offset += 12; + + MsInterface->InterfaceHandle = 0; + MsInterface->bInterfaceClass = 0; + MsInterface->bInterfaceSubClass = 0; + MsInterface->bInterfaceProtocol = 0; + MsInterface->InitCompleted = 0; + MsInterface->MsPipes = NULL; + + if (MsInterface->NumberOfPipes > 0) + { + MsInterface->MsPipes = + msusb_mspipes_read(data+(*offset), data_size-(*offset), MsInterface->NumberOfPipes, offset); + } + + return MsInterface; +} + +int +msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR * MsInterface, uint8 * data, int * offset) +{ + MSUSB_PIPE_DESCRIPTOR ** MsPipes; + MSUSB_PIPE_DESCRIPTOR * MsPipe; + int pnum = 0, move = 0; + + /* Length */ + data_write_uint16(data, MsInterface->Length); + /* InterfaceNumber */ + data_write_uint8(data + 2, MsInterface->InterfaceNumber); + /* AlternateSetting */ + data_write_uint8(data + 3, MsInterface->AlternateSetting); + /* bInterfaceClass */ + data_write_uint8(data + 4, MsInterface->bInterfaceClass); + /* bInterfaceSubClass */ + data_write_uint8(data + 5, MsInterface->bInterfaceSubClass); + /* bInterfaceProtocol */ + data_write_uint8(data + 6, MsInterface->bInterfaceProtocol); + /* Padding */ + data_write_uint8(data + 7, 0); + /* InterfaceHandle */ + data_write_uint32(data + 8, MsInterface->InterfaceHandle); + /* NumberOfPipes */ + data_write_uint32(data + 12, MsInterface->NumberOfPipes); + move += 16; + /* Pipes */ + MsPipes = MsInterface->MsPipes; + for(pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) + { + MsPipe = MsPipes[pnum]; + /* MaximumPacketSize */ + data_write_uint16(data + move, MsPipe->MaximumPacketSize); + /* EndpointAddress */ + data_write_uint8(data + move + 2, MsPipe->bEndpointAddress); + /* Interval */ + data_write_uint8(data + move + 3, MsPipe->bInterval); + /* PipeType */ + data_write_uint32(data + move + 4, MsPipe->PipeType); + /* PipeHandle */ + data_write_uint32(data + move + 8, MsPipe->PipeHandle); + /* MaximumTransferSize */ + data_write_uint32(data + move + 12, MsPipe->MaximumTransferSize); + /* PipeFlags */ + data_write_uint32(data + move + 16, MsPipe->PipeFlags); + + move += 20; + } + + *offset += move; + + return 0; +} + +static MSUSB_INTERFACE_DESCRIPTOR ** +msusb_msinterface_read_list(uint8 * data, uint32 data_size, uint32 NumInterfaces) +{ + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + int inum, offset = 0; + + MsInterfaces = (MSUSB_INTERFACE_DESCRIPTOR **)malloc(NumInterfaces * + sizeof(MSUSB_INTERFACE_DESCRIPTOR *)); + + for(inum = 0; inum < NumInterfaces; inum++) + { + MsInterfaces[inum] = msusb_msinterface_read(data + offset, data_size - offset, &offset); + } + + + return MsInterfaces; +} + +int +msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR * MsConfg, uint8 * data, int * offset) +{ + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + MSUSB_INTERFACE_DESCRIPTOR * MsInterface; + int inum = 0; + + /* ConfigurationHandle*/ + data_write_uint32(data + *offset, MsConfg->ConfigurationHandle); + /* NumInterfaces*/ + data_write_uint32(data + *offset + 4, MsConfg->NumInterfaces); + *offset += 8; + /* Interfaces */ + MsInterfaces = MsConfg->MsInterfaces; + for(inum = 0; inum < MsConfg->NumInterfaces; inum++) + { + MsInterface = MsInterfaces[inum]; + msusb_msinterface_write(MsInterface, data + (*offset), offset); + } + + return 0; +} + +MSUSB_CONFIG_DESCRIPTOR * +msusb_msconfig_new() +{ + MSUSB_CONFIG_DESCRIPTOR * MsConfig = NULL; + MsConfig = (MSUSB_CONFIG_DESCRIPTOR *)malloc(sizeof(MSUSB_CONFIG_DESCRIPTOR)); + memset(MsConfig, 0, sizeof(MSUSB_CONFIG_DESCRIPTOR)); + + return MsConfig; +} + +void +msusb_msconfig_free(MSUSB_CONFIG_DESCRIPTOR * MsConfig) +{ + if (MsConfig) + { + msusb_msinterface_free_list(MsConfig->MsInterfaces, MsConfig->NumInterfaces); + MsConfig->MsInterfaces = NULL; + zfree(MsConfig); + } +} + +MSUSB_CONFIG_DESCRIPTOR * +msusb_msconfig_read(uint8 * data, uint32 data_size, uint32 NumInterfaces) +{ + MSUSB_CONFIG_DESCRIPTOR * MsConfig; + uint8 lenConfiguration, typeConfiguration; + uint16 lenInterface; + int i, offset = 0; + + MsConfig = msusb_msconfig_new(); + + for(i = 0; i < NumInterfaces; i++) + { + data_read_uint16(data + offset, lenInterface); + offset += lenInterface; + } + data_read_uint8(data + offset, lenConfiguration); + data_read_uint8(data + offset + 1, typeConfiguration); + if (lenConfiguration != 0x9 || typeConfiguration != 0x2) + { + DEBUG("%s: len and type must be 0x9 and 0x2 , but it is 0x%x and 0x%x", + lenConfiguration, typeConfiguration); + } + data_read_uint16(data + offset + 2, MsConfig->wTotalLength); + data_read_uint8(data + offset + 5, MsConfig->bConfigurationValue); + MsConfig->NumInterfaces = NumInterfaces; + MsConfig->ConfigurationHandle = 0; + MsConfig->InitCompleted = 0; + MsConfig->MsOutSize = 0; + MsConfig->MsInterfaces = NULL; + offset = 0; + + if (NumInterfaces > 0) + { + MsConfig->MsInterfaces = + msusb_msinterface_read_list(data, data_size, NumInterfaces); + } + + return MsConfig; + +} + +void +msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR * MsConfig) +{ + MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces; + MSUSB_INTERFACE_DESCRIPTOR * MsInterface; + MSUSB_PIPE_DESCRIPTOR ** MsPipes; + MSUSB_PIPE_DESCRIPTOR * MsPipe; + int inum = 0, pnum = 0; + + printf("=================MsConfig:========================\n"); + printf("wTotalLength:%d\n", MsConfig->wTotalLength); + printf("bConfigurationValue:%d\n", MsConfig->bConfigurationValue); + printf("ConfigurationHandle:0x%x\n", MsConfig->ConfigurationHandle); + printf("InitCompleted:%d\n", MsConfig->InitCompleted); + printf("MsOutSize:%d\n", MsConfig->MsOutSize); + printf("NumInterfaces:%d\n\n", MsConfig->NumInterfaces); + MsInterfaces = MsConfig->MsInterfaces; + for(inum = 0; inum < MsConfig->NumInterfaces; inum++) + { + MsInterface = MsInterfaces[inum]; + printf(" Interfase: %d\n", MsInterface->InterfaceNumber); + printf(" Length: %d\n", MsInterface->Length); + printf(" NumberOfPipesExpected: %d\n", MsInterface->NumberOfPipesExpected); + printf(" AlternateSetting: %d\n", MsInterface->AlternateSetting); + printf(" NumberOfPipes: %d\n", MsInterface->NumberOfPipes); + printf(" InterfaceHandle: 0x%x\n", MsInterface->InterfaceHandle); + printf(" bInterfaceClass: 0x%x\n", MsInterface->bInterfaceClass); + printf(" bInterfaceSubClass: 0x%x\n", MsInterface->bInterfaceSubClass); + printf(" bInterfaceProtocol: 0x%x\n", MsInterface->bInterfaceProtocol); + printf(" InitCompleted: %d\n\n", MsInterface->InitCompleted); + MsPipes = MsInterface->MsPipes; + for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) + { + MsPipe = MsPipes[pnum]; + printf(" Pipe: %d\n", pnum); + printf(" MaximumPacketSize: 0x%x\n", MsPipe->MaximumPacketSize); + printf(" MaximumTransferSize: 0x%x\n", MsPipe->MaximumTransferSize); + printf(" PipeFlags: 0x%x\n", MsPipe->PipeFlags); + printf(" PipeHandle: 0x%x\n", MsPipe->PipeHandle); + printf(" bEndpointAddress: 0x%x\n", MsPipe->bEndpointAddress); + printf(" bInterval: %d\n", MsPipe->bInterval); + printf(" PipeType: 0x%x\n", MsPipe->PipeType); + printf(" InitCompleted: %d\n\n", MsPipe->InitCompleted); + } + } + printf("==================================================\n"); +} From 8e64d1803bdf4c09aa3a19eff32e6eced8928e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 25 Apr 2012 14:27:38 -0400 Subject: [PATCH 02/64] drdynvc: fix value of cb field --- channels/drdynvc/drdynvc_main.c | 10 +++++++++- libfreerdp-utils/svc_plugin.c | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/channels/drdynvc/drdynvc_main.c b/channels/drdynvc/drdynvc_main.c index 42d422d25..afe9bb522 100644 --- a/channels/drdynvc/drdynvc_main.c +++ b/channels/drdynvc/drdynvc_main.c @@ -45,6 +45,7 @@ struct drdynvc_plugin int PriorityCharge1; int PriorityCharge2; int PriorityCharge3; + int channel_error; IWTSVirtualChannelManager* channel_mgr; }; @@ -65,7 +66,7 @@ static int drdynvc_write_variable_uint(STREAM* stream, uint32 val) } else { - cb = 3; + cb = 2; stream_write_uint32(stream, val); } return cb; @@ -82,6 +83,9 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, uint32 ChannelId, uint8* data, ui DEBUG_DVC("ChannelId=%d size=%d", ChannelId, data_size); + if (drdynvc->channel_error != CHANNEL_RC_OK) + return 1; + data_out = stream_new(CHANNEL_CHUNK_LENGTH); stream_set_pos(data_out, 1); cbChId = drdynvc_write_variable_uint(data_out, ChannelId); @@ -139,6 +143,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, uint32 ChannelId, uint8* data, ui } if (error != CHANNEL_RC_OK) { + drdynvc->channel_error = error; DEBUG_WARN("VirtualChannelWrite failed %d", error); return 1; } @@ -182,6 +187,8 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in DEBUG_WARN("VirtualChannelWrite failed %d", error); return 1; } + drdynvc->channel_error = error; + return 0; } @@ -329,6 +336,7 @@ static void drdynvc_process_connect(rdpSvcPlugin* plugin) DEBUG_DVC("connecting"); drdynvc->channel_mgr = dvcman_new(drdynvc); + drdynvc->channel_error = 0; dvcman_load_plugin(drdynvc->channel_mgr, svc_plugin_get_data(plugin)); dvcman_init(drdynvc->channel_mgr); } diff --git a/libfreerdp-utils/svc_plugin.c b/libfreerdp-utils/svc_plugin.c index 72379d57d..ac0c51cc8 100644 --- a/libfreerdp-utils/svc_plugin.c +++ b/libfreerdp-utils/svc_plugin.c @@ -384,8 +384,12 @@ int svc_plugin_send(rdpSvcPlugin* plugin, STREAM* data_out) DEBUG_SVC("length %d", stream_get_length(data_out)); - error = plugin->channel_entry_points.pVirtualChannelWrite(plugin->priv->open_handle, - stream_get_data(data_out), stream_get_length(data_out), data_out); + if (!plugin || !plugin->priv) + error = CHANNEL_RC_BAD_INIT_HANDLE; + else + error = plugin->channel_entry_points.pVirtualChannelWrite(plugin->priv->open_handle, + stream_get_data(data_out), stream_get_length(data_out), data_out); + if (error != CHANNEL_RC_OK) { stream_free(data_out); From 6f61ef8772db1d73893ce8d3763bf751990abc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 30 Apr 2012 16:28:32 -0400 Subject: [PATCH 03/64] urbdrc: fix compilation against libusb --- channels/drdynvc/urbdrc/libusb/libusb_udevice.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevice.c b/channels/drdynvc/urbdrc/libusb/libusb_udevice.c index 9b70e9d1d..81a7cd546 100644 --- a/channels/drdynvc/urbdrc/libusb/libusb_udevice.c +++ b/channels/drdynvc/urbdrc/libusb/libusb_udevice.c @@ -1287,8 +1287,7 @@ libusb_udev_isoch_transfer(IUDEVICE * idev, uint32 RequestId, uint32 EndpointAdd *BufferSize, NumberOfPackets, func_iso_callback, - &iso_user_data, - TransferFlags, + &iso_user_data, 2000); libusb_set_iso_packet_lengths(iso_transfer, iso_packet_size); @@ -1448,8 +1447,7 @@ libusb_udev_bulk_or_interrupt_transfer(IUDEVICE * idev, uint32 RequestId, Buffer, *BufferSize, func_bulk_transfer_cb, - &completed, - TransferFlags, + &completed, Timeout); transfer->type = (unsigned char)transfer_type; From 4ab065bb88ffe1309b8317bcb1c6833255f9eef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 20 Sep 2012 20:23:09 -0400 Subject: [PATCH 04/64] third-party: fix gitignore --- third-party/.gitignore | 4 +++- third-party/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/third-party/.gitignore b/third-party/.gitignore index 453af308c..efc4279f7 100644 --- a/third-party/.gitignore +++ b/third-party/.gitignore @@ -1,2 +1,4 @@ -**/** +* +**/* +!CMakeLists.txt diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 5a27d8337..07bc7f806 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -22,9 +22,9 @@ file(GLOB all_valid_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt") foreach(dir ${all_valid_subdirs}) - message(STATUS "path = ${dir}") if(${dir} MATCHES "^([^/]*)//CMakeLists.txt") string(REGEX REPLACE "^([^/]*)//CMakeLists.txt" "\\1" dir_trimmed ${dir}) + message(STATUS "Adding third-party component ${dir_trimmed}") add_subdirectory(${dir_trimmed}) endif() endforeach(dir) From 403d85f0808ff35769948301b552eb4b98b73ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 20 Sep 2012 20:45:56 -0400 Subject: [PATCH 05/64] cmake: bump soname version to 1.1.0 --- CMakeLists.txt | 17 +++++++++-------- winpr/CMakeLists.txt | 6 ++++++ winpr/libwinpr/asn1/CMakeLists.txt | 6 ++---- winpr/libwinpr/bcrypt/CMakeLists.txt | 6 ++---- winpr/libwinpr/crt/CMakeLists.txt | 2 +- winpr/libwinpr/dsparse/CMakeLists.txt | 6 ++---- winpr/libwinpr/handle/CMakeLists.txt | 6 ++---- winpr/libwinpr/heap/CMakeLists.txt | 4 +--- winpr/libwinpr/interlocked/CMakeLists.txt | 2 +- winpr/libwinpr/library/CMakeLists.txt | 6 ++---- winpr/libwinpr/registry/CMakeLists.txt | 6 ++---- winpr/libwinpr/rpc/CMakeLists.txt | 6 ++---- winpr/libwinpr/sspi/CMakeLists.txt | 4 +--- winpr/libwinpr/sspicli/CMakeLists.txt | 6 ++---- winpr/libwinpr/synch/CMakeLists.txt | 2 +- winpr/libwinpr/sysinfo/CMakeLists.txt | 6 ++---- winpr/libwinpr/thread/CMakeLists.txt | 2 +- winpr/libwinpr/timezone/CMakeLists.txt | 2 +- winpr/libwinpr/utils/CMakeLists.txt | 6 ++---- winpr/libwinpr/winhttp/CMakeLists.txt | 2 +- winpr/libwinpr/winsock/CMakeLists.txt | 2 +- winpr/tools/hash/CMakeLists.txt | 4 +--- winpr/tools/reg/CMakeLists.txt | 4 +--- 23 files changed, 46 insertions(+), 67 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 407acaa11..4c455f6b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ include(GNUInstallDirsWrapper) # Soname versioning set(FREERDP_VERSION_MAJOR "1") -set(FREERDP_VERSION_MINOR "0") -set(FREERDP_VERSION_REVISION "1") +set(FREERDP_VERSION_MINOR "1") +set(FREERDP_VERSION_REVISION "0") set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}") set(FREERDP_VERSION_FULL "${FREERDP_VERSION}.${FREERDP_VERSION_REVISION}") include(GetGitRevisionDescription) @@ -186,15 +186,17 @@ set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp/extensions") include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -# WinPR -set(WINPR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/winpr/include") -include_directories(${WINPR_INCLUDE_DIR}) - # Configure files add_definitions("-DHAVE_CONFIG_H") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h) +# WinPR +set(WINPR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/winpr/include") +include_directories(${WINPR_INCLUDE_DIR}) + +add_subdirectory(winpr) + # Generate pkg-config if(NOT MSVC) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp.pc @ONLY) @@ -215,8 +217,6 @@ endif() add_subdirectory(include) -add_subdirectory(winpr) - add_subdirectory(libfreerdp) if(WITH_CHANNELS) @@ -246,3 +246,4 @@ string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_lower) set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}") include(CPack) + diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 4ad76b33d..dbe4f8751 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -15,6 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(WINPR_VERSION_MAJOR "0") +set(WINPR_VERSION_MINOR "1") +set(WINPR_VERSION_REVISION "0") +set(WINPR_VERSION "${WINPR_VERSION_MAJOR}.${WINPR_VERSION_MINOR}") +set(WINPR_VERSION_FULL "${WINPR_VERSION}.${WINPR_VERSION_REVISION}") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/winpr/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/winpr/config.h) diff --git a/winpr/libwinpr/asn1/CMakeLists.txt b/winpr/libwinpr/asn1/CMakeLists.txt index 94eb5ea97..7a528f689 100644 --- a/winpr/libwinpr/asn1/CMakeLists.txt +++ b/winpr/libwinpr/asn1/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-asn1 cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +24,7 @@ else() add_library(winpr-asn1 ${WINPR_ASN1_SRCS}) endif() -set_target_properties(winpr-asn1 PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-asn1 PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/bcrypt/CMakeLists.txt b/winpr/libwinpr/bcrypt/CMakeLists.txt index 1b2b8a086..9aa7646e3 100644 --- a/winpr/libwinpr/bcrypt/CMakeLists.txt +++ b/winpr/libwinpr/bcrypt/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-bcrypt cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +27,7 @@ endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(winpr-bcrypt PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-bcrypt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_BCRYPT_LIBS ${ZLIB_LIBRARIES}) diff --git a/winpr/libwinpr/crt/CMakeLists.txt b/winpr/libwinpr/crt/CMakeLists.txt index 4e0b4d7bb..c494a874b 100644 --- a/winpr/libwinpr/crt/CMakeLists.txt +++ b/winpr/libwinpr/crt/CMakeLists.txt @@ -26,7 +26,7 @@ else() add_library(winpr-crt ${WINPR_CRT_SRCS}) endif() -set_target_properties(winpr-crt PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-crt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/dsparse/CMakeLists.txt b/winpr/libwinpr/dsparse/CMakeLists.txt index b3420b341..aa459f240 100644 --- a/winpr/libwinpr/dsparse/CMakeLists.txt +++ b/winpr/libwinpr/dsparse/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-dsparse cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +24,7 @@ else() add_library(winpr-dsparse ${WINPR_DSPARSE_SRCS}) endif() -set_target_properties(winpr-dsparse PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-dsparse PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/handle/CMakeLists.txt b/winpr/libwinpr/handle/CMakeLists.txt index 4b6bd3ba4..34f9fe703 100644 --- a/winpr/libwinpr/handle/CMakeLists.txt +++ b/winpr/libwinpr/handle/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-handle cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +25,7 @@ else() add_library(winpr-handle ${WINPR_HANDLE_SRCS}) endif() -set_target_properties(winpr-handle PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-handle PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/heap/CMakeLists.txt b/winpr/libwinpr/heap/CMakeLists.txt index 3ee0bb22f..25ff8f483 100644 --- a/winpr/libwinpr/heap/CMakeLists.txt +++ b/winpr/libwinpr/heap/CMakeLists.txt @@ -1,8 +1,6 @@ # WinPR: Windows Portable Runtime # libwinpr-heap cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador # Copyright 2011 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +24,7 @@ else() add_library(winpr-heap ${WINPR_HEAP_SRCS}) endif() -set_target_properties(winpr-heap PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-heap PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/interlocked/CMakeLists.txt b/winpr/libwinpr/interlocked/CMakeLists.txt index fa4e89f4d..5128cd122 100644 --- a/winpr/libwinpr/interlocked/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/CMakeLists.txt @@ -24,7 +24,7 @@ else() add_library(winpr-interlocked ${WINPR_INTERLOCKED_SRCS}) endif() -set_target_properties(winpr-interlocked PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-interlocked PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/library/CMakeLists.txt b/winpr/libwinpr/library/CMakeLists.txt index 1f7808273..b47022219 100644 --- a/winpr/libwinpr/library/CMakeLists.txt +++ b/winpr/libwinpr/library/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-library cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +24,7 @@ else() add_library(winpr-library ${WINPR_LIBRARY_SRCS}) endif() -set_target_properties(winpr-library PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-library PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/registry/CMakeLists.txt b/winpr/libwinpr/registry/CMakeLists.txt index bec525300..53910a99c 100644 --- a/winpr/libwinpr/registry/CMakeLists.txt +++ b/winpr/libwinpr/registry/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-registry cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,7 +26,7 @@ else() add_library(winpr-registry ${WINPR_REGISTRY_SRCS}) endif() -set_target_properties(winpr-registry PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-registry PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/rpc/CMakeLists.txt b/winpr/libwinpr/rpc/CMakeLists.txt index 6e18f2d59..a825b3270 100644 --- a/winpr/libwinpr/rpc/CMakeLists.txt +++ b/winpr/libwinpr/rpc/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-rpc cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -40,7 +38,7 @@ endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(winpr-rpc PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-rpc PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_RPC_LIBS ${OPENSSL_LIBRARIES}) diff --git a/winpr/libwinpr/sspi/CMakeLists.txt b/winpr/libwinpr/sspi/CMakeLists.txt index 88c1b07b0..b197b42fb 100644 --- a/winpr/libwinpr/sspi/CMakeLists.txt +++ b/winpr/libwinpr/sspi/CMakeLists.txt @@ -1,8 +1,6 @@ # WinPR: Windows Portable Runtime # libwinpr-sspi cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador # Copyright 2011 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,7 +59,7 @@ endif() include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) -set_target_properties(winpr-sspi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-sspi PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_SSPI_LIBS ${ZLIB_LIBRARIES} diff --git a/winpr/libwinpr/sspicli/CMakeLists.txt b/winpr/libwinpr/sspicli/CMakeLists.txt index 24487a795..106d01158 100644 --- a/winpr/libwinpr/sspicli/CMakeLists.txt +++ b/winpr/libwinpr/sspicli/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-sspicli cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +24,7 @@ else() add_library(winpr-sspicli ${WINPR_SSPICLI_SRCS}) endif() -set_target_properties(winpr-sspicli PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-sspicli PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/synch/CMakeLists.txt b/winpr/libwinpr/synch/CMakeLists.txt index 32b55615a..e74a67911 100644 --- a/winpr/libwinpr/synch/CMakeLists.txt +++ b/winpr/libwinpr/synch/CMakeLists.txt @@ -40,7 +40,7 @@ else() add_library(winpr-synch ${WINPR_SYNCH_SRCS}) endif() -set_target_properties(winpr-synch PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-synch PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_SYNCH_LIBS ${CMAKE_THREAD_LIBS_INIT} diff --git a/winpr/libwinpr/sysinfo/CMakeLists.txt b/winpr/libwinpr/sysinfo/CMakeLists.txt index 159163800..e5e41d8cd 100644 --- a/winpr/libwinpr/sysinfo/CMakeLists.txt +++ b/winpr/libwinpr/sysinfo/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-sysinfo cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +24,7 @@ else() add_library(winpr-sysinfo ${WINPR_SYSINFO_SRCS}) endif() -set_target_properties(winpr-sysinfo PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-sysinfo PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/thread/CMakeLists.txt b/winpr/libwinpr/thread/CMakeLists.txt index b3fbe810a..343c3b16c 100644 --- a/winpr/libwinpr/thread/CMakeLists.txt +++ b/winpr/libwinpr/thread/CMakeLists.txt @@ -30,7 +30,7 @@ else() add_library(winpr-thread ${WINPR_THREAD_SRCS}) endif() -set_target_properties(winpr-thread PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-thread PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_SYNCH_LIBS ${CMAKE_THREAD_LIBS_INIT} diff --git a/winpr/libwinpr/timezone/CMakeLists.txt b/winpr/libwinpr/timezone/CMakeLists.txt index 03be44893..e780f26aa 100644 --- a/winpr/libwinpr/timezone/CMakeLists.txt +++ b/winpr/libwinpr/timezone/CMakeLists.txt @@ -24,7 +24,7 @@ else() add_library(winpr-timezone ${WINPR_TIMEZONE_SRCS}) endif() -set_target_properties(winpr-timezone PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-timezone PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/utils/CMakeLists.txt b/winpr/libwinpr/utils/CMakeLists.txt index ff4868d76..9edc35dc3 100644 --- a/winpr/libwinpr/utils/CMakeLists.txt +++ b/winpr/libwinpr/utils/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # libwinpr-utils cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,7 +30,7 @@ else() add_library(winpr-utils ${WINPR_UTILS_SRCS}) endif() -set_target_properties(winpr-utils PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-utils PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(WINPR_UTILS_LIBS ${ZLIB_LIBRARIES} diff --git a/winpr/libwinpr/winhttp/CMakeLists.txt b/winpr/libwinpr/winhttp/CMakeLists.txt index d13dfb004..1fa4dd60c 100644 --- a/winpr/libwinpr/winhttp/CMakeLists.txt +++ b/winpr/libwinpr/winhttp/CMakeLists.txt @@ -24,7 +24,7 @@ else() add_library(winpr-winhttp ${WINPR_WINHTTP_SRCS}) endif() -set_target_properties(winpr-winhttp PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-winhttp PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) diff --git a/winpr/libwinpr/winsock/CMakeLists.txt b/winpr/libwinpr/winsock/CMakeLists.txt index 602e57a74..a120c77b7 100644 --- a/winpr/libwinpr/winsock/CMakeLists.txt +++ b/winpr/libwinpr/winsock/CMakeLists.txt @@ -24,7 +24,7 @@ else() add_library(winpr-winsock ${WINPR_WINSOCK_SRCS}) endif() -set_target_properties(winpr-winsock PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(winpr-winsock PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WIN32) set(WINPR_WINSOCK_LIBS ${WINPR_WINSOCK_LIBS} ws2_32) diff --git a/winpr/tools/hash/CMakeLists.txt b/winpr/tools/hash/CMakeLists.txt index cef98e55d..0aff945d3 100644 --- a/winpr/tools/hash/CMakeLists.txt +++ b/winpr/tools/hash/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # winpr-hash cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/winpr/tools/reg/CMakeLists.txt b/winpr/tools/reg/CMakeLists.txt index 446de5d2f..1392862bc 100644 --- a/winpr/tools/reg/CMakeLists.txt +++ b/winpr/tools/reg/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # winpr-reg cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 24fc0267836c6850125e7a467d981782d7d5e30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 20 Sep 2012 22:11:56 -0400 Subject: [PATCH 06/64] libwinpr: add possibility of building WinPR as standalone --- CMakeLists.txt | 5 ----- winpr/CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c455f6b6..b9d106f61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,11 +135,6 @@ check_include_files(sys/strtio.h HAVE_SYS_STRTIO_H) check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF) -# Libraries that we have a hard dependency on -if(NOT DEFINED OPENSSL_INCLUDE_DIR OR NOT DEFINED OPENSSL_LIBRARIES) -find_required_package(OpenSSL) -endif() - # Mac OS X if(APPLE) if(IS_DIRECTORY /opt/local/include) diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index dbe4f8751..1330d6921 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -15,13 +15,60 @@ # See the License for the specific language governing permissions and # limitations under the License. +cmake_minimum_required(VERSION 2.6) + +project(WinPR C) + +set(CMAKE_COLOR_MAKEFILE ON) + +if(FREERDP_VERSION) + set(FREERDP_BUILD) +endif() + +# Include cmake modules +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckStructHasMember) +include(FindPkgConfig) +include(TestBigEndian) + +# Include our extra modules +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/) + +include(AutoVersioning) +include(ConfigOptions) +include(BuildFeatureCheck) +include(FindOptionalPackage) +include(CheckCCompilerFlag) +include(GNUInstallDirsWrapper) + +# Soname versioning set(WINPR_VERSION_MAJOR "0") set(WINPR_VERSION_MINOR "1") set(WINPR_VERSION_REVISION "0") set(WINPR_VERSION "${WINPR_VERSION_MAJOR}.${WINPR_VERSION_MINOR}") set(WINPR_VERSION_FULL "${WINPR_VERSION}.${WINPR_VERSION_REVISION}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE) +# Default to release build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +# Default to build shared libs +if(NOT DEFINED BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ON) +endif() + +# Libraries that we have a hard dependency on +if(NOT DEFINED OPENSSL_INCLUDE_DIR OR NOT DEFINED OPENSSL_LIBRARIES) + find_required_package(OpenSSL) +endif() + +if(FREERDP_BUILD) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE) +else() + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/winpr/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/winpr/config.h) From cb8c0ef3c8b1c4bcd7c0aec14a4231b08392834b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 20 Sep 2012 23:39:27 -0400 Subject: [PATCH 07/64] channels: refactoring of cmake build scripts --- channels/CMakeLists.txt | 23 +++++---- channels/cliprdr/ChannelOptions.cmake | 10 ++++ channels/drdynvc/ChannelOptions.cmake | 9 ++++ channels/rail/ChannelOptions.cmake | 9 ++++ channels/rdpdbg/CMakeLists.txt | 33 ------------ channels/rdpdbg/rdpdbg_main.c | 74 --------------------------- channels/rdpdr/ChannelOptions.cmake | 14 +++++ channels/rdpsnd/ChannelOptions.cmake | 12 +++++ channels/skel/ChannelOptions.cmake | 8 +++ 9 files changed, 76 insertions(+), 116 deletions(-) create mode 100644 channels/cliprdr/ChannelOptions.cmake create mode 100644 channels/drdynvc/ChannelOptions.cmake create mode 100644 channels/rail/ChannelOptions.cmake delete mode 100644 channels/rdpdbg/CMakeLists.txt delete mode 100644 channels/rdpdbg/rdpdbg_main.c create mode 100644 channels/rdpdr/ChannelOptions.cmake create mode 100644 channels/rdpsnd/ChannelOptions.cmake create mode 100644 channels/skel/ChannelOptions.cmake diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 1951fd8f1..06419e805 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -17,13 +17,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(cliprdr) -add_subdirectory(drdynvc) -add_subdirectory(rail) -add_subdirectory(rdpdbg) -add_subdirectory(skel) +set(FILENAME "ChannelOptions.cmake") +file(GLOB FILEPATHS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/${FILENAME}") + +foreach(FILEPATH ${FILEPATHS}) + if(${FILEPATH} MATCHES "^([^/]*)//${FILENAME}") + string(REGEX REPLACE "^([^/]*)//${FILENAME}" "\\1" DIR ${FILEPATH}) + set(CHANNEL_OPTION) + include(${FILEPATH}) + if(${CHANNEL_OPTION}) + message(STATUS "Adding ${CHANNEL_TYPE} channel \"${CHANNEL_SHORT_NAME}\": ${CHANNEL_LONG_NAME} (${CHANNEL_SPECIFICATIONS})") + add_subdirectory(${DIR}) + endif() + endif() +endforeach(FILEPATH) -if(NOT WIN32) - add_subdirectory(rdpdr) - add_subdirectory(rdpsnd) -endif() diff --git a/channels/cliprdr/ChannelOptions.cmake b/channels/cliprdr/ChannelOptions.cmake new file mode 100644 index 000000000..1cbbb619b --- /dev/null +++ b/channels/cliprdr/ChannelOptions.cmake @@ -0,0 +1,10 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "cliprdr") +set(CHANNEL_LONG_NAME "Clipboard Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPECLIP]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) + + diff --git a/channels/drdynvc/ChannelOptions.cmake b/channels/drdynvc/ChannelOptions.cmake new file mode 100644 index 000000000..cf67ef513 --- /dev/null +++ b/channels/drdynvc/ChannelOptions.cmake @@ -0,0 +1,9 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "drdynvc") +set(CHANNEL_LONG_NAME "Dynamic Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEDYC]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) + diff --git a/channels/rail/ChannelOptions.cmake b/channels/rail/ChannelOptions.cmake new file mode 100644 index 000000000..786cbfc17 --- /dev/null +++ b/channels/rail/ChannelOptions.cmake @@ -0,0 +1,9 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "rail") +set(CHANNEL_LONG_NAME "Remote Programs Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPERP]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) + diff --git a/channels/rdpdbg/CMakeLists.txt b/channels/rdpdbg/CMakeLists.txt deleted file mode 100644 index 7387269da..000000000 --- a/channels/rdpdbg/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# FreeRDP: A Remote Desktop Protocol Client -# FreeRDP cmake build script -# -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(RDPDBG_SRCS - rdpdbg_main.c -) - -add_library(rdpdbg ${RDPDBG_SRCS}) -set_target_properties(rdpdbg PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(rdpdbg freerdp) -else() - target_link_libraries(rdpdbg freerdp-utils) -endif() - -install(TARGETS rdpdbg DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/rdpdbg/rdpdbg_main.c b/channels/rdpdbg/rdpdbg_main.c deleted file mode 100644 index a1cdc212c..000000000 --- a/channels/rdpdbg/rdpdbg_main.c +++ /dev/null @@ -1,74 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol client. - * Debugging Virtual Channel - * - * Copyright 2010-2011 Marc-Andre Moreau - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include -#include -#include -#include - -typedef struct rdpdbg_plugin rdpdbgPlugin; -struct rdpdbg_plugin -{ - rdpSvcPlugin plugin; -}; - -static void rdpdbg_process_connect(rdpSvcPlugin* plugin) -{ - DEBUG_WARN("connecting"); -} - -static void rdpdbg_process_receive(rdpSvcPlugin* plugin, STREAM* data_in) -{ - STREAM* data_out; - - DEBUG_WARN("size %d", stream_get_size(data_in)); - stream_free(data_in); - - data_out = stream_new(8); - stream_write(data_out, "senddata", 8); - svc_plugin_send(plugin, data_out); -} - -static void rdpdbg_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event) -{ - DEBUG_WARN("event_type %d", event->event_type); - freerdp_event_free(event); - - event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL); - svc_plugin_send_event(plugin, event); -} - -static void rdpdbg_process_terminate(rdpSvcPlugin* plugin) -{ - DEBUG_WARN("terminating"); - xfree(plugin); -} - -DEFINE_SVC_PLUGIN(rdpdbg, "rdpdbg", - CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | - CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL) diff --git a/channels/rdpdr/ChannelOptions.cmake b/channels/rdpdr/ChannelOptions.cmake new file mode 100644 index 000000000..85e3f63b5 --- /dev/null +++ b/channels/rdpdr/ChannelOptions.cmake @@ -0,0 +1,14 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "rdpdr") +set(CHANNEL_LONG_NAME "Device Redirection Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEFS] [MS-RDPEPC] [MS-RDPESC] [MS-RDPESP]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) + +if(WIN32) + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) +else() + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) +endif() + diff --git a/channels/rdpsnd/ChannelOptions.cmake b/channels/rdpsnd/ChannelOptions.cmake new file mode 100644 index 000000000..fb8b2ef2a --- /dev/null +++ b/channels/rdpsnd/ChannelOptions.cmake @@ -0,0 +1,12 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "rdpsnd") +set(CHANNEL_LONG_NAME "Audio Output Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEA]") + +if(WIN32) + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) +else() + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) +endif() + diff --git a/channels/skel/ChannelOptions.cmake b/channels/skel/ChannelOptions.cmake new file mode 100644 index 000000000..9125cb227 --- /dev/null +++ b/channels/skel/ChannelOptions.cmake @@ -0,0 +1,8 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "skel") +set(CHANNEL_LONG_NAME "Skeleton Code Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "") + +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) + From 7d7536f6499896c076e25d863b92f8a51b501b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 21 Sep 2012 13:02:54 -0400 Subject: [PATCH 08/64] libwinpr: add module definition files --- winpr/libwinpr/asn1/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/bcrypt/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/crt/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/dsparse/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/handle/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/heap/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/interlocked/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/library/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/registry/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/rpc/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/sspi/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/sspicli/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/synch/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/sysinfo/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/thread/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/timezone/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/winhttp/ModuleOptions.cmake | 9 +++++++++ winpr/libwinpr/winsock/ModuleOptions.cmake | 9 +++++++++ 18 files changed, 162 insertions(+) create mode 100644 winpr/libwinpr/asn1/ModuleOptions.cmake create mode 100644 winpr/libwinpr/bcrypt/ModuleOptions.cmake create mode 100644 winpr/libwinpr/crt/ModuleOptions.cmake create mode 100644 winpr/libwinpr/dsparse/ModuleOptions.cmake create mode 100644 winpr/libwinpr/handle/ModuleOptions.cmake create mode 100644 winpr/libwinpr/heap/ModuleOptions.cmake create mode 100644 winpr/libwinpr/interlocked/ModuleOptions.cmake create mode 100644 winpr/libwinpr/library/ModuleOptions.cmake create mode 100644 winpr/libwinpr/registry/ModuleOptions.cmake create mode 100644 winpr/libwinpr/rpc/ModuleOptions.cmake create mode 100644 winpr/libwinpr/sspi/ModuleOptions.cmake create mode 100644 winpr/libwinpr/sspicli/ModuleOptions.cmake create mode 100644 winpr/libwinpr/synch/ModuleOptions.cmake create mode 100644 winpr/libwinpr/sysinfo/ModuleOptions.cmake create mode 100644 winpr/libwinpr/thread/ModuleOptions.cmake create mode 100644 winpr/libwinpr/timezone/ModuleOptions.cmake create mode 100644 winpr/libwinpr/winhttp/ModuleOptions.cmake create mode 100644 winpr/libwinpr/winsock/ModuleOptions.cmake diff --git a/winpr/libwinpr/asn1/ModuleOptions.cmake b/winpr/libwinpr/asn1/ModuleOptions.cmake new file mode 100644 index 000000000..ace05387e --- /dev/null +++ b/winpr/libwinpr/asn1/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "msasn1") +set(MINWIN_LONG_NAME "Microsoft ASN.1") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/bcrypt/ModuleOptions.cmake b/winpr/libwinpr/bcrypt/ModuleOptions.cmake new file mode 100644 index 000000000..c1dc8f3b0 --- /dev/null +++ b/winpr/libwinpr/bcrypt/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "bcrypt") +set(MINWIN_LONG_NAME "Cryptography API: Next Generation (CNG)") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/crt/ModuleOptions.cmake b/winpr/libwinpr/crt/ModuleOptions.cmake new file mode 100644 index 000000000..4530a74e5 --- /dev/null +++ b/winpr/libwinpr/crt/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "crt") +set(MINWIN_LONG_NAME "Microsoft C Run-Time") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/dsparse/ModuleOptions.cmake b/winpr/libwinpr/dsparse/ModuleOptions.cmake new file mode 100644 index 000000000..647de1ba2 --- /dev/null +++ b/winpr/libwinpr/dsparse/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "dsparse") +set(MINWIN_LONG_NAME "Domain Controller and Replication Management Functions") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/handle/ModuleOptions.cmake b/winpr/libwinpr/handle/ModuleOptions.cmake new file mode 100644 index 000000000..545a8e9cc --- /dev/null +++ b/winpr/libwinpr/handle/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "handle") +set(MINWIN_LONG_NAME "Handle and Object Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/heap/ModuleOptions.cmake b/winpr/libwinpr/heap/ModuleOptions.cmake new file mode 100644 index 000000000..81d4f8612 --- /dev/null +++ b/winpr/libwinpr/heap/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "heap") +set(MINWIN_LONG_NAME "Heap Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/interlocked/ModuleOptions.cmake b/winpr/libwinpr/interlocked/ModuleOptions.cmake new file mode 100644 index 000000000..8a1600aef --- /dev/null +++ b/winpr/libwinpr/interlocked/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "interlocked") +set(MINWIN_LONG_NAME "Interlocked Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/library/ModuleOptions.cmake b/winpr/libwinpr/library/ModuleOptions.cmake new file mode 100644 index 000000000..affda8690 --- /dev/null +++ b/winpr/libwinpr/library/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "1") +set(MINWIN_SHORT_NAME "libraryloader") +set(MINWIN_LONG_NAME "Dynamic-Link Library Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/registry/ModuleOptions.cmake b/winpr/libwinpr/registry/ModuleOptions.cmake new file mode 100644 index 000000000..a83eb09c7 --- /dev/null +++ b/winpr/libwinpr/registry/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "registry") +set(MINWIN_LONG_NAME "Registry Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/rpc/ModuleOptions.cmake b/winpr/libwinpr/rpc/ModuleOptions.cmake new file mode 100644 index 000000000..55987fef3 --- /dev/null +++ b/winpr/libwinpr/rpc/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "rpcrt4") +set(MINWIN_LONG_NAME "RPC NDR Engine") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/sspi/ModuleOptions.cmake b/winpr/libwinpr/sspi/ModuleOptions.cmake new file mode 100644 index 000000000..b947e302b --- /dev/null +++ b/winpr/libwinpr/sspi/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "sspi") +set(MINWIN_LONG_NAME "Security Support Provider Interface") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/sspicli/ModuleOptions.cmake b/winpr/libwinpr/sspicli/ModuleOptions.cmake new file mode 100644 index 000000000..3a356c74c --- /dev/null +++ b/winpr/libwinpr/sspicli/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "sspicli") +set(MINWIN_LONG_NAME "Authentication Functions") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/synch/ModuleOptions.cmake b/winpr/libwinpr/synch/ModuleOptions.cmake new file mode 100644 index 000000000..1aac06df5 --- /dev/null +++ b/winpr/libwinpr/synch/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "synch") +set(MINWIN_LONG_NAME "Synchronization Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/sysinfo/ModuleOptions.cmake b/winpr/libwinpr/sysinfo/ModuleOptions.cmake new file mode 100644 index 000000000..6a7ff02de --- /dev/null +++ b/winpr/libwinpr/sysinfo/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "sysinfo") +set(MINWIN_LONG_NAME "System Information Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/thread/ModuleOptions.cmake b/winpr/libwinpr/thread/ModuleOptions.cmake new file mode 100644 index 000000000..ae52dd9d0 --- /dev/null +++ b/winpr/libwinpr/thread/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "1") +set(MINWIN_SHORT_NAME "processthreads") +set(MINWIN_LONG_NAME "Process and Thread Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/timezone/ModuleOptions.cmake b/winpr/libwinpr/timezone/ModuleOptions.cmake new file mode 100644 index 000000000..7f5df3830 --- /dev/null +++ b/winpr/libwinpr/timezone/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "timezone") +set(MINWIN_LONG_NAME "Time Zone Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/winhttp/ModuleOptions.cmake b/winpr/libwinpr/winhttp/ModuleOptions.cmake new file mode 100644 index 000000000..e0fa34d1b --- /dev/null +++ b/winpr/libwinpr/winhttp/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "winhttp") +set(MINWIN_LONG_NAME "Windows HTTP (WinHTTP)") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + diff --git a/winpr/libwinpr/winsock/ModuleOptions.cmake b/winpr/libwinpr/winsock/ModuleOptions.cmake new file mode 100644 index 000000000..63275d0e1 --- /dev/null +++ b/winpr/libwinpr/winsock/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "0") +set(MINWIN_GROUP "none") +set(MINWIN_MAJOR_VERSION "0") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "ws2_32") +set(MINWIN_LONG_NAME "Windows Sockets (Winsock)") +set(MODULE_LIBRARY_NAME "${MINWIN_SHORT_NAME}") + From 538c89e3117b23c46726a898e37ce375a50dcb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 21 Sep 2012 19:28:47 -0400 Subject: [PATCH 09/64] cmake: add OpenSSL and MSVC runtime build options --- CMakeLists.txt | 26 +-- channels/CMakeLists.txt | 2 +- cmake/ConfigOptions.cmake | 1 - cmake/FindOpenSSL.cmake | 323 +++++++++++++++++++++++++++++ cmake/MSVCRuntime.cmake | 39 ++++ winpr/libwinpr/sspi/CMakeLists.txt | 6 + 6 files changed, 378 insertions(+), 19 deletions(-) create mode 100644 cmake/FindOpenSSL.cmake create mode 100644 cmake/MSVCRuntime.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b9d106f61..d851982cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,15 @@ if(NOT DEFINED BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS ON) endif() +# Configure MSVC Runtime +if(MSVC) + include(MSVCRuntime) + if(NOT DEFINED MSVC_RUNTIME) + set(MSVC_RUNTIME "dynamic") + endif() + configure_msvc_runtime() +endif() + # Compiler-specific flags if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") @@ -99,23 +108,6 @@ if(MSVC) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}) endif() -# This forces the MSVC runtime to be statically linked - -if(WITH_MSVC_STATIC) - foreach(flag_var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO) - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") - endforeach(flag_var) - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "MSVC C Debug MT flags " FORCE) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "MSVC CXX Debug MT flags " FORCE) - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "MSVC C Release MT flags " FORCE) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "MSVC CXX Release MT flags " FORCE) - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}" CACHE STRING "MSVC C Debug MT flags " FORCE) - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}" CACHE STRING "MSVC C Release MT flags " FORCE) - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE STRING "MSVC CXX Debug MT flags " FORCE) - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE STRING "MSVC CXX Release MT flags " FORCE) -endif() - # config.h definition for installable headers check_include_files(limits.h FREERDP_HAVE_LIMITS_H) check_include_files(stdint.h FREERDP_HAVE_STDINT_H) diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 06419e805..c29f04e30 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -26,7 +26,7 @@ foreach(FILEPATH ${FILEPATHS}) set(CHANNEL_OPTION) include(${FILEPATH}) if(${CHANNEL_OPTION}) - message(STATUS "Adding ${CHANNEL_TYPE} channel \"${CHANNEL_SHORT_NAME}\": ${CHANNEL_LONG_NAME} (${CHANNEL_SPECIFICATIONS})") + message(STATUS "Adding ${CHANNEL_TYPE} channel \"${CHANNEL_SHORT_NAME}\": ${CHANNEL_LONG_NAME}") add_subdirectory(${DIR}) endif() endif() diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index f99d7dcc2..2007b37cf 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -12,7 +12,6 @@ endif() if(MSVC) option(WITH_NATIVE_SSPI "Use native SSPI modules" ON) - option(WITH_MSVC_STATIC "Use static MSVC runtime" OFF) option(WITH_WIN8 "Use Windows 8 libraries" OFF) endif() diff --git a/cmake/FindOpenSSL.cmake b/cmake/FindOpenSSL.cmake new file mode 100644 index 000000000..cb47de37e --- /dev/null +++ b/cmake/FindOpenSSL.cmake @@ -0,0 +1,323 @@ +# - Try to find the OpenSSL encryption library +# Once done this will define +# +# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL +# +# Read-Only variables: +# OPENSSL_FOUND - system has the OpenSSL library +# OPENSSL_INCLUDE_DIR - the OpenSSL include directory +# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL +# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s) + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# Copyright 2006 Alexander Neundorf +# Copyright 2009-2011 Mathieu Malaterre +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (UNIX) + find_package(PkgConfig QUIET) + pkg_check_modules(_OPENSSL QUIET openssl) +endif (UNIX) + +# http://www.slproweb.com/products/Win32OpenSSL.html +SET(_OPENSSL_ROOT_HINTS + $ENV{OPENSSL_ROOT_DIR} + ${OPENSSL_ROOT_DIR} + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" + ) +SET(_OPENSSL_ROOT_PATHS + "$ENV{PROGRAMFILES}/OpenSSL" + "$ENV{PROGRAMFILES}/OpenSSL-Win32" + "$ENV{PROGRAMFILES}/OpenSSL-Win64" + "C:/OpenSSL/" + "C:/OpenSSL-Win32/" + "C:/OpenSSL-Win64/" + ) +SET(_OPENSSL_ROOT_HINTS_AND_PATHS + HINTS ${_OPENSSL_ROOT_HINTS} + PATHS ${_OPENSSL_ROOT_PATHS} + ) + +FIND_PATH(OPENSSL_INCLUDE_DIR + NAMES + openssl/ssl.h + HINTS + ${_OPENSSL_INCLUDEDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + include +) + +IF(WIN32) + if(${MSVC_RUNTIME} STREQUAL "static") + set(MSVC_RUNTIME_SUFFIX "MT") + else() + set(MSVC_RUNTIME_SUFFIX "MD") + endif() +ENDIF(WIN32) + +IF(WIN32 AND NOT CYGWIN) + # MINGW should go here too + IF(MSVC) + # /MD and /MDd are the standard values - if someone wants to use + # others, the libnames have to change here too + # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b + # TODO: handle /MT and static lib + # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix: + # * MD for dynamic-release + # * MDd for dynamic-debug + # * MT for static-release + # * MTd for static-debug + + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + # libeay32MD.lib is identical to ../libeay32.lib, and + # ssleay32MD.lib is identical to ../ssleay32.lib + + if(DEFINED OPENSSL_STATIC) + set(MSVC_RUNTIME_PATH_SUFFIX "lib/VC/static") + else() + set(MSVC_RUNTIME_PATH_SUFFIX "") + endif() + + FIND_LIBRARY(LIB_EAY_DEBUG + NAMES + "libeay32${MSVC_RUNTIME_SUFFIX}d" + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + ${MSVC_RUNTIME_PATH_SUFFIX} + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(LIB_EAY_RELEASE + NAMES + "libeay32${MSVC_RUNTIME_SUFFIX}" + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + ${MSVC_RUNTIME_PATH_SUFFIX} + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(SSL_EAY_DEBUG + NAMES + "ssleay32${MSVC_RUNTIME_SUFFIX}d" + ssleay32 + ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + ${MSVC_RUNTIME_PATH_SUFFIX} + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(SSL_EAY_RELEASE + NAMES + "ssleay32${MSVC_RUNTIME_SUFFIX}" + ssleay32 + ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + ${MSVC_RUNTIME_PATH_SUFFIX} + "lib" + "VC" + "lib/VC" + ) + + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + set( OPENSSL_LIBRARIES + optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} + optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG} + ) + else() + set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} ) + endif() + MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) + MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE) + ELSEIF(MINGW) + # same player, for MingW + FIND_LIBRARY(LIB_EAY + NAMES + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + ) + + FIND_LIBRARY(SSL_EAY + NAMES + ssleay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + ) + + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + ELSE(MSVC) + # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: + FIND_LIBRARY(LIB_EAY + NAMES + libeay32 + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + FIND_LIBRARY(SSL_EAY + NAMES + ssleay32 + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + ENDIF(MSVC) +ELSE(WIN32 AND NOT CYGWIN) + + FIND_LIBRARY(OPENSSL_SSL_LIBRARY + NAMES + ssl + ssleay32 + "ssleay32${MSVC_RUNTIME_SUFFIX}" + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARY + NAMES + crypto + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) + + # compat defines + SET(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + SET(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + + SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + +ENDIF(WIN32 AND NOT CYGWIN) + +function(from_hex HEX DEC) + string(TOUPPER "${HEX}" HEX) + set(_res 0) + string(LENGTH "${HEX}" _strlen) + + while (_strlen GREATER 0) + math(EXPR _res "${_res} * 16") + string(SUBSTRING "${HEX}" 0 1 NIBBLE) + string(SUBSTRING "${HEX}" 1 -1 HEX) + if (NIBBLE STREQUAL "A") + math(EXPR _res "${_res} + 10") + elseif (NIBBLE STREQUAL "B") + math(EXPR _res "${_res} + 11") + elseif (NIBBLE STREQUAL "C") + math(EXPR _res "${_res} + 12") + elseif (NIBBLE STREQUAL "D") + math(EXPR _res "${_res} + 13") + elseif (NIBBLE STREQUAL "E") + math(EXPR _res "${_res} + 14") + elseif (NIBBLE STREQUAL "F") + math(EXPR _res "${_res} + 15") + else() + math(EXPR _res "${_res} + ${NIBBLE}") + endif() + + string(LENGTH "${HEX}" _strlen) + endwhile() + + set(${DEC} ${_res} PARENT_SCOPE) +endfunction(from_hex) + +if (OPENSSL_INCLUDE_DIR) + if (_OPENSSL_VERSION) + set(OPENSSL_VERSION "${_OPENSSL_VERSION}") + elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") + file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str + REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") + + # The version number is encoded as 0xMNNFFPPS: major minor fix patch status + # The status gives if this is a developer or prerelease and is ignored here. + # Major, minor, and fix directly translate into the version numbers shown in + # the string. The patch field translates to the single character suffix that + # indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so + # on. + + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$" + "\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}") + list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR) + list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR) + from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR) + list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX) + from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX) + list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH) + + if (NOT OPENSSL_VERSION_PATCH STREQUAL "00") + from_hex("${OPENSSL_VERSION_PATCH}" _tmp) + # 96 is the ASCII code of 'a' minus 1 + math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96") + unset(_tmp) + # Once anyone knows how OpenSSL would call the patch versions beyond 'z' + # this should be updated to handle that, too. This has not happened yet + # so it is simply ignored here for now. + string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING) + endif (NOT OPENSSL_VERSION_PATCH STREQUAL "00") + + set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}") + endif (_OPENSSL_VERSION) +endif (OPENSSL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) + +if (OPENSSL_VERSION) + find_package_handle_standard_args(OpenSSL + REQUIRED_VARS + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + VERSION_VAR + OPENSSL_VERSION + FAIL_MESSAGE + "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + ) +else (OPENSSL_VERSION) + find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + ) +endif (OPENSSL_VERSION) + +MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) diff --git a/cmake/MSVCRuntime.cmake b/cmake/MSVCRuntime.cmake new file mode 100644 index 000000000..d659708e7 --- /dev/null +++ b/cmake/MSVCRuntime.cmake @@ -0,0 +1,39 @@ + +macro(configure_msvc_runtime) + if(MSVC) + # Default to statically-linked runtime. + if("${MSVC_RUNTIME}" STREQUAL "") + set(MSVC_RUNTIME "dynamic") + endif() + # Set compiler options. + set(variables + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO + ) + if(${MSVC_RUNTIME} STREQUAL "static") + message(STATUS + "MSVC: using statically-linked runtime (/MT and /MTd)." + ) + foreach(variable ${variables}) + if(${variable} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") + endif() + endforeach() + else() + message(STATUS + "MSVC: using dynamically-linked runtime (/MD and /MDd)." + ) + foreach(variable ${variables}) + if(${variable} MATCHES "/MT") + string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}") + endif() + endforeach() + endif() + endif() +endmacro(configure_msvc_runtime) diff --git a/winpr/libwinpr/sspi/CMakeLists.txt b/winpr/libwinpr/sspi/CMakeLists.txt index b197b42fb..2af96c6cb 100644 --- a/winpr/libwinpr/sspi/CMakeLists.txt +++ b/winpr/libwinpr/sspi/CMakeLists.txt @@ -65,6 +65,12 @@ set(WINPR_SSPI_LIBS ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) +if(WIN32) + set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ws2_32) +else() + set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ${ZLIB_LIBRARIES}) +endif() + if(WITH_MONOLITHIC_BUILD) set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} winpr) else() From 867c169148dbadcd441d83d19d70c648d5c3de7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 14:27:30 -0400 Subject: [PATCH 10/64] libfreerdp-locale: cleanup keyboard code --- client/DirectFB/df_event.c | 2 +- client/Windows/wf_event.c | 12 +- client/X11/xf_keyboard.c | 12 +- include/freerdp/errorcodes.h | 2 +- include/freerdp/input.h | 9 +- include/freerdp/keyboard_scancode.h | 186 ------------------ include/freerdp/locale/keyboard.h | 14 +- .../locale/{virtual_key_codes.h => vkcodes.h} | 0 include/freerdp/scancode.h | 185 +++++++++++++++++ libfreerdp/core/freerdp.c | 8 +- libfreerdp/core/input.c | 8 + libfreerdp/locale/keyboard.c | 24 +-- libfreerdp/locale/keyboard_keymap.c | 2 +- libfreerdp/locale/keyboard_layout.c | 2 +- libfreerdp/locale/virtual_key_codes.c | 2 +- 15 files changed, 233 insertions(+), 235 deletions(-) delete mode 100644 include/freerdp/keyboard_scancode.h rename include/freerdp/locale/{virtual_key_codes.h => vkcodes.h} (100%) create mode 100644 include/freerdp/scancode.h diff --git a/client/DirectFB/df_event.c b/client/DirectFB/df_event.c index d6814d084..4c2e8f2ec 100644 --- a/client/DirectFB/df_event.c +++ b/client/DirectFB/df_event.c @@ -202,7 +202,7 @@ void df_send_keyboard_event(rdpInput* input, boolean down, uint8 keycode, uint8 rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(vkcode); - freerdp_input_send_keyboard_event_2(input, down, rdp_scancode); + freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); } boolean df_event_process(freerdp* instance, DFBEvent* event) diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index bbdad59a3..1ee93165b 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -57,7 +57,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA); p = (PKBDLLHOOKSTRUCT) lParam; input = wfi->instance->input; - rdp_scancode = mk_rdp_scancode((uint8) p->scanCode, p->flags & LLKHF_EXTENDED); + rdp_scancode = MAKE_RDP_SCANCODE((uint8) p->scanCode, p->flags & LLKHF_EXTENDED); DEBUG_KBD("keydown %d scanCode %04X flags %02X vkCode %02X", (wParam == WM_KEYDOWN), (uint8) p->scanCode, p->flags, p->vkCode); @@ -85,10 +85,10 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) if (wParam == WM_KEYDOWN) { DEBUG_KBD("Pause, sent as Ctrl+NumLock"); - freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_LCONTROL); - freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_NUMLOCK); - freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_LCONTROL); - freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_NUMLOCK); + freerdp_input_send_keyboard_event_ex(input, true, RDP_SCANCODE_LCONTROL); + freerdp_input_send_keyboard_event_ex(input, true, RDP_SCANCODE_NUMLOCK); + freerdp_input_send_keyboard_event_ex(input, false, RDP_SCANCODE_LCONTROL); + freerdp_input_send_keyboard_event_ex(input, false, RDP_SCANCODE_NUMLOCK); } else { @@ -103,7 +103,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) rdp_scancode = RDP_SCANCODE_RSHIFT; } - freerdp_input_send_keyboard_event_2(input, !(p->flags & LLKHF_UP), rdp_scancode); + freerdp_input_send_keyboard_event_ex(input, !(p->flags & LLKHF_UP), rdp_scancode); if (p->vkCode == VK_CAPITAL) DEBUG_KBD("caps lock is processed on client side too to toggle caps lock indicator"); diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 1a3117513..0840f5ef5 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -69,7 +69,7 @@ void xf_kbd_release_all_keypress(xfInfo* xfi) if (xfi->pressed_keys[keycode] != NoSymbol) { rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode); - freerdp_input_send_keyboard_event_2(xfi->instance->input, false, rdp_scancode); + freerdp_input_send_keyboard_event_ex(xfi->instance->input, false, rdp_scancode); xfi->pressed_keys[keycode] = NoSymbol; } } @@ -99,15 +99,15 @@ void xf_kbd_send_key(xfInfo* xfi, boolean down, uint8 keycode) /* Pause without Ctrl has to be sent as Ctrl + NumLock. */ if (down) { - freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_LCONTROL); - freerdp_input_send_keyboard_event_2(input, true, RDP_SCANCODE_NUMLOCK); - freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_LCONTROL); - freerdp_input_send_keyboard_event_2(input, false, RDP_SCANCODE_NUMLOCK); + freerdp_input_send_keyboard_event_ex(input, true, RDP_SCANCODE_LCONTROL); + freerdp_input_send_keyboard_event_ex(input, true, RDP_SCANCODE_NUMLOCK); + freerdp_input_send_keyboard_event_ex(input, false, RDP_SCANCODE_LCONTROL); + freerdp_input_send_keyboard_event_ex(input, false, RDP_SCANCODE_NUMLOCK); } } else { - freerdp_input_send_keyboard_event_2(input, down, rdp_scancode); + freerdp_input_send_keyboard_event_ex(input, down, rdp_scancode); if ((rdp_scancode == RDP_SCANCODE_CAPSLOCK) && (down == false)) { diff --git a/include/freerdp/errorcodes.h b/include/freerdp/errorcodes.h index e36e2ce7c..826dfdc77 100644 --- a/include/freerdp/errorcodes.h +++ b/include/freerdp/errorcodes.h @@ -6,7 +6,7 @@ */ #ifndef ERRORCODES_H -#define ERRORCODES_H +#define ERRORCODES_H #ifdef __cplusplus extern "C" { diff --git a/include/freerdp/input.h b/include/freerdp/input.h index 0d8f0bf5a..d4cbf849e 100644 --- a/include/freerdp/input.h +++ b/include/freerdp/input.h @@ -24,7 +24,7 @@ typedef struct rdp_input rdpInput; #include #include -#include +#include /* keyboard Flags */ #define KBD_FLAGS_EXTENDED 0x0100 @@ -76,14 +76,9 @@ struct rdp_input FREERDP_API void freerdp_input_send_synchronize_event(rdpInput* input, uint32 flags); FREERDP_API void freerdp_input_send_keyboard_event(rdpInput* input, uint16 flags, uint16 code); +FREERDP_API void freerdp_input_send_keyboard_event_ex(rdpInput* input, boolean down, uint32 rdp_scancode); FREERDP_API void freerdp_input_send_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code); FREERDP_API void freerdp_input_send_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y); FREERDP_API void freerdp_input_send_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y); -#define freerdp_input_send_keyboard_event_2(input, down, rdp_scancode) \ - freerdp_input_send_keyboard_event(input, \ - (rdp_scancode_extended(rdp_scancode) ? KBD_FLAGS_EXTENDED : 0) | \ - ((down) ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE), \ - rdp_scancode_code(rdp_scancode)) - #endif /* __INPUT_API_H */ diff --git a/include/freerdp/keyboard_scancode.h b/include/freerdp/keyboard_scancode.h deleted file mode 100644 index c31f7f4a4..000000000 --- a/include/freerdp/keyboard_scancode.h +++ /dev/null @@ -1,186 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * RDP protocol "scancodes" - * - * Copyright 2009-2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H -#define __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H - -/* @msdn{cc240584} says: - * "... (a scancode is an 8-bit value specifying a key location on the keyboard). - * The server accepts a scancode value and translates it into the correct character depending on the language locale and keyboard layout used in the session." - * The 8-bit value is later called "keyCode" - * The extended flag is for all practical an important 9th bit with a strange encoding - not just a modifier. - */ - -typedef uint32 RDP_SCANCODE; /* Our own representation of a RDP protocol scancode */ -#define rdp_scancode_code(_rdp_scancode) ((uint8)(_rdp_scancode & 0xff)) -#define rdp_scancode_extended(_rdp_scancode) (((_rdp_scancode) & 0x100) ? true : false) -#define mk_rdp_scancode(_code, _extended) (((_code) & 0xff) | ((_extended) ? 0x100 : 0)) - - -/* Defines for known RDP_SCANCODE protocol values. - * Mostly the same as the PKBDLLHOOKSTRUCT scanCode, "A hardware scan code for the key", @msdn{ms644967}. - * Based @msdn{ms894073} US, @msdn{ms894072} UK, @msdn{ms892472} */ - -#define RDP_SCANCODE_UNKNOWN mk_rdp_scancode(0x00, false) - -#define RDP_SCANCODE_ESCAPE mk_rdp_scancode(0x01, false) /* VK_ESCAPE */ -#define RDP_SCANCODE_KEY_1 mk_rdp_scancode(0x02, false) /* VK_KEY_1 */ -#define RDP_SCANCODE_KEY_2 mk_rdp_scancode(0x03, false) /* VK_KEY_2 */ -#define RDP_SCANCODE_KEY_3 mk_rdp_scancode(0x04, false) /* VK_KEY_3 */ -#define RDP_SCANCODE_KEY_4 mk_rdp_scancode(0x05, false) /* VK_KEY_4 */ -#define RDP_SCANCODE_KEY_5 mk_rdp_scancode(0x06, false) /* VK_KEY_5 */ -#define RDP_SCANCODE_KEY_6 mk_rdp_scancode(0x07, false) /* VK_KEY_6 */ -#define RDP_SCANCODE_KEY_7 mk_rdp_scancode(0x08, false) /* VK_KEY_7 */ -#define RDP_SCANCODE_KEY_8 mk_rdp_scancode(0x09, false) /* VK_KEY_8 */ -#define RDP_SCANCODE_KEY_9 mk_rdp_scancode(0x0A, false) /* VK_KEY_9 */ -#define RDP_SCANCODE_KEY_0 mk_rdp_scancode(0x0B, false) /* VK_KEY_0 */ -#define RDP_SCANCODE_OEM_MINUS mk_rdp_scancode(0x0C, false) /* VK_OEM_MINUS */ -#define RDP_SCANCODE_OEM_PLUS mk_rdp_scancode(0x0D, false) /* VK_OEM_PLUS */ -#define RDP_SCANCODE_BACKSPACE mk_rdp_scancode(0x0E, false) /* VK_BACK Backspace */ -#define RDP_SCANCODE_TAB mk_rdp_scancode(0x0F, false) /* VK_TAB */ -#define RDP_SCANCODE_KEY_Q mk_rdp_scancode(0x10, false) /* VK_KEY_Q */ -#define RDP_SCANCODE_KEY_W mk_rdp_scancode(0x11, false) /* VK_KEY_W */ -#define RDP_SCANCODE_KEY_E mk_rdp_scancode(0x12, false) /* VK_KEY_E */ -#define RDP_SCANCODE_KEY_R mk_rdp_scancode(0x13, false) /* VK_KEY_R */ -#define RDP_SCANCODE_KEY_T mk_rdp_scancode(0x14, false) /* VK_KEY_T */ -#define RDP_SCANCODE_KEY_Y mk_rdp_scancode(0x15, false) /* VK_KEY_Y */ -#define RDP_SCANCODE_KEY_U mk_rdp_scancode(0x16, false) /* VK_KEY_U */ -#define RDP_SCANCODE_KEY_I mk_rdp_scancode(0x17, false) /* VK_KEY_I */ -#define RDP_SCANCODE_KEY_O mk_rdp_scancode(0x18, false) /* VK_KEY_O */ -#define RDP_SCANCODE_KEY_P mk_rdp_scancode(0x19, false) /* VK_KEY_P */ -#define RDP_SCANCODE_OEM_4 mk_rdp_scancode(0x1A, false) /* VK_OEM_4 '[' on US */ -#define RDP_SCANCODE_OEM_6 mk_rdp_scancode(0x1B, false) /* VK_OEM_6 ']' on US */ -#define RDP_SCANCODE_RETURN mk_rdp_scancode(0x1C, false) /* VK_RETURN Normal Enter */ -#define RDP_SCANCODE_LCONTROL mk_rdp_scancode(0x1D, false) /* VK_LCONTROL */ -#define RDP_SCANCODE_KEY_A mk_rdp_scancode(0x1E, false) /* VK_KEY_A */ -#define RDP_SCANCODE_KEY_S mk_rdp_scancode(0x1F, false) /* VK_KEY_S */ -#define RDP_SCANCODE_KEY_D mk_rdp_scancode(0x20, false) /* VK_KEY_D */ -#define RDP_SCANCODE_KEY_F mk_rdp_scancode(0x21, false) /* VK_KEY_F */ -#define RDP_SCANCODE_KEY_G mk_rdp_scancode(0x22, false) /* VK_KEY_G */ -#define RDP_SCANCODE_KEY_H mk_rdp_scancode(0x23, false) /* VK_KEY_H */ -#define RDP_SCANCODE_KEY_J mk_rdp_scancode(0x24, false) /* VK_KEY_J */ -#define RDP_SCANCODE_KEY_K mk_rdp_scancode(0x25, false) /* VK_KEY_K */ -#define RDP_SCANCODE_KEY_L mk_rdp_scancode(0x26, false) /* VK_KEY_L */ -#define RDP_SCANCODE_OEM_1 mk_rdp_scancode(0x27, false) /* VK_OEM_1 ';' on US */ -#define RDP_SCANCODE_OEM_7 mk_rdp_scancode(0x28, false) /* VK_OEM_7 "'" on US */ -#define RDP_SCANCODE_OEM_3 mk_rdp_scancode(0x29, false) /* VK_OEM_3 Top left, '`' on US, JP DBE_SBCSCHAR */ -#define RDP_SCANCODE_LSHIFT mk_rdp_scancode(0x2A, false) /* VK_LSHIFT */ -#define RDP_SCANCODE_OEM_5 mk_rdp_scancode(0x2B, false) /* VK_OEM_5 Next to Enter, '\' on US */ -#define RDP_SCANCODE_KEY_Z mk_rdp_scancode(0x2C, false) /* VK_KEY_Z */ -#define RDP_SCANCODE_KEY_X mk_rdp_scancode(0x2D, false) /* VK_KEY_X */ -#define RDP_SCANCODE_KEY_C mk_rdp_scancode(0x2E, false) /* VK_KEY_C */ -#define RDP_SCANCODE_KEY_V mk_rdp_scancode(0x2F, false) /* VK_KEY_V */ -#define RDP_SCANCODE_KEY_B mk_rdp_scancode(0x30, false) /* VK_KEY_B */ -#define RDP_SCANCODE_KEY_N mk_rdp_scancode(0x31, false) /* VK_KEY_N */ -#define RDP_SCANCODE_KEY_M mk_rdp_scancode(0x32, false) /* VK_KEY_M */ -#define RDP_SCANCODE_OEM_COMMA mk_rdp_scancode(0x33, false) /* VK_OEM_COMMA */ -#define RDP_SCANCODE_OEM_PERIOD mk_rdp_scancode(0x34, false) /* VK_OEM_PERIOD */ -#define RDP_SCANCODE_OEM_2 mk_rdp_scancode(0x35, false) /* VK_OEM_2 '/' on US */ -#define RDP_SCANCODE_RSHIFT mk_rdp_scancode(0x36, false) /* VK_RSHIFT */ -#define RDP_SCANCODE_MULTIPLY mk_rdp_scancode(0x37, false) /* VK_MULTIPLY Numerical */ -#define RDP_SCANCODE_LMENU mk_rdp_scancode(0x38, false) /* VK_LMENU Left 'Alt' key */ -#define RDP_SCANCODE_SPACE mk_rdp_scancode(0x39, false) /* VK_SPACE */ -#define RDP_SCANCODE_CAPSLOCK mk_rdp_scancode(0x3A, false) /* VK_CAPITAL 'Caps Lock', JP DBE_ALPHANUMERIC */ -#define RDP_SCANCODE_F1 mk_rdp_scancode(0x3B, false) /* VK_F1 */ -#define RDP_SCANCODE_F2 mk_rdp_scancode(0x3C, false) /* VK_F2 */ -#define RDP_SCANCODE_F3 mk_rdp_scancode(0x3D, false) /* VK_F3 */ -#define RDP_SCANCODE_F4 mk_rdp_scancode(0x3E, false) /* VK_F4 */ -#define RDP_SCANCODE_F5 mk_rdp_scancode(0x3F, false) /* VK_F5 */ -#define RDP_SCANCODE_F6 mk_rdp_scancode(0x40, false) /* VK_F6 */ -#define RDP_SCANCODE_F7 mk_rdp_scancode(0x41, false) /* VK_F7 */ -#define RDP_SCANCODE_F8 mk_rdp_scancode(0x42, false) /* VK_F8 */ -#define RDP_SCANCODE_F9 mk_rdp_scancode(0x43, false) /* VK_F9 */ -#define RDP_SCANCODE_F10 mk_rdp_scancode(0x44, false) /* VK_F10 */ -#define RDP_SCANCODE_NUMLOCK mk_rdp_scancode(0x45, false) /* VK_NUMLOCK */ /* Note: when this seems to appear in PKBDLLHOOKSTRUCT it means Pause which must be sent as Ctrl + NumLock */ -#define RDP_SCANCODE_SCROLLLOCK mk_rdp_scancode(0x46, false) /* VK_SCROLL 'Scroll Lock', JP OEM_SCROLL */ -#define RDP_SCANCODE_NUMPAD7 mk_rdp_scancode(0x47, false) /* VK_NUMPAD7 */ -#define RDP_SCANCODE_NUMPAD8 mk_rdp_scancode(0x48, false) /* VK_NUMPAD8 */ -#define RDP_SCANCODE_NUMPAD9 mk_rdp_scancode(0x49, false) /* VK_NUMPAD9 */ -#define RDP_SCANCODE_SUBTRACT mk_rdp_scancode(0x4A, false) /* VK_SUBTRACT */ -#define RDP_SCANCODE_NUMPAD4 mk_rdp_scancode(0x4B, false) /* VK_NUMPAD4 */ -#define RDP_SCANCODE_NUMPAD5 mk_rdp_scancode(0x4C, false) /* VK_NUMPAD5 */ -#define RDP_SCANCODE_NUMPAD6 mk_rdp_scancode(0x4D, false) /* VK_NUMPAD6 */ -#define RDP_SCANCODE_ADD mk_rdp_scancode(0x4E, false) /* VK_ADD */ -#define RDP_SCANCODE_NUMPAD1 mk_rdp_scancode(0x4F, false) /* VK_NUMPAD1 */ -#define RDP_SCANCODE_NUMPAD2 mk_rdp_scancode(0x50, false) /* VK_NUMPAD2 */ -#define RDP_SCANCODE_NUMPAD3 mk_rdp_scancode(0x51, false) /* VK_NUMPAD3 */ -#define RDP_SCANCODE_NUMPAD0 mk_rdp_scancode(0x52, false) /* VK_NUMPAD0 */ -#define RDP_SCANCODE_DECIMAL mk_rdp_scancode(0x53, false) /* VK_DECIMAL Numerical, '.' on US */ -#define RDP_SCANCODE_SYSREQ mk_rdp_scancode(0x54, false) /* Sys Req */ -#define RDP_SCANCODE_OEM_102 mk_rdp_scancode(0x56, false) /* VK_OEM_102 Lower left '\' on US */ -#define RDP_SCANCODE_F11 mk_rdp_scancode(0x57, false) /* VK_F11 */ -#define RDP_SCANCODE_F12 mk_rdp_scancode(0x58, false) /* VK_F12 */ -#define RDP_SCANCODE_SLEEP mk_rdp_scancode(0x5F, false) /* VK_SLEEP OEM_8 on FR (undocumented?) */ -#define RDP_SCANCODE_ZOOM mk_rdp_scancode(0x62, false) /* VK_ZOOM (undocumented?) */ -#define RDP_SCANCODE_HELP mk_rdp_scancode(0x63, false) /* VK_HELP (undocumented?) */ - -#define RDP_SCANCODE_F13 mk_rdp_scancode(0x64, false) /* VK_F13 */ /* JP agree, should 0x7d according to ms894073 */ -#define RDP_SCANCODE_F14 mk_rdp_scancode(0x65, false) /* VK_F14 */ -#define RDP_SCANCODE_F15 mk_rdp_scancode(0x66, false) /* VK_F15 */ -#define RDP_SCANCODE_F16 mk_rdp_scancode(0x67, false) /* VK_F16 */ -#define RDP_SCANCODE_F17 mk_rdp_scancode(0x68, false) /* VK_F17 */ -#define RDP_SCANCODE_F18 mk_rdp_scancode(0x69, false) /* VK_F18 */ -#define RDP_SCANCODE_F19 mk_rdp_scancode(0x6A, false) /* VK_F19 */ -#define RDP_SCANCODE_F20 mk_rdp_scancode(0x6B, false) /* VK_F20 */ -#define RDP_SCANCODE_F21 mk_rdp_scancode(0x6C, false) /* VK_F21 */ -#define RDP_SCANCODE_F22 mk_rdp_scancode(0x6D, false) /* VK_F22 */ -#define RDP_SCANCODE_F23 mk_rdp_scancode(0x6E, false) /* VK_F23 */ /* JP agree */ -#define RDP_SCANCODE_F24 mk_rdp_scancode(0x6F, false) /* VK_F24 */ /* 0x87 according to ms894073 */ - -#define RDP_SCANCODE_HIRAGANA mk_rdp_scancode(0x70, false) /* JP DBE_HIRAGANA */ -#define RDP_SCANCODE_HANJA_KANJI mk_rdp_scancode(0x71, false) /* VK_HANJA / VK_KANJI (undocumented?) */ -#define RDP_SCANCODE_KANA_HANGUL mk_rdp_scancode(0x72, false) /* VK_KANA / VK_HANGUL (undocumented?) */ -#define RDP_SCANCODE_ABNT_C1 mk_rdp_scancode(0x73, false) /* VK_ABNT_C1 JP OEM_102 */ -#define RDP_SCANCODE_F24_JP mk_rdp_scancode(0x76, false) /* JP F24 */ -#define RDP_SCANCODE_CONVERT_JP mk_rdp_scancode(0x79, false) /* JP CONVERT */ -#define RDP_SCANCODE_NONCONVERT_JP mk_rdp_scancode(0x7B, false) /* JP NONCONVERT */ -#define RDP_SCANCODE_TAB_JP mk_rdp_scancode(0x7C, false) /* JP TAB */ -#define RDP_SCANCODE_BACKSLASH_JP mk_rdp_scancode(0x7D, false) /* JP OEM_5 ('\') */ -#define RDP_SCANCODE_ABNT_C2 mk_rdp_scancode(0x7E, false) /* VK_ABNT_C2, JP */ -#define RDP_SCANCODE_ABNT_C2 mk_rdp_scancode(0x7E, false) /* JP OEM_PA2 */ - -#define RDP_SCANCODE_RETURN_KP mk_rdp_scancode(0x1C, true) /* not RDP_SCANCODE_RETURN Numerical Enter */ -#define RDP_SCANCODE_RCONTROL mk_rdp_scancode(0x1D, true) /* VK_RCONTROL */ -#define RDP_SCANCODE_DIVIDE mk_rdp_scancode(0x35, true) /* VK_DIVIDE Numerical */ -#define RDP_SCANCODE_PRINTSCREEN mk_rdp_scancode(0x37, true) /* VK_EXECUTE/VK_PRINT/VK_SNAPSHOT Print Screen */ -#define RDP_SCANCODE_RMENU mk_rdp_scancode(0x38, true) /* VK_RMENU Right 'Alt' / 'Alt Gr' */ -#define RDP_SCANCODE_PAUSE mk_rdp_scancode(0x46, true) /* VK_PAUSE Pause / Break (Slightly special handling) */ -#define RDP_SCANCODE_HOME mk_rdp_scancode(0x47, true) /* VK_HOME */ -#define RDP_SCANCODE_UP mk_rdp_scancode(0x48, true) /* VK_UP */ -#define RDP_SCANCODE_PRIOR mk_rdp_scancode(0x49, true) /* VK_PRIOR 'Page Up' */ -#define RDP_SCANCODE_LEFT mk_rdp_scancode(0x4B, true) /* VK_LEFT */ -#define RDP_SCANCODE_RIGHT mk_rdp_scancode(0x4D, true) /* VK_RIGHT */ -#define RDP_SCANCODE_END mk_rdp_scancode(0x4F, true) /* VK_END */ -#define RDP_SCANCODE_DOWN mk_rdp_scancode(0x50, true) /* VK_DOWN */ -#define RDP_SCANCODE_NEXT mk_rdp_scancode(0x51, true) /* VK_NEXT 'Page Down' */ -#define RDP_SCANCODE_INSERT mk_rdp_scancode(0x52, true) /* VK_INSERT */ -#define RDP_SCANCODE_DELETE mk_rdp_scancode(0x53, true) /* VK_DELETE */ -#define RDP_SCANCODE_NULL mk_rdp_scancode(0x54, true) /* <00> */ -#define RDP_SCANCODE_HELP2 mk_rdp_scancode(0x56, true) /* Help - documented, different from VK_HELP */ -#define RDP_SCANCODE_LWIN mk_rdp_scancode(0x5B, true) /* VK_LWIN */ -#define RDP_SCANCODE_RWIN mk_rdp_scancode(0x5C, true) /* VK_RWIN */ -#define RDP_SCANCODE_APPS mk_rdp_scancode(0x5D, true) /* VK_APPS Application */ -#define RDP_SCANCODE_POWER_JP mk_rdp_scancode(0x5E, true) /* JP POWER */ -#define RDP_SCANCODE_SLEEP_JP mk_rdp_scancode(0x5F, true) /* JP SLEEP */ - -/* _not_ valid scancode, but this is what a windows PKBDLLHOOKSTRUCT for NumLock contains */ -#define RDP_SCANCODE_NUMLOCK_EXTENDED mk_rdp_scancode(0x45, true) /* should be RDP_SCANCODE_NUMLOCK */ -#define RDP_SCANCODE_RSHIFT_EXTENDED mk_rdp_scancode(0x36, true) /* should be RDP_SCANCODE_RSHIFT */ - -#endif /* __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H */ diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index 3234816d1..3daeee602 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #define RDP_KEYBOARD_LAYOUT_TYPE_STANDARD 1 #define RDP_KEYBOARD_LAYOUT_TYPE_VARIANT 2 @@ -189,12 +189,20 @@ typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; #define KBD_CHINESE_TRADITIONAL_MICROSOFT_PINYIN_IME_3 0xE00E0804 #define KBD_CHINESE_TRADITIONAL_ALPHANUMERIC 0xE00F0404 +/* Keyboard Types */ +#define KBD_TYPE_IBM_PC_XT 0x00000001 /* IBM PC/XT or compatible (83-key) keyboard */ +#define KBD_TYPE_OLIVETTI_ICO 0x00000002 /* Olivetti "ICO" (102-key) keyboard */ +#define KBD_TYPE_IBM_PC_AT 0x00000003 /* IBM PC/AT (84-key) and similar keyboards */ +#define KBD_TYPE_IBM_ENHANCED 0x00000004 /* IBM enhanced (101-key or 102-key) keyboard */ +#define KBD_TYPE_NOKIA_1050 0x00000005 /* Nokia 1050 and similar keyboards */ +#define KBD_TYPE_NOKIA_9140 0x00000006 /* Nokia 9140 and similar keyboards */ +#define KBD_TYPE_JAPANESE 0x00000007 /* Japanese keyboard */ + FREERDP_API uint32 freerdp_keyboard_init(uint32 keyboardLayoutId); FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(uint32 keyboardLayoutId); FREERDP_API RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_x11_keycode(uint32 keycode); FREERDP_API uint32 freerdp_keyboard_get_x11_keycode_from_rdp_scancode(uint32 scancode, boolean extended); FREERDP_API RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(uint32 vkcode); -FREERDP_API void freerdp_keyboard_set_layout_code(rdpSettings* settings); #endif /* __FREERDP_LOCALE_KEYBOARD_H */ diff --git a/include/freerdp/locale/virtual_key_codes.h b/include/freerdp/locale/vkcodes.h similarity index 100% rename from include/freerdp/locale/virtual_key_codes.h rename to include/freerdp/locale/vkcodes.h diff --git a/include/freerdp/scancode.h b/include/freerdp/scancode.h new file mode 100644 index 000000000..6da0bfe21 --- /dev/null +++ b/include/freerdp/scancode.h @@ -0,0 +1,185 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * RDP protocol "scancodes" + * + * Copyright 2009-2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H +#define __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H + +/* @msdn{cc240584} says: + * "... (a scancode is an 8-bit value specifying a key location on the keyboard). + * The server accepts a scancode value and translates it into the correct character depending on the language locale and keyboard layout used in the session." + * The 8-bit value is later called "keyCode" + * The extended flag is for all practical an important 9th bit with a strange encoding - not just a modifier. + */ + +typedef uint32 RDP_SCANCODE; /* Our own representation of a RDP protocol scancode */ +#define RDP_SCANCODE_CODE(_rdp_scancode) ((uint8)(_rdp_scancode & 0xFF)) +#define RDP_SCANCODE_EXTENDED(_rdp_scancode) (((_rdp_scancode) & 0x100) ? true : false) +#define MAKE_RDP_SCANCODE(_code, _extended) (((_code) & 0xFF) | ((_extended) ? 0x100 : 0)) + +/* Defines for known RDP_SCANCODE protocol values. + * Mostly the same as the PKBDLLHOOKSTRUCT scanCode, "A hardware scan code for the key", @msdn{ms644967}. + * Based @msdn{ms894073} US, @msdn{ms894072} UK, @msdn{ms892472} */ + +#define RDP_SCANCODE_UNKNOWN MAKE_RDP_SCANCODE(0x00, false) + +#define RDP_SCANCODE_ESCAPE MAKE_RDP_SCANCODE(0x01, false) /* VK_ESCAPE */ +#define RDP_SCANCODE_KEY_1 MAKE_RDP_SCANCODE(0x02, false) /* VK_KEY_1 */ +#define RDP_SCANCODE_KEY_2 MAKE_RDP_SCANCODE(0x03, false) /* VK_KEY_2 */ +#define RDP_SCANCODE_KEY_3 MAKE_RDP_SCANCODE(0x04, false) /* VK_KEY_3 */ +#define RDP_SCANCODE_KEY_4 MAKE_RDP_SCANCODE(0x05, false) /* VK_KEY_4 */ +#define RDP_SCANCODE_KEY_5 MAKE_RDP_SCANCODE(0x06, false) /* VK_KEY_5 */ +#define RDP_SCANCODE_KEY_6 MAKE_RDP_SCANCODE(0x07, false) /* VK_KEY_6 */ +#define RDP_SCANCODE_KEY_7 MAKE_RDP_SCANCODE(0x08, false) /* VK_KEY_7 */ +#define RDP_SCANCODE_KEY_8 MAKE_RDP_SCANCODE(0x09, false) /* VK_KEY_8 */ +#define RDP_SCANCODE_KEY_9 MAKE_RDP_SCANCODE(0x0A, false) /* VK_KEY_9 */ +#define RDP_SCANCODE_KEY_0 MAKE_RDP_SCANCODE(0x0B, false) /* VK_KEY_0 */ +#define RDP_SCANCODE_OEM_MINUS MAKE_RDP_SCANCODE(0x0C, false) /* VK_OEM_MINUS */ +#define RDP_SCANCODE_OEM_PLUS MAKE_RDP_SCANCODE(0x0D, false) /* VK_OEM_PLUS */ +#define RDP_SCANCODE_BACKSPACE MAKE_RDP_SCANCODE(0x0E, false) /* VK_BACK Backspace */ +#define RDP_SCANCODE_TAB MAKE_RDP_SCANCODE(0x0F, false) /* VK_TAB */ +#define RDP_SCANCODE_KEY_Q MAKE_RDP_SCANCODE(0x10, false) /* VK_KEY_Q */ +#define RDP_SCANCODE_KEY_W MAKE_RDP_SCANCODE(0x11, false) /* VK_KEY_W */ +#define RDP_SCANCODE_KEY_E MAKE_RDP_SCANCODE(0x12, false) /* VK_KEY_E */ +#define RDP_SCANCODE_KEY_R MAKE_RDP_SCANCODE(0x13, false) /* VK_KEY_R */ +#define RDP_SCANCODE_KEY_T MAKE_RDP_SCANCODE(0x14, false) /* VK_KEY_T */ +#define RDP_SCANCODE_KEY_Y MAKE_RDP_SCANCODE(0x15, false) /* VK_KEY_Y */ +#define RDP_SCANCODE_KEY_U MAKE_RDP_SCANCODE(0x16, false) /* VK_KEY_U */ +#define RDP_SCANCODE_KEY_I MAKE_RDP_SCANCODE(0x17, false) /* VK_KEY_I */ +#define RDP_SCANCODE_KEY_O MAKE_RDP_SCANCODE(0x18, false) /* VK_KEY_O */ +#define RDP_SCANCODE_KEY_P MAKE_RDP_SCANCODE(0x19, false) /* VK_KEY_P */ +#define RDP_SCANCODE_OEM_4 MAKE_RDP_SCANCODE(0x1A, false) /* VK_OEM_4 '[' on US */ +#define RDP_SCANCODE_OEM_6 MAKE_RDP_SCANCODE(0x1B, false) /* VK_OEM_6 ']' on US */ +#define RDP_SCANCODE_RETURN MAKE_RDP_SCANCODE(0x1C, false) /* VK_RETURN Normal Enter */ +#define RDP_SCANCODE_LCONTROL MAKE_RDP_SCANCODE(0x1D, false) /* VK_LCONTROL */ +#define RDP_SCANCODE_KEY_A MAKE_RDP_SCANCODE(0x1E, false) /* VK_KEY_A */ +#define RDP_SCANCODE_KEY_S MAKE_RDP_SCANCODE(0x1F, false) /* VK_KEY_S */ +#define RDP_SCANCODE_KEY_D MAKE_RDP_SCANCODE(0x20, false) /* VK_KEY_D */ +#define RDP_SCANCODE_KEY_F MAKE_RDP_SCANCODE(0x21, false) /* VK_KEY_F */ +#define RDP_SCANCODE_KEY_G MAKE_RDP_SCANCODE(0x22, false) /* VK_KEY_G */ +#define RDP_SCANCODE_KEY_H MAKE_RDP_SCANCODE(0x23, false) /* VK_KEY_H */ +#define RDP_SCANCODE_KEY_J MAKE_RDP_SCANCODE(0x24, false) /* VK_KEY_J */ +#define RDP_SCANCODE_KEY_K MAKE_RDP_SCANCODE(0x25, false) /* VK_KEY_K */ +#define RDP_SCANCODE_KEY_L MAKE_RDP_SCANCODE(0x26, false) /* VK_KEY_L */ +#define RDP_SCANCODE_OEM_1 MAKE_RDP_SCANCODE(0x27, false) /* VK_OEM_1 ';' on US */ +#define RDP_SCANCODE_OEM_7 MAKE_RDP_SCANCODE(0x28, false) /* VK_OEM_7 "'" on US */ +#define RDP_SCANCODE_OEM_3 MAKE_RDP_SCANCODE(0x29, false) /* VK_OEM_3 Top left, '`' on US, JP DBE_SBCSCHAR */ +#define RDP_SCANCODE_LSHIFT MAKE_RDP_SCANCODE(0x2A, false) /* VK_LSHIFT */ +#define RDP_SCANCODE_OEM_5 MAKE_RDP_SCANCODE(0x2B, false) /* VK_OEM_5 Next to Enter, '\' on US */ +#define RDP_SCANCODE_KEY_Z MAKE_RDP_SCANCODE(0x2C, false) /* VK_KEY_Z */ +#define RDP_SCANCODE_KEY_X MAKE_RDP_SCANCODE(0x2D, false) /* VK_KEY_X */ +#define RDP_SCANCODE_KEY_C MAKE_RDP_SCANCODE(0x2E, false) /* VK_KEY_C */ +#define RDP_SCANCODE_KEY_V MAKE_RDP_SCANCODE(0x2F, false) /* VK_KEY_V */ +#define RDP_SCANCODE_KEY_B MAKE_RDP_SCANCODE(0x30, false) /* VK_KEY_B */ +#define RDP_SCANCODE_KEY_N MAKE_RDP_SCANCODE(0x31, false) /* VK_KEY_N */ +#define RDP_SCANCODE_KEY_M MAKE_RDP_SCANCODE(0x32, false) /* VK_KEY_M */ +#define RDP_SCANCODE_OEM_COMMA MAKE_RDP_SCANCODE(0x33, false) /* VK_OEM_COMMA */ +#define RDP_SCANCODE_OEM_PERIOD MAKE_RDP_SCANCODE(0x34, false) /* VK_OEM_PERIOD */ +#define RDP_SCANCODE_OEM_2 MAKE_RDP_SCANCODE(0x35, false) /* VK_OEM_2 '/' on US */ +#define RDP_SCANCODE_RSHIFT MAKE_RDP_SCANCODE(0x36, false) /* VK_RSHIFT */ +#define RDP_SCANCODE_MULTIPLY MAKE_RDP_SCANCODE(0x37, false) /* VK_MULTIPLY Numerical */ +#define RDP_SCANCODE_LMENU MAKE_RDP_SCANCODE(0x38, false) /* VK_LMENU Left 'Alt' key */ +#define RDP_SCANCODE_SPACE MAKE_RDP_SCANCODE(0x39, false) /* VK_SPACE */ +#define RDP_SCANCODE_CAPSLOCK MAKE_RDP_SCANCODE(0x3A, false) /* VK_CAPITAL 'Caps Lock', JP DBE_ALPHANUMERIC */ +#define RDP_SCANCODE_F1 MAKE_RDP_SCANCODE(0x3B, false) /* VK_F1 */ +#define RDP_SCANCODE_F2 MAKE_RDP_SCANCODE(0x3C, false) /* VK_F2 */ +#define RDP_SCANCODE_F3 MAKE_RDP_SCANCODE(0x3D, false) /* VK_F3 */ +#define RDP_SCANCODE_F4 MAKE_RDP_SCANCODE(0x3E, false) /* VK_F4 */ +#define RDP_SCANCODE_F5 MAKE_RDP_SCANCODE(0x3F, false) /* VK_F5 */ +#define RDP_SCANCODE_F6 MAKE_RDP_SCANCODE(0x40, false) /* VK_F6 */ +#define RDP_SCANCODE_F7 MAKE_RDP_SCANCODE(0x41, false) /* VK_F7 */ +#define RDP_SCANCODE_F8 MAKE_RDP_SCANCODE(0x42, false) /* VK_F8 */ +#define RDP_SCANCODE_F9 MAKE_RDP_SCANCODE(0x43, false) /* VK_F9 */ +#define RDP_SCANCODE_F10 MAKE_RDP_SCANCODE(0x44, false) /* VK_F10 */ +#define RDP_SCANCODE_NUMLOCK MAKE_RDP_SCANCODE(0x45, false) /* VK_NUMLOCK */ /* Note: when this seems to appear in PKBDLLHOOKSTRUCT it means Pause which must be sent as Ctrl + NumLock */ +#define RDP_SCANCODE_SCROLLLOCK MAKE_RDP_SCANCODE(0x46, false) /* VK_SCROLL 'Scroll Lock', JP OEM_SCROLL */ +#define RDP_SCANCODE_NUMPAD7 MAKE_RDP_SCANCODE(0x47, false) /* VK_NUMPAD7 */ +#define RDP_SCANCODE_NUMPAD8 MAKE_RDP_SCANCODE(0x48, false) /* VK_NUMPAD8 */ +#define RDP_SCANCODE_NUMPAD9 MAKE_RDP_SCANCODE(0x49, false) /* VK_NUMPAD9 */ +#define RDP_SCANCODE_SUBTRACT MAKE_RDP_SCANCODE(0x4A, false) /* VK_SUBTRACT */ +#define RDP_SCANCODE_NUMPAD4 MAKE_RDP_SCANCODE(0x4B, false) /* VK_NUMPAD4 */ +#define RDP_SCANCODE_NUMPAD5 MAKE_RDP_SCANCODE(0x4C, false) /* VK_NUMPAD5 */ +#define RDP_SCANCODE_NUMPAD6 MAKE_RDP_SCANCODE(0x4D, false) /* VK_NUMPAD6 */ +#define RDP_SCANCODE_ADD MAKE_RDP_SCANCODE(0x4E, false) /* VK_ADD */ +#define RDP_SCANCODE_NUMPAD1 MAKE_RDP_SCANCODE(0x4F, false) /* VK_NUMPAD1 */ +#define RDP_SCANCODE_NUMPAD2 MAKE_RDP_SCANCODE(0x50, false) /* VK_NUMPAD2 */ +#define RDP_SCANCODE_NUMPAD3 MAKE_RDP_SCANCODE(0x51, false) /* VK_NUMPAD3 */ +#define RDP_SCANCODE_NUMPAD0 MAKE_RDP_SCANCODE(0x52, false) /* VK_NUMPAD0 */ +#define RDP_SCANCODE_DECIMAL MAKE_RDP_SCANCODE(0x53, false) /* VK_DECIMAL Numerical, '.' on US */ +#define RDP_SCANCODE_SYSREQ MAKE_RDP_SCANCODE(0x54, false) /* Sys Req */ +#define RDP_SCANCODE_OEM_102 MAKE_RDP_SCANCODE(0x56, false) /* VK_OEM_102 Lower left '\' on US */ +#define RDP_SCANCODE_F11 MAKE_RDP_SCANCODE(0x57, false) /* VK_F11 */ +#define RDP_SCANCODE_F12 MAKE_RDP_SCANCODE(0x58, false) /* VK_F12 */ +#define RDP_SCANCODE_SLEEP MAKE_RDP_SCANCODE(0x5F, false) /* VK_SLEEP OEM_8 on FR (undocumented?) */ +#define RDP_SCANCODE_ZOOM MAKE_RDP_SCANCODE(0x62, false) /* VK_ZOOM (undocumented?) */ +#define RDP_SCANCODE_HELP MAKE_RDP_SCANCODE(0x63, false) /* VK_HELP (undocumented?) */ + +#define RDP_SCANCODE_F13 MAKE_RDP_SCANCODE(0x64, false) /* VK_F13 */ /* JP agree, should 0x7d according to ms894073 */ +#define RDP_SCANCODE_F14 MAKE_RDP_SCANCODE(0x65, false) /* VK_F14 */ +#define RDP_SCANCODE_F15 MAKE_RDP_SCANCODE(0x66, false) /* VK_F15 */ +#define RDP_SCANCODE_F16 MAKE_RDP_SCANCODE(0x67, false) /* VK_F16 */ +#define RDP_SCANCODE_F17 MAKE_RDP_SCANCODE(0x68, false) /* VK_F17 */ +#define RDP_SCANCODE_F18 MAKE_RDP_SCANCODE(0x69, false) /* VK_F18 */ +#define RDP_SCANCODE_F19 MAKE_RDP_SCANCODE(0x6A, false) /* VK_F19 */ +#define RDP_SCANCODE_F20 MAKE_RDP_SCANCODE(0x6B, false) /* VK_F20 */ +#define RDP_SCANCODE_F21 MAKE_RDP_SCANCODE(0x6C, false) /* VK_F21 */ +#define RDP_SCANCODE_F22 MAKE_RDP_SCANCODE(0x6D, false) /* VK_F22 */ +#define RDP_SCANCODE_F23 MAKE_RDP_SCANCODE(0x6E, false) /* VK_F23 */ /* JP agree */ +#define RDP_SCANCODE_F24 MAKE_RDP_SCANCODE(0x6F, false) /* VK_F24 */ /* 0x87 according to ms894073 */ + +#define RDP_SCANCODE_HIRAGANA MAKE_RDP_SCANCODE(0x70, false) /* JP DBE_HIRAGANA */ +#define RDP_SCANCODE_HANJA_KANJI MAKE_RDP_SCANCODE(0x71, false) /* VK_HANJA / VK_KANJI (undocumented?) */ +#define RDP_SCANCODE_KANA_HANGUL MAKE_RDP_SCANCODE(0x72, false) /* VK_KANA / VK_HANGUL (undocumented?) */ +#define RDP_SCANCODE_ABNT_C1 MAKE_RDP_SCANCODE(0x73, false) /* VK_ABNT_C1 JP OEM_102 */ +#define RDP_SCANCODE_F24_JP MAKE_RDP_SCANCODE(0x76, false) /* JP F24 */ +#define RDP_SCANCODE_CONVERT_JP MAKE_RDP_SCANCODE(0x79, false) /* JP CONVERT */ +#define RDP_SCANCODE_NONCONVERT_JP MAKE_RDP_SCANCODE(0x7B, false) /* JP NONCONVERT */ +#define RDP_SCANCODE_TAB_JP MAKE_RDP_SCANCODE(0x7C, false) /* JP TAB */ +#define RDP_SCANCODE_BACKSLASH_JP MAKE_RDP_SCANCODE(0x7D, false) /* JP OEM_5 ('\') */ +#define RDP_SCANCODE_ABNT_C2 MAKE_RDP_SCANCODE(0x7E, false) /* VK_ABNT_C2, JP */ +#define RDP_SCANCODE_ABNT_C2 MAKE_RDP_SCANCODE(0x7E, false) /* JP OEM_PA2 */ + +#define RDP_SCANCODE_RETURN_KP MAKE_RDP_SCANCODE(0x1C, true) /* not RDP_SCANCODE_RETURN Numerical Enter */ +#define RDP_SCANCODE_RCONTROL MAKE_RDP_SCANCODE(0x1D, true) /* VK_RCONTROL */ +#define RDP_SCANCODE_DIVIDE MAKE_RDP_SCANCODE(0x35, true) /* VK_DIVIDE Numerical */ +#define RDP_SCANCODE_PRINTSCREEN MAKE_RDP_SCANCODE(0x37, true) /* VK_EXECUTE/VK_PRINT/VK_SNAPSHOT Print Screen */ +#define RDP_SCANCODE_RMENU MAKE_RDP_SCANCODE(0x38, true) /* VK_RMENU Right 'Alt' / 'Alt Gr' */ +#define RDP_SCANCODE_PAUSE MAKE_RDP_SCANCODE(0x46, true) /* VK_PAUSE Pause / Break (Slightly special handling) */ +#define RDP_SCANCODE_HOME MAKE_RDP_SCANCODE(0x47, true) /* VK_HOME */ +#define RDP_SCANCODE_UP MAKE_RDP_SCANCODE(0x48, true) /* VK_UP */ +#define RDP_SCANCODE_PRIOR MAKE_RDP_SCANCODE(0x49, true) /* VK_PRIOR 'Page Up' */ +#define RDP_SCANCODE_LEFT MAKE_RDP_SCANCODE(0x4B, true) /* VK_LEFT */ +#define RDP_SCANCODE_RIGHT MAKE_RDP_SCANCODE(0x4D, true) /* VK_RIGHT */ +#define RDP_SCANCODE_END MAKE_RDP_SCANCODE(0x4F, true) /* VK_END */ +#define RDP_SCANCODE_DOWN MAKE_RDP_SCANCODE(0x50, true) /* VK_DOWN */ +#define RDP_SCANCODE_NEXT MAKE_RDP_SCANCODE(0x51, true) /* VK_NEXT 'Page Down' */ +#define RDP_SCANCODE_INSERT MAKE_RDP_SCANCODE(0x52, true) /* VK_INSERT */ +#define RDP_SCANCODE_DELETE MAKE_RDP_SCANCODE(0x53, true) /* VK_DELETE */ +#define RDP_SCANCODE_NULL MAKE_RDP_SCANCODE(0x54, true) /* <00> */ +#define RDP_SCANCODE_HELP2 MAKE_RDP_SCANCODE(0x56, true) /* Help - documented, different from VK_HELP */ +#define RDP_SCANCODE_LWIN MAKE_RDP_SCANCODE(0x5B, true) /* VK_LWIN */ +#define RDP_SCANCODE_RWIN MAKE_RDP_SCANCODE(0x5C, true) /* VK_RWIN */ +#define RDP_SCANCODE_APPS MAKE_RDP_SCANCODE(0x5D, true) /* VK_APPS Application */ +#define RDP_SCANCODE_POWER_JP MAKE_RDP_SCANCODE(0x5E, true) /* JP POWER */ +#define RDP_SCANCODE_SLEEP_JP MAKE_RDP_SCANCODE(0x5F, true) /* JP SLEEP */ + +/* _not_ valid scancode, but this is what a windows PKBDLLHOOKSTRUCT for NumLock contains */ +#define RDP_SCANCODE_NUMLOCK_EXTENDED MAKE_RDP_SCANCODE(0x45, true) /* should be RDP_SCANCODE_NUMLOCK */ +#define RDP_SCANCODE_RSHIFT_EXTENDED MAKE_RDP_SCANCODE(0x36, true) /* should be RDP_SCANCODE_RSHIFT */ + +#endif /* __FREERDP_LOCALE_KEYBOARD_RDP_SCANCODE_H */ diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 592c7ac5b..f20276b05 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -61,8 +61,12 @@ boolean freerdp_connect(freerdp* instance) IFCALLRET(instance->PreConnect, status, instance); - /* Advanced settings for keyboard layout */ - freerdp_keyboard_set_layout_code(rdp->mcs->transport->settings); + if (settings->kbd_layout == KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002) + { + settings->kbd_type = 7; + settings->kbd_subtype = 2; + settings->kbd_fn_keys = 12; + } extension_load_and_init_plugins(rdp->extension); extension_pre_connect(rdp->extension); diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index 8e5185dec..17d9fdbb1 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -396,6 +396,14 @@ void freerdp_input_send_keyboard_event(rdpInput* input, uint16 flags, uint16 cod IFCALL(input->KeyboardEvent, input, flags, code); } +void freerdp_input_send_keyboard_event_ex(rdpInput* input, boolean down, uint32 rdp_scancode) +{ + freerdp_input_send_keyboard_event(input, + (RDP_SCANCODE_EXTENDED(rdp_scancode) ? KBD_FLAGS_EXTENDED : 0) | + ((down) ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE), + RDP_SCANCODE_CODE(rdp_scancode)); +} + void freerdp_input_send_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code) { IFCALL(input->UnicodeKeyboardEvent, input, flags, code); diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index fe3bcc8f3..a967ef2df 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -84,8 +84,8 @@ uint32 freerdp_keyboard_init(uint32 keyboardLayoutId) memset(RDP_SCANCODE_TO_X11_KEYCODE, 0, sizeof(RDP_SCANCODE_TO_X11_KEYCODE)); for (keycode=0; keycode < ARRAY_SIZE(RDP_SCANCODE_TO_X11_KEYCODE); keycode++) RDP_SCANCODE_TO_X11_KEYCODE - [rdp_scancode_code(X11_KEYCODE_TO_RDP_SCANCODE[keycode])] - [rdp_scancode_extended(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? 1 : 0] = keycode; + [RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode])] + [RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? 1 : 0] = keycode; return keyboardLayoutId; } @@ -93,8 +93,8 @@ uint32 freerdp_keyboard_init(uint32 keyboardLayoutId) RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_x11_keycode(uint32 keycode) { DEBUG_KBD("x11 keycode: %02X -> rdp code: %02X%s", keycode, - rdp_scancode_code(X11_KEYCODE_TO_RDP_SCANCODE[keycode]), - rdp_scancode_extended(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? " extended" : ""); + RDP_SCANCODE_CODE(X11_KEYCODE_TO_RDP_SCANCODE[keycode]), + RDP_SCANCODE_EXTENDED(X11_KEYCODE_TO_RDP_SCANCODE[keycode]) ? " extended" : ""); return X11_KEYCODE_TO_RDP_SCANCODE[keycode]; } @@ -111,19 +111,3 @@ RDP_SCANCODE freerdp_keyboard_get_rdp_scancode_from_virtual_key_code(uint32 vkco { return VIRTUAL_KEY_CODE_TO_DEFAULT_RDP_SCANCODE_TABLE[vkcode]; } - -/** - * Set keyboard layout(kbd_type,kbd_subtype,kbd_fn_keys).\n - * @param settings rdp settings - */ -void freerdp_keyboard_set_layout_code(rdpSettings* settings) -{ - /* for jp */ - if (settings->kbd_layout == 0xE0010411) - { - settings->kbd_type = 7; - settings->kbd_subtype = 2; - settings->kbd_fn_keys = 12; - } - -} diff --git a/libfreerdp/locale/keyboard_keymap.c b/libfreerdp/locale/keyboard_keymap.c index 5e74e2795..f6f487fa8 100644 --- a/libfreerdp/locale/keyboard_keymap.c +++ b/libfreerdp/locale/keyboard_keymap.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include "liblocale.h" diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index 52d2a1934..04d012e31 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -28,7 +28,7 @@ #include "liblocale.h" #include -#include +#include #include #include diff --git a/libfreerdp/locale/virtual_key_codes.c b/libfreerdp/locale/virtual_key_codes.c index 7e8b7cf86..24da1e533 100644 --- a/libfreerdp/locale/virtual_key_codes.c +++ b/libfreerdp/locale/virtual_key_codes.c @@ -21,7 +21,7 @@ #include "config.h" #endif -#include +#include #include From 258f2c958ae69041e3724a5dc9c84b1d54d14d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 17:10:08 -0400 Subject: [PATCH 11/64] cmake: add warnings for MSVC static runtime option --- CMakeLists.txt | 5 +++++ cmake/MSVCRuntime.cmake | 11 +++++------ libfreerdp/crypto/tls.c | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d851982cc..1d94a63c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,11 @@ if(MSVC) if(NOT DEFINED MSVC_RUNTIME) set(MSVC_RUNTIME "dynamic") endif() + if(${MSVC_RUNTIME} STREQUAL "static") + message(STATUS "Use the MSVC static runtime option carefully!") + message(STATUS "OpenSSL uses /MD by default, and is very picky") + message(STATUS "Random freeing errors are a common sign of runtime issues") + endif() configure_msvc_runtime() endif() diff --git a/cmake/MSVCRuntime.cmake b/cmake/MSVCRuntime.cmake index d659708e7..c71a750a5 100644 --- a/cmake/MSVCRuntime.cmake +++ b/cmake/MSVCRuntime.cmake @@ -17,23 +17,22 @@ macro(configure_msvc_runtime) CMAKE_CXX_FLAGS_RELWITHDEBINFO ) if(${MSVC_RUNTIME} STREQUAL "static") - message(STATUS - "MSVC: using statically-linked runtime (/MT and /MTd)." - ) + message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).") foreach(variable ${variables}) if(${variable} MATCHES "/MD") string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") endif() endforeach() else() - message(STATUS - "MSVC: using dynamically-linked runtime (/MD and /MDd)." - ) + message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).") foreach(variable ${variables}) if(${variable} MATCHES "/MT") string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}") endif() endforeach() endif() + foreach(variable ${variables}) + set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE) + endforeach() endif() endmacro(configure_msvc_runtime) diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index b4e8720ac..896653eeb 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -52,7 +52,6 @@ static CryptoCert tls_get_certificate(rdpTls* tls, boolean peer) static void tls_free_certificate(CryptoCert cert) { - X509_free(cert->px509); xfree(cert); } From 3d65cb1c27cde772b48150d4a0feb2d86f62c8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 17:46:23 -0400 Subject: [PATCH 12/64] channels: moved client-side implementations in client subdirectories --- channels/cliprdr/CMakeLists.txt | 21 +------- channels/cliprdr/client/CMakeLists.txt | 36 +++++++++++++ .../cliprdr/{ => client}/cliprdr_constants.h | 0 .../cliprdr/{ => client}/cliprdr_format.c | 0 .../cliprdr/{ => client}/cliprdr_format.h | 0 channels/cliprdr/{ => client}/cliprdr_main.c | 0 channels/cliprdr/{ => client}/cliprdr_main.h | 0 channels/drdynvc/CMakeLists.txt | 28 +--------- channels/drdynvc/client/CMakeLists.txt | 43 +++++++++++++++ .../drdynvc/{ => client}/audin/CMakeLists.txt | 0 .../{ => client}/audin/alsa/CMakeLists.txt | 0 .../{ => client}/audin/alsa/audin_alsa.c | 0 .../drdynvc/{ => client}/audin/audin_main.c | 0 .../drdynvc/{ => client}/audin/audin_main.h | 0 .../{ => client}/audin/pulse/CMakeLists.txt | 0 .../{ => client}/audin/pulse/audin_pulse.c | 0 channels/drdynvc/{ => client}/drdynvc_main.c | 0 channels/drdynvc/{ => client}/drdynvc_main.h | 0 channels/drdynvc/{ => client}/drdynvc_types.h | 0 channels/drdynvc/{ => client}/dvcman.c | 0 channels/drdynvc/{ => client}/dvcman.h | 0 .../drdynvc/{ => client}/tsmf/CMakeLists.txt | 0 .../{ => client}/tsmf/alsa/CMakeLists.txt | 0 .../{ => client}/tsmf/alsa/tsmf_alsa.c | 0 .../{ => client}/tsmf/ffmpeg/CMakeLists.txt | 0 .../{ => client}/tsmf/ffmpeg/tsmf_ffmpeg.c | 0 .../tsmf/gstreamer/CMakeLists.txt | 0 .../tsmf/gstreamer/tsmf_gstreamer.c | 0 .../{ => client}/tsmf/pulse/CMakeLists.txt | 0 .../{ => client}/tsmf/pulse/tsmf_pulse.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_audio.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_audio.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_codec.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_codec.h | 0 .../{ => client}/tsmf/tsmf_constants.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_decoder.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_decoder.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_ifman.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_ifman.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_main.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_main.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_media.c | 0 .../drdynvc/{ => client}/tsmf/tsmf_media.h | 0 .../drdynvc/{ => client}/tsmf/tsmf_types.h | 0 channels/rail/CMakeLists.txt | 21 +------- channels/rail/client/CMakeLists.txt | 36 +++++++++++++ channels/rail/{ => client}/rail_main.c | 0 channels/rail/{ => client}/rail_main.h | 0 channels/rail/{ => client}/rail_orders.c | 0 channels/rail/{ => client}/rail_orders.h | 0 channels/rdpdr/CMakeLists.txt | 37 +------------ channels/rdpdr/client/CMakeLists.txt | 52 +++++++++++++++++++ channels/rdpdr/{ => client}/devman.c | 0 channels/rdpdr/{ => client}/devman.h | 0 .../rdpdr/{ => client}/disk/CMakeLists.txt | 0 channels/rdpdr/{ => client}/disk/disk_file.c | 0 channels/rdpdr/{ => client}/disk/disk_file.h | 0 channels/rdpdr/{ => client}/disk/disk_main.c | 0 channels/rdpdr/{ => client}/irp.c | 0 channels/rdpdr/{ => client}/irp.h | 0 .../{ => client}/parallel/CMakeLists.txt | 0 .../{ => client}/parallel/parallel_main.c | 0 .../rdpdr/{ => client}/printer/CMakeLists.txt | 0 .../rdpdr/{ => client}/printer/printer_cups.c | 0 .../rdpdr/{ => client}/printer/printer_cups.h | 0 .../rdpdr/{ => client}/printer/printer_main.c | 0 .../rdpdr/{ => client}/printer/printer_main.h | 0 .../rdpdr/{ => client}/rdpdr_capabilities.c | 0 .../rdpdr/{ => client}/rdpdr_capabilities.h | 0 channels/rdpdr/{ => client}/rdpdr_constants.h | 0 channels/rdpdr/{ => client}/rdpdr_main.c | 0 channels/rdpdr/{ => client}/rdpdr_main.h | 0 channels/rdpdr/{ => client}/rdpdr_types.h | 0 .../rdpdr/{ => client}/serial/CMakeLists.txt | 0 .../{ => client}/serial/serial_constants.h | 0 .../rdpdr/{ => client}/serial/serial_main.c | 0 .../rdpdr/{ => client}/serial/serial_tty.c | 0 .../rdpdr/{ => client}/serial/serial_tty.h | 0 .../{ => client}/smartcard/CMakeLists.txt | 0 .../rdpdr/{ => client}/smartcard/scard_main.c | 0 .../rdpdr/{ => client}/smartcard/scard_main.h | 0 .../{ => client}/smartcard/scard_operations.c | 0 channels/rdpsnd/CMakeLists.txt | 31 +---------- channels/rdpsnd/client/CMakeLists.txt | 46 ++++++++++++++++ .../rdpsnd/{ => client}/alsa/CMakeLists.txt | 0 .../rdpsnd/{ => client}/alsa/rdpsnd_alsa.c | 0 .../{ => client}/mac_audio/CMakeLists.txt | 0 .../{ => client}/mac_audio/rdpsnd_audio_q.c | 0 .../rdpsnd/{ => client}/pulse/CMakeLists.txt | 0 .../rdpsnd/{ => client}/pulse/rdpsnd_pulse.c | 0 channels/rdpsnd/{ => client}/rdpsnd_main.c | 0 channels/rdpsnd/{ => client}/rdpsnd_main.h | 0 channels/skel/CMakeLists.txt | 18 +------ channels/skel/client/CMakeLists.txt | 33 ++++++++++++ channels/skel/{ => client}/readme.txt | 0 .../skel/{ => client}/server_chan_test.cpp | 0 channels/skel/{ => client}/skel_main.c | 0 channels/skel/{ => client}/skel_main.h | 0 98 files changed, 258 insertions(+), 144 deletions(-) create mode 100644 channels/cliprdr/client/CMakeLists.txt rename channels/cliprdr/{ => client}/cliprdr_constants.h (100%) rename channels/cliprdr/{ => client}/cliprdr_format.c (100%) rename channels/cliprdr/{ => client}/cliprdr_format.h (100%) rename channels/cliprdr/{ => client}/cliprdr_main.c (100%) rename channels/cliprdr/{ => client}/cliprdr_main.h (100%) create mode 100644 channels/drdynvc/client/CMakeLists.txt rename channels/drdynvc/{ => client}/audin/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/audin/alsa/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/audin/alsa/audin_alsa.c (100%) rename channels/drdynvc/{ => client}/audin/audin_main.c (100%) rename channels/drdynvc/{ => client}/audin/audin_main.h (100%) rename channels/drdynvc/{ => client}/audin/pulse/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/audin/pulse/audin_pulse.c (100%) rename channels/drdynvc/{ => client}/drdynvc_main.c (100%) rename channels/drdynvc/{ => client}/drdynvc_main.h (100%) rename channels/drdynvc/{ => client}/drdynvc_types.h (100%) rename channels/drdynvc/{ => client}/dvcman.c (100%) rename channels/drdynvc/{ => client}/dvcman.h (100%) rename channels/drdynvc/{ => client}/tsmf/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/tsmf/alsa/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/tsmf/alsa/tsmf_alsa.c (100%) rename channels/drdynvc/{ => client}/tsmf/ffmpeg/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/tsmf/ffmpeg/tsmf_ffmpeg.c (100%) rename channels/drdynvc/{ => client}/tsmf/gstreamer/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/tsmf/gstreamer/tsmf_gstreamer.c (100%) rename channels/drdynvc/{ => client}/tsmf/pulse/CMakeLists.txt (100%) rename channels/drdynvc/{ => client}/tsmf/pulse/tsmf_pulse.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_audio.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_audio.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_codec.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_codec.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_constants.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_decoder.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_decoder.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_ifman.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_ifman.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_main.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_main.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_media.c (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_media.h (100%) rename channels/drdynvc/{ => client}/tsmf/tsmf_types.h (100%) create mode 100644 channels/rail/client/CMakeLists.txt rename channels/rail/{ => client}/rail_main.c (100%) rename channels/rail/{ => client}/rail_main.h (100%) rename channels/rail/{ => client}/rail_orders.c (100%) rename channels/rail/{ => client}/rail_orders.h (100%) create mode 100644 channels/rdpdr/client/CMakeLists.txt rename channels/rdpdr/{ => client}/devman.c (100%) rename channels/rdpdr/{ => client}/devman.h (100%) rename channels/rdpdr/{ => client}/disk/CMakeLists.txt (100%) rename channels/rdpdr/{ => client}/disk/disk_file.c (100%) rename channels/rdpdr/{ => client}/disk/disk_file.h (100%) rename channels/rdpdr/{ => client}/disk/disk_main.c (100%) rename channels/rdpdr/{ => client}/irp.c (100%) rename channels/rdpdr/{ => client}/irp.h (100%) rename channels/rdpdr/{ => client}/parallel/CMakeLists.txt (100%) rename channels/rdpdr/{ => client}/parallel/parallel_main.c (100%) rename channels/rdpdr/{ => client}/printer/CMakeLists.txt (100%) rename channels/rdpdr/{ => client}/printer/printer_cups.c (100%) rename channels/rdpdr/{ => client}/printer/printer_cups.h (100%) rename channels/rdpdr/{ => client}/printer/printer_main.c (100%) rename channels/rdpdr/{ => client}/printer/printer_main.h (100%) rename channels/rdpdr/{ => client}/rdpdr_capabilities.c (100%) rename channels/rdpdr/{ => client}/rdpdr_capabilities.h (100%) rename channels/rdpdr/{ => client}/rdpdr_constants.h (100%) rename channels/rdpdr/{ => client}/rdpdr_main.c (100%) rename channels/rdpdr/{ => client}/rdpdr_main.h (100%) rename channels/rdpdr/{ => client}/rdpdr_types.h (100%) rename channels/rdpdr/{ => client}/serial/CMakeLists.txt (100%) rename channels/rdpdr/{ => client}/serial/serial_constants.h (100%) rename channels/rdpdr/{ => client}/serial/serial_main.c (100%) rename channels/rdpdr/{ => client}/serial/serial_tty.c (100%) rename channels/rdpdr/{ => client}/serial/serial_tty.h (100%) rename channels/rdpdr/{ => client}/smartcard/CMakeLists.txt (100%) rename channels/rdpdr/{ => client}/smartcard/scard_main.c (100%) rename channels/rdpdr/{ => client}/smartcard/scard_main.h (100%) rename channels/rdpdr/{ => client}/smartcard/scard_operations.c (100%) create mode 100644 channels/rdpsnd/client/CMakeLists.txt rename channels/rdpsnd/{ => client}/alsa/CMakeLists.txt (100%) rename channels/rdpsnd/{ => client}/alsa/rdpsnd_alsa.c (100%) rename channels/rdpsnd/{ => client}/mac_audio/CMakeLists.txt (100%) rename channels/rdpsnd/{ => client}/mac_audio/rdpsnd_audio_q.c (100%) rename channels/rdpsnd/{ => client}/pulse/CMakeLists.txt (100%) rename channels/rdpsnd/{ => client}/pulse/rdpsnd_pulse.c (100%) rename channels/rdpsnd/{ => client}/rdpsnd_main.c (100%) rename channels/rdpsnd/{ => client}/rdpsnd_main.h (100%) create mode 100644 channels/skel/client/CMakeLists.txt rename channels/skel/{ => client}/readme.txt (100%) rename channels/skel/{ => client}/server_chan_test.cpp (100%) rename channels/skel/{ => client}/skel_main.c (100%) rename channels/skel/{ => client}/skel_main.h (100%) diff --git a/channels/cliprdr/CMakeLists.txt b/channels/cliprdr/CMakeLists.txt index 5c30a67ef..e6e70054d 100644 --- a/channels/cliprdr/CMakeLists.txt +++ b/channels/cliprdr/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,20 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(CLIPRDR_SRCS - cliprdr_constants.h - cliprdr_format.c - cliprdr_format.h - cliprdr_main.c - cliprdr_main.h) +add_subdirectory(client) -add_library(cliprdr ${CLIPRDR_SRCS}) -set_target_properties(cliprdr PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(cliprdr freerdp) -else() - target_link_libraries(cliprdr freerdp-utils) -endif() - -install(TARGETS cliprdr DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/cliprdr/client/CMakeLists.txt b/channels/cliprdr/client/CMakeLists.txt new file mode 100644 index 000000000..5c30a67ef --- /dev/null +++ b/channels/cliprdr/client/CMakeLists.txt @@ -0,0 +1,36 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(CLIPRDR_SRCS + cliprdr_constants.h + cliprdr_format.c + cliprdr_format.h + cliprdr_main.c + cliprdr_main.h) + +add_library(cliprdr ${CLIPRDR_SRCS}) +set_target_properties(cliprdr PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(cliprdr freerdp) +else() + target_link_libraries(cliprdr freerdp-utils) +endif() + +install(TARGETS cliprdr DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/cliprdr/cliprdr_constants.h b/channels/cliprdr/client/cliprdr_constants.h similarity index 100% rename from channels/cliprdr/cliprdr_constants.h rename to channels/cliprdr/client/cliprdr_constants.h diff --git a/channels/cliprdr/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c similarity index 100% rename from channels/cliprdr/cliprdr_format.c rename to channels/cliprdr/client/cliprdr_format.c diff --git a/channels/cliprdr/cliprdr_format.h b/channels/cliprdr/client/cliprdr_format.h similarity index 100% rename from channels/cliprdr/cliprdr_format.h rename to channels/cliprdr/client/cliprdr_format.h diff --git a/channels/cliprdr/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c similarity index 100% rename from channels/cliprdr/cliprdr_main.c rename to channels/cliprdr/client/cliprdr_main.c diff --git a/channels/cliprdr/cliprdr_main.h b/channels/cliprdr/client/cliprdr_main.h similarity index 100% rename from channels/cliprdr/cliprdr_main.h rename to channels/cliprdr/client/cliprdr_main.h diff --git a/channels/drdynvc/CMakeLists.txt b/channels/drdynvc/CMakeLists.txt index b1deab049..e6e70054d 100644 --- a/channels/drdynvc/CMakeLists.txt +++ b/channels/drdynvc/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,27 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(DRDYNVC_SRCS - drdynvc_main.c - drdynvc_main.h - drdynvc_types.h - dvcman.c - dvcman.h -) +add_subdirectory(client) -add_library(drdynvc ${DRDYNVC_SRCS}) -set_target_properties(drdynvc PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(drdynvc freerdp) -else() - target_link_libraries(drdynvc freerdp-utils) -endif() - -install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) - -if(NOT WIN32) - add_subdirectory(tsmf) -endif() - -add_subdirectory(audin) diff --git a/channels/drdynvc/client/CMakeLists.txt b/channels/drdynvc/client/CMakeLists.txt new file mode 100644 index 000000000..b1deab049 --- /dev/null +++ b/channels/drdynvc/client/CMakeLists.txt @@ -0,0 +1,43 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(DRDYNVC_SRCS + drdynvc_main.c + drdynvc_main.h + drdynvc_types.h + dvcman.c + dvcman.h +) + +add_library(drdynvc ${DRDYNVC_SRCS}) +set_target_properties(drdynvc PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(drdynvc freerdp) +else() + target_link_libraries(drdynvc freerdp-utils) +endif() + +install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) + +if(NOT WIN32) + add_subdirectory(tsmf) +endif() + +add_subdirectory(audin) diff --git a/channels/drdynvc/audin/CMakeLists.txt b/channels/drdynvc/client/audin/CMakeLists.txt similarity index 100% rename from channels/drdynvc/audin/CMakeLists.txt rename to channels/drdynvc/client/audin/CMakeLists.txt diff --git a/channels/drdynvc/audin/alsa/CMakeLists.txt b/channels/drdynvc/client/audin/alsa/CMakeLists.txt similarity index 100% rename from channels/drdynvc/audin/alsa/CMakeLists.txt rename to channels/drdynvc/client/audin/alsa/CMakeLists.txt diff --git a/channels/drdynvc/audin/alsa/audin_alsa.c b/channels/drdynvc/client/audin/alsa/audin_alsa.c similarity index 100% rename from channels/drdynvc/audin/alsa/audin_alsa.c rename to channels/drdynvc/client/audin/alsa/audin_alsa.c diff --git a/channels/drdynvc/audin/audin_main.c b/channels/drdynvc/client/audin/audin_main.c similarity index 100% rename from channels/drdynvc/audin/audin_main.c rename to channels/drdynvc/client/audin/audin_main.c diff --git a/channels/drdynvc/audin/audin_main.h b/channels/drdynvc/client/audin/audin_main.h similarity index 100% rename from channels/drdynvc/audin/audin_main.h rename to channels/drdynvc/client/audin/audin_main.h diff --git a/channels/drdynvc/audin/pulse/CMakeLists.txt b/channels/drdynvc/client/audin/pulse/CMakeLists.txt similarity index 100% rename from channels/drdynvc/audin/pulse/CMakeLists.txt rename to channels/drdynvc/client/audin/pulse/CMakeLists.txt diff --git a/channels/drdynvc/audin/pulse/audin_pulse.c b/channels/drdynvc/client/audin/pulse/audin_pulse.c similarity index 100% rename from channels/drdynvc/audin/pulse/audin_pulse.c rename to channels/drdynvc/client/audin/pulse/audin_pulse.c diff --git a/channels/drdynvc/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c similarity index 100% rename from channels/drdynvc/drdynvc_main.c rename to channels/drdynvc/client/drdynvc_main.c diff --git a/channels/drdynvc/drdynvc_main.h b/channels/drdynvc/client/drdynvc_main.h similarity index 100% rename from channels/drdynvc/drdynvc_main.h rename to channels/drdynvc/client/drdynvc_main.h diff --git a/channels/drdynvc/drdynvc_types.h b/channels/drdynvc/client/drdynvc_types.h similarity index 100% rename from channels/drdynvc/drdynvc_types.h rename to channels/drdynvc/client/drdynvc_types.h diff --git a/channels/drdynvc/dvcman.c b/channels/drdynvc/client/dvcman.c similarity index 100% rename from channels/drdynvc/dvcman.c rename to channels/drdynvc/client/dvcman.c diff --git a/channels/drdynvc/dvcman.h b/channels/drdynvc/client/dvcman.h similarity index 100% rename from channels/drdynvc/dvcman.h rename to channels/drdynvc/client/dvcman.h diff --git a/channels/drdynvc/tsmf/CMakeLists.txt b/channels/drdynvc/client/tsmf/CMakeLists.txt similarity index 100% rename from channels/drdynvc/tsmf/CMakeLists.txt rename to channels/drdynvc/client/tsmf/CMakeLists.txt diff --git a/channels/drdynvc/tsmf/alsa/CMakeLists.txt b/channels/drdynvc/client/tsmf/alsa/CMakeLists.txt similarity index 100% rename from channels/drdynvc/tsmf/alsa/CMakeLists.txt rename to channels/drdynvc/client/tsmf/alsa/CMakeLists.txt diff --git a/channels/drdynvc/tsmf/alsa/tsmf_alsa.c b/channels/drdynvc/client/tsmf/alsa/tsmf_alsa.c similarity index 100% rename from channels/drdynvc/tsmf/alsa/tsmf_alsa.c rename to channels/drdynvc/client/tsmf/alsa/tsmf_alsa.c diff --git a/channels/drdynvc/tsmf/ffmpeg/CMakeLists.txt b/channels/drdynvc/client/tsmf/ffmpeg/CMakeLists.txt similarity index 100% rename from channels/drdynvc/tsmf/ffmpeg/CMakeLists.txt rename to channels/drdynvc/client/tsmf/ffmpeg/CMakeLists.txt diff --git a/channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c b/channels/drdynvc/client/tsmf/ffmpeg/tsmf_ffmpeg.c similarity index 100% rename from channels/drdynvc/tsmf/ffmpeg/tsmf_ffmpeg.c rename to channels/drdynvc/client/tsmf/ffmpeg/tsmf_ffmpeg.c diff --git a/channels/drdynvc/tsmf/gstreamer/CMakeLists.txt b/channels/drdynvc/client/tsmf/gstreamer/CMakeLists.txt similarity index 100% rename from channels/drdynvc/tsmf/gstreamer/CMakeLists.txt rename to channels/drdynvc/client/tsmf/gstreamer/CMakeLists.txt diff --git a/channels/drdynvc/tsmf/gstreamer/tsmf_gstreamer.c b/channels/drdynvc/client/tsmf/gstreamer/tsmf_gstreamer.c similarity index 100% rename from channels/drdynvc/tsmf/gstreamer/tsmf_gstreamer.c rename to channels/drdynvc/client/tsmf/gstreamer/tsmf_gstreamer.c diff --git a/channels/drdynvc/tsmf/pulse/CMakeLists.txt b/channels/drdynvc/client/tsmf/pulse/CMakeLists.txt similarity index 100% rename from channels/drdynvc/tsmf/pulse/CMakeLists.txt rename to channels/drdynvc/client/tsmf/pulse/CMakeLists.txt diff --git a/channels/drdynvc/tsmf/pulse/tsmf_pulse.c b/channels/drdynvc/client/tsmf/pulse/tsmf_pulse.c similarity index 100% rename from channels/drdynvc/tsmf/pulse/tsmf_pulse.c rename to channels/drdynvc/client/tsmf/pulse/tsmf_pulse.c diff --git a/channels/drdynvc/tsmf/tsmf_audio.c b/channels/drdynvc/client/tsmf/tsmf_audio.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_audio.c rename to channels/drdynvc/client/tsmf/tsmf_audio.c diff --git a/channels/drdynvc/tsmf/tsmf_audio.h b/channels/drdynvc/client/tsmf/tsmf_audio.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_audio.h rename to channels/drdynvc/client/tsmf/tsmf_audio.h diff --git a/channels/drdynvc/tsmf/tsmf_codec.c b/channels/drdynvc/client/tsmf/tsmf_codec.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_codec.c rename to channels/drdynvc/client/tsmf/tsmf_codec.c diff --git a/channels/drdynvc/tsmf/tsmf_codec.h b/channels/drdynvc/client/tsmf/tsmf_codec.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_codec.h rename to channels/drdynvc/client/tsmf/tsmf_codec.h diff --git a/channels/drdynvc/tsmf/tsmf_constants.h b/channels/drdynvc/client/tsmf/tsmf_constants.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_constants.h rename to channels/drdynvc/client/tsmf/tsmf_constants.h diff --git a/channels/drdynvc/tsmf/tsmf_decoder.c b/channels/drdynvc/client/tsmf/tsmf_decoder.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_decoder.c rename to channels/drdynvc/client/tsmf/tsmf_decoder.c diff --git a/channels/drdynvc/tsmf/tsmf_decoder.h b/channels/drdynvc/client/tsmf/tsmf_decoder.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_decoder.h rename to channels/drdynvc/client/tsmf/tsmf_decoder.h diff --git a/channels/drdynvc/tsmf/tsmf_ifman.c b/channels/drdynvc/client/tsmf/tsmf_ifman.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_ifman.c rename to channels/drdynvc/client/tsmf/tsmf_ifman.c diff --git a/channels/drdynvc/tsmf/tsmf_ifman.h b/channels/drdynvc/client/tsmf/tsmf_ifman.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_ifman.h rename to channels/drdynvc/client/tsmf/tsmf_ifman.h diff --git a/channels/drdynvc/tsmf/tsmf_main.c b/channels/drdynvc/client/tsmf/tsmf_main.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_main.c rename to channels/drdynvc/client/tsmf/tsmf_main.c diff --git a/channels/drdynvc/tsmf/tsmf_main.h b/channels/drdynvc/client/tsmf/tsmf_main.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_main.h rename to channels/drdynvc/client/tsmf/tsmf_main.h diff --git a/channels/drdynvc/tsmf/tsmf_media.c b/channels/drdynvc/client/tsmf/tsmf_media.c similarity index 100% rename from channels/drdynvc/tsmf/tsmf_media.c rename to channels/drdynvc/client/tsmf/tsmf_media.c diff --git a/channels/drdynvc/tsmf/tsmf_media.h b/channels/drdynvc/client/tsmf/tsmf_media.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_media.h rename to channels/drdynvc/client/tsmf/tsmf_media.h diff --git a/channels/drdynvc/tsmf/tsmf_types.h b/channels/drdynvc/client/tsmf/tsmf_types.h similarity index 100% rename from channels/drdynvc/tsmf/tsmf_types.h rename to channels/drdynvc/client/tsmf/tsmf_types.h diff --git a/channels/rail/CMakeLists.txt b/channels/rail/CMakeLists.txt index 6e6a45441..e6e70054d 100644 --- a/channels/rail/CMakeLists.txt +++ b/channels/rail/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,20 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(RAIL_SRCS - rail_main.c - rail_main.h - rail_orders.c - rail_orders.h) - -add_library(rail ${RAIL_SRCS}) -set_target_properties(rail PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(rail freerdp) -else() - target_link_libraries(rail freerdp-utils) -endif() - -install(TARGETS rail DESTINATION ${FREERDP_PLUGIN_PATH}) +add_subdirectory(client) diff --git a/channels/rail/client/CMakeLists.txt b/channels/rail/client/CMakeLists.txt new file mode 100644 index 000000000..6e6a45441 --- /dev/null +++ b/channels/rail/client/CMakeLists.txt @@ -0,0 +1,36 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(RAIL_SRCS + rail_main.c + rail_main.h + rail_orders.c + rail_orders.h) + +add_library(rail ${RAIL_SRCS}) +set_target_properties(rail PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(rail freerdp) +else() + target_link_libraries(rail freerdp-utils) +endif() + +install(TARGETS rail DESTINATION ${FREERDP_PLUGIN_PATH}) + diff --git a/channels/rail/rail_main.c b/channels/rail/client/rail_main.c similarity index 100% rename from channels/rail/rail_main.c rename to channels/rail/client/rail_main.c diff --git a/channels/rail/rail_main.h b/channels/rail/client/rail_main.h similarity index 100% rename from channels/rail/rail_main.h rename to channels/rail/client/rail_main.h diff --git a/channels/rail/rail_orders.c b/channels/rail/client/rail_orders.c similarity index 100% rename from channels/rail/rail_orders.c rename to channels/rail/client/rail_orders.c diff --git a/channels/rail/rail_orders.h b/channels/rail/client/rail_orders.h similarity index 100% rename from channels/rail/rail_orders.h rename to channels/rail/client/rail_orders.h diff --git a/channels/rdpdr/CMakeLists.txt b/channels/rdpdr/CMakeLists.txt index 55b0e09ba..e6e70054d 100644 --- a/channels/rdpdr/CMakeLists.txt +++ b/channels/rdpdr/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,36 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(RDPDR_SRCS - rdpdr_constants.h - rdpdr_types.h - rdpdr_capabilities.c - rdpdr_capabilities.h - devman.c - devman.h - irp.c - irp.h - rdpdr_main.c - rdpdr_main.h) +add_subdirectory(client) -add_library(rdpdr ${RDPDR_SRCS}) -set_target_properties(rdpdr PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(rdpdr freerdp) -else() - target_link_libraries(rdpdr freerdp-utils) -endif() - -install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) - -if(NOT WIN32) - add_subdirectory(disk) - add_subdirectory(printer) - add_subdirectory(parallel) - add_subdirectory(serial) -endif() - -if(WITH_PCSC) - add_subdirectory(smartcard) -endif() diff --git a/channels/rdpdr/client/CMakeLists.txt b/channels/rdpdr/client/CMakeLists.txt new file mode 100644 index 000000000..55b0e09ba --- /dev/null +++ b/channels/rdpdr/client/CMakeLists.txt @@ -0,0 +1,52 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(RDPDR_SRCS + rdpdr_constants.h + rdpdr_types.h + rdpdr_capabilities.c + rdpdr_capabilities.h + devman.c + devman.h + irp.c + irp.h + rdpdr_main.c + rdpdr_main.h) + +add_library(rdpdr ${RDPDR_SRCS}) +set_target_properties(rdpdr PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(rdpdr freerdp) +else() + target_link_libraries(rdpdr freerdp-utils) +endif() + +install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) + +if(NOT WIN32) + add_subdirectory(disk) + add_subdirectory(printer) + add_subdirectory(parallel) + add_subdirectory(serial) +endif() + +if(WITH_PCSC) + add_subdirectory(smartcard) +endif() diff --git a/channels/rdpdr/devman.c b/channels/rdpdr/client/devman.c similarity index 100% rename from channels/rdpdr/devman.c rename to channels/rdpdr/client/devman.c diff --git a/channels/rdpdr/devman.h b/channels/rdpdr/client/devman.h similarity index 100% rename from channels/rdpdr/devman.h rename to channels/rdpdr/client/devman.h diff --git a/channels/rdpdr/disk/CMakeLists.txt b/channels/rdpdr/client/disk/CMakeLists.txt similarity index 100% rename from channels/rdpdr/disk/CMakeLists.txt rename to channels/rdpdr/client/disk/CMakeLists.txt diff --git a/channels/rdpdr/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c similarity index 100% rename from channels/rdpdr/disk/disk_file.c rename to channels/rdpdr/client/disk/disk_file.c diff --git a/channels/rdpdr/disk/disk_file.h b/channels/rdpdr/client/disk/disk_file.h similarity index 100% rename from channels/rdpdr/disk/disk_file.h rename to channels/rdpdr/client/disk/disk_file.h diff --git a/channels/rdpdr/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c similarity index 100% rename from channels/rdpdr/disk/disk_main.c rename to channels/rdpdr/client/disk/disk_main.c diff --git a/channels/rdpdr/irp.c b/channels/rdpdr/client/irp.c similarity index 100% rename from channels/rdpdr/irp.c rename to channels/rdpdr/client/irp.c diff --git a/channels/rdpdr/irp.h b/channels/rdpdr/client/irp.h similarity index 100% rename from channels/rdpdr/irp.h rename to channels/rdpdr/client/irp.h diff --git a/channels/rdpdr/parallel/CMakeLists.txt b/channels/rdpdr/client/parallel/CMakeLists.txt similarity index 100% rename from channels/rdpdr/parallel/CMakeLists.txt rename to channels/rdpdr/client/parallel/CMakeLists.txt diff --git a/channels/rdpdr/parallel/parallel_main.c b/channels/rdpdr/client/parallel/parallel_main.c similarity index 100% rename from channels/rdpdr/parallel/parallel_main.c rename to channels/rdpdr/client/parallel/parallel_main.c diff --git a/channels/rdpdr/printer/CMakeLists.txt b/channels/rdpdr/client/printer/CMakeLists.txt similarity index 100% rename from channels/rdpdr/printer/CMakeLists.txt rename to channels/rdpdr/client/printer/CMakeLists.txt diff --git a/channels/rdpdr/printer/printer_cups.c b/channels/rdpdr/client/printer/printer_cups.c similarity index 100% rename from channels/rdpdr/printer/printer_cups.c rename to channels/rdpdr/client/printer/printer_cups.c diff --git a/channels/rdpdr/printer/printer_cups.h b/channels/rdpdr/client/printer/printer_cups.h similarity index 100% rename from channels/rdpdr/printer/printer_cups.h rename to channels/rdpdr/client/printer/printer_cups.h diff --git a/channels/rdpdr/printer/printer_main.c b/channels/rdpdr/client/printer/printer_main.c similarity index 100% rename from channels/rdpdr/printer/printer_main.c rename to channels/rdpdr/client/printer/printer_main.c diff --git a/channels/rdpdr/printer/printer_main.h b/channels/rdpdr/client/printer/printer_main.h similarity index 100% rename from channels/rdpdr/printer/printer_main.h rename to channels/rdpdr/client/printer/printer_main.h diff --git a/channels/rdpdr/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c similarity index 100% rename from channels/rdpdr/rdpdr_capabilities.c rename to channels/rdpdr/client/rdpdr_capabilities.c diff --git a/channels/rdpdr/rdpdr_capabilities.h b/channels/rdpdr/client/rdpdr_capabilities.h similarity index 100% rename from channels/rdpdr/rdpdr_capabilities.h rename to channels/rdpdr/client/rdpdr_capabilities.h diff --git a/channels/rdpdr/rdpdr_constants.h b/channels/rdpdr/client/rdpdr_constants.h similarity index 100% rename from channels/rdpdr/rdpdr_constants.h rename to channels/rdpdr/client/rdpdr_constants.h diff --git a/channels/rdpdr/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c similarity index 100% rename from channels/rdpdr/rdpdr_main.c rename to channels/rdpdr/client/rdpdr_main.c diff --git a/channels/rdpdr/rdpdr_main.h b/channels/rdpdr/client/rdpdr_main.h similarity index 100% rename from channels/rdpdr/rdpdr_main.h rename to channels/rdpdr/client/rdpdr_main.h diff --git a/channels/rdpdr/rdpdr_types.h b/channels/rdpdr/client/rdpdr_types.h similarity index 100% rename from channels/rdpdr/rdpdr_types.h rename to channels/rdpdr/client/rdpdr_types.h diff --git a/channels/rdpdr/serial/CMakeLists.txt b/channels/rdpdr/client/serial/CMakeLists.txt similarity index 100% rename from channels/rdpdr/serial/CMakeLists.txt rename to channels/rdpdr/client/serial/CMakeLists.txt diff --git a/channels/rdpdr/serial/serial_constants.h b/channels/rdpdr/client/serial/serial_constants.h similarity index 100% rename from channels/rdpdr/serial/serial_constants.h rename to channels/rdpdr/client/serial/serial_constants.h diff --git a/channels/rdpdr/serial/serial_main.c b/channels/rdpdr/client/serial/serial_main.c similarity index 100% rename from channels/rdpdr/serial/serial_main.c rename to channels/rdpdr/client/serial/serial_main.c diff --git a/channels/rdpdr/serial/serial_tty.c b/channels/rdpdr/client/serial/serial_tty.c similarity index 100% rename from channels/rdpdr/serial/serial_tty.c rename to channels/rdpdr/client/serial/serial_tty.c diff --git a/channels/rdpdr/serial/serial_tty.h b/channels/rdpdr/client/serial/serial_tty.h similarity index 100% rename from channels/rdpdr/serial/serial_tty.h rename to channels/rdpdr/client/serial/serial_tty.h diff --git a/channels/rdpdr/smartcard/CMakeLists.txt b/channels/rdpdr/client/smartcard/CMakeLists.txt similarity index 100% rename from channels/rdpdr/smartcard/CMakeLists.txt rename to channels/rdpdr/client/smartcard/CMakeLists.txt diff --git a/channels/rdpdr/smartcard/scard_main.c b/channels/rdpdr/client/smartcard/scard_main.c similarity index 100% rename from channels/rdpdr/smartcard/scard_main.c rename to channels/rdpdr/client/smartcard/scard_main.c diff --git a/channels/rdpdr/smartcard/scard_main.h b/channels/rdpdr/client/smartcard/scard_main.h similarity index 100% rename from channels/rdpdr/smartcard/scard_main.h rename to channels/rdpdr/client/smartcard/scard_main.h diff --git a/channels/rdpdr/smartcard/scard_operations.c b/channels/rdpdr/client/smartcard/scard_operations.c similarity index 100% rename from channels/rdpdr/smartcard/scard_operations.c rename to channels/rdpdr/client/smartcard/scard_operations.c diff --git a/channels/rdpsnd/CMakeLists.txt b/channels/rdpsnd/CMakeLists.txt index 745358da0..e6e70054d 100644 --- a/channels/rdpsnd/CMakeLists.txt +++ b/channels/rdpsnd/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,30 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(RDPSND_SRCS - rdpsnd_main.c - rdpsnd_main.h) - -add_library(rdpsnd ${RDPSND_SRCS}) -set_target_properties(rdpsnd PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(rdpsnd freerdp) -else() - target_link_libraries(rdpsnd freerdp-utils) -endif() - -install(TARGETS rdpsnd DESTINATION ${FREERDP_PLUGIN_PATH}) - -if(WITH_ALSA) - add_subdirectory(alsa) -endif() - -if(WITH_PULSEAUDIO) - add_subdirectory(pulse) -endif() - -if(WITH_MACAUDIO) - add_subdirectory(mac_audio) -endif() +add_subdirectory(client) diff --git a/channels/rdpsnd/client/CMakeLists.txt b/channels/rdpsnd/client/CMakeLists.txt new file mode 100644 index 000000000..745358da0 --- /dev/null +++ b/channels/rdpsnd/client/CMakeLists.txt @@ -0,0 +1,46 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(RDPSND_SRCS + rdpsnd_main.c + rdpsnd_main.h) + +add_library(rdpsnd ${RDPSND_SRCS}) +set_target_properties(rdpsnd PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(rdpsnd freerdp) +else() + target_link_libraries(rdpsnd freerdp-utils) +endif() + +install(TARGETS rdpsnd DESTINATION ${FREERDP_PLUGIN_PATH}) + +if(WITH_ALSA) + add_subdirectory(alsa) +endif() + +if(WITH_PULSEAUDIO) + add_subdirectory(pulse) +endif() + +if(WITH_MACAUDIO) + add_subdirectory(mac_audio) +endif() + diff --git a/channels/rdpsnd/alsa/CMakeLists.txt b/channels/rdpsnd/client/alsa/CMakeLists.txt similarity index 100% rename from channels/rdpsnd/alsa/CMakeLists.txt rename to channels/rdpsnd/client/alsa/CMakeLists.txt diff --git a/channels/rdpsnd/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c similarity index 100% rename from channels/rdpsnd/alsa/rdpsnd_alsa.c rename to channels/rdpsnd/client/alsa/rdpsnd_alsa.c diff --git a/channels/rdpsnd/mac_audio/CMakeLists.txt b/channels/rdpsnd/client/mac_audio/CMakeLists.txt similarity index 100% rename from channels/rdpsnd/mac_audio/CMakeLists.txt rename to channels/rdpsnd/client/mac_audio/CMakeLists.txt diff --git a/channels/rdpsnd/mac_audio/rdpsnd_audio_q.c b/channels/rdpsnd/client/mac_audio/rdpsnd_audio_q.c similarity index 100% rename from channels/rdpsnd/mac_audio/rdpsnd_audio_q.c rename to channels/rdpsnd/client/mac_audio/rdpsnd_audio_q.c diff --git a/channels/rdpsnd/pulse/CMakeLists.txt b/channels/rdpsnd/client/pulse/CMakeLists.txt similarity index 100% rename from channels/rdpsnd/pulse/CMakeLists.txt rename to channels/rdpsnd/client/pulse/CMakeLists.txt diff --git a/channels/rdpsnd/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c similarity index 100% rename from channels/rdpsnd/pulse/rdpsnd_pulse.c rename to channels/rdpsnd/client/pulse/rdpsnd_pulse.c diff --git a/channels/rdpsnd/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c similarity index 100% rename from channels/rdpsnd/rdpsnd_main.c rename to channels/rdpsnd/client/rdpsnd_main.c diff --git a/channels/rdpsnd/rdpsnd_main.h b/channels/rdpsnd/client/rdpsnd_main.h similarity index 100% rename from channels/rdpsnd/rdpsnd_main.h rename to channels/rdpsnd/client/rdpsnd_main.h diff --git a/channels/skel/CMakeLists.txt b/channels/skel/CMakeLists.txt index 1c2943c8f..e6e70054d 100644 --- a/channels/skel/CMakeLists.txt +++ b/channels/skel/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,17 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(SKEL_SRCS - skel_main.c - skel_main.h) +add_subdirectory(client) -add_library(skel ${SKEL_SRCS}) -set_target_properties(skel PROPERTIES PREFIX "") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(skel freerdp) -else() - target_link_libraries(skel freerdp-utils) -endif() - -install(TARGETS skel DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/skel/client/CMakeLists.txt b/channels/skel/client/CMakeLists.txt new file mode 100644 index 000000000..1c2943c8f --- /dev/null +++ b/channels/skel/client/CMakeLists.txt @@ -0,0 +1,33 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(SKEL_SRCS + skel_main.c + skel_main.h) + +add_library(skel ${SKEL_SRCS}) +set_target_properties(skel PROPERTIES PREFIX "") + +if(WITH_MONOLITHIC_BUILD) + target_link_libraries(skel freerdp) +else() + target_link_libraries(skel freerdp-utils) +endif() + +install(TARGETS skel DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/skel/readme.txt b/channels/skel/client/readme.txt similarity index 100% rename from channels/skel/readme.txt rename to channels/skel/client/readme.txt diff --git a/channels/skel/server_chan_test.cpp b/channels/skel/client/server_chan_test.cpp similarity index 100% rename from channels/skel/server_chan_test.cpp rename to channels/skel/client/server_chan_test.cpp diff --git a/channels/skel/skel_main.c b/channels/skel/client/skel_main.c similarity index 100% rename from channels/skel/skel_main.c rename to channels/skel/client/skel_main.c diff --git a/channels/skel/skel_main.h b/channels/skel/client/skel_main.h similarity index 100% rename from channels/skel/skel_main.h rename to channels/skel/client/skel_main.h From 81974d1b2a2a4c81d8f91dbb0934da2c2c1d016d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 18:08:22 -0400 Subject: [PATCH 13/64] channels: moving dynamic virtual channels --- channels/{skel => audin}/CMakeLists.txt | 0 channels/audin/ChannelOptions.cmake | 10 ++++++++++ .../audin => audin/client}/CMakeLists.txt | 0 .../client}/alsa/CMakeLists.txt | 0 .../audin => audin/client}/alsa/audin_alsa.c | 0 .../audin => audin/client}/audin_main.c | 0 .../audin => audin/client}/audin_main.h | 14 +++++++++++++- .../client}/pulse/CMakeLists.txt | 0 .../client}/pulse/audin_pulse.c | 0 channels/drdynvc/client/CMakeLists.txt | 5 ----- channels/sample/CMakeLists.txt | 19 +++++++++++++++++++ channels/sample/ChannelOptions.cmake | 9 +++++++++ .../{skel => sample}/client/CMakeLists.txt | 0 channels/{skel => sample}/client/readme.txt | 0 .../client/server_chan_test.cpp | 0 channels/{skel => sample}/client/skel_main.c | 0 channels/{skel => sample}/client/skel_main.h | 0 channels/skel/ChannelOptions.cmake | 8 -------- channels/tsmf/ChannelOptions.cmake | 15 +++++++++++++++ .../tsmf => tsmf/client}/CMakeLists.txt | 0 .../tsmf => tsmf/client}/alsa/CMakeLists.txt | 0 .../tsmf => tsmf/client}/alsa/tsmf_alsa.c | 0 .../client}/ffmpeg/CMakeLists.txt | 0 .../tsmf => tsmf/client}/ffmpeg/tsmf_ffmpeg.c | 0 .../client}/gstreamer/CMakeLists.txt | 0 .../client}/gstreamer/tsmf_gstreamer.c | 0 .../tsmf => tsmf/client}/pulse/CMakeLists.txt | 0 .../tsmf => tsmf/client}/pulse/tsmf_pulse.c | 0 .../client/tsmf => tsmf/client}/tsmf_audio.c | 0 .../client/tsmf => tsmf/client}/tsmf_audio.h | 0 .../client/tsmf => tsmf/client}/tsmf_codec.c | 0 .../client/tsmf => tsmf/client}/tsmf_codec.h | 0 .../tsmf => tsmf/client}/tsmf_constants.h | 0 .../tsmf => tsmf/client}/tsmf_decoder.c | 0 .../tsmf => tsmf/client}/tsmf_decoder.h | 0 .../client/tsmf => tsmf/client}/tsmf_ifman.c | 0 .../client/tsmf => tsmf/client}/tsmf_ifman.h | 0 .../client/tsmf => tsmf/client}/tsmf_main.c | 0 .../client/tsmf => tsmf/client}/tsmf_main.h | 0 .../client/tsmf => tsmf/client}/tsmf_media.c | 0 .../client/tsmf => tsmf/client}/tsmf_media.h | 0 .../client/tsmf => tsmf/client}/tsmf_types.h | 0 42 files changed, 66 insertions(+), 14 deletions(-) rename channels/{skel => audin}/CMakeLists.txt (100%) create mode 100644 channels/audin/ChannelOptions.cmake rename channels/{drdynvc/client/audin => audin/client}/CMakeLists.txt (100%) rename channels/{drdynvc/client/audin => audin/client}/alsa/CMakeLists.txt (100%) rename channels/{drdynvc/client/audin => audin/client}/alsa/audin_alsa.c (100%) rename channels/{drdynvc/client/audin => audin/client}/audin_main.c (100%) rename channels/{drdynvc/client/audin => audin/client}/audin_main.h (87%) rename channels/{drdynvc/client/audin => audin/client}/pulse/CMakeLists.txt (100%) rename channels/{drdynvc/client/audin => audin/client}/pulse/audin_pulse.c (100%) create mode 100644 channels/sample/CMakeLists.txt create mode 100644 channels/sample/ChannelOptions.cmake rename channels/{skel => sample}/client/CMakeLists.txt (100%) rename channels/{skel => sample}/client/readme.txt (100%) rename channels/{skel => sample}/client/server_chan_test.cpp (100%) rename channels/{skel => sample}/client/skel_main.c (100%) rename channels/{skel => sample}/client/skel_main.h (100%) delete mode 100644 channels/skel/ChannelOptions.cmake create mode 100644 channels/tsmf/ChannelOptions.cmake rename channels/{drdynvc/client/tsmf => tsmf/client}/CMakeLists.txt (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/alsa/CMakeLists.txt (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/alsa/tsmf_alsa.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/ffmpeg/CMakeLists.txt (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/ffmpeg/tsmf_ffmpeg.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/gstreamer/CMakeLists.txt (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/gstreamer/tsmf_gstreamer.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/pulse/CMakeLists.txt (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/pulse/tsmf_pulse.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_audio.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_audio.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_codec.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_codec.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_constants.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_decoder.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_decoder.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_ifman.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_ifman.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_main.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_main.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_media.c (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_media.h (100%) rename channels/{drdynvc/client/tsmf => tsmf/client}/tsmf_types.h (100%) diff --git a/channels/skel/CMakeLists.txt b/channels/audin/CMakeLists.txt similarity index 100% rename from channels/skel/CMakeLists.txt rename to channels/audin/CMakeLists.txt diff --git a/channels/audin/ChannelOptions.cmake b/channels/audin/ChannelOptions.cmake new file mode 100644 index 000000000..71cc38a8d --- /dev/null +++ b/channels/audin/ChannelOptions.cmake @@ -0,0 +1,10 @@ + +set(CHANNEL_TYPE "dynamic") +set(CHANNEL_SHORT_NAME "audin") +set(CHANNEL_LONG_NAME "Audio Input Redirection Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEAI]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) + + diff --git a/channels/drdynvc/client/audin/CMakeLists.txt b/channels/audin/client/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/audin/CMakeLists.txt rename to channels/audin/client/CMakeLists.txt diff --git a/channels/drdynvc/client/audin/alsa/CMakeLists.txt b/channels/audin/client/alsa/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/audin/alsa/CMakeLists.txt rename to channels/audin/client/alsa/CMakeLists.txt diff --git a/channels/drdynvc/client/audin/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c similarity index 100% rename from channels/drdynvc/client/audin/alsa/audin_alsa.c rename to channels/audin/client/alsa/audin_alsa.c diff --git a/channels/drdynvc/client/audin/audin_main.c b/channels/audin/client/audin_main.c similarity index 100% rename from channels/drdynvc/client/audin/audin_main.c rename to channels/audin/client/audin_main.c diff --git a/channels/drdynvc/client/audin/audin_main.h b/channels/audin/client/audin_main.h similarity index 87% rename from channels/drdynvc/client/audin/audin_main.h rename to channels/audin/client/audin_main.h index 6ac45a283..e848acf7a 100644 --- a/channels/drdynvc/client/audin/audin_main.h +++ b/channels/audin/client/audin_main.h @@ -20,7 +20,19 @@ #ifndef __AUDIN_MAIN_H #define __AUDIN_MAIN_H -#include "drdynvc_types.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#ifdef WITH_DEBUG_DVC +#define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) +#else +#define DEBUG_DVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#endif typedef boolean (*AudinReceive) (uint8* data, int size, void* user_data); diff --git a/channels/drdynvc/client/audin/pulse/CMakeLists.txt b/channels/audin/client/pulse/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/audin/pulse/CMakeLists.txt rename to channels/audin/client/pulse/CMakeLists.txt diff --git a/channels/drdynvc/client/audin/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c similarity index 100% rename from channels/drdynvc/client/audin/pulse/audin_pulse.c rename to channels/audin/client/pulse/audin_pulse.c diff --git a/channels/drdynvc/client/CMakeLists.txt b/channels/drdynvc/client/CMakeLists.txt index b1deab049..69a86139b 100644 --- a/channels/drdynvc/client/CMakeLists.txt +++ b/channels/drdynvc/client/CMakeLists.txt @@ -36,8 +36,3 @@ endif() install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) -if(NOT WIN32) - add_subdirectory(tsmf) -endif() - -add_subdirectory(audin) diff --git a/channels/sample/CMakeLists.txt b/channels/sample/CMakeLists.txt new file mode 100644 index 000000000..e6e70054d --- /dev/null +++ b/channels/sample/CMakeLists.txt @@ -0,0 +1,19 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +add_subdirectory(client) + diff --git a/channels/sample/ChannelOptions.cmake b/channels/sample/ChannelOptions.cmake new file mode 100644 index 000000000..430a072ca --- /dev/null +++ b/channels/sample/ChannelOptions.cmake @@ -0,0 +1,9 @@ + +set(CHANNEL_TYPE "static") +set(CHANNEL_SHORT_NAME "sample") +set(CHANNEL_LONG_NAME "Sample Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) + diff --git a/channels/skel/client/CMakeLists.txt b/channels/sample/client/CMakeLists.txt similarity index 100% rename from channels/skel/client/CMakeLists.txt rename to channels/sample/client/CMakeLists.txt diff --git a/channels/skel/client/readme.txt b/channels/sample/client/readme.txt similarity index 100% rename from channels/skel/client/readme.txt rename to channels/sample/client/readme.txt diff --git a/channels/skel/client/server_chan_test.cpp b/channels/sample/client/server_chan_test.cpp similarity index 100% rename from channels/skel/client/server_chan_test.cpp rename to channels/sample/client/server_chan_test.cpp diff --git a/channels/skel/client/skel_main.c b/channels/sample/client/skel_main.c similarity index 100% rename from channels/skel/client/skel_main.c rename to channels/sample/client/skel_main.c diff --git a/channels/skel/client/skel_main.h b/channels/sample/client/skel_main.h similarity index 100% rename from channels/skel/client/skel_main.h rename to channels/sample/client/skel_main.h diff --git a/channels/skel/ChannelOptions.cmake b/channels/skel/ChannelOptions.cmake deleted file mode 100644 index 9125cb227..000000000 --- a/channels/skel/ChannelOptions.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -set(CHANNEL_TYPE "static") -set(CHANNEL_SHORT_NAME "skel") -set(CHANNEL_LONG_NAME "Skeleton Code Virtual Channel Extension") -set(CHANNEL_SPECIFICATIONS "") - -option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) - diff --git a/channels/tsmf/ChannelOptions.cmake b/channels/tsmf/ChannelOptions.cmake new file mode 100644 index 000000000..0e79c69f5 --- /dev/null +++ b/channels/tsmf/ChannelOptions.cmake @@ -0,0 +1,15 @@ + +set(CHANNEL_TYPE "dynamic") +set(CHANNEL_SHORT_NAME "tsmf") +set(CHANNEL_LONG_NAME "Video Redirection Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEV]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) + +if(WIN32) + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) +else() + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) +endif() + + diff --git a/channels/drdynvc/client/tsmf/CMakeLists.txt b/channels/tsmf/client/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/tsmf/CMakeLists.txt rename to channels/tsmf/client/CMakeLists.txt diff --git a/channels/drdynvc/client/tsmf/alsa/CMakeLists.txt b/channels/tsmf/client/alsa/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/tsmf/alsa/CMakeLists.txt rename to channels/tsmf/client/alsa/CMakeLists.txt diff --git a/channels/drdynvc/client/tsmf/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c similarity index 100% rename from channels/drdynvc/client/tsmf/alsa/tsmf_alsa.c rename to channels/tsmf/client/alsa/tsmf_alsa.c diff --git a/channels/drdynvc/client/tsmf/ffmpeg/CMakeLists.txt b/channels/tsmf/client/ffmpeg/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/tsmf/ffmpeg/CMakeLists.txt rename to channels/tsmf/client/ffmpeg/CMakeLists.txt diff --git a/channels/drdynvc/client/tsmf/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c similarity index 100% rename from channels/drdynvc/client/tsmf/ffmpeg/tsmf_ffmpeg.c rename to channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c diff --git a/channels/drdynvc/client/tsmf/gstreamer/CMakeLists.txt b/channels/tsmf/client/gstreamer/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/tsmf/gstreamer/CMakeLists.txt rename to channels/tsmf/client/gstreamer/CMakeLists.txt diff --git a/channels/drdynvc/client/tsmf/gstreamer/tsmf_gstreamer.c b/channels/tsmf/client/gstreamer/tsmf_gstreamer.c similarity index 100% rename from channels/drdynvc/client/tsmf/gstreamer/tsmf_gstreamer.c rename to channels/tsmf/client/gstreamer/tsmf_gstreamer.c diff --git a/channels/drdynvc/client/tsmf/pulse/CMakeLists.txt b/channels/tsmf/client/pulse/CMakeLists.txt similarity index 100% rename from channels/drdynvc/client/tsmf/pulse/CMakeLists.txt rename to channels/tsmf/client/pulse/CMakeLists.txt diff --git a/channels/drdynvc/client/tsmf/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c similarity index 100% rename from channels/drdynvc/client/tsmf/pulse/tsmf_pulse.c rename to channels/tsmf/client/pulse/tsmf_pulse.c diff --git a/channels/drdynvc/client/tsmf/tsmf_audio.c b/channels/tsmf/client/tsmf_audio.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_audio.c rename to channels/tsmf/client/tsmf_audio.c diff --git a/channels/drdynvc/client/tsmf/tsmf_audio.h b/channels/tsmf/client/tsmf_audio.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_audio.h rename to channels/tsmf/client/tsmf_audio.h diff --git a/channels/drdynvc/client/tsmf/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_codec.c rename to channels/tsmf/client/tsmf_codec.c diff --git a/channels/drdynvc/client/tsmf/tsmf_codec.h b/channels/tsmf/client/tsmf_codec.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_codec.h rename to channels/tsmf/client/tsmf_codec.h diff --git a/channels/drdynvc/client/tsmf/tsmf_constants.h b/channels/tsmf/client/tsmf_constants.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_constants.h rename to channels/tsmf/client/tsmf_constants.h diff --git a/channels/drdynvc/client/tsmf/tsmf_decoder.c b/channels/tsmf/client/tsmf_decoder.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_decoder.c rename to channels/tsmf/client/tsmf_decoder.c diff --git a/channels/drdynvc/client/tsmf/tsmf_decoder.h b/channels/tsmf/client/tsmf_decoder.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_decoder.h rename to channels/tsmf/client/tsmf_decoder.h diff --git a/channels/drdynvc/client/tsmf/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_ifman.c rename to channels/tsmf/client/tsmf_ifman.c diff --git a/channels/drdynvc/client/tsmf/tsmf_ifman.h b/channels/tsmf/client/tsmf_ifman.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_ifman.h rename to channels/tsmf/client/tsmf_ifman.h diff --git a/channels/drdynvc/client/tsmf/tsmf_main.c b/channels/tsmf/client/tsmf_main.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_main.c rename to channels/tsmf/client/tsmf_main.c diff --git a/channels/drdynvc/client/tsmf/tsmf_main.h b/channels/tsmf/client/tsmf_main.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_main.h rename to channels/tsmf/client/tsmf_main.h diff --git a/channels/drdynvc/client/tsmf/tsmf_media.c b/channels/tsmf/client/tsmf_media.c similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_media.c rename to channels/tsmf/client/tsmf_media.c diff --git a/channels/drdynvc/client/tsmf/tsmf_media.h b/channels/tsmf/client/tsmf_media.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_media.h rename to channels/tsmf/client/tsmf_media.h diff --git a/channels/drdynvc/client/tsmf/tsmf_types.h b/channels/tsmf/client/tsmf_types.h similarity index 100% rename from channels/drdynvc/client/tsmf/tsmf_types.h rename to channels/tsmf/client/tsmf_types.h From e4e85be15db638e5202febe3c1a001b82bf546ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 19:25:21 -0400 Subject: [PATCH 14/64] channels: add automatic inclusion and bundling of built-in server channels --- channels/CMakeLists.txt | 6 ++-- channels/audin/CMakeLists.txt | 10 ++++++ channels/audin/server/CMakeLists.txt | 29 +++++++++++++++ .../audin/server}/audin.c | 0 channels/rdpsnd/CMakeLists.txt | 10 ++++++ channels/rdpsnd/ChannelOptions.cmake | 2 ++ channels/rdpsnd/server/CMakeLists.txt | 29 +++++++++++++++ .../rdpsnd/server}/rdpsnd.c | 0 channels/server/CMakeLists.txt | 35 +++++++++++++++++++ channels/tsmf/CMakeLists.txt | 19 ++++++++++ channels/tsmf/client/tsmf_audio.h | 2 +- channels/tsmf/client/tsmf_codec.c | 1 - channels/tsmf/client/tsmf_decoder.c | 1 - channels/tsmf/client/tsmf_decoder.h | 1 - channels/tsmf/client/tsmf_ifman.c | 2 +- channels/tsmf/client/tsmf_main.c | 2 +- channels/tsmf/client/tsmf_media.c | 1 - channels/tsmf/client/tsmf_types.h | 12 +++++++ server/CMakeLists.txt | 2 -- server/channels/CMakeLists.txt | 34 ------------------ 20 files changed, 152 insertions(+), 46 deletions(-) create mode 100644 channels/audin/server/CMakeLists.txt rename {server/channels => channels/audin/server}/audin.c (100%) create mode 100644 channels/rdpsnd/server/CMakeLists.txt rename {server/channels => channels/rdpsnd/server}/rdpsnd.c (100%) create mode 100644 channels/server/CMakeLists.txt create mode 100644 channels/tsmf/CMakeLists.txt delete mode 100644 server/channels/CMakeLists.txt diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index c29f04e30..3ecbbd569 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,3 +30,5 @@ foreach(FILEPATH ${FILEPATHS}) endif() endforeach(FILEPATH) +add_subdirectory(server) + diff --git a/channels/audin/CMakeLists.txt b/channels/audin/CMakeLists.txt index e6e70054d..45849a4e0 100644 --- a/channels/audin/CMakeLists.txt +++ b/channels/audin/CMakeLists.txt @@ -15,5 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "audin") +set(MODULE_PREFIX "CHANNEL_AUDIN") + add_subdirectory(client) +add_subdirectory(server) + +set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) +set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) +set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) + + diff --git a/channels/audin/server/CMakeLists.txt b/channels/audin/server/CMakeLists.txt new file mode 100644 index 000000000..3280cfd05 --- /dev/null +++ b/channels/audin/server/CMakeLists.txt @@ -0,0 +1,29 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_PREFIX "CHANNEL_AUDIN_SERVER") + +set(${MODULE_PREFIX}_SRCS + audin.c + PARENT_SCOPE) + +if(WITH_MONOLITHIC_BUILD) + set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE) +else() + set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE) +endif() + diff --git a/server/channels/audin.c b/channels/audin/server/audin.c similarity index 100% rename from server/channels/audin.c rename to channels/audin/server/audin.c diff --git a/channels/rdpsnd/CMakeLists.txt b/channels/rdpsnd/CMakeLists.txt index e6e70054d..aad0c5af1 100644 --- a/channels/rdpsnd/CMakeLists.txt +++ b/channels/rdpsnd/CMakeLists.txt @@ -15,5 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "rdpsnd") +set(MODULE_PREFIX "CHANNEL_RDPSND") + add_subdirectory(client) +add_subdirectory(server) + +set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) +set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) +set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) + + diff --git a/channels/rdpsnd/ChannelOptions.cmake b/channels/rdpsnd/ChannelOptions.cmake index fb8b2ef2a..1b307d2ee 100644 --- a/channels/rdpsnd/ChannelOptions.cmake +++ b/channels/rdpsnd/ChannelOptions.cmake @@ -4,6 +4,8 @@ set(CHANNEL_SHORT_NAME "rdpsnd") set(CHANNEL_LONG_NAME "Audio Output Virtual Channel Extension") set(CHANNEL_SPECIFICATIONS "[MS-RDPEA]") +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) + if(WIN32) option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) else() diff --git a/channels/rdpsnd/server/CMakeLists.txt b/channels/rdpsnd/server/CMakeLists.txt new file mode 100644 index 000000000..2e680b46e --- /dev/null +++ b/channels/rdpsnd/server/CMakeLists.txt @@ -0,0 +1,29 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_PREFIX "CHANNEL_RDPSND_SERVER") + +set(${MODULE_PREFIX}_SRCS + rdpsnd.c + PARENT_SCOPE) + +if(WITH_MONOLITHIC_BUILD) + set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE) +else() + set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE) +endif() + diff --git a/server/channels/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c similarity index 100% rename from server/channels/rdpsnd.c rename to channels/rdpsnd/server/rdpsnd.c diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt new file mode 100644 index 000000000..5b7b8ba24 --- /dev/null +++ b/channels/server/CMakeLists.txt @@ -0,0 +1,35 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +foreach(MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES}) + string(TOUPPER "CHANNEL_${MODULE_NAME}" MODULE_PREFIX) + message(STATUS "Adding built-in channel server module: ${MODULE_NAME}") + + foreach(SRC ${${MODULE_PREFIX}_SERVER_SRCS}) + set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${MODULE_NAME}/server/${SRC}") + endforeach() + + set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${MODULE_PREFIX}_SERVER_LIBS}) +endforeach() + +add_library(freerdp-server ${CHANNEL_SERVER_SRCS}) + +set_target_properties(freerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + +target_link_libraries(freerdp-server ${CHANNEL_SERVER_LIBS}) +install(TARGETS freerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR}) + diff --git a/channels/tsmf/CMakeLists.txt b/channels/tsmf/CMakeLists.txt new file mode 100644 index 000000000..e6e70054d --- /dev/null +++ b/channels/tsmf/CMakeLists.txt @@ -0,0 +1,19 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +add_subdirectory(client) + diff --git a/channels/tsmf/client/tsmf_audio.h b/channels/tsmf/client/tsmf_audio.h index 5492cb88a..1215460c5 100644 --- a/channels/tsmf/client/tsmf_audio.h +++ b/channels/tsmf/client/tsmf_audio.h @@ -20,7 +20,7 @@ #ifndef __TSMF_AUDIO_H #define __TSMF_AUDIO_H -#include "drdynvc_types.h" +#include "tsmf_types.h" typedef struct _ITSMFAudioDevice ITSMFAudioDevice; diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index 64296b1c3..ceb28bbcf 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -29,7 +29,6 @@ #include #include -#include "drdynvc_types.h" #include "tsmf_constants.h" #include "tsmf_types.h" diff --git a/channels/tsmf/client/tsmf_decoder.c b/channels/tsmf/client/tsmf_decoder.c index 5a604eb30..267a9f97e 100644 --- a/channels/tsmf/client/tsmf_decoder.c +++ b/channels/tsmf/client/tsmf_decoder.c @@ -28,7 +28,6 @@ #include #include -#include "drdynvc_types.h" #include "tsmf_types.h" #include "tsmf_constants.h" #include "tsmf_decoder.h" diff --git a/channels/tsmf/client/tsmf_decoder.h b/channels/tsmf/client/tsmf_decoder.h index dd911dbcf..91d3ee31f 100644 --- a/channels/tsmf/client/tsmf_decoder.h +++ b/channels/tsmf/client/tsmf_decoder.h @@ -21,7 +21,6 @@ #ifndef __TSMF_DECODER_H #define __TSMF_DECODER_H -#include "drdynvc_types.h" #include "tsmf_types.h" typedef enum _ITSMFControlMsg diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 71a6d9bef..86f5101b3 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -29,7 +29,7 @@ #include #include -#include "drdynvc_types.h" +#include "tsmf_types.h" #include "tsmf_constants.h" #include "tsmf_media.h" #include "tsmf_codec.h" diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index 53a1dbdba..6c266cf51 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -28,7 +28,7 @@ #include #include -#include "drdynvc_types.h" +#include "tsmf_types.h" #include "tsmf_constants.h" #include "tsmf_ifman.h" #include "tsmf_media.h" diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 098bdf515..58568b958 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -45,7 +45,6 @@ #include -#include "drdynvc_types.h" #include "tsmf_constants.h" #include "tsmf_types.h" #include "tsmf_decoder.h" diff --git a/channels/tsmf/client/tsmf_types.h b/channels/tsmf/client/tsmf_types.h index 20745cb92..65e8b2a18 100644 --- a/channels/tsmf/client/tsmf_types.h +++ b/channels/tsmf/client/tsmf_types.h @@ -20,7 +20,19 @@ #ifndef __TSMF_TYPES_H #define __TSMF_TYPES_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include #include +#include + +#ifdef WITH_DEBUG_DVC +#define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) +#else +#define DEBUG_DVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#endif typedef struct _TS_AM_MEDIA_TYPE { diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index a42687eb0..6ac9ede9d 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -33,5 +33,3 @@ else() add_subdirectory(Windows) endif() -# Build Server Channels library -add_subdirectory(channels) diff --git a/server/channels/CMakeLists.txt b/server/channels/CMakeLists.txt deleted file mode 100644 index 2ee9473e5..000000000 --- a/server/channels/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# FreeRDP: A Remote Desktop Protocol Client -# libfreerdp-server-channels cmake build script -# -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(FREERDP_SERVER_CHANNELS_SRCS - audin.c - rdpsnd.c) - -add_library(freerdp-server-channels ${FREERDP_SERVER_CHANNELS_SRCS}) - -set_target_properties(freerdp-server-channels PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(freerdp-server-channels freerdp) -else() - target_link_libraries(freerdp-server-channels freerdp-channels freerdp-utils) -endif() - -install(TARGETS freerdp-server-channels DESTINATION ${CMAKE_INSTALL_LIBDIR}) From 6cb933aa5a0775a514fb163ab4f6aaa3182e2931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 20:16:38 -0400 Subject: [PATCH 15/64] channels: added build options to enabled/disable client and server channels --- CMakeLists.txt | 2 ++ channels/CMakeLists.txt | 4 +++- channels/audin/CMakeLists.txt | 16 +++++++++------- channels/audin/client/CMakeLists.txt | 1 - channels/cliprdr/CMakeLists.txt | 4 +++- channels/drdynvc/CMakeLists.txt | 4 +++- channels/rail/CMakeLists.txt | 4 +++- channels/rdpdr/CMakeLists.txt | 4 +++- channels/rdpsnd/CMakeLists.txt | 15 +++++++++------ channels/sample/CMakeLists.txt | 4 +++- channels/server/CMakeLists.txt | 1 - channels/tsmf/CMakeLists.txt | 5 ++++- cmake/ConfigOptions.cmake | 9 +++++++++ config.h.in | 4 +++- libfreerdp/utils/load_plugin.c | 5 ++--- 15 files changed, 56 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d94a63c1..446e685a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,8 @@ set(FREERDP_KEYMAP_PATH "${FREERDP_DATA_PATH}/keymaps") # Path to put plugins set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp") +set(FREERDP_CLIENT_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}/client") +set(FREERDP_SERVER_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}/server") # Path to put extensions set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp/extensions") diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 3ecbbd569..9c456090e 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -30,5 +30,7 @@ foreach(FILEPATH ${FILEPATHS}) endif() endforeach(FILEPATH) -add_subdirectory(server) +if(WITH_SERVER_CHANNELS) + add_subdirectory(server) +endif() diff --git a/channels/audin/CMakeLists.txt b/channels/audin/CMakeLists.txt index 45849a4e0..dc9f2b019 100644 --- a/channels/audin/CMakeLists.txt +++ b/channels/audin/CMakeLists.txt @@ -18,12 +18,14 @@ set(MODULE_NAME "audin") set(MODULE_PREFIX "CHANNEL_AUDIN") -add_subdirectory(client) - -add_subdirectory(server) - -set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) -set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) -set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() +if(WITH_SERVER_CHANNELS) + add_subdirectory(server) + set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) + set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) + set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) +endif() diff --git a/channels/audin/client/CMakeLists.txt b/channels/audin/client/CMakeLists.txt index 65534eb87..2be9f936b 100644 --- a/channels/audin/client/CMakeLists.txt +++ b/channels/audin/client/CMakeLists.txt @@ -41,4 +41,3 @@ endif() if(WITH_PULSEAUDIO) add_subdirectory(pulse) endif() - diff --git a/channels/cliprdr/CMakeLists.txt b/channels/cliprdr/CMakeLists.txt index e6e70054d..676de4e85 100644 --- a/channels/cliprdr/CMakeLists.txt +++ b/channels/cliprdr/CMakeLists.txt @@ -15,5 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() diff --git a/channels/drdynvc/CMakeLists.txt b/channels/drdynvc/CMakeLists.txt index e6e70054d..676de4e85 100644 --- a/channels/drdynvc/CMakeLists.txt +++ b/channels/drdynvc/CMakeLists.txt @@ -15,5 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() diff --git a/channels/rail/CMakeLists.txt b/channels/rail/CMakeLists.txt index e6e70054d..676de4e85 100644 --- a/channels/rail/CMakeLists.txt +++ b/channels/rail/CMakeLists.txt @@ -15,5 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() diff --git a/channels/rdpdr/CMakeLists.txt b/channels/rdpdr/CMakeLists.txt index e6e70054d..676de4e85 100644 --- a/channels/rdpdr/CMakeLists.txt +++ b/channels/rdpdr/CMakeLists.txt @@ -15,5 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() diff --git a/channels/rdpsnd/CMakeLists.txt b/channels/rdpsnd/CMakeLists.txt index aad0c5af1..14ce938d1 100644 --- a/channels/rdpsnd/CMakeLists.txt +++ b/channels/rdpsnd/CMakeLists.txt @@ -18,12 +18,15 @@ set(MODULE_NAME "rdpsnd") set(MODULE_PREFIX "CHANNEL_RDPSND") -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() -add_subdirectory(server) - -set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) -set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) -set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) +if(WITH_SERVER_CHANNELS) + add_subdirectory(server) + set(${MODULE_PREFIX}_SERVER_SRCS ${${MODULE_PREFIX}_SERVER_SRCS} PARENT_SCOPE) + set(${MODULE_PREFIX}_SERVER_LIBS ${${MODULE_PREFIX}_SERVER_LIBS} PARENT_SCOPE) + set(CHANNEL_BUILTIN_SERVER_MODULES ${CHANNEL_BUILTIN_SERVER_MODULES} ${MODULE_NAME} PARENT_SCOPE) +endif() diff --git a/channels/sample/CMakeLists.txt b/channels/sample/CMakeLists.txt index e6e70054d..676de4e85 100644 --- a/channels/sample/CMakeLists.txt +++ b/channels/sample/CMakeLists.txt @@ -15,5 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index 5b7b8ba24..d36053b2a 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -32,4 +32,3 @@ set_target_properties(freerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} target_link_libraries(freerdp-server ${CHANNEL_SERVER_LIBS}) install(TARGETS freerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR}) - diff --git a/channels/tsmf/CMakeLists.txt b/channels/tsmf/CMakeLists.txt index e6e70054d..7d38fd55f 100644 --- a/channels/tsmf/CMakeLists.txt +++ b/channels/tsmf/CMakeLists.txt @@ -15,5 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(client) +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() + diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 2007b37cf..76fa33a3b 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -22,6 +22,15 @@ endif() option(WITH_CLIENT "Build client binaries" ON) option(WITH_SERVER "Build server binaries" OFF) option(WITH_CHANNELS "Build virtual channel plugins" ON) + +if(WITH_CLIENT AND WITH_CHANNELS) + option(WITH_CLIENT_CHANNELS "Build virtual channel plugins" ON) +endif() + +if(WITH_SERVER AND WITH_CHANNELS) + option(WITH_SERVER_CHANNELS "Build virtual channel plugins" ON) +endif() + option(WITH_THIRD_PARTY "Build third-party components" OFF) option(WITH_SERVER_INTERFACE "Build server as a library with an interface" OFF) diff --git a/config.h.in b/config.h.in index 524822f70..74df3e656 100644 --- a/config.h.in +++ b/config.h.in @@ -9,8 +9,10 @@ #define GIT_REVISION "${GIT_REVISION}" #define FREERDP_DATA_PATH "${FREERDP_DATA_PATH}" -#define FREERDP_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}" #define FREERDP_KEYMAP_PATH "${FREERDP_KEYMAP_PATH}" +#define FREERDP_PLUGIN_PATH "${FREERDP_PLUGIN_PATH}" +#define FREERDP_CLIENT_PLUGIN_PATH "${FREERDP_CLIENT_PLUGIN_PATH}" +#define FREERDP_SERVER_PLUGIN_PATH "${FREERDP_SERVER_PLUGIN_PATH}" /* Include files */ #cmakedefine HAVE_FCNTL_H diff --git a/libfreerdp/utils/load_plugin.c b/libfreerdp/utils/load_plugin.c index c36e7ba62..9b713bc76 100644 --- a/libfreerdp/utils/load_plugin.c +++ b/libfreerdp/utils/load_plugin.c @@ -336,12 +336,13 @@ boolean freerdp_register_static_plugin(const char* name, const char* entry_name, */ void* freerdp_load_static_plugin(const char* name, const char* entry_name) { - staticPlugin* plugin; int i; + staticPlugin* plugin; for (i = 0; i < g_static_plugins_count; i++) { plugin = &g_static_plugins[i]; + if (!strcmp(plugin->name, name) && !strcmp(plugin->entry_name, entry_name)) { return plugin->entry_addr; @@ -350,5 +351,3 @@ void* freerdp_load_static_plugin(const char* name, const char* entry_name) return NULL; } - - From 90ffa6ea86404cd21f61d8cb918815193d7b6b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 22 Sep 2012 22:02:55 -0400 Subject: [PATCH 16/64] libwinpr: stubbed Path API --- winpr/include/winpr/environment.h | 92 +++++++ winpr/include/winpr/library.h | 11 + winpr/include/winpr/path.h | 140 ++++++++++ winpr/include/winpr/tchar.h | 2 + winpr/include/winpr/wtypes.h | 3 + winpr/libwinpr/CMakeLists.txt | 4 + winpr/libwinpr/environment/CMakeLists.txt | 37 +++ .../libwinpr/environment/ModuleOptions.cmake | 9 + winpr/libwinpr/environment/environment.c | 194 ++++++++++++++ winpr/libwinpr/library/library.c | 19 +- winpr/libwinpr/path/CMakeLists.txt | 37 +++ winpr/libwinpr/path/ModuleOptions.cmake | 9 + winpr/libwinpr/path/path.c | 245 ++++++++++++++++++ 13 files changed, 800 insertions(+), 2 deletions(-) create mode 100644 winpr/include/winpr/environment.h create mode 100644 winpr/include/winpr/path.h create mode 100644 winpr/libwinpr/environment/CMakeLists.txt create mode 100644 winpr/libwinpr/environment/ModuleOptions.cmake create mode 100644 winpr/libwinpr/environment/environment.c create mode 100644 winpr/libwinpr/path/CMakeLists.txt create mode 100644 winpr/libwinpr/path/ModuleOptions.cmake create mode 100644 winpr/libwinpr/path/path.c diff --git a/winpr/include/winpr/environment.h b/winpr/include/winpr/environment.h new file mode 100644 index 000000000..eab6a8891 --- /dev/null +++ b/winpr/include/winpr/environment.h @@ -0,0 +1,92 @@ +/** + * WinPR: Windows Portable Runtime + * Process Environment Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ENVIRONMENT_H +#define WINPR_ENVIRONMENT_H + +#include +#include + +#ifndef _WIN32 + +WINPR_API DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer); +WINPR_API DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer); + +WINPR_API BOOL SetCurrentDirectoryA(LPCSTR lpPathName); +WINPR_API BOOL SetCurrentDirectoryW(LPCWSTR lpPathName); + +WINPR_API DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart); +WINPR_API DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); + +WINPR_API HANDLE GetStdHandle(DWORD nStdHandle); +WINPR_API BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle); +WINPR_API BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle); + +WINPR_API LPSTR GetCommandLineA(VOID); +WINPR_API LPWSTR GetCommandLineW(VOID); + +WINPR_API BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName); +WINPR_API BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName); + +WINPR_API DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize); +WINPR_API DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize); + +WINPR_API BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue); +WINPR_API BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue); + +WINPR_API LPCH GetEnvironmentStrings(VOID); +WINPR_API LPWCH GetEnvironmentStringsW(VOID); + +WINPR_API BOOL SetEnvironmentStringsA(LPCH NewEnvironment); +WINPR_API BOOL SetEnvironmentStringsW(LPWCH NewEnvironment); + +WINPR_API DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize); +WINPR_API DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize); + +WINPR_API BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock); +WINPR_API BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock); + +#ifdef UNICODE +#define GetCurrentDirectory GetCurrentDirectoryW +#define SetCurrentDirectory SetCurrentDirectoryW +#define SearchPath SearchPathW +#define GetCommandLine GetCommandLineW +#define NeedCurrentDirectoryForExePath NeedCurrentDirectoryForExePathW +#define GetEnvironmentVariable GetEnvironmentVariableW +#define SetEnvironmentVariable SetEnvironmentVariableW +#define SetEnvironmentStrings SetEnvironmentStringsW +#define ExpandEnvironmentStrings ExpandEnvironmentStringsW +#define FreeEnvironmentStrings FreeEnvironmentStringsW +#else +#define GetCurrentDirectory GetCurrentDirectoryA +#define SetCurrentDirectory SetCurrentDirectoryA +#define SearchPath SearchPathA +#define GetCommandLine GetCommandLineA +#define NeedCurrentDirectoryForExePath NeedCurrentDirectoryForExePathA +#define GetEnvironmentVariable GetEnvironmentVariableA +#define SetEnvironmentVariable SetEnvironmentVariableA +#define SetEnvironmentStrings SetEnvironmentStringsA +#define ExpandEnvironmentStrings ExpandEnvironmentStringsA +#define FreeEnvironmentStrings FreeEnvironmentStringsA +#endif + +#endif + +#endif /* WINPR_ENVIRONMENT_H */ + diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h index 124086b87..203bcd755 100644 --- a/winpr/include/winpr/library.h +++ b/winpr/include/winpr/library.h @@ -23,6 +23,17 @@ #include #include +typedef HANDLE DLL_DIRECTORY_COOKIE; + +#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 +#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 +#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400 + +WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory); +WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie); +WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags); + #ifndef _WIN32 WINPR_API HMODULE LoadLibraryA(LPCSTR lpLibFileName); diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h new file mode 100644 index 000000000..edcb90314 --- /dev/null +++ b/winpr/include/winpr/path.h @@ -0,0 +1,140 @@ +/** + * WinPR: Windows Portable Runtime + * Path Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_PATH_H +#define WINPR_PATH_H + +#include +#include + +WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath); + +WINPR_API HRESULT PathCchRemoveBackslashA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath); + +WINPR_API HRESULT PathCchAddBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining); +WINPR_API HRESULT PathCchAddBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining); + +WINPR_API HRESULT PathCchRemoveBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining); +WINPR_API HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining); + +WINPR_API HRESULT PathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); +WINPR_API HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + +WINPR_API HRESULT PathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore); +WINPR_API HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore); + +WINPR_API HRESULT PathCchAppendExA(PSTR pszPath, size_t cchPath, PCSTR pszMore, unsigned long dwFlags); +WINPR_API HRESULT PathCchAppendExW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore, unsigned long dwFlags); + +WINPR_API HRESULT PathCchCanonicalizeA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn); +WINPR_API HRESULT PathCchCanonicalizeW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn); + +WINPR_API HRESULT PathCchCanonicalizeExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, unsigned long dwFlags); +WINPR_API HRESULT PathCchCanonicalizeExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, unsigned long dwFlags); + +WINPR_API HRESULT PathAllocCanonicalizeA(PCSTR pszPathIn, unsigned long dwFlags, PSTR* ppszPathOut); +WINPR_API HRESULT PathAllocCanonicalizeW(PCWSTR pszPathIn, unsigned long dwFlags, PWSTR* ppszPathOut); + +WINPR_API HRESULT PathCchCombineA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore); +WINPR_API HRESULT PathCchCombineW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore); + +WINPR_API HRESULT PathCchCombineExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags); +WINPR_API HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags); + +WINPR_API HRESULT PathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, PSTR* ppszPathOut); +WINPR_API HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut); + +WINPR_API HRESULT PathCchFindExtensionA(PCSTR pszPath, size_t cchPath, PCSTR* ppszExt); +WINPR_API HRESULT PathCchFindExtensionW(PCWSTR pszPath, size_t cchPath, PCWSTR* ppszExt); + +WINPR_API HRESULT PathCchRenameExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); +WINPR_API HRESULT PathCchRenameExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + +WINPR_API HRESULT PathCchRemoveExtensionA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchRemoveExtensionW(PWSTR pszPath, size_t cchPath); + +WINPR_API BOOL PathCchIsRootA(PCSTR pszPath); +WINPR_API BOOL PathCchIsRootW(PCWSTR pszPath); + +WINPR_API BOOL PathIsUNCExA(PCSTR pszPath, PCSTR* ppszServer); +WINPR_API BOOL PathIsUNCExW(PCWSTR pszPath, PCWSTR* ppszServer); + +WINPR_API HRESULT PathCchSkipRootA(PCSTR pszPath, PCSTR* ppszRootEnd); +WINPR_API HRESULT PathCchSkipRootW(PCWSTR pszPath, PCWSTR* ppszRootEnd); + +WINPR_API HRESULT PathCchStripToRootA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchStripToRootW(PWSTR pszPath, size_t cchPath); + +WINPR_API HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath); + +WINPR_API HRESULT PathCchRemoveFileSpecA(PSTR pszPath, size_t cchPath); +WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath); + +#ifdef UNICODE +#define PathCchAddBackslash PathCchAddBackslashW +#define PathCchRemoveBackslash PathCchRemoveBackslashW +#define PathCchAddBackslashEx PathCchAddBackslashExW +#define PathCchRemoveBackslashEx PathCchRemoveBackslashExW +#define PathCchAddExtension PathCchAddExtensionW +#define PathCchAppend PathCchAppendW +#define PathCchAppendEx PathCchAppendExW +#define PathCchCanonicalize PathCchCanonicalizeW +#define PathCchCanonicalizeEx PathCchCanonicalizeExW +#define PathAllocCanonicalize PathAllocCanonicalizeW +#define PathCchCombine PathCchCombineW +#define PathCchCombineEx PathCchCombineExW +#define PathAllocCombine PathAllocCombineW +#define PathCchFindExtension PathCchFindExtensionW +#define PathCchRenameExtension PathCchRenameExtensionW +#define PathCchRemoveExtension PathCchRemoveExtensionW +#define PathCchIsRoot PathCchIsRootW +#define PathIsUNCEx PathIsUNCExW +#define PathCchSkipRoot PathCchSkipRootW +#define PathCchStripToRoot PathCchStripToRootW +#define PathCchStripPrefix PathCchStripPrefixW +#define PathCchRemoveFileSpec PathCchRemoveFileSpecW +#else +#define PathCchAddBackslash PathCchAddBackslashA +#define PathCchRemoveBackslash PathCchRemoveBackslashA +#define PathCchAddBackslashEx PathCchAddBackslashExA +#define PathCchRemoveBackslashEx PathCchRemoveBackslashExA +#define PathCchAddExtension PathCchAddExtensionA +#define PathCchAppend PathCchAppendA +#define PathCchAppendEx PathCchAppendExA +#define PathCchCanonicalize PathCchCanonicalizeA +#define PathCchCanonicalizeEx PathCchCanonicalizeExA +#define PathAllocCanonicalize PathAllocCanonicalizeA +#define PathCchCombine PathCchCombineA +#define PathCchCombineEx PathCchCombineExA +#define PathAllocCombine PathAllocCombineA +#define PathCchFindExtension PathCchFindExtensionA +#define PathCchRenameExtension PathCchRenameExtensionA +#define PathCchRemoveExtension PathCchRemoveExtensionA +#define PathCchIsRoot PathCchIsRootA +#define PathIsUNCEx PathIsUNCExA +#define PathCchSkipRoot PathCchSkipRootA +#define PathCchStripToRoot PathCchStripToRootA +#define PathCchStripPrefix PathCchStripPrefixA +#define PathCchRemoveFileSpec PathCchRemoveFileSpecA +#endif + +#endif /* WINPR_PATH_H */ diff --git a/winpr/include/winpr/tchar.h b/winpr/include/winpr/tchar.h index 0078cc93b..9b3cedc62 100644 --- a/winpr/include/winpr/tchar.h +++ b/winpr/include/winpr/tchar.h @@ -41,6 +41,8 @@ typedef CHAR TCHAR; #define _tcscmp strcmp #endif +typedef TCHAR *LPTSTR, *LPTCH; + #endif #endif /* WINPR_TCHAR_H */ diff --git a/winpr/include/winpr/wtypes.h b/winpr/include/winpr/wtypes.h index ba897a003..ea4b3f988 100644 --- a/winpr/include/winpr/wtypes.h +++ b/winpr/include/winpr/wtypes.h @@ -90,6 +90,9 @@ typedef const CHAR *LPCSTR,*PCSTR; typedef WCHAR* LPWSTR, *PWSTR; typedef const WCHAR *LPCWSTR,*PCWSTR; +typedef CHAR *LPSTR, *LPCH; +typedef WCHAR *LPWSTR, *LPWCH; + typedef unsigned __int64 QWORD; typedef UCHAR* STRING; diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index 070776e0d..a4431394e 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -28,6 +28,8 @@ endif() add_subdirectory(crt) add_subdirectory(utils) add_subdirectory(heap) +add_subdirectory(path) +add_subdirectory(environment) add_subdirectory(interlocked) add_subdirectory(handle) add_subdirectory(synch) @@ -50,6 +52,8 @@ if(WITH_MONOLITHIC_BUILD) $ $ $ + $ + $ $ $ $ diff --git a/winpr/libwinpr/environment/CMakeLists.txt b/winpr/libwinpr/environment/CMakeLists.txt new file mode 100644 index 000000000..80c150445 --- /dev/null +++ b/winpr/libwinpr/environment/CMakeLists.txt @@ -0,0 +1,37 @@ +# WinPR: Windows Portable Runtime +# libwinpr-environment cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-environment") +set(MODULE_PREFIX "WINPR_ENVIRONMENT") + +set(${MODULE_PREFIX}_SRCS + environment.c) + +if(WITH_MONOLITHIC_BUILD) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) +else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +endif() + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(WITH_MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + diff --git a/winpr/libwinpr/environment/ModuleOptions.cmake b/winpr/libwinpr/environment/ModuleOptions.cmake new file mode 100644 index 000000000..d7b39ae40 --- /dev/null +++ b/winpr/libwinpr/environment/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "processenvironment") +set(MINWIN_LONG_NAME "Process Environment Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/environment/environment.c b/winpr/libwinpr/environment/environment.c new file mode 100644 index 000000000..906198b31 --- /dev/null +++ b/winpr/libwinpr/environment/environment.c @@ -0,0 +1,194 @@ +/** + * WinPR: Windows Portable Runtime + * Process Environment Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#ifndef _WIN32 + +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) +{ + char* cwd; + int length; + + cwd = getcwd(NULL, 0); + + if (!cwd) + return 0; + + length = strlen(cwd); + + if ((nBufferLength == 0) && (lpBuffer == NULL)) + { + free(cwd); + + return (DWORD) length; + } + else + { + if (lpBuffer == NULL) + { + free(cwd); + return 0; + } + + if ((length + 1) > nBufferLength) + { + free(cwd); + return (DWORD) (length + 1); + } + + memcpy(lpBuffer, cwd, length + 1); + return length; + } + + return 0; +} + +DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) +{ + return 0; +} + +BOOL SetCurrentDirectoryA(LPCSTR lpPathName) +{ + return TRUE; +} + +BOOL SetCurrentDirectoryW(LPCWSTR lpPathName) +{ + return TRUE; +} + +DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart) +{ + return 0; +} + +DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart) +{ + return 0; +} + +HANDLE GetStdHandle(DWORD nStdHandle) +{ + return NULL; +} + +BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle) +{ + return TRUE; +} + +BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle) +{ + return TRUE; +} + +LPSTR GetCommandLineA(VOID) +{ + return NULL; +} + +LPWSTR GetCommandLineW(VOID) +{ + return NULL; +} + +BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName) +{ + return TRUE; +} + +BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName) +{ + return TRUE; +} + +DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize) +{ + return 0; +} + +DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize) +{ + return 0; +} + +BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue) +{ + return TRUE; +} + +BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue) +{ + return TRUE; +} + +LPCH GetEnvironmentStrings(VOID) +{ + return NULL; +} + +LPWCH GetEnvironmentStringsW(VOID) +{ + return NULL; +} + +BOOL SetEnvironmentStringsA(LPCH NewEnvironment) +{ + return TRUE; +} + +BOOL SetEnvironmentStringsW(LPWCH NewEnvironment) +{ + return TRUE; +} + +DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize) +{ + return 0; +} + +DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize) +{ + return 0; +} + +BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock) +{ + return TRUE; +} + +BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock) +{ + return TRUE; +} + +#endif + diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c index 9688076cc..b5e38601f 100644 --- a/winpr/libwinpr/library/library.c +++ b/winpr/libwinpr/library/library.c @@ -27,6 +27,8 @@ * api-ms-win-core-libraryloader-l1-1-1.dll: * * AddDllDirectory + * RemoveDllDirectory + * SetDefaultDllDirectories * DisableThreadLibraryCalls * EnumResourceLanguagesExA * EnumResourceLanguagesExW @@ -53,11 +55,24 @@ * LoadStringW * LockResource * QueryOptionalDelayLoadedAPI - * RemoveDllDirectory - * SetDefaultDllDirectories * SizeofResource */ +DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory) +{ + return NULL; +} + +BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie) +{ + return TRUE; +} + +BOOL SetDefaultDllDirectories(DWORD DirectoryFlags) +{ + return TRUE; +} + #ifndef _WIN32 #include diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt new file mode 100644 index 000000000..559edc930 --- /dev/null +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -0,0 +1,37 @@ +# WinPR: Windows Portable Runtime +# libwinpr-path cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-path") +set(MODULE_PREFIX "WINPR_PATH") + +set(${MODULE_PREFIX}_SRCS + path.c) + +if(WITH_MONOLITHIC_BUILD) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) +else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +endif() + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(WITH_MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + diff --git a/winpr/libwinpr/path/ModuleOptions.cmake b/winpr/libwinpr/path/ModuleOptions.cmake new file mode 100644 index 000000000..b330a21e2 --- /dev/null +++ b/winpr/libwinpr/path/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "path") +set(MINWIN_LONG_NAME "Path Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c new file mode 100644 index 000000000..bc54e3494 --- /dev/null +++ b/winpr/libwinpr/path/path.c @@ -0,0 +1,245 @@ +/** + * WinPR: Windows Portable Runtime + * Path Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchRemoveBackslashA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchAddBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining) +{ + return 0; +} + +HRESULT PathCchAddBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining) +{ + return 0; +} + +HRESULT PathCchRemoveBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining) +{ + return 0; +} + +HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, size_t* pcchRemaining) +{ + return 0; +} + +HRESULT PathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt) +{ + return 0; +} + +HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt) +{ + return 0; +} + +HRESULT PathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore) +{ + return 0; +} + +HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore) +{ + return 0; +} + +HRESULT PathCchAppendExA(PSTR pszPath, size_t cchPath, PCSTR pszMore, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathCchAppendExW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathCchCanonicalizeA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn) +{ + return 0; +} + +HRESULT PathCchCanonicalizeW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn) +{ + return 0; +} + +HRESULT PathCchCanonicalizeExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathCchCanonicalizeExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathAllocCanonicalizeA(PCSTR pszPathIn, unsigned long dwFlags, PSTR* ppszPathOut) +{ + return 0; +} + +HRESULT PathAllocCanonicalizeW(PCWSTR pszPathIn, unsigned long dwFlags, PWSTR* ppszPathOut) +{ + return 0; +} + +HRESULT PathCchCombineA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore) +{ + return 0; +} + +HRESULT PathCchCombineW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore) +{ + return 0; +} + +HRESULT PathCchCombineExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags) +{ + return 0; +} + +HRESULT PathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, PSTR* ppszPathOut) +{ + return 0; +} + +HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, PWSTR* ppszPathOut) +{ + return 0; +} + +HRESULT PathCchFindExtensionA(PCSTR pszPath, size_t cchPath, PCSTR* ppszExt) +{ + return 0; +} + +HRESULT PathCchFindExtensionW(PCWSTR pszPath, size_t cchPath, PCWSTR* ppszExt) +{ + return 0; +} + +HRESULT PathCchRenameExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt) +{ + return 0; +} + +HRESULT PathCchRenameExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt) +{ + return 0; +} + +HRESULT PathCchRemoveExtensionA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchRemoveExtensionW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + +BOOL PathCchIsRootA(PCSTR pszPath) +{ + return 0; +} + +BOOL PathCchIsRootW(PCWSTR pszPath) +{ + return 0; +} + +BOOL PathIsUNCExA(PCSTR pszPath, PCSTR* ppszServer) +{ + return 0; +} + +BOOL PathIsUNCExW(PCWSTR pszPath, PCWSTR* ppszServer) +{ + return 0; +} + +HRESULT PathCchSkipRootA(PCSTR pszPath, PCSTR* ppszRootEnd) +{ + return 0; +} + +HRESULT PathCchSkipRootW(PCWSTR pszPath, PCWSTR* ppszRootEnd) +{ + return 0; +} + +HRESULT PathCchStripToRootA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchStripToRootW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchRemoveFileSpecA(PSTR pszPath, size_t cchPath) +{ + return 0; +} + +HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath) +{ + return 0; +} + From a11a69c70fb74b70a3d09d1eb6f9be4deb0425ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 13:54:14 -0400 Subject: [PATCH 17/64] channels/rdpdr/disk: replace thread utils by WinPR thread API --- channels/rdpdr/client/disk/CMakeLists.txt | 16 ++-- channels/rdpdr/client/disk/disk_main.c | 84 ++++++++++-------- channels/rdpdr/client/rdpdr_main.c | 2 +- channels/rdpdr/client/smartcard/scard_main.c | 89 +++++++++----------- libfreerdp/utils/svc_plugin.c | 22 +++-- winpr/include/winpr/synch.h | 10 +++ winpr/include/winpr/thread.h | 7 +- winpr/libwinpr/handle/table.c | 56 ++++++++++-- winpr/libwinpr/synch/event.c | 3 +- winpr/libwinpr/synch/wait.c | 2 +- winpr/libwinpr/thread/thread.c | 88 ++++++++++++++++--- 11 files changed, 264 insertions(+), 115 deletions(-) diff --git a/channels/rdpdr/client/disk/CMakeLists.txt b/channels/rdpdr/client/disk/CMakeLists.txt index aaac503a0..d6d7935f3 100644 --- a/channels/rdpdr/client/disk/CMakeLists.txt +++ b/channels/rdpdr/client/disk/CMakeLists.txt @@ -17,20 +17,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(DISK_SRCS +set(MODULE_NAME "disk") +set(MODULE_PREFIX "CHANNEL_DEVICE_DISK") + +set(${MODULE_PREFIX}_SRCS disk_file.c disk_file.h disk_main.c) include_directories(..) -add_library(disk ${DISK_SRCS}) -set_target_properties(disk PROPERTIES PREFIX "") +add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") if(WITH_MONOLITHIC_BUILD) - target_link_libraries(disk freerdp) + set(${MODULE_PREFIX}_LIBS freerdp winpr) else() - target_link_libraries(disk freerdp-utils) + set(${MODULE_PREFIX}_LIBS freerdp-utils winpr-synch winpr-thread) endif() -install(TARGETS disk DESTINATION ${FREERDP_PLUGIN_PATH}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH}) diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index 44126dd93..5616b8196 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -39,14 +39,17 @@ #include #include #include -#include #include +#include +#include + #include "rdpdr_constants.h" #include "rdpdr_types.h" #include "disk_file.h" typedef struct _DISK_DEVICE DISK_DEVICE; + struct _DISK_DEVICE { DEVICE device; @@ -54,15 +57,17 @@ struct _DISK_DEVICE char* path; LIST* files; + HANDLE mutex; + HANDLE thread; LIST* irp_list; - freerdp_thread* thread; + HANDLE irpEvent; + HANDLE stopEvent; DEVMAN* devman; pcRegisterDevice UnregisterDevice; }; -static uint32 -disk_map_posix_err(int fs_errno) +static uint32 disk_map_posix_err(int fs_errno) { uint32 rc; @@ -90,7 +95,9 @@ disk_map_posix_err(int fs_errno) rc = STATUS_UNSUCCESSFUL; break; } + DEBUG_SVC("errno 0x%x mapped to 0x%x", fs_errno, rc); + return rc; } @@ -101,7 +108,8 @@ static DISK_FILE* disk_get_file_by_id(DISK_DEVICE* disk, uint32 id) for (item = disk->files->head; item; item = item->next) { - file = (DISK_FILE*)item->data; + file = (DISK_FILE*) item->data; + if (file->id == id) return file; } @@ -238,7 +246,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp) } else { - buffer = (uint8*)xmalloc(Length); + buffer = (uint8*) xmalloc(Length); if (!disk_file_read(file, buffer, &Length)) { irp->IoStatus = STATUS_UNSUCCESSFUL; @@ -255,11 +263,13 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp) } stream_write_uint32(irp->output, Length); + if (Length > 0) { stream_check_size(irp->output, Length); stream_write(irp->output, buffer, Length); } + xfree(buffer); irp->Complete(irp); @@ -379,8 +389,8 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir struct STATVFS svfst; struct STAT st; UNICONV* uniconv; - char *volumeLabel = {"FREERDP"}; /* TODO:: Add sub routine to correctly pick up Volume Label name for each O/S supported*/ - char *diskType = {"FAT32"}; + char* volumeLabel = {"FREERDP"}; /* TODO: Add sub routine to correctly pick up Volume Label name for each O/S supported */ + char* diskType = {"FAT32"}; char* outStr; size_t len; @@ -581,12 +591,14 @@ static void disk_process_irp_list(DISK_DEVICE* disk) while (1) { - if (freerdp_thread_is_stopped(disk->thread)) + if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0) break; - freerdp_thread_lock(disk->thread); - irp = (IRP*)list_dequeue(disk->irp_list); - freerdp_thread_unlock(disk->thread); + WaitForSingleObject(disk->mutex, INFINITE); + + irp = (IRP*) list_dequeue(disk->irp_list); + + ReleaseMutex(disk->mutex); if (irp == NULL) break; @@ -597,63 +609,65 @@ static void disk_process_irp_list(DISK_DEVICE* disk) static void* disk_thread_func(void* arg) { - DISK_DEVICE* disk = (DISK_DEVICE*)arg; + DISK_DEVICE* disk = (DISK_DEVICE*) arg; while (1) { - freerdp_thread_wait(disk->thread); + WaitForSingleObject(disk->irpEvent, INFINITE); - if (freerdp_thread_is_stopped(disk->thread)) + if (WaitForSingleObject(disk->stopEvent, 0) == WAIT_OBJECT_0) break; - freerdp_thread_reset(disk->thread); + ResetEvent(disk->irpEvent); disk_process_irp_list(disk); } - freerdp_thread_quit(disk->thread); - return NULL; } static void disk_irp_request(DEVICE* device, IRP* irp) { - DISK_DEVICE* disk = (DISK_DEVICE*)device; + DISK_DEVICE* disk = (DISK_DEVICE*) device; - freerdp_thread_lock(disk->thread); + WaitForSingleObject(disk->mutex, INFINITE); list_enqueue(disk->irp_list, irp); - freerdp_thread_unlock(disk->thread); + ReleaseMutex(disk->mutex); - freerdp_thread_signal(disk->thread); + SetEvent(disk->irpEvent); } static void disk_free(DEVICE* device) { - DISK_DEVICE* disk = (DISK_DEVICE*)device; IRP* irp; DISK_FILE* file; + DISK_DEVICE* disk = (DISK_DEVICE*) device; - freerdp_thread_stop(disk->thread); - freerdp_thread_free(disk->thread); + SetEvent(disk->stopEvent); + CloseHandle(disk->thread); + CloseHandle(disk->irpEvent); + CloseHandle(disk->mutex); - while ((irp = (IRP*)list_dequeue(disk->irp_list)) != NULL) + while ((irp = (IRP*) list_dequeue(disk->irp_list)) != NULL) irp->Discard(irp); + list_free(disk->irp_list); - while ((file = (DISK_FILE*)list_dequeue(disk->files)) != NULL) + while ((file = (DISK_FILE*) list_dequeue(disk->files)) != NULL) disk_file_free(file); + list_free(disk->files); xfree(disk); } int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { - DISK_DEVICE* disk; char* name; char* path; int i, len; + DISK_DEVICE* disk; - name = (char*)pEntryPoints->plugin_data->data[1]; - path = (char*)pEntryPoints->plugin_data->data[2]; + name = (char*) pEntryPoints->plugin_data->data[1]; + path = (char*) pEntryPoints->plugin_data->data[2]; if (name[0] && path[0]) { @@ -666,6 +680,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) len = strlen(name); disk->device.data = stream_new(len + 1); + for (i = 0; i <= len; i++) stream_write_uint8(disk->device.data, name[i] < 0 ? '_' : name[i]); @@ -673,11 +688,14 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) disk->files = list_new(); disk->irp_list = list_new(); - disk->thread = freerdp_thread_new(); + disk->mutex = CreateMutex(NULL, FALSE, NULL); + disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) disk_thread_func, disk, CREATE_SUSPENDED, NULL); - pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)disk); + pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk); - freerdp_thread_start(disk->thread, disk_thread_func, disk); + ResumeThread(disk->thread); } return 0; diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index c7fcbb05c..8c03594d1 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -235,11 +235,11 @@ static boolean rdpdr_process_irp(rdpdrPlugin* rdpdr, STREAM* data_in) static void rdpdr_process_receive(rdpSvcPlugin* plugin, STREAM* data_in) { - rdpdrPlugin* rdpdr = (rdpdrPlugin*) plugin; uint16 component; uint16 packetID; uint32 deviceID; uint32 status; + rdpdrPlugin* rdpdr = (rdpdrPlugin*) plugin; stream_read_uint16(data_in, component); stream_read_uint16(data_in, packetID); diff --git a/channels/rdpdr/client/smartcard/scard_main.c b/channels/rdpdr/client/smartcard/scard_main.c index c3ba985a1..cac196787 100644 --- a/channels/rdpdr/client/smartcard/scard_main.c +++ b/channels/rdpdr/client/smartcard/scard_main.c @@ -37,33 +37,34 @@ #include "scard_main.h" -static void -scard_free(DEVICE* dev) +static void scard_free(DEVICE* dev) { - SCARD_DEVICE* scard = (SCARD_DEVICE*)dev; IRP* irp; COMPLETIONIDINFO* CompletionIdInfo; + SCARD_DEVICE* scard = (SCARD_DEVICE*) dev; freerdp_thread_stop(scard->thread); freerdp_thread_free(scard->thread); - while ((irp = (IRP*)list_dequeue(scard->irp_list)) != NULL) + while ((irp = (IRP*) list_dequeue(scard->irp_list)) != NULL) irp->Discard(irp); + list_free(scard->irp_list); /* Begin TS Client defect workaround. */ - while ((CompletionIdInfo = (COMPLETIONIDINFO*)list_dequeue(scard->CompletionIds)) != NULL) + + while ((CompletionIdInfo = (COMPLETIONIDINFO*) list_dequeue(scard->CompletionIds)) != NULL) xfree(CompletionIdInfo); + list_free(scard->CompletionIds); + /* End TS Client defect workaround. */ xfree(dev); return; } - -static void -scard_process_irp(SCARD_DEVICE* scard, IRP* irp) +static void scard_process_irp(SCARD_DEVICE* scard, IRP* irp) { switch (irp->MajorFunction) { @@ -80,16 +81,14 @@ scard_process_irp(SCARD_DEVICE* scard, IRP* irp) } } - -static void -scard_process_irp_list(SCARD_DEVICE* scard) +static void scard_process_irp_list(SCARD_DEVICE* scard) { - IRP *irp; + IRP* irp; while (!freerdp_thread_is_stopped(scard->thread)) { freerdp_thread_lock(scard->thread); - irp = (IRP *) list_dequeue(scard->irp_list); + irp = (IRP*) list_dequeue(scard->irp_list); freerdp_thread_unlock(scard->thread); if (irp == NULL) @@ -99,16 +98,14 @@ scard_process_irp_list(SCARD_DEVICE* scard) } } - -struct scard_irp_thread_args { +struct scard_irp_thread_args +{ SCARD_DEVICE* scard; IRP* irp; freerdp_thread* thread; }; - -static void -scard_process_irp_thread_func(struct scard_irp_thread_args* args) +static void scard_process_irp_thread_func(struct scard_irp_thread_args* args) { scard_process_irp(args->scard, args->irp); @@ -116,9 +113,7 @@ scard_process_irp_thread_func(struct scard_irp_thread_args* args) xfree(args); } - -static void * -scard_thread_func(void* arg) +static void* scard_thread_func(void* arg) { SCARD_DEVICE* scard = (SCARD_DEVICE*) arg; @@ -138,16 +133,14 @@ scard_thread_func(void* arg) return NULL; } - /* Begin TS Client defect workaround. */ -static COMPLETIONIDINFO* -scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) +static COMPLETIONIDINFO* scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) { -/* - * Search from the beginning of the LIST for one outstanding "CompletionID" - * that matches the one passed in. If there is one, mark it as a duplicate - * if it is not already marked. - */ + /* + * Search from the beginning of the LIST for one outstanding "CompletionID" + * that matches the one passed in. If there is one, mark it as a duplicate + * if it is not already marked. + */ LIST_ITEM* item; COMPLETIONIDINFO* CompletionIdInfo; @@ -164,18 +157,18 @@ scard_mark_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) return CompletionIdInfo; } } + return NULL; /* Either no items in the list or no match. */ } -static boolean -scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) +static boolean scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) { -/* - * Search from the end of the LIST for one outstanding "CompletionID" - * that matches the one passed in. Remove it from the list and free the - * memory associated with it. Return whether or not it was marked - * as a duplicate. - */ + /* + * Search from the end of the LIST for one outstanding "CompletionID" + * that matches the one passed in. Remove it from the list and free the + * memory associated with it. Return whether or not it was marked + * as a duplicate. + */ LIST_ITEM* item; COMPLETIONIDINFO* CompletionIdInfo; boolean duplicate; @@ -195,21 +188,22 @@ scard_check_for_duplicate_id(SCARD_DEVICE* scard, uint32 CompletionId) return duplicate; } } + /* This function should only be called when there is * at least one outstanding CompletionID item in the list. */ DEBUG_WARN("Error!!! No CompletionIDs (or no matching IDs) in the list!"); + return false; } -static void -scard_irp_complete(IRP* irp) +static void scard_irp_complete(IRP* irp) { -/* This function is (mostly) a copy of the statically-declared "irp_complete()" - * function except that this function adds extra operations for the - * smart card's handling of duplicate "CompletionID"s. This function needs - * to be in this file so that "scard_irp_request()" can reference it. - */ + /* This function is (mostly) a copy of the statically-declared "irp_complete()" + * function except that this function adds extra operations for the + * smart card's handling of duplicate "CompletionID"s. This function needs + * to be in this file so that "scard_irp_request()" can reference it. + */ int pos; boolean duplicate; SCARD_DEVICE* scard = (SCARD_DEVICE*)irp->device; @@ -247,13 +241,10 @@ scard_irp_complete(IRP* irp) } /* End TS Client defect workaround. */ - -static void -scard_irp_request(DEVICE* device, IRP* irp) +static void scard_irp_request(DEVICE* device, IRP* irp) { COMPLETIONIDINFO* CompletionIdInfo; - - SCARD_DEVICE* scard = (SCARD_DEVICE*)device; + SCARD_DEVICE* scard = (SCARD_DEVICE*) device; /* Begin TS Client defect workaround. */ CompletionIdInfo= xnew(COMPLETIONIDINFO); diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index 6d060959d..0506c2b68 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -110,9 +110,11 @@ static rdpSvcPlugin* svc_plugin_find_by_open_handle(uint32 open_handle) rdpSvcPlugin * plugin; WaitForSingleObject(g_mutex, INFINITE); + for (list = g_svc_plugin_list; list; list = list->next) { plugin = list->plugin; + if (plugin->priv->open_handle == open_handle) { ReleaseMutex(g_mutex); @@ -120,6 +122,7 @@ static rdpSvcPlugin* svc_plugin_find_by_open_handle(uint32 open_handle) } } ReleaseMutex(g_mutex); + return NULL; } @@ -215,22 +218,26 @@ static void svc_plugin_open_event(uint32 openHandle, uint32 event, void* pData, DEBUG_SVC("openHandle %d event %d dataLength %d totalLength %d dataFlags %d", openHandle, event, dataLength, totalLength, dataFlags); - plugin = (rdpSvcPlugin*)svc_plugin_find_by_open_handle(openHandle); + plugin = (rdpSvcPlugin*) svc_plugin_find_by_open_handle(openHandle); + if (plugin == NULL) { printf("svc_plugin_open_event: error no match\n"); return; } + switch (event) { case CHANNEL_EVENT_DATA_RECEIVED: svc_plugin_process_received(plugin, pData, dataLength, totalLength, dataFlags); break; + case CHANNEL_EVENT_WRITE_COMPLETE: - stream_free((STREAM*)pData); + stream_free((STREAM*) pData); break; + case CHANNEL_EVENT_USER: - svc_plugin_process_event(plugin, (RDP_EVENT*)pData); + svc_plugin_process_event(plugin, (RDP_EVENT*) pData); break; } } @@ -347,19 +354,23 @@ static void svc_plugin_init_event(void* pInitHandle, uint32 event, void* pData, DEBUG_SVC("event %d", event); - plugin = (rdpSvcPlugin*)svc_plugin_find_by_init_handle(pInitHandle); - if (plugin == NULL) + plugin = (rdpSvcPlugin*) svc_plugin_find_by_init_handle(pInitHandle); + + if (!plugin) { printf("svc_plugin_init_event: error no match\n"); return; } + switch (event) { case CHANNEL_EVENT_CONNECTED: svc_plugin_process_connected(plugin, pData, dataLength); break; + case CHANNEL_EVENT_DISCONNECTED: break; + case CHANNEL_EVENT_TERMINATED: svc_plugin_process_terminated(plugin); break; @@ -402,6 +413,7 @@ int svc_plugin_send(rdpSvcPlugin* plugin, STREAM* data_out) error = plugin->channel_entry_points.pVirtualChannelWrite(plugin->priv->open_handle, stream_get_data(data_out), stream_get_length(data_out), data_out); + if (error != CHANNEL_RC_OK) { stream_free(data_out); diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h index c8ef1a7d6..3f1a0da30 100644 --- a/winpr/include/winpr/synch.h +++ b/winpr/include/winpr/synch.h @@ -85,6 +85,16 @@ WINPR_API HANDLE OpenEventW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR WINPR_API BOOL SetEvent(HANDLE hEvent); WINPR_API BOOL ResetEvent(HANDLE hEvent); +#ifdef UNICODE +#define CreateEvent CreateEventW +#define CreateEventEx CreateEventExW +#define OpenEvent OpenEventW +#else +#define CreateEvent CreateEventA +#define CreateEventEx CreateEventExA +#define OpenEvent OpenEventA +#endif + /* One-Time Initialization */ typedef union _RTL_RUN_ONCE diff --git a/winpr/include/winpr/thread.h b/winpr/include/winpr/thread.h index 1db26fe86..7ecc6ec41 100644 --- a/winpr/include/winpr/thread.h +++ b/winpr/include/winpr/thread.h @@ -114,12 +114,15 @@ WINPR_API BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode); /* Thread */ -WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId); +#define CREATE_SUSPENDED 0x00000004 +#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); +WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); + WINPR_API VOID ExitThread(DWORD dwExitCode); WINPR_API HANDLE GetCurrentThread(VOID); diff --git a/winpr/libwinpr/handle/table.c b/winpr/libwinpr/handle/table.c index 02e1c354a..40e082c75 100644 --- a/winpr/libwinpr/handle/table.c +++ b/winpr/libwinpr/handle/table.c @@ -26,6 +26,10 @@ #ifndef _WIN32 +#include + +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + typedef struct _HANDLE_TABLE_ENTRY { ULONG Type; @@ -49,33 +53,49 @@ void winpr_HandleTable_New() { size_t size; - HandleTable.Count = 0; - HandleTable.MaxCount = 64; + pthread_mutex_lock(&mutex); - size = sizeof(HANDLE_TABLE_ENTRY) * HandleTable.MaxCount; + if (HandleTable.MaxCount < 1) + { + HandleTable.Count = 0; + HandleTable.MaxCount = 64; - HandleTable.Entries = (PHANDLE_TABLE_ENTRY) malloc(size); - ZeroMemory(HandleTable.Entries, size); + size = sizeof(HANDLE_TABLE_ENTRY) * HandleTable.MaxCount; + + HandleTable.Entries = (PHANDLE_TABLE_ENTRY) malloc(size); + ZeroMemory(HandleTable.Entries, size); + } + + pthread_mutex_unlock(&mutex); } void winpr_HandleTable_Grow() { size_t size; + + pthread_mutex_lock(&mutex); + HandleTable.MaxCount *= 2; size = sizeof(HANDLE_TABLE_ENTRY) * HandleTable.MaxCount; HandleTable.Entries = (PHANDLE_TABLE_ENTRY) realloc(HandleTable.Entries, size); ZeroMemory((void*) &HandleTable.Entries[HandleTable.MaxCount / 2], size / 2); + + pthread_mutex_unlock(&mutex); } void winpr_HandleTable_Free() { + pthread_mutex_lock(&mutex); + HandleTable.Count = 0; HandleTable.MaxCount = 0; free(HandleTable.Entries); HandleTable.Entries = NULL; + + pthread_mutex_unlock(&mutex); } HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) @@ -84,6 +104,8 @@ HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) HandleTable_GetInstance(); + pthread_mutex_lock(&mutex); + for (index = 0; index < (int) HandleTable.MaxCount; index++) { if (HandleTable.Entries[index].Object == NULL) @@ -93,10 +115,14 @@ HANDLE winpr_Handle_Insert(ULONG Type, PVOID Object) HandleTable.Entries[index].Type = Type; HandleTable.Entries[index].Object = Object; + pthread_mutex_unlock(&mutex); + return Object; } } + pthread_mutex_unlock(&mutex); + /* no available entry was found, the table needs to be grown */ winpr_HandleTable_Grow(); @@ -112,6 +138,8 @@ BOOL winpr_Handle_Remove(HANDLE handle) HandleTable_GetInstance(); + pthread_mutex_lock(&mutex); + for (index = 0; index < (int) HandleTable.MaxCount; index++) { if (HandleTable.Entries[index].Object == handle) @@ -120,10 +148,14 @@ BOOL winpr_Handle_Remove(HANDLE handle) HandleTable.Entries[index].Object = NULL; HandleTable.Count--; + pthread_mutex_unlock(&mutex); + return TRUE; } } + pthread_mutex_unlock(&mutex); + return FALSE; } @@ -133,12 +165,19 @@ ULONG winpr_Handle_GetType(HANDLE handle) HandleTable_GetInstance(); + pthread_mutex_lock(&mutex); + for (index = 0; index < (int) HandleTable.MaxCount; index++) { if (HandleTable.Entries[index].Object == handle) + { + pthread_mutex_unlock(&mutex); return HandleTable.Entries[index].Type; + } } + pthread_mutex_unlock(&mutex); + return HANDLE_TYPE_NONE; } @@ -155,16 +194,23 @@ BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, PVOID* pObject) HandleTable_GetInstance(); + pthread_mutex_lock(&mutex); + for (index = 0; index < (int) HandleTable.MaxCount; index++) { if (HandleTable.Entries[index].Object == handle) { *pType = HandleTable.Entries[index].Type; *pObject = HandleTable.Entries[index].Object; + + pthread_mutex_unlock(&mutex); + return TRUE; } } + pthread_mutex_unlock(&mutex); + return FALSE; } diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index d78fd1358..5eddde900 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -49,7 +49,7 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, event = (WINPR_EVENT*) malloc(sizeof(WINPR_EVENT)); - if (!event) + if (event) { event->bManualReset = bManualReset; @@ -63,6 +63,7 @@ HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, if (pipe(event->pipe_fd) < 0) { + printf("CreateEventW: failed to create event\n"); return NULL; } diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index 5a2707c8a..58aed1e7c 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -74,7 +74,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) FD_SET(event->pipe_fd[0], &rfds); ZeroMemory(&timeout, sizeof(timeout)); - if (dwMilliseconds != INFINITE) + if ((dwMilliseconds != INFINITE) && (dwMilliseconds != 0)) { timeout.tv_usec = dwMilliseconds * 1000; } diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 45a711959..9ce746c90 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -67,6 +67,8 @@ #ifndef _WIN32 +#include + #include /** @@ -76,37 +78,68 @@ typedef void *(*pthread_start_routine)(void*); -HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId) +struct winpr_thread { - return NULL; + BOOL started; + pthread_t thread; + SIZE_T dwStackSize; + LPVOID lpParameter; + pthread_mutex_t mutex; + LPTHREAD_START_ROUTINE lpStartAddress; + LPSECURITY_ATTRIBUTES lpThreadAttributes; +}; +typedef struct winpr_thread WINPR_THREAD; + +void winpr_StartThread(WINPR_THREAD* thread) +{ + pthread_attr_t attr; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + if (thread->dwStackSize > 0) + pthread_attr_setstacksize(&attr, (size_t) thread->dwStackSize); + + thread->started = TRUE; + pthread_create(&thread->thread, &attr, (pthread_start_routine) thread->lpStartAddress, thread->lpParameter); + + pthread_attr_destroy(&attr); } HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) { HANDLE handle; - pthread_t thread; - pthread_attr_t attr; + WINPR_THREAD* thread; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + thread = (WINPR_THREAD*) malloc(sizeof(WINPR_THREAD)); + ZeroMemory(thread, sizeof(WINPR_THREAD)); - if (dwStackSize > 0) - pthread_attr_setstacksize(&attr, (size_t) dwStackSize); + thread->started = FALSE; + thread->dwStackSize = dwStackSize; + thread->lpParameter = lpParameter; + thread->lpStartAddress = lpStartAddress; + thread->lpThreadAttributes = lpThreadAttributes; - pthread_create(&thread, &attr, (pthread_start_routine) lpStartAddress, lpParameter); + pthread_mutex_init(&thread->mutex, 0); handle = winpr_Handle_Insert(HANDLE_TYPE_THREAD, (void*) thread); - pthread_attr_destroy(&attr); + if (!(dwCreationFlags & CREATE_SUSPENDED)) + winpr_StartThread(thread); return handle; } +HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) +{ + return NULL; +} + VOID ExitThread(DWORD dwExitCode) { - + pthread_exit((void*) dwExitCode); } HANDLE GetCurrentThread(VOID) @@ -121,6 +154,22 @@ DWORD GetCurrentThreadId(VOID) DWORD ResumeThread(HANDLE hThread) { + ULONG Type; + PVOID Object; + WINPR_THREAD* thread; + + if (!winpr_Handle_GetInfo(hThread, &Type, &Object)) + return 0; + + thread = (WINPR_THREAD*) Object; + + pthread_mutex_lock(&thread->mutex); + + if (!thread->started) + winpr_StartThread(thread); + + pthread_mutex_unlock(&thread->mutex); + return 0; } @@ -136,6 +185,21 @@ BOOL SwitchToThread(VOID) BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode) { + ULONG Type; + PVOID Object; + WINPR_THREAD* thread; + + if (!winpr_Handle_GetInfo(hThread, &Type, &Object)) + return 0; + + thread = (WINPR_THREAD*) Object; + + pthread_mutex_lock(&thread->mutex); + + pthread_cancel(thread->thread); + + pthread_mutex_unlock(&thread->mutex); + return TRUE; } From 9ddcd4fd0c337793c7eb89584156ac61bd98023c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 14:37:49 -0400 Subject: [PATCH 18/64] libfreerdp-utils: adapt freerdp_uniconv_out to WinPR API --- include/freerdp/utils/unicode.h | 6 +- libfreerdp/utils/CMakeLists.txt | 3 + libfreerdp/utils/unicode.c | 162 +++++++++----------------------- 3 files changed, 55 insertions(+), 116 deletions(-) diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index 0dabc9309..6a90d42f4 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -49,6 +49,10 @@ FREERDP_API UNICONV* freerdp_uniconv_new(); FREERDP_API void freerdp_uniconv_free(UNICONV *uniconv); FREERDP_API char* freerdp_uniconv_in(UNICONV *uniconv, unsigned char* pin, size_t in_len); FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, const char *str, size_t *pout_len); -FREERDP_API void freerdp_uniconv_uppercase(UNICONV *uniconv, char *wstr, int length); + +#include + +FREERDP_API WCHAR* freerdp_AsciiToUnicode(const char* str, int* length); +FREERDP_API CHAR* freerdp_UnicodeToAscii(const WCHAR* wstr, int* length); #endif /* __UNICODE_UTILS_H */ diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index ea4edfadb..d2cedf32d 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -73,6 +73,9 @@ if(WITH_MONOLITHIC_BUILD) set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr) set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_UTILS_LIBS} PARENT_SCOPE) else() + if(NOT WIN32) + set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-crt) + endif() set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-synch) target_link_libraries(freerdp-utils ${FREERDP_UTILS_LIBS}) install(TARGETS freerdp-utils DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c index 3b84af97c..05c023606 100644 --- a/libfreerdp/utils/unicode.c +++ b/libfreerdp/utils/unicode.c @@ -27,6 +27,8 @@ #include +#include + /* Convert pin/in_len from WINDOWS_CODEPAGE - return like xstrdup, 0-terminated */ char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) @@ -99,121 +101,6 @@ char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) return pout; } -/* Convert str from DEFAULT_CODEPAGE to WINDOWS_CODEPAGE and return buffer like xstrdup. - * Buffer is 0-terminated but that is not included in the returned length. */ - -char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len) -{ - size_t ibl; - size_t obl; - char* pin; - char* pout; - char* pout0; - - if (str == NULL) - { - *pout_len = 0; - return NULL; - } - - ibl = strlen(str); - obl = 2 * ibl; - pin = (char*) str; - pout0 = xmalloc(obl + 2); - pout = pout0; - -#ifdef HAVE_ICONV - if (iconv(uniconv->out_iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1) - { - printf("freerdp_uniconv_out: iconv() error\n"); - return NULL; - } -#else - while ((ibl > 0) && (obl > 0)) - { - unsigned int wc; - - wc = (unsigned int)(unsigned char)(*pin++); - ibl--; - if (wc >= 0xF0) - { - wc = (wc - 0xF0) << 18; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80) << 12; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80) << 6; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80); - ibl -= 3; - } - else if (wc >= 0xE0) - { - wc = (wc - 0xE0) << 12; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80) << 6; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80); - ibl -= 2; - } - else if (wc >= 0xC0) - { - wc = (wc - 0xC0) << 6; - wc += ((unsigned int)(unsigned char)(*pin++) - 0x80); - ibl -= 1; - } - - if (wc <= 0xFFFF) - { - *pout++ = (char)(wc & 0xFF); - *pout++ = (char)(wc >> 8); - obl -= 2; - } - else - { - wc -= 0x10000; - *pout++ = (char)((wc >> 10) & 0xFF); - *pout++ = (char)((wc >> 18) + 0xD8); - *pout++ = (char)(wc & 0xFF); - *pout++ = (char)(((wc >> 8) & 0x03) + 0xDC); - obl -= 4; - } - } -#endif - - if (ibl > 0) - { - printf("freerdp_uniconv_out: string not fully converted - %d chars left\n", (int) ibl); - } - - *pout_len = pout - pout0; - *pout++ = 0; /* Add extra double zero termination */ - *pout = 0; - - return pout0; -} - -/* Uppercase a unicode string */ - -void freerdp_uniconv_uppercase(UNICONV *uniconv, char *wstr, int length) -{ - int i; - unsigned char* p; - unsigned int wc, uwc; - - p = (unsigned char*) wstr; - - for (i = 0; i < length; i++) - { - wc = (unsigned int)(*p); - wc += (unsigned int)(*(p + 1)) << 8; - - uwc = towupper(wc); - - if (uwc != wc) - { - *p = uwc & 0xFF; - *(p + 1) = (uwc >> 8) & 0xFF; - } - - p += 2; - } -} - UNICONV* freerdp_uniconv_new() { UNICONV *uniconv = xnew(UNICONV); @@ -246,3 +133,48 @@ void freerdp_uniconv_free(UNICONV *uniconv) xfree(uniconv); } } + +char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len) +{ + WCHAR* wstr; + int length; + + wstr = freerdp_AsciiToUnicode(str, &length); + *pout_len = (size_t) length; + + return (char*) wstr; +} + +WCHAR* freerdp_AsciiToUnicode(const char* str, int* length) +{ + WCHAR* wstr; + + if (!str) + { + *length = 0; + return NULL; + } + + *length = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0); + wstr = (WCHAR*) malloc((*length + 1) * sizeof(WCHAR)); + + MultiByteToWideChar(CP_UTF8, 0, str, *length, (LPWSTR) wstr, *length * sizeof(WCHAR)); + wstr[*length] = 0; + + *length *= 2; + + return wstr; +} + +CHAR* freerdp_UnicodeToAscii(const WCHAR* wstr, int* length) +{ + CHAR* str; + + *length = WideCharToMultiByte(CP_UTF8, 0, wstr, lstrlenW(wstr), NULL, 0, NULL, NULL); + str = (char*) malloc(*length + 1); + + WideCharToMultiByte(CP_UTF8, 0, wstr, *length, str, *length, NULL, NULL); + str[*length] = '\0'; + + return str; +} From fa3c66f00fc7c403b1ffe288555ce9670ac44ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 15:42:46 -0400 Subject: [PATCH 19/64] libfreerdp-codec: jpeg fix for issue #737 --- libfreerdp/codec/jpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libfreerdp/codec/jpeg.c b/libfreerdp/codec/jpeg.c index 70dbc08ea..89c7b3a00 100644 --- a/libfreerdp/codec/jpeg.c +++ b/libfreerdp/codec/jpeg.c @@ -27,7 +27,9 @@ #ifdef WITH_JPEG +#define XMD_H #define HAVE_BOOLEAN + #include struct mydata_decomp From 01a44aa6784b1425c6c4925e55f7f0abb86d59f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 15:46:30 -0400 Subject: [PATCH 20/64] libfreerdp-codec: jpeg fix for issue #737 --- libfreerdp/codec/jpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libfreerdp/codec/jpeg.c b/libfreerdp/codec/jpeg.c index 70dbc08ea..89c7b3a00 100644 --- a/libfreerdp/codec/jpeg.c +++ b/libfreerdp/codec/jpeg.c @@ -27,7 +27,9 @@ #ifdef WITH_JPEG +#define XMD_H #define HAVE_BOOLEAN + #include struct mydata_decomp From 1059337d90a45cb0ba6a6f3f89d60a5f509a29fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 18:08:12 -0400 Subject: [PATCH 21/64] libfreerdp-utils: make freerdp_uniconv_in a wrapper for WideCharToMultiByte --- include/freerdp/utils/unicode.h | 4 +- libfreerdp/utils/unicode.c | 119 ++++++++------------------------ winpr/libwinpr/crt/string.c | 19 ++++- 3 files changed, 46 insertions(+), 96 deletions(-) diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index 6a90d42f4..b864fb3b2 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -52,7 +52,7 @@ FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, const char *str, size_t #include -FREERDP_API WCHAR* freerdp_AsciiToUnicode(const char* str, int* length); -FREERDP_API CHAR* freerdp_UnicodeToAscii(const WCHAR* wstr, int* length); +FREERDP_API int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length); +FREERDP_API int freerdp_UnicodeToAsciiAlloc(const WCHAR* wstr, CHAR** str, int length); #endif /* __UNICODE_UTILS_H */ diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c index 05c023606..76091b875 100644 --- a/libfreerdp/utils/unicode.c +++ b/libfreerdp/utils/unicode.c @@ -23,84 +23,14 @@ #include #include +#include +#include #include #include #include -/* Convert pin/in_len from WINDOWS_CODEPAGE - return like xstrdup, 0-terminated */ - -char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) -{ - unsigned char *conv_pin = pin; - size_t conv_in_len = in_len; - char *pout = xmalloc(in_len * 2 + 1), *conv_pout = pout; - size_t conv_out_len = in_len * 2; - -#ifdef HAVE_ICONV - if (iconv(uniconv->in_iconv_h, (ICONV_CONST char **) &conv_pin, &conv_in_len, &conv_pout, &conv_out_len) == (size_t) - 1) - { - /* TODO: xrealloc if conv_out_len == 0 - it shouldn't be needed, but would allow a smaller initial alloc ... */ - printf("freerdp_uniconv_in: iconv failure\n"); - return 0; - } -#else - while (conv_in_len >= 2) - { - unsigned int wc; - - wc = (unsigned int)(unsigned char)(*conv_pin++); - wc += ((unsigned int)(unsigned char)(*conv_pin++)) << 8; - conv_in_len -= 2; - - if (wc >= 0xD800 && wc <= 0xDFFF && conv_in_len >= 2) - { - /* Code points U+10000 to U+10FFFF using surrogate pair */ - wc = ((wc - 0xD800) << 10) + 0x10000; - wc += (unsigned int)(unsigned char)(*conv_pin++); - wc += ((unsigned int)(unsigned char)(*conv_pin++) - 0xDC) << 8; - conv_in_len -= 2; - } - - if (wc <= 0x7F) - { - *conv_pout++ = (char)wc; - conv_out_len--; - } - else if (wc <= 0x07FF) - { - *conv_pout++ = (char)(0xC0 + (wc >> 6)); - *conv_pout++ = (char)(0x80 + (wc & 0x3F)); - conv_out_len -= 2; - } - else if (wc <= 0xFFFF) - { - *conv_pout++ = (char)(0xE0 + (wc >> 12)); - *conv_pout++ = (char)(0x80 + ((wc >> 6) & 0x3F)); - *conv_pout++ = (char)(0x80 + (wc & 0x3F)); - conv_out_len -= 3; - } - else - { - *conv_pout++ = (char)(0xF0 + (wc >> 18)); - *conv_pout++ = (char)(0x80 + ((wc >> 12) & 0x3F)); - *conv_pout++ = (char)(0x80 + ((wc >> 6) & 0x3F)); - *conv_pout++ = (char)(0x80 + (wc & 0x3F)); - conv_out_len -= 4; - } - } -#endif - - if (conv_in_len > 0) - { - printf("freerdp_uniconv_in: conversion failure - %d chars left\n", (int) conv_in_len); - } - - *conv_pout = 0; - return pout; -} - UNICONV* freerdp_uniconv_new() { UNICONV *uniconv = xnew(UNICONV); @@ -139,42 +69,49 @@ char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len) WCHAR* wstr; int length; - wstr = freerdp_AsciiToUnicode(str, &length); + length = freerdp_AsciiToUnicodeAlloc(str, &wstr, 0); *pout_len = (size_t) length; return (char*) wstr; } -WCHAR* freerdp_AsciiToUnicode(const char* str, int* length) +int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) { - WCHAR* wstr; - if (!str) { - *length = 0; - return NULL; + *wstr = NULL; + return 0; } - *length = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0); - wstr = (WCHAR*) malloc((*length + 1) * sizeof(WCHAR)); + if (length < 1) + length = strlen(str); - MultiByteToWideChar(CP_UTF8, 0, str, *length, (LPWSTR) wstr, *length * sizeof(WCHAR)); - wstr[*length] = 0; + length = MultiByteToWideChar(CP_UTF8, 0, str, length, NULL, 0); + *wstr = (WCHAR*) malloc((length + 1) * sizeof(WCHAR)); - *length *= 2; + MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) (*wstr), length * sizeof(WCHAR)); + (*wstr)[length] = 0; - return wstr; + length *= 2; + + return length; } -CHAR* freerdp_UnicodeToAscii(const WCHAR* wstr, int* length) +char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) { CHAR* str; + int length; - *length = WideCharToMultiByte(CP_UTF8, 0, wstr, lstrlenW(wstr), NULL, 0, NULL, NULL); - str = (char*) malloc(*length + 1); + length = freerdp_UnicodeToAsciiAlloc((WCHAR*) pin, &str, (int) (in_len / 2)); - WideCharToMultiByte(CP_UTF8, 0, wstr, *length, str, *length, NULL, NULL); - str[*length] = '\0'; - - return str; + return (char*) str; +} + +int freerdp_UnicodeToAsciiAlloc(const WCHAR* wstr, CHAR** str, int length) +{ + *str = malloc((length * 2) + 1); + + WideCharToMultiByte(CP_UTF8, 0, wstr, length, *str, length, NULL, NULL); + + return length; } diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 307cede6a..3d1baa70b 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -430,16 +430,29 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int size_t conv_out_len; unsigned char* conv_pin; - if (cchWideChar < 1) + /* + * if cbMultiByte is set to 0, the function returns the required buffer size + * for lpMultiByteStr and makes no use of the output parameter itself. + */ + + if (cbMultiByte == 0) + return lstrlenW(lpWideCharStr); + + /* If cchWideChar is set to 0, the function fails */ if (cchWideChar == 0) return 0; + /* cchWideChar is set to -1 if the string is null-terminated */ + + if (cchWideChar == -1) + cchWideChar = lstrlenW(lpWideCharStr); + conv_pin = (unsigned char*) lpWideCharStr; - conv_in_len = cchWideChar; + conv_in_len = cchWideChar * 2; pout = lpMultiByteStr; conv_pout = pout; - conv_out_len = cbMultiByte; + conv_out_len = cchWideChar * 2; #ifdef HAVE_ICONV { From 44f18159c4781cecd8b8ffb025c11b7647b09faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 18:41:07 -0400 Subject: [PATCH 22/64] libfreerdp-utils: get rid of UNICONV unicode conversion context --- channels/cliprdr/client/cliprdr_format.c | 4 +- channels/cliprdr/client/cliprdr_main.c | 7 ---- channels/cliprdr/client/cliprdr_main.h | 1 - channels/rail/client/rail_main.h | 1 - channels/rail/client/rail_orders.c | 7 ++-- channels/rdpdr/client/disk/disk_file.c | 15 ++++---- channels/rdpdr/client/disk/disk_main.c | 19 ++-------- .../rdpdr/client/parallel/parallel_main.c | 8 ++-- channels/rdpdr/client/printer/printer_main.c | 9 ++--- channels/rdpdr/client/rdpdr_main.c | 6 +-- channels/rdpdr/client/serial/serial_main.c | 14 ++++--- client/X11/xf_cliprdr.c | 18 +++------ include/freerdp/rail/rail.h | 1 - include/freerdp/settings.h | 3 +- include/freerdp/utils/string.h | 3 +- include/freerdp/utils/unicode.h | 27 +------------- libfreerdp/cache/bitmap.c | 2 + libfreerdp/cache/brush.c | 2 + libfreerdp/cache/glyph.c | 2 + libfreerdp/cache/nine_grid.c | 2 + libfreerdp/cache/offscreen.c | 2 + libfreerdp/cache/palette.c | 2 + libfreerdp/cache/pointer.c | 2 + libfreerdp/codec/mppc_dec.c | 5 ++- libfreerdp/core/errinfo.c | 2 + libfreerdp/core/gcc.c | 9 +++-- libfreerdp/core/info.c | 30 ++++++++------- libfreerdp/core/nego.c | 6 +-- libfreerdp/core/redirection.c | 14 +++---- libfreerdp/core/rpc.c | 4 +- libfreerdp/core/rpc.h | 2 - libfreerdp/core/settings.c | 2 - libfreerdp/core/timezone.c | 10 +++-- libfreerdp/core/tsg.c | 5 +-- libfreerdp/rail/rail.c | 2 - libfreerdp/rail/window.c | 4 +- libfreerdp/utils/profiler.c | 2 + libfreerdp/utils/string.c | 5 ++- libfreerdp/utils/time.c | 1 + libfreerdp/utils/unicode.c | 37 +------------------ 40 files changed, 111 insertions(+), 186 deletions(-) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index 4f603dbf3..fa3af9cf5 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -143,7 +143,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3 } else { - format_name->name = freerdp_uniconv_in(cliprdr->uniconv, s->p, 32); + format_name->name = freerdp_uniconv_in(s->p, 32); format_name->length = strlen(format_name->name); } @@ -187,7 +187,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32 break; } - format_name->name = freerdp_uniconv_in(cliprdr->uniconv, stream_get_tail(s), name_len); + format_name->name = freerdp_uniconv_in(stream_get_tail(s), name_len); format_name->length = strlen(format_name->name); stream_seek(s, name_len + 2); } diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index b7f4e136d..10eb26c9b 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -82,8 +82,6 @@ void cliprdr_packet_send(cliprdrPlugin* cliprdr, STREAM* s) static void cliprdr_process_connect(rdpSvcPlugin* plugin) { DEBUG_CLIPRDR("connecting"); - - ((cliprdrPlugin*) plugin)->uniconv = freerdp_uniconv_new(); } void cliprdr_print_general_capability_flags(uint32 flags) @@ -267,11 +265,6 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event) static void cliprdr_process_terminate(rdpSvcPlugin* plugin) { - cliprdrPlugin* cliprdr_plugin = (cliprdrPlugin*) plugin; - - if (cliprdr_plugin->uniconv != NULL) - freerdp_uniconv_free(cliprdr_plugin->uniconv); - xfree(plugin); } diff --git a/channels/cliprdr/client/cliprdr_main.h b/channels/cliprdr/client/cliprdr_main.h index e3059a272..bc6b35584 100644 --- a/channels/cliprdr/client/cliprdr_main.h +++ b/channels/cliprdr/client/cliprdr_main.h @@ -35,7 +35,6 @@ typedef struct _CLIPRDR_FORMAT_NAME CLIPRDR_FORMAT_NAME; struct cliprdr_plugin { rdpSvcPlugin plugin; - UNICONV* uniconv; boolean received_caps; boolean use_long_format_names; boolean stream_fileclip_enabled; diff --git a/channels/rail/client/rail_main.h b/channels/rail/client/rail_main.h index 49870a5be..31c243aa0 100644 --- a/channels/rail/client/rail_main.h +++ b/channels/rail/client/rail_main.h @@ -29,7 +29,6 @@ struct rdp_rail_order { - UNICONV* uniconv; RDP_PLUGIN_DATA* plugin_data; void* plugin; RAIL_HANDSHAKE_ORDER handshake; diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index 09826f149..f756b5ac0 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -24,6 +24,7 @@ #include #include +#include #include "rail_orders.h" @@ -78,7 +79,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_ if (string == NULL || strlen(string) < 1) return; - buffer = freerdp_uniconv_out(rail_order->uniconv, string, &length); + buffer = freerdp_uniconv_out(string, &length); unicode_string->string = (uint8*) buffer; unicode_string->length = (uint16) length; @@ -631,7 +632,7 @@ rdpRailOrder* rail_order_new() if (rail_order != NULL) { - rail_order->uniconv = freerdp_uniconv_new(); + } return rail_order; @@ -641,7 +642,7 @@ void rail_order_free(rdpRailOrder* rail_order) { if (rail_order != NULL) { - freerdp_uniconv_free(rail_order->uniconv); + xfree(rail_order); } } diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index 44745fb11..658278500 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -36,8 +36,10 @@ #include #include #include + #include #include +#include #include #ifdef HAVE_UNISTD_H @@ -425,7 +427,6 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui uint64 size; char* fullpath; struct STAT st; - UNICONV* uniconv; struct timeval tv[2]; uint64 LastWriteTime; uint32 FileAttributes; @@ -485,9 +486,8 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui stream_seek_uint8(input); /* ReplaceIfExists */ stream_seek_uint8(input); /* RootDirectory */ stream_read_uint32(input, FileNameLength); - uniconv = freerdp_uniconv_new(); - s = freerdp_uniconv_in(uniconv, stream_get_tail(input), FileNameLength); - freerdp_uniconv_free(uniconv); + + s = freerdp_uniconv_in(stream_get_tail(input), FileNameLength); fullpath = disk_file_combine_fullpath(file->basepath, s); xfree(s); @@ -520,7 +520,6 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui struct dirent* ent; char* ent_path; struct STAT st; - UNICONV* uniconv; size_t len; boolean ret; @@ -549,6 +548,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui do { ent = readdir(file->dir); + if (ent == NULL) continue; @@ -572,6 +572,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui memset(&st, 0, sizeof(struct STAT)); ent_path = xmalloc(strlen(file->fullpath) + strlen(ent->d_name) + 2); sprintf(ent_path, "%s/%s", file->fullpath, ent->d_name); + if (STAT(ent_path, &st) != 0) { DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno); @@ -580,9 +581,7 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui DEBUG_SVC(" pattern %s matched %s", file->pattern, ent_path); xfree(ent_path); - uniconv = freerdp_uniconv_new(); - ent_path = freerdp_uniconv_out(uniconv, ent->d_name, &len); - freerdp_uniconv_free(uniconv); + ent_path = freerdp_uniconv_out(ent->d_name, &len); ret = true; switch (FsInformationClass) diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index 5616b8196..f90e3c022 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -123,7 +123,6 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp) uint32 CreateDisposition; uint32 CreateOptions; uint32 PathLength; - UNICONV* uniconv; char* path; uint32 FileId; uint8 Information; @@ -134,9 +133,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp) stream_read_uint32(irp->input, CreateOptions); stream_read_uint32(irp->input, PathLength); - uniconv = freerdp_uniconv_new(); - path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength); - freerdp_uniconv_free(uniconv); + path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); FileId = irp->devman->id_sequence++; @@ -388,7 +385,6 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir STREAM* output = irp->output; struct STATVFS svfst; struct STAT st; - UNICONV* uniconv; char* volumeLabel = {"FREERDP"}; /* TODO: Add sub routine to correctly pick up Volume Label name for each O/S supported */ char* diskType = {"FAT32"}; char* outStr; @@ -403,9 +399,7 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir { case FileFsVolumeInformation: /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */ - uniconv = freerdp_uniconv_new(); - outStr = freerdp_uniconv_out(uniconv, volumeLabel, &len); - freerdp_uniconv_free(uniconv); + outStr = freerdp_uniconv_out(volumeLabel, &len); stream_write_uint32(output, 17 + len); /* Length */ stream_check_size(output, 17 + len); stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ @@ -429,9 +423,7 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir case FileFsAttributeInformation: /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */ - uniconv = freerdp_uniconv_new(); - outStr = freerdp_uniconv_out(uniconv, diskType, &len); - freerdp_uniconv_free(uniconv); + outStr = freerdp_uniconv_out(diskType, &len); stream_write_uint32(output, 12 + len); /* Length */ stream_check_size(output, 12 + len); @@ -480,7 +472,6 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp) uint32 FsInformationClass; uint8 InitialQuery; uint32 PathLength; - UNICONV* uniconv; char* path; stream_read_uint32(irp->input, FsInformationClass); @@ -488,9 +479,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp) stream_read_uint32(irp->input, PathLength); stream_seek(irp->input, 23); /* Padding */ - uniconv = freerdp_uniconv_new(); - path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength); - freerdp_uniconv_free(uniconv); + path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); file = disk_get_file_by_id(disk, irp->FileId); diff --git a/channels/rdpdr/client/parallel/parallel_main.c b/channels/rdpdr/client/parallel/parallel_main.c index 91f2b258d..0d09287d5 100644 --- a/channels/rdpdr/client/parallel/parallel_main.c +++ b/channels/rdpdr/client/parallel/parallel_main.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "rdpdr_constants.h" @@ -70,18 +71,15 @@ typedef struct _PARALLEL_DEVICE PARALLEL_DEVICE; static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) { - uint32 PathLength; char* path; - UNICONV* uniconv; + uint32 PathLength; stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_uint32(irp->input, PathLength); - uniconv = freerdp_uniconv_new(); - path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength); - freerdp_uniconv_free(uniconv); + path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); parallel->id = irp->devman->id_sequence++; parallel->file = open(parallel->path, O_RDWR); diff --git a/channels/rdpdr/client/printer/printer_main.c b/channels/rdpdr/client/printer/printer_main.c index fdedd193a..25b5e35f1 100644 --- a/channels/rdpdr/client/printer/printer_main.c +++ b/channels/rdpdr/client/printer/printer_main.c @@ -230,9 +230,7 @@ static void printer_free(DEVICE* device) void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer) { - PRINTER_DEVICE* printer_dev; char* port; - UNICONV* uniconv; uint32 Flags; size_t DriverNameLen; char* DriverName; @@ -240,6 +238,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri char* PrintName; uint32 CachedFieldsLen; uint8* CachedPrinterConfigData; + PRINTER_DEVICE* printer_dev; port = xmalloc(10); snprintf(port, 10, "PRN%d", printer->id); @@ -262,10 +261,8 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri if (printer->is_default) Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER; - uniconv = freerdp_uniconv_new(); - DriverName = freerdp_uniconv_out(uniconv, printer->driver, &DriverNameLen); - PrintName = freerdp_uniconv_out(uniconv, printer->name, &PrintNameLen); - freerdp_uniconv_free(uniconv); + DriverName = freerdp_uniconv_out(printer->driver, &DriverNameLen); + PrintName = freerdp_uniconv_out(printer->name, &PrintNameLen); printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 8c03594d1..390d254a5 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -96,15 +96,12 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) { char* s; STREAM* data_out; - UNICONV* uniconv; size_t computerNameLenW; - uniconv = freerdp_uniconv_new(); - if (!rdpdr->computerName[0]) gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1); - s = freerdp_uniconv_out(uniconv, rdpdr->computerName, &computerNameLenW); + s = freerdp_uniconv_out(rdpdr->computerName, &computerNameLenW); data_out = stream_new(16 + computerNameLenW + 2); stream_write_uint16(data_out, RDPDR_CTYP_CORE); @@ -117,7 +114,6 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) stream_write_uint16(data_out, 0); /* null terminator */ xfree(s); - freerdp_uniconv_free(uniconv); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); } diff --git a/channels/rdpdr/client/serial/serial_main.c b/channels/rdpdr/client/serial/serial_main.c index 547edbfa1..dc71b9324 100644 --- a/channels/rdpdr/client/serial/serial_main.c +++ b/channels/rdpdr/client/serial/serial_main.c @@ -79,23 +79,21 @@ static boolean serial_check_fds(SERIAL_DEVICE* serial); static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp) { + char* path; SERIAL_TTY* tty; uint32 PathLength; uint32 FileId; - char* path; - UNICONV* uniconv; stream_seek(irp->input, 28); /* DesiredAccess(4) AllocationSize(8), FileAttributes(4) */ /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_uint32(irp->input, PathLength); - uniconv = freerdp_uniconv_new(); - path = freerdp_uniconv_in(uniconv, stream_get_tail(irp->input), PathLength); - freerdp_uniconv_free(uniconv); + path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); FileId = irp->devman->id_sequence++; tty = serial_tty_new(serial->path, FileId); + if (tty == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; @@ -122,6 +120,7 @@ static void serial_process_irp_close(SERIAL_DEVICE* serial, IRP* irp) SERIAL_TTY* tty; tty = serial->tty; + if (tty == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; @@ -153,6 +152,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp) DEBUG_SVC("length %u offset %llu", Length, Offset); tty = serial->tty; + if (tty == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; @@ -179,11 +179,13 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp) } stream_write_uint32(irp->output, Length); + if (Length > 0) { stream_check_size(irp->output, Length); stream_write(irp->output, buffer, Length); } + xfree(buffer); irp->Complete(irp); @@ -202,6 +204,7 @@ static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp) DEBUG_SVC("length %u offset %llu", Length, Offset); tty = serial->tty; + if (tty == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; @@ -243,6 +246,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp) stream_seek(irp->input, 20); /* Padding */ tty = serial->tty; + if (tty == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 982fabab4..55bc4291d 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -530,13 +530,10 @@ static uint8* xf_cliprdr_process_requested_unicodetext(uint8* data, int* size) uint8* inbuf; uint8* outbuf; size_t out_size; - UNICONV* uniconv; inbuf = lf2crlf(data, size); - uniconv = freerdp_uniconv_new(); - outbuf = (uint8*) freerdp_uniconv_out(uniconv, (char*) inbuf, &out_size); - freerdp_uniconv_free(uniconv); + outbuf = (uint8*) freerdp_uniconv_out((char*) inbuf, &out_size); xfree(inbuf); @@ -578,9 +575,9 @@ static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size) uint8* in; uint8* outbuf; char num[11]; - UNICONV* uniconv; inbuf = NULL; + if (*size > 2) { if ((uint8) data[0] == 0xFE && (uint8) data[1] == 0xFF) @@ -590,11 +587,10 @@ static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size) if ((uint8) data[0] == 0xFF && (uint8) data[1] == 0xFE) { - uniconv = freerdp_uniconv_new(); - inbuf = (uint8*) freerdp_uniconv_in(uniconv, data + 2, *size - 2); - freerdp_uniconv_free(uniconv); + inbuf = (uint8*) freerdp_uniconv_in(data + 2, *size - 2); } } + if (inbuf == NULL) { inbuf = xzalloc(*size + 1); @@ -884,11 +880,7 @@ static void xf_cliprdr_process_text(clipboardContext* cb, uint8* data, int size) static void xf_cliprdr_process_unicodetext(clipboardContext* cb, uint8* data, int size) { - UNICONV* uniconv; - - uniconv = freerdp_uniconv_new(); - cb->data = (uint8*) freerdp_uniconv_in(uniconv, data, size); - freerdp_uniconv_free(uniconv); + cb->data = (uint8*) freerdp_uniconv_in(data, size); cb->data_length = strlen((char*) cb->data); crlf2lf(cb->data, &cb->data_length); } diff --git a/include/freerdp/rail/rail.h b/include/freerdp/rail/rail.h index ce0686ffb..7ffe15f62 100644 --- a/include/freerdp/rail/rail.h +++ b/include/freerdp/rail/rail.h @@ -45,7 +45,6 @@ typedef void (*railDesktopNonMonitored) (rdpRail* rail, rdpWindow* window); struct rdp_rail { void* extra; - UNICONV* uniconv; CLRCONV* clrconv; rdpIconCache* cache; rdpWindowList* list; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 400a5c612..f4afb7bcb 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -22,7 +22,6 @@ #include #include -#include /* Performance Flags */ #define PERF_FLAG_NONE 0x00000000 @@ -317,7 +316,7 @@ struct rdp_settings ALIGN64 char* home_path; /* 112 */ ALIGN64 uint32 share_id; /* 113 */ ALIGN64 uint32 pdu_source; /* 114 */ - ALIGN64 UNICONV* uniconv; /* 115 */ + ALIGN64 void* unused115; /* 115 */ ALIGN64 boolean server_mode; /* 116 */ ALIGN64 char* config_path; /* 117 */ ALIGN64 char* current_path; /* 118 */ diff --git a/include/freerdp/utils/string.h b/include/freerdp/utils/string.h index 636b93b04..4a67d0ea6 100644 --- a/include/freerdp/utils/string.h +++ b/include/freerdp/utils/string.h @@ -23,7 +23,6 @@ #include #include #include -#include struct rdp_string { @@ -33,7 +32,7 @@ struct rdp_string }; typedef struct rdp_string rdpString; -FREERDP_API void freerdp_string_read_length32(STREAM* s, rdpString* string, UNICONV* uniconv); +FREERDP_API void freerdp_string_read_length32(STREAM* s, rdpString* string); FREERDP_API void freerdp_string_free(rdpString* string); #endif /* __STRING_UTILS_H */ diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index b864fb3b2..c43dadbca 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -24,31 +24,8 @@ #include #include -#define DEFAULT_CODEPAGE "UTF-8" -#define WINDOWS_CODEPAGE "UTF-16LE" - -#ifdef HAVE_ICONV -#include -#endif - -#ifndef ICONV_CONST -#define ICONV_CONST "" -#endif - -struct _UNICONV -{ - int iconv; -#ifdef HAVE_ICONV - iconv_t* in_iconv_h; - iconv_t* out_iconv_h; -#endif -}; -typedef struct _UNICONV UNICONV; - -FREERDP_API UNICONV* freerdp_uniconv_new(); -FREERDP_API void freerdp_uniconv_free(UNICONV *uniconv); -FREERDP_API char* freerdp_uniconv_in(UNICONV *uniconv, unsigned char* pin, size_t in_len); -FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, const char *str, size_t *pout_len); +FREERDP_API char* freerdp_uniconv_in(unsigned char* pin, size_t in_len); +FREERDP_API char* freerdp_uniconv_out(const char *str, size_t *pout_len); #include diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index c361c4f88..0d52c2f8d 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include #include diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index 28ef07ef7..30cebd588 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include #include diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index ca0ca8931..052afdbc3 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include #include diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index 40bd9a3f8..7c89d40c2 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include #include diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 51ad5139b..132a8d5ad 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/libfreerdp/cache/palette.c b/libfreerdp/cache/palette.c index ca4576700..e73765cd9 100644 --- a/libfreerdp/cache/palette.c +++ b/libfreerdp/cache/palette.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/libfreerdp/cache/pointer.c b/libfreerdp/cache/pointer.c index dea91ebf5..c396bdce8 100644 --- a/libfreerdp/cache/pointer.c +++ b/libfreerdp/cache/pointer.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/libfreerdp/codec/mppc_dec.c b/libfreerdp/codec/mppc_dec.c index b8cbe73bd..7a4d8d8a4 100644 --- a/libfreerdp/codec/mppc_dec.c +++ b/libfreerdp/codec/mppc_dec.c @@ -22,9 +22,12 @@ #include "config.h" #endif -#include +#include + #include +#include + static uint8 HuffLenLEC[] = { 0x6, 0x6, 0x6, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x9, 0x8, 0x9, 0x9, 0x9, 0x9, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x8, 0x9, 0x9, 0xa, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0x9, 0xa, 0x9, 0xa, 0x9, 0x9, 0x9, 0xa, 0xa, 0x9, 0xa, 0x9, 0x9, 0x8, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x8, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x7, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xd, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xb, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0xa, 0x8, 0x9, 0x9, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0xa, 0xa, 0xa, 0x9, 0x9, 0x8, 0x7, 0xd, 0xd, 0x7, 0x7, 0xa, 0x7, 0x7, 0x6, 0x6, 0x6, 0x6, 0x5, 0x6, 0x6, 0x6, 0x5, 0x6, 0x5, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x8, 0x5, 0x6, 0x7, 0x7 }; diff --git a/libfreerdp/core/errinfo.c b/libfreerdp/core/errinfo.c index d2f255d37..423a4e6b1 100644 --- a/libfreerdp/core/errinfo.c +++ b/libfreerdp/core/errinfo.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include "errinfo.h" int connectErrorCode; diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index e751a263a..3c6d732a3 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -22,6 +22,7 @@ #endif #include +#include #include "gcc.h" #include "certificate.h" @@ -490,7 +491,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block stream_read_uint32(s, settings->client_build); /* clientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ - str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32); + str = freerdp_uniconv_in(stream_get_tail(s), 32); stream_seek(s, 32); snprintf(settings->client_hostname, 31, "%s", str); settings->client_hostname[31] = 0; @@ -545,7 +546,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block if (blockLength < 64) break; - str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64); + str = freerdp_uniconv_in(stream_get_tail(s), 64); stream_seek(s, 64); snprintf(settings->client_product_id, 32, "%s", str); xfree(str); @@ -642,8 +643,8 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) gcc_write_user_data_header(s, CS_CORE, 216); version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4; - clientName = freerdp_uniconv_out(settings->uniconv, settings->client_hostname, &clientNameLength); - clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength); + clientName = freerdp_uniconv_out(settings->client_hostname, &clientNameLength); + clientDigProductId = freerdp_uniconv_out(settings->client_product_id, &clientDigProductIdLength); stream_write_uint32(s, version); /* version */ stream_write_uint16(s, settings->width); /* desktopWidth */ diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index e5a9d381d..8f5ac3a23 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include "timezone.h" #include "info.h" @@ -119,7 +121,7 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings) settings->ipv6 = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? true : false); if (stream_get_left(s) < cbClientAddress) return false; - settings->ip_address = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientAddress); + settings->ip_address = freerdp_uniconv_in(stream_get_tail(s), cbClientAddress); stream_seek(s, cbClientAddress); stream_read_uint16(s, cbClientDir); /* cbClientDir */ @@ -127,7 +129,7 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings) return false; if (settings->client_dir) xfree(settings->client_dir); - settings->client_dir = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientDir); + settings->client_dir = freerdp_uniconv_in(stream_get_tail(s), cbClientDir); stream_seek(s, cbClientDir); if (!rdp_read_client_time_zone(s, settings)) @@ -166,10 +168,10 @@ void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings) clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET; - clientAddress = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->ip_address, &length); + clientAddress = (uint8*) freerdp_uniconv_out(settings->ip_address, &length); cbClientAddress = length; - clientDir = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->client_dir, &length); + clientDir = (uint8*) freerdp_uniconv_out(settings->client_dir, &length); cbClientDir = length; cbAutoReconnectLen = settings->client_auto_reconnect_cookie->cbLen; @@ -239,7 +241,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) return false; if (cbDomain > 0) { - settings->domain = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbDomain); + settings->domain = freerdp_uniconv_in(stream_get_tail(s), cbDomain); stream_seek(s, cbDomain); } stream_seek(s, 2); @@ -248,7 +250,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) return false; if (cbUserName > 0) { - settings->username = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbUserName); + settings->username = freerdp_uniconv_in(stream_get_tail(s), cbUserName); stream_seek(s, cbUserName); } stream_seek(s, 2); @@ -257,7 +259,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) return false; if (cbPassword > 0) { - settings->password = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbPassword); + settings->password = freerdp_uniconv_in(stream_get_tail(s), cbPassword); stream_seek(s, cbPassword); } stream_seek(s, 2); @@ -266,7 +268,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) return false; if (cbAlternateShell > 0) { - settings->shell = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbAlternateShell); + settings->shell = freerdp_uniconv_in(stream_get_tail(s), cbAlternateShell); stream_seek(s, cbAlternateShell); } stream_seek(s, 2); @@ -275,7 +277,7 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) return false; if (cbWorkingDir > 0) { - settings->directory = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbWorkingDir); + settings->directory = freerdp_uniconv_in(stream_get_tail(s), cbWorkingDir); stream_seek(s, cbWorkingDir); } stream_seek(s, 2); @@ -335,10 +337,10 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) if (settings->compression) flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_RDP6; - domain = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->domain, &length); + domain = (uint8*) freerdp_uniconv_out(settings->domain, &length); cbDomain = length; - userName = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->username, &length); + userName = (uint8*) freerdp_uniconv_out(settings->username, &length); cbUserName = length; if (settings->password_cookie && settings->password_cookie->length > 0) @@ -349,14 +351,14 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) } else { - password = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->password, &length); + password = (uint8*) freerdp_uniconv_out(settings->password, &length); cbPassword = length; } - alternateShell = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->shell, &length); + alternateShell = (uint8*) freerdp_uniconv_out(settings->shell, &length); cbAlternateShell = length; - workingDir = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->directory, &length); + workingDir = (uint8*) freerdp_uniconv_out(settings->directory, &length); cbWorkingDir = length; stream_write_uint32(s, 0); /* CodePage */ diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 8bd3fa5fb..502d7e7e0 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -26,6 +26,7 @@ #include #include +#include #include "tpkt.h" @@ -234,7 +235,6 @@ boolean nego_send_preconnection_pdu(rdpNego* nego) { STREAM* s; uint32 cbSize; - UNICONV* uniconv; uint16 cchPCB_times2 = 0; char* wszPCB = NULL; @@ -252,10 +252,8 @@ boolean nego_send_preconnection_pdu(rdpNego* nego) if (nego->preconnection_blob) { size_t size; - uniconv = freerdp_uniconv_new(); - wszPCB = freerdp_uniconv_out(uniconv, nego->preconnection_blob, &size); + wszPCB = freerdp_uniconv_out(nego->preconnection_blob, &size); cchPCB_times2 = (uint16) size; - freerdp_uniconv_free(uniconv); cchPCB_times2 += 2; /* zero-termination */ cbSize += cchPCB_times2; } diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 8fe1f7659..4b0561f15 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -78,7 +78,7 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) if (redirection->flags & LB_TARGET_NET_ADDRESS) { - freerdp_string_read_length32(s, &redirection->targetNetAddress, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->targetNetAddress); DEBUG_REDIR("targetNetAddress: %s", redirection->targetNetAddress.ascii); } @@ -96,13 +96,13 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) if (redirection->flags & LB_USERNAME) { - freerdp_string_read_length32(s, &redirection->username, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->username); DEBUG_REDIR("username: %s", redirection->username.ascii); } if (redirection->flags & LB_DOMAIN) { - freerdp_string_read_length32(s, &redirection->domain, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->domain); DEBUG_REDIR("domain: %s", redirection->domain.ascii); } @@ -121,19 +121,19 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) if (redirection->flags & LB_TARGET_FQDN) { - freerdp_string_read_length32(s, &redirection->targetFQDN, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->targetFQDN); DEBUG_REDIR("targetFQDN: %s", redirection->targetFQDN.ascii); } if (redirection->flags & LB_TARGET_NETBIOS_NAME) { - freerdp_string_read_length32(s, &redirection->targetNetBiosName, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->targetNetBiosName); DEBUG_REDIR("targetNetBiosName: %s", redirection->targetNetBiosName.ascii); } if (redirection->flags & LB_CLIENT_TSV_URL) { - freerdp_string_read_length32(s, &redirection->tsvUrl, rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->tsvUrl); DEBUG_REDIR("tsvUrl: %s", redirection->tsvUrl.ascii); } @@ -152,7 +152,7 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) for (i = 0; i < (int) count; i++) { - freerdp_string_read_length32(s, &redirection->targetNetAddresses[i], rdp->settings->uniconv); + freerdp_string_read_length32(s, &redirection->targetNetAddresses[i]); DEBUG_REDIR("targetNetAddresses: %s", (&redirection->targetNetAddresses[i])->ascii); } } diff --git a/libfreerdp/core/rpc.c b/libfreerdp/core/rpc.c index b074a19d2..08b8ff5c6 100644 --- a/libfreerdp/core/rpc.c +++ b/libfreerdp/core/rpc.c @@ -156,7 +156,7 @@ rdpNtlm* ntlm_new() if (ntlm != NULL) { - ntlm->uniconv = freerdp_uniconv_new(); + } return ntlm; @@ -166,7 +166,7 @@ void ntlm_free(rdpNtlm* ntlm) { if (ntlm != NULL) { - freerdp_uniconv_free(ntlm->uniconv); + } } diff --git a/libfreerdp/core/rpc.h b/libfreerdp/core/rpc.h index 3445c9a22..e35bab02e 100644 --- a/libfreerdp/core/rpc.h +++ b/libfreerdp/core/rpc.h @@ -530,7 +530,6 @@ typedef struct { struct rdp_ntlm { - UNICONV* uniconv; CtxtHandle context; ULONG cbMaxToken; ULONG fContextReq; @@ -647,7 +646,6 @@ struct rdp_rpc rdpNtlmHttp* ntlm_http_in; rdpNtlmHttp* ntlm_http_out; - UNICONV* uniconv; rdpSettings* settings; rdpTransport* transport; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 9935f4f29..20534403d 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -272,7 +272,6 @@ rdpSettings* settings_new(void* instance) settings->frame_acknowledge = 2; - settings->uniconv = freerdp_uniconv_new(); gethostname(settings->client_hostname, 31); settings->client_hostname[31] = 0; settings->mouse_motion = true; @@ -296,7 +295,6 @@ void settings_free(rdpSettings* settings) { if (settings != NULL) { - freerdp_uniconv_free(settings->uniconv); xfree(settings->hostname); xfree(settings->username); xfree(settings->password); diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 071a59735..3bccf9cde 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include "timezone.h" /** @@ -85,7 +87,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings) stream_read_uint32(s, clientTimeZone->bias); /* Bias */ /* standardName (64 bytes) */ - str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64); + str = freerdp_uniconv_in(stream_get_tail(s), 64); stream_seek(s, 64); strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName)); xfree(str); @@ -94,7 +96,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings) stream_read_uint32(s, clientTimeZone->standardBias); /* StandardBias */ /* daylightName (64 bytes) */ - str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64); + str = freerdp_uniconv_in(stream_get_tail(s), 64); stream_seek(s, 64); strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName)); xfree(str); @@ -127,10 +129,10 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings) clientTimeZone = settings->client_time_zone; freerdp_time_zone_detect(clientTimeZone); - standardName = (uint8*) freerdp_uniconv_out(settings->uniconv, clientTimeZone->standardName, &length); + standardName = (uint8*) freerdp_uniconv_out(clientTimeZone->standardName, &length); standardNameLength = length; - daylightName = (uint8*) freerdp_uniconv_out(settings->uniconv, clientTimeZone->daylightName, &length); + daylightName = (uint8*) freerdp_uniconv_out(clientTimeZone->daylightName, &length); daylightNameLength = length; if (standardNameLength > 62) diff --git a/libfreerdp/core/tsg.c b/libfreerdp/core/tsg.c index a6e799740..5a4f42529 100644 --- a/libfreerdp/core/tsg.c +++ b/libfreerdp/core/tsg.c @@ -459,7 +459,6 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) uint32 length; STREAM* s_p4; int status = -1; - UNICONV* tsg_uniconv; rdpRpc* rpc = tsg->rpc; uint8* dest_addr_unic; uint32 dest_addr_unic_len; @@ -572,9 +571,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) } status = -1; - tsg_uniconv = freerdp_uniconv_new(); - dest_addr_unic = (uint8*) freerdp_uniconv_out(tsg_uniconv, hostname, (size_t*) &dest_addr_unic_len); - freerdp_uniconv_free(tsg_uniconv); + dest_addr_unic = (uint8*) freerdp_uniconv_out(hostname, (size_t*) &dest_addr_unic_len); memcpy(tsg_packet4 + 4, tsg->TunnelContext, 16); memcpy(tsg_packet4 + 38, &port, 2); diff --git a/libfreerdp/rail/rail.c b/libfreerdp/rail/rail.c index d0aeb6a12..0720ce2dd 100644 --- a/libfreerdp/rail/rail.c +++ b/libfreerdp/rail/rail.c @@ -148,7 +148,6 @@ rdpRail* rail_new(rdpSettings* settings) rail->settings = settings; rail->cache = icon_cache_new(rail); rail->list = window_list_new(rail); - rail->uniconv = freerdp_uniconv_new(); rail->clrconv = (CLRCONV*) xzalloc(sizeof(CLRCONV)); } @@ -161,7 +160,6 @@ void rail_free(rdpRail* rail) { icon_cache_free(rail->cache); window_list_free(rail->list); - freerdp_uniconv_free(rail->uniconv); xfree(rail->clrconv); xfree(rail); } diff --git a/libfreerdp/rail/window.c b/libfreerdp/rail/window.c index 208e560c9..3cccb393f 100644 --- a/libfreerdp/rail/window.c +++ b/libfreerdp/rail/window.c @@ -285,7 +285,7 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window) { if (window->titleInfo.length > 0) { - window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length); + window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length); } else { @@ -327,7 +327,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window) if (window->title != NULL) xfree(window->title); - window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length); + window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length); IFCALL(rail->rail_SetWindowText, rail, window); } diff --git a/libfreerdp/utils/profiler.c b/libfreerdp/utils/profiler.c index dfd547a46..b12729e93 100644 --- a/libfreerdp/utils/profiler.c +++ b/libfreerdp/utils/profiler.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include PROFILER* profiler_create(char* name) diff --git a/libfreerdp/utils/string.c b/libfreerdp/utils/string.c index 9b0c30106..a1c3db452 100644 --- a/libfreerdp/utils/string.c +++ b/libfreerdp/utils/string.c @@ -22,15 +22,16 @@ #endif #include +#include #include -void freerdp_string_read_length32(STREAM* s, rdpString* string, UNICONV* uniconv) +void freerdp_string_read_length32(STREAM* s, rdpString* string) { stream_read_uint32(s, string->length); string->unicode = (char*) xmalloc(string->length); stream_read(s, string->unicode, string->length); - string->ascii = freerdp_uniconv_in(uniconv, (uint8*) string->unicode, string->length); + string->ascii = freerdp_uniconv_in((uint8*) string->unicode, string->length); } void freerdp_string_free(rdpString* string) diff --git a/libfreerdp/utils/time.c b/libfreerdp/utils/time.c index 6f500a7c6..9e22d0e79 100644 --- a/libfreerdp/utils/time.c +++ b/libfreerdp/utils/time.c @@ -21,6 +21,7 @@ #include "config.h" #endif +#include #include #include diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c index 76091b875..3ea8d16a8 100644 --- a/libfreerdp/utils/unicode.c +++ b/libfreerdp/utils/unicode.c @@ -31,40 +31,7 @@ #include -UNICONV* freerdp_uniconv_new() -{ - UNICONV *uniconv = xnew(UNICONV); - -#ifdef HAVE_ICONV - uniconv->iconv = 1; - uniconv->in_iconv_h = iconv_open(DEFAULT_CODEPAGE, WINDOWS_CODEPAGE); - if (errno == EINVAL) - { - printf("Error opening iconv converter to %s from %s\n", DEFAULT_CODEPAGE, WINDOWS_CODEPAGE); - } - uniconv->out_iconv_h = iconv_open(WINDOWS_CODEPAGE, DEFAULT_CODEPAGE); - if (errno == EINVAL) - { - printf("Error opening iconv converter to %s from %s\n", WINDOWS_CODEPAGE, DEFAULT_CODEPAGE); - } -#endif - - return uniconv; -} - -void freerdp_uniconv_free(UNICONV *uniconv) -{ - if (uniconv != NULL) - { -#ifdef HAVE_ICONV - iconv_close(uniconv->in_iconv_h); - iconv_close(uniconv->out_iconv_h); -#endif - xfree(uniconv); - } -} - -char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len) +char* freerdp_uniconv_out(const char *str, size_t* pout_len) { WCHAR* wstr; int length; @@ -97,7 +64,7 @@ int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) return length; } -char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) +char* freerdp_uniconv_in(unsigned char* pin, size_t in_len) { CHAR* str; int length; From d0ac31b2c1d073b59a3fac9e415d5647bc258416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 19:49:13 -0400 Subject: [PATCH 23/64] libfreerdp-utils: get rid of freerdp_uniconv_out --- channels/rail/client/rail_orders.c | 6 +- channels/rdpdr/client/disk/disk_file.c | 51 +++++++-------- channels/rdpdr/client/disk/disk_main.c | 35 +++++----- channels/rdpdr/client/printer/printer_main.c | 14 ++-- channels/rdpdr/client/rdpdr_main.c | 9 +-- client/X11/xf_cliprdr.c | 16 ++--- include/freerdp/utils/unicode.h | 1 - libfreerdp/core/gcc.c | 26 ++++---- libfreerdp/core/info.c | 67 ++++++++++---------- libfreerdp/core/nego.c | 16 ++--- libfreerdp/core/timezone.c | 17 ++--- libfreerdp/core/tsg.c | 6 +- libfreerdp/utils/unicode.c | 13 ---- 13 files changed, 130 insertions(+), 147 deletions(-) diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index f756b5ac0..ee9bf0178 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -67,8 +67,8 @@ static const char* const RAIL_ORDER_TYPE_STRINGS[] = void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_UNICODE_STRING* unicode_string) { - char* buffer; - size_t length = 0; + WCHAR* buffer; + int length = 0; if (unicode_string->string != NULL) xfree(unicode_string->string); @@ -79,7 +79,7 @@ void rail_string_to_unicode_string(rdpRailOrder* rail_order, char* string, RAIL_ if (string == NULL || strlen(string) < 1) return; - buffer = freerdp_uniconv_out(string, &length); + length = freerdp_AsciiToUnicodeAlloc(string, &buffer, 0) * 2; unicode_string->string = (uint8*) buffer; unicode_string->length = (uint16) length; diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index 658278500..aabb6b657 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -517,11 +517,11 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, uint8 InitialQuery, const char* path, STREAM* output) { - struct dirent* ent; - char* ent_path; - struct STAT st; - size_t len; + int length; boolean ret; + WCHAR* ent_path; + struct STAT st; + struct dirent* ent; DEBUG_SVC("path %s FsInformationClass %d InitialQuery %d", path, FsInformationClass, InitialQuery); @@ -570,26 +570,27 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui } memset(&st, 0, sizeof(struct STAT)); - ent_path = xmalloc(strlen(file->fullpath) + strlen(ent->d_name) + 2); - sprintf(ent_path, "%s/%s", file->fullpath, ent->d_name); + ent_path = (WCHAR*) malloc(strlen(file->fullpath) + strlen(ent->d_name) + 2); + sprintf((char*) ent_path, "%s/%s", file->fullpath, ent->d_name); - if (STAT(ent_path, &st) != 0) + if (STAT((char*) ent_path, &st) != 0) { - DEBUG_WARN("stat %s failed. errno = %d", ent_path, errno); + DEBUG_WARN("stat %s failed. errno = %d", (char*) ent_path, errno); } DEBUG_SVC(" pattern %s matched %s", file->pattern, ent_path); xfree(ent_path); - ent_path = freerdp_uniconv_out(ent->d_name, &len); + length = freerdp_AsciiToUnicodeAlloc(ent->d_name, &ent_path, 0) * 2; ret = true; + switch (FsInformationClass) { case FileDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232097.aspx */ - stream_write_uint32(output, 64 + len); /* Length */ - stream_check_size(output, 64 + len); + stream_write_uint32(output, 64 + length); /* Length */ + stream_check_size(output, 64 + length); stream_write_uint32(output, 0); /* NextEntryOffset */ stream_write_uint32(output, 0); /* FileIndex */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -599,14 +600,14 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui stream_write_uint64(output, st.st_size); /* EndOfFile */ stream_write_uint64(output, st.st_size); /* AllocationSize */ stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_uint32(output, len); /* FileNameLength */ - stream_write(output, ent_path, len); + stream_write_uint32(output, length); /* FileNameLength */ + stream_write(output, ent_path, length); break; case FileFullDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232068.aspx */ - stream_write_uint32(output, 68 + len); /* Length */ - stream_check_size(output, 68 + len); + stream_write_uint32(output, 68 + length); /* Length */ + stream_check_size(output, 68 + length); stream_write_uint32(output, 0); /* NextEntryOffset */ stream_write_uint32(output, 0); /* FileIndex */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -616,15 +617,15 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui stream_write_uint64(output, st.st_size); /* EndOfFile */ stream_write_uint64(output, st.st_size); /* AllocationSize */ stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_uint32(output, len); /* FileNameLength */ + stream_write_uint32(output, length); /* FileNameLength */ stream_write_uint32(output, 0); /* EaSize */ - stream_write(output, ent_path, len); + stream_write(output, ent_path, length); break; case FileBothDirectoryInformation: /* http://msdn.microsoft.com/en-us/library/cc232095.aspx */ - stream_write_uint32(output, 93 + len); /* Length */ - stream_check_size(output, 93 + len); + stream_write_uint32(output, 93 + length); /* Length */ + stream_check_size(output, 93 + length); stream_write_uint32(output, 0); /* NextEntryOffset */ stream_write_uint32(output, 0); /* FileIndex */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ @@ -634,22 +635,22 @@ boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, ui stream_write_uint64(output, st.st_size); /* EndOfFile */ stream_write_uint64(output, st.st_size); /* AllocationSize */ stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ - stream_write_uint32(output, len); /* FileNameLength */ + stream_write_uint32(output, length); /* FileNameLength */ stream_write_uint32(output, 0); /* EaSize */ stream_write_uint8(output, 0); /* ShortNameLength */ /* Reserved(1), MUST NOT be added! */ stream_write_zero(output, 24); /* ShortName */ - stream_write(output, ent_path, len); + stream_write(output, ent_path, length); break; case FileNamesInformation: /* http://msdn.microsoft.com/en-us/library/cc232077.aspx */ - stream_write_uint32(output, 12 + len); /* Length */ - stream_check_size(output, 12 + len); + stream_write_uint32(output, 12 + length); /* Length */ + stream_check_size(output, 12 + length); stream_write_uint32(output, 0); /* NextEntryOffset */ stream_write_uint32(output, 0); /* FileIndex */ - stream_write_uint32(output, len); /* FileNameLength */ - stream_write(output, ent_path, len); + stream_write_uint32(output, length); /* FileNameLength */ + stream_write(output, ent_path, length); break; default: diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index f90e3c022..24137d8d4 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -385,10 +385,10 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir STREAM* output = irp->output; struct STATVFS svfst; struct STAT st; - char* volumeLabel = {"FREERDP"}; /* TODO: Add sub routine to correctly pick up Volume Label name for each O/S supported */ + char* volumeLabel = {"FREERDP"}; char* diskType = {"FAT32"}; - char* outStr; - size_t len; + WCHAR* outStr; + int length; stream_read_uint32(irp->input, FsInformationClass); @@ -399,15 +399,15 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir { case FileFsVolumeInformation: /* http://msdn.microsoft.com/en-us/library/cc232108.aspx */ - outStr = freerdp_uniconv_out(volumeLabel, &len); - stream_write_uint32(output, 17 + len); /* Length */ - stream_check_size(output, 17 + len); + length = freerdp_AsciiToUnicodeAlloc(volumeLabel, &outStr, 0) * 2; + stream_write_uint32(output, 17 + length); /* Length */ + stream_check_size(output, 17 + length); stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* VolumeCreationTime */ stream_write_uint32(output, svfst.f_fsid); /* VolumeSerialNumber */ - stream_write_uint32(output, len); /* VolumeLabelLength */ + stream_write_uint32(output, length); /* VolumeLabelLength */ stream_write_uint8(output, 0); /* SupportsObjects */ /* Reserved(1), MUST NOT be added! */ - stream_write(output, outStr, len); /* VolumeLabel (Unicode) */ + stream_write(output, outStr, length); /* VolumeLabel (Unicode) */ xfree(outStr); break; @@ -423,17 +423,16 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir case FileFsAttributeInformation: /* http://msdn.microsoft.com/en-us/library/cc232101.aspx */ - outStr = freerdp_uniconv_out(diskType, &len); - - stream_write_uint32(output, 12 + len); /* Length */ - stream_check_size(output, 12 + len); + length = freerdp_AsciiToUnicodeAlloc(diskType, &outStr, 0) * 2; + stream_write_uint32(output, 12 + length); /* Length */ + stream_check_size(output, 12 + length); stream_write_uint32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK); /* FileSystemAttributes */ stream_write_uint32(output, svfst.f_namemax/*510*/); /* MaximumComponentNameLength */ - stream_write_uint32(output, len); /* FileSystemNameLength */ - stream_write(output, outStr, len); /* FileSystemName (Unicode) */ + stream_write_uint32(output, length); /* FileSystemNameLength */ + stream_write(output, outStr, length); /* FileSystemName (Unicode) */ xfree(outStr); break; @@ -652,7 +651,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { char* name; char* path; - int i, len; + int i, length; DISK_DEVICE* disk; name = (char*) pEntryPoints->plugin_data->data[1]; @@ -667,10 +666,10 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) disk->device.IRPRequest = disk_irp_request; disk->device.Free = disk_free; - len = strlen(name); - disk->device.data = stream_new(len + 1); + length = strlen(name); + disk->device.data = stream_new(length + 1); - for (i = 0; i <= len; i++) + for (i = 0; i <= length; i++) stream_write_uint8(disk->device.data, name[i] < 0 ? '_' : name[i]); disk->path = path; diff --git a/channels/rdpdr/client/printer/printer_main.c b/channels/rdpdr/client/printer/printer_main.c index 25b5e35f1..a4db9377b 100644 --- a/channels/rdpdr/client/printer/printer_main.c +++ b/channels/rdpdr/client/printer/printer_main.c @@ -232,10 +232,10 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri { char* port; uint32 Flags; - size_t DriverNameLen; - char* DriverName; - size_t PrintNameLen; - char* PrintName; + int DriverNameLen; + WCHAR* DriverName; + int PrintNameLen; + WCHAR* PrintName; uint32 CachedFieldsLen; uint8* CachedPrinterConfigData; PRINTER_DEVICE* printer_dev; @@ -258,11 +258,12 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri DEBUG_SVC("Printer %s registered", printer->name); Flags = 0; + if (printer->is_default) Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER; - DriverName = freerdp_uniconv_out(printer->driver, &DriverNameLen); - PrintName = freerdp_uniconv_out(printer->name, &PrintNameLen); + DriverNameLen = freerdp_AsciiToUnicodeAlloc(printer->driver, &DriverName, 0) * 2; + PrintNameLen = freerdp_AsciiToUnicodeAlloc(printer->name, &PrintName, 0) * 2; printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen); @@ -276,6 +277,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri stream_write_uint16(printer_dev->device.data, 0); stream_write(printer_dev->device.data, PrintName, PrintNameLen); stream_write_uint16(printer_dev->device.data, 0); + if (CachedFieldsLen > 0) { stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 390d254a5..bb5939b85 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -94,14 +94,15 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) { - char* s; STREAM* data_out; + WCHAR* computerNameW; size_t computerNameLenW; if (!rdpdr->computerName[0]) gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1); - s = freerdp_uniconv_out(rdpdr->computerName, &computerNameLenW); + computerNameLenW = freerdp_AsciiToUnicodeAlloc(rdpdr->computerName, &computerNameW, 0) * 2; + data_out = stream_new(16 + computerNameLenW + 2); stream_write_uint16(data_out, RDPDR_CTYP_CORE); @@ -110,10 +111,10 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) stream_write_uint32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */ stream_write_uint32(data_out, 0); /* codePage, must be set to zero */ stream_write_uint32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */ - stream_write(data_out, s, computerNameLenW); + stream_write(data_out, computerNameW, computerNameLenW); stream_write_uint16(data_out, 0); /* null terminator */ - xfree(s); + xfree(computerNameW); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 55bc4291d..6ada96f32 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -527,19 +527,17 @@ static uint8* xf_cliprdr_process_requested_raw(uint8* data, int* size) static uint8* xf_cliprdr_process_requested_unicodetext(uint8* data, int* size) { - uint8* inbuf; - uint8* outbuf; - size_t out_size; - - inbuf = lf2crlf(data, size); - - outbuf = (uint8*) freerdp_uniconv_out((char*) inbuf, &out_size); + char* inbuf; + WCHAR* outbuf; + int out_size; + inbuf = (char*) lf2crlf(data, size); + out_size = freerdp_AsciiToUnicodeAlloc(inbuf, &outbuf, 0); xfree(inbuf); - *size = (int) out_size + 2; + *size = (int) ((out_size + 1) * 2); - return outbuf; + return (uint8*) outbuf; } static uint8* xf_cliprdr_process_requested_text(uint8* data, int* size) diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index c43dadbca..732f58444 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -25,7 +25,6 @@ #include FREERDP_API char* freerdp_uniconv_in(unsigned char* pin, size_t in_len); -FREERDP_API char* freerdp_uniconv_out(const char *str, size_t *pout_len); #include diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 3c6d732a3..bfa0c25f2 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -612,7 +612,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block } /* - * If we are in server mode, accepth client's color depth only if + * If we are in server mode, accept client's color depth only if * it is smaller than ours. This is what Windows server does. */ if (color_depth < settings->color_depth || !settings->server_mode) @@ -631,20 +631,21 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) { uint32 version; - char* clientName; - size_t clientNameLength; + WCHAR* clientName; + int clientNameLength; uint8 connectionType; uint16 highColorDepth; uint16 supportedColorDepths; uint16 earlyCapabilityFlags; - char* clientDigProductId; - size_t clientDigProductIdLength; + WCHAR* clientDigProductId; + int clientDigProductIdLength; gcc_write_user_data_header(s, CS_CORE, 216); version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4; - clientName = freerdp_uniconv_out(settings->client_hostname, &clientNameLength); - clientDigProductId = freerdp_uniconv_out(settings->client_product_id, &clientDigProductIdLength); + + clientNameLength = freerdp_AsciiToUnicodeAlloc(settings->client_hostname, &clientName, 0); + clientDigProductIdLength = freerdp_AsciiToUnicodeAlloc(settings->client_product_id, &clientDigProductId, 0); stream_write_uint32(s, version); /* version */ stream_write_uint16(s, settings->width); /* desktopWidth */ @@ -655,14 +656,15 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) stream_write_uint32(s, settings->client_build); /* clientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ - if (clientNameLength > 30) + + if (clientNameLength > 15) { - clientNameLength = 30; + clientNameLength = 15; clientName[clientNameLength] = 0; - clientName[clientNameLength + 1] = 0; } - stream_write(s, clientName, clientNameLength + 2); - stream_write_zero(s, 32 - clientNameLength - 2); + + stream_write(s, clientName, ((clientNameLength + 1) * 2)); + stream_write_zero(s, 32 - ((clientNameLength + 1) * 2)); xfree(clientName); stream_write_uint32(s, settings->kbd_type); /* keyboardType */ diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 8f5ac3a23..e0598397b 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -158,23 +158,20 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings) void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings) { - size_t length; - uint16 clientAddressFamily; - uint8* clientAddress; - uint16 cbClientAddress; - uint8* clientDir; - uint16 cbClientDir; - uint16 cbAutoReconnectLen; + int clientAddressFamily; + WCHAR* clientAddress; + int cbClientAddress; + WCHAR* clientDir; + int cbClientDir; + int cbAutoReconnectLen; clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET; - clientAddress = (uint8*) freerdp_uniconv_out(settings->ip_address, &length); - cbClientAddress = length; + cbClientAddress = freerdp_AsciiToUnicodeAlloc(settings->ip_address, &clientAddress, 0) * 2; - clientDir = (uint8*) freerdp_uniconv_out(settings->client_dir, &length); - cbClientDir = length; + cbClientDir = freerdp_AsciiToUnicodeAlloc(settings->client_dir, &clientDir, 0) * 2; - cbAutoReconnectLen = settings->client_auto_reconnect_cookie->cbLen; + cbAutoReconnectLen = (int) settings->client_auto_reconnect_cookie->cbLen; stream_write_uint16(s, clientAddressFamily); /* clientAddressFamily */ @@ -297,18 +294,17 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) void rdp_write_info_packet(STREAM* s, rdpSettings* settings) { - size_t length; uint32 flags; - uint8* domain; - uint16 cbDomain; - uint8* userName; - uint16 cbUserName; - uint8* password; - uint16 cbPassword; - uint8* alternateShell; - uint16 cbAlternateShell; - uint8* workingDir; - uint16 cbWorkingDir; + WCHAR* domain; + int cbDomain; + WCHAR* userName; + int cbUserName; + WCHAR* password; + int cbPassword; + WCHAR* alternateShell; + int cbAlternateShell; + WCHAR* workingDir; + int cbWorkingDir; boolean usedPasswordCookie = false; flags = INFO_MOUSE | @@ -337,29 +333,32 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) if (settings->compression) flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_RDP6; - domain = (uint8*) freerdp_uniconv_out(settings->domain, &length); - cbDomain = length; + if (settings->domain) + { + cbDomain = freerdp_AsciiToUnicodeAlloc(settings->domain, &domain, 0) * 2; + } + else + { + domain = NULL; + cbDomain = 0; + } - userName = (uint8*) freerdp_uniconv_out(settings->username, &length); - cbUserName = length; + cbUserName = freerdp_AsciiToUnicodeAlloc(settings->username, &userName, 0) * 2; if (settings->password_cookie && settings->password_cookie->length > 0) { usedPasswordCookie = true; - password = (uint8*)settings->password_cookie->data; + password = (WCHAR*) settings->password_cookie->data; cbPassword = settings->password_cookie->length - 2; /* Strip double zero termination */ } else { - password = (uint8*) freerdp_uniconv_out(settings->password, &length); - cbPassword = length; + cbPassword = freerdp_AsciiToUnicodeAlloc(settings->password, &password, 0) * 2; } - alternateShell = (uint8*) freerdp_uniconv_out(settings->shell, &length); - cbAlternateShell = length; + cbAlternateShell = freerdp_AsciiToUnicodeAlloc(settings->shell, &alternateShell, 0) * 2; - workingDir = (uint8*) freerdp_uniconv_out(settings->directory, &length); - cbWorkingDir = length; + cbWorkingDir = freerdp_AsciiToUnicodeAlloc(settings->directory, &workingDir, 0) * 2; stream_write_uint32(s, 0); /* CodePage */ stream_write_uint32(s, flags); /* flags */ diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 502d7e7e0..0f3201355 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -235,8 +235,8 @@ boolean nego_send_preconnection_pdu(rdpNego* nego) { STREAM* s; uint32 cbSize; - uint16 cchPCB_times2 = 0; - char* wszPCB = NULL; + uint16 cchPCB = 0; + WCHAR* wszPCB = NULL; if (!nego->send_preconnection_pdu) return true; @@ -251,11 +251,9 @@ boolean nego_send_preconnection_pdu(rdpNego* nego) if (nego->preconnection_blob) { - size_t size; - wszPCB = freerdp_uniconv_out(nego->preconnection_blob, &size); - cchPCB_times2 = (uint16) size; - cchPCB_times2 += 2; /* zero-termination */ - cbSize += cchPCB_times2; + cchPCB = (uint16) freerdp_AsciiToUnicodeAlloc(nego->preconnection_blob, &wszPCB, 0); + cchPCB += 1; /* zero-termination */ + cbSize += cchPCB * 2; } s = transport_send_stream_init(nego->transport, cbSize); @@ -263,11 +261,11 @@ boolean nego_send_preconnection_pdu(rdpNego* nego) stream_write_uint32(s, 0); /* Flags */ stream_write_uint32(s, PRECONNECTION_PDU_V2); /* Version */ stream_write_uint32(s, nego->preconnection_id); /* Id */ - stream_write_uint16(s, cchPCB_times2 / 2); /* cchPCB */ + stream_write_uint16(s, cchPCB); /* cchPCB */ if (wszPCB) { - stream_write(s, wszPCB, cchPCB_times2); /* wszPCB */ + stream_write(s, wszPCB, cchPCB * 2); /* wszPCB */ xfree(wszPCB); } diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 3bccf9cde..0361ab69b 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -119,21 +119,17 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings) uint32 bias; sint32 sbias; uint32 bias2c; - size_t length; - uint8* standardName; - uint8* daylightName; - size_t standardNameLength; - size_t daylightNameLength; + WCHAR* standardName; + WCHAR* daylightName; + int standardNameLength; + int daylightNameLength; TIME_ZONE_INFO* clientTimeZone; clientTimeZone = settings->client_time_zone; freerdp_time_zone_detect(clientTimeZone); - standardName = (uint8*) freerdp_uniconv_out(clientTimeZone->standardName, &length); - standardNameLength = length; - - daylightName = (uint8*) freerdp_uniconv_out(clientTimeZone->daylightName, &length); - daylightNameLength = length; + standardNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->standardName, &standardName, 0) * 2; + daylightNameLength = freerdp_AsciiToUnicodeAlloc(clientTimeZone->daylightName, &daylightName, 0) * 2; if (standardNameLength > 62) standardNameLength = 62; @@ -161,6 +157,7 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings) stream_write_zero(s, 64 - standardNameLength); rdp_write_system_time(s, &clientTimeZone->standardDate); /* StandardDate */ + DEBUG_TIMEZONE("bias=%d stdName='%s' dlName='%s'", bias, clientTimeZone->standardName, clientTimeZone->daylightName); diff --git a/libfreerdp/core/tsg.c b/libfreerdp/core/tsg.c index 5a4f42529..f643f24ae 100644 --- a/libfreerdp/core/tsg.c +++ b/libfreerdp/core/tsg.c @@ -460,8 +460,8 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) STREAM* s_p4; int status = -1; rdpRpc* rpc = tsg->rpc; - uint8* dest_addr_unic; - uint32 dest_addr_unic_len; + WCHAR* dest_addr_unic; + int dest_addr_unic_len; if (!rpc_connect(rpc)) { @@ -571,7 +571,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) } status = -1; - dest_addr_unic = (uint8*) freerdp_uniconv_out(hostname, (size_t*) &dest_addr_unic_len); + dest_addr_unic_len = freerdp_AsciiToUnicodeAlloc(hostname, &dest_addr_unic, 0) * 2; memcpy(tsg_packet4 + 4, tsg->TunnelContext, 16); memcpy(tsg_packet4 + 38, &port, 2); diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c index 3ea8d16a8..123784f48 100644 --- a/libfreerdp/utils/unicode.c +++ b/libfreerdp/utils/unicode.c @@ -31,17 +31,6 @@ #include -char* freerdp_uniconv_out(const char *str, size_t* pout_len) -{ - WCHAR* wstr; - int length; - - length = freerdp_AsciiToUnicodeAlloc(str, &wstr, 0); - *pout_len = (size_t) length; - - return (char*) wstr; -} - int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) { if (!str) @@ -59,8 +48,6 @@ int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) (*wstr), length * sizeof(WCHAR)); (*wstr)[length] = 0; - length *= 2; - return length; } From 58e1fd325a2ae0f464be33acb1f5114f073c25e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 23 Sep 2012 20:11:50 -0400 Subject: [PATCH 24/64] libfreerdp-utils: get rid of freerdp_uniconv_in --- channels/cliprdr/client/cliprdr_format.c | 6 ++--- channels/rdpdr/client/disk/disk_file.c | 2 +- channels/rdpdr/client/disk/disk_main.c | 4 ++-- .../rdpdr/client/parallel/parallel_main.c | 2 +- channels/rdpdr/client/serial/serial_main.c | 2 +- client/X11/xf_cliprdr.c | 7 +++--- include/freerdp/utils/unicode.h | 2 -- libfreerdp/core/gcc.c | 5 ++-- libfreerdp/core/info.c | 24 +++++++++++++------ libfreerdp/core/timezone.c | 4 ++-- libfreerdp/rail/window.c | 4 ++-- libfreerdp/utils/string.c | 2 +- libfreerdp/utils/unicode.c | 10 -------- 13 files changed, 35 insertions(+), 39 deletions(-) diff --git a/channels/cliprdr/client/cliprdr_format.c b/channels/cliprdr/client/cliprdr_format.c index fa3af9cf5..1d9b2865b 100644 --- a/channels/cliprdr/client/cliprdr_format.c +++ b/channels/cliprdr/client/cliprdr_format.c @@ -143,8 +143,7 @@ void cliprdr_process_short_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint3 } else { - format_name->name = freerdp_uniconv_in(s->p, 32); - format_name->length = strlen(format_name->name); + format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) s->p, &format_name->name, 32 / 2); } stream_seek(s, 32); @@ -187,8 +186,7 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32 break; } - format_name->name = freerdp_uniconv_in(stream_get_tail(s), name_len); - format_name->length = strlen(format_name->name); + format_name->length = freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &format_name->name, name_len / 2); stream_seek(s, name_len + 2); } } diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index aabb6b657..a8a02a8ad 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -487,7 +487,7 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui stream_seek_uint8(input); /* RootDirectory */ stream_read_uint32(input, FileNameLength); - s = freerdp_uniconv_in(stream_get_tail(input), FileNameLength); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(input), &s, FileNameLength / 2); fullpath = disk_file_combine_fullpath(file->basepath, s); xfree(s); diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index 24137d8d4..a6203ecce 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -133,7 +133,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp) stream_read_uint32(irp->input, CreateOptions); stream_read_uint32(irp->input, PathLength); - path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2); FileId = irp->devman->id_sequence++; @@ -478,7 +478,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp) stream_read_uint32(irp->input, PathLength); stream_seek(irp->input, 23); /* Padding */ - path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2); file = disk_get_file_by_id(disk, irp->FileId); diff --git a/channels/rdpdr/client/parallel/parallel_main.c b/channels/rdpdr/client/parallel/parallel_main.c index 0d09287d5..aa73bd5b1 100644 --- a/channels/rdpdr/client/parallel/parallel_main.c +++ b/channels/rdpdr/client/parallel/parallel_main.c @@ -79,7 +79,7 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_uint32(irp->input, PathLength); - path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2); parallel->id = irp->devman->id_sequence++; parallel->file = open(parallel->path, O_RDWR); diff --git a/channels/rdpdr/client/serial/serial_main.c b/channels/rdpdr/client/serial/serial_main.c index dc71b9324..1a0b069eb 100644 --- a/channels/rdpdr/client/serial/serial_main.c +++ b/channels/rdpdr/client/serial/serial_main.c @@ -88,7 +88,7 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp) /* SharedAccess(4) CreateDisposition(4), CreateOptions(4) */ stream_read_uint32(irp->input, PathLength); - path = freerdp_uniconv_in(stream_get_tail(irp->input), PathLength); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2); FileId = irp->devman->id_sequence++; diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 6ada96f32..01a9aa844 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -569,7 +569,7 @@ static uint8* xf_cliprdr_process_requested_dib(uint8* data, int* size) static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size) { - uint8* inbuf; + char* inbuf; uint8* in; uint8* outbuf; char num[11]; @@ -585,7 +585,7 @@ static uint8* xf_cliprdr_process_requested_html(uint8* data, int* size) if ((uint8) data[0] == 0xFF && (uint8) data[1] == 0xFE) { - inbuf = (uint8*) freerdp_uniconv_in(data + 2, *size - 2); + freerdp_UnicodeToAsciiAlloc((WCHAR*) (data + 2), &inbuf, (*size - 2) / 2); } } @@ -878,8 +878,7 @@ static void xf_cliprdr_process_text(clipboardContext* cb, uint8* data, int size) static void xf_cliprdr_process_unicodetext(clipboardContext* cb, uint8* data, int size) { - cb->data = (uint8*) freerdp_uniconv_in(data, size); - cb->data_length = strlen((char*) cb->data); + cb->data_length = freerdp_UnicodeToAsciiAlloc((WCHAR*) data, (CHAR**) &(cb->data), size / 2); crlf2lf(cb->data, &cb->data_length); } diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index 732f58444..81cece1f5 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -24,8 +24,6 @@ #include #include -FREERDP_API char* freerdp_uniconv_in(unsigned char* pin, size_t in_len); - #include FREERDP_API int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length); diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index bfa0c25f2..8e38d3b1a 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -491,7 +491,7 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block stream_read_uint32(s, settings->client_build); /* clientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ - str = freerdp_uniconv_in(stream_get_tail(s), 32); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 32 / 2); stream_seek(s, 32); snprintf(settings->client_hostname, 31, "%s", str); settings->client_hostname[31] = 0; @@ -546,7 +546,8 @@ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 block if (blockLength < 64) break; - str = freerdp_uniconv_in(stream_get_tail(s), 64); + + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2); stream_seek(s, 64); snprintf(settings->client_product_id, 32, "%s", str); xfree(str); diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index e0598397b..15e5decee 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -119,17 +119,22 @@ boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings) stream_read_uint16(s, cbClientAddress); /* cbClientAddress */ settings->ipv6 = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? true : false); + if (stream_get_left(s) < cbClientAddress) return false; - settings->ip_address = freerdp_uniconv_in(stream_get_tail(s), cbClientAddress); + + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->ip_address, cbClientAddress / 2); stream_seek(s, cbClientAddress); stream_read_uint16(s, cbClientDir); /* cbClientDir */ + if (stream_get_left(s) < cbClientDir) return false; + if (settings->client_dir) xfree(settings->client_dir); - settings->client_dir = freerdp_uniconv_in(stream_get_tail(s), cbClientDir); + + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->client_dir, cbClientDir / 2); stream_seek(s, cbClientDir); if (!rdp_read_client_time_zone(s, settings)) @@ -236,45 +241,50 @@ boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings) if (stream_get_left(s) < cbDomain + 2) return false; + if (cbDomain > 0) { - settings->domain = freerdp_uniconv_in(stream_get_tail(s), cbDomain); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->domain, cbDomain / 2); stream_seek(s, cbDomain); } stream_seek(s, 2); if (stream_get_left(s) < cbUserName + 2) return false; + if (cbUserName > 0) { - settings->username = freerdp_uniconv_in(stream_get_tail(s), cbUserName); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->username, cbUserName / 2); stream_seek(s, cbUserName); } stream_seek(s, 2); if (stream_get_left(s) < cbPassword + 2) return false; + if (cbPassword > 0) { - settings->password = freerdp_uniconv_in(stream_get_tail(s), cbPassword); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->password, cbPassword / 2); stream_seek(s, cbPassword); } stream_seek(s, 2); if (stream_get_left(s) < cbAlternateShell + 2) return false; + if (cbAlternateShell > 0) { - settings->shell = freerdp_uniconv_in(stream_get_tail(s), cbAlternateShell); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->shell, cbAlternateShell / 2); stream_seek(s, cbAlternateShell); } stream_seek(s, 2); if (stream_get_left(s) < cbWorkingDir + 2) return false; + if (cbWorkingDir > 0) { - settings->directory = freerdp_uniconv_in(stream_get_tail(s), cbWorkingDir); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &settings->directory, cbWorkingDir / 2); stream_seek(s, cbWorkingDir); } stream_seek(s, 2); diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index 0361ab69b..f9f86916f 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -87,7 +87,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings) stream_read_uint32(s, clientTimeZone->bias); /* Bias */ /* standardName (64 bytes) */ - str = freerdp_uniconv_in(stream_get_tail(s), 64); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2); stream_seek(s, 64); strncpy(clientTimeZone->standardName, str, sizeof(clientTimeZone->standardName)); xfree(str); @@ -96,7 +96,7 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings) stream_read_uint32(s, clientTimeZone->standardBias); /* StandardBias */ /* daylightName (64 bytes) */ - str = freerdp_uniconv_in(stream_get_tail(s), 64); + freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(s), &str, 64 / 2); stream_seek(s, 64); strncpy(clientTimeZone->daylightName, str, sizeof(clientTimeZone->daylightName)); xfree(str); diff --git a/libfreerdp/rail/window.c b/libfreerdp/rail/window.c index 3cccb393f..5fae5aa7f 100644 --- a/libfreerdp/rail/window.c +++ b/libfreerdp/rail/window.c @@ -285,7 +285,7 @@ void rail_CreateWindow(rdpRail* rail, rdpWindow* window) { if (window->titleInfo.length > 0) { - window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length); + freerdp_UnicodeToAsciiAlloc((WCHAR*) window->titleInfo.string, &window->title, window->titleInfo.length / 2); } else { @@ -327,7 +327,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window) if (window->title != NULL) xfree(window->title); - window->title = freerdp_uniconv_in(window->titleInfo.string, window->titleInfo.length); + freerdp_UnicodeToAsciiAlloc((WCHAR*) window->titleInfo.string, &window->title, window->titleInfo.length / 2); IFCALL(rail->rail_SetWindowText, rail, window); } diff --git a/libfreerdp/utils/string.c b/libfreerdp/utils/string.c index a1c3db452..a8229f006 100644 --- a/libfreerdp/utils/string.c +++ b/libfreerdp/utils/string.c @@ -31,7 +31,7 @@ void freerdp_string_read_length32(STREAM* s, rdpString* string) stream_read_uint32(s, string->length); string->unicode = (char*) xmalloc(string->length); stream_read(s, string->unicode, string->length); - string->ascii = freerdp_uniconv_in((uint8*) string->unicode, string->length); + freerdp_UnicodeToAsciiAlloc((WCHAR*) string->unicode, &string->ascii, string->length / 2); } void freerdp_string_free(rdpString* string) diff --git a/libfreerdp/utils/unicode.c b/libfreerdp/utils/unicode.c index 123784f48..027150b1c 100644 --- a/libfreerdp/utils/unicode.c +++ b/libfreerdp/utils/unicode.c @@ -51,16 +51,6 @@ int freerdp_AsciiToUnicodeAlloc(const CHAR* str, WCHAR** wstr, int length) return length; } -char* freerdp_uniconv_in(unsigned char* pin, size_t in_len) -{ - CHAR* str; - int length; - - length = freerdp_UnicodeToAsciiAlloc((WCHAR*) pin, &str, (int) (in_len / 2)); - - return (char*) str; -} - int freerdp_UnicodeToAsciiAlloc(const WCHAR* wstr, CHAR** str, int length) { *str = malloc((length * 2) + 1); From 6dcc8e73eed6a5353e1bccbe6c5ff18416b40ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 24 Sep 2012 04:40:32 -0400 Subject: [PATCH 25/64] libfreerdp-utils: get rid of rdpBlob --- include/freerdp/codec/bitmap.h | 1 + include/freerdp/codec/mppc_dec.h | 21 ++++----- include/freerdp/codec/mppc_enc.h | 1 + include/freerdp/crypto/certificate.h | 1 - include/freerdp/crypto/crypto.h | 3 +- include/freerdp/crypto/tls.h | 3 +- include/freerdp/settings.h | 57 +++++++++++++----------- include/freerdp/utils/blob.h | 37 ---------------- libfreerdp/codec/mppc_dec.c | 2 + libfreerdp/codec/mppc_enc.c | 6 ++- libfreerdp/core/certificate.c | 64 +++++++++++++++++---------- libfreerdp/core/certificate.h | 1 - libfreerdp/core/connection.c | 32 +++++++++----- libfreerdp/core/gcc.c | 34 +++++++------- libfreerdp/core/info.c | 6 +-- libfreerdp/core/nego.c | 14 +++--- libfreerdp/core/nego.h | 7 +-- libfreerdp/core/redirection.c | 25 ++++++----- libfreerdp/core/redirection.h | 7 +-- libfreerdp/core/security.c | 9 ++-- libfreerdp/core/settings.c | 4 -- libfreerdp/crypto/crypto.c | 14 +++--- libfreerdp/crypto/nla.c | 8 ++-- libfreerdp/crypto/tls.c | 9 ++-- libfreerdp/locale/keyboard_xkbfile.c | 2 + libfreerdp/locale/timezone.c | 1 + libfreerdp/locale/virtual_key_codes.c | 4 ++ libfreerdp/locale/xkb_layout_ids.c | 2 + libfreerdp/utils/CMakeLists.txt | 1 - libfreerdp/utils/blob.c | 57 ------------------------ libfreerdp/utils/time.c | 3 ++ 31 files changed, 201 insertions(+), 235 deletions(-) delete mode 100644 include/freerdp/utils/blob.h delete mode 100644 libfreerdp/utils/blob.c diff --git a/include/freerdp/codec/bitmap.h b/include/freerdp/codec/bitmap.h index b440eaf60..d09c495bc 100644 --- a/include/freerdp/codec/bitmap.h +++ b/include/freerdp/codec/bitmap.h @@ -20,6 +20,7 @@ #ifndef __BITMAP_H #define __BITMAP_H +#include #include FREERDP_API boolean bitmap_decompress(uint8* srcData, uint8* dstData, int width, int height, int size, int srcBpp, int dstBpp); diff --git a/include/freerdp/codec/mppc_dec.h b/include/freerdp/codec/mppc_dec.h index 55b7d6a74..14fae4be6 100644 --- a/include/freerdp/codec/mppc_dec.h +++ b/include/freerdp/codec/mppc_dec.h @@ -21,20 +21,21 @@ #ifndef __MPPC_H #define __MPPC_H +#include #include /* Compression Types */ -#define PACKET_COMPRESSED 0x20 -#define PACKET_AT_FRONT 0x40 -#define PACKET_FLUSHED 0x80 -#define PACKET_COMPR_TYPE_8K 0x00 -#define PACKET_COMPR_TYPE_64K 0x01 -#define PACKET_COMPR_TYPE_RDP6 0x02 -#define PACKET_COMPR_TYPE_RDP61 0x03 -#define CompressionTypeMask 0x0F +#define PACKET_COMPRESSED 0x20 +#define PACKET_AT_FRONT 0x40 +#define PACKET_FLUSHED 0x80 +#define PACKET_COMPR_TYPE_8K 0x00 +#define PACKET_COMPR_TYPE_64K 0x01 +#define PACKET_COMPR_TYPE_RDP6 0x02 +#define PACKET_COMPR_TYPE_RDP61 0x03 +#define CompressionTypeMask 0x0F -#define RDP6_HISTORY_BUF_SIZE 65536 -#define RDP6_OFFSET_CACHE_SIZE 8 +#define RDP6_HISTORY_BUF_SIZE 65536 +#define RDP6_OFFSET_CACHE_SIZE 8 struct rdp_mppc_dec { diff --git a/include/freerdp/codec/mppc_enc.h b/include/freerdp/codec/mppc_enc.h index 1160b3dbd..e0014c010 100644 --- a/include/freerdp/codec/mppc_enc.h +++ b/include/freerdp/codec/mppc_enc.h @@ -21,6 +21,7 @@ #ifndef __MPPC_ENC_H #define __MPPC_ENC_H +#include #include #define PROTO_RDP_40 1 diff --git a/include/freerdp/crypto/certificate.h b/include/freerdp/crypto/certificate.h index 9038ac87d..117179359 100644 --- a/include/freerdp/crypto/certificate.h +++ b/include/freerdp/crypto/certificate.h @@ -28,7 +28,6 @@ typedef struct rdp_certificate_store rdpCertificateStore; #include #include -#include #include #include diff --git a/include/freerdp/crypto/crypto.h b/include/freerdp/crypto/crypto.h index e3baa6079..e57431f77 100644 --- a/include/freerdp/crypto/crypto.h +++ b/include/freerdp/crypto/crypto.h @@ -44,7 +44,6 @@ #include #include -#include #include struct crypto_sha1_struct @@ -128,7 +127,7 @@ FREERDP_API void crypto_cert_free(CryptoCert cert); FREERDP_API boolean x509_verify_certificate(CryptoCert cert, char* certificate_store_path); FREERDP_API rdpCertificateData* crypto_get_certificate_data(X509* xcert, char* hostname); -FREERDP_API boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key); +FREERDP_API boolean crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* PublicKeyLength); #define TSSK_KEY_LENGTH 64 extern const uint8 tssk_modulus[]; diff --git a/include/freerdp/crypto/tls.h b/include/freerdp/crypto/tls.h index f0b2e8905..c271202e2 100644 --- a/include/freerdp/crypto/tls.h +++ b/include/freerdp/crypto/tls.h @@ -37,7 +37,8 @@ struct rdp_tls SSL* ssl; int sockfd; SSL_CTX* ctx; - rdpBlob public_key; + BYTE* PublicKey; + DWORD PublicKeyLength; rdpSettings* settings; rdpCertificateStore* certificate_store; }; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index f4afb7bcb..2baffa7b8 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -21,7 +21,6 @@ #define __RDP_SETTINGS_H #include -#include /* Performance Flags */ #define PERF_FLAG_NONE 0x00000000 @@ -159,7 +158,8 @@ typedef struct rdp_X509CertChain rdpX509CertChain; struct rdp_CertInfo { - rdpBlob modulus; + BYTE* Modulus; + DWORD ModulusLength; uint8 exponent[4]; }; typedef struct rdp_CertInfo rdpCertInfo; @@ -173,8 +173,10 @@ typedef struct rdp_certificate rdpCertificate; struct rdp_key { - rdpBlob modulus; - rdpBlob private_exponent; + BYTE* Modulus; + DWORD ModulusLength; + BYTE* PrivateExponent; + DWORD PrivateExponentLength; uint8 exponent[4]; }; typedef struct rdp_key rdpKey; @@ -285,20 +287,21 @@ struct rdp_settings ALIGN64 boolean autologon; /* 58 */ ALIGN64 boolean compression; /* 59 */ ALIGN64 uint32 performance_flags; /* 60 */ - ALIGN64 rdpBlob* password_cookie; /* 61 */ - ALIGN64 char* kerberos_kdc; /* 62 */ - ALIGN64 char* kerberos_realm; /* 63 */ - ALIGN64 boolean ts_gateway; /* 64 */ - ALIGN64 char* tsg_hostname; /* 65 */ - ALIGN64 char* tsg_username; /* 66 */ - ALIGN64 char* tsg_password; /* 67 */ - ALIGN64 boolean local; /* 68 */ - ALIGN64 boolean authentication_only; /* 69 */ - ALIGN64 boolean from_stdin; /* 70 */ - ALIGN64 boolean send_preconnection_pdu; /* 71 */ - ALIGN64 uint32 preconnection_id; /* 72 */ - ALIGN64 char* preconnection_blob; /* 73 */ - uint64 paddingC[80 - 74]; /* 74 */ + ALIGN64 BYTE* password_cookie; /* 61 */ + ALIGN64 DWORD password_cookie_length; /* 62 */ + ALIGN64 char* kerberos_kdc; /* 63 */ + ALIGN64 char* kerberos_realm; /* 64 */ + ALIGN64 boolean ts_gateway; /* 65 */ + ALIGN64 char* tsg_hostname; /* 66 */ + ALIGN64 char* tsg_username; /* 67 */ + ALIGN64 char* tsg_password; /* 68 */ + ALIGN64 boolean local; /* 69 */ + ALIGN64 boolean authentication_only; /* 70 */ + ALIGN64 boolean from_stdin; /* 71 */ + ALIGN64 boolean send_preconnection_pdu; /* 72 */ + ALIGN64 uint32 preconnection_id; /* 73 */ + ALIGN64 char* preconnection_blob; /* 74 */ + uint64 paddingC[80 - 75]; /* 75 */ /* User Interface Parameters */ ALIGN64 boolean sw_gdi; /* 80 */ @@ -382,14 +385,16 @@ struct rdp_settings ALIGN64 char* privatekey_file; /* 249 */ ALIGN64 char* client_hostname; /* 250 */ ALIGN64 char* client_product_id; /* 251 */ - ALIGN64 rdpBlob* server_random; /* 252 */ - ALIGN64 rdpBlob* server_certificate; /* 253 */ - ALIGN64 boolean ignore_certificate; /* 254 */ - ALIGN64 rdpCertificate* server_cert; /* 255 */ - ALIGN64 char* rdp_key_file; /* 256 */ - ALIGN64 rdpKey* server_key; /* 257 */ - ALIGN64 char* certificate_name; /* 258 */ - uint64 paddingL[280 - 259]; /* 259 */ + ALIGN64 BYTE* server_random; /* 252 */ + ALIGN64 DWORD server_random_length; /* 253 */ + ALIGN64 BYTE* server_certificate; /* 254 */ + ALIGN64 DWORD server_certificate_length; /* 255 */ + ALIGN64 boolean ignore_certificate; /* 256 */ + ALIGN64 rdpCertificate* server_cert; /* 257 */ + ALIGN64 char* rdp_key_file; /* 258 */ + ALIGN64 rdpKey* server_key; /* 259 */ + ALIGN64 char* certificate_name; /* 260 */ + uint64 paddingL[280 - 261]; /* 261 */ /* Codecs */ ALIGN64 boolean rfx_codec; /* 280 */ diff --git a/include/freerdp/utils/blob.h b/include/freerdp/utils/blob.h deleted file mode 100644 index 6c5f46acb..000000000 --- a/include/freerdp/utils/blob.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * BLOB Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __BLOB_UTILS_H -#define __BLOB_UTILS_H - -#include -#include - -struct rdp_blob -{ - void* data; - int length; -}; -typedef struct rdp_blob rdpBlob; - -FREERDP_API void freerdp_blob_alloc(rdpBlob* blob, int length); -FREERDP_API void freerdp_blob_free(rdpBlob* blob); -FREERDP_API void freerdp_blob_copy(rdpBlob* dstblob, rdpBlob* srcblob); - -#endif /* __BLOB_UTILS_H */ diff --git a/libfreerdp/codec/mppc_dec.c b/libfreerdp/codec/mppc_dec.c index 7a4d8d8a4..b1d378b77 100644 --- a/libfreerdp/codec/mppc_dec.c +++ b/libfreerdp/codec/mppc_dec.c @@ -23,6 +23,8 @@ #endif #include +#include +#include #include diff --git a/libfreerdp/codec/mppc_enc.c b/libfreerdp/codec/mppc_enc.c index 3efe88abe..b8264fb83 100644 --- a/libfreerdp/codec/mppc_enc.c +++ b/libfreerdp/codec/mppc_enc.c @@ -22,9 +22,13 @@ #include "config.h" #endif +#include +#include +#include + +#include #include #include -#include #define MPPC_ENC_DEBUG 0 diff --git a/libfreerdp/core/certificate.c b/libfreerdp/core/certificate.c index 75cf1088a..1f28616ff 100644 --- a/libfreerdp/core/certificate.c +++ b/libfreerdp/core/certificate.c @@ -195,12 +195,13 @@ void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info) } while (padding == 0); - freerdp_blob_alloc(&info->modulus, modulus_length); - stream_read(s, info->modulus.data, modulus_length); + info->ModulusLength = modulus_length; + info->Modulus = (BYTE*) malloc(info->ModulusLength); + stream_read(s, info->Modulus, info->ModulusLength); ber_read_integer_length(s, &exponent_length); /* publicExponent (INTEGER) */ stream_read(s, &info->exponent[4 - exponent_length], exponent_length); - crypto_reverse(info->modulus.data, modulus_length); + crypto_reverse(info->Modulus, info->ModulusLength); crypto_reverse(info->exponent, 4); stream_detach(s); @@ -256,6 +257,7 @@ static boolean certificate_process_server_public_key(rdpCertificate* certificate uint32 modlen; stream_read(s, magic, 4); + if (memcmp(magic, "RSA1", 4) != 0) { printf("gcc_process_server_public_key: magic error\n"); @@ -267,8 +269,10 @@ static boolean certificate_process_server_public_key(rdpCertificate* certificate stream_read_uint32(s, datalen); stream_read(s, certificate->cert_info.exponent, 4); modlen = keylen - 8; - freerdp_blob_alloc(&(certificate->cert_info.modulus), modlen); - stream_read(s, certificate->cert_info.modulus.data, modlen); + + certificate->cert_info.ModulusLength = modlen; + certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength); + stream_read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength); /* 8 bytes of zero padding */ stream_seek(s, 8); @@ -277,11 +281,11 @@ static boolean certificate_process_server_public_key(rdpCertificate* certificate static boolean certificate_process_server_public_signature(rdpCertificate* certificate, uint8* sigdata, int sigdatalen, STREAM* s, uint32 siglen) { - uint8 md5hash[CRYPTO_MD5_DIGEST_LENGTH]; - uint8 encsig[TSSK_KEY_LENGTH + 8]; - uint8 sig[TSSK_KEY_LENGTH]; - CryptoMd5 md5ctx; int i, sum; + CryptoMd5 md5ctx; + uint8 sig[TSSK_KEY_LENGTH]; + uint8 encsig[TSSK_KEY_LENGTH + 8]; + uint8 md5hash[CRYPTO_MD5_DIGEST_LENGTH]; md5ctx = crypto_md5_init(); crypto_md5_update(md5ctx, sigdata, sigdatalen); @@ -351,36 +355,46 @@ boolean certificate_read_server_proprietary_certificate(rdpCertificate* certific sigdata = stream_get_tail(s) - 4; stream_read_uint32(s, dwSigAlgId); stream_read_uint32(s, dwKeyAlgId); + if (!(dwSigAlgId == SIGNATURE_ALG_RSA && dwKeyAlgId == KEY_EXCHANGE_ALG_RSA)) { printf("certificate_read_server_proprietary_certificate: parse error 1\n"); return false; } + stream_read_uint16(s, wPublicKeyBlobType); + if (wPublicKeyBlobType != BB_RSA_KEY_BLOB) { printf("certificate_read_server_proprietary_certificate: parse error 2\n"); return false; } + stream_read_uint16(s, wPublicKeyBlobLen); + if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen)) { printf("certificate_read_server_proprietary_certificate: parse error 3\n"); return false; } + sigdatalen = stream_get_tail(s) - sigdata; stream_read_uint16(s, wSignatureBlobType); + if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB) { printf("certificate_read_server_proprietary_certificate: parse error 4\n"); return false; } + stream_read_uint16(s, wSignatureBlobLen); + if (wSignatureBlobLen != 72) { printf("certificate_process_server_public_signature: invalid signature length (got %d, expected %d)\n", wSignatureBlobLen, 64); return false; } + if (!certificate_process_server_public_signature(certificate, sigdata, sigdatalen, s, wSignatureBlobLen)) { printf("certificate_read_server_proprietary_certificate: parse error 5\n"); @@ -423,8 +437,8 @@ boolean certificate_read_server_x509_certificate_chain(rdpCertificate* certifica rdpCertInfo cert_info; DEBUG_CERTIFICATE("License Server Certificate"); certificate_read_x509_certificate(&certificate->x509_cert_chain->array[i], &cert_info); - DEBUG_LICENSE("modulus length:%d", cert_info.modulus.length); - freerdp_blob_free(&cert_info.modulus); + DEBUG_LICENSE("modulus length:%d", cert_info.ModulusLength); + free(cert_info.Modulus); } else if (numCertBlobs - i == 1) { @@ -481,9 +495,9 @@ boolean certificate_read_server_certificate(rdpCertificate* certificate, uint8* rdpKey* key_new(const char* keyfile) { + FILE* fp; + RSA* rsa; rdpKey* key; - RSA *rsa; - FILE *fp; key = (rdpKey*) xzalloc(sizeof(rdpKey)); @@ -538,12 +552,16 @@ rdpKey* key_new(const char* keyfile) return NULL; } - freerdp_blob_alloc(&key->modulus, BN_num_bytes(rsa->n)); - BN_bn2bin(rsa->n, key->modulus.data); - crypto_reverse(key->modulus.data, key->modulus.length); - freerdp_blob_alloc(&key->private_exponent, BN_num_bytes(rsa->d)); - BN_bn2bin(rsa->d, key->private_exponent.data); - crypto_reverse(key->private_exponent.data, key->private_exponent.length); + key->ModulusLength = BN_num_bytes(rsa->n); + key->Modulus = (BYTE*) malloc(key->ModulusLength); + BN_bn2bin(rsa->n, key->Modulus); + crypto_reverse(key->Modulus, key->ModulusLength); + + key->PrivateExponentLength = BN_num_bytes(rsa->d); + key->PrivateExponent = (BYTE*) malloc(key->PrivateExponentLength); + BN_bn2bin(rsa->d, key->PrivateExponent); + crypto_reverse(key->PrivateExponent, key->PrivateExponentLength); + memset(key->exponent, 0, sizeof(key->exponent)); BN_bn2bin(rsa->e, key->exponent + sizeof(key->exponent) - BN_num_bytes(rsa->e)); crypto_reverse(key->exponent, sizeof(key->exponent)); @@ -557,8 +575,8 @@ void key_free(rdpKey* key) { if (key != NULL) { - freerdp_blob_free(&key->modulus); - freerdp_blob_free(&key->private_exponent); + free(key->Modulus); + free(key->PrivateExponent); xfree(key); } } @@ -594,8 +612,8 @@ void certificate_free(rdpCertificate* certificate) { certificate_free_x509_certificate_chain(certificate->x509_cert_chain); - if (certificate->cert_info.modulus.data != NULL) - freerdp_blob_free(&(certificate->cert_info.modulus)); + if (certificate->cert_info.Modulus != NULL) + free(certificate->cert_info.Modulus); xfree(certificate); } diff --git a/libfreerdp/core/certificate.h b/libfreerdp/core/certificate.h index fee06d972..8ebaa6eaf 100644 --- a/libfreerdp/core/certificate.h +++ b/libfreerdp/core/certificate.h @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 9db8db005..be17767a4 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -91,7 +91,8 @@ boolean rdp_client_connect(rdpRdp* rdp) if ((rdp->nego->selected_protocol & PROTOCOL_TLS) || (rdp->nego->selected_protocol == PROTOCOL_RDP)) { - if ((settings->username != NULL) && ((settings->password != NULL) || (settings->password_cookie != NULL && settings->password_cookie->length > 0))) + if ((settings->username != NULL) && ((settings->password != NULL) || + (settings->password_cookie != NULL && settings->password_cookie_length > 0))) settings->autologon = true; } @@ -143,9 +144,8 @@ boolean rdp_client_redirect(rdpRdp* rdp) license_free(rdp->license); transport_free(rdp->transport); - /* FIXME: this is a subset of settings_free */ - freerdp_blob_free(settings->server_random); - freerdp_blob_free(settings->server_certificate); + free(settings->server_random); + free(settings->server_certificate); xfree(settings->ip_address); rdp->transport = transport_new(settings); @@ -158,7 +158,7 @@ boolean rdp_client_redirect(rdpRdp* rdp) if (redirection->flags & LB_LOAD_BALANCE_INFO) { - nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo); + nego_set_routing_token(rdp->nego, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); } else { @@ -193,7 +193,8 @@ boolean rdp_client_redirect(rdpRdp* rdp) if (redirection->flags & LB_PASSWORD) { - settings->password_cookie = &redirection->password_cookie; + settings->password_cookie = redirection->PasswordCookie; + settings->password_cookie_length = redirection->PasswordCookieLength; } return rdp_client_connect(rdp); @@ -218,8 +219,8 @@ static boolean rdp_client_establish_keys(rdpRdp* rdp) /* encrypt client random */ memset(crypt_client_random, 0, sizeof(crypt_client_random)); crypto_nonce(client_random, sizeof(client_random)); - key_len = rdp->settings->server_cert->cert_info.modulus.length; - mod = rdp->settings->server_cert->cert_info.modulus.data; + key_len = rdp->settings->server_cert->cert_info.ModulusLength; + mod = rdp->settings->server_cert->cert_info.Modulus; exp = rdp->settings->server_cert->cert_info.exponent; crypto_rsa_public_encrypt(client_random, sizeof(client_random), key_len, mod, exp, crypt_client_random); @@ -264,7 +265,7 @@ static boolean rdp_client_establish_keys(rdpRdp* rdp) static boolean rdp_server_establish_keys(rdpRdp* rdp, STREAM* s) { - uint8 client_random[64]; /* Should be only 32 after successfull decryption, but on failure might take up to 64 bytes. */ + uint8 client_random[64]; /* Should be only 32 after successful decryption, but on failure might take up to 64 bytes. */ uint8 crypt_client_random[256 + 8]; uint32 rand_len, key_len; uint16 channel_id, length, sec_flags; @@ -282,25 +283,30 @@ static boolean rdp_server_establish_keys(rdpRdp* rdp, STREAM* s) printf("rdp_server_establish_keys: invalid RDP header\n"); return false; } + rdp_read_security_header(s, &sec_flags); + if ((sec_flags & SEC_EXCHANGE_PKT) == 0) { printf("rdp_server_establish_keys: missing SEC_EXCHANGE_PKT in security header\n"); return false; } + stream_read_uint32(s, rand_len); - key_len = rdp->settings->server_key->modulus.length; + key_len = rdp->settings->server_key->ModulusLength; + if (rand_len != key_len + 8) { printf("rdp_server_establish_keys: invalid encrypted client random length\n"); return false; } + memset(crypt_client_random, 0, sizeof(crypt_client_random)); stream_read(s, crypt_client_random, rand_len); /* 8 zero bytes of padding */ stream_seek(s, 8); - mod = rdp->settings->server_key->modulus.data; - priv_exp = rdp->settings->server_key->private_exponent.data; + mod = rdp->settings->server_key->Modulus; + priv_exp = rdp->settings->server_key->PrivateExponent; crypto_rsa_private_decrypt(crypt_client_random, rand_len - 8, key_len, mod, priv_exp, client_random); /* now calculate encrypt / decrypt and update keys */ @@ -336,8 +342,10 @@ boolean rdp_client_connect_mcs_connect_response(rdpRdp* rdp, STREAM* s) printf("rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed\n"); return false; } + if (!mcs_send_erect_domain_request(rdp->mcs)) return false; + if (!mcs_send_attach_user_request(rdp->mcs)) return false; diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 8e38d3b1a..3318e53f6 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -799,8 +799,6 @@ boolean gcc_read_server_security_data(STREAM* s, rdpSettings* settings) { uint8* data; uint32 length; - uint32 serverRandomLen; - uint32 serverCertLen; stream_read_uint32(s, settings->encryption_method); /* encryptionMethod */ stream_read_uint32(s, settings->encryption_level); /* encryptionLevel */ @@ -814,29 +812,30 @@ boolean gcc_read_server_security_data(STREAM* s, rdpSettings* settings) return true; } - stream_read_uint32(s, serverRandomLen); /* serverRandomLen */ - stream_read_uint32(s, serverCertLen); /* serverCertLen */ + stream_read_uint32(s, settings->server_random_length); /* serverRandomLen */ + stream_read_uint32(s, settings->server_certificate_length); /* serverCertLen */ - if (serverRandomLen > 0) + if (settings->server_random_length > 0) { /* serverRandom */ - freerdp_blob_alloc(settings->server_random, serverRandomLen); - stream_read(s, settings->server_random->data, serverRandomLen); + settings->server_random = (BYTE*) malloc(settings->server_random_length); + stream_read(s, settings->server_random, settings->server_random_length); } else { return false; } - if (serverCertLen > 0) + if (settings->server_certificate_length > 0) { /* serverCertificate */ - freerdp_blob_alloc(settings->server_certificate, serverCertLen); - stream_read(s, settings->server_certificate->data, serverCertLen); + settings->server_certificate = (BYTE*) malloc(settings->server_certificate_length); + stream_read(s, settings->server_certificate, settings->server_certificate_length); + certificate_free(settings->server_cert); settings->server_cert = certificate_new(); - data = settings->server_certificate->data; - length = settings->server_certificate->length; + data = settings->server_certificate; + length = settings->server_certificate_length; if (!certificate_read_server_certificate(settings->server_cert, data, length)) return false; @@ -936,7 +935,7 @@ void gcc_write_server_security_data(STREAM* s, rdpSettings* settings) { serverRandomLen = 32; - keyLen = settings->server_key->modulus.length; + keyLen = settings->server_key->ModulusLength; expLen = sizeof(settings->server_key->exponent); wPublicKeyBlobLen = 4; /* magic (RSA1) */ wPublicKeyBlobLen += 4; /* keylen */ @@ -977,9 +976,10 @@ void gcc_write_server_security_data(STREAM* s, rdpSettings* settings) stream_write_uint32(s, serverRandomLen); /* serverRandomLen */ stream_write_uint32(s, serverCertLen); /* serverCertLen */ - freerdp_blob_alloc(settings->server_random, serverRandomLen); - crypto_nonce(settings->server_random->data, serverRandomLen); - stream_write(s, settings->server_random->data, serverRandomLen); + settings->server_random_length = serverRandomLen; + settings->server_random = (BYTE*) malloc(serverRandomLen); + crypto_nonce(settings->server_random, serverRandomLen); + stream_write(s, settings->server_random, serverRandomLen); sigData = stream_get_tail(s); @@ -995,7 +995,7 @@ void gcc_write_server_security_data(STREAM* s, rdpSettings* settings) stream_write_uint32(s, keyLen - 1); /* datalen */ stream_write(s, settings->server_key->exponent, expLen); - stream_write(s, settings->server_key->modulus.data, keyLen); + stream_write(s, settings->server_key->Modulus, keyLen); stream_write_zero(s, 8); sigDataLen = stream_get_tail(s) - sigData; diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 15e5decee..8e50a1c34 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -355,11 +355,11 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) cbUserName = freerdp_AsciiToUnicodeAlloc(settings->username, &userName, 0) * 2; - if (settings->password_cookie && settings->password_cookie->length > 0) + if (settings->password_cookie && settings->password_cookie_length > 0) { usedPasswordCookie = true; - password = (WCHAR*) settings->password_cookie->data; - cbPassword = settings->password_cookie->length - 2; /* Strip double zero termination */ + password = (WCHAR*) settings->password_cookie; + cbPassword = settings->password_cookie_length - 2; /* Strip double zero termination */ } else { diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 0f3201355..6af15ad97 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -568,10 +568,10 @@ boolean nego_send_negotiation_request(rdpNego* nego) stream_get_mark(s, bm); stream_seek(s, length); - if (nego->routing_token != NULL) + if (nego->RoutingToken != NULL) { - stream_write(s, nego->routing_token->data, nego->routing_token->length); - length += nego->routing_token->length; + stream_write(s, nego->RoutingToken, nego->RoutingTokenLength); + length += nego->RoutingTokenLength; } else if (nego->cookie != NULL) { @@ -898,12 +898,14 @@ void nego_enable_nla(rdpNego* nego, boolean enable_nla) /** * Set routing token. * @param nego - * @param routing_token + * @param RoutingToken + * @param RoutingTokenLength */ -void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token) +void nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken, DWORD RoutingTokenLength) { - nego->routing_token = routing_token; + nego->RoutingToken = RoutingToken; + nego->RoutingTokenLength = RoutingTokenLength; } /** diff --git a/libfreerdp/core/nego.h b/libfreerdp/core/nego.h index cf30c94e9..8e4b665c0 100644 --- a/libfreerdp/core/nego.h +++ b/libfreerdp/core/nego.h @@ -23,7 +23,6 @@ #include "transport.h" #include #include -#include #include #include @@ -80,7 +79,8 @@ struct rdp_nego uint32 flags; char* hostname; char* cookie; - rdpBlob* routing_token; + BYTE* RoutingToken; + DWORD RoutingTokenLength; boolean send_preconnection_pdu; uint32 preconnection_id; char* preconnection_blob; @@ -119,13 +119,14 @@ boolean nego_send_negotiation_response(rdpNego* nego); rdpNego* nego_new(struct rdp_transport * transport); void nego_free(rdpNego* nego); + void nego_init(rdpNego* nego); void nego_set_target(rdpNego* nego, char* hostname, int port); void nego_set_negotiation_enabled(rdpNego* nego, boolean security_layer_negotiation_enabled); void nego_enable_rdp(rdpNego* nego, boolean enable_rdp); void nego_enable_nla(rdpNego* nego, boolean enable_nla); void nego_enable_tls(rdpNego* nego, boolean enable_tls); -void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token); +void nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken, DWORD RoutingTokenLength); void nego_set_cookie(rdpNego* nego, char* cookie); void nego_set_send_preconnection_pdu(rdpNego* nego, boolean send_pcpdu); void nego_set_preconnection_id(rdpNego* nego, uint32 id); diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 4b0561f15..78ff55230 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -84,10 +84,9 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) if (redirection->flags & LB_LOAD_BALANCE_INFO) { - uint32 loadBalanceInfoLength; - stream_read_uint32(s, loadBalanceInfoLength); - freerdp_blob_alloc(&redirection->loadBalanceInfo, loadBalanceInfoLength); - stream_read(s, redirection->loadBalanceInfo.data, loadBalanceInfoLength); + stream_read_uint32(s, redirection->LoadBalanceInfoLength); + redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength); + stream_read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); #ifdef WITH_DEBUG_REDIR DEBUG_REDIR("loadBalanceInfo:"); freerdp_hexdump(redirection->loadBalanceInfo.data, redirection->loadBalanceInfo.length); @@ -108,14 +107,14 @@ boolean rdp_recv_server_redirection_pdu(rdpRdp* rdp, STREAM* s) if (redirection->flags & LB_PASSWORD) { - uint32 passwordLength; - stream_read_uint32(s, passwordLength); /* Note: length (hopefully) includes double zero termination */ - freerdp_blob_alloc(&redirection->password_cookie, passwordLength); - stream_read(s, redirection->password_cookie.data, passwordLength); + /* Note: length (hopefully) includes double zero termination */ + stream_read_uint32(s, redirection->PasswordCookieLength); + redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength); + stream_read(s, redirection->PasswordCookie, redirection->PasswordCookieLength); #ifdef WITH_DEBUG_REDIR DEBUG_REDIR("password_cookie:"); - freerdp_hexdump(redirection->password_cookie.data, redirection->password_cookie.length); + freerdp_hexdump(redirection->PasswordCookie, redirection->PasswordCookieLength); #endif } @@ -200,11 +199,15 @@ void redirection_free(rdpRedirection* redirection) freerdp_string_free(&redirection->tsvUrl); freerdp_string_free(&redirection->username); freerdp_string_free(&redirection->domain); - freerdp_blob_free(&redirection->password_cookie); freerdp_string_free(&redirection->targetFQDN); freerdp_string_free(&redirection->targetNetBiosName); freerdp_string_free(&redirection->targetNetAddress); - freerdp_blob_free(&redirection->loadBalanceInfo); + + if (redirection->LoadBalanceInfo) + free(redirection->LoadBalanceInfo); + + if (redirection->PasswordCookie) + free(redirection->PasswordCookie); if (redirection->targetNetAddresses != NULL) { diff --git a/libfreerdp/core/redirection.h b/libfreerdp/core/redirection.h index efbb13d20..fe084fd76 100644 --- a/libfreerdp/core/redirection.h +++ b/libfreerdp/core/redirection.h @@ -23,7 +23,6 @@ #include "rdp.h" #include -#include #include #include #include @@ -50,9 +49,11 @@ struct rdp_redirection rdpString tsvUrl; rdpString username; rdpString domain; - rdpBlob password_cookie; + BYTE* PasswordCookie; + DWORD PasswordCookieLength; rdpString targetFQDN; - rdpBlob loadBalanceInfo; + BYTE* LoadBalanceInfo; + DWORD LoadBalanceInfoLength; rdpString targetNetBiosName; rdpString targetNetAddress; uint32 targetNetAddressesCount; diff --git a/libfreerdp/core/security.c b/libfreerdp/core/security.c index 0ce305e9f..b15a551d6 100644 --- a/libfreerdp/core/security.c +++ b/libfreerdp/core/security.c @@ -355,7 +355,7 @@ boolean security_establish_keys(uint8* client_random, rdpRdp* rdp) rdpSettings* settings; settings = rdp->settings; - server_random = settings->server_random->data; + server_random = settings->server_random; if (settings->encryption_method == ENCRYPTION_METHOD_FIPS) { @@ -398,12 +398,15 @@ boolean security_establish_keys(uint8* client_random, rdpRdp* rdp) memcpy(rdp->sign_key, session_key_blob, 16); - if (rdp->settings->server_mode) { + if (rdp->settings->server_mode) + { security_md5_16_32_32(&session_key_blob[16], client_random, server_random, rdp->encrypt_key); security_md5_16_32_32(&session_key_blob[32], client_random, server_random, rdp->decrypt_key); - } else { + } + else + { security_md5_16_32_32(&session_key_blob[16], client_random, server_random, rdp->decrypt_key); security_md5_16_32_32(&session_key_blob[32], client_random, diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 20534403d..9af876501 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -280,8 +280,6 @@ rdpSettings* settings_new(void* instance) settings->server_auto_reconnect_cookie = xnew(ARC_SC_PRIVATE_PACKET); settings->client_time_zone = xnew(TIME_ZONE_INFO); - settings->server_random = xnew(rdpBlob); - settings->server_certificate = xnew(rdpBlob); freerdp_detect_paths(settings); @@ -309,8 +307,6 @@ void settings_free(rdpSettings* settings) xfree(settings->order_support); xfree(settings->client_hostname); xfree(settings->client_product_id); - freerdp_blob_free(settings->server_random); - freerdp_blob_free(settings->server_certificate); xfree(settings->server_random); xfree(settings->server_certificate); xfree(settings->rdp_key_file); diff --git a/libfreerdp/crypto/crypto.c b/libfreerdp/crypto/crypto.c index d5b0a7d54..a520e52e4 100644 --- a/libfreerdp/crypto/crypto.c +++ b/libfreerdp/crypto/crypto.c @@ -160,13 +160,15 @@ void crypto_cert_free(CryptoCert cert) { if (cert == NULL) return; + X509_free(cert->px509); + xfree(cert); } -boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key) +boolean crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* PublicKeyLength) { - uint8* p; + BYTE* ptr; int length; boolean status = true; EVP_PKEY* pkey = NULL; @@ -189,9 +191,11 @@ boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key) goto exit; } - freerdp_blob_alloc(public_key, length); - p = (uint8*) public_key->data; - i2d_PublicKey(pkey, &p); + *PublicKeyLength = (DWORD) length; + *PublicKey = (BYTE*) malloc(length); + ptr = (BYTE*) (*PublicKey); + + i2d_PublicKey(pkey, &ptr); exit: if (pkey) diff --git a/libfreerdp/crypto/nla.c b/libfreerdp/crypto/nla.c index 89035cf06..dc20954fa 100644 --- a/libfreerdp/crypto/nla.c +++ b/libfreerdp/crypto/nla.c @@ -133,8 +133,8 @@ int credssp_ntlm_client_init(rdpCredssp* credssp) (char*) credssp->identity.User, (char*) credssp->identity.Domain, (char*) credssp->identity.Password); #endif - sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->public_key.length); - CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->public_key.data, credssp->tls->public_key.length); + sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->PublicKeyLength); + CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->PublicKey, credssp->tls->PublicKeyLength); length = sizeof(TERMSRV_SPN_PREFIX) + strlen(settings->hostname); @@ -164,8 +164,8 @@ int credssp_ntlm_server_init(rdpCredssp* credssp) rdpSettings* settings = credssp->settings; instance = (freerdp*) settings->instance; - sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->public_key.length); - CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->public_key.data, credssp->tls->public_key.length); + sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->PublicKeyLength); + CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->PublicKey, credssp->tls->PublicKeyLength); return 1; } diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 896653eeb..8c8fd6f10 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -133,10 +133,10 @@ boolean tls_connect(rdpTls* tls) return false; } - if (!crypto_cert_get_public_key(cert, &tls->public_key)) + if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength)) { printf("tls_connect: crypto_cert_get_public_key failed to return the server public key.\n"); - tls_free_certificate(cert) ; + tls_free_certificate(cert); return false; } @@ -234,7 +234,7 @@ boolean tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_fi return false; } - if (!crypto_cert_get_public_key(cert, &tls->public_key)) + if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength)) { printf("tls_connect: crypto_cert_get_public_key failed to return the server public key.\n"); tls_free_certificate(cert); @@ -639,7 +639,8 @@ void tls_free(rdpTls* tls) if (tls->ctx) SSL_CTX_free(tls->ctx); - freerdp_blob_free(&tls->public_key); + if (tls->PublicKey) + free(tls->PublicKey); certificate_store_free(tls->certificate_store); diff --git a/libfreerdp/locale/keyboard_xkbfile.c b/libfreerdp/locale/keyboard_xkbfile.c index 34c76981e..7e1c000b8 100644 --- a/libfreerdp/locale/keyboard_xkbfile.c +++ b/libfreerdp/locale/keyboard_xkbfile.c @@ -23,6 +23,8 @@ #include "keyboard_xkbfile.h" +#include + #include #include diff --git a/libfreerdp/locale/timezone.c b/libfreerdp/locale/timezone.c index 7abe3911a..895374f7a 100644 --- a/libfreerdp/locale/timezone.c +++ b/libfreerdp/locale/timezone.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "liblocale.h" diff --git a/libfreerdp/locale/virtual_key_codes.c b/libfreerdp/locale/virtual_key_codes.c index 24da1e533..bd2d9cc81 100644 --- a/libfreerdp/locale/virtual_key_codes.c +++ b/libfreerdp/locale/virtual_key_codes.c @@ -21,6 +21,10 @@ #include "config.h" #endif +#include +#include +#include + #include #include diff --git a/libfreerdp/locale/xkb_layout_ids.c b/libfreerdp/locale/xkb_layout_ids.c index d2b18b8eb..1037351fa 100644 --- a/libfreerdp/locale/xkb_layout_ids.c +++ b/libfreerdp/locale/xkb_layout_ids.c @@ -23,6 +23,8 @@ #include "xkb_layout_ids.h" +#include + #include #include diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index d2cedf32d..84d471360 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -22,7 +22,6 @@ find_required_package(Threads) set(FREERDP_UTILS_SRCS args.c - blob.c dsp.c event.c bitmap.c diff --git a/libfreerdp/utils/blob.c b/libfreerdp/utils/blob.c deleted file mode 100644 index 045da60b1..000000000 --- a/libfreerdp/utils/blob.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * BLOB Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -/** - * Allocate memory for data blob. - * @param blob blob structure - * @param length memory length - */ - -void freerdp_blob_alloc(rdpBlob* blob, int length) -{ - blob->data = xmalloc(length); - blob->length = length; -} - -/** - * Free memory allocated for data blob. - * @param blob - */ - -void freerdp_blob_free(rdpBlob* blob) -{ - if (blob->data) - xfree(blob->data); - - blob->length = 0; -} - -void freerdp_blob_copy(rdpBlob* dstblob, rdpBlob* srcblob) -{ - freerdp_blob_alloc(dstblob, srcblob->length); - memcpy(dstblob->data, srcblob->data, dstblob->length); -} diff --git a/libfreerdp/utils/time.c b/libfreerdp/utils/time.c index 9e22d0e79..0183b58c3 100644 --- a/libfreerdp/utils/time.c +++ b/libfreerdp/utils/time.c @@ -22,6 +22,9 @@ #endif #include +#include +#include + #include #include From c7719e9982cf1e015f8509e078e86e31129ee244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 24 Sep 2012 04:59:18 -0400 Subject: [PATCH 26/64] libfreerdp-utils: get rid of rect utils --- channels/rail/client/rail_orders.c | 15 ++++++-- include/freerdp/utils/rail.h | 1 - include/freerdp/utils/rect.h | 33 ---------------- libfreerdp/core/update.c | 16 ++++++-- libfreerdp/core/window.c | 10 ++++- libfreerdp/utils/CMakeLists.txt | 1 - libfreerdp/utils/rect.c | 60 ------------------------------ 7 files changed, 33 insertions(+), 103 deletions(-) delete mode 100644 include/freerdp/utils/rect.h delete mode 100644 libfreerdp/utils/rect.c diff --git a/channels/rail/client/rail_orders.c b/channels/rail/client/rail_orders.c index ee9bf0178..db99515f4 100644 --- a/channels/rail/client/rail_orders.c +++ b/channels/rail/client/rail_orders.c @@ -254,15 +254,24 @@ void rail_write_client_sysparam_order(STREAM* s, RAIL_SYSPARAM_ORDER* sysparam) break; case SPI_SET_WORK_AREA: - freerdp_write_rectangle_16(s, &sysparam->workArea); + stream_write_uint16(s, sysparam->workArea.left); /* left (2 bytes) */ + stream_write_uint16(s, sysparam->workArea.top); /* top (2 bytes) */ + stream_write_uint16(s, sysparam->workArea.right); /* right (2 bytes) */ + stream_write_uint16(s, sysparam->workArea.bottom); /* bottom (2 bytes) */ break; case SPI_DISPLAY_CHANGE: - freerdp_write_rectangle_16(s, &sysparam->displayChange); + stream_write_uint16(s, sysparam->displayChange.left); /* left (2 bytes) */ + stream_write_uint16(s, sysparam->displayChange.top); /* top (2 bytes) */ + stream_write_uint16(s, sysparam->displayChange.right); /* right (2 bytes) */ + stream_write_uint16(s, sysparam->displayChange.bottom); /* bottom (2 bytes) */ break; case SPI_TASKBAR_POS: - freerdp_write_rectangle_16(s, &sysparam->taskbarPos); + stream_write_uint16(s, sysparam->taskbarPos.left); /* left (2 bytes) */ + stream_write_uint16(s, sysparam->taskbarPos.top); /* top (2 bytes) */ + stream_write_uint16(s, sysparam->taskbarPos.right); /* right (2 bytes) */ + stream_write_uint16(s, sysparam->taskbarPos.bottom); /* bottom (2 bytes) */ break; case SPI_SET_HIGH_CONTRAST: diff --git a/include/freerdp/utils/rail.h b/include/freerdp/utils/rail.h index 8ad2129fc..0db550b4c 100644 --- a/include/freerdp/utils/rail.h +++ b/include/freerdp/utils/rail.h @@ -22,7 +22,6 @@ #include #include -#include #include FREERDP_API void rail_unicode_string_alloc(RAIL_UNICODE_STRING* unicode_string, uint16 cbString); diff --git a/include/freerdp/utils/rect.h b/include/freerdp/utils/rect.h deleted file mode 100644 index 530dfbb1e..000000000 --- a/include/freerdp/utils/rect.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Rectangle Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __RECT_UTILS_H -#define __RECT_UTILS_H - -#include -#include -#include - -FREERDP_API void freerdp_read_rectangle_16(STREAM* s, RECTANGLE_16* rectangle_16); -FREERDP_API void freerdp_write_rectangle_16(STREAM* s, RECTANGLE_16* rectangle_16); - -FREERDP_API RECTANGLE_16* freerdp_rectangle_16_new(uint16 left, uint16 top, uint16 right, uint16 bottom); -FREERDP_API void freerdp_rectangle_16_free(RECTANGLE_16* rectangle_16); - -#endif /* __RECT_UTILS_H */ diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 7b9648c5a..dbfb067ca 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -23,7 +23,7 @@ #include "update.h" #include "surface.h" -#include + #include /* @@ -355,7 +355,12 @@ static void update_write_refresh_rect(STREAM* s, uint8 count, RECTANGLE_16* area stream_seek(s, 3); /* pad3Octets (3 bytes) */ for (i = 0; i < count; i++) - freerdp_write_rectangle_16(s, &areas[i]); + { + stream_write_uint16(s, areas[i].left); /* left (2 bytes) */ + stream_write_uint16(s, areas[i].top); /* top (2 bytes) */ + stream_write_uint16(s, areas[i].right); /* right (2 bytes) */ + stream_write_uint16(s, areas[i].bottom); /* bottom (2 bytes) */ + } } static void update_send_refresh_rect(rdpContext* context, uint8 count, RECTANGLE_16* areas) @@ -378,7 +383,12 @@ static void update_write_suppress_output(STREAM* s, uint8 allow, RECTANGLE_16* a stream_seek(s, 3); /* pad3Octets (3 bytes) */ if (allow > 0) - freerdp_write_rectangle_16(s, area); + { + stream_write_uint16(s, area->left); /* left (2 bytes) */ + stream_write_uint16(s, area->top); /* top (2 bytes) */ + stream_write_uint16(s, area->right); /* right (2 bytes) */ + stream_write_uint16(s, area->bottom); /* bottom (2 bytes) */ + } } static void update_send_suppress_output(rdpContext* context, uint8 allow, RECTANGLE_16* area) diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index a0de29fab..b80a8ce9a 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -146,7 +146,10 @@ void update_read_window_state_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WIN /* windowRects */ for (i = 0; i < (int) window_state->numWindowRects; i++) { - freerdp_read_rectangle_16(s, &window_state->windowRects[i]); + stream_read_uint16(s, window_state->windowRects[i].left); /* left (2 bytes) */ + stream_read_uint16(s, window_state->windowRects[i].top); /* top (2 bytes) */ + stream_read_uint16(s, window_state->windowRects[i].right); /* right (2 bytes) */ + stream_read_uint16(s, window_state->windowRects[i].bottom); /* bottom (2 bytes) */ } } @@ -166,7 +169,10 @@ void update_read_window_state_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WIN /* visibilityRects */ for (i = 0; i < (int) window_state->numVisibilityRects; i++) { - freerdp_read_rectangle_16(s, &window_state->visibilityRects[i]); + stream_read_uint16(s, window_state->visibilityRects[i].left); /* left (2 bytes) */ + stream_read_uint16(s, window_state->visibilityRects[i].top); /* top (2 bytes) */ + stream_read_uint16(s, window_state->visibilityRects[i].right); /* right (2 bytes) */ + stream_read_uint16(s, window_state->visibilityRects[i].bottom); /* bottom (2 bytes) */ } } } diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index 84d471360..0d3c83b5c 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -34,7 +34,6 @@ set(FREERDP_UTILS_SRCS pcap.c profiler.c rail.c - rect.c signal.c sleep.c stopwatch.c diff --git a/libfreerdp/utils/rect.c b/libfreerdp/utils/rect.c deleted file mode 100644 index e8ee55d91..000000000 --- a/libfreerdp/utils/rect.c +++ /dev/null @@ -1,60 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Rectangle Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -void freerdp_read_rectangle_16(STREAM* s, RECTANGLE_16* rectangle_16) -{ - stream_read_uint16(s, rectangle_16->left); /* left (2 bytes) */ - stream_read_uint16(s, rectangle_16->top); /* top (2 bytes) */ - stream_read_uint16(s, rectangle_16->right); /* right (2 bytes) */ - stream_read_uint16(s, rectangle_16->bottom); /* bottom (2 bytes) */ -} - -void freerdp_write_rectangle_16(STREAM* s, RECTANGLE_16* rectangle_16) -{ - stream_write_uint16(s, rectangle_16->left); /* left (2 bytes) */ - stream_write_uint16(s, rectangle_16->top); /* top (2 bytes) */ - stream_write_uint16(s, rectangle_16->right); /* right (2 bytes) */ - stream_write_uint16(s, rectangle_16->bottom); /* bottom (2 bytes) */ -} - -RECTANGLE_16* freerdp_rectangle_16_new(uint16 left, uint16 top, uint16 right, uint16 bottom) -{ - RECTANGLE_16* rectangle_16 = xnew(RECTANGLE_16); - - rectangle_16->left = left; - rectangle_16->top = top; - rectangle_16->right = right; - rectangle_16->bottom = bottom; - - return rectangle_16; -} - -void freerdp_rectangle_16_free(RECTANGLE_16* rectangle_16) -{ - xfree(rectangle_16); -} From 1d6a4f68bb7b0994583a8ae2849c510a9c9dd8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 24 Sep 2012 05:01:04 -0400 Subject: [PATCH 27/64] libfreerdp-utils: remove forgotten registry utils header --- include/freerdp/utils/registry.h | 72 -------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 include/freerdp/utils/registry.h diff --git a/include/freerdp/utils/registry.h b/include/freerdp/utils/registry.h deleted file mode 100644 index b3956cefc..000000000 --- a/include/freerdp/utils/registry.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Registry Utils - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __REGISTRY_UTILS_H -#define __REGISTRY_UTILS_H - -typedef struct rdp_registry rdpRegistry; - -#include -#include -#include -#include -#include -#include -#include - -enum REG_TYPE -{ - REG_TYPE_NONE, - REG_TYPE_STRING, - REG_TYPE_INTEGER, - REG_TYPE_BOOLEAN, - REG_TYPE_SECTION -}; - -typedef struct -{ - uint8 type; - char* name; - uint32 length; - void* value; -} REG_ENTRY; - -typedef REG_ENTRY REG_STRING; -typedef REG_ENTRY REG_INTEGER; -typedef REG_ENTRY REG_BOOLEAN; -typedef REG_ENTRY REG_SECTION; - -struct rdp_registry -{ - FILE* fp; - char* path; - char* file; - char* home; - boolean available; - struct rdp_settings* settings; -}; - -FREERDP_API void registry_open(rdpRegistry* registry); -FREERDP_API void registry_close(rdpRegistry* registry); - -FREERDP_API void registry_init(rdpRegistry* registry); -FREERDP_API rdpRegistry* registry_new(rdpSettings* settings); -FREERDP_API void registry_free(rdpRegistry* registry); - -#endif /* __REGISTRY_UTILS_H */ From 75f7f78af13a8b50d66e3d86646422dd821539a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 24 Sep 2012 15:58:33 -0400 Subject: [PATCH 28/64] libwinpr: add stubs for io and file modules --- winpr/include/winpr/file.h | 31 +++++++ winpr/include/winpr/io.h | 78 ++++++++++++++++ winpr/include/winpr/wtypes.h | 4 +- winpr/libwinpr/CMakeLists.txt | 4 + winpr/libwinpr/file/CMakeLists.txt | 37 ++++++++ winpr/libwinpr/file/ModuleOptions.cmake | 9 ++ winpr/libwinpr/file/file.c | 115 ++++++++++++++++++++++++ winpr/libwinpr/io/CMakeLists.txt | 37 ++++++++ winpr/libwinpr/io/ModuleOptions.cmake | 9 ++ winpr/libwinpr/io/io.c | 96 ++++++++++++++++++++ 10 files changed, 418 insertions(+), 2 deletions(-) create mode 100644 winpr/include/winpr/file.h create mode 100644 winpr/include/winpr/io.h create mode 100644 winpr/libwinpr/file/CMakeLists.txt create mode 100644 winpr/libwinpr/file/ModuleOptions.cmake create mode 100644 winpr/libwinpr/file/file.c create mode 100644 winpr/libwinpr/io/CMakeLists.txt create mode 100644 winpr/libwinpr/io/ModuleOptions.cmake create mode 100644 winpr/libwinpr/io/io.c diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h new file mode 100644 index 000000000..41245b178 --- /dev/null +++ b/winpr/include/winpr/file.h @@ -0,0 +1,31 @@ +/** + * WinPR: Windows Portable Runtime + * File Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_FILE_H +#define WINPR_FILE_H + +#include +#include + +#ifndef _WIN32 + +#endif + +#endif /* WINPR_FILE_H */ + diff --git a/winpr/include/winpr/io.h b/winpr/include/winpr/io.h new file mode 100644 index 000000000..23e064bb5 --- /dev/null +++ b/winpr/include/winpr/io.h @@ -0,0 +1,78 @@ +/** + * WinPR: Windows Portable Runtime + * Asynchronous I/O Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_IO_H +#define WINPR_IO_H + +#include +#include + +#ifndef _WIN32 + +typedef struct _OVERLAPPED +{ + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + union + { + struct + { + DWORD Offset; + DWORD OffsetHigh; + }; + PVOID Pointer; + }; + HANDLE hEvent; +} OVERLAPPED, *LPOVERLAPPED; + +typedef struct _OVERLAPPED_ENTRY +{ + ULONG_PTR lpCompletionKey; + LPOVERLAPPED lpOverlapped; + ULONG_PTR Internal; + DWORD dwNumberOfBytesTransferred; +} OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; + +WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped,LPDWORD lpNumberOfBytesTransferred, BOOL bWait); + +WINPR_API BOOL GetOverlappedResultEx(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, DWORD dwMilliseconds, BOOL bAlertable); + +WINPR_API BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); + +WINPR_API HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, ULONG_PTR CompletionKey, DWORD NumberOfConcurrentThreads); + +WINPR_API BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, DWORD dwMilliseconds); + +WINPR_API BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable); + +WINPR_API BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, DWORD dwNumberOfBytesTransferred, ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL CancelIo(HANDLE hFile); + +WINPR_API BOOL CancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL CancelSynchronousIo(HANDLE hThread); + +#endif + +#endif /* WINPR_IO_H */ + diff --git a/winpr/include/winpr/wtypes.h b/winpr/include/winpr/wtypes.h index ea4b3f988..9a4e63c57 100644 --- a/winpr/include/winpr/wtypes.h +++ b/winpr/include/winpr/wtypes.h @@ -78,8 +78,8 @@ typedef long LONG, *PLONG, *LPLONG; typedef signed __int64 LONGLONG; typedef LONG HRESULT; -typedef __int3264 LONG_PTR; -typedef unsigned __int3264 ULONG_PTR; +typedef __int3264 LONG_PTR, *PLONG_PTR; +typedef unsigned __int3264 ULONG_PTR, *PULONG_PTR; typedef signed int LONG32; typedef signed __int64 LONG64; diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index a4431394e..4e7a6f2f7 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -29,6 +29,8 @@ add_subdirectory(crt) add_subdirectory(utils) add_subdirectory(heap) add_subdirectory(path) +add_subdirectory(io) +add_subdirectory(file) add_subdirectory(environment) add_subdirectory(interlocked) add_subdirectory(handle) @@ -53,6 +55,8 @@ if(WITH_MONOLITHIC_BUILD) $ $ $ + $ + $ $ $ $ diff --git a/winpr/libwinpr/file/CMakeLists.txt b/winpr/libwinpr/file/CMakeLists.txt new file mode 100644 index 000000000..af233a751 --- /dev/null +++ b/winpr/libwinpr/file/CMakeLists.txt @@ -0,0 +1,37 @@ +# WinPR: Windows Portable Runtime +# libwinpr-file cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-file") +set(MODULE_PREFIX "WINPR_FILE") + +set(${MODULE_PREFIX}_SRCS + file.c) + +if(WITH_MONOLITHIC_BUILD) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) +else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +endif() + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(WITH_MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + diff --git a/winpr/libwinpr/file/ModuleOptions.cmake b/winpr/libwinpr/file/ModuleOptions.cmake new file mode 100644 index 000000000..e2f0d36d2 --- /dev/null +++ b/winpr/libwinpr/file/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "2") +set(MINWIN_MINOR_VERSION "0") +set(MINWIN_SHORT_NAME "file") +set(MINWIN_LONG_NAME "File Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c new file mode 100644 index 000000000..1a1205310 --- /dev/null +++ b/winpr/libwinpr/file/file.c @@ -0,0 +1,115 @@ +/** + * WinPR: Windows Portable Runtime + * File Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/** + * api-ms-win-core-file-l1-2-0.dll: + * + * CompareFileTime + * CreateDirectoryA + * CreateDirectoryW + * CreateFile2 + * CreateFileA + * CreateFileW + * DefineDosDeviceW + * DeleteFileA + * DeleteFileW + * DeleteVolumeMountPointW + * FileTimeToLocalFileTime + * FindClose + * FindCloseChangeNotification + * FindFirstChangeNotificationA + * FindFirstChangeNotificationW + * FindFirstFileA + * FindFirstFileExA + * FindFirstFileExW + * FindFirstFileW + * FindFirstVolumeW + * FindNextChangeNotification + * FindNextFileA + * FindNextFileW + * FindNextVolumeW + * FindVolumeClose + * FlushFileBuffers + * GetDiskFreeSpaceA + * GetDiskFreeSpaceExA + * GetDiskFreeSpaceExW + * GetDiskFreeSpaceW + * GetDriveTypeA + * GetDriveTypeW + * GetFileAttributesA + * GetFileAttributesExA + * GetFileAttributesExW + * GetFileAttributesW + * GetFileInformationByHandle + * GetFileSize + * GetFileSizeEx + * GetFileTime + * GetFileType + * GetFinalPathNameByHandleA + * GetFinalPathNameByHandleW + * GetFullPathNameA + * GetFullPathNameW + * GetLogicalDrives + * GetLogicalDriveStringsW + * GetLongPathNameA + * GetLongPathNameW + * GetShortPathNameW + * GetTempFileNameW + * GetTempPathW + * GetVolumeInformationByHandleW + * GetVolumeInformationW + * GetVolumeNameForVolumeMountPointW + * GetVolumePathNamesForVolumeNameW + * GetVolumePathNameW + * LocalFileTimeToFileTime + * LockFile + * LockFileEx + * QueryDosDeviceW + * ReadFile + * ReadFileEx + * ReadFileScatter + * RemoveDirectoryA + * RemoveDirectoryW + * SetEndOfFile + * SetFileAttributesA + * SetFileAttributesW + * SetFileInformationByHandle + * SetFilePointer + * SetFilePointerEx + * SetFileTime + * SetFileValidData + * UnlockFile + * UnlockFileEx + * WriteFile + * WriteFileEx + * WriteFileGather + */ + +#ifndef _WIN32 + + + +#endif + diff --git a/winpr/libwinpr/io/CMakeLists.txt b/winpr/libwinpr/io/CMakeLists.txt new file mode 100644 index 000000000..63e9a8428 --- /dev/null +++ b/winpr/libwinpr/io/CMakeLists.txt @@ -0,0 +1,37 @@ +# WinPR: Windows Portable Runtime +# libwinpr-io cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-io") +set(MODULE_PREFIX "WINPR_IO") + +set(${MODULE_PREFIX}_SRCS + io.c) + +if(WITH_MONOLITHIC_BUILD) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) +else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +endif() + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(WITH_MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + diff --git a/winpr/libwinpr/io/ModuleOptions.cmake b/winpr/libwinpr/io/ModuleOptions.cmake new file mode 100644 index 000000000..f9f991d4c --- /dev/null +++ b/winpr/libwinpr/io/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "1") +set(MINWIN_SHORT_NAME "io") +set(MINWIN_LONG_NAME "Asynchronous I/O Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/io/io.c b/winpr/libwinpr/io/io.c new file mode 100644 index 000000000..00f14997c --- /dev/null +++ b/winpr/libwinpr/io/io.c @@ -0,0 +1,96 @@ +/** + * WinPR: Windows Portable Runtime + * Asynchronous I/O Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/** + * api-ms-win-core-io-l1-1-1.dll: + * + * GetOverlappedResult + * GetOverlappedResultEx + * DeviceIoControl + * CreateIoCompletionPort + * GetQueuedCompletionStatus + * GetQueuedCompletionStatusEx + * PostQueuedCompletionStatus + * CancelIo + * CancelIoEx + * CancelSynchronousIo + */ + +#ifndef _WIN32 + +BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped,LPDWORD lpNumberOfBytesTransferred, BOOL bWait) +{ + return TRUE; +} + +BOOL GetOverlappedResultEx(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, DWORD dwMilliseconds, BOOL bAlertable) +{ + return TRUE; +} + +BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, ULONG_PTR CompletionKey, DWORD NumberOfConcurrentThreads) +{ + return NULL; +} + +BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, DWORD dwMilliseconds) +{ + return TRUE; +} + +BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable) +{ + return TRUE; +} + +BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, DWORD dwNumberOfBytesTransferred, ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL CancelIo(HANDLE hFile) +{ + return TRUE; +} + +BOOL CancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL CancelSynchronousIo(HANDLE hThread) +{ + return TRUE; +} + +#endif From 06720e2a8dcf986af8ba8f14098afd2af6d0b4b8 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Wed, 26 Sep 2012 15:45:30 +0200 Subject: [PATCH 29/64] build: check libavcodec api version If pkg-config is available libavcodec api version is checked and cmake fails if the required version isn't available. In case pkg-config isn't available a notification message with the required version is printed. This fixes/prevents #740. --- cmake/FindFFmpeg.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake index add7336ed..3151be906 100644 --- a/cmake/FindFFmpeg.cmake +++ b/cmake/FindFFmpeg.cmake @@ -5,6 +5,9 @@ # FFMPEG_INCLUDE_DIRS - combined include directories # FFMPEG_LIBRARIES - combined libraries to link +set(REQUIRED_AVCODEC_VERSION 0.8) +set(REQUIRED_AVCODEC_API_VERSION 53.25.0) + include(FindPkgConfig) if (PKG_CONFIG_FOUND) @@ -31,6 +34,14 @@ endif() FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFmpeg DEFAULT_MSG AVUTIL_FOUND AVCODEC_FOUND) +if (AVCODEC_VERSION) + if (${AVCODEC_VERSION} VERSION_LESS ${REQUIRED_AVCODEC_API_VERSION}) + message(FATAL_ERROR "libavcodec version >= ${REQUIRED_AVCODEC_VERSION} (API >= ${REQUIRED_AVCODEC_API_VERSION}) is required") + endif() +else() + message("Note: To build libavcodec version >= ${REQUIRED_AVCODEC_VERSION} (API >= ${REQUIRED_AVCODEC_API_VERSION}) is required") +endif() + if(FFMPEG_FOUND) set(FFMPEG_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR}) set(FFMPEG_LIBRARIES ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY}) From 089312abb0a7142622c4658026ab5d123f4c27fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 26 Sep 2012 12:37:35 -0400 Subject: [PATCH 30/64] libwinpr-error: stub error API --- winpr/include/winpr/error.h | 83 +++++++++++++++++ winpr/include/winpr/file.h | 62 +++++++++++++ winpr/include/winpr/io.h | 2 +- winpr/include/winpr/wtypes.h | 1 + winpr/libwinpr/CMakeLists.txt | 2 + winpr/libwinpr/error/CMakeLists.txt | 37 ++++++++ winpr/libwinpr/error/ModuleOptions.cmake | 9 ++ winpr/libwinpr/error/error.c | 105 ++++++++++++++++++++++ winpr/libwinpr/file/file.c | 110 +++++++++++++++++++---- winpr/libwinpr/io/io.c | 2 +- 10 files changed, 396 insertions(+), 17 deletions(-) create mode 100644 winpr/include/winpr/error.h create mode 100644 winpr/libwinpr/error/CMakeLists.txt create mode 100644 winpr/libwinpr/error/ModuleOptions.cmake create mode 100644 winpr/libwinpr/error/error.c diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h new file mode 100644 index 000000000..c87851924 --- /dev/null +++ b/winpr/include/winpr/error.h @@ -0,0 +1,83 @@ +/** + * WinPR: Windows Portable Runtime + * Error Handling Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ERROR_H +#define WINPR_ERROR_H + +#include +#include + +#ifndef _WIN32 + +#define EXCEPTION_MAXIMUM_PARAMETERS 15 + +typedef struct _EXCEPTION_RECORD EXCEPTION_RECORD; +typedef struct _EXCEPTION_RECORD *PEXCEPTION_RECORD; + +struct _EXCEPTION_RECORD +{ + DWORD ExceptionCode; + DWORD ExceptionFlags; + PEXCEPTION_RECORD ExceptionRecord; + PVOID ExceptionAddress; + DWORD NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +}; + +typedef void* PCONTEXT; + +typedef struct _EXCEPTION_POINTERS +{ + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; +} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; + +typedef LONG (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo); +typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER; + +typedef LONG (*PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo); + +WINPR_API UINT GetErrorMode(void); + +WINPR_API UINT SetErrorMode(UINT uMode); + +WINPR_API DWORD GetLastError(VOID); + +WINPR_API VOID SetLastError(DWORD dwErrCode); + +WINPR_API VOID RestoreLastError(DWORD dwErrCode); + +WINPR_API VOID RaiseException(DWORD dwExceptionCode, DWORD dwExceptionFlags, DWORD nNumberOfArguments, CONST ULONG_PTR* lpArguments); + +WINPR_API LONG UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo); + +WINPR_API LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter); + +WINPR_API PVOID AddVectoredExceptionHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler); + +WINPR_API ULONG RemoveVectoredExceptionHandler(PVOID Handle); + +WINPR_API PVOID AddVectoredContinueHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler); + +WINPR_API ULONG RemoveVectoredContinueHandler(PVOID Handle); + +#endif + +#endif /* WINPR_ERROR_H */ + diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h index 41245b178..0b06c8acf 100644 --- a/winpr/include/winpr/file.h +++ b/winpr/include/winpr/file.h @@ -23,8 +23,70 @@ #include #include +#include + #ifndef _WIN32 +#define FILE_FLAG_WRITE_THROUGH 0x80000000 +#define FILE_FLAG_OVERLAPPED 0x40000000 +#define FILE_FLAG_NO_BUFFERING 0x20000000 +#define FILE_FLAG_RANDOM_ACCESS 0x10000000 +#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 +#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000 +#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000 +#define FILE_FLAG_POSIX_SEMANTICS 0x01000000 +#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000 +#define FILE_FLAG_OPEN_NO_RECALL 0x00100000 +#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 + +typedef union _FILE_SEGMENT_ELEMENT +{ + PVOID64 Buffer; + ULONGLONG Alignment; +} FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL ReadFileEx(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + +WINPR_API BOOL ReadFileScatter(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToRead, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL WriteFileEx(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + +WINPR_API BOOL WriteFileGather(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL FlushFileBuffers(HANDLE hFile); + +WINPR_API BOOL SetEndOfFile(HANDLE hFile); + +WINPR_API DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, + PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod); + +WINPR_API BOOL SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, + PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod); + +WINPR_API BOOL LockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh); + +WINPR_API BOOL LockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh); + +WINPR_API BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, + DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped); + #endif #endif /* WINPR_FILE_H */ diff --git a/winpr/include/winpr/io.h b/winpr/include/winpr/io.h index 23e064bb5..237f2674b 100644 --- a/winpr/include/winpr/io.h +++ b/winpr/include/winpr/io.h @@ -49,7 +49,7 @@ typedef struct _OVERLAPPED_ENTRY DWORD dwNumberOfBytesTransferred; } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; -WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped,LPDWORD lpNumberOfBytesTransferred, BOOL bWait); +WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); WINPR_API BOOL GetOverlappedResultEx(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, DWORD dwMilliseconds, BOOL bAlertable); diff --git a/winpr/include/winpr/wtypes.h b/winpr/include/winpr/wtypes.h index 9a4e63c57..315006b8b 100644 --- a/winpr/include/winpr/wtypes.h +++ b/winpr/include/winpr/wtypes.h @@ -110,6 +110,7 @@ typedef unsigned __int64 ULONG64; typedef wchar_t UNICODE; typedef unsigned short USHORT; typedef void VOID, *PVOID, *LPVOID; +typedef void *PVOID64, *LPVOID64; typedef const void *LPCVOID; typedef unsigned short WORD, *PWORD, *LPWORD; diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index 4e7a6f2f7..0dd4aeaf8 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -31,6 +31,7 @@ add_subdirectory(heap) add_subdirectory(path) add_subdirectory(io) add_subdirectory(file) +add_subdirectory(error) add_subdirectory(environment) add_subdirectory(interlocked) add_subdirectory(handle) @@ -57,6 +58,7 @@ if(WITH_MONOLITHIC_BUILD) $ $ $ + $ $ $ $ diff --git a/winpr/libwinpr/error/CMakeLists.txt b/winpr/libwinpr/error/CMakeLists.txt new file mode 100644 index 000000000..08740f0a0 --- /dev/null +++ b/winpr/libwinpr/error/CMakeLists.txt @@ -0,0 +1,37 @@ +# WinPR: Windows Portable Runtime +# libwinpr-error cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(MODULE_NAME "winpr-error") +set(MODULE_PREFIX "WINPR_ERROR") + +set(${MODULE_PREFIX}_SRCS + error.c) + +if(WITH_MONOLITHIC_BUILD) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) +else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +endif() + +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") + +if(WITH_MONOLITHIC_BUILD) + +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() + diff --git a/winpr/libwinpr/error/ModuleOptions.cmake b/winpr/libwinpr/error/ModuleOptions.cmake new file mode 100644 index 000000000..b455bd742 --- /dev/null +++ b/winpr/libwinpr/error/ModuleOptions.cmake @@ -0,0 +1,9 @@ + +set(MINWIN_LAYER "1") +set(MINWIN_GROUP "core") +set(MINWIN_MAJOR_VERSION "1") +set(MINWIN_MINOR_VERSION "1") +set(MINWIN_SHORT_NAME "errorhandling") +set(MINWIN_LONG_NAME "Error Handling Functions") +set(MODULE_LIBRARY_NAME "api-ms-win-${MINWIN_GROUP}-${MINWIN_SHORT_NAME}-l${MINWIN_LAYER}-${MINWIN_MAJOR_VERSION}-${MINWIN_MINOR_VERSION}") + diff --git a/winpr/libwinpr/error/error.c b/winpr/libwinpr/error/error.c new file mode 100644 index 000000000..ff11daa6b --- /dev/null +++ b/winpr/libwinpr/error/error.c @@ -0,0 +1,105 @@ +/** + * WinPR: Windows Portable Runtime + * Error Handling Functions + * + * Copyright 2012 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/** + * api-ms-win-core-errorhandling-l1-1-1.dll: + * + * GetErrorMode + * SetErrorMode + * GetLastError + * SetLastError + * RestoreLastError + * RaiseException + * UnhandledExceptionFilter + * SetUnhandledExceptionFilter + * AddVectoredExceptionHandler + * RemoveVectoredExceptionHandler + * AddVectoredContinueHandler + * RemoveVectoredContinueHandler + */ + +#ifndef _WIN32 + +UINT GetErrorMode(void) +{ + return 0; +} + +UINT SetErrorMode(UINT uMode) +{ + return 0; +} + +DWORD GetLastError(VOID) +{ + return 0; +} + +VOID SetLastError(DWORD dwErrCode) +{ + +} + +VOID RestoreLastError(DWORD dwErrCode) +{ + +} + +VOID RaiseException(DWORD dwExceptionCode, DWORD dwExceptionFlags, DWORD nNumberOfArguments, CONST ULONG_PTR* lpArguments) +{ + +} + +LONG UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) +{ + return 0; +} + +LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) +{ + return NULL; +} + +PVOID AddVectoredExceptionHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler) +{ + return NULL; +} + +ULONG RemoveVectoredExceptionHandler(PVOID Handle) +{ + return 0; +} + +PVOID AddVectoredContinueHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler) +{ + return NULL; +} + +ULONG RemoveVectoredContinueHandler(PVOID Handle) +{ + return 0; +} + +#endif diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 1a1205310..04a519e01 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -51,7 +51,6 @@ * FindNextFileW * FindNextVolumeW * FindVolumeClose - * FlushFileBuffers * GetDiskFreeSpaceA * GetDiskFreeSpaceExA * GetDiskFreeSpaceExW @@ -84,32 +83,113 @@ * GetVolumePathNamesForVolumeNameW * GetVolumePathNameW * LocalFileTimeToFileTime - * LockFile - * LockFileEx * QueryDosDeviceW + * RemoveDirectoryA + * RemoveDirectoryW + * SetFileAttributesA + * SetFileAttributesW + * SetFileTime + * SetFileValidData + * SetFileInformationByHandle * ReadFile * ReadFileEx * ReadFileScatter - * RemoveDirectoryA - * RemoveDirectoryW - * SetEndOfFile - * SetFileAttributesA - * SetFileAttributesW - * SetFileInformationByHandle - * SetFilePointer - * SetFilePointerEx - * SetFileTime - * SetFileValidData - * UnlockFile - * UnlockFileEx * WriteFile * WriteFileEx * WriteFileGather + * FlushFileBuffers + * SetEndOfFile + * SetFilePointer + * SetFilePointerEx + * LockFile + * LockFileEx + * UnlockFile + * UnlockFileEx */ #ifndef _WIN32 +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} +BOOL ReadFileEx(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) +{ + return TRUE; +} + +BOOL ReadFileScatter(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToRead, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL WriteFileEx(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) +{ + return TRUE; +} + +BOOL WriteFileGather(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL FlushFileBuffers(HANDLE hFile) +{ + return TRUE; +} + +BOOL SetEndOfFile(HANDLE hFile) +{ + return TRUE; +} + +DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, + PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) +{ + return TRUE; +} + +BOOL SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, + PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod) +{ + return TRUE; +} + +BOOL LockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh) +{ + return TRUE; +} + +BOOL LockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh) +{ + return TRUE; +} + +BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, + DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} #endif diff --git a/winpr/libwinpr/io/io.c b/winpr/libwinpr/io/io.c index 00f14997c..b319e6c77 100644 --- a/winpr/libwinpr/io/io.c +++ b/winpr/libwinpr/io/io.c @@ -40,7 +40,7 @@ #ifndef _WIN32 -BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped,LPDWORD lpNumberOfBytesTransferred, BOOL bWait) +BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait) { return TRUE; } From ce887f973c6e8176a13e27bf0b17c675036c327e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 26 Sep 2012 13:38:21 -0400 Subject: [PATCH 31/64] libwinpr-error: define all windows error codes --- winpr/include/winpr/error.h | 2780 ++++++++++++++++++++++++++++++++++- 1 file changed, 2779 insertions(+), 1 deletion(-) diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h index c87851924..21f5f05c6 100644 --- a/winpr/include/winpr/error.h +++ b/winpr/include/winpr/error.h @@ -25,7 +25,2785 @@ #ifndef _WIN32 -#define EXCEPTION_MAXIMUM_PARAMETERS 15 +/* System Error Codes (0-499) */ + +#define ERROR_SUCCESS 0x00000000 +#define ERROR_INVALID_FUNCTION 0x00000001 +#define ERROR_FILE_NOT_FOUND 0x00000002 +#define ERROR_PATH_NOT_FOUND 0x00000003 +#define ERROR_TOO_MANY_OPEN_FILES 0x00000004 +#define ERROR_ACCESS_DENIED 0x00000005 +#define ERROR_INVALID_HANDLE 0x00000006 +#define ERROR_ARENA_TRASHED 0x00000007 +#define ERROR_NOT_ENOUGH_MEMORY 0x00000008 +#define ERROR_INVALID_BLOCK 0x00000009 +#define ERROR_BAD_ENVIRONMENT 0x0000000A +#define ERROR_BAD_FORMAT 0x0000000B +#define ERROR_INVALID_ACCESS 0x0000000C +#define ERROR_INVALID_DATA 0x0000000D +#define ERROR_OUTOFMEMORY 0x0000000E +#define ERROR_INVALID_DRIVE 0x0000000F +#define ERROR_CURRENT_DIRECTORY 0x00000010 +#define ERROR_NOT_SAME_DEVICE 0x00000011 +#define ERROR_NO_MORE_FILES 0x00000012 +#define ERROR_WRITE_PROTECT 0x00000013 +#define ERROR_BAD_UNIT 0x00000014 +#define ERROR_NOT_READY 0x00000015 +#define ERROR_BAD_COMMAND 0x00000016 +#define ERROR_CRC 0x00000017 +#define ERROR_BAD_LENGTH 0x00000018 +#define ERROR_SEEK 0x00000019 +#define ERROR_NOT_DOS_DISK 0x0000001A +#define ERROR_SECTOR_NOT_FOUND 0x0000001B +#define ERROR_OUT_OF_PAPER 0x0000001C +#define ERROR_WRITE_FAULT 0x0000001D +#define ERROR_READ_FAULT 0x0000001E +#define ERROR_GEN_FAILURE 0x0000001F +#define ERROR_SHARING_VIOLATION 0x00000020 +#define ERROR_LOCK_VIOLATION 0x00000021 +#define ERROR_WRONG_DISK 0x00000022 +#define ERROR_SHARING_BUFFER_EXCEEDED 0x00000024 +#define ERROR_HANDLE_EOF 0x00000026 +#define ERROR_HANDLE_DISK_FULL 0x00000027 +#define ERROR_NOT_SUPPORTED 0x00000032 +#define ERROR_REM_NOT_LIST 0x00000033 +#define ERROR_DUP_NAME 0x00000034 +#define ERROR_BAD_NETPATH 0x00000035 +#define ERROR_NETWORK_BUSY 0x00000036 +#define ERROR_DEV_NOT_EXIST 0x00000037 +#define ERROR_TOO_MANY_CMDS 0x00000038 +#define ERROR_ADAP_HDW_ERR 0x00000039 +#define ERROR_BAD_NET_RESP 0x0000003A +#define ERROR_UNEXP_NET_ERR 0x0000003B +#define ERROR_BAD_REM_ADAP 0x0000003C +#define ERROR_PRINTQ_FULL 0x0000003D +#define ERROR_NO_SPOOL_SPACE 0x0000003E +#define ERROR_PRINT_CANCELLED 0x0000003F +#define ERROR_NETNAME_DELETED 0x00000040 +#define ERROR_NETWORK_ACCESS_DENIED 0x00000041 +#define ERROR_BAD_DEV_TYPE 0x00000042 +#define ERROR_BAD_NET_NAME 0x00000043 +#define ERROR_TOO_MANY_NAMES 0x00000044 +#define ERROR_TOO_MANY_SESS 0x00000045 +#define ERROR_SHARING_PAUSED 0x00000046 +#define ERROR_REQ_NOT_ACCEP 0x00000047 +#define ERROR_REDIR_PAUSED 0x00000048 +#define ERROR_FILE_EXISTS 0x00000050 +#define ERROR_CANNOT_MAKE 0x00000052 +#define ERROR_FAIL_I24 0x00000053 +#define ERROR_OUT_OF_STRUCTURES 0x00000054 +#define ERROR_ALREADY_ASSIGNED 0x00000055 +#define ERROR_INVALID_PASSWORD 0x00000056 +#define ERROR_INVALID_PARAMETER 0x00000057 +#define ERROR_NET_WRITE_FAULT 0x00000058 +#define ERROR_NO_PROC_SLOTS 0x00000059 +#define ERROR_TOO_MANY_SEMAPHORES 0x00000064 +#define ERROR_EXCL_SEM_ALREADY_OWNED 0x00000065 +#define ERROR_SEM_IS_SET 0x00000066 +#define ERROR_TOO_MANY_SEM_REQUESTS 0x00000067 +#define ERROR_INVALID_AT_INTERRUPT_TIME 0x00000068 +#define ERROR_SEM_OWNER_DIED 0x00000069 +#define ERROR_SEM_USER_LIMIT 0x0000006A +#define ERROR_DISK_CHANGE 0x0000006B +#define ERROR_DRIVE_LOCKED 0x0000006C +#define ERROR_BROKEN_PIPE 0x0000006D +#define ERROR_OPEN_FAILED 0x0000006E +#define ERROR_BUFFER_OVERFLOW 0x0000006F +#define ERROR_DISK_FULL 0x00000070 +#define ERROR_NO_MORE_SEARCH_HANDLES 0x00000071 +#define ERROR_INVALID_TARGET_HANDLE 0x00000072 +#define ERROR_INVALID_CATEGORY 0x00000075 +#define ERROR_INVALID_VERIFY_SWITCH 0x00000076 +#define ERROR_BAD_DRIVER_LEVEL 0x00000077 +#define ERROR_CALL_NOT_IMPLEMENTED 0x00000078 +#define ERROR_SEM_TIMEOUT 0x00000079 +#define ERROR_INSUFFICIENT_BUFFER 0x0000007A +#define ERROR_INVALID_NAME 0x0000007B +#define ERROR_INVALID_LEVEL 0x0000007C +#define ERROR_NO_VOLUME_LABEL 0x0000007D +#define ERROR_MOD_NOT_FOUND 0x0000007E +#define ERROR_PROC_NOT_FOUND 0x0000007F +#define ERROR_WAIT_NO_CHILDREN 0x00000080 +#define ERROR_CHILD_NOT_COMPLETE 0x00000081 +#define ERROR_DIRECT_ACCESS_HANDLE 0x00000082 +#define ERROR_NEGATIVE_SEEK 0x00000083 +#define ERROR_SEEK_ON_DEVICE 0x00000084 +#define ERROR_IS_JOIN_TARGET 0x00000085 +#define ERROR_IS_JOINED 0x00000086 +#define ERROR_IS_SUBSTED 0x00000087 +#define ERROR_NOT_JOINED 0x00000088 +#define ERROR_NOT_SUBSTED 0x00000089 +#define ERROR_JOIN_TO_JOIN 0x0000008A +#define ERROR_SUBST_TO_SUBST 0x0000008B +#define ERROR_JOIN_TO_SUBST 0x0000008C +#define ERROR_SUBST_TO_JOIN 0x0000008D +#define ERROR_BUSY_DRIVE 0x0000008E +#define ERROR_SAME_DRIVE 0x0000008F +#define ERROR_DIR_NOT_ROOT 0x00000090 +#define ERROR_DIR_NOT_EMPTY 0x00000091 +#define ERROR_IS_SUBST_PATH 0x00000092 +#define ERROR_IS_JOIN_PATH 0x00000093 +#define ERROR_PATH_BUSY 0x00000094 +#define ERROR_IS_SUBST_TARGET 0x00000095 +#define ERROR_SYSTEM_TRACE 0x00000096 +#define ERROR_INVALID_EVENT_COUNT 0x00000097 +#define ERROR_TOO_MANY_MUXWAITERS 0x00000098 +#define ERROR_INVALID_LIST_FORMAT 0x00000099 +#define ERROR_LABEL_TOO_LONG 0x0000009A +#define ERROR_TOO_MANY_TCBS 0x0000009B +#define ERROR_SIGNAL_REFUSED 0x0000009C +#define ERROR_DISCARDED 0x0000009D +#define ERROR_NOT_LOCKED 0x0000009E +#define ERROR_BAD_THREADID_ADDR 0x0000009F +#define ERROR_BAD_ARGUMENTS 0x000000A0 +#define ERROR_BAD_PATHNAME 0x000000A1 +#define ERROR_SIGNAL_PENDING 0x000000A2 +#define ERROR_MAX_THRDS_REACHED 0x000000A4 +#define ERROR_LOCK_FAILED 0x000000A7 +#define ERROR_BUSY 0x000000AA +#define ERROR_DEVICE_SUPPORT_IN_PROGRESS 0x000000AB +#define ERROR_CANCEL_VIOLATION 0x000000AD +#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 0x000000AE +#define ERROR_INVALID_SEGMENT_NUMBER 0x000000B4 +#define ERROR_INVALID_ORDINAL 0x000000B6 +#define ERROR_ALREADY_EXISTS 0x000000B7 +#define ERROR_INVALID_FLAG_NUMBER 0x000000BA +#define ERROR_SEM_NOT_FOUND 0x000000BB +#define ERROR_INVALID_STARTING_CODESEG 0x000000BC +#define ERROR_INVALID_STACKSEG 0x000000BD +#define ERROR_INVALID_MODULETYPE 0x000000BE +#define ERROR_INVALID_EXE_SIGNATURE 0x000000BF +#define ERROR_EXE_MARKED_INVALID 0x000000C0 +#define ERROR_BAD_EXE_FORMAT 0x000000C1 +#define ERROR_ITERATED_DATA_EXCEEDS_64k 0x000000C2 +#define ERROR_INVALID_MINALLOCSIZE 0x000000C3 +#define ERROR_DYNLINK_FROM_INVALID_RING 0x000000C4 +#define ERROR_IOPL_NOT_ENABLED 0x000000C5 +#define ERROR_INVALID_SEGDPL 0x000000C6 +#define ERROR_AUTODATASEG_EXCEEDS_64k 0x000000C7 +#define ERROR_RING2SEG_MUST_BE_MOVABLE 0x000000C8 +#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 0x000000C9 +#define ERROR_INFLOOP_IN_RELOC_CHAIN 0x000000CA +#define ERROR_ENVVAR_NOT_FOUND 0x000000CB +#define ERROR_NO_SIGNAL_SENT 0x000000CD +#define ERROR_FILENAME_EXCED_RANGE 0x000000CE +#define ERROR_RING2_STACK_IN_USE 0x000000CF +#define ERROR_META_EXPANSION_TOO_LONG 0x000000D0 +#define ERROR_INVALID_SIGNAL_NUMBER 0x000000D1 +#define ERROR_THREAD_1_INACTIVE 0x000000D2 +#define ERROR_LOCKED 0x000000D4 +#define ERROR_TOO_MANY_MODULES 0x000000D6 +#define ERROR_NESTING_NOT_ALLOWED 0x000000D7 +#define ERROR_EXE_MACHINE_TYPE_MISMATCH 0x000000D8 +#define ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY 0x000000D9 +#define ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY 0x000000DA +#define ERROR_FILE_CHECKED_OUT 0x000000DC +#define ERROR_CHECKOUT_REQUIRED 0x000000DD +#define ERROR_BAD_FILE_TYPE 0x000000DE +#define ERROR_FILE_TOO_LARGE 0x000000DF +#define ERROR_FORMS_AUTH_REQUIRED 0x000000E0 +#define ERROR_VIRUS_INFECTED 0x000000E1 +#define ERROR_VIRUS_DELETED 0x000000E2 +#define ERROR_PIPE_LOCAL 0x000000E5 +#define ERROR_BAD_PIPE 0x000000E6 +#define ERROR_PIPE_BUSY 0x000000E7 +#define ERROR_NO_DATA 0x000000E8 +#define ERROR_PIPE_NOT_CONNECTED 0x000000E9 +#define ERROR_MORE_DATA 0x000000EA +#define ERROR_VC_DISCONNECTED 0x000000F0 +#define ERROR_INVALID_EA_NAME 0x000000FE +#define ERROR_EA_LIST_INCONSISTENT 0x000000FF +#define WAIT_TIMEOUT 0x00000102 +#define ERROR_NO_MORE_ITEMS 0x00000103 +#define ERROR_CANNOT_COPY 0x0000010A +#define ERROR_DIRECTORY 0x0000010B +#define ERROR_EAS_DIDNT_FIT 0x00000113 +#define ERROR_EA_FILE_CORRUPT 0x00000114 +#define ERROR_EA_TABLE_FULL 0x00000115 +#define ERROR_INVALID_EA_HANDLE 0x00000116 +#define ERROR_EAS_NOT_SUPPORTED 0x0000011A +#define ERROR_NOT_OWNER 0x00000120 +#define ERROR_TOO_MANY_POSTS 0x0000012A +#define ERROR_PARTIAL_COPY 0x0000012B +#define ERROR_OPLOCK_NOT_GRANTED 0x0000012C +#define ERROR_INVALID_OPLOCK_PROTOCOL 0x0000012D +#define ERROR_DISK_TOO_FRAGMENTED 0x0000012E +#define ERROR_DELETE_PENDING 0x0000012F +#define ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING 0x00000130 +#define ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME 0x00000131 +#define ERROR_SECURITY_STREAM_IS_INCONSISTENT 0x00000132 +#define ERROR_INVALID_LOCK_RANGE 0x00000133 +#define ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT 0x00000134 +#define ERROR_NOTIFICATION_GUID_ALREADY_DEFINED 0x00000135 +#define ERROR_INVALID_EXCEPTION_HANDLER 0x00000136 +#define ERROR_DUPLICATE_PRIVILEGES 0x00000137 +#define ERROR_NO_RANGES_PROCESSED 0x00000138 +#define ERROR_NOT_ALLOWED_ON_SYSTEM_FILE 0x00000139 +#define ERROR_DISK_RESOURCES_EXHAUSTED 0x0000013A +#define ERROR_INVALID_TOKEN 0x0000013B +#define ERROR_DEVICE_FEATURE_NOT_SUPPORTED 0x0000013C +#define ERROR_MR_MID_NOT_FOUND 0x0000013D +#define ERROR_SCOPE_NOT_FOUND 0x0000013E +#define ERROR_UNDEFINED_SCOPE 0x0000013F +#define ERROR_INVALID_CAP 0x00000140 +#define ERROR_DEVICE_UNREACHABLE 0x00000141 +#define ERROR_DEVICE_NO_RESOURCES 0x00000142 +#define ERROR_DATA_CHECKSUM_ERROR 0x00000143 +#define ERROR_INTERMIXED_KERNEL_EA_OPERATION 0x00000144 +#define ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED 0x00000146 +#define ERROR_OFFSET_ALIGNMENT_VIOLATION 0x00000147 +#define ERROR_INVALID_FIELD_IN_PARAMETER_LIST 0x00000148 +#define ERROR_OPERATION_IN_PROGRESS 0x00000149 +#define ERROR_BAD_DEVICE_PATH 0x0000014A +#define ERROR_TOO_MANY_DESCRIPTORS 0x0000014B +#define ERROR_SCRUB_DATA_DISABLED 0x0000014C +#define ERROR_NOT_REDUNDANT_STORAGE 0x0000014D +#define ERROR_RESIDENT_FILE_NOT_SUPPORTED 0x0000014E +#define ERROR_COMPRESSED_FILE_NOT_SUPPORTED 0x0000014F +#define ERROR_DIRECTORY_NOT_SUPPORTED 0x00000150 +#define ERROR_NOT_READ_FROM_COPY 0x00000151 +#define ERROR_FAIL_NOACTION_REBOOT 0x0000015E +#define ERROR_FAIL_SHUTDOWN 0x0000015F +#define ERROR_FAIL_RESTART 0x00000160 +#define ERROR_MAX_SESSIONS_REACHED 0x00000161 +#define ERROR_THREAD_MODE_ALREADY_BACKGROUND 0x00000190 +#define ERROR_THREAD_MODE_NOT_BACKGROUND 0x00000191 +#define ERROR_PROCESS_MODE_ALREADY_BACKGROUND 0x00000192 +#define ERROR_PROCESS_MODE_NOT_BACKGROUND 0x00000193 +#define ERROR_INVALID_ADDRESS 0x000001E7 + +/* System Error Codes (500-999) */ + + +#define ERROR_USER_PROFILE_LOAD 0x000001F4 +#define ERROR_ARITHMETIC_OVERFLOW 0x00000216 +#define ERROR_PIPE_CONNECTED 0x00000217 +#define ERROR_PIPE_LISTENING 0x00000218 +#define ERROR_VERIFIER_STOP 0x00000219 +#define ERROR_ABIOS_ERROR 0x0000021A +#define ERROR_WX86_WARNING 0x0000021B +#define ERROR_WX86_ERROR 0x0000021C +#define ERROR_TIMER_NOT_CANCELED 0x0000021D +#define ERROR_UNWIND 0x0000021E +#define ERROR_BAD_STACK 0x0000021F +#define ERROR_INVALID_UNWIND_TARGET 0x00000220 +#define ERROR_INVALID_PORT_ATTRIBUTES 0x00000221 +#define ERROR_PORT_MESSAGE_TOO_LONG 0x00000222 +#define ERROR_INVALID_QUOTA_LOWER 0x00000223 +#define ERROR_DEVICE_ALREADY_ATTACHED 0x00000224 +#define ERROR_INSTRUCTION_MISALIGNMENT 0x00000225 +#define ERROR_PROFILING_NOT_STARTED 0x00000226 +#define ERROR_PROFILING_NOT_STOPPED 0x00000227 +#define ERROR_COULD_NOT_INTERPRET 0x00000228 +#define ERROR_PROFILING_AT_LIMIT 0x00000229 +#define ERROR_CANT_WAIT 0x0000022A +#define ERROR_CANT_TERMINATE_SELF 0x0000022B +#define ERROR_UNEXPECTED_MM_CREATE_ERR 0x0000022C +#define ERROR_UNEXPECTED_MM_MAP_ERROR 0x0000022D +#define ERROR_UNEXPECTED_MM_EXTEND_ERR 0x0000022E +#define ERROR_BAD_FUNCTION_TABLE 0x0000022F +#define ERROR_NO_GUID_TRANSLATION 0x00000230 +#define ERROR_INVALID_LDT_SIZE 0x00000231 +#define ERROR_INVALID_LDT_OFFSET 0x00000233 +#define ERROR_INVALID_LDT_DESCRIPTOR 0x00000234 +#define ERROR_TOO_MANY_THREADS 0x00000235 +#define ERROR_THREAD_NOT_IN_PROCESS 0x00000236 +#define ERROR_PAGEFILE_QUOTA_EXCEEDED 0x00000237 +#define ERROR_LOGON_SERVER_CONFLICT 0x00000238 +#define ERROR_SYNCHRONIZATION_REQUIRED 0x00000239 +#define ERROR_NET_OPEN_FAILED 0x0000023A +#define ERROR_IO_PRIVILEGE_FAILED 0x0000023B +#define ERROR_CONTROL_C_EXIT 0x0000023C +#define ERROR_MISSING_SYSTEMFILE 0x0000023D +#define ERROR_UNHANDLED_EXCEPTION 0x0000023E +#define ERROR_APP_INIT_FAILURE 0x0000023F +#define ERROR_PAGEFILE_CREATE_FAILED 0x00000240 +#define ERROR_INVALID_IMAGE_HASH 0x00000241 +#define ERROR_NO_PAGEFILE 0x00000242 +#define ERROR_ILLEGAL_FLOAT_CONTEXT 0x00000243 +#define ERROR_NO_EVENT_PAIR 0x00000244 +#define ERROR_DOMAIN_CTRLR_CONFIG_ERROR 0x00000245 +#define ERROR_ILLEGAL_CHARACTER 0x00000246 +#define ERROR_UNDEFINED_CHARACTER 0x00000247 +#define ERROR_FLOPPY_VOLUME 0x00000248 +#define ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT 0x00000249 +#define ERROR_BACKUP_CONTROLLER 0x0000024A +#define ERROR_MUTANT_LIMIT_EXCEEDED 0x0000024B +#define ERROR_FS_DRIVER_REQUIRED 0x0000024C +#define ERROR_CANNOT_LOAD_REGISTRY_FILE 0x0000024D +#define ERROR_DEBUG_ATTACH_FAILED 0x0000024E +#define ERROR_SYSTEM_PROCESS_TERMINATED 0x0000024F +#define ERROR_DATA_NOT_ACCEPTED 0x00000250 +#define ERROR_VDM_HARD_ERROR 0x00000251 +#define ERROR_DRIVER_CANCEL_TIMEOUT 0x00000252 +#define ERROR_REPLY_MESSAGE_MISMATCH 0x00000253 +#define ERROR_LOST_WRITEBEHIND_DATA 0x00000254 +#define ERROR_CLIENT_SERVER_PARAMETERS_INVALID 0x00000255 +#define ERROR_NOT_TINY_STREAM 0x00000256 +#define ERROR_STACK_OVERFLOW_READ 0x00000257 +#define ERROR_CONVERT_TO_LARGE 0x00000258 +#define ERROR_FOUND_OUT_OF_SCOPE 0x00000259 +#define ERROR_ALLOCATE_BUCKET 0x0000025A +#define ERROR_MARSHALL_OVERFLOW 0x0000025B +#define ERROR_INVALID_VARIANT 0x0000025C +#define ERROR_BAD_COMPRESSION_BUFFER 0x0000025D +#define ERROR_AUDIT_FAILED 0x0000025E +#define ERROR_TIMER_RESOLUTION_NOT_SET 0x0000025F +#define ERROR_INSUFFICIENT_LOGON_INFO 0x00000260 +#define ERROR_BAD_DLL_ENTRYPOINT 0x00000261 +#define ERROR_BAD_SERVICE_ENTRYPOINT 0x00000262 +#define ERROR_IP_ADDRESS_CONFLICT1 0x00000263 +#define ERROR_IP_ADDRESS_CONFLICT2 0x00000264 +#define ERROR_REGISTRY_QUOTA_LIMIT 0x00000265 +#define ERROR_NO_CALLBACK_ACTIVE 0x00000266 +#define ERROR_PWD_TOO_SHORT 0x00000267 +#define ERROR_PWD_TOO_RECENT 0x00000268 +#define ERROR_PWD_HISTORY_CONFLICT 0x00000269 +#define ERROR_UNSUPPORTED_COMPRESSION 0x0000026A +#define ERROR_INVALID_HW_PROFILE 0x0000026B +#define ERROR_INVALID_PLUGPLAY_DEVICE_PATH 0x0000026C +#define ERROR_QUOTA_LIST_INCONSISTENT 0x0000026D +#define ERROR_EVALUATION_EXPIRATION 0x0000026E +#define ERROR_ILLEGAL_DLL_RELOCATION 0x0000026F +#define ERROR_DLL_INIT_FAILED_LOGOFF 0x00000270 +#define ERROR_VALIDATE_CONTINUE 0x00000271 +#define ERROR_NO_MORE_MATCHES 0x00000272 +#define ERROR_RANGE_LIST_CONFLICT 0x00000273 +#define ERROR_SERVER_SID_MISMATCH 0x00000274 +#define ERROR_CANT_ENABLE_DENY_ONLY 0x00000275 +#define ERROR_FLOAT_MULTIPLE_FAULTS 0x00000276 +#define ERROR_FLOAT_MULTIPLE_TRAPS 0x00000277 +#define ERROR_NOINTERFACE 0x00000278 +#define ERROR_DRIVER_FAILED_SLEEP 0x00000279 +#define ERROR_CORRUPT_SYSTEM_FILE 0x0000027A +#define ERROR_COMMITMENT_MINIMUM 0x0000027B +#define ERROR_PNP_RESTART_ENUMERATION 0x0000027C +#define ERROR_SYSTEM_IMAGE_BAD_SIGNATURE 0x0000027D +#define ERROR_PNP_REBOOT_REQUIRED 0x0000027E +#define ERROR_INSUFFICIENT_POWER 0x0000027F +#define ERROR_MULTIPLE_FAULT_VIOLATION 0x00000280 +#define ERROR_SYSTEM_SHUTDOWN 0x00000281 +#define ERROR_PORT_NOT_SET 0x00000282 +#define ERROR_DS_VERSION_CHECK_FAILURE 0x00000283 +#define ERROR_RANGE_NOT_FOUND 0x00000284 +#define ERROR_NOT_SAFE_MODE_DRIVER 0x00000286 +#define ERROR_FAILED_DRIVER_ENTRY 0x00000287 +#define ERROR_DEVICE_ENUMERATION_ERROR 0x00000288 +#define ERROR_MOUNT_POINT_NOT_RESOLVED 0x00000289 +#define ERROR_INVALID_DEVICE_OBJECT_PARAMETER 0x0000028A +#define ERROR_MCA_OCCURED 0x0000028B +#define ERROR_DRIVER_DATABASE_ERROR 0x0000028C +#define ERROR_SYSTEM_HIVE_TOO_LARGE 0x0000028D +#define ERROR_DRIVER_FAILED_PRIOR_UNLOAD 0x0000028E +#define ERROR_VOLSNAP_PREPARE_HIBERNATE 0x0000028F +#define ERROR_HIBERNATION_FAILURE 0x00000290 +#define ERROR_PWD_TOO_LONG 0x00000291 +#define ERROR_FILE_SYSTEM_LIMITATION 0x00000299 +#define ERROR_ASSERTION_FAILURE 0x0000029C +#define ERROR_ACPI_ERROR 0x0000029D +#define ERROR_WOW_ASSERTION 0x0000029E +#define ERROR_PNP_BAD_MPS_TABLE 0x0000029F +#define ERROR_PNP_TRANSLATION_FAILED 0x000002A0 +#define ERROR_PNP_IRQ_TRANSLATION_FAILED 0x000002A1 +#define ERROR_PNP_INVALID_ID 0x000002A2 +#define ERROR_WAKE_SYSTEM_DEBUGGER 0x000002A3 +#define ERROR_HANDLES_CLOSED 0x000002A4 +#define ERROR_EXTRANEOUS_INFORMATION 0x000002A5 +#define ERROR_RXACT_COMMIT_NECESSARY 0x000002A6 +#define ERROR_MEDIA_CHECK 0x000002A7 +#define ERROR_GUID_SUBSTITUTION_MADE 0x000002A8 +#define ERROR_STOPPED_ON_SYMLINK 0x000002A9 +#define ERROR_LONGJUMP 0x000002AA +#define ERROR_PLUGPLAY_QUERY_VETOED 0x000002AB +#define ERROR_UNWIND_CONSOLIDATE 0x000002AC +#define ERROR_REGISTRY_HIVE_RECOVERED 0x000002AD +#define ERROR_DLL_MIGHT_BE_INSECURE 0x000002AE +#define ERROR_DLL_MIGHT_BE_INCOMPATIBLE 0x000002AF +#define ERROR_DBG_EXCEPTION_NOT_HANDLED 0x000002B0 +#define ERROR_DBG_REPLY_LATER 0x000002B1 +#define ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE 0x000002B2 +#define ERROR_DBG_TERMINATE_THREAD 0x000002B3 +#define ERROR_DBG_TERMINATE_PROCESS 0x000002B4 +#define ERROR_DBG_CONTROL_C 0x000002B5 +#define ERROR_DBG_PRINTEXCEPTION_C 0x000002B6 +#define ERROR_DBG_RIPEXCEPTION 0x000002B7 +#define ERROR_DBG_CONTROL_BREAK 0x000002B8 +#define ERROR_DBG_COMMAND_EXCEPTION 0x000002B9 +#define ERROR_OBJECT_NAME_EXISTS 0x000002BA +#define ERROR_THREAD_WAS_SUSPENDED 0x000002BB +#define ERROR_IMAGE_NOT_AT_BASE 0x000002BC +#define ERROR_RXACT_STATE_CREATED 0x000002BD +#define ERROR_SEGMENT_NOTIFICATION 0x000002BE +#define ERROR_BAD_CURRENT_DIRECTORY 0x000002BF +#define ERROR_FT_READ_RECOVERY_FROM_BACKUP 0x000002C0 +#define ERROR_FT_WRITE_RECOVERY 0x000002C1 +#define ERROR_IMAGE_MACHINE_TYPE_MISMATCH 0x000002C2 +#define ERROR_RECEIVE_PARTIAL 0x000002C3 +#define ERROR_RECEIVE_EXPEDITED 0x000002C4 +#define ERROR_RECEIVE_PARTIAL_EXPEDITED 0x000002C5 +#define ERROR_EVENT_DONE 0x000002C6 +#define ERROR_EVENT_PENDING 0x000002C7 +#define ERROR_CHECKING_FILE_SYSTEM 0x000002C8 +#define ERROR_FATAL_APP_EXIT 0x000002C9 +#define ERROR_PREDEFINED_HANDLE 0x000002CA +#define ERROR_WAS_UNLOCKED 0x000002CB +#define ERROR_SERVICE_NOTIFICATION 0x000002CC +#define ERROR_WAS_LOCKED 0x000002CD +#define ERROR_LOG_HARD_ERROR 0x000002CE +#define ERROR_ALREADY_WIN32 0x000002CF +#define ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE 0x000002D0 +#define ERROR_NO_YIELD_PERFORMED 0x000002D1 +#define ERROR_TIMER_RESUME_IGNORED 0x000002D2 +#define ERROR_ARBITRATION_UNHANDLED 0x000002D3 +#define ERROR_CARDBUS_NOT_SUPPORTED 0x000002D4 +#define ERROR_MP_PROCESSOR_MISMATCH 0x000002D5 +#define ERROR_HIBERNATED 0x000002D6 +#define ERROR_RESUME_HIBERNATION 0x000002D7 +#define ERROR_FIRMWARE_UPDATED 0x000002D8 +#define ERROR_DRIVERS_LEAKING_LOCKED_PAGES 0x000002D9 +#define ERROR_WAKE_SYSTEM 0x000002DA +#define ERROR_WAIT_1 0x000002DB +#define ERROR_WAIT_2 0x000002DC +#define ERROR_WAIT_3 0x000002DD +#define ERROR_WAIT_63 0x000002DE +#define ERROR_ABANDONED_WAIT_0 0x000002DF +#define ERROR_ABANDONED_WAIT_63 0x000002E0 +#define ERROR_USER_APC 0x000002E1 +#define ERROR_KERNEL_APC 0x000002E2 +#define ERROR_ALERTED 0x000002E3 +#define ERROR_ELEVATION_REQUIRED 0x000002E4 +#define ERROR_REPARSE 0x000002E5 +#define ERROR_OPLOCK_BREAK_IN_PROGRESS 0x000002E6 +#define ERROR_VOLUME_MOUNTED 0x000002E7 +#define ERROR_RXACT_COMMITTED 0x000002E8 +#define ERROR_NOTIFY_CLEANUP 0x000002E9 +#define ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED 0x000002EA +#define ERROR_PAGE_FAULT_TRANSITION 0x000002EB +#define ERROR_PAGE_FAULT_DEMAND_ZERO 0x000002EC +#define ERROR_PAGE_FAULT_COPY_ON_WRITE 0x000002ED +#define ERROR_PAGE_FAULT_GUARD_PAGE 0x000002EE +#define ERROR_PAGE_FAULT_PAGING_FILE 0x000002EF +#define ERROR_CACHE_PAGE_LOCKED 0x000002F0 +#define ERROR_CRASH_DUMP 0x000002F1 +#define ERROR_BUFFER_ALL_ZEROS 0x000002F2 +#define ERROR_REPARSE_OBJECT 0x000002F3 +#define ERROR_RESOURCE_REQUIREMENTS_CHANGED 0x000002F4 +#define ERROR_TRANSLATION_COMPLETE 0x000002F5 +#define ERROR_NOTHING_TO_TERMINATE 0x000002F6 +#define ERROR_PROCESS_NOT_IN_JOB 0x000002F7 +#define ERROR_PROCESS_IN_JOB 0x000002F8 +#define ERROR_VOLSNAP_HIBERNATE_READY 0x000002F9 +#define ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY 0x000002FA +#define ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED 0x000002FB +#define ERROR_INTERRUPT_STILL_CONNECTED 0x000002FC +#define ERROR_WAIT_FOR_OPLOCK 0x000002FD +#define ERROR_DBG_EXCEPTION_HANDLED 0x000002FE +#define ERROR_DBG_CONTINUE 0x000002FF +#define ERROR_CALLBACK_POP_STACK 0x00000300 +#define ERROR_COMPRESSION_DISABLED 0x00000301 +#define ERROR_CANTFETCHBACKWARDS 0x00000302 +#define ERROR_CANTSCROLLBACKWARDS 0x00000303 +#define ERROR_ROWSNOTRELEASED 0x00000304 +#define ERROR_BAD_ACCESSOR_FLAGS 0x00000305 +#define ERROR_ERRORS_ENCOUNTERED 0x00000306 +#define ERROR_NOT_CAPABLE 0x00000307 +#define ERROR_REQUEST_OUT_OF_SEQUENCE 0x00000308 +#define ERROR_VERSION_PARSE_ERROR 0x00000309 +#define ERROR_BADSTARTPOSITION 0x0000030A +#define ERROR_MEMORY_HARDWARE 0x0000030B +#define ERROR_DISK_REPAIR_DISABLED 0x0000030C +#define ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE 0x0000030D +#define ERROR_SYSTEM_POWERSTATE_TRANSITION 0x0000030E +#define ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION 0x0000030F +#define ERROR_MCA_EXCEPTION 0x00000310 +#define ERROR_ACCESS_AUDIT_BY_POLICY 0x00000311 +#define ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY 0x00000312 +#define ERROR_ABANDON_HIBERFILE 0x00000313 +#define ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED 0x00000314 +#define ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR 0x00000315 +#define ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR 0x00000316 +#define ERROR_BAD_MCFG_TABLE 0x00000317 +#define ERROR_DISK_REPAIR_REDIRECTED 0x00000318 +#define ERROR_DISK_REPAIR_UNSUCCESSFUL 0x00000319 +#define ERROR_CORRUPT_LOG_OVERFULL 0x0000031A +#define ERROR_CORRUPT_LOG_CORRUPTED 0x0000031B +#define ERROR_CORRUPT_LOG_UNAVAILABLE 0x0000031C +#define ERROR_CORRUPT_LOG_DELETED_FULL 0x0000031D +#define ERROR_CORRUPT_LOG_CLEARED 0x0000031E +#define ERROR_ORPHAN_NAME_EXHAUSTED 0x0000031F +#define ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE 0x00000320 +#define ERROR_CANNOT_GRANT_REQUESTED_OPLOCK 0x00000321 +#define ERROR_CANNOT_BREAK_OPLOCK 0x00000322 +#define ERROR_OPLOCK_HANDLE_CLOSED 0x00000323 +#define ERROR_NO_ACE_CONDITION 0x00000324 +#define ERROR_INVALID_ACE_CONDITION 0x00000325 +#define ERROR_FILE_HANDLE_REVOKED 0x00000326 +#define ERROR_IMAGE_AT_DIFFERENT_BASE 0x00000327 +#define ERROR_EA_ACCESS_DENIED 0x000003E2 +#define ERROR_OPERATION_ABORTED 0x000003E3 +#define ERROR_IO_INCOMPLETE 0x000003E4 +#define ERROR_IO_PENDING 0x000003E5 +#define ERROR_NOACCESS 0x000003E6 +#define ERROR_SWAPERROR 0x000003E7 + +/* System Error Codes (1000-1299) */ + +#define ERROR_STACK_OVERFLOW 0x000003E9 +#define ERROR_INVALID_MESSAGE 0x000003EA +#define ERROR_CAN_NOT_COMPLETE 0x000003EB +#define ERROR_INVALID_FLAGS 0x000003EC +#define ERROR_UNRECOGNIZED_VOLUME 0x000003ED +#define ERROR_FILE_INVALID 0x000003EE +#define ERROR_FULLSCREEN_MODE 0x000003EF +#define ERROR_NO_TOKEN 0x000003F0 +#define ERROR_BADDB 0x000003F1 +#define ERROR_BADKEY 0x000003F2 +#define ERROR_CANTOPEN 0x000003F3 +#define ERROR_CANTREAD 0x000003F4 +#define ERROR_CANTWRITE 0x000003F5 +#define ERROR_REGISTRY_RECOVERED 0x000003F6 +#define ERROR_REGISTRY_CORRUPT 0x000003F7 +#define ERROR_REGISTRY_IO_FAILED 0x000003F8 +#define ERROR_NOT_REGISTRY_FILE 0x000003F9 +#define ERROR_KEY_DELETED 0x000003FA +#define ERROR_NO_LOG_SPACE 0x000003FB +#define ERROR_KEY_HAS_CHILDREN 0x000003FC +#define ERROR_CHILD_MUST_BE_VOLATILE 0x000003FD +#define ERROR_NOTIFY_ENUM_DIR 0x000003FE +#define ERROR_DEPENDENT_SERVICES_RUNNING 0x0000041B +#define ERROR_INVALID_SERVICE_CONTROL 0x0000041C +#define ERROR_SERVICE_REQUEST_TIMEOUT 0x0000041D +#define ERROR_SERVICE_NO_THREAD 0x0000041E +#define ERROR_SERVICE_DATABASE_LOCKED 0x0000041F +#define ERROR_SERVICE_ALREADY_RUNNING 0x00000420 +#define ERROR_INVALID_SERVICE_ACCOUNT 0x00000421 +#define ERROR_SERVICE_DISABLED 0x00000422 +#define ERROR_CIRCULAR_DEPENDENCY 0x00000423 +#define ERROR_SERVICE_DOES_NOT_EXIST 0x00000424 +#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 0x00000425 +#define ERROR_SERVICE_NOT_ACTIVE 0x00000426 +#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 0x00000427 +#define ERROR_EXCEPTION_IN_SERVICE 0x00000428 +#define ERROR_DATABASE_DOES_NOT_EXIST 0x00000429 +#define ERROR_SERVICE_SPECIFIC_ERROR 0x0000042A +#define ERROR_PROCESS_ABORTED 0x0000042B +#define ERROR_SERVICE_DEPENDENCY_FAIL 0x0000042C +#define ERROR_SERVICE_LOGON_FAILED 0x0000042D +#define ERROR_SERVICE_START_HANG 0x0000042E +#define ERROR_INVALID_SERVICE_LOCK 0x0000042F +#define ERROR_SERVICE_MARKED_FOR_DELETE 0x00000430 +#define ERROR_SERVICE_EXISTS 0x00000431 +#define ERROR_ALREADY_RUNNING_LKG 0x00000432 +#define ERROR_SERVICE_DEPENDENCY_DELETED 0x00000433 +#define ERROR_BOOT_ALREADY_ACCEPTED 0x00000434 +#define ERROR_SERVICE_NEVER_STARTED 0x00000435 +#define ERROR_DUPLICATE_SERVICE_NAME 0x00000436 +#define ERROR_DIFFERENT_SERVICE_ACCOUNT 0x00000437 +#define ERROR_CANNOT_DETECT_DRIVER_FAILURE 0x00000438 +#define ERROR_CANNOT_DETECT_PROCESS_ABORT 0x00000439 +#define ERROR_NO_RECOVERY_PROGRAM 0x0000043A +#define ERROR_SERVICE_NOT_IN_EXE 0x0000043B +#define ERROR_NOT_SAFEBOOT_SERVICE 0x0000043C +#define ERROR_END_OF_MEDIA 0x0000044C +#define ERROR_FILEMARK_DETECTED 0x0000044D +#define ERROR_BEGINNING_OF_MEDIA 0x0000044E +#define ERROR_SETMARK_DETECTED 0x0000044F +#define ERROR_NO_DATA_DETECTED 0x00000450 +#define ERROR_PARTITION_FAILURE 0x00000451 +#define ERROR_INVALID_BLOCK_LENGTH 0x00000452 +#define ERROR_DEVICE_NOT_PARTITIONED 0x00000453 +#define ERROR_UNABLE_TO_LOCK_MEDIA 0x00000454 +#define ERROR_UNABLE_TO_UNLOAD_MEDIA 0x00000455 +#define ERROR_MEDIA_CHANGED 0x00000456 +#define ERROR_BUS_RESET 0x00000457 +#define ERROR_NO_MEDIA_IN_DRIVE 0x00000458 +#define ERROR_NO_UNICODE_TRANSLATION 0x00000459 +#define ERROR_DLL_INIT_FAILED 0x0000045A +#define ERROR_SHUTDOWN_IN_PROGRESS 0x0000045B +#define ERROR_NO_SHUTDOWN_IN_PROGRESS 0x0000045C +#define ERROR_IO_DEVICE 0x0000045D +#define ERROR_SERIAL_NO_DEVICE 0x0000045E +#define ERROR_IRQ_BUSY 0x0000045F +#define ERROR_MORE_WRITES 0x00000460 +#define ERROR_COUNTER_TIMEOUT 0x00000461 +#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 0x00000462 +#define ERROR_FLOPPY_WRONG_CYLINDER 0x00000463 +#define ERROR_FLOPPY_UNKNOWN_ERROR 0x00000464 +#define ERROR_FLOPPY_BAD_REGISTERS 0x00000465 +#define ERROR_DISK_RECALIBRATE_FAILED 0x00000466 +#define ERROR_DISK_OPERATION_FAILED 0x00000467 +#define ERROR_DISK_RESET_FAILED 0x00000468 +#define ERROR_EOM_OVERFLOW 0x00000469 +#define ERROR_NOT_ENOUGH_SERVER_MEMORY 0x0000046A +#define ERROR_POSSIBLE_DEADLOCK 0x0000046B +#define ERROR_MAPPED_ALIGNMENT 0x0000046C +#define ERROR_SET_POWER_STATE_VETOED 0x00000474 +#define ERROR_SET_POWER_STATE_FAILED 0x00000475 +#define ERROR_TOO_MANY_LINKS 0x00000476 +#define ERROR_OLD_WIN_VERSION 0x0000047E +#define ERROR_APP_WRONG_OS 0x0000047F +#define ERROR_SINGLE_INSTANCE_APP 0x00000480 +#define ERROR_RMODE_APP 0x00000481 +#define ERROR_INVALID_DLL 0x00000482 +#define ERROR_NO_ASSOCIATION 0x00000483 +#define ERROR_DDE_FAIL 0x00000484 +#define ERROR_DLL_NOT_FOUND 0x00000485 +#define ERROR_NO_MORE_USER_HANDLES 0x00000486 +#define ERROR_MESSAGE_SYNC_ONLY 0x00000487 +#define ERROR_SOURCE_ELEMENT_EMPTY 0x00000488 +#define ERROR_DESTINATION_ELEMENT_FULL 0x00000489 +#define ERROR_ILLEGAL_ELEMENT_ADDRESS 0x0000048A +#define ERROR_MAGAZINE_NOT_PRESENT 0x0000048B +#define ERROR_DEVICE_REINITIALIZATION_NEEDED 0x0000048C +#define ERROR_DEVICE_REQUIRES_CLEANING 0x0000048D +#define ERROR_DEVICE_DOOR_OPEN 0x0000048E +#define ERROR_DEVICE_NOT_CONNECTED 0x0000048F +#define ERROR_NOT_FOUND 0x00000490 +#define ERROR_NO_MATCH 0x00000491 +#define ERROR_SET_NOT_FOUND 0x00000492 +#define ERROR_POINT_NOT_FOUND 0x00000493 +#define ERROR_NO_TRACKING_SERVICE 0x00000494 +#define ERROR_NO_VOLUME_ID 0x00000495 +#define ERROR_UNABLE_TO_REMOVE_REPLACED 0x00000497 +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT 0x00000498 +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 0x00000499 +#define ERROR_JOURNAL_DELETE_IN_PROGRESS 0x0000049A +#define ERROR_JOURNAL_NOT_ACTIVE 0x0000049B +#define ERROR_POTENTIAL_FILE_FOUND 0x0000049C +#define ERROR_JOURNAL_ENTRY_DELETED 0x0000049D +#define ERROR_SHUTDOWN_IS_SCHEDULED 0x000004A6 +#define ERROR_SHUTDOWN_USERS_LOGGED_ON 0x000004A7 +#define ERROR_BAD_DEVICE 0x000004B0 +#define ERROR_CONNECTION_UNAVAIL 0x000004B1 +#define ERROR_DEVICE_ALREADY_REMEMBERED 0x000004B2 +#define ERROR_NO_NET_OR_BAD_PATH 0x000004B3 +#define ERROR_BAD_PROVIDER 0x000004B4 +#define ERROR_CANNOT_OPEN_PROFILE 0x000004B5 +#define ERROR_BAD_PROFILE 0x000004B6 +#define ERROR_NOT_CONTAINER 0x000004B7 +#define ERROR_EXTENDED_ERROR 0x000004B8 +#define ERROR_INVALID_GROUPNAME 0x000004B9 +#define ERROR_INVALID_COMPUTERNAME 0x000004BA +#define ERROR_INVALID_EVENTNAME 0x000004BB +#define ERROR_INVALID_DOMAINNAME 0x000004BC +#define ERROR_INVALID_SERVICENAME 0x000004BD +#define ERROR_INVALID_NETNAME 0x000004BE +#define ERROR_INVALID_SHARENAME 0x000004BF +#define ERROR_INVALID_PASSWORDNAME 0x000004C0 +#define ERROR_INVALID_MESSAGENAME 0x000004C1 +#define ERROR_INVALID_MESSAGEDEST 0x000004C2 +#define ERROR_SESSION_CREDENTIAL_CONFLICT 0x000004C3 +#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 0x000004C4 +#define ERROR_DUP_DOMAINNAME 0x000004C5 +#define ERROR_NO_NETWORK 0x000004C6 +#define ERROR_CANCELLED 0x000004C7 +#define ERROR_USER_MAPPED_FILE 0x000004C8 +#define ERROR_CONNECTION_REFUSED 0x000004C9 +#define ERROR_GRACEFUL_DISCONNECT 0x000004CA +#define ERROR_ADDRESS_ALREADY_ASSOCIATED 0x000004CB +#define ERROR_ADDRESS_NOT_ASSOCIATED 0x000004CC +#define ERROR_CONNECTION_INVALID 0x000004CD +#define ERROR_CONNECTION_ACTIVE 0x000004CE +#define ERROR_NETWORK_UNREACHABLE 0x000004CF +#define ERROR_HOST_UNREACHABLE 0x000004D0 +#define ERROR_PROTOCOL_UNREACHABLE 0x000004D1 +#define ERROR_PORT_UNREACHABLE 0x000004D2 +#define ERROR_REQUEST_ABORTED 0x000004D3 +#define ERROR_CONNECTION_ABORTED 0x000004D4 +#define ERROR_RETRY 0x000004D5 +#define ERROR_CONNECTION_COUNT_LIMIT 0x000004D6 +#define ERROR_LOGIN_TIME_RESTRICTION 0x000004D7 +#define ERROR_LOGIN_WKSTA_RESTRICTION 0x000004D8 +#define ERROR_INCORRECT_ADDRESS 0x000004D9 +#define ERROR_ALREADY_REGISTERED 0x000004DA +#define ERROR_SERVICE_NOT_FOUND 0x000004DB +#define ERROR_NOT_AUTHENTICATED 0x000004DC +#define ERROR_NOT_LOGGED_ON 0x000004DD +#define ERROR_CONTINUE 0x000004DE +#define ERROR_ALREADY_INITIALIZED 0x000004DF +#define ERROR_NO_MORE_DEVICES 0x000004E0 +#define ERROR_NO_SUCH_SITE 0x000004E1 +#define ERROR_DOMAIN_CONTROLLER_EXISTS 0x000004E2 +#define ERROR_ONLY_IF_CONNECTED 0x000004E3 +#define ERROR_OVERRIDE_NOCHANGES 0x000004E4 +#define ERROR_BAD_USER_PROFILE 0x000004E5 +#define ERROR_NOT_SUPPORTED_ON_SBS 0x000004E6 +#define ERROR_SERVER_SHUTDOWN_IN_PROGRESS 0x000004E7 +#define ERROR_HOST_DOWN 0x000004E8 +#define ERROR_NON_ACCOUNT_SID 0x000004E9 +#define ERROR_NON_DOMAIN_SID 0x000004EA +#define ERROR_APPHELP_BLOCK 0x000004EB +#define ERROR_ACCESS_DISABLED_BY_POLICY 0x000004EC +#define ERROR_REG_NAT_CONSUMPTION 0x000004ED +#define ERROR_CSCSHARE_OFFLINE 0x000004EE +#define ERROR_PKINIT_FAILURE 0x000004EF +#define ERROR_SMARTCARD_SUBSYSTEM_FAILURE 0x000004F0 +#define ERROR_DOWNGRADE_DETECTED 0x000004F1 +#define ERROR_MACHINE_LOCKED 0x000004F7 +#define ERROR_CALLBACK_SUPPLIED_INVALID_DATA 0x000004F9 +#define ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED 0x000004FA +#define ERROR_DRIVER_BLOCKED 0x000004FB +#define ERROR_INVALID_IMPORT_OF_NON_DLL 0x000004FC +#define ERROR_ACCESS_DISABLED_WEBBLADE 0x000004FD +#define ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER 0x000004FE +#define ERROR_RECOVERY_FAILURE 0x000004FF +#define ERROR_ALREADY_FIBER 0x00000500 +#define ERROR_ALREADY_THREAD 0x00000501 +#define ERROR_STACK_BUFFER_OVERRUN 0x00000502 +#define ERROR_PARAMETER_QUOTA_EXCEEDED 0x00000503 +#define ERROR_DEBUGGER_INACTIVE 0x00000504 +#define ERROR_DELAY_LOAD_FAILED 0x00000505 +#define ERROR_VDM_DISALLOWED 0x00000506 +#define ERROR_UNIDENTIFIED_ERROR 0x00000507 +#define ERROR_INVALID_CRUNTIME_PARAMETER 0x00000508 +#define ERROR_BEYOND_VDL 0x00000509 +#define ERROR_INCOMPATIBLE_SERVICE_SID_TYPE 0x0000050A +#define ERROR_DRIVER_PROCESS_TERMINATED 0x0000050B +#define ERROR_IMPLEMENTATION_LIMIT 0x0000050C +#define ERROR_PROCESS_IS_PROTECTED 0x0000050D +#define ERROR_SERVICE_NOTIFY_CLIENT_LAGGING 0x0000050E +#define ERROR_DISK_QUOTA_EXCEEDED 0x0000050F +#define ERROR_CONTENT_BLOCKED 0x00000510 +#define ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE 0x00000511 +#define ERROR_APP_HANG 0x00000512 +#define ERROR_INVALID_LABEL 0x00000513 + +/* System Error Codes (1300-1699) */ +#define ERROR_NOT_ALL_ASSIGNED 0x00000514 +#define ERROR_SOME_NOT_MAPPED 0x00000515 +#define ERROR_NO_QUOTAS_FOR_ACCOUNT 0x00000516 +#define ERROR_LOCAL_USER_SESSION_KEY 0x00000517 +#define ERROR_NULL_LM_PASSWORD 0x00000518 +#define ERROR_UNKNOWN_REVISION 0x00000519 +#define ERROR_REVISION_MISMATCH 0x0000051A +#define ERROR_INVALID_OWNER 0x0000051B +#define ERROR_INVALID_PRIMARY_GROUP 0x0000051C +#define ERROR_NO_IMPERSONATION_TOKEN 0x0000051D +#define ERROR_CANT_DISABLE_MANDATORY 0x0000051E +#define ERROR_NO_LOGON_SERVERS 0x0000051F +#define ERROR_NO_SUCH_LOGON_SESSION 0x00000520 +#define ERROR_NO_SUCH_PRIVILEGE 0x00000521 +#define ERROR_PRIVILEGE_NOT_HELD 0x00000522 +#define ERROR_INVALID_ACCOUNT_NAME 0x00000523 +#define ERROR_USER_EXISTS 0x00000524 +#define ERROR_NO_SUCH_USER 0x00000525 +#define ERROR_GROUP_EXISTS 0x00000526 +#define ERROR_NO_SUCH_GROUP 0x00000527 +#define ERROR_MEMBER_IN_GROUP 0x00000528 +#define ERROR_MEMBER_NOT_IN_GROUP 0x00000529 +#define ERROR_LAST_ADMIN 0x0000052A +#define ERROR_WRONG_PASSWORD 0x0000052B +#define ERROR_ILL_FORMED_PASSWORD 0x0000052C +#define ERROR_PASSWORD_RESTRICTION 0x0000052D +#define ERROR_LOGON_FAILURE 0x0000052E +#define ERROR_ACCOUNT_RESTRICTION 0x0000052F +#define ERROR_INVALID_LOGON_HOURS 0x00000530 +#define ERROR_INVALID_WORKSTATION 0x00000531 +#define ERROR_PASSWORD_EXPIRED 0x00000532 +#define ERROR_ACCOUNT_DISABLED 0x00000533 +#define ERROR_NONE_MAPPED 0x00000534 +#define ERROR_TOO_MANY_LUIDS_REQUESTED 0x00000535 +#define ERROR_LUIDS_EXHAUSTED 0x00000536 +#define ERROR_INVALID_SUB_AUTHORITY 0x00000537 +#define ERROR_INVALID_ACL 0x00000538 +#define ERROR_INVALID_SID 0x00000539 +#define ERROR_INVALID_SECURITY_DESCR 0x0000053A +#define ERROR_BAD_INHERITANCE_ACL 0x0000053C +#define ERROR_SERVER_DISABLED 0x0000053D +#define ERROR_SERVER_NOT_DISABLED 0x0000053E +#define ERROR_INVALID_ID_AUTHORITY 0x0000053F +#define ERROR_ALLOTTED_SPACE_EXCEEDED 0x00000540 +#define ERROR_INVALID_GROUP_ATTRIBUTES 0x00000541 +#define ERROR_BAD_IMPERSONATION_LEVEL 0x00000542 +#define ERROR_CANT_OPEN_ANONYMOUS 0x00000543 +#define ERROR_BAD_VALIDATION_CLASS 0x00000544 +#define ERROR_BAD_TOKEN_TYPE 0x00000545 +#define ERROR_NO_SECURITY_ON_OBJECT 0x00000546 +#define ERROR_CANT_ACCESS_DOMAIN_INFO 0x00000547 +#define ERROR_INVALID_SERVER_STATE 0x00000548 +#define ERROR_INVALID_DOMAIN_STATE 0x00000549 +#define ERROR_INVALID_DOMAIN_ROLE 0x0000054A +#define ERROR_NO_SUCH_DOMAIN 0x0000054B +#define ERROR_DOMAIN_EXISTS 0x0000054C +#define ERROR_DOMAIN_LIMIT_EXCEEDED 0x0000054D +#define ERROR_INTERNAL_DB_CORRUPTION 0x0000054E +#define ERROR_INTERNAL_ERROR 0x0000054F +#define ERROR_GENERIC_NOT_MAPPED 0x00000550 +#define ERROR_BAD_DESCRIPTOR_FORMAT 0x00000551 +#define ERROR_NOT_LOGON_PROCESS 0x00000552 +#define ERROR_LOGON_SESSION_EXISTS 0x00000553 +#define ERROR_NO_SUCH_PACKAGE 0x00000554 +#define ERROR_BAD_LOGON_SESSION_STATE 0x00000555 +#define ERROR_LOGON_SESSION_COLLISION 0x00000556 +#define ERROR_INVALID_LOGON_TYPE 0x00000557 +#define ERROR_CANNOT_IMPERSONATE 0x00000558 +#define ERROR_RXACT_INVALID_STATE 0x00000559 +#define ERROR_RXACT_COMMIT_FAILURE 0x0000055A +#define ERROR_SPECIAL_ACCOUNT 0x0000055B +#define ERROR_SPECIAL_GROUP 0x0000055C +#define ERROR_SPECIAL_USER 0x0000055D +#define ERROR_MEMBERS_PRIMARY_GROUP 0x0000055E +#define ERROR_TOKEN_ALREADY_IN_USE 0x0000055F +#define ERROR_NO_SUCH_ALIAS 0x00000560 +#define ERROR_MEMBER_NOT_IN_ALIAS 0x00000561 +#define ERROR_MEMBER_IN_ALIAS 0x00000562 +#define ERROR_ALIAS_EXISTS 0x00000563 +#define ERROR_LOGON_NOT_GRANTED 0x00000564 +#define ERROR_TOO_MANY_SECRETS 0x00000565 +#define ERROR_SECRET_TOO_LONG 0x00000566 +#define ERROR_INTERNAL_DB_ERROR 0x00000567 +#define ERROR_TOO_MANY_CONTEXT_IDS 0x00000568 +#define ERROR_LOGON_TYPE_NOT_GRANTED 0x00000569 +#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 0x0000056A +#define ERROR_NO_SUCH_MEMBER 0x0000056B +#define ERROR_INVALID_MEMBER 0x0000056C +#define ERROR_TOO_MANY_SIDS 0x0000056D +#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 0x0000056E +#define ERROR_NO_INHERITANCE 0x0000056F +#define ERROR_FILE_CORRUPT 0x00000570 +#define ERROR_DISK_CORRUPT 0x00000571 +#define ERROR_NO_USER_SESSION_KEY 0x00000572 +#define ERROR_LICENSE_QUOTA_EXCEEDED 0x00000573 +#define ERROR_WRONG_TARGET_NAME 0x00000574 +#define ERROR_MUTUAL_AUTH_FAILED 0x00000575 +#define ERROR_TIME_SKEW 0x00000576 +#define ERROR_CURRENT_DOMAIN_NOT_ALLOWED 0x00000577 +#define ERROR_INVALID_WINDOW_HANDLE 0x00000578 +#define ERROR_INVALID_MENU_HANDLE 0x00000579 +#define ERROR_INVALID_CURSOR_HANDLE 0x0000057A +#define ERROR_INVALID_ACCEL_HANDLE 0x0000057B +#define ERROR_INVALID_HOOK_HANDLE 0x0000057C +#define ERROR_INVALID_DWP_HANDLE 0x0000057D +#define ERROR_TLW_WITH_WSCHILD 0x0000057E +#define ERROR_CANNOT_FIND_WND_CLASS 0x0000057F +#define ERROR_WINDOW_OF_OTHER_THREAD 0x00000580 +#define ERROR_HOTKEY_ALREADY_REGISTERED 0x00000581 +#define ERROR_CLASS_ALREADY_EXISTS 0x00000582 +#define ERROR_CLASS_DOES_NOT_EXIST 0x00000583 +#define ERROR_CLASS_HAS_WINDOWS 0x00000584 +#define ERROR_INVALID_INDEX 0x00000585 +#define ERROR_INVALID_ICON_HANDLE 0x00000586 +#define ERROR_PRIVATE_DIALOG_INDEX 0x00000587 +#define ERROR_LISTBOX_ID_NOT_FOUND 0x00000588 +#define ERROR_NO_WILDCARD_CHARACTERS 0x00000589 +#define ERROR_CLIPBOARD_NOT_OPEN 0x0000058A +#define ERROR_HOTKEY_NOT_REGISTERED 0x0000058B +#define ERROR_WINDOW_NOT_DIALOG 0x0000058C +#define ERROR_CONTROL_ID_NOT_FOUND 0x0000058D +#define ERROR_INVALID_COMBOBOX_MESSAGE 0x0000058E +#define ERROR_WINDOW_NOT_COMBOBOX 0x0000058F +#define ERROR_INVALID_EDIT_HEIGHT 0x00000590 +#define ERROR_DC_NOT_FOUND 0x00000591 +#define ERROR_INVALID_HOOK_FILTER 0x00000592 +#define ERROR_INVALID_FILTER_PROC 0x00000593 +#define ERROR_HOOK_NEEDS_HMOD 0x00000594 +#define ERROR_GLOBAL_ONLY_HOOK 0x00000595 +#define ERROR_JOURNAL_HOOK_SET 0x00000596 +#define ERROR_HOOK_NOT_INSTALLED 0x00000597 +#define ERROR_INVALID_LB_MESSAGE 0x00000598 +#define ERROR_SETCOUNT_ON_BAD_LB 0x00000599 +#define ERROR_LB_WITHOUT_TABSTOPS 0x0000059A +#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 0x0000059B +#define ERROR_CHILD_WINDOW_MENU 0x0000059C +#define ERROR_NO_SYSTEM_MENU 0x0000059D +#define ERROR_INVALID_MSGBOX_STYLE 0x0000059E +#define ERROR_INVALID_SPI_VALUE 0x0000059F +#define ERROR_SCREEN_ALREADY_LOCKED 0x000005A0 +#define ERROR_HWNDS_HAVE_DIFF_PARENT 0x000005A1 +#define ERROR_NOT_CHILD_WINDOW 0x000005A2 +#define ERROR_INVALID_GW_COMMAND 0x000005A3 +#define ERROR_INVALID_THREAD_ID 0x000005A4 +#define ERROR_NON_MDICHILD_WINDOW 0x000005A5 +#define ERROR_POPUP_ALREADY_ACTIVE 0x000005A6 +#define ERROR_NO_SCROLLBARS 0x000005A7 +#define ERROR_INVALID_SCROLLBAR_RANGE 0x000005A8 +#define ERROR_INVALID_SHOWWIN_COMMAND 0x000005A9 +#define ERROR_NO_SYSTEM_RESOURCES 0x000005AA +#define ERROR_NONPAGED_SYSTEM_RESOURCES 0x000005AB +#define ERROR_PAGED_SYSTEM_RESOURCES 0x000005AC +#define ERROR_WORKING_SET_QUOTA 0x000005AD +#define ERROR_PAGEFILE_QUOTA 0x000005AE +#define ERROR_COMMITMENT_LIMIT 0x000005AF +#define ERROR_MENU_ITEM_NOT_FOUND 0x000005B0 +#define ERROR_INVALID_KEYBOARD_HANDLE 0x000005B1 +#define ERROR_HOOK_TYPE_NOT_ALLOWED 0x000005B2 +#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 0x000005B3 +#define ERROR_TIMEOUT 0x000005B4 +#define ERROR_INVALID_MONITOR_HANDLE 0x000005B5 +#define ERROR_INCORRECT_SIZE 0x000005B6 +#define ERROR_SYMLINK_CLASS_DISABLED 0x000005B7 +#define ERROR_SYMLINK_NOT_SUPPORTED 0x000005B8 +#define ERROR_XML_PARSE_ERROR 0x000005B9 +#define ERROR_XMLDSIG_ERROR 0x000005BA +#define ERROR_RESTART_APPLICATION 0x000005BB +#define ERROR_WRONG_COMPARTMENT 0x000005BC +#define ERROR_AUTHIP_FAILURE 0x000005BD +#define ERROR_NO_NVRAM_RESOURCES 0x000005BE +#define ERROR_NOT_GUI_PROCESS 0x000005BF +#define ERROR_EVENTLOG_FILE_CORRUPT 0x000005DC +#define ERROR_EVENTLOG_CANT_START 0x000005DD +#define ERROR_LOG_FILE_FULL 0x000005DE +#define ERROR_EVENTLOG_FILE_CHANGED 0x000005DF +#define ERROR_INVALID_TASK_NAME 0x0000060E +#define ERROR_INVALID_TASK_INDEX 0x0000060F +#define ERROR_THREAD_ALREADY_IN_TASK 0x00000610 +#define ERROR_INSTALL_SERVICE_FAILURE 0x00000641 +#define ERROR_INSTALL_USEREXIT 0x00000642 +#define ERROR_INSTALL_FAILURE 0x00000643 +#define ERROR_INSTALL_SUSPEND 0x00000644 +#define ERROR_UNKNOWN_PRODUCT 0x00000645 +#define ERROR_UNKNOWN_FEATURE 0x00000646 +#define ERROR_UNKNOWN_COMPONENT 0x00000647 +#define ERROR_UNKNOWN_PROPERTY 0x00000648 +#define ERROR_INVALID_HANDLE_STATE 0x00000649 +#define ERROR_BAD_CONFIGURATION 0x0000064A +#define ERROR_INDEX_ABSENT 0x0000064B +#define ERROR_INSTALL_SOURCE_ABSENT 0x0000064C +#define ERROR_INSTALL_PACKAGE_VERSION 0x0000064D +#define ERROR_PRODUCT_UNINSTALLED 0x0000064E +#define ERROR_BAD_QUERY_SYNTAX 0x0000064F +#define ERROR_INVALID_FIELD 0x00000650 +#define ERROR_DEVICE_REMOVED 0x00000651 +#define ERROR_INSTALL_ALREADY_RUNNING 0x00000652 +#define ERROR_INSTALL_PACKAGE_OPEN_FAILED 0x00000653 +#define ERROR_INSTALL_PACKAGE_INVALID 0x00000654 +#define ERROR_INSTALL_UI_FAILURE 0x00000655 +#define ERROR_INSTALL_LOG_FAILURE 0x00000656 +#define ERROR_INSTALL_LANGUAGE_UNSUPPORTED 0x00000657 +#define ERROR_INSTALL_TRANSFORM_FAILURE 0x00000658 +#define ERROR_INSTALL_PACKAGE_REJECTED 0x00000659 +#define ERROR_FUNCTION_NOT_CALLED 0x0000065A +#define ERROR_FUNCTION_FAILED 0x0000065B +#define ERROR_INVALID_TABLE 0x0000065C +#define ERROR_DATATYPE_MISMATCH 0x0000065D +#define ERROR_UNSUPPORTED_TYPE 0x0000065E +#define ERROR_CREATE_FAILED 0x0000065F +#define ERROR_INSTALL_TEMP_UNWRITABLE 0x00000660 +#define ERROR_INSTALL_PLATFORM_UNSUPPORTED 0x00000661 +#define ERROR_INSTALL_NOTUSED 0x00000662 +#define ERROR_PATCH_PACKAGE_OPEN_FAILED 0x00000663 +#define ERROR_PATCH_PACKAGE_INVALID 0x00000664 +#define ERROR_PATCH_PACKAGE_UNSUPPORTED 0x00000665 +#define ERROR_PRODUCT_VERSION 0x00000666 +#define ERROR_INVALID_COMMAND_LINE 0x00000667 +#define ERROR_INSTALL_REMOTE_DISALLOWED 0x00000668 +#define ERROR_SUCCESS_REBOOT_INITIATED 0x00000669 +#define ERROR_PATCH_TARGET_NOT_FOUND 0x0000066A +#define ERROR_PATCH_PACKAGE_REJECTED 0x0000066B +#define ERROR_INSTALL_TRANSFORM_REJECTED 0x0000066C +#define ERROR_INSTALL_REMOTE_PROHIBITED 0x0000066D +#define ERROR_PATCH_REMOVAL_UNSUPPORTED 0x0000066E +#define ERROR_UNKNOWN_PATCH 0x0000066F +#define ERROR_PATCH_NO_SEQUENCE 0x00000670 +#define ERROR_PATCH_REMOVAL_DISALLOWED 0x00000671 +#define ERROR_INVALID_PATCH_XML 0x00000672 +#define ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT 0x00000673 +#define ERROR_INSTALL_SERVICE_SAFEBOOT 0x00000674 +#define ERROR_FAIL_FAST_EXCEPTION 0x00000675 +#define ERROR_INSTALL_REJECTED 0x00000676 + +/* System Error Codes (1700-3999) */ + +#define RPC_S_INVALID_STRING_BINDING 0x000006A4 +#define RPC_S_WRONG_KIND_OF_BINDING 0x000006A5 +#define RPC_S_INVALID_BINDING 0x000006A6 +#define RPC_S_PROTSEQ_NOT_SUPPORTED 0x000006A7 +#define RPC_S_INVALID_RPC_PROTSEQ 0x000006A8 +#define RPC_S_INVALID_STRING_UUID 0x000006A9 +#define RPC_S_INVALID_ENDPOINT_FORMAT 0x000006AA +#define RPC_S_INVALID_NET_ADDR 0x000006AB +#define RPC_S_NO_ENDPOINT_FOUND 0x000006AC +#define RPC_S_INVALID_TIMEOUT 0x000006AD +#define RPC_S_OBJECT_NOT_FOUND 0x000006AE +#define RPC_S_ALREADY_REGISTERED 0x000006AF +#define RPC_S_TYPE_ALREADY_REGISTERED 0x000006B0 +#define RPC_S_ALREADY_LISTENING 0x000006B1 +#define RPC_S_NO_PROTSEQS_REGISTERED 0x000006B2 +#define RPC_S_NOT_LISTENING 0x000006B3 +#define RPC_S_UNKNOWN_MGR_TYPE 0x000006B4 +#define RPC_S_UNKNOWN_IF 0x000006B5 +#define RPC_S_NO_BINDINGS 0x000006B6 +#define RPC_S_NO_PROTSEQS 0x000006B7 +#define RPC_S_CANT_CREATE_ENDPOINT 0x000006B8 +#define RPC_S_OUT_OF_RESOURCES 0x000006B9 +#define RPC_S_SERVER_UNAVAILABLE 0x000006BA +#define RPC_S_SERVER_TOO_BUSY 0x000006BB +#define RPC_S_INVALID_NETWORK_OPTIONS 0x000006BC +#define RPC_S_NO_CALL_ACTIVE 0x000006BD +#define RPC_S_CALL_FAILED 0x000006BE +#define RPC_S_CALL_FAILED_DNE 0x000006BF +#define RPC_S_PROTOCOL_ERROR 0x000006C0 +#define RPC_S_PROXY_ACCESS_DENIED 0x000006C1 +#define RPC_S_UNSUPPORTED_TRANS_SYN 0x000006C2 +#define RPC_S_UNSUPPORTED_TYPE 0x000006C4 +#define RPC_S_INVALID_TAG 0x000006C5 +#define RPC_S_INVALID_BOUND 0x000006C6 +#define RPC_S_NO_ENTRY_NAME 0x000006C7 +#define RPC_S_INVALID_NAME_SYNTAX 0x000006C8 +#define RPC_S_UNSUPPORTED_NAME_SYNTAX 0x000006C9 +#define RPC_S_UUID_NO_ADDRESS 0x000006CB +#define RPC_S_DUPLICATE_ENDPOINT 0x000006CC +#define RPC_S_UNKNOWN_AUTHN_TYPE 0x000006CD +#define RPC_S_MAX_CALLS_TOO_SMALL 0x000006CE +#define RPC_S_STRING_TOO_LONG 0x000006CF +#define RPC_S_PROTSEQ_NOT_FOUND 0x000006D0 +#define RPC_S_PROCNUM_OUT_OF_RANGE 0x000006D1 +#define RPC_S_BINDING_HAS_NO_AUTH 0x000006D2 +#define RPC_S_UNKNOWN_AUTHN_SERVICE 0x000006D3 +#define RPC_S_UNKNOWN_AUTHN_LEVEL 0x000006D4 +#define RPC_S_INVALID_AUTH_IDENTITY 0x000006D5 +#define RPC_S_UNKNOWN_AUTHZ_SERVICE 0x000006D6 +#define EPT_S_INVALID_ENTRY 0x000006D7 +#define EPT_S_CANT_PERFORM_OP 0x000006D8 +#define EPT_S_NOT_REGISTERED 0x000006D9 +#define RPC_S_NOTHING_TO_EXPORT 0x000006DA +#define RPC_S_INCOMPLETE_NAME 0x000006DB +#define RPC_S_INVALID_VERS_OPTION 0x000006DC +#define RPC_S_NO_MORE_MEMBERS 0x000006DD +#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 0x000006DE +#define RPC_S_INTERFACE_NOT_FOUND 0x000006DF +#define RPC_S_ENTRY_ALREADY_EXISTS 0x000006E0 +#define RPC_S_ENTRY_NOT_FOUND 0x000006E1 +#define RPC_S_NAME_SERVICE_UNAVAILABLE 0x000006E2 +#define RPC_S_INVALID_NAF_ID 0x000006E3 +#define RPC_S_CANNOT_SUPPORT 0x000006E4 +#define RPC_S_NO_CONTEXT_AVAILABLE 0x000006E5 +#define RPC_S_INTERNAL_ERROR 0x000006E6 +#define RPC_S_ZERO_DIVIDE 0x000006E7 +#define RPC_S_ADDRESS_ERROR 0x000006E8 +#define RPC_S_FP_DIV_ZERO 0x000006E9 +#define RPC_S_FP_UNDERFLOW 0x000006EA +#define RPC_S_FP_OVERFLOW 0x000006EB +#define RPC_X_NO_MORE_ENTRIES 0x000006EC +#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 0x000006ED +#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 0x000006EE +#define RPC_X_SS_IN_NULL_CONTEXT 0x000006EF +#define RPC_X_SS_CONTEXT_DAMAGED 0x000006F1 +#define RPC_X_SS_HANDLES_MISMATCH 0x000006F2 +#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 0x000006F3 +#define RPC_X_NULL_REF_POINTER 0x000006F4 +#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 0x000006F5 +#define RPC_X_BYTE_COUNT_TOO_SMALL 0x000006F6 +#define RPC_X_BAD_STUB_DATA 0x000006F7 +#define ERROR_INVALID_USER_BUFFER 0x000006F8 +#define ERROR_UNRECOGNIZED_MEDIA 0x000006F9 +#define ERROR_NO_TRUST_LSA_SECRET 0x000006FA +#define ERROR_NO_TRUST_SAM_ACCOUNT 0x000006FB +#define ERROR_TRUSTED_DOMAIN_FAILURE 0x000006FC +#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 0x000006FD +#define ERROR_TRUST_FAILURE 0x000006FE +#define RPC_S_CALL_IN_PROGRESS 0x000006FF +#define ERROR_NETLOGON_NOT_STARTED 0x00000700 +#define ERROR_ACCOUNT_EXPIRED 0x00000701 +#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 0x00000702 +#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 0x00000703 +#define ERROR_UNKNOWN_PORT 0x00000704 +#define ERROR_UNKNOWN_PRINTER_DRIVER 0x00000705 +#define ERROR_UNKNOWN_PRINTPROCESSOR 0x00000706 +#define ERROR_INVALID_SEPARATOR_FILE 0x00000707 +#define ERROR_INVALID_PRIORITY 0x00000708 +#define ERROR_INVALID_PRINTER_NAME 0x00000709 +#define ERROR_PRINTER_ALREADY_EXISTS 0x0000070A +#define ERROR_INVALID_PRINTER_COMMAND 0x0000070B +#define ERROR_INVALID_DATATYPE 0x0000070C +#define ERROR_INVALID_ENVIRONMENT 0x0000070D +#define RPC_S_NO_MORE_BINDINGS 0x0000070E +#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0x0000070F +#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0x00000710 +#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 0x00000711 +#define ERROR_DOMAIN_TRUST_INCONSISTENT 0x00000712 +#define ERROR_SERVER_HAS_OPEN_HANDLES 0x00000713 +#define ERROR_RESOURCE_DATA_NOT_FOUND 0x00000714 +#define ERROR_RESOURCE_TYPE_NOT_FOUND 0x00000715 +#define ERROR_RESOURCE_NAME_NOT_FOUND 0x00000716 +#define ERROR_RESOURCE_LANG_NOT_FOUND 0x00000717 +#define ERROR_NOT_ENOUGH_QUOTA 0x00000718 +#define RPC_S_NO_INTERFACES 0x00000719 +#define RPC_S_CALL_CANCELLED 0x0000071A +#define RPC_S_BINDING_INCOMPLETE 0x0000071B +#define RPC_S_COMM_FAILURE 0x0000071C +#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 0x0000071D +#define RPC_S_NO_PRINC_NAME 0x0000071E +#define RPC_S_NOT_RPC_ERROR 0x0000071F +#define RPC_S_UUID_LOCAL_ONLY 0x00000720 +#define RPC_S_SEC_PKG_ERROR 0x00000721 +#define RPC_S_NOT_CANCELLED 0x00000722 +#define RPC_X_INVALID_ES_ACTION 0x00000723 +#define RPC_X_WRONG_ES_VERSION 0x00000724 +#define RPC_X_WRONG_STUB_VERSION 0x00000725 +#define RPC_X_INVALID_PIPE_OBJECT 0x00000726 +#define RPC_X_WRONG_PIPE_ORDER 0x00000727 +#define RPC_X_WRONG_PIPE_VERSION 0x00000728 +#define RPC_S_COOKIE_AUTH_FAILED 0x00000729 +#define RPC_S_GROUP_MEMBER_NOT_FOUND 0x0000076A +#define EPT_S_CANT_CREATE 0x0000076B +#define RPC_S_INVALID_OBJECT 0x0000076C +#define ERROR_INVALID_TIME 0x0000076D +#define ERROR_INVALID_FORM_NAME 0x0000076E +#define ERROR_INVALID_FORM_SIZE 0x0000076F +#define ERROR_ALREADY_WAITING 0x00000770 +#define ERROR_PRINTER_DELETED 0x00000771 +#define ERROR_INVALID_PRINTER_STATE 0x00000772 +#define ERROR_PASSWORD_MUST_CHANGE 0x00000773 +#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 0x00000774 +#define ERROR_ACCOUNT_LOCKED_OUT 0x00000775 +#define OR_INVALID_OXID 0x00000776 +#define OR_INVALID_OID 0x00000777 +#define OR_INVALID_SET 0x00000778 +#define RPC_S_SEND_INCOMPLETE 0x00000779 +#define RPC_S_INVALID_ASYNC_HANDLE 0x0000077A +#define RPC_S_INVALID_ASYNC_CALL 0x0000077B +#define RPC_X_PIPE_CLOSED 0x0000077C +#define RPC_X_PIPE_DISCIPLINE_ERROR 0x0000077D +#define RPC_X_PIPE_EMPTY 0x0000077E +#define ERROR_NO_SITENAME 0x0000077F +#define ERROR_CANT_ACCESS_FILE 0x00000780 +#define ERROR_CANT_RESOLVE_FILENAME 0x00000781 +#define RPC_S_ENTRY_TYPE_MISMATCH 0x00000782 +#define RPC_S_NOT_ALL_OBJS_EXPORTED 0x00000783 +#define RPC_S_INTERFACE_NOT_EXPORTED 0x00000784 +#define RPC_S_PROFILE_NOT_ADDED 0x00000785 +#define RPC_S_PRF_ELT_NOT_ADDED 0x00000786 +#define RPC_S_PRF_ELT_NOT_REMOVED 0x00000787 +#define RPC_S_GRP_ELT_NOT_ADDED 0x00000788 +#define RPC_S_GRP_ELT_NOT_REMOVED 0x00000789 +#define ERROR_KM_DRIVER_BLOCKED 0x0000078A +#define ERROR_CONTEXT_EXPIRED 0x0000078B +#define ERROR_PER_USER_TRUST_QUOTA_EXCEEDED 0x0000078C +#define ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED 0x0000078D +#define ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED 0x0000078E +#define ERROR_AUTHENTICATION_FIREWALL_FAILED 0x0000078F +#define ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED 0x00000790 +#define ERROR_NTLM_BLOCKED 0x00000791 +#define ERROR_PASSWORD_CHANGE_REQUIRED 0x00000792 +#define ERROR_INVALID_PIXEL_FORMAT 0x000007D0 +#define ERROR_BAD_DRIVER 0x000007D1 +#define ERROR_INVALID_WINDOW_STYLE 0x000007D2 +#define ERROR_METAFILE_NOT_SUPPORTED 0x000007D3 +#define ERROR_TRANSFORM_NOT_SUPPORTED 0x000007D4 +#define ERROR_CLIPPING_NOT_SUPPORTED 0x000007D5 +#define ERROR_INVALID_CMM 0x000007DA +#define ERROR_INVALID_PROFILE 0x000007DB +#define ERROR_TAG_NOT_FOUND 0x000007DC +#define ERROR_TAG_NOT_PRESENT 0x000007DD +#define ERROR_DUPLICATE_TAG 0x000007DE +#define ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE 0x000007DF +#define ERROR_PROFILE_NOT_FOUND 0x000007E0 +#define ERROR_INVALID_COLORSPACE 0x000007E1 +#define ERROR_ICM_NOT_ENABLED 0x000007E2 +#define ERROR_DELETING_ICM_XFORM 0x000007E3 +#define ERROR_INVALID_TRANSFORM 0x000007E4 +#define ERROR_COLORSPACE_MISMATCH 0x000007E5 +#define ERROR_INVALID_COLORINDEX 0x000007E6 +#define ERROR_PROFILE_DOES_NOT_MATCH_DEVICE 0x000007E7 +#define ERROR_CONNECTED_OTHER_PASSWORD 0x0000083C +#define ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT 0x0000083D +#define ERROR_BAD_USERNAME 0x0000089A +#define ERROR_NOT_CONNECTED 0x000008CA +#define ERROR_OPEN_FILES 0x00000961 +#define ERROR_ACTIVE_CONNECTIONS 0x00000962 +#define ERROR_DEVICE_IN_USE 0x00000964 +#define ERROR_UNKNOWN_PRINT_MONITOR 0x00000BB8 +#define ERROR_PRINTER_DRIVER_IN_USE 0x00000BB9 +#define ERROR_SPOOL_FILE_NOT_FOUND 0x00000BBA +#define ERROR_SPL_NO_STARTDOC 0x00000BBB +#define ERROR_SPL_NO_ADDJOB 0x00000BBC +#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 0x00000BBD +#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 0x00000BBE +#define ERROR_INVALID_PRINT_MONITOR 0x00000BBF +#define ERROR_PRINT_MONITOR_IN_USE 0x00000BC0 +#define ERROR_PRINTER_HAS_JOBS_QUEUED 0x00000BC1 +#define ERROR_SUCCESS_REBOOT_REQUIRED 0x00000BC2 +#define ERROR_SUCCESS_RESTART_REQUIRED 0x00000BC3 +#define ERROR_PRINTER_NOT_FOUND 0x00000BC4 +#define ERROR_PRINTER_DRIVER_WARNED 0x00000BC5 +#define ERROR_PRINTER_DRIVER_BLOCKED 0x00000BC6 +#define ERROR_PRINTER_DRIVER_PACKAGE_IN_USE 0x00000BC7 +#define ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND 0x00000BC8 +#define ERROR_FAIL_REBOOT_REQUIRED 0x00000BC9 +#define ERROR_FAIL_REBOOT_INITIATED 0x00000BCA +#define ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED 0x00000BCB +#define ERROR_PRINT_JOB_RESTART_REQUIRED 0x00000BCC +#define ERROR_INVALID_PRINTER_DRIVER_MANIFEST 0x00000BCD +#define ERROR_PRINTER_NOT_SHAREABLE 0x00000BCE +#define ERROR_REQUEST_PAUSED 0x00000BEA +#define ERROR_IO_REISSUE_AS_CACHED 0x00000F6E + +/* System Error Codes (4000-5999) */ + +#define ERROR_WINS_INTERNAL 0x00000FA0 +#define ERROR_CAN_NOT_DEL_LOCAL_WINS 0x00000FA1 +#define ERROR_STATIC_INIT 0x00000FA2 +#define ERROR_INC_BACKUP 0x00000FA3 +#define ERROR_FULL_BACKUP 0x00000FA4 +#define ERROR_REC_NON_EXISTENT 0x00000FA5 +#define ERROR_RPL_NOT_ALLOWED 0x00000FA6 +#define PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED 0x00000FD2 +#define PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO 0x00000FD3 +#define PEERDIST_ERROR_MISSING_DATA 0x00000FD4 +#define PEERDIST_ERROR_NO_MORE 0x00000FD5 +#define PEERDIST_ERROR_NOT_INITIALIZED 0x00000FD6 +#define PEERDIST_ERROR_ALREADY_INITIALIZED 0x00000FD7 +#define PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS 0x00000FD8 +#define PEERDIST_ERROR_INVALIDATED 0x00000FD9 +#define PEERDIST_ERROR_ALREADY_EXISTS 0x00000FDA +#define PEERDIST_ERROR_OPERATION_NOTFOUND 0x00000FDB +#define PEERDIST_ERROR_ALREADY_COMPLETED 0x00000FDC +#define PEERDIST_ERROR_OUT_OF_BOUNDS 0x00000FDD +#define PEERDIST_ERROR_VERSION_UNSUPPORTED 0x00000FDE +#define PEERDIST_ERROR_INVALID_CONFIGURATION 0x00000FDF +#define PEERDIST_ERROR_NOT_LICENSED 0x00000FE0 +#define PEERDIST_ERROR_SERVICE_UNAVAILABLE 0x00000FE1 +#define PEERDIST_ERROR_TRUST_FAILURE 0x00000FE2 +#define ERROR_DHCP_ADDRESS_CONFLICT 0x00001004 +#define ERROR_WMI_GUID_NOT_FOUND 0x00001068 +#define ERROR_WMI_INSTANCE_NOT_FOUND 0x00001069 +#define ERROR_WMI_ITEMID_NOT_FOUND 0x0000106A +#define ERROR_WMI_TRY_AGAIN 0x0000106B +#define ERROR_WMI_DP_NOT_FOUND 0x0000106C +#define ERROR_WMI_UNRESOLVED_INSTANCE_REF 0x0000106D +#define ERROR_WMI_ALREADY_ENABLED 0x0000106E +#define ERROR_WMI_GUID_DISCONNECTED 0x0000106F +#define ERROR_WMI_SERVER_UNAVAILABLE 0x00001070 +#define ERROR_WMI_DP_FAILED 0x00001071 +#define ERROR_WMI_INVALID_MOF 0x00001072 +#define ERROR_WMI_INVALID_REGINFO 0x00001073 +#define ERROR_WMI_ALREADY_DISABLED 0x00001074 +#define ERROR_WMI_READ_ONLY 0x00001075 +#define ERROR_WMI_SET_FAILURE 0x00001076 +#define ERROR_NOT_APPCONTAINER 0x0000109A +#define ERROR_APPCONTAINER_REQUIRED 0x0000109B +#define ERROR_NOT_SUPPORTED_IN_APPCONTAINER 0x0000109C +#define ERROR_INVALID_PACKAGE_SID_LENGTH 0x0000109D +#define ERROR_INVALID_MEDIA 0x000010CC +#define ERROR_INVALID_LIBRARY 0x000010CD +#define ERROR_INVALID_MEDIA_POOL 0x000010CE +#define ERROR_DRIVE_MEDIA_MISMATCH 0x000010CF +#define ERROR_MEDIA_OFFLINE 0x000010D0 +#define ERROR_LIBRARY_OFFLINE 0x000010D1 +#define ERROR_EMPTY 0x000010D2 +#define ERROR_NOT_EMPTY 0x000010D3 +#define ERROR_MEDIA_UNAVAILABLE 0x000010D4 +#define ERROR_RESOURCE_DISABLED 0x000010D5 +#define ERROR_INVALID_CLEANER 0x000010D6 +#define ERROR_UNABLE_TO_CLEAN 0x000010D7 +#define ERROR_OBJECT_NOT_FOUND 0x000010D8 +#define ERROR_DATABASE_FAILURE 0x000010D9 +#define ERROR_DATABASE_FULL 0x000010DA +#define ERROR_MEDIA_INCOMPATIBLE 0x000010DB +#define ERROR_RESOURCE_NOT_PRESENT 0x000010DC +#define ERROR_INVALID_OPERATION 0x000010DD +#define ERROR_MEDIA_NOT_AVAILABLE 0x000010DE +#define ERROR_DEVICE_NOT_AVAILABLE 0x000010DF +#define ERROR_REQUEST_REFUSED 0x000010E0 +#define ERROR_INVALID_DRIVE_OBJECT 0x000010E1 +#define ERROR_LIBRARY_FULL 0x000010E2 +#define ERROR_MEDIUM_NOT_ACCESSIBLE 0x000010E3 +#define ERROR_UNABLE_TO_LOAD_MEDIUM 0x000010E4 +#define ERROR_UNABLE_TO_INVENTORY_DRIVE 0x000010E5 +#define ERROR_UNABLE_TO_INVENTORY_SLOT 0x000010E6 +#define ERROR_UNABLE_TO_INVENTORY_TRANSPORT 0x000010E7 +#define ERROR_TRANSPORT_FULL 0x000010E8 +#define ERROR_CONTROLLING_IEPORT 0x000010E9 +#define ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA 0x000010EA +#define ERROR_CLEANER_SLOT_SET 0x000010EB +#define ERROR_CLEANER_SLOT_NOT_SET 0x000010EC +#define ERROR_CLEANER_CARTRIDGE_SPENT 0x000010ED +#define ERROR_UNEXPECTED_OMID 0x000010EE +#define ERROR_CANT_DELETE_LAST_ITEM 0x000010EF +#define ERROR_MESSAGE_EXCEEDS_MAX_SIZE 0x000010F0 +#define ERROR_VOLUME_CONTAINS_SYS_FILES 0x000010F1 +#define ERROR_INDIGENOUS_TYPE 0x000010F2 +#define ERROR_NO_SUPPORTING_DRIVES 0x000010F3 +#define ERROR_CLEANER_CARTRIDGE_INSTALLED 0x000010F4 +#define ERROR_IEPORT_FULL 0x000010F5 +#define ERROR_FILE_OFFLINE 0x000010FE +#define ERROR_REMOTE_STORAGE_NOT_ACTIVE 0x000010FF +#define ERROR_REMOTE_STORAGE_MEDIA_ERROR 0x00001100 +#define ERROR_NOT_A_REPARSE_POINT 0x00001126 +#define ERROR_REPARSE_ATTRIBUTE_CONFLICT 0x00001127 +#define ERROR_INVALID_REPARSE_DATA 0x00001128 +#define ERROR_REPARSE_TAG_INVALID 0x00001129 +#define ERROR_REPARSE_TAG_MISMATCH 0x0000112A +#define ERROR_APP_DATA_NOT_FOUND 0x00001130 +#define ERROR_APP_DATA_EXPIRED 0x00001131 +#define ERROR_APP_DATA_CORRUPT 0x00001132 +#define ERROR_APP_DATA_LIMIT_EXCEEDED 0x00001133 +#define ERROR_APP_DATA_REBOOT_REQUIRED 0x00001134 +#define ERROR_SECUREBOOT_ROLLBACK_DETECTED 0x00001144 +#define ERROR_SECUREBOOT_POLICY_VIOLATION 0x00001145 +#define ERROR_SECUREBOOT_INVALID_POLICY 0x00001146 +#define ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND 0x00001147 +#define ERROR_SECUREBOOT_POLICY_NOT_SIGNED 0x00001148 +#define ERROR_SECUREBOOT_NOT_ENABLED 0x00001149 +#define ERROR_SECUREBOOT_FILE_REPLACED 0x0000114A +#define ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED 0x00001158 +#define ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED 0x00001159 +#define ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED 0x0000115A +#define ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED 0x0000115B +#define ERROR_VOLUME_NOT_SIS_ENABLED 0x00001194 +#define ERROR_DEPENDENT_RESOURCE_EXISTS 0x00001389 +#define ERROR_DEPENDENCY_NOT_FOUND 0x0000138A +#define ERROR_DEPENDENCY_ALREADY_EXISTS 0x0000138B +#define ERROR_RESOURCE_NOT_ONLINE 0x0000138C +#define ERROR_HOST_NODE_NOT_AVAILABLE 0x0000138D +#define ERROR_RESOURCE_NOT_AVAILABLE 0x0000138E +#define ERROR_RESOURCE_NOT_FOUND 0x0000138F +#define ERROR_SHUTDOWN_CLUSTER 0x00001390 +#define ERROR_CANT_EVICT_ACTIVE_NODE 0x00001391 +#define ERROR_OBJECT_ALREADY_EXISTS 0x00001392 +#define ERROR_OBJECT_IN_LIST 0x00001393 +#define ERROR_GROUP_NOT_AVAILABLE 0x00001394 +#define ERROR_GROUP_NOT_FOUND 0x00001395 +#define ERROR_GROUP_NOT_ONLINE 0x00001396 +#define ERROR_HOST_NODE_NOT_RESOURCE_OWNER 0x00001397 +#define ERROR_HOST_NODE_NOT_GROUP_OWNER 0x00001398 +#define ERROR_RESMON_CREATE_FAILED 0x00001399 +#define ERROR_RESMON_ONLINE_FAILED 0x0000139A +#define ERROR_RESOURCE_ONLINE 0x0000139B +#define ERROR_QUORUM_RESOURCE 0x0000139C +#define ERROR_NOT_QUORUM_CAPABLE 0x0000139D +#define ERROR_CLUSTER_SHUTTING_DOWN 0x0000139E +#define ERROR_INVALID_STATE 0x0000139F +#define ERROR_RESOURCE_PROPERTIES_STORED 0x000013A0 +#define ERROR_NOT_QUORUM_CLASS 0x000013A1 +#define ERROR_CORE_RESOURCE 0x000013A2 +#define ERROR_QUORUM_RESOURCE_ONLINE_FAILED 0x000013A3 +#define ERROR_QUORUMLOG_OPEN_FAILED 0x000013A4 +#define ERROR_CLUSTERLOG_CORRUPT 0x000013A5 +#define ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE 0x000013A6 +#define ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE 0x000013A7 +#define ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND 0x000013A8 +#define ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE 0x000013A9 +#define ERROR_QUORUM_OWNER_ALIVE 0x000013AA +#define ERROR_NETWORK_NOT_AVAILABLE 0x000013AB +#define ERROR_NODE_NOT_AVAILABLE 0x000013AC +#define ERROR_ALL_NODES_NOT_AVAILABLE 0x000013AD +#define ERROR_RESOURCE_FAILED 0x000013AE +#define ERROR_CLUSTER_INVALID_NODE 0x000013AF +#define ERROR_CLUSTER_NODE_EXISTS 0x000013B0 +#define ERROR_CLUSTER_JOIN_IN_PROGRESS 0x000013B1 +#define ERROR_CLUSTER_NODE_NOT_FOUND 0x000013B2 +#define ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND 0x000013B3 +#define ERROR_CLUSTER_NETWORK_EXISTS 0x000013B4 +#define ERROR_CLUSTER_NETWORK_NOT_FOUND 0x000013B5 +#define ERROR_CLUSTER_NETINTERFACE_EXISTS 0x000013B6 +#define ERROR_CLUSTER_NETINTERFACE_NOT_FOUND 0x000013B7 +#define ERROR_CLUSTER_INVALID_REQUEST 0x000013B8 +#define ERROR_CLUSTER_INVALID_NETWORK_PROVIDER 0x000013B9 +#define ERROR_CLUSTER_NODE_DOWN 0x000013BA +#define ERROR_CLUSTER_NODE_UNREACHABLE 0x000013BB +#define ERROR_CLUSTER_NODE_NOT_MEMBER 0x000013BC +#define ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS 0x000013BD +#define ERROR_CLUSTER_INVALID_NETWORK 0x000013BE +#define ERROR_CLUSTER_NODE_UP 0x000013C0 +#define ERROR_CLUSTER_IPADDR_IN_USE 0x000013C1 +#define ERROR_CLUSTER_NODE_NOT_PAUSED 0x000013C2 +#define ERROR_CLUSTER_NO_SECURITY_CONTEXT 0x000013C3 +#define ERROR_CLUSTER_NETWORK_NOT_INTERNAL 0x000013C4 +#define ERROR_CLUSTER_NODE_ALREADY_UP 0x000013C5 +#define ERROR_CLUSTER_NODE_ALREADY_DOWN 0x000013C6 +#define ERROR_CLUSTER_NETWORK_ALREADY_ONLINE 0x000013C7 +#define ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE 0x000013C8 +#define ERROR_CLUSTER_NODE_ALREADY_MEMBER 0x000013C9 +#define ERROR_CLUSTER_LAST_INTERNAL_NETWORK 0x000013CA +#define ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS 0x000013CB +#define ERROR_INVALID_OPERATION_ON_QUORUM 0x000013CC +#define ERROR_DEPENDENCY_NOT_ALLOWED 0x000013CD +#define ERROR_CLUSTER_NODE_PAUSED 0x000013CE +#define ERROR_NODE_CANT_HOST_RESOURCE 0x000013CF +#define ERROR_CLUSTER_NODE_NOT_READY 0x000013D0 +#define ERROR_CLUSTER_NODE_SHUTTING_DOWN 0x000013D1 +#define ERROR_CLUSTER_JOIN_ABORTED 0x000013D2 +#define ERROR_CLUSTER_INCOMPATIBLE_VERSIONS 0x000013D3 +#define ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED 0x000013D4 +#define ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED 0x000013D5 +#define ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND 0x000013D6 +#define ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED 0x000013D7 +#define ERROR_CLUSTER_RESNAME_NOT_FOUND 0x000013D8 +#define ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED 0x000013D9 +#define ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST 0x000013DA +#define ERROR_CLUSTER_DATABASE_SEQMISMATCH 0x000013DB +#define ERROR_RESMON_INVALID_STATE 0x000013DC +#define ERROR_CLUSTER_GUM_NOT_LOCKER 0x000013DD +#define ERROR_QUORUM_DISK_NOT_FOUND 0x000013DE +#define ERROR_DATABASE_BACKUP_CORRUPT 0x000013DF +#define ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT 0x000013E0 +#define ERROR_RESOURCE_PROPERTY_UNCHANGEABLE 0x000013E1 +#define ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE 0x00001702 +#define ERROR_CLUSTER_QUORUMLOG_NOT_FOUND 0x00001703 +#define ERROR_CLUSTER_MEMBERSHIP_HALT 0x00001704 +#define ERROR_CLUSTER_INSTANCE_ID_MISMATCH 0x00001705 +#define ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP 0x00001706 +#define ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH 0x00001707 +#define ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP 0x00001708 +#define ERROR_CLUSTER_PARAMETER_MISMATCH 0x00001709 +#define ERROR_NODE_CANNOT_BE_CLUSTERED 0x0000170A +#define ERROR_CLUSTER_WRONG_OS_VERSION 0x0000170B +#define ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME 0x0000170C +#define ERROR_CLUSCFG_ALREADY_COMMITTED 0x0000170D +#define ERROR_CLUSCFG_ROLLBACK_FAILED 0x0000170E +#define ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT 0x0000170F +#define ERROR_CLUSTER_OLD_VERSION 0x00001710 +#define ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME 0x00001711 +#define ERROR_CLUSTER_NO_NET_ADAPTERS 0x00001712 +#define ERROR_CLUSTER_POISONED 0x00001713 +#define ERROR_CLUSTER_GROUP_MOVING 0x00001714 +#define ERROR_CLUSTER_RESOURCE_TYPE_BUSY 0x00001715 +#define ERROR_RESOURCE_CALL_TIMED_OUT 0x00001716 +#define ERROR_INVALID_CLUSTER_IPV6_ADDRESS 0x00001717 +#define ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION 0x00001718 +#define ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS 0x00001719 +#define ERROR_CLUSTER_PARTIAL_SEND 0x0000171A +#define ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION 0x0000171B +#define ERROR_CLUSTER_INVALID_STRING_TERMINATION 0x0000171C +#define ERROR_CLUSTER_INVALID_STRING_FORMAT 0x0000171D +#define ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS 0x0000171E +#define ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS 0x0000171F +#define ERROR_CLUSTER_NULL_DATA 0x00001720 +#define ERROR_CLUSTER_PARTIAL_READ 0x00001721 +#define ERROR_CLUSTER_PARTIAL_WRITE 0x00001722 +#define ERROR_CLUSTER_CANT_DESERIALIZE_DATA 0x00001723 +#define ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT 0x00001724 +#define ERROR_CLUSTER_NO_QUORUM 0x00001725 +#define ERROR_CLUSTER_INVALID_IPV6_NETWORK 0x00001726 +#define ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK 0x00001727 +#define ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP 0x00001728 +#define ERROR_DEPENDENCY_TREE_TOO_COMPLEX 0x00001729 +#define ERROR_EXCEPTION_IN_RESOURCE_CALL 0x0000172A +#define ERROR_CLUSTER_RHS_FAILED_INITIALIZATION 0x0000172B +#define ERROR_CLUSTER_NOT_INSTALLED 0x0000172C +#define ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE 0x0000172D +#define ERROR_CLUSTER_MAX_NODES_IN_CLUSTER 0x0000172E +#define ERROR_CLUSTER_TOO_MANY_NODES 0x0000172F +#define ERROR_CLUSTER_OBJECT_ALREADY_USED 0x00001730 +#define ERROR_NONCORE_GROUPS_FOUND 0x00001731 +#define ERROR_FILE_SHARE_RESOURCE_CONFLICT 0x00001732 +#define ERROR_CLUSTER_EVICT_INVALID_REQUEST 0x00001733 +#define ERROR_CLUSTER_SINGLETON_RESOURCE 0x00001734 +#define ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE 0x00001735 +#define ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED 0x00001736 +#define ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR 0x00001737 +#define ERROR_CLUSTER_GROUP_BUSY 0x00001738 +#define ERROR_CLUSTER_NOT_SHARED_VOLUME 0x00001739 +#define ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR 0x0000173A +#define ERROR_CLUSTER_SHARED_VOLUMES_IN_USE 0x0000173B +#define ERROR_CLUSTER_USE_SHARED_VOLUMES_API 0x0000173C +#define ERROR_CLUSTER_BACKUP_IN_PROGRESS 0x0000173D +#define ERROR_NON_CSV_PATH 0x0000173E +#define ERROR_CSV_VOLUME_NOT_LOCAL 0x0000173F +#define ERROR_CLUSTER_WATCHDOG_TERMINATING 0x00001740 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES 0x00001741 +#define ERROR_CLUSTER_INVALID_NODE_WEIGHT 0x00001742 +#define ERROR_CLUSTER_RESOURCE_VETOED_CALL 0x00001743 +#define ERROR_RESMON_SYSTEM_RESOURCES_LACKING 0x00001744 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION 0x00001745 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE 0x00001746 +#define ERROR_CLUSTER_GROUP_QUEUED 0x00001747 +#define ERROR_CLUSTER_RESOURCE_LOCKED_STATUS 0x00001748 +#define ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED 0x00001749 +#define ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS 0x0000174A +#define ERROR_CLUSTER_DISK_NOT_CONNECTED 0x0000174B +#define ERROR_DISK_NOT_CSV_CAPABLE 0x0000174C +#define ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE 0x0000174D +#define ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED 0x0000174E +#define ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED 0x0000174F +#define ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES 0x00001750 +#define ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES 0x00001751 +#define ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE 0x00001752 +#define ERROR_CLUSTER_AFFINITY_CONFLICT 0x00001753 +#define ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE 0x00001754 + +/* System Error Codes (6000-8199) */ + +#define ERROR_ENCRYPTION_FAILED 0x00001770 +#define ERROR_DECRYPTION_FAILED 0x00001771 +#define ERROR_FILE_ENCRYPTED 0x00001772 +#define ERROR_NO_RECOVERY_POLICY 0x00001773 +#define ERROR_NO_EFS 0x00001774 +#define ERROR_WRONG_EFS 0x00001775 +#define ERROR_NO_USER_KEYS 0x00001776 +#define ERROR_FILE_NOT_ENCRYPTED 0x00001777 +#define ERROR_NOT_EXPORT_FORMAT 0x00001778 +#define ERROR_FILE_READ_ONLY 0x00001779 +#define ERROR_DIR_EFS_DISALLOWED 0x0000177A +#define ERROR_EFS_SERVER_NOT_TRUSTED 0x0000177B +#define ERROR_BAD_RECOVERY_POLICY 0x0000177C +#define ERROR_EFS_ALG_BLOB_TOO_BIG 0x0000177D +#define ERROR_VOLUME_NOT_SUPPORT_EFS 0x0000177E +#define ERROR_EFS_DISABLED 0x0000177F +#define ERROR_EFS_VERSION_NOT_SUPPORT 0x00001780 +#define ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE 0x00001781 +#define ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER 0x00001782 +#define ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE 0x00001783 +#define ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE 0x00001784 +#define ERROR_CS_ENCRYPTION_FILE_NOT_CSE 0x00001785 +#define ERROR_ENCRYPTION_POLICY_DENIES_OPERATION 0x00001786 +#define ERROR_NO_BROWSER_SERVERS_FOUND 0x000017E6 +#define SCHED_E_SERVICE_NOT_LOCALSYSTEM 0x00001838 +#define ERROR_LOG_SECTOR_INVALID 0x000019C8 +#define ERROR_LOG_SECTOR_PARITY_INVALID 0x000019C9 +#define ERROR_LOG_SECTOR_REMAPPED 0x000019CA +#define ERROR_LOG_BLOCK_INCOMPLETE 0x000019CB +#define ERROR_LOG_INVALID_RANGE 0x000019CC +#define ERROR_LOG_BLOCKS_EXHAUSTED 0x000019CD +#define ERROR_LOG_READ_CONTEXT_INVALID 0x000019CE +#define ERROR_LOG_RESTART_INVALID 0x000019CF +#define ERROR_LOG_BLOCK_VERSION 0x000019D0 +#define ERROR_LOG_BLOCK_INVALID 0x000019D1 +#define ERROR_LOG_READ_MODE_INVALID 0x000019D2 +#define ERROR_LOG_NO_RESTART 0x000019D3 +#define ERROR_LOG_METADATA_CORRUPT 0x000019D4 +#define ERROR_LOG_METADATA_INVALID 0x000019D5 +#define ERROR_LOG_METADATA_INCONSISTENT 0x000019D6 +#define ERROR_LOG_RESERVATION_INVALID 0x000019D7 +#define ERROR_LOG_CANT_DELETE 0x000019D8 +#define ERROR_LOG_CONTAINER_LIMIT_EXCEEDED 0x000019D9 +#define ERROR_LOG_START_OF_LOG 0x000019DA +#define ERROR_LOG_POLICY_ALREADY_INSTALLED 0x000019DB +#define ERROR_LOG_POLICY_NOT_INSTALLED 0x000019DC +#define ERROR_LOG_POLICY_INVALID 0x000019DD +#define ERROR_LOG_POLICY_CONFLICT 0x000019DE +#define ERROR_LOG_PINNED_ARCHIVE_TAIL 0x000019DF +#define ERROR_LOG_RECORD_NONEXISTENT 0x000019E0 +#define ERROR_LOG_RECORDS_RESERVED_INVALID 0x000019E1 +#define ERROR_LOG_SPACE_RESERVED_INVALID 0x000019E2 +#define ERROR_LOG_TAIL_INVALID 0x000019E3 +#define ERROR_LOG_FULL 0x000019E4 +#define ERROR_COULD_NOT_RESIZE_LOG 0x000019E5 +#define ERROR_LOG_MULTIPLEXED 0x000019E6 +#define ERROR_LOG_DEDICATED 0x000019E7 +#define ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS 0x000019E8 +#define ERROR_LOG_ARCHIVE_IN_PROGRESS 0x000019E9 +#define ERROR_LOG_EPHEMERAL 0x000019EA +#define ERROR_LOG_NOT_ENOUGH_CONTAINERS 0x000019EB +#define ERROR_LOG_CLIENT_ALREADY_REGISTERED 0x000019EC +#define ERROR_LOG_CLIENT_NOT_REGISTERED 0x000019ED +#define ERROR_LOG_FULL_HANDLER_IN_PROGRESS 0x000019EE +#define ERROR_LOG_CONTAINER_READ_FAILED 0x000019EF +#define ERROR_LOG_CONTAINER_WRITE_FAILED 0x000019F0 +#define ERROR_LOG_CONTAINER_OPEN_FAILED 0x000019F1 +#define ERROR_LOG_CONTAINER_STATE_INVALID 0x000019F2 +#define ERROR_LOG_STATE_INVALID 0x000019F3 +#define ERROR_LOG_PINNED 0x000019F4 +#define ERROR_LOG_METADATA_FLUSH_FAILED 0x000019F5 +#define ERROR_LOG_INCONSISTENT_SECURITY 0x000019F6 +#define ERROR_LOG_APPENDED_FLUSH_FAILED 0x000019F7 +#define ERROR_LOG_PINNED_RESERVATION 0x000019F8 +#define ERROR_INVALID_TRANSACTION 0x00001A2C +#define ERROR_TRANSACTION_NOT_ACTIVE 0x00001A2D +#define ERROR_TRANSACTION_REQUEST_NOT_VALID 0x00001A2E +#define ERROR_TRANSACTION_NOT_REQUESTED 0x00001A2F +#define ERROR_TRANSACTION_ALREADY_ABORTED 0x00001A30 +#define ERROR_TRANSACTION_ALREADY_COMMITTED 0x00001A31 +#define ERROR_TM_INITIALIZATION_FAILED 0x00001A32 +#define ERROR_RESOURCEMANAGER_READ_ONLY 0x00001A33 +#define ERROR_TRANSACTION_NOT_JOINED 0x00001A34 +#define ERROR_TRANSACTION_SUPERIOR_EXISTS 0x00001A35 +#define ERROR_CRM_PROTOCOL_ALREADY_EXISTS 0x00001A36 +#define ERROR_TRANSACTION_PROPAGATION_FAILED 0x00001A37 +#define ERROR_CRM_PROTOCOL_NOT_FOUND 0x00001A38 +#define ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER 0x00001A39 +#define ERROR_CURRENT_TRANSACTION_NOT_VALID 0x00001A3A +#define ERROR_TRANSACTION_NOT_FOUND 0x00001A3B +#define ERROR_RESOURCEMANAGER_NOT_FOUND 0x00001A3C +#define ERROR_ENLISTMENT_NOT_FOUND 0x00001A3D +#define ERROR_TRANSACTIONMANAGER_NOT_FOUND 0x00001A3E +#define ERROR_TRANSACTIONMANAGER_NOT_ONLINE 0x00001A3F +#define ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION 0x00001A40 +#define ERROR_TRANSACTION_NOT_ROOT 0x00001A41 +#define ERROR_TRANSACTION_OBJECT_EXPIRED 0x00001A42 +#define ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED 0x00001A43 +#define ERROR_TRANSACTION_RECORD_TOO_LONG 0x00001A44 +#define ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED 0x00001A45 +#define ERROR_TRANSACTION_INTEGRITY_VIOLATED 0x00001A46 +#define ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH 0x00001A47 +#define ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT 0x00001A48 +#define ERROR_TRANSACTION_MUST_WRITETHROUGH 0x00001A49 +#define ERROR_TRANSACTION_NO_SUPERIOR 0x00001A4A +#define ERROR_HEURISTIC_DAMAGE_POSSIBLE 0x00001A4B +#define ERROR_TRANSACTIONAL_CONFLICT 0x00001A90 +#define ERROR_RM_NOT_ACTIVE 0x00001A91 +#define ERROR_RM_METADATA_CORRUPT 0x00001A92 +#define ERROR_DIRECTORY_NOT_RM 0x00001A93 +#define ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE 0x00001A95 +#define ERROR_LOG_RESIZE_INVALID_SIZE 0x00001A96 +#define ERROR_OBJECT_NO_LONGER_EXISTS 0x00001A97 +#define ERROR_STREAM_MINIVERSION_NOT_FOUND 0x00001A98 +#define ERROR_STREAM_MINIVERSION_NOT_VALID 0x00001A99 +#define ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION 0x00001A9A +#define ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT 0x00001A9B +#define ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS 0x00001A9C +#define ERROR_REMOTE_FILE_VERSION_MISMATCH 0x00001A9E +#define ERROR_HANDLE_NO_LONGER_VALID 0x00001A9F +#define ERROR_NO_TXF_METADATA 0x00001AA0 +#define ERROR_LOG_CORRUPTION_DETECTED 0x00001AA1 +#define ERROR_CANT_RECOVER_WITH_HANDLE_OPEN 0x00001AA2 +#define ERROR_RM_DISCONNECTED 0x00001AA3 +#define ERROR_ENLISTMENT_NOT_SUPERIOR 0x00001AA4 +#define ERROR_RECOVERY_NOT_NEEDED 0x00001AA5 +#define ERROR_RM_ALREADY_STARTED 0x00001AA6 +#define ERROR_FILE_IDENTITY_NOT_PERSISTENT 0x00001AA7 +#define ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY 0x00001AA8 +#define ERROR_CANT_CROSS_RM_BOUNDARY 0x00001AA9 +#define ERROR_TXF_DIR_NOT_EMPTY 0x00001AAA +#define ERROR_INDOUBT_TRANSACTIONS_EXIST 0x00001AAB +#define ERROR_TM_VOLATILE 0x00001AAC +#define ERROR_ROLLBACK_TIMER_EXPIRED 0x00001AAD +#define ERROR_TXF_ATTRIBUTE_CORRUPT 0x00001AAE +#define ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION 0x00001AAF +#define ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED 0x00001AB0 +#define ERROR_LOG_GROWTH_FAILED 0x00001AB1 +#define ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE 0x00001AB2 +#define ERROR_TXF_METADATA_ALREADY_PRESENT 0x00001AB3 +#define ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET 0x00001AB4 +#define ERROR_TRANSACTION_REQUIRED_PROMOTION 0x00001AB5 +#define ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION 0x00001AB6 +#define ERROR_TRANSACTIONS_NOT_FROZEN 0x00001AB7 +#define ERROR_TRANSACTION_FREEZE_IN_PROGRESS 0x00001AB8 +#define ERROR_NOT_SNAPSHOT_VOLUME 0x00001AB9 +#define ERROR_NO_SAVEPOINT_WITH_OPEN_FILES 0x00001ABA +#define ERROR_DATA_LOST_REPAIR 0x00001ABB +#define ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION 0x00001ABC +#define ERROR_TM_IDENTITY_MISMATCH 0x00001ABD +#define ERROR_FLOATED_SECTION 0x00001ABE +#define ERROR_CANNOT_ACCEPT_TRANSACTED_WORK 0x00001ABF +#define ERROR_CANNOT_ABORT_TRANSACTIONS 0x00001AC0 +#define ERROR_BAD_CLUSTERS 0x00001AC1 +#define ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION 0x00001AC2 +#define ERROR_VOLUME_DIRTY 0x00001AC3 +#define ERROR_NO_LINK_TRACKING_IN_TRANSACTION 0x00001AC4 +#define ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION 0x00001AC5 +#define ERROR_EXPIRED_HANDLE 0x00001AC6 +#define ERROR_TRANSACTION_NOT_ENLISTED 0x00001AC7 +#define ERROR_CTX_WINSTATION_NAME_INVALID 0x00001B59 +#define ERROR_CTX_INVALID_PD 0x00001B5A +#define ERROR_CTX_PD_NOT_FOUND 0x00001B5B +#define ERROR_CTX_WD_NOT_FOUND 0x00001B5C +#define ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY 0x00001B5D +#define ERROR_CTX_SERVICE_NAME_COLLISION 0x00001B5E +#define ERROR_CTX_CLOSE_PENDING 0x00001B5F +#define ERROR_CTX_NO_OUTBUF 0x00001B60 +#define ERROR_CTX_MODEM_INF_NOT_FOUND 0x00001B61 +#define ERROR_CTX_INVALID_MODEMNAME 0x00001B62 +#define ERROR_CTX_MODEM_RESPONSE_ERROR 0x00001B63 +#define ERROR_CTX_MODEM_RESPONSE_TIMEOUT 0x00001B64 +#define ERROR_CTX_MODEM_RESPONSE_NO_CARRIER 0x00001B65 +#define ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE 0x00001B66 +#define ERROR_CTX_MODEM_RESPONSE_BUSY 0x00001B67 +#define ERROR_CTX_MODEM_RESPONSE_VOICE 0x00001B68 +#define ERROR_CTX_TD_ERROR 0x00001B69 +#define ERROR_CTX_WINSTATION_NOT_FOUND 0x00001B6E +#define ERROR_CTX_WINSTATION_ALREADY_EXISTS 0x00001B6F +#define ERROR_CTX_WINSTATION_BUSY 0x00001B70 +#define ERROR_CTX_BAD_VIDEO_MODE 0x00001B71 +#define ERROR_CTX_GRAPHICS_INVALID 0x00001B7B +#define ERROR_CTX_LOGON_DISABLED 0x00001B7D +#define ERROR_CTX_NOT_CONSOLE 0x00001B7E +#define ERROR_CTX_CLIENT_QUERY_TIMEOUT 0x00001B80 +#define ERROR_CTX_CONSOLE_DISCONNECT 0x00001B81 +#define ERROR_CTX_CONSOLE_CONNECT 0x00001B82 +#define ERROR_CTX_SHADOW_DENIED 0x00001B84 +#define ERROR_CTX_WINSTATION_ACCESS_DENIED 0x00001B85 +#define ERROR_CTX_INVALID_WD 0x00001B89 +#define ERROR_CTX_SHADOW_INVALID 0x00001B8A +#define ERROR_CTX_SHADOW_DISABLED 0x00001B8B +#define ERROR_CTX_CLIENT_LICENSE_IN_USE 0x00001B8C +#define ERROR_CTX_CLIENT_LICENSE_NOT_SET 0x00001B8D +#define ERROR_CTX_LICENSE_NOT_AVAILABLE 0x00001B8E +#define ERROR_CTX_LICENSE_CLIENT_INVALID 0x00001B8F +#define ERROR_CTX_LICENSE_EXPIRED 0x00001B90 +#define ERROR_CTX_SHADOW_NOT_RUNNING 0x00001B91 +#define ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE 0x00001B92 +#define ERROR_ACTIVATION_COUNT_EXCEEDED 0x00001B93 +#define ERROR_CTX_WINSTATIONS_DISABLED 0x00001B94 +#define ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED 0x00001B95 +#define ERROR_CTX_SESSION_IN_USE 0x00001B96 +#define ERROR_CTX_NO_FORCE_LOGOFF 0x00001B97 +#define ERROR_CTX_ACCOUNT_RESTRICTION 0x00001B98 +#define ERROR_RDP_PROTOCOL_ERROR 0x00001B99 +#define ERROR_CTX_CDM_CONNECT 0x00001B9A +#define ERROR_CTX_CDM_DISCONNECT 0x00001B9B +#define ERROR_CTX_SECURITY_LAYER_ERROR 0x00001B9C +#define ERROR_TS_INCOMPATIBLE_SESSIONS 0x00001B9D +#define ERROR_TS_VIDEO_SUBSYSTEM_ERROR 0x00001B9E +#define FRS_ERR_INVALID_API_SEQUENCE 0x00001F41 +#define FRS_ERR_STARTING_SERVICE 0x00001F42 +#define FRS_ERR_STOPPING_SERVICE 0x00001F43 +#define FRS_ERR_INTERNAL_API 0x00001F44 +#define FRS_ERR_INTERNAL 0x00001F45 +#define FRS_ERR_SERVICE_COMM 0x00001F46 +#define FRS_ERR_INSUFFICIENT_PRIV 0x00001F47 +#define FRS_ERR_AUTHENTICATION 0x00001F48 +#define FRS_ERR_PARENT_INSUFFICIENT_PRIV 0x00001F49 +#define FRS_ERR_PARENT_AUTHENTICATION 0x00001F4A +#define FRS_ERR_CHILD_TO_PARENT_COMM 0x00001F4B +#define FRS_ERR_PARENT_TO_CHILD_COMM 0x00001F4C +#define FRS_ERR_SYSVOL_POPULATE 0x00001F4D +#define FRS_ERR_SYSVOL_POPULATE_TIMEOUT 0x00001F4E +#define FRS_ERR_SYSVOL_IS_BUSY 0x00001F4F +#define FRS_ERR_SYSVOL_DEMOTE 0x00001F50 +#define FRS_ERR_INVALID_SERVICE_PARAMETER 0x00001F51 + +/* System Error Codes (8200-8999) */ + +#define ERROR_DS_NOT_INSTALLED 0x00002008 +#define ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY 0x00002009 +#define ERROR_DS_NO_ATTRIBUTE_OR_VALUE 0x0000200A +#define ERROR_DS_INVALID_ATTRIBUTE_SYNTAX 0x0000200B +#define ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED 0x0000200C +#define ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS 0x0000200D +#define ERROR_DS_BUSY 0x0000200E +#define ERROR_DS_UNAVAILABLE 0x0000200F +#define ERROR_DS_NO_RIDS_ALLOCATED 0x00002010 +#define ERROR_DS_NO_MORE_RIDS 0x00002011 +#define ERROR_DS_INCORRECT_ROLE_OWNER 0x00002012 +#define ERROR_DS_RIDMGR_INIT_ERROR 0x00002013 +#define ERROR_DS_OBJ_CLASS_VIOLATION 0x00002014 +#define ERROR_DS_CANT_ON_NON_LEAF 0x00002015 +#define ERROR_DS_CANT_ON_RDN 0x00002016 +#define ERROR_DS_CANT_MOD_OBJ_CLASS 0x00002017 +#define ERROR_DS_CROSS_DOM_MOVE_ERROR 0x00002018 +#define ERROR_DS_GC_NOT_AVAILABLE 0x00002019 +#define ERROR_SHARED_POLICY 0x0000201A +#define ERROR_POLICY_OBJECT_NOT_FOUND 0x0000201B +#define ERROR_POLICY_ONLY_IN_DS 0x0000201C +#define ERROR_PROMOTION_ACTIVE 0x0000201D +#define ERROR_NO_PROMOTION_ACTIVE 0x0000201E +#define ERROR_DS_OPERATIONS_ERROR 0x00002020 +#define ERROR_DS_PROTOCOL_ERROR 0x00002021 +#define ERROR_DS_TIMELIMIT_EXCEEDED 0x00002022 +#define ERROR_DS_SIZELIMIT_EXCEEDED 0x00002023 +#define ERROR_DS_ADMIN_LIMIT_EXCEEDED 0x00002024 +#define ERROR_DS_COMPARE_FALSE 0x00002025 +#define ERROR_DS_COMPARE_TRUE 0x00002026 +#define ERROR_DS_AUTH_METHOD_NOT_SUPPORTED 0x00002027 +#define ERROR_DS_STRONG_AUTH_REQUIRED 0x00002028 +#define ERROR_DS_INAPPROPRIATE_AUTH 0x00002029 +#define ERROR_DS_AUTH_UNKNOWN 0x0000202A +#define ERROR_DS_REFERRAL 0x0000202B +#define ERROR_DS_UNAVAILABLE_CRIT_EXTENSION 0x0000202C +#define ERROR_DS_CONFIDENTIALITY_REQUIRED 0x0000202D +#define ERROR_DS_INAPPROPRIATE_MATCHING 0x0000202E +#define ERROR_DS_CONSTRAINT_VIOLATION 0x0000202F +#define ERROR_DS_NO_SUCH_OBJECT 0x00002030 +#define ERROR_DS_ALIAS_PROBLEM 0x00002031 +#define ERROR_DS_INVALID_DN_SYNTAX 0x00002032 +#define ERROR_DS_IS_LEAF 0x00002033 +#define ERROR_DS_ALIAS_DEREF_PROBLEM 0x00002034 +#define ERROR_DS_UNWILLING_TO_PERFORM 0x00002035 +#define ERROR_DS_LOOP_DETECT 0x00002036 +#define ERROR_DS_NAMING_VIOLATION 0x00002037 +#define ERROR_DS_OBJECT_RESULTS_TOO_LARGE 0x00002038 +#define ERROR_DS_AFFECTS_MULTIPLE_DSAS 0x00002039 +#define ERROR_DS_SERVER_DOWN 0x0000203A +#define ERROR_DS_LOCAL_ERROR 0x0000203B +#define ERROR_DS_ENCODING_ERROR 0x0000203C +#define ERROR_DS_DECODING_ERROR 0x0000203D +#define ERROR_DS_FILTER_UNKNOWN 0x0000203E +#define ERROR_DS_PARAM_ERROR 0x0000203F +#define ERROR_DS_NOT_SUPPORTED 0x00002040 +#define ERROR_DS_NO_RESULTS_RETURNED 0x00002041 +#define ERROR_DS_CONTROL_NOT_FOUND 0x00002042 +#define ERROR_DS_CLIENT_LOOP 0x00002043 +#define ERROR_DS_REFERRAL_LIMIT_EXCEEDED 0x00002044 +#define ERROR_DS_SORT_CONTROL_MISSING 0x00002045 +#define ERROR_DS_OFFSET_RANGE_ERROR 0x00002046 +#define ERROR_DS_RIDMGR_DISABLED 0x00002047 +#define ERROR_DS_ROOT_MUST_BE_NC 0x0000206D +#define ERROR_DS_ADD_REPLICA_INHIBITED 0x0000206E +#define ERROR_DS_ATT_NOT_DEF_IN_SCHEMA 0x0000206F +#define ERROR_DS_MAX_OBJ_SIZE_EXCEEDED 0x00002070 +#define ERROR_DS_OBJ_STRING_NAME_EXISTS 0x00002071 +#define ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA 0x00002072 +#define ERROR_DS_RDN_DOESNT_MATCH_SCHEMA 0x00002073 +#define ERROR_DS_NO_REQUESTED_ATTS_FOUND 0x00002074 +#define ERROR_DS_USER_BUFFER_TO_SMALL 0x00002075 +#define ERROR_DS_ATT_IS_NOT_ON_OBJ 0x00002076 +#define ERROR_DS_ILLEGAL_MOD_OPERATION 0x00002077 +#define ERROR_DS_OBJ_TOO_LARGE 0x00002078 +#define ERROR_DS_BAD_INSTANCE_TYPE 0x00002079 +#define ERROR_DS_MASTERDSA_REQUIRED 0x0000207A +#define ERROR_DS_OBJECT_CLASS_REQUIRED 0x0000207B +#define ERROR_DS_MISSING_REQUIRED_ATT 0x0000207C +#define ERROR_DS_ATT_NOT_DEF_FOR_CLASS 0x0000207D +#define ERROR_DS_ATT_ALREADY_EXISTS 0x0000207E +#define ERROR_DS_CANT_ADD_ATT_VALUES 0x00002080 +#define ERROR_DS_SINGLE_VALUE_CONSTRAINT 0x00002081 +#define ERROR_DS_RANGE_CONSTRAINT 0x00002082 +#define ERROR_DS_ATT_VAL_ALREADY_EXISTS 0x00002083 +#define ERROR_DS_CANT_REM_MISSING_ATT 0x00002084 +#define ERROR_DS_CANT_REM_MISSING_ATT_VAL 0x00002085 +#define ERROR_DS_ROOT_CANT_BE_SUBREF 0x00002086 +#define ERROR_DS_NO_CHAINING 0x00002087 +#define ERROR_DS_NO_CHAINED_EVAL 0x00002088 +#define ERROR_DS_NO_PARENT_OBJECT 0x00002089 +#define ERROR_DS_PARENT_IS_AN_ALIAS 0x0000208A +#define ERROR_DS_CANT_MIX_MASTER_AND_REPS 0x0000208B +#define ERROR_DS_CHILDREN_EXIST 0x0000208C +#define ERROR_DS_OBJ_NOT_FOUND 0x0000208D +#define ERROR_DS_ALIASED_OBJ_MISSING 0x0000208E +#define ERROR_DS_BAD_NAME_SYNTAX 0x0000208F +#define ERROR_DS_ALIAS_POINTS_TO_ALIAS 0x00002090 +#define ERROR_DS_CANT_DEREF_ALIAS 0x00002091 +#define ERROR_DS_OUT_OF_SCOPE 0x00002092 +#define ERROR_DS_OBJECT_BEING_REMOVED 0x00002093 +#define ERROR_DS_CANT_DELETE_DSA_OBJ 0x00002094 +#define ERROR_DS_GENERIC_ERROR 0x00002095 +#define ERROR_DS_DSA_MUST_BE_INT_MASTER 0x00002096 +#define ERROR_DS_CLASS_NOT_DSA 0x00002097 +#define ERROR_DS_INSUFF_ACCESS_RIGHTS 0x00002098 +#define ERROR_DS_ILLEGAL_SUPERIOR 0x00002099 +#define ERROR_DS_ATTRIBUTE_OWNED_BY_SAM 0x0000209A +#define ERROR_DS_NAME_TOO_MANY_PARTS 0x0000209B +#define ERROR_DS_NAME_TOO_LONG 0x0000209C +#define ERROR_DS_NAME_VALUE_TOO_LONG 0x0000209D +#define ERROR_DS_NAME_UNPARSEABLE 0x0000209E +#define ERROR_DS_NAME_TYPE_UNKNOWN 0x0000209F +#define ERROR_DS_NOT_AN_OBJECT 0x000020A0 +#define ERROR_DS_SEC_DESC_TOO_SHORT 0x000020A1 +#define ERROR_DS_SEC_DESC_INVALID 0x000020A2 +#define ERROR_DS_NO_DELETED_NAME 0x000020A3 +#define ERROR_DS_SUBREF_MUST_HAVE_PARENT 0x000020A4 +#define ERROR_DS_NCNAME_MUST_BE_NC 0x000020A5 +#define ERROR_DS_CANT_ADD_SYSTEM_ONLY 0x000020A6 +#define ERROR_DS_CLASS_MUST_BE_CONCRETE 0x000020A7 +#define ERROR_DS_INVALID_DMD 0x000020A8 +#define ERROR_DS_OBJ_GUID_EXISTS 0x000020A9 +#define ERROR_DS_NOT_ON_BACKLINK 0x000020AA +#define ERROR_DS_NO_CROSSREF_FOR_NC 0x000020AB +#define ERROR_DS_SHUTTING_DOWN 0x000020AC +#define ERROR_DS_UNKNOWN_OPERATION 0x000020AD +#define ERROR_DS_INVALID_ROLE_OWNER 0x000020AE +#define ERROR_DS_COULDNT_CONTACT_FSMO 0x000020AF +#define ERROR_DS_CROSS_NC_DN_RENAME 0x000020B0 +#define ERROR_DS_CANT_MOD_SYSTEM_ONLY 0x000020B1 +#define ERROR_DS_REPLICATOR_ONLY 0x000020B2 +#define ERROR_DS_OBJ_CLASS_NOT_DEFINED 0x000020B3 +#define ERROR_DS_OBJ_CLASS_NOT_SUBCLASS 0x000020B4 +#define ERROR_DS_NAME_REFERENCE_INVALID 0x000020B5 +#define ERROR_DS_CROSS_REF_EXISTS 0x000020B6 +#define ERROR_DS_CANT_DEL_MASTER_CROSSREF 0x000020B7 +#define ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD 0x000020B8 +#define ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX 0x000020B9 +#define ERROR_DS_DUP_RDN 0x000020BA +#define ERROR_DS_DUP_OID 0x000020BB +#define ERROR_DS_DUP_MAPI_ID 0x000020BC +#define ERROR_DS_DUP_SCHEMA_ID_GUID 0x000020BD +#define ERROR_DS_DUP_LDAP_DISPLAY_NAME 0x000020BE +#define ERROR_DS_SEMANTIC_ATT_TEST 0x000020BF +#define ERROR_DS_SYNTAX_MISMATCH 0x000020C0 +#define ERROR_DS_EXISTS_IN_MUST_HAVE 0x000020C1 +#define ERROR_DS_EXISTS_IN_MAY_HAVE 0x000020C2 +#define ERROR_DS_NONEXISTENT_MAY_HAVE 0x000020C3 +#define ERROR_DS_NONEXISTENT_MUST_HAVE 0x000020C4 +#define ERROR_DS_AUX_CLS_TEST_FAIL 0x000020C5 +#define ERROR_DS_NONEXISTENT_POSS_SUP 0x000020C6 +#define ERROR_DS_SUB_CLS_TEST_FAIL 0x000020C7 +#define ERROR_DS_BAD_RDN_ATT_ID_SYNTAX 0x000020C8 +#define ERROR_DS_EXISTS_IN_AUX_CLS 0x000020C9 +#define ERROR_DS_EXISTS_IN_SUB_CLS 0x000020CA +#define ERROR_DS_EXISTS_IN_POSS_SUP 0x000020CB +#define ERROR_DS_RECALCSCHEMA_FAILED 0x000020CC +#define ERROR_DS_TREE_DELETE_NOT_FINISHED 0x000020CD +#define ERROR_DS_CANT_DELETE 0x000020CE +#define ERROR_DS_ATT_SCHEMA_REQ_ID 0x000020CF +#define ERROR_DS_BAD_ATT_SCHEMA_SYNTAX 0x000020D0 +#define ERROR_DS_CANT_CACHE_ATT 0x000020D1 +#define ERROR_DS_CANT_CACHE_CLASS 0x000020D2 +#define ERROR_DS_CANT_REMOVE_ATT_CACHE 0x000020D3 +#define ERROR_DS_CANT_REMOVE_CLASS_CACHE 0x000020D4 +#define ERROR_DS_CANT_RETRIEVE_DN 0x000020D5 +#define ERROR_DS_MISSING_SUPREF 0x000020D6 +#define ERROR_DS_CANT_RETRIEVE_INSTANCE 0x000020D7 +#define ERROR_DS_CODE_INCONSISTENCY 0x000020D8 +#define ERROR_DS_DATABASE_ERROR 0x000020D9 +#define ERROR_DS_GOVERNSID_MISSING 0x000020DA +#define ERROR_DS_MISSING_EXPECTED_ATT 0x000020DB +#define ERROR_DS_NCNAME_MISSING_CR_REF 0x000020DC +#define ERROR_DS_SECURITY_CHECKING_ERROR 0x000020DD +#define ERROR_DS_SCHEMA_NOT_LOADED 0x000020DE +#define ERROR_DS_SCHEMA_ALLOC_FAILED 0x000020DF +#define ERROR_DS_ATT_SCHEMA_REQ_SYNTAX 0x000020E0 +#define ERROR_DS_GCVERIFY_ERROR 0x000020E1 +#define ERROR_DS_DRA_SCHEMA_MISMATCH 0x000020E2 +#define ERROR_DS_CANT_FIND_DSA_OBJ 0x000020E3 +#define ERROR_DS_CANT_FIND_EXPECTED_NC 0x000020E4 +#define ERROR_DS_CANT_FIND_NC_IN_CACHE 0x000020E5 +#define ERROR_DS_CANT_RETRIEVE_CHILD 0x000020E6 +#define ERROR_DS_SECURITY_ILLEGAL_MODIFY 0x000020E7 +#define ERROR_DS_CANT_REPLACE_HIDDEN_REC 0x000020E8 +#define ERROR_DS_BAD_HIERARCHY_FILE 0x000020E9 +#define ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED 0x000020EA +#define ERROR_DS_CONFIG_PARAM_MISSING 0x000020EB +#define ERROR_DS_COUNTING_AB_INDICES_FAILED 0x000020EC +#define ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED 0x000020ED +#define ERROR_DS_INTERNAL_FAILURE 0x000020EE +#define ERROR_DS_UNKNOWN_ERROR 0x000020EF +#define ERROR_DS_ROOT_REQUIRES_CLASS_TOP 0x000020F0 +#define ERROR_DS_REFUSING_FSMO_ROLES 0x000020F1 +#define ERROR_DS_MISSING_FSMO_SETTINGS 0x000020F2 +#define ERROR_DS_UNABLE_TO_SURRENDER_ROLES 0x000020F3 +#define ERROR_DS_DRA_GENERIC 0x000020F4 +#define ERROR_DS_DRA_INVALID_PARAMETER 0x000020F5 +#define ERROR_DS_DRA_BUSY 0x000020F6 +#define ERROR_DS_DRA_BAD_DN 0x000020F7 +#define ERROR_DS_DRA_BAD_NC 0x000020F8 +#define ERROR_DS_DRA_DN_EXISTS 0x000020F9 +#define ERROR_DS_DRA_INTERNAL_ERROR 0x000020FA +#define ERROR_DS_DRA_INCONSISTENT_DIT 0x000020FB +#define ERROR_DS_DRA_CONNECTION_FAILED 0x000020FC +#define ERROR_DS_DRA_BAD_INSTANCE_TYPE 0x000020FD +#define ERROR_DS_DRA_OUT_OF_MEM 0x000020FE +#define ERROR_DS_DRA_MAIL_PROBLEM 0x000020FF +#define ERROR_DS_DRA_REF_ALREADY_EXISTS 0x00002100 +#define ERROR_DS_DRA_REF_NOT_FOUND 0x00002101 +#define ERROR_DS_DRA_OBJ_IS_REP_SOURCE 0x00002102 +#define ERROR_DS_DRA_DB_ERROR 0x00002103 +#define ERROR_DS_DRA_NO_REPLICA 0x00002104 +#define ERROR_DS_DRA_ACCESS_DENIED 0x00002105 +#define ERROR_DS_DRA_NOT_SUPPORTED 0x00002106 +#define ERROR_DS_DRA_RPC_CANCELLED 0x00002107 +#define ERROR_DS_DRA_SOURCE_DISABLED 0x00002108 +#define ERROR_DS_DRA_SINK_DISABLED 0x00002109 +#define ERROR_DS_DRA_NAME_COLLISION 0x0000210A +#define ERROR_DS_DRA_SOURCE_REINSTALLED 0x0000210B +#define ERROR_DS_DRA_MISSING_PARENT 0x0000210C +#define ERROR_DS_DRA_PREEMPTED 0x0000210D +#define ERROR_DS_DRA_ABANDON_SYNC 0x0000210E +#define ERROR_DS_DRA_SHUTDOWN 0x0000210F +#define ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET 0x00002110 +#define ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA 0x00002111 +#define ERROR_DS_DRA_EXTN_CONNECTION_FAILED 0x00002112 +#define ERROR_DS_INSTALL_SCHEMA_MISMATCH 0x00002113 +#define ERROR_DS_DUP_LINK_ID 0x00002114 +#define ERROR_DS_NAME_ERROR_RESOLVING 0x00002115 +#define ERROR_DS_NAME_ERROR_NOT_FOUND 0x00002116 +#define ERROR_DS_NAME_ERROR_NOT_UNIQUE 0x00002117 +#define ERROR_DS_NAME_ERROR_NO_MAPPING 0x00002118 +#define ERROR_DS_NAME_ERROR_DOMAIN_ONLY 0x00002119 +#define ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING 0x0000211A +#define ERROR_DS_CONSTRUCTED_ATT_MOD 0x0000211B +#define ERROR_DS_WRONG_OM_OBJ_CLASS 0x0000211C +#define ERROR_DS_DRA_REPL_PENDING 0x0000211D +#define ERROR_DS_DS_REQUIRED 0x0000211E +#define ERROR_DS_INVALID_LDAP_DISPLAY_NAME 0x0000211F +#define ERROR_DS_NON_BASE_SEARCH 0x00002120 +#define ERROR_DS_CANT_RETRIEVE_ATTS 0x00002121 +#define ERROR_DS_BACKLINK_WITHOUT_LINK 0x00002122 +#define ERROR_DS_EPOCH_MISMATCH 0x00002123 +#define ERROR_DS_SRC_NAME_MISMATCH 0x00002124 +#define ERROR_DS_SRC_AND_DST_NC_IDENTICAL 0x00002125 +#define ERROR_DS_DST_NC_MISMATCH 0x00002126 +#define ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC 0x00002127 +#define ERROR_DS_SRC_GUID_MISMATCH 0x00002128 +#define ERROR_DS_CANT_MOVE_DELETED_OBJECT 0x00002129 +#define ERROR_DS_PDC_OPERATION_IN_PROGRESS 0x0000212A +#define ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD 0x0000212B +#define ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION 0x0000212C +#define ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS 0x0000212D +#define ERROR_DS_NC_MUST_HAVE_NC_PARENT 0x0000212E +#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE 0x0000212F +#define ERROR_DS_DST_DOMAIN_NOT_NATIVE 0x00002130 +#define ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER 0x00002131 +#define ERROR_DS_CANT_MOVE_ACCOUNT_GROUP 0x00002132 +#define ERROR_DS_CANT_MOVE_RESOURCE_GROUP 0x00002133 +#define ERROR_DS_INVALID_SEARCH_FLAG 0x00002134 +#define ERROR_DS_NO_TREE_DELETE_ABOVE_NC 0x00002135 +#define ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE 0x00002136 +#define ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE 0x00002137 +#define ERROR_DS_SAM_INIT_FAILURE 0x00002138 +#define ERROR_DS_SENSITIVE_GROUP_VIOLATION 0x00002139 +#define ERROR_DS_CANT_MOD_PRIMARYGROUPID 0x0000213A +#define ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD 0x0000213B +#define ERROR_DS_NONSAFE_SCHEMA_CHANGE 0x0000213C +#define ERROR_DS_SCHEMA_UPDATE_DISALLOWED 0x0000213D +#define ERROR_DS_CANT_CREATE_UNDER_SCHEMA 0x0000213E +#define ERROR_DS_INSTALL_NO_SRC_SCH_VERSION 0x0000213F +#define ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE 0x00002140 +#define ERROR_DS_INVALID_GROUP_TYPE 0x00002141 +#define ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN 0x00002142 +#define ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN 0x00002143 +#define ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER 0x00002144 +#define ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER 0x00002145 +#define ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER 0x00002146 +#define ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER 0x00002147 +#define ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER 0x00002148 +#define ERROR_DS_HAVE_PRIMARY_MEMBERS 0x00002149 +#define ERROR_DS_STRING_SD_CONVERSION_FAILED 0x0000214A +#define ERROR_DS_NAMING_MASTER_GC 0x0000214B +#define ERROR_DS_DNS_LOOKUP_FAILURE 0x0000214C +#define ERROR_DS_COULDNT_UPDATE_SPNS 0x0000214D +#define ERROR_DS_CANT_RETRIEVE_SD 0x0000214E +#define ERROR_DS_KEY_NOT_UNIQUE 0x0000214F +#define ERROR_DS_WRONG_LINKED_ATT_SYNTAX 0x00002150 +#define ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD 0x00002151 +#define ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY 0x00002152 +#define ERROR_DS_CANT_START 0x00002153 +#define ERROR_DS_INIT_FAILURE 0x00002154 +#define ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION 0x00002155 +#define ERROR_DS_SOURCE_DOMAIN_IN_FOREST 0x00002156 +#define ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST 0x00002157 +#define ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED 0x00002158 +#define ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN 0x00002159 +#define ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER 0x0000215A +#define ERROR_DS_SRC_SID_EXISTS_IN_FOREST 0x0000215B +#define ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH 0x0000215C +#define ERROR_SAM_INIT_FAILURE 0x0000215D +#define ERROR_DS_DRA_SCHEMA_INFO_SHIP 0x0000215E +#define ERROR_DS_DRA_SCHEMA_CONFLICT 0x0000215F +#define ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT 0x00002160 +#define ERROR_DS_DRA_OBJ_NC_MISMATCH 0x00002161 +#define ERROR_DS_NC_STILL_HAS_DSAS 0x00002162 +#define ERROR_DS_GC_REQUIRED 0x00002163 +#define ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY 0x00002164 +#define ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS 0x00002165 +#define ERROR_DS_CANT_ADD_TO_GC 0x00002166 +#define ERROR_DS_NO_CHECKPOINT_WITH_PDC 0x00002167 +#define ERROR_DS_SOURCE_AUDITING_NOT_ENABLED 0x00002168 +#define ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC 0x00002169 +#define ERROR_DS_INVALID_NAME_FOR_SPN 0x0000216A +#define ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS 0x0000216B +#define ERROR_DS_UNICODEPWD_NOT_IN_QUOTES 0x0000216C +#define ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED 0x0000216D +#define ERROR_DS_MUST_BE_RUN_ON_DST_DC 0x0000216E +#define ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER 0x0000216F +#define ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ 0x00002170 +#define ERROR_DS_INIT_FAILURE_CONSOLE 0x00002171 +#define ERROR_DS_SAM_INIT_FAILURE_CONSOLE 0x00002172 +#define ERROR_DS_FOREST_VERSION_TOO_HIGH 0x00002173 +#define ERROR_DS_DOMAIN_VERSION_TOO_HIGH 0x00002174 +#define ERROR_DS_FOREST_VERSION_TOO_LOW 0x00002175 +#define ERROR_DS_DOMAIN_VERSION_TOO_LOW 0x00002176 +#define ERROR_DS_INCOMPATIBLE_VERSION 0x00002177 +#define ERROR_DS_LOW_DSA_VERSION 0x00002178 +#define ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN 0x00002179 +#define ERROR_DS_NOT_SUPPORTED_SORT_ORDER 0x0000217A +#define ERROR_DS_NAME_NOT_UNIQUE 0x0000217B +#define ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 0x0000217C +#define ERROR_DS_OUT_OF_VERSION_STORE 0x0000217D +#define ERROR_DS_INCOMPATIBLE_CONTROLS_USED 0x0000217E +#define ERROR_DS_NO_REF_DOMAIN 0x0000217F +#define ERROR_DS_RESERVED_LINK_ID 0x00002180 +#define ERROR_DS_LINK_ID_NOT_AVAILABLE 0x00002181 +#define ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER 0x00002182 +#define ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE 0x00002183 +#define ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC 0x00002184 +#define ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG 0x00002185 +#define ERROR_DS_MODIFYDN_WRONG_GRANDPARENT 0x00002186 +#define ERROR_DS_NAME_ERROR_TRUST_REFERRAL 0x00002187 +#define ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER 0x00002188 +#define ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD 0x00002189 +#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 0x0000218A +#define ERROR_DS_THREAD_LIMIT_EXCEEDED 0x0000218B +#define ERROR_DS_NOT_CLOSEST 0x0000218C +#define ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF 0x0000218D +#define ERROR_DS_SINGLE_USER_MODE_FAILED 0x0000218E +#define ERROR_DS_NTDSCRIPT_SYNTAX_ERROR 0x0000218F +#define ERROR_DS_NTDSCRIPT_PROCESS_ERROR 0x00002190 +#define ERROR_DS_DIFFERENT_REPL_EPOCHS 0x00002191 +#define ERROR_DS_DRS_EXTENSIONS_CHANGED 0x00002192 +#define ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR 0x00002193 +#define ERROR_DS_NO_MSDS_INTID 0x00002194 +#define ERROR_DS_DUP_MSDS_INTID 0x00002195 +#define ERROR_DS_EXISTS_IN_RDNATTID 0x00002196 +#define ERROR_DS_AUTHORIZATION_FAILED 0x00002197 +#define ERROR_DS_INVALID_SCRIPT 0x00002198 +#define ERROR_DS_REMOTE_CROSSREF_OP_FAILED 0x00002199 +#define ERROR_DS_CROSS_REF_BUSY 0x0000219A +#define ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN 0x0000219B +#define ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC 0x0000219C +#define ERROR_DS_DUPLICATE_ID_FOUND 0x0000219D +#define ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT 0x0000219E +#define ERROR_DS_GROUP_CONVERSION_ERROR 0x0000219F +#define ERROR_DS_CANT_MOVE_APP_BASIC_GROUP 0x000021A0 +#define ERROR_DS_CANT_MOVE_APP_QUERY_GROUP 0x000021A1 +#define ERROR_DS_ROLE_NOT_VERIFIED 0x000021A2 +#define ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL 0x000021A3 +#define ERROR_DS_DOMAIN_RENAME_IN_PROGRESS 0x000021A4 +#define ERROR_DS_EXISTING_AD_CHILD_NC 0x000021A5 +#define ERROR_DS_REPL_LIFETIME_EXCEEDED 0x000021A6 +#define ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER 0x000021A7 +#define ERROR_DS_LDAP_SEND_QUEUE_FULL 0x000021A8 +#define ERROR_DS_DRA_OUT_SCHEDULE_WINDOW 0x000021A9 +#define ERROR_DS_POLICY_NOT_KNOWN 0x000021AA +#define ERROR_NO_SITE_SETTINGS_OBJECT 0x000021AB +#define ERROR_NO_SECRETS 0x000021AC +#define ERROR_NO_WRITABLE_DC_FOUND 0x000021AD +#define ERROR_DS_NO_SERVER_OBJECT 0x000021AE +#define ERROR_DS_NO_NTDSA_OBJECT 0x000021AF +#define ERROR_DS_NON_ASQ_SEARCH 0x000021B0 +#define ERROR_DS_AUDIT_FAILURE 0x000021B1 +#define ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE 0x000021B2 +#define ERROR_DS_INVALID_SEARCH_FLAG_TUPLE 0x000021B3 +#define ERROR_DS_HIERARCHY_TABLE_TOO_DEEP 0x000021B4 +#define ERROR_DS_DRA_CORRUPT_UTD_VECTOR 0x000021B5 +#define ERROR_DS_DRA_SECRETS_DENIED 0x000021B6 +#define ERROR_DS_RESERVED_MAPI_ID 0x000021B7 +#define ERROR_DS_MAPI_ID_NOT_AVAILABLE 0x000021B8 +#define ERROR_DS_DRA_MISSING_KRBTGT_SECRET 0x000021B9 +#define ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST 0x000021BA +#define ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST 0x000021BB +#define ERROR_INVALID_USER_PRINCIPAL_NAME 0x000021BC +#define ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS 0x000021BD +#define ERROR_DS_OID_NOT_FOUND 0x000021BE +#define ERROR_DS_DRA_RECYCLED_TARGET 0x000021BF +#define ERROR_DS_DISALLOWED_NC_REDIRECT 0x000021C0 +#define ERROR_DS_HIGH_ADLDS_FFL 0x000021C1 +#define ERROR_DS_HIGH_DSA_VERSION 0x000021C2 +#define ERROR_DS_LOW_ADLDS_FFL 0x000021C3 +#define ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION 0x000021C4 +#define ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED 0x000021C5 +#define ERROR_INCORRECT_ACCOUNT_TYPE 0x000021C6 + +/* System Error Codes (9000-11999) */ + +#define DNS_ERROR_RCODE_FORMAT_ERROR 0x00002329 +#define DNS_ERROR_RCODE_SERVER_FAILURE 0x0000232A +#define DNS_ERROR_RCODE_NAME_ERROR 0x0000232B +#define DNS_ERROR_RCODE_NOT_IMPLEMENTED 0x0000232C +#define DNS_ERROR_RCODE_REFUSED 0x0000232D +#define DNS_ERROR_RCODE_YXDOMAIN 0x0000232E +#define DNS_ERROR_RCODE_YXRRSET 0x0000232F +#define DNS_ERROR_RCODE_NXRRSET 0x00002330 +#define DNS_ERROR_RCODE_NOTAUTH 0x00002331 +#define DNS_ERROR_RCODE_NOTZONE 0x00002332 +#define DNS_ERROR_RCODE_BADSIG 0x00002338 +#define DNS_ERROR_RCODE_BADKEY 0x00002339 +#define DNS_ERROR_RCODE_BADTIME 0x0000233A +#define DNS_ERROR_KEYMASTER_REQUIRED 0x0000238D +#define DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE 0x0000238E +#define DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 0x0000238F +#define DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS 0x00002390 +#define DNS_ERROR_UNSUPPORTED_ALGORITHM 0x00002391 +#define DNS_ERROR_INVALID_KEY_SIZE 0x00002392 +#define DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE 0x00002393 +#define DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION 0x00002394 +#define DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR 0x00002395 +#define DNS_ERROR_UNEXPECTED_CNG_ERROR 0x00002396 +#define DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION 0x00002397 +#define DNS_ERROR_KSP_NOT_ACCESSIBLE 0x00002398 +#define DNS_ERROR_TOO_MANY_SKDS 0x00002399 +#define DNS_ERROR_INVALID_ROLLOVER_PERIOD 0x0000239A +#define DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET 0x0000239B +#define DNS_ERROR_ROLLOVER_IN_PROGRESS 0x0000239C +#define DNS_ERROR_STANDBY_KEY_NOT_PRESENT 0x0000239D +#define DNS_ERROR_NOT_ALLOWED_ON_ZSK 0x0000239E +#define DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD 0x0000239F +#define DNS_ERROR_ROLLOVER_ALREADY_QUEUED 0x000023A0 +#define DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE 0x000023A1 +#define DNS_ERROR_BAD_KEYMASTER 0x000023A2 +#define DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD 0x000023A3 +#define DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT 0x000023A4 +#define DNS_ERROR_DNSSEC_IS_DISABLED 0x000023A5 +#define DNS_ERROR_INVALID_XML 0x000023A6 +#define DNS_ERROR_NO_VALID_TRUST_ANCHORS 0x000023A7 +#define DNS_ERROR_ROLLOVER_NOT_POKEABLE 0x000023A8 +#define DNS_ERROR_NSEC3_NAME_COLLISION 0x000023A9 +#define DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 0x000023AA +#define DNS_INFO_NO_RECORDS 0x0000251D +#define DNS_ERROR_BAD_PACKET 0x0000251E +#define DNS_ERROR_NO_PACKET 0x0000251F +#define DNS_ERROR_RCODE 0x00002520 +#define DNS_ERROR_UNSECURE_PACKET 0x00002521 +#define DNS_REQUEST_PENDING 0x00002522 +#define DNS_ERROR_INVALID_TYPE 0x0000254F +#define DNS_ERROR_INVALID_IP_ADDRESS 0x00002550 +#define DNS_ERROR_INVALID_PROPERTY 0x00002551 +#define DNS_ERROR_TRY_AGAIN_LATER 0x00002552 +#define DNS_ERROR_NOT_UNIQUE 0x00002553 +#define DNS_ERROR_NON_RFC_NAME 0x00002554 +#define DNS_STATUS_FQDN 0x00002555 +#define DNS_STATUS_DOTTED_NAME 0x00002556 +#define DNS_STATUS_SINGLE_PART_NAME 0x00002557 +#define DNS_ERROR_INVALID_NAME_CHAR 0x00002558 +#define DNS_ERROR_NUMERIC_NAME 0x00002559 +#define DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER 0x0000255A +#define DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION 0x0000255B +#define DNS_ERROR_CANNOT_FIND_ROOT_HINTS 0x0000255C +#define DNS_ERROR_INCONSISTENT_ROOT_HINTS 0x0000255D +#define DNS_ERROR_DWORD_VALUE_TOO_SMALL 0x0000255E +#define DNS_ERROR_DWORD_VALUE_TOO_LARGE 0x0000255F +#define DNS_ERROR_BACKGROUND_LOADING 0x00002560 +#define DNS_ERROR_NOT_ALLOWED_ON_RODC 0x00002561 +#define DNS_ERROR_NOT_ALLOWED_UNDER_DNAME 0x00002562 +#define DNS_ERROR_DELEGATION_REQUIRED 0x00002563 +#define DNS_ERROR_INVALID_POLICY_TABLE 0x00002564 +#define DNS_ERROR_ZONE_DOES_NOT_EXIST 0x00002581 +#define DNS_ERROR_NO_ZONE_INFO 0x00002582 +#define DNS_ERROR_INVALID_ZONE_OPERATION 0x00002583 +#define DNS_ERROR_ZONE_CONFIGURATION_ERROR 0x00002584 +#define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 0x00002585 +#define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 0x00002586 +#define DNS_ERROR_ZONE_LOCKED 0x00002587 +#define DNS_ERROR_ZONE_CREATION_FAILED 0x00002588 +#define DNS_ERROR_ZONE_ALREADY_EXISTS 0x00002589 +#define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 0x0000258A +#define DNS_ERROR_INVALID_ZONE_TYPE 0x0000258B +#define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 0x0000258C +#define DNS_ERROR_ZONE_NOT_SECONDARY 0x0000258D +#define DNS_ERROR_NEED_SECONDARY_ADDRESSES 0x0000258E +#define DNS_ERROR_WINS_INIT_FAILED 0x0000258F +#define DNS_ERROR_NEED_WINS_SERVERS 0x00002590 +#define DNS_ERROR_NBSTAT_INIT_FAILED 0x00002591 +#define DNS_ERROR_SOA_DELETE_INVALID 0x00002592 +#define DNS_ERROR_FORWARDER_ALREADY_EXISTS 0x00002593 +#define DNS_ERROR_ZONE_REQUIRES_MASTER_IP 0x00002594 +#define DNS_ERROR_ZONE_IS_SHUTDOWN 0x00002595 +#define DNS_ERROR_ZONE_LOCKED_FOR_SIGNING 0x00002596 +#define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 0x000025B3 +#define DNS_ERROR_INVALID_DATAFILE_NAME 0x000025B4 +#define DNS_ERROR_DATAFILE_OPEN_FAILURE 0x000025B5 +#define DNS_ERROR_FILE_WRITEBACK_FAILED 0x000025B6 +#define DNS_ERROR_DATAFILE_PARSING 0x000025B7 +#define DNS_ERROR_RECORD_DOES_NOT_EXIST 0x000025E5 +#define DNS_ERROR_RECORD_FORMAT 0x000025E6 +#define DNS_ERROR_NODE_CREATION_FAILED 0x000025E7 +#define DNS_ERROR_UNKNOWN_RECORD_TYPE 0x000025E8 +#define DNS_ERROR_RECORD_TIMED_OUT 0x000025E9 +#define DNS_ERROR_NAME_NOT_IN_ZONE 0x000025EA +#define DNS_ERROR_CNAME_LOOP 0x000025EB +#define DNS_ERROR_NODE_IS_CNAME 0x000025EC +#define DNS_ERROR_CNAME_COLLISION 0x000025ED +#define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 0x000025EE +#define DNS_ERROR_RECORD_ALREADY_EXISTS 0x000025EF +#define DNS_ERROR_SECONDARY_DATA 0x000025F0 +#define DNS_ERROR_NO_CREATE_CACHE_DATA 0x000025F1 +#define DNS_ERROR_NAME_DOES_NOT_EXIST 0x000025F2 +#define DNS_WARNING_PTR_CREATE_FAILED 0x000025F3 +#define DNS_WARNING_DOMAIN_UNDELETED 0x000025F4 +#define DNS_ERROR_DS_UNAVAILABLE 0x000025F5 +#define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 0x000025F6 +#define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 0x000025F7 +#define DNS_ERROR_NODE_IS_DNAME 0x000025F8 +#define DNS_ERROR_DNAME_COLLISION 0x000025F9 +#define DNS_ERROR_ALIAS_LOOP 0x000025FA +#define DNS_INFO_AXFR_COMPLETE 0x00002617 +#define DNS_ERROR_AXFR 0x00002618 +#define DNS_INFO_ADDED_LOCAL_WINS 0x00002619 +#define DNS_STATUS_CONTINUE_NEEDED 0x00002649 +#define DNS_ERROR_NO_TCPIP 0x0000267B +#define DNS_ERROR_NO_DNS_SERVERS 0x0000267C +#define DNS_ERROR_DP_DOES_NOT_EXIST 0x000026AD +#define DNS_ERROR_DP_ALREADY_EXISTS 0x000026AE +#define DNS_ERROR_DP_NOT_ENLISTED 0x000026AF +#define DNS_ERROR_DP_ALREADY_ENLISTED 0x000026B0 +#define DNS_ERROR_DP_NOT_AVAILABLE 0x000026B1 +#define DNS_ERROR_DP_FSMO_ERROR 0x000026B2 +#define WSAEINTR 0x00002714 +#define WSAEBADF 0x00002719 +#define WSAEACCES 0x0000271D +#define WSAEFAULT 0x0000271E +#define WSAEINVAL 0x00002726 +#define WSAEMFILE 0x00002728 +#define WSAEWOULDBLOCK 0x00002733 +#define WSAEINPROGRESS 0x00002734 +#define WSAEALREADY 0x00002735 +#define WSAENOTSOCK 0x00002736 +#define WSAEDESTADDRREQ 0x00002737 +#define WSAEMSGSIZE 0x00002738 +#define WSAEPROTOTYPE 0x00002739 +#define WSAENOPROTOOPT 0x0000273A +#define WSAEPROTONOSUPPORT 0x0000273B +#define WSAESOCKTNOSUPPORT 0x0000273C +#define WSAEOPNOTSUPP 0x0000273D +#define WSAEPFNOSUPPORT 0x0000273E +#define WSAEAFNOSUPPORT 0x0000273F +#define WSAEADDRINUSE 0x00002740 +#define WSAEADDRNOTAVAIL 0x00002741 +#define WSAENETDOWN 0x00002742 +#define WSAENETUNREACH 0x00002743 +#define WSAENETRESET 0x00002744 +#define WSAECONNABORTED 0x00002745 +#define WSAECONNRESET 0x00002746 +#define WSAENOBUFS 0x00002747 +#define WSAEISCONN 0x00002748 +#define WSAENOTCONN 0x00002749 +#define WSAESHUTDOWN 0x0000274A +#define WSAETOOMANYREFS 0x0000274B +#define WSAETIMEDOUT 0x0000274C +#define WSAECONNREFUSED 0x0000274D +#define WSAELOOP 0x0000274E +#define WSAENAMETOOLONG 0x0000274F +#define WSAEHOSTDOWN 0x00002750 +#define WSAEHOSTUNREACH 0x00002751 +#define WSAENOTEMPTY 0x00002752 +#define WSAEPROCLIM 0x00002753 +#define WSAEUSERS 0x00002754 +#define WSAEDQUOT 0x00002755 +#define WSAESTALE 0x00002756 +#define WSAEREMOTE 0x00002757 +#define WSASYSNOTREADY 0x0000276B +#define WSAVERNOTSUPPORTED 0x0000276C +#define WSANOTINITIALISED 0x0000276D +#define WSAEDISCON 0x00002775 +#define WSAENOMORE 0x00002776 +#define WSAECANCELLED 0x00002777 +#define WSAEINVALIDPROCTABLE 0x00002778 +#define WSAEINVALIDPROVIDER 0x00002779 +#define WSAEPROVIDERFAILEDINIT 0x0000277A +#define WSASYSCALLFAILURE 0x0000277B +#define WSASERVICE_NOT_FOUND 0x0000277C +#define WSATYPE_NOT_FOUND 0x0000277D +#define WSA_E_NO_MORE 0x0000277E +#define WSA_E_CANCELLED 0x0000277F +#define WSAEREFUSED 0x00002780 +#define WSAHOST_NOT_FOUND 0x00002AF9 +#define WSATRY_AGAIN 0x00002AFA +#define WSANO_RECOVERY 0x00002AFB +#define WSANO_DATA 0x00002AFC +#define WSA_QOS_RECEIVERS 0x00002AFD +#define WSA_QOS_SENDERS 0x00002AFE +#define WSA_QOS_NO_SENDERS 0x00002AFF +#define WSA_QOS_NO_RECEIVERS 0x00002B00 +#define WSA_QOS_REQUEST_CONFIRMED 0x00002B01 +#define WSA_QOS_ADMISSION_FAILURE 0x00002B02 +#define WSA_QOS_POLICY_FAILURE 0x00002B03 +#define WSA_QOS_BAD_STYLE 0x00002B04 +#define WSA_QOS_BAD_OBJECT 0x00002B05 +#define WSA_QOS_TRAFFIC_CTRL_ERROR 0x00002B06 +#define WSA_QOS_GENERIC_ERROR 0x00002B07 +#define WSA_QOS_ESERVICETYPE 0x00002B08 +#define WSA_QOS_EFLOWSPEC 0x00002B09 +#define WSA_QOS_EPROVSPECBUF 0x00002B0A +#define WSA_QOS_EFILTERSTYLE 0x00002B0B +#define WSA_QOS_EFILTERTYPE 0x00002B0C +#define WSA_QOS_EFILTERCOUNT 0x00002B0D +#define WSA_QOS_EOBJLENGTH 0x00002B0E +#define WSA_QOS_EFLOWCOUNT 0x00002B0F +#define WSA_QOS_EUNKOWNPSOBJ 0x00002B10 +#define WSA_QOS_EPOLICYOBJ 0x00002B11 +#define WSA_QOS_EFLOWDESC 0x00002B12 +#define WSA_QOS_EPSFLOWSPEC 0x00002B13 +#define WSA_QOS_EPSFILTERSPEC 0x00002B14 +#define WSA_QOS_ESDMODEOBJ 0x00002B15 +#define WSA_QOS_ESHAPERATEOBJ 0x00002B16 +#define WSA_QOS_RESERVED_PETYPE 0x00002B17 +#define WSA_SECURE_HOST_NOT_FOUND 0x00002B18 +#define WSA_IPSEC_NAME_POLICY_ERROR 0x00002B19 + +/* System Error Codes (12000-15999) */ + +/* ERROR_INTERNET_* : (12000 - 12175) defined in WinInet.h */ + +#define ERROR_IPSEC_QM_POLICY_EXISTS 0x000032C8 +#define ERROR_IPSEC_QM_POLICY_NOT_FOUND 0x000032C9 +#define ERROR_IPSEC_QM_POLICY_IN_USE 0x000032CA +#define ERROR_IPSEC_MM_POLICY_EXISTS 0x000032CB +#define ERROR_IPSEC_MM_POLICY_NOT_FOUND 0x000032CC +#define ERROR_IPSEC_MM_POLICY_IN_USE 0x000032CD +#define ERROR_IPSEC_MM_FILTER_EXISTS 0x000032CE +#define ERROR_IPSEC_MM_FILTER_NOT_FOUND 0x000032CF +#define ERROR_IPSEC_TRANSPORT_FILTER_EXISTS 0x000032D0 +#define ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND 0x000032D1 +#define ERROR_IPSEC_MM_AUTH_EXISTS 0x000032D2 +#define ERROR_IPSEC_MM_AUTH_NOT_FOUND 0x000032D3 +#define ERROR_IPSEC_MM_AUTH_IN_USE 0x000032D4 +#define ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND 0x000032D5 +#define ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND 0x000032D6 +#define ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND 0x000032D7 +#define ERROR_IPSEC_TUNNEL_FILTER_EXISTS 0x000032D8 +#define ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND 0x000032D9 +#define ERROR_IPSEC_MM_FILTER_PENDING_DELETION 0x000032DA +#define ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION 0x000032DB +#define ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION 0x000032DC +#define ERROR_IPSEC_MM_POLICY_PENDING_DELETION 0x000032DD +#define ERROR_IPSEC_MM_AUTH_PENDING_DELETION 0x000032DE +#define ERROR_IPSEC_QM_POLICY_PENDING_DELETION 0x000032DF +#define WARNING_IPSEC_MM_POLICY_PRUNED 0x000032E0 +#define WARNING_IPSEC_QM_POLICY_PRUNED 0x000032E1 +#define ERROR_IPSEC_IKE_NEG_STATUS_BEGIN 0x000035E8 +#define ERROR_IPSEC_IKE_AUTH_FAIL 0x000035E9 +#define ERROR_IPSEC_IKE_ATTRIB_FAIL 0x000035EA +#define ERROR_IPSEC_IKE_NEGOTIATION_PENDING 0x000035EB +#define ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR 0x000035EC +#define ERROR_IPSEC_IKE_TIMED_OUT 0x000035ED +#define ERROR_IPSEC_IKE_NO_CERT 0x000035EE +#define ERROR_IPSEC_IKE_SA_DELETED 0x000035EF +#define ERROR_IPSEC_IKE_SA_REAPED 0x000035F0 +#define ERROR_IPSEC_IKE_MM_ACQUIRE_DROP 0x000035F1 +#define ERROR_IPSEC_IKE_QM_ACQUIRE_DROP 0x000035F2 +#define ERROR_IPSEC_IKE_QUEUE_DROP_MM 0x000035F3 +#define ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM 0x000035F4 +#define ERROR_IPSEC_IKE_DROP_NO_RESPONSE 0x000035F5 +#define ERROR_IPSEC_IKE_MM_DELAY_DROP 0x000035F6 +#define ERROR_IPSEC_IKE_QM_DELAY_DROP 0x000035F7 +#define ERROR_IPSEC_IKE_ERROR 0x000035F8 +#define ERROR_IPSEC_IKE_CRL_FAILED 0x000035F9 +#define ERROR_IPSEC_IKE_INVALID_KEY_USAGE 0x000035FA +#define ERROR_IPSEC_IKE_INVALID_CERT_TYPE 0x000035FB +#define ERROR_IPSEC_IKE_NO_PRIVATE_KEY 0x000035FC +#define ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY 0x000035FD +#define ERROR_IPSEC_IKE_DH_FAIL 0x000035FE +#define ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED 0x000035FF +#define ERROR_IPSEC_IKE_INVALID_HEADER 0x00003600 +#define ERROR_IPSEC_IKE_NO_POLICY 0x00003601 +#define ERROR_IPSEC_IKE_INVALID_SIGNATURE 0x00003602 +#define ERROR_IPSEC_IKE_KERBEROS_ERROR 0x00003603 +#define ERROR_IPSEC_IKE_NO_PUBLIC_KEY 0x00003604 +#define ERROR_IPSEC_IKE_PROCESS_ERR 0x00003605 +#define ERROR_IPSEC_IKE_PROCESS_ERR_SA 0x00003606 +#define ERROR_IPSEC_IKE_PROCESS_ERR_PROP 0x00003607 +#define ERROR_IPSEC_IKE_PROCESS_ERR_TRANS 0x00003608 +#define ERROR_IPSEC_IKE_PROCESS_ERR_KE 0x00003609 +#define ERROR_IPSEC_IKE_PROCESS_ERR_ID 0x0000360A +#define ERROR_IPSEC_IKE_PROCESS_ERR_CERT 0x0000360B +#define ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ 0x0000360C +#define ERROR_IPSEC_IKE_PROCESS_ERR_HASH 0x0000360D +#define ERROR_IPSEC_IKE_PROCESS_ERR_SIG 0x0000360E +#define ERROR_IPSEC_IKE_PROCESS_ERR_NONCE 0x0000360F +#define ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY 0x00003610 +#define ERROR_IPSEC_IKE_PROCESS_ERR_DELETE 0x00003611 +#define ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR 0x00003612 +#define ERROR_IPSEC_IKE_INVALID_PAYLOAD 0x00003613 +#define ERROR_IPSEC_IKE_LOAD_SOFT_SA 0x00003614 +#define ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN 0x00003615 +#define ERROR_IPSEC_IKE_INVALID_COOKIE 0x00003616 +#define ERROR_IPSEC_IKE_NO_PEER_CERT 0x00003617 +#define ERROR_IPSEC_IKE_PEER_CRL_FAILED 0x00003618 +#define ERROR_IPSEC_IKE_POLICY_CHANGE 0x00003619 +#define ERROR_IPSEC_IKE_NO_MM_POLICY 0x0000361A +#define ERROR_IPSEC_IKE_NOTCBPRIV 0x0000361B +#define ERROR_IPSEC_IKE_SECLOADFAIL 0x0000361C +#define ERROR_IPSEC_IKE_FAILSSPINIT 0x0000361D +#define ERROR_IPSEC_IKE_FAILQUERYSSP 0x0000361E +#define ERROR_IPSEC_IKE_SRVACQFAIL 0x0000361F +#define ERROR_IPSEC_IKE_SRVQUERYCRED 0x00003620 +#define ERROR_IPSEC_IKE_GETSPIFAIL 0x00003621 +#define ERROR_IPSEC_IKE_INVALID_FILTER 0x00003622 +#define ERROR_IPSEC_IKE_OUT_OF_MEMORY 0x00003623 +#define ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED 0x00003624 +#define ERROR_IPSEC_IKE_INVALID_POLICY 0x00003625 +#define ERROR_IPSEC_IKE_UNKNOWN_DOI 0x00003626 +#define ERROR_IPSEC_IKE_INVALID_SITUATION 0x00003627 +#define ERROR_IPSEC_IKE_DH_FAILURE 0x00003628 +#define ERROR_IPSEC_IKE_INVALID_GROUP 0x00003629 +#define ERROR_IPSEC_IKE_ENCRYPT 0x0000362A +#define ERROR_IPSEC_IKE_DECRYPT 0x0000362B +#define ERROR_IPSEC_IKE_POLICY_MATCH 0x0000362C +#define ERROR_IPSEC_IKE_UNSUPPORTED_ID 0x0000362D +#define ERROR_IPSEC_IKE_INVALID_HASH 0x0000362E +#define ERROR_IPSEC_IKE_INVALID_HASH_ALG 0x0000362F +#define ERROR_IPSEC_IKE_INVALID_HASH_SIZE 0x00003630 +#define ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG 0x00003631 +#define ERROR_IPSEC_IKE_INVALID_AUTH_ALG 0x00003632 +#define ERROR_IPSEC_IKE_INVALID_SIG 0x00003633 +#define ERROR_IPSEC_IKE_LOAD_FAILED 0x00003634 +#define ERROR_IPSEC_IKE_RPC_DELETE 0x00003635 +#define ERROR_IPSEC_IKE_BENIGN_REINIT 0x00003636 +#define ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY 0x00003637 +#define ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION 0x00003638 +#define ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN 0x00003639 +#define ERROR_IPSEC_IKE_MM_LIMIT 0x0000363A +#define ERROR_IPSEC_IKE_NEGOTIATION_DISABLED 0x0000363B +#define ERROR_IPSEC_IKE_QM_LIMIT 0x0000363C +#define ERROR_IPSEC_IKE_MM_EXPIRED 0x0000363D +#define ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID 0x0000363E +#define ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH 0x0000363F +#define ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID 0x00003640 +#define ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD 0x00003641 +#define ERROR_IPSEC_IKE_DOS_COOKIE_SENT 0x00003642 +#define ERROR_IPSEC_IKE_SHUTTING_DOWN 0x00003643 +#define ERROR_IPSEC_IKE_CGA_AUTH_FAILED 0x00003644 +#define ERROR_IPSEC_IKE_PROCESS_ERR_NATOA 0x00003645 +#define ERROR_IPSEC_IKE_INVALID_MM_FOR_QM 0x00003646 +#define ERROR_IPSEC_IKE_QM_EXPIRED 0x00003647 +#define ERROR_IPSEC_IKE_TOO_MANY_FILTERS 0x00003648 +#define ERROR_IPSEC_IKE_NEG_STATUS_END 0x00003649 +#define ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL 0x0000364A +#define ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE 0x0000364B +#define ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING 0x0000364C +#define ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING 0x0000364D +#define ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS 0x0000364E +#define ERROR_IPSEC_IKE_RATELIMIT_DROP 0x0000364F +#define ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE 0x00003650 +#define ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE 0x00003651 +#define ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE 0x00003652 +#define ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY 0x00003653 +#define ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE 0x00003654 +#define ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END 0x00003655 +#define ERROR_IPSEC_BAD_SPI 0x00003656 +#define ERROR_IPSEC_SA_LIFETIME_EXPIRED 0x00003657 +#define ERROR_IPSEC_WRONG_SA 0x00003658 +#define ERROR_IPSEC_REPLAY_CHECK_FAILED 0x00003659 +#define ERROR_IPSEC_INVALID_PACKET 0x0000365A +#define ERROR_IPSEC_INTEGRITY_CHECK_FAILED 0x0000365B +#define ERROR_IPSEC_CLEAR_TEXT_DROP 0x0000365C +#define ERROR_IPSEC_AUTH_FIREWALL_DROP 0x0000365D +#define ERROR_IPSEC_THROTTLE_DROP 0x0000365E +#define ERROR_IPSEC_DOSP_BLOCK 0x00003665 +#define ERROR_IPSEC_DOSP_RECEIVED_MULTICAST 0x00003666 +#define ERROR_IPSEC_DOSP_INVALID_PACKET 0x00003667 +#define ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED 0x00003668 +#define ERROR_IPSEC_DOSP_MAX_ENTRIES 0x00003669 +#define ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED 0x0000366A +#define ERROR_IPSEC_DOSP_NOT_INSTALLED 0x0000366B +#define ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES 0x0000366C +#define ERROR_SXS_SECTION_NOT_FOUND 0x000036B0 +#define ERROR_SXS_CANT_GEN_ACTCTX 0x000036B1 +#define ERROR_SXS_INVALID_ACTCTXDATA_FORMAT 0x000036B2 +#define ERROR_SXS_ASSEMBLY_NOT_FOUND 0x000036B3 +#define ERROR_SXS_MANIFEST_FORMAT_ERROR 0x000036B4 +#define ERROR_SXS_MANIFEST_PARSE_ERROR 0x000036B5 +#define ERROR_SXS_ACTIVATION_CONTEXT_DISABLED 0x000036B6 +#define ERROR_SXS_KEY_NOT_FOUND 0x000036B7 +#define ERROR_SXS_VERSION_CONFLICT 0x000036B8 +#define ERROR_SXS_WRONG_SECTION_TYPE 0x000036B9 +#define ERROR_SXS_THREAD_QUERIES_DISABLED 0x000036BA +#define ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET 0x000036BB +#define ERROR_SXS_UNKNOWN_ENCODING_GROUP 0x000036BC +#define ERROR_SXS_UNKNOWN_ENCODING 0x000036BD +#define ERROR_SXS_INVALID_XML_NAMESPACE_URI 0x000036BE +#define ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED 0x000036BF +#define ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED 0x000036C0 +#define ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE 0x000036C1 +#define ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE 0x000036C2 +#define ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE 0x000036C3 +#define ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT 0x000036C4 +#define ERROR_SXS_DUPLICATE_DLL_NAME 0x000036C5 +#define ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME 0x000036C6 +#define ERROR_SXS_DUPLICATE_CLSID 0x000036C7 +#define ERROR_SXS_DUPLICATE_IID 0x000036C8 +#define ERROR_SXS_DUPLICATE_TLBID 0x000036C9 +#define ERROR_SXS_DUPLICATE_PROGID 0x000036CA +#define ERROR_SXS_DUPLICATE_ASSEMBLY_NAME 0x000036CB +#define ERROR_SXS_FILE_HASH_MISMATCH 0x000036CC +#define ERROR_SXS_POLICY_PARSE_ERROR 0x000036CD +#define ERROR_SXS_XML_E_MISSINGQUOTE 0x000036CE +#define ERROR_SXS_XML_E_COMMENTSYNTAX 0x000036CF +#define ERROR_SXS_XML_E_BADSTARTNAMECHAR 0x000036D0 +#define ERROR_SXS_XML_E_BADNAMECHAR 0x000036D1 +#define ERROR_SXS_XML_E_BADCHARINSTRING 0x000036D2 +#define ERROR_SXS_XML_E_XMLDECLSYNTAX 0x000036D3 +#define ERROR_SXS_XML_E_BADCHARDATA 0x000036D4 +#define ERROR_SXS_XML_E_MISSINGWHITESPACE 0x000036D5 +#define ERROR_SXS_XML_E_EXPECTINGTAGEND 0x000036D6 +#define ERROR_SXS_XML_E_MISSINGSEMICOLON 0x000036D7 +#define ERROR_SXS_XML_E_UNBALANCEDPAREN 0x000036D8 +#define ERROR_SXS_XML_E_INTERNALERROR 0x000036D9 +#define ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE 0x000036DA +#define ERROR_SXS_XML_E_INCOMPLETE_ENCODING 0x000036DB +#define ERROR_SXS_XML_E_MISSING_PAREN 0x000036DC +#define ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE 0x000036DD +#define ERROR_SXS_XML_E_MULTIPLE_COLONS 0x000036DE +#define ERROR_SXS_XML_E_INVALID_DECIMAL 0x000036DF +#define ERROR_SXS_XML_E_INVALID_HEXIDECIMAL 0x000036E0 +#define ERROR_SXS_XML_E_INVALID_UNICODE 0x000036E1 +#define ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK 0x000036E2 +#define ERROR_SXS_XML_E_UNEXPECTEDENDTAG 0x000036E3 +#define ERROR_SXS_XML_E_UNCLOSEDTAG 0x000036E4 +#define ERROR_SXS_XML_E_DUPLICATEATTRIBUTE 0x000036E5 +#define ERROR_SXS_XML_E_MULTIPLEROOTS 0x000036E6 +#define ERROR_SXS_XML_E_INVALIDATROOTLEVEL 0x000036E7 +#define ERROR_SXS_XML_E_BADXMLDECL 0x000036E8 +#define ERROR_SXS_XML_E_MISSINGROOT 0x000036E9 +#define ERROR_SXS_XML_E_UNEXPECTEDEOF 0x000036EA +#define ERROR_SXS_XML_E_BADPEREFINSUBSET 0x000036EB +#define ERROR_SXS_XML_E_UNCLOSEDSTARTTAG 0x000036EC +#define ERROR_SXS_XML_E_UNCLOSEDENDTAG 0x000036ED +#define ERROR_SXS_XML_E_UNCLOSEDSTRING 0x000036EE +#define ERROR_SXS_XML_E_UNCLOSEDCOMMENT 0x000036EF +#define ERROR_SXS_XML_E_UNCLOSEDDECL 0x000036F0 +#define ERROR_SXS_XML_E_UNCLOSEDCDATA 0x000036F1 +#define ERROR_SXS_XML_E_RESERVEDNAMESPACE 0x000036F2 +#define ERROR_SXS_XML_E_INVALIDENCODING 0x000036F3 +#define ERROR_SXS_XML_E_INVALIDSWITCH 0x000036F4 +#define ERROR_SXS_XML_E_BADXMLCASE 0x000036F5 +#define ERROR_SXS_XML_E_INVALID_STANDALONE 0x000036F6 +#define ERROR_SXS_XML_E_UNEXPECTED_STANDALONE 0x000036F7 +#define ERROR_SXS_XML_E_INVALID_VERSION 0x000036F8 +#define ERROR_SXS_XML_E_MISSINGEQUALS 0x000036F9 +#define ERROR_SXS_PROTECTION_RECOVERY_FAILED 0x000036FA +#define ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT 0x000036FB +#define ERROR_SXS_PROTECTION_CATALOG_NOT_VALID 0x000036FC +#define ERROR_SXS_UNTRANSLATABLE_HRESULT 0x000036FD +#define ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING 0x000036FE +#define ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE 0x000036FF +#define ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME 0x00003700 +#define ERROR_SXS_ASSEMBLY_MISSING 0x00003701 +#define ERROR_SXS_CORRUPT_ACTIVATION_STACK 0x00003702 +#define ERROR_SXS_CORRUPTION 0x00003703 +#define ERROR_SXS_EARLY_DEACTIVATION 0x00003704 +#define ERROR_SXS_INVALID_DEACTIVATION 0x00003705 +#define ERROR_SXS_MULTIPLE_DEACTIVATION 0x00003706 +#define ERROR_SXS_PROCESS_TERMINATION_REQUESTED 0x00003707 +#define ERROR_SXS_RELEASE_ACTIVATION_CONTEXT 0x00003708 +#define ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY 0x00003709 +#define ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE 0x0000370A +#define ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME 0x0000370B +#define ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE 0x0000370C +#define ERROR_SXS_IDENTITY_PARSE_ERROR 0x0000370D +#define ERROR_MALFORMED_SUBSTITUTION_STRING 0x0000370E +#define ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN 0x0000370F +#define ERROR_UNMAPPED_SUBSTITUTION_STRING 0x00003710 +#define ERROR_SXS_ASSEMBLY_NOT_LOCKED 0x00003711 +#define ERROR_SXS_COMPONENT_STORE_CORRUPT 0x00003712 +#define ERROR_ADVANCED_INSTALLER_FAILED 0x00003713 +#define ERROR_XML_ENCODING_MISMATCH 0x00003714 +#define ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT 0x00003715 +#define ERROR_SXS_IDENTITIES_DIFFERENT 0x00003716 +#define ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT 0x00003717 +#define ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY 0x00003718 +#define ERROR_SXS_MANIFEST_TOO_BIG 0x00003719 +#define ERROR_SXS_SETTING_NOT_REGISTERED 0x0000371A +#define ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE 0x0000371B +#define ERROR_SMI_PRIMITIVE_INSTALLER_FAILED 0x0000371C +#define ERROR_GENERIC_COMMAND_FAILED 0x0000371D +#define ERROR_SXS_FILE_HASH_MISSING 0x0000371E +#define ERROR_EVT_INVALID_CHANNEL_PATH 0x00003A98 +#define ERROR_EVT_INVALID_QUERY 0x00003A99 +#define ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND 0x00003A9A +#define ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND 0x00003A9B +#define ERROR_EVT_INVALID_PUBLISHER_NAME 0x00003A9C +#define ERROR_EVT_INVALID_EVENT_DATA 0x00003A9D +#define ERROR_EVT_CHANNEL_NOT_FOUND 0x00003A9F +#define ERROR_EVT_MALFORMED_XML_TEXT 0x00003AA0 +#define ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL 0x00003AA1 +#define ERROR_EVT_CONFIGURATION_ERROR 0x00003AA2 +#define ERROR_EVT_QUERY_RESULT_STALE 0x00003AA3 +#define ERROR_EVT_QUERY_RESULT_INVALID_POSITION 0x00003AA4 +#define ERROR_EVT_NON_VALIDATING_MSXML 0x00003AA5 +#define ERROR_EVT_FILTER_ALREADYSCOPED 0x00003AA6 +#define ERROR_EVT_FILTER_NOTELTSET 0x00003AA7 +#define ERROR_EVT_FILTER_INVARG 0x00003AA8 +#define ERROR_EVT_FILTER_INVTEST 0x00003AA9 +#define ERROR_EVT_FILTER_INVTYPE 0x00003AAA +#define ERROR_EVT_FILTER_PARSEERR 0x00003AAB +#define ERROR_EVT_FILTER_UNSUPPORTEDOP 0x00003AAC +#define ERROR_EVT_FILTER_UNEXPECTEDTOKEN 0x00003AAD +#define ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL 0x00003AAE +#define ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE 0x00003AAF +#define ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE 0x00003AB0 +#define ERROR_EVT_CHANNEL_CANNOT_ACTIVATE 0x00003AB1 +#define ERROR_EVT_FILTER_TOO_COMPLEX 0x00003AB2 +#define ERROR_EVT_MESSAGE_NOT_FOUND 0x00003AB3 +#define ERROR_EVT_MESSAGE_ID_NOT_FOUND 0x00003AB4 +#define ERROR_EVT_UNRESOLVED_VALUE_INSERT 0x00003AB5 +#define ERROR_EVT_UNRESOLVED_PARAMETER_INSERT 0x00003AB6 +#define ERROR_EVT_MAX_INSERTS_REACHED 0x00003AB7 +#define ERROR_EVT_EVENT_DEFINITION_NOT_FOUND 0x00003AB8 +#define ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND 0x00003AB9 +#define ERROR_EVT_VERSION_TOO_OLD 0x00003ABA +#define ERROR_EVT_VERSION_TOO_NEW 0x00003ABB +#define ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY 0x00003ABC +#define ERROR_EVT_PUBLISHER_DISABLED 0x00003ABD +#define ERROR_EVT_FILTER_OUT_OF_RANGE 0x00003ABE +#define ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE 0x00003AE8 +#define ERROR_EC_LOG_DISABLED 0x00003AE9 +#define ERROR_EC_CIRCULAR_FORWARDING 0x00003AEA +#define ERROR_EC_CREDSTORE_FULL 0x00003AEB +#define ERROR_EC_CRED_NOT_FOUND 0x00003AEC +#define ERROR_EC_NO_ACTIVE_CHANNEL 0x00003AED +#define ERROR_MUI_FILE_NOT_FOUND 0x00003AFC +#define ERROR_MUI_INVALID_FILE 0x00003AFD +#define ERROR_MUI_INVALID_RC_CONFIG 0x00003AFE +#define ERROR_MUI_INVALID_LOCALE_NAME 0x00003AFF +#define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME 0x00003B00 +#define ERROR_MUI_FILE_NOT_LOADED 0x00003B01 +#define ERROR_RESOURCE_ENUM_USER_STOP 0x00003B02 +#define ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED 0x00003B03 +#define ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME 0x00003B04 +#define ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE 0x00003B06 +#define ERROR_MRM_INVALID_PRICONFIG 0x00003B07 +#define ERROR_MRM_INVALID_FILE_TYPE 0x00003B08 +#define ERROR_MRM_UNKNOWN_QUALIFIER 0x00003B09 +#define ERROR_MRM_INVALID_QUALIFIER_VALUE 0x00003B0A +#define ERROR_MRM_NO_CANDIDATE 0x00003B0B +#define ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE 0x00003B0C +#define ERROR_MRM_RESOURCE_TYPE_MISMATCH 0x00003B0D +#define ERROR_MRM_DUPLICATE_MAP_NAME 0x00003B0E +#define ERROR_MRM_DUPLICATE_ENTRY 0x00003B0F +#define ERROR_MRM_INVALID_RESOURCE_IDENTIFIER 0x00003B10 +#define ERROR_MRM_FILEPATH_TOO_LONG 0x00003B11 +#define ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE 0x00003B12 +#define ERROR_MRM_INVALID_PRI_FILE 0x00003B16 +#define ERROR_MRM_NAMED_RESOURCE_NOT_FOUND 0x00003B17 +#define ERROR_MRM_MAP_NOT_FOUND 0x00003B1F +#define ERROR_MRM_UNSUPPORTED_PROFILE_TYPE 0x00003B20 +#define ERROR_MRM_INVALID_QUALIFIER_OPERATOR 0x00003B21 +#define ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE 0x00003B22 +#define ERROR_MRM_AUTOMERGE_ENABLED 0x00003B23 +#define ERROR_MRM_TOO_MANY_RESOURCES 0x00003B24 +#define ERROR_MCA_INVALID_CAPABILITIES_STRING 0x00003B60 +#define ERROR_MCA_INVALID_VCP_VERSION 0x00003B61 +#define ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION 0x00003B62 +#define ERROR_MCA_MCCS_VERSION_MISMATCH 0x00003B63 +#define ERROR_MCA_UNSUPPORTED_MCCS_VERSION 0x00003B64 +#define ERROR_MCA_INTERNAL_ERROR 0x00003B65 +#define ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED 0x00003B66 +#define ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE 0x00003B67 +#define ERROR_AMBIGUOUS_SYSTEM_DEVICE 0x00003B92 +#define ERROR_SYSTEM_DEVICE_NOT_FOUND 0x00003BC3 +#define ERROR_HASH_NOT_SUPPORTED 0x00003BC4 +#define ERROR_HASH_NOT_PRESENT 0x00003BC5 +#define ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED 0x00003BD9 +#define ERROR_GPIO_CLIENT_INFORMATION_INVALID 0x00003BDA +#define ERROR_GPIO_VERSION_NOT_SUPPORTED 0x00003BDB +#define ERROR_GPIO_INVALID_REGISTRATION_PACKET 0x00003BDC +#define ERROR_GPIO_OPERATION_DENIED 0x00003BDD +#define ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE 0x00003BDE +#define ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED 0x00003BDF +#define ERROR_CANNOT_SWITCH_RUNLEVEL 0x00003C28 +#define ERROR_INVALID_RUNLEVEL_SETTING 0x00003C29 +#define ERROR_RUNLEVEL_SWITCH_TIMEOUT 0x00003C2A +#define ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT 0x00003C2B +#define ERROR_RUNLEVEL_SWITCH_IN_PROGRESS 0x00003C2C +#define ERROR_SERVICES_FAILED_AUTOSTART 0x00003C2D +#define ERROR_COM_TASK_STOP_PENDING 0x00003C8D +#define ERROR_INSTALL_OPEN_PACKAGE_FAILED 0x00003CF0 +#define ERROR_INSTALL_PACKAGE_NOT_FOUND 0x00003CF1 +#define ERROR_INSTALL_INVALID_PACKAGE 0x00003CF2 +#define ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED 0x00003CF3 +#define ERROR_INSTALL_OUT_OF_DISK_SPACE 0x00003CF4 +#define ERROR_INSTALL_NETWORK_FAILURE 0x00003CF5 +#define ERROR_INSTALL_REGISTRATION_FAILURE 0x00003CF6 +#define ERROR_INSTALL_DEREGISTRATION_FAILURE 0x00003CF7 +#define ERROR_INSTALL_CANCEL 0x00003CF8 +#define ERROR_INSTALL_FAILED 0x00003CF9 +#define ERROR_REMOVE_FAILED 0x00003CFA +#define ERROR_PACKAGE_ALREADY_EXISTS 0x00003CFB +#define ERROR_NEEDS_REMEDIATION 0x00003CFC +#define ERROR_INSTALL_PREREQUISITE_FAILED 0x00003CFD +#define ERROR_PACKAGE_REPOSITORY_CORRUPTED 0x00003CFE +#define ERROR_INSTALL_POLICY_FAILURE 0x00003CFF +#define ERROR_PACKAGE_UPDATING 0x00003D00 +#define ERROR_DEPLOYMENT_BLOCKED_BY_POLICY 0x00003D01 +#define ERROR_PACKAGES_IN_USE 0x00003D02 +#define ERROR_RECOVERY_FILE_CORRUPT 0x00003D03 +#define ERROR_INVALID_STAGED_SIGNATURE 0x00003D04 +#define ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED 0x00003D05 +#define ERROR_INSTALL_PACKAGE_DOWNGRADE 0x00003D06 +#define ERROR_SYSTEM_NEEDS_REMEDIATION 0x00003D07 +#define ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN 0x00003D08 +#define ERROR_RESILIENCY_FILE_CORRUPT 0x00003D09 +#define ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING 0x00003D0A +#define APPMODEL_ERROR_NO_PACKAGE 0x00003D54 +#define APPMODEL_ERROR_PACKAGE_RUNTIME_CORRUPT 0x00003D55 +#define APPMODEL_ERROR_PACKAGE_IDENTITY_CORRUPT 0x00003D56 +#define APPMODEL_ERROR_NO_APPLICATION 0x00003D57 +#define ERROR_STATE_LOAD_STORE_FAILED 0x00003DB8 +#define ERROR_STATE_GET_VERSION_FAILED 0x00003DB9 +#define ERROR_STATE_SET_VERSION_FAILED 0x00003DBA +#define ERROR_STATE_STRUCTURED_RESET_FAILED 0x00003DBB +#define ERROR_STATE_OPEN_CONTAINER_FAILED 0x00003DBC +#define ERROR_STATE_CREATE_CONTAINER_FAILED 0x00003DBD +#define ERROR_STATE_DELETE_CONTAINER_FAILED 0x00003DBE +#define ERROR_STATE_READ_SETTING_FAILED 0x00003DBF +#define ERROR_STATE_WRITE_SETTING_FAILED 0x00003DC0 +#define ERROR_STATE_DELETE_SETTING_FAILED 0x00003DC1 +#define ERROR_STATE_QUERY_SETTING_FAILED 0x00003DC2 +#define ERROR_STATE_READ_COMPOSITE_SETTING_FAILED 0x00003DC3 +#define ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED 0x00003DC4 +#define ERROR_STATE_ENUMERATE_CONTAINER_FAILED 0x00003DC5 +#define ERROR_STATE_ENUMERATE_SETTINGS_FAILED 0x00003DC6 +#define ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED 0x00003DC7 +#define ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED 0x00003DC8 +#define ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED 0x00003DC9 +#define ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED 0x00003DCA +#define ERROR_API_UNAVAILABLE 0x00003DE1 + + +#define EXCEPTION_MAXIMUM_PARAMETERS 15 typedef struct _EXCEPTION_RECORD EXCEPTION_RECORD; typedef struct _EXCEPTION_RECORD *PEXCEPTION_RECORD; From 9f284fa1a99450f97907f7c66b587060d452355c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 26 Sep 2012 15:28:05 -0400 Subject: [PATCH 32/64] libwinpr: add check for objective-c bool type --- winpr/include/winpr/wtypes.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/winpr/include/winpr/wtypes.h b/winpr/include/winpr/wtypes.h index 315006b8b..a405ef2ff 100644 --- a/winpr/include/winpr/wtypes.h +++ b/winpr/include/winpr/wtypes.h @@ -39,7 +39,12 @@ #define __int3264 __int32 #endif +#ifdef OBJC_BOOL_DEFINED +typedef OBJC_BOOL BOOL, *PBOOL, *LPBOOL; +#else typedef int BOOL, *PBOOL, *LPBOOL; +#endif + typedef unsigned char BYTE, *PBYTE, *LPBYTE; typedef BYTE BOOLEAN, *PBOOLEAN; typedef unsigned short WCHAR, *PWCHAR; From 0df7bcf632d1ce3f221061fd673d0f94c614b698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 26 Sep 2012 16:25:23 -0400 Subject: [PATCH 33/64] libwinpr-file: added CreateFile/DeleteFile --- winpr/include/winpr/file.h | 100 ++++++++++++++++++++++++++++ winpr/libwinpr/file/CMakeLists.txt | 5 ++ winpr/libwinpr/file/file.c | 38 ++++++++--- winpr/libwinpr/synch/CMakeLists.txt | 19 +++--- 4 files changed, 146 insertions(+), 16 deletions(-) diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h index 0b06c8acf..88ee610dd 100644 --- a/winpr/include/winpr/file.h +++ b/winpr/include/winpr/file.h @@ -27,6 +27,82 @@ #ifndef _WIN32 +#define FILE_READ_DATA 0x0001 +#define FILE_LIST_DIRECTORY 0x0001 +#define FILE_WRITE_DATA 0x0002 +#define FILE_ADD_FILE 0x0002 +#define FILE_APPEND_DATA 0x0004 +#define FILE_ADD_SUBDIRECTORY 0x0004 +#define FILE_CREATE_PIPE_INSTANCE 0x0004 +#define FILE_READ_EA 0x0008 +#define FILE_WRITE_EA 0x0010 +#define FILE_EXECUTE 0x0020 +#define FILE_TRAVERSE 0x0020 +#define FILE_DELETE_CHILD 0x0040 +#define FILE_READ_ATTRIBUTES 0x0080 +#define FILE_WRITE_ATTRIBUTES 0x0100 + +#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) +#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE) +#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE) +#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE) + +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 +#define FILE_SHARE_DELETE 0x00000004 + +#define FILE_ATTRIBUTE_READONLY 0x00000001 +#define FILE_ATTRIBUTE_HIDDEN 0x00000002 +#define FILE_ATTRIBUTE_SYSTEM 0x00000004 +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 +#define FILE_ATTRIBUTE_DEVICE 0x00000040 +#define FILE_ATTRIBUTE_NORMAL 0x00000080 +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 +#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 +#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 +#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 +#define FILE_ATTRIBUTE_OFFLINE 0x00001000 +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 +#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 + +#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 +#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 +#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 +#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 +#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 +#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 +#define FILE_NOTIFY_CHANGE_CREATION 0x00000040 +#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 + +#define FILE_ACTION_ADDED 0x00000001 +#define FILE_ACTION_REMOVED 0x00000002 +#define FILE_ACTION_MODIFIED 0x00000003 +#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 +#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 + +#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +#define FILE_CASE_PRESERVED_NAMES 0x00000002 +#define FILE_UNICODE_ON_DISK 0x00000004 +#define FILE_PERSISTENT_ACLS 0x00000008 +#define FILE_FILE_COMPRESSION 0x00000010 +#define FILE_VOLUME_QUOTAS 0x00000020 +#define FILE_SUPPORTS_SPARSE_FILES 0x00000040 +#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 +#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 +#define FILE_VOLUME_IS_COMPRESSED 0x00008000 +#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 +#define FILE_SUPPORTS_ENCRYPTION 0x00020000 +#define FILE_NAMED_STREAMS 0x00040000 +#define FILE_READ_ONLY_VOLUME 0x00080000 +#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 +#define FILE_SUPPORTS_TRANSACTIONS 0x00200000 +#define FILE_SUPPORTS_HARD_LINKS 0x00400000 +#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 +#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 +#define FILE_SUPPORTS_USN_JOURNAL 0x02000000 + #define FILE_FLAG_WRITE_THROUGH 0x80000000 #define FILE_FLAG_OVERLAPPED 0x40000000 #define FILE_FLAG_NO_BUFFERING 0x20000000 @@ -39,6 +115,12 @@ #define FILE_FLAG_OPEN_NO_RECALL 0x00100000 #define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 +#define CREATE_NEW 1 +#define CREATE_ALWAYS 2 +#define OPEN_EXISTING 3 +#define OPEN_ALWAYS 4 +#define TRUNCATE_EXISTING 5 + typedef union _FILE_SEGMENT_ELEMENT { PVOID64 Buffer; @@ -47,6 +129,16 @@ typedef union _FILE_SEGMENT_ELEMENT typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped); +WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); + +WINPR_API HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); + +WINPR_API BOOL DeleteFileA(LPCSTR lpFileName); + +WINPR_API BOOL DeleteFileW(LPCWSTR lpFileName); + WINPR_API BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); @@ -87,6 +179,14 @@ WINPR_API BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffse WINPR_API BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped); +#ifdef UNICODE +#define CreateFile CreateFileW +#define DeleteFile DeleteFileW +#else +#define CreateFile CreateFileA +#define DeleteFile DeleteFileA +#endif + #endif #endif /* WINPR_FILE_H */ diff --git a/winpr/libwinpr/file/CMakeLists.txt b/winpr/libwinpr/file/CMakeLists.txt index af233a751..d75aed803 100644 --- a/winpr/libwinpr/file/CMakeLists.txt +++ b/winpr/libwinpr/file/CMakeLists.txt @@ -32,6 +32,11 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO if(WITH_MONOLITHIC_BUILD) else() + if(NOT WIN32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle) + endif() + + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 04a519e01..9ae9c831b 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -26,17 +26,20 @@ /** * api-ms-win-core-file-l1-2-0.dll: * - * CompareFileTime - * CreateDirectoryA - * CreateDirectoryW - * CreateFile2 * CreateFileA * CreateFileW - * DefineDosDeviceW + * CreateFile2 * DeleteFileA * DeleteFileW + * CreateDirectoryA + * CreateDirectoryW + * RemoveDirectoryA + * RemoveDirectoryW + * CompareFileTime + * DefineDosDeviceW * DeleteVolumeMountPointW * FileTimeToLocalFileTime + * LocalFileTimeToFileTime * FindClose * FindCloseChangeNotification * FindFirstChangeNotificationA @@ -82,10 +85,7 @@ * GetVolumeNameForVolumeMountPointW * GetVolumePathNamesForVolumeNameW * GetVolumePathNameW - * LocalFileTimeToFileTime * QueryDosDeviceW - * RemoveDirectoryA - * RemoveDirectoryW * SetFileAttributesA * SetFileAttributesW * SetFileTime @@ -109,6 +109,28 @@ #ifndef _WIN32 +HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + return NULL; +} + +HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + return NULL; +} + +BOOL DeleteFileA(LPCSTR lpFileName) +{ + return TRUE; +} + +BOOL DeleteFileW(LPCWSTR lpFileName) +{ + return TRUE; +} + BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { diff --git a/winpr/libwinpr/synch/CMakeLists.txt b/winpr/libwinpr/synch/CMakeLists.txt index e74a67911..6361fe435 100644 --- a/winpr/libwinpr/synch/CMakeLists.txt +++ b/winpr/libwinpr/synch/CMakeLists.txt @@ -15,10 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "winpr-synch") +set(MODULE_PREFIX "WINPR_SYNCH") + set(CMAKE_THREAD_PREFER_PTHREAD) find_required_package(Threads) -set(WINPR_SYNCH_SRCS +set(${MODULE_PREFIX}_SRCS address.c barrier.c condition.c @@ -35,14 +38,14 @@ set(WINPR_SYNCH_SRCS wait.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-synch OBJECT ${WINPR_SYNCH_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-synch ${WINPR_SYNCH_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() set_target_properties(winpr-synch PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_SYNCH_LIBS +set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) @@ -51,13 +54,13 @@ if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SYNCH_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} winpr-handle) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle) endif() - target_link_libraries(winpr-synch ${WINPR_SYNCH_LIBS}) - install(TARGETS winpr-synch DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() From 03b19c3f3009b6cfdce5cd00a070fe4a807f08a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 28 Sep 2012 18:10:37 -0400 Subject: [PATCH 34/64] libwinpr: fix compilation on Windows --- channels/audin/server/CMakeLists.txt | 3 +-- server/Windows/wf_update.c | 2 ++ winpr/include/winpr/library.h | 4 ++-- winpr/libwinpr/library/library.c | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/channels/audin/server/CMakeLists.txt b/channels/audin/server/CMakeLists.txt index 3280cfd05..d728b7009 100644 --- a/channels/audin/server/CMakeLists.txt +++ b/channels/audin/server/CMakeLists.txt @@ -24,6 +24,5 @@ set(${MODULE_PREFIX}_SRCS if(WITH_MONOLITHIC_BUILD) set(${MODULE_PREFIX}_LIBS freerdp PARENT_SCOPE) else() - set(${MODULE_PREFIX}_LIBS freerdp-utils PARENT_SCOPE) + set(${MODULE_PREFIX}_LIBS freerdp-utils freerdp-channels PARENT_SCOPE) endif() - diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 98bde03a4..70d5a81ca 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h index 203bcd755..b38cf2a6e 100644 --- a/winpr/include/winpr/library.h +++ b/winpr/include/winpr/library.h @@ -23,6 +23,8 @@ #include #include +#ifndef _WIN32 + typedef HANDLE DLL_DIRECTORY_COOKIE; #define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 @@ -34,8 +36,6 @@ WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory); WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie); WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags); -#ifndef _WIN32 - WINPR_API HMODULE LoadLibraryA(LPCSTR lpLibFileName); WINPR_API HMODULE LoadLibraryW(LPCWSTR lpLibFileName); diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c index b5e38601f..8707dc80b 100644 --- a/winpr/libwinpr/library/library.c +++ b/winpr/libwinpr/library/library.c @@ -58,6 +58,12 @@ * SizeofResource */ +#ifndef _WIN32 + +#include +#include +#include + DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory) { return NULL; @@ -73,12 +79,6 @@ BOOL SetDefaultDllDirectories(DWORD DirectoryFlags) return TRUE; } -#ifndef _WIN32 - -#include -#include -#include - HMODULE LoadLibraryA(LPCSTR lpLibFileName) { HMODULE library; From 7de10e209252a413ec048319868ed86cc21d435c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 30 Sep 2012 01:09:45 -0400 Subject: [PATCH 35/64] cmake: add cunit detection support on Windows --- cmake/FindCUnit.cmake | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/cmake/FindCUnit.cmake b/cmake/FindCUnit.cmake index 3e6b17518..9abfd121e 100644 --- a/cmake/FindCUnit.cmake +++ b/cmake/FindCUnit.cmake @@ -27,21 +27,40 @@ # limitations under the License. #============================================================================= -find_path(CUNIT_INCLUDE_DIR NAMES CUnit.h - PATH_SUFFIXES CUnit - DOC "The CUnit include directory" +if(WIN32) +set(_CUNIT_ROOT_HINTS + $ENV{CUNIT_ROOT_DIR} + ${CUNIT_ROOT_DIR}) + +set(_CUNIT_ROOT_PATHS + "$ENV{PROGRAMFILES}/CUnit" + "$ENV{SYSTEMDRIVE}/CUnit") + +set(_CUNIT_ROOT_HINTS_AND_PATHS + HINTS ${_CUNIT_ROOT_HINTS} + PATHS ${_CUNIT_ROOT_PATHS}) +endif(WIN32) + +find_path(CUNIT_INCLUDE_DIR + NAMES CUnit.h + HINTS ${_CUNIT_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES CUnit include + DOC "The CUnit include directory" ) -find_library(CUNIT_LIBRARY NAMES cunit - DOC "The CUnit library" +find_library(CUNIT_LIBRARY + NAMES cunit + HINTS ${_CUNIT_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES lib + DOC "The CUnit library" ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR) if(CUNIT_FOUND) - set( CUNIT_LIBRARIES ${CUNIT_LIBRARY} ) - set( CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR} ) + set(CUNIT_LIBRARIES ${CUNIT_LIBRARY}) + set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR}) endif() mark_as_advanced(CUNIT_INCLUDE_DIR CUNIT_LIBRARY) From 440a4e23f25c4ff226bec9794608ebca11dc98e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 30 Sep 2012 16:33:42 -0400 Subject: [PATCH 36/64] cunit: cleanup old test suites --- cunit/CMakeLists.txt | 12 - cunit/test_ber.c | 96 ------- cunit/test_ber.h | 28 -- cunit/test_channels.c | 91 ------ cunit/test_channels.h | 26 -- cunit/test_freerdp.c | 20 +- cunit/test_license.c | 8 +- cunit/test_list.c | 94 ------ cunit/test_list.h | 26 -- cunit/test_per.c | 64 ----- cunit/test_per.h | 27 -- cunit/test_stream.c | 76 ----- cunit/test_stream.h | 26 -- cunit/test_utils.c | 650 ------------------------------------------ cunit/test_utils.h | 30 -- 15 files changed, 8 insertions(+), 1266 deletions(-) delete mode 100644 cunit/test_ber.c delete mode 100644 cunit/test_ber.h delete mode 100644 cunit/test_channels.c delete mode 100644 cunit/test_channels.h delete mode 100644 cunit/test_list.c delete mode 100644 cunit/test_list.h delete mode 100644 cunit/test_per.c delete mode 100644 cunit/test_per.h delete mode 100644 cunit/test_stream.c delete mode 100644 cunit/test_stream.h delete mode 100644 cunit/test_utils.c delete mode 100644 cunit/test_utils.h diff --git a/cunit/CMakeLists.txt b/cunit/CMakeLists.txt index 18f7c1216..dd902d674 100644 --- a/cunit/CMakeLists.txt +++ b/cunit/CMakeLists.txt @@ -26,10 +26,6 @@ include_directories(../libfreerdp/cache) include_directories(../libfreerdp/codec) add_executable(test_freerdp - test_per.c - test_per.h - test_ber.c - test_ber.h test_gcc.c test_gcc.h test_mcs.c @@ -40,8 +36,6 @@ add_executable(test_freerdp test_bitmap.h test_gdi.c test_gdi.h - test_list.c - test_list.h test_orders.c test_orders.h test_pcap.c @@ -50,12 +44,6 @@ add_executable(test_freerdp test_ntlm.h test_license.c test_license.h - test_stream.c - test_stream.h - test_utils.c - test_utils.h - test_channels.c - test_channels.h test_cliprdr.c test_cliprdr.h test_drdynvc.c diff --git a/cunit/test_ber.c b/cunit/test_ber.c deleted file mode 100644 index cb555f0e3..000000000 --- a/cunit/test_ber.c +++ /dev/null @@ -1,96 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Basic Encoding Rules (BER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "test_ber.h" -#include - -int init_ber_suite(void) -{ - return 0; -} - -int clean_ber_suite(void) -{ - return 0; -} - -int add_ber_suite(void) -{ - add_test_suite(ber); - - add_test_function(ber_write_length); - add_test_function(ber_write_universal_tag); - add_test_function(ber_write_application_tag); - - return 0; -} - -uint8 ber_length_expected_1[1] = "\x40"; /* 64 */ -uint8 ber_length_expected_2[3] = "\x82\x01\x94"; /* 404 */ - -void test_ber_write_length(void) -{ - STREAM *s1, *s2; - - s1 = stream_new(sizeof(ber_length_expected_1)); - s2 = stream_new(sizeof(ber_length_expected_2)); - - ber_write_length(s1, 64); - ASSERT_STREAM(s1, (uint8*) ber_length_expected_1, sizeof(ber_length_expected_1)); - - ber_write_length(s2, 404); - ASSERT_STREAM(s2, (uint8*) ber_length_expected_2, sizeof(ber_length_expected_2)); - - stream_free(s1); - stream_free(s2); -} - -/* BOOLEAN, length 1, without value */ -uint8 ber_universal_tag_expected[1] = "\x01"; - -void test_ber_write_universal_tag(void) -{ - STREAM* s; - - s = stream_new(sizeof(ber_universal_tag_expected)); - ber_write_universal_tag(s, 1, false); - - ASSERT_STREAM(s, (uint8*) ber_universal_tag_expected, sizeof(ber_universal_tag_expected)); - - stream_free(s); -} - -/* T.125 MCS Application 101 (Connect-Initial), length 404 */ -uint8 ber_application_tag_expected[5] = "\x7F\x65\x82\x01\x94"; - -void test_ber_write_application_tag(void) -{ - STREAM* s; - - s = stream_new(sizeof(ber_application_tag_expected)); - ber_write_application_tag(s, 101, 404); - - ASSERT_STREAM(s, (uint8*) ber_application_tag_expected, sizeof(ber_application_tag_expected)); - - stream_free(s); -} diff --git a/cunit/test_ber.h b/cunit/test_ber.h deleted file mode 100644 index 0cc922885..000000000 --- a/cunit/test_ber.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Basic Encoding Rules (BER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_ber_suite(void); -int clean_ber_suite(void); -int add_ber_suite(void); - -void test_ber_write_length(void); -void test_ber_write_universal_tag(void); -void test_ber_write_application_tag(void); diff --git a/cunit/test_channels.c b/cunit/test_channels.c deleted file mode 100644 index 6ef97cda2..000000000 --- a/cunit/test_channels.c +++ /dev/null @@ -1,91 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Channel Manager Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test_channels.h" - -int init_channels_suite(void) -{ - freerdp_channels_global_init(); - return 0; -} - -int clean_channels_suite(void) -{ - freerdp_channels_global_uninit(); - return 0; -} - -int add_channels_suite(void) -{ - add_test_suite(channels); - - add_test_function(channels); - - return 0; -} - -static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, int data_size) -{ - printf("chan_id %d data_size %d\n", chan_id, data_size); - return 0; -} - -void test_channels(void) -{ - rdpChannels* chan_man; - rdpSettings settings = { 0 }; - freerdp instance = { 0 }; - RDP_EVENT* event; - - settings.hostname = "testhost"; - instance.settings = &settings; - instance.SendChannelData = test_rdp_channel_data; - - chan_man = freerdp_channels_new(); - - freerdp_channels_load_plugin(chan_man, &settings, "../channels/rdpdbg/rdpdbg.so", NULL); - freerdp_channels_pre_connect(chan_man, &instance); - freerdp_channels_post_connect(chan_man, &instance); - - freerdp_channels_data(&instance, 0, "testdata", 8, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 8); - freerdp_channels_data(&instance, 0, "testdata1", 9, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 9); - freerdp_channels_data(&instance, 0, "testdata11", 10, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 10); - freerdp_channels_data(&instance, 0, "testdata111", 11, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 11); - - event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL); - freerdp_channels_send_event(chan_man, event); - - while ((event = freerdp_channels_pop_event(chan_man)) == NULL) - { - freerdp_channels_check_fds(chan_man, &instance); - } - printf("responded event_type %d\n", event->event_type); - freerdp_event_free(event); - - freerdp_channels_close(chan_man, &instance); - freerdp_channels_free(chan_man); -} diff --git a/cunit/test_channels.h b/cunit/test_channels.h deleted file mode 100644 index 678a5c08d..000000000 --- a/cunit/test_channels.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Channel Manager Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_channels_suite(void); -int clean_channels_suite(void); -int add_channels_suite(void); - -void test_channels(void); diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index a7223de83..077550054 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -19,21 +19,15 @@ #include -#include "test_per.h" -#include "test_ber.h" #include "test_gcc.h" #include "test_mcs.h" #include "test_color.h" #include "test_bitmap.h" #include "test_gdi.h" -#include "test_list.h" #include "test_sspi.h" -#include "test_stream.h" -#include "test_utils.h" #include "test_orders.h" #include "test_ntlm.h" #include "test_license.h" -#include "test_channels.h" #include "test_cliprdr.h" #include "test_drdynvc.h" #include "test_rfx.h" @@ -122,29 +116,23 @@ typedef struct _test_suite test_suite; const static test_suite suites[] = { - { "ber", add_ber_suite }, { "bitmap", add_bitmap_suite }, - { "channels", add_channels_suite }, - { "cliprdr", add_cliprdr_suite }, + //{ "cliprdr", add_cliprdr_suite }, { "color", add_color_suite }, - { "drdynvc", add_drdynvc_suite }, + //{ "drdynvc", add_drdynvc_suite }, { "gcc", add_gcc_suite }, { "gdi", add_gdi_suite }, { "license", add_license_suite }, - { "list", add_list_suite }, { "mcs", add_mcs_suite }, { "mppc", add_mppc_suite }, { "mppc_enc", add_mppc_enc_suite }, { "ntlm", add_ntlm_suite }, { "orders", add_orders_suite }, { "pcap", add_pcap_suite }, - { "per", add_per_suite }, - { "rail", add_rail_suite }, + //{ "rail", add_rail_suite }, { "rfx", add_rfx_suite }, { "nsc", add_nsc_suite }, - { "sspi", add_sspi_suite }, - { "stream", add_stream_suite }, - { "utils", add_utils_suite } + { "sspi", add_sspi_suite } }; #define N_SUITES (sizeof suites / sizeof suites[0]) diff --git a/cunit/test_license.c b/cunit/test_license.c index 49e7e0457..997ad6c63 100644 --- a/cunit/test_license.c +++ b/cunit/test_license.c @@ -426,8 +426,8 @@ void test_license_generate_keys(void) memcpy(license->server_random, test_server_random, sizeof(test_server_random)); memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret)); memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent)); - memcpy(license->certificate->cert_info.modulus.data, test_modulus, sizeof(test_modulus)); - license->certificate->cert_info.modulus.length = sizeof(test_modulus); + memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus)); + license->certificate->cert_info.ModulusLength = sizeof(test_modulus); license_generate_keys(license); license_encrypt_premaster_secret(license); @@ -460,8 +460,8 @@ void test_license_encrypt_premaster_secret(void) s = &_s; memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret)); memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent)); - memcpy(license->certificate->cert_info.modulus.data, test_modulus, sizeof(test_modulus)); - license->certificate->cert_info.modulus.length = sizeof(test_modulus); + memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus)); + license->certificate->cert_info.ModulusLength = sizeof(test_modulus); s->data = license->encrypted_premaster_secret->data; s->p = s->data + sizeof(test_encrypted_premaster_secret); diff --git a/cunit/test_list.c b/cunit/test_list.c deleted file mode 100644 index c5ef963f9..000000000 --- a/cunit/test_list.c +++ /dev/null @@ -1,94 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * List Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include "test_list.h" - -int init_list_suite(void) -{ - return 0; -} - -int clean_list_suite(void) -{ - return 0; -} - -int add_list_suite(void) -{ - add_test_suite(list); - - add_test_function(list); - - return 0; -} - -struct _my_list_item -{ - uint32 a; - uint32 b; -}; -typedef struct _my_list_item my_list_item; - -void test_list(void) -{ - LIST* list; - LIST_ITEM* list_item; - my_list_item* item; - my_list_item* item1; - my_list_item* item2; - int i; - - list = list_new(); - - for (i = 0; i < 10; i++) - { - item = xnew(my_list_item); - item->a = i; - item->b = i * i; - list_enqueue(list, item); - } - - for (i = 0, list_item = list->head; list_item; i++, list_item = list_item->next) - { - CU_ASSERT(((my_list_item*)list_item->data)->a == i); - CU_ASSERT(((my_list_item*)list_item->data)->b == i * i); - /*printf("%d %d\n", item->a, item->b);*/ - } - - item1 = xnew(my_list_item); - list_add(list, item1); - item2 = xnew(my_list_item); - list_add(list, item2); - - CU_ASSERT(list_remove(list, item1) == item1); - xfree(item1); - CU_ASSERT(list_remove(list, item2) == item2); - CU_ASSERT(list_remove(list, item2) == NULL); - xfree(item2); - - while ((item = list_dequeue(list)) != NULL) - xfree(item); - list_free(list); -} diff --git a/cunit/test_list.h b/cunit/test_list.h deleted file mode 100644 index 01afbb02d..000000000 --- a/cunit/test_list.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * List Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_list_suite(void); -int clean_list_suite(void); -int add_list_suite(void); - -void test_list(void); diff --git a/cunit/test_per.c b/cunit/test_per.c deleted file mode 100644 index 3d872849f..000000000 --- a/cunit/test_per.c +++ /dev/null @@ -1,64 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Packed Encoding Rules (PER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "test_per.h" -#include - -int init_per_suite(void) -{ - return 0; -} - -int clean_per_suite(void) -{ - return 0; -} - -int add_per_suite(void) -{ - add_test_suite(per); - - add_test_function(per_write_length); - add_test_function(per_write_object_identifier); - - return 0; -} - -uint8 per_length_expected[2] = "\x81\x2A"; - -void test_per_write_length(void) -{ - STREAM* s = stream_new(2); - per_write_length(s, 298); - ASSERT_STREAM(s, (uint8*) per_length_expected, sizeof(per_length_expected)); -} - -uint8 per_oid[6] = { 0, 0, 20, 124, 0, 1 }; -uint8 per_oid_expected[6] = "\x05\x00\x14\x7C\x00\x01"; - -void test_per_write_object_identifier(void) -{ - STREAM* s = stream_new(6); - per_write_object_identifier(s, per_oid); - ASSERT_STREAM(s, (uint8*) per_oid_expected, sizeof(per_oid_expected)); -} diff --git a/cunit/test_per.h b/cunit/test_per.h deleted file mode 100644 index 30f8d6fe6..000000000 --- a/cunit/test_per.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Packed Encoding Rules (PER) Unit Tests - * - * Copyright 2011 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_per_suite(void); -int clean_per_suite(void); -int add_per_suite(void); - -void test_per_write_length(void); -void test_per_write_object_identifier(void); diff --git a/cunit/test_stream.c b/cunit/test_stream.c deleted file mode 100644 index ae1a9e256..000000000 --- a/cunit/test_stream.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Stream Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include - -#include "test_stream.h" - -int init_stream_suite(void) -{ - return 0; -} - -int clean_stream_suite(void) -{ - return 0; -} - -int add_stream_suite(void) -{ - add_test_suite(stream); - - add_test_function(stream); - - return 0; -} - -void test_stream(void) -{ - STREAM * stream; - int pos; - uint32 n; - uint64 n64; - - stream = stream_new(1); - pos = stream_get_pos(stream); - - stream_write_uint8(stream, 0xFE); - - stream_check_size(stream, 14); - stream_write_uint16(stream, 0x0102); - stream_write_uint32(stream, 0x03040506); - stream_write_uint64(stream, 0x0708091011121314LL); - - /* freerdp_hexdump(stream->buffer, 15); */ - - stream_set_pos(stream, pos); - stream_seek(stream, 3); - stream_read_uint32(stream, n); - stream_read_uint64(stream, n64); - - CU_ASSERT(n == 0x03040506); - CU_ASSERT(n64 == 0x0708091011121314LL); - - stream_free(stream); -} diff --git a/cunit/test_stream.h b/cunit/test_stream.h deleted file mode 100644 index 32080edb5..000000000 --- a/cunit/test_stream.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Stream Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_stream_suite(void); -int clean_stream_suite(void); -int add_stream_suite(void); - -void test_stream(void); diff --git a/cunit/test_utils.c b/cunit/test_utils.c deleted file mode 100644 index 673da5163..000000000 --- a/cunit/test_utils.c +++ /dev/null @@ -1,650 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Utils Unit Tests - * - * Copyright 2011 Vic Lee, 2011 Shea Levy - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _XOPEN_SOURCE 700 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.h" - -int init_utils_suite(void) -{ - return 0; -} - -int clean_utils_suite(void) -{ - return 0; -} - -int add_utils_suite(void) -{ - add_test_suite(utils); - - add_test_function(load_plugin); - add_test_function(wait_obj); - add_test_function(args); - add_test_function(passphrase_read); - add_test_function(handle_signals); - - return 0; -} - -void test_load_plugin(void) -{ - void* entry; - -#ifdef _WIN32 - /* untested */ - entry = freerdp_load_plugin("..\\channels\\cliprdr\\cliprdr", "VirtualChannelEntry"); -#else - entry = freerdp_load_plugin("../channels/cliprdr/cliprdr.so", "VirtualChannelEntry"); -#endif - CU_ASSERT(entry != NULL); -} - -void test_wait_obj(void) -{ - struct wait_obj* wo; - int set; - - wo = wait_obj_new(); - - set = wait_obj_is_set(wo); - CU_ASSERT(set == 0); - - wait_obj_set(wo); - set = wait_obj_is_set(wo); - CU_ASSERT(set == 1); - - wait_obj_clear(wo); - set = wait_obj_is_set(wo); - CU_ASSERT(set == 0); - - wait_obj_select(&wo, 1, 1000); - - wait_obj_free(wo); -} - -static int process_plugin_args(rdpSettings* settings, const char* name, - RDP_PLUGIN_DATA* plugin_data, void* user_data) -{ - /*printf("load plugin: %s\n", name);*/ - return 1; -} - -static int process_ui_args(rdpSettings* settings, const char* opt, - const char* val, void* user_data) -{ - /*printf("ui arg: %s %s\n", opt, val);*/ - return 1; -} - -void test_args(void) -{ - char* argv_c[] = - { - "freerdp", "-a", "8", "-u", "testuser", "-d", "testdomain", "-g", "640x480", "address1:3389", - "freerdp", "-a", "16", "-u", "testuser", "-d", "testdomain", "-g", "1280x960", "address2:3390" - }; - char** argv = argv_c; - int argc = ARRAY_SIZE(argv_c); - int i; - int c; - rdpSettings* settings; - - i = 0; - while (argc > 0) - { - settings = settings_new(NULL); - - i++; - c = freerdp_parse_args(settings, argc, argv, process_plugin_args, NULL, process_ui_args, NULL); - CU_ASSERT(c > 0); - if (c == 0) - { - settings_free(settings); - break; - } - CU_ASSERT(settings->color_depth == i * 8); - CU_ASSERT(settings->width == i * 640); - CU_ASSERT(settings->height == i * 480); - CU_ASSERT(settings->port == i + 3388); - - settings_free(settings); - argc -= c; - argv += c; - } - CU_ASSERT(i == 2); -} - -void passphrase_read_prompts_to_tty() -{ - static const int read_nbyte = 11; - int masterfd; - char* slavedevice = NULL; - char read_buf[read_nbyte]; - fd_set fd_set_write; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - char buffer[password_size]; - int slavefd; - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - if ((slavefd = open(slavedevice, O_RDWR)) == 0) - CU_FAIL_FATAL("Could not open slave end of pty"); - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - close(masterfd); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - close(slavefd); - exit(EXIT_SUCCESS); - } - } - - read_buf[read_nbyte - 1] = '\0'; - - FD_ZERO(&fd_set_write); - FD_SET(masterfd, &fd_set_write); - if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1) - CU_FAIL_FATAL("Master end of pty not writeable"); - if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to slave end of pty"); - CU_ASSERT_STRING_EQUAL(read_buf, "Password: "); - - write(masterfd, "\n", (size_t) 2); - close(masterfd); - return; -} - -void passphrase_read_reads_from_tty() -{ - static const int read_nbyte = 11; - int masterfd; - int pipe_ends[2]; - char* slavedevice = NULL; - char read_buf[read_nbyte]; - fd_set fd_set_write; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - if (pipe(pipe_ends) != 0) - CU_FAIL_FATAL("Could not create pipe"); - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - char buffer[password_size]; - int slavefd; - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - if ((slavefd = open(slavedevice, O_RDWR)) == 0) - CU_FAIL_FATAL("Could not open slave end of pty"); - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - close(masterfd); - close(pipe_ends[0]); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - write(pipe_ends[1], buffer, password_size); - close(slavefd); - close(pipe_ends[1]); - exit(EXIT_SUCCESS); - } - } - - close(pipe_ends[1]); - read_buf[read_nbyte - 1] = '\0'; - - FD_ZERO(&fd_set_write); - FD_SET(masterfd, &fd_set_write); - if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1) - CU_FAIL_FATAL("Master end of pty not writeable"); - if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to slave end of pty"); - - write(masterfd, "passw0rd\n", sizeof "passw0rd\n"); - if (read(pipe_ends[0], read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to pipe"); - CU_ASSERT_STRING_EQUAL(read_buf, "passw0rd"); - close(masterfd); - close(pipe_ends[0]); - return; -} - -void passphrase_read_turns_off_echo_during_read() -{ - static const int read_nbyte = 11; - int masterfd, slavefd; - char* slavedevice = NULL; - char read_buf[read_nbyte]; - fd_set fd_set_write; - struct termios term_flags; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - slavefd = open(slavedevice, O_RDWR|O_NOCTTY); - if (slavefd == -1) - CU_FAIL_FATAL("Could not open slave end of pty"); - - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - if (!(term_flags.c_lflag & ECHO)) - { - term_flags.c_lflag |= ECHO; - if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0) - CU_FAIL_FATAL("Could not turn ECHO on on slave pty"); - } - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - int child_slavefd; - char buffer[password_size]; - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - if ((child_slavefd = open(slavedevice, O_RDWR)) == 0) - CU_FAIL_FATAL("Could not open slave end of pty"); - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - close(masterfd); - close(slavefd); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - close(child_slavefd); - exit(EXIT_SUCCESS); - } - } - - read_buf[read_nbyte - 1] = '\0'; - - FD_ZERO(&fd_set_write); - FD_SET(masterfd, &fd_set_write); - if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1) - CU_FAIL_FATAL("Master end of pty not writeable"); - if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to slave end of pty"); - - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - CU_ASSERT(!(term_flags.c_lflag & ECHO)) - write(masterfd, "\n", (size_t) 2); - close(masterfd); - close(slavefd); - return; -} - -void passphrase_read_resets_terminal_after_read() -{ - static const int read_nbyte = 11; - int masterfd, slavefd, status; - char* slavedevice = NULL; - char read_buf[read_nbyte]; - fd_set fd_set_write; - struct termios term_flags; - pid_t child; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - slavefd = open(slavedevice, O_RDWR|O_NOCTTY); - if (slavefd == -1) - CU_FAIL_FATAL("Could not open slave end of pty"); - - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - if (!(term_flags.c_lflag & ECHO)) - { - term_flags.c_lflag |= ECHO; - if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0) - CU_FAIL_FATAL("Could not turn ECHO on on slave pty"); - } - - switch (child = fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - int child_slavefd; - char buffer[password_size]; - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - if ((child_slavefd = open(slavedevice, O_RDWR)) == 0) - CU_FAIL_FATAL("Could not open slave end of pty"); - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - close(masterfd); - close(slavefd); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - close(child_slavefd); - exit(EXIT_SUCCESS); - } - } - - read_buf[read_nbyte - 1] = '\0'; - - FD_ZERO(&fd_set_write); - FD_SET(masterfd, &fd_set_write); - if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1) - CU_FAIL_FATAL("Master end of pty not writeable"); - if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to slave end of pty"); - - write(masterfd, "\n", (size_t) 2); - waitpid(child, &status, WUNTRACED); - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - CU_ASSERT(term_flags.c_lflag & ECHO) - close(masterfd); - close(slavefd); - return; -} - -void passphrase_read_turns_on_newline_echo_during_read() -{ - static const int read_nbyte = 11; - int masterfd, slavefd; - char* slavedevice = NULL; - char read_buf[read_nbyte]; - fd_set fd_set_write; - struct termios term_flags; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - slavefd = open(slavedevice, O_RDWR|O_NOCTTY); - if (slavefd == -1) - CU_FAIL_FATAL("Could not open slave end of pty"); - - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - if (term_flags.c_lflag & ECHONL) - { - term_flags.c_lflag &= ~ECHONL; - if (tcsetattr(slavefd, TCSANOW, &term_flags) != 0) - CU_FAIL_FATAL("Could not turn ECHO on on slave pty"); - } - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - int child_slavefd; - char buffer[password_size]; - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - if ((child_slavefd = open(slavedevice, O_RDWR)) == 0) - CU_FAIL_FATAL("Could not open slave end of pty"); - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); - close(masterfd); - close(slavefd); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - close(child_slavefd); - exit(EXIT_SUCCESS); - } - } - - read_buf[read_nbyte - 1] = '\0'; - - FD_ZERO(&fd_set_write); - FD_SET(masterfd, &fd_set_write); - if (select(masterfd + 1, NULL, &fd_set_write, NULL, NULL) == -1) - CU_FAIL_FATAL("Master end of pty not writeable"); - if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to slave end of pty"); - - if (tcgetattr(slavefd, &term_flags) != 0) - CU_FAIL_FATAL("Could not get slave pty attributes"); - CU_ASSERT(term_flags.c_lflag & ECHONL) - write(masterfd, "\n", (size_t) 2); - close(masterfd); - close(slavefd); - return; -} - -void passphrase_read_prompts_to_stderr_when_no_tty() -{ - static const int read_nbyte = 11; - int stdin_pipe[2], stderr_pipe[2]; - char read_buf[read_nbyte]; - struct sigaction ignore, orig; - - ignore.sa_handler = SIG_IGN; - sigemptyset(&ignore.sa_mask); - - if (pipe(stdin_pipe) != 0 || pipe(stderr_pipe) != 0) - CU_FAIL_FATAL("Could not create pipe"); - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - char buffer[password_size]; - close(stderr_pipe[0]); - close(stdin_pipe[1]); - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - dup2(stdin_pipe[0], STDIN_FILENO); - dup2(stderr_pipe[1], STDERR_FILENO); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - exit(EXIT_SUCCESS); - } - } - close(stderr_pipe[1]); - close(stdin_pipe[0]); - - read_buf[read_nbyte - 1] = '\0'; - - if (read(stderr_pipe[0], read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to pipe"); - CU_ASSERT_STRING_EQUAL(read_buf, "Password: "); - - sigaction(SIGPIPE, &ignore, &orig); - write(stdin_pipe[1], "\n", (size_t) 2); - sigaction(SIGPIPE, &orig, NULL); - close(stderr_pipe[0]); - close(stdin_pipe[1]); - return; -} - -void passphrase_read_reads_from_stdin_when_no_tty() -{ - static const int read_nbyte = 11; - int stdin_pipe[2], stderr_pipe[2], result_pipe[2]; - char read_buf[read_nbyte]; - struct sigaction ignore, orig; - - ignore.sa_handler = SIG_IGN; - sigemptyset(&ignore.sa_mask); - - if (pipe(stdin_pipe) != 0 - || pipe(stderr_pipe) != 0 - || pipe(result_pipe) !=0) - CU_FAIL_FATAL("Could not create pipe"); - - switch (fork()) - { - case -1: - CU_FAIL_FATAL("Could not fork"); - case 0: - { - static const int password_size = 512; - char buffer[password_size]; - close(stderr_pipe[0]); - close(result_pipe[0]); - close(stdin_pipe[1]); - if (setsid() == (pid_t) -1) - CU_FAIL_FATAL("Could not create new session"); - - dup2(stdin_pipe[0], STDIN_FILENO); - dup2(stderr_pipe[1], STDERR_FILENO); - freerdp_passphrase_read("Password: ", buffer, password_size, 0); - write(result_pipe[1], buffer, strlen(buffer) + (size_t) 1); - exit(EXIT_SUCCESS); - } - } - close(stderr_pipe[1]); - close(result_pipe[1]); - close(stdin_pipe[0]); - - read_buf[read_nbyte - 1] = '\0'; - - if (read(stderr_pipe[0], read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to pipe"); - - sigaction(SIGPIPE, &ignore, &orig); - write(stdin_pipe[1], "passw0rd\n", sizeof "passw0rd\n"); - sigaction(SIGPIPE, &orig, NULL); - - if (read(result_pipe[0], read_buf, read_nbyte) == (ssize_t) -1) - CU_FAIL_FATAL("Nothing written to pipe"); - CU_ASSERT_STRING_EQUAL(read_buf, "passw0rd"); - - close(stderr_pipe[0]); - close(stdin_pipe[1]); - return; -} - -void test_passphrase_read(void) -{ - passphrase_read_prompts_to_tty(); - passphrase_read_reads_from_tty(); - passphrase_read_turns_off_echo_during_read(); - passphrase_read_resets_terminal_after_read(); - passphrase_read_turns_on_newline_echo_during_read(); - passphrase_read_prompts_to_stderr_when_no_tty(); - passphrase_read_reads_from_stdin_when_no_tty(); -} - -void handle_signals_resets_terminal(void) -{ - int status, masterfd; - char* slavedevice = NULL; - struct termios test_flags; - pid_t child_pid; - - masterfd = posix_openpt(O_RDWR|O_NOCTTY); - - if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - CU_FAIL_FATAL("Could not create pty"); - - terminal_fildes = open(slavedevice, O_RDWR|O_NOCTTY); - tcgetattr(terminal_fildes, &orig_flags); - new_flags = orig_flags; - new_flags.c_lflag &= ~ECHO; - tcsetattr(terminal_fildes, TCSANOW, &new_flags); - terminal_needs_reset = 1; - - if((child_pid = fork()) == 0) - { - freerdp_handle_signals(); - raise(SIGINT); - } - while(wait(&status) != -1); - tcgetattr(terminal_fildes, &test_flags); - CU_ASSERT_EQUAL(orig_flags.c_lflag, test_flags.c_lflag); - close(masterfd); - close(terminal_fildes); -} - -void test_handle_signals(void) -{ - handle_signals_resets_terminal(); -} diff --git a/cunit/test_utils.h b/cunit/test_utils.h deleted file mode 100644 index 6f7567603..000000000 --- a/cunit/test_utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Utils Unit Tests - * - * Copyright 2011 Vic Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_utils_suite(void); -int clean_utils_suite(void); -int add_utils_suite(void); - -void test_load_plugin(void); -void test_wait_obj(void); -void test_args(void); -void test_passphrase_read(void); -void test_handle_signals(void); From a18ebef019d31a95f8635f77806316a55266ef2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 30 Sep 2012 20:15:42 -0400 Subject: [PATCH 37/64] cunit: migrate Sspi tests to CTest --- .gitignore | 2 + CMakeLists.txt | 10 +- cunit/CMakeLists.txt | 3 +- cunit/test_freerdp.c | 10 +- cunit/test_sspi.c | 225 ------------------ cunit/test_sspi.h | 29 --- winpr/libwinpr/sspi/CMakeLists.txt | 5 + winpr/libwinpr/sspi/test/.gitignore | 3 + winpr/libwinpr/sspi/test/CMakeLists.txt | 25 ++ .../sspi/test/TestAcquireCredentialsHandle.c | 53 +++++ .../sspi/test/TestEnumerateSecurityPackages.c | 36 +++ .../sspi/test/TestInitializeSecurityContext.c | 96 ++++++++ .../sspi/test/TestQuerySecurityPackageInfo.c | 28 +++ 13 files changed, 263 insertions(+), 262 deletions(-) delete mode 100644 cunit/test_sspi.c delete mode 100644 cunit/test_sspi.h create mode 100644 winpr/libwinpr/sspi/test/.gitignore create mode 100644 winpr/libwinpr/sspi/test/CMakeLists.txt create mode 100644 winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c create mode 100644 winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c create mode 100644 winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c create mode 100644 winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c diff --git a/.gitignore b/.gitignore index 21444d459..e65348cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,11 @@ install_manifest.txt CTestTestfile.cmake freerdp.pc Makefile +Testing cmake_install.cmake CPackConfig.cmake CPackSourceConfig.cmake +DartConfiguration.tcl # Eclipse *.project diff --git a/CMakeLists.txt b/CMakeLists.txt index 446e685a7..db3825e12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,14 @@ add_definitions("-DHAVE_CONFIG_H") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/freerdp/config.h) +# Unit Tests + +INCLUDE(CTest) + +if(BUILD_TESTING) + enable_testing() +endif() + # WinPR set(WINPR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/winpr/include") include_directories(${WINPR_INCLUDE_DIR}) @@ -201,9 +209,9 @@ endif() #find_optional_package(IPP) # Build CUnit + find_optional_package(CUnit) if(WITH_CUNIT) - enable_testing() add_subdirectory(cunit) endif() diff --git a/cunit/CMakeLists.txt b/cunit/CMakeLists.txt index dd902d674..b03f55240 100644 --- a/cunit/CMakeLists.txt +++ b/cunit/CMakeLists.txt @@ -74,4 +74,5 @@ target_link_libraries(test_freerdp freerdp-crypto) target_link_libraries(test_freerdp winpr-sspi) -add_test(CUnitTests ${EXECUTABLE_OUTPUT_PATH}/test_freerdp) +add_test(CUnitTests ${CMAKE_SOURCE_DIR}/cunit/test_freerdp) + diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index 077550054..dc178de85 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -24,7 +24,6 @@ #include "test_color.h" #include "test_bitmap.h" #include "test_gdi.h" -#include "test_sspi.h" #include "test_orders.h" #include "test_ntlm.h" #include "test_license.h" @@ -120,19 +119,18 @@ const static test_suite suites[] = //{ "cliprdr", add_cliprdr_suite }, { "color", add_color_suite }, //{ "drdynvc", add_drdynvc_suite }, - { "gcc", add_gcc_suite }, + //{ "gcc", add_gcc_suite }, { "gdi", add_gdi_suite }, { "license", add_license_suite }, - { "mcs", add_mcs_suite }, + //{ "mcs", add_mcs_suite }, { "mppc", add_mppc_suite }, { "mppc_enc", add_mppc_enc_suite }, { "ntlm", add_ntlm_suite }, - { "orders", add_orders_suite }, + //{ "orders", add_orders_suite }, { "pcap", add_pcap_suite }, //{ "rail", add_rail_suite }, { "rfx", add_rfx_suite }, - { "nsc", add_nsc_suite }, - { "sspi", add_sspi_suite } + { "nsc", add_nsc_suite } }; #define N_SUITES (sizeof suites / sizeof suites[0]) diff --git a/cunit/test_sspi.c b/cunit/test_sspi.c deleted file mode 100644 index 213a8d98d..000000000 --- a/cunit/test_sspi.c +++ /dev/null @@ -1,225 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Security Support Provider Interface (SSPI) Tests - * - * Copyright 2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include -#include - -#include "test_sspi.h" - -#define NTLM_PACKAGE_NAME "NTLM" - -int init_sspi_suite(void) -{ - sspi_GlobalInit(); - return 0; -} - -int clean_sspi_suite(void) -{ - sspi_GlobalFinish(); - return 0; -} - -int add_sspi_suite(void) -{ - add_test_suite(sspi); - - add_test_function(EnumerateSecurityPackages); - add_test_function(QuerySecurityPackageInfo); - add_test_function(AcquireCredentialsHandle); - add_test_function(InitializeSecurityContext); - - return 0; -} - -void test_EnumerateSecurityPackages(void) -{ - ULONG cPackages; - SECURITY_STATUS status; - SecPkgInfo* pPackageInfo; - - status = EnumerateSecurityPackages(&cPackages, &pPackageInfo); - - if (status == SEC_E_OK) - { - int index; - - printf("\nEnumerateSecurityPackages (%d):\n", (unsigned int)cPackages); - - for (index = 0; index < cPackages; index++) - { - printf("\"%s\", \"%s\"\n", - pPackageInfo[index].Name, pPackageInfo[index].Comment); - } - } - - FreeContextBuffer(pPackageInfo); -} - -void test_QuerySecurityPackageInfo(void) -{ - SECURITY_STATUS status; - SecPkgInfo* pPackageInfo; - - status = QuerySecurityPackageInfo("NTLM", &pPackageInfo); - - if (status == SEC_E_OK) - { - printf("\nQuerySecurityPackageInfo:\n"); - printf("\"%s\", \"%s\"\n", pPackageInfo->Name, pPackageInfo->Comment); - } -} - -const char* test_User = "User"; -const char* test_Domain = "Domain"; -const char* test_Password = "Password"; - -void test_AcquireCredentialsHandle(void) -{ - SECURITY_STATUS status; - CredHandle credentials; - TimeStamp expiration; - SEC_WINNT_AUTH_IDENTITY identity; - SecurityFunctionTable* table; - SecPkgCredentials_Names credential_names; - - table = InitSecurityInterface(); - - identity.User = (uint16*) xstrdup(test_User); - identity.UserLength = sizeof(test_User); - identity.Domain = (uint16*) xstrdup(test_Domain); - identity.DomainLength = sizeof(test_Domain); - identity.Password = (uint16*) xstrdup(test_Password); - identity.PasswordLength = sizeof(test_Password); - identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; - - status = table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME, - SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); - - if (status == SEC_E_OK) - { - status = table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names); - - if (status == SEC_E_OK) - { - printf("\nQueryCredentialsAttributes: %s\n", credential_names.sUserName); - } - } -} - -void test_InitializeSecurityContext(void) -{ - uint32 cbMaxLen; - uint32 fContextReq; - void* output_buffer; - CtxtHandle context; - ULONG pfContextAttr; - SECURITY_STATUS status; - CredHandle credentials; - TimeStamp expiration; - SecPkgInfo* pPackageInfo; - SEC_WINNT_AUTH_IDENTITY identity; - SecurityFunctionTable* table; - SecBuffer* p_SecBuffer; - SecBuffer output_SecBuffer; - SecBufferDesc output_SecBuffer_desc; - - table = InitSecurityInterface(); - - status = QuerySecurityPackageInfo(NTLM_PACKAGE_NAME, &pPackageInfo); - - if (status != SEC_E_OK) - { - printf("QuerySecurityPackageInfo status: 0x%08X\n", status); - return; - } - - cbMaxLen = pPackageInfo->cbMaxToken; - - identity.User = (uint16*) xstrdup(test_User); - identity.UserLength = sizeof(test_User); - identity.Domain = (uint16*) xstrdup(test_Domain); - identity.DomainLength = sizeof(test_Domain); - identity.Password = (uint16*) xstrdup(test_Password); - identity.PasswordLength = sizeof(test_Password); - identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; - - status = table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME, - SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); - - if (status != SEC_E_OK) - { - printf("AcquireCredentialsHandle status: 0x%08X\n", status); - return; - } - - fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE; - - output_buffer = xmalloc(cbMaxLen); - - output_SecBuffer_desc.ulVersion = 0; - output_SecBuffer_desc.cBuffers = 1; - output_SecBuffer_desc.pBuffers = &output_SecBuffer; - - output_SecBuffer.cbBuffer = cbMaxLen; - output_SecBuffer.BufferType = SECBUFFER_TOKEN; - output_SecBuffer.pvBuffer = output_buffer; - - status = table->InitializeSecurityContext(&credentials, NULL, NULL, fContextReq, 0, 0, NULL, 0, - &context, &output_SecBuffer_desc, &pfContextAttr, &expiration); - - if (status != SEC_I_CONTINUE_NEEDED) - { - printf("InitializeSecurityContext status: 0x%08X\n", status); - return; - } - - printf("cBuffers: %ld ulVersion: %ld\n", output_SecBuffer_desc.cBuffers, output_SecBuffer_desc.ulVersion); - - p_SecBuffer = &output_SecBuffer_desc.pBuffers[0]; - - printf("BufferType: 0x%04lX cbBuffer:%ld\n", p_SecBuffer->BufferType, p_SecBuffer->cbBuffer); - - freerdp_hexdump((uint8*) p_SecBuffer->pvBuffer, p_SecBuffer->cbBuffer); - - table->FreeCredentialsHandle(&credentials); - - FreeContextBuffer(pPackageInfo); -} - - - - - - - - - - - - - - - - - diff --git a/cunit/test_sspi.h b/cunit/test_sspi.h deleted file mode 100644 index 81def91dc..000000000 --- a/cunit/test_sspi.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Implementation - * Security Support Provider Interface (SSPI) Tests - * - * Copyright 2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "test_freerdp.h" - -int init_sspi_suite(void); -int clean_sspi_suite(void); -int add_sspi_suite(void); - -void test_EnumerateSecurityPackages(void); -void test_QuerySecurityPackageInfo(void); -void test_AcquireCredentialsHandle(void); -void test_InitializeSecurityContext(void); diff --git a/winpr/libwinpr/sspi/CMakeLists.txt b/winpr/libwinpr/sspi/CMakeLists.txt index 2af96c6cb..7f725e4a9 100644 --- a/winpr/libwinpr/sspi/CMakeLists.txt +++ b/winpr/libwinpr/sspi/CMakeLists.txt @@ -90,3 +90,8 @@ else() target_link_libraries(winpr-sspi ${WINPR_SSPI_LIBS}) install(TARGETS winpr-sspi DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +if(BUILD_TESTING) + add_subdirectory(test) +endif() + diff --git a/winpr/libwinpr/sspi/test/.gitignore b/winpr/libwinpr/sspi/test/.gitignore new file mode 100644 index 000000000..ad5671c60 --- /dev/null +++ b/winpr/libwinpr/sspi/test/.gitignore @@ -0,0 +1,3 @@ +TestSspi +TestSspi.c + diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt new file mode 100644 index 000000000..2b70c2648 --- /dev/null +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -0,0 +1,25 @@ + +set(MODULE_NAME "TestSspi") +set(MODULE_PREFIX "TEST_SSPI") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestQuerySecurityPackageInfo.c + TestEnumerateSecurityPackages.c + TestInitializeSecurityContext.c + TestAcquireCredentialsHandle.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +target_link_libraries(${MODULE_NAME} winpr-sspi) + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) +endforeach() + diff --git a/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c new file mode 100644 index 000000000..e9d60ea3f --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c @@ -0,0 +1,53 @@ + +#include +#include +#include +#include + +static const char* test_User = "User"; +static const char* test_Domain = "Domain"; +static const char* test_Password = "Password"; + +int TestAcquireCredentialsHandle(int argc, char* argv[]) +{ + SECURITY_STATUS status; + CredHandle credentials; + TimeStamp expiration; + SEC_WINNT_AUTH_IDENTITY identity; + SecurityFunctionTable* table; + SecPkgCredentials_Names credential_names; + + sspi_GlobalInit(); + + table = InitSecurityInterface(); + + identity.User = (UINT16*) _strdup(test_User); + identity.UserLength = sizeof(test_User); + identity.Domain = (UINT16*) _strdup(test_Domain); + identity.DomainLength = sizeof(test_Domain); + identity.Password = (UINT16*) _strdup(test_Password); + identity.PasswordLength = sizeof(test_Password); + identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; + + status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, + SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + status = table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c new file mode 100644 index 000000000..cab3884c6 --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c @@ -0,0 +1,36 @@ + +#include +#include +#include +#include + +int TestEnumerateSecurityPackages(int argc, char* argv[]) +{ + int index; + ULONG cPackages; + SECURITY_STATUS status; + SecPkgInfo* pPackageInfo; + + sspi_GlobalInit(); + + status = EnumerateSecurityPackages(&cPackages, &pPackageInfo); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + printf("\nEnumerateSecurityPackages (%d):\n", (unsigned int)cPackages); + + for (index = 0; index < cPackages; index++) + { + printf("\"%s\", \"%s\"\n", pPackageInfo[index].Name, pPackageInfo[index].Comment); + } + + FreeContextBuffer(pPackageInfo); + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c new file mode 100644 index 000000000..d434234bf --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c @@ -0,0 +1,96 @@ + +#include +#include +#include +#include + +static const char* test_User = "User"; +static const char* test_Domain = "Domain"; +static const char* test_Password = "Password"; + +int TestInitializeSecurityContext(int argc, char* argv[]) +{ + UINT32 cbMaxLen; + UINT32 fContextReq; + void* output_buffer; + CtxtHandle context; + ULONG pfContextAttr; + SECURITY_STATUS status; + CredHandle credentials; + TimeStamp expiration; + PSecPkgInfo pPackageInfo; + SEC_WINNT_AUTH_IDENTITY identity; + SecurityFunctionTable* table; + PSecBuffer p_SecBuffer; + SecBuffer output_SecBuffer; + SecBufferDesc output_SecBuffer_desc; + + sspi_GlobalInit(); + + table = InitSecurityInterface(); + + status = QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo); + + if (status != SEC_E_OK) + { + printf("QuerySecurityPackageInfo status: 0x%08X\n", status); + return -1; + } + + cbMaxLen = pPackageInfo->cbMaxToken; + + identity.User = (UINT16*) _strdup(test_User); + identity.UserLength = sizeof(test_User); + identity.Domain = (UINT16*) _strdup(test_Domain); + identity.DomainLength = sizeof(test_Domain); + identity.Password = (UINT16*) _strdup(test_Password); + identity.PasswordLength = sizeof(test_Password); + identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; + + status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, + SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, &credentials, &expiration); + + if (status != SEC_E_OK) + { + printf("AcquireCredentialsHandle status: 0x%08X\n", status); + sspi_GlobalFinish(); + return -1; + } + + fContextReq = ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_DELEGATE; + + output_buffer = malloc(cbMaxLen); + + output_SecBuffer_desc.ulVersion = 0; + output_SecBuffer_desc.cBuffers = 1; + output_SecBuffer_desc.pBuffers = &output_SecBuffer; + + output_SecBuffer.cbBuffer = cbMaxLen; + output_SecBuffer.BufferType = SECBUFFER_TOKEN; + output_SecBuffer.pvBuffer = output_buffer; + + status = table->InitializeSecurityContext(&credentials, NULL, NULL, fContextReq, 0, 0, NULL, 0, + &context, &output_SecBuffer_desc, &pfContextAttr, &expiration); + + if (status != SEC_I_CONTINUE_NEEDED) + { + printf("InitializeSecurityContext status: 0x%08X\n", status); + sspi_GlobalFinish(); + return -1; + } + + printf("cBuffers: %ld ulVersion: %ld\n", output_SecBuffer_desc.cBuffers, output_SecBuffer_desc.ulVersion); + + p_SecBuffer = &output_SecBuffer_desc.pBuffers[0]; + + printf("BufferType: 0x%04lX cbBuffer:%ld\n", p_SecBuffer->BufferType, p_SecBuffer->cbBuffer); + + table->FreeCredentialsHandle(&credentials); + + FreeContextBuffer(pPackageInfo); + + sspi_GlobalFinish(); + + return 0; +} + diff --git a/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c new file mode 100644 index 000000000..5f970fd86 --- /dev/null +++ b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c @@ -0,0 +1,28 @@ + +#include +#include +#include + +int TestQuerySecurityPackageInfo(int argc, char* argv[]) +{ + SECURITY_STATUS status; + SecPkgInfo* pPackageInfo; + + sspi_GlobalInit(); + + status = QuerySecurityPackageInfo(NTLMSP_NAME, &pPackageInfo); + + if (status != SEC_E_OK) + { + sspi_GlobalFinish(); + return -1; + } + + printf("\nQuerySecurityPackageInfo:\n"); + printf("\"%s\", \"%s\"\n", pPackageInfo->Name, pPackageInfo->Comment); + + sspi_GlobalFinish(); + + return 0; +} + From fcc9f91302c08c237bdef2ded976af3ee0ec2793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 30 Sep 2012 22:58:59 -0400 Subject: [PATCH 38/64] cmake: add support for solution groups --- CMakeLists.txt | 3 + libfreerdp/cache/CMakeLists.txt | 27 +++--- libfreerdp/channels/CMakeLists.txt | 31 +++---- libfreerdp/codec/CMakeLists.txt | 35 ++++---- libfreerdp/core/CMakeLists.txt | 35 ++++---- libfreerdp/crypto/CMakeLists.txt | 38 +++++---- libfreerdp/gdi/CMakeLists.txt | 26 +++--- libfreerdp/locale/CMakeLists.txt | 48 ++++++----- libfreerdp/rail/CMakeLists.txt | 28 ++++--- libfreerdp/utils/CMakeLists.txt | 37 ++++---- winpr/libwinpr/asn1/CMakeLists.txt | 15 ++-- winpr/libwinpr/bcrypt/CMakeLists.txt | 25 +++--- winpr/libwinpr/crt/CMakeLists.txt | 15 ++-- winpr/libwinpr/dsparse/CMakeLists.txt | 15 ++-- winpr/libwinpr/environment/CMakeLists.txt | 1 + winpr/libwinpr/error/CMakeLists.txt | 1 + winpr/libwinpr/file/CMakeLists.txt | 1 + winpr/libwinpr/handle/CMakeLists.txt | 15 ++-- winpr/libwinpr/heap/CMakeLists.txt | 15 ++-- winpr/libwinpr/interlocked/CMakeLists.txt | 18 ++-- winpr/libwinpr/interlocked/test/.gitignore | 3 + .../libwinpr/interlocked/test/CMakeLists.txt | 25 ++++++ .../interlocked/test/TestInterlockedSList.c | 84 +++++++++++++++++++ winpr/libwinpr/io/CMakeLists.txt | 1 + winpr/libwinpr/library/CMakeLists.txt | 15 ++-- winpr/libwinpr/path/CMakeLists.txt | 1 + winpr/libwinpr/registry/CMakeLists.txt | 17 ++-- winpr/libwinpr/rpc/CMakeLists.txt | 52 +++++++----- winpr/libwinpr/sspi/CMakeLists.txt | 54 ++++++------ winpr/libwinpr/sspi/test/CMakeLists.txt | 5 ++ winpr/libwinpr/sspicli/CMakeLists.txt | 15 ++-- winpr/libwinpr/synch/CMakeLists.txt | 3 +- winpr/libwinpr/sysinfo/CMakeLists.txt | 15 ++-- winpr/libwinpr/thread/CMakeLists.txt | 24 +++--- winpr/libwinpr/timezone/CMakeLists.txt | 15 ++-- winpr/libwinpr/utils/CMakeLists.txt | 23 +++-- winpr/libwinpr/winhttp/CMakeLists.txt | 15 ++-- winpr/libwinpr/winsock/CMakeLists.txt | 21 +++-- 38 files changed, 532 insertions(+), 285 deletions(-) create mode 100644 winpr/libwinpr/interlocked/test/.gitignore create mode 100644 winpr/libwinpr/interlocked/test/CMakeLists.txt create mode 100644 winpr/libwinpr/interlocked/test/TestInterlockedSList.c diff --git a/CMakeLists.txt b/CMakeLists.txt index db3825e12..0345901b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,9 @@ include(GetGitRevisionDescription) git_describe(GIT_REVISION --match "[0-9]*" --abbrev=4 --tags --always) message(STATUS "Git Revision ${GIT_REVISION}") +# Turn on solution folders (2.8.4+) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + # Default to release build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") diff --git a/libfreerdp/cache/CMakeLists.txt b/libfreerdp/cache/CMakeLists.txt index 940f9e409..0cc624659 100644 --- a/libfreerdp/cache/CMakeLists.txt +++ b/libfreerdp/cache/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-cache cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CACHE_SRCS +set(MODULE_NAME "freerdp-cache") +set(MODULE_PREFIX "FREERDP_CACHE") + +set(${MODULE_PREFIX}_SRCS brush.c pointer.c bitmap.c @@ -28,22 +29,22 @@ set(FREERDP_CACHE_SRCS cache.c) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-cache OBJECT ${FREERDP_CACHE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-cache ${FREERDP_CACHE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-cache PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") - -set(FREERDP_CACHE_LIBS) +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CACHE_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_CACHE_LIBS ${FREERDP_CACHE_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-utils) - target_link_libraries(freerdp-cache ${FREERDP_CACHE_LIBS}) - install(TARGETS freerdp-cache DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/channels/CMakeLists.txt b/libfreerdp/channels/CMakeLists.txt index 30f61f338..63fa9fdcc 100644 --- a/libfreerdp/channels/CMakeLists.txt +++ b/libfreerdp/channels/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-channels cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,32 +15,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CHANNELS_SRCS +set(MODULE_NAME "freerdp-channels") +set(MODULE_PREFIX "FREERDP_CHANNELS") + +set(${MODULE_PREFIX}_SRCS libchannels.c libchannels.h wtsvc.c wtsvc.h) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-channels OBJECT ${FREERDP_CHANNELS_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-channels ${FREERDP_CHANNELS_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-channels PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") - -set(FREERDP_CHANNELS_LIBS) +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS} winpr) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CHANNELS_LIBS} PARENT_SCOPE) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) - set(FREERDP_CHANNELS_LIBS ${FREERDP_CHANNELS_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-synch) - target_link_libraries(freerdp-channels ${FREERDP_CHANNELS_LIBS}) - install(TARGETS freerdp-channels DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/codec/CMakeLists.txt b/libfreerdp/codec/CMakeLists.txt index 6a03e002e..a404535d6 100644 --- a/libfreerdp/codec/CMakeLists.txt +++ b/libfreerdp/codec/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-codec cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CODEC_SRCS +set(MODULE_NAME "freerdp-codec") +set(MODULE_PREFIX "FREERDP_CODEC") + +set(${MODULE_PREFIX}_SRCS bitmap.c color.c rfx_bitstream.h @@ -46,18 +47,18 @@ set(FREERDP_CODEC_SRCS mppc_enc.c jpeg.c) -set(FREERDP_CODEC_SSE2_SRCS +set(${MODULE_PREFIX}_SSE2_SRCS rfx_sse2.c rfx_sse2.h nsc_sse2.c nsc_sse2.h) -set(FREERDP_CODEC_NEON_SRCS +set(${MODULE_PREFIX}_NEON_SRCS rfx_neon.c rfx_neon.h) if(WITH_SSE2) - set(FREERDP_CODEC_SRCS ${FREERDP_CODEC_SRCS} ${FREERDP_CODEC_SSE2_SRCS}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SSE2_SRCS}) if(CMAKE_COMPILER_IS_GNUCC) set_property(SOURCE rfx_sse2.c nsc_sse2.c PROPERTY COMPILE_FLAGS "-msse2") @@ -69,7 +70,7 @@ if(WITH_SSE2) endif() if(WITH_NEON) - set(FREERDP_CODEC_SRCS ${FREERDP_CODEC_SRCS} ${FREERDP_CODEC_NEON_SRCS}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_NEON_SRCS}) set_property(SOURCE rfx_neon.c PROPERTY COMPILE_FLAGS "-mfpu=neon -mfloat-abi=softfp") endif() @@ -78,22 +79,24 @@ if(WITH_JPEG) endif() if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-codec OBJECT ${FREERDP_CODEC_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-codec ${FREERDP_CODEC_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-codec PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") -set(FREERDP_CODEC_LIBS +set(${MODULE_PREFIX}_LIBS ${FREERDP_JPEG_LIBS}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CODEC_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_CODEC_LIBS ${FREERDP_CODEC_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) - target_link_libraries(freerdp-codec ${FREERDP_CODEC_LIBS}) - install(TARGETS freerdp-codec DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 9f4a09423..14467460a 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -1,8 +1,6 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-core cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador # Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,12 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "freerdp-core") +set(MODULE_PREFIX "FREERDP_CORE") + add_definitions(-DEXT_PATH="${FREERDP_EXTENSION_PATH}") include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set(FREERDP_CORE_SRCS +set(${MODULE_PREFIX}_SRCS activation.c activation.h extension.c @@ -92,42 +93,44 @@ set(FREERDP_CORE_SRCS peer.h) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-core OBJECT ${FREERDP_CORE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-core ${FREERDP_CORE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-core PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CORE_LIBS winpr) + set(${MODULE_PREFIX}_LIBS winpr) else() - set(FREERDP_CORE_LIBS + set(${MODULE_PREFIX}_LIBS winpr-utils winpr-sspi) if(NOT WIN32) - set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} winpr-registry) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-registry) endif() endif() if(WIN32) - set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() -set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} ${OPENSSL_LIBRARIES}) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSSL_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CORE_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_CORE_LIBS ${FREERDP_CORE_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils freerdp-codec freerdp-crypto freerdp-locale) - target_link_libraries(freerdp-core ${FREERDP_CORE_LIBS}) - install(TARGETS freerdp-core DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/crypto/CMakeLists.txt b/libfreerdp/crypto/CMakeLists.txt index 554f7336e..33f984a63 100644 --- a/libfreerdp/crypto/CMakeLists.txt +++ b/libfreerdp/crypto/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-crypto cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CRYPTO_SRCS +set(MODULE_NAME "freerdp-crypto") +set(MODULE_PREFIX "FREERDP_CRYPTO") + +set(${MODULE_PREFIX}_SRCS er.c der.c ber.c @@ -28,39 +29,42 @@ set(FREERDP_CRYPTO_SRCS tls.c) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-crypto OBJECT ${FREERDP_CRYPTO_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-crypto ${FREERDP_CRYPTO_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(freerdp-crypto PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") -set(FREERDP_CRYPTO_LIBS +set(${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) else() - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr-sspi) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-sspi) if(NOT WIN32) - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} winpr-library) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-library) endif() endif() if(WIN32) - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_CRYPTO_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_CRYPTO_LIBS ${FREERDP_CRYPTO_LIBS} freerdp-utils) - target_link_libraries(freerdp-crypto ${FREERDP_CRYPTO_LIBS}) - install(TARGETS freerdp-crypto DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) + + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/gdi/CMakeLists.txt b/libfreerdp/gdi/CMakeLists.txt index 2513b0673..106fc0f16 100644 --- a/libfreerdp/gdi/CMakeLists.txt +++ b/libfreerdp/gdi/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-gdi cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,9 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "freerdp-gdi") +set(MODULE_PREFIX "FREERDP_GDI") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -set(FREERDP_GDI_SRCS +set(${MODULE_PREFIX}_SRCS 8bpp.c 16bpp.c 32bpp.c @@ -39,24 +40,23 @@ set(FREERDP_GDI_SRCS gdi.h) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-gdi OBJECT ${FREERDP_GDI_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-gdi ${FREERDP_GDI_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-gdi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") - -set(FREERDP_GDI_LIBS) +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_GDI_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_GDI_LIBS ${FREERDP_GDI_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-cache freerdp-codec) - target_link_libraries(freerdp-gdi ${FREERDP_GDI_LIBS}) - install(TARGETS freerdp-gdi DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/locale/CMakeLists.txt b/libfreerdp/locale/CMakeLists.txt index 8e9c27035..52e03500e 100644 --- a/libfreerdp/locale/CMakeLists.txt +++ b/libfreerdp/locale/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-locale cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_LOCALE_SRCS +set(MODULE_NAME "freerdp-locale") +set(MODULE_PREFIX "FREERDP_LOCALE") + +set(${MODULE_PREFIX}_SRCS virtual_key_codes.c keyboard_layout.c keyboard.c @@ -25,21 +26,21 @@ set(FREERDP_LOCALE_SRCS timezone.c liblocale.h) -set(FREERDP_LOCALE_X11_SRCS +set(${MODULE_PREFIX}_X11_SRCS xkb_layout_ids.c xkb_layout_ids.h) -set(FREERDP_LOCALE_X11_KEYMAP_SRCS +set(${MODULE_PREFIX}_X11_KEYMAP_SRCS keyboard_keymap.c keyboard_keymap.h keyboard_x11.c keyboard_x11.h) -set(FREERDP_LOCALE_XKBFILE_SRCS +set(${MODULE_PREFIX}_XKBFILE_SRCS keyboard_xkbfile.c keyboard_xkbfile.h) -set(FREERDP_LOCALE_SUN_SRCS +set(${MODULE_PREFIX}_SUN_SRCS keyboard_sun.c keyboard_sun.h) @@ -47,44 +48,45 @@ if(CMAKE_SYSTEM_NAME MATCHES Solaris) set(WITH_SUN true) endif() -set(FREERDP_LOCALE_LIBS) - if(NOT WIN32) find_suggested_package(X11) if(WITH_X11) add_definitions(-DWITH_X11) include_directories(${X11_INCLUDE_DIRS}) - set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_X11_SRCS}) - set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} ${X11_LIBRARIES}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_SRCS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${X11_LIBRARIES}) if(WITH_SUN) add_definitions(-DWITH_SUN) - set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_SUN_SRCS}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_SUN_SRCS}) elseif(NOT APPLE) find_suggested_package(XKBFile) endif() if(WITH_XKBFILE) add_definitions(-DWITH_XKBFILE) include_directories(${XKBFILE_INCLUDE_DIRS}) - set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_XKBFILE_SRCS}) - set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} ${XKBFILE_LIBRARIES}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_XKBFILE_SRCS}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XKBFILE_LIBRARIES}) else() - set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_X11_KEYMAP_SRCS}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_X11_KEYMAP_SRCS}) endif() endif() endif() if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-locale OBJECT ${FREERDP_LOCALE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-locale ${FREERDP_LOCALE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-locale PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_LOCALE_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_LOCALE_LIBS ${FREERDP_LOCALE_LIBS} freerdp-utils) - target_link_libraries(freerdp-locale ${FREERDP_LOCALE_LIBS}) - install(TARGETS freerdp-locale DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) + + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/rail/CMakeLists.txt b/libfreerdp/rail/CMakeLists.txt index 728441ae3..8f256ed37 100644 --- a/libfreerdp/rail/CMakeLists.txt +++ b/libfreerdp/rail/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-rail cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_RAIL_SRCS +set(MODULE_NAME "freerdp-rail") +set(MODULE_PREFIX "FREERDP_RAIL") + +set(${MODULE_PREFIX}_SRCS window_list.c window.c icon.c @@ -25,19 +26,20 @@ set(FREERDP_RAIL_SRCS librail.h) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-rail OBJECT ${FREERDP_RAIL_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-rail ${FREERDP_RAIL_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-rail PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") - -set(FREERDP_RAIL_LIBS) +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_RAIL_LIBS} PARENT_SCOPE) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - set(FREERDP_RAIL_LIBS ${FREERDP_RAIL_LIBS} freerdp-utils) - target_link_libraries(freerdp-rail ${FREERDP_RAIL_LIBS}) - install(TARGETS freerdp-rail DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(FREERDP_RAIL_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-utils) + + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/libfreerdp/utils/CMakeLists.txt b/libfreerdp/utils/CMakeLists.txt index 0d3c83b5c..41b2c639e 100644 --- a/libfreerdp/utils/CMakeLists.txt +++ b/libfreerdp/utils/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # libfreerdp-utils cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,10 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "freerdp-utils") +set(MODULE_PREFIX "FREERDP_UTILS") + set(CMAKE_THREAD_PREFER_PTHREAD) find_required_package(Threads) -set(FREERDP_UTILS_SRCS +set(${MODULE_PREFIX}_SRCS args.c dsp.c event.c @@ -48,33 +49,37 @@ set(FREERDP_UTILS_SRCS wait_obj.c) if(WITH_MONOLITHIC_BUILD) - add_library(freerdp-utils OBJECT ${FREERDP_UTILS_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(freerdp-utils ${FREERDP_UTILS_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(freerdp-utils PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") -set(FREERDP_UTILS_LIBS +set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) if(WIN32) - set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) endif() if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) - set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} rt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt) endif() if(WITH_MONOLITHIC_BUILD) - set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr) - set(FREERDP_LIBS ${FREERDP_LIBS} ${FREERDP_UTILS_LIBS} PARENT_SCOPE) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) + set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-crt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) endif() - set(FREERDP_UTILS_LIBS ${FREERDP_UTILS_LIBS} winpr-synch) - target_link_libraries(freerdp-utils ${FREERDP_UTILS_LIBS}) - install(TARGETS freerdp-utils DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-synch) + + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP") diff --git a/winpr/libwinpr/asn1/CMakeLists.txt b/winpr/libwinpr/asn1/CMakeLists.txt index 7a528f689..5cbef153a 100644 --- a/winpr/libwinpr/asn1/CMakeLists.txt +++ b/winpr/libwinpr/asn1/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_ASN1_SRCS +set(MODULE_NAME "winpr-asn1") +set(MODULE_PREFIX "WINPR_ASN1") + +set(${MODULE_PREFIX}_SRCS asn1.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-asn1 OBJECT ${WINPR_ASN1_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-asn1 ${WINPR_ASN1_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-asn1 PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-asn1 DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/bcrypt/CMakeLists.txt b/winpr/libwinpr/bcrypt/CMakeLists.txt index 9aa7646e3..fc58b0b78 100644 --- a/winpr/libwinpr/bcrypt/CMakeLists.txt +++ b/winpr/libwinpr/bcrypt/CMakeLists.txt @@ -15,32 +15,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_BCRYPT_SRCS +set(MODULE_NAME "winpr-bcrypt") +set(MODULE_PREFIX "WINPR_BCRYPT") + +set(${MODULE_PREFIX}_SRCS bcrypt.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-bcrypt OBJECT ${WINPR_BCRYPT_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-bcrypt ${WINPR_BCRYPT_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(winpr-bcrypt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_BCRYPT_LIBS +set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_BCRYPT_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(WINPR_BCRYPT_LIBS ${WINPR_BCRYPT_LIBS} winpr-crt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) endif() - set(WINPR_BCRYPT_LIBS ${WINPR_BCRYPT_LIBS} winpr-utils) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-utils) - target_link_libraries(winpr-bcrypt ${WINPR_BCRYPT_LIBS}) - install(TARGETS winpr-bcrypt DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/crt/CMakeLists.txt b/winpr/libwinpr/crt/CMakeLists.txt index c494a874b..926fb5f4f 100644 --- a/winpr/libwinpr/crt/CMakeLists.txt +++ b/winpr/libwinpr/crt/CMakeLists.txt @@ -15,21 +15,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_CRT_SRCS +set(MODULE_NAME "winpr-crt") +set(MODULE_PREFIX "WINPR_CRT") + +set(${MODULE_PREFIX}_SRCS alignment.c memory.c string.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-crt OBJECT ${WINPR_CRT_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-crt ${WINPR_CRT_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-crt PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-crt DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/dsparse/CMakeLists.txt b/winpr/libwinpr/dsparse/CMakeLists.txt index aa459f240..eb59108cb 100644 --- a/winpr/libwinpr/dsparse/CMakeLists.txt +++ b/winpr/libwinpr/dsparse/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_DSPARSE_SRCS +set(MODULE_NAME "winpr-dsparse") +set(MODULE_PREFIX "WINPR_DSPARSE") + +set(${MODULE_PREFIX}_SRCS dsparse.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-dsparse OBJECT ${WINPR_DSPARSE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-dsparse ${WINPR_DSPARSE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-dsparse PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-dsparse DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/environment/CMakeLists.txt b/winpr/libwinpr/environment/CMakeLists.txt index 80c150445..207632a69 100644 --- a/winpr/libwinpr/environment/CMakeLists.txt +++ b/winpr/libwinpr/environment/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/error/CMakeLists.txt b/winpr/libwinpr/error/CMakeLists.txt index 08740f0a0..65790882b 100644 --- a/winpr/libwinpr/error/CMakeLists.txt +++ b/winpr/libwinpr/error/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/file/CMakeLists.txt b/winpr/libwinpr/file/CMakeLists.txt index d75aed803..82baa624a 100644 --- a/winpr/libwinpr/file/CMakeLists.txt +++ b/winpr/libwinpr/file/CMakeLists.txt @@ -40,3 +40,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/handle/CMakeLists.txt b/winpr/libwinpr/handle/CMakeLists.txt index 34f9fe703..69acd270f 100644 --- a/winpr/libwinpr/handle/CMakeLists.txt +++ b/winpr/libwinpr/handle/CMakeLists.txt @@ -15,20 +15,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_HANDLE_SRCS +set(MODULE_NAME "winpr-handle") +set(MODULE_PREFIX "WINPR_HANDLE") + +set(${MODULE_PREFIX}_SRCS handle.c table.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-handle OBJECT ${WINPR_HANDLE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-handle ${WINPR_HANDLE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-handle PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-handle DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/heap/CMakeLists.txt b/winpr/libwinpr/heap/CMakeLists.txt index 25ff8f483..a1790a12e 100644 --- a/winpr/libwinpr/heap/CMakeLists.txt +++ b/winpr/libwinpr/heap/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_HEAP_SRCS +set(MODULE_NAME "winpr-heap") +set(MODULE_PREFIX "WINPR_HEAP") + +set(${MODULE_PREFIX}_SRCS heap.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-heap OBJECT ${WINPR_HEAP_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-heap ${WINPR_HEAP_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-heap PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-heap DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/interlocked/CMakeLists.txt b/winpr/libwinpr/interlocked/CMakeLists.txt index 5128cd122..c6edc4cee 100644 --- a/winpr/libwinpr/interlocked/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/CMakeLists.txt @@ -15,20 +15,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_INTERLOCKED_SRCS +set(MODULE_NAME "winpr-interlocked") +set(MODULE_PREFIX "WINPR_INTERLOCKED") + +set(${MODULE_PREFIX}_SRCS interlocked.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-interlocked OBJECT ${WINPR_INTERLOCKED_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-interlocked ${WINPR_INTERLOCKED_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-interlocked PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-interlocked DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/winpr/libwinpr/interlocked/test/.gitignore b/winpr/libwinpr/interlocked/test/.gitignore new file mode 100644 index 000000000..1d4702c9b --- /dev/null +++ b/winpr/libwinpr/interlocked/test/.gitignore @@ -0,0 +1,3 @@ +TestInterlocked +TestInterlocked.c + diff --git a/winpr/libwinpr/interlocked/test/CMakeLists.txt b/winpr/libwinpr/interlocked/test/CMakeLists.txt new file mode 100644 index 000000000..4ad5918b4 --- /dev/null +++ b/winpr/libwinpr/interlocked/test/CMakeLists.txt @@ -0,0 +1,25 @@ + +set(MODULE_NAME "TestInterlocked") +set(MODULE_PREFIX "TEST_INTERLOCKED") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestInterlockedSList.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +if(NOT WIN32) + target_link_libraries(${MODULE_NAME} winpr-interlocked) +endif() + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) +endforeach() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR\\Test") diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c new file mode 100644 index 000000000..04a4a9c63 --- /dev/null +++ b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c @@ -0,0 +1,84 @@ + +#include +#include +#include +#include +#include + +typedef struct _PROGRAM_ITEM +{ + SLIST_ENTRY ItemEntry; + ULONG Signature; +} PROGRAM_ITEM, *PPROGRAM_ITEM; + +int TestInterlockedSList(int argc, char* argv[]) +{ + ULONG Count; + PSLIST_ENTRY pFirstEntry; + PSLIST_ENTRY pListEntry; + PSLIST_HEADER pListHead; + PPROGRAM_ITEM pProgramItem; + + /* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */ + pListHead = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); + + if( NULL == pListHead ) + { + printf("Memory allocation failed.\n"); + return -1; + } + InitializeSListHead(pListHead); + + /* Insert 10 items into the list. */ + for (Count = 1; Count <= 10; Count += 1) + { + pProgramItem = (PPROGRAM_ITEM) _aligned_malloc(sizeof(PROGRAM_ITEM), MEMORY_ALLOCATION_ALIGNMENT); + + if (!pProgramItem) + { + printf("Memory allocation failed.\n"); + return -1; + } + + pProgramItem->Signature = Count; + pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry)); + } + + /* Remove 10 items from the list and display the signature. */ + for (Count = 10; Count >= 1; Count -= 1) + { + pListEntry = InterlockedPopEntrySList(pListHead); + + if (!pListEntry) + { + printf("List is empty.\n"); + return -1; + } + + pProgramItem = (PPROGRAM_ITEM) pListEntry; + printf("Signature is %d\n", pProgramItem->Signature); + + /* + * This example assumes that the SLIST_ENTRY structure is the + * first member of the structure. If your structure does not + * follow this convention, you must compute the starting address + * of the structure before calling the free function. + */ + + _aligned_free(pListEntry); + } + + /* Flush the list and verify that the items are gone. */ + pListEntry = InterlockedFlushSList(pListHead); + pFirstEntry = InterlockedPopEntrySList(pListHead); + + if (pFirstEntry) + { + printf("Error: List is not empty.\n"); + return -1; + } + + _aligned_free(pListHead); + + return 0; +} diff --git a/winpr/libwinpr/io/CMakeLists.txt b/winpr/libwinpr/io/CMakeLists.txt index 63e9a8428..d2632ae74 100644 --- a/winpr/libwinpr/io/CMakeLists.txt +++ b/winpr/libwinpr/io/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/library/CMakeLists.txt b/winpr/libwinpr/library/CMakeLists.txt index b47022219..e8004c957 100644 --- a/winpr/libwinpr/library/CMakeLists.txt +++ b/winpr/libwinpr/library/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_LIBRARY_SRCS +set(MODULE_NAME "winpr-library") +set(MODULE_PREFIX "WINPR_LIBRARY") + +set(${MODULE_PREFIX}_SRCS library.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-library OBJECT ${WINPR_LIBRARY_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-library ${WINPR_LIBRARY_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-library PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-library DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 559edc930..1caa7346b 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -35,3 +35,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/registry/CMakeLists.txt b/winpr/libwinpr/registry/CMakeLists.txt index 53910a99c..b76c1014f 100644 --- a/winpr/libwinpr/registry/CMakeLists.txt +++ b/winpr/libwinpr/registry/CMakeLists.txt @@ -15,22 +15,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_REGISTRY_SRCS +set(MODULE_NAME "winpr-registry") +set(MODULE_PREFIX "WINPR_REGISTRY") + +set(${MODULE_PREFIX}_SRCS registry_reg.c registry_reg.h registry.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-registry OBJECT ${WINPR_REGISTRY_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-registry ${WINPR_REGISTRY_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-registry PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - target_link_libraries(winpr-registry winpr-utils) - install(TARGETS winpr-registry DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} winpr-utils) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/rpc/CMakeLists.txt b/winpr/libwinpr/rpc/CMakeLists.txt index a825b3270..ec3c3bb39 100644 --- a/winpr/libwinpr/rpc/CMakeLists.txt +++ b/winpr/libwinpr/rpc/CMakeLists.txt @@ -15,43 +15,57 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_RPC_SRCS +set(MODULE_NAME "winpr-rpc") +set(MODULE_PREFIX "WINPR_RPC") + +set(${MODULE_PREFIX}_SRCS rpc.c ndr.c - ndr_array.c ndr_array.h - ndr_context.c ndr_context.h - ndr_correlation.c ndr_correlation.h - ndr_pointer.c ndr_pointer.h - ndr_private.c ndr_private.h - ndr_simple.c ndr_simple.h - ndr_string.c ndr_string.h - ndr_structure.c ndr_structure.h - ndr_union.c ndr_union.h + ndr_array.c + ndr_array.h + ndr_context.c + ndr_context.h + ndr_correlation.c + ndr_correlation.h + ndr_pointer.c + ndr_pointer.h + ndr_private.c + ndr_private.h + ndr_simple.c + ndr_simple.h + ndr_string.c + ndr_string.h + ndr_structure.c + ndr_structure.h + ndr_union.c + ndr_union.h midl.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-rpc OBJECT ${WINPR_RPC_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-rpc ${WINPR_RPC_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() include_directories(${OPENSSL_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIRS}) -set_target_properties(winpr-rpc PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_RPC_LIBS +set(${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES}) if(WIN32) - set(WINPR_RPC_LIBS ${WINPR_RPC_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(WINPR_RPC_LIBS ${WINPR_RPC_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_RPC_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-rpc ${WINPR_RPC_LIBS}) - install(TARGETS winpr-rpc DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/sspi/CMakeLists.txt b/winpr/libwinpr/sspi/CMakeLists.txt index 7f725e4a9..197aa4639 100644 --- a/winpr/libwinpr/sspi/CMakeLists.txt +++ b/winpr/libwinpr/sspi/CMakeLists.txt @@ -15,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SSPI_NTLM_SRCS +set(MODULE_NAME "winpr-sspi") +set(MODULE_PREFIX "WINPR_SSPI") + +set(${MODULE_PREFIX}_NTLM_SRCS NTLM/ntlm_av_pairs.c NTLM/ntlm_av_pairs.h NTLM/ntlm_compute.c @@ -25,73 +28,74 @@ set(WINPR_SSPI_NTLM_SRCS NTLM/ntlm.c NTLM/ntlm.h) -set(WINPR_SSPI_NEGOTIATE_SRCS +set(${MODULE_PREFIX}_NEGOTIATE_SRCS Negotiate/negotiate.c Negotiate/negotiate.h) -set(WINPR_SSPI_SCHANNEL_SRCS +set(${MODULE_PREFIX}_SCHANNEL_SRCS Schannel/schannel.c Schannel/schannel.h) -set(WINPR_SSPI_CREDSSP_SRCS +set(${MODULE_PREFIX}_CREDSSP_SRCS CredSSP/credssp.c) -set(WINPR_SSPI_SRCS - ${WINPR_SSPI_CREDSSP_SRCS} +set(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_CREDSSP_SRCS} sspi.c sspi.h) if(NOT WITH_NATIVE_SSPI) - set(WINPR_SSPI_SRCS - ${WINPR_SSPI_NTLM_SRCS} - ${WINPR_SSPI_KERBEROS_SRCS} - ${WINPR_SSPI_NEGOTIATE_SRCS} - ${WINPR_SSPI_SCHANNEL_SRCS} - ${WINPR_SSPI_SRCS}) + set(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_NTLM_SRCS} + ${${MODULE_PREFIX}_KERBEROS_SRCS} + ${${MODULE_PREFIX}_NEGOTIATE_SRCS} + ${${MODULE_PREFIX}_SCHANNEL_SRCS} + ${${MODULE_PREFIX}_SRCS}) endif() if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sspi OBJECT ${WINPR_SSPI_SRCS}) + add_library(${MODULE_NAME} OBJECT ${WINPR_SSPI_SRCS}) else() - add_library(winpr-sspi ${WINPR_SSPI_SRCS}) + add_library(${MODULE_NAME} ${WINPR_SSPI_SRCS}) endif() include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) -set_target_properties(winpr-sspi PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_SSPI_LIBS +set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) if(WIN32) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) else() - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} ${ZLIB_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${ZLIB_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} winpr) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr) else() if (NOT WIN32) - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt winpr-sysinfo winpr-registry) endif() - set(WINPR_SSPI_LIBS ${WINPR_SSPI_LIBS} winpr-utils) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-utils) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SSPI_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-sspi ${WINPR_SSPI_LIBS}) - install(TARGETS winpr-sspi DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + if(BUILD_TESTING) add_subdirectory(test) endif() - diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt index 2b70c2648..2567dc784 100644 --- a/winpr/libwinpr/sspi/test/CMakeLists.txt +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -16,6 +16,10 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +if(WIN32) + target_link_libraries(${MODULE_NAME} secur32) +endif() + target_link_libraries(${MODULE_NAME} winpr-sspi) foreach(test ${${MODULE_PREFIX}_TESTS}) @@ -23,3 +27,4 @@ foreach(test ${${MODULE_PREFIX}_TESTS}) add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) endforeach() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR\\Test") diff --git a/winpr/libwinpr/sspicli/CMakeLists.txt b/winpr/libwinpr/sspicli/CMakeLists.txt index 106d01158..9374da3fb 100644 --- a/winpr/libwinpr/sspicli/CMakeLists.txt +++ b/winpr/libwinpr/sspicli/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SSPICLI_SRCS +set(MODULE_NAME "winpr-sspicli") +set(MODULE_PREFIX "WINPR_SSPICLI") + +set(${MODULE_PREFIX}_SRCS sspicli.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sspicli OBJECT ${WINPR_SSPICLI_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-sspicli ${WINPR_SSPICLI_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-sspicli PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-sspicli DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/synch/CMakeLists.txt b/winpr/libwinpr/synch/CMakeLists.txt index 6361fe435..5db40b18e 100644 --- a/winpr/libwinpr/synch/CMakeLists.txt +++ b/winpr/libwinpr/synch/CMakeLists.txt @@ -43,7 +43,7 @@ else() add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-synch PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} @@ -64,3 +64,4 @@ else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/sysinfo/CMakeLists.txt b/winpr/libwinpr/sysinfo/CMakeLists.txt index e5e41d8cd..f05d6c553 100644 --- a/winpr/libwinpr/sysinfo/CMakeLists.txt +++ b/winpr/libwinpr/sysinfo/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_SYSINFO_SRCS +set(MODULE_NAME "winpr-sysinfo") +set(MODULE_PREFIX "WINPR_SYSINFO") + +set(${MODULE_PREFIX}_SRCS sysinfo.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-sysinfo OBJECT ${WINPR_SYSINFO_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-sysinfo ${WINPR_SYSINFO_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-sysinfo PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-sysinfo DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/thread/CMakeLists.txt b/winpr/libwinpr/thread/CMakeLists.txt index 343c3b16c..d53f523ea 100644 --- a/winpr/libwinpr/thread/CMakeLists.txt +++ b/winpr/libwinpr/thread/CMakeLists.txt @@ -15,39 +15,43 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "winpr-thread") +set(MODULE_PREFIX "WINPR_THREAD") + set(CMAKE_THREAD_PREFER_PTHREAD) find_required_package(Threads) -set(WINPR_THREAD_SRCS +set(${MODULE_PREFIX}_SRCS process.c processor.c thread.c tls.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-thread OBJECT ${WINPR_THREAD_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-thread ${WINPR_THREAD_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-thread PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_SYNCH_LIBS +set(${MODULE_PREFIX}_LIBS ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) if(${CMAKE_SYSTEM_NAME} MATCHES SunOS) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} rt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_SYNCH_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if(NOT WIN32) - set(WINPR_SYNCH_LIBS ${WINPR_SYNCH_LIBS} winpr-handle) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-handle) endif() - target_link_libraries(winpr-thread ${WINPR_SYNCH_LIBS}) - install(TARGETS winpr-thread DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/timezone/CMakeLists.txt b/winpr/libwinpr/timezone/CMakeLists.txt index e780f26aa..afbbd50d7 100644 --- a/winpr/libwinpr/timezone/CMakeLists.txt +++ b/winpr/libwinpr/timezone/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_TIMEZONE_SRCS +set(MODULE_NAME "winpr-timezone") +set(MODULE_PREFIX "WINPR_TIMEZONE") + +set(${MODULE_PREFIX}_SRCS timezone.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-timezone OBJECT ${WINPR_TIMEZONE_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-timezone ${WINPR_TIMEZONE_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-timezone PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-timezone DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/utils/CMakeLists.txt b/winpr/libwinpr/utils/CMakeLists.txt index 9edc35dc3..eb327c5e5 100644 --- a/winpr/libwinpr/utils/CMakeLists.txt +++ b/winpr/libwinpr/utils/CMakeLists.txt @@ -15,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_UTILS_SRCS +set(MODULE_NAME "winpr-utils") +set(MODULE_PREFIX "WINPR_UTILS") + +set(${MODULE_PREFIX}_SRCS ntlm.c print.c sam.c @@ -25,24 +28,26 @@ include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${OPENSSL_INCLUDE_DIR}) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-utils OBJECT ${WINPR_UTILS_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-utils ${WINPR_UTILS_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-utils PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") -set(WINPR_UTILS_LIBS +set(${MODULE_PREFIX}_LIBS ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_UTILS_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() if (NOT WIN32) - set(WINPR_UTILS_LIBS ${WINPR_UTILS_LIBS} winpr-crt) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-crt) endif() - target_link_libraries(winpr-utils ${WINPR_UTILS_LIBS}) - install(TARGETS winpr-utils DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/winhttp/CMakeLists.txt b/winpr/libwinpr/winhttp/CMakeLists.txt index 1fa4dd60c..ccdf271f5 100644 --- a/winpr/libwinpr/winhttp/CMakeLists.txt +++ b/winpr/libwinpr/winhttp/CMakeLists.txt @@ -15,19 +15,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_WINHTTP_SRCS +set(MODULE_NAME "winpr-winhttp") +set(MODULE_PREFIX "WINPR_WINHTTP") + +set(${MODULE_PREFIX}_SRCS winhttp.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-winhttp OBJECT ${WINPR_WINHTTP_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-winhttp ${WINPR_WINHTTP_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-winhttp PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WITH_MONOLITHIC_BUILD) else() - install(TARGETS winpr-winhttp DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") diff --git a/winpr/libwinpr/winsock/CMakeLists.txt b/winpr/libwinpr/winsock/CMakeLists.txt index a120c77b7..abdab2387 100644 --- a/winpr/libwinpr/winsock/CMakeLists.txt +++ b/winpr/libwinpr/winsock/CMakeLists.txt @@ -15,24 +15,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(WINPR_WINSOCK_SRCS +set(MODULE_NAME "winpr-winsock") +set(MODULE_PREFIX "WINPR_WINSOCK") + +set(${MODULE_PREFIX}_SRCS winsock.c) if(WITH_MONOLITHIC_BUILD) - add_library(winpr-winsock OBJECT ${WINPR_WINSOCK_SRCS}) + add_library(${MODULE_NAME} OBJECT ${${MODULE_PREFIX}_SRCS}) else() - add_library(winpr-winsock ${WINPR_WINSOCK_SRCS}) + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() -set_target_properties(winpr-winsock PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib") if(WIN32) - set(WINPR_WINSOCK_LIBS ${WINPR_WINSOCK_LIBS} ws2_32) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ws2_32) endif() if(WITH_MONOLITHIC_BUILD) - set(WINPR_LIBS ${WINPR_LIBS} ${WINPR_WINSOCK_LIBS} PARENT_SCOPE) + set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() - target_link_libraries(winpr-winsock ${WINPR_WINSOCK_LIBS}) - install(TARGETS winpr-winsock DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") From 659a90145043bbfe6bc99591b362857ff06692b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 11:48:53 -0400 Subject: [PATCH 39/64] cmake: add solution folder subdirectories --- channels/CMakeLists.txt | 1 - channels/server/CMakeLists.txt | 23 +++-- client/CMakeLists.txt | 8 +- client/DirectFB/CMakeLists.txt | 23 +++-- client/Mac/CMakeLists.txt | 2 + client/{test => Sample}/CMakeLists.txt | 23 +++-- client/{test => Sample}/freerdp.c | 0 client/Windows/CMakeLists.txt | 17 ++-- client/X11/CMakeLists.txt | 29 +++--- server/CMakeLists.txt | 6 +- server/{test => Sample}/CMakeLists.txt | 21 +++-- server/{test => Sample}/rfx_test.pcap | Bin server/{test => Sample}/server.crt | 0 server/{test => Sample}/server.key | 0 server/{test => Sample}/test_icon.ppm | 0 server/{test => Sample}/tfreerdp.c | 0 server/Windows/CMakeLists.txt | 27 +++--- server/Windows/cli/CMakeLists.txt | 17 ++-- server/X11/CMakeLists.txt | 32 ++++--- .../libwinpr/interlocked/test/CMakeLists.txt | 2 +- winpr/libwinpr/sspi/test/CMakeLists.txt | 2 +- winpr/tools/CMakeLists.txt | 5 +- winpr/tools/hash/CMakeLists.txt | 12 ++- winpr/tools/reg/CMakeLists.txt | 29 ------ winpr/tools/reg/reg.c | 86 ------------------ 25 files changed, 143 insertions(+), 222 deletions(-) rename client/{test => Sample}/CMakeLists.txt (55%) rename client/{test => Sample}/freerdp.c (100%) rename server/{test => Sample}/CMakeLists.txt (63%) rename server/{test => Sample}/rfx_test.pcap (100%) rename server/{test => Sample}/server.crt (100%) rename server/{test => Sample}/server.key (100%) rename server/{test => Sample}/test_icon.ppm (100%) rename server/{test => Sample}/tfreerdp.c (100%) delete mode 100644 winpr/tools/reg/CMakeLists.txt delete mode 100644 winpr/tools/reg/reg.c diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 9c456090e..09cba743f 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -33,4 +33,3 @@ endforeach(FILEPATH) if(WITH_SERVER_CHANNELS) add_subdirectory(server) endif() - diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index d36053b2a..b8de4ee2d 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -15,20 +15,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -foreach(MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES}) - string(TOUPPER "CHANNEL_${MODULE_NAME}" MODULE_PREFIX) - message(STATUS "Adding built-in channel server module: ${MODULE_NAME}") +set(MODULE_NAME "freerdp-server-channels") +set(MODULE_PREFIX "FREERDP_SERVER_CHANNELS") - foreach(SRC ${${MODULE_PREFIX}_SERVER_SRCS}) - set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${MODULE_NAME}/server/${SRC}") +foreach(_MODULE_NAME ${CHANNEL_BUILTIN_SERVER_MODULES}) + string(TOUPPER "CHANNEL_${_MODULE_NAME}" _MODULE_PREFIX) + message(STATUS "Adding built-in channel server module: ${_MODULE_NAME}") + + foreach(SRC ${${_MODULE_PREFIX}_SERVER_SRCS}) + set(CHANNEL_SERVER_SRCS ${CHANNEL_SERVER_SRCS} "../${_MODULE_NAME}/server/${SRC}") endforeach() - set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${MODULE_PREFIX}_SERVER_LIBS}) + set(CHANNEL_SERVER_LIBS ${CHANNEL_SERVER_LIBS} ${${_MODULE_PREFIX}_SERVER_LIBS}) endforeach() -add_library(freerdp-server ${CHANNEL_SERVER_SRCS}) +add_library(${MODULE_NAME} ${CHANNEL_SERVER_SRCS}) -set_target_properties(freerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") +set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") -target_link_libraries(freerdp-server ${CHANNEL_SERVER_LIBS}) -install(TARGETS freerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR}) +target_link_libraries(${MODULE_NAME} ${CHANNEL_SERVER_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index cb1d48e13..98afbbe4c 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP Client User Interfaces # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +18,8 @@ # User Interfaces if(NOT WIN32) - # Build Test Client - add_subdirectory(test) + # Build Sample Client + add_subdirectory(Sample) # Build X11 Client find_suggested_package(X11) diff --git a/client/DirectFB/CMakeLists.txt b/client/DirectFB/CMakeLists.txt index a9c076d2f..287176422 100644 --- a/client/DirectFB/CMakeLists.txt +++ b/client/DirectFB/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP DirectFB Client # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,9 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "dfreerdp") +set(MODULE_PREFIX "FREERDP_CLIENT_DIRECTFB") + include_directories(${DIRECTFB_INCLUDE_DIRS}) -set(FREERDP_CLIENT_DIRECTFB_SRCS +set(${MODULE_PREFIX}_SRCS df_event.c df_event.h df_graphics.c @@ -27,14 +28,14 @@ set(FREERDP_CLIENT_DIRECTFB_SRCS dfreerdp.c dfreerdp.h) -add_executable(dfreerdp ${FREERDP_CLIENT_DIRECTFB_SRCS}) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set(FREERDP_CLIENT_DIRECTFB_LIBS ${DIRECTFB_LIBRARIES}) +set(${MODULE_PREFIX}_LIBS ${DIRECTFB_LIBRARIES}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CLIENT_DIRECTFB_LIBS ${FREERDP_CLIENT_DIRECTFB_LIBS} freerdp) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() - set(FREERDP_CLIENT_DIRECTFB_LIBS ${FREERDP_CLIENT_DIRECTFB_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-gdi freerdp-locale @@ -42,5 +43,7 @@ else() freerdp-utils) endif() -target_link_libraries(dfreerdp ${FREERDP_CLIENT_DIRECTFB_LIBS}) -install(TARGETS dfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/DirectFB") diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index 98a9abaa9..c14c063d4 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -143,3 +143,5 @@ target_link_libraries(MacFreeRDP freerdp-codec freerdp-rail ) + +set_property(TARGET MacFreeRDP PROPERTY FOLDER "Client/Mac") diff --git a/client/test/CMakeLists.txt b/client/Sample/CMakeLists.txt similarity index 55% rename from client/test/CMakeLists.txt rename to client/Sample/CMakeLists.txt index 2ef51bef2..bebd12694 100644 --- a/client/test/CMakeLists.txt +++ b/client/Sample/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client -# FreeRDP Test UI cmake build script +# FreeRDP Sample UI cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,21 +15,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CLIENT_TEST_SRCS +set(MODULE_NAME "sfreerdp") +set(MODULE_PREFIX "FREERDP_CLIENT_SAMPLE") + +set(${MODULE_PREFIX}_SRCS freerdp.c) -add_executable(freerdp-test ${FREERDP_CLIENT_TEST_SRCS}) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS} ${CMAKE_DL_LIBS}) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CMAKE_DL_LIBS}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS} freerdp) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() - set(FREERDP_CLIENT_TEST_LIBS ${FREERDP_CLIENT_TEST_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-gdi freerdp-utils freerdp-channels) endif() -target_link_libraries(freerdp-test ${FREERDP_CLIENT_TEST_LIBS}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Sample") diff --git a/client/test/freerdp.c b/client/Sample/freerdp.c similarity index 100% rename from client/test/freerdp.c rename to client/Sample/freerdp.c diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 4b05882d5..74bf93589 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -15,7 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(FREERDP_CLIENT_WINDOWS_SRCS +set(MODULE_NAME "wfreerdp") +set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS") + +set(${MODULE_PREFIX}_SRCS wf_gdi.c wf_gdi.h wf_event.c @@ -31,12 +34,12 @@ set(FREERDP_CLIENT_WINDOWS_SRCS wfreerdp.c wfreerdp.h) -add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS}) +add_executable(${MODULE_NAME} WIN32 ${${MODULE_PREFIX}_SRCS}) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() - set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-gdi freerdp-codec @@ -44,5 +47,7 @@ else() freerdp-utils) endif() -target_link_libraries(wfreerdp ${FREERDP_CLIENT_WINDOWS_LIBS}) -install(TARGETS wfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows") diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 5ecd0fbaf..2bf4efc82 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP X11 Client # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,10 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "wfreerdp") +set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS") + include(FindXmlto) include_directories(${X11_INCLUDE_DIRS}) -set(FREERDP_CLIENT_X11_SRCS +set(${MODULE_PREFIX}_SRCS xf_gdi.c xf_gdi.h xf_rail.c @@ -42,9 +43,9 @@ set(FREERDP_CLIENT_X11_SRCS xfreerdp.c xfreerdp.h) -add_executable(xfreerdp ${FREERDP_CLIENT_X11_SRCS}) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set(FREERDP_CLIENT_X11_LIBS +set(${MODULE_PREFIX}_LIBS ${X11_LIBRARIES} ${CMAKE_DL_LIBS}) @@ -67,7 +68,7 @@ find_suggested_package(Xinerama) if(WITH_XINERAMA) add_definitions(-DWITH_XINERAMA -DWITH_XEXT) include_directories(${XINERAMA_INCLUDE_DIRS}) - set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XINERAMA_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XINERAMA_LIBRARIES}) endif() find_suggested_package(Xext) @@ -81,22 +82,22 @@ find_suggested_package(Xcursor) if(WITH_XCURSOR) add_definitions(-DWITH_XCURSOR) include_directories(${XCURSOR_INCLUDE_DIRS}) - set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XCURSOR_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XCURSOR_LIBRARIES}) endif() find_suggested_package(Xv) if(WITH_XV) add_definitions(-DWITH_XV) include_directories(${XV_INCLUDE_DIRS}) - set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} ${XV_LIBRARIES}) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XV_LIBRARIES}) endif() include_directories(${CMAKE_SOURCE_DIR}/resources) if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} freerdp) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() - set(FREERDP_CLIENT_X11_LIBS ${FREERDP_CLIENT_X11_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-gdi freerdp-locale @@ -105,5 +106,7 @@ else() freerdp-utils) endif() -target_link_libraries(xfreerdp ${FREERDP_CLIENT_X11_LIBS}) -install(TARGETS xfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/X11") diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 6ac9ede9d..e7b64a890 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP Servers # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +20,7 @@ if(NOT WIN32) # Build Test Server - add_subdirectory(test) + add_subdirectory(Sample) # Build X11 Server find_suggested_package(X11) diff --git a/server/test/CMakeLists.txt b/server/Sample/CMakeLists.txt similarity index 63% rename from server/test/CMakeLists.txt rename to server/Sample/CMakeLists.txt index fbf0d72ce..a7219c248 100644 --- a/server/test/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client -# FreeRDP Test Server cmake build script +# FreeRDP Sample Server cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,18 +15,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_executable(tfreerdp-server +set(MODULE_NAME "sfreerdp-server") +set(MODULE_PREFIX "FREERDP_SERVER_SAMPLE") + +set(${MODULE_PREFIX}_SRCS tfreerdp.c) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + if(WITH_MONOLITHIC_BUILD) - target_link_libraries(tfreerdp-server + target_link_libraries(${MODULE_NAME} freerdp - freerdp-server-channels) + freerdp-server) else() - target_link_libraries(tfreerdp-server + target_link_libraries(${MODULE_NAME} freerdp-core freerdp-utils freerdp-codec freerdp-channels freerdp-server-channels) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Sample") diff --git a/server/test/rfx_test.pcap b/server/Sample/rfx_test.pcap similarity index 100% rename from server/test/rfx_test.pcap rename to server/Sample/rfx_test.pcap diff --git a/server/test/server.crt b/server/Sample/server.crt similarity index 100% rename from server/test/server.crt rename to server/Sample/server.crt diff --git a/server/test/server.key b/server/Sample/server.key similarity index 100% rename from server/test/server.key rename to server/Sample/server.key diff --git a/server/test/test_icon.ppm b/server/Sample/test_icon.ppm similarity index 100% rename from server/test/test_icon.ppm rename to server/Sample/test_icon.ppm diff --git a/server/test/tfreerdp.c b/server/Sample/tfreerdp.c similarity index 100% rename from server/test/tfreerdp.c rename to server/Sample/tfreerdp.c diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 59570b44d..b0d680db4 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -15,9 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "wfreerdp-server") +set(MODULE_PREFIX "FREERDP_SERVER_WINDOWS") + include_directories(.) -set(WFREERDP_SERVER_SRCS +set(${MODULE_PREFIX}_SRCS wf_update.c wf_update.h wf_dxgi.c @@ -37,37 +40,39 @@ set(WFREERDP_SERVER_SRCS wf_info.h) if(WITH_SERVER_INTERFACE) - add_library(wfreerdp-server ${WFREERDP_SERVER_SRCS}) - set_target_properties(wfreerdp-server PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib") else() - set(WFREERDP_SERVER_SRCS ${WFREERDP_SERVER_SRCS} cli/wfreerdp.c cli/wfreerdp.h) - add_executable(wfreerdp-server ${WFREERDP_SERVER_SRCS}) + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/wfreerdp.c cli/wfreerdp.h) + add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) endif() if(WITH_WIN8) - set(WFREERDP_SERVER_LIBS d3d11 dxgi dxguid) + set(${MODULE_PREFIX}_LIBS d3d11 dxgi dxguid) endif() if(WITH_MONOLITHIC_BUILD) - set(WFREERDP_SERVER_LIBS ${WFREERDP_SERVER_LIBS} freerdp) + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp) else() - set(WFREERDP_SERVER_LIBS ${WFREERDP_SERVER_LIBS} + set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-core freerdp-utils freerdp-codec freerdp-channels) endif() -target_link_libraries(wfreerdp-server ${WFREERDP_SERVER_LIBS}) +target_link_libraries(wfreerdp-server ${${MODULE_PREFIX}_LIBS}) if(WITH_SERVER_INTERFACE) - install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() - install(TARGETS wfreerdp-server DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() if(WITH_SERVER_INTERFACE) add_subdirectory(cli) endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Windows") diff --git a/server/Windows/cli/CMakeLists.txt b/server/Windows/cli/CMakeLists.txt index bbd5f1a40..f7d2ade5a 100644 --- a/server/Windows/cli/CMakeLists.txt +++ b/server/Windows/cli/CMakeLists.txt @@ -15,20 +15,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "wfreerdp-server") +set(MODULE_PREFIX "FREERDP_SERVER_WINDOWS_CLI") + include_directories(..) -set(WFREERDP_SERVER_CLI_SRCS +set(${MODULE_PREFIX}_SRCS wfreerdp.c wfreerdp.h) -add_executable(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_SRCS}) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_target_properties(wfreerdp-server-cli PROPERTIES OUTPUT_NAME "wfreerdp-server") +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "wfreerdp-server") -set(WFREERDP_SERVER_CLI_LIBS wfreerdp-server) +set(${MODULE_PREFIX}_LIBS wfreerdp-server) -target_link_libraries(wfreerdp-server-cli ${WFREERDP_SERVER_CLI_LIBS}) +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) +install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(TARGETS wfreerdp-server-cli DESTINATION ${CMAKE_INSTALL_BINDIR}) - +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Windows") diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index be56d64bc..a2fe3f03e 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -1,9 +1,7 @@ # FreeRDP: A Remote Desktop Protocol Client # FreeRDP X11 Server cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,15 +15,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(MODULE_NAME "xfreerdp-server") +set(MODULE_PREFIX "FREERDP_SERVER_X11") + include_directories(${X11_INCLUDE_DIRS}) -add_executable(xfreerdp-server +set(${MODULE_PREFIX}_SRCS xf_peer.c xf_event.c xf_input.c xf_encode.c xfreerdp.c) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + find_suggested_package(XShm) if(WITH_XSHM) add_definitions(-DWITH_XSHM) @@ -36,42 +39,45 @@ find_suggested_package(Xext) if(WITH_XEXT) add_definitions(-DWITH_XEXT) include_directories(${XEXT_INCLUDE_DIRS}) - target_link_libraries(xfreerdp-server ${XEXT_LIBRARIES}) + target_link_libraries(${MODULE_NAME} ${XEXT_LIBRARIES}) endif() find_suggested_package(Xdamage) if(WITH_XDAMAGE) add_definitions(-DWITH_XDAMAGE) include_directories(${XDAMAGE_INCLUDE_DIRS}) - target_link_libraries(xfreerdp-server ${XDAMAGE_LIBRARIES}) + target_link_libraries(${MODULE_NAME} ${XDAMAGE_LIBRARIES}) endif() find_suggested_package(Xfixes) if(WITH_XFIXES) add_definitions(-DWITH_XFIXES) include_directories(${XFIXES_INCLUDE_DIRS}) - target_link_libraries(xfreerdp-server ${XFIXES_LIBRARIES}) + target_link_libraries(${MODULE_NAME} ${XFIXES_LIBRARIES}) endif() find_suggested_package(XTest) if(WITH_XTEST) add_definitions(-DWITH_XTEST) include_directories(${XTEST_INCLUDE_DIRS}) - target_link_libraries(xfreerdp-server ${XTEST_LIBRARIES}) + target_link_libraries(${MODULE_NAME} ${XTEST_LIBRARIES}) endif() if(WITH_MONOLITHIC_BUILD) - target_link_libraries(xfreerdp-server freerdp) - target_link_libraries(xfreerdp-server winpr) + target_link_libraries(${MODULE_NAME} freerdp) + target_link_libraries(${MODULE_NAME} winpr) else() - target_link_libraries(xfreerdp-server + target_link_libraries(${MODULE_NAME} freerdp-core freerdp-codec freerdp-utils freerdp-gdi freerdp-crypto freerdp-locale) - target_link_libraries(xfreerdp-server winpr-sspi) + + target_link_libraries(${MODULE_NAME} winpr-sspi) endif() -target_link_libraries(xfreerdp-server ${X11_LIBRARIES}) +target_link_libraries(${MODULE_NAME} ${X11_LIBRARIES}) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11") diff --git a/winpr/libwinpr/interlocked/test/CMakeLists.txt b/winpr/libwinpr/interlocked/test/CMakeLists.txt index 4ad5918b4..b7232f115 100644 --- a/winpr/libwinpr/interlocked/test/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/test/CMakeLists.txt @@ -22,4 +22,4 @@ foreach(test ${${MODULE_PREFIX}_TESTS}) add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) endforeach() -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR\\Test") +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt index 2567dc784..0c774a0e5 100644 --- a/winpr/libwinpr/sspi/test/CMakeLists.txt +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -27,4 +27,4 @@ foreach(test ${${MODULE_PREFIX}_TESTS}) add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) endforeach() -set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR\\Test") +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") diff --git a/winpr/tools/CMakeLists.txt b/winpr/tools/CMakeLists.txt index d04fbc019..86376a2df 100644 --- a/winpr/tools/CMakeLists.txt +++ b/winpr/tools/CMakeLists.txt @@ -1,9 +1,7 @@ # WinPR: Windows Portable Runtime # winpr cmake build script # -# Copyright 2011 O.S. Systems Software Ltda. -# Copyright 2011 Otavio Salvador -# Copyright 2011 Marc-Andre Moreau +# Copyright 2012 Marc-Andre Moreau # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(reg) add_subdirectory(hash) diff --git a/winpr/tools/hash/CMakeLists.txt b/winpr/tools/hash/CMakeLists.txt index 0aff945d3..1e671ab0e 100644 --- a/winpr/tools/hash/CMakeLists.txt +++ b/winpr/tools/hash/CMakeLists.txt @@ -15,12 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_executable(winpr-hash +set(MODULE_NAME "winpr-hash") +set(MODULE_PREFIX "WINPR_TOOLS_HASH") + +set(${MODULE_PREFIX}_SRCS hash.c) +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + if(WITH_MONOLITHIC_BUILD) - target_link_libraries(winpr-hash winpr) + target_link_libraries(${MODULE_NAME} winpr) else() - target_link_libraries(winpr-hash winpr-utils) + target_link_libraries(${MODULE_NAME} winpr-utils) endif() +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") diff --git a/winpr/tools/reg/CMakeLists.txt b/winpr/tools/reg/CMakeLists.txt deleted file mode 100644 index 1392862bc..000000000 --- a/winpr/tools/reg/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# WinPR: Windows Portable Runtime -# winpr-reg cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_executable(winpr-reg - reg.c) - -if(WITH_MONOLITHIC_BUILD) - target_link_libraries(winpr-reg winpr) -else() - target_link_libraries(winpr-reg winpr-utils) - - if(NOT WIN32) - target_link_libraries(winpr-reg winpr-registry) - endif() -endif() diff --git a/winpr/tools/reg/reg.c b/winpr/tools/reg/reg.c deleted file mode 100644 index 5333a7a9f..000000000 --- a/winpr/tools/reg/reg.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol Client - * Registry API Tool - * - * Copyright 2012 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include - -#include -#include - -int main(int argc, char* argv[]) -{ - HKEY hKey; - LONG status; - DWORD dwType; - DWORD dwSize; - DWORD dwValue; - DWORD RemoteFX; - char* ComputerName; - - status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\FreeRDP"), 0, KEY_READ, &hKey); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegOpenKeyEx error: 0x%08lX\n"), status); - return 0; - } - - dwValue = 0; - status = RegQueryValueEx(hKey, _T("RemoteFX"), NULL, &dwType, (BYTE*) &dwValue, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - RemoteFX = dwValue; - - status = RegQueryValueEx(hKey, _T("ComputerName"), NULL, &dwType, NULL, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - ComputerName = (char*) malloc(dwSize + 1); - - status = RegQueryValueEx(hKey, _T("ComputerName"), NULL, &dwType, (BYTE*) ComputerName, &dwSize); - - if (status != ERROR_SUCCESS) - { - _tprintf(_T("RegQueryValueEx error: 0x%08lX\n"), status); - return 0; - } - - printf("RemoteFX: %08lX\n", RemoteFX); - printf("ComputerName: %s\n", ComputerName); - - RegCloseKey(hKey); - - free(ComputerName); - - return 0; -} - From 7a68fcf62634c35e56bb83d82409a33c28d6bb03 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Mon, 1 Oct 2012 11:08:13 -0700 Subject: [PATCH 40/64] win32: fix for 100% cpu, reset event --- libfreerdp/core/transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index c75b544f6..1073eb95f 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -390,6 +390,9 @@ int transport_check_fds(rdpTransport** ptransport) STREAM* received; rdpTransport* transport = *ptransport; +#ifdef _WIN32 + WSAResetEvent(transport->tcp->wsa_event); +#endif wait_obj_clear(transport->recv_event); status = transport_read_nonblocking(transport); From 7ef2ba88b468205fc958b9ae54e38daf15a4b6d1 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Mon, 1 Oct 2012 12:09:28 -0700 Subject: [PATCH 41/64] win32: increate the MsgWaitForMultipleObjects timeout since the main loop is working right --- client/Windows/wfreerdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 6bc8a59ea..17fc9a9ed 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -526,7 +526,7 @@ int wfreerdp_run(freerdp* instance) } /* do the wait */ - if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, 1, QS_ALLINPUT) == WAIT_FAILED) + if (MsgWaitForMultipleObjects(fds_count, fds, FALSE, 1000, QS_ALLINPUT) == WAIT_FAILED) { printf("wfreerdp_run: WaitForMultipleObjects failed: 0x%04X\n", GetLastError()); break; From 9155bf3eabb14e8c86dd90737ec6dbfb96a73b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 16:49:34 -0400 Subject: [PATCH 42/64] libwinpr-path: start writing tests --- winpr/include/winpr/error.h | 3 + winpr/include/winpr/path.h | 23 +++++ winpr/libwinpr/path/CMakeLists.txt | 4 + winpr/libwinpr/path/test/.gitignore | 3 + winpr/libwinpr/path/test/CMakeLists.txt | 48 ++++++++++ .../path/test/TestPathAllocCanonicalize.c | 12 +++ .../libwinpr/path/test/TestPathAllocCombine.c | 94 +++++++++++++++++++ .../path/test/TestPathCchAddBackslash.c | 54 +++++++++++ .../path/test/TestPathCchAddBackslashEx.c | 56 +++++++++++ .../path/test/TestPathCchAddExtension.c | 92 ++++++++++++++++++ winpr/libwinpr/path/test/TestPathCchAppend.c | 93 ++++++++++++++++++ .../libwinpr/path/test/TestPathCchAppendEx.c | 12 +++ .../path/test/TestPathCchCanonicalize.c | 12 +++ .../path/test/TestPathCchCanonicalizeEx.c | 12 +++ winpr/libwinpr/path/test/TestPathCchCombine.c | 12 +++ .../libwinpr/path/test/TestPathCchCombineEx.c | 12 +++ .../path/test/TestPathCchFindExtension.c | 12 +++ winpr/libwinpr/path/test/TestPathCchIsRoot.c | 12 +++ .../path/test/TestPathCchRemoveBackslash.c | 12 +++ .../path/test/TestPathCchRemoveBackslashEx.c | 12 +++ .../path/test/TestPathCchRemoveExtension.c | 12 +++ .../path/test/TestPathCchRemoveFileSpec.c | 12 +++ .../path/test/TestPathCchRenameExtension.c | 12 +++ .../libwinpr/path/test/TestPathCchSkipRoot.c | 12 +++ .../path/test/TestPathCchStripPrefix.c | 61 ++++++++++++ .../path/test/TestPathCchStripToRoot.c | 12 +++ winpr/libwinpr/path/test/TestPathIsUNCEx.c | 50 ++++++++++ 27 files changed, 761 insertions(+) create mode 100644 winpr/libwinpr/path/test/.gitignore create mode 100644 winpr/libwinpr/path/test/CMakeLists.txt create mode 100644 winpr/libwinpr/path/test/TestPathAllocCanonicalize.c create mode 100644 winpr/libwinpr/path/test/TestPathAllocCombine.c create mode 100644 winpr/libwinpr/path/test/TestPathCchAddBackslash.c create mode 100644 winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c create mode 100644 winpr/libwinpr/path/test/TestPathCchAddExtension.c create mode 100644 winpr/libwinpr/path/test/TestPathCchAppend.c create mode 100644 winpr/libwinpr/path/test/TestPathCchAppendEx.c create mode 100644 winpr/libwinpr/path/test/TestPathCchCanonicalize.c create mode 100644 winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c create mode 100644 winpr/libwinpr/path/test/TestPathCchCombine.c create mode 100644 winpr/libwinpr/path/test/TestPathCchCombineEx.c create mode 100644 winpr/libwinpr/path/test/TestPathCchFindExtension.c create mode 100644 winpr/libwinpr/path/test/TestPathCchIsRoot.c create mode 100644 winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c create mode 100644 winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c create mode 100644 winpr/libwinpr/path/test/TestPathCchRemoveExtension.c create mode 100644 winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c create mode 100644 winpr/libwinpr/path/test/TestPathCchRenameExtension.c create mode 100644 winpr/libwinpr/path/test/TestPathCchSkipRoot.c create mode 100644 winpr/libwinpr/path/test/TestPathCchStripPrefix.c create mode 100644 winpr/libwinpr/path/test/TestPathCchStripToRoot.c create mode 100644 winpr/libwinpr/path/test/TestPathIsUNCEx.c diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h index 21f5f05c6..58ffc31d8 100644 --- a/winpr/include/winpr/error.h +++ b/winpr/include/winpr/error.h @@ -25,6 +25,9 @@ #ifndef _WIN32 +#define S_OK ((HRESULT) 0L) +#define S_FALSE ((HRESULT) 1L) + /* System Error Codes (0-499) */ #define ERROR_SUCCESS 0x00000000 diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h index edcb90314..432c12c20 100644 --- a/winpr/include/winpr/path.h +++ b/winpr/include/winpr/path.h @@ -21,8 +21,29 @@ #define WINPR_PATH_H #include +#include #include +//#define HAVE_PATHCCH_H 1 + +#ifdef HAVE_PATHCCH_H + +#include + +#else + +#define PATHCCH_ALLOW_LONG_PATHS 0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */ + +#define VOLUME_PREFIX _T("\\\\?\\Volume") +#define VOLUME_PREFIX_LEN ((sizeof(VOLUME_PREFIX) / sizeof(TCHAR)) - 1) + +/* + * Maximum number of characters we support using the "\\?\" syntax + * (0x7FFF + 1 for NULL terminator) + */ + +#define PATHCCH_MAX_CCH 0x8000 + WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath); WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath); @@ -137,4 +158,6 @@ WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath); #define PathCchRemoveFileSpec PathCchRemoveFileSpecA #endif +#endif + #endif /* WINPR_PATH_H */ diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 1caa7346b..0c19c75fd 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -36,3 +36,7 @@ else() endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/winpr/libwinpr/path/test/.gitignore b/winpr/libwinpr/path/test/.gitignore new file mode 100644 index 000000000..7c43324cd --- /dev/null +++ b/winpr/libwinpr/path/test/.gitignore @@ -0,0 +1,3 @@ +TestPath +TestPath.c + diff --git a/winpr/libwinpr/path/test/CMakeLists.txt b/winpr/libwinpr/path/test/CMakeLists.txt new file mode 100644 index 000000000..b8eb05fd0 --- /dev/null +++ b/winpr/libwinpr/path/test/CMakeLists.txt @@ -0,0 +1,48 @@ + +set(MODULE_NAME "TestPath") +set(MODULE_PREFIX "TEST_PATH") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestPathCchAddBackslash.c + TestPathCchRemoveBackslash.c + TestPathCchAddBackslashEx.c + TestPathCchRemoveBackslashEx.c + TestPathCchAddExtension.c + TestPathCchAppend.c + TestPathCchAppendEx.c + TestPathCchCanonicalize.c + TestPathCchCanonicalizeEx.c + TestPathAllocCanonicalize.c + TestPathCchCombine.c + TestPathCchCombineEx.c + TestPathAllocCombine.c + TestPathCchFindExtension.c + TestPathCchRenameExtension.c + TestPathCchRemoveExtension.c + TestPathCchIsRoot.c + TestPathIsUNCEx.c + TestPathCchSkipRoot.c + TestPathCchStripToRoot.c + TestPathCchStripPrefix.c + TestPathCchRemoveFileSpec.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +if(WIN32) + target_link_libraries(${MODULE_NAME} Pathcch) +else() + target_link_libraries(${MODULE_NAME} winpr-path) +endif() + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) +endforeach() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") diff --git a/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c b/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c new file mode 100644 index 000000000..81f601432 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathAllocCanonicalize(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathAllocCombine.c b/winpr/libwinpr/path/test/TestPathAllocCombine.c new file mode 100644 index 000000000..a2fd2b069 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathAllocCombine.c @@ -0,0 +1,94 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testBasePathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files"); +static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0"); +static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0"); +static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0"); +static const TCHAR testPathOutMorePathBackslash[] = _T("C:\\Microsoft Visual Studio 11.0"); + +int TestPathAllocCombine(int argc, char* argv[]) +{ + HRESULT status; + LPTSTR PathOut; + + /* Base Path: Backslash, More Path: No Backslash */ + + status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: Backslash, More Path: Backslash */ + + status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: No Backslash, More Path: Backslash */ + + status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + /* Base Path: No Backslash, More Path: No Backslash */ + + status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut); + + if (status != S_OK) + { + _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(PathOut, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut); + return -1; + } + + HeapFree(GetProcessHeap(), 0, PathOut); + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c new file mode 100644 index 000000000..b237b6b27 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c @@ -0,0 +1,54 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files"); + +int TestPathCchAddBackslash(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + _tcscpy(Path, testPathNoBackslash); + + /* Add a backslash to a path without a trailing backslash, expect S_OK */ + + status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + /* Add a backslash to a path with a trailing backslash, expect S_FALSE */ + + _tcscpy(Path, testPathBackslash); + + status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c new file mode 100644 index 000000000..9fe39be84 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c @@ -0,0 +1,56 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files"); + +int TestPathCchAddBackslashEx(int argc, char* argv[]) +{ + HRESULT status; + LPTSTR pszEnd; + size_t cchRemaining; + TCHAR Path[PATHCCH_MAX_CCH]; + + _tcscpy(Path, testPathNoBackslash); + + /* Add a backslash to a path without a trailing backslash, expect S_OK */ + + status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + /* Add a backslash to a path with a trailing backslash, expect S_FALSE */ + + _tcscpy(Path, testPathBackslash); + + status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathBackslash) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAddExtension.c b/winpr/libwinpr/path/test/TestPathCchAddExtension.c new file mode 100644 index 000000000..ef766cffa --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAddExtension.c @@ -0,0 +1,92 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testExtDot[] = _T(".exe"); +static const TCHAR testExtNoDot[] = _T("exe"); +static const TCHAR testPathNoExtension[] = _T("C:\\Windows\\System32\\cmd"); +static const TCHAR testPathExtension[] = _T("C:\\Windows\\System32\\cmd.exe"); + +int TestPathCchAddExtension(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path: no extension, Extension: dot */ + + _tcscpy(Path, testPathNoExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: no extension, Extension: no dot */ + + _tcscpy(Path, testPathNoExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtNoDot); + + if (status != S_OK) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: extension, Extension: dot */ + + _tcscpy(Path, testPathExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + /* Path: extension, Extension: no dot */ + + _tcscpy(Path, testPathExtension); + + status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathExtension) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c new file mode 100644 index 000000000..76053c38a --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAppend.c @@ -0,0 +1,93 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testBasePathBackslash[] = _T("C:\\Program Files\\"); +static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files"); +static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0"); +static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0"); +static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0"); + +int TestPathCchAppend(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Base Path: Backslash, More Path: No Backslash */ + + _tcscpy(Path, testBasePathBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: Backslash, More Path: Backslash */ + + _tcscpy(Path, testBasePathBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: No Backslash, More Path: Backslash */ + + _tcscpy(Path, testBasePathNoBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + /* Base Path: No Backslash, More Path: No Backslash */ + + _tcscpy(Path, testBasePathNoBackslash); + + status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash); + + if (status != S_OK) + { + _tprintf(_T("PathCchAppend status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathOut) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchAppendEx.c b/winpr/libwinpr/path/test/TestPathCchAppendEx.c new file mode 100644 index 000000000..6f040fad1 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchAppendEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchAppendEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalize.c b/winpr/libwinpr/path/test/TestPathCchCanonicalize.c new file mode 100644 index 000000000..7c5b868dd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCanonicalize.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCanonicalize(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c b/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c new file mode 100644 index 000000000..13c4d373e --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCanonicalizeEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCombine.c b/winpr/libwinpr/path/test/TestPathCchCombine.c new file mode 100644 index 000000000..bfe1e86c6 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCombine.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCombine(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchCombineEx.c b/winpr/libwinpr/path/test/TestPathCchCombineEx.c new file mode 100644 index 000000000..5c3d0b8be --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchCombineEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchCombineEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchFindExtension.c b/winpr/libwinpr/path/test/TestPathCchFindExtension.c new file mode 100644 index 000000000..35ce6b576 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchFindExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchFindExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchIsRoot.c b/winpr/libwinpr/path/test/TestPathCchIsRoot.c new file mode 100644 index 000000000..a4e48daf9 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchIsRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchIsRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c new file mode 100644 index 000000000..a7c00ecfd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveBackslash(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c new file mode 100644 index 000000000..903341a46 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveBackslashEx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c b/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c new file mode 100644 index 000000000..f52ea8fc3 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c b/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c new file mode 100644 index 000000000..192894e0c --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRemoveFileSpec(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchRenameExtension.c b/winpr/libwinpr/path/test/TestPathCchRenameExtension.c new file mode 100644 index 000000000..a1816cbcd --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchRenameExtension.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchRenameExtension(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchSkipRoot.c b/winpr/libwinpr/path/test/TestPathCchSkipRoot.c new file mode 100644 index 000000000..4e83ef541 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchSkipRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchSkipRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c new file mode 100644 index 000000000..7163c1346 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c @@ -0,0 +1,61 @@ + +#include +#include +#include +#include +#include + +/** + * Naming Files, Paths, and Namespaces: + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247/ + */ + +static const TCHAR testPathPrefixFileNamespace[] = _T("\\\\?\\C:\\Program Files\\"); +static const TCHAR testPathNoPrefixFileNamespace[] = _T("C:\\Program Files\\"); + +static const TCHAR testPathPrefixDeviceNamespace[] = _T("\\\\?\\GLOBALROOT"); + +int TestPathCchStripPrefix(int argc, char* argv[]) +{ + HRESULT status; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path with prefix (File Namespace) */ + + _tcscpy(Path, testPathPrefixFileNamespace); + + status = PathCchStripPrefix(Path, sizeof(testPathPrefixFileNamespace) / sizeof(TCHAR)); + + if (status != S_OK) + { + _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathNoPrefixFileNamespace) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathNoPrefixFileNamespace); + return -1; + } + + /* Path with prefix (Device Namespace) */ + + _tcscpy(Path, testPathPrefixDeviceNamespace); + + status = PathCchStripPrefix(Path, sizeof(testPathPrefixDeviceNamespace) / sizeof(TCHAR)); + + if (status != S_FALSE) + { + _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Path, testPathPrefixDeviceNamespace) != 0) + { + _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathPrefixDeviceNamespace); + return -1; + } + + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathCchStripToRoot.c b/winpr/libwinpr/path/test/TestPathCchStripToRoot.c new file mode 100644 index 000000000..cc6e13cd9 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathCchStripToRoot.c @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include + +int TestPathCchStripToRoot(int argc, char* argv[]) +{ + return 0; +} + diff --git a/winpr/libwinpr/path/test/TestPathIsUNCEx.c b/winpr/libwinpr/path/test/TestPathIsUNCEx.c new file mode 100644 index 000000000..3cea93432 --- /dev/null +++ b/winpr/libwinpr/path/test/TestPathIsUNCEx.c @@ -0,0 +1,50 @@ + +#include +#include +#include +#include +#include + +static const TCHAR testServer[] = _T("server\\share\\path\\file"); +static const TCHAR testPathUNC[] = _T("\\\\server\\share\\path\\file"); +static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file"); + +int TestPathIsUNCEx(int argc, char* argv[]) +{ + BOOL status; + LPTSTR Server; + TCHAR Path[PATHCCH_MAX_CCH]; + + /* Path is UNC */ + + _tcscpy(Path, testPathUNC); + + status = PathIsUNCEx(Path, &Server); + + if (!status) + { + _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status); + return -1; + } + + if (_tcscmp(Server, testServer) != 0) + { + _tprintf(_T("Server Name Mismatch: Actual: %s, Expected: %s\n"), Server, testServer); + return -1; + } + + /* Path is not UNC */ + + _tcscpy(Path, testPathNotUNC); + + status = PathIsUNCEx(Path, &Server); + + if (status) + { + _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status); + return -1; + } + + return 0; +} + From 423585a6a133cdf8863dfaf0984af98029f6af11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 18:34:46 -0400 Subject: [PATCH 43/64] libwinpr-path: fix build on Linux --- .gitignore | 4 ++-- client/X11/CMakeLists.txt | 2 +- winpr/include/winpr/path.h | 1 + winpr/include/winpr/tchar.h | 2 ++ winpr/libwinpr/heap/heap.c | 2 ++ winpr/libwinpr/interlocked/CMakeLists.txt | 1 + winpr/libwinpr/path/CMakeLists.txt | 1 + winpr/libwinpr/path/path.c | 2 ++ winpr/libwinpr/path/test/TestPathCchAddBackslash.c | 4 ++-- 9 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e65348cdf..bd2a0d06d 100644 --- a/.gitignore +++ b/.gitignore @@ -43,9 +43,9 @@ RelWithDebInfo cunit/test_freerdp client/X11/xfreerdp client/Mac/xcode -client/test/freerdp-test +client/Sample/sfreerdp client/DirectFB/dfreerdp -server/test/tfreerdp-server +server/Sample/sfreerdp-server server/X11/xfreerdp-server xcode diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 2bf4efc82..980579067 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(MODULE_NAME "wfreerdp") +set(MODULE_NAME "xfreerdp") set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS") include(FindXmlto) diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h index 432c12c20..d823e15be 100644 --- a/winpr/include/winpr/path.h +++ b/winpr/include/winpr/path.h @@ -22,6 +22,7 @@ #include #include +#include #include //#define HAVE_PATHCCH_H 1 diff --git a/winpr/include/winpr/tchar.h b/winpr/include/winpr/tchar.h index 9b3cedc62..5d43a0c74 100644 --- a/winpr/include/winpr/tchar.h +++ b/winpr/include/winpr/tchar.h @@ -34,11 +34,13 @@ typedef WCHAR TCHAR; #define _tprintf wprintf #define _tcsdup _wcsdup #define _tcscmp wcscmp +#define _tcscpy wcscpy #else typedef CHAR TCHAR; #define _tprintf printf #define _tcsdup _strdup #define _tcscmp strcmp +#define _tcscpy strcpy #endif typedef TCHAR *LPTSTR, *LPTCH; diff --git a/winpr/libwinpr/heap/heap.c b/winpr/libwinpr/heap/heap.c index 5de8cba21..a53b2eff0 100644 --- a/winpr/libwinpr/heap/heap.c +++ b/winpr/libwinpr/heap/heap.c @@ -23,6 +23,8 @@ #include +#include + /* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */ /* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */ diff --git a/winpr/libwinpr/interlocked/CMakeLists.txt b/winpr/libwinpr/interlocked/CMakeLists.txt index c6edc4cee..7aea061f1 100644 --- a/winpr/libwinpr/interlocked/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/CMakeLists.txt @@ -32,6 +32,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO if(WITH_MONOLITHIC_BUILD) else() + target_link_libraries(${MODULE_NAME} winpr-crt) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 0c19c75fd..00080ee0a 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -32,6 +32,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SO if(WITH_MONOLITHIC_BUILD) else() + target_link_libraries(${MODULE_NAME} winpr-heap) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index bc54e3494..ce0a80aaa 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath) diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c index b237b6b27..a4e4a6df8 100644 --- a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c +++ b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c @@ -21,7 +21,7 @@ int TestPathCchAddBackslash(int argc, char* argv[]) if (status != S_OK) { - _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status); return -1; } @@ -39,7 +39,7 @@ int TestPathCchAddBackslash(int argc, char* argv[]) if (status != S_FALSE) { - _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status); + _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status); return -1; } From a80eeabc4817ae26e8b10ff14990039df71dfdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 19:10:00 -0400 Subject: [PATCH 44/64] libwinpr-crt: add tests for memory aligned allocation functions --- winpr/libwinpr/crt/CMakeLists.txt | 5 ++ winpr/libwinpr/crt/alignment.c | 25 ++++++-- winpr/libwinpr/crt/test/.gitignore | 3 + winpr/libwinpr/crt/test/CMakeLists.txt | 26 ++++++++ winpr/libwinpr/crt/test/TestAlignment.c | 79 +++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 winpr/libwinpr/crt/test/.gitignore create mode 100644 winpr/libwinpr/crt/test/CMakeLists.txt create mode 100644 winpr/libwinpr/crt/test/TestAlignment.c diff --git a/winpr/libwinpr/crt/CMakeLists.txt b/winpr/libwinpr/crt/CMakeLists.txt index 926fb5f4f..bc8a74907 100644 --- a/winpr/libwinpr/crt/CMakeLists.txt +++ b/winpr/libwinpr/crt/CMakeLists.txt @@ -38,3 +38,8 @@ else() endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") + +if(BUILD_TESTING) + add_subdirectory(test) +endif() + diff --git a/winpr/libwinpr/crt/alignment.c b/winpr/libwinpr/crt/alignment.c index c947e0496..9ae32a0eb 100644 --- a/winpr/libwinpr/crt/alignment.c +++ b/winpr/libwinpr/crt/alignment.c @@ -27,14 +27,26 @@ #ifndef _WIN32 +#include +#include + void* _aligned_malloc(size_t size, size_t alignment) { - return NULL; + void* memptr; + + if (posix_memalign(&memptr, alignment, size) != 0) + return NULL; + + return memptr; } void* _aligned_realloc(void* memblock, size_t size, size_t alignment) { - return NULL; + void* memptr = NULL; + + memptr = realloc(memblock, size); + + return memptr; } void* _aligned_recalloc(void* memblock, size_t num, size_t size, size_t alignment) @@ -44,7 +56,12 @@ void* _aligned_recalloc(void* memblock, size_t num, size_t size, size_t alignmen void* _aligned_offset_malloc(size_t size, size_t alignment, size_t offset) { - return NULL; + void* memptr; + + if (posix_memalign(&memptr, alignment, size) != 0) + return NULL; + + return memptr; } void* _aligned_offset_realloc(void* memblock, size_t size, size_t alignment, size_t offset) @@ -64,7 +81,7 @@ size_t _aligned_msize(void* memblock, size_t alignment, size_t offset) void _aligned_free(void* memblock) { - + free(memblock); } #endif diff --git a/winpr/libwinpr/crt/test/.gitignore b/winpr/libwinpr/crt/test/.gitignore new file mode 100644 index 000000000..7180deec5 --- /dev/null +++ b/winpr/libwinpr/crt/test/.gitignore @@ -0,0 +1,3 @@ +TestCrt +TestCrt.c + diff --git a/winpr/libwinpr/crt/test/CMakeLists.txt b/winpr/libwinpr/crt/test/CMakeLists.txt new file mode 100644 index 000000000..b66524907 --- /dev/null +++ b/winpr/libwinpr/crt/test/CMakeLists.txt @@ -0,0 +1,26 @@ + +set(MODULE_NAME "TestCrt") +set(MODULE_PREFIX "TEST_CRT") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestAlignment.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +if(NOT WIN32) + target_link_libraries(${MODULE_NAME} winpr-crt) +endif() + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName}) +endforeach() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test") + diff --git a/winpr/libwinpr/crt/test/TestAlignment.c b/winpr/libwinpr/crt/test/TestAlignment.c new file mode 100644 index 000000000..6db2641f8 --- /dev/null +++ b/winpr/libwinpr/crt/test/TestAlignment.c @@ -0,0 +1,79 @@ + +#include +#include +#include +#include + +int TestAlignment(int argc, char* argv[]) +{ + void* ptr; + size_t alignment; + size_t offset; + + /* Alignment should be 2^N where N is a positive integer */ + + alignment = 16; + offset = 5; + + /* _aligned_malloc */ + + ptr = _aligned_malloc(100, alignment); + + if (ptr == NULL) + { + printf("Error allocating aligned memory.\n"); + return -1; + } + + if (((size_t) ptr % alignment) == 0) + printf("This pointer, %d, is aligned on %d\n", ptr, alignment); + else + printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + + /* _aligned_realloc */ + + ptr = _aligned_realloc(ptr, 200, alignment); + + if (((size_t) ptr % alignment) == 0) + printf("This pointer, %d, is aligned on %d\n", ptr, alignment); + else + printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + + _aligned_free(ptr); + + /* _aligned_offset_malloc */ + + ptr = _aligned_offset_malloc(200, alignment, offset); + + if (ptr == NULL) + { + printf("Error reallocating aligned offset memory."); + return -1; + } + + if (((((size_t) ptr) + offset) % alignment) == 0) + printf("This pointer, %d, is offset by %d on alignment of %d\n", ptr, offset, alignment); + else + printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + + /* _aligned_offset_realloc */ + + ptr = _aligned_offset_realloc(ptr, 200, alignment, offset); + + if (ptr == NULL) + { + printf("Error reallocating aligned offset memory."); + return -1; + } + + if (((((size_t) ptr) + offset) % alignment) == 0) + printf("This pointer, %d, is offset by %d on alignment of %d\n", ptr, offset, alignment); + else + printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + + /* _aligned_free works for both _aligned_malloc and _aligned_offset_malloc. free() should not be used. */ + _aligned_free(ptr); + + return 0; +} + From eb54da8eb55fec2d709e0027d342b2bca7ecea6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 21:58:24 -0400 Subject: [PATCH 45/64] libwinpr-interlocked: added unit tests for interlocked access --- winpr/include/winpr/interlocked.h | 50 ++++-- winpr/include/winpr/spec.h | 8 +- winpr/libwinpr/interlocked/interlocked.c | 104 +++++++++-- .../libwinpr/interlocked/test/CMakeLists.txt | 1 + .../interlocked/test/TestInterlockedAccess.c | 164 ++++++++++++++++++ .../interlocked/test/TestInterlockedSList.c | 7 +- 6 files changed, 304 insertions(+), 30 deletions(-) create mode 100644 winpr/libwinpr/interlocked/test/TestInterlockedAccess.c diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h index a3563a75e..6055a4bd2 100644 --- a/winpr/include/winpr/interlocked.h +++ b/winpr/include/winpr/interlocked.h @@ -57,7 +57,7 @@ typedef struct LIST_ENTRY64 } LIST_ENTRY64; typedef LIST_ENTRY64 *PLIST_ENTRY64; -#ifdef _AMD64_ +#ifdef _WIN64 typedef struct _SLIST_ENTRY *PSLIST_ENTRY; typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY @@ -65,24 +65,46 @@ typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY PSLIST_ENTRY Next; } SLIST_ENTRY; -#else /* _AMD64_ */ +#else /* _WIN64 */ #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY -#endif /* _AMD64_ */ +#endif /* _WIN64 */ -#if defined(_AMD64_) +#ifdef _WIN64 -typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER +typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { - ULONGLONG Alignment; - ULONGLONG Region; -} SLIST_HEADER; -typedef struct _SLIST_HEADER *PSLIST_HEADER; + struct + { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; -#else /* _AMD64_ */ + struct + { + ULONGLONG Depth:16; + ULONGLONG Sequence:9; + ULONGLONG NextEntry:39; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:59; + ULONGLONG Region:3; + } Header8; + + struct + { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; +} SLIST_HEADER, *PSLIST_HEADER; + +#else /* _WIN64 */ typedef union _SLIST_HEADER { @@ -96,13 +118,13 @@ typedef union _SLIST_HEADER } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; -#endif /* _AMD64_ */ +#endif /* _WIN64 */ WINPR_API VOID InitializeSListHead(PSLIST_HEADER ListHead); -WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead); WINPR_API PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry); WINPR_API PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count); +WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead); WINPR_API PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead); WINPR_API USHORT QueryDepthSList(PSLIST_HEADER ListHead); @@ -113,8 +135,8 @@ WINPR_API LONG InterlockedDecrement(LONG volatile *Addend); WINPR_API LONG InterlockedExchange(LONG volatile *Target, LONG Value); WINPR_API LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value); -WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange, LONG Comperand); -WINPR_API LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand); +WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG Exchange, LONG Comperand); +WINPR_API LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand); #endif /* _WIN32 */ diff --git a/winpr/include/winpr/spec.h b/winpr/include/winpr/spec.h index 9a64f9c82..25355e5bc 100644 --- a/winpr/include/winpr/spec.h +++ b/winpr/include/winpr/spec.h @@ -27,6 +27,10 @@ #endif #endif /* _AMD64_ */ +#ifdef _AMD64_ +#define _WIN64 +#endif + #ifndef DECLSPEC_ALIGN #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) @@ -37,11 +41,13 @@ #endif #endif /* DECLSPEC_ALIGN */ -#ifdef _AMD64_ +#ifdef _WIN64 #define MEMORY_ALLOCATION_ALIGNMENT 16 #else #define MEMORY_ALLOCATION_ALIGNMENT 8 #endif +#define DUMMYSTRUCTNAME s + #endif /* WINPR_SPEC_H */ diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index fdbdea5ad..02983d4b0 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -44,26 +44,106 @@ VOID InitializeSListHead(PSLIST_HEADER ListHead) { - -} - -PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead) -{ - return NULL; +#ifdef _WIN64 + ListHead->s.Alignment = 0; + ListHead->s.Region = 0; + ListHead->Header8.Init = 1; +#else + ListHead->Alignment = 0; +#endif } PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry) { - return NULL; + SLIST_HEADER old; + SLIST_HEADER new; + +#ifdef _WIN64 + new.HeaderX64.NextEntry = (((ULONG_PTR) ListEntry) >> 4); + + do + { + old = *ListHead; + ListEntry->Next = (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4); + new.HeaderX64.Depth = old.HeaderX64.Depth + 1; + new.HeaderX64.Sequence = old.HeaderX64.Sequence + 1; + } + while (!InterlockedCompareExchange64((LONG64*) ListHead, new.s.Alignment, old.s.Alignment)); + + return (PSLIST_ENTRY) ((ULONG_PTR) old.HeaderX64.NextEntry << 4); +#else + new.s.Next.Next = entry; + + do + { + old = *ListHead; + ListEntry->Next = old.s.Next.Next; + new.s.Depth = old.s.Depth + 1; + new.s.Sequence = old.s.Sequence + 1; + } + while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment); + + return old.s.Next.Next; +#endif } PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count) { +#ifdef _WIN64 + +#else + +#endif return NULL; } +PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead) +{ + SLIST_HEADER old; + SLIST_HEADER new; + PSLIST_ENTRY entry; + +#ifdef _WIN64 + do + { + old = *ListHead; + + entry = (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4); + + if (!entry) + return NULL; + + new.HeaderX64.NextEntry = ((ULONG_PTR) entry->Next) >> 4; + new.HeaderX64.Depth = old.HeaderX64.Depth - 1; + new.HeaderX64.Sequence = old.HeaderX64.Sequence - 1; + } + while (!InterlockedCompareExchange64((LONG64*) ListHead, new.s.Alignment, old.s.Alignment)); +#else + do + { + old = *ListHead; + + entry = old.s.Next.Next; + + if (!entry) + return NULL; + + new.s.Next.Next = entry->Next; + new.s.Depth = old.s.Depth - 1; + new.s.Sequence = old.s.Sequence + 1; + } + while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment); +#endif + return entry; +} + PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead) { +#ifdef _WIN64 + +#else + +#endif return NULL; } @@ -102,25 +182,25 @@ LONG InterlockedExchange(LONG volatile *Target, LONG Value) LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value) { #ifdef __GNUC__ - return __sync_add_and_fetch(Addend, Value); + return __sync_fetch_and_add(Addend, Value); #else return 0; #endif } -LONG InterlockedCompareExchange(LONG volatile *Destination, LONG ExChange, LONG Comperand) +LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG Comperand) { #ifdef __GNUC__ - return __sync_val_compare_and_swap(Destination, Comperand, ExChange); + return __sync_val_compare_and_swap(Destination, Comperand, Exchange); #else return 0; #endif } -LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 ExChange, LONG64 Comperand) +LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand) { #ifdef __GNUC__ - return __sync_val_compare_and_swap(Destination, Comperand, ExChange); + return __sync_val_compare_and_swap(Destination, Comperand, Exchange); #else return 0; #endif diff --git a/winpr/libwinpr/interlocked/test/CMakeLists.txt b/winpr/libwinpr/interlocked/test/CMakeLists.txt index b7232f115..c04306ba1 100644 --- a/winpr/libwinpr/interlocked/test/CMakeLists.txt +++ b/winpr/libwinpr/interlocked/test/CMakeLists.txt @@ -5,6 +5,7 @@ set(MODULE_PREFIX "TEST_INTERLOCKED") set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) set(${MODULE_PREFIX}_TESTS + TestInterlockedAccess.c TestInterlockedSList.c) create_test_sourcelist(${MODULE_PREFIX}_SRCS diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c new file mode 100644 index 000000000..38c557fa0 --- /dev/null +++ b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c @@ -0,0 +1,164 @@ + +#include +#include +#include +#include +#include + +int TestInterlockedAccess(int argc, char* argv[]) +{ + int index; + LONG* Addend; + LONG* Target; + LONG oldValue; + LONG* Destination; + LONGLONG oldValue64; + LONGLONG* Destination64; + + /* InterlockedIncrement */ + + Addend = _aligned_malloc(sizeof(LONG), sizeof(LONG)); + + *Addend = 0; + + for (index = 0; index < 10; index ++) + InterlockedIncrement(Addend); + + if (*Addend != 10) + { + printf("InterlockedIncrement failure: Actual: %d, Expected: %d\n", (int) *Addend, 10); + return -1; + } + + /* InterlockedDecrement */ + + for (index = 0; index < 10; index ++) + InterlockedDecrement(Addend); + + if (*Addend != 0) + { + printf("InterlockedDecrement failure: Actual: %d, Expected: %d\n", (int) *Addend, 0); + return -1; + } + + /* InterlockedExchange */ + + Target = _aligned_malloc(sizeof(LONG), sizeof(LONG)); + + *Target = 0xAA; + + oldValue = InterlockedExchange(Target, 0xFF); + + if (oldValue != 0xAA) + { + printf("InterlockedExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAA); + return -1; + } + + if (*Target != 0xFF) + { + printf("InterlockedExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Target, 0xFF); + return -1; + } + + /* InterlockedExchangeAdd */ + + *Addend = 25; + + oldValue = InterlockedExchangeAdd(Addend, 100); + + if (oldValue != 25) + { + printf("InterlockedExchangeAdd failure: Actual: %d, Expected: %d\n", (int) oldValue, 25); + return -1; + } + + if (*Addend != 125) + { + printf("InterlockedExchangeAdd failure: Actual: %d, Expected: %d\n", (int) *Addend, 125); + return -1; + } + + /* InterlockedCompareExchange (*Destination == Comparand) */ + + Destination = _aligned_malloc(sizeof(LONG), sizeof(LONG)); + + *Destination = 0xAABBCCDD; + + oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0xAABBCCDD); + + if (oldValue != 0xAABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAABBCCDD); + return -1; + } + + if (*Destination != 0xCCDDEEFF) + { + printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Destination, 0xCCDDEEFF); + return -1; + } + + /* InterlockedCompareExchange (*Destination != Comparand) */ + + *Destination = 0xAABBCCDD; + + oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0x66778899); + + if (oldValue != 0xAABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) oldValue, 0xAABBCCDD); + return -1; + } + + if (*Destination != 0xAABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: 0x%08X, Expected: 0x%08X\n", (int) *Destination, 0xAABBCCDD); + return -1; + } + + /* InterlockedCompareExchange64 (*Destination == Comparand) */ + + Destination64 = _aligned_malloc(sizeof(LONGLONG), sizeof(LONGLONG)); + + *Destination64 = 0x66778899AABBCCDD; + + oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFF, 0x66778899AABBCCDD); + + if (oldValue64 != 0x66778899AABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", oldValue64, (LONGLONG) 0x66778899AABBCCDD); + return -1; + } + + if (*Destination64 != 0x8899AABBCCDDEEFF) + { + printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", *Destination64, (LONGLONG) 0x8899AABBCCDDEEFF); + return -1; + } + + /* InterlockedCompareExchange64 (*Destination != Comparand) */ + + *Destination64 = 0x66778899AABBCCDD; + + oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFF, 12345); + + if (oldValue64 != 0x66778899AABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", oldValue64, (LONGLONG) 0x66778899AABBCCDD); + return -1; + } + + if (*Destination64 != 0x66778899AABBCCDD) + { + printf("InterlockedCompareExchange failure: Actual: %lld, Expected: %lld\n", *Destination64, (LONGLONG) 0x66778899AABBCCDD); + return -1; + } + + _aligned_free(Addend); + _aligned_free(Target); + _aligned_free(Destination); + _aligned_free(Destination64); + + return 0; +} diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c index 04a4a9c63..b3eb357ec 100644 --- a/winpr/libwinpr/interlocked/test/TestInterlockedSList.c +++ b/winpr/libwinpr/interlocked/test/TestInterlockedSList.c @@ -22,11 +22,12 @@ int TestInterlockedSList(int argc, char* argv[]) /* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */ pListHead = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); - if( NULL == pListHead ) + if (!pListHead) { printf("Memory allocation failed.\n"); return -1; } + InitializeSListHead(pListHead); /* Insert 10 items into the list. */ @@ -41,7 +42,7 @@ int TestInterlockedSList(int argc, char* argv[]) } pProgramItem->Signature = Count; - pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry)); + pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry)); } /* Remove 10 items from the list and display the signature. */ @@ -56,7 +57,7 @@ int TestInterlockedSList(int argc, char* argv[]) } pProgramItem = (PPROGRAM_ITEM) pListEntry; - printf("Signature is %d\n", pProgramItem->Signature); + printf("Signature is %d\n", (int) pProgramItem->Signature); /* * This example assumes that the SLIST_ENTRY structure is the From ebbdc8dca92457cdaa81dbc469c32cf5f9fbf8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 23:00:41 -0400 Subject: [PATCH 46/64] libwinpr-interlocked: make tests pass --- winpr/include/winpr/interlocked.h | 2 +- winpr/libwinpr/interlocked/interlocked.c | 31 +++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h index 6055a4bd2..d651c629e 100644 --- a/winpr/include/winpr/interlocked.h +++ b/winpr/include/winpr/interlocked.h @@ -136,7 +136,7 @@ WINPR_API LONG InterlockedExchange(LONG volatile *Target, LONG Value); WINPR_API LONG InterlockedExchangeAdd(LONG volatile *Addend, LONG Value); WINPR_API LONG InterlockedCompareExchange(LONG volatile *Destination,LONG Exchange, LONG Comperand); -WINPR_API LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand); +WINPR_API LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand); #endif /* _WIN32 */ diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index 02983d4b0..789012fc8 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -42,6 +42,9 @@ #ifndef _WIN32 +#include +#include + VOID InitializeSListHead(PSLIST_HEADER ListHead) { #ifdef _WIN64 @@ -61,14 +64,21 @@ PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY List #ifdef _WIN64 new.HeaderX64.NextEntry = (((ULONG_PTR) ListEntry) >> 4); - do + while (1) { old = *ListHead; + ListEntry->Next = (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4); + new.HeaderX64.Depth = old.HeaderX64.Depth + 1; new.HeaderX64.Sequence = old.HeaderX64.Sequence + 1; + + if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment)) + { + InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region); + break; + } } - while (!InterlockedCompareExchange64((LONG64*) ListHead, new.s.Alignment, old.s.Alignment)); return (PSLIST_ENTRY) ((ULONG_PTR) old.HeaderX64.NextEntry << 4); #else @@ -104,7 +114,7 @@ PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead) PSLIST_ENTRY entry; #ifdef _WIN64 - do + while (1) { old = *ListHead; @@ -116,8 +126,13 @@ PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead) new.HeaderX64.NextEntry = ((ULONG_PTR) entry->Next) >> 4; new.HeaderX64.Depth = old.HeaderX64.Depth - 1; new.HeaderX64.Sequence = old.HeaderX64.Sequence - 1; + + if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment)) + { + InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region); + break; + } } - while (!InterlockedCompareExchange64((LONG64*) ListHead, new.s.Alignment, old.s.Alignment)); #else do { @@ -149,7 +164,11 @@ PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead) USHORT QueryDepthSList(PSLIST_HEADER ListHead) { - return 0; +#ifdef _WIN64 + return ListHead->HeaderX64.Depth; +#else + return ListHead->s.Depth; +#endif } LONG InterlockedIncrement(LONG volatile *Addend) @@ -197,7 +216,7 @@ LONG InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG #endif } -LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand) +LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG Exchange, LONGLONG Comperand) { #ifdef __GNUC__ return __sync_val_compare_and_swap(Destination, Comperand, Exchange); From f31b5c7f5d4f34dad4f34ffe7d3f3c629f580845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 1 Oct 2012 23:31:49 -0400 Subject: [PATCH 47/64] libwinpr-crt: improve aligned memory tests --- winpr/libwinpr/crt/alignment.c | 25 ++++++++++++++++++ winpr/libwinpr/crt/test/TestAlignment.c | 28 ++++++++++++--------- winpr/libwinpr/interlocked/interlocked.c | 32 +++++++++++++++++++++++- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/winpr/libwinpr/crt/alignment.c b/winpr/libwinpr/crt/alignment.c index 9ae32a0eb..ce2c85647 100644 --- a/winpr/libwinpr/crt/alignment.c +++ b/winpr/libwinpr/crt/alignment.c @@ -34,6 +34,16 @@ void* _aligned_malloc(size_t size, size_t alignment) { void* memptr; + /* alignment must be a power of 2 */ + + if (alignment % 2 == 1) + return NULL; + + /* offset must be less than size */ + + if (offset >= size) + return NULL; + if (posix_memalign(&memptr, alignment, size) != 0) return NULL; @@ -58,6 +68,21 @@ void* _aligned_offset_malloc(size_t size, size_t alignment, size_t offset) { void* memptr; + /* alignment must be a power of 2 */ + + if (alignment % 2 == 1) + return NULL; + + /* offset must be less than size */ + + if (offset >= size) + return NULL; + + /* minimum alignment is pointer size */ + + if (alignment < sizeof(void*)) + alignment = sizeof(void*); + if (posix_memalign(&memptr, alignment, size) != 0) return NULL; diff --git a/winpr/libwinpr/crt/test/TestAlignment.c b/winpr/libwinpr/crt/test/TestAlignment.c index 6db2641f8..bd911db0f 100644 --- a/winpr/libwinpr/crt/test/TestAlignment.c +++ b/winpr/libwinpr/crt/test/TestAlignment.c @@ -25,19 +25,21 @@ int TestAlignment(int argc, char* argv[]) return -1; } - if (((size_t) ptr % alignment) == 0) - printf("This pointer, %d, is aligned on %d\n", ptr, alignment); - else + if (((size_t) ptr % alignment) != 0) + { printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + return -1; + } /* _aligned_realloc */ ptr = _aligned_realloc(ptr, 200, alignment); - if (((size_t) ptr % alignment) == 0) - printf("This pointer, %d, is aligned on %d\n", ptr, alignment); - else + if (((size_t) ptr % alignment) != 0) + { printf("This pointer, %d, is not aligned on %d\n", ptr, alignment); + return -1; + } _aligned_free(ptr); @@ -51,10 +53,11 @@ int TestAlignment(int argc, char* argv[]) return -1; } - if (((((size_t) ptr) + offset) % alignment) == 0) - printf("This pointer, %d, is offset by %d on alignment of %d\n", ptr, offset, alignment); - else + if (((((size_t) ptr) + offset) % alignment) != 0) + { printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + return -1; + } /* _aligned_offset_realloc */ @@ -66,10 +69,11 @@ int TestAlignment(int argc, char* argv[]) return -1; } - if (((((size_t) ptr) + offset) % alignment) == 0) - printf("This pointer, %d, is offset by %d on alignment of %d\n", ptr, offset, alignment); - else + if (((((size_t) ptr) + offset) % alignment) != 0) + { printf("This pointer, %d, does not satisfy offset %d and alignment %d\n", ptr, offset, alignment); + return -1; + } /* _aligned_free works for both _aligned_malloc and _aligned_offset_malloc. free() should not be used. */ _aligned_free(ptr); diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index 789012fc8..0be301529 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -154,12 +154,42 @@ PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead) PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead) { + SLIST_HEADER old; + SLIST_HEADER new; + + if (!QueryDepthSList(ListHead)) + return NULL; + #ifdef _WIN64 + new.s.Alignment = 0; + new.s.Region = 0; + new.HeaderX64.HeaderType = 1; + while (1) + { + old = *ListHead; + new.HeaderX64.Sequence = old.HeaderX64.Sequence + 1; + + if (InterlockedCompareExchange64((LONGLONG*) ListHead, new.s.Alignment, old.s.Alignment)) + { + InterlockedCompareExchange64(&((LONGLONG*) ListHead)[1], new.s.Region, old.s.Region); + break; + } + } + + return (PSLIST_ENTRY) (((ULONG_PTR) old.HeaderX64.NextEntry) << 4); #else + new.Alignment = 0; + do + { + old = *ListHead; + new.s.Sequence = old.s.Sequence + 1; + } + while(InterlockedCompareExchange64(&ListHead->Alignment, new.Alignment, old.Alignment) != old.Alignment); + + return old.s.Next.Next; #endif - return NULL; } USHORT QueryDepthSList(PSLIST_HEADER ListHead) From e1fc37b5e4ee27e8c7f5cb823598697337a3af11 Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 08:48:11 +0200 Subject: [PATCH 48/64] Add missing #ifdef/#endif around include stdint --- libfreerdp/codec/nsc.c | 2 ++ libfreerdp/codec/nsc_encode.c | 2 ++ libfreerdp/codec/rfx.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index ac74dcc0c..4ce27529d 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -25,7 +25,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index 7feb4879a..50a9c5bce 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -24,7 +24,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 1e7478356..b3ed3ca99 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -24,7 +24,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include #include From 7a7103ee3d56e03c9502759a139d04dae8cac048 Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 08:49:18 +0200 Subject: [PATCH 49/64] Add MSVC2008 project files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 21444d459..f5009b5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,12 @@ client/X11/xfreerdp.1 # Windows *.vcxproj *.vcxproj.* +*.vcproj +*.vcproj.* *.sdf *.sln *.suo +*.ncb *.opensdf ipch Debug From fbe8a2eaaef35a9cfecaf90c10ef76a49797c1f7 Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 08:58:54 +0200 Subject: [PATCH 50/64] Make the rdpdr disk plugin working on windows. Currently not working are rename and setting of read only attribute and file times. In addition it also adds the ability to staticly link plugins into the binary, so you get one big exe and need no dlls. I have only tested this on windows (only disk plugin so far). I use the following options for cmake for static binary: cmake -DWITH_MONOLITHIC_BUILD=ON -DMSVC_RUNTIME=static -DBUILD_SHARED_LIBS=OFF -DWITH_RDPDR=ON -DOPENSSL_INCLUDE_DIR=\opensslpath\inc32 -DOPENSSL_LIBRARIES="\opensslpath\out32.dbg\ssleay32.lib;d:\path\out32.dbg\libeay32.lib" -G "Visual Studio 9 2008" . Important notice: Openssl need to be compiled with the same static runtime. Currently missing is a switch to link different openssl libraries for debug and release builds. --- CMakeLists.txt | 5 + channels/rdpdr/client/CMakeLists.txt | 2 +- channels/rdpdr/client/disk/CMakeLists.txt | 1 + channels/rdpdr/client/disk/dirent.h | 374 ++++++++++++++++++++++ channels/rdpdr/client/disk/disk_file.c | 22 +- channels/rdpdr/client/disk/disk_file.h | 24 +- channels/rdpdr/client/disk/disk_main.c | 4 + channels/rdpdr/client/disk/statvfs.c | 67 ++++ channels/rdpdr/client/disk/statvfs.h | 46 +++ client/Windows/CMakeLists.txt | 99 +++--- client/Windows/wfreerdp.c | 15 +- config.h.in | 6 + include/freerdp/utils/svc_plugin.h | 6 + 13 files changed, 610 insertions(+), 61 deletions(-) create mode 100644 channels/rdpdr/client/disk/dirent.h create mode 100644 channels/rdpdr/client/disk/statvfs.c create mode 100644 channels/rdpdr/client/disk/statvfs.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 446e685a7..2fe8a1096 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,10 @@ if(NOT DEFINED BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS ON) endif() +if(NOT BUILD_SHARED_LIBS AND WITH_MONOLITHIC_BUILD) + set(WITH_STATIC_PLUGINS ON) +endif() + # Configure MSVC Runtime if(MSVC) include(MSVCRuntime) @@ -73,6 +77,7 @@ if(MSVC) configure_msvc_runtime() endif() + # Compiler-specific flags if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") diff --git a/channels/rdpdr/client/CMakeLists.txt b/channels/rdpdr/client/CMakeLists.txt index 55b0e09ba..854770647 100644 --- a/channels/rdpdr/client/CMakeLists.txt +++ b/channels/rdpdr/client/CMakeLists.txt @@ -40,8 +40,8 @@ endif() install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) +add_subdirectory(disk) if(NOT WIN32) - add_subdirectory(disk) add_subdirectory(printer) add_subdirectory(parallel) add_subdirectory(serial) diff --git a/channels/rdpdr/client/disk/CMakeLists.txt b/channels/rdpdr/client/disk/CMakeLists.txt index d6d7935f3..b1e57878e 100644 --- a/channels/rdpdr/client/disk/CMakeLists.txt +++ b/channels/rdpdr/client/disk/CMakeLists.txt @@ -21,6 +21,7 @@ set(MODULE_NAME "disk") set(MODULE_PREFIX "CHANNEL_DEVICE_DISK") set(${MODULE_PREFIX}_SRCS + statvfs.c disk_file.c disk_file.h disk_main.c) diff --git a/channels/rdpdr/client/disk/dirent.h b/channels/rdpdr/client/disk/dirent.h new file mode 100644 index 000000000..fa5a294d5 --- /dev/null +++ b/channels/rdpdr/client/disk/dirent.h @@ -0,0 +1,374 @@ +/***************************************************************************** + * dirent.h - dirent API for Microsoft Visual Studio + * + * Copyright (C) 2006 Toni Ronkko + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * ``Software''), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Mar 15, 2011, Toni Ronkko + * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0. + * + * Aug 11, 2010, Toni Ronkko + * Added d_type and d_namlen fields to dirent structure. The former is + * especially useful for determining whether directory entry represents a + * file or a directory. For more information, see + * http://www.delorie.com/gnu/docs/glibc/libc_270.html + * + * Aug 11, 2010, Toni Ronkko + * Improved conformance to the standards. For example, errno is now set + * properly on failure and assert() is never used. Thanks to Peter Brockam + * for suggestions. + * + * Aug 11, 2010, Toni Ronkko + * Fixed a bug in rewinddir(): when using relative directory names, change + * of working directory no longer causes rewinddir() to fail. + * + * Dec 15, 2009, John Cunningham + * Added rewinddir member function + * + * Jan 18, 2008, Toni Ronkko + * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string + * between multi-byte and unicode representations. This makes the + * code simpler and also allows the code to be compiled under MingW. Thanks + * to Azriel Fasten for the suggestion. + * + * Mar 4, 2007, Toni Ronkko + * Bug fix: due to the strncpy_s() function this file only compiled in + * Visual Studio 2005. Using the new string functions only when the + * compiler version allows. + * + * Nov 2, 2006, Toni Ronkko + * Major update: removed support for Watcom C, MS-DOS and Turbo C to + * simplify the file, updated the code to compile cleanly on Visual + * Studio 2005 with both unicode and multi-byte character strings, + * removed rewinddir() as it had a bug. + * + * Aug 20, 2006, Toni Ronkko + * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified + * comments by removing SGML tags. + * + * May 14 2002, Toni Ronkko + * Embedded the function definitions directly to the header so that no + * source modules need to be included in the Visual Studio project. Removed + * all the dependencies to other projects so that this very header can be + * used independently. + * + * May 28 1998, Toni Ronkko + * First version. + *****************************************************************************/ +#ifndef DIRENT_H +#define DIRENT_H + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include +#include +#include + +/* Entries missing from MSVC 6.0 */ +#if !defined(FILE_ATTRIBUTE_DEVICE) +# define FILE_ATTRIBUTE_DEVICE 0x40 +#endif + +/* File type and permission flags for stat() */ +#if defined(_MSC_VER) && !defined(S_IREAD) +# define S_IFMT _S_IFMT /* file type mask */ +# define S_IFDIR _S_IFDIR /* directory */ +# define S_IFCHR _S_IFCHR /* character device */ +# define S_IFFIFO _S_IFFIFO /* pipe */ +# define S_IFREG _S_IFREG /* regular file */ +# define S_IREAD _S_IREAD /* read permission */ +# define S_IWRITE _S_IWRITE /* write permission */ +# define S_IEXEC _S_IEXEC /* execute permission */ +#endif +#define S_IFBLK 0 /* block device */ +#define S_IFLNK 0 /* link */ +#define S_IFSOCK 0 /* socket */ + +#if defined(_MSC_VER) +# define S_IRUSR S_IREAD /* read, user */ +# define S_IWUSR S_IWRITE /* write, user */ +# define S_IXUSR 0 /* execute, user */ +# define S_IRGRP 0 /* read, group */ +# define S_IWGRP 0 /* write, group */ +# define S_IXGRP 0 /* execute, group */ +# define S_IROTH 0 /* read, others */ +# define S_IWOTH 0 /* write, others */ +# define S_IXOTH 0 /* execute, others */ +#endif + +/* Indicates that d_type field is available in dirent structure */ +#define _DIRENT_HAVE_D_TYPE + +/* File type flags for d_type */ +#define DT_UNKNOWN 0 +#define DT_REG S_IFREG +#define DT_DIR S_IFDIR +#define DT_FIFO S_IFFIFO +#define DT_SOCK S_IFSOCK +#define DT_CHR S_IFCHR +#define DT_BLK S_IFBLK + +/* Macros for converting between st_mode and d_type */ +#define IFTODT(mode) ((mode) & S_IFMT) +#define DTTOIF(type) (type) + +/* + * File type macros. Note that block devices, sockets and links cannot be + * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are + * only defined for compatibility. These macros should always return false + * on Windows. + */ +#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO) +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) +#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) +#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct dirent +{ + char d_name[MAX_PATH + 1]; /* File name */ + size_t d_namlen; /* Length of name without \0 */ + int d_type; /* File type */ +} dirent; + + +typedef struct DIR +{ + dirent curentry; /* Current directory entry */ + WIN32_FIND_DATAA find_data; /* Private file data */ + int cached; /* True if data is valid */ + HANDLE search_handle; /* Win32 search handle */ + char patt[MAX_PATH + 3]; /* Initial directory name */ +} DIR; + + +/* Forward declarations */ +static DIR *opendir(const char *dirname); +static struct dirent *readdir(DIR *dirp); +static int closedir(DIR *dirp); +static void rewinddir(DIR* dirp); + + +/* Use the new safe string functions introduced in Visual Studio 2005 */ +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE) +#else +# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size)) +#endif + +/* Set errno variable */ +#if defined(_MSC_VER) +#define DIRENT_SET_ERRNO(x) _set_errno (x) +#else +#define DIRENT_SET_ERRNO(x) (errno = (x)) +#endif + + +/***************************************************************************** + * Open directory stream DIRNAME for read and return a pointer to the + * internal working area that is used to retrieve individual directory + * entries. + */ +static DIR *opendir(const char *dirname) +{ + DIR *dirp; + + /* ensure that the resulting search pattern will be a valid file name */ + if (dirname == NULL) { + DIRENT_SET_ERRNO (ENOENT); + return NULL; + } + if (strlen (dirname) + 3 >= MAX_PATH) { + DIRENT_SET_ERRNO (ENAMETOOLONG); + return NULL; + } + + /* construct new DIR structure */ + dirp = (DIR*) malloc (sizeof (struct DIR)); + if (dirp != NULL) { + int error; + + /* + * Convert relative directory name to an absolute one. This + * allows rewinddir() to function correctly when the current working + * directory is changed between opendir() and rewinddir(). + */ + if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) { + char *p; + + /* append the search pattern "\\*\0" to the directory name */ + p = strchr (dirp->patt, '\0'); + if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { + *p++ = '\\'; + } + *p++ = '*'; + *p = '\0'; + + /* open directory stream and retrieve the first entry */ + dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data); + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + /* a directory entry is now waiting in memory */ + dirp->cached = 1; + error = 0; + } else { + /* search pattern is not a directory name? */ + DIRENT_SET_ERRNO (ENOENT); + error = 1; + } + } else { + /* buffer too small */ + DIRENT_SET_ERRNO (ENOMEM); + error = 1; + } + + if (error) { + free (dirp); + dirp = NULL; + } + } + + return dirp; +} + + +/***************************************************************************** + * Read a directory entry, and return a pointer to a dirent structure + * containing the name of the entry in d_name field. Individual directory + * entries returned by this very function include regular files, + * sub-directories, pseudo-directories "." and "..", but also volume labels, + * hidden files and system files may be returned. + */ +static struct dirent *readdir(DIR *dirp) +{ + DWORD attr; + if (dirp == NULL) { + /* directory stream did not open */ + DIRENT_SET_ERRNO (EBADF); + return NULL; + } + + /* get next directory entry */ + if (dirp->cached != 0) { + /* a valid directory entry already in memory */ + dirp->cached = 0; + } else { + /* get the next directory entry from stream */ + if (dirp->search_handle == INVALID_HANDLE_VALUE) { + return NULL; + } + if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) { + /* the very last entry has been processed or an error occured */ + FindClose (dirp->search_handle); + dirp->search_handle = INVALID_HANDLE_VALUE; + return NULL; + } + } + + /* copy as a multibyte character string */ + DIRENT_STRNCPY ( dirp->curentry.d_name, + dirp->find_data.cFileName, + sizeof(dirp->curentry.d_name) ); + dirp->curentry.d_name[MAX_PATH] = '\0'; + + /* compute the length of name */ + dirp->curentry.d_namlen = strlen (dirp->curentry.d_name); + + /* determine file type */ + attr = dirp->find_data.dwFileAttributes; + if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { + dirp->curentry.d_type = DT_CHR; + } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { + dirp->curentry.d_type = DT_DIR; + } else { + dirp->curentry.d_type = DT_REG; + } + return &dirp->curentry; +} + + +/***************************************************************************** + * Close directory stream opened by opendir() function. Close of the + * directory stream invalidates the DIR structure as well as any previously + * read directory entry. + */ +static int closedir(DIR *dirp) +{ + if (dirp == NULL) { + /* invalid directory stream */ + DIRENT_SET_ERRNO (EBADF); + return -1; + } + + /* release search handle */ + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->search_handle); + dirp->search_handle = INVALID_HANDLE_VALUE; + } + + /* release directory structure */ + free (dirp); + return 0; +} + + +/***************************************************************************** + * Resets the position of the directory stream to which dirp refers to the + * beginning of the directory. It also causes the directory stream to refer + * to the current state of the corresponding directory, as a call to opendir() + * would have done. If dirp does not refer to a directory stream, the effect + * is undefined. + */ +static void rewinddir(DIR* dirp) +{ + if (dirp != NULL) { + /* release search handle */ + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->search_handle); + } + + /* open new search handle and retrieve the first entry */ + dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data); + if (dirp->search_handle != INVALID_HANDLE_VALUE) { + /* a directory entry is now waiting in memory */ + dirp->cached = 1; + } else { + /* failed to re-open directory: no directory entry in memory */ + dirp->cached = 0; + } + } +} + + +#ifdef __cplusplus +} +#endif +#endif /*DIRENT_H*/ diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index a8a02a8ad..5efead5ca 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -4,6 +4,7 @@ * * Copyright 2010-2011 Marc-Andre Moreau * Copyright 2010-2011 Vic Lee + * Copyright 2012 Gerald Richter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,10 +183,12 @@ static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath) static boolean disk_file_init(DISK_FILE* file, uint32 DesiredAccess, uint32 CreateDisposition, uint32 CreateOptions) { - const static int mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH; struct STAT st; boolean exists; -#ifndef WIN32 +#ifdef WIN32 + const static int mode = _S_IREAD | _S_IWRITE ; +#else + const static int mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH; boolean largeFile = false; #endif int oflag = 0; @@ -423,7 +426,8 @@ boolean disk_file_query_information(DISK_FILE* file, uint32 FsInformationClass, boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, uint32 Length, STREAM* input) { char* s; - mode_t m; + + mode_t m; uint64 size; char* fullpath; struct STAT st; @@ -449,7 +453,9 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui tv[0].tv_usec = 0; tv[1].tv_sec = (LastWriteTime > 0 ? FILE_TIME_RDP_TO_SYSTEM(LastWriteTime) : st.st_mtime); tv[1].tv_usec = 0; - futimes(file->fd, tv); +#ifndef WIN32 +/* TODO on win32 */ + futimes(file->fd, tv); if (FileAttributes > 0) { @@ -461,7 +467,8 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui if (m != st.st_mode) fchmod(file->fd, st.st_mode); } - break; +#endif + break; case FileEndOfFileInformation: /* http://msdn.microsoft.com/en-us/library/cc232067.aspx */ @@ -492,14 +499,15 @@ boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, ui fullpath = disk_file_combine_fullpath(file->basepath, s); xfree(s); - if (rename(file->fullpath, fullpath) == 0) + /* TODO rename does not work on win32 */ + if (rename(file->fullpath, fullpath) == 0) { DEBUG_SVC("renamed %s to %s", file->fullpath, fullpath); disk_file_set_fullpath(file, fullpath); } else { - DEBUG_WARN("rename %s to %s failed", file->fullpath, fullpath); + DEBUG_WARN("rename %s to %s failed, errno = %d", file->fullpath, fullpath, errno); free(fullpath); return false; } diff --git a/channels/rdpdr/client/disk/disk_file.h b/channels/rdpdr/client/disk/disk_file.h index 2d85bf80e..35db89a43 100644 --- a/channels/rdpdr/client/disk/disk_file.h +++ b/channels/rdpdr/client/disk/disk_file.h @@ -4,6 +4,7 @@ * * Copyright 2010-2011 Marc-Andre Moreau * Copyright 2010-2011 Vic Lee + * Copyright 2012 Gerald Richter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,17 +25,32 @@ #include #include -#ifndef _WIN32 -#include +#include "dirent.h" +#ifdef _WIN32 +#include +#include +#include "statvfs.h" +#else #include #endif #ifdef _WIN32 #define STAT stat -#define OPEN open -#define LSEEK lseek +#define OPEN _open +#define close _close +#define read _read +#define write _write +#define LSEEK _lseek #define FSTAT fstat #define STATVFS statvfs +#define mkdir(a,b) _mkdir(a) +#define rmdir _rmdir +#define unlink(a) _unlink(a) +#define ftruncate(a,b) _chsize(a,b) + +typedef uint32 ssize_t ; +typedef uint32 mode_t ; + #elif defined(__APPLE__) || defined(__FreeBSD__) #define STAT stat #define OPEN open diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index a6203ecce..504df2a72 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -647,7 +647,11 @@ static void disk_free(DEVICE* device) xfree(disk); } +#ifdef WITH_STATIC_PLUGINS +int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#else int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#endif { char* name; char* path; diff --git a/channels/rdpdr/client/disk/statvfs.c b/channels/rdpdr/client/disk/statvfs.c new file mode 100644 index 000000000..063b0e9f9 --- /dev/null +++ b/channels/rdpdr/client/disk/statvfs.c @@ -0,0 +1,67 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * statvfs emulation für windows + * + * Copyright 2012 Gerald Richter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "statvfs.h" +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int statvfs(const char *path, struct statvfs *buf) + { + DWORD lpSectorsPerCluster; + DWORD lpBytesPerSector; + DWORD lpNumberOfFreeClusters; + DWORD lpTotalNumberOfClusters; + + BOOL res; + + int len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); + LPWSTR unicodestr = (LPWSTR)malloc(len); // free() nicht vergessen! + MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len); + + res = GetDiskFreeSpace(unicodestr, + &lpSectorsPerCluster, + &lpBytesPerSector, + &lpNumberOfFreeClusters, + &lpTotalNumberOfClusters); + + + buf->f_bsize = lpBytesPerSector; /* file system block size */ + buf->f_frsize=0; /* fragment size */ + buf->f_blocks=lpTotalNumberOfClusters; /* size of fs in f_frsize units */ + buf->f_bfree=lpNumberOfFreeClusters; /* # free blocks */ + buf->f_bavail=lpNumberOfFreeClusters; /* # free blocks for unprivileged users */ + buf->f_files=0; /* # inodes */ + buf->f_ffree=0; /* # free inodes */ + buf->f_favail=0; /* # free inodes for unprivileged users */ + buf->f_fsid=lpNumberOfFreeClusters & 0xffff; /* file system ID */ + buf->f_flag=0; /* mount flags */ + buf->f_namemax=250; /* maximum filename length */ + + return res; + } + +#ifdef __cplusplus +} +#endif + \ No newline at end of file diff --git a/channels/rdpdr/client/disk/statvfs.h b/channels/rdpdr/client/disk/statvfs.h new file mode 100644 index 000000000..fd6fb2cf9 --- /dev/null +++ b/channels/rdpdr/client/disk/statvfs.h @@ -0,0 +1,46 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * statvfs emulation für windows + * + * Copyright 2012 Gerald Richter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long long fsblkcnt_t; +typedef unsigned long long fsfilcnt_t; + +struct statvfs { + unsigned long f_bsize; /* file system block size */ + unsigned long f_frsize; /* fragment size */ + fsblkcnt_t f_blocks; /* size of fs in f_frsize units */ + fsblkcnt_t f_bfree; /* # free blocks */ + fsblkcnt_t f_bavail; /* # free blocks for unprivileged users */ + fsfilcnt_t f_files; /* # inodes */ + fsfilcnt_t f_ffree; /* # free inodes */ + fsfilcnt_t f_favail; /* # free inodes for unprivileged users */ + unsigned long f_fsid; /* file system ID */ + unsigned long f_flag; /* mount flags */ + unsigned long f_namemax; /* maximum filename length */ +}; + + +int statvfs(const char *path, struct statvfs *buf); +#ifdef __cplusplus +} +#endif + \ No newline at end of file diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 4b05882d5..527ab1bba 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -1,48 +1,51 @@ -# FreeRDP: A Remote Desktop Protocol Client -# FreeRDP Windows cmake build script -# -# Copyright 2012 Marc-Andre Moreau -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(FREERDP_CLIENT_WINDOWS_SRCS - wf_gdi.c - wf_gdi.h - wf_event.c - wf_event.h - wf_graphics.c - wf_graphics.h - wf_cliprdr.c - wf_cliprdr.h - wf_window.c - wf_window.h - wf_rail.c - wf_rail.h - wfreerdp.c - wfreerdp.h) - -add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS}) - -if(WITH_MONOLITHIC_BUILD) - set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp) -else() - set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} - freerdp-core - freerdp-gdi - freerdp-codec - freerdp-channels - freerdp-utils) -endif() - -target_link_libraries(wfreerdp ${FREERDP_CLIENT_WINDOWS_LIBS}) -install(TARGETS wfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR}) +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP Windows cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(FREERDP_CLIENT_WINDOWS_SRCS + wf_gdi.c + wf_gdi.h + wf_event.c + wf_event.h + wf_graphics.c + wf_graphics.h + wf_cliprdr.c + wf_cliprdr.h + wf_window.c + wf_window.h + wf_rail.c + wf_rail.h + wfreerdp.c + wfreerdp.h) + +add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS}) + +if(WITH_MONOLITHIC_BUILD) + set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp) + if(WITH_RDPDR) + set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} rdpdr disk) + endif() +else() + set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} + freerdp-core + freerdp-gdi + freerdp-codec + freerdp-channels + freerdp-utils) +endif() + +target_link_libraries(wfreerdp ${FREERDP_CLIENT_WINDOWS_LIBS}) +install(TARGETS wfreerdp DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 17fc9a9ed..f44572c11 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include "wf_gdi.h" @@ -631,6 +633,12 @@ static DWORD WINAPI kbd_thread_func(LPVOID lpParam) return (DWORD) NULL; } +#ifdef WITH_RDPDR +DEFINE_SVC_PLUGIN_ENTRY(rdpdr) ; +DEFINE_DEV_PLUGIN_ENTRY(disk) ; +#endif + + INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { freerdp* instance; @@ -688,7 +696,12 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine instance->context->argc = __argc; instance->context->argv = __argv; - if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) +#ifdef WITH_RDPDR + REGISTER_SVC_PLUGIN_ENTRY(rdpdr) ; + REGISTER_DEV_PLUGIN_ENTRY(disk) ; +#endif + + if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) printf("error creating keyboard handler thread"); //while (1) diff --git a/config.h.in b/config.h.in index 74df3e656..d9c4d367a 100644 --- a/config.h.in +++ b/config.h.in @@ -27,6 +27,7 @@ #cmakedefine HAVE_TM_GMTOFF + /* Options */ #cmakedefine WITH_PROFILER #cmakedefine WITH_SSE2 @@ -35,6 +36,11 @@ #cmakedefine WITH_JPEG #cmakedefine WITH_WIN8 +/* Plugins */ +#cmakedefine WITH_STATIC_PLUGINS +#cmakedefine WITH_RDPDR + + /* Debug */ #cmakedefine WITH_DEBUG_CERTIFICATE #cmakedefine WITH_DEBUG_CHANNELS diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index 4f593d15e..7c2a06131 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -62,7 +62,13 @@ FREERDP_API int svc_plugin_send_event(rdpSvcPlugin* plugin, RDP_EVENT* event); #ifdef WITH_STATIC_PLUGINS #define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints) +#define DEFINE_DEV_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints) +#define REGISTER_SVC_PLUGIN_ENTRY(_prefix) freerdp_register_static_plugin(#_prefix, "VirtualChannelEntry", _prefix##_entry) +#define REGISTER_DEV_PLUGIN_ENTRY(_prefix) freerdp_register_static_plugin(#_prefix, "DeviceServiceEntry", _prefix##_entry) #else +#define REGISTER_DEV_PLUGIN_ENTRY(_prefix) +#define REGISTER_SVC_PLUGIN_ENTRY(_prefix) +#define DEFINE_DEV_PLUGIN_ENTRY(_prefix) #define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) #endif From 6bb2a8f6b0e8ff6c3d7664cf857e123d2daaf06a Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 09:02:17 +0200 Subject: [PATCH 51/64] win32: Add the following options for the disk plugin: disk::* will share all windows drives disk::% will share the home directory of the user In addition c+\xxx in the pathname will be replaced by c:\xxx to avoid conflicts with option separators --- channels/rdpdr/client/disk/disk_main.c | 92 +++++++++++++++++++++----- 1 file changed, 77 insertions(+), 15 deletions(-) diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index 504df2a72..bc5391f09 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -263,7 +263,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp) if (Length > 0) { - stream_check_size(irp->output, Length); + stream_check_size(irp->output, (int)Length); stream_write(irp->output, buffer, Length); } @@ -647,19 +647,23 @@ static void disk_free(DEVICE* device) xfree(disk); } -#ifdef WITH_STATIC_PLUGINS -int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) -#else -int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) -#endif -{ - char* name; - char* path; - int i, length; - DISK_DEVICE* disk; - name = (char*) pEntryPoints->plugin_data->data[1]; - path = (char*) pEntryPoints->plugin_data->data[2]; +void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char *name, char *path) +{ + DISK_DEVICE* disk; + int i, length ; + +#ifdef WIN32 + // We cannot enter pathes like c:\ because : is an arg separator + // thus, pathes are entered as c+\ and the + is substitutet here + if ( path[1] == '+' ) + { + if ( (path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z') ) + { + path[1] = ':'; + } + } +#endif if (name[0] && path[0]) { @@ -687,8 +691,66 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk); - ResumeThread(disk->thread); + ResumeThread(disk->thread); } - return 0; } + + + +#ifdef WITH_STATIC_PLUGINS +int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#else +int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#endif +{ + char* name; + char* path; + int i ; +#ifdef WIN32 + char devlist[512], buf[512]; + char *dev; + int len ; +#endif + + name = (char*) pEntryPoints->plugin_data->data[1]; + path = (char*) pEntryPoints->plugin_data->data[2]; + +#ifndef WIN32 + disk_register_disk_path(pEntryPoints, name, path); +#else + // Special case: path[0] == '*' -> export all drives + // Special case: path[0] == '%' -> user home dir + if( path[0] == '%' ) + { + _snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE")); + disk_register_disk_path(pEntryPoints, name, xstrdup(buf)); + } + else if( path[0] == '*' ) + { + // Enumerate all devices: + GetLogicalDriveStringsA(sizeof(devlist)-1, devlist); + for(dev=devlist, i=0; *dev; dev += 4, i++ ) + { + if( *dev > 'B') + { // Supress disk drives A and B to avoid pesty messages + _snprintf(buf, sizeof(buf)-4, "%s", name); + len=strlen(buf); + buf[len] = '_'; + buf[len+1] = dev[0]; + buf[len+2] = 0; + buf[len+3] = 0; + disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev)); + } + } + } + else + { + disk_register_disk_path(pEntryPoints, name, path); + } + +#endif + + return 0; + } + From f99e8e364a0895acd1eecb197bae5032f24090dc Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 09:04:58 +0200 Subject: [PATCH 52/64] win32: Fixes segfault that can occurs when a keyboard event arrives, but no main window is available (e.g. while closing the application) --- client/Windows/wf_event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index 1ee93165b..48450a806 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -56,6 +56,8 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) case WM_SYSKEYUP: wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA); p = (PKBDLLHOOKSTRUCT) lParam; + if (!wfi || !p) + return 1; input = wfi->instance->input; rdp_scancode = MAKE_RDP_SCANCODE((uint8) p->scanCode, p->flags & LLKHF_EXTENDED); From 37ca446cae74cffae7b263854e970c86ff883aa0 Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 09:10:21 +0200 Subject: [PATCH 53/64] win32: make rdpdr printer plugin working on win32 --- channels/rdpdr/client/CMakeLists.txt | 2 +- channels/rdpdr/client/printer/CMakeLists.txt | 7 + channels/rdpdr/client/printer/printer_main.c | 11 + channels/rdpdr/client/printer/printer_win.c | 283 +++++++++++++++++++ channels/rdpdr/client/printer/printer_win.h | 37 +++ client/Windows/CMakeLists.txt | 2 +- client/Windows/wfreerdp.c | 2 + 7 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 channels/rdpdr/client/printer/printer_win.c create mode 100644 channels/rdpdr/client/printer/printer_win.h diff --git a/channels/rdpdr/client/CMakeLists.txt b/channels/rdpdr/client/CMakeLists.txt index 854770647..a3fa82e1c 100644 --- a/channels/rdpdr/client/CMakeLists.txt +++ b/channels/rdpdr/client/CMakeLists.txt @@ -41,8 +41,8 @@ endif() install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) add_subdirectory(disk) +add_subdirectory(printer) if(NOT WIN32) - add_subdirectory(printer) add_subdirectory(parallel) add_subdirectory(serial) endif() diff --git a/channels/rdpdr/client/printer/CMakeLists.txt b/channels/rdpdr/client/printer/CMakeLists.txt index ea4e19fa4..91dd64863 100644 --- a/channels/rdpdr/client/printer/CMakeLists.txt +++ b/channels/rdpdr/client/printer/CMakeLists.txt @@ -31,6 +31,13 @@ if(WITH_CUPS) add_definitions(-DWITH_CUPS) endif() +if(WIN32) + set(PRINTER_SRCS + ${PRINTER_SRCS} + printer_win.c + printer_win.h) +endif() + include_directories(..) add_library(printer ${PRINTER_SRCS}) diff --git a/channels/rdpdr/client/printer/printer_main.c b/channels/rdpdr/client/printer/printer_main.c index a4db9377b..2716472cf 100644 --- a/channels/rdpdr/client/printer/printer_main.c +++ b/channels/rdpdr/client/printer/printer_main.c @@ -40,6 +40,10 @@ #include "printer_main.h" +#ifdef WIN32 +#include "printer_win.h" +#endif + typedef struct _PRINTER_DEVICE PRINTER_DEVICE; struct _PRINTER_DEVICE { @@ -294,7 +298,11 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev); } +#ifdef WITH_STATIC_PLUGINS +int printer_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#else int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) +#endif { rdpPrinterDriver* driver = NULL; rdpPrinter** printers; @@ -305,6 +313,9 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) #ifdef WITH_CUPS driver = printer_cups_get_driver(); +#endif +#ifdef WIN32 + driver = printer_win_get_driver(); #endif if (driver == NULL) { diff --git a/channels/rdpdr/client/printer/printer_win.c b/channels/rdpdr/client/printer/printer_win.c new file mode 100644 index 000000000..6b00704b4 --- /dev/null +++ b/channels/rdpdr/client/printer/printer_win.c @@ -0,0 +1,283 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * Print Virtual Channel - WIN driver + * + * Copyright 2012 Gerald Richter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include +#include + +#include "rdpdr_types.h" +#include "printer_main.h" + +#include "printer_win.h" + +typedef struct rdp_win_printer_driver rdpWinPrinterDriver; +typedef struct rdp_win_printer rdpWinPrinter; +typedef struct rdp_win_print_job rdpWinPrintJob; + +struct rdp_win_printer_driver +{ + rdpPrinterDriver driver; + + int id_sequence; +}; + +struct rdp_win_printer +{ + rdpPrinter printer; + HANDLE hPrinter; + rdpWinPrintJob* printjob; +}; + +struct rdp_win_print_job +{ + rdpPrintJob printjob; + DOC_INFO_1 di; + DWORD handle; + + void* printjob_object; + int printjob_id; +}; + +static void printer_win_get_printjob_name(char* buf, int size) +{ + time_t tt; + struct tm* t; + + DEBUG_WINPR(""); + + tt = time(NULL); + t = localtime(&tt); + snprintf(buf, size - 1, "FreeRDP Print Job %d%02d%02d%02d%02d%02d", + t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + + DEBUG_WINPR("buf: %s", buf); + +} + +static void printer_win_write_printjob(rdpPrintJob* printjob, uint8* data, int size) +{ + rdpWinPrintJob* win_printjob = (rdpWinPrintJob*)printjob; + + LPVOID pBuf = data; + DWORD cbBuf = size; + DWORD pcWritten; + + if( ! WritePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter, pBuf, cbBuf, &pcWritten ) ) + DEBUG_WINPR("WritePrinter failed"); +; + +} + +static void printer_win_close_printjob(rdpPrintJob* printjob) +{ + rdpWinPrintJob* win_printjob = (rdpWinPrintJob*)printjob; + + DEBUG_WINPR(""); + + if ( ! EndPagePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter ) ) + DEBUG_WINPR("EndPagePrinter failed");; + if ( ! ClosePrinter( ((rdpWinPrinter*)printjob->printer)->hPrinter ) ) + DEBUG_WINPR("ClosePrinter failed");; + + ((rdpWinPrinter*)printjob->printer)->printjob = NULL; + xfree(win_printjob) ; +} + +static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, uint32 id) +{ + rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; + rdpWinPrintJob* win_printjob; + + DEBUG_WINPR(""); + + if (win_printer->printjob != NULL) + return NULL; + + win_printjob = xnew(rdpWinPrintJob); + + win_printjob->printjob.id = id; + win_printjob->printjob.printer = printer; + win_printjob->di.pDocName = L"FREERDPjob"; + win_printjob->di.pDatatype= NULL; + win_printjob->di.pOutputFile = NULL; + + win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE)&(win_printjob->di) ); + if(! win_printjob->handle) DEBUG_WINPR("StartDocPrinter failed"); + if ( ! StartPagePrinter(win_printer->hPrinter) ) + DEBUG_WINPR("ClosePrinter failed"); + + + win_printjob->printjob.Write = printer_win_write_printjob; + win_printjob->printjob.Close = printer_win_close_printjob; + + + + win_printer->printjob = win_printjob; + + return (rdpPrintJob*)win_printjob; +} + +static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, uint32 id) +{ + rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; + + DEBUG_WINPR(""); + + if (win_printer->printjob == NULL) + return NULL; + if (win_printer->printjob->printjob.id != id) + return NULL; + + return (rdpPrintJob*)win_printer->printjob; +} + +static void printer_win_free_printer(rdpPrinter* printer) +{ + rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; + + DEBUG_WINPR(""); + + if (win_printer->printjob) + win_printer->printjob->printjob.Close((rdpPrintJob*)win_printer->printjob); + xfree(printer->name); + xfree(printer); +} + +static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, const char* name, const wchar_t* drivername, boolean is_default) +{ + rdpWinPrinter* win_printer; + wchar_t wname[256]; + DWORD needed; + PRINTER_INFO_2 *prninfo=NULL; + size_t charsConverted; + DEBUG_WINPR(""); + + win_printer = xnew(rdpWinPrinter); + + win_printer->printer.id = win_driver->id_sequence++; + win_printer->printer.name = xstrdup(name); + win_printer->printer.is_default = is_default; + + win_printer->printer.CreatePrintJob = printer_win_create_printjob; + win_printer->printer.FindPrintJob = printer_win_find_printjob; + win_printer->printer.Free = printer_win_free_printer; + + swprintf(wname, 256, L"%hs", name); + OpenPrinter(wname, &(win_printer->hPrinter), NULL); + DEBUG_WINPR("handle: 0x%08X", win_printer->hPrinter); + + GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, 0, &needed); + prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed); + GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, needed, &needed); + + win_printer->printer.driver = xmalloc(1000); + wcstombs_s(&charsConverted, win_printer->printer.driver, 1000, prninfo->pDriverName, _TRUNCATE); + + return (rdpPrinter*)win_printer; +} + +static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver) +{ + rdpPrinter** printers; + int num_printers; + int i; + char pname[1000]; + size_t charsConverted; + + PRINTER_INFO_2 *prninfo=NULL; + DWORD needed, returned; + + DEBUG_WINPR(""); + + + //find required size for the buffer + EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &returned); + + + //allocate array of PRINTER_INFO structures + prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed); + + //call again + if ( !EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE) prninfo, needed, &needed, &returned) ) { + DEBUG_WINPR("EnumPrinters failed"); + + } ; /* eRROR... */ + + DEBUG_WINPR("printers found: %d", returned); + + + printers = (rdpPrinter**)xzalloc(sizeof(rdpPrinter*) * (returned + 1)); + num_printers = 0; + + for (i = 0; i < (int)returned; i++) + { + wcstombs_s(&charsConverted, pname, 1000, prninfo[i].pPrinterName, _TRUNCATE); + printers[num_printers++] = printer_win_new_printer((rdpWinPrinterDriver*)driver, + pname, prninfo[i].pDriverName, 0); + } + + GlobalFree(prninfo); + return printers; +} + +static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver, const char* name) +{ + rdpWinPrinterDriver* win_driver = (rdpWinPrinterDriver*)driver; + rdpPrinter *myPrinter = NULL; + + DEBUG_WINPR("printer %s", name); + + myPrinter = printer_win_new_printer(win_driver, name, L"", win_driver->id_sequence == 1 ? true : false); + + return myPrinter; +} + +static rdpWinPrinterDriver* win_driver = NULL; + +rdpPrinterDriver* printer_win_get_driver(void) +{ + DEBUG_WINPR(""); + + if (win_driver == NULL) + { + win_driver = xnew(rdpWinPrinterDriver); + + win_driver->driver.EnumPrinters = printer_win_enum_printers; + win_driver->driver.GetPrinter = printer_win_get_printer; + + win_driver->id_sequence = 1; + +//#ifdef _win_API_1_4 +// DEBUG_SVC("using win API 1.4"); +//#else +// DEBUG_SVC("using win API 1.2"); +//#endif + } + + return (rdpPrinterDriver*)win_driver; +} + diff --git a/channels/rdpdr/client/printer/printer_win.h b/channels/rdpdr/client/printer/printer_win.h new file mode 100644 index 000000000..5b694ac40 --- /dev/null +++ b/channels/rdpdr/client/printer/printer_win.h @@ -0,0 +1,37 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * Print Virtual Channel - win driver + * + * Copyright 2012 Gerald Richter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __PRINTER_WIN_H +#define __PRINTER_WIN_H + + +rdpPrinterDriver* printer_win_get_driver(void); + +#ifdef WITH_DEBUG_WINPR +#define DEBUG_WINPR(fmt, ...) DEBUG_CLASS(WINPR, fmt, ## __VA_ARGS__) +#else +#define DEBUG_WINPR(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#endif + +#endif + +#ifdef WIN32 +#define snprintf _snprintf +#endif + diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 527ab1bba..d3ba988b8 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -36,7 +36,7 @@ add_executable(wfreerdp WIN32 ${FREERDP_CLIENT_WINDOWS_SRCS}) if(WITH_MONOLITHIC_BUILD) set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} freerdp) if(WITH_RDPDR) - set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} rdpdr disk) + set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} rdpdr disk printer) endif() else() set(FREERDP_CLIENT_WINDOWS_LIBS ${FREERDP_CLIENT_WINDOWS_LIBS} diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index f44572c11..04cfc7a35 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -636,6 +636,7 @@ static DWORD WINAPI kbd_thread_func(LPVOID lpParam) #ifdef WITH_RDPDR DEFINE_SVC_PLUGIN_ENTRY(rdpdr) ; DEFINE_DEV_PLUGIN_ENTRY(disk) ; +DEFINE_DEV_PLUGIN_ENTRY(printer) ; #endif @@ -699,6 +700,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine #ifdef WITH_RDPDR REGISTER_SVC_PLUGIN_ENTRY(rdpdr) ; REGISTER_DEV_PLUGIN_ENTRY(disk) ; + REGISTER_DEV_PLUGIN_ENTRY(printer) ; #endif if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) From 67c71112364b258053781cbf9e6f3665805ebe09 Mon Sep 17 00:00:00 2001 From: richterger Date: Tue, 2 Oct 2012 09:12:08 +0200 Subject: [PATCH 54/64] Add support for connection via http proxy Adds --proxy : commandline option Simple implementation, no proxy authentication --- include/freerdp/settings.h | 5 +++++ libfreerdp/core/transport.c | 41 ++++++++++++++++++++++++++++++++++++- libfreerdp/core/transport.h | 6 ++++++ libfreerdp/utils/args.c | 21 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 2baffa7b8..f6b079085 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -477,6 +477,11 @@ struct rdp_settings /* Extensions */ ALIGN64 int num_extensions; ALIGN64 struct rdp_ext_set extensions[16]; + + /* Proxy */ + ALIGN64 char * proxy_host; + ALIGN64 int proxy_port; + }; typedef struct rdp_settings rdpSettings; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 1073eb95f..272fc0ecd 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -204,7 +204,46 @@ boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 } else { - status = tcp_connect(transport->tcp, hostname, port); + if(transport->settings->proxy_host) + { + status = tcp_connect(transport->tcp, transport->settings->proxy_host, transport->settings->proxy_port); + if(status) + { + char buf[8192]; + int bytes_read; + int n = snprintf(buf,sizeof(buf), "CONNECT %s:%d HTTP/1.0\r\n\r\n", hostname, port); + tcp_write(transport->tcp, buf, n); + + bytes_read = tcp_read(transport->tcp, buf, sizeof(buf)); + if(bytes_read > 12) + { + if( (strncmp(buf,"HTTP/1.0 200", 12) == 0) || + (strncmp(buf,"HTTP/1.1 200", 12) == 0) ) + { + printf("Connected via proxy\n"); + while (bytes_read > 0) + { + if (bytes_read > 4 && strncmp(buf + bytes_read - 4, "\r\n\r\n", 4) == 0) + break ; + bytes_read = tcp_read(transport->tcp, buf, sizeof(buf) - 1) ; + } + } + else + { + printf("Proxy connection failed: %s\n", buf); + return false; + } + } + else + { + return false; + } + } + } + else + { + status = tcp_connect(transport->tcp, hostname, port); + } } return status; diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index e082fc44e..683d549b2 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -43,6 +43,12 @@ typedef struct rdp_transport rdpTransport; #include #include +#ifdef _WIN32 +#ifndef snprintf +#define snprintf _snprintf +#endif +#endif + typedef boolean (*TransportRecv) (rdpTransport* transport, STREAM* stream, void* extra); struct rdp_transport diff --git a/libfreerdp/utils/args.c b/libfreerdp/utils/args.c index 503af4286..d55628073 100644 --- a/libfreerdp/utils/args.c +++ b/libfreerdp/utils/args.c @@ -91,6 +91,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, { int t; char* p; + char* cp; int i, j; int index = 1; int num_extensions = 0; @@ -163,6 +164,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, " --no-salted-checksum: disable salted checksums with Standard RDP encryption\n" " --pcid: preconnection id\n" " --pcb: preconnection blob\n" + " --proxy: : connect via http proxy\n" " --version: print version information\n" "\n", argv[0]); return FREERDP_ARGS_PARSE_HELP; /* TODO: What is the correct return? */ @@ -816,6 +818,25 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("This is FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION); return FREERDP_ARGS_PARSE_VERSION; } + else if (strcmp("--proxy", argv[index]) == 0) + { + index++; + if (index == argc) + { + printf("missing proxy\n"); + return FREERDP_ARGS_PARSE_FAILURE; + } + // split in proxy and port + settings->proxy_host = xstrdup(argv[index]); + cp = strrchr(settings->proxy_host, ':'); + if( ! cp ) + { + printf("illegal proxy spec\n"); + return FREERDP_ARGS_PARSE_FAILURE; + } + *cp = 0; + settings->proxy_port = atoi(cp+1); + } else if (argv[index][0] != '-') { freerdp_parse_hostname(settings, argv[index]); From 111ab8d6c6613d398d980dfdcc31ec8d0eafaa93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 09:30:31 -0400 Subject: [PATCH 55/64] libwinpr-crt: fix compilation --- winpr/libwinpr/crt/alignment.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/winpr/libwinpr/crt/alignment.c b/winpr/libwinpr/crt/alignment.c index ce2c85647..084eef03f 100644 --- a/winpr/libwinpr/crt/alignment.c +++ b/winpr/libwinpr/crt/alignment.c @@ -39,11 +39,6 @@ void* _aligned_malloc(size_t size, size_t alignment) if (alignment % 2 == 1) return NULL; - /* offset must be less than size */ - - if (offset >= size) - return NULL; - if (posix_memalign(&memptr, alignment, size) != 0) return NULL; From 610af773b3e35947a0489b8d7c612c3ba52500cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 09:57:32 -0400 Subject: [PATCH 56/64] channels/scard: fix compilation --- .../rdpdr/client/smartcard/scard_operations.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/channels/rdpdr/client/smartcard/scard_operations.c b/channels/rdpdr/client/smartcard/scard_operations.c index 52d98c098..88bdc6358 100644 --- a/channels/rdpdr/client/smartcard/scard_operations.c +++ b/channels/rdpdr/client/smartcard/scard_operations.c @@ -28,12 +28,14 @@ #include #include #include -#include #include +#include +#define BOOL PCSC_BOOL #include #include #include +#undef BOOL #include #include @@ -1368,10 +1370,15 @@ boolean scard_async_op(IRP* irp) void scard_device_control(SCARD_DEVICE* scard, IRP* irp) { - uint32 output_len, input_len, ioctl_code; - uint32 stream_len, result; - uint32 pos, pad_len; - uint32 irp_result_pos, output_len_pos, result_pos; + uint32 pos; + uint32 result; + uint32 result_pos; + uint32 output_len; + uint32 input_len; + uint32 ioctl_code; + uint32 stream_len; + uint32 irp_result_pos; + uint32 output_len_pos; const uint32 header_lengths = 16; /* MS-RPCE, Sections 2.2.6.1 * and 2.2.6.2. */ From 84b21a61c4279c23baa7edb47f632e7fefc5344b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 10:28:04 -0400 Subject: [PATCH 57/64] libfreerdp-core: fix setting rdp->disconnect --- client/Windows/wfreerdp.c | 4 ++++ libfreerdp/core/rdp.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 04cfc7a35..60aae23c2 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -539,6 +539,10 @@ int wfreerdp_run(freerdp* instance) printf("Failed to check FreeRDP file descriptor\n"); break; } + if (freerdp_shall_disconnect(instance)) + { + break; + } if (wf_check_fds(instance) != TRUE) { printf("Failed to check wfreerdp file descriptor\n"); diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index ad5c99f22..3623c2b67 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -228,8 +228,12 @@ boolean rdp_read_header(rdpRdp* rdp, STREAM* s, uint16* length, uint16* channel_ enum DomainMCSPDU MCSPDU; MCSPDU = (rdp->settings->server_mode) ? DomainMCSPDU_SendDataRequest : DomainMCSPDU_SendDataIndication; + if (!mcs_read_domain_mcspdu_header(s, &MCSPDU, length)) - return false ; + { + if (MCSPDU != DomainMCSPDU_DisconnectProviderUltimatum) + return false; + } if (*length - 8 > stream_get_left(s)) return false; From 412f5dc452e7ce2ba270e4cfad57788c64eb7a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 10:57:39 -0400 Subject: [PATCH 58/64] freerdp: fix build on Linux --- channels/rdpdr/client/disk/CMakeLists.txt | 8 +++- channels/rdpdr/client/disk/disk_file.c | 3 ++ channels/rdpdr/client/disk/disk_file.h | 3 +- channels/rdpdr/client/disk/statvfs.c | 58 ++++++++++------------- channels/rdpdr/client/disk/statvfs.h | 12 +++-- include/freerdp/settings.h | 5 -- libfreerdp/core/transport.c | 41 +--------------- libfreerdp/core/transport.h | 6 --- libfreerdp/utils/args.c | 21 -------- 9 files changed, 45 insertions(+), 112 deletions(-) diff --git a/channels/rdpdr/client/disk/CMakeLists.txt b/channels/rdpdr/client/disk/CMakeLists.txt index b1e57878e..e19638503 100644 --- a/channels/rdpdr/client/disk/CMakeLists.txt +++ b/channels/rdpdr/client/disk/CMakeLists.txt @@ -21,10 +21,16 @@ set(MODULE_NAME "disk") set(MODULE_PREFIX "CHANNEL_DEVICE_DISK") set(${MODULE_PREFIX}_SRCS - statvfs.c disk_file.c disk_file.h disk_main.c) + +if(WIN32) + set(${MODULE_PREFIX}_SRCS + statvfs.c + statvfs.h + dirent.h) +endif() include_directories(..) diff --git a/channels/rdpdr/client/disk/disk_file.c b/channels/rdpdr/client/disk/disk_file.c index 5efead5ca..0bf28af66 100644 --- a/channels/rdpdr/client/disk/disk_file.c +++ b/channels/rdpdr/client/disk/disk_file.c @@ -119,10 +119,12 @@ static boolean disk_file_remove_dir(const char* path) boolean ret = true; dir = opendir(path); + if (dir == NULL) return false; pdirent = readdir(dir); + while (pdirent) { if (strcmp(pdirent->d_name, ".") == 0 || strcmp(pdirent->d_name, "..") == 0) @@ -175,6 +177,7 @@ static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath) xfree(file->fullpath); file->fullpath = fullpath; file->filename = strrchr(file->fullpath, '/'); + if (file->filename == NULL) file->filename = file->fullpath; else diff --git a/channels/rdpdr/client/disk/disk_file.h b/channels/rdpdr/client/disk/disk_file.h index 35db89a43..ba55f3c7c 100644 --- a/channels/rdpdr/client/disk/disk_file.h +++ b/channels/rdpdr/client/disk/disk_file.h @@ -25,12 +25,13 @@ #include #include -#include "dirent.h" #ifdef _WIN32 #include #include +#include "dirent.h" #include "statvfs.h" #else +#include #include #endif diff --git a/channels/rdpdr/client/disk/statvfs.c b/channels/rdpdr/client/disk/statvfs.c index 063b0e9f9..6ab29c4ea 100644 --- a/channels/rdpdr/client/disk/statvfs.c +++ b/channels/rdpdr/client/disk/statvfs.c @@ -17,51 +17,41 @@ * limitations under the License. */ -#include "statvfs.h" -#include #include #include -#ifdef __cplusplus -extern "C" { -#endif - +#include +#include + +#include "statvfs.h" + int statvfs(const char *path, struct statvfs *buf) - { +{ + BOOL res; + int len; + LPWSTR unicodestr; DWORD lpSectorsPerCluster; DWORD lpBytesPerSector; DWORD lpNumberOfFreeClusters; DWORD lpTotalNumberOfClusters; - - BOOL res; - int len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); - LPWSTR unicodestr = (LPWSTR)malloc(len); // free() nicht vergessen! + len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); + unicodestr = (LPWSTR) malloc(len); MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len); - res = GetDiskFreeSpace(unicodestr, - &lpSectorsPerCluster, - &lpBytesPerSector, - &lpNumberOfFreeClusters, - &lpTotalNumberOfClusters); + res = GetDiskFreeSpace(unicodestr, &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters); - - buf->f_bsize = lpBytesPerSector; /* file system block size */ - buf->f_frsize=0; /* fragment size */ - buf->f_blocks=lpTotalNumberOfClusters; /* size of fs in f_frsize units */ - buf->f_bfree=lpNumberOfFreeClusters; /* # free blocks */ - buf->f_bavail=lpNumberOfFreeClusters; /* # free blocks for unprivileged users */ - buf->f_files=0; /* # inodes */ - buf->f_ffree=0; /* # free inodes */ - buf->f_favail=0; /* # free inodes for unprivileged users */ - buf->f_fsid=lpNumberOfFreeClusters & 0xffff; /* file system ID */ - buf->f_flag=0; /* mount flags */ - buf->f_namemax=250; /* maximum filename length */ + buf->f_bsize = lpBytesPerSector; /* file system block size */ + buf->f_frsize = 0; /* fragment size */ + buf->f_blocks = lpTotalNumberOfClusters; /* size of fs in f_frsize units */ + buf->f_bfree = lpNumberOfFreeClusters; /* # free blocks */ + buf->f_bavail = lpNumberOfFreeClusters; /* # free blocks for unprivileged users */ + buf->f_files = 0; /* # inodes */ + buf->f_ffree = 0; /* # free inodes */ + buf->f_favail = 0; /* # free inodes for unprivileged users */ + buf->f_fsid = lpNumberOfFreeClusters & 0xffff; /* file system ID */ + buf->f_flag = 0; /* mount flags */ + buf->f_namemax = 250; /* maximum filename length */ return res; - } - -#ifdef __cplusplus -} -#endif - \ No newline at end of file +} diff --git a/channels/rdpdr/client/disk/statvfs.h b/channels/rdpdr/client/disk/statvfs.h index fd6fb2cf9..a38dc71dc 100644 --- a/channels/rdpdr/client/disk/statvfs.h +++ b/channels/rdpdr/client/disk/statvfs.h @@ -1,6 +1,6 @@ /** * FreeRDP: A Remote Desktop Protocol client. - * statvfs emulation für windows + * statvfs emulation for windows * * Copyright 2012 Gerald Richter * @@ -17,10 +17,13 @@ * limitations under the License. */ +#ifndef RDPDR_DISK_STATVFS_H +#define RDPDR_DISK_STATVFS_H + #ifdef __cplusplus extern "C" { #endif - + typedef unsigned long long fsblkcnt_t; typedef unsigned long long fsfilcnt_t; @@ -38,9 +41,10 @@ struct statvfs { unsigned long f_namemax; /* maximum filename length */ }; - int statvfs(const char *path, struct statvfs *buf); + #ifdef __cplusplus } #endif - \ No newline at end of file + +#endif /* RDPDR_DISK_STATVFS_H */ diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index f6b079085..2baffa7b8 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -477,11 +477,6 @@ struct rdp_settings /* Extensions */ ALIGN64 int num_extensions; ALIGN64 struct rdp_ext_set extensions[16]; - - /* Proxy */ - ALIGN64 char * proxy_host; - ALIGN64 int proxy_port; - }; typedef struct rdp_settings rdpSettings; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 272fc0ecd..1073eb95f 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -204,46 +204,7 @@ boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 } else { - if(transport->settings->proxy_host) - { - status = tcp_connect(transport->tcp, transport->settings->proxy_host, transport->settings->proxy_port); - if(status) - { - char buf[8192]; - int bytes_read; - int n = snprintf(buf,sizeof(buf), "CONNECT %s:%d HTTP/1.0\r\n\r\n", hostname, port); - tcp_write(transport->tcp, buf, n); - - bytes_read = tcp_read(transport->tcp, buf, sizeof(buf)); - if(bytes_read > 12) - { - if( (strncmp(buf,"HTTP/1.0 200", 12) == 0) || - (strncmp(buf,"HTTP/1.1 200", 12) == 0) ) - { - printf("Connected via proxy\n"); - while (bytes_read > 0) - { - if (bytes_read > 4 && strncmp(buf + bytes_read - 4, "\r\n\r\n", 4) == 0) - break ; - bytes_read = tcp_read(transport->tcp, buf, sizeof(buf) - 1) ; - } - } - else - { - printf("Proxy connection failed: %s\n", buf); - return false; - } - } - else - { - return false; - } - } - } - else - { - status = tcp_connect(transport->tcp, hostname, port); - } + status = tcp_connect(transport->tcp, hostname, port); } return status; diff --git a/libfreerdp/core/transport.h b/libfreerdp/core/transport.h index 683d549b2..e082fc44e 100644 --- a/libfreerdp/core/transport.h +++ b/libfreerdp/core/transport.h @@ -43,12 +43,6 @@ typedef struct rdp_transport rdpTransport; #include #include -#ifdef _WIN32 -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - typedef boolean (*TransportRecv) (rdpTransport* transport, STREAM* stream, void* extra); struct rdp_transport diff --git a/libfreerdp/utils/args.c b/libfreerdp/utils/args.c index d55628073..503af4286 100644 --- a/libfreerdp/utils/args.c +++ b/libfreerdp/utils/args.c @@ -91,7 +91,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, { int t; char* p; - char* cp; int i, j; int index = 1; int num_extensions = 0; @@ -164,7 +163,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, " --no-salted-checksum: disable salted checksums with Standard RDP encryption\n" " --pcid: preconnection id\n" " --pcb: preconnection blob\n" - " --proxy: : connect via http proxy\n" " --version: print version information\n" "\n", argv[0]); return FREERDP_ARGS_PARSE_HELP; /* TODO: What is the correct return? */ @@ -818,25 +816,6 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("This is FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION); return FREERDP_ARGS_PARSE_VERSION; } - else if (strcmp("--proxy", argv[index]) == 0) - { - index++; - if (index == argc) - { - printf("missing proxy\n"); - return FREERDP_ARGS_PARSE_FAILURE; - } - // split in proxy and port - settings->proxy_host = xstrdup(argv[index]); - cp = strrchr(settings->proxy_host, ':'); - if( ! cp ) - { - printf("illegal proxy spec\n"); - return FREERDP_ARGS_PARSE_FAILURE; - } - *cp = 0; - settings->proxy_port = atoi(cp+1); - } else if (argv[index][0] != '-') { freerdp_parse_hostname(settings, argv[index]); From 5126e393ee81d5ca8a70e2f7ad52f52560af585e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 11:11:11 -0400 Subject: [PATCH 59/64] channels/rdpdr: fix warning --- channels/rdpdr/client/disk/disk_main.c | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index bc5391f09..0df444f61 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -706,7 +706,6 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { char* name; char* path; - int i ; #ifdef WIN32 char devlist[512], buf[512]; char *dev; @@ -719,8 +718,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) #ifndef WIN32 disk_register_disk_path(pEntryPoints, name, path); #else - // Special case: path[0] == '*' -> export all drives - // Special case: path[0] == '%' -> user home dir + /* Special case: path[0] == '*' -> export all drives */ + /* Special case: path[0] == '%' -> user home dir */ if( path[0] == '%' ) { _snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE")); @@ -728,19 +727,23 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) } else if( path[0] == '*' ) { - // Enumerate all devices: - GetLogicalDriveStringsA(sizeof(devlist)-1, devlist); - for(dev=devlist, i=0; *dev; dev += 4, i++ ) + int i; + + /* Enumerate all devices: */ + GetLogicalDriveStringsA(sizeof(devlist) - 1, devlist); + + for (dev = devlist, i = 0; *dev; dev += 4, i++) { - if( *dev > 'B') - { // Supress disk drives A and B to avoid pesty messages - _snprintf(buf, sizeof(buf)-4, "%s", name); - len=strlen(buf); - buf[len] = '_'; - buf[len+1] = dev[0]; - buf[len+2] = 0; - buf[len+3] = 0; - disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev)); + if (*dev > 'B') + { + /* Suppress disk drives A and B to avoid pesty messages */ + _snprintf(buf, sizeof(buf) - 4, "%s", name); + len = strlen(buf); + buf[len] = '_'; + buf[len + 1] = dev[0]; + buf[len + 2] = 0; + buf[len + 3] = 0; + disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev)); } } } @@ -748,7 +751,6 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { disk_register_disk_path(pEntryPoints, name, path); } - #endif return 0; From ab7c952d80ea3a290c6dd0efe12039436e3dad42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 11:16:40 -0400 Subject: [PATCH 60/64] channels: code style cleanup --- channels/rdpdr/client/disk/disk_main.c | 9 ++++----- winpr/libwinpr/crt/CMakeLists.txt | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/channels/rdpdr/client/disk/disk_main.c b/channels/rdpdr/client/disk/disk_main.c index 0df444f61..f5fc3e508 100644 --- a/channels/rdpdr/client/disk/disk_main.c +++ b/channels/rdpdr/client/disk/disk_main.c @@ -654,8 +654,10 @@ void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char *na int i, length ; #ifdef WIN32 - // We cannot enter pathes like c:\ because : is an arg separator - // thus, pathes are entered as c+\ and the + is substitutet here + /* + * We cannot enter paths like c:\ because : is an arg separator + * thus, paths are entered as c+\ and the + is substituted here + */ if ( path[1] == '+' ) { if ( (path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z') ) @@ -696,8 +698,6 @@ void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char *na } - - #ifdef WITH_STATIC_PLUGINS int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) #else @@ -755,4 +755,3 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) return 0; } - diff --git a/winpr/libwinpr/crt/CMakeLists.txt b/winpr/libwinpr/crt/CMakeLists.txt index bc8a74907..20074470b 100644 --- a/winpr/libwinpr/crt/CMakeLists.txt +++ b/winpr/libwinpr/crt/CMakeLists.txt @@ -42,4 +42,3 @@ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR") if(BUILD_TESTING) add_subdirectory(test) endif() - From 59016f1c6f743efb2f5c2d57feaec845964d0443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 11:56:10 -0400 Subject: [PATCH 61/64] cmake: disable test build by default --- CMakeLists.txt | 1 - cmake/ConfigOptions.cmake | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80c8f382e..e5eaa9a8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,6 @@ if(MSVC) configure_msvc_runtime() endif() - # Compiler-specific flags if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 76fa33a3b..908caddfd 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -15,6 +15,8 @@ if(MSVC) option(WITH_WIN8 "Use Windows 8 libraries" OFF) endif() +option(BUILD_TESTING "Build unit tests" OFF) + if(${CMAKE_VERSION} VERSION_GREATER 2.8.8) option(WITH_MONOLITHIC_BUILD "Use monolithic build" OFF) endif() From dda32388ffd7fac359628cdf0bce5445e674794f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 16:54:14 -0400 Subject: [PATCH 62/64] urbdrc: move USB redirection code --- channels/drdynvc/CMakeLists.txt | 20 - channels/drdynvc/client/drdynvc_types.h | 1 + channels/drdynvc/client/dvcman.h | 1 + channels/drdynvc/urbdrc/urbdrc_types.h | 355 ------------------ channels/urbdrc/CMakeLists.txt | 24 ++ channels/urbdrc/ChannelOptions.cmake | 15 + .../urbdrc => urbdrc/client}/CMakeLists.txt | 5 +- .../urbdrc => urbdrc/client}/data_transfer.c | 0 .../urbdrc => urbdrc/client}/data_transfer.h | 0 .../urbdrc => urbdrc/client}/isoch_queue.c | 0 .../urbdrc => urbdrc/client}/isoch_queue.h | 0 .../urbdrc => urbdrc/client}/searchman.c | 0 .../urbdrc => urbdrc/client}/searchman.h | 0 .../urbdrc => urbdrc/client}/urbdrc_main.c | 4 +- .../urbdrc => urbdrc/client}/urbdrc_main.h | 44 +-- channels/urbdrc/client/urbdrc_types.h | 337 +++++++++++++++++ .../urbdrc/libusb/CMakeLists.txt | 6 +- .../urbdrc/libusb/libusb_udevice.c | 0 .../urbdrc/libusb/libusb_udevice.h | 0 .../urbdrc/libusb/libusb_udevman.c | 0 .../urbdrc/libusb/request_queue.c | 0 .../urbdrc/libusb/request_queue.h | 0 22 files changed, 403 insertions(+), 409 deletions(-) delete mode 100644 channels/drdynvc/urbdrc/urbdrc_types.h create mode 100644 channels/urbdrc/CMakeLists.txt create mode 100644 channels/urbdrc/ChannelOptions.cmake rename channels/{drdynvc/urbdrc => urbdrc/client}/CMakeLists.txt (96%) rename channels/{drdynvc/urbdrc => urbdrc/client}/data_transfer.c (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/data_transfer.h (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/isoch_queue.c (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/isoch_queue.h (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/searchman.c (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/searchman.h (100%) rename channels/{drdynvc/urbdrc => urbdrc/client}/urbdrc_main.c (99%) rename channels/{drdynvc/urbdrc => urbdrc/client}/urbdrc_main.h (94%) create mode 100644 channels/urbdrc/client/urbdrc_types.h rename channels/{drdynvc => }/urbdrc/libusb/CMakeLists.txt (96%) rename channels/{drdynvc => }/urbdrc/libusb/libusb_udevice.c (100%) rename channels/{drdynvc => }/urbdrc/libusb/libusb_udevice.h (100%) rename channels/{drdynvc => }/urbdrc/libusb/libusb_udevman.c (100%) rename channels/{drdynvc => }/urbdrc/libusb/request_queue.c (100%) rename channels/{drdynvc => }/urbdrc/libusb/request_queue.h (100%) diff --git a/channels/drdynvc/CMakeLists.txt b/channels/drdynvc/CMakeLists.txt index 9637fdac0..676de4e85 100644 --- a/channels/drdynvc/CMakeLists.txt +++ b/channels/drdynvc/CMakeLists.txt @@ -15,27 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(DRDYNVC_SRCS - drdynvc_main.c - drdynvc_main.h - drdynvc_types.h - dvcman.c - dvcman.h -) - -add_library(drdynvc ${DRDYNVC_SRCS}) -set_target_properties(drdynvc PROPERTIES PREFIX "") - -target_link_libraries(drdynvc freerdp-utils) - -install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) - -add_subdirectory(tsmf) -add_subdirectory(audin) -add_subdirectory(urbdrc) - if(WITH_CLIENT_CHANNELS) add_subdirectory(client) endif() - diff --git a/channels/drdynvc/client/drdynvc_types.h b/channels/drdynvc/client/drdynvc_types.h index e19d0d1b5..1591f4766 100644 --- a/channels/drdynvc/client/drdynvc_types.h +++ b/channels/drdynvc/client/drdynvc_types.h @@ -36,3 +36,4 @@ #endif #endif + diff --git a/channels/drdynvc/client/dvcman.h b/channels/drdynvc/client/dvcman.h index 679243f30..0e0bb9ce2 100644 --- a/channels/drdynvc/client/dvcman.h +++ b/channels/drdynvc/client/dvcman.h @@ -33,3 +33,4 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, ui int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId, uint8* data, uint32 data_size); #endif + diff --git a/channels/drdynvc/urbdrc/urbdrc_types.h b/channels/drdynvc/urbdrc/urbdrc_types.h deleted file mode 100644 index 38fbb4e1a..000000000 --- a/channels/drdynvc/urbdrc/urbdrc_types.h +++ /dev/null @@ -1,355 +0,0 @@ -/** - * FreeRDP: A Remote Desktop Protocol client. - * RemoteFX USB Redirection - * - * Copyright 2012 Atrust corp. - * Copyright 2012 Alfred Liu - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#ifndef __URBDRC_TYPES_H -#define __URBDRC_TYPES_H - - -#include "config.h" -#include -#include -#include -#include -#include -#include "drdynvc_types.h" - -#include -#include -#include - -#define CAPABILITIES_NEGOTIATOR 0x00000000 -#define CLIENT_DEVICE_SINK 0x00000001 -#define SERVER_CHANNEL_NOTIFICATION 0x00000002 -#define CLIENT_CHANNEL_NOTIFICATION 0x00000003 -#define BASE_USBDEVICE_NUM 0x00000005 - -#define RIMCALL_RELEASE 0x00000001 -#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100 -#define CHANNEL_CREATED 0x00000100 -#define ADD_VIRTUAL_CHANNEL 0x00000100 -#define ADD_DEVICE 0x00000101 - - -#define INIT_CHANNEL_IN 1 -#define INIT_CHANNEL_OUT 0 - - -/* InterfaceClass */ -#define CLASS_RESERVE 0x00 -#define CLASS_AUDIO 0x01 -#define CLASS_COMMUNICATION_IF 0x02 -#define CLASS_HID 0x03 -#define CLASS_PHYSICAL 0x05 -#define CLASS_IMAGE 0x06 -#define CLASS_PRINTER 0x07 -#define CLASS_MASS_STORAGE 0x08 -#define CLASS_HUB 0x09 -#define CLASS_COMMUNICATION_DATA_IF 0x0a -#define CLASS_SMART_CARD 0x0b -#define CLASS_CONTENT_SECURITY 0x0d -#define CLASS_VIDEO 0x0e -#define CLASS_PERSONAL_HEALTHCARE 0x0f -#define CLASS_DIAGNOSTIC 0xdc -#define CLASS_WIRELESS_CONTROLLER 0xe0 -#define CLASS_ELSE_DEVICE 0xef -#define CLASS_DEPENDENCE 0xfe -#define CLASS_VENDOR_DEPENDENCE 0xff - - -/* usb version */ -#define USB_v1_0 0x100 -#define USB_v1_1 0x110 -#define USB_v2_0 0x200 -#define USB_v3_0 0x300 - -#define STREAM_ID_NONE 0x0 -#define STREAM_ID_PROXY 0x1 -#define STREAM_ID_STUB 0x2 - -#define CANCEL_REQUEST 0x00000100 -#define REGISTER_REQUEST_CALLBACK 0x00000101 -#define IO_CONTROL 0x00000102 -#define INTERNAL_IO_CONTROL 0x00000103 -#define QUERY_DEVICE_TEXT 0x00000104 -#define TRANSFER_IN_REQUEST 0x00000105 -#define TRANSFER_OUT_REQUEST 0x00000106 -#define RETRACT_DEVICE 0x00000107 - - -#define IOCONTROL_COMPLETION 0x00000100 -#define URB_COMPLETION 0x00000101 -#define URB_COMPLETION_NO_DATA 0x00000102 - -/* The USB device is to be stopped from being redirected because the - * device is blocked by the server's policy. */ -#define UsbRetractReason_BlockedByPolicy 0x00000001 - - - -enum device_text_type { - DeviceTextDescription = 0, - DeviceTextLocationInformation = 1, -}; - -enum device_descriptor_table { - B_LENGTH = 0, - B_DESCRIPTOR_TYPE = 1, - BCD_USB = 2, - B_DEVICE_CLASS = 4, - B_DEVICE_SUBCLASS = 5, - B_DEVICE_PROTOCOL = 6, - B_MAX_PACKET_SIZE0 = 7, - ID_VENDOR = 8, - ID_PRODUCT = 10, - BCD_DEVICE = 12, - I_MANUFACTURER = 14, - I_PRODUCT = 15, - I_SERIAL_NUMBER = 16, - B_NUM_CONFIGURATIONS = 17 -}; - - -#define PIPE_CANCEL 0 -#define PIPE_RESET 1 - -#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003 -#define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007 -#define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013 -#define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F -#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027 - - - -#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000 -#define URB_FUNCTION_SELECT_INTERFACE 0x0001 -#define URB_FUNCTION_ABORT_PIPE 0x0002 -#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003 -#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004 -#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005 -#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006 -#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007 -#define URB_FUNCTION_CONTROL_TRANSFER 0x0008 -#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 -#define URB_FUNCTION_ISOCH_TRANSFER 0x000A -#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B -#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C -#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D -#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E -#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F -#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010 -#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011 -#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012 -#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013 -#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014 -#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015 -#define URB_FUNCTION_RESERVED_0X0016 0x0016 -#define URB_FUNCTION_VENDOR_DEVICE 0x0017 -#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 -#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 -#define URB_FUNCTION_CLASS_DEVICE 0x001A -#define URB_FUNCTION_CLASS_INTERFACE 0x001B -#define URB_FUNCTION_CLASS_ENDPOINT 0x001C -#define URB_FUNCTION_RESERVE_0X001D 0x001D -#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E -#define URB_FUNCTION_CLASS_OTHER 0x001F -#define URB_FUNCTION_VENDOR_OTHER 0x0020 -#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021 -#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022 -#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023 -#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024 -#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025 -#define URB_FUNCTION_GET_CONFIGURATION 0x0026 -#define URB_FUNCTION_GET_INTERFACE 0x0027 -#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028 -#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029 -#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A -#define URB_FUNCTION_RESERVE_0X002B 0x002B -#define URB_FUNCTION_RESERVE_0X002C 0x002C -#define URB_FUNCTION_RESERVE_0X002D 0x002D -#define URB_FUNCTION_RESERVE_0X002E 0x002E -#define URB_FUNCTION_RESERVE_0X002F 0x002F -// USB 2.0 calls start at 0x0030 -#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030 -#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031 -#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032 - - - - -#define USBD_STATUS_SUCCESS 0x0 -#define USBD_STATUS_PENDING 0x40000000 -#define USBD_STATUS_CANCELED 0xC0010000 - -#define USBD_STATUS_CRC 0xC0000001 -#define USBD_STATUS_BTSTUFF 0xC0000002 -#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003 -#define USBD_STATUS_STALL_PID 0xC0000004 -#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005 -#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006 -#define USBD_STATUS_UNEXPECTED_PID 0xC0000007 -#define USBD_STATUS_DATA_OVERRUN 0xC0000008 -#define USBD_STATUS_DATA_UNDERRUN 0xC0000009 -#define USBD_STATUS_RESERVED1 0xC000000A -#define USBD_STATUS_RESERVED2 0xC000000B -#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C -#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D - -/* unknow */ -#define USBD_STATUS_NO_DATA 0xC000000E - -#define USBD_STATUS_NOT_ACCESSED 0xC000000F -#define USBD_STATUS_FIFO 0xC0000010 -#define USBD_STATUS_XACT_ERROR 0xC0000011 -#define USBD_STATUS_BABBLE_DETECTED 0xC0000012 -#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013 - -#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00 -#define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000 -#define USBD_STATUS_TIMEOUT 0xC0006000 -#define USBD_STATUS_DEVICE_GONE 0xC0007000 - -#define USBD_STATUS_NO_MEMORY 0x80000100 -#define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200 -#define USBD_STATUS_INVALID_PARAMETER 0x80000300 -#define USBD_STATUS_REQUEST_FAILED 0x80000500 -#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600 -#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900 - -// Values for URB TransferFlags Field -// - -/* - Set if data moves device->host -*/ -#define USBD_TRANSFER_DIRECTION 0x00000001 -/* - This bit if not set indicates that a short packet, and hence, - a short transfer is an error condition -*/ -#define USBD_SHORT_TRANSFER_OK 0x00000002 -/* - Subit the iso transfer on the next frame -*/ -#define USBD_START_ISO_TRANSFER_ASAP 0x00000004 -#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008 - - -#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) & USBD_TRANSFER_DIRECTION) - -#define USBD_TRANSFER_DIRECTION_OUT 0 -#define USBD_TRANSFER_DIRECTION_IN 1 - -#define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \ - USBD_TRANSFER_DIRECTION | \ - USBD_START_ISO_TRANSFER_ASAP | \ - USBD_DEFAULT_PIPE_TRANSFER) - - - - -#define ENDPOINT_HALT 0x00 -#define DEVICE_REMOTE_WAKEUP 0x01 - - -/* transfer type */ -#define CONTROL_TRANSFER 0x00 -#define ISOCHRONOUS_TRANSFER 0x01 -#define BULK_TRANSFER 0x02 -#define INTERRUPT_TRANSFER 0x03 - - - -#define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE) -#define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE) -#define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR) -#define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS) -#define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS) -#define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE) -#define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE) - - - -#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 -#define USBD_PF_SHORT_PACKET_OPT 0x00000002 -#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 -#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 - -/* feature request */ -#define URB_SET_FEATURE 0x00 -#define URB_CLEAR_FEATURE 0x01 - -#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 -#define USBD_PF_SHORT_PACKET_OPT 0x00000002 -#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 -#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 - - -#define URB_CONTROL_TRANSFER_EXTERNAL 0x1 -#define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0 - - -#define USBFS_URB_SHORT_NOT_OK 0x01 -#define USBFS_URB_ISO_ASAP 0x02 -#define USBFS_URB_BULK_CONTINUATION 0x04 -#define USBFS_URB_QUEUE_BULK 0x10 - - -#define URBDRC_DEVICE_INITIALIZED 0x01 -#define URBDRC_DEVICE_NOT_FOUND 0x02 -#define URBDRC_DEVICE_SIGNAL_END 0x04 -#define URBDRC_DEVICE_CHANNEL_CLOSED 0x08 -#define URBDRC_DEVICE_ALREADY_SEND 0x10 -#define URBDRC_DEVICE_DETACH_KERNEL 0x20 - - -#define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01 -#define UDEVMAN_FLAG_ADD_BY_ADDR 0x02 -#define UDEVMAN_FLAG_ADD_BY_AUTO 0x04 -#define UDEVMAN_FLAG_DEBUG 0x08 - - -#define MAX_URB_REQUSET_NUM 0x80 - - -#define LOG_LEVEL 1 -#define LLOG(_level, _args) \ - do { if (_level < LOG_LEVEL) { printf _args ; } } while (0) -#define LLOGLN(_level, _args) \ - do { if (_level < LOG_LEVEL) { printf _args ; printf("\n"); } } while (0) - - -#define dummy_wait_obj(void) do{ sleep(5); } while(0) -#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0) - -#define ISOCH_FIFO 1 -#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */ - -#define urbdrc_get_mstime(_t) do { \ - struct timeval _tp; \ - gettimeofday(&_tp, 0); \ - _t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \ -} while (0) - - -extern int urbdrc_debug; - -#endif /* __URBDRC_TYPES_H */ diff --git a/channels/urbdrc/CMakeLists.txt b/channels/urbdrc/CMakeLists.txt new file mode 100644 index 000000000..f49c8bedc --- /dev/null +++ b/channels/urbdrc/CMakeLists.txt @@ -0,0 +1,24 @@ +# FreeRDP: A Remote Desktop Protocol Client +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +add_subdirectory(libusb) + +if(WITH_CLIENT_CHANNELS) + add_subdirectory(client) +endif() + + diff --git a/channels/urbdrc/ChannelOptions.cmake b/channels/urbdrc/ChannelOptions.cmake new file mode 100644 index 000000000..78a631eed --- /dev/null +++ b/channels/urbdrc/ChannelOptions.cmake @@ -0,0 +1,15 @@ + +set(CHANNEL_TYPE "dynamic") +set(CHANNEL_SHORT_NAME "urbdrc") +set(CHANNEL_LONG_NAME "USB Devices Virtual Channel Extension") +set(CHANNEL_SPECIFICATIONS "[MS-RDPEUSB]") + +string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) + +if(WIN32) + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) +else() + option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) +endif() + + diff --git a/channels/drdynvc/urbdrc/CMakeLists.txt b/channels/urbdrc/client/CMakeLists.txt similarity index 96% rename from channels/drdynvc/urbdrc/CMakeLists.txt rename to channels/urbdrc/client/CMakeLists.txt index 627bf8704..ce8087e8c 100644 --- a/channels/drdynvc/urbdrc/CMakeLists.txt +++ b/channels/urbdrc/client/CMakeLists.txt @@ -25,8 +25,7 @@ set(URBDRC_SRCS data_transfer.h urbdrc_main.c urbdrc_main.h - urbdrc_types.h -) + urbdrc_types.h) include_directories(..) @@ -41,5 +40,3 @@ target_link_libraries(urbdrc freerdp-utils) install(TARGETS urbdrc DESTINATION ${FREERDP_PLUGIN_PATH}) -add_subdirectory(libusb) - diff --git a/channels/drdynvc/urbdrc/data_transfer.c b/channels/urbdrc/client/data_transfer.c similarity index 100% rename from channels/drdynvc/urbdrc/data_transfer.c rename to channels/urbdrc/client/data_transfer.c diff --git a/channels/drdynvc/urbdrc/data_transfer.h b/channels/urbdrc/client/data_transfer.h similarity index 100% rename from channels/drdynvc/urbdrc/data_transfer.h rename to channels/urbdrc/client/data_transfer.h diff --git a/channels/drdynvc/urbdrc/isoch_queue.c b/channels/urbdrc/client/isoch_queue.c similarity index 100% rename from channels/drdynvc/urbdrc/isoch_queue.c rename to channels/urbdrc/client/isoch_queue.c diff --git a/channels/drdynvc/urbdrc/isoch_queue.h b/channels/urbdrc/client/isoch_queue.h similarity index 100% rename from channels/drdynvc/urbdrc/isoch_queue.h rename to channels/urbdrc/client/isoch_queue.h diff --git a/channels/drdynvc/urbdrc/searchman.c b/channels/urbdrc/client/searchman.c similarity index 100% rename from channels/drdynvc/urbdrc/searchman.c rename to channels/urbdrc/client/searchman.c diff --git a/channels/drdynvc/urbdrc/searchman.h b/channels/urbdrc/client/searchman.h similarity index 100% rename from channels/drdynvc/urbdrc/searchman.h rename to channels/urbdrc/client/searchman.h diff --git a/channels/drdynvc/urbdrc/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c similarity index 99% rename from channels/drdynvc/urbdrc/urbdrc_main.c rename to channels/urbdrc/client/urbdrc_main.c index e2e1e8efb..4b269015a 100644 --- a/channels/drdynvc/urbdrc/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -25,10 +25,10 @@ #include #include +#include #include #include "urbdrc_types.h" -#include "dvcman.h" #include "urbdrc_main.h" #include "data_transfer.h" #include "searchman.h" @@ -479,7 +479,7 @@ urbdrc_search_usb_device(void * arg) udev_monitor_enable_receiving(mon); /* Get the file descriptor (fd) for the monitor. This fd will get passed to select() */ - mon_fd = wait_obj_new_with_fd((void *)udev_monitor_get_fd(mon)); + mon_fd = wait_obj_new_with_fd((void*) (size_t) udev_monitor_get_fd(mon)); while (1) { diff --git a/channels/drdynvc/urbdrc/urbdrc_main.h b/channels/urbdrc/client/urbdrc_main.h similarity index 94% rename from channels/drdynvc/urbdrc/urbdrc_main.h rename to channels/urbdrc/client/urbdrc_main.h index 146e8a4fe..ff71869be 100644 --- a/channels/drdynvc/urbdrc/urbdrc_main.h +++ b/channels/urbdrc/client/urbdrc_main.h @@ -27,11 +27,10 @@ #include "isoch_queue.h" #define DEVICE_HARDWARE_ID_SIZE 32 -#define DEVICE_COMPATIBILITY_ID_SIZE 36 +#define DEVICE_COMPATIBILITY_ID_SIZE 36 #define DEVICE_INSTANCE_STR_SIZE 37 #define DEVICE_CONTAINER_STR_SIZE 39 - typedef struct _IUDEVICE IUDEVICE; typedef struct _IUDEVMAN IUDEVMAN; @@ -42,40 +41,41 @@ typedef struct _IUDEVMAN IUDEVMAN; _type (*get_##_arg) (IUDEVMAN *udevman); \ void (*set_##_arg) (IUDEVMAN *udevman, _type _arg) - typedef struct _URBDRC_LISTENER_CALLBACK URBDRC_LISTENER_CALLBACK; + struct _URBDRC_LISTENER_CALLBACK { IWTSListenerCallback iface; - IWTSPlugin * plugin; - IWTSVirtualChannelManager * channel_mgr; + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; }; typedef struct _URBDRC_CHANNEL_CALLBACK URBDRC_CHANNEL_CALLBACK; + struct _URBDRC_CHANNEL_CALLBACK { IWTSVirtualChannelCallback iface; - IWTSPlugin * plugin; - IWTSVirtualChannelManager * channel_mgr; - IWTSVirtualChannel * channel; + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + IWTSVirtualChannel* channel; }; typedef struct _URBDRC_PLUGIN URBDRC_PLUGIN; + struct _URBDRC_PLUGIN { IWTSPlugin iface; - URBDRC_LISTENER_CALLBACK * listener_callback; + URBDRC_LISTENER_CALLBACK* listener_callback; - IUDEVMAN * udevman; - USB_SEARCHMAN * searchman; + IUDEVMAN* udevman; + USB_SEARCHMAN* searchman; uint32 first_channel_id; uint32 vchannel_status; }; - #define URBDRC_UDEVMAN_EXPORT_FUNC_NAME "FreeRDPUDEVMANEntry" typedef void (*PREGISTERURBDRCSERVICE)(IWTSPlugin* plugin, IUDEVMAN* udevman); @@ -91,21 +91,18 @@ typedef FREERDP_URBDRC_SERVICE_ENTRY_POINTS* PFREERDP_URBDRC_SERVICE_ENTRY_POINT typedef int (*PFREERDP_URBDRC_DEVICE_ENTRY)(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS pEntryPoints); - - - typedef struct _TRANSFER_DATA TRANSFER_DATA; + struct _TRANSFER_DATA { - URBDRC_CHANNEL_CALLBACK * callback; - URBDRC_PLUGIN * urbdrc; - IUDEVMAN * udevman; - uint8 * pBuffer; - uint32 cbSize; - uint32 UsbDevice; + URBDRC_CHANNEL_CALLBACK* callback; + URBDRC_PLUGIN* urbdrc; + IUDEVMAN* udevman; + uint8* pBuffer; + uint32 cbSize; + uint32 UsbDevice; }; - struct _IUDEVICE { /* Transfer */ @@ -228,8 +225,6 @@ struct _IUDEVICE }; - - struct _IUDEVMAN { /* Standard */ @@ -265,5 +260,4 @@ struct _IUDEVMAN void (*wait_urb) (IUDEVMAN * idevman); }; - #endif /* __URBDRC_MAIN_H */ diff --git a/channels/urbdrc/client/urbdrc_types.h b/channels/urbdrc/client/urbdrc_types.h new file mode 100644 index 000000000..b392b9ddd --- /dev/null +++ b/channels/urbdrc/client/urbdrc_types.h @@ -0,0 +1,337 @@ +/** + * FreeRDP: A Remote Desktop Protocol client. + * RemoteFX USB Redirection + * + * Copyright 2012 Atrust corp. + * Copyright 2012 Alfred Liu + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __URBDRC_TYPES_H +#define __URBDRC_TYPES_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef WITH_DEBUG_DVC +#define DEBUG_DVC(fmt, ...) DEBUG_CLASS(DVC, fmt, ## __VA_ARGS__) +#else +#define DEBUG_DVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) +#endif + +#define CAPABILITIES_NEGOTIATOR 0x00000000 +#define CLIENT_DEVICE_SINK 0x00000001 +#define SERVER_CHANNEL_NOTIFICATION 0x00000002 +#define CLIENT_CHANNEL_NOTIFICATION 0x00000003 +#define BASE_USBDEVICE_NUM 0x00000005 + +#define RIMCALL_RELEASE 0x00000001 +#define RIM_EXCHANGE_CAPABILITY_REQUEST 0x00000100 +#define CHANNEL_CREATED 0x00000100 +#define ADD_VIRTUAL_CHANNEL 0x00000100 +#define ADD_DEVICE 0x00000101 + +#define INIT_CHANNEL_IN 1 +#define INIT_CHANNEL_OUT 0 + +/* InterfaceClass */ +#define CLASS_RESERVE 0x00 +#define CLASS_AUDIO 0x01 +#define CLASS_COMMUNICATION_IF 0x02 +#define CLASS_HID 0x03 +#define CLASS_PHYSICAL 0x05 +#define CLASS_IMAGE 0x06 +#define CLASS_PRINTER 0x07 +#define CLASS_MASS_STORAGE 0x08 +#define CLASS_HUB 0x09 +#define CLASS_COMMUNICATION_DATA_IF 0x0a +#define CLASS_SMART_CARD 0x0b +#define CLASS_CONTENT_SECURITY 0x0d +#define CLASS_VIDEO 0x0e +#define CLASS_PERSONAL_HEALTHCARE 0x0f +#define CLASS_DIAGNOSTIC 0xdc +#define CLASS_WIRELESS_CONTROLLER 0xe0 +#define CLASS_ELSE_DEVICE 0xef +#define CLASS_DEPENDENCE 0xfe +#define CLASS_VENDOR_DEPENDENCE 0xff + +/* usb version */ +#define USB_v1_0 0x100 +#define USB_v1_1 0x110 +#define USB_v2_0 0x200 +#define USB_v3_0 0x300 + +#define STREAM_ID_NONE 0x0 +#define STREAM_ID_PROXY 0x1 +#define STREAM_ID_STUB 0x2 + +#define CANCEL_REQUEST 0x00000100 +#define REGISTER_REQUEST_CALLBACK 0x00000101 +#define IO_CONTROL 0x00000102 +#define INTERNAL_IO_CONTROL 0x00000103 +#define QUERY_DEVICE_TEXT 0x00000104 +#define TRANSFER_IN_REQUEST 0x00000105 +#define TRANSFER_OUT_REQUEST 0x00000106 +#define RETRACT_DEVICE 0x00000107 + + +#define IOCONTROL_COMPLETION 0x00000100 +#define URB_COMPLETION 0x00000101 +#define URB_COMPLETION_NO_DATA 0x00000102 + +/* The USB device is to be stopped from being redirected because the + * device is blocked by the server's policy. */ +#define UsbRetractReason_BlockedByPolicy 0x00000001 + +enum device_text_type +{ + DeviceTextDescription = 0, + DeviceTextLocationInformation = 1, +}; + +enum device_descriptor_table +{ + B_LENGTH = 0, + B_DESCRIPTOR_TYPE = 1, + BCD_USB = 2, + B_DEVICE_CLASS = 4, + B_DEVICE_SUBCLASS = 5, + B_DEVICE_PROTOCOL = 6, + B_MAX_PACKET_SIZE0 = 7, + ID_VENDOR = 8, + ID_PRODUCT = 10, + BCD_DEVICE = 12, + I_MANUFACTURER = 14, + I_PRODUCT = 15, + I_SERIAL_NUMBER = 16, + B_NUM_CONFIGURATIONS = 17 +}; + +#define PIPE_CANCEL 0 +#define PIPE_RESET 1 + +#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003 +#define IOCTL_INTERNAL_USB_RESET_PORT 0x00220007 +#define IOCTL_INTERNAL_USB_GET_PORT_STATUS 0x00220013 +#define IOCTL_INTERNAL_USB_CYCLE_PORT 0x0022001F +#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION 0x00220027 + + + +#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000 +#define URB_FUNCTION_SELECT_INTERFACE 0x0001 +#define URB_FUNCTION_ABORT_PIPE 0x0002 +#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003 +#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004 +#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005 +#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006 +#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007 +#define URB_FUNCTION_CONTROL_TRANSFER 0x0008 +#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 +#define URB_FUNCTION_ISOCH_TRANSFER 0x000A +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B +#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C +#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D +#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E +#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F +#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010 +#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011 +#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012 +#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013 +#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014 +#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015 +#define URB_FUNCTION_RESERVED_0X0016 0x0016 +#define URB_FUNCTION_VENDOR_DEVICE 0x0017 +#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 +#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 +#define URB_FUNCTION_CLASS_DEVICE 0x001A +#define URB_FUNCTION_CLASS_INTERFACE 0x001B +#define URB_FUNCTION_CLASS_ENDPOINT 0x001C +#define URB_FUNCTION_RESERVE_0X001D 0x001D +#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E +#define URB_FUNCTION_CLASS_OTHER 0x001F +#define URB_FUNCTION_VENDOR_OTHER 0x0020 +#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021 +#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022 +#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023 +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024 +#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025 +#define URB_FUNCTION_GET_CONFIGURATION 0x0026 +#define URB_FUNCTION_GET_INTERFACE 0x0027 +#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028 +#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029 +#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A +#define URB_FUNCTION_RESERVE_0X002B 0x002B +#define URB_FUNCTION_RESERVE_0X002C 0x002C +#define URB_FUNCTION_RESERVE_0X002D 0x002D +#define URB_FUNCTION_RESERVE_0X002E 0x002E +#define URB_FUNCTION_RESERVE_0X002F 0x002F +// USB 2.0 calls start at 0x0030 +#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030 +#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031 +#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032 + +#define USBD_STATUS_SUCCESS 0x0 +#define USBD_STATUS_PENDING 0x40000000 +#define USBD_STATUS_CANCELED 0xC0010000 + +#define USBD_STATUS_CRC 0xC0000001 +#define USBD_STATUS_BTSTUFF 0xC0000002 +#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003 +#define USBD_STATUS_STALL_PID 0xC0000004 +#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005 +#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006 +#define USBD_STATUS_UNEXPECTED_PID 0xC0000007 +#define USBD_STATUS_DATA_OVERRUN 0xC0000008 +#define USBD_STATUS_DATA_UNDERRUN 0xC0000009 +#define USBD_STATUS_RESERVED1 0xC000000A +#define USBD_STATUS_RESERVED2 0xC000000B +#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C +#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D + +/* unknown */ +#define USBD_STATUS_NO_DATA 0xC000000E + +#define USBD_STATUS_NOT_ACCESSED 0xC000000F +#define USBD_STATUS_FIFO 0xC0000010 +#define USBD_STATUS_XACT_ERROR 0xC0000011 +#define USBD_STATUS_BABBLE_DETECTED 0xC0000012 +#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013 + +#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00 +#define USBD_STATUS_BUFFER_TOO_SMALL 0xC0003000 +#define USBD_STATUS_TIMEOUT 0xC0006000 +#define USBD_STATUS_DEVICE_GONE 0xC0007000 + +#define USBD_STATUS_NO_MEMORY 0x80000100 +#define USBD_STATUS_INVALID_URB_FUNCTION 0x80000200 +#define USBD_STATUS_INVALID_PARAMETER 0x80000300 +#define USBD_STATUS_REQUEST_FAILED 0x80000500 +#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600 +#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900 + +// Values for URB TransferFlags Field +// + +/* + Set if data moves device->host +*/ +#define USBD_TRANSFER_DIRECTION 0x00000001 +/* + This bit if not set indicates that a short packet, and hence, + a short transfer is an error condition +*/ +#define USBD_SHORT_TRANSFER_OK 0x00000002 +/* + Subit the iso transfer on the next frame +*/ +#define USBD_START_ISO_TRANSFER_ASAP 0x00000004 +#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008 + + +#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) & USBD_TRANSFER_DIRECTION) + +#define USBD_TRANSFER_DIRECTION_OUT 0 +#define USBD_TRANSFER_DIRECTION_IN 1 + +#define VALID_TRANSFER_FLAGS_MASK USBD_SHORT_TRANSFER_OK | \ + USBD_TRANSFER_DIRECTION | \ + USBD_START_ISO_TRANSFER_ASAP | \ + USBD_DEFAULT_PIPE_TRANSFER) + +#define ENDPOINT_HALT 0x00 +#define DEVICE_REMOTE_WAKEUP 0x01 + +/* transfer type */ +#define CONTROL_TRANSFER 0x00 +#define ISOCHRONOUS_TRANSFER 0x01 +#define BULK_TRANSFER 0x02 +#define INTERRUPT_TRANSFER 0x03 + +#define ClearHubFeature (0x2000 | LIBUSB_REQUEST_CLEAR_FEATURE) +#define ClearPortFeature (0x2300 | LIBUSB_REQUEST_CLEAR_FEATURE) +#define GetHubDescriptor (0xa000 | LIBUSB_REQUEST_GET_DESCRIPTOR) +#define GetHubStatus (0xa000 | LIBUSB_REQUEST_GET_STATUS) +#define GetPortStatus (0xa300 | LIBUSB_REQUEST_GET_STATUS) +#define SetHubFeature (0x2000 | LIBUSB_REQUEST_SET_FEATURE) +#define SetPortFeature (0x2300 | LIBUSB_REQUEST_SET_FEATURE) + +#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 +#define USBD_PF_SHORT_PACKET_OPT 0x00000002 +#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 +#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 + +/* feature request */ +#define URB_SET_FEATURE 0x00 +#define URB_CLEAR_FEATURE 0x01 + +#define USBD_PF_CHANGE_MAX_PACKET 0x00000001 +#define USBD_PF_SHORT_PACKET_OPT 0x00000002 +#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004 +#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008 + +#define URB_CONTROL_TRANSFER_EXTERNAL 0x1 +#define URB_CONTROL_TRANSFER_NONEXTERNAL 0x0 + +#define USBFS_URB_SHORT_NOT_OK 0x01 +#define USBFS_URB_ISO_ASAP 0x02 +#define USBFS_URB_BULK_CONTINUATION 0x04 +#define USBFS_URB_QUEUE_BULK 0x10 + +#define URBDRC_DEVICE_INITIALIZED 0x01 +#define URBDRC_DEVICE_NOT_FOUND 0x02 +#define URBDRC_DEVICE_SIGNAL_END 0x04 +#define URBDRC_DEVICE_CHANNEL_CLOSED 0x08 +#define URBDRC_DEVICE_ALREADY_SEND 0x10 +#define URBDRC_DEVICE_DETACH_KERNEL 0x20 + +#define UDEVMAN_FLAG_ADD_BY_VID_PID 0x01 +#define UDEVMAN_FLAG_ADD_BY_ADDR 0x02 +#define UDEVMAN_FLAG_ADD_BY_AUTO 0x04 +#define UDEVMAN_FLAG_DEBUG 0x08 + +#define MAX_URB_REQUSET_NUM 0x80 + +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { printf _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { printf _args ; printf("\n"); } } while (0) + +#define dummy_wait_obj(void) do{ sleep(5); } while(0) +#define dummy_wait_s_obj(_s) do{ sleep(_s); } while(0) + +#define ISOCH_FIFO 1 +#define WAIT_COMPLETE_SLEEP 10000 /* for cpu high loading */ + +#define urbdrc_get_mstime(_t) do { \ + struct timeval _tp; \ + gettimeofday(&_tp, 0); \ + _t = (_tp.tv_sec * 1000) + (_tp.tv_usec / 1000); \ +} while (0) + +extern int urbdrc_debug; + +#endif /* __URBDRC_TYPES_H */ diff --git a/channels/drdynvc/urbdrc/libusb/CMakeLists.txt b/channels/urbdrc/libusb/CMakeLists.txt similarity index 96% rename from channels/drdynvc/urbdrc/libusb/CMakeLists.txt rename to channels/urbdrc/libusb/CMakeLists.txt index f3ba9c242..cd874c1c7 100644 --- a/channels/drdynvc/urbdrc/libusb/CMakeLists.txt +++ b/channels/urbdrc/libusb/CMakeLists.txt @@ -21,10 +21,9 @@ set(LIBUSB_UDEVMAN_SRCS libusb_udevice.c libusb_udevice.h request_queue.c - request_queue.h -) + request_queue.h) -include_directories(..) +include_directories(../client) add_library(libusb_udevman ${LIBUSB_UDEVMAN_SRCS}) set_target_properties(libusb_udevman PROPERTIES PREFIX "") @@ -36,3 +35,4 @@ target_link_libraries(libusb_udevman usb-1.0) target_link_libraries(libusb_udevman freerdp-utils) install(TARGETS libusb_udevman DESTINATION ${FREERDP_PLUGIN_PATH}) + diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevice.c b/channels/urbdrc/libusb/libusb_udevice.c similarity index 100% rename from channels/drdynvc/urbdrc/libusb/libusb_udevice.c rename to channels/urbdrc/libusb/libusb_udevice.c diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevice.h b/channels/urbdrc/libusb/libusb_udevice.h similarity index 100% rename from channels/drdynvc/urbdrc/libusb/libusb_udevice.h rename to channels/urbdrc/libusb/libusb_udevice.h diff --git a/channels/drdynvc/urbdrc/libusb/libusb_udevman.c b/channels/urbdrc/libusb/libusb_udevman.c similarity index 100% rename from channels/drdynvc/urbdrc/libusb/libusb_udevman.c rename to channels/urbdrc/libusb/libusb_udevman.c diff --git a/channels/drdynvc/urbdrc/libusb/request_queue.c b/channels/urbdrc/libusb/request_queue.c similarity index 100% rename from channels/drdynvc/urbdrc/libusb/request_queue.c rename to channels/urbdrc/libusb/request_queue.c diff --git a/channels/drdynvc/urbdrc/libusb/request_queue.h b/channels/urbdrc/libusb/request_queue.h similarity index 100% rename from channels/drdynvc/urbdrc/libusb/request_queue.h rename to channels/urbdrc/libusb/request_queue.h From 299b780d130da05f88328d79385b00c01fd17e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 17:24:52 -0400 Subject: [PATCH 63/64] urbdrc: code style cleanup --- channels/urbdrc/client/data_transfer.c | 349 ++++++++---------- channels/urbdrc/client/isoch_queue.c | 46 +-- channels/urbdrc/client/searchman.c | 52 +-- channels/urbdrc/client/urbdrc_main.c | 490 +++++++++++++------------ 4 files changed, 445 insertions(+), 492 deletions(-) diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index c00c504d0..541b0cc28 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -30,47 +30,52 @@ #include "urbdrc_types.h" #include "data_transfer.h" - -static void -usb_process_get_port_status(IUDEVICE * pdev, uint8 * OutputBuffer) +static void usb_process_get_port_status(IUDEVICE* pdev, uint8* OutputBuffer) { int bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB); - switch (bcdUSB){ + + switch (bcdUSB) + { case USB_v1_0: data_write_uint32(OutputBuffer, 0x303); break; + case USB_v1_1: data_write_uint32(OutputBuffer, 0x103); break; + case USB_v2_0: data_write_uint32(OutputBuffer, 0x503); break; + default: data_write_uint32(OutputBuffer, 0x503); break; } } - #if ISOCH_FIFO -static int -func_check_isochronous_fds(IUDEVICE * pdev) -{ - ISOCH_CALLBACK_QUEUE * isoch_queue = NULL; - ISOCH_CALLBACK_DATA * isoch = NULL; - URBDRC_CHANNEL_CALLBACK * callback; - uint32 size_temp, process_times = 2; - uint8 * data_temp; - int ret = 0; - isoch_queue = (ISOCH_CALLBACK_QUEUE *)pdev->get_isoch_queue(pdev); +static int func_check_isochronous_fds(IUDEVICE* pdev) +{ + int ret = 0; + uint8* data_temp; + uint32 size_temp, process_times = 2; + ISOCH_CALLBACK_QUEUE* isoch_queue = NULL; + ISOCH_CALLBACK_DATA* isoch = NULL; + URBDRC_CHANNEL_CALLBACK* callback; + + isoch_queue = (ISOCH_CALLBACK_QUEUE*) pdev->get_isoch_queue(pdev); while (process_times) { process_times--; + if (isoch_queue == NULL || !pdev) return -1; + pthread_mutex_lock(&isoch_queue->isoch_loading); + if (isoch_queue->head == NULL) { pthread_mutex_unlock(&isoch_queue->isoch_loading); @@ -80,6 +85,7 @@ func_check_isochronous_fds(IUDEVICE * pdev) { isoch = isoch_queue->head; } + if (!isoch || !isoch->out_data) { pthread_mutex_unlock(&isoch_queue->isoch_loading); @@ -87,43 +93,41 @@ func_check_isochronous_fds(IUDEVICE * pdev) } else { - callback = (URBDRC_CHANNEL_CALLBACK *)isoch->callback; + callback = (URBDRC_CHANNEL_CALLBACK*) isoch->callback; size_temp = isoch->out_size; data_temp = isoch->out_data; ret = isoch_queue->unregister_data(isoch_queue, isoch); + if (!ret) LLOGLN(0, ("isoch_queue_unregister_data: Not found isoch data!!\n")); + pthread_mutex_unlock(&isoch_queue->isoch_loading); if (pdev && !pdev->isSigToEnd(pdev)) { - callback->channel->Write(callback->channel, size_temp, - data_temp, NULL); + callback->channel->Write(callback->channel, size_temp, data_temp, NULL); zfree(data_temp); } - } - } + return 0; } + #endif -static int -urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK * callback, - uint8 * data, - uint32 data_sizem, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK* callback, + uint8* data, uint32 data_sizem, IUDEVMAN* udevman, uint32 UsbDevice) { - IUDEVICE * pdev; - uint32 NumRequestCompletion = 0; - uint32 RequestCompletion = 0; + IUDEVICE* pdev; + uint32 NumRequestCompletion = 0; + uint32 RequestCompletion = 0; LLOGLN(urbdrc_debug, ("urbdrc_process_register_request_callback")); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; @@ -138,6 +142,7 @@ urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK * callback, else /** Unregister the device */ { data_read_uint32(data + 0, RequestCompletion); + if (1)//(pdev->get_ReqCompletion(pdev) == RequestCompletion) { /** The wrong driver may also receive this message, So we @@ -152,20 +157,18 @@ urbdrc_process_register_request_callback(URBDRC_CHANNEL_CALLBACK * callback, return 0; } -static int -urbdrc_process_cancel_request(uint8 * data, uint32 data_sizem, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_cancel_request(uint8* data, uint32 data_sizem, IUDEVMAN* udevman, uint32 UsbDevice) { IUDEVICE* pdev; - uint32 CancelId; - int error = 0; + uint32 CancelId; + int error = 0; data_read_uint32(data + 0, CancelId); /** RequestId */ LLOGLN(urbdrc_debug, ("urbdrc_process_cancel_request: id 0x%x", CancelId)); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; @@ -174,10 +177,7 @@ urbdrc_process_cancel_request(uint8 * data, uint32 data_sizem, return error; } -static int -urbdrc_process_retract_device_request(uint8 * data, uint32 data_sizem, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_retract_device_request(uint8* data, uint32 data_sizem, IUDEVMAN* udevman, uint32 UsbDevice) { uint32 Reason; LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request")); @@ -190,6 +190,7 @@ urbdrc_process_retract_device_request(uint8 * data, uint32 data_sizem, LLOGLN(urbdrc_debug, ("UsbRetractReason_BlockedByPolicy: now it is not support")); return -1; break; + default: LLOGLN(urbdrc_debug, ("urbdrc_process_retract_device_request: Unknown Reason %d", Reason)); return -1; @@ -199,24 +200,20 @@ urbdrc_process_retract_device_request(uint8 * data, uint32 data_sizem, return 0; } -static int -urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN * udevman, uint32 UsbDevice) { - IUDEVICE * pdev; - uint32 out_size; - uint32 InterfaceId; - uint32 IoControlCode; - uint32 InputBufferSize; - uint32 OutputBufferSize; - uint32 RequestId; - uint32 usbd_status = USBD_STATUS_SUCCESS; - uint8 * OutputBuffer; - uint8 * out_data; - int i, offset, success = 0; + IUDEVICE* pdev; + uint32 out_size; + uint32 InterfaceId; + uint32 IoControlCode; + uint32 InputBufferSize; + uint32 OutputBufferSize; + uint32 RequestId; + uint32 usbd_status = USBD_STATUS_SUCCESS; + uint8* OutputBuffer; + uint8* out_data; + int i, offset, success = 0; LLOGLN(urbdrc_debug, ("urbdrc_process__io_control")); @@ -226,30 +223,31 @@ urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, data_read_uint32(data + 12 + InputBufferSize, RequestId); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); - /** process */ OutputBuffer = (uint8 *)malloc(OutputBufferSize); memset(OutputBuffer, 0, OutputBufferSize); - switch (IoControlCode){ + switch (IoControlCode) + { case IOCTL_INTERNAL_USB_SUBMIT_URB: /** 0x00220003 */ LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_URB")); printf(" Function IOCTL_INTERNAL_USB_SUBMIT_URB: Unchecked\n"); break; + case IOCTL_INTERNAL_USB_RESET_PORT: /** 0x00220007 */ LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_RESET_PORT")); break; + case IOCTL_INTERNAL_USB_GET_PORT_STATUS: /** 0x00220013 */ LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_GET_PORT_STATUS")); - success = pdev->query_device_port_status(pdev, &usbd_status, - &OutputBufferSize, - OutputBuffer); + success = pdev->query_device_port_status(pdev, &usbd_status, &OutputBufferSize, OutputBuffer); if (success) { @@ -262,42 +260,47 @@ urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, usb_process_get_port_status(pdev, OutputBuffer); OutputBufferSize = 4; } + LLOGLN(urbdrc_debug, ("PORT STATUS(fake!):0x%02x%02x%02x%02x", OutputBuffer[3], OutputBuffer[2], OutputBuffer[1], OutputBuffer[0])); } break; + case IOCTL_INTERNAL_USB_CYCLE_PORT: /** 0x0022001F */ LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_CYCLE_PORT")); printf(" Function IOCTL_INTERNAL_USB_CYCLE_PORT: Unchecked\n"); break; + case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: /** 0x00220027 */ LLOGLN(urbdrc_debug, ("ioctl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION")); printf(" Function IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION: Unchecked\n"); break; + default: LLOGLN(urbdrc_debug, ("urbdrc_process_io_control: unknown IoControlCode 0x%X", IoControlCode)); return -1; break; } - offset = 28; out_size = offset + OutputBufferSize; out_data = (uint8 *) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /** interface */ - data_write_uint32(out_data + 4, MessageId); /** message id */ - data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ - data_write_uint32(out_data + 12, RequestId); /** RequestId */ - data_write_uint32(out_data + 16, USBD_STATUS_SUCCESS); /** HResult */ - data_write_uint32(out_data + 20, OutputBufferSize); /** Information */ - data_write_uint32(out_data + 24, OutputBufferSize); /** OutputBufferSize */ + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, USBD_STATUS_SUCCESS); /** HResult */ + data_write_uint32(out_data + 20, OutputBufferSize); /** Information */ + data_write_uint32(out_data + 24, OutputBufferSize); /** OutputBufferSize */ - for (i=0;iisSigToEnd(pdev)) callback->channel->Write(callback->channel, out_size, out_data, NULL); @@ -307,17 +310,13 @@ urbdrc_process_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, return 0; } -static int -urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice) { IUDEVICE* pdev; + uint8* out_data; uint32 out_size, IoControlCode, InterfaceId, InputBufferSize; uint32 OutputBufferSize, RequestId, frames; - uint8 * out_data; data_read_uint32(data + 0, IoControlCode); @@ -328,8 +327,10 @@ urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * d data_read_uint32(data + 12, RequestId); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; + InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); /** Fixme: Currently this is a false bustime... */ @@ -338,15 +339,14 @@ urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * d out_size = 32; out_data = (uint8 *) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /** interface */ - data_write_uint32(out_data + 4, MessageId); /** message id */ - data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ - data_write_uint32(out_data + 12, RequestId); /** RequestId */ - data_write_uint32(out_data + 16, 0); /** HResult */ - data_write_uint32(out_data + 20, 4); /** Information */ - data_write_uint32(out_data + 24, 4); /** OutputBufferSize */ - data_write_uint32(out_data + 28, frames); /** OutputBuffer */ - + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + data_write_uint32(out_data + 8, IOCONTROL_COMPLETION); /** function id */ + data_write_uint32(out_data + 12, RequestId); /** RequestId */ + data_write_uint32(out_data + 16, 0); /** HResult */ + data_write_uint32(out_data + 20, 4); /** Information */ + data_write_uint32(out_data + 24, 4); /** OutputBufferSize */ + data_write_uint32(out_data + 28, frames); /** OutputBuffer */ if (!pdev->isSigToEnd(pdev)) callback->channel->Write(callback->channel, out_size, out_data, NULL); @@ -356,23 +356,18 @@ urbdrc_process_internal_io_control(URBDRC_CHANNEL_CALLBACK * callback, uint8 * d return 0; } -static int -urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK * callback, - uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice) +static int urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice) { - IUDEVICE * pdev; - uint32 out_size; - uint32 InterfaceId; - uint32 TextType; - uint32 LocaleId; - uint32 bufferSize = 1024; - uint8 * out_data; - uint8 DeviceDescription[bufferSize]; - int out_offset; + IUDEVICE* pdev; + uint32 out_size; + uint32 InterfaceId; + uint32 TextType; + uint32 LocaleId; + uint32 bufferSize = 1024; + uint8* out_data; + uint8 DeviceDescription[bufferSize]; + int out_offset; LLOGLN(urbdrc_debug, ("urbdrc_process_query_device_text")); @@ -380,29 +375,29 @@ urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK * callback, data_read_uint32(data + 4, LocaleId); pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; - pdev->control_query_device_text( - pdev, - TextType, - LocaleId, - &bufferSize, - DeviceDescription); + pdev->control_query_device_text(pdev, TextType, LocaleId, &bufferSize, DeviceDescription); - - InterfaceId = ((STREAM_ID_STUB<<30) | UsbDevice); + InterfaceId = ((STREAM_ID_STUB << 30) | UsbDevice); out_offset = 16; out_size = out_offset + bufferSize; - if(bufferSize != 0) + + if (bufferSize != 0) out_size += 2; - out_data = (uint8 *) malloc(out_size); + + out_data = (uint8*) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /** interface */ - data_write_uint32(out_data + 4, MessageId); /** message id */ - if (bufferSize != 0) { - data_write_uint32(out_data + 8, (bufferSize/2)+1); /** cchDeviceDescription */ + + data_write_uint32(out_data + 0, InterfaceId); /** interface */ + data_write_uint32(out_data + 4, MessageId); /** message id */ + + if (bufferSize != 0) + { + data_write_uint32(out_data + 8, (bufferSize/2)+1); /** cchDeviceDescription */ out_offset = 12; memcpy(out_data + out_offset, DeviceDescription, bufferSize); out_offset += bufferSize; @@ -411,7 +406,7 @@ urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK * callback, } else { - data_write_uint32(out_data + 8, 0); /** cchDeviceDescription */ + data_write_uint32(out_data + 8, 0); /** cchDeviceDescription */ out_offset = 12; } @@ -425,15 +420,12 @@ urbdrc_process_query_device_text(URBDRC_CHANNEL_CALLBACK * callback, return 0; } - - -static void -func_select_all_interface_for_msconfig(IUDEVICE * pdev, MSUSB_CONFIG_DESCRIPTOR * MsConfig) +static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, MSUSB_CONFIG_DESCRIPTOR* MsConfig) { - MSUSB_INTERFACE_DESCRIPTOR ** MsInterfaces = MsConfig->MsInterfaces; + int inum; + MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces; uint8 InterfaceNumber, AlternateSetting; uint32 NumInterfaces = MsConfig->NumInterfaces; - int inum; for (inum = 0; inum < NumInterfaces; inum++) { @@ -443,29 +435,24 @@ func_select_all_interface_for_msconfig(IUDEVICE * pdev, MSUSB_CONFIG_DESCRIPTOR } } - - -static int -urb_select_configuration(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice, - int transferDir) +static int urb_select_configuration(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice, int transferDir) { MSUSB_CONFIG_DESCRIPTOR * MsConfig = NULL; - IUDEVICE * pdev = NULL; - uint32 out_size, InterfaceId, RequestId, NumInterfaces, usbd_status = 0; - uint8 ConfigurationDescriptorIsValid; - uint8 * out_data; - int MsOutSize = 0, offset = 0; + IUDEVICE* pdev = NULL; + uint32 out_size, InterfaceId, RequestId, NumInterfaces, usbd_status = 0; + uint8 ConfigurationDescriptorIsValid; + uint8* out_data; + int MsOutSize = 0, offset = 0; - if (transferDir == 0){ + if (transferDir == 0) + { printf("urb_select_configuration: not support transfer out\n"); return -1; } pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; @@ -538,38 +525,34 @@ urb_select_configuration(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, return 0; } - -static int -urb_select_interface(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice, - int transferDir) +static int urb_select_interface(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, uint32 data_sizem, + uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice, int transferDir) { - MSUSB_CONFIG_DESCRIPTOR * MsConfig; - MSUSB_INTERFACE_DESCRIPTOR * MsInterface; - IUDEVICE * pdev; - uint32 out_size, InterfaceId, RequestId, ConfigurationHandle; - uint32 OutputBufferSize; - uint8 InterfaceNumber; - uint8 * out_data; - int out_offset, interface_size; + MSUSB_CONFIG_DESCRIPTOR* MsConfig; + MSUSB_INTERFACE_DESCRIPTOR* MsInterface; + IUDEVICE* pdev; + uint32 out_size, InterfaceId, RequestId, ConfigurationHandle; + uint32 OutputBufferSize; + uint8 InterfaceNumber; + uint8* out_data; + int out_offset, interface_size; - if (transferDir == 0){ + if (transferDir == 0) + { printf("urb_select_interface: not support transfer out\n"); return -1; } pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; - InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev)); data_read_uint32(data + 0, RequestId); data_read_uint32(data + 4, ConfigurationHandle); - out_offset = 8; + out_offset = 8; MsInterface = msusb_msinterface_read(data + out_offset, data_sizem - out_offset, &out_offset); @@ -588,8 +571,9 @@ urb_select_interface(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, interface_size = 16 + (MsInterface->NumberOfPipes * 20); out_size = 36 + interface_size ; - out_data = (uint8 *) malloc(out_size); + out_data = (uint8*) malloc(out_size); memset(out_data, 0, out_size); + data_write_uint32(out_data + 0, InterfaceId); /** interface */ data_write_uint32(out_data + 4, MessageId); /** message id */ data_write_uint32(out_data + 8, URB_COMPLETION_NO_DATA); /** function id */ @@ -612,34 +596,28 @@ urb_select_interface(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, callback->channel->Write(callback->channel, out_size, out_data, NULL); zfree(out_data); + return 0; } - - -static int -urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice, - int transferDir, - int External) +static int urb_control_transfer(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice, int transferDir, int External) { - IUDEVICE * pdev; - uint32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle; - uint32 TransferFlags, OutputBufferSize, usbd_status, Timeout; - uint8 bmRequestType, Request; - uint16 Value, Index, length; - uint8 * buffer; - uint8 * out_data; - int offset, ret; + IUDEVICE* pdev; + uint32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle; + uint32 TransferFlags, OutputBufferSize, usbd_status, Timeout; + uint8 bmRequestType, Request; + uint16 Value, Index, length; + uint8* buffer; + uint8* out_data; + int offset, ret; pdev = udevman->get_udevice_by_UsbDevice(udevman, UsbDevice); + if (pdev == NULL) return 0; - InterfaceId = ((STREAM_ID_PROXY<<30) | pdev->get_ReqCompletion(pdev)); + InterfaceId = ((STREAM_ID_PROXY << 30) | pdev->get_ReqCompletion(pdev)); data_read_uint32(data + 0, RequestId); data_read_uint32(data + 4, PipeHandle); data_read_uint32(data + 8, TransferFlags); /** TransferFlags */ @@ -647,6 +625,7 @@ urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, EndpointAddress = (PipeHandle & 0x000000ff); offset = 12; Timeout = 2000; + switch (External) { case URB_CONTROL_TRANSFER_EXTERNAL: @@ -656,6 +635,7 @@ urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, case URB_CONTROL_TRANSFER_NONEXTERNAL: break; } + /** SetupPacket 8 bytes */ data_read_uint8(data + offset, bmRequestType); data_read_uint8(data + offset + 1, Request); @@ -665,7 +645,8 @@ urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, data_read_uint32(data + offset + 8, OutputBufferSize); offset += 12; - if (length != OutputBufferSize){ + if (length != OutputBufferSize) + { LLOGLN(urbdrc_debug, ("urb_control_transfer ERROR: buf != length")); return -1; } @@ -727,18 +708,12 @@ urb_control_transfer(URBDRC_CHANNEL_CALLBACK * callback, uint8 * data, callback->channel->Write(callback->channel, out_size, out_data, NULL); zfree(out_data); + return 0; } - -static int -urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK * callback, - uint8 * data, - uint32 data_sizem, - uint32 MessageId, - IUDEVMAN * udevman, - uint32 UsbDevice, - int transferDir) +static int urb_bulk_or_interrupt_transfer(URBDRC_CHANNEL_CALLBACK* callback, uint8* data, + uint32 data_sizem, uint32 MessageId, IUDEVMAN* udevman, uint32 UsbDevice, int transferDir) { IUDEVICE * pdev; uint32 out_size, RequestId, InterfaceId, EndpointAddress, PipeHandle; diff --git a/channels/urbdrc/client/isoch_queue.c b/channels/urbdrc/client/isoch_queue.c index fe77739d1..22a64ce09 100644 --- a/channels/urbdrc/client/isoch_queue.c +++ b/channels/urbdrc/client/isoch_queue.c @@ -24,15 +24,12 @@ #include #include "isoch_queue.h" - -static void -isoch_queue_rewind(ISOCH_CALLBACK_QUEUE * queue) +static void isoch_queue_rewind(ISOCH_CALLBACK_QUEUE* queue) { queue->curr = queue->head; } -static int -isoch_queue_has_next(ISOCH_CALLBACK_QUEUE * queue) +static int isoch_queue_has_next(ISOCH_CALLBACK_QUEUE* queue) { if (queue->curr == NULL) return 0; @@ -40,8 +37,7 @@ isoch_queue_has_next(ISOCH_CALLBACK_QUEUE * queue) return 1; } -static ISOCH_CALLBACK_DATA* -isoch_queue_get_next(ISOCH_CALLBACK_QUEUE * queue) +static ISOCH_CALLBACK_DATA* isoch_queue_get_next(ISOCH_CALLBACK_QUEUE* queue) { ISOCH_CALLBACK_DATA* isoch; @@ -51,16 +47,11 @@ isoch_queue_get_next(ISOCH_CALLBACK_QUEUE * queue) return isoch; } - - - -static ISOCH_CALLBACK_DATA* -isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void * callback, - void * dev) +static ISOCH_CALLBACK_DATA* isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void* callback, void* dev) { - ISOCH_CALLBACK_DATA* isoch; + ISOCH_CALLBACK_DATA* isoch; - isoch = (ISOCH_CALLBACK_DATA*)malloc(sizeof(ISOCH_CALLBACK_DATA)); + isoch = (ISOCH_CALLBACK_DATA*) malloc(sizeof(ISOCH_CALLBACK_DATA)); isoch->prev = NULL; isoch->next = NULL; @@ -71,6 +62,7 @@ isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void * callback, isoch->callback = callback; pthread_mutex_lock(&queue->isoch_loading); + if (queue->head == NULL) { /* linked queue is empty */ @@ -85,18 +77,18 @@ isoch_queue_register_data(ISOCH_CALLBACK_QUEUE* queue, void * callback, queue->tail = isoch; } queue->isoch_num += 1; + pthread_mutex_unlock(&queue->isoch_loading); + return isoch; } - - -static int -isoch_queue_unregister_data(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch) +static int isoch_queue_unregister_data(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* isoch) { ISOCH_CALLBACK_DATA* p; queue->rewind(queue); + while (queue->has_next(queue) != 0) { p = queue->get_next(queue); @@ -145,15 +137,15 @@ isoch_queue_unregister_data(ISOCH_CALLBACK_QUEUE* queue, ISOCH_CALLBACK_DATA* is return 0; } - -void -isoch_queue_free(ISOCH_CALLBACK_QUEUE * queue) +void isoch_queue_free(ISOCH_CALLBACK_QUEUE* queue) { - ISOCH_CALLBACK_DATA * isoch; + ISOCH_CALLBACK_DATA* isoch; pthread_mutex_lock(&queue->isoch_loading); + /** unregister all isochronous data*/ queue->rewind(queue); + while (queue->has_next(queue)) { isoch = queue->get_next(queue); @@ -169,13 +161,11 @@ isoch_queue_free(ISOCH_CALLBACK_QUEUE * queue) zfree(queue); } - -ISOCH_CALLBACK_QUEUE* -isoch_queue_new() +ISOCH_CALLBACK_QUEUE* isoch_queue_new() { - ISOCH_CALLBACK_QUEUE * queue; + ISOCH_CALLBACK_QUEUE* queue; - queue = (ISOCH_CALLBACK_QUEUE *)malloc(sizeof(ISOCH_CALLBACK_QUEUE)); + queue = (ISOCH_CALLBACK_QUEUE*) malloc(sizeof(ISOCH_CALLBACK_QUEUE)); queue->isoch_num = 0; queue->curr = NULL; queue->head = NULL; diff --git a/channels/urbdrc/client/searchman.c b/channels/urbdrc/client/searchman.c index bfb4d56ce..6b710997e 100644 --- a/channels/urbdrc/client/searchman.c +++ b/channels/urbdrc/client/searchman.c @@ -25,14 +25,12 @@ #include #include "searchman.h" -static void -searchman_rewind(USB_SEARCHMAN* searchman) +static void searchman_rewind(USB_SEARCHMAN* searchman) { searchman->idev = searchman->head; } -static int -searchman_has_next(USB_SEARCHMAN* searchman) +static int searchman_has_next(USB_SEARCHMAN* searchman) { if (searchman->idev == NULL) return 0; @@ -40,25 +38,21 @@ searchman_has_next(USB_SEARCHMAN* searchman) return 1; } -static USB_SEARCHDEV* -searchman_get_next(USB_SEARCHMAN* searchman) +static USB_SEARCHDEV* searchman_get_next(USB_SEARCHMAN* searchman) { USB_SEARCHDEV* search; search = searchman->idev; - searchman->idev = (USB_SEARCHDEV*)searchman->idev->next; + searchman->idev = (USB_SEARCHDEV*) searchman->idev->next; return search; } - - -static int -searchman_list_add(USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct) +static int searchman_list_add(USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct) { USB_SEARCHDEV* search; - search = (USB_SEARCHDEV*)malloc(sizeof(USB_SEARCHDEV)); + search = (USB_SEARCHDEV*) malloc(sizeof(USB_SEARCHDEV)); search->prev = NULL; search->next = NULL; @@ -83,15 +77,13 @@ searchman_list_add(USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct) return 1; } - -static int -searchman_list_remove(USB_SEARCHMAN* searchman, uint16 idVendor, - uint16 idProduct) +static int searchman_list_remove(USB_SEARCHMAN* searchman, uint16 idVendor, uint16 idProduct) { USB_SEARCHDEV* search; USB_SEARCHDEV* point; searchman_rewind(searchman); + while (searchman_has_next(searchman) != 0) { point = searchman_get_next(searchman); @@ -139,10 +131,7 @@ searchman_list_remove(USB_SEARCHMAN* searchman, uint16 idVendor, return 0; } - - -static void -searchman_start(USB_SEARCHMAN* self, void * func) +static void searchman_start(USB_SEARCHMAN* self, void* func) { pthread_t thread; @@ -153,18 +142,15 @@ searchman_start(USB_SEARCHMAN* self, void * func) } /* close thread */ -static void -searchman_close(USB_SEARCHMAN* self) +static void searchman_close(USB_SEARCHMAN* self) { wait_obj_set(self->term_event); } - -static void -searchman_list_show(USB_SEARCHMAN* self) +static void searchman_list_show(USB_SEARCHMAN* self) { - USB_SEARCHDEV* usb; int num = 0; + USB_SEARCHDEV* usb; printf("=========== Usb Search List ========= \n"); self->rewind(self); @@ -178,9 +164,7 @@ searchman_list_show(USB_SEARCHMAN* self) printf("================= END =============== \n"); } - -void -searchman_free(USB_SEARCHMAN* self) +void searchman_free(USB_SEARCHMAN* self) { USB_SEARCHDEV * dev; @@ -196,14 +180,13 @@ searchman_free(USB_SEARCHMAN* self) free(self); } - -USB_SEARCHMAN* -searchman_new(void * urbdrc, uint32 UsbDevice) +USB_SEARCHMAN* searchman_new(void * urbdrc, uint32 UsbDevice) { - USB_SEARCHMAN* searchman; int ret; - searchman = (USB_SEARCHMAN*)malloc(sizeof(USB_SEARCHMAN)); + USB_SEARCHMAN* searchman; + searchman = (USB_SEARCHMAN*) malloc(sizeof(USB_SEARCHMAN)); + searchman->idev = NULL; searchman->head = NULL; searchman->tail = NULL; @@ -212,6 +195,7 @@ searchman_new(void * urbdrc, uint32 UsbDevice) searchman->UsbDevice = UsbDevice; ret = pthread_mutex_init(&searchman->mutex, NULL); + if (ret != 0) { printf("searchman mutex initialization: searchman->mutex failed"); diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 4b269015a..f3a051a74 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -35,8 +35,7 @@ int urbdrc_debug = 0; -static int -func_hardware_id_format(IUDEVICE * pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_SIZE]) +static int func_hardware_id_format(IUDEVICE* pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_SIZE]) { char str[DEVICE_HARDWARE_ID_SIZE]; int idVendor, idProduct, bcdDevice; @@ -55,9 +54,7 @@ func_hardware_id_format(IUDEVICE * pdev, char (*HardwareIds)[DEVICE_HARDWARE_ID_ return 0; } - -static int -func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBILITY_ID_SIZE]) +static int func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBILITY_ID_SIZE]) { char str[DEVICE_COMPATIBILITY_ID_SIZE]; int bDeviceClass, bDeviceSubClass, bDeviceProtocol; @@ -66,7 +63,8 @@ func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBIL bDeviceSubClass = pdev->query_device_descriptor(pdev, B_DEVICE_SUBCLASS); bDeviceProtocol = pdev->query_device_descriptor(pdev, B_DEVICE_PROTOCOL); - if(!(pdev->isCompositeDevice(pdev))){ + if(!(pdev->isCompositeDevice(pdev))) + { sprintf(str, "USB\\Class_%02X", bDeviceClass); strcpy(CompatibilityIds[2], str); sprintf(str, "%s&SubClass_%02X", str, bDeviceSubClass); @@ -74,7 +72,8 @@ func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBIL sprintf(str, "%s&Prot_%02X", str, bDeviceProtocol); strcpy(CompatibilityIds[0], str); } - else{ + else + { sprintf(str, "USB\\DevClass_00"); strcpy(CompatibilityIds[2], str); sprintf(str, "%s&SubClass_00", str); @@ -86,38 +85,36 @@ func_compat_id_format(IUDEVICE *pdev, char (*CompatibilityIds)[DEVICE_COMPATIBIL return 0; } - -static void -func_close_udevice(USB_SEARCHMAN * searchman, IUDEVICE * pdev) +static void func_close_udevice(USB_SEARCHMAN* searchman, IUDEVICE* pdev) { - URBDRC_PLUGIN * urbdrc = searchman->urbdrc; int idVendor = 0; int idProduct = 0; + URBDRC_PLUGIN* urbdrc = searchman->urbdrc; pdev->SigToEnd(pdev); idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR); idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT); - searchman->add(searchman, (uint16)idVendor, (uint16)idProduct); + searchman->add(searchman, (uint16) idVendor, (uint16) idProduct); pdev->cancel_all_transfer_request(pdev); pdev->wait_action_completion(pdev); #if ISOCH_FIFO - /* free isoch queue */ - ISOCH_CALLBACK_QUEUE* isoch_queue = pdev->get_isoch_queue(pdev); - if (isoch_queue) - isoch_queue->free(isoch_queue); + { + /* free isoch queue */ + ISOCH_CALLBACK_QUEUE* isoch_queue = pdev->get_isoch_queue(pdev); + + if (isoch_queue) + isoch_queue->free(isoch_queue); + } #endif urbdrc->udevman->unregister_udevice(urbdrc->udevman, pdev->get_bus_number(pdev), pdev->get_dev_number(pdev)); - //searchman->show(searchman); } - -static int -fun_device_string_send_set(char * out_data, int out_offset, char * str) +static int fun_device_string_send_set(char* out_data, int out_offset, char* str) { int i = 0; int offset = 0; @@ -128,28 +125,31 @@ fun_device_string_send_set(char * out_data, int out_offset, char * str) i++; offset += 2; } + data_write_uint16(out_data + out_offset + offset, 0x0000); /* add "\0" */ offset += 2; + return offset + out_offset; } - -static int -func_container_id_generate(IUDEVICE * pdev, char * strContainerId) +static int func_container_id_generate(IUDEVICE* pdev, char* strContainerId) { - char containerId[17]; char *p, *path; + char containerId[17]; int idVendor, idProduct; idVendor = pdev->query_device_descriptor(pdev, ID_VENDOR); idProduct = pdev->query_device_descriptor(pdev, ID_PRODUCT); + path = pdev->getPath(pdev); + if (strlen(path) > 8) p = (path + strlen(path)) - 8; else p = path; sprintf(containerId, "%04X%04X%s", idVendor, idProduct, p); + /* format */ sprintf(strContainerId, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}", @@ -161,14 +161,13 @@ func_container_id_generate(IUDEVICE * pdev, char * strContainerId) return 0; } - -static int -func_instance_id_generate(IUDEVICE * pdev, char *strInstanceId) +static int func_instance_id_generate(IUDEVICE* pdev, char* strInstanceId) { char instanceId[17]; memset(instanceId, 0, 17); sprintf(instanceId, "\\%s", pdev->getPath(pdev)); + /* format */ sprintf(strInstanceId, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", @@ -180,26 +179,27 @@ func_instance_id_generate(IUDEVICE * pdev, char *strInstanceId) return 0; } - #if ISOCH_FIFO -static void -func_lock_isoch_mutex(TRANSFER_DATA* transfer_data) + +static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data) { - IUDEVMAN * udevman = transfer_data->udevman; + int noAck = 0; IUDEVICE* pdev; uint32 FunctionId; uint32 RequestField; uint16 URB_Function; - int noAck = 0; + IUDEVMAN* udevman = transfer_data->udevman; if (transfer_data->cbSize >= 8) { data_read_uint32(transfer_data->pBuffer + 4, FunctionId); + if ((FunctionId == TRANSFER_IN_REQUEST || FunctionId == TRANSFER_OUT_REQUEST) && transfer_data->cbSize >= 16) { data_read_uint16(transfer_data->pBuffer + 14, URB_Function); + if (URB_Function == URB_FUNCTION_ISOCH_TRANSFER && transfer_data->cbSize >= 20) { @@ -208,20 +208,17 @@ func_lock_isoch_mutex(TRANSFER_DATA* transfer_data) if (!noAck) { - pdev = udevman->get_udevice_by_UsbDevice(udevman, - transfer_data->UsbDevice); + pdev = udevman->get_udevice_by_UsbDevice(udevman, transfer_data->UsbDevice); pdev->lock_fifo_isoch(pdev); } } } } } + #endif - -static int -urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK * callback, - char * data, uint32 data_sizem, uint32 MessageId) +static int urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback, char* data, uint32 data_sizem, uint32 MessageId) { uint32 InterfaceId; uint32 Version; @@ -236,27 +233,24 @@ urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK * callback, out_size = 16; out_data = (char *) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /* interface id */ - data_write_uint32(out_data + 4, MessageId); /* message id */ - data_write_uint32(out_data + 8, Version); /* usb protocol version */ - data_write_uint32(out_data + 12, 0x00000000); /* HRESULT */ - callback->channel->Write(callback->channel, out_size, (uint8 *)out_data, NULL); + data_write_uint32(out_data + 0, InterfaceId); /* interface id */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, Version); /* usb protocol version */ + data_write_uint32(out_data + 12, 0x00000000); /* HRESULT */ + callback->channel->Write(callback->channel, out_size, (uint8*) out_data, NULL); zfree(out_data); return 0; } -static int -urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK * callback, char * data, - uint32 data_sizem, - uint32 MessageId) +static int urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK* callback, char* data, uint32 data_sizem, uint32 MessageId) { uint32 InterfaceId; uint32 out_size; uint32 MajorVersion; uint32 MinorVersion; uint32 Capabilities; - char * out_data; + char* out_data; LLOGLN(10, ("urbdrc_process_channel_create")); data_read_uint32(data + 0, MajorVersion); @@ -268,25 +262,23 @@ urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK * callback, char * data, out_size = 24; out_data = (char *) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /* interface id */ - data_write_uint32(out_data + 4, MessageId); /* message id */ - data_write_uint32(out_data + 8, CHANNEL_CREATED); /* function id */ + data_write_uint32(out_data + 0, InterfaceId); /* interface id */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, CHANNEL_CREATED); /* function id */ data_write_uint32(out_data + 12, MajorVersion); data_write_uint32(out_data + 16, MinorVersion); - data_write_uint32(out_data + 20, Capabilities); /* capabilities version */ + data_write_uint32(out_data + 20, Capabilities); /* capabilities version */ callback->channel->Write(callback->channel, out_size, (uint8 *)out_data, NULL); zfree(out_data); return 0; } - -static int -urdbrc_send_virtual_channel_add(IWTSVirtualChannel * channel, uint32 MessageId) +static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, uint32 MessageId) { uint32 out_size; uint32 InterfaceId; - char * out_data; + char* out_data; LLOGLN(10, ("urdbrc_send_virtual_channel_add")); @@ -295,35 +287,33 @@ urdbrc_send_virtual_channel_add(IWTSVirtualChannel * channel, uint32 MessageId) out_size = 12; out_data = (char *) malloc(out_size); memset(out_data, 0, out_size); - data_write_uint32(out_data + 0, InterfaceId); /* interface */ - data_write_uint32(out_data + 4, MessageId); /* message id */ - data_write_uint32(out_data + 8, ADD_VIRTUAL_CHANNEL); /* function id */ + data_write_uint32(out_data + 0, InterfaceId); /* interface */ + data_write_uint32(out_data + 4, MessageId); /* message id */ + data_write_uint32(out_data + 8, ADD_VIRTUAL_CHANNEL); /* function id */ - channel->Write(channel, out_size, (uint8 *)out_data, NULL); + channel->Write(channel, out_size, (uint8*) out_data, NULL); zfree(out_data); return 0; } - - -static int -urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK * callback, IUDEVICE* pdev) +static int urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVICE* pdev) { - uint32 InterfaceId; - char HardwareIds[2][DEVICE_HARDWARE_ID_SIZE]; - char CompatibilityIds[3][DEVICE_COMPATIBILITY_ID_SIZE]; - char * out_data; - char strContainerId[DEVICE_CONTAINER_STR_SIZE]; - char strInstanceId[DEVICE_INSTANCE_STR_SIZE]; - char * composite_str = "USB\\COMPOSITE"; - int size, out_offset, cchCompatIds, bcdUSB; + char* out_data; + uint32 InterfaceId; + char HardwareIds[2][DEVICE_HARDWARE_ID_SIZE]; + char CompatibilityIds[3][DEVICE_COMPATIBILITY_ID_SIZE]; + char strContainerId[DEVICE_CONTAINER_STR_SIZE]; + char strInstanceId[DEVICE_INSTANCE_STR_SIZE]; + char* composite_str = "USB\\COMPOSITE"; + int size, out_offset, cchCompatIds, bcdUSB; LLOGLN(10, ("urdbrc_send_usb_device_add")); InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK); /* USB kernel driver detach!! */ pdev->detach_kernel_driver(pdev); + #if ISOCH_FIFO /* create/initial isoch queue */ pdev->set_isoch_queue(pdev, (void *)isoch_queue_new()); @@ -334,42 +324,44 @@ urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK * callback, IUDEVICE* pdev) func_instance_id_generate(pdev, strInstanceId); func_container_id_generate(pdev, strContainerId); - cchCompatIds = strlen(CompatibilityIds[0])+1 + - strlen(CompatibilityIds[1])+1 + - strlen(CompatibilityIds[2])+2; + cchCompatIds = strlen(CompatibilityIds[0]) + 1 + + strlen(CompatibilityIds[1]) + 1 + + strlen(CompatibilityIds[2]) + 2; - if(pdev->isCompositeDevice(pdev)) + if (pdev->isCompositeDevice(pdev)) cchCompatIds += strlen(composite_str)+1; out_offset = 24; size = 24; - size += (strlen(strInstanceId)+1)*2 + - (strlen(HardwareIds[0])+1)*2 + 4 + - (strlen(HardwareIds[1])+1)*2 + 2 + - 4 + (cchCompatIds)*2 + - (strlen(strContainerId)+1)*2 + 4 + 28; - out_data = (char *) malloc(size); + size += (strlen(strInstanceId)+1) * 2 + + (strlen(HardwareIds[0]) + 1) * 2 + 4 + + (strlen(HardwareIds[1]) + 1) * 2 + 2 + + 4 + (cchCompatIds) * 2 + + (strlen(strContainerId) + 1) * 2 + 4 + 28; + + out_data = (char*) malloc(size); memset(out_data, 0, size); - data_write_uint32(out_data + 0, InterfaceId); /* interface */ - data_write_uint32(out_data + 4, 0); /* message id */ - data_write_uint32(out_data + 8, ADD_DEVICE); /* function id */ - data_write_uint32(out_data + 12, 0x00000001); /* NumUsbDevice */ - data_write_uint32(out_data + 16, pdev->get_UsbDevice(pdev)); /* UsbDevice */ - data_write_uint32(out_data + 20, 0x00000025); /* cchDeviceInstanceId */ + + data_write_uint32(out_data + 0, InterfaceId); /* interface */ + data_write_uint32(out_data + 4, 0); /* message id */ + data_write_uint32(out_data + 8, ADD_DEVICE); /* function id */ + data_write_uint32(out_data + 12, 0x00000001); /* NumUsbDevice */ + data_write_uint32(out_data + 16, pdev->get_UsbDevice(pdev)); /* UsbDevice */ + data_write_uint32(out_data + 20, 0x00000025); /* cchDeviceInstanceId */ out_offset = fun_device_string_send_set(out_data, out_offset, strInstanceId); - data_write_uint32(out_data + out_offset, 0x00000036); /* cchHwIds */ + data_write_uint32(out_data + out_offset, 0x00000036); /* cchHwIds */ out_offset += 4; /* HardwareIds 1 */ out_offset = fun_device_string_send_set(out_data, out_offset, HardwareIds[0]); /* HardwareIds 2 */ out_offset = fun_device_string_send_set(out_data, out_offset, HardwareIds[1]); - data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ + data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ out_offset += 2; - data_write_uint32(out_data + out_offset, cchCompatIds); /* cchCompatIds */ + data_write_uint32(out_data + out_offset, cchCompatIds); /* cchCompatIds */ out_offset += 4; /* CompatibilityIds 1 */ out_offset = fun_device_string_send_set(out_data, out_offset, CompatibilityIds[0]); @@ -378,30 +370,33 @@ urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK * callback, IUDEVICE* pdev) /* CompatibilityIds 3 */ out_offset = fun_device_string_send_set(out_data, out_offset, CompatibilityIds[2]); - if(pdev->isCompositeDevice(pdev)) + if (pdev->isCompositeDevice(pdev)) out_offset = fun_device_string_send_set(out_data, out_offset, composite_str); - data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ + data_write_uint16(out_data + out_offset, 0x0000); /* add "\0" */ out_offset += 2; - data_write_uint32(out_data + out_offset, 0x00000027); /* cchContainerId */ + data_write_uint32(out_data + out_offset, 0x00000027); /* cchContainerId */ out_offset += 4; /* ContainerId */ out_offset = fun_device_string_send_set(out_data, out_offset, strContainerId); /* USB_DEVICE_CAPABILITIES 28 bytes */ - data_write_uint32(out_data + out_offset, 0x0000001c); /* CbSize */ - data_write_uint32(out_data + out_offset + 4, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */ - data_write_uint32(out_data + out_offset + 8, 0x600); /* USBDI_Version, 0x500 or 0x600 */ + data_write_uint32(out_data + out_offset, 0x0000001c); /* CbSize */ + data_write_uint32(out_data + out_offset + 4, 2); /* UsbBusInterfaceVersion, 0 ,1 or 2 */ + data_write_uint32(out_data + out_offset + 8, 0x600); /* USBDI_Version, 0x500 or 0x600 */ + /* Supported_USB_Version, 0x110,0x110 or 0x200(usb2.0) */ bcdUSB = pdev->query_device_descriptor(pdev, BCD_USB); data_write_uint32(out_data + out_offset + 12, bcdUSB); - data_write_uint32(out_data + out_offset + 16, 0x00000000); /* HcdCapabilities, MUST always be zero */ + data_write_uint32(out_data + out_offset + 16, 0x00000000); /* HcdCapabilities, MUST always be zero */ + if (bcdUSB < 0x200) - data_write_uint32(out_data + out_offset + 20, 0x00000000); /* DeviceIsHighSpeed */ + data_write_uint32(out_data + out_offset + 20, 0x00000000); /* DeviceIsHighSpeed */ else - data_write_uint32(out_data + out_offset + 20, 0x00000001); /* DeviceIsHighSpeed */ - data_write_uint32(out_data + out_offset + 24, 0x50); /* NoAckIsochWriteJitterBufferSizeInMs, >=10 or <=512 */ + data_write_uint32(out_data + out_offset + 20, 0x00000001); /* DeviceIsHighSpeed */ + + data_write_uint32(out_data + out_offset + 24, 0x50); /* NoAckIsochWriteJitterBufferSizeInMs, >=10 or <=512 */ out_offset += 28; callback->channel->Write(callback->channel, out_offset, (uint8 *)out_data, NULL); @@ -410,11 +405,7 @@ urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK * callback, IUDEVICE* pdev) return 0; } - -static int -urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK * callback, - char * pBuffer, - uint32 cbSize) +static int urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char* pBuffer, uint32 cbSize) { uint32 MessageId; uint32 FunctionId; @@ -427,33 +418,29 @@ urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK * callback, switch (FunctionId) { case RIM_EXCHANGE_CAPABILITY_REQUEST: - error = urbdrc_process_capability_request(callback, - pBuffer + 8, - cbSize - 8, - MessageId); + error = urbdrc_process_capability_request(callback, pBuffer + 8, cbSize - 8, MessageId); break; + default: LLOGLN(10, ("urbdrc_exchange_capabilities: unknown FunctionId 0x%X", FunctionId)); error = 1; break; } + return error; } - - -static void * -urbdrc_search_usb_device(void * arg) +static void* urbdrc_search_usb_device(void* arg) { USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) arg; URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) searchman->urbdrc; IUDEVMAN* udevman = urbdrc->udevman; - IWTSVirtualChannelManager * channel_mgr; - IWTSVirtualChannel * dvc_channel; + IWTSVirtualChannelManager* channel_mgr; + IWTSVirtualChannel* dvc_channel; USB_SEARCHDEV* sdev; - IUDEVICE * pdev = NULL; - struct wait_obj * listobj[2]; - struct wait_obj * mon_fd; + IUDEVICE* pdev = NULL; + struct wait_obj* listobj[2]; + struct wait_obj* mon_fd; int numobj, timeout; int busnum, devnum; int success = 0, error, on_close = 0, found = 0; @@ -463,12 +450,14 @@ urbdrc_search_usb_device(void * arg) channel_mgr = urbdrc->listener_callback->channel_mgr; /* init usb monitor */ - struct udev *udev; - struct udev_device *dev; - struct udev_monitor *mon; + struct udev* udev; + struct udev_device* dev; + struct udev_monitor* mon; udev = udev_new(); - if (!udev) { + + if (!udev) + { printf("Can't create udev\n"); return 0; } @@ -477,6 +466,7 @@ urbdrc_search_usb_device(void * arg) mon = udev_monitor_new_from_netlink(udev, "udev"); udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", "usb_device"); udev_monitor_enable_receiving(mon); + /* Get the file descriptor (fd) for the monitor. This fd will get passed to select() */ mon_fd = wait_obj_new_with_fd((void*) (size_t) udev_monitor_get_fd(mon)); @@ -494,6 +484,7 @@ urbdrc_search_usb_device(void * arg) listobj[1] = mon_fd; numobj = 2; wait_obj_select(listobj, numobj, -1); + if (wait_obj_is_set(searchman->term_event)) { sem_post(&searchman->sem_term); @@ -503,17 +494,20 @@ urbdrc_search_usb_device(void * arg) if (wait_obj_is_set(mon_fd)) { dev = udev_monitor_receive_device(mon); - if (dev) { - const char * action = udev_device_get_action(dev); + + if (dev) + { + const char* action = udev_device_get_action(dev); + if (strcmp(action, "add") == 0) { int idVendor, idProduct; success = 0; found = 0; - idVendor = strtol( - udev_device_get_sysattr_value(dev, "idVendor"), NULL, 16); - idProduct = strtol( - udev_device_get_sysattr_value(dev, "idProduct"), NULL, 16); + + idVendor = strtol(udev_device_get_sysattr_value(dev, "idVendor"), NULL, 16); + idProduct = strtol(udev_device_get_sysattr_value(dev, "idProduct"), NULL, 16); + if (idVendor < 0 || idProduct < 0) { udev_device_unref(dev); @@ -525,10 +519,13 @@ urbdrc_search_usb_device(void * arg) dvc_channel = channel_mgr->FindChannelById(channel_mgr, urbdrc->first_channel_id); + searchman->rewind(searchman); + while(dvc_channel && searchman->has_next(searchman)) { sdev = searchman->get_next(searchman); + if (sdev->idVendor == idVendor && sdev->idProduct == idProduct) { @@ -547,16 +544,15 @@ urbdrc_search_usb_device(void * arg) } if (found) - success = udevman->register_udevice(udevman, - busnum, - devnum, - searchman->UsbDevice, - 0, - 0, - UDEVMAN_FLAG_ADD_BY_ADDR); + { + success = udevman->register_udevice(udevman, busnum, devnum, + searchman->UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR); + } + if (success) { searchman->UsbDevice++; + /* when we send the usb device add request, * we will detach the device driver at same * time. But, if the time of detach the @@ -564,20 +560,24 @@ urbdrc_search_usb_device(void * arg) * the system will crash. workaround: we * wait it for some time to avoid system * crash. */ + listobj[0] = searchman->term_event; numobj = 1; timeout = 4000; /* milliseconds */ + wait_obj_select(listobj, numobj, timeout); + if (wait_obj_is_set(searchman->term_event)) { wait_obj_free(mon_fd); sem_post(&searchman->sem_term); return 0; } + error = urdbrc_send_virtual_channel_add(dvc_channel, 0); + if (found == 1) - searchman->remove(searchman, sdev->idVendor, - sdev->idProduct); + searchman->remove(searchman, sdev->idVendor, sdev->idProduct); } } else if (strcmp(action, "remove") == 0) @@ -588,17 +588,18 @@ urbdrc_search_usb_device(void * arg) usleep(500000); udevman->loading_lock(udevman); udevman->rewind(udevman); + while(udevman->has_next(udevman)) { pdev = udevman->get_next(udevman); - if (pdev->get_bus_number(pdev) == busnum && - pdev->get_dev_number(pdev) == devnum) + + if (pdev->get_bus_number(pdev) == busnum && pdev->get_dev_number(pdev) == devnum) { - dvc_channel = channel_mgr->FindChannelById(channel_mgr, - pdev->get_channel_id(pdev)); - if (dvc_channel == NULL){ - LLOGLN(0, ("SEARCH: dvc_channel %d is NULL!!", - pdev->get_channel_id(pdev))); + dvc_channel = channel_mgr->FindChannelById(channel_mgr, pdev->get_channel_id(pdev)); + + if (dvc_channel == NULL) + { + LLOGLN(0, ("SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev))); func_close_udevice(searchman, pdev); break; } @@ -608,16 +609,20 @@ urbdrc_search_usb_device(void * arg) dvc_channel->Write(dvc_channel, 0, NULL, NULL); pdev->SigToEnd(pdev); } + on_close = 1; break; } } + udevman->loading_unlock(udevman); listobj[0] = searchman->term_event; numobj = 1; timeout = 3000; /* milliseconds */ + wait_obj_select(listobj, numobj, timeout); + if (wait_obj_is_set(searchman->term_event)) { wait_obj_free(mon_fd); @@ -625,13 +630,13 @@ urbdrc_search_usb_device(void * arg) return 0; } - if(pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) && - !(pdev->isChannelClosed(pdev))) + if(pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) && !(pdev->isChannelClosed(pdev))) { on_close = 0; dvc_channel->Close(dvc_channel); } } + udev_device_unref(dev); } else { @@ -646,22 +651,19 @@ urbdrc_search_usb_device(void * arg) return 0; } - -void * -urbdrc_new_device_create(void * arg) +void* urbdrc_new_device_create(void * arg) { TRANSFER_DATA* transfer_data = (TRANSFER_DATA*) arg; - URBDRC_CHANNEL_CALLBACK * callback = transfer_data->callback; - IWTSVirtualChannelManager * channel_mgr; - URBDRC_PLUGIN * urbdrc = transfer_data->urbdrc; - USB_SEARCHMAN * searchman = urbdrc->searchman; - uint8 * pBuffer = transfer_data->pBuffer; - //uint32 cbSize = transfer_data->cbSize; - IUDEVMAN * udevman = transfer_data->udevman; - IUDEVICE * pdev = NULL; - uint32 ChannelId = 0; - uint32 MessageId; - uint32 FunctionId; + URBDRC_CHANNEL_CALLBACK* callback = transfer_data->callback; + IWTSVirtualChannelManager* channel_mgr; + URBDRC_PLUGIN* urbdrc = transfer_data->urbdrc; + USB_SEARCHMAN* searchman = urbdrc->searchman; + uint8* pBuffer = transfer_data->pBuffer; + IUDEVMAN* udevman = transfer_data->udevman; + IUDEVICE* pdev = NULL; + uint32 ChannelId = 0; + uint32 MessageId; + uint32 FunctionId; int i = 0, found = 0; channel_mgr = urbdrc->listener_callback->channel_mgr; @@ -671,22 +673,27 @@ urbdrc_new_device_create(void * arg) data_read_uint32(pBuffer + 4, FunctionId); int error = 0; - switch (urbdrc->vchannel_status){ + + switch (urbdrc->vchannel_status) + { case INIT_CHANNEL_IN: urbdrc->first_channel_id = ChannelId; searchman->start(searchman, urbdrc_search_usb_device); - for(i=0; i < udevman->get_device_num(udevman); i++) - { + for (i = 0; i < udevman->get_device_num(udevman); i++) error = urdbrc_send_virtual_channel_add(callback->channel, MessageId); - } + urbdrc->vchannel_status = INIT_CHANNEL_OUT; break; - case INIT_CHANNEL_OUT: + + case INIT_CHANNEL_OUT: udevman->loading_lock(udevman); udevman->rewind(udevman); - while(udevman->has_next(udevman)){ + + while(udevman->has_next(udevman)) + { pdev = udevman->get_next(udevman); + if (!pdev->isAlreadySend(pdev)) { found = 1; @@ -703,12 +710,15 @@ urbdrc_new_device_create(void * arg) * the device driver at same time. But, if the time of detach the * driver and attach driver is too close, the system will crash. * workaround: we wait it for some time to avoid system crash. */ + error = pdev->wait_for_detach(pdev); + if (error >= 0) urdbrc_send_usb_device_add(callback, pdev); } break; + default: LLOGLN(0, ("urbdrc_new_device_create: vchannel_status unknown value %d", urbdrc->vchannel_status)); @@ -718,16 +728,12 @@ urbdrc_new_device_create(void * arg) return 0; } - - -static int -urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, - char * pBuffer, uint32 cbSize) +static int urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback, char* pBuffer, uint32 cbSize) { - URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) callback->plugin; + int i, error = 0; uint32 MessageId; uint32 FunctionId; - int i, error = 0; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) callback->plugin; data_read_uint32(pBuffer + 0, MessageId); data_read_uint32(pBuffer + 4, FunctionId); @@ -737,6 +743,7 @@ urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, case CHANNEL_CREATED: error = urbdrc_process_channel_create(callback, pBuffer + 8, cbSize - 8, MessageId); break; + case RIMCALL_RELEASE: LLOGLN(10, ("urbdrc_process_channel_notification: recv RIMCALL_RELEASE")); pthread_t thread; @@ -750,6 +757,7 @@ urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, transfer_data->urbdrc = urbdrc; transfer_data->cbSize = cbSize; transfer_data->pBuffer = (uint8 *)malloc((cbSize)); + for (i = 0; i < (cbSize); i++) { transfer_data->pBuffer[i] = pBuffer[i]; @@ -758,6 +766,7 @@ urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, pthread_create(&thread, 0, urbdrc_new_device_create, transfer_data); pthread_detach(thread); break; + default: LLOGLN(10, ("urbdrc_process_channel_notification: unknown FunctionId 0x%X", FunctionId)); error = 1; @@ -766,28 +775,29 @@ urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK * callback, return error; } - - - -static int -urbdrc_on_data_received(IWTSVirtualChannelCallback * pChannelCallback, - uint32 cbSize, - uint8 * Buffer) +static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, uint32 cbSize, uint8* Buffer) { - URBDRC_CHANNEL_CALLBACK * callback = (URBDRC_CHANNEL_CALLBACK *) pChannelCallback; - URBDRC_PLUGIN * urbdrc; - IUDEVMAN * udevman; - uint32 InterfaceTemp; - uint32 InterfaceId; - uint32 Mask; - int error = 0; - char * pBuffer = (char *) Buffer; + URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*) pChannelCallback; + URBDRC_PLUGIN* urbdrc; + IUDEVMAN* udevman; + uint32 InterfaceTemp; + uint32 InterfaceId; + uint32 Mask; + int error = 0; + char* pBuffer = (char*) Buffer; - if (callback == NULL) return 0; - if (callback->plugin == NULL) return 0; - urbdrc = (URBDRC_PLUGIN *) callback->plugin; - if (urbdrc->udevman == NULL) return 0; - udevman = (IUDEVMAN *) urbdrc->udevman; + if (callback == NULL) + return 0; + + if (callback->plugin == NULL) + return 0; + + urbdrc = (URBDRC_PLUGIN*) callback->plugin; + + if (urbdrc->udevman == NULL) + return 0; + + udevman = (IUDEVMAN*) urbdrc->udevman; data_read_uint32(pBuffer + 0, InterfaceTemp); InterfaceId = (InterfaceTemp & 0x0fffffff); @@ -799,17 +809,21 @@ urbdrc_on_data_received(IWTSVirtualChannelCallback * pChannelCallback, case CAPABILITIES_NEGOTIATOR: error = urbdrc_exchange_capabilities(callback, pBuffer + 4, cbSize - 4); break; + case SERVER_CHANNEL_NOTIFICATION: error = urbdrc_process_channel_notification(callback, pBuffer + 4, cbSize - 4); break; + default: LLOGLN(10, ("urbdrc_on_data_received: InterfaceId 0x%X Start matching devices list", InterfaceId)); - pthread_t thread; - TRANSFER_DATA* transfer_data; + pthread_t thread; + TRANSFER_DATA* transfer_data; + + transfer_data = (TRANSFER_DATA*) malloc(sizeof(TRANSFER_DATA)); - transfer_data = (TRANSFER_DATA*)malloc(sizeof(TRANSFER_DATA)); if (transfer_data == NULL) printf("transfer_data is NULL!!"); + transfer_data->callback = callback; transfer_data->urbdrc = urbdrc; transfer_data->udevman = udevman; @@ -828,27 +842,25 @@ urbdrc_on_data_received(IWTSVirtualChannelCallback * pChannelCallback, #endif error = pthread_create(&thread, 0, urbdrc_process_udev_data_transfer, transfer_data); + if (error < 0) LLOGLN(0, ("Create Data Transfer Thread got error = %d", error)); else pthread_detach(thread); - //urbdrc_process_udev_data_transfer(transfer_data); - break; } return 0; } -static int -urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) +static int urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) { - URBDRC_CHANNEL_CALLBACK * callback = (URBDRC_CHANNEL_CALLBACK *) pChannelCallback; - URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) callback->plugin; - IUDEVMAN * udevman = (IUDEVMAN *) urbdrc->udevman; - USB_SEARCHMAN * searchman = (USB_SEARCHMAN*) urbdrc->searchman; - IUDEVICE * pdev = NULL; + URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*) pChannelCallback; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) callback->plugin; + IUDEVMAN* udevman = (IUDEVMAN*) urbdrc->udevman; + USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) urbdrc->searchman; + IUDEVICE* pdev = NULL; uint32 ChannelId = 0; int found = 0; @@ -858,16 +870,20 @@ urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) udevman->loading_lock(udevman); udevman->rewind(udevman); + while(udevman->has_next(udevman)) { pdev = udevman->get_next(udevman); + if (pdev->get_channel_id(pdev) == ChannelId) { found = 1; break; } } + udevman->loading_unlock(udevman); + if (found && pdev && !(pdev->isChannelClosed(pdev))) { pdev->setChannelClosed(pdev); @@ -881,36 +897,32 @@ urbdrc_on_close(IWTSVirtualChannelCallback * pChannelCallback) return 0; } -static int -urbdrc_on_new_channel_connection(IWTSListenerCallback * pListenerCallback, - IWTSVirtualChannel * pChannel, - uint8 * pData, - int * pbAccept, - IWTSVirtualChannelCallback ** ppCallback) +static int urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCallback, + IWTSVirtualChannel * pChannel, uint8* pData, int* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - URBDRC_LISTENER_CALLBACK * listener_callback = (URBDRC_LISTENER_CALLBACK *) pListenerCallback; - URBDRC_CHANNEL_CALLBACK * callback; + URBDRC_LISTENER_CALLBACK* listener_callback = (URBDRC_LISTENER_CALLBACK*) pListenerCallback; + URBDRC_CHANNEL_CALLBACK* callback; LLOGLN(10, ("urbdrc_on_new_channel_connection:")); - callback = (URBDRC_CHANNEL_CALLBACK *) malloc(sizeof(URBDRC_CHANNEL_CALLBACK)); + callback = (URBDRC_CHANNEL_CALLBACK*) malloc(sizeof(URBDRC_CHANNEL_CALLBACK)); callback->iface.OnDataReceived = urbdrc_on_data_received; callback->iface.OnClose = urbdrc_on_close; callback->plugin = listener_callback->plugin; callback->channel_mgr = listener_callback->channel_mgr; callback->channel = pChannel; - *ppCallback = (IWTSVirtualChannelCallback *) callback; + *ppCallback = (IWTSVirtualChannelCallback*) callback; + return 0; } -static int -urbdrc_plugin_initialize(IWTSPlugin * pPlugin, IWTSVirtualChannelManager * pChannelMgr) +static int urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr) { - URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) pPlugin; - IUDEVMAN * udevman = NULL; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; + IUDEVMAN* udevman = NULL; USB_SEARCHMAN * searchman = NULL; LLOGLN(10, ("urbdrc_plugin_initialize:")); - urbdrc->listener_callback = (URBDRC_LISTENER_CALLBACK *) malloc(sizeof(URBDRC_LISTENER_CALLBACK)); + urbdrc->listener_callback = (URBDRC_LISTENER_CALLBACK*) malloc(sizeof(URBDRC_LISTENER_CALLBACK)); memset(urbdrc->listener_callback, 0, sizeof(URBDRC_LISTENER_CALLBACK)); urbdrc->listener_callback->iface.OnNewChannelConnection = urbdrc_on_new_channel_connection; @@ -919,19 +931,18 @@ urbdrc_plugin_initialize(IWTSPlugin * pPlugin, IWTSVirtualChannelManager * pChan /* Init searchman */ udevman = urbdrc->udevman; - searchman = searchman_new((void *)urbdrc, udevman->get_defUsbDevice(udevman)); + searchman = searchman_new((void*) urbdrc, udevman->get_defUsbDevice(udevman)); urbdrc->searchman = searchman; return pChannelMgr->CreateListener(pChannelMgr, "URBDRC", 0, (IWTSListenerCallback *) urbdrc->listener_callback, NULL); } -static int -urbdrc_plugin_terminated(IWTSPlugin * pPlugin) +static int urbdrc_plugin_terminated(IWTSPlugin* pPlugin) { - URBDRC_PLUGIN * urbdrc = (URBDRC_PLUGIN *) pPlugin; - IUDEVMAN* udevman = urbdrc->udevman; - USB_SEARCHMAN* searchman = urbdrc->searchman; + URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; + IUDEVMAN* udevman = urbdrc->udevman; + USB_SEARCHMAN* searchman = urbdrc->searchman; LLOGLN(10, ("urbdrc_plugin_terminated:")); @@ -939,6 +950,7 @@ urbdrc_plugin_terminated(IWTSPlugin * pPlugin) { /* close searchman */ searchman->close(searchman); + /* free searchman */ if (searchman->strated) { @@ -947,6 +959,7 @@ urbdrc_plugin_terminated(IWTSPlugin * pPlugin) ts.tv_nsec = 0; sem_timedwait(&searchman->sem_term, &ts); } + searchman->free(searchman); searchman = NULL; } @@ -959,14 +972,14 @@ urbdrc_plugin_terminated(IWTSPlugin * pPlugin) if (urbdrc->listener_callback) zfree(urbdrc->listener_callback); + if(urbdrc) zfree(urbdrc); + return 0; } - -static void -urbdrc_register_udevman_plugin(IWTSPlugin* pPlugin, IUDEVMAN* udevman) +static void urbdrc_register_udevman_plugin(IWTSPlugin* pPlugin, IUDEVMAN* udevman) { URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) pPlugin; @@ -981,10 +994,7 @@ urbdrc_register_udevman_plugin(IWTSPlugin* pPlugin, IUDEVMAN* udevman) urbdrc->udevman = udevman; } - - -static int -urbdrc_load_udevman_plugin(IWTSPlugin* pPlugin, const char* name, RDP_PLUGIN_DATA* data) +static int urbdrc_load_udevman_plugin(IWTSPlugin* pPlugin, const char* name, RDP_PLUGIN_DATA* data) { char* fullname; PFREERDP_URBDRC_DEVICE_ENTRY entry; @@ -1019,11 +1029,7 @@ urbdrc_load_udevman_plugin(IWTSPlugin* pPlugin, const char* name, RDP_PLUGIN_DAT return true; } - - - -static int -urbdrc_process_plugin_data(IWTSPlugin* pPlugin, RDP_PLUGIN_DATA* data) +static int urbdrc_process_plugin_data(IWTSPlugin* pPlugin, RDP_PLUGIN_DATA* data) { boolean ret; @@ -1036,9 +1042,7 @@ urbdrc_process_plugin_data(IWTSPlugin* pPlugin, RDP_PLUGIN_DATA* data) return true; } - -int -DVCPluginEntry(IDRDYNVC_ENTRY_POINTS * pEntryPoints) +int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) { int error = 0; URBDRC_PLUGIN* urbdrc; @@ -1059,6 +1063,7 @@ DVCPluginEntry(IDRDYNVC_ENTRY_POINTS * pEntryPoints) urbdrc->vchannel_status = INIT_CHANNEL_IN; urbdrc_debug = 10; + if (data->data[2] && strstr((char *)data->data[2], "debug")) urbdrc_debug = 0; @@ -1070,4 +1075,3 @@ DVCPluginEntry(IDRDYNVC_ENTRY_POINTS * pEntryPoints) return error; } - From 4b13b4aabb32894ba8b59555ff1d7b5701c9ec6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 2 Oct 2012 17:27:08 -0400 Subject: [PATCH 64/64] urbdrc: disable by default --- channels/urbdrc/ChannelOptions.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/channels/urbdrc/ChannelOptions.cmake b/channels/urbdrc/ChannelOptions.cmake index 78a631eed..dbf01a2dc 100644 --- a/channels/urbdrc/ChannelOptions.cmake +++ b/channels/urbdrc/ChannelOptions.cmake @@ -6,10 +6,6 @@ set(CHANNEL_SPECIFICATIONS "[MS-RDPEUSB]") string(TOUPPER "WITH_${CHANNEL_SHORT_NAME}" CHANNEL_OPTION) -if(WIN32) - option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF) -else() - option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" ON) -endif() +option(${CHANNEL_OPTION} "Build ${CHANNEL_SHORT_NAME}" OFF)