RPC Error Codes
This section details the error codes returned by Remote Procedure Call (RPC) functions in the Windows API.
Understanding RPC Errors
RPC operations can fail for a variety of reasons, including network issues, authentication problems, server unavailability, or incorrect parameters. When an RPC function fails, it typically returns an error code that indicates the nature of the failure. These error codes are crucial for diagnosing and debugging distributed applications.
Most RPC error codes are defined in the winerror.h header file and can be returned as HRESULT values or as NTSTATUS codes. When an RPC function returns a non-zero value, it generally signifies an error.
Common RPC Error Codes
The following table lists some of the most common RPC error codes. For a comprehensive list, please refer to the official Windows SDK documentation.
| Error Code (Hex) | Constant Name | Description |
|---|---|---|
| 0x80010001 | RPC_E_INVALID_BINDING | The binding handle is invalid. |
| 0x80010002 | RPC_E_WRONG_CHANNEL_ORDER | The communication channel is in the wrong order. |
| 0x80010003 | RPC_E_CANT_CREATECLIENT | The client cannot be created. |
| 0x80010004 | RPC_E_INVALID_STRING_BINDING | The string binding is invalid. |
| 0x80010005 | RPC_E_NETWORK_ERROR | A network error occurred. |
| 0x80010006 | RPC_E_OUT_OF_RESOURCES | Not enough system resources to perform the operation. |
| 0x80010007 | RPC_E_CONNECTION_REFUSED | The connection was refused by the server. |
| 0x80010008 | RPC_E_SERVER_UNAVAILABLE | The RPC server is unavailable. |
| 0x80010009 | RPC_E_TIMEOUT | The RPC operation timed out. |
| 0x8001000A | RPC_E_ACCESS_DENIED | Access is denied. |
| 0x8001000B | RPC_E_INVALID_ENDPOINT_FORMAT | The endpoint format is invalid. |
| 0x8001000C | RPC_E_PROCNUM_OUT_OF_RANGE | The procedure number is out of range. |
| 0x8001000D | RPC_E_BINDING_INCOMPLETE | The binding handle is incomplete. |
| 0x8001000E | RPC_E_INVALID_TIMEOUT | The timeout value is invalid. |
| 0x80010010 | RPC_E_INCOMPLETE_TRANSMISSION | The transmission is incomplete. |
| 0x80010011 | RPC_E_CLIENT_DIED | The client process has terminated unexpectedly. |
| 0x80010012 | RPC_E_INJECT_FAILURE | A failure was injected for testing purposes. |
| 0x80010013 | RPC_E_LOOPS_TOO_DEEP | The binding has too many levels of indirection. |
| 0x80010014 | RPC_E_INVALID_ARGUMENT | An invalid argument was provided. |
| 0x80010015 | RPC_E_NOT_SUPPORTED | The requested operation is not supported. |
| 0x80010016 | RPC_E_UNSUPPORTED_TRANS_SYN | The specified transport and syntax are not supported. |
| 0x80010017 | RPC_E_UNSUPPORTED_AUTHN_LEVEL | The authentication level is not supported. |
| 0x80010018 | RPC_E_INVALID_CALL_ORDER | The call is in an invalid order. |
| 0x80010019 | RPC_E_INVALID_AUTHN_SERVICE | The authentication service is invalid. |
| 0x8001001A | RPC_E_INVALID_AUTHN_QUALITY_OF_PROTECTION | The authentication quality of protection is invalid. |
| 0x8001001B | RPC_E_COMM_FAILURE | A communication failure occurred. |
| 0x8001001C | RPC_E_NO_BINDING | No binding handle was specified. |
| 0x8001001D | RPC_E_SERVER_TOO_BUSY | The RPC server is too busy to handle the request. |
| 0x8001001E | RPC_E_UNKNOWN_AUTHN_SERVICE | The authentication service is unknown. |
| 0x8001001F | RPC_E_RPC_FAULT | An RPC fault occurred on the server. |
| 0x80010020 | RPC_E_INVALID_STRING_FORMAT | The string format is invalid. |
| 0x80010021 | RPC_E_REMOTE_COMM_FAILURE | A communication failure occurred on the remote system. |
| 0x80010022 | RPC_E_UNEXPECTED_END_OF_FILE | An unexpected end of file was encountered. |
| 0x80010023 | RPC_E_PROTSEQ_NOT_SUPPORTED | The protocol sequence is not supported. |
| 0x80010024 | RPC_E_INVALID_NETWORK_OPTIONS | The network options are invalid. |
| 0x80010025 | RPC_E_NO_IamPermissions | Insufficient permissions. |
| 0x80010026 | RPC_E_QUOTA_EXCEEDED | The quota has been exceeded. |
| 0x80010027 | RPC_E_SS_CANNOT_CONNECT | The security subsystem cannot connect. |
| 0x80010028 | RPC_E_ASYNC_CALL_PENDING | An asynchronous call is pending. |
| 0x80010029 | RPC_E_SEC_PKG_NOT_FOUND | The security package was not found. |
| 0x8001002A | RPC_E_NOT_FOUND | The specified item was not found. |
| 0x8001002B | RPC_E_BINDING_HANDLE_NOT_BOUND | The binding handle is not bound. |
| 0x8001002C | RPC_E_INVALID_OBJECT | The object identifier is invalid. |
| 0x8001002D | RPC_E_WRONG_INTERFACE | The interface is incorrect. |
| 0x8001002E | RPC_E_REMOTE_INVALID_BINDING | The remote binding handle is invalid. |
| 0x8001002F | RPC_E_UNSUPPORTED_RPC_VERSION | The RPC version is not supported. |
| 0x80010100 | RPC_S_OK | The operation completed successfully. (Note: This is a success code, not an error.) |
| 0x80010101 | RPC_S_CALL_IN_PROGRESS | An RPC call is already in progress. |
Handling RPC Errors
When calling RPC functions, it is essential to check the return value. If the return value indicates an error, you should take appropriate action, which may include:
- Logging the error for debugging.
- Retrying the operation (if the error is transient, like a network timeout).
- Informing the user about the failure.
- Exiting gracefully or attempting alternative operations.
You can use the Windows API function FormatMessage to retrieve a descriptive string for an error code.
DWORD dwRet = RpcCallFunction(...);
if (dwRet != RPC_S_OK) {
LPSTR msgBuf = NULL;
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwRet,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msgBuf,
0,
NULL
);
// Use msgBuf for logging or displaying the error
LocalFree(msgBuf);
}
Further Information
For a comprehensive and up-to-date list of RPC error codes and their meanings, please consult the official Microsoft documentation for the Windows SDK, specifically the sections on RPC error codes and HRESULT values.
Related Topics: