windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

Add more precise NTSTATUS const fns.

Open NateD-MSFT opened this issue 1 year ago • 1 comments

The current NT_SUCCESS macro checks for NTSTATUS >= 0. While this is semantically equivalent to the official behavior I think it is appropriate to match MSDN documentation exactly.

This PR also adds the other NT_ macros for information, warning, and error values.

Reference: https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values

NateD-MSFT avatar Jul 09 '24 19:07 NateD-MSFT

For reference, here's how they're defined in C:

#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)

#ifdef _PREFAST_
#define NT_INFORMATION(Status) (((NTSTATUS)(Status)) >= (long)0x40000000)
#else
#define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
#endif

#ifdef _PREFAST_
#define NT_WARNING(Status) (((NTSTATUS)(Status) < (long)0xc0000000))
#else
#define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
#endif

#ifdef _PREFAST_
#define NT_ERROR(Status) (((NTSTATUS)(Status)) >= (unsigned long)0xc0000000)
#else
#define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
#endif

ChrisDenton avatar Jul 11 '24 03:07 ChrisDenton

@wmmc88 it looks like one of the docs jobs hanged. Can you restart it or bypass it?

NateD-MSFT avatar Sep 05 '24 01:09 NateD-MSFT

@wmmc88 it looks like one of the docs jobs hanged. Can you restart it or bypass it?

Ah. Hanged on winget installation. Winget installation is primarily used to get the WDK. Do you think someone could port the pipelines to use the new nuget pkgs?

wmmc88 avatar Sep 05 '24 02:09 wmmc88