Leaked source code of windows server 2003
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.

150 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. init.c
  5. Abstract:
  6. This module provides the initialization and unload functions.
  7. Author:
  8. Andy Thornton (andrewth) 20-Oct-97
  9. Revision History:
  10. --*/
  11. #include "SpSim.h"
  12. NTSTATUS
  13. DriverEntry(
  14. IN PDRIVER_OBJECT DriverObject,
  15. IN PUNICODE_STRING RegistryPath
  16. );
  17. VOID
  18. SpSimUnload(
  19. IN PDRIVER_OBJECT DriverObject
  20. );
  21. #ifdef ALLOC_PRAGMA
  22. #pragma alloc_text(INIT, DriverEntry)
  23. #pragma alloc_text(PAGE, SpSimUnload)
  24. #endif
  25. PDRIVER_OBJECT SpSimDriverObject;
  26. NTSTATUS
  27. SpSimDispatchNop(
  28. IN PDEVICE_OBJECT DeviceObject,
  29. IN PIRP Irp
  30. )
  31. /*++
  32. Routine Description:
  33. This routine handles irps like IRP_MJ_DEVICE_CONTROL, which we don't support.
  34. This handler will complete the irp (if PDO) or pass it (if FDO).
  35. Arguments:
  36. DeviceObject - Pointer to the device object for which this IRP applies.
  37. Irp - Pointer to the IRP to dispatch.
  38. Return Value:
  39. NT status.
  40. --*/
  41. {
  42. NTSTATUS status;
  43. PSPSIM_EXTENSION spsim;
  44. PDEVICE_OBJECT attachedDevice;
  45. PAGED_CODE();
  46. spsim = DeviceObject->DeviceExtension;
  47. IoSkipCurrentIrpStackLocation(Irp);
  48. return IoCallDriver(spsim->AttachedDevice, Irp);
  49. }
  50. NTSTATUS
  51. DriverEntry(
  52. IN PDRIVER_OBJECT DriverObject,
  53. IN PUNICODE_STRING RegistryPath
  54. )
  55. /*++
  56. Routine Description:
  57. This is the entry point to SpSim.SYS and performs initialization.
  58. Arguments:
  59. DriverObject - The system owned driver object for SpSim
  60. RegistryPath - The path to SpSim's service entry
  61. Return Value:
  62. STATUS_SUCCESS
  63. --*/
  64. {
  65. DriverObject->DriverExtension->AddDevice = SpSimAddDevice;
  66. DriverObject->MajorFunction[IRP_MJ_CREATE] = SpSimOpenClose;
  67. DriverObject->MajorFunction[IRP_MJ_CLOSE] = SpSimOpenClose;
  68. DriverObject->MajorFunction[IRP_MJ_PNP] = SpSimDispatchPnp;
  69. DriverObject->MajorFunction[IRP_MJ_POWER] = SpSimDispatchPower;
  70. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = SpSimDevControl;
  71. DriverObject->DriverUnload = SpSimUnload;
  72. //
  73. // Remember the driver object
  74. //
  75. SpSimDriverObject = DriverObject;
  76. DEBUG_MSG(1, ("Completed DriverEntry for Driver 0x%08x\n", DriverObject));
  77. return STATUS_SUCCESS;
  78. }
  79. VOID
  80. SpSimUnload(
  81. IN PDRIVER_OBJECT DriverObject
  82. )
  83. /*++
  84. Routine Description:
  85. This is called to reverse any operations performed in DriverEntry before a
  86. driver is unloaded.
  87. Arguments:
  88. DriverObject - The system owned driver object for SpSim
  89. Return Value:
  90. STATUS_SUCCESS
  91. --*/
  92. {
  93. PAGED_CODE();
  94. DEBUG_MSG(1, ("Completed Unload for Driver 0x%08x\n", DriverObject));
  95. return;
  96. }