[PSEH]
[reactos.git] / reactos / lib / pseh / i386 / pseh3_i386.S
index adab89c..69f8b75 100644 (file)
@@ -30,6 +30,10 @@ __SEH3$_RegisterFrameWithNonVolatiles:
     mov [eax + SEH3_REGISTRATION_FRAME_Esi], esi
     mov [eax + SEH3_REGISTRATION_FRAME_Edi], edi
 
+    /* Safe the return address */
+    mov ebx, [esp]
+    mov [eax + SEH3_REGISTRATION_FRAME_ReturnAddress], ebx
+
 .global __SEH3$_RegisterFrameWithStackLayout
 __SEH3$_RegisterFrameWithStackLayout:
 
@@ -79,6 +83,10 @@ __SEH3$_RegisterTryLevelWithNonVolatiles:
     mov [eax + SEH3_REGISTRATION_FRAME_Esi], esi
     mov [eax + SEH3_REGISTRATION_FRAME_Edi], edi
 
+    /* Safe the return address */
+    mov ebx, [esp]
+    mov [eax + SEH3_REGISTRATION_FRAME_ReturnAddress], ebx
+
 .global __SEH3$_RegisterTryLevelWithStackLayout
 __SEH3$_RegisterTryLevelWithStackLayout:
 
@@ -128,22 +136,26 @@ __SEH3$_InvokeEmbeddedFilterFromRegistration:
     mov edi, [eax + SEH3_REGISTRATION_FRAME_Edi]
     mov ebp, [eax + SEH3_REGISTRATION_FRAME_Ebp]
 
-    jmp __SEH3$_InvokeEmbeddedFilter2
+    /* Calculate the size of the temp stack frame region */
+    mov ecx, [eax + SEH3_REGISTRATION_FRAME_AllocaFrame]
+    sub ecx, [eax + SEH3_REGISTRATION_FRAME_Esp]
 
-    /* Get the saved stack pointer */
-    mov edx, [eax + SEH3_REGISTRATION_FRAME_Esp]
+    /* Put the return address on the stack */
+    push offset __SEH3$_InvokeEmbeddedFilterReturn
 
-    xor eax, eax
-    inc eax
-    call [edx]
+    /* Save the current stack pointer in the AllocaFrame member */
+    mov [eax + SEH3_REGISTRATION_FRAME_AllocaFrame], esp
 
-    /* Restore the current non-volatiles */
-    pop edi
-    pop esi
-    pop ebx
-    pop ebp
+    /* Allocate enough temp stack space on the stack */
+    sub esp, ecx
 
-    ret
+    /* Get the return address that was saved when registering the frame */
+    mov edx, [eax + SEH3_REGISTRATION_FRAME_ReturnAddress]
+
+    /* Jump into the filter or finally function */
+    xor eax, eax
+    inc eax
+    jmp edx
 
 
 .global __SEH3$_InvokeEmbeddedFilter
@@ -157,7 +169,7 @@ __SEH3$_InvokeEmbeddedFilter:
 
     /* Load ebp from the registration invocation */
     mov ebp, [eax + SEH3_REGISTRATION_FRAME_Ebp]
-__SEH3$_InvokeEmbeddedFilter2:
+
     /* Calculate the size of the temp stack frame region */
     mov ecx, [eax + SEH3_REGISTRATION_FRAME_AllocaFrame]
     sub ecx, [eax + SEH3_REGISTRATION_FRAME_Esp]