Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/librdprs.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ typedef struct CGOSharedDirectoryWriteRequest {
uint8_t *write_data;
} CGOSharedDirectoryWriteRequest;













Comment on lines +236 to +247
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this happened, maybe a bug in cbindgen

void init(void);

/**
Expand Down
14 changes: 14 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/src/rdpdr/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use super::flags;
use super::Boolean;

pub const CHANNEL_NAME: &str = "rdpdr";

// Each redirected device requires a unique ID. We only share
Expand Down Expand Up @@ -192,3 +195,14 @@ pub enum FileSystemInformationClassLevel {
FileFsVolumeFlagsInformation = 10,
FileFsSectorSizeInformation = 11,
}

const fn size_of<T>() -> u32 {
std::mem::size_of::<T>() as u32
}

pub const U32_SIZE: u32 = size_of::<u32>();
pub const I64_SIZE: u32 = size_of::<i64>();
pub const I8_SIZE: u32 = size_of::<i8>();
pub const U8_SIZE: u32 = size_of::<u8>();
pub const FILE_ATTR_SIZE: u32 = size_of::<flags::FileAttributes>();
pub const BOOL_SIZE: u32 = size_of::<Boolean>();
38 changes: 18 additions & 20 deletions lib/srv/desktop/rdp/rdpclient/src/rdpdr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ use crate::{
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use consts::{
CapabilityType, Component, DeviceType, FileInformationClassLevel,
FileSystemInformationClassLevel, MajorFunction, MinorFunction, PacketId,
DIRECTORY_SHARE_CLIENT_NAME, DRIVE_CAPABILITY_VERSION_02, GENERAL_CAPABILITY_VERSION_02,
NTSTATUS, SCARD_DEVICE_ID, SMARTCARD_CAPABILITY_VERSION_01, VERSION_MAJOR, VERSION_MINOR,
FileSystemInformationClassLevel, MajorFunction, MinorFunction, PacketId, BOOL_SIZE,
DIRECTORY_SHARE_CLIENT_NAME, DRIVE_CAPABILITY_VERSION_02, FILE_ATTR_SIZE,
GENERAL_CAPABILITY_VERSION_02, I64_SIZE, I8_SIZE, NTSTATUS, SCARD_DEVICE_ID,
SMARTCARD_CAPABILITY_VERSION_01, U32_SIZE, U8_SIZE, VERSION_MAJOR, VERSION_MINOR,
};
use num_traits::{FromPrimitive, ToPrimitive};
use rdp::core::mcs;
Expand Down Expand Up @@ -2341,8 +2342,7 @@ struct FileBasicInformation {
}

impl FileBasicInformation {
/// 4 i64's and 1 u32's = (4 * 8) + 4
const BASE_SIZE: u32 = (4 * 8) + 4;
const BASE_SIZE: u32 = (4 * I64_SIZE) + FILE_ATTR_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand Down Expand Up @@ -2411,7 +2411,7 @@ struct FileStandardInformation {
}

impl FileStandardInformation {
const BASE_SIZE: u32 = (2 * 8) + 4 + 2;
const BASE_SIZE: u32 = (2 * I64_SIZE) + U32_SIZE + (2 * BOOL_SIZE);

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand All @@ -2437,7 +2437,7 @@ struct FileAttributeTagInformation {
}

impl FileAttributeTagInformation {
const BASE_SIZE: u32 = 2 * 4;
const BASE_SIZE: u32 = U32_SIZE + FILE_ATTR_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand Down Expand Up @@ -2486,8 +2486,7 @@ struct FileBothDirectoryInformation {
impl FileBothDirectoryInformation {
/// Base size of the FileBothDirectoryInformation, not accounting for variably sized file_name.
/// Note that file_name's size should be calculated as if it were a Unicode string.
/// 5 u32's (including FileAttributesFlags) + 6 i64's + 1 i8 + 24 bytes
const BASE_SIZE: u32 = (5 * 4) + (6 * 8) + 1 + 24; // 93
const BASE_SIZE: u32 = (4 * U32_SIZE) + FILE_ATTR_SIZE + (6 * I64_SIZE) + I8_SIZE + 24; // 93

fn new(
creation_time: i64,
Expand Down Expand Up @@ -2586,8 +2585,7 @@ struct FileFullDirectoryInformation {
impl FileFullDirectoryInformation {
/// Base size of the FileFullDirectoryInformation, not accounting for variably sized file_name.
/// Note that file_name's size should be calculated as if it were a Unicode string.
/// 5 u32's (including FileAttributesFlags) + 6 i64's
const BASE_SIZE: u32 = (5 * 4) + (6 * 8); // 68
const BASE_SIZE: u32 = (4 * U32_SIZE) + FILE_ATTR_SIZE + (6 * I64_SIZE); // 68

fn new(
creation_time: i64,
Expand Down Expand Up @@ -2668,7 +2666,7 @@ struct FileEndOfFileInformation {
}

impl FileEndOfFileInformation {
const BASE_SIZE: u32 = 8;
const BASE_SIZE: u32 = I64_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand All @@ -2694,7 +2692,7 @@ struct FileDispositionInformation {
}

impl FileDispositionInformation {
const BASE_SIZE: u32 = 1;
const BASE_SIZE: u32 = U8_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand Down Expand Up @@ -2723,7 +2721,7 @@ struct FileRenameInformation {
impl FileRenameInformation {
// This matches the FreeRDP implementation rather than Microsoft specification
// see encode method
const BASE_SIZE: u32 = 1 + 1 + 4;
const BASE_SIZE: u32 = (2 * U8_SIZE) + U32_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
// https://github.com/FreeRDP/FreeRDP/blob/511444a65e7aa2f537c5e531fa68157a50c1bd4d/channels/drive/client/drive_file.c#L709
Expand Down Expand Up @@ -2767,7 +2765,7 @@ struct FileAllocationInformation {
}

impl FileAllocationInformation {
const BASE_SIZE: u32 = 8;
const BASE_SIZE: u32 = I64_SIZE;

fn encode(&self) -> RdpResult<Vec<u8>> {
let mut w = vec![];
Expand Down Expand Up @@ -2827,7 +2825,7 @@ struct FileFsVolumeInformation {
impl FileFsVolumeInformation {
/// Base size of the FileFsVolumeInformation, not accounting for variably sized volume_label.
/// 1 i64, 2 u32, 1 Boolean
const BASE_SIZE: u32 = 8 + (2 * 4) + 1; // 17
const BASE_SIZE: u32 = I64_SIZE + (2 * U32_SIZE) + BOOL_SIZE; // 17

fn new(volume_creation_time: i64) -> Self {
// volume_label can just be something we make up
Expand Down Expand Up @@ -2877,7 +2875,7 @@ struct FileFsSizeInformation {

#[allow(dead_code)]
impl FileFsSizeInformation {
const BASE_SIZE: u32 = (2 * 8) + (2 * 4);
const BASE_SIZE: u32 = (2 * I64_SIZE) + (2 * U32_SIZE);

fn new() -> Self {
// Fill these out with the default fallback values FreeRDP uses
Expand Down Expand Up @@ -2918,7 +2916,7 @@ struct FileFsAttributeInformation {

#[allow(dead_code)]
impl FileFsAttributeInformation {
const BASE_SIZE: u32 = 3 * 4;
const BASE_SIZE: u32 = (2 * U32_SIZE) + FILE_ATTR_SIZE;

fn new() -> Self {
// https://github.com/FreeRDP/FreeRDP/blob/511444a65e7aa2f537c5e531fa68157a50c1bd4d/channels/drive/client/drive_main.c#L447
Expand Down Expand Up @@ -2967,7 +2965,7 @@ struct FileFsFullSizeInformation {

#[allow(dead_code)]
impl FileFsFullSizeInformation {
const BASE_SIZE: u32 = (3 * 8) + (2 * 4);
const BASE_SIZE: u32 = (3 * I64_SIZE) + (2 * U32_SIZE);

fn new() -> Self {
// Fill these out with the default fallback values FreeRDP uses
Expand Down Expand Up @@ -3010,7 +3008,7 @@ struct FileFsDeviceInformation {

#[allow(dead_code)]
impl FileFsDeviceInformation {
const BASE_SIZE: u32 = 2 * 4;
const BASE_SIZE: u32 = 2 * U32_SIZE;

fn new() -> Self {
// https://github.com/FreeRDP/FreeRDP/blob/511444a65e7aa2f537c5e531fa68157a50c1bd4d/channels/drive/client/drive_main.c#L570-L571
Expand Down