Skip to content

Commit 2b786cf

Browse files
committed
Added most Win32 error codes as an enumeration.
1 parent 12bb303 commit 2b786cf

3 files changed

Lines changed: 3091 additions & 6 deletions

File tree

NtApiDotNet/NtObjectUtils.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ public static bool IsSuccess(this NtStatus status)
121121
return (int)status >= 0;
122122
}
123123

124+
/// <summary>
125+
/// Checks if the NtStatus value is an error.
126+
/// </summary>
127+
/// <param name="status">The NtStatus value</param>
128+
/// <returns>True if an error.</returns>
129+
public static bool IsError(this NtStatus status)
130+
{
131+
return status.GetSeverity() == NtStatusSeverity.STATUS_SEVERITY_ERROR;
132+
}
133+
124134
/// <summary>
125135
/// Get the severity of the NTSTATUS.
126136
/// </summary>
@@ -542,13 +552,13 @@ internal static NtStatus MapDosErrorToStatus()
542552
/// </summary>
543553
/// <param name="status">The status code.</param>
544554
/// <returns>The mapped DOS error.</returns>
545-
public static int MapNtStatusToDosError(NtStatus status)
555+
public static Win32Error MapNtStatusToDosError(NtStatus status)
546556
{
547557
if (status.GetFacility() == NtStatusFacility.FACILITY_NTWIN32)
548558
{
549-
return status.GetStatusCode();
559+
return (Win32Error)status.GetStatusCode();
550560
}
551-
return NtRtl.RtlNtStatusToDosErrorNoTeb(status);
561+
return (Win32Error)NtRtl.RtlNtStatusToDosErrorNoTeb(status);
552562
}
553563

554564
/// <summary>

0 commit comments

Comments
 (0)