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

assert.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 assert.c 00008 00009 Abstract: 00010 00011 This module implements the RtlAssert function that is referenced by the 00012 debugging version of the ASSERT macro defined in NTDEF.H 00013 00014 Author: 00015 00016 Steve Wood (stevewo) 03-Oct-1989 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include <nt.h> 00023 #include <ntrtl.h> 00024 #include <zwapi.h> 00025 00026 // 00027 // RtlAssert is not called unless the caller is compiled with DBG non-zero 00028 // therefore it does no harm to always have this routin in the kernel. 00029 // This allows checked drivers to be thrown on the system and have their 00030 // asserts be meaningful. 00031 // 00032 00033 #define RTL_ASSERT_ALWAYS_ENABLED 1 00034 00035 VOID 00036 RtlAssert( 00037 IN PVOID FailedAssertion, 00038 IN PVOID FileName, 00039 IN ULONG LineNumber, 00040 IN PCHAR Message OPTIONAL 00041 ) 00042 { 00043 #if DBG || RTL_ASSERT_ALWAYS_ENABLED 00044 char Response[ 2 ]; 00045 CONTEXT Context; 00046 00047 #ifndef BLDR_KERNEL_RUNTIME 00048 RtlCaptureContext( &Context ); 00049 #endif 00050 00051 while (TRUE) { 00052 DbgPrint( "\n*** Assertion failed: %s%s\n*** Source File: %s, line %ld\n\n", 00053 Message ? Message : "", 00054 FailedAssertion, 00055 FileName, 00056 LineNumber 00057 ); 00058 00059 DbgPrompt( "Break, Ignore, Terminate Process or Terminate Thread (bipt)? ", 00060 Response, 00061 sizeof( Response ) 00062 ); 00063 switch (Response[0]) { 00064 case 'B': 00065 case 'b': 00066 DbgPrint( "Execute '!cxr %p' to dump context\n", &Context); 00067 DbgBreakPoint(); 00068 break; 00069 00070 case 'I': 00071 case 'i': 00072 return; 00073 00074 case 'P': 00075 case 'p': 00076 ZwTerminateProcess( NtCurrentProcess(), STATUS_UNSUCCESSFUL ); 00077 break; 00078 00079 case 'T': 00080 case 't': 00081 ZwTerminateThread( NtCurrentThread(), STATUS_UNSUCCESSFUL ); 00082 break; 00083 } 00084 } 00085 00086 DbgBreakPoint(); 00087 ZwTerminateProcess( NtCurrentProcess(), STATUS_UNSUCCESSFUL ); 00088 #endif 00089 }

Generated on Sat May 15 19:39:16 2004 for test by doxygen 1.3.7