ReactOS  0.4.15-dev-1197-g8081ba9
dispatch.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (C) Microsoft Corporation, 1991 - 2005
4 
5 Module Name:
6 
7  dispatch.c
8 
9 Abstract:
10 
11  Code to support multiple dispatch tables.
12 
13 Environment:
14 
15  kernel mode only
16 
17 Notes:
18 
19 
20 Revision 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 
37 VOID
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 
72 NTAPI /* 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 
88 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
91  IN PIRP Irp
92  )
93 /*++
94 
95 Routine 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 
102 Arguments:
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 
110 Return 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 
125  if ((IoGetCurrentIrpStackLocation(Irp))->MajorFunction == IRP_MJ_POWER) {
127  }
128  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
131 }
132 
133 
#define IN
Definition: typedefs.h:39
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSTATUS NTAPI ClassCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: create.c:57
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
DRIVER_DISPATCH ClassDispatchUnimplemented
Definition: dispatch.c:30
#define IRP_MJ_SCSI
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI ClassShutdownFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:8773
NTSTATUS NTAPI ClassDeviceControlDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: class.c:7258
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 ClassDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: power.c:105
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
VOID ClassInitializeDispatchTables(PCLASS_DRIVER_EXTENSION DriverExtension)
Definition: dispatch.c:38
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define IRP_MJ_SYSTEM_CONTROL
NTSTATUS NTAPI ClassDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:894
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IRP_MJ_READ
Definition: rdpdr.c:46
NTSTATUS NTAPI ClassSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: classwmi.c:221
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
PDRIVER_DISPATCH * DispatchTable
Definition: classpnp.h:638
NTSTATUS NTAPI ClassGlobalDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:73
#define _Analysis_assume_(expr)
Definition: no_sal2.h:10
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define PAGED_CODE()