From 06c2dfd8d28b1aa02c8f03eacb32ccbe7a779d05 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 1 Aug 2013 16:42:38 -0700 Subject: [PATCH] Add file_id to volume queries, send real times and attributes back. --- .../rdp/guac_rdpdr/rdpdr_fs_messages.c | 17 +++++++++----- .../rdp/guac_rdpdr/rdpdr_fs_messages.h | 2 +- .../guac_rdpdr/rdpdr_fs_messages_file_info.c | 22 +++++++++++++------ .../guac_rdpdr/rdpdr_fs_messages_vol_info.c | 16 ++++++++------ .../guac_rdpdr/rdpdr_fs_messages_vol_info.h | 10 ++++----- .../rdp/guac_rdpdr/rdpdr_fs_service.c | 2 +- 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c index 5785d15f..cb7c1aae 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.c @@ -161,7 +161,7 @@ void guac_rdpdr_fs_process_close(guac_rdpdr_device* device, } void guac_rdpdr_fs_process_volume_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { int fs_information_class, length; @@ -178,23 +178,28 @@ void guac_rdpdr_fs_process_volume_info(guac_rdpdr_device* device, wStream* input switch (fs_information_class) { case FileFsVolumeInformation: - guac_rdpdr_fs_process_query_volume_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_query_volume_info(device, input_stream, + file_id, completion_id); break; case FileFsSizeInformation: - guac_rdpdr_fs_process_query_size_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_query_size_info(device, input_stream, + file_id, completion_id); break; case FileFsDeviceInformation: - guac_rdpdr_fs_process_query_device_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_query_device_info(device, input_stream, + file_id, completion_id); break; case FileFsAttributeInformation: - guac_rdpdr_fs_process_query_attribute_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_query_attribute_info(device, input_stream, + file_id, completion_id); break; case FileFsFullSizeInformation: - guac_rdpdr_fs_process_query_full_size_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_query_full_size_info(device, input_stream, + file_id, completion_id); break; default: diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.h index ff9ae98d..09a48d61 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages.h @@ -95,7 +95,7 @@ void guac_rdpdr_fs_process_device_control(guac_rdpdr_device* device, wStream* in * separate file. */ void guac_rdpdr_fs_process_volume_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); /** * Handles a Server Drive Set Volume Information Request. Currently, this diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_file_info.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_file_info.c index eb7db5a0..8a089b08 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_file_info.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_file_info.c @@ -56,7 +56,8 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream* int file_id, int completion_id) { wStream* output_stream = Stream_New(NULL, 60); - /*guac_rdpdr_fs_file* file = device->files[file_id];*/ + guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data; + guac_rdpdr_fs_file* file = &(data->files[file_id]); /* Write header */ Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); @@ -68,12 +69,19 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream* Stream_Write_UINT32(output_stream, STATUS_SUCCESS); Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH); - Stream_Write_UINT64(output_stream, WINDOWS_TIME(0)); /* CreationTime */ - Stream_Write_UINT64(output_stream, WINDOWS_TIME(0)); /* LastAccessTime */ - Stream_Write_UINT64(output_stream, WINDOWS_TIME(0)); /* LastWriteTime */ - Stream_Write_UINT64(output_stream, WINDOWS_TIME(0)); /* ChangeTime */ - Stream_Write_UINT32(output_stream, FILE_ATTRIBUTE_NORMAL); /* FileAttributes */ - Stream_Write_UINT32(output_stream, 0); /* Reserved */ + Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->ctime)); /* CreationTime */ + Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->atime)); /* LastAccessTime */ + Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->mtime)); /* LastWriteTime */ + Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->mtime)); /* ChangeTime */ + + /* FileAttributes */ + if (file->type == GUAC_RDPDR_FS_DIRECTORY) + Stream_Write_UINT32(output_stream, FILE_ATTRIBUTE_DIRECTORY); + else + Stream_Write_UINT32(output_stream, FILE_ATTRIBUTE_NORMAL); /* FileAttributes */ + + /* Reserved */ + Stream_Write_UINT32(output_stream, 0); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.c index 6ad54a50..8bce110b 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.c @@ -52,9 +52,11 @@ #include void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { wStream* output_stream = Stream_New(NULL, 38 + GUAC_FILESYSTEM_NAME_LENGTH); + guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data; + guac_rdpdr_fs_file* file = &(data->files[file_id]); /* Write header */ Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); @@ -66,8 +68,8 @@ void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream* Stream_Write_UINT32(output_stream, STATUS_SUCCESS); Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH); - Stream_Write_UINT64(output_stream, WINDOWS_TIME(0)); /* VolumeCreationTime */ - Stream_Write(output_stream, "GUAC", 4); /* VolumeSerialNumber */ + Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->ctime)); /* VolumeCreationTime */ + Stream_Write(output_stream, "GUAC", 4); /* VolumeSerialNumber */ Stream_Write_UINT32(output_stream, GUAC_FILESYSTEM_NAME_LENGTH); Stream_Write_UINT8(output_stream, FALSE); /* SupportsObjects */ Stream_Write_UINT8(output_stream, 0); /* Reserved */ @@ -78,28 +80,28 @@ void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream* } void guac_rdpdr_fs_process_query_size_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { /* STUB */ guac_client_log_error(device->rdpdr->client, "Unimplemented stub: guac_rdpdr_fs_query_size_info"); } void guac_rdpdr_fs_process_query_device_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { /* STUB */ guac_client_log_error(device->rdpdr->client, "Unimplemented stub: guac_rdpdr_fs_query_devive_info"); } void guac_rdpdr_fs_process_query_attribute_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { /* STUB */ guac_client_log_error(device->rdpdr->client, "Unimplemented stub: guac_rdpdr_fs_query_attribute_info"); } void guac_rdpdr_fs_process_query_full_size_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id) { + int file_id, int completion_id) { /* STUB */ guac_client_log_error(device->rdpdr->client, "Unimplemented stub: guac_rdpdr_fs_query_full_size_info"); diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.h index 74b23083..c9fbcfbf 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_messages_vol_info.h @@ -60,31 +60,31 @@ * file system is mounted." */ void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); /** * Processes a query request for FileFsSizeInformation. */ void guac_rdpdr_fs_process_query_size_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); /** * Processes a query request for FileFsAttributeInformation. */ void guac_rdpdr_fs_process_query_attribute_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); /** * Processes a query request for FileFsFullSizeInformation. */ void guac_rdpdr_fs_process_query_full_size_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); /** * Processes a query request for FileFsDeviceInformation. */ void guac_rdpdr_fs_process_query_device_info(guac_rdpdr_device* device, wStream* input_stream, - int completion_id); + int file_id, int completion_id); #endif diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_service.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_service.c index cfa433a7..c5730114 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs_service.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs_service.c @@ -99,7 +99,7 @@ static void guac_rdpdr_device_fs_iorequest_handler(guac_rdpdr_device* device, /* Query volume (drive) information */ case IRP_MJ_QUERY_VOLUME_INFORMATION: - guac_rdpdr_fs_process_volume_info(device, input_stream, completion_id); + guac_rdpdr_fs_process_volume_info(device, input_stream, file_id, completion_id); break; /* Set volume (drive) information */