Introduction
Avalanche.StatusCode.HResult contains HResults as message descriptions, [git], [www].
Add package reference to .csproj.
<PropertyGroup>
<RestoreAdditionalProjectSources>https://avalanche.fi/Avalanche.Core/nupkg/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalanche.StatusCodes.HResult"/>
</ItemGroup>
HResult message descriptions can be constructed into status code and event messages.
IMessage statusCode = HResult.COR_E_ARGUMENT.New();
HResult is microsoft's status code.
HResult message descriptions can throw exceptions with message attached.
try
{
HResult.E_NOTIMPL.Throw();
}
catch (NotImplementedException e)
{
WriteLine(e); //
}
HResult.Messages is table that be queried by code.
// Get by code
IMessageDescription messageDescription = HResult.Messages.Codes[0x00000000];
// Print template text
WriteLine(messageDescription.Template); // "Operation successful"
Table can be queried by key.
// Get by key
IMessageDescription messageDescription = HResult.Messages.Keys["NULL.S_OK"];
// Print template text
WriteLine(messageDescription.Template); // "Operation successful"
HResultIds contains int constants.
// Get code
int hresult = HResultIds.COR_E_ARGUMENT;
// Print code
WriteLine("0x{0:X8}", hresult); // "0x80070057"
Full example
using Avalanche.Message;
using Avalanche.StatusCode;
using static System.Console;
class hresult_index
{
public static void Run()
{
{
// <00A>
IMessage statusCode = HResult.COR_E_ARGUMENT.New();
// </00A>
}
{
// <00B>
try
{
HResult.E_NOTIMPL.Throw();
}
catch (NotImplementedException e)
{
WriteLine(e); //
}
// </00B>
}
{
// <01>
// Get by code
IMessageDescription messageDescription = HResult.Messages.Codes[0x00000000];
// Print template text
WriteLine(messageDescription.Template); // "Operation successful"
// </01>
}
{
// <02>
// Get by key
IMessageDescription messageDescription = HResult.Messages.Keys["NULL.S_OK"];
// Print template text
WriteLine(messageDescription.Template); // "Operation successful"
// </02>
}
{
// <03>
// Get code
int hresult = HResultIds.COR_E_ARGUMENT;
// Print code
WriteLine("0x{0:X8}", hresult); // "0x80070057"
// </03>
}
}
}
Bit Masks
HResult uses following bit semantics.
Bit | Mask | Description |
---|---|---|
0-15 | 0x000FF0FF | Code |
16-26 | 0x07FF0000 | Facility |
27 | 0x08000000 | 0=StatusCode, 1=Display text |
28 | 0x10000000 | Reserved |
29 | 0x20000000 | 0=Microsoft, 1=3rd party code |
30 | 0x40000000 | ? Information ? |
31 | 0x80000000 | 0=Good, 1=Bad |
HResult severity flags.
Value | Code | Description |
---|---|---|
Good | 0x00000000 | Operation was successful. |
Bad | 0x80000000 | Operation failed. |
SeverityMask | 0x80000000 | Bit mask when checking for Bad result. |
Table
Avalanche.StatusCode.HResult contains following message descriptions:
HResult | Facility | Text | Exception |
---|---|---|---|
0x00000000 | Basic | Basic status codes | |
0x00010000 | Rpc | Remote Procedure Call | |
0x00020000 | Dispatch | COM Dispatch | |
0x00030000 | Storage | OLE Storage | |
0x00040000 | Itf | COM/OLE Interface management | |
0x00070000 | Win32 | Win32 | |
0x00080000 | Windows | Windows subsystem | |
0x00090000 | Sspi | Security API layer | |
0x000A0000 | Control | Control mechanism | |
0x000B0000 | Cert | Certificate client or server | |
0x000C0000 | Internet | Wininet related | |
0x000D0000 | MediaServer | Windows Media Server | |
0x000E0000 | Msmq | Microsoft Message Queue | |
0x000F0000 | SetupApi | Setup API | |
0x00100000 | Scard | Smart-card subsystem | |
0x00110000 | ComPlus | COM+ | |
0x00120000 | AAF | Microsoft agent | |
0x00130000 | Clr | .NET CLR (Common Language Runtime) | |
0x00140000 | Acs | Audit collection service | |
0x00150000 | Dplay | Direct Play | |
0x00160000 | Umi | Ubiquitous memoryintrospection service | |
0x00170000 | Sxs | Side-by-side servicing | |
0x00180000 | WindowsCE | Windows CE | |
0x00190000 | Http | HTTP support | |
0x001A0000 | UserModeCommonLog | Common Logging | |
0x001F0000 | UserModeFilterManager | User mode filter manager | |
0x00200000 | BackgroundCopy | Background copy control | |
0x00210000 | Configuration | Configuration services | |
0x00220000 | StateManagement | State management services | |
0x00230000 | MetaDirectory | Microsoft Identity Server | |
0x00240000 | WindowsUpdate | Windows update | |
0x00250000 | DirectoryService | Active Directory | |
0x00260000 | Graphics | Graphics drivers | |
0x00270000 | Shell | User Shell | |
0x00280000 | TpmServices | Trusted Platform Module services | |
0x00290000 | TpmSoftware | Trusted Platform Module applications | |
0x00300000 | Pla | Performance Logs and Alerts | |
0x00310000 | Fve | Full volume encryption | |
0x00320000 | Fwp | Firewall Platform | |
0x00330000 | WinRm | Windows Resource Manager | |
0x00340000 | Ndis | Network Driver Interface | |
0x00350000 | UserModeHypervisor | Usermode Hypervisor components | |
0x00360000 | CMI | Configuration Management Infrastructure | |
0x00370000 | UserModeVirtualization | User mode virtualization subsystem | |
0x00380000 | UserModeVolMgr | User mode volume manager | |
0x00390000 | BCD | Boot Configuration Database | |
0x003A0000 | UserModeVhd | User mode virtual hard disk support | |
0x003C0000 | SDiag | System Diagnostics | |
0x003D0000 | WebServices | Web Services | |
0x00500000 | WindowsDefender | Windows Defender component | |
0x00510000 | Opc | Open connectivity service | |
0x05EA0000 | Dlt | Distributed Link Tracking | |
0x001B0000 | Wer | Wired Equivalent Privacy Encryption | |
0x002A0000 | Ui | User Interface | |
0x002B0000 | Xaml | eXtended Application Markup Language | |
0x002C0000 | ActionQueue | ||
0x003E0000 | Wpn | Notification Platform | |
0x003F0000 | WindowsStore | Windows Store | |
0x00400000 | Input | Input | |
0x00420000 | Eap | Extensible Authentication Protocol | |
0x00520000 | Xps | XPS (XML Paper Specification) Document | |
0x00530000 | Ras | ||
0x00540000 | Mbn | ||
0x00550000 | Eas | Exchange Active Synchronization | |
0x00620000 | P2PInt | ||
0x00630000 | P2p | Peer Graphing API | |
0x00640000 | Daf | ||
0x00650000 | BluetootAtt | Bluetooth ATT (Attribute Protocol) | |
0x00660000 | Audio | Audio | |
0x006D0000 | VisualCpp | ||
0x00700000 | Script | ||
0x00710000 | Parse | ||
0x00780000 | Blb | ||
0x00790000 | BlbCli | ||
0x007A0000 | Wsbapp | ||
0x00800000 | Blbui | ||
0x00810000 | Usn | ||
0x00820000 | Usermode_volsnap | ||
0x00830000 | Tiering | ||
0x00850000 | Wsb_online | ||
0x00860000 | Online_id | ||
0x00990000 | Dls | ||
0x00A00000 | Sos | ||
0x00B00000 | Debugger | Debugger | |
0x00E70000 | Usermode_spaces | Storage Spaces - Group physicial drives in virtual drives storage pools | |
0x01000000 | Dmserver | ||
0x01010000 | DeploymentServicesServer | Windows Deployment Services (WDS) Server | |
0x01020000 | DeploymentServicesImaging | Windows Deployment Services (WDS) Imaging | |
0x01030000 | DeploymentServicesManagement | Windows Deployment Services (WDS) Management | |
0x01040000 | DeploymentServicesUtil | Windows Deployment Services (WDS) Util | |
0x01050000 | DeploymentServicesBinlsvc | Windows Deployment Services (WDS) Binlsvc | |
0x01070000 | DeploymentServicesPxe | Windows Deployment Services (WDS) Pxe | |
0x01080000 | DeploymentServicesTftp | Windows Deployment Services (WDS) TFP | |
0x01100000 | DeploymentServicesTransportManagement | Windows Deployment Services (WDS) Transport Manager | |
0x01160000 | DeploymentServicesDriverProvisioning | Windows Deployment Services (WDS) Driver Provisioning | |
0x01210000 | DeploymentServicesMulticastServer | Windows Deployment Services (WDS) Multicast Server | |
0x01220000 | DeploymentServicesMulticastClient | Windows Deployment Services (WDS) Multicast Client | |
0x01250000 | DeploymentServicesContentProvider | Windows Deployment Services (WDS) Content Provider | |
0x01310000 | Linguistic_services | ||
0x03750000 | Web | ||
0x03760000 | WebSocket | ||
0x04460000 | AudioStreaming | ||
0x06000000 | Accelerator | ||
0x07010000 | Mobile | ||
0x07CC0000 | Wmaaecma | ||
0x08010000 | Wep | WEP Encryption (Wired Equivalent Privacy) | |
0x08020000 | SyncEngine | ||
0x08780000 | DirectMusic | Direct Music (part of DirectX) - Audio | |
0x08790000 | Direct3d10 | Direct3D 10 | |
0x087A0000 | Dxgi | DirectX Graphics Infrastructure | |
0x087B0000 | Dxgi_ddi | DirectX Graphics Infrastructure Device Driver Interface | |
0x087C0000 | Direct3d11 | Direct3D 11 | |
0x08880000 | Leap | XAudio2 Internal Errors | |
0x08890000 | Audclnt | Audio Client | |
0x08980000 | WincodecDwriteDwm | DirectWrite (part of DirectX) - Text layout and glyph rendering | |
0x08990000 | Direct2d | Direct 2D (hardware accelerated GUI rendering) | |
0x09000000 | Defrag | Defragging | |
0x09010000 | Usermode_sdbus | SD (Secure Digital) Bus - SD Card | |
0x09020000 | Jscript | Javascript | |
0x0A010000 | Pidgenx | ||
0x20AA0000 | Avalanche | Avalanche.* | |
0x23450000 | Mscorlib | mscorlib.dll resource codes |
This document is partially derived from work with following license.
/*This file is a derivate of a source file that has following license (below). ======================================================================== The MIT License (MIT) Copyright (c) Microsoft Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ======================================================================*/