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

ioassert.h File Reference

Go to the source code of this file.

Classes

struct  _DCPARAM_TYPE_ENTRY
struct  _DCERROR_CLASS
struct  _DC_CHECK_DATA

Defines

#define DIAG_INITIALIZED   0x00000001
#define DIAG_BEEP   0x00000002
#define DIAG_ZAPPED   0x00000004
#define DIAG_CLEARED   0x00000008
#define DIAG_FATAL_ERROR   0x00000010
#define DIAG_WDM_ERROR   0x00000020
#define DIAG_IGNORE_DRIVER_LIST   0x00000040
#define DCPARAM_IRP   0x00000001
#define DCPARAM_ROUTINE   0x00000008
#define DCPARAM_DEVOBJ   0x00000040
#define DCPARAM_STATUS   0x00000200
#define _DC_ASSERT_OUT(ParenWrappedParamList, Frames)
#define WDM_CHASTISE_CALLER3(x)   _DC_ASSERT_OUT(x, 3)
#define WDM_CHASTISE_CALLER5(x)   _DC_ASSERT_OUT(x, 5)
#define WDM_FAIL_CALLER(x, depth)   _DC_ASSERT_OUT(x, depth)
#define WDM_FAIL_CALLER1(x)   _DC_ASSERT_OUT(x, 1)
#define WDM_FAIL_CALLER2(x)   _DC_ASSERT_OUT(x, 2)
#define WDM_FAIL_CALLER3(x)   _DC_ASSERT_OUT(x, 3)
#define WDM_FAIL_CALLER4(x)   _DC_ASSERT_OUT(x, 4)
#define WDM_FAIL_CALLER5(x)   _DC_ASSERT_OUT(x, 5)
#define WDM_FAIL_CALLER6(x)   _DC_ASSERT_OUT(x, 6)
#define WDM_FAIL_ROUTINE(x)   _DC_ASSERT_OUT(x, -1)
#define WDM_CHASTISE_ROUTINE(x)   _DC_ASSERT_OUT(x, -1)
#define KDASSERT(x)   { if (KdDebuggerEnabled) { ASSERT(x) ; } }
#define ASSERT_SPINLOCK_HELD(x)

Typedefs

typedef enum _DCERROR_ID DCERROR_ID
typedef _DCPARAM_TYPE_ENTRY DCPARAM_TYPE_ENTRY
typedef _DCPARAM_TYPE_ENTRYPDCPARAM_TYPE_ENTRY
typedef _DCERROR_CLASS DCERROR_CLASS
typedef _DCERROR_CLASSPDCERROR_CLASS
typedef const PDCERROR_CLASS PCDCERROR_CLASS
typedef _DC_CHECK_DATA DC_CHECK_DATA
typedef _DC_CHECK_DATAPDC_CHECK_DATA

Enumerations

enum  _DCERROR_ID {
  DCERROR_UNSPECIFIED = 0x200, DCERROR_DELETE_WHILE_ATTACHED, DCERROR_DETACH_NOT_ATTACHED, DCERROR_CANCELROUTINE_FORWARDED,
  DCERROR_NULL_DEVOBJ_FORWARDED, DCERROR_QUEUED_IRP_FORWARDED, DCERROR_NEXTIRPSP_DIRTY, DCERROR_IRPSP_COPIED,
  DCERROR_INSUFFICIENT_STACK_LOCATIONS, DCERROR_QUEUED_IRP_COMPLETED, DCERROR_FREE_OF_INUSE_TRACKED_IRP, DCERROR_FREE_OF_INUSE_IRP,
  DCERROR_FREE_OF_THREADED_IRP, DCERROR_REINIT_OF_ALLOCATED_IRP_WITH_QUOTA, DCERROR_PNP_IRP_BAD_INITIAL_STATUS, DCERROR_POWER_IRP_BAD_INITIAL_STATUS,
  DCERROR_WMI_IRP_BAD_INITIAL_STATUS, DCERROR_SKIPPED_DEVICE_OBJECT, DCERROR_BOGUS_FUNC_TRASHED, DCERROR_BOGUS_STATUS_TRASHED,
  DCERROR_BOGUS_INFO_TRASHED, DCERROR_PNP_FAILURE_FORWARDED, DCERROR_PNP_IRP_STATUS_RESET, DCERROR_PNP_IRP_NEEDS_FDO_HANDLING,
  DCERROR_PNP_IRP_FDO_HANDS_OFF, DCERROR_POWER_FAILURE_FORWARDED, DCERROR_POWER_IRP_STATUS_RESET, DCERROR_INVALID_STATUS,
  DCERROR_UNNECCESSARY_COPY, DCERROR_SHOULDVE_DETACHED, DCERROR_SHOULDVE_DELETED, DCERROR_MISSING_DISPATCH_FUNCTION,
  DCERROR_WMI_IRP_NOT_FORWARDED, DCERROR_DELETED_PRESENT_PDO, DCERROR_BUS_FILTER_ERRONEOUSLY_DETACHED, DCERROR_BUS_FILTER_ERRONEOUSLY_DELETED,
  DCERROR_INCONSISTANT_STATUS, DCERROR_UNINITIALIZED_STATUS, DCERROR_IRP_RETURNED_WITHOUT_COMPLETION, DCERROR_COMPLETION_ROUTINE_PAGABLE,
  DCERROR_PENDING_BIT_NOT_MIGRATED, DCERROR_CANCELROUTINE_ON_FORWARDED_IRP, DCERROR_PNP_IRP_NEEDS_PDO_HANDLING, DCERROR_TARGET_RELATION_LIST_EMPTY,
  DCERROR_TARGET_RELATION_NEEDS_REF, DCERROR_BOGUS_PNP_IRP_COMPLETED, DCERROR_SUCCESSFUL_PNP_IRP_NOT_FORWARDED, DCERROR_UNTOUCHED_PNP_IRP_NOT_FORWARDED,
  DCERROR_BOGUS_POWER_IRP_COMPLETED, DCERROR_SUCCESSFUL_POWER_IRP_NOT_FORWARDED, DCERROR_UNTOUCHED_POWER_IRP_NOT_FORWARDED, DCERROR_PNP_QUERY_CAP_BAD_VERSION,
  DCERROR_PNP_QUERY_CAP_BAD_SIZE, DCERROR_PNP_QUERY_CAP_BAD_ADDRESS, DCERROR_PNP_QUERY_CAP_BAD_UI_NUM, DCERROR_RESTRICTED_IRP,
  DCERROR_REINIT_OF_ALLOCATED_IRP_WITHOUT_QUOTA, DCERROR_UNFORWARDED_IRP_COMPLETED, DCERROR_DISPATCH_CALLED_AT_BAD_IRQL, DCERROR_BOGUS_MINOR_STATUS_TRASHED,
  DCERROR_MAXIMUM
}

Functions

VOID IopDriverCorrectnessTakeLock (IN PULONG ControlNew, IN LONG StackFramesToSkip)
NTSTATUS IopDriverCorrectnessCheckUnderLock (IN DCERROR_ID MessageIndex, IN ULONG MessageParameterMask,...)
VOID IopDriverCorrectnessReleaseLock (VOID)
NTSTATUS IopDriverCorrectnessProcessMessageText (IN ULONG MaxOutputBufferSize, OUT PSTR OutputBuffer, IN OUT PDC_CHECK_DATA DcCheckData)
VOID IopDriverCorrectnessProcessParams (IN OUT PULONG Control OPTIONAL, IN LONG StackFramesToSkip, IN DCERROR_ID MessageID, IN ULONG MessageParameterMask, IN va_list *MessageParameters, IN PVOID *DcParamArray, OUT PDC_CHECK_DATA DcCheckData)
BOOLEAN IopDriverCorrectnessApplyControl (IN OUT PDC_CHECK_DATA DcCheckData)
VOID IopDriverCorrectnessThrowBugCheck (IN PDC_CHECK_DATA DcCheckData)
VOID IopDriverCorrectnessPrintBuffer (IN PDC_CHECK_DATA DcCheckData)
VOID IopDriverCorrectnessPrintParamData (IN PDC_CHECK_DATA DcCheckData)
VOID IopDriverCorrectnessPrintIrp (IN PIRP IrpToFlag)
VOID IopDriverCorrectnessPrintIrpStack (IN PIO_STACK_LOCATION IrpSp)
VOID IopDriverCorrectnessPrompt (IN PDC_CHECK_DATA DcCheckData, OUT PBOOLEAN ExitAssertion)
PVOID IopDriverCorrectnessAddressToFileHeader (IN PVOID PcValue, OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry)
BOOLEAN IopIsMemoryRangeReadable (IN PVOID Location, IN size_t Length)

Variables

LONG IovpInitCalled
ULONG IovpVerifierLevel
ULONG IovpEnforcementLevel
ULONG IopDcControlInitial
ULONG IopDcControlOverride
KSPIN_LOCK IopDcControlLock


Define Documentation

#define _DC_ASSERT_OUT ParenWrappedParamList,
Frames   ) 
 

Value:

{ \ static ULONG Flags=0 ; \ if (IovpInitCalled) { \ IopDriverCorrectnessTakeLock(&Flags, Frames) ;\ IopDriverCorrectnessCheckUnderLock##ParenWrappedParamList;\ IopDriverCorrectnessReleaseLock() ;\ } \ }

Definition at line 135 of file ioassert.h.

#define ASSERT_SPINLOCK_HELD  ) 
 

Definition at line 165 of file ioassert.h.

Referenced by IovpSessionDataAttachSurrogate(), IovpSessionDataClose(), IovpSessionDataDereference(), IovpSessionDataReference(), IovpTrackingDataDereference(), IovpTrackingDataFindPointer(), IovpTrackingDataGetCurrentSessionData(), IovpTrackingDataReference(), and IovpTrackingDataReleaseLock().

#define DCPARAM_DEVOBJ   0x00000040
 

Definition at line 132 of file ioassert.h.

Referenced by IovpAssertIrpStackUpward(), IovpCallDriver2(), and IovpDetachDevice().

#define DCPARAM_IRP   0x00000001
 

Definition at line 130 of file ioassert.h.

Referenced by IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), IovpCallDriver1(), IovpCallDriver2(), IovpCancelIrp(), IovpCompleteRequest1(), IovpCompleteRequest3(), IovpCompleteRequest4(), IovpExamineIrpStackForwarding(), IovpFreeIrp(), IovpInitializeIrp(), and IovpInternalDeferredCompletion().

#define DCPARAM_ROUTINE   0x00000008
 

Definition at line 131 of file ioassert.h.

Referenced by IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpCallDriver2(), IovpCancelIrp(), IovpCompleteRequest3(), IovpCompleteRequest4(), and IovpInternalDeferredCompletion().

#define DCPARAM_STATUS   0x00000200
 

Definition at line 133 of file ioassert.h.

Referenced by IovpCallDriver2().

#define DIAG_BEEP   0x00000002
 

Definition at line 123 of file ioassert.h.

Referenced by IopDriverCorrectnessPrompt().

#define DIAG_CLEARED   0x00000008
 

Definition at line 125 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl(), and IopDriverCorrectnessPrompt().

#define DIAG_FATAL_ERROR   0x00000010
 

Definition at line 126 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl(), IopDriverCorrectnessPrintBuffer(), and IopDriverCorrectnessThrowBugCheck().

#define DIAG_IGNORE_DRIVER_LIST   0x00000040
 

Definition at line 128 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl(), and IoVerifierInit().

#define DIAG_INITIALIZED   0x00000001
 

Definition at line 122 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl().

#define DIAG_WDM_ERROR   0x00000020
 

Definition at line 127 of file ioassert.h.

#define DIAG_ZAPPED   0x00000004
 

Definition at line 124 of file ioassert.h.

Referenced by IopDriverCorrectnessPrompt().

#define KDASSERT  )     { if (KdDebuggerEnabled) { ASSERT(x) ; } }
 

Definition at line 163 of file ioassert.h.

Referenced by IovpInternalDeferredCompletion().

#define WDM_CHASTISE_CALLER3  )     _DC_ASSERT_OUT(x, 3)
 

Definition at line 151 of file ioassert.h.

Referenced by IovpCompleteRequest1(), and IovpExamineIrpStackForwarding().

#define WDM_CHASTISE_CALLER5  )     _DC_ASSERT_OUT(x, 5)
 

Definition at line 152 of file ioassert.h.

Referenced by IovpExamineIrpStackForwarding().

#define WDM_CHASTISE_ROUTINE  )     _DC_ASSERT_OUT(x, -1)
 

Definition at line 161 of file ioassert.h.

#define WDM_FAIL_CALLER x,
depth   )     _DC_ASSERT_OUT(x, depth)
 

Definition at line 153 of file ioassert.h.

#define WDM_FAIL_CALLER1  )     _DC_ASSERT_OUT(x, 1)
 

Definition at line 154 of file ioassert.h.

Referenced by IovpDeleteDevice().

#define WDM_FAIL_CALLER2  )     _DC_ASSERT_OUT(x, 2)
 

Definition at line 155 of file ioassert.h.

Referenced by IovpDetachDevice(), IovpFreeIrp(), and IovpInitializeIrp().

#define WDM_FAIL_CALLER3  )     _DC_ASSERT_OUT(x, 3)
 

Definition at line 156 of file ioassert.h.

Referenced by IovpCompleteRequest1().

#define WDM_FAIL_CALLER4  )     _DC_ASSERT_OUT(x, 4)
 

Definition at line 157 of file ioassert.h.

Referenced by IovpAssertIrpStackDownward(), and IovpAssertNewRequest().

#define WDM_FAIL_CALLER5  )     _DC_ASSERT_OUT(x, 5)
 

Definition at line 158 of file ioassert.h.

#define WDM_FAIL_CALLER6  )     _DC_ASSERT_OUT(x, 6)
 

Definition at line 159 of file ioassert.h.

Referenced by IovpAssertIrpStackDownward(), and IovpAssertNewRequest().

#define WDM_FAIL_ROUTINE  )     _DC_ASSERT_OUT(x, -1)
 

Definition at line 160 of file ioassert.h.

Referenced by IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpCallDriver2(), IovpCancelIrp(), IovpCompleteRequest3(), IovpCompleteRequest4(), and IovpInternalDeferredCompletion().


Typedef Documentation

typedef struct _DC_CHECK_DATA DC_CHECK_DATA
 

Referenced by IopDriverCorrectnessCheckUnderLock().

typedef struct _DCERROR_CLASS DCERROR_CLASS
 

typedef enum _DCERROR_ID DCERROR_ID
 

Referenced by IopDriverCorrectnessCheckUnderLock().

typedef struct _DCPARAM_TYPE_ENTRY DCPARAM_TYPE_ENTRY
 

typedef const PDCERROR_CLASS PCDCERROR_CLASS
 

Definition at line 208 of file ioassert.h.

typedef struct _DC_CHECK_DATA * PDC_CHECK_DATA
 

Referenced by IopDriverCorrectnessProcessParams().

typedef struct _DCERROR_CLASS * PDCERROR_CLASS
 

typedef struct _DCPARAM_TYPE_ENTRY * PDCPARAM_TYPE_ENTRY
 


Enumeration Type Documentation

enum _DCERROR_ID
 

Enumeration values:
DCERROR_UNSPECIFIED 
DCERROR_DELETE_WHILE_ATTACHED 
DCERROR_DETACH_NOT_ATTACHED 
DCERROR_CANCELROUTINE_FORWARDED 
DCERROR_NULL_DEVOBJ_FORWARDED 
DCERROR_QUEUED_IRP_FORWARDED 
DCERROR_NEXTIRPSP_DIRTY 
DCERROR_IRPSP_COPIED 
DCERROR_INSUFFICIENT_STACK_LOCATIONS 
DCERROR_QUEUED_IRP_COMPLETED 
DCERROR_FREE_OF_INUSE_TRACKED_IRP 
DCERROR_FREE_OF_INUSE_IRP 
DCERROR_FREE_OF_THREADED_IRP 
DCERROR_REINIT_OF_ALLOCATED_IRP_WITH_QUOTA 
DCERROR_PNP_IRP_BAD_INITIAL_STATUS 
DCERROR_POWER_IRP_BAD_INITIAL_STATUS 
DCERROR_WMI_IRP_BAD_INITIAL_STATUS 
DCERROR_SKIPPED_DEVICE_OBJECT 
DCERROR_BOGUS_FUNC_TRASHED 
DCERROR_BOGUS_STATUS_TRASHED 
DCERROR_BOGUS_INFO_TRASHED 
DCERROR_PNP_FAILURE_FORWARDED 
DCERROR_PNP_IRP_STATUS_RESET 
DCERROR_PNP_IRP_NEEDS_FDO_HANDLING 
DCERROR_PNP_IRP_FDO_HANDS_OFF 
DCERROR_POWER_FAILURE_FORWARDED 
DCERROR_POWER_IRP_STATUS_RESET 
DCERROR_INVALID_STATUS 
DCERROR_UNNECCESSARY_COPY 
DCERROR_SHOULDVE_DETACHED 
DCERROR_SHOULDVE_DELETED 
DCERROR_MISSING_DISPATCH_FUNCTION 
DCERROR_WMI_IRP_NOT_FORWARDED 
DCERROR_DELETED_PRESENT_PDO 
DCERROR_BUS_FILTER_ERRONEOUSLY_DETACHED 
DCERROR_BUS_FILTER_ERRONEOUSLY_DELETED 
DCERROR_INCONSISTANT_STATUS 
DCERROR_UNINITIALIZED_STATUS 
DCERROR_IRP_RETURNED_WITHOUT_COMPLETION 
DCERROR_COMPLETION_ROUTINE_PAGABLE 
DCERROR_PENDING_BIT_NOT_MIGRATED 
DCERROR_CANCELROUTINE_ON_FORWARDED_IRP 
DCERROR_PNP_IRP_NEEDS_PDO_HANDLING 
DCERROR_TARGET_RELATION_LIST_EMPTY 
DCERROR_TARGET_RELATION_NEEDS_REF 
DCERROR_BOGUS_PNP_IRP_COMPLETED 
DCERROR_SUCCESSFUL_PNP_IRP_NOT_FORWARDED 
DCERROR_UNTOUCHED_PNP_IRP_NOT_FORWARDED 
DCERROR_BOGUS_POWER_IRP_COMPLETED 
DCERROR_SUCCESSFUL_POWER_IRP_NOT_FORWARDED 
DCERROR_UNTOUCHED_POWER_IRP_NOT_FORWARDED 
DCERROR_PNP_QUERY_CAP_BAD_VERSION 
DCERROR_PNP_QUERY_CAP_BAD_SIZE 
DCERROR_PNP_QUERY_CAP_BAD_ADDRESS 
DCERROR_PNP_QUERY_CAP_BAD_UI_NUM 
DCERROR_RESTRICTED_IRP 
DCERROR_REINIT_OF_ALLOCATED_IRP_WITHOUT_QUOTA 
DCERROR_UNFORWARDED_IRP_COMPLETED 
DCERROR_DISPATCH_CALLED_AT_BAD_IRQL 
DCERROR_BOGUS_MINOR_STATUS_TRASHED 
DCERROR_MAXIMUM 

Definition at line 56 of file ioassert.h.

