pub struct HACCESSTOKEN(/* private fields */);
Available on crate feature
advapi
only.Expand description
Handle to an
access token.
Originally just a HANDLE
.
Implementations§
Source§impl HACCESSTOKEN
impl HACCESSTOKEN
Sourcepub fn AdjustTokenPrivileges(&self, new_state: DisabPriv<'_>) -> SysResult<()>
pub fn AdjustTokenPrivileges(&self, new_state: DisabPriv<'_>) -> SysResult<()>
AdjustTokenPrivileges
function.
§Examples
use winsafe::{self as w, prelude::*, co};
let htoken = w::HPROCESS::GetCurrentProcess()
.OpenProcessToken(co::TOKEN::ADJUST_PRIVILEGES | co::TOKEN::QUERY)?;
let luid = w::LookupPrivilegeValue(None, co::SE_PRIV::SHUTDOWN_NAME)?;
let privs = w::TOKEN_PRIVILEGES::new(&[
w::LUID_AND_ATTRIBUTES::new(luid, co::SE_PRIV_ATTR::ENABLED),
])?;
htoken.AdjustTokenPrivileges(w::DisabPriv::Privs(&privs))?;
Sourcepub fn CheckTokenCapability(
&self,
capability_sid_to_check: &SID,
) -> SysResult<bool>
pub fn CheckTokenCapability( &self, capability_sid_to_check: &SID, ) -> SysResult<bool>
CheckTokenCapability
function.
Sourcepub fn CheckTokenMembership(&self, sid_to_check: &SID) -> SysResult<bool>
pub fn CheckTokenMembership(&self, sid_to_check: &SID) -> SysResult<bool>
CheckTokenMembership
function.
Sourcepub fn DuplicateToken(
&self,
level: SECURITY_IMPERSONATION,
) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
pub fn DuplicateToken( &self, level: SECURITY_IMPERSONATION, ) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
DuplicateToken
function.
Sourcepub fn GetCurrentProcessToken() -> HACCESSTOKEN
pub fn GetCurrentProcessToken() -> HACCESSTOKEN
GetCurrentProcessToken
function.
Sourcepub fn GetCurrentThreadEffectiveToken() -> HACCESSTOKEN
pub fn GetCurrentThreadEffectiveToken() -> HACCESSTOKEN
GetCurrentThreadEffectiveToken
function.
Sourcepub fn GetTokenInformation(
&self,
information_class: TOKEN_INFORMATION_CLASS,
) -> SysResult<TokenInfo<'_, '_, '_, '_, '_, '_>>
pub fn GetTokenInformation( &self, information_class: TOKEN_INFORMATION_CLASS, ) -> SysResult<TokenInfo<'_, '_, '_, '_, '_, '_>>
GetTokenInformation
function.
The returned enum variant will correspond to the passed
information_class
.
§Examples
Retrieving the Groups
information:
use winsafe::{self as w, prelude::*, co};
let htoken = w::HPROCESS::GetCurrentProcess()
.OpenProcessToken(co::TOKEN::QUERY)?;
let nfo = htoken.GetTokenInformation(co::TOKEN_INFORMATION_CLASS::Groups)?;
let w::TokenInfo::Groups(groups) = nfo else { unreachable!() };
for (idx, g) in groups.Groups().iter().enumerate() {
println!("{}: {}", idx, g.Sid().unwrap());
}
Sourcepub fn ImpersonateLoggedOnUser(&self) -> SysResult<()>
pub fn ImpersonateLoggedOnUser(&self) -> SysResult<()>
ImpersonateLoggedOnUser
function.
Sourcepub fn IsTokenRestricted(&self) -> SysResult<bool>
pub fn IsTokenRestricted(&self) -> SysResult<bool>
IsTokenRestricted
function.
Trait Implementations§
Source§impl Debug for HACCESSTOKEN
impl Debug for HACCESSTOKEN
Source§impl Display for HACCESSTOKEN
impl Display for HACCESSTOKEN
Source§impl Handle for HACCESSTOKEN
impl Handle for HACCESSTOKEN
Source§const NULL: Self
const NULL: Self
Available on crate feature
kernel
only.The null, uninitialized handle; equals to
0
.Source§const INVALID: Self
const INVALID: Self
Available on crate feature
kernel
only.The invalid handle; equals to
-1
. Read moreSource§unsafe fn from_ptr(p: *mut c_void) -> Self
unsafe fn from_ptr(p: *mut c_void) -> Self
Available on crate feature
kernel
only.Creates a new handle object by wrapping a pointer. Read more
Source§unsafe fn as_mut(&mut self) -> &mut *mut c_void
unsafe fn as_mut(&mut self) -> &mut *mut c_void
Available on crate feature
kernel
only.Returns a mutable reference to the underlying raw pointer. Read more
Source§unsafe fn raw_copy(&self) -> Self
unsafe fn raw_copy(&self) -> Self
Available on crate feature
kernel
only.Returns a raw copy of the underlying handle pointer. Read more
Source§impl Hash for HACCESSTOKEN
impl Hash for HACCESSTOKEN
Source§impl LowerHex for HACCESSTOKEN
impl LowerHex for HACCESSTOKEN
Source§impl PartialEq for HACCESSTOKEN
impl PartialEq for HACCESSTOKEN
Source§impl UpperHex for HACCESSTOKEN
impl UpperHex for HACCESSTOKEN
impl Eq for HACCESSTOKEN
impl Send for HACCESSTOKEN
impl StructuralPartialEq for HACCESSTOKEN
Auto Trait Implementations§
impl Freeze for HACCESSTOKEN
impl RefUnwindSafe for HACCESSTOKEN
impl !Sync for HACCESSTOKEN
impl Unpin for HACCESSTOKEN
impl UnwindSafe for HACCESSTOKEN
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more