Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmain.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS NDIS User I/O driver 00004 * FILE: main.c 00005 * PURPOSE: Driver entry point and protocol initialization 00006 * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org) 00007 */ 00008 00009 #include "ndisuio.h" 00010 00011 //#define NDEBUG 00012 #include <debug.h> 00013 00014 PDEVICE_OBJECT GlobalDeviceObject; 00015 NDIS_HANDLE GlobalProtocolHandle; 00016 KSPIN_LOCK GlobalAdapterListLock; 00017 LIST_ENTRY GlobalAdapterList; 00018 00019 NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO"); 00020 00021 VOID NTAPI NduUnload(PDRIVER_OBJECT DriverObject) 00022 { 00023 DPRINT("NDISUIO: Unloaded\n"); 00024 } 00025 00026 NTSTATUS 00027 NTAPI 00028 DriverEntry(PDRIVER_OBJECT DriverObject, 00029 PUNICODE_STRING RegistryPath) 00030 { 00031 NDIS_STATUS Status; 00032 NDIS_PROTOCOL_CHARACTERISTICS Chars; 00033 UNICODE_STRING NtDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_NT); 00034 UNICODE_STRING DosDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_DOS); 00035 00036 /* Setup dispatch functions */ 00037 DriverObject->MajorFunction[IRP_MJ_CREATE] = NduDispatchCreate; 00038 DriverObject->MajorFunction[IRP_MJ_CLOSE] = NduDispatchClose; 00039 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = NduDispatchDeviceControl; 00040 DriverObject->MajorFunction[IRP_MJ_READ] = NduDispatchRead; 00041 DriverObject->MajorFunction[IRP_MJ_WRITE] = NduDispatchWrite; 00042 DriverObject->DriverUnload = NduUnload; 00043 00044 /* Setup global state */ 00045 InitializeListHead(&GlobalAdapterList); 00046 KeInitializeSpinLock(&GlobalAdapterListLock); 00047 00048 /* Create the NDISUIO device object */ 00049 Status = IoCreateDevice(DriverObject, 00050 0, 00051 &NtDeviceName, 00052 FILE_DEVICE_SECURE_OPEN, 00053 0, 00054 FALSE, 00055 &GlobalDeviceObject); 00056 if (!NT_SUCCESS(Status)) 00057 { 00058 DPRINT1("Failed to create device object with status 0x%x\n", Status); 00059 return Status; 00060 } 00061 00062 /* Create a symbolic link into the DOS devices namespace */ 00063 Status = IoCreateSymbolicLink(&DosDeviceName, &NtDeviceName); 00064 if (!NT_SUCCESS(Status)) 00065 { 00066 DPRINT1("Failed to create symbolic link with status 0x%x\n", Status); 00067 IoDeleteDevice(GlobalDeviceObject); 00068 return Status; 00069 } 00070 00071 /* Register the protocol with NDIS */ 00072 RtlZeroMemory(&Chars, sizeof(Chars)); 00073 Chars.MajorNdisVersion = NDIS_MAJOR_VERSION; 00074 Chars.MinorNdisVersion = NDIS_MINOR_VERSION; 00075 Chars.OpenAdapterCompleteHandler = NduOpenAdapterComplete; 00076 Chars.CloseAdapterCompleteHandler = NduCloseAdapterComplete; 00077 Chars.SendCompleteHandler = NduSendComplete; 00078 Chars.TransferDataCompleteHandler = NduTransferDataComplete; 00079 Chars.ResetCompleteHandler = NduResetComplete; 00080 Chars.RequestCompleteHandler = NduRequestComplete; 00081 Chars.ReceiveHandler = NduReceive; 00082 Chars.ReceiveCompleteHandler = NduReceiveComplete; 00083 Chars.StatusHandler = NduStatus; 00084 Chars.StatusCompleteHandler = NduStatusComplete; 00085 Chars.Name = ProtocolName; 00086 Chars.BindAdapterHandler = NduBindAdapter; 00087 Chars.UnbindAdapterHandler = NduUnbindAdapter; 00088 00089 NdisRegisterProtocol(&Status, 00090 &GlobalProtocolHandle, 00091 &Chars, 00092 sizeof(Chars)); 00093 if (Status != NDIS_STATUS_SUCCESS) 00094 { 00095 DPRINT1("Failed to register protocol with status 0x%x\n", Status); 00096 IoDeleteSymbolicLink(&DosDeviceName); 00097 IoDeleteDevice(GlobalDeviceObject); 00098 return Status; 00099 } 00100 00101 DPRINT("NDISUIO: Loaded\n"); 00102 00103 return STATUS_SUCCESS; 00104 } Generated on Fri May 25 2012 04:15:06 for ReactOS by
1.7.6.1
|