#[non_exhaustive]
pub enum Hive {
ClassesRoot,
CurrentConfig,
CurrentUser,
CurrentUserLocalSettings,
LocalMachine,
PerformanceData,
Users,
// some variants omitted
}
Expand description
All hives of the Windows Registry. Start here to get to a registry key.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
source§impl Hive
impl Hive
pub fn open<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn write<P>(&self, file_path: P) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn create<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn delete<P>(&self, path: P, is_recursive: bool) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
sourcepub fn load_file<P: AsRef<Path>>(
file_path: P,
sec: Security
) -> Result<RegKey, Error>
pub fn load_file<P: AsRef<Path>>( file_path: P, sec: Security ) -> Result<RegKey, Error>
Examples found in repository?
More examples
examples/private-hive.rs (lines 25-28)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
fn main() -> Result<(), std::io::Error> {
let mut token = std::ptr::null_mut();
let r = unsafe { OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &mut token) };
if r == 0 {
return Err(std::io::Error::last_os_error());
}
set_privilege(token, SE_RESTORE_NAME)?;
set_privilege(token, SE_BACKUP_NAME)?;
let hive_key = Hive::load_file(
r"C:\Users\Default\NTUSER.DAT",
Security::Read | Security::Write,
)
.unwrap();
let keys: Vec<_> = hive_key.keys().map(|k| k.unwrap().to_string()).collect();
println!("{:?}", keys);
Ok(())
}