Windows HRESULT, NTSTATUS and Win32 Error Codes
Decode Windows error values correctly: HRESULT 0x80070005, NTSTATUS 0xC0000005, Win32 error 5 and native exit codes are different formats.
Windows exposes several error formats that look interchangeable but are not. 0x80070005 is an HRESULT for access denied. 0xC0000005 is an NTSTATUS access violation. 5 is the Win32 error number for access denied. The same failure can appear as any of these depending on which layer reports it.
The three formats at a glance
| Format | Example | Typical producer | How to read it |
|---|---|---|---|
| Win32 error | 5 | Win32 API, GetLastError() | Plain 32-bit error number; look up the Win32 code. |
| HRESULT | 0x80070005 | COM, Win32 API wrappers, .NET interop | Severity and facility bits plus a Win32 code in the low 16 bits. |
| NTSTATUS | 0xC0000005 | Kernel, native API, drivers | Status code, not a Win32 error; use the NTSTATUS reference. |
| Process exit code | -1073740791 | Native crash, service, game | Signed decimal view of a 32-bit status such as 0xC0000409. |
Decode 0x80070005
0x80070005 is a 32-bit HRESULT. The high bit is set, which means failure. The facility is 0x7, FACILITY_WIN32. The low 16 bits are 0x0005, which is ERROR_ACCESS_DENIED. That is why installers, services, registry operations and updates can all report the same value: they are all reporting a permission decision through a Win32 facility.
The same access-denied condition can appear as:
0x80070005in a COM or .NET error dialog.5or “Access is denied” from a Win32 API.ERROR_ACCESS_DENIEDin a log message.0xC0000022(STATUS_ACCESS_DENIED) from a native/kernel path.
They point at the same family of causes, but the layer determines where to look: object ACL, UAC, service account, group policy, antivirus controlled folder access, or an explicit deny ACE.
Decode NTSTATUS values
0xC0000005 is STATUS_ACCESS_VIOLATION. It is not an HRESULT and not a Win32 error. It means the process tried to access memory it does not own. 0xC0000409 is STATUS_STACK_BUFFER_OVERRUN in the status reference and is commonly surfaced as a fail-fast termination. In decimal, 0xC0000409 is -1073740791; the negative number is just the signed 32-bit representation.
Do not “fix” an NTSTATUS by applying a Win32 permission checklist unless the code actually maps to a permission problem. A 0xC0000005 usually needs a faulting module, a driver/overlay check, or a memory diagnostic, not a registry ACL change.
Why the decimal form appears
Many launchers and event logs print a 32-bit status as a signed decimal. Use a programmer calculator or PowerShell to convert:
# Show the hexadecimal form of a signed 32-bit exit code
'{0:X8}' -f [uint32]([int64]-1073740791 -band 0xFFFFFFFF)
# -> C0000409
# Decode a Win32 error with the built-in message lookup
[ComponentModel.Win32Exception]5 | Format-List *
# Show recent Application/System events (run as administrator where needed)
Get-WinEvent -LogName Application -MaxEvents 20
Get-WinEvent -LogName System -MaxEvents 20
The exact command depends on your PowerShell version and policy. If a command is blocked, use Event Viewer and the vendor’s own log instead of disabling security controls.
Where to look for 0x80070005
- Account: which user or service account is actually running the operation? A scheduled task or service may not run as your interactive account.
- Object: check the file, folder, registry key, service or share ACL. The parent directory or a deny ACE may be the blocker.
- Elevation: is the process elevated when the operation requires it? Do not elevate permanently; elevate the specific task.
- Policy/security: check group policy, AppLocker/WDAC, antivirus controlled folder access and endpoint protection logs.
- Scope: change the smallest permission on the specific object, not the whole drive.
For the dedicated code page, see Windows 0x80070005. For the access-violation crash path, see Windows 0xC0000005. For other common values, use the Windows product hub.
A decision path
| Observed value | Most likely format | First evidence to collect |
|---|---|---|
0x80070005 | HRESULT | Operation, object path, account, Event Viewer |
5 | Win32 error | API name and GetLastError() context |
0xC0000005 | NTSTATUS | Faulting module, dump, driver/overlay list |
-1073740791 | Signed NTSTATUS/exit code | Hex conversion, launcher log, Windows event |
0x80070002 | HRESULT for ERROR_FILE_NOT_FOUND | Path, working directory, file existence |
Architecture and registry views
The same failure can look different in a 32-bit process and a 64-bit process. A 32-bit process on 64-bit Windows may see the WOW6432Node registry view, a redirected System32 directory, and different environment variables. If one app fails with 0x80070005 while another succeeds on the same machine, check the process architecture before changing ACLs.
Service accounts add another layer. A Windows service, scheduled task or IIS application pool may run as SYSTEM, NetworkService or a virtual account rather than your interactive user. The file may be readable by you and still denied to the service. Confirm the actual account and the actual object path, including any redirects.
Look up the message, not just the number
Windows can format a Win32 error into a localized message. That message is useful, but it can hide the original numeric value. Capture both: the number for support, and the text for the user-facing description. The built-in message lookup can confirm that a value is a Win32 error and show the canonical text.
# Convert a signed exit code to its 32-bit hexadecimal form
'{0:X8}' -f [uint32]([int64]-1073740791 -band 0xFFFFFFFF)
# Format a Win32 error number as a message
[ComponentModel.Win32Exception]5 | Select-Object -ExpandProperty Message
# Check the machine architecture and process context
[Environment]::Is64BitOperatingSystem
[Environment]::Is64BitProcess
# Review the exact service account and command line
Get-CimInstance Win32_Service | Where-Object Name -eq 'YourService' |
Select-Object Name, StartName, PathName, State
Commands may differ under PowerShell constraints. If a command is blocked by policy, use Event Viewer or the vendor’s own diagnostic tool rather than disabling the policy.
What each format can and cannot tell you
| Format | Can tell you | Cannot tell you |
|---|---|---|
| Win32 error | A specific API failure such as access denied or file not found. | Which component wrapped it or which object was denied. |
| HRESULT | Severity, facility and the underlying Win32 code. | Whether the failure came from COM, .NET, a shell extension or an installer. |
| NTSTATUS | A kernel/native status such as access violation or stack buffer overrun. | The user-mode module that caused it without a dump or event log. |
| Exit code | How a process terminated, often as a signed 32-bit value. | The first failure if the process caught and re-wrapped it. |
Common mistakes
- Treating
0x80070005and0xC0000005as the same “access” error. One is a permission denial; the other is a memory access violation. - Taking ownership of
C:\or disabling UAC to “fix” a single app. That is broader than the problem and can weaken the system. - Ignoring the architecture: a 32-bit process may see a different registry view or file-system redirector.
- Reporting only the decimal exit code. Convert it to hex so support can identify the status.
What to record in a ticket
Record the hexadecimal value, the decimal value if the tool shows one, the exact operation, the account that ran it, the object path, the Windows build and the timestamp. Add the Event Viewer provider and event ID if one exists. If the failure is a crash, include the faulting module and the dump path; if it is a permission failure, include the ACL or policy that denied the action.
That package lets support distinguish a format problem from a permissions problem. It also prevents the most common waste of time: applying a generic “access denied” fix to a memory access violation because both values contain the word “access”.
Related pages
Other Windows values that often appear in the same investigations: 0x80070002 (file not found), 0x8007007E (module not found), 0x80070070 (disk space), 0x80070057 (invalid parameter), 0x8007045D (I/O device error), 0x800F081F (source files missing) and 0x80070032 (not supported).
Sources
- Microsoft Learn: System Error Codes
- Microsoft Learn: HRESULT_FROM_WIN32
- Microsoft Open Specifications: NTSTATUS values
Search the code you are seeing
Every page links the official source and the date it was last checked.