Enum registry::Hive

source ·
#[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.
§

ClassesRoot

§

CurrentConfig

§

CurrentUser

§

CurrentUserLocalSettings

§

LocalMachine

§

PerformanceData

§

Users

Implementations§

source§

impl Hive

source

pub fn open<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn write<P>(&self, file_path: P) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn create<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn delete<P>(&self, path: P, is_recursive: bool) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn load_file<P: AsRef<Path>>( file_path: P, sec: Security ) -> Result<RegKey, Error>

Examples found in repository?
examples/appkey.rs (lines 6-9)
5
6
7
8
9
10
11
12
13
14
fn main() -> Result<(), std::io::Error> {
    let hive_key = Hive::load_file(
        Path::new(r"C:\Users\Default\NTUSER.DAT"),
        Security::Read | Security::Write,
    )
    .unwrap();

    walk_keys(hive_key, 0);
    Ok(())
}
More examples
Hide additional 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(())
}

Trait Implementations§

source§

impl Clone for Hive

source§

fn clone(&self) -> Hive

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Hive

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Hive

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for Hive

Auto Trait Implementations§

§

impl RefUnwindSafe for Hive

§

impl Send for Hive

§

impl Sync for Hive

§

impl Unpin for Hive

§

impl UnwindSafe for Hive

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.