diff --git a/Cargo.lock b/Cargo.lock index f382884..41a4105 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,7 +258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -374,9 +374,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -401,6 +401,16 @@ version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -485,9 +495,9 @@ dependencies = [ [[package]] name = "mssf-pal" -version = "0.0.15" +version = "0.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a34574d346fdc1574a0ad15b33f582eaa0d690d1962ab43255f16df0120796" +checksum = "3a10e4931c41abf7a8740fdd7ebb6302fdca84852830542e11b1cd85cea9bc23" dependencies = [ "libc", "windows", @@ -707,6 +717,7 @@ dependencies = [ name = "simple" version = "0.1.0" dependencies = [ + "libloading", "msquic-sys", "windows-core", ] @@ -776,9 +787,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", diff --git a/crates/samples/simple/Cargo.toml b/crates/samples/simple/Cargo.toml index 292e00c..2477819 100644 --- a/crates/samples/simple/Cargo.toml +++ b/crates/samples/simple/Cargo.toml @@ -6,5 +6,6 @@ description = "Example of using the generated MsQuic binding from winmd" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +libloading = "0.8" "msquic-sys" = { version = "*", path = "../../libs/msquic-sys", features = ["MsQuic"]} -"windows-core" = "0.57.0" \ No newline at end of file +"windows-core" = "0.57.0" diff --git a/crates/samples/simple/src/lib.rs b/crates/samples/simple/src/lib.rs index 352fcd2..40b38d0 100644 --- a/crates/samples/simple/src/lib.rs +++ b/crates/samples/simple/src/lib.rs @@ -171,3 +171,27 @@ mod tests { api.registation_close(rh); } } + +#[cfg(test)] +mod test2 { + use msquic_sys::Microsoft::MsQuic::{QUIC_API_TABLE, QUIC_API_VERSION_2}; + + #[test] + fn dynamic_load() { + let lib_name = libloading::library_filename("msquic"); + let lib = unsafe { libloading::Library::new(lib_name) }.unwrap(); + let fn_open: libloading::Symbol< + unsafe extern "C" fn(u32, *mut *mut QUIC_API_TABLE) -> i32, + > = unsafe { lib.get(b"MsQuicOpenVersion") }.unwrap(); + let fn_close: libloading::Symbol = + unsafe { lib.get(b"MsQuicClose") }.unwrap(); + let mut api = std::ptr::null_mut::(); + let ec = unsafe { fn_open(QUIC_API_VERSION_2, std::ptr::addr_of_mut!(api)) }; + assert_eq!( + ec, + msquic_sys::Microsoft::MsQuic::Win32::QUIC_STATUS_SUCCESS.0 + ); + assert!(!api.is_null()); + unsafe { fn_close(api) }; + } +}