首页
论坛
课程
招聘
[求助]UnhandledExceptionFilter合适被调用的?
2015-9-26 17:59 3717

[求助]UnhandledExceptionFilter合适被调用的?

2015-9-26 17:59
3717
问题放在最前面说:
UnhandledExceptionFilter是在哪个函数中被调用的?

下午无聊突然想翻下源码,看看r3异常处理的东西.
以前都是被告知,windows的SEH处理会调用UnhandledExceptionFilter来处理SetUnhandledExceptionFilter注册的自定义异常处理函数.但是我没有找到具体调用UnhandleExceptionFilter的地方.

KiDispatchException里面只设置了调用KeUserExceptionDispatcher.
我觉得这个KeUserExceptionDispatcher应该是KiUserExceptionDispatcer

然后:
0:000> u ntdll!KiUserExceptionDispatcher L100
ntdll!KiUserExceptionDispatcher:
7c92e45c 8b4c2404        mov     ecx,dword ptr [esp+4]
7c92e460 8b1c24          mov     ebx,dword ptr [esp]
7c92e463 51              push    ecx
7c92e464 53              push    ebx
7c92e465 e8e6c40100      call    ntdll!RtlDispatchException (7c94a950)
7c92e46a 0ac0            or      al,al
7c92e46c 740c            je      ntdll!KiUserExceptionDispatcher+0x1e (7c92e47a)---------
7c92e46e 5b              pop     ebx							|
7c92e46f 59              pop     ecx							|
7c92e470 6a00            push    0							|
7c92e472 51              push    ecx							|
7c92e473 e8c8ebffff      call    ntdll!NtContinue (7c92d040)				|
7c92e478 eb0b            jmp     ntdll!KiUserExceptionDispatcher+0x29 (7c92e485)--------|-------|
7c92e47a 5b              pop     ebx					<----------------	|
7c92e47b 59              pop     ecx								|
7c92e47c 6a00            push    0								|
7c92e47e 51              push    ecx								|
7c92e47f 53              push    ebx								|
7c92e480 e80bf5ffff      call    ntdll!ZwRaiseException (7c92d990)				|
7c92e485 83c4ec          add     esp,0FFFFFFECh				<------------------------
7c92e488 890424          mov     dword ptr [esp],eax
7c92e48b c744240401000000 mov     dword ptr [esp+4],1
7c92e493 895c2408        mov     dword ptr [esp+8],ebx
7c92e497 c744241000000000 mov     dword ptr [esp+10h],0
7c92e49f 54              push    esp
7c92e4a0 e863000000      call    ntdll!RtlRaiseException (7c92e508)
7c92e4a5 c20800          ret     8


0:000> u ntdll!ZwRaiseException
ntdll!ZwRaiseException:
7c92d990 b8b5000000      mov     eax,0B5h
7c92d995 ba0003fe7f      mov     edx,offset SharedUserData!SystemCallStub (7ffe0300)
7c92d99a ff12            call    dword ptr [edx]
7c92d99c c20c00          ret     0Ch

RtlDispatchException遍历完异常结构之后还没有处理的Exception为unhandled exception.
然后应该走到ZwRaiseException里面去了,在之后就是系统调用0x5b
这个系统调用翻了N多资料都没有找到具体的是哪个系统调用.

找了个有seh的程序看了一下系统SEH连上最后一个seh函数是
ntdll!_except_handler3
IDA看了一下这个函数的调用逻辑,也没有发现掉到UnhandledExceptionFilter里面去.

求各位高手讲解一下~~

看雪招聘平台创建简历并且简历完整度达到90%及以上可获得500看雪币~

收藏
点赞0
打赏
分享
最新回复 (1)
雪    币: 1162
活跃值: 活跃值 (682)
能力值: ( LV6,RANK:80 )
在线值:
发帖
回帖
粉丝
Hacksign 活跃值 1 2015-9-26 18:14
2
0
好吧,我特么2了......
调用位置的确是在except_handler3里面:
0:000> kv
ChildEBP RetAddr  Args to Child              
0022fa78 7c843892 0022faa0 7c839b21 0022faa8 kernel32!UnhandledExceptionFilter (FPO: [Non-Fpo])
0022fa80 7c839b21 0022faa8 00000000 0022faa8 kernel32!BaseProcessStart+0x39 (FPO: [Non-Fpo])
0022faa8 7c9232a8 0022fb94 0022ffe0 0022fba8 kernel32!_except_handler3+0x61 (FPO: [Uses EBP] [3,0,7])
0022facc 7c92327a 0022fb94 0022ffe0 0022fba8 ntdll!ExecuteHandler2+0x26
0022fb7c 7c92e46a 00000000 0022fba8 0022fb94 ntdll!ExecuteHandler+0x24
0022fb7c 7c812aeb 00000000 0022fba8 0022fb94 ntdll!KiUserExceptionDispatcher+0xe (FPO: [2,0,0]) (CONTEXT @ 0022fba8)
0022fec8 004015ec 11223344 00000000 00000000 kernel32!RaiseException+0x53 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
0022fee8 004013e2 003e24c0 0000000a 00000001 image00400000+0x15ec
0022ffc0 7c817067 017af6ee 017af71c 7ffd5000 image00400000+0x13e2
0022fff0 00000000 004014e0 00000000 78746341 kernel32!BaseProcessStart+0x23 (FPO: [Non-Fpo])


__except_handler3+B                    mov     ebx, [ebp+TargetFrame]
__except_handler3+E                    mov     eax, [ebp+arg_0]
__except_handler3+11                   test    dword ptr [eax+4], 6
__except_handler3+18                   jnz     loc_7C92E9C9
__except_handler3+1E                   mov     [ebp+var_8], eax
__except_handler3+21                   mov     eax, [ebp+arg_8]
__except_handler3+24                   mov     [ebp+var_4], eax
__except_handler3+27                   lea     eax, [ebp+var_8]
__except_handler3+2A                   mov     [ebx-4], eax
__except_handler3+2D                   mov     esi, [ebx+0Ch]
__except_handler3+30                   mov     edi, [ebx+8]
__except_handler3+33                   push    ebx
__except_handler3+34                   call    __ValidateEH3RN
__except_handler3+39                   add     esp, 4
__except_handler3+3C                   or      eax, eax
__except_handler3+3E                   jz      short loc_7C92E9BB
__except_handler3+40
__except_handler3+40   loc_7C92E940:                           ; CODE XREF: __except_handler3+B2j
__except_handler3+40                   cmp     esi, 0FFFFFFFFh
__except_handler3+43                   jz      short loc_7C92E9C2
__except_handler3+45                   lea     ecx, [esi+esi*2]
__except_handler3+48                   mov     eax, [edi+ecx*4+4]
__except_handler3+4C                   or      eax, eax
__except_handler3+4E                   jz      short loc_7C92E9A9
__except_handler3+50                   push    esi
__except_handler3+51                   push    ebp
__except_handler3+52                   lea     ebp, [ebx+10h]
__except_handler3+55                   xor     ebx, ebx
__except_handler3+57                   xor     ecx, ecx
__except_handler3+59                   xor     edx, edx
__except_handler3+5B                   xor     esi, esi
__except_handler3+5D                   xor     edi, edi
__except_handler3+5F                   call    eax
__except_handler3+61                   pop     ebp
__except_handler3+62                   pop     esi
__except_handler3+63                   mov     ebx, [ebp+TargetFrame]
游客
登录 | 注册 方可回帖
返回