1 /* 2 * PROJECT: ReactOS Kernel 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: ntoskrnl/fsrtl/filter.c 5 * PURPOSE: Provides support for usage of SEH inside File System Drivers 6 * PROGRAMMERS: None. 7 */ 8 9 /* INCLUDES ******************************************************************/ 10 11 #include <ntoskrnl.h> 12 #define NDEBUG 13 #include <debug.h> 14 15 #undef FsRtlAllocatePoolWithQuotaTag 16 #undef FsRtlAllocatePoolWithTag 17 18 /* PUBLIC FUNCTIONS **********************************************************/ 19 20 /*++ 21 * @name FsRtlIsTotalDeviceFailure 22 * @implemented NT 4.0 23 * 24 * The FsRtlIsTotalDeviceFailure routine checks if an NTSTATUS error code 25 * represents a disk hardware failure. 26 * 27 * @param NtStatus 28 * The NTSTATUS Code to Test 29 * 30 * @return TRUE in case of Hardware Failure, FALSE otherwise. 31 * 32 * @remarks None. 33 * 34 *--*/ 35 BOOLEAN 36 NTAPI 37 FsRtlIsTotalDeviceFailure(IN NTSTATUS NtStatus) 38 { 39 return((NT_SUCCESS(NtStatus)) || 40 (STATUS_CRC_ERROR == NtStatus) || 41 (STATUS_DEVICE_DATA_ERROR == NtStatus) ? FALSE : TRUE); 42 } 43 44 /*++ 45 * @name FsRtlIsNtstatusExpected 46 * @implemented NT 4.0 47 * 48 * The FsRtlIsNtstatusExpected routine checks if an NTSTATUS error code 49 * is expected by the File System Support Library. 50 * 51 * @param NtStatus 52 * The NTSTATUS Code to Test 53 * 54 * @return TRUE if the Value is Expected, FALSE otherwise. 55 * 56 * @remarks None. 57 * 58 *--*/ 59 BOOLEAN 60 NTAPI 61 FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus) 62 { 63 return((STATUS_DATATYPE_MISALIGNMENT == NtStatus) || 64 (STATUS_ACCESS_VIOLATION == NtStatus) || 65 (STATUS_ILLEGAL_INSTRUCTION == NtStatus) || 66 (STATUS_INSTRUCTION_MISALIGNMENT == NtStatus)) ? FALSE : TRUE; 67 } 68 69 /*++ 70 * @name FsRtlNormalizeNtstatus 71 * @implemented NT 4.0 72 * 73 * The FsRtlNormalizeNtstatus routine normalizes an NTSTATUS error code. 74 * 75 * @param NtStatusToNormalize 76 * The NTSTATUS error code to Normalize. 77 * 78 * @param NormalizedNtStatus 79 * The NTSTATUS error code to return if the NtStatusToNormalize is not 80 * a proper expected error code by the File System Library. 81 * 82 * @return NtStatusToNormalize if it is an expected value, otherwise 83 * NormalizedNtStatus. 84 * 85 * @remarks None. 86 * 87 *--*/ 88 NTSTATUS 89 NTAPI 90 FsRtlNormalizeNtstatus(IN NTSTATUS NtStatusToNormalize, 91 IN NTSTATUS NormalizedNtStatus) 92 { 93 return(TRUE == FsRtlIsNtstatusExpected(NtStatusToNormalize)) ? 94 NtStatusToNormalize : NormalizedNtStatus; 95 } 96 97 /*++ 98 * @name FsRtlAllocatePool 99 * @implemented 100 * 101 * FILLME 102 * 103 * @param PoolType 104 * FILLME 105 * 106 * @param NumberOfBytes 107 * FILLME 108 * 109 * @return None 110 * 111 * @remarks The pool tag used is "FSrt". 112 * 113 *--*/ 114 PVOID 115 NTAPI 116 FsRtlAllocatePool(IN POOL_TYPE PoolType, 117 IN ULONG NumberOfBytes) 118 { 119 PVOID Address; 120 121 Address = ExAllocatePoolWithTag(PoolType, 122 NumberOfBytes, 123 IFS_POOL_TAG); 124 125 if (NULL == Address) 126 { 127 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 128 } 129 130 return Address; 131 } 132 133 /*++ 134 * @name FsRtlAllocatePoolWithQuota 135 * @implemented 136 * 137 * FILLME 138 * 139 * @param PoolType 140 * FILLME 141 * 142 * @param NumberOfBytes 143 * FILLME 144 * 145 * @return None 146 * 147 * @remarks The pool tag used is "FSrt". 148 * 149 *--*/ 150 PVOID 151 NTAPI 152 FsRtlAllocatePoolWithQuota(IN POOL_TYPE PoolType, 153 IN ULONG NumberOfBytes) 154 { 155 PVOID Address; 156 157 Address = ExAllocatePoolWithQuotaTag(PoolType, 158 NumberOfBytes, 159 IFS_POOL_TAG); 160 if (NULL == Address) 161 { 162 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 163 } 164 return Address; 165 } 166 167 /*++ 168 * @name FsRtlAllocatePoolWithQuotaTag 169 * @implemented 170 * 171 * FILLME 172 * 173 * @param PoolType 174 * FILLME 175 * 176 * @param NumberOfBytes 177 * FILLME 178 * 179 * @param Tag 180 * FILLME 181 * 182 * @return None 183 * 184 * @remarks None 185 * 186 *--*/ 187 PVOID 188 NTAPI 189 FsRtlAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType, 190 IN ULONG NumberOfBytes, 191 IN ULONG Tag) 192 { 193 PVOID Address; 194 195 Address = ExAllocatePoolWithQuotaTag(PoolType, 196 NumberOfBytes, 197 Tag); 198 199 if (NULL == Address) 200 { 201 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 202 } 203 204 return Address; 205 } 206 207 /*++ 208 * @name FsRtlAllocatePoolWithTag 209 * @implemented 210 * 211 * FILLME 212 * 213 * @param PoolType 214 * FILLME 215 * 216 * @param NumberOfBytes 217 * FILLME 218 * 219 * @param Tag 220 * FILLME 221 * 222 * @return None 223 * 224 * @remarks None 225 * 226 *--*/ 227 PVOID 228 NTAPI 229 FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, 230 IN ULONG NumberOfBytes, 231 IN ULONG Tag) 232 { 233 PVOID Address; 234 235 Address = ExAllocatePoolWithTag(PoolType, 236 NumberOfBytes, 237 Tag); 238 239 if (NULL == Address) 240 { 241 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 242 } 243 244 return Address; 245 } 246 247