Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more precise NTSTATUS const fns #183

Merged
merged 9 commits into from
Sep 5, 2024
27 changes: 26 additions & 1 deletion crates/wdk-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,33 @@ lazy_static! {
#[allow(missing_docs)]
#[must_use]
#[allow(non_snake_case)]
#[allow(clippy::cast_sign_loss)]
pub const fn NT_SUCCESS(nt_status: NTSTATUS) -> bool {
nt_status >= 0
NateD-MSFT marked this conversation as resolved.
Show resolved Hide resolved
nt_status as u32 <= 0x7FFF_FFFF
NateD-MSFT marked this conversation as resolved.
Show resolved Hide resolved
}

#[allow(missing_docs)]
NateD-MSFT marked this conversation as resolved.
Show resolved Hide resolved
#[must_use]
#[allow(non_snake_case)]
#[allow(clippy::cast_sign_loss)]
pub const fn NT_INFORMATION(nt_status: NTSTATUS) -> bool {
nt_status as u32 >= 0x4000_0000 && nt_status as u32 <= 0x7FFF_FFFF
}

#[allow(missing_docs)]
#[must_use]
#[allow(non_snake_case)]
#[allow(clippy::cast_sign_loss)]
pub const fn NT_WARNING(nt_status: NTSTATUS) -> bool {
nt_status as u32 >= 0x8000_0000 && nt_status as u32 <= 0xBFFF_FFFF
}

#[allow(missing_docs)]
#[must_use]
#[allow(non_snake_case)]
#[allow(clippy::cast_sign_loss)]
pub const fn NT_ERROR(nt_status: NTSTATUS) -> bool {
nt_status as u32 >= 0xC000_0000
}

#[allow(missing_docs)]
Expand Down
Loading