Expand description
Safe Rust wrapper for Windows process token privilege and elevation detection.
All unsafe Win32 FFI calls are contained within the crate. Consumers use a fully
safe public API and can maintain #![forbid(unsafe_code)] in their own crates.
On non-Windows platforms, all functions return
Err(TokenPrivilegeError::UnsupportedPlatform).
§Examples
use token_privilege::{is_elevated, is_privilege_enabled, privileges};
fn main() -> Result<(), Box<dyn std::error::Error>> {
if is_elevated()? {
println!("Running as Administrator");
}
if is_privilege_enabled(privileges::SE_DEBUG)? {
println!("SeDebugPrivilege is enabled");
}
Ok(())
}Modules§
- privileges
- Well-known Windows privilege name constants.
Structs§
- Privilege
Info - Represents the status of a single Windows privilege.
Enums§
- Token
Privilege Error - Errors that can occur when querying token privileges.
Functions§
- enumerate_
privileges - Enumerate all privileges on the current process token.
- has_
privilege - Check if a specific named privilege is present on the current process token, regardless of whether it is currently enabled.
- is_
elevated - Check if the current process is running with elevated (Administrator) privileges.
- is_
privilege_ enabled - Check if a specific named privilege is present and enabled on the current process token.