Bump windows from 0.48.0 to 0.52.0 (#11325)

# Description
Bump `windows` to 0.52.0 and fix `is_admin`

https://github.com/microsoft/windows-rs/pull/2476

# User-Facing Changes
N/A

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
nibon7 2023-12-22 01:49:15 +08:00 committed by GitHub
parent 5e5d1ea81b
commit 748d82cec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 11 deletions

20
Cargo.lock generated
View file

@ -1788,7 +1788,7 @@ dependencies = [
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
"windows-core 0.51.1",
]
[[package]]
@ -2893,7 +2893,7 @@ dependencies = [
"uuid",
"wax",
"which 5.0.0",
"windows 0.48.0",
"windows 0.52.0",
"winreg",
]
@ -6136,11 +6136,12 @@ dependencies = [
[[package]]
name = "windows"
version = "0.48.0"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
dependencies = [
"windows-targets 0.48.5",
"windows-core 0.52.0",
"windows-targets 0.52.0",
]
[[package]]
@ -6152,6 +6153,15 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-sys"
version = "0.45.0"

View file

@ -122,7 +122,7 @@ features = [
"Win32_Security",
"Win32_System_Threading",
]
version = "0.48"
version = "0.52"
[features]
plugin = ["nu-parser/plugin"]

View file

@ -66,16 +66,17 @@ fn is_root_impl() -> bool {
System::Threading::{GetCurrentProcess, OpenProcessToken},
};
let mut handle = HANDLE::default();
let mut elevated = false;
// Checks whether the access token associated with the current process has elevated privileges.
// SAFETY: `elevated` only touched by safe code.
// `handle` lives long enough, initialized, mutated as out param, used, closed with validity check.
// `handle` lives long enough, initialized, mutated, used and closed with validity check.
// `elevation` only read on success and passed with correct `size`.
unsafe {
let mut handle = HANDLE::default();
// Opens the access token associated with the current process.
if OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &mut handle).as_bool() {
if OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &mut handle).is_ok() {
let mut elevation = TOKEN_ELEVATION::default();
let mut size = std::mem::size_of::<TOKEN_ELEVATION>() as u32;
@ -89,7 +90,7 @@ fn is_root_impl() -> bool {
size,
&mut size,
)
.as_bool()
.is_ok()
{
// Whether the token has elevated privileges.
// Safe to read as `GetTokenInformation` will not write outside `elevation` and it succeeded
@ -100,7 +101,7 @@ fn is_root_impl() -> bool {
if !handle.is_invalid() {
// Closes the object handle.
CloseHandle(handle);
let _ = CloseHandle(handle);
}
}