Skip to content

Commit

Permalink
deps: Move from winapi to windows
Browse files Browse the repository at this point in the history
`winapi` is in maintenance mode and the new blessed way to access Windows APIs are the `windows`
and `windows-sys` crates. I was forced to use `windows` because `sysinfo` uses the COM APIs
which are not present in `windows-sys`.
  • Loading branch information
poliorcetics committed Sep 22, 2023
1 parent 7cdab25 commit 006bb9a
Show file tree
Hide file tree
Showing 15 changed files with 774 additions and 936 deletions.
53 changes: 36 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 35 additions & 36 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,43 +41,42 @@ serde = { version = "^1.0.152", optional = true }
once_cell = "1.0"

[target.'cfg(windows)'.dependencies]
# FIXME: remove std feature once https://github.com/retep998/winapi-rs/pull/1003 has been merged.
winapi = { version = "0.3.9", features = [
"errhandlingapi",
"fileapi",
"handleapi",
"heapapi",
"ifdef",
"ioapiset",
"minwindef",
"pdh",
"psapi",
"synchapi",
"sysinfoapi",
"winbase",
"winerror",
"winioctl",
"winnt",
"oleauto",
"wbemcli",
"rpcdce",
"combaseapi",
"objidl",
"powerbase",
"netioapi",
"lmcons",
"lmaccess",
"lmapibuf",
"memoryapi",
"ntlsa",
"securitybaseapi",
"shellapi",
"std",
"iphlpapi",
"winsock2",
"sddl",
]}
ntapi = "0.4"
windows = { version = "0.51", features = [
"Wdk_System_SystemInformation",
"Wdk_System_SystemServices",
"Wdk_System_Threading",
"Win32_Foundation",
"Win32_NetworkManagement_IpHelper",
"Win32_NetworkManagement_NetManagement",
"Win32_NetworkManagement_Ndis",
"Win32_Networking_WinSock",
"Win32_Security",
"Win32_Security_Authentication_Identity",
"Win32_Security_Authorization",
"Win32_Storage_FileSystem",
"Win32_System_Com",
"Win32_System_Diagnostics_Debug",
"Win32_System_IO",
"Win32_System_Ioctl",
"Win32_System_LibraryLoader",
"Win32_System_Kernel",
"Win32_System_Memory",
"Win32_System_Ole",
"Win32_System_Performance",
"Win32_System_Power",
"Win32_System_ProcessStatus",
"Win32_System_Registry",
"Win32_System_RemoteDesktop",
"Win32_System_Rpc",
"Win32_System_SystemInformation",
"Win32_System_SystemServices",
"Win32_System_Threading",
"Win32_System_Variant",
"Win32_System_WindowsProgramming",
"Win32_System_Wmi",
"Win32_UI_Shell",
]}

[target.'cfg(not(any(target_os = "unknown", target_arch = "wasm32")))'.dependencies]
libc = "^0.2.144"
Expand Down
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ pub fn get_current_pid() -> Result<Pid, &'static str> {
}
} else if #[cfg(windows)] {
fn inner() -> Result<Pid, &'static str> {
use winapi::um::processthreadsapi::GetCurrentProcessId;
use windows::Win32::System::Threading::GetCurrentProcessId;

unsafe { Ok(Pid(GetCurrentProcessId() as _)) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ cfg_if::cfg_if! {
pub(crate) const MIN_USERS: usize = 1;
} else if #[cfg(windows)] {
mod windows;
use windows as sys;
use windows::network_helper;
use crate::windows as sys;
use crate::windows::network_helper;
mod network;

#[cfg(test)]
Expand Down
Loading

0 comments on commit 006bb9a

Please sign in to comment.