rdpdr-fs-messages-vol-info.c (5835B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#include "channels/common-svc.h" 21#include "channels/rdpdr/rdpdr-fs-messages-vol-info.h" 22#include "channels/rdpdr/rdpdr-fs.h" 23#include "channels/rdpdr/rdpdr.h" 24#include "fs.h" 25 26#include <guacamole/client.h> 27#include <guacamole/unicode.h> 28#include <winpr/file.h> 29#include <winpr/io.h> 30#include <winpr/nt.h> 31#include <winpr/stream.h> 32#include <winpr/wtypes.h> 33 34void guac_rdpdr_fs_process_query_volume_info(guac_rdp_common_svc* svc, 35 guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest, 36 wStream* input_stream) { 37 38 wStream* output_stream = guac_rdpdr_new_io_completion(device, 39 iorequest->completion_id, STATUS_SUCCESS, 21 + GUAC_FILESYSTEM_LABEL_LENGTH); 40 41 guac_client_log(svc->client, GUAC_LOG_DEBUG, "%s: [file_id=%i]", __func__, 42 iorequest->file_id); 43 44 Stream_Write_UINT32(output_stream, 17 + GUAC_FILESYSTEM_LABEL_LENGTH); 45 Stream_Write_UINT64(output_stream, 0); /* VolumeCreationTime */ 46 Stream_Write_UINT32(output_stream, 0); /* VolumeSerialNumber */ 47 Stream_Write_UINT32(output_stream, GUAC_FILESYSTEM_LABEL_LENGTH); 48 Stream_Write_UINT8(output_stream, FALSE); /* SupportsObjects */ 49 /* Reserved field must not be sent */ 50 Stream_Write(output_stream, GUAC_FILESYSTEM_LABEL, GUAC_FILESYSTEM_LABEL_LENGTH); 51 52 guac_rdp_common_svc_write(svc, output_stream); 53 54} 55 56void guac_rdpdr_fs_process_query_size_info(guac_rdp_common_svc* svc, 57 guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest, 58 wStream* input_stream) { 59 60 guac_rdp_fs_info info = {0}; 61 guac_rdp_fs_get_info((guac_rdp_fs*) device->data, &info); 62 63 wStream* output_stream = guac_rdpdr_new_io_completion(device, 64 iorequest->completion_id, STATUS_SUCCESS, 28); 65 66 guac_client_log(svc->client, GUAC_LOG_DEBUG, "%s: [file_id=%i]", __func__, 67 iorequest->file_id); 68 69 Stream_Write_UINT32(output_stream, 24); 70 Stream_Write_UINT64(output_stream, info.blocks_total); /* TotalAllocationUnits */ 71 Stream_Write_UINT64(output_stream, info.blocks_available); /* AvailableAllocationUnits */ 72 Stream_Write_UINT32(output_stream, 1); /* SectorsPerAllocationUnit */ 73 Stream_Write_UINT32(output_stream, info.block_size); /* BytesPerSector */ 74 75 guac_rdp_common_svc_write(svc, output_stream); 76 77} 78 79void guac_rdpdr_fs_process_query_device_info(guac_rdp_common_svc* svc, 80 guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest, 81 wStream* input_stream) { 82 83 wStream* output_stream = guac_rdpdr_new_io_completion(device, 84 iorequest->completion_id, STATUS_SUCCESS, 12); 85 86 guac_client_log(svc->client, GUAC_LOG_DEBUG, "%s: [file_id=%i]", __func__, 87 iorequest->file_id); 88 89 Stream_Write_UINT32(output_stream, 8); 90 Stream_Write_UINT32(output_stream, FILE_DEVICE_DISK); /* DeviceType */ 91 Stream_Write_UINT32(output_stream, 0); /* Characteristics */ 92 93 guac_rdp_common_svc_write(svc, output_stream); 94 95} 96 97void guac_rdpdr_fs_process_query_attribute_info(guac_rdp_common_svc* svc, 98 guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest, 99 wStream* input_stream) { 100 101 int name_len = guac_utf8_strlen(device->device_name); 102 103 wStream* output_stream = guac_rdpdr_new_io_completion(device, 104 iorequest->completion_id, STATUS_SUCCESS, 16 + name_len); 105 106 guac_client_log(svc->client, GUAC_LOG_DEBUG, "%s: [file_id=%i]", __func__, 107 iorequest->file_id); 108 109 Stream_Write_UINT32(output_stream, 12 + name_len); 110 Stream_Write_UINT32(output_stream, 111 FILE_UNICODE_ON_DISK 112 | FILE_CASE_SENSITIVE_SEARCH 113 | FILE_CASE_PRESERVED_NAMES); /* FileSystemAttributes */ 114 Stream_Write_UINT32(output_stream, GUAC_RDP_FS_MAX_PATH ); /* MaximumComponentNameLength */ 115 Stream_Write_UINT32(output_stream, name_len); 116 Stream_Write(output_stream, device->device_name, name_len); 117 118 guac_rdp_common_svc_write(svc, output_stream); 119 120} 121 122void guac_rdpdr_fs_process_query_full_size_info(guac_rdp_common_svc* svc, 123 guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest, 124 wStream* input_stream) { 125 126 guac_rdp_fs_info info = {0}; 127 guac_rdp_fs_get_info((guac_rdp_fs*) device->data, &info); 128 129 wStream* output_stream = guac_rdpdr_new_io_completion(device, 130 iorequest->completion_id, STATUS_SUCCESS, 36); 131 132 guac_client_log(svc->client, GUAC_LOG_DEBUG, "%s: [file_id=%i]", __func__, 133 iorequest->file_id); 134 135 Stream_Write_UINT32(output_stream, 32); 136 Stream_Write_UINT64(output_stream, info.blocks_total); /* TotalAllocationUnits */ 137 Stream_Write_UINT64(output_stream, info.blocks_available); /* CallerAvailableAllocationUnits */ 138 Stream_Write_UINT64(output_stream, info.blocks_available); /* ActualAvailableAllocationUnits */ 139 Stream_Write_UINT32(output_stream, 1); /* SectorsPerAllocationUnit */ 140 Stream_Write_UINT32(output_stream, info.block_size); /* BytesPerSector */ 141 142 guac_rdp_common_svc_write(svc, output_stream); 143 144} 145