码迷,mamicode.com
首页 > 其他好文 > 详细

Kernel Assert

时间:2017-08-16 20:30:06      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:sap   bre   ase   sys   efi   prompt   ber   ons   log   

 

#define ASSERT( exp )     ((!(exp)) ?         (RtlAssert( #exp, __FILE__, __LINE__, NULL ),FALSE) :         TRUE)

  

NTSYSAPI
VOID
NTAPI
RtlAssert(
    __in PVOID VoidFailedAssertion,
    __in PVOID VoidFileName,
    __in ULONG LineNumber,
    __in_opt PSTR MutableMessage
    )
{
#if DBG || RTL_ASSERT_ALWAYS_ENABLED
    char Response[ 2 ];

    CONST PCSTR FailedAssertion = (PCSTR)VoidFailedAssertion;
    CONST PCSTR FileName = (PCSTR)VoidFileName;
    CONST PCSTR Message  = (PCSTR)MutableMessage;

    CONTEXT Context;

    RtlCaptureContext( &Context );

    while (TRUE) {
        DbgPrint( "\n*** Assertion failed: %s%s\n***   Source File: %s, line %ld\n\n",
                  Message ? Message : "",
                  FailedAssertion,
                  FileName,
                  LineNumber
                );
        DbgPrompt( "Break repeatedly, break Once, Ignore, terminate Process, or terminate Thread (boipt)? ",
                   Response,
                   sizeof( Response )
                 );
        switch (Response[0]) {
            case ‘B‘:
            case ‘b‘:
            case ‘O‘:
            case ‘o‘:
                DbgPrint( "Execute ‘.cxr %p‘ to dump context\n", &Context);
                DbgBreakPoint();
                if (Response[0] == ‘o‘ || Response[0] == ‘O‘)
                    return;
                break;

            case ‘I‘:
            case ‘i‘:
                return;

            case ‘P‘:
            case ‘p‘:
                ZwTerminateProcess( NtCurrentProcess(), STATUS_UNSUCCESSFUL );
                break;

            case ‘T‘:
            case ‘t‘:
                ZwTerminateThread( NtCurrentThread(), STATUS_UNSUCCESSFUL );
                break;
            }
        }

    DbgBreakPoint();
    ZwTerminateProcess( NtCurrentProcess(), STATUS_UNSUCCESSFUL );
#endif
}

  

Kernel Assert

标签:sap   bre   ase   sys   efi   prompt   ber   ons   log   

原文地址:http://www.cnblogs.com/aliflycoris/p/7375256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!