diff --git a/CMakeLists.txt b/CMakeLists.txt index 026d1784d..0b6b6c8be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,9 +170,7 @@ add_subdirectory(libfreerdp-channels) add_subdirectory(libfreerdp-locale) add_subdirectory(libfreerdp-core) -if(NOT WIN32) - add_subdirectory(channels) -endif() +add_subdirectory(channels) option(WITH_CLIENT "Build client binaries" ON) if(WITH_CLIENT) diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index efb877c08..2cbc568b3 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -17,11 +17,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(cliprdr) add_subdirectory(drdynvc) add_subdirectory(rdpdbg) -add_subdirectory(rdpdr) -add_subdirectory(rail) -add_subdirectory(rdpsnd) add_subdirectory(skel) +if(NOT WIN32) + add_subdirectory(rdpdr) + add_subdirectory(cliprdr) + add_subdirectory(rail) + add_subdirectory(rdpsnd) +endif() diff --git a/channels/drdynvc/CMakeLists.txt b/channels/drdynvc/CMakeLists.txt index 1e3cc13f3..602d41c62 100644 --- a/channels/drdynvc/CMakeLists.txt +++ b/channels/drdynvc/CMakeLists.txt @@ -32,6 +32,8 @@ target_link_libraries(drdynvc freerdp-utils) install(TARGETS drdynvc DESTINATION ${FREERDP_PLUGIN_PATH}) -add_subdirectory(tsmf) -add_subdirectory(audin) +if(NOT WIN32) + add_subdirectory(tsmf) +endif() +add_subdirectory(audin) diff --git a/channels/drdynvc/audin/audin_main.c b/channels/drdynvc/audin/audin_main.c index 095c53967..c9b6e8fc0 100644 --- a/channels/drdynvc/audin/audin_main.c +++ b/channels/drdynvc/audin/audin_main.c @@ -248,7 +248,7 @@ static int audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, STRE DEBUG_DVC("FramesPerPacket=%d initialFormat=%d", FramesPerPacket, initialFormat); - if (initialFormat >= callback->formats_count) + if (initialFormat >= (uint32) callback->formats_count) { DEBUG_WARN("invalid format index %d (total %d)", initialFormat, callback->formats_count); @@ -279,7 +279,7 @@ static int audin_process_format_change(IWTSVirtualChannelCallback* pChannelCallb DEBUG_DVC("NewFormat=%d", NewFormat); - if (NewFormat >= callback->formats_count) + if (NewFormat >= (uint32) callback->formats_count) { DEBUG_WARN("invalid format index %d (total %d)", NewFormat, callback->formats_count); diff --git a/channels/drdynvc/dvcman.c b/channels/drdynvc/dvcman.c index d24b11489..9bd210af0 100644 --- a/channels/drdynvc/dvcman.c +++ b/channels/drdynvc/dvcman.c @@ -194,7 +194,7 @@ int dvcman_load_plugin(IWTSVirtualChannelManager* pChannelMgr, RDP_PLUGIN_DATA* while (data && data->size > 0) { - pDVCPluginEntry = freerdp_load_plugin((char*) data->data[0], "DVCPluginEntry"); + pDVCPluginEntry = (PDVC_PLUGIN_ENTRY) freerdp_load_plugin((char*) data->data[0], "DVCPluginEntry"); if (pDVCPluginEntry != NULL) { @@ -206,7 +206,7 @@ int dvcman_load_plugin(IWTSVirtualChannelManager* pChannelMgr, RDP_PLUGIN_DATA* pDVCPluginEntry((IDRDYNVC_ENTRY_POINTS*) &entryPoints); } - data = (RDP_PLUGIN_DATA*)(((void*) data) + data->size); + data = (RDP_PLUGIN_DATA*)(((uint8*) data) + data->size); } return 0; @@ -414,7 +414,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, uint32 C if (channel->dvc_data) { /* Fragmented data */ - if (stream_get_length(channel->dvc_data) + data_size > stream_get_size(channel->dvc_data)) + if (stream_get_length(channel->dvc_data) + data_size > (uint32) stream_get_size(channel->dvc_data)) { DEBUG_WARN("data exceeding declared length!"); stream_free(channel->dvc_data); diff --git a/channels/drdynvc/tsmf/tsmf_ifman.c b/channels/drdynvc/tsmf/tsmf_ifman.c index 1881d15d5..4e49d271a 100644 --- a/channels/drdynvc/tsmf/tsmf_ifman.c +++ b/channels/drdynvc/tsmf/tsmf_ifman.c @@ -228,14 +228,18 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) { - DEBUG_DVC("on stream volume"); TSMF_PRESENTATION* presentation; + + DEBUG_DVC("on stream volume"); + presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) { - stream_seek(ifman->input, 16); uint32 newVolume; uint32 muted; + + stream_seek(ifman->input, 16); stream_read_uint32(ifman->input, newVolume); DEBUG_DVC("on stream volume: new volume=[%d]", newVolume); stream_read_uint32(ifman->input, muted); @@ -243,28 +247,37 @@ int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) tsmf_presentation_volume_changed(presentation, newVolume, muted); } else + { DEBUG_WARN("unknown presentation id"); + } ifman->output_pending = true; + return 0; } int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman) { - DEBUG_DVC("on channel volume"); TSMF_PRESENTATION* presentation; + + DEBUG_DVC("on channel volume"); + presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) { - stream_seek(ifman->input, 16); uint32 channelVolume; uint32 changedChannel; + + stream_seek(ifman->input, 16); stream_read_uint32(ifman->input, channelVolume); DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume); stream_read_uint32(ifman->input, changedChannel); DEBUG_DVC("on stream volume: changed channel=[%d]", changedChannel); } + ifman->output_pending = true; + return 0; } @@ -310,7 +323,9 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects); if (presentation == NULL) + { error = 1; + } else { if (num_rects > 0) @@ -335,7 +350,9 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) } tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects, rects); } + ifman->output_pending = true; + return error; } @@ -472,11 +489,13 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman) int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman) { + TSMF_PRESENTATION* presentation; + DEBUG_DVC(""); ifman->output_pending = true; /* Added pause control so gstreamer pipeline can be paused accordingly */ - TSMF_PRESENTATION* presentation; + presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); if (presentation) tsmf_presentation_paused(presentation); @@ -487,16 +506,20 @@ int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman) int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman) { + TSMF_PRESENTATION* presentation; + DEBUG_DVC(""); ifman->output_pending = true; /* Added restart control so gstreamer pipeline can be resumed accordingly */ - TSMF_PRESENTATION* presentation; + presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) tsmf_presentation_restarted(presentation); else DEBUG_WARN("unknown presentation id"); + return 0; } @@ -507,6 +530,7 @@ int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) tsmf_presentation_stop(presentation); else diff --git a/channels/drdynvc/tsmf/tsmf_main.c b/channels/drdynvc/tsmf/tsmf_main.c index e0c944d3a..66823d2fb 100644 --- a/channels/drdynvc/tsmf/tsmf_main.c +++ b/channels/drdynvc/tsmf/tsmf_main.c @@ -416,7 +416,7 @@ static void tsmf_process_plugin_data(IWTSPlugin* pPlugin, RDP_PLUGIN_DATA* data) } } - data = (RDP_PLUGIN_DATA*)(((void*)data) + data->size); + data = (RDP_PLUGIN_DATA*)(((uint8*)data) + data->size); } } diff --git a/channels/drdynvc/tsmf/tsmf_media.c b/channels/drdynvc/tsmf/tsmf_media.c index fb34c9409..3bda3d04a 100644 --- a/channels/drdynvc/tsmf/tsmf_media.c +++ b/channels/drdynvc/tsmf/tsmf_media.c @@ -22,8 +22,15 @@ #include #include #include + +#ifdef HAVE_UNISTD_H #include +#endif + +#ifndef _WIN32 #include +#endif + #include #include #include @@ -238,18 +245,19 @@ static void tsmf_stream_process_ack(TSMF_STREAM* stream) TSMF_PRESENTATION* tsmf_presentation_new(const uint8* guid, IWTSVirtualChannelCallback* pChannelCallback) { + TSMF_PRESENTATION* presentation; pthread_t thid = pthread_self(); FILE* fout = NULL; fout = fopen("/tmp/tsmf.tid", "wt"); + if (fout) { fprintf(fout, "%d\n", (int) thid); fclose(fout); } - TSMF_PRESENTATION* presentation; - presentation = tsmf_presentation_find_by_id(guid); + if (presentation) { DEBUG_WARN("duplicated presentation id!"); @@ -319,6 +327,7 @@ static void tsmf_sample_playback_video(TSMF_SAMPLE* sample) if (sample->data) { t = get_current_time(); + if (stream->next_start_time > t && (sample->end_time >= presentation->audio_start_time || sample->end_time < stream->last_end_time)) @@ -1006,14 +1015,17 @@ void tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pC uint32 sample_id, uint64 start_time, uint64 end_time, uint64 duration, uint32 extensions, uint32 data_size, uint8* data) { + TSMF_SAMPLE* sample; + pthread_mutex_lock(&tsmf_mutex); + if (TERMINATING) { pthread_mutex_unlock(&tsmf_mutex); return; } + pthread_mutex_unlock(&tsmf_mutex); - TSMF_SAMPLE* sample; sample = xnew(TSMF_SAMPLE); @@ -1033,6 +1045,8 @@ void tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pC freerdp_thread_unlock(stream->thread); } +#ifndef _WIN32 + static void tsmf_signal_handler(int s) { pthread_mutex_lock(&tsmf_mutex); @@ -1069,14 +1083,18 @@ static void tsmf_signal_handler(int s) } } +#endif + void tsmf_media_init(void) { +#ifndef _WIN32 struct sigaction sigtrap; sigtrap.sa_handler = tsmf_signal_handler; sigemptyset(&sigtrap.sa_mask); sigtrap.sa_flags = 0; sigaction(SIGINT, &sigtrap, 0); sigaction(SIGUSR1, &sigtrap, 0); +#endif if (presentation_list == NULL) presentation_list = list_new(); diff --git a/channels/rdpdr/CMakeLists.txt b/channels/rdpdr/CMakeLists.txt index e43aeff7b..b24836e12 100644 --- a/channels/rdpdr/CMakeLists.txt +++ b/channels/rdpdr/CMakeLists.txt @@ -37,10 +37,12 @@ target_link_libraries(rdpdr freerdp-utils) install(TARGETS rdpdr DESTINATION ${FREERDP_PLUGIN_PATH}) -add_subdirectory(disk) -add_subdirectory(printer) -add_subdirectory(parallel) -add_subdirectory(serial) +if(NOT WIN32) + add_subdirectory(disk) + add_subdirectory(printer) + add_subdirectory(parallel) + add_subdirectory(serial) +endif() if(WITH_PCSC) add_subdirectory(smartcard) diff --git a/channels/rdpdr/disk/disk_file.h b/channels/rdpdr/disk/disk_file.h index 68252dfd9..2d85bf80e 100644 --- a/channels/rdpdr/disk/disk_file.h +++ b/channels/rdpdr/disk/disk_file.h @@ -22,11 +22,14 @@ #define __DISK_FILE_H #include -#include #include -#include -#if defined WIN32 +#ifndef _WIN32 +#include +#include +#endif + +#ifdef _WIN32 #define STAT stat #define OPEN open #define LSEEK lseek @@ -60,10 +63,6 @@ (_f->delete_pending ? FILE_ATTRIBUTE_TEMPORARY : 0) | \ (st.st_mode & S_IWUSR ? 0 : FILE_ATTRIBUTE_READONLY)) - - - - typedef struct _DISK_FILE DISK_FILE; struct _DISK_FILE { diff --git a/channels/rdpdr/parallel/parallel_main.c b/channels/rdpdr/parallel/parallel_main.c index 934def095..94435841c 100644 --- a/channels/rdpdr/parallel/parallel_main.c +++ b/channels/rdpdr/parallel/parallel_main.c @@ -22,12 +22,19 @@ #include #include +#ifdef HAVE_UNISTD_H #include +#endif + #include -#include #include + +#ifndef _WIN32 +#include #include #include +#endif + #ifdef __LINUX__ #include #include @@ -74,6 +81,7 @@ static void parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp) parallel->id = irp->devman->id_sequence++; parallel->file = open(parallel->path, O_RDWR); + if (parallel->file < 0) { irp->IoStatus = STATUS_ACCESS_DENIED; @@ -163,6 +171,7 @@ static void parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp) DEBUG_SVC("Length %u Offset %llu", Length, Offset); len = Length; + while (len > 0) { status = write(parallel->file, stream_get_tail(irp->input), len); diff --git a/channels/rdpdr/rdpdr_constants.h b/channels/rdpdr/rdpdr_constants.h index ce8b7f00b..ceb2f6cfe 100644 --- a/channels/rdpdr/rdpdr_constants.h +++ b/channels/rdpdr/rdpdr_constants.h @@ -124,6 +124,8 @@ enum FILE_CREATE_OPTION }; /* DR_CREATE_REQ.DesiredAccess [MS-SMB2] */ + +#ifndef _WIN32 enum FILE_ACCESS { FILE_READ_DATA = 0x00000001, @@ -146,6 +148,7 @@ enum FILE_ACCESS GENERIC_WRITE = 0x40000000, GENERIC_READ = 0x80000000 }; +#endif /* DR_CREATE_RSP.Information */ /* DR_DRIVE_CREATE_RSP.DeviceCreateResponse */ @@ -221,8 +224,10 @@ enum RDP_LOWIO_OP enum NTSTATUS { STATUS_SUCCESS = 0x00000000, +#ifndef _WIN32 STATUS_TIMEOUT = 0x00000102, STATUS_PENDING = 0x00000103, +#endif STATUS_REPARSE = 0x00000104, STATUS_MORE_ENTRIES = 0x00000105, STATUS_NOT_ALL_ASSIGNED = 0x00000106, @@ -245,8 +250,10 @@ enum NTSTATUS STATUS_UNSUCCESSFUL = 0xC0000001, STATUS_NOT_IMPLEMENTED = 0xC0000002, STATUS_INVALID_INFO_CLASS = 0xC0000003, +#ifndef _WIN32 STATUS_INVALID_HANDLE = 0xC0000008, STATUS_INVALID_PARAMETER = 0xC000000D, +#endif STATUS_NO_SUCH_DEVICE = 0xC000000E, STATUS_NO_SUCH_FILE = 0xC000000F, STATUS_INVALID_DEVICE_REQUEST = 0xC0000010, @@ -289,6 +296,9 @@ enum RDPDR_PRINTER_ANNOUNCE_FLAG }; /* [MS-FSCC] FileAttributes */ + +#ifndef _WIN32 + enum FILE_ATTRIBUTE { FILE_ATTRIBUTE_ARCHIVE = 0x00000020, @@ -306,6 +316,8 @@ enum FILE_ATTRIBUTE FILE_ATTRIBUTE_TEMPORARY = 0x00000100 }; +#endif + /* [MS-FSCC] FSCTL Structures */ enum FSCTL_STRUCTURE { @@ -337,6 +349,9 @@ enum FSCTL_STRUCTURE }; /* [MS-FSCC] FileFsAttributeInformation.FileSystemAttributes */ + +#ifndef _WIN32 + enum FILE_FS_ATTRIBUTE_INFORMATION { FILE_SUPPORTS_USN_JOURNAL = 0x02000000, @@ -361,6 +376,8 @@ enum FILE_FS_ATTRIBUTE_INFORMATION FILE_CASE_SENSITIVE_SEARCH = 0x00000001 }; +#endif + /* [MS-FSCC] FileFsDeviceInformation.DeviceType */ enum FILE_FS_DEVICE_TYPE { diff --git a/channels/rdpdr/rdpdr_main.c b/channels/rdpdr/rdpdr_main.c index f9d9a587a..c8c10925d 100644 --- a/channels/rdpdr/rdpdr_main.c +++ b/channels/rdpdr/rdpdr_main.c @@ -59,7 +59,7 @@ static void rdpdr_process_connect(rdpSvcPlugin* plugin) { devman_load_device_service(rdpdr->devman, data); } - data = (RDP_PLUGIN_DATA*) (((void*) data) + data->size); + data = (RDP_PLUGIN_DATA*) (((uint8*) data) + data->size); } } @@ -83,7 +83,7 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) stream_write_uint16(data_out, rdpdr->versionMajor); stream_write_uint16(data_out, rdpdr->versionMinor); - stream_write_uint32(data_out, rdpdr->clientID); + stream_write_uint32(data_out, (uint32) rdpdr->clientID); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); } diff --git a/channels/rdpdr/serial/serial_tty.c b/channels/rdpdr/serial/serial_tty.c index bdca70372..3408b5c57 100644 --- a/channels/rdpdr/serial/serial_tty.c +++ b/channels/rdpdr/serial/serial_tty.c @@ -30,13 +30,16 @@ #include #include +#ifndef _WIN32 #include #include +#include +#include +#endif + #include #include #include -#include -#include #include #include "rdpdr_constants.h" diff --git a/channels/rdpdr/serial/serial_tty.h b/channels/rdpdr/serial/serial_tty.h index a4b82f98f..d9b76414e 100644 --- a/channels/rdpdr/serial/serial_tty.h +++ b/channels/rdpdr/serial/serial_tty.h @@ -23,7 +23,10 @@ #include #include + +#ifndef _WIN32 #include +#endif typedef struct _SERIAL_TTY SERIAL_TTY; struct _SERIAL_TTY @@ -59,7 +62,6 @@ struct _SERIAL_TTY int event_pending; }; - SERIAL_TTY* serial_tty_new(const char* path, uint32 id); void serial_tty_free(SERIAL_TTY* tty); diff --git a/channels/rdpsnd/rdpsnd_main.c b/channels/rdpsnd/rdpsnd_main.c index ca774d8ad..c6b4a75cb 100644 --- a/channels/rdpsnd/rdpsnd_main.c +++ b/channels/rdpsnd/rdpsnd_main.c @@ -477,7 +477,7 @@ static void rdpsnd_process_plugin_data(rdpsndPlugin* rdpsnd, RDP_PLUGIN_DATA* da static void rdpsnd_process_connect(rdpSvcPlugin* plugin) { - rdpsndPlugin* rdpsnd = (rdpsndPlugin*)plugin; + rdpsndPlugin* rdpsnd = (rdpsndPlugin*) plugin; RDP_PLUGIN_DATA* data; RDP_PLUGIN_DATA default_data[2] = { { 0 }, { 0 } }; @@ -489,10 +489,11 @@ static void rdpsnd_process_connect(rdpSvcPlugin* plugin) rdpsnd->latency = -1; data = (RDP_PLUGIN_DATA*)plugin->channel_entry_points.pExtendedData; + while (data && data->size > 0) { rdpsnd_process_plugin_data(rdpsnd, data); - data = (RDP_PLUGIN_DATA*) (((void*) data) + data->size); + data = (RDP_PLUGIN_DATA*) (((uint8*) data) + data->size); } if (rdpsnd->device == NULL) diff --git a/libfreerdp-codec/rfx_sse2.c b/libfreerdp-codec/rfx_sse2.c index cdf92ae20..e3339952a 100644 --- a/libfreerdp-codec/rfx_sse2.c +++ b/libfreerdp-codec/rfx_sse2.c @@ -40,7 +40,7 @@ static __inline void __attribute__((__gnu_inline__, __always_inline__, __artific _mm_prefetch_buffer(char * buffer, int num_bytes) { __m128i * buf = (__m128i*) buffer; - int i; + unsigned int i; for (i = 0; i < (num_bytes / sizeof(__m128i)); i+=(CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&buf[i]), _MM_HINT_NTA);