none
Why is bit 30 of the error code sometimes marked as reserved? RRS feed

  • Question

  • Ref. : http://msdn.microsoft.com/en-us/library/ms690088%28v=VS.85%29.aspx

    Hello all,

    Working on error handling with VBScript, I went to the Microsoft COM documentation on COM error codes. I have been surprized to find the page in reference, dated 21-oct-2010 where the writer just hides the four SEVERITY values present and documented in Windows XP Winerror.h

    Of course, afaik, there are two bits used for this, not only one, which are 30 and 31 :

    // Sev - is the severity code
    //
    //          00 - Success
    //          01 - Informational
    //          10 - Warning
    //          11 - Error

    Why does the page in reference list Bit 30 as reserved ?
    Could someone please clarify "a bit" :-)

    Thanks a  lot.
    Regards

    DTL
    Toulouse
    France

    Wednesday, October 27, 2010 6:02 AM

Answers

  • Hello Toulousaing,

     

    The definition of “COM Error Codes” observed in winerror.h (see Winerror.h: Part 2) is consistent with the HRESULT definition in MS-ERREF Section 2.1.

    Bit S of HRESULT defines the severity (0 for success, 1 for failure).

    Bits R and N of HRESULT are reserved bits used for NTSTATUS (MS-ERREF Section 2.3).

    With NTSTATUS, bit 30 (i.e. bit R of HRESULT) is sometimes regarded as the NT's second severity bit.

    Bit R of HRESULT is a reserved bit that is defined by the NTSTATUS numbering space. This explains the NTSTATUS severity code 00, 01, 10, and 11.

    //          00 - Success

    //          01 - Informational

    //          10 - Warning

    //          11 - Error

     

    References:

     

    Structure of COM Error Codes

    http://msdn.microsoft.com/en-us/library/ms690088%28v=VS.85%29.aspx

     

    The following illustration shows the format of an HRESULT or SCODE; the numbers indicate bit positions:

     

     

    The high-order bit in the HRESULT or SCODE indicates whether the return value represents success or failure. If set to 0, SEVERITY_SUCCESS, the value indicates success. If set to 1, SEVERITY_ERROR, it indicates failure.

    The R, C, N, and r bits are reserved.

    The facility field indicates the system service responsible for the error. Microsoft allocates new facility codes as they become necessary. Most SCODEs and HRESULT values set the facility field to FACILITY_ITF, indicating an interface method error.

     

     

    Winerror.h: Part 1

    http://msdn.microsoft.com/en-us/library/ms819773.aspx

     

    //

    //  Values are 32 bit values laid out as follows:

    //

    //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1

    //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

    //  +---+-+-+-----------------------+-------------------------------+

    //  |Sev|C|R|     Facility          |               Code            |

    //  +---+-+-+-----------------------+-------------------------------+

    //

    //  where

    //

    //      Sev - is the severity code

    //

    //          00 - Success

    //          01 - Informational

    //          10 - Warning

    //          11 - Error

    //

    //      C - is the Customer code flag

    //

    //      R - is a reserved bit

    //

    //      Facility - is the facility code

    //

    //      Code - is the facility's status code

     

     

    Winerror.h: Part 2

    http://msdn.microsoft.com/en-us/library/ms819775.aspx

     

    ////////////////////////////////////
    //                                //
    //     COM Error Codes            //
    //                                //
    ////////////////////////////////////
     
    //
    // The return value of COM functions and methods is an HRESULT.
    // This is not a handle to anything, but is merely a 32-bit value
    // with several fields encoded in the value.  The parts of an
    // HRESULT are shown below.
    //
    // Many of the macros and functions below were orginally defined to
    // operate on SCODEs.  SCODEs are no longer used.  The macros are
    // still present for compatibility and easy porting of Win16 code.
    // Newly written code should use the HRESULT macros and functions.
    //
     
    //
    //  HRESULTs are 32 bit values laid out as follows:
    //
    //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
    //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
    //  +-+-+-+-+-+---------------------+-------------------------------+
    //  |S|R|C|N|r|    Facility         |               Code            |
    //  +-+-+-+-+-+---------------------+-------------------------------+
    //
    //  where
    //
    //      S - Severity - indicates success/fail
    //
    //          0 - Success
    //          1 - Fail (COERROR)
    //
    //      R - reserved portion of the facility code, corresponds to NT's
    //              second severity bit.
    //
    //      C - reserved portion of the facility code, corresponds to NT's
    //              C field.
    //
    //      N - reserved portion of the facility code. Used to indicate a
    //              mapped NT status value.
    //
    //      r - reserved portion of the facility code. Reserved for internal
    //              use. Used to indicate HRESULT values that are not status
    //              values, but are instead message ids for display strings.
    //
    //      Facility - is the facility code
    //
    //      Code - is the facility's status code
    //
     
    //
    // Severity values
    //
     
    #define SEVERITY_SUCCESS    0
    #define SEVERITY_ERROR      1

     

    MS-ERREF

     

    2.1 HRESULT

    http://msdn.microsoft.com/en-us/library/cc231198(v=PROT.10).aspx

    The HRESULT numbering space is vendor-extensible. Vendors can supply their own values for this field, as long as the C bit (0x20000000) is set, indicating it is a customer code.

    The HRESULT numbering space has the following internal structure. The following diagram is independent of endianness (that is, the diagram is shown in host byte order); it merely shows the layout of the numbering space. Any protocol that uses NTSTATUS values on the wire is responsible for stating the order in which the bytes are placed on the wire.


    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    1
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    2
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    3
    0


    1

    S

    R

    C

    N

    X

    Facility

    Code

    S (1 bit): Severity. If set, indicates a failure result. If clear, indicates a success result.

    R (1 bit): Reserved. If the N bit is clear, this bit MUST be set to 0. If the N bit is set, this bit is defined by the NTSTATUS numbering space (as specified in section 2.3).

    C (1 bit): Customer. This bit specifies if the value is customer-defined or Microsoft-defined. The bit is set for customer-defined values and clear for Microsoft-defined values.<1>

    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.

    X (1 bit): Reserved. SHOULD be set to 0. <2>

    Facility (11 bits): An indicator of the source of the error. New facilities are occasionally added by Microsoft.

     

    2.3 NTSTATUS

    http://msdn.microsoft.com/en-us/library/cc231200(v=PROT.10).aspx

    Values are 32 bit and are laid out as follows. The following diagram is independent of endianness; that is, the diagram is shown in host byte order and merely shows the layout of the numbering space.

    Any protocol that uses NTSTATUS values on the wire is responsible for stating the order that the bytes are placed on the wire.


    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    1
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    2
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    3
    0


    1

    Sev

    C

    N

    Facility

    Code

    Sev (2 bits): Severity. Severity codes are as follows.

    Value

    Meaning

    STATUS_SEVERITY_SUCCESS
    0x0

    Success

    STATUS_SEVERITY_INFORMATIONAL
    0x1

    Informational

    STATUS_SEVERITY_WARNING
    0x2

    Warning

    STATUS_SEVERITY_ERROR
    0x3

    Error

    C (1 bit): Customer. This specifies if the value is customer- or Microsoft-defined. This bit is set for customer-defined values and clear for Microsoft-defined values.<4>

    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.

    Facility (12 bits): A value that, together with the C bit, indicates the numbering space to use for the Code field.<5>

    Code (2 bytes): The remainder of the error code. Vendors SHOULD reuse the values in the following table with their indicated meaning or define their own values with the C bit set. Choosing any other value with the C bit clear runs the risk of a collision in the future.

     

     

    Regards,

    Edgar

     


    Edgar
    Friday, October 29, 2010 9:24 PM
    Moderator

  • Hi,

    This forum handles requests related to Open Specifications documentation issues.
    The Open Specifications can be found at: http://msdn2.microsoft.com/en-us/library/cc203350.aspx.
    Your question does not appear to be related to the Open Specifications documentation set.

    The best way to get assistance on this issue is to submit a documentation feedback. You will find the submission link "Send comments about this topic to Microsoft" just on top of the "Build date: 10/21/2010" at the bottom of the page  http://msdn.microsoft.com/en-us/library/ms690088%28v=VS.85%29.aspx.
    This enables the message to be directed to the appropriate team with the right topic and release number.

    Regards,
    Edgar

    Wednesday, October 27, 2010 3:52 PM
    Moderator

