2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS User I/O driver
5 * PURPOSE: Driver entry point and protocol initialization
6 * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
14 PDEVICE_OBJECT GlobalDeviceObject
;
15 NDIS_HANDLE GlobalProtocolHandle
;
16 KSPIN_LOCK GlobalAdapterListLock
;
17 LIST_ENTRY GlobalAdapterList
;
19 NDIS_STRING ProtocolName
= RTL_CONSTANT_STRING(L
"NDISUIO");
21 VOID NTAPI
NduUnload(PDRIVER_OBJECT DriverObject
)
23 DPRINT("NDISUIO: Unloaded\n");
28 DriverEntry(PDRIVER_OBJECT DriverObject
,
29 PUNICODE_STRING RegistryPath
)
32 NDIS_PROTOCOL_CHARACTERISTICS Chars
;
33 UNICODE_STRING NtDeviceName
= RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_NT
);
34 UNICODE_STRING DosDeviceName
= RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_DOS
);
36 /* Setup dispatch functions */
37 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = NduDispatchCreate
;
38 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = NduDispatchClose
;
39 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = NduDispatchDeviceControl
;
40 DriverObject
->MajorFunction
[IRP_MJ_READ
] = NduDispatchRead
;
41 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = NduDispatchWrite
;
42 DriverObject
->DriverUnload
= NduUnload
;
44 /* Setup global state */
45 InitializeListHead(&GlobalAdapterList
);
46 KeInitializeSpinLock(&GlobalAdapterListLock
);
48 /* Create the NDISUIO device object */
49 Status
= IoCreateDevice(DriverObject
,
52 FILE_DEVICE_SECURE_OPEN
,
56 if (!NT_SUCCESS(Status
))
58 DPRINT1("Failed to create device object with status 0x%x\n", Status
);
62 /* Create a symbolic link into the DOS devices namespace */
63 Status
= IoCreateSymbolicLink(&DosDeviceName
, &NtDeviceName
);
64 if (!NT_SUCCESS(Status
))
66 DPRINT1("Failed to create symbolic link with status 0x%x\n", Status
);
67 IoDeleteDevice(GlobalDeviceObject
);
71 /* Register the protocol with NDIS */
72 RtlZeroMemory(&Chars
, sizeof(Chars
));
73 Chars
.MajorNdisVersion
= NDIS_MAJOR_VERSION
;
74 Chars
.MinorNdisVersion
= NDIS_MINOR_VERSION
;
75 Chars
.OpenAdapterCompleteHandler
= NduOpenAdapterComplete
;
76 Chars
.CloseAdapterCompleteHandler
= NduCloseAdapterComplete
;
77 Chars
.SendCompleteHandler
= NduSendComplete
;
78 Chars
.TransferDataCompleteHandler
= NduTransferDataComplete
;
79 Chars
.ResetCompleteHandler
= NduResetComplete
;
80 Chars
.RequestCompleteHandler
= NduRequestComplete
;
81 Chars
.ReceiveHandler
= NduReceive
;
82 Chars
.ReceiveCompleteHandler
= NduReceiveComplete
;
83 Chars
.StatusHandler
= NduStatus
;
84 Chars
.StatusCompleteHandler
= NduStatusComplete
;
85 Chars
.Name
= ProtocolName
;
86 Chars
.BindAdapterHandler
= NduBindAdapter
;
87 Chars
.UnbindAdapterHandler
= NduUnbindAdapter
;
89 NdisRegisterProtocol(&Status
,
90 &GlobalProtocolHandle
,
93 if (Status
!= NDIS_STATUS_SUCCESS
)
95 DPRINT1("Failed to register protocol with status 0x%x\n", Status
);
96 IoDeleteSymbolicLink(&DosDeviceName
);
97 IoDeleteDevice(GlobalDeviceObject
);
101 DPRINT("NDISUIO: Loaded\n");
103 return STATUS_SUCCESS
;