private string DecodeWindowsError()

in TpmRcDecoder/TpmRcDecoder.Universal/Decoder.cs [1371:1395]


        private string DecodeWindowsError(uint input)
        {
            string output = "Windows Error Code:\n";

            string name = Enum.GetName(typeof(TPM_WIN_ERROR), input);
            if (string.IsNullOrEmpty(name))
            {
                output += " Unknown Windows error code.\n";
            }
            else
            { 
                output += " " + name + "\n ";
                // map the 0xC029xxxx error codes to the 0x8028xxxx error code - the description is the same
                if ((input & (uint)TPM_WIN_ERROR.STATUS_TPM_ERROR_MASK) == (uint)TPM_WIN_ERROR.STATUS_TPM_ERROR_MASK)
                {
                    input = (input ^ (uint)TPM_WIN_ERROR.STATUS_TPM_ERROR_MASK) | (uint)TPM_WIN_ERROR.TPM_E_ERROR_MASK;
                }
                string description;
                if (TPM_WIN_ERROR_DESC.TryGetValue(input, out description))
                {
                    output += " " + description;
                }
            }
            return output;
        }