ntdll: Made DBG_EXCEPTION_HANDLED a synonym of DBG_CONTINUE for exception handlers.
[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 /*******************************************************************
82  *         EXC_RaiseHandler
83  *
84  * Handler for exceptions happening inside a handler.
85  */
86 static DWORD EXC_RaiseHandler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
87                                CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
88 {
89     if (rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
90         return ExceptionContinueSearch;
91     /* We shouldn't get here so we store faulty frame in dispatcher */
92     *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
93     return ExceptionNestedException;
94 }
95
96
97 /*******************************************************************
98  *         EXC_UnwindHandler
99  *
100  * Handler for exceptions happening inside an unwind handler.
101  */
102 static DWORD EXC_UnwindHandler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
103                                 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
104 {
105     if (!(rec->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
106         return ExceptionContinueSearch;
107     /* We shouldn't get here so we store faulty frame in dispatcher */
108     *dispatcher = ((EXC_NESTED_FRAME*)frame)->prevFrame;
109     return ExceptionCollidedUnwind;
110 }
111
112
113 /*******************************************************************
114  *         EXC_CallHandler
115  *
116  * Call an exception handler, setting up an exception frame to catch exceptions
117  * happening during the handler execution.
118  *
119  * For i386 this function is implemented in assembler in signal_i386.c.
120  */
121 #ifndef __i386__
122 static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
123                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
124                               PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler)
125 {
126     EXC_NESTED_FRAME newframe;
127     DWORD ret;
128
129     newframe.frame.Handler = nested_handler;
130     newframe.prevFrame     = frame;
131     __wine_push_frame( &newframe.frame );
132     TRACE( "calling handler at %p code=%lx flags=%lx\n",
133            handler, record->ExceptionCode, record->ExceptionFlags );
134     ret = handler( record, frame, context, dispatcher );
135     TRACE( "handler returned %lx\n", ret );
136     __wine_pop_frame( &newframe.frame );
137     return ret;
138 }
139 #else
140 /* in signal_i386.c */
141 extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
142                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
143                               PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler);
144 #endif
145
146 /**********************************************************************
147  *           wait_suspend
148  *
149  * Wait until the thread is no longer suspended.
150  */
151 void wait_suspend( CONTEXT *context )
152 {
153     LARGE_INTEGER timeout;
154
155     /* store the context we got at suspend time */
156     SERVER_START_REQ( set_thread_context )
157     {
158         req->handle  = GetCurrentThread();
159         req->flags   = CONTEXT_FULL;
160         req->suspend = 1;
161         wine_server_add_data( req, context, sizeof(*context) );
162         wine_server_call( req );
163     }
164     SERVER_END_REQ;
165
166     /* wait with 0 timeout, will only return once the thread is no longer suspended */
167     timeout.QuadPart = 0;
168     NTDLL_wait_for_multiple_objects( 0, NULL, 0, &timeout, 0 );
169
170     /* retrieve the new context */
171     SERVER_START_REQ( get_thread_context )
172     {
173         req->handle  = GetCurrentThread();
174         req->flags   = CONTEXT_FULL;
175         req->suspend = 1;
176         wine_server_set_reply( req, context, sizeof(*context) );
177         wine_server_call( req );
178     }
179     SERVER_END_REQ;
180 }
181
182
183 /**********************************************************************
184  *           send_debug_event
185  *
186  * Send an EXCEPTION_DEBUG_EVENT event to the debugger.
187  */
188 static NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context )
189 {
190     int ret;
191     HANDLE handle = 0;
192
193     if (!NtCurrentTeb()->Peb->BeingDebugged) return 0;  /* no debugger present */
194
195     SERVER_START_REQ( queue_exception_event )
196     {
197         req->first   = first_chance;
198         wine_server_add_data( req, context, sizeof(*context) );
199         wine_server_add_data( req, rec, sizeof(*rec) );
200         if (!wine_server_call( req )) handle = reply->handle;
201     }
202     SERVER_END_REQ;
203     if (!handle) return 0;
204
205     NTDLL_wait_for_multiple_objects( 1, &handle, 0, NULL, 0 );
206
207     SERVER_START_REQ( get_exception_status )
208     {
209         req->handle = handle;
210         wine_server_set_reply( req, context, sizeof(*context) );
211         ret = wine_server_call( req );
212     }
213     SERVER_END_REQ;
214     return ret;
215 }
216
217
218 /**********************************************************************
219  *           call_vectored_handlers
220  *
221  * Call the vectored handlers chain.
222  */
223 static LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
224 {
225     struct list *ptr;
226     LONG ret = EXCEPTION_CONTINUE_SEARCH;
227     EXCEPTION_POINTERS except_ptrs;
228
229     except_ptrs.ExceptionRecord = rec;
230     except_ptrs.ContextRecord = context;
231
232     RtlEnterCriticalSection( &vectored_handlers_section );
233     LIST_FOR_EACH( ptr, &vectored_handlers )
234     {
235         VECTORED_HANDLER *handler = LIST_ENTRY( ptr, VECTORED_HANDLER, entry );
236         ret = handler->func( &except_ptrs );
237         if (ret == EXCEPTION_CONTINUE_EXECUTION) break;
238     }
239     RtlLeaveCriticalSection( &vectored_handlers_section );
240     return ret;
241 }
242
243
244 /*******************************************************************
245  *         EXC_DefaultHandling
246  *
247  * Default handling for exceptions. Called when we didn't find a suitable handler.
248  */
249 static void EXC_DefaultHandling( EXCEPTION_RECORD *rec, CONTEXT *context )
250 {
251     if (send_debug_event( rec, FALSE, context ) == DBG_CONTINUE) return;  /* continue execution */
252
253     if (rec->ExceptionFlags & EH_STACK_INVALID)
254         ERR("Exception frame is not in stack limits => unable to dispatch exception.\n");
255     else if (rec->ExceptionCode == STATUS_NONCONTINUABLE_EXCEPTION)
256         ERR("Process attempted to continue execution after noncontinuable exception.\n");
257     else
258         ERR("Unhandled exception code %lx flags %lx addr %p\n",
259             rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
260     NtTerminateProcess( NtCurrentProcess(), 1 );
261 }
262
263
264 /***********************************************************************
265  *              RtlRaiseException (NTDLL.@)
266  */
267 void WINAPI __regs_RtlRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context )
268 {
269     EXCEPTION_REGISTRATION_RECORD *frame, *dispatch, *nested_frame;
270     EXCEPTION_RECORD newrec;
271     DWORD res, c;
272     NTSTATUS status;
273
274     TRACE( "code=%lx flags=%lx addr=%p\n", rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
275     for (c=0; c<rec->NumberParameters; c++) TRACE(" info[%ld]=%08lx\n", c, rec->ExceptionInformation[c]);
276     if (rec->ExceptionCode == EXCEPTION_WINE_STUB)
277     {
278         if (HIWORD(rec->ExceptionInformation[1]))
279             MESSAGE( "wine: Call from %p to unimplemented function %s.%s, aborting\n",
280                    rec->ExceptionAddress,
281                    (char*)rec->ExceptionInformation[0], (char*)rec->ExceptionInformation[1] );
282         else
283             MESSAGE( "wine: Call from %p to unimplemented function %s.%ld, aborting\n",
284                    rec->ExceptionAddress,
285                    (char*)rec->ExceptionInformation[0], rec->ExceptionInformation[1] );
286     }
287 #ifdef __i386__
288     else
289     {
290         TRACE(" eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
291               context->Eax, context->Ebx, context->Ecx,
292               context->Edx, context->Esi, context->Edi );
293         TRACE(" ebp=%08lx esp=%08lx cs=%04lx ds=%04lx es=%04lx fs=%04lx gs=%04lx flags=%08lx\n",
294               context->Ebp, context->Esp, context->SegCs, context->SegDs,
295               context->SegEs, context->SegFs, context->SegGs, context->EFlags );
296     }
297 #endif
298
299     status = send_debug_event( rec, TRUE, context );
300     if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED) return;  /* continue execution */
301
302     if (call_vectored_handlers( rec, context ) == EXCEPTION_CONTINUE_EXECUTION) return;
303
304     frame = NtCurrentTeb()->Tib.ExceptionList;
305     nested_frame = NULL;
306     while (frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL)
307     {
308         /* Check frame address */
309         if (((void*)frame < NtCurrentTeb()->Tib.StackLimit) ||
310             ((void*)(frame+1) > NtCurrentTeb()->Tib.StackBase) ||
311             (ULONG_PTR)frame & 3)
312         {
313             rec->ExceptionFlags |= EH_STACK_INVALID;
314             break;
315         }
316
317         /* Call handler */
318         res = EXC_CallHandler( rec, frame, context, &dispatch, frame->Handler, EXC_RaiseHandler );
319         if (frame == nested_frame)
320         {
321             /* no longer nested */
322             nested_frame = NULL;
323             rec->ExceptionFlags &= ~EH_NESTED_CALL;
324         }
325
326         switch(res)
327         {
328         case ExceptionContinueExecution:
329             if (!(rec->ExceptionFlags & EH_NONCONTINUABLE)) return;
330             newrec.ExceptionCode    = STATUS_NONCONTINUABLE_EXCEPTION;
331             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
332             newrec.ExceptionRecord  = rec;
333             newrec.NumberParameters = 0;
334             RtlRaiseException( &newrec );  /* never returns */
335             break;
336         case ExceptionContinueSearch:
337             break;
338         case ExceptionNestedException:
339             if (nested_frame < dispatch) nested_frame = dispatch;
340             rec->ExceptionFlags |= EH_NESTED_CALL;
341             break;
342         default:
343             newrec.ExceptionCode    = STATUS_INVALID_DISPOSITION;
344             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
345             newrec.ExceptionRecord  = rec;
346             newrec.NumberParameters = 0;
347             RtlRaiseException( &newrec );  /* never returns */
348             break;
349         }
350         frame = frame->Prev;
351     }
352     EXC_DefaultHandling( rec, context );
353 }
354
355 /**********************************************************************/
356
357 #ifdef DEFINE_REGS_ENTRYPOINT
358 DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 4, 4 );
359 #else
360 void WINAPI RtlRaiseException( EXCEPTION_RECORD *rec )
361 {
362     CONTEXT context;
363     memset( &context, 0, sizeof(context) );
364     __regs_RtlRaiseException( rec, &context );
365 }
366 #endif
367
368
369 /*******************************************************************
370  *              RtlUnwind (NTDLL.@)
371  */
372 void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID unusedEip,
373                               PEXCEPTION_RECORD pRecord, PVOID returnEax, CONTEXT *context )
374 {
375     EXCEPTION_RECORD record, newrec;
376     EXCEPTION_REGISTRATION_RECORD *frame, *dispatch;
377
378 #ifdef __i386__
379     context->Eax = (DWORD)returnEax;
380 #endif
381
382     /* build an exception record, if we do not have one */
383     if (!pRecord)
384     {
385         record.ExceptionCode    = STATUS_UNWIND;
386         record.ExceptionFlags   = 0;
387         record.ExceptionRecord  = NULL;
388         record.ExceptionAddress = GET_IP(context);
389         record.NumberParameters = 0;
390         pRecord = &record;
391     }
392
393     pRecord->ExceptionFlags |= EH_UNWINDING | (pEndFrame ? 0 : EH_EXIT_UNWIND);
394
395     TRACE( "code=%lx flags=%lx\n", pRecord->ExceptionCode, pRecord->ExceptionFlags );
396
397     /* get chain of exception frames */
398     frame = NtCurrentTeb()->Tib.ExceptionList;
399     while ((frame != (EXCEPTION_REGISTRATION_RECORD*)~0UL) && (frame != pEndFrame))
400     {
401         /* Check frame address */
402         if (pEndFrame && (frame > pEndFrame))
403         {
404             newrec.ExceptionCode    = STATUS_INVALID_UNWIND_TARGET;
405             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
406             newrec.ExceptionRecord  = pRecord;
407             newrec.NumberParameters = 0;
408             RtlRaiseException( &newrec );  /* never returns */
409         }
410         if (((void*)frame < NtCurrentTeb()->Tib.StackLimit) ||
411             ((void*)(frame+1) > NtCurrentTeb()->Tib.StackBase) ||
412             (UINT_PTR)frame & 3)
413         {
414             newrec.ExceptionCode    = STATUS_BAD_STACK;
415             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
416             newrec.ExceptionRecord  = pRecord;
417             newrec.NumberParameters = 0;
418             RtlRaiseException( &newrec );  /* never returns */
419         }
420
421         /* Call handler */
422         switch(EXC_CallHandler( pRecord, frame, context, &dispatch,
423                                 frame->Handler, EXC_UnwindHandler ))
424         {
425         case ExceptionContinueSearch:
426             break;
427         case ExceptionCollidedUnwind:
428             frame = dispatch;
429             break;
430         default:
431             newrec.ExceptionCode    = STATUS_INVALID_DISPOSITION;
432             newrec.ExceptionFlags   = EH_NONCONTINUABLE;
433             newrec.ExceptionRecord  = pRecord;
434             newrec.NumberParameters = 0;
435             RtlRaiseException( &newrec );  /* never returns */
436             break;
437         }
438         frame = __wine_pop_frame( frame );
439     }
440 }
441
442 /**********************************************************************/
443
444 #ifdef DEFINE_REGS_ENTRYPOINT
445 DEFINE_REGS_ENTRYPOINT( RtlUnwind, 16, 16 );
446 #else
447 void WINAPI RtlUnwind( PVOID pEndFrame, PVOID unusedEip,
448                        PEXCEPTION_RECORD pRecord, PVOID returnEax )
449 {
450     CONTEXT context;
451     memset( &context, 0, sizeof(context) );
452     __regs_RtlUnwind( pEndFrame, unusedEip, pRecord, returnEax, &context );
453 }
454 #endif
455
456
457 /*******************************************************************
458  *              NtRaiseException (NTDLL.@)
459  */
460 void WINAPI __regs_NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *ctx,
461                                   BOOL first, CONTEXT *context )
462 {
463     __regs_RtlRaiseException( rec, ctx );
464     *context = *ctx;
465 }
466
467 #ifdef DEFINE_REGS_ENTRYPOINT
468 DEFINE_REGS_ENTRYPOINT( NtRaiseException, 12, 12 );
469 #else
470 void WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *ctx, BOOL first )
471 {
472     CONTEXT context;
473     memset( &context, 0, sizeof(context) );
474     __regs_NtRaiseException( rec, ctx, first, &context );
475 }
476 #endif
477
478
479 /***********************************************************************
480  *            RtlRaiseStatus  (NTDLL.@)
481  *
482  * Raise an exception with ExceptionCode = status
483  */
484 void WINAPI RtlRaiseStatus( NTSTATUS status )
485 {
486     EXCEPTION_RECORD ExceptionRec;
487
488     ExceptionRec.ExceptionCode    = status;
489     ExceptionRec.ExceptionFlags   = EH_NONCONTINUABLE;
490     ExceptionRec.ExceptionRecord  = NULL;
491     ExceptionRec.NumberParameters = 0;
492     RtlRaiseException( &ExceptionRec );
493 }
494
495
496 /*******************************************************************
497  *         RtlAddVectoredExceptionHandler   (NTDLL.@)
498  */
499 PVOID WINAPI RtlAddVectoredExceptionHandler( ULONG first, PVECTORED_EXCEPTION_HANDLER func )
500 {
501     VECTORED_HANDLER *handler = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*handler) );
502     if (handler)
503     {
504         handler->func = func;
505         RtlEnterCriticalSection( &vectored_handlers_section );
506         if (first) list_add_head( &vectored_handlers, &handler->entry );
507         else list_add_tail( &vectored_handlers, &handler->entry );
508         RtlLeaveCriticalSection( &vectored_handlers_section );
509     }
510     return handler;
511 }
512
513
514 /*******************************************************************
515  *         RtlRemoveVectoredExceptionHandler   (NTDLL.@)
516  */
517 ULONG WINAPI RtlRemoveVectoredExceptionHandler( PVOID handler )
518 {
519     struct list *ptr;
520     ULONG ret = FALSE;
521
522     RtlEnterCriticalSection( &vectored_handlers_section );
523     LIST_FOR_EACH( ptr, &vectored_handlers )
524     {
525         VECTORED_HANDLER *curr_handler = LIST_ENTRY( ptr, VECTORED_HANDLER, entry );
526         if (curr_handler == handler)
527         {
528             list_remove( ptr );
529             ret = TRUE;
530             break;
531         }
532     }
533     RtlLeaveCriticalSection( &vectored_handlers_section );
534     if (ret) RtlFreeHeap( GetProcessHeap(), 0, handler );
535     return ret;
536 }
537
538
539 /*************************************************************
540  *            __wine_exception_handler (NTDLL.@)
541  *
542  * Exception handler for exception blocks declared in Wine code.
543  */
544 DWORD __wine_exception_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
545                                 CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
546 {
547     __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
548
549     if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
550         return ExceptionContinueSearch;
551
552     if (wine_frame->u.filter == (void *)1)  /* special hack for page faults */
553     {
554         if (record->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
555             return ExceptionContinueSearch;
556     }
557     else if (wine_frame->u.filter)
558     {
559         EXCEPTION_POINTERS ptrs;
560         ptrs.ExceptionRecord = record;
561         ptrs.ContextRecord = context;
562         switch(wine_frame->u.filter( &ptrs ))
563         {
564         case EXCEPTION_CONTINUE_SEARCH:
565             return ExceptionContinueSearch;
566         case EXCEPTION_CONTINUE_EXECUTION:
567             return ExceptionContinueExecution;
568         case EXCEPTION_EXECUTE_HANDLER:
569             break;
570         default:
571             MESSAGE( "Invalid return value from exception filter\n" );
572             assert( FALSE );
573         }
574     }
575     /* hack to make GetExceptionCode() work in handler */
576     wine_frame->ExceptionCode   = record->ExceptionCode;
577     wine_frame->ExceptionRecord = wine_frame;
578
579     RtlUnwind( frame, 0, record, 0 );
580     __wine_pop_frame( frame );
581     siglongjmp( wine_frame->jmp, 1 );
582 }
583
584
585 /*************************************************************
586  *            __wine_finally_handler (NTDLL.@)
587  *
588  * Exception handler for try/finally blocks declared in Wine code.
589  */
590 DWORD __wine_finally_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RECORD *frame,
591                               CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher )
592 {
593     if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
594     {
595         __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
596         wine_frame->u.finally_func( FALSE );
597     }
598     return ExceptionContinueSearch;
599 }
600
601
602 /*************************************************************
603  *            __wine_spec_unimplemented_stub
604  *
605  * ntdll-specific implementation to avoid depending on kernel functions.
606  * Can be removed once ntdll.spec no longer contains stubs.
607  */
608 void __wine_spec_unimplemented_stub( const char *module, const char *function )
609 {
610     EXCEPTION_RECORD record;
611
612     record.ExceptionCode    = EXCEPTION_WINE_STUB;
613     record.ExceptionFlags   = EH_NONCONTINUABLE;
614     record.ExceptionRecord  = NULL;
615     record.ExceptionAddress = __wine_spec_unimplemented_stub;
616     record.NumberParameters = 2;
617     record.ExceptionInformation[0] = (ULONG_PTR)module;
618     record.ExceptionInformation[1] = (ULONG_PTR)function;
619     RtlRaiseException( &record );
620 }