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 30 DRIVER_DISPATCH ClassDispatchUnimplemented; 31 32 // 33 // Routines start 34 // 35 36 37 VOID 38 ClassInitializeDispatchTables( 39 PCLASS_DRIVER_EXTENSION DriverExtension 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; 58 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControlDispatch; 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 71 NTSTATUS 72 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ 73 ClassGlobalDispatch( 74 IN PDEVICE_OBJECT DeviceObject, 75 IN PIRP Irp 76 ) 77 78 { 79 PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension; 80 PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp); 81 // Code Analysis cannot analyze the code paths specific to clients. 82 _Analysis_assume_(FALSE); 83 return (commonExtension->DispatchTable[irpStack->MajorFunction])(DeviceObject, Irp); 84 85 } 86 87 NTSTATUS 88 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ 89 ClassDispatchUnimplemented( 90 IN PDEVICE_OBJECT DeviceObject, 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 { 118 UNREFERENCED_PARAMETER( DeviceObject ); 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) { 126 PoStartNextPowerIrp(Irp); 127 } 128 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; 129 IoCompleteRequest( Irp, IO_NO_INCREMENT ); 130 return STATUS_INVALID_DEVICE_REQUEST; 131 } 132 133 134