21

In a previous question, I asked what it meant when my program returned an obscure value like

-1073741819

Well, now I'm getting another large return value,

-1073740777

And I would like to know if there is some list of all of these values and what they mean sopmewhere?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • I can't believe it, but this is the first time this question has appeared on SO, as far as I can see. I thought sure it must be a duplicate by now. – John Saunders Jul 04 '09 at 01:30

7 Answers7

14

Because the Windows error code system is extensible, there is no single place to look up all possible Windows error codes. However, you can start with:

  • Study the Structure of COM Error Codes. Sometimes knowing what facility an error comes from can help you discover what header file it comes from.
  • Visual Studio, since at least 2003, includes an ERRLOOK tool. Try that first if you're using Visual Studio.
  • Many of the codes you'll encounter are in Winerror.h. I've included a link to MSDN that contains the contents of that header file. Or you can look at the error code listing by number on this page.
  • Ideally you know what function returned the code, and then you can lookup the function on MSDN and look at all the possible return values. Of course, you'll need to refer to Winerror.h, or an another header file to get the actual values.
  • You can find (like Unix grep) in the Include directory of the platform SDK for either the hex value of the entire error code, or the decimal value of just the code section--that is, the lower 16 bits. Use HRESULT_CODE to extract that. See the Structure of COM Error Codes above.
  • There are a few error lookup tools where you can paste in a value and it looks it up in its database and tells you what it means. Look here and here.
  • Google. Use the full hex value. Sometimes you'll find very useful information, or at least clues.
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Jared Oberhaus
  • 14,547
  • 4
  • 56
  • 55
14

Here is a 100% free online tool "MagnumDB" for "Magical Number Database" that contains about 350,000 constants (integers, strings, guids, etc.) parsed from the whole Windows SDK files (~6,000 files), that you can query by value and by name. Disclaimer: I wrote it after years of searching for constants, names, guids...

Here is the result for -1073741819 which maps to 3 different constants (with the same value and the same meaning) defined in 3 different files, the most common being STATUS_ACCESS_VIOLATION.

enter image description here

And for -1073740777 which is STATUS_INVALID_CRUNTIME_PARAMETER defined in winnt.h.

enter image description here

It supports integers, signed integers, unsigned integers, hexadecimal notation, and also raw text searches. It also knows the value of constants that are defined by operations (like c2 = c1 + 1).

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • 1
    this is a really dope/amazing tool, thanks for sharing! – m1m1k Oct 03 '22 at 20:00
  • 1
    Awesome tool! It even helped me realize I fooled myself by printing an error code in hex without a leading "x" that was ambiguous - 578). Highly recommended and now on my browser's speed dial. – Tom the Toolman Jan 20 '23 at 14:43
12

Generally you will get better search results if you print out the error number in hex, instead of signed decimal form.

