ReactOS 0.4.15-dev-7942-gd23573b
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
17typedef NTSTATUS (NTAPI *USER_CALL)(PVOID Argument, ULONG ArgumentLength);
18
19/* FUNCTIONS ****************************************************************/
20
21/*
22 * @implemented
23 */
24VOID
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 */
57VOID
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 */
76VOID
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}
#define NtCurrentPeb()
Definition: FLS.c:22
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
NTSTATUS(NTAPI * USER_CALL)(PVOID Argument, ULONG ArgumentLength)
Definition: dispatch.c:17
VOID NTAPI KiUserCallbackDispatcher(ULONG Index, PVOID Argument, ULONG ArgumentLength)
Definition: dispatch.c:78
VOID NTAPI KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context)
Definition: dispatch.c:26
VOID NTAPI KiRaiseUserExceptionDispatcher(VOID)
Definition: dispatch.c:59
#define NTSTATUS
Definition: precomp.h:21
struct _TEB * PTEB
Status
Definition: gdiplustypes.h:25
#define NtCurrentTeb
NTSYSAPI NTSTATUS NTAPI ZwCallbackReturn(_In_ PVOID Result, _In_ ULONG ResultLength, _In_ NTSTATUS Status)
NTSYSAPI BOOLEAN NTAPI RtlDispatchException(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
Definition: except.c:43
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
NTSTATUS NTAPI NtContinue(IN PCONTEXT Context, IN BOOLEAN TestAlert)
Definition: except.c:220
NTSTATUS NTAPI NtRaiseException(IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN BOOLEAN FirstChance)
Definition: except.c:179
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index