ReactOS  0.4.14-dev-293-g2b39b42
dispatch.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS NT Library
4  * FILE: dll/ntdll/dispatch/dispatch.c
5  * PURPOSE: User-Mode NT Dispatchers
6  * PROGRAMERS: Alex Ionescu (alex@relsoft.net)
7  * David Welch <welch@cwcom.net>
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include <ntdll.h>
13 
14 #define NDEBUG
15 #include <debug.h>
16 
17 typedef NTSTATUS (NTAPI *USER_CALL)(PVOID Argument, ULONG ArgumentLength);
18 
19 /* FUNCTIONS ****************************************************************/
20 
21 /*
22  * @implemented
23  */
24 VOID
25 NTAPI
28 {
29  EXCEPTION_RECORD NestedExceptionRecord;
31 
32  /* Dispatch the exception and check the result */
33  if (RtlDispatchException(ExceptionRecord, Context))
34  {
35  /* Continue executing */
37  }
38  else
39  {
40  /* Raise an exception */
41  Status = NtRaiseException(ExceptionRecord, Context, FALSE);
42  }
43 
44  /* Setup the Exception record */
45  NestedExceptionRecord.ExceptionCode = Status;
46  NestedExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
47  NestedExceptionRecord.ExceptionRecord = ExceptionRecord;
48  NestedExceptionRecord.NumberParameters = Status;
49 
50  /* Raise the exception */
51  RtlRaiseException(&NestedExceptionRecord);
52 }
53 
54 /*
55  * @implemented
56  */
57 VOID
58 NTAPI
60 {
61  EXCEPTION_RECORD ExceptionRecord;
62 
63  /* Setup the exception record */
64  ExceptionRecord.ExceptionCode = ((PTEB)NtCurrentTeb())->ExceptionCode;
65  ExceptionRecord.ExceptionFlags = 0;
66  ExceptionRecord.ExceptionRecord = NULL;
67  ExceptionRecord.NumberParameters = 0;
68 
69  /* Raise the exception */
70  RtlRaiseException(&ExceptionRecord);
71 }
72 
73 /*
74  * @implemented
75  */
76 VOID
77 NTAPI
79  PVOID Argument,
80  ULONG ArgumentLength)
81 {
82  /* Return with the result of the callback function */
83  USER_CALL *KernelCallbackTable = NtCurrentPeb()->KernelCallbackTable;
85  0,
86  KernelCallbackTable[Index](Argument, ArgumentLength));
87 }
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1782
LONG NTSTATUS
Definition: precomp.h:26
#define EXCEPTION_NONCONTINUABLE
Definition: rtltypes.h:150
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
NTSYSAPI NTSTATUS NTAPI ZwCallbackReturn(_In_ PVOID Result, _In_ ULONG ResultLength, _In_ NTSTATUS Status)
DWORD ExceptionCode
Definition: compat.h:196
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI NtContinue(IN PCONTEXT Context, IN BOOLEAN TestAlert)
Definition: except.c:212
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtRaiseException(IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN BOOLEAN FirstChance)
Definition: except.c:171
VOID NTAPI KiUserCallbackDispatcher(ULONG Index, PVOID Argument, ULONG ArgumentLength)
Definition: dispatch.c:78
NTSYSAPI BOOLEAN NTAPI RtlDispatchException(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
Definition: except.c:34
static const UCHAR Index[8]
Definition: usbohci.c:18
#define NTSTATUS
Definition: precomp.h:20
Status
Definition: gdiplustypes.h:24
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:198
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define NtCurrentPeb()
Definition: FLS.c:20
struct _TEB * PTEB
VOID NTAPI KiRaiseUserExceptionDispatcher(VOID)
Definition: dispatch.c:59
unsigned int ULONG
Definition: retypes.h:1
DWORD ExceptionFlags
Definition: compat.h:197
VOID NTAPI KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context)
Definition: dispatch.c:26
DWORD NumberParameters
Definition: compat.h:200
NTSTATUS(NTAPI * USER_CALL)(PVOID Argument, ULONG ArgumentLength)
Definition: dispatch.c:17