Codes like 0x80070005 or 0x80004005 are technically known as HRESULTs. These are 32-bit values returned by COM (Component Object Model) functions or Windows APIs. Understanding how to decode an HRESULT instantly tells you exactly what part of Windows failed.
1. Anatomy of a 32-Bit HRESULT
Let's tear down the classic "Access Denied" error: 0x80070005.
- 0x: Indicates this is a hexadecimal number.
- 8 (Bit 31 - Severity): An '8' in the first position means the severity bit is set to 1 (Failure/Error). A '0' would mean Success.
- 007 (Bits 16-26 - Facility): The facility defines WHICH Windows subsystem triggered the error. `007` is FACILITY_WIN32. `000` is NULL (Generic). `004` is ITf (interfaces).
- 0005 (Bits 0-15 - Error Code): The specific error. In this case, `5` corresponds to the standard Win32
ERROR_ACCESS_DENIED.
2. The "Facility 7" Translation Trick
Because `007` (FACILITY_WIN32) is simply a wrapper around standard DOS/Win32 decimal error codes, you can instantly translate any 0x8007... error.
Take 0x80070002. Strip away the 8007 prefix. You are left with `2`. In standard Windows Error Codes, `2` translates to `ERROR_FILE_NOT_FOUND`. Therefore, `0x80070002` simply means "File Not Found".
3. Common Base Error Codes
By learning these raw Win32 base codes, you can read complex HRESULTs efficiently:
- 5: Access Denied (Permissions issue)
- 2: File Not Found (Missing executable or file path)
- 3: Path Not Found (Bad directory mapping)
- 87: Invalid Parameter (Command line argument typed wrong)
- 14: Out of Memory (RAM or Paging File exhaustion)