parselnk/extra_data/
property_store_data_block.rs

1use super::Result;
2use crate::error::ExtraDataError;
3use std::io::{Cursor, Read};
4
5/// A PropertyStoreDataBlock structure specifies a set of properties that can be used by applications to store extra data in the shell link.
6#[derive(Clone, Debug, Default)]
7pub struct PropertyStoreDataBlock {
8    /// A 32-bit, unsigned integer that specifies the size of the PropertyStoreDataBlock structure. This value MUST be greater than or equal to 0x0000000C.
9    pub block_size: u32,
10
11    /// A 32-bit, unsigned integer that specifies the signature of the PropertyStoreDataBlock extra data section. This value MUST be 0xA0000009.
12    pub block_signature: u32,
13
14    /// A serialized property storage structure ([MS-PROPSTORE] section 2.2).
15    pub property_store: Vec<u8>,
16}
17
18impl PropertyStoreDataBlock {
19    /// Construct a new `KnownFolderDataBlock`
20    pub(crate) fn new(
21        block_size: u32,
22        block_signature: u32,
23        cursor: &mut Cursor<Vec<u8>>,
24    ) -> Result<Self> {
25        let this = Self {
26            block_size,
27            block_signature,
28            property_store: {
29                let store_size = block_size as usize - (std::mem::size_of::<u32>() * 2);
30                let mut property_store = vec![0; store_size];
31                cursor
32                    .read_exact(&mut property_store)
33                    .map_err(ExtraDataError::Read)?;
34                property_store
35            },
36        };
37
38        Ok(this)
39    }
40}