Windows NT 4.0 source code leak
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.

193 lines
4.7 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. msinit.c
  5. Abstract:
  6. This module implements the DRIVER_INITIALIZATION routine for the
  7. mailslot file system.
  8. Author:
  9. Manny Weiser (mannyw) 7-Jan-91
  10. Revision History:
  11. --*/
  12. #include "mailslot.h"
  13. //#include <zwapi.h>
  14. NTSTATUS
  15. DriverEntry(
  16. IN PDRIVER_OBJECT DriverObject,
  17. IN PUNICODE_STRING RegistryPath
  18. );
  19. #ifdef ALLOC_PRAGMA
  20. #pragma alloc_text( PAGE, DriverEntry )
  21. #endif
  22. NTSTATUS
  23. DriverEntry(
  24. IN PDRIVER_OBJECT DriverObject,
  25. IN PUNICODE_STRING RegistryPath
  26. )
  27. /*++
  28. Routine Description:
  29. This is the initialization routine for the mailslot file system
  30. device driver. This routine creates the device object for the mailslot
  31. device and performs all other driver initialization.
  32. Arguments:
  33. DriverObject - Pointer to driver object created by the system.
  34. Return Value:
  35. NTSTATUS - The function value is the final status from the initialization
  36. operation.
  37. --*/
  38. {
  39. NTSTATUS status = STATUS_SUCCESS;
  40. UNICODE_STRING nameString;
  41. PDEVICE_OBJECT deviceObject;
  42. PMSFS_DEVICE_OBJECT msfsDeviceObject;
  43. BOOLEAN vcbInitialized;
  44. PAGED_CODE();
  45. //
  46. // Initialize MSFS global data.
  47. //
  48. MsInitializeData();
  49. //
  50. // Set driver to be completely paged out.
  51. //
  52. MmPageEntireDriver(DriverEntry);
  53. //
  54. // Create the MSFS device object.
  55. //
  56. RtlInitUnicodeString( &nameString, L"\\Device\\Mailslot" );
  57. status = IoCreateDevice( DriverObject,
  58. sizeof(MSFS_DEVICE_OBJECT)-sizeof(DEVICE_OBJECT),
  59. &nameString,
  60. FILE_DEVICE_MAILSLOT,
  61. 0,
  62. FALSE,
  63. &deviceObject );
  64. if (!NT_SUCCESS( status )) {
  65. return status;
  66. }
  67. //
  68. // Now because we use the irp stack for storing a data entry we need
  69. // to bump up the stack size in the device object we just created.
  70. //
  71. deviceObject->StackSize += 1;
  72. //
  73. // Note that because of the way data copying is done, we set neither
  74. // the Direct I/O or Buffered I/O bit in DeviceObject->Flags. If
  75. // data is not buffered we may set up for Direct I/O by hand.
  76. //
  77. //
  78. // Initialize the driver object with this driver's entry points.
  79. //
  80. DriverObject->MajorFunction[IRP_MJ_CREATE] =
  81. (PDRIVER_DISPATCH)MsFsdCreate;
  82. DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] =
  83. (PDRIVER_DISPATCH)MsFsdCreateMailslot;
  84. DriverObject->MajorFunction[IRP_MJ_CLOSE] =
  85. (PDRIVER_DISPATCH)MsFsdClose;
  86. DriverObject->MajorFunction[IRP_MJ_READ] =
  87. (PDRIVER_DISPATCH)MsFsdRead;
  88. DriverObject->MajorFunction[IRP_MJ_WRITE] =
  89. (PDRIVER_DISPATCH)MsFsdWrite;
  90. DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
  91. (PDRIVER_DISPATCH)MsFsdQueryInformation;
  92. DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
  93. (PDRIVER_DISPATCH)MsFsdSetInformation;
  94. DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
  95. (PDRIVER_DISPATCH)MsFsdQueryVolumeInformation;
  96. DriverObject->MajorFunction[IRP_MJ_CLEANUP] =
  97. (PDRIVER_DISPATCH)MsFsdCleanup;
  98. DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
  99. (PDRIVER_DISPATCH)MsFsdDirectoryControl;
  100. DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
  101. (PDRIVER_DISPATCH)MsFsdFsControl;
  102. DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
  103. (PDRIVER_DISPATCH)MsFsdQuerySecurityInfo;
  104. DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
  105. (PDRIVER_DISPATCH)MsFsdSetSecurityInfo;
  106. #ifdef _PNP_POWER_
  107. //
  108. // Mailslots should probably have a SetPower handler to ensure
  109. // that the driver is not powered down while a guarateed
  110. // mailslot delivery is in progress. For now, we'll just
  111. // ignore this and let the machine set power.
  112. //
  113. deviceObject->DeviceObjectExtension->PowerControlNeeded = FALSE;
  114. #endif
  115. vcbInitialized = FALSE;
  116. try {
  117. //
  118. // Initialize stuff
  119. //
  120. msfsDeviceObject = (PMSFS_DEVICE_OBJECT)deviceObject;
  121. //
  122. // Now initialize the Vcb, and create the root dcb
  123. //
  124. MsInitializeVcb( &msfsDeviceObject->Vcb );
  125. (VOID)MsCreateRootDcb( &msfsDeviceObject->Vcb );
  126. vcbInitialized = TRUE;
  127. } finally {
  128. if (AbnormalTermination() ) {
  129. //
  130. // We encountered some unrecoverable error while initializing.
  131. // Cleanup as necessary.
  132. //
  133. if (vcbInitialized) {
  134. MsDeleteVcb( &msfsDeviceObject->Vcb );
  135. }
  136. }
  137. }
  138. //
  139. // Return to the caller.
  140. //
  141. return( status );
  142. }