Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. driver.c
  5. Abstract:
  6. This module contains the driver entry and unload routines
  7. for ws2ifsl.sys driver.
  8. Author:
  9. Vadim Eydelman (VadimE) Dec-1996
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. // Local routine declarations
  14. NTSTATUS
  15. DriverEntry (
  16. IN PDRIVER_OBJECT DriverObject,
  17. IN PUNICODE_STRING RegistryPath
  18. );
  19. NTSTATUS
  20. DriverUnload (
  21. IN PDRIVER_OBJECT DriverObject
  22. );
  23. #ifdef ALLOC_PRAGMA
  24. #pragma alloc_text(INIT, DriverEntry )
  25. #pragma alloc_text(PAGE, DriverUnload)
  26. #endif
  27. PDEVICE_OBJECT DeviceObject;
  28. FAST_IO_DISPATCH FastIoDispatchTable = {
  29. sizeof (FAST_IO_DISPATCH), // SizeOfFastIoDispatch
  30. NULL, // FastIoCheckIfPossible
  31. NULL, // FastIoRead
  32. NULL, // FastIoWrite
  33. NULL, // FastIoQueryBasicInfo
  34. NULL, // FastIoQueryStandardInfo
  35. NULL, // FastIoLock
  36. NULL, // FastIoUnlockSingle
  37. NULL, // FastIoUnlockAll
  38. NULL, // FastIoUnlockAllByKey
  39. FastIoDeviceControl // FastIoDeviceControl
  40. };
  41. NTSTATUS
  42. DriverEntry (
  43. IN PDRIVER_OBJECT DriverObject,
  44. IN PUNICODE_STRING RegistryPath
  45. )
  46. /*++
  47. Routine Description:
  48. This is the initialization routine for the ws2ifsl device driver.
  49. Arguments:
  50. DriverObject - Pointer to driver object created by the system.
  51. RegistryPath - path to driver's registry ley
  52. Return Value:
  53. Final status from the initialization operation.
  54. --*/
  55. {
  56. NTSTATUS status;
  57. UNICODE_STRING deviceName;
  58. PAGED_CODE( );
  59. #if DBG
  60. ReadDbgInfo (RegistryPath);
  61. #endif
  62. //
  63. // Create the device object. (IoCreateDevice zeroes the memory
  64. // occupied by the object.)
  65. //
  66. RtlInitUnicodeString( &deviceName, WS2IFSL_DEVICE_NAME );
  67. status = IoCreateDevice(
  68. DriverObject, // DriverObject
  69. 0, // DeviceExtension
  70. &deviceName, // DeviceName
  71. FILE_DEVICE_WS2IFSL, // DeviceType
  72. 0, // DeviceCharacteristics
  73. FALSE, // Exclusive
  74. &DeviceObject // DeviceObject
  75. );
  76. if (NT_SUCCESS(status)) {
  77. // Initialize device object
  78. // DeviceObject->Flags |= 0; // Neither direct nor buffering
  79. DeviceObject->StackSize = 1; // No underlying drivers
  80. //
  81. // Initialize the driver object.
  82. //
  83. DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
  84. DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
  85. DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DispatchCleanup;
  86. DriverObject->MajorFunction[IRP_MJ_READ] =
  87. DriverObject->MajorFunction[IRP_MJ_WRITE] = DispatchReadWrite;
  88. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
  89. DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnP;
  90. DriverObject->DriverUnload = DriverUnload;
  91. DriverObject->FastIoDispatch = &FastIoDispatchTable;
  92. //
  93. // Initialize global data.
  94. //
  95. WsPrint (DBG_LOAD, ("WS2IFSL DriverEntry: driver loaded OK\n"));
  96. return STATUS_SUCCESS;
  97. }
  98. else {
  99. WsPrint (DBG_FAILURES|DBG_LOAD,
  100. ("WS2IFSL DriverEntry: unable to create device object: %X\n",
  101. status ));
  102. }
  103. return status;
  104. } // DriverEntry
  105. NTSTATUS
  106. DriverUnload (
  107. IN PDRIVER_OBJECT DriverObject
  108. )
  109. /*++
  110. Routine Description:
  111. This routine releases all resources allocated by the driver
  112. when it is unloaded.
  113. Arguments:
  114. DriverObject - Pointer to driver object created by the system.
  115. Return Value:
  116. STATUS_SUCCESS
  117. --*/
  118. {
  119. PAGED_CODE( );
  120. // Release global resources
  121. IoDeleteDevice (DeviceObject);
  122. WsPrint (DBG_LOAD, ("WS2IFSL DriverUnload: driver unloaded OK\n"));
  123. return STATUS_SUCCESS;
  124. } // DriverUnload