For example, your first error is -1073741819 which can also be represented by 0xC0000005 in hex. This is an "access violation" error as google will quickly tell you.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • The hex for 1073740777 is 3ffffbe9, which doesn't have any google results. –  Jul 04 '09 at 01:40
  • 1
    It's negative 1073740777, not positive. –  Jul 04 '09 at 01:43
  • And what is negative 1073740777 in hex? –  Jul 04 '09 at 01:46
  • If you use printf("%08x\n", (int)-1073740777); it's easy to get the right answer. If you use a calculator, enter 0x100000000 and subtract decimal 1073740777, then convert back to hex. – Jared Oberhaus Jul 04 '09 at 01:53
  • Thank you. That makes it c0000417, or invlaid runtime parameter. –  Jul 04 '09 at 02:07
  • 3
    If you paste "-1073741819" into Windows Calculator (`calc.exe`) and then click the `Hex` radio button (when it's in its 'Scientific' View), then the result is FFFFFFFFC0000005, which you can see means 0xC0000005. – ChrisW Jul 04 '09 at 02:24
6

Well there's a bunch of them here,

http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx

But when I get one like your example I just Google the number.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
6

Many of them (but not I think the ones related to COM) are in a header file named winerror.h.

In (some versions of) Visual Studio, under the 'Tools' menu, you might find an menu item named 'Error Lookup...'.

ChrisW
  • 54,973
  • 13
  • 116
  • 224
6

NTSTATUS

NTSTATUS *covers a range of facilities
FACILITY_URT (0x013) *CLR exceptions

HRESULTS

FACILITY_NULL (0x000)
FACILITY_RPC (0x001)
FACILITY_DISPATCH (0x002)
FACILITY_RPC_STUBS (0x003)
FACILITY_USER (0x004) *multiple libraries can reuse the same error code
FACILITY_MCA_ERROR_CODE (0x005)
FACILITY_WIN32, MSDN (0x007) *standard WINAPI error codes
FACILITY_WINDOWS (0x008)
FACILITY_SECURITY (0x009)
FACILITY_CERT (0x00B)
FACILITY_INTERNET (0x00C)
FACILITY_MEDIASERVER (0x00D)
FACILITY_MSMQ (0x00E)
FACILITY_SETUPAPI (0x00F)
FACILITY_SCARD (0x010)
FACILITY_COMPLUS (0x011)
FACILITY_HTTP (0x019)
FACILITY_USERMODE_FILTER_MANAGER (0x01F)
FACILITY_WINDOWSUPDATE (0x024)
FACILITY_GRAPHICS (0x026)
FACILITY_NAP (0x027)
FACILITY_INK (0x028)
FACILITY_TPM_SOFTWARE (0x029)
FACILITY_UI (0x02A)
FACILITY_PLA (0x030)
FACILITY_FVE (0x031)
FACILITY_FWP (0x032)
FACILITY_WINRM (0x033)
FACILITY_NDIS (0x034)
FACILITY_USERMODE_HYPERVISOR (0x035)
FACILITY_USERMODE_VIRTUALIZATION (0x037)
FACILITY_USERMODE_VOLMGR (0x038)
FACILITY_BCD (0x039)
FACILITY_USERMODE_VHD (0x03A)
FACILITY_SDIAG (0x03C)
FACILITY_WEBSERVICES (0x03D)
FACILITY_WPN (0x03E)
FACILITY_MBN (0x054)
FACILITY_P2P (0x063)
FACILITY_BLUETOOTH_ATT (0x065)
FACILITY_AUDIO (0x066)
FACILITY_IMAPI2 (0x0AA)
FACILITY_RTC_INTERFACE (0x0EE)
FACILITY_SIP_STATUS_CODE (0x0EF)
FACILITY_PINT_STATUS_CODE (0x0F0)
FACILITY_MAX_WDSTPTMGMT (0x110)
FACILITY_WDSMCSERVER (0x121)
FACILITY_MAX_WDSMC (0x122)
FACILITY_MAX_WDSCP (0x125)
FACILITY_BACKUP (0x7FF)
FACILITY_NTDSB (0x800)
FACILITY_DIRECT3D10 (0x879)
FACILITY_DXGI (0x87A)
FACILITY_DXGI_DDI (0x87B)
FACILITY_DIRECT3D11 (0x87C)
FACILITY_DWRITE (0x898)
FACILITY_D2D (0x899)
FACILITY_DEFRAG (0x900)
FACILITY_ONLINE_ID (0xA02)

Bug Checks

Bug Check Code Reference *aka Blue Screens

josh poley
  • 7,236
  • 1
  • 25
  • 25
1

Here's a class in C# to help you convert the error codes to string:

public static class WinErrors
{
    #region definitions
    [DllImport("kernel32.dll", SetLastError = true)]
    static extern IntPtr LocalFree(IntPtr hMem);

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern int FormatMessage(FormatMessageFlags dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, ref IntPtr lpBuffer, uint nSize, IntPtr Arguments);

    [Flags]
    private enum FormatMessageFlags : uint
    {
        FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
        FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
        FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
        FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000,
        FORMAT_MESSAGE_FROM_HMODULE = 0x00000800,
        FORMAT_MESSAGE_FROM_STRING = 0x00000400,
    }
    #endregion

    /// <summary>
    /// Gets a user friendly string message for a system error code
    /// </summary>
    /// <param name="errorCode">System error code</param>
    /// <returns>Error string</returns>
    public static string GetSystemMessage(int errorCode)
    {
        try
        {
            IntPtr lpMsgBuf = IntPtr.Zero;

            int dwChars = FormatMessage(
                FormatMessageFlags.FORMAT_MESSAGE_ALLOCATE_BUFFER | FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM | FormatMessageFlags.FORMAT_MESSAGE_IGNORE_INSERTS,
                IntPtr.Zero,
                (uint) errorCode,
                0, // Default language
                ref lpMsgBuf,
                0,
                IntPtr.Zero);
            if (dwChars == 0)
            {
                // Handle the error.
                int le = Marshal.GetLastWin32Error();
                return "Unable to get error code string from System - Error " + le.ToString();
            }

            string sRet = Marshal.PtrToStringAnsi(lpMsgBuf);

            // Free the buffer.
            lpMsgBuf = LocalFree(lpMsgBuf);
            return sRet;
        }
        catch (Exception e)
        {
            return "Unable to get error code string from System -> " + e.ToString();
        }
    }
}
Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50
rboy
  • 2,018
  • 1
  • 23
  • 35