pub struct Hive<B: ByteSlice> { /* private fields */ }
Expand description
Root structure describing a registry hive.
Implementations§
Source§impl<B> Hive<B>where
B: ByteSlice,
impl<B> Hive<B>where
B: ByteSlice,
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?
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() -> Result<(), String> {
// Parse arguments.
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: readhive <FILENAME>");
return Ok(());
}
// Read the hive file.
let filename = &args[1];
let mut f = File::open(filename).map_err(|e| format!("Error opening hive file: {}", e))?;
let mut buffer = Vec::<u8>::new();
f.read_to_end(&mut buffer)
.map_err(|e| format!("Error reading hive file: {}", e))?;
// Parse the hive.
let hive = Hive::new(buffer.as_ref()).map_err(|e| format!("Error parsing hive file: {}", e))?;
// Print the name of the root key node.
let root_key = hive
.root_key_node()
.map_err(|e| format!("Error getting root key: {}", e))?;
println!("{}", root_key.name().unwrap().to_string_lossy());
process_subkey(root_key, 0)?;
Ok(())
}
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<&Self, B>>
pub fn root_key_node(&self) -> Result<KeyNode<&Self, B>>
Returns the root KeyNode
of this hive.
Examples found in repository?
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() -> Result<(), String> {
// Parse arguments.
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: readhive <FILENAME>");
return Ok(());
}
// Read the hive file.
let filename = &args[1];
let mut f = File::open(filename).map_err(|e| format!("Error opening hive file: {}", e))?;
let mut buffer = Vec::<u8>::new();
f.read_to_end(&mut buffer)
.map_err(|e| format!("Error reading hive file: {}", e))?;
// Parse the hive.
let hive = Hive::new(buffer.as_ref()).map_err(|e| format!("Error parsing hive file: {}", e))?;
// Print the name of the root key node.
let root_key = hive
.root_key_node()
.map_err(|e| format!("Error getting root key: {}", e))?;
println!("{}", root_key.name().unwrap().to_string_lossy());
process_subkey(root_key, 0)?;
Ok(())
}
Source§impl<B> Hive<B>where
B: ByteSliceMut,
impl<B> Hive<B>where
B: ByteSliceMut,
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.