mirror of
https://github.com/reactos/reactos.git
synced 2024-09-03 09:09:19 +00:00
[PSEH]
- Make _except_handler3 human-readable CORE-12283 svn path=/trunk/; revision=73145
This commit is contained in:
parent
7eea8b9401
commit
2c8f2ae901
|
@ -9,6 +9,7 @@
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
|
#include <ks386.inc>
|
||||||
|
|
||||||
#define DISPOSITION_DISMISS 0
|
#define DISPOSITION_DISMISS 0
|
||||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||||
|
@ -17,6 +18,16 @@
|
||||||
#define EXCEPTION_EXIT_UNWIND 4
|
#define EXCEPTION_EXIT_UNWIND 4
|
||||||
#define EXCEPTION_UNWINDING 2
|
#define EXCEPTION_UNWINDING 2
|
||||||
|
|
||||||
|
/* See seh_prolog.s */
|
||||||
|
SEH_FRAME_NewEsp = 0 /* 0x00 */
|
||||||
|
SEH_FRAME_unused = 4 /* 0x04 */
|
||||||
|
SEH_FRAME_PreviousRecord = 8 /* 0x08 */
|
||||||
|
SEH_FRAME_Handler = 12 /* 0x0c */
|
||||||
|
SEH_FRAME_SEHTable = 16 /* 0x10 */
|
||||||
|
SEH_FRAME_Disable = 20 /* 0x14 */
|
||||||
|
SEH_FRAME_OriginalEbp = 24 /* 0x18 */
|
||||||
|
SEH_FRAME_Size = 28 /* 0x1c */
|
||||||
|
|
||||||
|
|
||||||
EXTERN _RtlUnwind@16:PROC
|
EXTERN _RtlUnwind@16:PROC
|
||||||
|
|
||||||
|
@ -301,7 +312,9 @@ except_return2:
|
||||||
|
|
||||||
|
|
||||||
__except_handler3:
|
__except_handler3:
|
||||||
|
PARAM_ExceptionRecord = 8
|
||||||
|
PARAM_RegistrationFrame = 12
|
||||||
|
PARAM_Context = 16
|
||||||
/* Setup stack and save volatiles */
|
/* Setup stack and save volatiles */
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
@ -315,23 +328,23 @@ __except_handler3:
|
||||||
cld
|
cld
|
||||||
|
|
||||||
/* Get exception registration and record */
|
/* Get exception registration and record */
|
||||||
mov ebx, [ebp+12]
|
mov ebx, [ebp+PARAM_RegistrationFrame]
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+PARAM_ExceptionRecord]
|
||||||
|
|
||||||
/* Check if this is an unwind */
|
/* Check if this is an unwind */
|
||||||
test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING
|
test dword ptr [eax+EXCEPTION_RECORD_EXCEPTION_FLAGS], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING
|
||||||
jnz except_unwind3
|
jnz except_unwind3
|
||||||
|
|
||||||
/* Save exception pointers structure */
|
/* Save exception pointers structure */
|
||||||
mov [ebp-8], eax
|
mov [ebp-8+EXCEPTION_POINTERS_EXCEPTION_RECORD], eax
|
||||||
mov eax, [ebp+16]
|
mov eax, [ebp+PARAM_Context]
|
||||||
mov [ebp-4], eax
|
mov [ebp-8+EXCEPTION_POINTERS_CONTEXT_RECORD], eax
|
||||||
lea eax, [ebp-8]
|
lea eax, [ebp-8]
|
||||||
mov [ebx-4], eax
|
mov [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_unused], eax
|
||||||
|
|
||||||
/* Get the try level and scope table */
|
/* Get the try level and scope table */
|
||||||
mov esi, [ebx+12]
|
mov esi, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_Disable]
|
||||||
mov edi, [ebx+8]
|
mov edi, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_SEHTable]
|
||||||
|
|
||||||
/* FIXME: Validate the SEH exception */
|
/* FIXME: Validate the SEH exception */
|
||||||
|
|
||||||
|
@ -343,13 +356,13 @@ except_loop3:
|
||||||
/* Check if this is the termination handler */
|
/* Check if this is the termination handler */
|
||||||
lea ecx, [esi+esi*2]
|
lea ecx, [esi+esi*2]
|
||||||
mov eax, [edi+ecx*4+4]
|
mov eax, [edi+ecx*4+4]
|
||||||
or eax, eax
|
test eax, eax
|
||||||
jz except_continue3
|
jz except_continue3
|
||||||
|
|
||||||
/* Save registers clear them all */
|
/* Save registers clear them all */
|
||||||
push esi
|
push esi
|
||||||
push ebp
|
push ebp
|
||||||
lea ebp, [ebx+16]
|
lea ebp, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_OriginalEbp]
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
|
@ -362,19 +375,19 @@ except_loop3:
|
||||||
pop esi
|
pop esi
|
||||||
|
|
||||||
/* Restore ebx and check the result */
|
/* Restore ebx and check the result */
|
||||||
mov ebx, [ebp+12]
|
mov ebx, [ebp+PARAM_RegistrationFrame]
|
||||||
or eax, eax
|
test eax, eax
|
||||||
jz except_continue3
|
jz except_continue3
|
||||||
js except_dismiss3
|
js except_dismiss3
|
||||||
|
|
||||||
/* So this is an accept, call the termination handlers */
|
/* So this is an accept, call the termination handlers */
|
||||||
mov edi, [ebx+8]
|
mov edi, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_SEHTable]
|
||||||
push ebx
|
push ebx
|
||||||
call __global_unwind2
|
call __global_unwind2
|
||||||
add esp, 4
|
add esp, 4
|
||||||
|
|
||||||
/* Restore ebp */
|
/* Restore ebp */
|
||||||
lea ebp, [ebx+16]
|
lea ebp, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_OriginalEbp]
|
||||||
|
|
||||||
/* Do local unwind */
|
/* Do local unwind */
|
||||||
push esi
|
push esi
|
||||||
|
@ -387,7 +400,7 @@ except_loop3:
|
||||||
/* Set new try level */
|
/* Set new try level */
|
||||||
lea ecx, [esi+esi*2]
|
lea ecx, [esi+esi*2]
|
||||||
mov eax, [edi+ecx*4]
|
mov eax, [edi+ecx*4]
|
||||||
mov [ebx+12], eax
|
mov [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_Disable], eax
|
||||||
|
|
||||||
/* Clear registers and call except handler */
|
/* Clear registers and call except handler */
|
||||||
mov eax, [edi+ecx*4+8]
|
mov eax, [edi+ecx*4+8]
|
||||||
|
@ -400,7 +413,7 @@ except_loop3:
|
||||||
|
|
||||||
except_continue3:
|
except_continue3:
|
||||||
/* Reload try level and except again */
|
/* Reload try level and except again */
|
||||||
mov edi, [ebx+8]
|
mov edi, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_SEHTable]
|
||||||
lea ecx, [esi+esi*2]
|
lea ecx, [esi+esi*2]
|
||||||
mov esi, [edi+ecx*4]
|
mov esi, [edi+ecx*4]
|
||||||
jmp except_loop3
|
jmp except_loop3
|
||||||
|
@ -410,22 +423,20 @@ except_dismiss3:
|
||||||
mov eax, DISPOSITION_DISMISS
|
mov eax, DISPOSITION_DISMISS
|
||||||
jmp except_return3
|
jmp except_return3
|
||||||
|
|
||||||
except_search3:
|
|
||||||
/* Continue searching */
|
|
||||||
mov eax, DISPOSITION_CONTINUE_SEARCH
|
|
||||||
jmp except_return3
|
|
||||||
|
|
||||||
/* Do local unwind */
|
/* Do local unwind */
|
||||||
except_unwind3:
|
except_unwind3:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, [ebx+16]
|
mov ebp, [ebx-SEH_FRAME_PreviousRecord+SEH_FRAME_OriginalEbp]
|
||||||
push -1
|
push -1
|
||||||
push ebx
|
push ebx
|
||||||
call __local_unwind2
|
call __local_unwind2
|
||||||
add esp, 8
|
add esp, 8
|
||||||
|
|
||||||
/* Retore EBP and set return disposition */
|
/* Restore EBP */
|
||||||
pop ebp
|
pop ebp
|
||||||
|
|
||||||
|
except_search3:
|
||||||
|
/* Continue searching */
|
||||||
mov eax, DISPOSITION_CONTINUE_SEARCH
|
mov eax, DISPOSITION_CONTINUE_SEARCH
|
||||||
|
|
||||||
except_return3:
|
except_return3:
|
||||||
|
|
Loading…
Reference in a new issue