This is work in progress.

Windows / HRESULT

HRESULT

HRESULT codes are used under the COM system.

The table below denotes the structure of a HRESULT code.

13
0
9876543212
0
9876543211
0
9876543210
SRCNXFacilityCode

Legend

Facilities

The table below lists facilities defined in the MS-ERREF specification.

NameValueDescription
FACILITY_NULL0Default
FACILITY_RPC1RPC subsystem
FACILITY_DISPATCH2COM Dispatch
FACILITY_STORAGE3OLE Storage
FACILITY_ITF4COM/OLE Interface management
FACILITY_WIN327Win32
FACILITY_WINDOWS8Windows
FACILITY_SECURITY9Security API
FACILITY_CONTROL10Control mechanism
FACILITY_CERT11Certificate
FACILITY_INTERNET12Wininet
FACILITY_MEDIASERVER13Windows Media Server
FACILITY_MSMQ14Microsoft Message Queue
FACILITY_SETUPAPI15Setup API
FACILITY_SCARD16Smart-card subsystem
FACILITY_COMPLUS17COM+
FACILITY_AAF18Microsoft agent
FACILITY_URT19.NET CLR
FACILITY_ACS20Audit Collection Service
FACILITY_DPLAY21Direct Play
FACILITY_UMI22Ubiquitous Memory-introspection service
FACILITY_SXS23Side-by-side (sxs) servicing
FACILITY_WINDOWS_CE24Windows CE
FACILITY_HTTP25HTTP
FACILITY_USERMODE_COMMONLOG26Common Logging
FACILITY_USERMODE_FILTER_MANAGER31User Mode Filter Manager
FACILITY_BACKGROUNDCOPY32Background Copy
FACILITY_CONFIGURATION33Configuration Services
FACILITY_STATE_MANAGEMENT34State Management Services
FACILITY_METADIRECTORY35Microsoft Identity Server
FACILITY_WINDOWSUPDATE36Windows update
FACILITY_DIRECTORYSERVICE37Active Directory
FACILITY_GRAPHICS38Graphics drivers
FACILITY_SHELL39User shell
FACILITY_TPM_SERVICES40Trusted Platform Module services
FACILITY_TPM_SOFTWARE41Trusted Platform Module applications
FACILITY_PLA48Performance Logs and Alerts
FACILITY_FVE49Full Volume Encryption
FACILITY_FWP50Firewall Platform
FACILITY_WINRM51Windows Resource Manager
FACILITY_NDIS52Network Driver Interface
FACILITY_USERMODE_HYPERVISOR53Usermode Hypervisor components
FACILITY_CMI54Configuration Management Infrastructure
FACILITY_USERMODE_VIRTUALIZATION55User Mode Virtualization Subsystem
FACILITY_USERMODE_VOLMGR56User Mode Volume Manager
FACILITY_BCD57Boot Configuration Database
FACILITY_USERMODE_VHD58User Mode Virtual Hard Disk
FACILITY_SDIAG60System Diagnostics
FACILITY_WEBSERVICES61Web Services
FACILITY_WINDOWS_DEFENDER80Windows Defender
FACILITY_OPC81Open Connectivity service

Exceptions to the X Bit

Some HRESULT codes, as exceptions, have the X bit set. They are listed below.

ValueName
0x0DEAD100TRK_S_OUT_OF_SYNC
0x0DEAD102TRK_VOLUME_NOT_FOUND
0x0DEAD103TRK_VOLUME_NOT_OWNED
0x0DEAD107TRK_S_NOTIFICATION_QUOTA_EXCEEDED
0x8DEAD01BTRK_E_NOT_FOUND
0x8DEAD01CTRK_E_VOLUME_QUOTA_EXCEEDED
0x8DEAD01ETRK_SERVER_TOO_BUSY

Converting Win32 Codes to HRESULT

Converting Win32 error codes to an HRESULT code is done with the following C macro.

#define FACILITY_WIN32 0x0007
#define __HRESULT_FROM_WIN32(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))