zoukankan      html  css  js  c++  java
  • Win32汇编_异常_筛选器

    .386
    .model flat, stdcall
    option casemap:none

    include    windows.inc
    include    user32.inc
    include    kernel32.inc
    includelib user32.lib
    includelib kernel32.lib

    .data
    lpOldHandler    dd      ?

    .const
    szMsg            db      '
    异常发生位置: %08X, 异常代码: %08X, 标志: %08X', 0
    szSafe           db      '
    回到安全地方!!!', 0
    szCaption       db      '
    筛选器异常处理的例子!!!', 0

    .code

    _Handler        proc        _lpExceptionPoint
        LOCAL @szBuffer[256]:byte
       
        pushad
        mov      esi, _lpExceptionPoint
        assume  esi: ptr EXCEPTION_POINTERS
        mov      edi, [esi].ContextRecord
        mov      esi, [esi].pExceptionRecord
        assume  esi: ptr EXCEPTION_RECORD, edi: ptr CONTEXT
        invoke   wsprintf, addr @szBuffer, addr szMsg, [edi].regEip, [esi].ExceptionCode, [esi].ExceptionFlags
        invoke   MessageBox, NULL, addr @szBuffer, NULL, MB_OK
        ;
    设置跳到哪行代码去继续执行,
        mov      [edi].regEip, offset _SafePlace
        assume  esi: nothing, edi: nothing   
        popad
        ;
    返回值设置为继续执行代码
        mov      eax, EXCEPTION_CONTINUE_EXECUTION
        ret
    _Handler endp

    start:
        ;
    设置异常回调函数
        invoke  SetUnhandledExceptionFilter, addr _Handler
        ;
    保存原先的异常回调函数
        mov     lpOldHandler, eax
        xor      eax, eax
        ;
    产生异常,就会跳到上边设置的异常回调函数去执行
        mov     dword ptr [eax], 0
      
    _SafePlace:
        invoke  MessageBox, NULL, addr szSafe, addr szCaption, MB_OK
        ;
    设置回原先的异常回调函数
        invoke  SetUnhandledExceptionFilter, lpOldHandler
        invoke  ExitProcess, NULL
       
        end     start

  • 相关阅读:
    JS从后台获取数据,前台动态添加tr标签中的td标签
    Java方式导出EXCEL表格
    框架搭建相关博文
    Spring框架相关博文集
    Eclipse相关工具使用
    关于Spring Boot的博客集合
    Springboot spring data jpa 多数据源的配置01
    springboot1.X 到2.X 的改变
    Spring-Boot devtools项目自动重启
    JSR 303
  • 原文地址:https://www.cnblogs.com/w413133157/p/1804517.html
Copyright © 2011-2022 走看看