-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![allow( | ||
non_snake_case, | ||
non_upper_case_globals, | ||
non_camel_case_types, | ||
dead_code, | ||
clippy::all | ||
)] | ||
|
||
#[inline] | ||
pub unsafe fn EnableMouseInPointer(fenable: bool) -> windows_core::Result<()> { | ||
windows_targets::link!("user32.dll" "system" fn EnableMouseInPointer(fenable : windows::Win32::Foundation:: BOOL) -> windows::Win32::Foundation:: BOOL); | ||
EnableMouseInPointer(fenable.into()).ok() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#![allow( | ||
non_snake_case, | ||
non_upper_case_globals, | ||
non_camel_case_types, | ||
dead_code, | ||
clippy::all | ||
)] | ||
|
||
#[inline] | ||
pub unsafe fn CreateEventW<P3>( | ||
lpeventattributes: Option<*const windows::Win32::Security::SECURITY_ATTRIBUTES>, | ||
bmanualreset: bool, | ||
binitialstate: bool, | ||
lpname: P3, | ||
) -> windows_core::Result<windows::Win32::Foundation::HANDLE> | ||
where | ||
P3: windows_core::Param<windows_core::PCWSTR>, | ||
{ | ||
windows_targets::link!("kernel32.dll" "system" fn CreateEventW(lpeventattributes : *const windows::Win32::Security:: SECURITY_ATTRIBUTES, bmanualreset : windows::Win32::Foundation:: BOOL, binitialstate : windows::Win32::Foundation:: BOOL, lpname : windows_core::PCWSTR) -> windows::Win32::Foundation:: HANDLE); | ||
let result__ = CreateEventW( | ||
core::mem::transmute(lpeventattributes.unwrap_or(core::mem::zeroed())), | ||
bmanualreset.into(), | ||
binitialstate.into(), | ||
lpname.param().abi(), | ||
); | ||
(!result__.is_invalid()) | ||
.then_some(result__) | ||
.ok_or_else(windows_core::Error::from_win32) | ||
} | ||
#[inline] | ||
pub unsafe fn NtWaitForSingleObject( | ||
handle: windows::Win32::Foundation::HANDLE, | ||
alertable: bool, | ||
timeout: *mut i64, | ||
) -> windows::Win32::Foundation::NTSTATUS { | ||
windows_targets::link!("ntdll.dll" "system" fn NtWaitForSingleObject(handle : windows::Win32::Foundation:: HANDLE, alertable : windows::Win32::Foundation:: BOOLEAN, timeout : *mut i64) -> windows::Win32::Foundation:: NTSTATUS); | ||
NtWaitForSingleObject( | ||
core::mem::transmute(handle), | ||
alertable.into(), | ||
core::mem::transmute(timeout), | ||
) | ||
} | ||
#[inline] | ||
pub unsafe fn SetEvent(hevent: windows::Win32::Foundation::HANDLE) -> windows_core::Result<()> { | ||
windows_targets::link!("kernel32.dll" "system" fn SetEvent(hevent : windows::Win32::Foundation:: HANDLE) -> windows::Win32::Foundation:: BOOL); | ||
SetEvent(core::mem::transmute(hevent)).ok() | ||
} | ||
#[inline] | ||
pub unsafe fn WaitForSingleObjectEx( | ||
hhandle: windows::Win32::Foundation::HANDLE, | ||
dwmilliseconds: u32, | ||
balertable: bool, | ||
) -> windows::Win32::Foundation::WAIT_EVENT { | ||
windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObjectEx(hhandle : windows::Win32::Foundation:: HANDLE, dwmilliseconds : u32, balertable : windows::Win32::Foundation:: BOOL) -> windows::Win32::Foundation:: WAIT_EVENT); | ||
WaitForSingleObjectEx( | ||
core::mem::transmute(hhandle), | ||
core::mem::transmute(dwmilliseconds), | ||
balertable.into(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use test_bindgen::bool_event::*; | ||
use windows::Win32::Foundation::{STATUS_SUCCESS, STATUS_TIMEOUT, WAIT_OBJECT_0, WAIT_TIMEOUT}; | ||
|
||
#[test] | ||
fn test() { | ||
unsafe { | ||
// These bool parameters are actually BOOL. | ||
let event = CreateEventW(None, true, false, None).unwrap(); | ||
|
||
// This bool parameter is actually BOOL. | ||
assert_eq!(WAIT_TIMEOUT, WaitForSingleObjectEx(event, 0, false)); | ||
|
||
// This bool parameter is actually BOOLEAN. | ||
assert_eq!(STATUS_TIMEOUT, NtWaitForSingleObject(event, false, &mut 0)); | ||
|
||
let event = CreateEventW(None, true, true, None).unwrap(); | ||
|
||
assert_eq!(WAIT_OBJECT_0, WaitForSingleObjectEx(event, 0, false)); | ||
assert_eq!(STATUS_SUCCESS, NtWaitForSingleObject(event, false, &mut 0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ fn no_run() { | |
Default::default(), | ||
None, | ||
None, | ||
BOOLEAN(1), | ||
true, | ||
std::ptr::null_mut(), | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters