ReactOS
0.4.16-dev-125-g798ea90
createclose.c
Go to the documentation of this file.
1
/*
2
* COPYRIGHT: See COPYING in the top level directory
3
* PROJECT: ReactOS NDIS User I/O driver
4
* FILE: createclose.c
5
* PURPOSE: IRP_MJ_CREATE and IRP_MJ_CLOSE handling
6
* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
7
*/
8
9
#include "
ndisuio.h
"
10
11
//#define NDEBUG
12
#include <debug.h>
13
14
NTSTATUS
15
NTAPI
16
NduDispatchCreate
(
PDEVICE_OBJECT
DeviceObject
,
17
PIRP
Irp
)
18
{
19
PIO_STACK_LOCATION
IrpSp
=
IoGetCurrentIrpStackLocation
(
Irp
);
20
21
ASSERT
(
DeviceObject
==
GlobalDeviceObject
);
22
23
DPRINT
(
"Created file object 0x%x\n"
,
IrpSp
->
FileObject
);
24
25
/* This is associated with an adapter during IOCTL_NDISUIO_OPEN_(WRITE_)DEVICE */
26
IrpSp
->
FileObject
->FsContext =
NULL
;
27
IrpSp
->
FileObject
->FsContext2 =
NULL
;
28
29
/* Completed successfully */
30
Irp
->IoStatus.Status =
STATUS_SUCCESS
;
31
Irp
->IoStatus.Information =
FILE_OPENED
;
32
IoCompleteRequest
(
Irp
,
IO_NO_INCREMENT
);
33
34
/* Return success */
35
return
STATUS_SUCCESS
;
36
}
37
38
NTSTATUS
39
NTAPI
40
NduDispatchClose
(
PDEVICE_OBJECT
DeviceObject
,
41
PIRP
Irp
)
42
{
43
PIO_STACK_LOCATION
IrpSp
=
IoGetCurrentIrpStackLocation
(
Irp
);
44
PNDISUIO_ADAPTER_CONTEXT
AdapterContext =
IrpSp
->
FileObject
->FsContext;
45
PNDISUIO_OPEN_ENTRY
OpenEntry =
IrpSp
->
FileObject
->FsContext2;
46
47
ASSERT
(
DeviceObject
==
GlobalDeviceObject
);
48
49
DPRINT
(
"Closing file object 0x%x\n"
,
IrpSp
->
FileObject
);
50
51
/* Check if this handle was ever associated with an adapter */
52
if
(AdapterContext !=
NULL
)
53
{
54
ASSERT
(OpenEntry !=
NULL
);
55
56
DPRINT
(
"Removing binding to adapter %wZ\n"
, &AdapterContext->
DeviceName
);
57
58
/* Call the our helper */
59
DereferenceAdapterContextWithOpenEntry
(AdapterContext, OpenEntry);
60
}
61
62
/* Completed */
63
Irp
->IoStatus.Status =
STATUS_SUCCESS
;
64
Irp
->IoStatus.Information = 0;
65
IoCompleteRequest
(
Irp
,
IO_NO_INCREMENT
);
66
67
/* Return success */
68
return
STATUS_SUCCESS
;
69
}
IoGetCurrentIrpStackLocation
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
Definition:
Bus_PDO_EvalMethod.c:150
NTSTATUS
LONG NTSTATUS
Definition:
precomp.h:26
Irp
_In_ PIRP Irp
Definition:
csq.h:116
NULL
#define NULL
Definition:
types.h:112
IrpSp
_In_ PIO_STACK_LOCATION IrpSp
Definition:
create.c:4137
NduDispatchClose
NTSTATUS NTAPI NduDispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition:
createclose.c:40
NduDispatchCreate
NTSTATUS NTAPI NduDispatchCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition:
createclose.c:16
GlobalDeviceObject
PDEVICE_OBJECT GlobalDeviceObject
Definition:
main.c:14
DereferenceAdapterContextWithOpenEntry
VOID DereferenceAdapterContextWithOpenEntry(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PNDISUIO_OPEN_ENTRY OpenEntry)
Definition:
misc.c:149
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
ndisuio.h
FILE_OPENED
#define FILE_OPENED
Definition:
nt_native.h:769
IoCompleteRequest
#define IoCompleteRequest
Definition:
irp.c:1240
STATUS_SUCCESS
#define STATUS_SUCCESS
Definition:
shellext.h:65
DPRINT
#define DPRINT
Definition:
sndvol32.h:73
_DEVICE_OBJECT
Definition:
env_spec_w32.h:413
_IO_STACK_LOCATION
Definition:
Bus_PDO_EvalMethod.c:93
_IO_STACK_LOCATION::FileObject
PFILE_OBJECT FileObject
Definition:
iotypes.h:3169
_IRP
Definition:
Bus_PDO_EvalMethod.c:105
_NDISUIO_ADAPTER_CONTEXT
Definition:
ndisuio.h:20
_NDISUIO_ADAPTER_CONTEXT::DeviceName
UNICODE_STRING DeviceName
Definition:
ndisuio.h:44
_NDISUIO_OPEN_ENTRY
Definition:
ndisuio.h:54
NTAPI
#define NTAPI
Definition:
typedefs.h:36
DeviceObject
_In_ PDEVICE_OBJECT DeviceObject
Definition:
wdfdevice.h:2055
IO_NO_INCREMENT
#define IO_NO_INCREMENT
Definition:
iotypes.h:598
drivers
network
ndisuio
createclose.c
Generated on Mon Oct 14 2024 06:06:25 for ReactOS by
1.9.6