Skip to content

Commit

Permalink
Fix BOOLEAN parameter binding (#2635)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Aug 28, 2023
1 parent 0b86626 commit 101467c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ impl ::core::ops::Not for BOOLEAN {
}
}
}
impl ::windows_core::IntoParam<BOOLEAN> for bool {
fn into_param(self) -> ::windows_core::Param<BOOLEAN> {
::windows_core::Param::Owned(self.into())
}
}
5 changes: 5 additions & 0 deletions crates/libs/windows/src/Windows/Win32/Foundation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21677,6 +21677,11 @@ impl ::core::ops::Not for BOOLEAN {
}
}
}
impl ::windows_core::IntoParam<BOOLEAN> for bool {
fn into_param(self) -> ::windows_core::Param<BOOLEAN> {
::windows_core::Param::Owned(self.into())
}
}
impl NTSTATUS {
#[inline]
pub const fn is_ok(self) -> bool {
Expand Down
4 changes: 4 additions & 0 deletions crates/tests/extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ path = "../../libs/windows"
features = [
"Win32_Foundation",
"Win32_Security_Cryptography",
"Win32_NetworkManagement_IpHelper",
"Win32_NetworkManagement_Ndis",
"Win32_Networking_WinSock",
"Win32_System_Threading",
]
11 changes: 10 additions & 1 deletion crates/tests/extensions/tests/bool32.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use windows::Win32::Foundation::*;
use windows::{Win32::Foundation::*, Win32::System::Threading::*};

#[test]
fn test() {
Expand All @@ -21,3 +21,12 @@ fn test() {
let error = result.unwrap_err();
assert_eq!(error.code(), E_ACCESSDENIED);
}

#[test]
#[ignore]
fn no_run() {
unsafe {
_ = CreateEventA(None, false, true, None);
_ = CreateEventA(None, BOOL(0), BOOL(1), None);
}
}
23 changes: 22 additions & 1 deletion crates/tests/extensions/tests/boolean.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use windows::Win32::Foundation::*;
use windows::{Win32::Foundation::*, Win32::NetworkManagement::IpHelper::*};

#[test]
fn test() {
Expand All @@ -21,3 +21,24 @@ fn test() {
let error = result.unwrap_err();
assert_eq!(error.code(), E_ACCESSDENIED);
}

#[test]
#[ignore]
fn no_run() {
unsafe {
_ = NotifyUnicastIpAddressChange(
Default::default(),
None,
None,
true,
std::ptr::null_mut(),
);
_ = NotifyUnicastIpAddressChange(
Default::default(),
None,
None,
BOOLEAN(1),
std::ptr::null_mut(),
);
}
}

0 comments on commit 101467c

Please sign in to comment.