pub struct Hive<B: SplitByteSlice> { /* private fields */ }
Expand description
Root structure describing a registry hive.
Implementations§
Source§impl<B> Hive<B>where
B: SplitByteSlice,
impl<B> Hive<B>where
B: SplitByteSlice,
Sourcepub fn new(bytes: B) -> Result<Self>
pub fn new(bytes: B) -> Result<Self>
Creates a new Hive
from any byte slice.
Performs basic validation and rejects any invalid hive.
You may use Hive::without_validation
if you want to accept hives that fail validation.
Examples found in repository?
11fn main() -> Result<(), String> {
12 // Parse arguments.
13 let args: Vec<String> = env::args().collect();
14 if args.len() < 2 {
15 println!("Usage: readhive <FILENAME>");
16 return Ok(());
17 }
18
19 // Read the hive file.
20 let filename = &args[1];
21 let mut f = File::open(filename).map_err(|e| format!("Error opening hive file: {e}"))?;
22 let mut buffer = Vec::<u8>::new();
23 f.read_to_end(&mut buffer)
24 .map_err(|e| format!("Error reading hive file: {e}"))?;
25
26 // Parse the hive.
27 let hive = Hive::new(buffer.as_ref()).map_err(|e| format!("Error parsing hive file: {e}"))?;
28
29 // Print the name of the root key node.
30 let root_key = hive
31 .root_key_node()
32 .map_err(|e| format!("Error getting root key: {e}"))?;
33 println!("{}", root_key.name().unwrap().to_string_lossy());
34
35 process_subkey(root_key, 0)?;
36
37 Ok(())
38}
Sourcepub fn without_validation(bytes: B) -> Result<Self>
pub fn without_validation(bytes: B) -> Result<Self>
Creates a new Hive
from any byte slice, without validating the header.
You may later validate the header via Hive::validate
.
This is a solution for accessing parts of hives that have not been fully flushed to disk
(e.g. due to hibernation and mismatching sequence numbers).
Sourcepub fn major_version(&self) -> u32
pub fn major_version(&self) -> u32
Returns the major version of this hive.
The only known value is 1
.
Sourcepub fn minor_version(&self) -> u32
pub fn minor_version(&self) -> u32
Returns the minor version of this hive.
You can feed this value to HiveMinorVersion::n
to find out whether this is a known version.
Sourcepub fn root_key_node(&self) -> Result<KeyNode<'_, B>>
pub fn root_key_node(&self) -> Result<KeyNode<'_, B>>
Returns the root KeyNode
of this hive.
Examples found in repository?
11fn main() -> Result<(), String> {
12 // Parse arguments.
13 let args: Vec<String> = env::args().collect();
14 if args.len() < 2 {
15 println!("Usage: readhive <FILENAME>");
16 return Ok(());
17 }
18
19 // Read the hive file.
20 let filename = &args[1];
21 let mut f = File::open(filename).map_err(|e| format!("Error opening hive file: {e}"))?;
22 let mut buffer = Vec::<u8>::new();
23 f.read_to_end(&mut buffer)
24 .map_err(|e| format!("Error reading hive file: {e}"))?;
25
26 // Parse the hive.
27 let hive = Hive::new(buffer.as_ref()).map_err(|e| format!("Error parsing hive file: {e}"))?;
28
29 // Print the name of the root key node.
30 let root_key = hive
31 .root_key_node()
32 .map_err(|e| format!("Error getting root key: {e}"))?;
33 println!("{}", root_key.name().unwrap().to_string_lossy());
34
35 process_subkey(root_key, 0)?;
36
37 Ok(())
38}
Source§impl<B> Hive<B>where
B: SplitByteSliceMut,
impl<B> Hive<B>where
B: SplitByteSliceMut,
Sourcepub fn clear_volatile_subkeys(&mut self) -> Result<()>
pub fn clear_volatile_subkeys(&mut self) -> Result<()>
Clears the volatile_subkey_count
field of all key nodes recursively.
This needs to be done before passing the hive to an NT kernel during boot. See https://github.com/reactos/reactos/pull/1883 for more information.