Process Hacker
error.c
Go to the documentation of this file.
1 /*
2  * Process Hacker -
3  * error codes
4  *
5  * Copyright (C) 2010-2011 wj32
6  *
7  * This file is part of Process Hacker.
8  *
9  * Process Hacker is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * Process Hacker is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <phbase.h>
24 
32  _In_ NTSTATUS Status
33  )
34 {
35  if (NT_NTWIN32(Status)) // RtlNtStatusToDosError doesn't seem to handle these cases correctly
36  return WIN32_FROM_NTSTATUS(Status);
37  else
38  return RtlNtStatusToDosError(Status);
39 }
40 
48  _In_ ULONG DosError
49  )
50 {
51  switch (DosError)
52  {
53  case ERROR_INVALID_FUNCTION: return STATUS_ILLEGAL_FUNCTION;
54  case ERROR_FILE_NOT_FOUND: return STATUS_NO_SUCH_FILE;
55  case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
56  case ERROR_INVALID_HANDLE: return STATUS_INVALID_HANDLE;
57  case ERROR_HANDLE_EOF: return STATUS_END_OF_FILE;
58  case ERROR_NOT_SUPPORTED: return STATUS_NOT_SUPPORTED;
59  case ERROR_INVALID_PARAMETER: return STATUS_INVALID_PARAMETER;
60  case ERROR_NOT_LOCKED: return STATUS_NOT_LOCKED;
61  case ERROR_MORE_DATA: return STATUS_MORE_ENTRIES;
62  case ERROR_NOACCESS: return STATUS_ACCESS_VIOLATION;
63  case ERROR_STACK_OVERFLOW: return STATUS_STACK_OVERFLOW;
64  case ERROR_INTERNAL_ERROR: return STATUS_INTERNAL_ERROR;
65  default: return NTSTATUS_FROM_WIN32(DosError);
66  }
67 }
68 
74  _In_ NTSTATUS Status
75  )
76 {
77  switch (Status)
78  {
79  case STATUS_NO_SUCH_FILE:
80  return TRUE;
81  case STATUS_OBJECT_NAME_INVALID:
82  return TRUE;
83  case STATUS_OBJECT_NAME_NOT_FOUND:
84  return TRUE;
85  case STATUS_OBJECT_NO_LONGER_EXISTS:
86  return TRUE;
87  case STATUS_OBJECT_PATH_INVALID:
88  return TRUE;
89  case STATUS_OBJECT_PATH_NOT_FOUND:
90  return TRUE;
91  default: return FALSE;
92  }
93 }