Question

In my C++ Windows application I received what appears to be an invalid system error code using GetLastError() after a failed Overlapped I/O operation.

// Code
DWORD errorCode = GetLastError();
loggerInt1(LOGERROR, "failed getIoResult, errorCode %d", (int)errorCode);

// Log file
failed getIoResult, errorCode -1073741781
failed getIoResult, errorCode -1073741781
failed getIoResult, errorCode -1073741781
//... many more times at different time points

errorCode is a DWORD, which is an unsigned long, and I casted it to int. But Windows system error codes should only be between 0 and 15999, well within an int.

-1073741781 is C000 002B on 32-bit system (mine) and FFFF FFFF C000 002B on 64-bit system. Interpreted as unsigned long it's 3,221,225,515 (32-bit) or some freakishly huge number (64-bit). Either way it's well outside of the 0-15999 range of a Windows system error.

How can this be? Is there a sane reason for why I got such an error code?

Was it helpful?

Solution

0xC000002B is an NTSTATUS code which resolves to STATUS_PARITY_ERROR.

There is no contractual agreement that a value stored here is a standard Win32 error code. The documentation for GetLastError vaguely implies this:

The error codes returned by a function are not part of the Windows API specification and can vary by operating system or device driver. For this reason, we cannot provide the complete list of error codes that can be returned by each function

The standard error codes are well documented, so the above statement wouldn't make much sense if all possible results are initially understood.

Note that some WINAPIs can also return HRESULT values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top