docs.rs failed to build windows-token-0.1.0-dev
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
windows-token
STATUS: pre-alpha (0.1.0-dev). API surface stable-ish; implementations partial; not exercised against a live DC.
RAII wrappers over the Win32 access-token surface. The one hard invariant: dropping an ImpersonationGuard calls RevertToSelf — always, including on unwind. That is the whole reason the crate exists; hand-written impersonation code (Rubeus-style) forgets this on early returns.
Purpose
Token::open_current_process/open_process(pid, access)— RAII aroundOpenProcessToken.Token::duplicate(ty, level)—DuplicateTokenExreturning an owned handle.Token::enable_privilege(Privilege::…)—LookupPrivilegeValueW+AdjustTokenPrivileges, correctly readingERROR_NOT_ALL_ASSIGNEDfromGetLastErroron nominal success.Token::impersonate_on_thread()/set_on_current_thread()— returnsImpersonationGuard,Drop = RevertToSelf.Token::user_sid()/integrity_level()—GetTokenInformation(TokenUser | TokenIntegrityLevel).
Minimal usage
use ;
let tok = open_current_process?;
let _prev = tok.enable_privilege?;
// impersonation with guaranteed revert:
// <- RevertToSelf on drop, including on panic
# Ok::
What is not done
OpenThreadTokenis not yet wired (onlyOpenProcessToken).- No
LookupAccountSidW— SIDs render asS-1-…strings only, no name resolution. - No
CreateProcessAsUserW/ restricted-token helpers. - No integration tests against a real DC; only smoke tests on
GetCurrentProcess().
Deps (S-tier posture)
windows0.58 — narrowly featured (Win32_Security,Win32_System_Threading,Win32_Security_Authentication_Identity,Win32_Foundation).windows-core0.58 — forResult/Errorinterop.thiserror2 — error boilerplate only.
No serde, no log, no async runtime.
License
MIT. See LICENSE.