ntdll: Use NtSetContextThread in NtRaiseException.
[wine] / dlls / ntdll / exception.c
1 /*
2  * NT exception handling routines
3  *
4  * Copyright 1999 Turchanov Sergey
5  * Copyright 1999 Alexandre Julliard
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23 #include "wine/port.h"
24
25 #include <assert.h>
26 #include <signal.h>
27 #include <stdarg.h>
28
29 #include "ntstatus.h"
30 #define WIN32_NO_STATUS
31 #include "windef.h"
32 #include "winternl.h"
33 #include "wine/exception.h"
34 #include "wine/server.h"
35 #include "wine/list.h"
36 #include "wine/debug.h"
37 #include "excpt.h"
38 #include "ntdll_misc.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(seh);
41
42 /* Exception record for handling exceptions happening inside exception handlers */
43 typedef struct
44 {
45     EXCEPTION_REGISTRATION_RECORD frame;
46     EXCEPTION_REGISTRATION_RECORD *prevFrame;
47 } EXC_NESTED_FRAME;
48
49 typedef struct
50 {
51     struct list                 entry;
52     PVECTORED_EXCEPTION_HANDLER func;
53 } VECTORED_HANDLER;
54
55 static struct list vectored_handlers = LIST_INIT(vectored_handlers);
56
57 static RTL_CRITICAL_SECTION vectored_handlers_section;
58 static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
59 {
60     0, 0, &vectored_handlers_section,
61     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
62       0, 0, { (DWORD_PTR)(__FILE__ ": vectored_handlers_section") }
63 };
64 static RTL_CRITICAL_SECTION vectored_handlers_section = { &critsect_debug, -1, 0, 0, 0, 0 };
65
66 #ifdef __i386__
67 # define GET_IP(context) ((LPVOID)(context)->Eip)
68 #elif defined(__sparc__)
69 # define GET_IP(context) ((LPVOID)(context)->pc)
70 #elif defined(__powerpc__)
71 # define GET_IP(context) ((LPVOID)(context)->Iar)
72 #elif defined(__ALPHA__)
73 # define GET_IP(context) ((LPVOID)(context)->Fir)
74 #elif defined(__x86_64__)
75 # define GET_IP(context) ((LPVOID)(context)->Rip)
76 #else
77 # error You must define GET_IP for this CPU
78 #endif
79
80 /*******************************************************************
81  *         EXC_RaiseHandler
82  *
83  * Handler for exceptions happening inside a handler.
84  */
85 static DWORD EXC_RaiseHandler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
86                                CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
87 {
88     if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
89         return ExceptionContinueSearch;
90     /* We shouldn't get here so we store faulty frame in dispatcher */
91     *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
92     return ExceptionNestedException;
93 }
94
95
96 /*******************************************************************
97  *         EXC_UnwindHandler
98  *
99  * Handler for exceptions happening inside an unwind handler.
100  */
101 static DWORD EXC_UnwindHandler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
102                                 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
103 {
104     if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
105         return ExceptionContinueSearch;
106     /* We shouldn't get here so we store faulty frame in dispatcher */
107     *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
108     return ExceptionCollidedUnwind;
109 }
110
111
112 /*******************************************************************
113  *         EXC_CallHandler
114  *
115  * Call an exception handler, setting up an exception frame to catch exceptions
116  * happening during the handler execution.
117  *
118  * For i386 this function is implemented in assembler in signal_i386.c.
119  */
120 #ifndef __i386__
121 static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
122                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
123                               PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler)
124 {
125     EXC_NESTED_FRAME newframe;
126     DWORD ret;
127
128     newframe.frame.Handler = nested_handler;
129     newframe.prevFrame     = frame;
130     __wine_push_frame( &newframe.frame );
131     ret = handler( record, frame, context, dispatcher );
132     __wine_pop_frame( &newframe.frame );
133     return ret;
134 }
135 #else
136 /* in signal_i386.c */
137 extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
138                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
139                               PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler);
140 #endif
141
142 /**********************************************************************
143  *           wait_suspend
144  *
145  * Wait until the thread is no longer suspended.
146  */
147 void wait_suspend( CONTEXT *context )
148 {
149     LARGE_INTEGER timeout;
150
151     /* store the context we got at suspend time */
152     SERVER_START_REQ( set_thread_context )
153     {
154         req->handle  = GetCurrentThread();
155         req->flags   = CONTEXT_FULL;
156         req->suspend = 1;
157         wine_server_add_data( req, context, sizeof(*context) );
158         wine_server_call( req );
159     }
160     SERVER_END_REQ;
161
162     /* wait with 0 timeout, will only return once the thread is no longer suspended */
163     timeout.QuadPart = 0;
164     NTDLL_wait_for_multiple_objects( 0, NULL, 0, &timeout, 0 );
165
166     /* retrieve the new context */
167     SERVER_START_REQ( get_thread_context )
168     {
169         req->handle  = GetCurrentThread();
170         req->flags   = CONTEXT_FULL;
171         req->suspend = 1;
172         wine_server_set_reply( req, context, sizeof(*context) );
173         wine_server_call( req );
174     }
175     SERVER_END_REQ;
176 }
177
178
179 /**********************************************************************
180  *           send_debug_event
181  *
182  * Send an EXCEPTION_DEBUG_EVENT event to the debugger.
183  */
184 static NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context )
185 {
186     int ret;
187     HANDLE handle = 0;
188
189     if (!NtCurrentTeb()->Peb->BeingDebugged) return 0;  /* no debugger present */
190
191     SERVER_START_REQ( queue_exception_event )
192     {
193         req->first   = first_chance;
194         wine_server_add_data( req, context, sizeof(*context) );
195         wine_server_add_data( req, rec, sizeof(*rec) );
196         if (!wine_server_call( req )) handle = reply->handle;
197     }
198     SERVER_END_REQ;
199     if (!handle) return 0;
200
201     NTDLL_wait_for_multiple_objects( 1, &handle, 0, NULL, 0 );
202
203     SERVER_START_REQ( get_exception_status )
204     {
205         req->handle = handle;
206         wine_server_set_reply( req, context, sizeof(*context) );
207         ret = wine_server_call( req );
208     }
209     SERVER_END_REQ;
210     return ret;
211 }
212
213
214 /**********************************************************************
215  *           call_vectored_handlers
216  *
217  * Call the vectored handlers chain.
218  */
219 static LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
220 {
221     struct list *ptr;
222     LONG ret = EXCEPTION_CONTINUE_SEARCH;
223     EXCEPTION_POINTERS except_ptrs;
224
225     except_ptrs.ExceptionRecord = rec;
226     except_ptrs.ContextRecord = context;
227
228     RtlEnterCriticalSection( &vectored_handlers_section );
229     LIST_FOR_EACH( ptr, &vectored_handlers )
230     {
231         VECTORED_HANDLER *handler = LIST_ENTRY( ptr, VECTORED_HANDLER, entry );
232         ret = handler->func( &except_ptrs );
233         if (ret == EXCEPTION_CONTINUE_EXECUTION) break;
234     }
235     RtlLeaveCriticalSection( &vectored_handlers_section );
236     return ret;
237 }
238
239
240 /**********************************************************************
241  *           call_stack_handlers
242  *
243  * Call the stack handlers chain.
244  */
245 static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
246 {
247     EXCEPTION_REGISTRATION_RECORD *frame, *dispatch, *nested_frame;
248     DWORD res;
249
250     frame = NtCurrentTeb()->Tib.ExceptionList;
251     nested_frame = NULL;
252     while (frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL)
253     {
254         /* Check frame address */
255         if (((void*)frame < NtCurrentTeb()->Tib.StackLimit) ||
256             ((void*)(frame+1) > NtCurrentTeb()->Tib.StackBase) ||
257             (ULONG_PTR)frame & 3)
258         {
259             rec->ExceptionFlags |= EH_STACK_INVALID;
260             break;
261         }
262
263         /* Call handler */
264         TRACE( "calling handler at %p code=%lx flags=%lx\n",
265                frame->Handler, rec->ExceptionCode, rec->ExceptionFlags );
266         res = EXC_CallHandler( rec, frame, context, &dispatch, frame->Handler, EXC_RaiseHandler );
267         TRACE( "handler at %p returned %lx\n", frame->Handler, res );
268
269         if (frame == nested_frame)
270         {
271             /* no longer nested */
272             nested_frame = NULL;
273             rec->ExceptionFlags &= ~EH_NESTED_CALL;
274         }
275
276         switch(res)
277         {
278         case ExceptionContinueExecution:
279             if (!(rec->ExceptionFlags & EH_NONCONTINUABLE)) return STATUS_SUCCESS;
280             return STATUS_NONCONTINUABLE_EXCEPTION;
281         case ExceptionContinueSearch:
282             break;
283         case ExceptionNestedException:
284             if (nested_frame < dispatch) nested_frame = dispatch;
285             rec->ExceptionFlags |= EH_NESTED_CALL;
286             break;
287         default:
288             return STATUS_INVALID_DISPOSITION;
289         }
290         frame = frame->Prev;
291     }
292     return STATUS_UNHANDLED_EXCEPTION;
293 }
294
295
296 /*******************************************************************
297  *              raise_exception
298  *
299  * Implementation of NtRaiseException.
300  */
301 static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
302 {
303     NTSTATUS status;
304
305     if (first_chance)
306     {
307         DWORD c;
308
309         TRACE( "code=%lx flags=%lx addr=%p\n",
310                rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
311         for (c = 0; c < rec->NumberParameters; c++)
312             TRACE( " info[%ld]=%08lx\n", c, rec->ExceptionInformation[c] );
313         if (rec->ExceptionCode == EXCEPTION_WINE_STUB)
314         {
315             if (rec->ExceptionInformation[1] >> 16)
316                 MESSAGE( "wine: Call from %p to unimplemented function %s.%s, aborting\n",
317                          rec->ExceptionAddress,
318                          (char*)rec->ExceptionInformation[0], (char*)rec->ExceptionInformation[1] );
319             else
320                 MESSAGE( "wine: Call from %p to unimplemented function %s.%ld, aborting\n",
321                          rec->ExceptionAddress,
322                          (char*)rec->ExceptionInformation[0], rec->ExceptionInformation[1] );
323         }
324 #ifdef __i386__
325         else
326         {
327             TRACE(" eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
328                   context->Eax, context->Ebx, context->Ecx,
329                   context->Edx, context->Esi, context->Edi );
330             TRACE(" ebp=%08lx esp=%08lx cs=%04lx ds=%04lx es=%04lx fs=%04lx gs=%04lx flags=%08lx\n",
331                   context->Ebp, context->Esp, context->SegCs, context->SegDs,
332                   context->SegEs, context->SegFs, context->SegGs, context->EFlags );
333         }
334 #endif
335         status = send_debug_event( rec, TRUE, context );
336         if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED)
337             return STATUS_SUCCESS;
338
339         if (call_vectored_handlers( rec, context ) == EXCEPTION_CONTINUE_EXECUTION)
340             return STATUS_SUCCESS;
341
342         if ((status = call_stack_handlers( rec, context )) != STATUS_UNHANDLED_EXCEPTION)
343             return status;
344     }
345
346     /* last chance exception */
347
348     status = send_debug_event( rec, FALSE, context );
349     if (status != DBG_CONTINUE)
350     {
351         if (rec->ExceptionFlags & EH_STACK_INVALID)
352             ERR("Exception frame is not in stack limits => unable to dispatch exception.\n");
353         else if (rec->ExceptionCode == STATUS_NONCONTINUABLE_EXCEPTION)
354             ERR("Process attempted to continue execution after noncontinuable exception.\n");
355         else
356             ERR("Unhandled exception code %lx flags %lx addr %p\n",
357                 rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
358         NtTerminateProcess( NtCurrentProcess(), 1 );
359     }
360     return STATUS_SUCCESS;
361 }
362
363
364 /*******************************************************************
365  *              NtRaiseException (NTDLL.@)
366  */
367 NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
368 {
369     NTSTATUS status = raise_exception( rec, context, first_chance );
370     if (status == STATUS_SUCCESS) NtSetContextThread( GetCurrentThread(), context );
371     return status;
372 }
373
374 /***********************************************************************
375  *              RtlRaiseException (NTDLL.@)
376  */
377 void WINAPI __regs_RtlRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context )
378 {
379     NTSTATUS status = raise_exception( rec, context, TRUE );
380     if (status != STATUS_SUCCESS)
381     {
382         EXCEPTION_RECORD newrec;
383         newrec.ExceptionCode    = status;
384         newrec.ExceptionFlags   = EH_NONCONTINUABLE;
385         newrec.ExceptionRecord  = rec;
386         newrec.NumberParameters = 0;
387         RtlRaiseException( &newrec );  /* never returns */
388     }
389 }
390
391 /**********************************************************************/
392
393 #ifdef DEFINE_REGS_ENTRYPOINT
394 DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 4, 4 );
395 #else
396 void WINAPI RtlRaiseException( EXCEPTION_RECORD *rec )
397 {
398     CONTEXT context;
399     memset( &context, 0, sizeof(context) );
400     __regs_RtlRaiseException( rec, &context );
401 }
402 #endif
403
404
405 /*******************************************************************
406  *              RtlUnwind (NTDLL.@)
407  */
408 void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID unusedEip,
409                               PEXCEPTION_RECORD pRecord, PVOID returnEax, CONTEXT *context )
410 {
411     EXCEPTION_RECORD record, newrec;
412     EXCEPTION_REGISTRATION_RECORD *frame, *dispatch;
413     DWORD res;
414
415 #ifdef __i386__
416     context->Eax = (DWORD)returnEax;
417 #endif
418
419     /* build an exception record, if we do not have one */
420     if (!pRecord)
421     {
422         record.ExceptionCode    = STATUS_UNWIND;
423         record.ExceptionFlags   = 0;
424         record.ExceptionRecord  = NULL;
425         record.ExceptionAddress = GET_IP(context);
426         record.NumberParameters = 0;
427         pRecord = &record;
428     }
429
430     pRecord->ExceptionFlags |= EH_UNWINDING | (pEndFrame ? 0 : EH_EXIT_UNWIND);
431
432     TRACE( "code=%lx flags=%lx\n", pRecord->ExceptionCode, pRecord->ExceptionFlags );
433
434     /* get chain of exception frames */
435     frame = NtCurrentTeb()->Tib.ExceptionList;
436     while ((frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL) && (frame != pEndFrame))
437     {
438         /* Check frame address */
439         if (pEndFrame && (frame > pEndFrame))
440         {
441             newrec.ExceptionCode    = STATUS_INVALID_UNWIND_TARGET;
442             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
443             newrec.ExceptionRecord  = pRecord;
444             newrec.NumberParameters = 0;
445             RtlRaiseException( &newrec );  /* never returns */
446         }
447         if (((void*)frame < NtCurrentTeb()->Tib.StackLimit) ||
448             ((void*)(frame+1) > NtCurrentTeb()->Tib.StackBase) ||
449             (UINT_PTR)frame & 3)
450         {
451             newrec.ExceptionCode    = STATUS_BAD_STACK;
452             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
453             newrec.ExceptionRecord  = pRecord;
454             newrec.NumberParameters = 0;
455             RtlRaiseException( &newrec );  /* never returns */
456         }
457
458         /* Call handler */
459         TRACE( "calling handler at %p code=%lx flags=%lx\n",
460                frame->Handler, pRecord->ExceptionCode, pRecord->ExceptionFlags );
461         res = EXC_CallHandler( pRecord, frame, context, &dispatch, frame->Handler, EXC_UnwindHandler );
462         TRACE( "handler at %p returned %lx\n", frame->Handler, res );
463
464         switch(res)
465         {
466         case ExceptionContinueSearch:
467             break;
468         case ExceptionCollidedUnwind:
469             frame = dispatch;
470             break;
471         default:
472             newrec.ExceptionCode    = STATUS_INVALID_DISPOSITION;
473             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
474             newrec.ExceptionRecord  = pRecord;
475             newrec.NumberParameters = 0;
476             RtlRaiseException( &newrec );  /* never returns */
477             break;
478         }
479         frame = __wine_pop_frame( frame );
480     }
481 }
482
483 /**********************************************************************/
484
485 #ifdef DEFINE_REGS_ENTRYPOINT
486 DEFINE_REGS_ENTRYPOINT( RtlUnwind, 16, 16 );
487 #else
488 void WINAPI RtlUnwind( PVOID pEndFrame, PVOID unusedEip,
489                        PEXCEPTION_RECORD pRecord, PVOID returnEax )
490 {
491     CONTEXT context;
492     memset( &context, 0, sizeof(context) );
493     __regs_RtlUnwind( pEndFrame, unusedEip, pRecord, returnEax, &context );
494 }
495 #endif
496
497
498 /***********************************************************************
499  *            RtlRaiseStatus  (NTDLL.@)
500  *
501  * Raise an exception with ExceptionCode = status
502  */
503 void WINAPI RtlRaiseStatus( NTSTATUS status )
504 {
505     EXCEPTION_RECORD ExceptionRec;
506
507     ExceptionRec.ExceptionCode    = status;
508     ExceptionRec.ExceptionFlags   = EH_NONCONTINUABLE;
509     ExceptionRec.ExceptionRecord  = NULL;
510     ExceptionRec.NumberParameters = 0;
511     RtlRaiseException( &ExceptionRec );
512 }
513
514
515 /*******************************************************************
516  *         RtlAddVectoredExceptionHandler   (NTDLL.@)
517  */
518 PVOID WINAPI RtlAddVectoredExceptionHandler( ULONG first, PVECTORED_EXCEPTION_HANDLER func )
519 {
520     VECTORED_HANDLER *handler = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*handler) );
521     if (handler)
522     {
523         handler->func = func;
524         RtlEnterCriticalSection( &vectored_handlers_section );
525         if (first) list_add_head( &vectored_handlers, &handler->entry );
526         else list_add_tail( &vectored_handlers, &handler->entry );
527         RtlLeaveCriticalSection( &vectored_handlers_section );
528     }
529     return handler;
530 }
531
532
533 /*******************************************************************
534  *         RtlRemoveVectoredExceptionHandler   (NTDLL.@)
535  */
536 ULONG WINAPI RtlRemoveVectoredExceptionHandler( PVOID handler )
537 {
538     struct list *ptr;
539     ULONG ret = FALSE;
540
541     RtlEnterCriticalSection( &vectored_handlers_section );
542     LIST_FOR_EACH( ptr, &vectored_handlers )
543     {
544         VECTORED_HANDLER *curr_handler = LIST_ENTRY( ptr, VECTORED_HANDLER, entry );
545         if (curr_handler == handler)
546         {
547             list_remove( ptr );
548             ret = TRUE;
549             break;
550         }
551     }
552     RtlLeaveCriticalSection( &vectored_handlers_section );
553     if (ret) RtlFreeHeap( GetProcessHeap(), 0, handler );
554     return ret;
555 }
556
557
558 /*************************************************************
559  *            __wine_exception_handler (NTDLL.@)
560  *
561  * Exception handler for exception blocks declared in Wine code.
562  */
563 DWORD __wine_exception_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
564                                 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
565 {
566     __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
567
568     if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
569         return ExceptionContinueSearch;
570
571     if (wine_frame->u.filter == (void *)1)  /* special hack for page faults */
572     {
573         if (record->ExceptionCode != STATUS_ACCESS_VIOLATION)
574             return ExceptionContinueSearch;
575     }
576     else if (wine_frame->u.filter)
577     {
578         EXCEPTION_POINTERS ptrs;
579         ptrs.ExceptionRecord = record;
580         ptrs.ContextRecord = context;
581         switch(wine_frame->u.filter( &ptrs ))
582         {
583         case EXCEPTION_CONTINUE_SEARCH:
584             return ExceptionContinueSearch;
585         case EXCEPTION_CONTINUE_EXECUTION:
586             return ExceptionContinueExecution;
587         case EXCEPTION_EXECUTE_HANDLER:
588             break;
589         default:
590             MESSAGE( "Invalid return value from exception filter\n" );
591             assert( FALSE );
592         }
593     }
594     /* hack to make GetExceptionCode() work in handler */
595     wine_frame->ExceptionCode   = record->ExceptionCode;
596     wine_frame->ExceptionRecord = wine_frame;
597
598     RtlUnwind( frame, 0, record, 0 );
599     __wine_pop_frame( frame );
600     siglongjmp( wine_frame->jmp, 1 );
601 }
602
603
604 /*************************************************************
605  *            __wine_finally_handler (NTDLL.@)
606  *
607  * Exception handler for try/finally blocks declared in Wine code.
608  */
609 DWORD __wine_finally_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
610                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
611 {
612     if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
613     {
614         __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
615         wine_frame->u.finally_func( FALSE );
616     }
617     return ExceptionContinueSearch;
618 }
619
620
621 /*************************************************************
622  *            __wine_spec_unimplemented_stub
623  *
624  * ntdll-specific implementation to avoid depending on kernel functions.
625  * Can be removed once ntdll.spec no longer contains stubs.
626  */
627 void __wine_spec_unimplemented_stub( const char *module, const char *function )
628 {
629     EXCEPTION_RECORD record;
630
631     record.ExceptionCode    = EXCEPTION_WINE_STUB;
632     record.ExceptionFlags   = EH_NONCONTINUABLE;
633     record.ExceptionRecord  = NULL;
634     record.ExceptionAddress = __wine_spec_unimplemented_stub;
635     record.NumberParameters = 2;
636     record.ExceptionInformation[0] = (ULONG_PTR)module;
637     record.ExceptionInformation[1] = (ULONG_PTR)function;
638     RtlRaiseException( &record );
639 }