Changeset 21474 for trunk/src


Ignore:
Timestamp:
Nov 14, 2010, 12:41:50 AM (15 years ago)
Author:
dmik
Message:

kernel32/SEH: Added support for setjmp()/longjmp() within the try block. See #26.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/seh/sehutil.s

    r21431 r21474  
    1111/*
    1212 * int __seh_handler(PEXCEPTION_RECORD pRec,
    13  *                   struct ___seh_PEXCEPTION_FRAME *pFrame,
     13 *                   struct ___seh_EXCEPTION_FRAME *pFrame,
    1414 *                   PCONTEXT pContext, PVOID)
    1515 *
     
    1818 *
    1919 * NOTE: This is a heavily platform specific stuff. The code depends on the
    20  * struct ___seh_PEXCEPTION_FRAME layout so be very careful and keep both
     20 * struct ___seh_EXCEPTION_FRAME layout so be very careful and keep both
    2121 * in sync!
    2222 *
     
    3333     * 12(%ebp) - pFrame
    3434     * 16(%ebp) - pContext
    35      * 20(%ebp) - pVOid
     35     * 20(%ebp) - pVoid
    3636     */
    3737
     
    4040    pushl %edi
    4141    pushl %esi
     42
     43    pushl %fs
     44    popl %eax
     45    andl $0x0000FFFF, %eax
     46    cmpl $Dos32TIB, %eax /* Running along the OS/2 chain? */
     47    jne ___seh_handler_Win32 /* No, assume the Win32 chain */
     48
     49    movl 8(%ebp), %eax
     50    movl 0(%eax), %eax
     51    cmpl $0xC0000026, %eax  /* XCPT_UNWIND? */
     52    je ___seh_handler_OS2_Unwind
     53
     54    /* restore the OS/2 chain in our frame */
     55    movl 12(%ebp), %eax
     56    movl 44(%eax), %ecx /* pPrevFrameOS2 */
     57    movl %ecx, 0(%eax)  /* pPrev */
     58
     59    xorl %eax, %eax  /* return XCPT_CONTINUE_SEARCH (0) */
     60    jmp ___seh_handler_Return
     61
     62___seh_handler_OS2_Unwind:
     63
     64    /* restore the Win32 chain in our frame */
     65    movl 12(%ebp), %eax
     66    movl 60(%eax), %ecx /* pPrevFrameWin32 */
     67    movl %ecx, 0(%eax)  /* pPrev */
     68
     69    /* unwind the Win32 chain including our frame as someone's definitely
     70     * jumping outside it if we're being unwound */
     71    pushl %fs
     72    pushl $1
     73    call _SetWin32TIB@4 /* _stdcall, rtl, callee cleans stack */
     74    pushl $0        /* DWORD (unused) */
     75    pushl $0        /* PEXCEPTION_RECORD */
     76    pushl $0        /* LPVOID (unused) */
     77    pushl %ecx      /* PEXCEPTION_FRAME */
     78    call _RtlUnwind@16 /* _stdcall, rtl, callee cleans stack */
     79    popl %fs
     80
     81    /* restore the OS/2 chain in our frame */
     82    movl 12(%ebp), %eax
     83    movl 44(%eax), %ecx /* pPrevFrameOS2 */
     84    movl %ecx, 0(%eax)  /* pPrev */
     85
     86    xor %eax, %eax  /* return code is irrelevant for XCPT_UNWIND */
     87    jmp ___seh_handler_Return
     88
     89___seh_handler_Win32:
     90
     91    /* restore the Win32 chain in our frame */
     92    movl 12(%ebp), %eax
     93    movl 60(%eax), %ecx /* pPrevFrameWin32 */
     94    movl %ecx, 0(%eax)  /* pPrev */
    4295
    4396    /* skip EH_UNWINDING calls (for compatibility with MSVC) */
     
    140193    jmp ___seh_handler_Return
    1411941:
    142     /* Assume EXCEPTION_CONTINUE_SEARCH (0) */
     195    /* assume EXCEPTION_CONTINUE_SEARCH (0) */
    143196    movl $1, %eax /* ExceptionContinueSearch */
    144197    jmp ___seh_handler_Return
     
    146199___seh_handler_Unwind:
    147200
    148     /* Unwind Win32 exception chain up to ours */
     201    /* unwind Win32 exception chain up to ours */
    149202    pushl $0        /* DWORD (unused) */
    150203    pushl 8(%ebp)   /* PEXCEPTION_RECORD */
     
    153206    call _RtlUnwind@16 /* _stdcall, rtl, callee cleans stack */
    154207
    155     /* Unwind OS/2 exception chain */
    156     movl 12(%ebp), %eax
     208    /* restore the OS/2 chain in our frame */
     209    movl 12(%ebp), %eax
     210    movl 44(%eax), %ecx /* pPrevFrameOS2 */
     211    movl %ecx, 0(%eax)  /* pPrev */
     212
     213    /* unwind OS/2 exception chain up to ours */
     214    pushl %fs
     215    pushl $Dos32TIB
     216    popl %fs
    157217    pushl $0        /* PEXCEPTIONREPORTRECORD */
    158218    pushl $1f       /* PVOID pTargetIP */
    159     pushl 44(%eax)  /* PEXCEPTIONREGISTRATIONRECORD */
     219    pushl 12(%ebp)  /* PEXCEPTIONREGISTRATIONRECORD */
    160220    call _DosUnwindException /* _syscall, rtl, caller cleans stack */
    1612211:
    162222    addl $12, %esp
     223    popl %fs
     224
     225    /* restore the Win32 chain in our frame */
     226    movl 12(%ebp), %eax
     227    movl 60(%eax), %ecx /* pPrevFrameWin32 */
     228    movl %ecx, 0(%eax)  /* pPrev */
    163229
    164230    /* restore __try/__except context */
Note: See TracChangeset for help on using the changeset viewer.