.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;include
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;數據段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
lpOldHandler dd
?
.const
szMsg db
"異常發生位置:%08X,%08X,異常代碼:%08X,標誌:%08X",0
szSafe db
"回到了安全的地方",0
szTitle 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
mov eax,[esi].ExceptionFlags
;如果標誌被置位,說明異常是致命的,應該退出
and eax,00000001h
.if eax==1
mov eax,EXCEPTION_CONTINUE_SEARCH
ret
.endif
;ExceptionCode中包含了,異常的類型,嚴重性,觸發異常的設置,是內存
;還是網絡,還是CPU,還是接口卡,還是多媒體設置
;ExceptionFlag中指名了異常是否導致程序的終止
invoke
wsprintf,addr @szBuffer,addr szMsg,\
[edi].regEip,[esi].ExceptionAddress,[esi].ExceptionCode,[esi].ExceptionFlags
invoke
MessageBox,NULL,addr @szBuffer,NULL,MB_OK
mov [edi].regEip,offset _SafePlace
assume
esi:nothing,edi:nothing
popad
;返回值,根據ExceptionFlag來決定是否應該讓程序進行下去
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 szTitle,MB_OK
invoke
ExitProcess,NULL
end start
篩選器異常處理
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
關於SEH(結構化異常處理)的一些知識
lanwanjunxixihaha
2020-07-03 05:28:39
彙編語言命令參數程序的編寫
George0102
2020-02-21 15:05:59
程序的加載和鏈接機制
George0102
2020-02-21 15:05:59
複習8086彙編中的 CLI STI CLD STD指令
lanwanjunxixihaha
2020-02-20 17:03:39
複習實模式和保護模式的知識
lanwanjunxixihaha
2020-02-20 17:03:39
爲何實模式要採用段地址和偏移地址的方式來尋址
lanwanjunxixihaha
2020-02-20 17:03:39
關於彙編的一些零散知識點
lanwanjunxixihaha
2020-02-20 17:03:38
反彙編中關於IDA與OLLYDBG的使用
lanwanjunxixihaha
2020-02-20 17:03:38
內存映射文件來處理大文件可以提高效率
lanwanjunxixihaha
2020-02-20 17:03:38
關於SEH(結構化異常處理)的一些知識
lanwanjunxixihaha
2020-07-03 05:28:39
彙編語言命令參數程序的編寫
George0102
2020-02-21 15:05:59
程序的加載和鏈接機制
George0102
2020-02-21 15:05:59
複習8086彙編中的 CLI STI CLD STD指令
lanwanjunxixihaha
2020-02-20 17:03:39