Skip to content

Commit 7a389f3

Browse files
Copilotbenhillis
authored andcommitted
Migrate PAL security.rs, tp.rs, alpc.rs and disk_vhdmp from winapi to windows
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
1 parent a24c5eb commit 7a389f3

File tree

7 files changed

+54
-52
lines changed

7 files changed

+54
-52
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ dependencies = [
13741374
"tempfile",
13751375
"thiserror 2.0.12",
13761376
"vm_resource",
1377-
"winapi",
1377+
"windows 0.59.0",
13781378
]
13791379

13801380
[[package]]

support/pal/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ features = [
5555
"Wdk_Foundation",
5656
"Win32_Foundation",
5757
"Win32_Security",
58+
"Win32_Security_Authorization",
5859
"Win32_System_IO",
5960
"Win32_System_Threading",
6061
"Win32_System_ErrorReporting",
61-
"Win32_System_Memory",
62+
"Win32_System_Memory",
63+
"Win32_System_SystemServices",
6264
"Win32_Networking_WinSock",
6365
"Win32_Storage_FileSystem"
6466
]

support/pal/src/windows/alpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use std::os::windows::prelude::*;
1818
use std::ptr::NonNull;
1919
use std::ptr::null_mut;
2020
use std::time::Duration;
21-
use winapi::shared::ntstatus::STATUS_TIMEOUT;
21+
use windows::Win32::Foundation::STATUS_TIMEOUT;
2222

