From 2570303364ebbefccdf20d936682ecf3a3e3dc28 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Sat, 9 Nov 2024 14:24:30 +0800 Subject: [PATCH] get_wintun_bin_pattern_path issues --- examples/basic-async.rs | 5 ++++- examples/basic.rs | 5 ++++- examples/udp-echo-async.rs | 5 ++++- examples/udp-echo.rs | 5 ++++- examples/wireshark.rs | 5 ++++- src/fn_holder.rs | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/basic-async.rs b/examples/basic-async.rs index 76e4288..4af1d79 100644 --- a/examples/basic-async.rs +++ b/examples/basic-async.rs @@ -11,7 +11,10 @@ static RUNNING: AtomicBool = AtomicBool::new(true); async fn main() -> Result<(), BoxError> { dotenvy::dotenv().ok(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init(); - let dll_path = get_wintun_bin_pattern_path()?; + let mut dll_path = get_wintun_bin_pattern_path()?; + if !std::fs::exists(&dll_path)? { + dll_path = "wintun.dll".into(); + } let wintun = unsafe { load_from_path(dll_path)? }; let version = get_running_driver_version(&wintun); diff --git a/examples/basic.rs b/examples/basic.rs index 5cb1f35..58b3fd2 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -5,7 +5,10 @@ static RUNNING: AtomicBool = AtomicBool::new(true); fn main() -> Result<(), wintun_bindings::BoxError> { dotenvy::dotenv().ok(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init(); - let dll_path = wintun_bindings::get_wintun_bin_pattern_path()?; + let mut dll_path = wintun_bindings::get_wintun_bin_pattern_path()?; + if !std::fs::exists(&dll_path)? { + dll_path = "wintun.dll".into(); + } let wintun = unsafe { wintun_bindings::load_from_path(dll_path)? }; let version = wintun_bindings::get_running_driver_version(&wintun); diff --git a/examples/udp-echo-async.rs b/examples/udp-echo-async.rs index 1a53d6c..e3eb488 100644 --- a/examples/udp-echo-async.rs +++ b/examples/udp-echo-async.rs @@ -52,7 +52,10 @@ async fn main() -> Result<(), BoxError> { dotenvy::dotenv().ok(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init(); // Loading wintun - let dll_path = get_wintun_bin_pattern_path()?; + let mut dll_path = get_wintun_bin_pattern_path()?; + if !std::fs::exists(&dll_path)? { + dll_path = "wintun.dll".into(); + } let wintun = unsafe { load_from_path(dll_path)? }; let version = get_running_driver_version(&wintun); diff --git a/examples/udp-echo.rs b/examples/udp-echo.rs index b067a84..44057e3 100644 --- a/examples/udp-echo.rs +++ b/examples/udp-echo.rs @@ -52,7 +52,10 @@ fn main() -> Result<(), BoxError> { dotenvy::dotenv().ok(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init(); // Loading wintun - let dll_path = get_wintun_bin_pattern_path()?; + let mut dll_path = get_wintun_bin_pattern_path()?; + if !std::fs::exists(&dll_path)? { + dll_path = "wintun.dll".into(); + } let wintun = unsafe { load_from_path(dll_path)? }; let version = get_running_driver_version(&wintun); diff --git a/examples/wireshark.rs b/examples/wireshark.rs index 7be66da..ce1cfa0 100644 --- a/examples/wireshark.rs +++ b/examples/wireshark.rs @@ -66,7 +66,10 @@ fn main() -> Result<(), BoxError> { dotenvy::dotenv().ok(); env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init(); - let dll_path = get_wintun_bin_pattern_path()?; + let mut dll_path = get_wintun_bin_pattern_path()?; + if !std::fs::exists(&dll_path)? { + dll_path = "wintun.dll".into(); + } let wintun = unsafe { wintun_bindings::load_from_path(dll_path)? }; let adapter = match wintun_bindings::Adapter::open(&wintun, "Demo") { diff --git a/src/fn_holder.rs b/src/fn_holder.rs index f5b0ead..b336651 100644 --- a/src/fn_holder.rs +++ b/src/fn_holder.rs @@ -42,7 +42,7 @@ macro_rules! define_fn_dynamic_load { // usage use windows_sys::Win32::Foundation::BOOL; define_fn_dynamic_load!( - ProcessPrngDeclear, + ProcessPrngDeclare, unsafe extern "system" fn(pbdata: *mut u8, cbdata: usize) -> BOOL, PROCESS_PRNG, ProcessPrng,