diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index 5f12aaaf..633ba2b3 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -82,7 +82,7 @@ pub const fn NT_SUCCESS(nt_status: NTSTATUS) -> bool { /// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and /// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. pub const fn NT_INFORMATION(nt_status: NTSTATUS) -> bool { - nt_status >> 30 == 1 + (nt_status as u32 >> 30) == 1 } #[must_use] @@ -94,7 +94,7 @@ pub const fn NT_INFORMATION(nt_status: NTSTATUS) -> bool { /// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and /// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. pub const fn NT_WARNING(nt_status: NTSTATUS) -> bool { - nt_status >> 30 == 2 + (nt_status as u32 >> 30) == 2 } #[must_use] @@ -106,7 +106,7 @@ pub const fn NT_WARNING(nt_status: NTSTATUS) -> bool { /// See the [NTSTATUS reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781) and /// [Using NTSTATUS values](https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values) for details. pub const fn NT_ERROR(nt_status: NTSTATUS) -> bool { - nt_status >> 30 == 3 + (nt_status as u32 >> 30) == 3 } #[allow(missing_docs)] @@ -117,3 +117,28 @@ macro_rules! PAGED_CODE { debug_assert!(unsafe { KeGetCurrentIrql() <= APC_LEVEL as u8 }); }; } + +#[cfg(test)] +mod tests { + use crate::{ + NT_ERROR, + NT_INFORMATION, + NT_SUCCESS, + NT_WARNING, + STATUS_BREAKPOINT, + STATUS_HIBERNATED, + STATUS_PRIVILEGED_INSTRUCTION, + STATUS_SUCCESS, + }; + #[test] + pub fn status_tests() { + const { + assert!(NT_SUCCESS(STATUS_SUCCESS)); + assert!(NT_SUCCESS(STATUS_HIBERNATED)); + assert!(NT_INFORMATION(STATUS_HIBERNATED)); + assert!(NT_WARNING(STATUS_BREAKPOINT)); + assert!(NT_ERROR(STATUS_PRIVILEGED_INSTRUCTION)); + assert!(!(NT_INFORMATION(STATUS_SUCCESS))); + } + } +}