2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS User I/O driver
5 * PURPOSE: IRP_MJ_CREATE and IRP_MJ_CLOSE handling
6 * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
16 NduDispatchCreate(PDEVICE_OBJECT DeviceObject
,
19 PIO_STACK_LOCATION IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
21 ASSERT(DeviceObject
== GlobalDeviceObject
);
23 DPRINT("Created file object 0x%x\n", IrpSp
->FileObject
);
25 /* This is associated with an adapter during IOCTL_NDISUIO_OPEN_(WRITE_)DEVICE */
26 IrpSp
->FileObject
->FsContext
= NULL
;
27 IrpSp
->FileObject
->FsContext2
= NULL
;
29 /* Completed successfully */
30 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
31 Irp
->IoStatus
.Information
= FILE_OPENED
;
32 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
35 return STATUS_SUCCESS
;
40 NduDispatchClose(PDEVICE_OBJECT DeviceObject
,
43 PIO_STACK_LOCATION IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
44 PNDISUIO_ADAPTER_CONTEXT AdapterContext
= IrpSp
->FileObject
->FsContext
;
45 PNDISUIO_OPEN_ENTRY OpenEntry
= IrpSp
->FileObject
->FsContext2
;
47 ASSERT(DeviceObject
== GlobalDeviceObject
);
49 DPRINT("Closing file object 0x%x\n", IrpSp
->FileObject
);
51 /* Check if this handle was ever associated with an adapter */
52 if (AdapterContext
!= NULL
)
54 ASSERT(OpenEntry
!= NULL
);
56 DPRINT("Removing binding to adapter %wZ\n", &AdapterContext
->DeviceName
);
58 /* Call the our helper */
59 DereferenceAdapterContextWithOpenEntry(AdapterContext
, OpenEntry
);
63 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
64 Irp
->IoStatus
.Information
= 0;
65 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
68 return STATUS_SUCCESS
;