public string Decode()

in TpmRcDecoder/TpmRcDecoder.Universal/Decoder.cs [15:64]


        public string Decode(string inputText)
        {
            string inStr = inputText;
            if (inStr.Trim().StartsWith("0x", StringComparison.CurrentCultureIgnoreCase))
            {
                inStr = inStr.Trim().Substring(2);
            }
            UInt32 input = 0;
            try
            {
                input = UInt32.Parse(inStr, NumberStyles.HexNumber);
            }
            catch (FormatException)
            {
                return "Input format error.";
            }

            // Windows error codes
            string output = "";
            if ((((input & STATUS_SEVERITY_MASK) == STATUS_SEVERITY_ERROR) ||
                 ((input & STATUS_SEVERITY_MASK) == STATUS_SEVERITY_WARNING)) &&
                (((input & STATUS_FACILITY_MASK) == FACILITY_TPM_SERVICE) ||
                 ((input & STATUS_FACILITY_MASK) == FACILITY_TPM_SOFTWARE)))
            {
                output = DecodeWindowsError(input);
            }
            else if ((input & TPM_RC_FMT) == TPM_RC_FMT)
            {
                output += DecodeFormatError(input);
            }
            else if ((input & TPM_RC_VENDOR_ERROR) == TPM_RC_VENDOR_ERROR)
            {
                output += String.Format("Vendor specific error: 0x{0:x}", input & TPM_RC_ERROR_MASK);
            }
            else if ((input & TPM_RC_RSVD) == TPM_RC_RSVD)
            {
                output += "Bit 9 of return code not 0.\n";
                output += String.Format("Cleaned return code is 0x{0:x}.\n", input ^ TPM_RC_RSVD);
            }
            else if ((input & TPM_RC_WARN) == TPM_RC_WARN)
            {
                output += DecodeWarning(input);
            }
            else
            {
                output += DecodeError(input);
            }

            return output;
        }