2323
mod ntlpcapi {
2424
#![allow(non_snake_case, dead_code, clippy::upper_case_acronyms)]
2525

2626
pub use ntapi::ntlpcapi::*;
27-
use winapi::shared::ntdef::HANDLE;
28-
use winapi::shared::ntdef::NTSTATUS;
27+
use windows::Win32::Foundation::HANDLE;
28+
use windows::Win32::Foundation::NTSTATUS;
2929

3030
// These constants are not defined in ntapi.
3131
pub const LPC_CONNECTION_REPLY: u32 = 11;

support/pal/src/windows/security.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ use std::ptr::null_mut;
1414
use std::str::FromStr;
1515
use widestring::U16CStr;
1616
use widestring::U16CString;
17-
use winapi::shared::minwindef::BOOL;
18-
use winapi::shared::sddl::ConvertSecurityDescriptorToStringSecurityDescriptorW;
19-
use winapi::shared::sddl::ConvertSidToStringSidW;
20-
use winapi::shared::sddl::ConvertStringSecurityDescriptorToSecurityDescriptorW;
21-
use winapi::shared::sddl::SDDL_REVISION_1;
22-
use winapi::um::securitybaseapi::DeriveCapabilitySidsFromName;
23-
use winapi::um::winbase::LocalFree;
24-
use winapi::um::winnt::DACL_SECURITY_INFORMATION;
25-
use winapi::um::winnt::GROUP_SECURITY_INFORMATION;
26-
use winapi::um::winnt::HANDLE;
27-
use winapi::um::winnt::LABEL_SECURITY_INFORMATION;
28-
use winapi::um::winnt::LPSECURITY_CAPABILITIES;
29-
use winapi::um::winnt::OWNER_SECURITY_INFORMATION;
30-
use winapi::um::winnt::PHANDLE;
31-
use winapi::um::winnt::PSECURITY_DESCRIPTOR;
32-
use winapi::um::winnt::PSID;
33-
use winapi::um::winnt::SACL_SECURITY_INFORMATION;
34-
use winapi::um::winnt::SE_GROUP_ENABLED;
35-
use winapi::um::winnt::SECURITY_CAPABILITIES;
36-
use winapi::um::winnt::SID_AND_ATTRIBUTES;
17+
use windows::Win32::Foundation::BOOL;
18+
use windows::Win32::Foundation::HANDLE;
19+
use windows::Win32::Foundation::LocalFree;
20+
use windows::Win32::Security::Authorization::ConvertSecurityDescriptorToStringSecurityDescriptorW;
21+
use windows::Win32::Security::Authorization::ConvertSidToStringSidW;
22+
use windows::Win32::Security::Authorization::ConvertStringSecurityDescriptorToSecurityDescriptorW;
23+
use windows::Win32::Security::DeriveCapabilitySidsFromName;
24+
use windows::Win32::Security::DACL_SECURITY_INFORMATION;
25+
use windows::Win32::Security::GROUP_SECURITY_INFORMATION;
26+
use windows::Win32::Security::LABEL_SECURITY_INFORMATION;
27+
use windows::Win32::Security::LPSECURITY_CAPABILITIES;
28+
use windows::Win32::Security::OWNER_SECURITY_INFORMATION;
29+
use windows::Win32::Security::PHANDLE;
30+
use windows::Win32::Security::PSECURITY_DESCRIPTOR;
31+
use windows::Win32::Security::PSID;
32+
use windows::Win32::Security::SACL_SECURITY_INFORMATION;
33+
use windows::Win32::Security::SE_GROUP_ENABLED;
34+
use windows::Win32::Security::SECURITY_CAPABILITIES;
35+
use windows::Win32::Security::SID_AND_ATTRIBUTES;
36+
use windows::Win32::Security::SDDL_REVISION_1;
3737

3838
const MAX_SUBAUTHORITY_COUNT: usize = 15;
3939

support/pal/src/windows/tp.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ use std::os::windows::prelude::*;
99
use std::ptr::NonNull;
1010
use std::ptr::null_mut;
1111
use std::time::Duration;
12-
use winapi::shared::minwindef::FILETIME;
13-
use winapi::um::threadpoolapiset::CancelThreadpoolIo;
14-
use winapi::um::threadpoolapiset::CloseThreadpoolIo;
15-
use winapi::um::threadpoolapiset::CloseThreadpoolTimer;
16-
use winapi::um::threadpoolapiset::CloseThreadpoolWait;
17-
use winapi::um::threadpoolapiset::CloseThreadpoolWork;
18-
use winapi::um::threadpoolapiset::CreateThreadpoolIo;
19-
use winapi::um::threadpoolapiset::CreateThreadpoolTimer;
20-
use winapi::um::threadpoolapiset::CreateThreadpoolWait;
21-
use winapi::um::threadpoolapiset::CreateThreadpoolWork;
22-
use winapi::um::threadpoolapiset::PTP_WIN32_IO_CALLBACK;
23-
use winapi::um::threadpoolapiset::SetThreadpoolTimerEx;
24-
use winapi::um::threadpoolapiset::SetThreadpoolWaitEx;
25-
use winapi::um::threadpoolapiset::StartThreadpoolIo;
26-
use winapi::um::threadpoolapiset::SubmitThreadpoolWork;
27-
use winapi::um::winnt::PTP_TIMER_CALLBACK;
28-
use winapi::um::winnt::PTP_WAIT_CALLBACK;
29-
use winapi::um::winnt::PTP_WORK_CALLBACK;
30-
use winapi::um::winnt::TP_IO;
31-
use winapi::um::winnt::TP_TIMER;
32-
use winapi::um::winnt::TP_WAIT;
33-
use winapi::um::winnt::TP_WORK;
12+
use windows::Win32::Foundation::FILETIME;
13+
use windows::Win32::System::Threading::CancelThreadpoolIo;
14+
use windows::Win32::System::Threading::CloseThreadpoolIo;
15+
use windows::Win32::System::Threading::CloseThreadpoolTimer;
16+
use windows::Win32::System::Threading::CloseThreadpoolWait;
17+
use windows::Win32::System::Threading::CloseThreadpoolWork;
18+
use windows::Win32::System::Threading::CreateThreadpoolIo;
19+
use windows::Win32::System::Threading::CreateThreadpoolTimer;
20+
use windows::Win32::System::Threading::CreateThreadpoolWait;
21+
use windows::Win32::System::Threading::CreateThreadpoolWork;
22+
use windows::Win32::System::Threading::PTP_WIN32_IO_CALLBACK;
23+
use windows::Win32::System::Threading::SetThreadpoolTimerEx;
24+
use windows::Win32::System::Threading::SetThreadpoolWaitEx;
25+
use windows::Win32::System::Threading::StartThreadpoolIo;
26+
use windows::Win32::System::Threading::SubmitThreadpoolWork;
27+
use windows::Win32::System::Threading::PTP_TIMER_CALLBACK;
28+
use windows::Win32::System::Threading::PTP_WAIT_CALLBACK;
29+
use windows::Win32::System::Threading::PTP_WORK_CALLBACK;
30+
use windows::Win32::System::Threading::TP_IO;
31+
use windows::Win32::System::Threading::TP_TIMER;
32+
use windows::Win32::System::Threading::TP_WAIT;
33+
use windows::Win32::System::Threading::TP_WORK;
3434

3535
/// Wrapper around a threadpool wait object (TP_WAIT).
3636
#[derive(Debug)]

vm/devices/storage/disk_vhdmp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mesh.workspace = true
1818

1919
futures.workspace = true
2020
thiserror.workspace = true
21-
winapi = { workspace = true, features = [ "handleapi", "winbase", "winnt" ] }
21+
windows = { workspace = true, features = [ "Win32_Foundation", "Win32_System_IO" ] }
2222

2323
[target.'cfg(windows)'.dev-dependencies]
2424
disk_vhd1.workspace = true

vm/devices/storage/disk_vhdmp/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ mod virtdisk {
3434
)]
3535

3636
use std::os::windows::prelude::*;
37-
use winapi::shared::guiddef::GUID;
38-
use winapi::shared::minwindef::BOOL;
39-
use winapi::um::minwinbase::OVERLAPPED;
40-
use winapi::um::winnt::SECURITY_DESCRIPTOR;
37+
use windows::core::GUID;
38+
use windows::Win32::Foundation::BOOL;
39+
use windows::Win32::System::IO::OVERLAPPED;
40+
use windows::Win32::Security::SECURITY_DESCRIPTOR;
4141

4242
#[repr(C)]
4343
#[derive(Copy, Clone)]

0 commit comments

Comments
 (0)