Skip to content

Commit

Permalink
Add support for dynamic loading of windows dll
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachNo committed Jan 19, 2024
1 parent 3856fa5 commit 1d82bfb
Show file tree
Hide file tree
Showing 7 changed files with 559 additions and 149 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ gat-std = { version = "0.1.1", optional = true }
# and these libraries would truncate the min support Rust version (MSRV)
tun-tap = { version = "0.1.3", optional = true }
etherparse = { version = "0.13.0", optional = true }
libloading = "0.8"

[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.36.1", features = ["Win32_Foundation", "Win32_Networking_WinSock"] }
once_cell = "1.19"

[dev-dependencies]
tempdir = "0.3"
Expand All @@ -34,7 +36,7 @@ tempdir = "0.3"
eui48 = "1.1"

[build-dependencies]
libloading = "0.6"
libloading = "0.8"
regex = "1"
pkg-config = "0.3"

Expand All @@ -44,6 +46,7 @@ pkg-config = "0.3"
capture-stream = ["tokio", "futures"]
tap-tests = ["tun-tap", "etherparse"]
lending-iter = ["gat-std"]
dynamic-load = []
# an empty feature to detect if '--all-features' was set
all-features = []

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn get_libpcap_version(libdirpath: Option<PathBuf>) -> Result<Version, Box<dyn s
libfile = libdir.join(libfile);
}

let lib = if let Ok(lib) = libloading::Library::new(libfile) {
let lib = if let Ok(lib) = unsafe { libloading::Library::new(libfile) } {
lib
} else {
return Ok(Version::max());
Expand Down
Loading

0 comments on commit 1d82bfb

Please sign in to comment.