Changeset 21431 for trunk/src


Ignore:
Timestamp:
Aug 27, 2010, 1:54:20 PM (15 years ago)
Author:
dmik
Message:

SEH: A better implementation of r21427, doesn't need separate allocations on heap for EXCEPTION_RECORD and CONTEXT.

Location:
trunk/src/kernel32/seh
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/seh/makefile

    r21427 r21431  
    2929#
    3030OBJS = \
    31 $(OBJDIR)\seh.obj \
    3231$(OBJDIR)\sehutil.obj
    3332
  • trunk/src/kernel32/seh/sehutil.s

    r21427 r21431  
    6262    movl %ecx, 4(%esp) /* save length */
    6363
     64    /* check that EXCEPTION_RECORD and CONTEXT are on our stack
     65     * and save their offsets in pFrame */
     66    movl 8(%ebp), %eax
     67    subl %esp, %eax
     68    jl ___seh_handler_Error /* Invalid stack! */
     69    cmpl %ecx, %eax
     70    jg ___seh_handler_Error /* Invalid stack! */
     71    movl %eax, 48(%ebx) /* pFrame->Pointers.ExceptionRecord */
     72
     73    movl 16(%ebp), %eax
     74    subl %esp, %eax
     75    jl ___seh_handler_Error /* Invalid stack! */
     76    cmpl %ecx, %eax
     77    jg ___seh_handler_Error /* Invalid stack! */
     78    movl %eax, 52(%ebx) /* pFrame->Pointers.ContextRecord */
     79
    6480    /* save the handler's stack on heap */
    6581    movl %ecx, %eax /* size_t */
     
    7692    rep movsb
    7793
    78     /* prepare a jump to the filter callback */
    79     subl $12, %esp
    80     movl 12(%ebp), %ebx
    81     movl %ebx, 0(%esp)
    82     movl 8(%ebp), %ebx
    83     movl %ebx, 4(%esp)
    84     movl 16(%ebp), %ebx
    85     movl %ebx, 8(%esp)
    86     call ___seh_makePointers  /* _cdecl, rtl, caller cleans stack */
    87     addl $12, %esp
     94    /* correct Pointers offsets to point to the saved stack on heap */
     95    movl 16(%ebx), %eax /* pFrame->pHandlerContext */
     96    addl %eax, 48(%ebx) /* pFrame->Pointers.ExceptionRecord */
     97    addl %eax, 52(%ebx) /* pFrame->Pointers.ContextRecord */
    8898
    8999    /* restore __try/__catch context */
     
    113123    popl %ebp
    114124
    115     /* free heap blocks */
    116     movl 52(%ebx), %eax /* pFrame->Pointers.ContextRecord */
    117     subl $4, %esp
    118     movl %eax, 0(%esp)
    119     call odin_free /* _Optlink, rtl, EAX/EDX/ECX-in, caller cleans stack */
    120     addl $4, %esp
    121 
    122     movl 48(%ebx), %eax /* pFrame->Pointers.ExceptionRecord */
    123     subl $4, %esp
    124     movl %eax, 0(%esp)
    125     call odin_free /* _Optlink, rtl, EAX/EDX/ECX-in, caller cleans stack */
    126     addl $4, %esp
    127 
     125    /* free heap block */
    128126    movl 16(%ebx), %eax /* pFrame->pHandlerContext */
    129127    subl $4, %esp
Note: See TracChangeset for help on using the changeset viewer.