Ejemplo n.º 1
0
        /// <summary>
        /// Gets a string which describes the NT status value.
        /// </summary>
        /// <param name="status">The NT status value.</param>
        /// <returns>A message, or null if the message could not be retrieved.</returns>
        public static string GetMessage(this NtStatus status)
        {
            string message;

            message = NativeUtils.GetMessage(
                Loader.GetDllHandle("ntdll.dll"),
                0xb,
                System.Threading.Thread.CurrentThread.CurrentUICulture.LCID,
                (int)status
                );

            if (message != null)
            {
                // Fix those messages which are formatted like:
                // {Asdf}\r\nAsdf asdf asdf...
                if (message.StartsWith("{"))
                {
                    string[] split = message.Split('\n');

                    if (split.Length > 1)
                    {
                        message = split[1];
                    }
                }
            }

            return(message);
        }