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

  • 相关阅读:
    打破国外垄断,开发中国人自己的编程语言(1):实现可以解析表达式的计算器
    the best way to get the OBJECTID OID name in arcpy?
    arcpy 自定义工具可选参数留空时的处理
    Word 显示隐藏图片
    删除Word表格后的一张空白页
    如何查看别人申请加群的历史记录
    OpenLayers v2 热力图插件
    IDEA JRebel热部署插件安装使用
    Lombok的@Data等注解无效
    CAP理论/AP架构/CP架构
  • 原文地址:https://www.cnblogs.com/w413133157/p/1804517.html
Copyright © 2011-2022 走看看