예제 #1
0
    public void GetMessage_NTStatus()
    {
        NTStatus error   = NTStatus.Code.EPT_NT_INVALID_ENTRY;
        string   message = error.GetMessage();

        Assert.Equal("The entry is invalid", message);
    }
예제 #2
0
        /// <summary>
        /// Gets the message associated with the given <see cref="NTStatus"/>.
        /// </summary>
        /// <param name="status">The <see cref="NTStatus"/> for the error.</param>
        /// <returns>The description of the error.</returns>
        private static string GetMessage(NTStatus status)
        {
            string hexCode = $"0x{(int)status:X8}";
            string namedCode = Enum.GetName(typeof(NTStatus.Code), status.AsUInt32);
            string statusAsString = namedCode != null
                ? $"{namedCode} ({hexCode})"
                : hexCode;
            string insert = $"NT_STATUS {GetSeverityString(status)}: {statusAsString}";
            string message = null;
#if DESKTOP
            message = status.GetMessage();
#endif

            return message != null
                ? $"{message} ({insert})"
                : insert;
        }