00056 { 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 ;


Function Documentation

PVOID IopDriverCorrectnessAddressToFileHeader IN PVOID  PcValue,
OUT PLDR_DATA_TABLE_ENTRY *  DataTableEntry
 

Definition at line 1254 of file ioassert.c.

References NULL, and PsLoadedModuleList.

Referenced by IopDriverCorrectnessProcessParams().

01261 : 01262 01263 This function returns the base of an image that contains the 01264 specified Address. An image contains the address if the address 01265 is within the ImageBase, and the ImageBase plus the size of the 01266 virtual image. 01267 01268 Arguments: 01269 01270 Address - Supplies an address to resolve to a loader entry. 01271 01272 DataTableEntry - Suppies a pointer to a variable that receives the 01273 address of the data table entry that describes the image. 01274 01275 Return Value: 01276 01277 NULL - No image was found that contains the passed in address. 01278 01279 NON-NULL - Returns the base address of the image that contain the 01280 address. 01281 01282 --*/ 01283 01284 { 01285 01286 PLIST_ENTRY ModuleListHead; 01287 PLDR_DATA_TABLE_ENTRY Entry; 01288 PLIST_ENTRY Next; 01289 UINT_PTR Bounds; 01290 PVOID ReturnBase=NULL, Base; 01291 01292 ModuleListHead = &PsLoadedModuleList; 01293 01294 // 01295 // It would be nice if we could call MiLookupDataTableEntry, but it's 01296 // pageable, so we do what the bugcheck stuff does... 01297 // 01298 Next = ModuleListHead->Flink; 01299 if (Next != NULL) { 01300 while (Next != ModuleListHead) { 01301 Entry = CONTAINING_RECORD(Next, 01302 LDR_DATA_TABLE_ENTRY, 01303 InLoadOrderLinks); 01304 01305 Next = Next->Flink; 01306 Base = Entry->DllBase; 01307 Bounds = (UINT_PTR)Base + Entry->SizeOfImage; 01308 if ((UINT_PTR)Address >= (UINT_PTR)Base && (UINT_PTR)Address < Bounds) { 01309 *DataTableEntry = Entry; 01310 ReturnBase = Base; 01311 break; 01312 } 01313 } 01314 } 01315 01316 return ReturnBase; 01317 }

BOOLEAN IopDriverCorrectnessApplyControl IN OUT PDC_CHECK_DATA  DcCheckData  ) 
 

Definition at line 776 of file ioassert.c.

References DIAG_CLEARED, DIAG_FATAL_ERROR, DIAG_IGNORE_DRIVER_LIST, DIAG_INITIALIZED, FALSE, IopDcControlInitial, IopDcControlOverride, KdDebuggerEnabled, and TRUE.

Referenced by IopDriverCorrectnessCheckUnderLock().

00779 { 00780 ULONG assertionControl; 00781 00782 if (IopDcControlOverride) { 00783 00784 assertionControl = IopDcControlOverride; 00785 00786 } else if (DcCheckData->Control) { 00787 00788 // 00789 // Initialize the control if appropo 00790 // 00791 if (!((*DcCheckData->Control)&DIAG_INITIALIZED)) { 00792 00793 *DcCheckData->Control |= ( 00794 DIAG_INITIALIZED | IopDcControlInitial | 00795 DcCheckData->AssertionClass->ClassFlags ); 00796 } 00797 00798 assertionControl = *DcCheckData->Control; 00799 00800 } else { 00801 00802 assertionControl = 00803 ( IopDcControlInitial | DcCheckData->AssertionClass->ClassFlags ); 00804 } 00805 00806 if (assertionControl&DIAG_CLEARED) { 00807 00808 // 00809 // If the breakpoint was cleared, then return, print/rip not. 00810 // 00811 return FALSE; 00812 } 00813 00814 if ((!(assertionControl&DIAG_IGNORE_DRIVER_LIST)) && 00815 (!DcCheckData->InVerifierList)) { 00816 00817 // 00818 // Not of interest, skip this one. 00819 // 00820 return FALSE; 00821 } 00822 00823 // 00824 // If there is no debugger, don't halt the machine. We are probably 00825 // ripping like mad and the user just wants to be able to boot. 00826 // The one exception is if DIAG_FATAL_ERROR is set. Then we shall 00827 // invoke the driver bugcheck... 00828 // 00829 if ((!KdDebuggerEnabled) && (!(assertionControl&DIAG_FATAL_ERROR))) { 00830 00831 return FALSE; 00832 } 00833 00834 // 00835 // Record our intentions and continue. 00836 // 00837 DcCheckData->AssertionControl = assertionControl; 00838 return TRUE; 00839 }

NTSTATUS IopDriverCorrectnessCheckUnderLock IN DCERROR_ID  MessageIndex,
IN ULONG  MessageParameterMask,
  ...
 

Definition at line 463 of file ioassert.c.

References ASSERT, DC_CHECK_DATA, DCERROR_ID, DcParamTable, IopDcControlCurrent, IopDcCurrentFrameSkips, IopDriverCorrectnessApplyControl(), IopDriverCorrectnessPrintBuffer(), IopDriverCorrectnessPrintParamData(), IopDriverCorrectnessProcessMessageText(), IopDriverCorrectnessProcessParams(), IopDriverCorrectnessPrompt(), IopDriverCorrectnessThrowBugCheck(), NT_SUCCESS, and NTSTATUS().

00470 : 00471 00472 This routine displays an assert and provides options for 00473 removing the breakpoint, changing to just a text-out, etc. 00474 00475 This routine is used as part of a macro for providing "Zappable" traps - 00476 IE, users get the option of changing how a specific instance of 00477 WDM_DEBUG_OUT in the code is handled (default is spew and break, options 00478 are spew or blow away for this boot). 00479 00480 Macro must call IopDiagSetAssertLock, IopDiagAssertPrintfUnderLock, and 00481 IopDiagReleaseAssertLock in order 00482 00483 DCPARAM_IRP*(count)+DCPARAM_ROUTINE*(count)+DCPARAM_DEVOBJ*(count), 00484 irp1, 00485 irp2, 00486 irp3, 00487 routine1, 00488 .., 00489 .., 00490 devobj1, 00491 00492 count can be a max of 3. 00493 00494 00495 Arguments: 00496 00497 Control - if present, this variable determines whether we will 00498 actually do anything. 00499 00500 if DIAG_ZAPPED is set we will print the assert text and return. 00501 if DIAG_CLEARED is set, we will neither print or stop. 00502 if DIAG_BEEP is set, we will beep if not zapped. 00503 00504 StackFramesToSkip - If this parameter is -1, it is not used. 00505 Otherwise, the assertion code will attempt to walk 00506 back the appropriate number of frames and 00507 determine the caller to blame based on return 00508 address. 00509 00510 IrpToFlag - IRP to print out failure data for if mishandling of 00511 this IRP was the source of the error. 00512 00513 AddressToFlag - Address that the assert should be blaimed on. This 00514 should be null if StackFramesToSkip is not -1. 00515 00516 AssertionClass - Text describing the overall class of the assert 00517 00518 AssertionText - Text specifically describing the assert. Carriage 00519 returns should not be embedded in the text, this 00520 routine will automatically ensure words are not split 00521 across the screen. 00522 00523 Notes: 00524 00525 The text will automagically be formatted and printed as such: 00526 00527 ASSERTION CLASS: ASSERTION TEXT ASSERTION TEXT ASSERTION 00528 TEXT ASSERTION TEXT ... 00529 00530 --*/ 00531 00532 { 00533 va_list arglist; 00534 UCHAR finalBuffer[512]; 00535 NTSTATUS status; 00536 DC_CHECK_DATA dcCheckData; 00537 PVOID dcParamArray[3*sizeof(DcParamTable)/sizeof(DCPARAM_TYPE_ENTRY)]; 00538 BOOLEAN exitAssertion; 00539 00540 va_start(arglist, MessageParameterMask); 00541 00542 // 00543 // Determine what our basic policy towards this check will be and fill out 00544 // the dcCheckData structure as well as we can. 00545 // 00546 IopDriverCorrectnessProcessParams( 00547 IopDcControlCurrent, 00548 IopDcCurrentFrameSkips, 00549 MessageID, 00550 MessageParameterMask, 00551 &arglist, 00552 dcParamArray, 00553 &dcCheckData 00554 ); 00555 00556 va_end(arglist); 00557 00558 if (!IopDriverCorrectnessApplyControl(&dcCheckData)) { 00559 00560 // 00561 // Nothing to see here, just ignore the assert... 00562 // 00563 return STATUS_SUCCESS; 00564 } 00565 00566 // 00567 // We are going to express our disatifaction somehow. Expand out the 00568 // message we've prepared for this scenario. 00569 // 00570 status = IopDriverCorrectnessProcessMessageText( 00571 sizeof(finalBuffer), 00572 finalBuffer, 00573 &dcCheckData 00574 ); 00575 00576 if (!NT_SUCCESS(status)) { 00577 00578 ASSERT(0); 00579 00580 // 00581 // Something went wrong with the index lookup! 00582 // 00583 return status; 00584 } 00585 00586 do { 00587 00588 IopDriverCorrectnessPrintBuffer(&dcCheckData); 00589 IopDriverCorrectnessPrintParamData(&dcCheckData); 00590 IopDriverCorrectnessThrowBugCheck(&dcCheckData); 00591 IopDriverCorrectnessPrompt(&dcCheckData, &exitAssertion); 00592 00593 } while (!exitAssertion); 00594 00595 return status; 00596 }

VOID IopDriverCorrectnessPrintBuffer IN PDC_CHECK_DATA  DcCheckData  ) 
 

Definition at line 1016 of file ioassert.c.

References DbgPrint, DIAG_FATAL_ERROR, KeBugCheckUnicodeToAnsi(), NULL, sprintf(), and strlen().

Referenced by IopDriverCorrectnessCheckUnderLock().

01019 { 01020 UCHAR buffer[82]; 01021 UCHAR classBuf[81]; 01022 UCHAR callerBuf[81+40]; 01023 UCHAR ansiDriverName[81]; 01024 LONG lMargin, i, lMarginCur, rMargin=78; 01025 PSTR lineStart, lastWord, current, lMarginText; 01026 01027 // 01028 // Put down a carraige return 01029 // 01030 DbgPrint("\n") ; 01031 01032 // 01033 // Drop a banner if this is a fatal assert. 01034 // 01035 if (DcCheckData->AssertionControl&DIAG_FATAL_ERROR) { 01036 01037 DbgPrint( 01038 "***********************************************************************\n" 01039 "* THIS DRIVER BUG IS FATAL AND WILL CAUSE THE VERIFIER TO HALT *\n" 01040 "* WINDOWS (BUGCHECK) WHEN THE MACHINE IS NOT UNDER A KERNEL DEBUGGER! *\n" 01041 "***********************************************************************\n" 01042 "\n" 01043 ); 01044 } 01045 01046 // 01047 // Prepare left margin (ClassText) 01048 // 01049 if (DcCheckData->ClassText != NULL) { 01050 01051 lMargin = strlen(DcCheckData->ClassText)+2; 01052 01053 DbgPrint("%s: ", DcCheckData->ClassText); 01054 01055 } else { 01056 01057 lMargin = 0; 01058 } 01059 01060 if (lMargin+1>=rMargin) { 01061 01062 lMargin=0; 01063 } 01064 01065 for(i=0; i<lMargin; i++) classBuf[i] = ' '; 01066 classBuf[lMargin] = '\0'; 01067 lMarginText = classBuf+lMargin; 01068 lMarginCur = lMargin; 01069 01070 lineStart = lastWord = current = DcCheckData->AssertionText; 01071 01072 // 01073 // Print out culprit if we have him... 01074 // 01075 if (DcCheckData->CulpritAddress) { 01076 01077 if (DcCheckData->DriverName.Length) { 01078 01079 KeBugCheckUnicodeToAnsi( 01080 &DcCheckData->DriverName, 01081 ansiDriverName, 01082 sizeof(ansiDriverName) 01083 ); 01084 01085 sprintf(callerBuf, "[%s @ 0x%p] ", 01086 ansiDriverName, 01087 DcCheckData->CulpritAddress 01088 ); 01089 01090 } else { 01091 01092 sprintf(callerBuf, "[0x%p] ", DcCheckData->CulpritAddress); 01093 } 01094 01095 DbgPrint("%s", callerBuf); 01096 lMarginCur += strlen(callerBuf); 01097 } 01098 01099 // 01100 // Format and print our assertion text 01101 // 01102 while(*current) { 01103 01104 if (*current == ' ') { 01105 01106 if ((current - lineStart) >= (rMargin-lMarginCur-1)) { 01107 01108 DbgPrint("%s", lMarginText); 01109 lMarginText = classBuf; 01110 lMarginCur = lMargin; 01111 01112 if ((lastWord-lineStart)<rMargin) { 01113 01114 memcpy(buffer, lineStart, (ULONG)(lastWord-lineStart)*sizeof(UCHAR)); 01115 buffer[lastWord-lineStart] = '\0'; 01116 DbgPrint("%s\n", buffer); 01117 01118 } 01119 01120 lineStart = lastWord+1; 01121 } 01122 01123 lastWord = current; 01124 } 01125 01126 current++; 01127 } 01128 01129 if ((current - lineStart) >= (rMargin-lMarginCur-1)) { 01130 01131 DbgPrint("%s", lMarginText); 01132 lMarginText = classBuf; 01133 01134 if ((lastWord-lineStart)<rMargin) { 01135 01136 memcpy(buffer, lineStart, (ULONG)(lastWord-lineStart)*sizeof(UCHAR)); 01137 buffer[lastWord-lineStart] = '\0'; 01138 DbgPrint("%s\n", buffer); 01139 } 01140 01141 lineStart = lastWord+1; 01142 } 01143 01144 if (lineStart<current) { 01145 01146 DbgPrint("%s%s\n", lMarginText, lineStart); 01147 } 01148 }

VOID IopDriverCorrectnessPrintIrp IN PIRP  IrpToFlag  ) 
 

Definition at line 1370 of file ioassert.c.

References DbgPrint, IO_STACK_LOCATION, IoGetCurrentIrpStackLocation, IoGetNextIrpStackLocation, IopDriverCorrectnessPrintIrpStack(), IopIsMemoryRangeReadable(), and _IO_STACK_LOCATION::MinorFunction.

Referenced by IopDriverCorrectnessPrintParamData().

01373 { 01374 PIO_STACK_LOCATION irpSpCur ; 01375 PIO_STACK_LOCATION irpSpNxt ; 01376 01377 // 01378 // First see if we can touch the IRP header 01379 // 01380 if(!IopIsMemoryRangeReadable(IrpToFlag, sizeof(IRP))) { 01381 return ; 01382 } 01383 01384 // 01385 // OK, get the next two stack locations... 01386 // 01387 irpSpNxt = IoGetNextIrpStackLocation( IrpToFlag ); 01388 irpSpCur = IoGetCurrentIrpStackLocation( IrpToFlag ); 01389 01390 if (IopIsMemoryRangeReadable(irpSpNxt, 2*sizeof(IO_STACK_LOCATION))) { 01391 01392 // 01393 // Both are present, print the best one! 01394 // 01395 if (irpSpNxt->MinorFunction == irpSpCur->MinorFunction) { 01396 01397 // 01398 // Looks forwarded 01399 // 01400 IopDriverCorrectnessPrintIrpStack(irpSpNxt) ; 01401 } else if (irpSpNxt->MinorFunction == 0) { 01402 01403 // 01404 // Next location is probably currently zero'd 01405 // 01406 IopDriverCorrectnessPrintIrpStack(irpSpCur) ; 01407 } else { 01408 DbgPrint("Next: >") ; 01409 IopDriverCorrectnessPrintIrpStack(irpSpNxt) ; 01410 DbgPrint("Current: ") ; 01411 IopDriverCorrectnessPrintIrpStack(irpSpCur) ; 01412 } 01413 } else if (IopIsMemoryRangeReadable(irpSpCur, sizeof(IO_STACK_LOCATION))) { 01414 01415 IopDriverCorrectnessPrintIrpStack(irpSpCur) ; 01416 } else if (IopIsMemoryRangeReadable(irpSpNxt, sizeof(IO_STACK_LOCATION))) { 01417 01418 IopDriverCorrectnessPrintIrpStack(irpSpNxt) ; 01419 } 01420 }

VOID IopDriverCorrectnessPrintIrpStack IN PIO_STACK_LOCATION  IrpSp  ) 
 

Definition at line 1516 of file ioassert.c.

References BusQueryCompatibleIDs, BusQueryDeviceID, BusQueryHardwareIDs, BusQueryInstanceID, BusRelations, DbgPrint, DeviceTextDescription, DeviceTextLocationInformation, DeviceUsageTypeDumpFile, DeviceUsageTypeHibernation, DeviceUsageTypePaging, DeviceUsageTypeUndefined, EjectionRelations, IRP_MJ_INTERNAL_DEVICE_CONTROL, IRP_MJ_PNP, IRP_MJ_POWER, IRP_MJ_SYSTEM_CONTROL, IRP_MN_DEVICE_USAGE_NOTIFICATION, IRP_MN_QUERY_BUS_INFORMATION, IRP_MN_QUERY_DEVICE_RELATIONS, IRP_MN_QUERY_DEVICE_TEXT, IRP_MN_QUERY_ID, IRP_MN_QUERY_INTERFACE, IRP_MN_QUERY_LEGACY_BUS_INFORMATION, IRP_MN_READ_CONFIG, IRP_MN_SCSI_CLASS, IRP_MN_SET_LOCK, IRP_MN_WRITE_CONFIG, IrpMajorNames, MAX_NAMED_MAJOR_IRPS, MAX_NAMED_PNP_IRP, MAX_NAMED_POWER_IRP, MAX_NAMED_WMI_IRP, PnPIrpNames, PowerIrpNames, PowerRelations, RemovalRelations, TargetDeviceRelation, and WmiIrpNames.

Referenced by IopDriverCorrectnessPrintIrp().

01519 { 01520 if ((IrpSp->MajorFunction==IRP_MJ_INTERNAL_DEVICE_CONTROL)&&(IrpSp->MinorFunction == IRP_MN_SCSI_CLASS)) { 01521 01522 DbgPrint("IRP_MJ_SCSI") ; 01523 01524 } else if (IrpSp->MajorFunction<=MAX_NAMED_MAJOR_IRPS) { 01525 01526 DbgPrint(IrpMajorNames[IrpSp->MajorFunction]) ; 01527 01528 } else if (IrpSp->MajorFunction==0xFF) { 01529 01530 DbgPrint("IRP_MJ_BOGUS") ; 01531 01532 } else { 01533 01534 DbgPrint("IRP_MJ_??") ; 01535 } 01536 01537 switch(IrpSp->MajorFunction) { 01538 01539 case IRP_MJ_SYSTEM_CONTROL: 01540 DbgPrint(".") ; 01541 if (IrpSp->MinorFunction<=MAX_NAMED_WMI_IRP) { 01542 01543 DbgPrint(WmiIrpNames[IrpSp->MinorFunction]) ; 01544 } else if (IrpSp->MinorFunction==0xFF) { 01545 01546 DbgPrint("IRP_MN_BOGUS") ; 01547 } else { 01548 DbgPrint("(Bogus)\n") ; 01549 } 01550 DbgPrint("\n") ; 01551 break ; 01552 case IRP_MJ_PNP: 01553 DbgPrint(".") ; 01554 if (IrpSp->MinorFunction<=MAX_NAMED_PNP_IRP) { 01555 01556 DbgPrint(PnPIrpNames[IrpSp->MinorFunction]) ; 01557 } else if (IrpSp->MinorFunction==0xFF) { 01558 01559 DbgPrint("IRP_MN_BOGUS") ; 01560 } else { 01561 01562 DbgPrint("(Bogus)\n") ; 01563 } 01564 switch(IrpSp->MinorFunction) { 01565 case IRP_MN_QUERY_DEVICE_RELATIONS: 01566 01567 switch(IrpSp->Parameters.QueryDeviceRelations.Type) { 01568 case BusRelations: 01569 DbgPrint("(BusRelations)") ; 01570 break ; 01571 case EjectionRelations: 01572 DbgPrint("(EjectionRelations)") ; 01573 break ; 01574 case PowerRelations: 01575 DbgPrint("(PowerRelations)") ; 01576 break ; 01577 case RemovalRelations: 01578 DbgPrint("(RemovalRelations)") ; 01579 break ; 01580 case TargetDeviceRelation: 01581 DbgPrint("(TargetDeviceRelation)") ; 01582 break ; 01583 default: 01584 DbgPrint("(Bogus)\n") ; 01585 break ; 01586 } 01587 break ; 01588 case IRP_MN_QUERY_INTERFACE: 01589 break ; 01590 case IRP_MN_QUERY_DEVICE_TEXT: 01591 switch(IrpSp->Parameters.QueryId.IdType) { 01592 case DeviceTextDescription: 01593 DbgPrint("(DeviceTextDescription)") ; 01594 break ; 01595 case DeviceTextLocationInformation: 01596 DbgPrint("(DeviceTextLocationInformation)") ; 01597 break ; 01598 default: 01599 DbgPrint("(Bogus)\n") ; 01600 break ; 01601 } 01602 break ; 01603 case IRP_MN_WRITE_CONFIG: 01604 case IRP_MN_READ_CONFIG: 01605 DbgPrint("(WhichSpace=%x, Buffer=%x, Offset=%x, Length=%x)", 01606 IrpSp->Parameters.ReadWriteConfig.WhichSpace, 01607 IrpSp->Parameters.ReadWriteConfig.Buffer, 01608 IrpSp->Parameters.ReadWriteConfig.Offset, 01609 IrpSp->Parameters.ReadWriteConfig.Length 01610 ) ; 01611 break ; 01612 case IRP_MN_SET_LOCK: 01613 if (IrpSp->Parameters.SetLock.Lock) DbgPrint("(True)") ; 01614 else DbgPrint("(False)") ; 01615 break ; 01616 case IRP_MN_QUERY_ID: 01617 switch(IrpSp->Parameters.QueryId.IdType) { 01618 case BusQueryDeviceID: 01619 DbgPrint("(BusQueryDeviceID)") ; 01620 break ; 01621 case BusQueryHardwareIDs: 01622 DbgPrint("(BusQueryHardwareIDs)") ; 01623 break ; 01624 case BusQueryCompatibleIDs: 01625 DbgPrint("(BusQueryCompatibleIDs)") ; 01626 break ; 01627 case BusQueryInstanceID: 01628 DbgPrint("(BusQueryInstanceID)") ; 01629 break ; 01630 default: 01631 DbgPrint("(Bogus)\n") ; 01632 break ; 01633 } 01634 break ; 01635 case IRP_MN_QUERY_BUS_INFORMATION: 01636 // BUGBUG: Should print out 01637 break ; 01638 case IRP_MN_DEVICE_USAGE_NOTIFICATION: 01639 switch(IrpSp->Parameters.UsageNotification.Type) { 01640 case DeviceUsageTypeUndefined: 01641 DbgPrint("(DeviceUsageTypeUndefined") ; 01642 break ; 01643 case DeviceUsageTypePaging: 01644 DbgPrint("(DeviceUsageTypePaging") ; 01645 break ; 01646 case DeviceUsageTypeHibernation: 01647 DbgPrint("(DeviceUsageTypeHibernation") ; 01648 break ; 01649 case DeviceUsageTypeDumpFile: 01650 DbgPrint("(DeviceUsageTypeDumpFile") ; 01651 break ; 01652 default: 01653 DbgPrint("(Bogus)\n") ; 01654 break ; 01655 } 01656 if (IrpSp->Parameters.UsageNotification.InPath) { 01657 DbgPrint(", InPath=TRUE)") ; 01658 } else { 01659 DbgPrint(", InPath=FALSE)") ; 01660 } 01661 break ; 01662 case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: 01663 // BUGBUG: Should print out 01664 break ; 01665 default: 01666 break ; 01667 } 01668 DbgPrint("\n") ; 01669 break ; 01670 01671 case IRP_MJ_POWER: 01672 DbgPrint(".") ; 01673 if (IrpSp->MinorFunction<=MAX_NAMED_POWER_IRP) { 01674 01675 DbgPrint(PowerIrpNames[IrpSp->MinorFunction]) ; 01676 } else if (IrpSp->MinorFunction==0xFF) { 01677 01678 DbgPrint("IRP_MN_BOGUS") ; 01679 } else { 01680 DbgPrint("(Bogus)\n") ; 01681 } 01682 DbgPrint("\n") ; 01683 break ; 01684 01685 default: 01686 DbgPrint("\n") ; 01687 break ; 01688 } 01689 }

VOID IopDriverCorrectnessPrintParamData IN PDC_CHECK_DATA  DcCheckData  ) 
 

Definition at line 1151 of file ioassert.c.

References IopDriverCorrectnessPrintIrp().

Referenced by IopDriverCorrectnessCheckUnderLock().

01154 { 01155 if (DcCheckData->DcParamArray[0]) { 01156 01157 IopDriverCorrectnessPrintIrp((PIRP) DcCheckData->DcParamArray[0]); 01158 } 01159 }

NTSTATUS IopDriverCorrectnessProcessMessageText IN ULONG  MaxOutputBufferSize,
OUT PSTR  OutputBuffer,
IN OUT PDC_CHECK_DATA  DcCheckData
 

Definition at line 842 of file ioassert.c.

References DcParamTable, IopDcMessageTable, _DCERROR_MESSAGE::MessageText, and strlen().

Referenced by IopDriverCorrectnessCheckUnderLock().

00847 { 00848 ULONG paramType, maxParameterTypes; 00849 ULONG arrayIndex, paramLength; 00850 PSTR messageHead, newMessage; 00851 LONG charsRemaining, length; 00852 00853 // 00854 // Get the message text. 00855 // 00856 messageHead = IopDcMessageTable[DcCheckData->TableIndex].MessageText; 00857 00858 // 00859 // Now manually build out the message. 00860 // 00861 newMessage = OutputBuffer; 00862 charsRemaining = (MaxOutputBufferSize/sizeof(UCHAR))-1; 00863 maxParameterTypes = sizeof(DcParamTable)/sizeof(DCPARAM_TYPE_ENTRY); 00864 00865 while(*messageHead != '\0') { 00866 00867 if (charsRemaining <= 0) { 00868 00869 return STATUS_BUFFER_OVERFLOW; 00870 } 00871 00872 if (*messageHead != '%') { 00873 00874 *newMessage = *messageHead; 00875 newMessage++; 00876 messageHead++; 00877 charsRemaining--; 00878 00879 } else { 00880 00881 for(paramType = 0; paramType < maxParameterTypes; paramType++) { 00882 00883 paramLength = strlen(DcParamTable[paramType].DcParamName); 00884 00885 // 00886 // Do we have a match? 00887 // 00888 // N.B. - We don't do any case 'de-sensitizing' anywhere, so 00889 // everything's cases must match! 00890 // 00891 if (RtlCompareMemory( 00892 messageHead+1, 00893 DcParamTable[paramType].DcParamName, 00894 paramLength*sizeof(UCHAR)) == paramLength*sizeof(UCHAR)) { 00895 00896 arrayIndex = paramType*3; 00897 messageHead += (paramLength+1); 00898 00899 // 00900 // Was an index passed in (ie, "3rd" irp requested)? 00901 // 00902 if ((*messageHead >= '1') && (*messageHead <= '3')) { 00903 00904 // 00905 // Adjust table index appropriately. 00906 // 00907 arrayIndex += (*messageHead - '1') ; 00908 messageHead++; 00909 } 00910 00911 length = _snprintf( 00912 newMessage, 00913 charsRemaining+1, 00914 "%p", 00915 DcCheckData->DcParamArray[arrayIndex] 00916 ); 00917 00918 if (length == -1) { 00919 00920 return STATUS_BUFFER_OVERFLOW; 00921 } 00922 00923 charsRemaining -= length; 00924 newMessage += length; 00925 break; 00926 } 00927 } 00928 00929 if (paramType == maxParameterTypes) { 00930 00931 // 00932 // Either the message we looked up is malformed, we don't recognize 00933 // the %thing it is talking about, or this is %%! 00934 // 00935 *newMessage = *messageHead; 00936 messageHead++; 00937 newMessage++; 00938 charsRemaining--; 00939 00940 if (*messageHead == '%') { 00941 00942 messageHead++; 00943 } 00944 } 00945 } 00946 } 00947 00948 // 00949 // Null-terminate it (we have room because we took one off the buffer size 00950 // above). 00951 // 00952 *newMessage = '\0'; 00953 00954 DcCheckData->ClassText = DcCheckData->AssertionClass->MessageClassText; 00955 DcCheckData->AssertionText = OutputBuffer; 00956 return STATUS_SUCCESS; 00957 }

VOID IopDriverCorrectnessProcessParams IN OUT PULONG Control  OPTIONAL,
IN LONG  StackFramesToSkip,
IN DCERROR_ID  MessageID,
IN ULONG  MessageParameterMask,
IN va_list *  MessageParameters,
IN PVOID *  DcParamArray,
OUT PDC_CHECK_DATA  DcCheckData
 

Definition at line 599 of file ioassert.c.

References ASSERT, DCERROR_UNSPECIFIED, _DCPARAM_TYPE_ENTRY::DcParamMask, DcParamTable, FALSE, IopDcMessageTable, IopDcOverrideTable, IopDriverCorrectnessAddressToFileHeader(), KeBugCheckUnicodeToAnsi(), _DCERROR_MESSAGE::MessageClass, _DC_OVERRIDE_TABLE::MessageID, MmIsAddressValid(), NULL, PDC_CHECK_DATA, _DC_OVERRIDE_TABLE::ReplacementClass, RtlCaptureStackBackTrace(), RtlImageNtHeader(), RtlInitUnicodeString(), and TRUE.

Referenced by IopDriverCorrectnessCheckUnderLock().

00608 { 00609 PVOID returnAddress[1]; 00610 PVOID baseOfImage, culpritAddress; 00611 ULONG stackHash; 00612 PLDR_DATA_TABLE_ENTRY dataTableEntry; 00613 PIMAGE_NT_HEADERS ntHeaders; 00614 ULONG i, currentMessageMask, paramType, maxParameterTypes, paramMask; 00615 ULONG tableIndex; 00616 char ansiDriverName[81]; 00617 00618 tableIndex = MessageID - DCERROR_UNSPECIFIED; 00619 00620 // 00621 // Retrieve a pointer to the appropriate message text. 00622 // 00623 if (tableIndex >= sizeof(IopDcMessageTable)/sizeof(DCERROR_MESSAGE)) { 00624 00625 // 00626 // Bogus message index! 00627 // 00628 ASSERT(0); 00629 tableIndex = 0; 00630 } 00631 00632 ASSERT(IopDcMessageTable[tableIndex].MessageID == MessageID); 00633 00634 // 00635 // OK, we're going to do *something*. Process the incoming parameters. 00636 // 00637 maxParameterTypes = sizeof(DcParamTable)/sizeof(DCPARAM_TYPE_ENTRY); 00638 00639 // 00640 // First we grab parameter off the stack and slot them appropriately into 00641 // our array of "things". 00642 // 00643 // The array is in groups of three for each possible member of a given type 00644 // (three irps, three routines, three device objects, etc). Items not 00645 // referenced in are set to NULL. 00646 // 00647 currentMessageMask = MessageParameterMask; 00648 00649 for(paramType = 0; paramType < maxParameterTypes; paramType++) { 00650 00651 paramMask = DcParamTable[paramType].DcParamMask ; 00652 for(i=0; i<3; i++) { 00653 00654 if (currentMessageMask&(paramMask*3)) { 00655 00656 currentMessageMask -= paramMask; 00657 DcParamArray[paramType*3+i] = va_arg(*MessageParameters, PVOID); 00658 00659 } else { 00660 00661 DcParamArray[paramType*3+i] = NULL; 00662 } 00663 } 00664 } 00665 00666 // 00667 // If this fires, part of the MessageParameterMask was not understood, 00668 // probably a bug by the caller! 00669 // 00670 ASSERT(currentMessageMask == 0); 00671 00672 // 00673 // Pre-init unhelpful answers... 00674 // 00675 culpritAddress = NULL; 00676 DcCheckData->OffsetIntoImage = 0; 00677 DcCheckData->InVerifierList = TRUE; 00678 RtlInitUnicodeString(&DcCheckData->DriverName, NULL); 00679 00680 // 00681 // Blame caller if appropriate 00682 // 00683 if (StackFramesToSkip != -1) { 00684 00685 if (RtlCaptureStackBackTrace(StackFramesToSkip+2, 1, returnAddress, 00686 &stackHash)==1) { 00687 00688 culpritAddress = returnAddress[0]; 00689 } 00690 00691 } else { 00692 00693 // 00694 // %Routine1 00695 // 00696 culpritAddress = DcParamArray[3]; 00697 } 00698 00699 // 00700 // Extract the culprit's name if possible... 00701 // 00702 if (culpritAddress) { 00703 00704 baseOfImage = IopDriverCorrectnessAddressToFileHeader( 00705 (PVOID) culpritAddress, 00706 &dataTableEntry 00707 ); 00708 00709 if (baseOfImage != NULL) { 00710 00711 // 00712 // If we found a match, drill into the dataTableEntry's to get 00713 // 00714 // 00715 if (MmIsAddressValid(dataTableEntry->DllBase) != FALSE) { 00716 00717 ntHeaders = RtlImageNtHeader(dataTableEntry->DllBase); 00718 00719 RtlCopyMemory( 00720 &DcCheckData->DriverName, 00721 &dataTableEntry->BaseDllName, 00722 sizeof(UNICODE_STRING) 00723 ); 00724 00725 DcCheckData->OffsetIntoImage = (PUCHAR) culpritAddress - (PUCHAR) baseOfImage; 00726 } 00727 00728 // 00729 // Now record whether this is in the verifying table. 00730 // 00731 if (!(dataTableEntry->Flags & LDRP_IMAGE_VERIFYING)) { 00732 00733 DcCheckData->InVerifierList = FALSE; 00734 } 00735 } 00736 } 00737 00738 DcCheckData->CulpritAddress = culpritAddress; 00739 DcCheckData->DcParamArray = DcParamArray; 00740 DcCheckData->TableIndex = tableIndex; 00741 DcCheckData->MessageID = MessageID; 00742 DcCheckData->Control = Control; 00743 DcCheckData->AssertionClass = IopDcMessageTable[DcCheckData->TableIndex].MessageClass; 00744 00745 // 00746 // Get an ANSI version of the driver name and root through the override 00747 // table. 00748 // 00749 KeBugCheckUnicodeToAnsi( 00750 &DcCheckData->DriverName, 00751 ansiDriverName, 00752 sizeof(ansiDriverName) 00753 ); 00754 00755 for(i=0; i<sizeof(IopDcOverrideTable)/sizeof(DC_OVERRIDE_TABLE); i++) { 00756 00757 if ((IopDcOverrideTable[i].MessageID == MessageID) || 00758 (IopDcOverrideTable[i].MessageID == DCERROR_UNSPECIFIED)) { 00759 00760 if (!_stricmp(ansiDriverName, IopDcOverrideTable[i].DriverName)) { 00761 00762 // 00763 // We have a match, override the error class. Note that as 00764 // Control is not per-driver, but per assert, we null out 00765 // the passed in Control so that we don't apply this override 00766 // policy against every driver! 00767 // 00768 DcCheckData->Control = NULL; 00769 DcCheckData->AssertionClass = IopDcOverrideTable[i].ReplacementClass; 00770 } 00771 } 00772 } 00773 }

VOID IopDriverCorrectnessPrompt IN PDC_CHECK_DATA  DcCheckData,
OUT PBOOLEAN  ExitAssertion
 

Definition at line 1162 of file ioassert.c.

References DbgPrint, DbgPrompt(), DIAG_BEEP, DIAG_CLEARED, DIAG_ZAPPED, FALSE, IopDcControlOverride, and TRUE.

Referenced by IopDriverCorrectnessCheckUnderLock().

01166 { 01167 char response[2]; 01168 ULONG assertionControl; 01169 BOOLEAN waitForInput; 01170 01171 assertionControl = DcCheckData->AssertionControl; 01172 01173 *ExitAssertion = TRUE; 01174 01175 // 01176 // Vocalize if so ordered. 01177 // 01178 if (assertionControl&DIAG_BEEP) { 01179 01180 DbgPrint("%c", 7); 01181 } 01182 01183 if (assertionControl&DIAG_ZAPPED) { 01184 01185 return; 01186 } 01187 01188 // 01189 // Wait for input... 01190 // 01191 waitForInput = TRUE; 01192 while(waitForInput) { 01193 01194 if (DcCheckData->Control) { 01195 01196 DbgPrompt( "Break, Ignore, Zap, Remove, Disable all (bizrd)? ", response, sizeof( response )); 01197 } else { 01198 01199 DbgPrompt( "Break, Ignore, Disable all (bid)? ", response, sizeof( response )); 01200 } 01201 01202 switch (response[0]) { 01203 01204 case 'B': 01205 case 'b': 01206 DbgPrint("Breaking in... (press g<enter> to return to assert menu)\n"); 01207 DbgBreakPoint(); 01208 waitForInput = FALSE; 01209 *ExitAssertion = FALSE; 01210 break; 01211 01212 case 'I': 01213 case 'i': 01214 waitForInput = FALSE; 01215 break; 01216 01217 case 'Z': 01218 case 'z': 01219 if (DcCheckData->Control) { 01220 01221 DbgPrint("Breakpoint zapped (OS will print text and return)\n"); 01222 assertionControl |= DIAG_ZAPPED; 01223 assertionControl &=~ DIAG_BEEP; 01224 waitForInput = FALSE; 01225 } 01226 break; 01227 01228 case 'D': 01229 case 'd': 01230 IopDcControlOverride = DIAG_CLEARED; 01231 DbgPrint("Verification asserts disabled.\n"); 01232 //assertionControl |= DIAG_CLEARED; 01233 waitForInput = FALSE; 01234 break; 01235 01236 case 'R': 01237 case 'r': 01238 if (DcCheckData->Control) { 01239 01240 DbgPrint("Breakpoint removed\n") ; 01241 assertionControl |= DIAG_CLEARED; 01242 waitForInput = FALSE; 01243 } 01244 break; 01245 } 01246 } 01247 01248 if (DcCheckData->Control) { 01249 *DcCheckData->Control = assertionControl; 01250 } 01251 }

VOID IopDriverCorrectnessReleaseLock VOID   ) 
 

Definition at line 446 of file ioassert.c.

References IopDcControlCurrent, IopDcControlIrql, IopDcControlLock, IopDcCurrentFrameSkips, and NULL.

00451 : 00452 00453 Worker routine for KD_ASSERT_OUT, see IopDiagSetAssertLock 00454 00455 --*/ 00456 { 00457 IopDcControlCurrent = NULL ; 00458 IopDcCurrentFrameSkips = -1 ; 00459 ExReleaseSpinLock( &IopDcControlLock, IopDcControlIrql ); 00460 }

VOID IopDriverCorrectnessTakeLock IN PULONG  ControlNew,
IN LONG  StackFramesToSkip
 

Definition at line 423 of file ioassert.c.

References ASSERT, IopDcControlCurrent, IopDcControlIrql, IopDcControlLock, IopDcCurrentFrameSkips, IovpInitCalled, and NULL.

Referenced by IoVerifierInit().

00429 : 00430 00431 Worker routine for KD_ASSERT_OUT, takes the assertion spinlock. We do 00432 this because we *must* use a macro to instantiate a caller-specific 00433 tag and we cannot pass in that value along with a variable printf style 00434 debug output. Hence we must "pre-program" the output routine with the 00435 breakpoint ID, and use a spinlock to protect ourselves 00436 --*/ 00437 { 00438 ASSERT(IovpInitCalled); 00439 ExAcquireSpinLock( &IopDcControlLock, &IopDcControlIrql ); 00440 ASSERT(IopDcControlCurrent == NULL) ; 00441 IopDcControlCurrent = ControlNew ; 00442 IopDcCurrentFrameSkips = StackFramesToSkip ; 00443 }

VOID IopDriverCorrectnessThrowBugCheck IN PDC_CHECK_DATA  DcCheckData  ) 
 

Definition at line 960 of file ioassert.c.

References DIAG_FATAL_ERROR, KdDebuggerEnabled, KeBugCheckEx(), and KeBugCheckUnicodeToAnsi().

Referenced by IopDriverCorrectnessCheckUnderLock().

00963 { 00964 PVOID parameterArray[4]; 00965 char captionBuffer[256]; 00966 char ansiDriverName[81]; 00967 UNICODE_STRING unicodeString; 00968 00969 // 00970 // Do not bugcheck if a kernel debugger is attached, nor if this isn't a 00971 // fatal error. 00972 // 00973 if (KdDebuggerEnabled || (!(DcCheckData->AssertionControl&DIAG_FATAL_ERROR))) { 00974 00975 return; 00976 } 00977 00978 // 00979 // We are here because DIAG_FATAL_ERROR is set. We use 00980 // FATAL_UNHANDLED_HARD_ERROR so that we can give a 00981 // descriptive text string for the problem. 00982 // 00983 parameterArray[0] = (PVOID) DcCheckData->MessageID; 00984 parameterArray[1] = DcCheckData->CulpritAddress; 00985 parameterArray[2] = DcCheckData->DcParamArray[0]; 00986 parameterArray[3] = DcCheckData->DcParamArray[6]; 00987 00988 KeBugCheckUnicodeToAnsi( 00989 &DcCheckData->DriverName, 00990 ansiDriverName, 00991 sizeof(ansiDriverName) 00992 ); 00993 00994 _snprintf( 00995 captionBuffer, 00996 sizeof(captionBuffer), 00997 "IO SYSTEM VERIFICATION ERROR in %s (%s %x)\n[%s+%x at %p]\n", 00998 ansiDriverName, 00999 DcCheckData->ClassText, 01000 DcCheckData->MessageID, 01001 ansiDriverName, 01002 DcCheckData->OffsetIntoImage, 01003 DcCheckData->CulpritAddress 01004 ); 01005 01006 KeBugCheckEx( 01007 FATAL_UNHANDLED_HARD_ERROR, 01008 DRIVER_VERIFIER_IOMANAGER_VIOLATION, 01009 (ULONG_PTR) parameterArray, 01010 (ULONG_PTR) captionBuffer, 01011 (ULONG_PTR) "" // DcCheckData->AssertionText is too technical 01012 ); 01013 }

BOOLEAN IopIsMemoryRangeReadable IN PVOID  Location,
IN size_t  Length
 

Definition at line 1320 of file ioassert.c.

References FALSE, MmIsAddressValid(), and TRUE.

Referenced by IopDriverCorrectnessPrintIrp(), IovpAssertNewRequest(), and IovpSessionDataAttachSurrogate().

01324 { 01325 while (((ULONG_PTR)Location & (sizeof(ULONG_PTR)-1)) && (Length > 0)) { 01326 01327 // 01328 // Check to determine if the move will succeed before actually performing 01329 // the operation. 01330 // 01331 if (MmIsAddressValid(Location)==FALSE) { 01332 return FALSE ; 01333 } 01334 01335 ((PCHAR) Location)++ ; 01336 Length-- ; 01337 } 01338 01339 while (Length > (sizeof(ULONG_PTR)-1)) { 01340 01341 // 01342 // Check to determine if the move will succeed before actually performing 01343 // the operation. 01344 // 01345 if (MmIsAddressValid(Location)==FALSE) { 01346 return FALSE ; 01347 } 01348 ((PCHAR) Location) += sizeof(ULONG_PTR); 01349 Length -= sizeof(ULONG_PTR); 01350 01351 } 01352 01353 while (Length > 0) { 01354 01355 // 01356 // Check to determine if the move will succeed before actually performing 01357 // the operation. 01358 // 01359 if (MmIsAddressValid(Location)==FALSE) { 01360 return FALSE; 01361 } 01362 01363 ((PCHAR) Location)++ ; 01364 Length-- ; 01365 } 01366 return TRUE ; 01367 }


Variable Documentation

ULONG IopDcControlInitial
 

Definition at line 52 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl(), and IoVerifierInit().

KSPIN_LOCK IopDcControlLock
 

Definition at line 54 of file ioassert.h.

Referenced by IopDriverCorrectnessReleaseLock(), IopDriverCorrectnessTakeLock(), and IoVerifierInit().

ULONG IopDcControlOverride
 

Definition at line 53 of file ioassert.h.

Referenced by IopDriverCorrectnessApplyControl(), IopDriverCorrectnessPrompt(), and IoVerifierInit().

ULONG IovpEnforcementLevel
 

Definition at line 51 of file ioassert.h.

LONG IovpInitCalled
 

Definition at line 49 of file ioassert.h.

Referenced by IopDriverCorrectnessTakeLock(), and IoVerifierInit().

ULONG IovpVerifierLevel
 

Definition at line 50 of file ioassert.h.


Generated on Sat May 15 19:44:17 2004 for test by doxygen 1.3.7