ReactOS 0.4.15-dev-7924-g5949c20
dispatch.c
Go to the documentation of this file.
1/*++
2
3Copyright (C) Microsoft Corporation, 1991 - 2005
4
5Module Name:
6
7 dispatch.c
8
9Abstract:
10
11 Code to support multiple dispatch tables.
12
13Environment:
14
15 kernel mode only
16
17Notes:
18
19
20Revision History:
21
22--*/
23
24#include "classp.h"
25
26#ifdef ALLOC_PRAGMA
27#pragma alloc_text(PAGE, ClassInitializeDispatchTables)
28#endif
29
31
32//
33// Routines start
34//
35
36
37VOID
40 )
41{
42 ULONG idx;
43
44 PAGED_CODE();
45
46 //
47 // Initialize the standard device dispatch table
48 //
49
50 for (idx = 0; idx <= IRP_MJ_MAXIMUM_FUNCTION; idx++) {
51 DriverExtension->DeviceMajorFunctionTable[idx] = ClassDispatchUnimplemented;
52 }
53
54 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_CREATE] = ClassCreateClose;
55 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_CLOSE] = ClassCreateClose;
56 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_READ] = ClassReadWrite;
57 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_WRITE] = ClassReadWrite;
59 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SCSI] = ClassInternalIoControl;
60 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SHUTDOWN] = ClassShutdownFlush;
61 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_FLUSH_BUFFERS] = ClassShutdownFlush;
62 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_PNP] = ClassDispatchPnp;
63 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_POWER] = ClassDispatchPower;
64 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SYSTEM_CONTROL] = ClassSystemControl;
65
66
67 return;
68}
69
70
72NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
75 IN PIRP Irp
76 )
77
78{
79 PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
81 // Code Analysis cannot analyze the code paths specific to clients.
83 return (commonExtension->DispatchTable[irpStack->MajorFunction])(DeviceObject, Irp);
84
85}
86
88NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
91 IN PIRP Irp
92 )
93/*++
94
95Routine Description:
96
97 This function is the default dispatch routine. Its
98 responsibility is simply to set the status in the packet to indicate
99 that the operation requested is invalid for this device type, and then
100 complete the packet.
101
102Arguments:
103
104 DeviceObject - Specifies the device object for which this request is
105 bound. Ignored by this routine.
106
107 Irp - Specifies the address of the I/O Request Packet (IRP) for this
108 request.
109
110Return Value:
111
112 The final status is always STATUS_INVALID_DEVICE_REQUEST.
113
114
115--*/
116
117{
119
120 //
121 // Simply store the appropriate status, complete the request, and return
122 // the same status stored in the packet.
123 //
124
127 }
128 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
131}
132
133
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
NTSTATUS NTAPI ClassSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: classwmi.c:221
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
NTSTATUS NTAPI ClassInternalIoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:9394
NTSTATUS NTAPI ClassReadWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:2431
NTSTATUS NTAPI ClassDeviceControlDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: class.c:7258
NTSTATUS NTAPI ClassDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:894
NTSTATUS NTAPI ClassShutdownFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:8773
NTSTATUS NTAPI ClassCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: create.c:57
NTSTATUS NTAPI ClassGlobalDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:73
DRIVER_DISPATCH ClassDispatchUnimplemented
Definition: dispatch.c:30
VOID ClassInitializeDispatchTables(PCLASS_DRIVER_EXTENSION DriverExtension)
Definition: dispatch.c:38
NTSTATUS NTAPI ClassDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: power.c:105
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PDRIVER_DISPATCH * DispatchTable
Definition: classpnp.h:638
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IRP_MJ_SCSI
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_POWER
#define IRP_MJ_MAXIMUM_FUNCTION