pub fn query_system_information<T>() -> Result<Vec<T>>
where
    T: SystemInformation,
{
    let info = get_system_info();
    let proc_amount = info.dwNumberOfProcessors as usize;
    if proc_amount == 0 {
        let inner = io::Error::from(io::ErrorKind::InvalidData);
        return Err(Error::from(inner).with_message("No processors were found"));
    }

    let mut info = Vec::<T>::with_capacity(proc_amount);
    let buffer_length = proc_amount * mem::size_of::<T>();

    unsafe {
        let result = ntexapi::NtQuerySystemInformation(
            T::class(),
            info.as_mut_ptr() as *mut _,
            buffer_length as u32,
            ptr::null_mut(),
        );
        if result != ntstatus::STATUS_SUCCESS {
            return Err(Error::last_os_error().with_ffi("NtQuerySystemInformation"));
        }
        info.set_len(proc_amount);
    };

    debug_assert!(!info.is_empty());

    Ok(info)
}
// Safe wrapper around the `NtQuerySystemInformation`
Safe wrapper around the `NtQuerySystemInformation`
Safe wrapper around the ` NtQuerySystemInformation `
pub fn query_system_information<T>() -> Result<Vec<T>>
where
    T: SystemInformation,
{
    let info = get_system_info();
    let proc_amount = info.dwNumberOfProcessors as usize;
    if proc_amount == 0 {
        let inner = io::Error::from(io::ErrorKind::InvalidData);
        return Err(Error::from(inner).with_message("No processors were found"));
    }
    let mut info = Vec::<T>::with_capacity(proc_amount);
    let buffer_length = proc_amount * mem::size_of::<T>();
    unsafe {
        let result = ntexapi::NtQuerySystemInformation(
            T::class(),
            info.as_mut_ptr() as *mut _,
            buffer_length as u32,
            ptr::null_mut(),
        );
        if result != ntstatus::STATUS_SUCCESS {
            return Err(Error::last_os_error().with_ffi("NtQuerySystemInformation"));
        }
        info.set_len(proc_amount);
    };
    debug_assert!(!info.is_empty());
    Ok(info)
}
pub fn query_system_information < T > ( ) -> Result < Vec < T > > where T : SystemInformation , { let info = get_system_info ( ) ; let proc_amount = info . dwNumberOfProcessors as usize ; if proc_amount == 0 { let inner = io :: Error :: from ( io :: ErrorKind :: InvalidData ) ; return Err ( Error :: from ( inner ) . with_message ( " " ) ) ; } let mut info = Vec :: < T > :: with_capacity ( proc_amount ) ; let buffer_length = proc_amount * mem :: size_of :: < T > ( ) ; unsafe { let result = ntexapi :: NtQuerySystemInformation ( T :: class ( ) , info . as_mut_ptr ( ) as * mut _ , buffer_length as u32 , ptr :: null_mut ( ) , ) ; if result != ntstatus :: STATUS_SUCCESS { return Err ( Error :: last_os_error ( ) . with_ffi ( " " ) ) ; } info . set_len ( proc_amount ) ; } ; debug_assert ! ( info is_empty ( ) ) ; Ok ( info ) }
Safe wrapper around the `NtQuerySystemInformation`
Safe wrapper around the ` NtQuerySystemInformation `