I am reviewing the MS-ERREF documentation for HRESULT error codes, which states the following for the N bit:
N (1 bit): If set, indicates that the error code is an NTSTATUS value (as specified in section 2.3), except that this bit is set.
The NTSTATUS section has this to say regarding the N bit:
N (1 bit): Reserved. MUST be set to 0 so that it is possible to map an NTSTATUS value to an equivalent HRESULT value, as specified in section 2.1, by setting this bit.
I'm trying to understand the "except that this bit is set" part in the HRESULT section's description of the N bit...
Is it saying that if the N bit is set in an HRESULT, then we should clear the bit and then reinterpret the error as an NTSTATUS?
I am reviewing the MS-ERREF documentation for HRESULT error codes, which states the following for the N bit:
N (1 bit): If set, indicates that the error code is an NTSTATUS value (as specified in section 2.3), except that this bit is set.
The NTSTATUS section has this to say regarding the N bit:
N (1 bit): Reserved. MUST be set to 0 so that it is possible to map an NTSTATUS value to an equivalent HRESULT value, as specified in section 2.1, by setting this bit.
I'm trying to understand the "except that this bit is set" part in the HRESULT section's description of the N bit...
Is it saying that if the N bit is set in an HRESULT, then we should clear the bit and then reinterpret the error as an NTSTATUS?
Share Improve this question asked Feb 15 at 14:22 Bill_StewartBill_Stewart 24.6k5 gold badges54 silver badges67 bronze badges 3 |1 Answer
Reset to default 0Thanks to @RbMm and @IInspectable for the clarification on the Microsoft documentation: The answer is that the N bit in an HRESULT error code means "clear the N bit and interpret the result as an NTSTATAUS error code."
To help with error code analysis, I wrote an open-source console program to output details about Windows error codes, available here:
https://github/Bill-Stewart/ErrInfo/
It outputs the error code in binary, hexadecimal, and decimal numeric formats and uses FormatMessage to try to retrieve the message string related to the error code. (It's kind of an improved net helpmsg
command.)
HRESULT
values, where theN
-bit identifies anNTSTATUS
value stored as anHRESULT
. – IInspectable Commented Feb 15 at 14:41