Author: fireball Date: Sun Nov 11 18:47:21 2007 New Revision: 30359
URL: http://svn.reactos.org/svn/reactos?rev=30359&view=rev Log: - After bugfixing, more complete except_nt exception handling implementation could be used, so get rid of the old one and thus code duplication. - Move cpp/cppexcept.c to /except directory, and add a specific note in README.WINE that those files are shared with Wine. - I moved PowerPC stubs too, but it will most probably break anyway, due to more missing stubs, my apologize. See issue #2371 for more details.
Added: trunk/reactos/lib/sdk/crt/except/cpp.c - copied unchanged from r30350, trunk/reactos/lib/sdk/crt/wine/cpp.c trunk/reactos/lib/sdk/crt/except/cppexcept.c - copied unchanged from r30350, trunk/reactos/lib/sdk/crt/wine/cppexcept.c trunk/reactos/lib/sdk/crt/except/i386/chkstk_asm.s - copied unchanged from r30350, trunk/reactos/lib/sdk/crt/except_nt/i386/chkstk_asm.s trunk/reactos/lib/sdk/crt/except/i386/seh.s (contents, props changed) - copied, changed from r30353, trunk/reactos/lib/sdk/crt/except_nt/i386/seh.s trunk/reactos/lib/sdk/crt/except/powerpc/ - copied from r30350, trunk/reactos/lib/sdk/crt/except_nt/powerpc/ Removed: trunk/reactos/lib/sdk/crt/except/exhand2.c trunk/reactos/lib/sdk/crt/except_nt/ trunk/reactos/lib/sdk/crt/wine/cpp.c trunk/reactos/lib/sdk/crt/wine/cppexcept.c Modified: trunk/reactos/lib/sdk/crt/crt.rbuild trunk/reactos/lib/sdk/crt/except/abnorter.c trunk/reactos/lib/sdk/crt/except/i386/unwind.c trunk/reactos/lib/sdk/crt/libcntpr.rbuild trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/lib/sdk/crt/crt.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.rbuild?rev=... ============================================================================== --- trunk/reactos/lib/sdk/crt/crt.rbuild (original) +++ trunk/reactos/lib/sdk/crt/crt.rbuild Sun Nov 11 18:47:21 2007 @@ -40,13 +40,20 @@ </directory> <directory name="except"> <file>abnorter.c</file> - <file>exhand2.c</file> + <file>cpp.c</file> + <file>cppexcept.c</file> <file>matherr.c</file> <if property="ARCH" value="i386"> <directory name="i386"> <file>prolog.s</file> <file>seh.s</file> <file>unwind.c</file> + </directory> + </if> + <if property="ARCH" value="powerpc"> + <directory name="powerpc"> + <file>seh.s</file> + <file>chkstk_asm.s</file> </directory> </if> <file>xcptfil.c</file> @@ -475,8 +482,6 @@ <file>wlasttok.c</file> </directory> <directory name="wine"> - <file>cpp.c</file> - <file>cppexcept.c</file> <file>heap.c</file> <file>scanf.c</file> <file>thread.c</file>
Modified: trunk/reactos/lib/sdk/crt/except/abnorter.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/abnorter... ============================================================================== --- trunk/reactos/lib/sdk/crt/except/abnorter.c (original) +++ trunk/reactos/lib/sdk/crt/except/abnorter.c Sun Nov 11 18:47:21 2007 @@ -1,16 +1,1 @@ #include <precomp.h> - -#ifdef __GNUC__ - -/* - * @unimplemented - */ -int _abnormal_termination(void) -{ - printf("Abnormal Termination\n"); -// return AbnormalTermination(); - return 0; -} - -#else -#endif
Removed: trunk/reactos/lib/sdk/crt/except/exhand2.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/exhand2.... ============================================================================== --- trunk/reactos/lib/sdk/crt/except/exhand2.c (original) +++ trunk/reactos/lib/sdk/crt/except/exhand2.c (removed) @@ -1,33 +1,0 @@ -#include <precomp.h> -#include <excpt.h> - -#ifdef __GNUC__ -#else -ULONG DbgPrint(PCH Format,...) -{ - return 0; -} -#endif - -VOID STDCALL -MsvcrtDebug(ULONG Value) -{ - //DbgPrint("MsvcrtDebug 0x%.08x\n", Value); -} - -struct _EXCEPTION_RECORD; -struct _CONTEXT; - -/* - * @implemented - */ -EXCEPTION_DISPOSITION -_except_handler2( -struct _EXCEPTION_RECORD *ExceptionRecord, -void *Frame, -struct _CONTEXT *ContextRecord, -void *DispatcherContext) -{ - //printf("_except_handler2()\n"); - return 0; -}
Copied: trunk/reactos/lib/sdk/crt/except/i386/seh.s (from r30353, trunk/reactos/lib/sdk/crt/except_nt/i386/seh.s) URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/i386/seh... ============================================================================== --- trunk/reactos/lib/sdk/crt/except_nt/i386/seh.s (original) +++ trunk/reactos/lib/sdk/crt/except/i386/seh.s Sun Nov 11 18:47:21 2007 @@ -1,468 +1,468 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS CRT - * FILE: lib/crt/misc/i386/seh.S - * PURPOSE: SEH Support for the CRT - * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) - */ - -/* INCLUDES ******************************************************************/ - -#include <ndk/asm.h> -.intel_syntax noprefix - -#define DISPOSITION_DISMISS 0 -#define DISPOSITION_CONTINUE_SEARCH 1 -#define DISPOSITION_COLLIDED_UNWIND 3 - -/* GLOBALS *******************************************************************/ - -.globl __global_unwind2 -.globl __local_unwind2 -.globl __abnormal_termination -.globl __except_handler2 -.globl __except_handler3 - -/* FUNCTIONS *****************************************************************/ - -.func unwind_handler -_unwind_handler: - - /* Check if we were unwinding and continue search if not */ - mov ecx, [esp+4] - test dword ptr [ecx+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING - mov eax, DISPOSITION_CONTINUE_SEARCH - jz unwind_handler_return - - /* We have a collision, do a local unwind */ - mov eax, [esp+20] - push ebp - mov ebp, [eax+16] - mov edx, [eax+40] - push edx - mov edx, [eax+36] - push edx - call __local_unwind2 - add esp, 8 - pop ebp - - /* Set new try level */ - mov eax, [esp+8] - mov edx, [esp+16] - mov [edx], eax - - /* Return collided unwind */ - mov eax, DISPOSITION_COLLIDED_UNWIND - -unwind_handler_return: - ret -.endfunc - -.func _global_unwind2 -__global_unwind2: - - /* Create stack and save all registers */ - push ebp - mov ebp, esp - push ebx - push esi - push edi - push ebp - - /* Call unwind */ - push 0 - push 0 - push glu_return - push [ebp+8] - call _RtlUnwind@16 - -glu_return: - /* Restore registers and return */ - pop ebp - pop edi - pop esi - pop ebx - mov esp, ebp - pop ebp - ret -.endfunc - -.func _abnormal_termination -__abnormal_termination: - - /* Assume false */ - xor eax, eax - - /* Check if the handler is the unwind handler */ - mov ecx, fs:0 - cmp dword ptr [ecx+4], offset _unwind_handler - jne short ab_return - - /* Get the try level */ - mov edx, [ecx+12] - mov edx, [edx+12] - - /* Compare it */ - cmp [ecx+8], edx - jne ab_return - - /* Return true */ - mov eax, 1 - - /* Return */ -ab_return: - ret -.endfunc - -.func _local_unwind2 -__local_unwind2: - - /* Save volatiles */ - push ebx - push esi - push edi - - /* Get the exception registration */ - mov eax, [esp+16] - - /* Setup SEH to protect the unwind */ - push ebp - push eax - push -2 - push offset _unwind_handler - push fs:0 - mov fs:0, esp - -unwind_loop: - /* Get the exception registration and try level */ - mov eax, [esp+36] - mov ebx, [eax+8] - mov esi, [eax+12] - - /* Validate the unwind */ - cmp esi, -1 - je unwind_return - cmp dword ptr [esp+40], -1 - je unwind_ok - cmp esi, [esp+40] - jbe unwind_return - -unwind_ok: - /* Get the new enclosing level and save it */ - lea esi, [esi+esi*2] - mov ecx, [ebx+esi*4] - mov [esp+8], ecx - mov [eax+12], ecx - - /* Check the filter type */ - cmp dword ptr [ebx+esi*4+4], 0 - jnz __NLG_Return2 - - /* FIXME: NLG Notification */ - - /* Call the handler */ - call dword ptr [ebx+esi*4+8] - -__NLG_Return2: - /* Unwind again */ - jmp unwind_loop - -unwind_return: - /* Cleanup SEH */ - pop fs:0 - add esp, 16 - pop edi - pop esi - pop ebx - ret -.endfunc - -.func _except_handler2 -__except_handler2: - - /* Setup stack and save volatiles */ - push ebp - mov ebp, esp - sub esp, 8 - push ebx - push esi - push edi - push ebp - - /* Clear direction flag */ - cld - - /* Get exception registration and record */ - mov ebx, [ebp+12] - mov eax, [ebp+8] - - /* Check if this is an unwind */ - test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING - jnz except_unwind2 - - /* Save exception pointers structure */ - mov [ebp-8], eax - mov eax, [ebp+16] - mov [ebp-4], eax - lea eax, [ebp-8] - mov [ebx+20], eax - - /* Get the try level and scope table */ - mov esi, [ebx+12] - mov edi, [ebx+8] - -except_loop2: - /* Validate try level */ - cmp esi, -1 - je except_search2 - - /* Check if this is the termination handler */ - lea ecx, [esi+esi*2] - cmp dword ptr [edi+ecx*4+4], 0 - jz except_continue2 - - /* Save registers and call filter, then restore them */ - push esi - push ebp - mov ebp, [ebx+16] - call dword ptr [edi+ecx*4+4] - pop ebp - pop esi - - /* Restore ebx and check the result */ - mov ebx, [ebp+12] - or eax, eax - jz except_continue2 - js except_dismiss2 - - /* So this is an accept, call the termination handlers */ - mov edi, [ebx+8] - push ebx - call __global_unwind2 - add esp, 4 - - /* Restore ebp */ - mov ebp, [ebx+16] - - /* Do local unwind */ - push esi - push ebx - call __local_unwind2 - add esp, 8 - - /* Set new try level */ - lea ecx, [esi+esi*2] - mov eax, [edi+ecx*4] - mov [ebx+12], eax - - /* Call except handler */ - call [edi+ecx*4+8] - -except_continue2: - /* Reload try level and except again */ - mov edi, [ebx+8] - lea ecx, [esi+esi*2] - mov esi, [edi+ecx*4] - jmp except_loop2 - -except_dismiss2: - /* Dismiss it */ - mov eax, DISPOSITION_DISMISS - jmp except_return2 - -except_search2: - /* Continue searching */ - mov eax, DISPOSITION_CONTINUE_SEARCH - jmp except_return2 - - /* Do local unwind */ -except_unwind2: - push ebp - mov ebp, [ebx+16] - push -1 - push ebx - call __local_unwind2 - add esp, 8 - - /* Retore EBP and set return disposition */ - pop ebp - mov eax, DISPOSITION_CONTINUE_SEARCH - -except_return2: - /* Restore registers and stack */ - pop ebp - pop edi - pop esi - pop ebx - mov esp, ebp - pop ebp - ret -.endfunc - -.func _except_handler3 -__except_handler3: - - /* Setup stack and save volatiles */ - push ebp - mov ebp, esp - sub esp, 8 - push ebx - push esi - push edi - push ebp - - /* Clear direction flag */ - cld - - /* Get exception registration and record */ - mov ebx, [ebp+12] - mov eax, [ebp+8] - - /* Check if this is an unwind */ - test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING - jnz except_unwind3 - - /* Save exception pointers structure */ - mov [ebp-8], eax - mov eax, [ebp+16] - mov [ebp-4], eax - lea eax, [ebp-8] - mov [ebx-4], eax - - /* Get the try level and scope table */ - mov esi, [ebx+12] - mov edi, [ebx+8] - - /* FIXME: Validate the SEH exception */ - -except_loop3: - /* Validate try level */ - cmp esi, -1 - je except_search3 - - /* Check if this is the termination handler */ - lea ecx, [esi+esi*2] - mov eax, [edi+ecx*4+4] - or eax, eax - jz except_continue3 - - /* Save registers clear them all */ - push esi - push ebp - lea ebp, [ebx+16] - xor ebx, ebx - xor ecx, ecx - xor edx, edx - xor esi, esi - xor edi, edi - - /* Call the filter and restore our registers */ - call eax - pop ebp - pop esi - - /* Restore ebx and check the result */ - mov ebx, [ebp+12] - or eax, eax - jz except_continue3 - js except_dismiss3 - - /* So this is an accept, call the termination handlers */ - mov edi, [ebx+8] - push ebx - call __global_unwind2 - add esp, 4 - - /* Restore ebp */ - lea ebp, [ebx+16] - - /* Do local unwind */ - push esi - push ebx - call __local_unwind2 - add esp, 8 - - /* FIXME: Do NLG Notification */ - - /* Set new try level */ - lea ecx, [esi+esi*2] - mov eax, [edi+ecx*4] - mov [ebx+12], eax - - /* Clear registers and call except handler */ - mov eax, [edi+ecx*4+8] - xor ebx, ebx - xor ecx, ecx - xor edx, edx - xor esi, esi - xor edi, edi - call eax - -except_continue3: - /* Reload try level and except again */ - mov edi, [ebx+8] - lea ecx, [esi+esi*2] - mov esi, [edi+ecx*4] - jmp except_loop3 - -except_dismiss3: - /* Dismiss it */ - mov eax, DISPOSITION_DISMISS - jmp except_return3 - -except_search3: - /* Continue searching */ - mov eax, DISPOSITION_CONTINUE_SEARCH - jmp except_return3 - - /* Do local unwind */ -except_unwind3: - push ebp - mov ebp, [ebx+16] - push -1 - push ebx - call __local_unwind2 - add esp, 8 - - /* Retore EBP and set return disposition */ - pop ebp - mov eax, DISPOSITION_CONTINUE_SEARCH - -except_return3: - /* Restore registers and stack */ - pop ebp - pop edi - pop esi - pop ebx - mov esp, ebp - pop ebp - ret -.endfunc - -// -// -// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME -// -// -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 -_RtlpGetStackLimits@8: - - /* Get the current thread */ - mov eax, [fs:KPCR_CURRENT_THREAD] - - /* Get the stack limits */ - mov ecx, [eax+KTHREAD_STACK_LIMIT] - mov edx, [eax+KTHREAD_INITIAL_STACK] - sub edx, SIZEOF_FX_SAVE_AREA - - /* Return them */ - mov eax, [esp+4] - mov [eax], ecx - - mov eax, [esp+8] - mov [eax], edx - - /* return */ - ret 8 -.endfunc +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT + * FILE: lib/crt/misc/i386/seh.S + * PURPOSE: SEH Support for the CRT + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include <ndk/asm.h> +.intel_syntax noprefix + +#define DISPOSITION_DISMISS 0 +#define DISPOSITION_CONTINUE_SEARCH 1 +#define DISPOSITION_COLLIDED_UNWIND 3 + +/* GLOBALS *******************************************************************/ + +.globl __global_unwind2 +.globl __local_unwind2 +.globl __abnormal_termination +.globl __except_handler2 +.globl __except_handler3 + +/* FUNCTIONS *****************************************************************/ + +.func unwind_handler +_unwind_handler: + + /* Check if we were unwinding and continue search if not */ + mov ecx, [esp+4] + test dword ptr [ecx+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + mov eax, DISPOSITION_CONTINUE_SEARCH + jz unwind_handler_return + + /* We have a collision, do a local unwind */ + mov eax, [esp+20] + push ebp + mov ebp, [eax+16] + mov edx, [eax+40] + push edx + mov edx, [eax+36] + push edx + call __local_unwind2 + add esp, 8 + pop ebp + + /* Set new try level */ + mov eax, [esp+8] + mov edx, [esp+16] + mov [edx], eax + + /* Return collided unwind */ + mov eax, DISPOSITION_COLLIDED_UNWIND + +unwind_handler_return: + ret +.endfunc + +.func _global_unwind2 +__global_unwind2: + + /* Create stack and save all registers */ + push ebp + mov ebp, esp + push ebx + push esi + push edi + push ebp + + /* Call unwind */ + push 0 + push 0 + push glu_return + push [ebp+8] + call _RtlUnwind@16 + +glu_return: + /* Restore registers and return */ + pop ebp + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +.func _abnormal_termination +__abnormal_termination: + + /* Assume false */ + xor eax, eax + + /* Check if the handler is the unwind handler */ + mov ecx, fs:0 + cmp dword ptr [ecx+4], offset _unwind_handler + jne short ab_return + + /* Get the try level */ + mov edx, [ecx+12] + mov edx, [edx+12] + + /* Compare it */ + cmp [ecx+8], edx + jne ab_return + + /* Return true */ + mov eax, 1 + + /* Return */ +ab_return: + ret +.endfunc + +.func _local_unwind2 +__local_unwind2: + + /* Save volatiles */ + push ebx + push esi + push edi + + /* Get the exception registration */ + mov eax, [esp+16] + + /* Setup SEH to protect the unwind */ + push ebp + push eax + push -2 + push offset _unwind_handler + push fs:0 + mov fs:0, esp + +unwind_loop: + /* Get the exception registration and try level */ + mov eax, [esp+36] + mov ebx, [eax+8] + mov esi, [eax+12] + + /* Validate the unwind */ + cmp esi, -1 + je unwind_return + cmp dword ptr [esp+40], -1 + je unwind_ok + cmp esi, [esp+40] + jbe unwind_return + +unwind_ok: + /* Get the new enclosing level and save it */ + lea esi, [esi+esi*2] + mov ecx, [ebx+esi*4] + mov [esp+8], ecx + mov [eax+12], ecx + + /* Check the filter type */ + cmp dword ptr [ebx+esi*4+4], 0 + jnz __NLG_Return2 + + /* FIXME: NLG Notification */ + + /* Call the handler */ + call dword ptr [ebx+esi*4+8] + +__NLG_Return2: + /* Unwind again */ + jmp unwind_loop + +unwind_return: + /* Cleanup SEH */ + pop fs:0 + add esp, 16 + pop edi + pop esi + pop ebx + ret +.endfunc + +.func _except_handler2 +__except_handler2: + + /* Setup stack and save volatiles */ + push ebp + mov ebp, esp + sub esp, 8 + push ebx + push esi + push edi + push ebp + + /* Clear direction flag */ + cld + + /* Get exception registration and record */ + mov ebx, [ebp+12] + mov eax, [ebp+8] + + /* Check if this is an unwind */ + test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + jnz except_unwind2 + + /* Save exception pointers structure */ + mov [ebp-8], eax + mov eax, [ebp+16] + mov [ebp-4], eax + lea eax, [ebp-8] + mov [ebx+20], eax + + /* Get the try level and scope table */ + mov esi, [ebx+12] + mov edi, [ebx+8] + +except_loop2: + /* Validate try level */ + cmp esi, -1 + je except_search2 + + /* Check if this is the termination handler */ + lea ecx, [esi+esi*2] + cmp dword ptr [edi+ecx*4+4], 0 + jz except_continue2 + + /* Save registers and call filter, then restore them */ + push esi + push ebp + mov ebp, [ebx+16] + call dword ptr [edi+ecx*4+4] + pop ebp + pop esi + + /* Restore ebx and check the result */ + mov ebx, [ebp+12] + or eax, eax + jz except_continue2 + js except_dismiss2 + + /* So this is an accept, call the termination handlers */ + mov edi, [ebx+8] + push ebx + call __global_unwind2 + add esp, 4 + + /* Restore ebp */ + mov ebp, [ebx+16] + + /* Do local unwind */ + push esi + push ebx + call __local_unwind2 + add esp, 8 + + /* Set new try level */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4] + mov [ebx+12], eax + + /* Call except handler */ + call [edi+ecx*4+8] + +except_continue2: + /* Reload try level and except again */ + mov edi, [ebx+8] + lea ecx, [esi+esi*2] + mov esi, [edi+ecx*4] + jmp except_loop2 + +except_dismiss2: + /* Dismiss it */ + mov eax, DISPOSITION_DISMISS + jmp except_return2 + +except_search2: + /* Continue searching */ + mov eax, DISPOSITION_CONTINUE_SEARCH + jmp except_return2 + + /* Do local unwind */ +except_unwind2: + push ebp + mov ebp, [ebx+16] + push -1 + push ebx + call __local_unwind2 + add esp, 8 + + /* Retore EBP and set return disposition */ + pop ebp + mov eax, DISPOSITION_CONTINUE_SEARCH + +except_return2: + /* Restore registers and stack */ + pop ebp + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +.func _except_handler3 +__except_handler3: + + /* Setup stack and save volatiles */ + push ebp + mov ebp, esp + sub esp, 8 + push ebx + push esi + push edi + push ebp + + /* Clear direction flag */ + cld + + /* Get exception registration and record */ + mov ebx, [ebp+12] + mov eax, [ebp+8] + + /* Check if this is an unwind */ + test dword ptr [eax+4], EXCEPTION_EXIT_UNWIND + EXCEPTION_UNWINDING + jnz except_unwind3 + + /* Save exception pointers structure */ + mov [ebp-8], eax + mov eax, [ebp+16] + mov [ebp-4], eax + lea eax, [ebp-8] + mov [ebx-4], eax + + /* Get the try level and scope table */ + mov esi, [ebx+12] + mov edi, [ebx+8] + + /* FIXME: Validate the SEH exception */ + +except_loop3: + /* Validate try level */ + cmp esi, -1 + je except_search3 + + /* Check if this is the termination handler */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4+4] + or eax, eax + jz except_continue3 + + /* Save registers clear them all */ + push esi + push ebp + lea ebp, [ebx+16] + xor ebx, ebx + xor ecx, ecx + xor edx, edx + xor esi, esi + xor edi, edi + + /* Call the filter and restore our registers */ + call eax + pop ebp + pop esi + + /* Restore ebx and check the result */ + mov ebx, [ebp+12] + or eax, eax + jz except_continue3 + js except_dismiss3 + + /* So this is an accept, call the termination handlers */ + mov edi, [ebx+8] + push ebx + call __global_unwind2 + add esp, 4 + + /* Restore ebp */ + lea ebp, [ebx+16] + + /* Do local unwind */ + push esi + push ebx + call __local_unwind2 + add esp, 8 + + /* FIXME: Do NLG Notification */ + + /* Set new try level */ + lea ecx, [esi+esi*2] + mov eax, [edi+ecx*4] + mov [ebx+12], eax + + /* Clear registers and call except handler */ + mov eax, [edi+ecx*4+8] + xor ebx, ebx + xor ecx, ecx + xor edx, edx + xor esi, esi + xor edi, edi + call eax + +except_continue3: + /* Reload try level and except again */ + mov edi, [ebx+8] + lea ecx, [esi+esi*2] + mov esi, [edi+ecx*4] + jmp except_loop3 + +except_dismiss3: + /* Dismiss it */ + mov eax, DISPOSITION_DISMISS + jmp except_return3 + +except_search3: + /* Continue searching */ + mov eax, DISPOSITION_CONTINUE_SEARCH + jmp except_return3 + + /* Do local unwind */ +except_unwind3: + push ebp + mov ebp, [ebx+16] + push -1 + push ebx + call __local_unwind2 + add esp, 8 + + /* Retore EBP and set return disposition */ + pop ebp + mov eax, DISPOSITION_CONTINUE_SEARCH + +except_return3: + /* Restore registers and stack */ + pop ebp + pop edi + pop esi + pop ebx + mov esp, ebp + pop ebp + ret +.endfunc + +// +// +// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME +// +// +.func RtlpGetStackLimits@8 +.globl _RtlpGetStackLimits@8 +_RtlpGetStackLimits@8: + + /* Get the current thread */ + mov eax, [fs:KPCR_CURRENT_THREAD] + + /* Get the stack limits */ + mov ecx, [eax+KTHREAD_STACK_LIMIT] + mov edx, [eax+KTHREAD_INITIAL_STACK] + sub edx, SIZEOF_FX_SAVE_AREA + + /* Return them */ + mov eax, [esp+4] + mov [eax], ecx + + mov eax, [esp+8] + mov [eax], edx + + /* return */ + ret 8 +.endfunc
Propchange: trunk/reactos/lib/sdk/crt/except/i386/seh.s ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/reactos/lib/sdk/crt/except/i386/unwind.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/i386/unw... ============================================================================== --- trunk/reactos/lib/sdk/crt/except/i386/unwind.c (original) +++ trunk/reactos/lib/sdk/crt/except/i386/unwind.c Sun Nov 11 18:47:21 2007 @@ -5,22 +5,6 @@ #include <ndk/umtypes.h> #include <ndk/extypes.h> #include <ndk/rtlfuncs.h> - -/* - * @implemented - */ -void __cdecl -_global_unwind2(PEXCEPTION_REGISTRATION_RECORD RegistrationFrame) -{ -#ifdef __GNUC__ - RtlUnwind(RegistrationFrame, &&__ret_label, NULL, 0); -__ret_label: - // return is important - return; -#else -#endif -} -
/* VC++ extensions to Win32 SEH */ typedef struct _SCOPETABLE
Modified: trunk/reactos/lib/sdk/crt/libcntpr.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/libcntpr.rbuild... ============================================================================== --- trunk/reactos/lib/sdk/crt/libcntpr.rbuild (original) +++ trunk/reactos/lib/sdk/crt/libcntpr.rbuild Sun Nov 11 18:47:21 2007 @@ -13,7 +13,7 @@ <define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define> </if>
- <directory name="except_nt"> + <directory name="except"> <if property="ARCH" value="i386"> <directory name="i386"> <file>chkstk_asm.s</file>
Removed: trunk/reactos/lib/sdk/crt/wine/cpp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/wine/cpp.c?rev=... ============================================================================== --- trunk/reactos/lib/sdk/crt/wine/cpp.c (original) +++ trunk/reactos/lib/sdk/crt/wine/cpp.c (removed) @@ -1,1250 +1,0 @@ -/* - * msvcrt.dll C++ objects - * - * Copyright 2000 Jon Griffiths - * Copyright 2003 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "wine/config.h" -#include "wine/port.h" - -#include <stdarg.h> - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "winternl.h" -#include "wine/exception.h" -#include "winnt.h" -#include "excpt.h" -#include "wine/debug.h" -#include <malloc.h> -#include <stdlib.h> - -#include <internal/wine/msvcrt.h> -#include <internal/wine/cppexcept.h> -#include <internal/mtdll.h> - -WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -/* - * exception object: base for exception, bad_cast, bad_typeid, __non_rtti_object - */ -typedef struct -{ - void* pfn_vector_dtor; - void* pfn_what; -} exception_vtable; - -typedef struct __exception -{ - const exception_vtable *vtable; - char *name; /* Name of this exception, always a new copy for each object */ - int do_free; /* Whether to free 'name' in our dtor */ -} exception; - -typedef exception bad_cast; -typedef exception bad_typeid; -typedef exception __non_rtti_object; - -typedef struct _rtti_base_descriptor -{ - type_info *type_descriptor; - int num_base_classes; - int base_class_offset; - unsigned int flags; - int unknown1; - int unknown2; -} rtti_base_descriptor; - -typedef struct _rtti_base_array -{ - const rtti_base_descriptor *bases[3]; /* First element is the class itself */ -} rtti_base_array; - -typedef struct _rtti_object_hierachy -{ - int unknown1; - int unknown2; - int array_len; /* Size of the array pointed to by 'base_classes' */ - const rtti_base_array *base_classes; -} rtti_object_hierachy; - -typedef struct _rtti_object_locator -{ - int unknown1; - int base_class_offset; - unsigned int flags; - type_info *type_descriptor; - const rtti_object_hierachy *type_hierachy; -} rtti_object_locator; - - -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define DEFINE_THISCALL_WRAPPER0(func) \ - extern void __thiscall_ ## func(); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) "@4" ) -#define DEFINE_THISCALL_WRAPPER1(func) \ - extern void __thiscall_ ## func(); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) "@8" ) - -const exception_vtable MSVCRT_exception_vtable; -const exception_vtable MSVCRT_bad_typeid_vtable; -const exception_vtable MSVCRT_bad_cast_vtable; -const exception_vtable MSVCRT___non_rtti_object_vtable; -static const exception_vtable MSVCRT_type_info_vtable; - -/* Internal common ctor for exception */ -static void WINAPI EXCEPTION_ctor(exception *_this, const char** name) -{ - _this->vtable = &MSVCRT_exception_vtable; - if (*name) - { - size_t name_len = strlen(*name) + 1; - _this->name = MSVCRT_malloc(name_len); - memcpy(_this->name, *name, name_len); - _this->do_free = TRUE; - } - else - { - _this->name = NULL; - _this->do_free = FALSE; - } -} - -/****************************************************************** - * ??0exception@@QAE@ABQBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_ctor); -exception * __stdcall MSVCRT_exception_ctor(exception * _this, const char ** name) -{ - TRACE("(%p,%s)\n", _this, *name); - EXCEPTION_ctor(_this, name); - return _this; -} - -/****************************************************************** - * ??0exception@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_copy_ctor); -exception * __stdcall MSVCRT_exception_copy_ctor(exception * _this, const exception * rhs) -{ - TRACE("(%p,%p)\n", _this, rhs); - - if (!rhs->do_free) - { - _this->vtable = &MSVCRT_exception_vtable; - _this->name = rhs->name; - _this->do_free = FALSE; - } - else - EXCEPTION_ctor(_this, (const char**)&rhs->name); - TRACE("name = %s\n", _this->name); - return _this; -} - -/****************************************************************** - * ??0exception@@QAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_exception_default_ctor); -exception * __stdcall MSVCRT_exception_default_ctor(exception * _this) -{ - static const char* empty = NULL; - - TRACE("(%p)\n", _this); - EXCEPTION_ctor(_this, &empty); - return _this; -} - -/****************************************************************** - * ??1exception@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_exception_dtor); -void __stdcall MSVCRT_exception_dtor(exception * _this) -{ - TRACE("(%p)\n", _this); - _this->vtable = &MSVCRT_exception_vtable; - if (_this->do_free) MSVCRT_free(_this->name); -} - -/****************************************************************** - * ??4exception@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_opequals); -exception * __stdcall MSVCRT_exception_opequals(exception * _this, const exception * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - if (_this != rhs) - { - MSVCRT_exception_dtor(_this); - MSVCRT_exception_copy_ctor(_this, rhs); - } - TRACE("name = %s\n", _this->name); - return _this; -} - -/****************************************************************** - * ??_Eexception@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_vector_dtor); -void * __stdcall MSVCRT_exception_vector_dtor(exception * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_exception_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_exception_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gexception@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_exception_scalar_dtor); -void * __stdcall MSVCRT_exception_scalar_dtor(exception * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_exception_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ?what@exception@@UBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_what_exception); -const char * __stdcall MSVCRT_what_exception(exception * _this) -{ - TRACE("(%p) returning %s\n", _this, _this->name); - return _this->name ? _this->name : "Unknown exception"; -} - -/****************************************************************** - * ??0bad_typeid@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_copy_ctor); -bad_typeid * __stdcall MSVCRT_bad_typeid_copy_ctor(bad_typeid * _this, const bad_typeid * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT_bad_typeid_vtable; - return _this; -} - -/****************************************************************** - * ??0bad_typeid@@QAE@PBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_ctor); -bad_typeid * __stdcall MSVCRT_bad_typeid_ctor(bad_typeid * _this, const char * name) -{ - TRACE("(%p %s)\n", _this, name); - EXCEPTION_ctor(_this, &name); - _this->vtable = &MSVCRT_bad_typeid_vtable; - return _this; -} - -/****************************************************************** - * ??1bad_typeid@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_bad_typeid_dtor); -void __stdcall MSVCRT_bad_typeid_dtor(bad_typeid * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_exception_dtor(_this); -} - -/****************************************************************** - * ??4bad_typeid@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_opequals); -bad_typeid * __stdcall MSVCRT_bad_typeid_opequals(bad_typeid * _this, const bad_typeid * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_Ebad_typeid@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_vector_dtor); -void * __stdcall MSVCRT_bad_typeid_vector_dtor(bad_typeid * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_typeid_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_bad_typeid_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gbad_typeid@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_typeid_scalar_dtor); -void * __stdcall MSVCRT_bad_typeid_scalar_dtor(bad_typeid * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_bad_typeid_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??0__non_rtti_object@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_copy_ctor); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object * _this, - const __non_rtti_object * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_bad_typeid_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT___non_rtti_object_vtable; - return _this; -} - -/****************************************************************** - * ??0__non_rtti_object@@QAE@PBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_ctor); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_ctor(__non_rtti_object * _this, - const char * name) -{ - TRACE("(%p %s)\n", _this, name); - EXCEPTION_ctor(_this, &name); - _this->vtable = &MSVCRT___non_rtti_object_vtable; - return _this; -} - -/****************************************************************** - * ??1__non_rtti_object@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT___non_rtti_object_dtor); -void __stdcall MSVCRT___non_rtti_object_dtor(__non_rtti_object * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_bad_typeid_dtor(_this); -} - -/****************************************************************** - * ??4__non_rtti_object@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_opequals); -__non_rtti_object * __stdcall MSVCRT___non_rtti_object_opequals(__non_rtti_object * _this, - const __non_rtti_object *rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_bad_typeid_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_E__non_rtti_object@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_vector_dtor); -void * __stdcall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT___non_rtti_object_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT___non_rtti_object_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_G__non_rtti_object@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT___non_rtti_object_scalar_dtor); -void * __stdcall MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT___non_rtti_object_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??0bad_cast@@QAE@ABQBD@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_ctor); -bad_cast * __stdcall MSVCRT_bad_cast_ctor(bad_cast * _this, const char ** name) -{ - TRACE("(%p %s)\n", _this, *name); - EXCEPTION_ctor(_this, name); - _this->vtable = &MSVCRT_bad_cast_vtable; - return _this; -} - -/****************************************************************** - * ??0bad_cast@@QAE@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_copy_ctor); -bad_cast * __stdcall MSVCRT_bad_cast_copy_ctor(bad_cast * _this, const bad_cast * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_copy_ctor(_this, rhs); - _this->vtable = &MSVCRT_bad_cast_vtable; - return _this; -} - -/****************************************************************** - * ??1bad_cast@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_bad_cast_dtor); -void __stdcall MSVCRT_bad_cast_dtor(bad_cast * _this) -{ - TRACE("(%p)\n", _this); - MSVCRT_exception_dtor(_this); -} - -/****************************************************************** - * ??4bad_cast@@QAEAAV0@ABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_opequals); -bad_cast * __stdcall MSVCRT_bad_cast_opequals(bad_cast * _this, const bad_cast * rhs) -{ - TRACE("(%p %p)\n", _this, rhs); - MSVCRT_exception_opequals(_this, rhs); - return _this; -} - -/****************************************************************** - * ??_Ebad_cast@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_vector_dtor); -void * __stdcall MSVCRT_bad_cast_vector_dtor(bad_cast * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_cast_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_bad_cast_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/****************************************************************** - * ??_Gbad_cast@@UAEPAXI@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_bad_cast_scalar_dtor); -void * __stdcall MSVCRT_bad_cast_scalar_dtor(bad_cast * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - MSVCRT_bad_cast_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - return _this; -} - -/****************************************************************** - * ??8type_info@@QBEHABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_opequals_equals); -int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs) -{ - int ret = !strcmp(_this->mangled + 1, rhs->mangled + 1); - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ??9type_info@@QBEHABV0@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_opnot_equals); -int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs) -{ - int ret = !!strcmp(_this->mangled + 1, rhs->mangled + 1); - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ?before@type_info@@QBEHABV1@@Z (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_before); -int __stdcall MSVCRT_type_info_before(type_info * _this, const type_info * rhs) -{ - int ret = strcmp(_this->mangled + 1, rhs->mangled + 1) < 0; - TRACE("(%p %p) returning %d\n", _this, rhs, ret); - return ret; -} - -/****************************************************************** - * ??1type_info@@UAE@XZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_dtor); -void __stdcall MSVCRT_type_info_dtor(type_info * _this) -{ - TRACE("(%p)\n", _this); - if (_this->name) - MSVCRT_free(_this->name); -} - -/****************************************************************** - * ?name@type_info@@QBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_name); -const char * __stdcall MSVCRT_type_info_name(type_info * _this) -{ - if (!_this->name) - { - /* Create and set the demangled name */ - /* Nota: mangled name in type_info struct always start with a '.', while - * it isn't valid for mangled name. - * Is this '.' really part of the mangled name, or has it some other meaning ? - */ - char* name = __unDName(0, _this->mangled + 1, 0, - MSVCRT_malloc, MSVCRT_free, 0x2800); - - if (name) - { - unsigned int len = strlen(name); - - /* It seems _unDName may leave blanks at the end of the demangled name */ - while (len && name[--len] == ' ') - name[len] = '\0'; - - _mlock(_EXIT_LOCK2); - - if (_this->name) - { - /* Another thread set this member since we checked above - use it */ - MSVCRT_free(name); - } - else - _this->name = name; - - _munlock(_EXIT_LOCK2); - } - } - TRACE("(%p) returning %s\n", _this, _this->name); - return _this->name; -} - -/****************************************************************** - * ?raw_name@type_info@@QBEPBDXZ (MSVCRT.@) - */ -DEFINE_THISCALL_WRAPPER0(MSVCRT_type_info_raw_name); -const char * __stdcall MSVCRT_type_info_raw_name(type_info * _this) -{ - TRACE("(%p) returning %s\n", _this, _this->mangled); - return _this->mangled; -} - -/* Unexported */ -DEFINE_THISCALL_WRAPPER1(MSVCRT_type_info_vector_dtor); -void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int flags) -{ - TRACE("(%p %x)\n", _this, flags); - if (flags & 2) - { - /* we have an array, with the number of elements stored before the first object */ - int i, *ptr = (int *)_this - 1; - - for (i = *ptr - 1; i >= 0; i--) MSVCRT_type_info_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCRT_type_info_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -/* vtables */ - -const exception_vtable MSVCRT_exception_vtable = -{ - __thiscall_MSVCRT_exception_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT_bad_typeid_vtable = -{ - __thiscall_MSVCRT_bad_typeid_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT_bad_cast_vtable = -{ - __thiscall_MSVCRT_bad_cast_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -const exception_vtable MSVCRT___non_rtti_object_vtable = -{ - __thiscall_MSVCRT___non_rtti_object_vector_dtor, - __thiscall_MSVCRT_what_exception -}; - -static const exception_vtable MSVCRT_type_info_vtable = -{ - __thiscall_MSVCRT_type_info_vector_dtor, - NULL -}; - -/* Static RTTI for exported objects */ - -static type_info exception_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVexception@@" -}; - -static const rtti_base_descriptor exception_rtti_base_descriptor = -{ - &exception_type_info, - 0, - 0, - 0, - 0, - 0 -}; - -static const rtti_base_array exception_rtti_base_array = -{ - { - &exception_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierachy exception_type_hierachy = -{ - 0, - 0, - 1, - &exception_rtti_base_array -}; - -static const rtti_object_locator exception_rtti = -{ - 0, - 0, - 0, - &exception_type_info, - &exception_type_hierachy -}; - -static const cxx_type_info exception_cxx_type_info = -{ - 0, - &exception_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_exception_copy_ctor -}; - -static type_info bad_typeid_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVbad_typeid@@" -}; - -static const rtti_base_descriptor bad_typeid_rtti_base_descriptor = -{ - &bad_typeid_type_info, - 1, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array bad_typeid_rtti_base_array = -{ - { - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierachy bad_typeid_type_hierachy = -{ - 0, - 0, - 2, - &bad_typeid_rtti_base_array -}; - -static const rtti_object_locator bad_typeid_rtti = -{ - 0, - 0, - 0, - &bad_typeid_type_info, - &bad_typeid_type_hierachy -}; - -static const cxx_type_info bad_typeid_cxx_type_info = -{ - 0, - &bad_typeid_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_bad_typeid_copy_ctor -}; - -static type_info bad_cast_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVbad_cast@@" -}; - -static const rtti_base_descriptor bad_cast_rtti_base_descriptor = -{ - &bad_cast_type_info, - 1, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array bad_cast_rtti_base_array = -{ - { - &bad_cast_rtti_base_descriptor, - &exception_rtti_base_descriptor, - NULL - } -}; - -static const rtti_object_hierachy bad_cast_type_hierachy = -{ - 0, - 0, - 2, - &bad_cast_rtti_base_array -}; - -static const rtti_object_locator bad_cast_rtti = -{ - 0, - 0, - 0, - &bad_cast_type_info, - &bad_cast_type_hierachy -}; - -static const cxx_type_info bad_cast_cxx_type_info = -{ - 0, - &bad_cast_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT_bad_cast_copy_ctor -}; - -static type_info __non_rtti_object_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AV__non_rtti_object@@" -}; - -static const rtti_base_descriptor __non_rtti_object_rtti_base_descriptor = -{ - &__non_rtti_object_type_info, - 2, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array __non_rtti_object_rtti_base_array = -{ - { - &__non_rtti_object_rtti_base_descriptor, - &bad_typeid_rtti_base_descriptor, - &exception_rtti_base_descriptor - } -}; - -static const rtti_object_hierachy __non_rtti_object_type_hierachy = -{ - 0, - 0, - 3, - &__non_rtti_object_rtti_base_array -}; - -static const rtti_object_locator __non_rtti_object_rtti = -{ - 0, - 0, - 0, - &__non_rtti_object_type_info, - &__non_rtti_object_type_hierachy -}; - -static const cxx_type_info __non_rtti_object_cxx_type_info = -{ - 0, - &__non_rtti_object_type_info, - 0, - -1, - 0, - sizeof(exception), - (cxx_copy_ctor)__thiscall_MSVCRT___non_rtti_object_copy_ctor -}; - -static type_info type_info_type_info = -{ - (void*)&MSVCRT_type_info_vtable, - NULL, - ".?AVtype_info@@" -}; - -static const rtti_base_descriptor type_info_rtti_base_descriptor = -{ - &type_info_type_info, - 0, - 0, - 0xffffffff, - 0, - 0 -}; - -static const rtti_base_array type_info_rtti_base_array = -{ - { - &type_info_rtti_base_descriptor, - NULL, - NULL - } -}; - -static const rtti_object_hierachy type_info_type_hierachy = -{ - 0, - 0, - 1, - &type_info_rtti_base_array -}; - -static const rtti_object_locator type_info_rtti = -{ - 0, - 0, - 0, - &type_info_type_info, - &type_info_type_hierachy -}; - -/* - * Exception RTTI for cpp objects - */ -static const cxx_type_info_table bad_cast_type_info_table = -{ - 3, - { - &__non_rtti_object_cxx_type_info, - &bad_typeid_cxx_type_info, - &exception_cxx_type_info - } -}; - -static const cxx_exception_type bad_cast_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT_bad_cast_dtor, - NULL, - &bad_cast_type_info_table -}; - -static const cxx_type_info_table bad_typeid_type_info_table = -{ - 2, - { - &bad_cast_cxx_type_info, - &exception_cxx_type_info, - NULL - } -}; - -static const cxx_exception_type bad_typeid_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT_bad_typeid_dtor, - NULL, - &bad_cast_type_info_table -}; - -static const cxx_exception_type __non_rtti_object_exception_type = -{ - 0, - (void*)__thiscall_MSVCRT___non_rtti_object_dtor, - NULL, - &bad_typeid_type_info_table -}; - -#endif /* __i386__ */ - - -/****************************************************************** - * ?set_terminate@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) - * - * Install a handler to be called when terminate() is called. - * - * PARAMS - * func [I] Handler function to install - * - * RETURNS - * The previously installed handler function, if any. - */ -terminate_function MSVCRT_set_terminate(terminate_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - terminate_function previous = data->terminate_handler; - TRACE("(%p) returning %p\n",func,previous); - data->terminate_handler = func; - return previous; -} - -/****************************************************************** - * ?set_unexpected@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) - * - * Install a handler to be called when unexpected() is called. - * - * PARAMS - * func [I] Handler function to install - * - * RETURNS - * The previously installed handler function, if any. - */ -unexpected_function MSVCRT_set_unexpected(unexpected_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - unexpected_function previous = data->unexpected_handler; - TRACE("(%p) returning %p\n",func,previous); - data->unexpected_handler = func; - return previous; -} - -/****************************************************************** - * ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z (MSVCRT.@) - */ -_se_translator_function MSVCRT__set_se_translator(_se_translator_function func) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - _se_translator_function previous = data->se_translator; - TRACE("(%p) returning %p\n",func,previous); - data->se_translator = func; - return previous; -} - -/****************************************************************** - * ?terminate@@YAXXZ (MSVCRT.@) - * - * Default handler for an unhandled exception. - * - * PARAMS - * None. - * - * RETURNS - * This function does not return. Either control resumes from any - * handler installed by calling set_terminate(), or (by default) abort() - * is called. - */ -void MSVCRT_terminate(void) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - if (data->terminate_handler) data->terminate_handler(); - abort(); -} - -/****************************************************************** - * ?unexpected@@YAXXZ (MSVCRT.@) - */ -void MSVCRT_unexpected(void) -{ - MSVCRT_thread_data *data = msvcrt_get_thread_data(); - if (data->unexpected_handler) data->unexpected_handler(); - MSVCRT_terminate(); -} - -/* Get type info from an object (internal) */ -static const rtti_object_locator* RTTI_GetObjectLocator(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = NULL; - -#ifdef __i386__ - const exception_vtable* vtable = (const exception_vtable*)cppobj->vtable; - - /* Perhaps this is one of classes we export? */ - if (vtable == &MSVCRT_exception_vtable) - { - TRACE("returning exception_rtti\n"); - return &exception_rtti; - } - else if (vtable == &MSVCRT_bad_typeid_vtable) - { - TRACE("returning bad_typeid_rtti\n"); - return &bad_typeid_rtti; - } - else if (vtable == &MSVCRT_bad_cast_vtable) - { - TRACE("returning bad_cast_rtti\n"); - return &bad_cast_rtti; - } - else if (vtable == &MSVCRT___non_rtti_object_vtable) - { - TRACE("returning __non_rtti_object_rtti\n"); - return &__non_rtti_object_rtti; - } - else if (vtable == &MSVCRT_type_info_vtable) - { - TRACE("returning type_info_rtti\n"); - return &type_info_rtti; - } -#endif - - if (!IsBadReadPtr(cppobj, sizeof(void *)) && - !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) && - !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator))) - { - obj_locator = (rtti_object_locator *)cppobj->vtable[-1]; - TRACE("returning type_info from vtable (%p)\n", obj_locator); - } - - return obj_locator; -} - -/****************************************************************** - * __RTtypeid (MSVCRT.@) - * - * Retrieve the Run Time Type Information (RTTI) for a C++ object. - * - * PARAMS - * cppobj [I] C++ object to get type information for. - * - * RETURNS - * Success: A type_info object describing cppobj. - * Failure: If the object to be cast has no RTTI, a __non_rtti_object - * exception is thrown. If cppobj is NULL, a bad_typeid exception - * is thrown. In either case, this function does not return. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -type_info* MSVCRT___RTtypeid(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = RTTI_GetObjectLocator(cppobj); - -#ifdef __i386__ - if (!obj_locator) - { - static const char* szNullPtr = "Attempted a typeid of NULL pointer!"; - static const char* szBadPtr = "Bad read pointer - no RTTI data!"; - const cxx_exception_type *e_type; - exception e; - - /* Throw a bad_typeid or __non_rtti_object exception */ - if (!cppobj) - { - EXCEPTION_ctor(&e, &szNullPtr); - e.vtable = &MSVCRT_bad_typeid_vtable; - e_type = &bad_typeid_exception_type; - } - else - { - EXCEPTION_ctor(&e, &szBadPtr); - e.vtable = &MSVCRT___non_rtti_object_vtable; - e_type = &__non_rtti_object_exception_type; - } - - _CxxThrowException(&e, e_type); - DebugBreak(); - } - return obj_locator->type_descriptor; -#else - return NULL; -#endif -} - -/****************************************************************** - * __RTDynamicCast (MSVCRT.@) - * - * Dynamically cast a C++ object to one of its base classes. - * - * PARAMS - * cppobj [I] Any C++ object to cast - * unknown [I] Reserved, set to 0 - * src [I] type_info object describing cppobj - * dst [I] type_info object describing the base class to cast to - * do_throw [I] TRUE = throw an exception if the cast fails, FALSE = don't - * - * RETURNS - * Success: The address of cppobj, cast to the object described by dst. - * Failure: NULL, If the object to be cast has no RTTI, or dst is not a - * valid cast for cppobj. If do_throw is TRUE, a bad_cast exception - * is thrown and this function does not return. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -void* MSVCRT___RTDynamicCast(type_info *cppobj, int unknown, - type_info *src, type_info *dst, - int do_throw) -{ - const rtti_object_locator *obj_locator; - - /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */ - TRACE("(%p,%d,%p,%p,%d)\n", cppobj, unknown, src, dst, do_throw); - if (!cppobj) - return 0; - obj_locator= RTTI_GetObjectLocator(cppobj); - if (unknown) - FIXME("Unknown parameter is non-zero: please report\n"); - - /* To cast an object at runtime: - * 1.Find out the true type of the object from the typeinfo at vtable[-1] - * 2.Search for the destination type in the class heirachy - * 3.If destination type is found, return base object address + dest offset - * Otherwise, fail the cast - */ - if (obj_locator) - { - int count = 0; - const rtti_object_hierachy *obj_bases = obj_locator->type_hierachy; - const rtti_base_descriptor* const *base_desc = obj_bases->base_classes->bases; - int src_offset = obj_locator->base_class_offset, dst_offset = -1; - - while (count < obj_bases->array_len) - { - const type_info *typ = (*base_desc)->type_descriptor; - - if (!strcmp(typ->mangled, dst->mangled)) - { - dst_offset = (*base_desc)->base_class_offset; - break; - } - base_desc++; - count++; - } - if (dst_offset >= 0) - return (void*)((unsigned long)cppobj - src_offset + dst_offset); - } - -#ifdef __i386__ - /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned - * to a reference, since references cannot be NULL. - */ - if (do_throw) - { - static const char* exception_text = "Bad dynamic_cast!"; - exception e; - - /* Throw a bad_cast exception */ - EXCEPTION_ctor(&e, &exception_text); - e.vtable = &MSVCRT_bad_cast_vtable; - _CxxThrowException(&e, &bad_cast_exception_type); - DebugBreak(); - } -#endif - return NULL; -} - - -/****************************************************************** - * __RTCastToVoid (MSVCRT.@) - * - * Dynamically cast a C++ object to a void*. - * - * PARAMS - * cppobj [I] The C++ object to cast - * - * RETURNS - * Success: The base address of the object as a void*. - * Failure: NULL, if cppobj is NULL or has no RTTI. - * - * NOTES - * This function is usually called by compiler generated code as a result - * of using one of the C++ dynamic cast statements. - */ -void* MSVCRT___RTCastToVoid(type_info *cppobj) -{ - const rtti_object_locator *obj_locator = RTTI_GetObjectLocator(cppobj); - - /* Note: cppobj _isn't_ a type_info, we use that struct for its vtable ptr */ - TRACE("(%p)\n", cppobj); - - /* Casts to void* simply cast to the base object */ - if (obj_locator) - return (void*)((unsigned long)cppobj - obj_locator->base_class_offset); - return NULL; -}
Removed: trunk/reactos/lib/sdk/crt/wine/cppexcept.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/wine/cppexcept.... ============================================================================== --- trunk/reactos/lib/sdk/crt/wine/cppexcept.c (original) +++ trunk/reactos/lib/sdk/crt/wine/cppexcept.c (removed) @@ -1,442 +1,0 @@ -/* - * msvcrt C++ exception handling - * - * Copyright 2002 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * NOTES - * A good reference is the article "How a C++ compiler implements - * exception handling" by Vishal Kochhar, available on - * www.thecodeproject.com. - */ - -#include "wine/config.h" -#include "wine/port.h" - -#include <stdarg.h> - -#include "windef.h" -#include "winbase.h" -#include "winreg.h" -#include "winternl.h" -#include <internal/wine/msvcrt.h> -#include "wine/exception.h" -#include "excpt.h" -#include "wine/debug.h" - -#include <internal/wine/cppexcept.h> - -WINE_DEFAULT_DEBUG_CHANNEL(seh); - -#ifdef __i386__ /* CxxFrameHandler is not supported on non-i386 */ - -static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch, - cxx_function_descr *descr, EXCEPTION_REGISTRATION_RECORD* nested_frame, - int nested_trylevel ); - -/* call a function with a given ebp */ -__inline static void *call_ebp_func( void *func, void *ebp ) -{ - void *ret; - __asm__ __volatile__ ("pushl %%ebp; movl %2,%%ebp; call *%%eax; popl %%ebp" \ - : "=a" (ret) : "0" (func), "g" (ebp) : "ecx", "edx", "memory" ); - return ret; -} - -/* call a copy constructor */ -__inline static void call_copy_ctor( void *func, void *this, void *src, int has_vbase ) -{ - TRACE( "calling copy ctor %p object %p src %p\n", func, this, src ); - if (has_vbase) - /* in that case copy ctor takes an extra bool indicating whether to copy the base class */ - __asm__ __volatile__("pushl $1; pushl %2; call *%0" - : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" ); - else - __asm__ __volatile__("pushl %2; call *%0" - : : "r" (func), "c" (this), "g" (src) : "eax", "edx", "memory" ); -} - -/* call the destructor of the exception object */ -__inline static void call_dtor( void *func, void *object ) -{ - __asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" ); -} - -static void dump_type( const cxx_type_info *type ) -{ - DPRINTF( "flags %x type %p", type->flags, type->type_info ); - if (type->type_info) DPRINTF( " (%p %s)", type->type_info->name, type->type_info->mangled ); - DPRINTF( " offset %d vbase %d,%d size %d copy ctor %p\n", type->this_offset, - type->vbase_descr, type->vbase_offset, type->size, type->copy_ctor ); -} - -static void dump_exception_type( const cxx_exception_type *type ) -{ - UINT i; - - DPRINTF( "exception type:\n" ); - DPRINTF( "flags %x destr %p handler %p type info %p\n", - type->flags, type->destructor, type->custom_handler, type->type_info_table ); - for (i = 0; i < type->type_info_table->count; i++) - { - DPRINTF( " %d: ", i ); - dump_type( type->type_info_table->info[i] ); - } -} - -static void dump_function_descr( const cxx_function_descr *descr, const cxx_exception_type *info ) -{ - UINT i; - int j; - - DPRINTF( "function descr:\n" ); - DPRINTF( "magic %x\n", descr->magic ); - DPRINTF( "unwind table: %p %d\n", descr->unwind_table, descr->unwind_count ); - for (i = 0; i < descr->unwind_count; i++) - { - DPRINTF( " %d: prev %d func %p\n", i, - descr->unwind_table[i].prev, descr->unwind_table[i].handler ); - } - DPRINTF( "try table: %p %d\n", descr->tryblock, descr->tryblock_count ); - for (i = 0; i < descr->tryblock_count; i++) - { - DPRINTF( " %d: start %d end %d catchlevel %d catch %p %d\n", i, - descr->tryblock[i].start_level, descr->tryblock[i].end_level, - descr->tryblock[i].catch_level, descr->tryblock[i].catchblock, - descr->tryblock[i].catchblock_count ); - for (j = 0; j < descr->tryblock[i].catchblock_count; j++) - { - catchblock_info *ptr = &descr->tryblock[i].catchblock[j]; - DPRINTF( " %d: flags %x offset %d handler %p type %p", - j, ptr->flags, ptr->offset, ptr->handler, ptr->type_info ); - if (ptr->type_info) DPRINTF( " (%p %s)", ptr->type_info->name, ptr->type_info->mangled ); - DPRINTF( "\n" ); - } - } -} - -/* compute the this pointer for a base class of a given type */ -static void *get_this_pointer( const cxx_type_info *type, void *object ) -{ - void *this_ptr; - int *offset_ptr; - - if (!object) return NULL; - this_ptr = (char *)object + type->this_offset; - if (type->vbase_descr >= 0) - { - /* move this ptr to vbase descriptor */ - this_ptr = (char *)this_ptr + type->vbase_descr; - /* and fetch additional offset from vbase descriptor */ - offset_ptr = (int *)(*(char **)this_ptr + type->vbase_offset); - this_ptr = (char *)this_ptr + *offset_ptr; - } - return this_ptr; -} - -/* check if the exception type is caught by a given catch block, and return the type that matched */ -static const cxx_type_info *find_caught_type( cxx_exception_type *exc_type, catchblock_info *catchblock ) -{ - UINT i; - - for (i = 0; i < exc_type->type_info_table->count; i++) - { - const cxx_type_info *type = exc_type->type_info_table->info[i]; - - if (!catchblock->type_info) return type; /* catch(...) matches any type */ - if (catchblock->type_info != type->type_info) - { - if (strcmp( catchblock->type_info->mangled, type->type_info->mangled )) continue; - } - /* type is the same, now check the flags */ - if ((exc_type->flags & TYPE_FLAG_CONST) && - !(catchblock->flags & TYPE_FLAG_CONST)) continue; - if ((exc_type->flags & TYPE_FLAG_VOLATILE) && - !(catchblock->flags & TYPE_FLAG_VOLATILE)) continue; - return type; /* it matched */ - } - return NULL; -} - - -/* copy the exception object where the catch block wants it */ -static void copy_exception( void *object, cxx_exception_frame *frame, - catchblock_info *catchblock, const cxx_type_info *type ) -{ - void **dest_ptr; - - if (!catchblock->type_info || !catchblock->type_info->mangled[0]) return; - if (!catchblock->offset) return; - dest_ptr = (void **)((char *)&frame->ebp + catchblock->offset); - - if (catchblock->flags & TYPE_FLAG_REFERENCE) - { - *dest_ptr = get_this_pointer( type, object ); - } - else if (type->flags & CLASS_IS_SIMPLE_TYPE) - { - memmove( dest_ptr, object, type->size ); - /* if it is a pointer, adjust it */ - if (type->size == sizeof(void *)) *dest_ptr = get_this_pointer( type, *dest_ptr ); - } - else /* copy the object */ - { - if (type->copy_ctor) - call_copy_ctor( type->copy_ctor, dest_ptr, get_this_pointer(type,object), - (type->flags & CLASS_HAS_VIRTUAL_BASE_CLASS) ); - else - memmove( dest_ptr, get_this_pointer(type,object), type->size ); - } -} - -/* unwind the local function up to a given trylevel */ -static void cxx_local_unwind( cxx_exception_frame* frame, cxx_function_descr *descr, int last_level) -{ - void (*handler)(); - int trylevel = frame->trylevel; - - while (trylevel != last_level) - { - if (trylevel < 0 || trylevel >= (int)descr->unwind_count) - { - ERR( "invalid trylevel %d\n", trylevel ); - MSVCRT_terminate(); - } - handler = descr->unwind_table[trylevel].handler; - if (handler) - { - TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n", - handler, trylevel, last_level, &frame->ebp ); - call_ebp_func( handler, &frame->ebp ); - } - trylevel = descr->unwind_table[trylevel].prev; - } - frame->trylevel = last_level; -} - -/* exception frame for nested exceptions in catch block */ -struct catch_func_nested_frame -{ - EXCEPTION_REGISTRATION_RECORD frame; /* standard exception frame */ - EXCEPTION_RECORD *prev_rec; /* previous record to restore in thread data */ - cxx_exception_frame *cxx_frame; /* frame of parent exception */ - cxx_function_descr *descr; /* descriptor of parent exception */ - int trylevel; /* current try level */ -}; - -/* handler for exceptions happening while calling a catch function */ -static DWORD catch_function_nested_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame, - CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher ) -{ - struct catch_func_nested_frame *nested_frame = (struct catch_func_nested_frame *)frame; - - if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) - { - msvcrt_get_thread_data()->exc_record = nested_frame->prev_rec; - return ExceptionContinueSearch; - } - else - { - TRACE( "got nested exception in catch function\n" ); - return cxx_frame_handler( rec, nested_frame->cxx_frame, context, - NULL, nested_frame->descr, &nested_frame->frame, - nested_frame->trylevel ); - } -} - -/* find and call the appropriate catch block for an exception */ -/* returns the address to continue execution to after the catch block was called */ -__inline static void *call_catch_block( PEXCEPTION_RECORD rec, cxx_exception_frame *frame, - cxx_function_descr *descr, int nested_trylevel, - cxx_exception_type *info ) -{ - UINT i; - int j; - void *addr, *object = (void *)rec->ExceptionInformation[1]; - struct catch_func_nested_frame nested_frame; - int trylevel = frame->trylevel; - MSVCRT_thread_data *thread_data = msvcrt_get_thread_data(); - - for (i = 0; i < descr->tryblock_count; i++) - { - tryblock_info *tryblock = &descr->tryblock[i]; - - if (trylevel < tryblock->start_level) continue; - if (trylevel > tryblock->end_level) continue; - - /* got a try block */ - for (j = 0; j < tryblock->catchblock_count; j++) - { - catchblock_info *catchblock = &tryblock->catchblock[j]; - const cxx_type_info *type = find_caught_type( info, catchblock ); - if (!type) continue; - - TRACE( "matched type %p in tryblock %d catchblock %d\n", type, i, j ); - - /* copy the exception to its destination on the stack */ - copy_exception( object, frame, catchblock, type ); - - /* unwind the stack */ - RtlUnwind( frame, 0, rec, 0 ); - cxx_local_unwind( frame, descr, tryblock->start_level ); - frame->trylevel = tryblock->end_level + 1; - - /* call the catch block */ - TRACE( "calling catch block %p for type %p addr %p ebp %p\n", - catchblock, type, catchblock->handler, &frame->ebp ); - - /* setup an exception block for nested exceptions */ - - //nested_frame.frame.Handler = catch_function_nested_handler; - nested_frame.frame.Handler = (PEXCEPTION_HANDLER)catch_function_nested_handler; - nested_frame.prev_rec = thread_data->exc_record; - nested_frame.cxx_frame = frame; - nested_frame.descr = descr; - nested_frame.trylevel = nested_trylevel + 1; - - __wine_push_frame( &nested_frame.frame ); - thread_data->exc_record = rec; - addr = call_ebp_func( catchblock->handler, &frame->ebp ); - thread_data->exc_record = nested_frame.prev_rec; - __wine_pop_frame( &nested_frame.frame ); - - if (info->destructor) call_dtor( info->destructor, object ); - TRACE( "done, continuing at %p\n", addr ); - return addr; - } - } - return NULL; -} - - -/********************************************************************* - * cxx_frame_handler - * - * Implementation of __CxxFrameHandler. - */ -static DWORD cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch, - cxx_function_descr *descr, EXCEPTION_REGISTRATION_RECORD* nested_frame, - int nested_trylevel ) -{ - cxx_exception_type *exc_type; - void *next_ip; - PEXCEPTION_RECORD orig_rec = rec; - - if (descr->magic != CXX_FRAME_MAGIC) - { - ERR( "invalid frame magic %x\n", descr->magic ); - return ExceptionContinueSearch; - } - if (rec->ExceptionFlags & (EH_UNWINDING|EH_EXIT_UNWIND)) - { - if (descr->unwind_count && !nested_trylevel) cxx_local_unwind( frame, descr, -1 ); - return ExceptionContinueSearch; - } - if (!descr->tryblock_count) return ExceptionContinueSearch; - - exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; - if (rec->ExceptionCode == CXX_EXCEPTION && - rec->ExceptionInformation[0] > CXX_FRAME_MAGIC && - exc_type->custom_handler) - { - return exc_type->custom_handler( rec, frame, exc_context, dispatch, - descr, nested_trylevel, nested_frame, 0 ); - } - - if (!exc_type) /* nested exception, fetch info from original exception */ - { - rec = msvcrt_get_thread_data()->exc_record; - exc_type = (cxx_exception_type *)rec->ExceptionInformation[2]; - } - - if (TRACE_ON(seh)) - { - TRACE("handling C++ exception rec %p frame %p trylevel %d descr %p nested_frame %p\n", - rec, frame, frame->trylevel, descr, nested_frame ); - dump_exception_type( exc_type ); - dump_function_descr( descr, exc_type ); - } - - next_ip = call_catch_block( rec, frame, descr, frame->trylevel, exc_type ); - - if (!next_ip) return ExceptionContinueSearch; - orig_rec->ExceptionFlags &= ~EH_NONCONTINUABLE; - exc_context->Eip = (DWORD)next_ip; - exc_context->Ebp = (DWORD)&frame->ebp; - exc_context->Esp = ((DWORD*)frame)[-1]; - return ExceptionContinueExecution; -} - - -/********************************************************************* - * __CxxFrameHandler (MSVCRT.@) - */ -DWORD __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, - PCONTEXT exc_context, EXCEPTION_REGISTRATION_RECORD** dispatch ) -{ - cxx_function_descr *descr; - - __asm__ __volatile__("mov %%eax, %0\n" : "=m"(descr)); - return cxx_frame_handler(rec, (cxx_exception_frame *)frame, - exc_context, dispatch, descr, NULL, 0 ); -} -#endif /* __i386__ */ - -/********************************************************************* - * _CxxThrowException (MSVCRT.@) - */ -void _CxxThrowException( void *object, const cxx_exception_type *type ) -{ - DWORD args[3]; - - args[0] = CXX_FRAME_MAGIC; - args[1] = (DWORD)object; - args[2] = (DWORD)type; - RaiseException( CXX_EXCEPTION, EH_NONCONTINUABLE, 3, args ); -} - -/********************************************************************* - * __CxxDetectRethrow (MSVCRT.@) - */ -BOOL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs) -{ - PEXCEPTION_RECORD rec; - - if (!ptrs) - return FALSE; - - rec = ptrs->ExceptionRecord; - - if (rec->ExceptionCode == CXX_EXCEPTION && - rec->NumberParameters == 3 && - rec->ExceptionInformation[0] == CXX_FRAME_MAGIC && - rec->ExceptionInformation[2]) - { - ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record; - return TRUE; - } - return (msvcrt_get_thread_data()->exc_record == rec); -} - -/********************************************************************* - * __CxxQueryExceptionSize (MSVCRT.@) - */ -unsigned int __CxxQueryExceptionSize(void) -{ - return sizeof(cxx_exception_type); -}
Modified: trunk/reactos/media/doc/README.WINE URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=3... ============================================================================== --- trunk/reactos/media/doc/README.WINE (original) +++ trunk/reactos/media/doc/README.WINE Sun Nov 11 18:47:21 2007 @@ -119,6 +119,8 @@
msvcrt - reactos/dll/win32/msvcrt/wine/*.c # Out of sync + reactos/lib/sdk/crt/except # Synced at XXXXXXXX + reactos/lib/sdk/crt/wine # Synced at XXXXXXXX
User32 - reactos/dll/win32/user32/controls/button.c # Synced at 20071022