Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ioassert.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1998 Microsoft Corporation 00004 00005 Module Name: 00006 00007 ioassert.h 00008 00009 Abstract: 00010 00011 This module implements some useful assertion routines 00012 00013 Author: 00014 00015 Adrian J. Oney (adriao) 20-Apr-1998 00016 00017 Revision History: 00018 00019 00020 --*/ 00021 00022 #ifndef _IOASSERT_H_ 00023 #define _IOASSERT_H_ 00024 00025 #if defined(_WIN64) 00026 #define NO_SPECIAL_IRP 00027 #else 00028 #undef NO_SPECIAL_IRP 00029 #endif 00030 00031 #ifdef NO_SPECIAL_IRP 00032 00033 #define WDM_CHASTISE_CALLER3(x) 00034 #define WDM_CHASTISE_CALLER5(x) 00035 #define WDM_CHASTISE_ROUTINE(x) 00036 #define WDM_FAIL_CALLER(x, depth) 00037 #define WDM_FAIL_CALLER1(x) 00038 #define WDM_FAIL_CALLER2(x) 00039 #define WDM_FAIL_CALLER3(x) 00040 #define WDM_FAIL_CALLER4(x) 00041 #define WDM_FAIL_CALLER5(x) 00042 #define WDM_FAIL_CALLER6(x) 00043 #define WDM_FAIL_ROUTINE(x) 00044 #define KDASSERT(x) 00045 #define ASSERT_SPINLOCK_HELD(x) 00046 00047 #else // NO_SPECIAL_IRP 00048 00049 extern LONG IovpInitCalled; 00050 extern ULONG IovpVerifierLevel; 00051 extern ULONG IovpEnforcementLevel; 00052 extern ULONG IopDcControlInitial; 00053 extern ULONG IopDcControlOverride; 00054 extern KSPIN_LOCK IopDcControlLock; 00055 00056 typedef enum _DCERROR_ID { 00057 00058 DCERROR_UNSPECIFIED = 0x200, 00059 DCERROR_DELETE_WHILE_ATTACHED, 00060 DCERROR_DETACH_NOT_ATTACHED, 00061 DCERROR_CANCELROUTINE_FORWARDED, 00062 DCERROR_NULL_DEVOBJ_FORWARDED, 00063 DCERROR_QUEUED_IRP_FORWARDED, 00064 DCERROR_NEXTIRPSP_DIRTY, 00065 DCERROR_IRPSP_COPIED, 00066 DCERROR_INSUFFICIENT_STACK_LOCATIONS, 00067 DCERROR_QUEUED_IRP_COMPLETED, 00068 DCERROR_FREE_OF_INUSE_TRACKED_IRP, 00069 DCERROR_FREE_OF_INUSE_IRP, 00070 DCERROR_FREE_OF_THREADED_IRP, 00071 DCERROR_REINIT_OF_ALLOCATED_IRP_WITH_QUOTA, 00072 DCERROR_PNP_IRP_BAD_INITIAL_STATUS, 00073 DCERROR_POWER_IRP_BAD_INITIAL_STATUS, 00074 DCERROR_WMI_IRP_BAD_INITIAL_STATUS, 00075 DCERROR_SKIPPED_DEVICE_OBJECT, 00076 DCERROR_BOGUS_FUNC_TRASHED, 00077 DCERROR_BOGUS_STATUS_TRASHED, 00078 DCERROR_BOGUS_INFO_TRASHED, 00079 DCERROR_PNP_FAILURE_FORWARDED, 00080 DCERROR_PNP_IRP_STATUS_RESET, 00081 DCERROR_PNP_IRP_NEEDS_FDO_HANDLING, 00082 DCERROR_PNP_IRP_FDO_HANDS_OFF, 00083 DCERROR_POWER_FAILURE_FORWARDED, 00084 DCERROR_POWER_IRP_STATUS_RESET, 00085 DCERROR_INVALID_STATUS, 00086 DCERROR_UNNECCESSARY_COPY, 00087 DCERROR_SHOULDVE_DETACHED, 00088 DCERROR_SHOULDVE_DELETED, 00089 DCERROR_MISSING_DISPATCH_FUNCTION, 00090 DCERROR_WMI_IRP_NOT_FORWARDED, 00091 DCERROR_DELETED_PRESENT_PDO, 00092 DCERROR_BUS_FILTER_ERRONEOUSLY_DETACHED, 00093 DCERROR_BUS_FILTER_ERRONEOUSLY_DELETED, 00094 DCERROR_INCONSISTANT_STATUS, 00095 DCERROR_UNINITIALIZED_STATUS, 00096 DCERROR_IRP_RETURNED_WITHOUT_COMPLETION, 00097 DCERROR_COMPLETION_ROUTINE_PAGABLE, 00098 DCERROR_PENDING_BIT_NOT_MIGRATED, 00099 DCERROR_CANCELROUTINE_ON_FORWARDED_IRP, 00100 DCERROR_PNP_IRP_NEEDS_PDO_HANDLING, 00101 DCERROR_TARGET_RELATION_LIST_EMPTY, 00102 DCERROR_TARGET_RELATION_NEEDS_REF, 00103 DCERROR_BOGUS_PNP_IRP_COMPLETED, 00104 DCERROR_SUCCESSFUL_PNP_IRP_NOT_FORWARDED, 00105 DCERROR_UNTOUCHED_PNP_IRP_NOT_FORWARDED, 00106 DCERROR_BOGUS_POWER_IRP_COMPLETED, 00107 DCERROR_SUCCESSFUL_POWER_IRP_NOT_FORWARDED, 00108 DCERROR_UNTOUCHED_POWER_IRP_NOT_FORWARDED, 00109 DCERROR_PNP_QUERY_CAP_BAD_VERSION, 00110 DCERROR_PNP_QUERY_CAP_BAD_SIZE, 00111 DCERROR_PNP_QUERY_CAP_BAD_ADDRESS, 00112 DCERROR_PNP_QUERY_CAP_BAD_UI_NUM, 00113 DCERROR_RESTRICTED_IRP, 00114 DCERROR_REINIT_OF_ALLOCATED_IRP_WITHOUT_QUOTA, 00115 DCERROR_UNFORWARDED_IRP_COMPLETED, 00116 DCERROR_DISPATCH_CALLED_AT_BAD_IRQL, 00117 DCERROR_BOGUS_MINOR_STATUS_TRASHED, 00118 DCERROR_MAXIMUM 00119 00120 } DCERROR_ID ; 00121 00122 #define DIAG_INITIALIZED 0x00000001 00123 #define DIAG_BEEP 0x00000002 00124 #define DIAG_ZAPPED 0x00000004 00125 #define DIAG_CLEARED 0x00000008 00126 #define DIAG_FATAL_ERROR 0x00000010 00127 #define DIAG_WDM_ERROR 0x00000020 00128 #define DIAG_IGNORE_DRIVER_LIST 0x00000040 00129 00130 #define DCPARAM_IRP 0x00000001 00131 #define DCPARAM_ROUTINE 0x00000008 00132 #define DCPARAM_DEVOBJ 0x00000040 00133 #define DCPARAM_STATUS 0x00000200 00134 00135 #define _DC_ASSERT_OUT(ParenWrappedParamList, Frames) \ 00136 { \ 00137 static ULONG Flags=0 ; \ 00138 if (IovpInitCalled) { \ 00139 IopDriverCorrectnessTakeLock(&Flags, Frames) ;\ 00140 IopDriverCorrectnessCheckUnderLock##ParenWrappedParamList;\ 00141 IopDriverCorrectnessReleaseLock() ;\ 00142 } \ 00143 } 00144 00145 // 00146 // These macro's allow printf style debug output. They are invoked 00147 // as follows (the excess parathesis's are required): 00148 // 00149 // WDM_FAIL_CALLER3(("Foo=%x",FooValue), irp) ; 00150 // 00151 #define WDM_CHASTISE_CALLER3(x) _DC_ASSERT_OUT(x, 3) 00152 #define WDM_CHASTISE_CALLER5(x) _DC_ASSERT_OUT(x, 5) 00153 #define WDM_FAIL_CALLER(x, depth) _DC_ASSERT_OUT(x, depth) 00154 #define WDM_FAIL_CALLER1(x) _DC_ASSERT_OUT(x, 1) 00155 #define WDM_FAIL_CALLER2(x) _DC_ASSERT_OUT(x, 2) 00156 #define WDM_FAIL_CALLER3(x) _DC_ASSERT_OUT(x, 3) 00157 #define WDM_FAIL_CALLER4(x) _DC_ASSERT_OUT(x, 4) 00158 #define WDM_FAIL_CALLER5(x) _DC_ASSERT_OUT(x, 5) 00159 #define WDM_FAIL_CALLER6(x) _DC_ASSERT_OUT(x, 6) 00160 #define WDM_FAIL_ROUTINE(x) _DC_ASSERT_OUT(x, -1) 00161 #define WDM_CHASTISE_ROUTINE(x) _DC_ASSERT_OUT(x, -1) 00162 00163 #define KDASSERT(x) { if (KdDebuggerEnabled) { ASSERT(x) ; } } 00164 00165 #define ASSERT_SPINLOCK_HELD(x) 00166 00167 // 00168 // From here to #else is for use of ioassert.c only 00169 // 00170 00171 VOID IopDriverCorrectnessTakeLock( 00172 IN PULONG ControlNew, 00173 IN LONG StackFramesToSkip 00174 ); 00175 00176 NTSTATUS 00177 IopDriverCorrectnessCheckUnderLock( 00178 IN DCERROR_ID MessageIndex, 00179 IN ULONG MessageParameterMask, 00180 ... 00181 ); 00182 00183 VOID 00184 IopDriverCorrectnessReleaseLock( 00185 VOID 00186 ); 00187 00188 // 00189 // This structure and the table using it define the types and ordering of 00190 // IopDriverCorrectnessCheck (see this function for a more detailed explanation) 00191 // 00192 typedef struct _DCPARAM_TYPE_ENTRY { 00193 00194 ULONG DcParamMask; 00195 PSTR DcParamName; 00196 00197 } DCPARAM_TYPE_ENTRY, *PDCPARAM_TYPE_ENTRY; 00198 00199 // 00200 // Internal structures used in the buildup of a correctness check. 00201 // 00202 typedef struct _DCERROR_CLASS { 00203 00204 ULONG ClassFlags; 00205 PSTR MessageClassText; 00206 00207 } DCERROR_CLASS, *PDCERROR_CLASS; 00208 typedef const PDCERROR_CLASS PCDCERROR_CLASS; 00209 00210 typedef struct _DC_CHECK_DATA { 00211 00212 PULONG Control; 00213 ULONG AssertionControl; 00214 ULONG TableIndex; 00215 DCERROR_ID MessageID; 00216 PVOID CulpritAddress; 00217 ULONG_PTR OffsetIntoImage; 00218 UNICODE_STRING DriverName; 00219 PDCERROR_CLASS AssertionClass; 00220 PVOID *DcParamArray; 00221 PSTR ClassText; 00222 PSTR AssertionText; 00223 BOOLEAN InVerifierList; 00224 00225 } DC_CHECK_DATA, *PDC_CHECK_DATA; 00226 00227 NTSTATUS 00228 IopDriverCorrectnessProcessMessageText( 00229 IN ULONG MaxOutputBufferSize, 00230 OUT PSTR OutputBuffer, 00231 IN OUT PDC_CHECK_DATA DcCheckData 00232 ); 00233 00234 VOID 00235 IopDriverCorrectnessProcessParams( 00236 IN OUT PULONG Control OPTIONAL, 00237 IN LONG StackFramesToSkip, 00238 IN DCERROR_ID MessageID, 00239 IN ULONG MessageParameterMask, 00240 IN va_list * MessageParameters, 00241 IN PVOID * DcParamArray, 00242 OUT PDC_CHECK_DATA DcCheckData 00243 ); 00244 00245 BOOLEAN 00246 IopDriverCorrectnessApplyControl( 00247 IN OUT PDC_CHECK_DATA DcCheckData 00248 ); 00249 00250 VOID 00251 IopDriverCorrectnessThrowBugCheck( 00252 IN PDC_CHECK_DATA DcCheckData 00253 ); 00254 00255 VOID 00256 IopDriverCorrectnessPrintBuffer( 00257 IN PDC_CHECK_DATA DcCheckData 00258 ); 00259 00260 VOID 00261 IopDriverCorrectnessPrintParamData( 00262 IN PDC_CHECK_DATA DcCheckData 00263 ); 00264 00265 VOID 00266 IopDriverCorrectnessPrintIrp( 00267 IN PIRP IrpToFlag 00268 ); 00269 00270 VOID 00271 IopDriverCorrectnessPrintIrpStack( 00272 IN PIO_STACK_LOCATION IrpSp 00273 ); 00274 00275 VOID 00276 IopDriverCorrectnessPrompt( 00277 IN PDC_CHECK_DATA DcCheckData, 00278 OUT PBOOLEAN ExitAssertion 00279 ); 00280 00281 PVOID 00282 IopDriverCorrectnessAddressToFileHeader( 00283 IN PVOID PcValue, 00284 OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry 00285 ); 00286 00287 BOOLEAN 00288 IopIsMemoryRangeReadable( 00289 IN PVOID Location, 00290 IN size_t Length 00291 ); 00292 00293 #endif // NO_SPECIAL_IRP 00294 00295 #endif // _IOASSERT_H_ 00296

Generated on Sat May 15 19:40:29 2004 for test by doxygen 1.3.7