2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Ancillary Function Driver
5 * PURPOSE: MSAFD kernel mode module
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * CSH 01/09-2000 Created
14 /* See debug.h for debug/trace constants */
15 DWORD DebugTraceLevel
= MIN_TRACE
;
23 PDEVICE_OBJECT DeviceObject
,
28 Irp
->IoStatus
.Status
= STATUS_UNSUCCESSFUL
;
29 Irp
->IoStatus
.Information
= 0;
30 return STATUS_UNSUCCESSFUL
;
37 PDEVICE_OBJECT DeviceObject
,
40 * FUNCTION: IOCTL dispatch routine
42 * DeviceObject = Pointer to a device object for this driver
43 * Irp = Pointer to a I/O request packet
45 * Status of the operation
49 PIO_STACK_LOCATION IrpSp
;
51 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
53 AFD_DbgPrint(MAX_TRACE
, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X), IrpSp->FileObject (0x%X).\n",
54 DeviceObject
, Irp
, IrpSp
->FileObject
));
56 Irp
->IoStatus
.Information
= 0;
58 switch (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
) {
60 Status
= AfdDispBind(Irp
, IrpSp
);
63 case IOCTL_AFD_LISTEN
:
64 Status
= AfdDispListen(Irp
, IrpSp
);
67 case IOCTL_AFD_SENDTO
:
68 Status
= AfdDispSendTo(Irp
, IrpSp
);
71 case IOCTL_AFD_RECVFROM
:
72 Status
= AfdDispRecvFrom(Irp
, IrpSp
);
76 AFD_DbgPrint(MIN_TRACE
, ("Unknown IOCTL (0x%X).\n",
77 IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
));
78 Status
= STATUS_NOT_IMPLEMENTED
;
82 if (Status
!= STATUS_PENDING
) {
83 Irp
->IoStatus
.Status
= Status
;
84 IoCompleteRequest(Irp
, IO_NETWORK_INCREMENT
);
87 AFD_DbgPrint(MAX_TRACE
, ("Leaving. Status (0x%X).\n", Status
));
94 PDRIVER_OBJECT DriverObject
)
96 * FUNCTION: Unloads the driver
98 * DriverObject = Pointer to driver object created by the system
101 DbgPrint("Unloading Ancillary Function Driver\n");
108 PDRIVER_OBJECT DriverObject
,
109 PUNICODE_STRING RegistryPath
)
111 * FUNCTION: Called by the system to initialize the driver
113 * DriverObject = object describing this driver
114 * RegistryPath = path to our configuration entries
116 * Status of operation
119 PDEVICE_EXTENSION DeviceExt
;
120 PDEVICE_OBJECT DeviceObject
;
121 UNICODE_STRING DeviceName
;
124 DbgPrint("Ancillary Function Driver\n");
126 RtlInitUnicodeString(&DeviceName
, L
"\\Device\\Afd");
127 Status
= IoCreateDevice(DriverObject
,
128 sizeof(DEVICE_EXTENSION
),
130 FILE_DEVICE_NAMED_PIPE
,
134 if (!NT_SUCCESS(Status
)) {
135 AFD_DbgPrint(MIN_TRACE
, ("Could not create device (0x%X).\n", Status
));
139 DeviceObject
->Flags
|= DO_DIRECT_IO
;
141 DeviceExt
= DeviceObject
->DeviceExtension
;
142 KeInitializeSpinLock(&DeviceExt
->FCBListLock
);
143 InitializeListHead(&DeviceExt
->FCBListHead
);
145 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = AfdCreate
;
146 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = AfdClose
;
147 DriverObject
->MajorFunction
[IRP_MJ_READ
] = AfdRead
;
148 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = AfdWrite
;
149 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] = AfdFileSystemControl
;
150 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = AfdDispatch
;
151 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = AfdClose
;
153 DriverObject
->DriverUnload
= (PDRIVER_UNLOAD
)AfdUnload
;
155 return STATUS_SUCCESS
;