Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace winapi with windows-sys #525

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ openssl-probe = { version = "0.1.2", optional = true }

[target.'cfg(target_env = "msvc")'.dependencies]
schannel = "0.1.13"
winapi = { version = '0.3', features = ['libloaderapi', 'wincrypt'] }
windows-sys = { version = "0.48", features = ["Win32_System_LibraryLoader", "Win32_Security_Cryptography"] }

[dev-dependencies]
mio = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion curl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ features = ["no_log_capture"]
openssl-sys = { version = "0.9.64", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winsock2", "ws2def"] }
windows-sys = { version = "0.48", features = ["Win32_Networking_WinSock"] }

[target.'cfg(target_env = "msvc")'.build-dependencies]
vcpkg = "0.2"
Expand Down
4 changes: 2 additions & 2 deletions curl-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use libc::{c_char, c_double, c_int, c_long, c_short, c_uint, c_void, size_t, tim
#[cfg(unix)]
pub use libc::fd_set;
#[cfg(windows)]
use winapi::shared::ws2def::SOCKADDR;
pub use windows_sys::Win32::Networking::WinSock::FD_SET as fd_set;
#[cfg(windows)]
pub use winapi::um::winsock2::fd_set;
use windows_sys::Win32::Networking::WinSock::SOCKADDR;

#[cfg(target_env = "msvc")]
#[doc(hidden)]
Expand Down
19 changes: 7 additions & 12 deletions src/easy/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ use libc::c_void;
mod win {
use schannel::cert_context::ValidUses;
use schannel::cert_store::CertStore;
use std::ffi::CString;
use std::ffi::*;
use std::mem;
use std::ptr;
use winapi::ctypes::*;
use winapi::um::libloaderapi::*;
use winapi::um::wincrypt::*;
use windows_sys::Win32::Security::Cryptography::*;
use windows_sys::Win32::System::LibraryLoader::*;

fn lookup(module: &str, symbol: &str) -> Option<*const c_void> {
unsafe {
let symbol = CString::new(symbol).unwrap();
let mut mod_buf: Vec<u16> = module.encode_utf16().collect();
mod_buf.push(0);
let handle = GetModuleHandleW(mod_buf.as_mut_ptr());
let n = GetProcAddress(handle, symbol.as_ptr());
if n == ptr::null_mut() {
None
} else {
Some(n as *const c_void)
}
GetProcAddress(handle, symbol.as_ptr()).map(|n| n as *const c_void)
}
}

Expand Down Expand Up @@ -104,7 +97,9 @@ mod win {
match valid_uses {
ValidUses::All => {}
ValidUses::Oids(ref oids) => {
let oid = szOID_PKIX_KP_SERVER_AUTH.to_owned();
let oid = CStr::from_ptr(szOID_PKIX_KP_SERVER_AUTH as *const _)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to_string_lossy()
.into_owned();
if !oids.contains(&oid) {
continue;
}
Expand Down