Skip to content

Commit

Permalink
Bump version 0.7.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Sep 27, 2024
1 parent 2e28bf0 commit 31ccb7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wintun-bindings"
version = "0.7.11"
version = "0.7.12"
edition = "2021"
authors = [
"ssrlive",
Expand Down
17 changes: 13 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use windows_sys::{
core::GUID,
Win32::{
Foundation::{
GetLastError, LocalFree, ERROR_BUFFER_OVERFLOW, ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS, NO_ERROR,
WIN32_ERROR,
GetLastError, LocalFree, ERROR_ADDRESS_NOT_ASSOCIATED, ERROR_BUFFER_OVERFLOW, ERROR_INSUFFICIENT_BUFFER,
ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY, ERROR_NO_DATA, ERROR_SUCCESS, NO_ERROR, WIN32_ERROR,
},
NetworkManagement::{
IpHelper::{
Expand Down Expand Up @@ -233,7 +233,7 @@ where
let result = unsafe { GetAdaptersAddresses(family, flags, std::ptr::null_mut(), std::ptr::null_mut(), &mut size) };

if result != ERROR_BUFFER_OVERFLOW {
return Err(format!("GetAdaptersAddresses failed: {}", format_message(result)?).into());
return Err(format!("GetAdaptersAddresses first attemp failed: {}", format_message(result)?).into());
}
// Allocate memory for the buffer
let mut addresses: Vec<u8> = vec![0; (size + 4) as usize];
Expand All @@ -245,7 +245,16 @@ where
};

if ERROR_SUCCESS != result {
return Err(format!("GetAdaptersAddresses failed: {}", format_message(result)?).into());
let err_msg = match result {
ERROR_ADDRESS_NOT_ASSOCIATED => "ERROR_ADDRESS_NOT_ASSOCIATED".into(),
ERROR_BUFFER_OVERFLOW => "ERROR_BUFFER_OVERFLOW".into(),
ERROR_INVALID_PARAMETER => "ERROR_INVALID_PARAMETER".into(),
ERROR_NOT_ENOUGH_MEMORY => "ERROR_NOT_ENOUGH_MEMORY".into(),
ERROR_NO_DATA => "ERROR_NO_DATA".into(),
_ => format_message(result)?,
};

return Err(format!("GetAdaptersAddresses second attemp failed: {err_msg}").into());
}

// If successful, output some information from the data we received
Expand Down

0 comments on commit 31ccb7f

Please sign in to comment.