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.

143 lines
4.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: initunld.c
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // This file contains functions associated with driver initialization and unload.
  12. //
  13. #include "pch.h"
  14. NTSTATUS
  15. DriverEntry(
  16. IN PDRIVER_OBJECT DriverObject,
  17. IN PUNICODE_STRING pRegistryPath
  18. )
  19. /*++dvdf2
  20. Routine Description:
  21. This routine initializes the ParClass driver. This is the first driver
  22. routine called after the driver is loaded.
  23. Arguments:
  24. DriverObject - points to the ParClass (parallel.sys) driver object
  25. pRegistryPath - points to the registry path for this driver
  26. Return Value:
  27. STATUS_SUCCESS
  28. --*/
  29. {
  30. PAGED_CODE();
  31. #if DBG
  32. ParInitDebugLevel(pRegistryPath); // initialize driver debug settings from registry
  33. //ParDebugLevel = -1;
  34. #endif
  35. ParBreak(PAR_BREAK_ON_DRIVER_ENTRY, ("DriverEntry(PDRIVER_OBJECT, PUNICODE_STRING)\n") );
  36. //
  37. // initialize driver globals
  38. //
  39. //
  40. // Default timeout when trying to acquire ParPort
  41. //
  42. AcquirePortTimeout.QuadPart = -((LONGLONG) 10*1000*500); // 500 ms (timeouts in 100ns units)
  43. //
  44. // Save Registry path that we were given for use later for WMI.
  45. //
  46. RegistryPath.Buffer = ExAllocatePool( PagedPool, pRegistryPath->MaximumLength + sizeof(UNICODE_NULL) );
  47. if( NULL == RegistryPath.Buffer ) {
  48. ParDump2(PARERRORS, ("initunld::DriverEntry - unable to alloc space to hold RegistryPath\n") );
  49. return STATUS_INSUFFICIENT_RESOURCES;
  50. } else {
  51. RtlZeroMemory( RegistryPath.Buffer, pRegistryPath->MaximumLength + sizeof(UNICODE_NULL) );
  52. RegistryPath.Length = pRegistryPath->Length;
  53. RegistryPath.MaximumLength = pRegistryPath->MaximumLength;
  54. RtlMoveMemory( RegistryPath.Buffer, pRegistryPath->Buffer, pRegistryPath->Length );
  55. }
  56. //
  57. // Check for settings under HKLM\SYSTEM\CurrentControlSet\Services\Parallel\Parameters
  58. //
  59. ParGetDriverParameterDword( &RegistryPath, (PWSTR)L"SppNoRaiseIrql", &SppNoRaiseIrql );
  60. ParGetDriverParameterDword( &RegistryPath, (PWSTR)L"DefaultModes", &DefaultModes );
  61. ParGetDriverParameterDword( &RegistryPath, (PWSTR)L"DumpDevExtTable", &DumpDevExtTable );
  62. //
  63. // Dump DEVICE_EXTENSION offsets if requested
  64. //
  65. if( DumpDevExtTable ) {
  66. ParDumpDevExtTable();
  67. }
  68. //
  69. // initialize DriverObject pointers to our dispatch routines
  70. //
  71. DriverObject->MajorFunction[IRP_MJ_CREATE] = ParCreateOpen;
  72. DriverObject->MajorFunction[IRP_MJ_CLOSE] = ParClose;
  73. DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ParCleanup;
  74. DriverObject->MajorFunction[IRP_MJ_READ] = ParReadWrite;
  75. DriverObject->MajorFunction[IRP_MJ_WRITE] = ParReadWrite;
  76. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ParDeviceControl;
  77. DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ParInternalDeviceControl;
  78. DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = ParQueryInformationFile;
  79. DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = ParSetInformationFile;
  80. DriverObject->MajorFunction[IRP_MJ_PNP] = ParParallelPnp;
  81. DriverObject->MajorFunction[IRP_MJ_POWER] = ParPower;
  82. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = ParWmiPdoSystemControlDispatch;
  83. DriverObject->DriverExtension->AddDevice = ParPnpAddDevice;
  84. DriverObject->DriverUnload = ParUnload;
  85. return STATUS_SUCCESS;
  86. }
  87. VOID
  88. ParUnload(
  89. IN PDRIVER_OBJECT DriverObject
  90. )
  91. /*++dvdf2
  92. Routine Description:
  93. This routine is called to allow the ParClass driver to do any required
  94. cleanup prior to the driver being unloaded. This is the last driver
  95. routine called before the driver is loaded.
  96. Arguments:
  97. DriverObject - points to the ParClass driver object
  98. Notes:
  99. No ParClass device objects remain at the time that this routine is called.
  100. Return Value:
  101. None
  102. --*/
  103. {
  104. UNREFERENCED_PARAMETER( DriverObject );
  105. PAGED_CODE();
  106. RtlFreeUnicodeString( &RegistryPath ); // free buffer we allocated in DriverEntry
  107. ParDump2(PARUNLOAD, ("ParUnload() - Cleanup prior to unload of ParClass driver (parallel.sys)\n") );
  108. ParBreak(PAR_BREAK_ON_UNLOAD, ("ParUnload(PDRIVER_OBJECT)\n") );
  109. }