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.

1130 lines
20 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. clusdskp.h
  5. Abstract:
  6. Private header file for the cluster disk driver.
  7. Authors:
  8. Rod Gamache 30-Mar-1997
  9. Environment:
  10. kernel mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. #define _NTDDK_ // [HACKHACK] to make ProbeForRead work. Better to include ntddk instead of ntos //
  15. #include "ntos.h"
  16. #include "zwapi.h"
  17. #include "stdarg.h"
  18. #include "stdio.h"
  19. #include "ntddscsi.h"
  20. #include "ntdddisk.h"
  21. #include "clusdef.h"
  22. #if 1 // turn on tagging all the time
  23. #ifdef ExAllocatePool
  24. #undef ExAllocatePool
  25. #endif
  26. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'kdSC')
  27. #endif
  28. //
  29. // Global definitions
  30. //
  31. #define CLUSDISK_ROOT_DEVICE L"\\Device\\ClusDisk0"
  32. #define CLUSDISK_SIGNATURE_DISK_NAME L"DiskName"
  33. #define CLUSDISK_SIGNATURE_FIELD L"\\12345678"
  34. #define CLUSDISK_PARAMETERS_KEYNAME L"\\Parameters"
  35. #define CLUSDISK_SIGNATURE_KEYNAME L"\\Signatures"
  36. #define CLUSDISK_AVAILABLE_DISKS_KEYNAME L"\\AvailableDisks"
  37. #define CLUSDISK_SINGLE_BUS_KEYNAME L"SingleBus"
  38. #define CLUSSVC_VALUENAME_MANAGEDISKSONSYSTEMBUSES L"ManageDisksOnSystemBuses"
  39. #define UNINITIALIZED_DISK_NUMBER (ULONG)-1
  40. #define MAX_BUSSES 20 // Maximum number of shared busses
  41. #define MAX_BUFFER_SIZE 256 // Maximum buffer size
  42. #define MAX_RETRIES 2
  43. // #define RESERVE_TIMER 3 // [GN] moved to cluster\inc\diskarbp.h
  44. #if DBG
  45. #define ClusDiskPrint(x) ClusDiskDebugPrint x
  46. #define WCSLEN_ASSERT( _buf ) ( wcslen( _buf ) < (sizeof( _buf ) / sizeof( WCHAR )))
  47. #else
  48. #define ClusDiskPrint(x)
  49. #define WCSLEN_ASSERT( _buf )
  50. #endif // DBG
  51. //
  52. // Error log messages
  53. //
  54. #define CLUSDISK_BAD_DEVICE L"Skipping device. Possible filter driver installed!"
  55. //
  56. // Macros
  57. #define IsAlpha( c ) \
  58. ( ((c) >= 'a' && (c) <= 'z') || ((c) >='A' && (c) <= 'Z') )
  59. //
  60. // Device Extension
  61. //
  62. typedef struct _CLUS_DEVICE_EXTENSION {
  63. //
  64. // Back pointer to this extension's device object
  65. //
  66. PDEVICE_OBJECT DeviceObject;
  67. //
  68. // device object to which clusdisk's device obj is attached
  69. //
  70. PDEVICE_OBJECT TargetDeviceObject;
  71. //
  72. // back ptr to clusdisk Partition0 Device Object
  73. //
  74. PDEVICE_OBJECT PhysicalDevice;
  75. //
  76. // The SCSI_ADDRESS for this device
  77. //
  78. SCSI_ADDRESS ScsiAddress;
  79. //
  80. // Disk signature
  81. //
  82. ULONG Signature;
  83. //
  84. // Disk number for reference on verifying attach
  85. //
  86. ULONG DiskNumber;
  87. //
  88. // Disk State. This is only maintained in the physical or partition
  89. // zero extension.
  90. //
  91. ULONG DiskState;
  92. //
  93. // Reservation timer - valid on the physical (partition0) extension
  94. //
  95. ULONG ReserveTimer;
  96. //
  97. // Time of last reservation.
  98. //
  99. LARGE_INTEGER LastReserve;
  100. //
  101. // Event flag for use with reservation IRP.
  102. // Use is controlled by the TimerBusy flag.
  103. //
  104. KEVENT Event;
  105. //
  106. // The bus type. E.G. Scsi, SSA, etc.
  107. //
  108. ULONG BusType;
  109. //
  110. // Last reserve failure.
  111. //
  112. NTSTATUS ReserveFailure;
  113. //
  114. // Hold I/O IRPs
  115. //
  116. LIST_ENTRY HoldIO;
  117. //
  118. // Waiting IOCTL's looking for Reserve Failure notification.
  119. //
  120. LIST_ENTRY WaitingIoctls;
  121. //
  122. // Work queue item context.
  123. //
  124. WORK_QUEUE_ITEM WorkItem;
  125. //
  126. // Reservation time IRP
  127. //
  128. BOOLEAN PerformReserves;
  129. //
  130. // Work queue item busy.
  131. //
  132. BOOLEAN TimerBusy;
  133. //
  134. // Attached state. True if this device object is supposed to be
  135. // attached. False if not sure.
  136. //
  137. BOOLEAN AttachValid;
  138. //
  139. // Device is detached.
  140. //
  141. BOOLEAN Detached;
  142. //
  143. // Flag to indicate offline/terminate is in process.
  144. //
  145. BOOLEAN OfflinePending;
  146. //
  147. // The driver object for use on repartitioning. RNGFIX -???
  148. //
  149. PDRIVER_OBJECT DriverObject;
  150. //
  151. // The partition number for the last extension created
  152. // only maintained in the physical or partition zero extension.
  153. //
  154. ULONG LastPartitionNumber;
  155. //
  156. // context value for when we deregister from disk device
  157. // notifications
  158. //
  159. PVOID DiskNotificationEntry;
  160. //
  161. // context value for when we deregister from mounted device
  162. // notifications
  163. //
  164. PVOID VolumeNotificationEntry;
  165. // [GN]
  166. // Physical Sector Size of the device
  167. // If SectorSize == 0 then
  168. // persistent writing is disabled
  169. ULONG SectorSize;
  170. //
  171. // Physical Sector which is used
  172. // for persistent reservations.
  173. ULONG ArbitrationSector;
  174. //
  175. // For tracing purposes:
  176. // Approximate time of the last write to
  177. // the disk. (Approximate, because we
  178. // update this field without holding any locks)
  179. //
  180. LARGE_INTEGER LastWriteTime;
  181. //
  182. // P0 object stores an array of handles to all volumes on
  183. // this disk to be dismounted when offline happens
  184. // First entry in this array is a number of handles in the array
  185. //
  186. PHANDLE VolumeHandles;
  187. //
  188. // Lock to prevent removal while I/O in progress.
  189. //
  190. IO_REMOVE_LOCK RemoveLock;
  191. //
  192. // Keep track of paging files, crash dump files, and hibernation files.
  193. //
  194. KEVENT PagingPathCountEvent;
  195. ULONG PagingPathCount;
  196. ULONG HibernationPathCount;
  197. ULONG DumpPathCount;
  198. //
  199. // Cache partition info when possible.
  200. //
  201. PDRIVE_LAYOUT_INFORMATION DriveLayout;
  202. ULONG DriveLayoutSize;
  203. ERESOURCE DriveLayoutLock;
  204. } CLUS_DEVICE_EXTENSION, *PCLUS_DEVICE_EXTENSION;
  205. #define DEVICE_EXTENSION_SIZE sizeof(CLUS_DEVICE_EXTENSION)
  206. //
  207. // Device list entry
  208. //
  209. typedef struct _DEVICE_LIST_ENTRY {
  210. struct _DEVICE_LIST_ENTRY *Next;
  211. ULONG Signature;
  212. PDEVICE_OBJECT DeviceObject;
  213. BOOLEAN Attached;
  214. BOOLEAN LettersAssigned;
  215. BOOLEAN FreePool;
  216. } DEVICE_LIST_ENTRY, *PDEVICE_LIST_ENTRY;
  217. typedef struct _SCSI_BUS_ENTRY {
  218. struct _SCSI_BUS_ENTRY *Next;
  219. UCHAR Port;
  220. UCHAR Path;
  221. USHORT Reserved;
  222. } SCSI_BUS_ENTRY, *PSCSI_BUS_ENTRY;
  223. typedef enum _ClusterBusType {
  224. RootBus,
  225. ScsiBus,
  226. UnknownBus
  227. } ClusterBusType;
  228. typedef struct _WORK_CONTEXT {
  229. PDEVICE_OBJECT DeviceObject;
  230. KEVENT CompletionEvent;
  231. NTSTATUS FinalStatus;
  232. PVOID Context;
  233. } WORK_CONTEXT, *PWORK_CONTEXT;
  234. //
  235. // Flags for ClusDiskpReplaceHandleArray
  236. //
  237. enum {
  238. DO_DISMOUNT = 0x00000001,
  239. RELEASE_REMOVE_LOCK = 0x00000002,
  240. };
  241. typedef struct _REPLACE_CONTEXT {
  242. PCLUS_DEVICE_EXTENSION DeviceExtension;
  243. PHANDLE NewValue; // OPTIONAL
  244. ULONG Flags;
  245. } REPLACE_CONTEXT, *PREPLACE_CONTEXT;
  246. typedef struct _HALTPROC_CONTEXT {
  247. PCLUS_DEVICE_EXTENSION DeviceExtension;
  248. PHANDLE FileHandle;
  249. } HALTPROC_CONTEXT, *PHALTPROC_CONTEXT;
  250. typedef struct _VOL_STATE_INFO {
  251. PIO_WORKITEM WorkItem;
  252. ULONG NewDiskState;
  253. } VOL_STATE_INFO, *PVOL_STATE_INFO;
  254. typedef struct _DEVICE_CHANGE_CONTEXT {
  255. PIO_WORKITEM WorkItem;
  256. PCLUS_DEVICE_EXTENSION DeviceExtension;
  257. UNICODE_STRING SymbolicLinkName;
  258. } DEVICE_CHANGE_CONTEXT, *PDEVICE_CHANGE_CONTEXT;
  259. //
  260. // External Function declartions
  261. //
  262. VOID
  263. ClusDiskReserveDriveLetters(
  264. IN ULONG Signature,
  265. IN BOOLEAN DeleteLetter
  266. );
  267. NTSTATUS
  268. GetDriveLetterFromMountMgr(
  269. IN LPWSTR PartitionString,
  270. OUT PUCHAR DriveLetter
  271. );
  272. VOID
  273. ClusDiskReleaseDriveLetters(
  274. VOID
  275. );
  276. NTSTATUS
  277. ClusDiskDismount(
  278. IN ULONG Signature
  279. );
  280. //
  281. // Function declarations
  282. //
  283. NTSTATUS
  284. DriverEntry(
  285. IN PDRIVER_OBJECT DriverObject,
  286. IN PUNICODE_STRING RegistryPath
  287. );
  288. VOID
  289. ClusDiskScsiInitialize(
  290. IN PDRIVER_OBJECT DriverObject,
  291. IN PVOID NextDisk,
  292. IN ULONG Count
  293. );
  294. VOID
  295. ClusDiskUnload(
  296. IN PDRIVER_OBJECT DriverObject
  297. );
  298. NTSTATUS
  299. ClusDiskCreate(
  300. IN PDEVICE_OBJECT DeviceObject,
  301. IN PIRP Irp
  302. );
  303. NTSTATUS
  304. ClusDiskClose(
  305. IN PDEVICE_OBJECT DeviceObject,
  306. IN PIRP Irp
  307. );
  308. NTSTATUS
  309. ClusDiskCleanup(
  310. IN PDEVICE_OBJECT DeviceObject,
  311. IN PIRP Irp
  312. );
  313. NTSTATUS
  314. ClusDiskRead(
  315. IN PDEVICE_OBJECT DeviceObject,
  316. IN PIRP Irp
  317. );
  318. NTSTATUS
  319. ClusDiskWrite(
  320. IN PDEVICE_OBJECT DeviceObject,
  321. IN PIRP Irp
  322. );
  323. NTSTATUS
  324. ClusDiskIoCompletion(
  325. IN PDEVICE_OBJECT DeviceObject,
  326. IN PIRP Irp,
  327. IN PVOID Context
  328. );
  329. NTSTATUS
  330. ClusDiskDeviceControl(
  331. IN PDEVICE_OBJECT DeviceObject,
  332. IN PIRP Irp
  333. );
  334. NTSTATUS
  335. ClusDiskRootDeviceControl(
  336. PDEVICE_OBJECT DeviceObject,
  337. PIRP Irp
  338. );
  339. NTSTATUS
  340. ClusDiskShutdownFlush(
  341. IN PDEVICE_OBJECT DeviceObject,
  342. IN PIRP Irp
  343. );
  344. NTSTATUS
  345. ClusDiskNewDiskCompletion(
  346. IN PDEVICE_OBJECT DeviceObject,
  347. IN PIRP Irp,
  348. IN PVOID Context
  349. );
  350. NTSTATUS
  351. ClusDiskSetLayoutCompletion(
  352. IN PDEVICE_OBJECT DeviceObject,
  353. IN PIRP Irp,
  354. IN PVOID Context
  355. );
  356. NTSTATUS
  357. ClusDiskDismountDevice(
  358. IN ULONG DiskNumber,
  359. IN BOOLEAN ForceDismount
  360. );
  361. BOOLEAN
  362. ClusDiskAttached(
  363. IN PDEVICE_OBJECT DeviceObject,
  364. IN ULONG DiskNumber
  365. );
  366. BOOLEAN
  367. ClusDiskVerifyAttach(
  368. IN PDEVICE_OBJECT DeviceObject
  369. );
  370. BOOLEAN
  371. AddAttachedDevice(
  372. IN ULONG Signature,
  373. IN PDEVICE_OBJECT DeviceObject
  374. );
  375. BOOLEAN
  376. MatchDevice(
  377. IN ULONG Signature,
  378. OUT PDEVICE_OBJECT *DeviceObject
  379. );
  380. BOOLEAN
  381. MatchScsiBus(
  382. PSCSI_ADDRESS ScsiAddress
  383. );
  384. NTSTATUS
  385. GetScsiAddress(
  386. PDEVICE_OBJECT DeviceObject,
  387. PSCSI_ADDRESS ScsiAddress
  388. );
  389. VOID
  390. ClusDiskAddScsiBusList(
  391. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  392. );
  393. VOID
  394. ClusDiskWriteDiskInfo(
  395. IN ULONG Signature,
  396. IN ULONG DiskNumber,
  397. IN LPWSTR KeyName
  398. );
  399. PDRIVE_LAYOUT_INFORMATION
  400. ClusDiskGetPartitionInfo(
  401. PCLUS_DEVICE_EXTENSION DeviceExtension
  402. );
  403. NTSTATUS
  404. ClusDiskTryAttachDevice(
  405. ULONG Signature,
  406. ULONG NextDisk,
  407. PDRIVER_OBJECT DriverObject
  408. );
  409. NTSTATUS
  410. ClusDiskAttachDevice(
  411. ULONG Signature,
  412. ULONG NextDisk,
  413. PDRIVER_OBJECT DriverObject,
  414. BOOLEAN Reset,
  415. BOOLEAN *StopProcessing
  416. );
  417. NTSTATUS
  418. ClusDiskDetachDevice(
  419. ULONG Signature,
  420. PDRIVER_OBJECT DriverObject
  421. );
  422. VOID
  423. ClusDiskAssignLetters(
  424. VOID
  425. );
  426. VOID
  427. ClusDiskAssignLetter(
  428. IN UCHAR DriveLetter,
  429. IN LPWSTR AssignDevice
  430. );
  431. NTSTATUS
  432. DismountDevice(
  433. IN HANDLE FileHandle
  434. );
  435. NTSTATUS
  436. ClusDiskGetDiskGeometry(
  437. PDEVICE_OBJECT DeviceObject
  438. );
  439. NTSTATUS
  440. GetDiskGeometry(
  441. PDEVICE_OBJECT DeviceObject
  442. );
  443. PDRIVE_LAYOUT_INFORMATION
  444. DoGetPartitionInfo(
  445. PDEVICE_OBJECT DeviceObject
  446. );
  447. PDRIVE_LAYOUT_INFORMATION
  448. GetPartitionInfo(
  449. PDEVICE_OBJECT DeviceObject,
  450. NTSTATUS *Status
  451. );
  452. PDEVICE_OBJECT
  453. GetDeviceObject(
  454. IN LPWSTR lpwstrDirectory,
  455. IN LPWSTR lpwstrObject,
  456. IN LPWSTR lpwstrType
  457. );
  458. NTSTATUS
  459. GetDriveLetterFromObjectDir(
  460. IN LPWSTR Name,
  461. OUT PUCHAR Letter
  462. );
  463. VOID
  464. ResetScsiDevice(
  465. PDEVICE_OBJECT DeviceObject,
  466. PSCSI_ADDRESS ScsiAddress
  467. );
  468. NTSTATUS
  469. ReserveScsiDevice(
  470. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  471. );
  472. VOID
  473. ReleaseScsiDevice(
  474. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  475. );
  476. BOOLEAN
  477. AttachedDevice(
  478. IN ULONG Signature,
  479. OUT PDEVICE_OBJECT *DeviceObject
  480. );
  481. NTSTATUS
  482. EnableHaltProcessing(
  483. IN KIRQL *Irql
  484. );
  485. NTSTATUS
  486. DisableHaltProcessing(
  487. IN KIRQL *Irql
  488. );
  489. NTSTATUS
  490. ClusDiskOfflineFtSet(
  491. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  492. );
  493. VOID
  494. ClusDiskEventCallback(
  495. IN CLUSNET_EVENT_TYPE EventType,
  496. IN CL_NODE_ID NodeId,
  497. IN CL_NETWORK_ID NetworkId
  498. );
  499. VOID
  500. ClusDiskLogError(
  501. IN PDRIVER_OBJECT DriverObject,
  502. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  503. IN ULONG SequenceNumber,
  504. IN UCHAR MajorFunctionCode,
  505. IN UCHAR RetryCount,
  506. IN ULONG UniqueErrorValue,
  507. IN NTSTATUS FinalStatus,
  508. IN NTSTATUS SpecificIOStatus,
  509. IN ULONG LengthOfText,
  510. IN PWCHAR Text
  511. );
  512. NTSTATUS
  513. CluSetFtMemberComplete(
  514. IN PDEVICE_OBJECT DeviceObject,
  515. IN PIRP Irp,
  516. IN PVOID Context
  517. );
  518. NTSTATUS
  519. DismountPartition(
  520. IN PDEVICE_OBJECT TargetDevice,
  521. IN ULONG DiskNumber,
  522. IN ULONG PartNumber
  523. );
  524. NTSTATUS
  525. DismountPartitionDevice(
  526. IN UCHAR DriveLetter
  527. );
  528. VOID
  529. DeleteSpecificDriveLetter(
  530. IN UCHAR Letter
  531. );
  532. #if DBG
  533. VOID
  534. ClusDiskDebugPrint(
  535. IN ULONG Level,
  536. IN PCHAR DebugMessage,
  537. ...
  538. );
  539. #endif
  540. VOID
  541. GetSymbolicLink(
  542. IN PWCHAR Root,
  543. IN OUT PWCHAR Path
  544. );
  545. NTSTATUS
  546. ClusDiskGetTargetDevice(
  547. IN ULONG DiskNumber,
  548. IN ULONG PartitionNumber,
  549. OUT PDEVICE_OBJECT * DeviceObject OPTIONAL,
  550. IN OUT PUNICODE_STRING UnicodeString,
  551. OUT PDRIVE_LAYOUT_INFORMATION * PartitionInfo OPTIONAL,
  552. OUT PSCSI_ADDRESS ScsiAddress OPTIONAL,
  553. IN BOOLEAN Reset
  554. );
  555. //[GN]
  556. NTSTATUS
  557. ArbitrationInitialize(
  558. VOID
  559. );
  560. VOID
  561. ArbitrationDone(
  562. VOID
  563. );
  564. VOID
  565. ArbitrationTick(
  566. VOID
  567. );
  568. VOID
  569. ArbitrationReserve(
  570. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  571. );
  572. NTSTATUS
  573. VerifyArbitrationArgumentsIfAny(
  574. IN PULONG InputData,
  575. IN LONG InputSize
  576. );
  577. VOID
  578. ProcessArbitrationArgumentsIfAny(
  579. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  580. IN PULONG InputData,
  581. IN LONG InputSize
  582. );
  583. NTSTATUS
  584. ProcessArbitrationEscape(
  585. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  586. IN PULONG InputData,
  587. IN LONG InputSize,
  588. IN OUT PULONG OutputSize
  589. );
  590. NTSTATUS
  591. SimpleDeviceIoControl(
  592. IN PDEVICE_OBJECT DeviceObject,
  593. IN ULONG Ioctl,
  594. IN PVOID InBuffer,
  595. IN ULONG InBufferSize,
  596. IN PVOID OutBuffer,
  597. IN ULONG OutBufferSize);
  598. NTSTATUS
  599. ClusDiskInitRegistryString(
  600. OUT PUNICODE_STRING UnicodeString,
  601. IN LPWSTR KeyName,
  602. IN ULONG KeyNameSize
  603. );
  604. NTSTATUS
  605. ClusDiskAddSignature(
  606. IN PUNICODE_STRING UnicodeString,
  607. IN ULONG Signature,
  608. IN BOOLEAN Volatile
  609. );
  610. NTSTATUS
  611. ClusDiskDeleteSignature(
  612. IN PUNICODE_STRING UnicodeString,
  613. IN ULONG Signature
  614. );
  615. ULONG
  616. ClusDiskIsSignatureDisk(
  617. IN ULONG Signature
  618. );
  619. NTSTATUS
  620. ClusDiskMarkIrpPending(
  621. PIRP Irp,
  622. PDRIVER_CANCEL CancelRoutine
  623. );
  624. VOID
  625. ClusDiskCompletePendingRequest(
  626. IN PIRP Irp,
  627. IN NTSTATUS Status,
  628. PCLUS_DEVICE_EXTENSION DeviceExtension
  629. );
  630. VOID
  631. ClusDiskIrpCancel(
  632. PDEVICE_OBJECT DeviceObject,
  633. PIRP Irp
  634. );
  635. MEDIA_TYPE
  636. GetMediaType(
  637. IN PDEVICE_OBJECT DeviceObject
  638. );
  639. NTSTATUS
  640. GetScsiPortNumber(
  641. IN ULONG DiskSignature,
  642. IN PUCHAR DiskPortNumber
  643. );
  644. NTSTATUS
  645. IsDiskClusterCapable(
  646. IN UCHAR PortNumber,
  647. OUT PBOOLEAN IsCapable
  648. );
  649. NTSTATUS
  650. GetBootTimeSystemRoot(
  651. IN OUT PWCHAR Path
  652. );
  653. NTSTATUS
  654. GetRunTimeSystemRoot(
  655. IN OUT PWCHAR Path
  656. );
  657. NTSTATUS
  658. GetSystemRootPort(
  659. VOID
  660. );
  661. VOID
  662. ResetScsiBusses(
  663. VOID
  664. );
  665. NTSTATUS
  666. GetDriveLayout(
  667. IN PDEVICE_OBJECT DeviceObject,
  668. OUT PDRIVE_LAYOUT_INFORMATION *DriveLayout,
  669. BOOLEAN UpdateCachedLayout
  670. );
  671. NTSTATUS
  672. ClusDiskInitialize(
  673. IN PDRIVER_OBJECT DriverObject
  674. );
  675. NTSTATUS
  676. DriverEntry(
  677. IN PDRIVER_OBJECT DriverObject,
  678. IN PUNICODE_STRING RegistryPath
  679. );
  680. NTSTATUS
  681. LockVolumes(
  682. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  683. );
  684. NTSTATUS
  685. ClusDiskHaltProcessingWorker(
  686. IN PVOID Context
  687. );
  688. NTSTATUS
  689. ClusDiskRescanWorker(
  690. IN PVOID Context
  691. );
  692. VOID
  693. ClusDiskTickHandler(
  694. IN PDEVICE_OBJECT DeviceObject,
  695. IN PVOID Context
  696. );
  697. NTSTATUS
  698. RegistryQueryValue(
  699. PVOID hKey,
  700. LPWSTR pValueName,
  701. PULONG pulType,
  702. PVOID pData,
  703. PULONG pulDataSize
  704. );
  705. NTSTATUS
  706. ClusDiskCreateHandle(
  707. OUT PHANDLE pHandle,
  708. IN ULONG DiskNumber,
  709. IN ULONG PartitionNumber,
  710. IN ACCESS_MASK DesiredAccess
  711. );
  712. VOID
  713. ClusDiskCompletePendedIrps(
  714. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  715. IN PFILE_OBJECT FileObject OPTIONAL,
  716. IN ULONG Offline
  717. );
  718. NTSTATUS
  719. ClusDiskOfflineEntireDisk(
  720. IN PDEVICE_OBJECT Part0DeviceObject
  721. );
  722. NTSTATUS
  723. ClusDiskDismountVolumes(
  724. IN PDEVICE_OBJECT Part0DeviceObject
  725. );
  726. NTSTATUS
  727. ClusDiskForwardIrpSynchronous(
  728. IN PDEVICE_OBJECT DeviceObject,
  729. IN PIRP Irp
  730. );
  731. VOID
  732. ClusDiskReservationWorker(
  733. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  734. );
  735. VOID
  736. ClusDiskpReplaceHandleArray(
  737. PDEVICE_OBJECT DeviceObject,
  738. PWORK_CONTEXT WorkContext
  739. );
  740. VOID
  741. ClusDiskpOpenFileHandles(
  742. PDEVICE_OBJECT Part0DeviceObject,
  743. PWORK_CONTEXT WorkContext
  744. );
  745. NTSTATUS
  746. EjectVolumes(
  747. IN PDEVICE_OBJECT DeviceObject
  748. );
  749. NTSTATUS
  750. ReclaimVolumes(
  751. IN PDEVICE_OBJECT DeviceObject
  752. );
  753. NTSTATUS
  754. ProcessDelayedWorkSynchronous(
  755. PDEVICE_OBJECT DeviceObject,
  756. PVOID WorkerRoutine,
  757. PVOID Context
  758. );
  759. VOID
  760. EnableHaltProcessingWorker(
  761. PDEVICE_OBJECT DeviceObject,
  762. PWORK_CONTEXT WorkContext
  763. );
  764. VOID
  765. DisableHaltProcessingWorker(
  766. PDEVICE_OBJECT DeviceObject,
  767. PWORK_CONTEXT WorkContext
  768. );
  769. BOOLEAN
  770. IsDiskMbr(
  771. IN PDEVICE_OBJECT DeviceObject
  772. );
  773. NTSTATUS
  774. GetRegistryValue(
  775. PUNICODE_STRING KeyName,
  776. PWSTR ValueName,
  777. PULONG ReturnValue
  778. );
  779. NTSTATUS
  780. SetVolumeState(
  781. PCLUS_DEVICE_EXTENSION PhysicalDisk,
  782. ULONG NewDiskState
  783. );
  784. VOID
  785. SetVolumeStateWorker(
  786. PDEVICE_OBJECT DeviceObject,
  787. PVOID Context
  788. );
  789. NTSTATUS
  790. AttachSignatureList(
  791. PDEVICE_OBJECT DeviceObject,
  792. PULONG InBuffer,
  793. ULONG InBufferLen
  794. );
  795. NTSTATUS
  796. DetachSignatureList(
  797. PDEVICE_OBJECT DeviceObject,
  798. PULONG InBuffer,
  799. ULONG InBufferLen
  800. );
  801. NTSTATUS
  802. IsVolumeMounted(
  803. IN ULONG DiskNumber,
  804. IN ULONG PartNumber,
  805. OUT BOOLEAN *IsMounted
  806. );
  807. NTSTATUS
  808. SendFtdiskIoctlSync(
  809. PDEVICE_OBJECT TargetObject,
  810. IN ULONG DiskNumber,
  811. IN ULONG PartNumber,
  812. ULONG Ioctl
  813. );
  814. NTSTATUS
  815. ClusDiskDeviceChangeNotification(
  816. IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION DeviceChangeNotification,
  817. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  818. );
  819. NTSTATUS
  820. ClusDiskDeviceChangeNotificationWorker(
  821. IN PDEVICE_OBJECT DeviceObject,
  822. IN PVOID Context
  823. );
  824. NTSTATUS
  825. CleanupDeviceList(
  826. PDEVICE_OBJECT DeviceObject
  827. );
  828. VOID
  829. CleanupDeviceListWorker(
  830. PDEVICE_OBJECT DeviceObject,
  831. PVOID Context
  832. );
  833. #if DBG
  834. //
  835. // RemoveLock tracing functions.
  836. //
  837. NTSTATUS
  838. AcquireRemoveLock(
  839. IN PIO_REMOVE_LOCK RemoveLock,
  840. IN OPTIONAL PVOID Tag
  841. );
  842. VOID
  843. ReleaseRemoveLock(
  844. IN PIO_REMOVE_LOCK RemoveLock,
  845. IN PVOID Tag
  846. );
  847. VOID
  848. ReleaseRemoveLockAndWait(
  849. IN PIO_REMOVE_LOCK RemoveLock,
  850. IN PVOID Tag
  851. );
  852. //
  853. // Debug print helper routines
  854. //
  855. PCHAR
  856. PnPMinorFunctionString (
  857. UCHAR MinorFunction
  858. );
  859. PCHAR
  860. BoolToString(
  861. BOOLEAN Value
  862. );
  863. PCHAR
  864. DiskStateToString(
  865. ULONG DiskState
  866. );
  867. #else
  868. #define AcquireRemoveLock(RemoveLock, Tag) IoAcquireRemoveLock(RemoveLock, Tag)
  869. #define ReleaseRemoveLock(RemoveLock, Tag) IoReleaseRemoveLock(RemoveLock, Tag)
  870. #define ReleaseRemoveLockAndWait(RemoveLock, Tag) IoReleaseRemoveLockAndWait(RemoveLock, Tag)
  871. #endif
  872. #define WPP_CONTROL_GUIDS \
  873. WPP_DEFINE_CONTROL_GUID(ClusdiskLH,(b25a9257,9a39,43df,9f35,b0976e28e843), \
  874. WPP_DEFINE_BIT(DEFAULT) \
  875. WPP_DEFINE_BIT(CREATE) \
  876. WPP_DEFINE_BIT(CLOSE) \
  877. WPP_DEFINE_BIT(CLEANUP) \
  878. WPP_DEFINE_BIT(UNPEND) \
  879. WPP_DEFINE_BIT(LEGACY) \
  880. ) \
  881. WPP_DEFINE_CONTROL_GUID(ClusdiskHB,(7f827e76,1a10,11d3,ba86,00c04f8eed00), \
  882. WPP_DEFINE_BIT(RESERVE) \
  883. WPP_DEFINE_BIT(READ) \
  884. WPP_DEFINE_BIT(WRITE) \
  885. WPP_DEFINE_BIT(TICK) \
  886. )