int ipfw_module_init(void) { int ret = 0; rn_init(64); my_mod_register("ipfw", 1, moddesc_ipfw, NULL, NULL); my_mod_register("sy_ipfw", 2, NULL, sysinit_ipfw_init, sysuninit_ipfw_destroy); my_mod_register("sy_Vnet_ipfw", 3, NULL, sysinit_vnet_ipfw_init, sysuninit_vnet_ipfw_uninit); my_mod_register("dummynet", 4, moddesc_dummynet, NULL, NULL); my_mod_register("dn_fifo", 5, moddesc_dn_fifo, NULL, NULL); my_mod_register("dn_wf2qp", 6, moddesc_dn_wf2qp, NULL, NULL); my_mod_register("dn_rr", 7, moddesc_dn_rr, NULL, NULL); my_mod_register("dn_qfq", 8, moddesc_dn_qfq, NULL, NULL); my_mod_register("dn_prio", 9, moddesc_dn_prio, NULL, NULL); init_children(); #ifdef EMULATE_SYSCTL keinit_GST(); #endif return ret; }
NTSTATUS DriverEntry(__in PDRIVER_OBJECT DriverObject, __in PUNICODE_STRING RegistryPath) { NTSTATUS ntStatus; UNICODE_STRING ntUnicodeString; UNICODE_STRING ntWin32NameString; PDEVICE_OBJECT deviceObject = NULL; // pointer to the instanced device object // PDEVICE_DESCRIPTION devDes; UNREFERENCED_PARAMETER(RegistryPath); UNREFERENCED_PARAMETER(deviceObject); RtlInitUnicodeString(&ntUnicodeString, NETMAP_NT_DEVICE_NAME); ntStatus = IoCreateDevice( DriverObject, // The Driver Object 0, // DeviceExtensionSize &ntUnicodeString, // DeviceName FILE_DEVICE_UNKNOWN, // Device type FILE_DEVICE_SECURE_OPEN, // Device characteristics FALSE, // Not exclusive &deviceObject ); // Returned pointer to the device if ( !NT_SUCCESS( ntStatus ) ) { DbgPrint("NETMAP.SYS: Couldn't create the device object\n"); return ntStatus; } DbgPrint("NETMAP.SYS: Driver loaded at address 0x%p \n",&deviceObject); // Init function pointers to major driver functions DriverObject->MajorFunction[IRP_MJ_CREATE] = ioctlCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE] = ioctlClose; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ioctlDeviceControl; DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ioctlInternalDeviceControl; //DriverObject->MajorFunction[IRP_MJ_READ] = ReadSync; //DriverObject->MajorFunction[IRP_MJ_WRITE] = WriteSync; DriverObject->DriverUnload = ioctlUnloadDriver; // Initialize a Unicode String containing the Win32 name // for our device. RtlInitUnicodeString(&ntWin32NameString, NETMAP_DOS_DEVICE_NAME); // Symlink creation ntStatus = IoCreateSymbolicLink(&ntWin32NameString, &ntUnicodeString ); if (netmap_init() != 0) { DbgPrint("NETMAP.SYS: Netmap init FAILED!!!\n"); ntStatus = STATUS_DEVICE_INSUFFICIENT_RESOURCES; } if ( !NT_SUCCESS( ntStatus ) ) { //Clear all in case of not success DbgPrint("NETMAP.SYS: Couldn't create driver\n"); IoDeleteDevice( deviceObject ); } else { keinit_GST(); deviceObject->Flags |= DO_DIRECT_IO; } return ntStatus; }