__except() 的处理2 --- 全局展开
前面我们了解到对 EXCEPTION_EXECUTE_HANDLER 的处理,重要的一步会进行全局展开:
MSVCR100D!_except_handler4_common+0x118: 01152558 8b4de0 mov ecx,dword ptr [ebp-20h] ; esp 0115255b 83c108 add ecx,8 ; get prev_struct 0115255e 8b5510 mov edx,dword ptr [ebp+10h] ; ExceptionRecord 01152561 e8ccb3ffff call MSVCR100D!_EH4_GlobalUnwind2 (0114d932) 01152566 8b55e0 mov edx,dword ptr [ebp-20h] ; RegistrationNode 01152569 8b4214 mov eax,dword ptr [edx+14h] ; get TryLevel 0115256c 3b45d8 cmp eax,dword ptr [ebp-28h] ; TryLevel == eax 0115256f 7416 je MSVCR100D!_except_handler4_common+0x147 (01152587) |
给这个 EH4_GlobalUnwind2() 传递两个参数:
- prev_struct
- ExceptionRcord
这两个都是指针值,MSVCR100D!_EH4_GlobalUnwind2() 代码如下:
MSVCR100D!_EH4_GlobalUnwind2: 0110d932 55 push ebp 0110d933 8bec mov ebp,esp 0110d935 53 push ebx 0110d936 56 push esi 0110d937 57 push edi 0110d938 6a00 push 0 0110d93a 52 push edx 0110d93b 6846d91001 push offset MSVCR100D!_EH4_GlobalUnwind2+0x14 (0110d946) 0110d940 51 push ecx 0110d941 e8f6ca0200 call MSVCR100D!RtlUnwind (0113a43c) 0110d946 5f pop edi 0110d947 5e pop esi 0110d948 5b pop ebx 0110d949 5d pop ebp 0110d94a c3 ret |
MSVCR100D!_EH4_GlobalUnwind2() 是一个转接层,最终的工作交由 MSVCR100D!RtlUnwind() 去执行,给 MSVCR100D!RtlUnwind() 传递 4 个参数:
它看起来像下面:
RtlUnwind(_EH4_EXCEPTION_REGISTRATION_RECORD *, void *, _EXCEPTION_RECORD *, |