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.

190 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1991-1998 Microsoft Corporation
  3. Module Name:
  4. memcard.c
  5. Abstract:
  6. Author:
  7. Neil Sandlin (neilsa) 26-Apr-99
  8. Environment:
  9. Kernel mode only.
  10. --*/
  11. #include "pch.h"
  12. //
  13. // Internal References
  14. //
  15. NTSTATUS
  16. DriverEntry(
  17. IN PDRIVER_OBJECT DriverObject,
  18. IN PUNICODE_STRING RegistryPath
  19. );
  20. VOID
  21. MemCardUnload(
  22. IN PDRIVER_OBJECT DriverObject
  23. );
  24. NTSTATUS
  25. MemCardCreateClose(
  26. IN PDEVICE_OBJECT DeviceObject,
  27. IN PIRP Irp
  28. );
  29. #ifdef ALLOC_PRAGMA
  30. #pragma alloc_text(INIT,DriverEntry)
  31. #pragma alloc_text(PAGE,MemCardCreateClose)
  32. #endif
  33. NTSTATUS
  34. DriverEntry(
  35. IN PDRIVER_OBJECT DriverObject,
  36. IN PUNICODE_STRING RegistryPath
  37. )
  38. /*++
  39. Routine Description:
  40. This routine is the driver's entry point, called by the I/O system
  41. to load the driver. The driver's entry points are initialized and
  42. a mutex to control paging is initialized.
  43. In DBG mode, this routine also examines the registry for special
  44. debug parameters.
  45. Arguments:
  46. DriverObject - a pointer to the object that represents this device
  47. driver.
  48. RegistryPath - a pointer to this driver's key in the Services tree.
  49. Return Value:
  50. STATUS_SUCCESS unless we can't allocate a mutex.
  51. --*/
  52. {
  53. NTSTATUS ntStatus = STATUS_SUCCESS;
  54. MemCardDump(MEMCARDSHOW, ("MemCard: DriverEntry\n") );
  55. //
  56. // Initialize the driver object with this driver's entry points.
  57. //
  58. DriverObject->MajorFunction[IRP_MJ_CREATE] = MemCardCreateClose;
  59. DriverObject->MajorFunction[IRP_MJ_CLOSE] = MemCardCreateClose;
  60. DriverObject->MajorFunction[IRP_MJ_READ] = MemCardIrpReadWrite;
  61. DriverObject->MajorFunction[IRP_MJ_WRITE] = MemCardIrpReadWrite;
  62. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = MemCardDeviceControl;
  63. DriverObject->MajorFunction[IRP_MJ_PNP] = MemCardPnp;
  64. DriverObject->MajorFunction[IRP_MJ_POWER] = MemCardPower;
  65. DriverObject->DriverUnload = MemCardUnload;
  66. DriverObject->DriverExtension->AddDevice = MemCardAddDevice;
  67. return ntStatus;
  68. }
  69. VOID
  70. MemCardUnload(
  71. IN PDRIVER_OBJECT DriverObject
  72. )
  73. /*++
  74. Routine Description:
  75. Unload the driver from the system. The paging mutex is freed before
  76. final unload.
  77. Arguments:
  78. DriverObject - a pointer to the object that represents this device
  79. driver.
  80. Return Value:
  81. none
  82. --*/
  83. {
  84. MemCardDump( MEMCARDSHOW, ("MemCardUnload:\n"));
  85. //
  86. // The device object(s) should all be gone by now.
  87. //
  88. ASSERT( DriverObject->DeviceObject == NULL );
  89. return;
  90. }
  91. NTSTATUS
  92. MemCardCreateClose(
  93. IN PDEVICE_OBJECT DeviceObject,
  94. IN PIRP Irp
  95. )
  96. /*++
  97. Routine Description:
  98. This routine is called only rarely by the I/O system; it's mainly
  99. for layered drivers to call. All it does is complete the IRP
  100. successfully.
  101. Arguments:
  102. DeviceObject - a pointer to the object that represents the device
  103. that I/O is to be done on.
  104. Irp - a pointer to the I/O Request Packet for this request.
  105. Return Value:
  106. Always returns STATUS_SUCCESS, since this is a null operation.
  107. --*/
  108. {
  109. UNREFERENCED_PARAMETER( DeviceObject );
  110. MemCardDump(
  111. MEMCARDSHOW,
  112. ("MemCardCreateClose...\n")
  113. );
  114. //
  115. // Null operation. Do not give an I/O boost since
  116. // no I/O was actually done. IoStatus.Information should be
  117. // FILE_OPENED for an open; it's undefined for a close.
  118. //
  119. Irp->IoStatus.Status = STATUS_SUCCESS;
  120. Irp->IoStatus.Information = FILE_OPENED;
  121. IoCompleteRequest( Irp, IO_NO_INCREMENT );
  122. return STATUS_SUCCESS;
  123. }