All replies


  • Hi,

    This forum handles requests related to Open Specifications documentation issues.
    The Open Specifications can be found at: http://msdn2.microsoft.com/en-us/library/cc203350.aspx.
    Your question does not appear to be related to the Open Specifications documentation set.

    The best way to get assistance on this issue is to submit a documentation feedback. You will find the submission link "Send comments about this topic to Microsoft" just on top of the "Build date: 10/21/2010" at the bottom of the page  http://msdn.microsoft.com/en-us/library/ms690088%28v=VS.85%29.aspx.
    This enables the message to be directed to the appropriate team with the right topic and release number.

    Regards,
    Edgar

    Wednesday, October 27, 2010 3:52 PM
    Moderator
  • Hello Edgar,

    Thanks for your prompt reply.

    The way Winerr.h errors is coded *is* part of the Open Specs.

    See http://msdn.microsoft.com/en-us/library/cc231198(v=PROT.10).aspx

    HRESULT is a structure of the Windows Error Codes, part of the References of the Windows protocol, a member of the Open Specs (according to what I understood).

    I did submit a question to the Doc Group but I'm not totally happy with the answer I got:

    "Thank you for the question. The authoritative definition of HRESULT is in the protocol documentation, at http://msdn.microsoft.com/en-us/library/cc231198(v=PROT.10).aspx . The winerror.h file does contain a definition of HRESULT that conforms to the protocol, and you can find it by searching for “COM Error Codes” in a current version of winerror.h. "

    This is a nice answer, but it does not actually answer my question, you see.

    Wednesday, October 27, 2010 5:57 PM
  • Hello Toulousaing,

    One of our engineers will investigate this and provide a feedback.

    Regards,

    Edgar

     

    Thursday, October 28, 2010 2:52 PM
    Moderator
  • Hello Toulousaing,

     

    The definition of “COM Error Codes” observed in winerror.h (see Winerror.h: Part 2) is consistent with the HRESULT definition in MS-ERREF Section 2.1.

    Bit S of HRESULT defines the severity (0 for success, 1 for failure).

    Bits R and N of HRESULT are reserved bits used for NTSTATUS (MS-ERREF Section 2.3).

    With NTSTATUS, bit 30 (i.e. bit R of HRESULT) is sometimes regarded as the NT's second severity bit.

    Bit R of HRESULT is a reserved bit that is defined by the NTSTATUS numbering space. This explains the NTSTATUS severity code 00, 01, 10, and 11.

    //          00 - Success

    //          01 - Informational

    //          10 - Warning

    //          11 - Error

     

    References:

     

    Structure of COM Error Codes

    http://msdn.microsoft.com/en-us/library/ms690088%28v=VS.85%29.aspx

     

    The following illustration shows the format of an HRESULT or SCODE; the numbers indicate bit positions:

     

     

    The high-order bit in the HRESULT or SCODE indicates whether the return value represents success or failure. If set to 0, SEVERITY_SUCCESS, the value indicates success. If set to 1, SEVERITY_ERROR, it indicates failure.

    The R, C, N, and r bits are reserved.

    The facility field indicates the system service responsible for the error. Microsoft allocates new facility codes as they become necessary. Most SCODEs and HRESULT values set the facility field to FACILITY_ITF, indicating an interface method error.

     

     

    Winerror.h: Part 1

    http://msdn.microsoft.com/en-us/library/ms819773.aspx

     

    //

    //  Values are 32 bit values laid out as follows:

    //

    //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1

    //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

    //  +---+-+-+-----------------------+-------------------------------+

    //  |Sev|C|R|     Facility          |               Code            |

    //  +---+-+-+-----------------------+-------------------------------+

    //

    //  where

    //

    //      Sev - is the severity code

    //

    //          00 - Success

    //          01 - Informational

    //          10 - Warning

    //          11 - Error

    //

    //      C - is the Customer code flag

    //

    //      R - is a reserved bit

    //

    //      Facility - is the facility code

    //

    //      Code - is the facility's status code

     

     

    Winerror.h: Part 2

    http://msdn.microsoft.com/en-us/library/ms819775.aspx

     

    ////////////////////////////////////
    //                                //
    //     COM Error Codes            //
    //                                //
    ////////////////////////////////////
     
    //
    // The return value of COM functions and methods is an HRESULT.
    // This is not a handle to anything, but is merely a 32-bit value
    // with several fields encoded in the value.  The parts of an
    // HRESULT are shown below.
    //
    // Many of the macros and functions below were orginally defined to
    // operate on SCODEs.  SCODEs are no longer used.  The macros are
    // still present for compatibility and easy porting of Win16 code.
    // Newly written code should use the HRESULT macros and functions.
    //
     
    //
    //  HRESULTs are 32 bit values laid out as follows:
    //
    //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
    //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
    //  +-+-+-+-+-+---------------------+-------------------------------+
    //  |S|R|C|N|r|    Facility         |               Code            |
    //  +-+-+-+-+-+---------------------+-------------------------------+
    //
    //  where
    //
    //      S - Severity - indicates success/fail
    //
    //          0 - Success
    //          1 - Fail (COERROR)
    //
    //      R - reserved portion of the facility code, corresponds to NT's
    //              second severity bit.
    //
    //      C - reserved portion of the facility code, corresponds to NT's
    //              C field.
    //
    //      N - reserved portion of the facility code. Used to indicate a
    //              mapped NT status value.
    //
    //      r - reserved portion of the facility code. Reserved for internal
    //              use. Used to indicate HRESULT values that are not status
    //              values, but are instead message ids for display strings.
    //
    //      Facility - is the facility code
    //
    //      Code - is the facility's status code
    //
     
    //
    // Severity values
    //
     
    #define SEVERITY_SUCCESS    0
    #define SEVERITY_ERROR      1

     

    MS-ERREF

     

    2.1 HRESULT

    http://msdn.microsoft.com/en-us/library/cc231198(v=PROT.10).aspx

    The HRESULT numbering space is vendor-extensible. Vendors can supply their own values for this field, as long as the C bit (0x20000000) is set, indicating it is a customer code.

    The HRESULT numbering space has the following internal structure. The following diagram is independent of endianness (that is, the diagram is shown in host byte order); it merely shows the layout of the numbering space. Any protocol that uses NTSTATUS values on the wire is responsible for stating the order in which the bytes are placed on the wire.


    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    1
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    2
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    3
    0


    1

    S

    R

    C

    N

    X

    Facility

    Code

    S (1 bit): Severity. If set, indicates a failure result. If clear, indicates a success result.

    R (1 bit): Reserved. If the N bit is clear, this bit MUST be set to 0. If the N bit is set, this bit is defined by the NTSTATUS numbering space (as specified in section 2.3).

    C (1 bit): Customer. This bit specifies if the value is customer-defined or Microsoft-defined. The bit is set for customer-defined values and clear for Microsoft-defined values.<1>

    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.

    X (1 bit): Reserved. SHOULD be set to 0. <2>

    Facility (11 bits): An indicator of the source of the error. New facilities are occasionally added by Microsoft.

     

    2.3 NTSTATUS

    http://msdn.microsoft.com/en-us/library/cc231200(v=PROT.10).aspx

    Values are 32 bit and are laid out as follows. The following diagram is independent of endianness; that is, the diagram is shown in host byte order and merely shows the layout of the numbering space.

    Any protocol that uses NTSTATUS values on the wire is responsible for stating the order that the bytes are placed on the wire.


    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    1
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    2
    0


    1


    2


    3


    4


    5


    6


    7


    8


    9

    3
    0


    1

    Sev

    C

    N

    Facility

    Code

    Sev (2 bits): Severity. Severity codes are as follows.

    Value

    Meaning

    STATUS_SEVERITY_SUCCESS
    0x0

    Success

    STATUS_SEVERITY_INFORMATIONAL
    0x1

    Informational

    STATUS_SEVERITY_WARNING
    0x2

    Warning

    STATUS_SEVERITY_ERROR
    0x3

    Error

    C (1 bit): Customer. This specifies if the value is customer- or Microsoft-defined. This bit is set for customer-defined values and clear for Microsoft-defined values.<4>

    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.

    Facility (12 bits): A value that, together with the C bit, indicates the numbering space to use for the Code field.<5>

    Code (2 bytes): The remainder of the error code. Vendors SHOULD reuse the values in the following table with their indicated meaning or define their own values with the C bit set. Choosing any other value with the C bit clear runs the risk of a collision in the future.

     

     

    Regards,

    Edgar

     


    Edgar
    Friday, October 29, 2010 9:24 PM
    Moderator
  • Ok this is what I missed:

      R - reserved portion of the facility code, corresponds to NT's
    

    //              second severity bit.

    Thanks for your time.

     

     

    Saturday, October 30, 2010 5:13 AM