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.

1303 lines
23 KiB

  1. /*++
  2. Copyright (c) 1990-2000 Microsoft Corporation
  3. Module Name:
  4. drive.hxx
  5. Abstract:
  6. The drive class hierarchy models the concept of a drive in various
  7. stages. It looks like this:
  8. DRIVE
  9. DP_DRIVE
  10. IO_DP_DRIVE
  11. LOG_IO_DP_DRIVE
  12. PHYS_IO_DP_DRIVE
  13. DRIVE
  14. -----
  15. DRIVE implements a container for the drive path which is recognizable
  16. by the file system. 'Initialize' takes the path as an argument so
  17. that it can be later queried with 'GetNtDriveName'.
  18. DP_DRIVE
  19. --------
  20. DP_DRIVE (Drive Parameters) implements queries for the geometry of the
  21. drive. 'Initiliaze' queries the information from the drive. What
  22. is returned is the default drive geometry for the drive. The user
  23. may ask by means of 'IsSupported' if the physical device will support
  24. another MEDIA_TYPE.
  25. A protected member function called 'SetMediaType' allows the a derived
  26. class to set the MEDIA_TYPE to another media type which is supported
  27. by the device. This method is protected because only a low-level
  28. format will actually change the media type.
  29. IO_DP_DRIVE
  30. -----------
  31. IO_DP_DRIVE implements the reading a writting of sectors as well
  32. as 'Lock', 'Unlock', and 'Dismount'. The 'FormatVerifyFloppy' method
  33. does a low-level format. A version of this method allows the user
  34. to specify a new MEDIA_TYPE for the media.
  35. LOG_IO_DP_DRIVE and PHYS_IO_DP_DRIVE
  36. ------------------------------------
  37. LOG_IO_DP_DRIVE models logical drive. PHYS_IO_DP_DRIVE models a
  38. physical drive. Currently both implementations just initialize
  39. an IO_DP_DRIVE. The difference is in the drive path specified.
  40. Some drive paths are to logical drives and others are to physical
  41. drives.
  42. Author:
  43. Mark Shavlik (marks) Jun-90
  44. Norbert P. Kusters (norbertk) 22-Feb-91
  45. --*/
  46. #if ! defined( DRIVE_DEFN )
  47. #define DRIVE_DEFN
  48. #include "wstring.hxx"
  49. #include "bigint.hxx"
  50. #if defined ( _AUTOCHECK_ ) || ( _EFICHECK_ )
  51. #define IFSUTIL_EXPORT
  52. #elif defined ( _IFSUTIL_MEMBER_ )
  53. #define IFSUTIL_EXPORT __declspec(dllexport)
  54. #else
  55. #define IFSUTIL_EXPORT __declspec(dllimport)
  56. #endif
  57. //
  58. // Forward references
  59. //
  60. DECLARE_CLASS( DRIVE );
  61. DECLARE_CLASS( DP_DRIVE );
  62. DECLARE_CLASS( IO_DP_DRIVE );
  63. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  64. DECLARE_CLASS( PHYS_IO_DP_DRIVE );
  65. DECLARE_CLASS( NUMBER_SET );
  66. DECLARE_CLASS( MESSAGE );
  67. DECLARE_CLASS( DRIVE_CACHE );
  68. #if !defined _PARTITION_SYSTEM_ID_DEFINED_
  69. #define _PARTITION_SYSTEM_ID_DEFINED_
  70. #define SYSID_NONE 0x0
  71. #define SYSID_FAT12BIT 0x1
  72. #define SYSID_FAT16BIT 0x4
  73. #define SYSID_FAT32MEG 0x6
  74. #define SYSID_IFS 0x7
  75. #define SYSID_FAT32BIT 0xB
  76. #define SYSID_EXTENDED 0x5
  77. #define SYSID_EFI 0xEE
  78. #define SYSID_EFI_BOOT 0xEF
  79. typedef UCHAR PARTITION_SYSTEM_ID, *PPARTITON_SYSTEM_ID;
  80. #endif
  81. DEFINE_TYPE( ULONG, SECTORCOUNT ); // count of sectors
  82. DEFINE_TYPE( ULONG, LBN ); // Logical buffer number
  83. DEFINE_POINTER_AND_REFERENCE_TYPES( MEDIA_TYPE );
  84. DEFINE_POINTER_AND_REFERENCE_TYPES( DISK_GEOMETRY );
  85. struct _DRTYPE {
  86. MEDIA_TYPE MediaType;
  87. ULONG SectorSize;
  88. BIG_INT Sectors; // w/o hidden sectors.
  89. BIG_INT HiddenSectors;
  90. SECTORCOUNT SectorsPerTrack;
  91. ULONG Heads;
  92. #if defined(FE_SB) && defined(_X86_)
  93. // NEC Oct.24.1994
  94. ULONG PhysicalSectorSize; // used only PC-98
  95. BIG_INT PhysicalHiddenSectors; // used only PC-98
  96. #endif
  97. };
  98. // Hosted volumes always have certain values fixed. Define
  99. // those values here:
  100. //
  101. CONST MEDIA_TYPE HostedDriveMediaType = FixedMedia;
  102. CONST ULONG HostedDriveSectorSize = 512;
  103. CONST ULONG64 HostedDriveHiddenSectors = 0;
  104. CONST SECTORCOUNT HostedDriveSectorsPerTrack = 0x11;
  105. CONST SECTORCOUNT HostedDriveHeads = 6;
  106. DEFINE_TYPE( struct _DRTYPE, DRTYPE );
  107. class DRIVE : public OBJECT {
  108. public:
  109. DECLARE_CONSTRUCTOR(DRIVE);
  110. VIRTUAL
  111. ~DRIVE(
  112. );
  113. NONVIRTUAL
  114. BOOLEAN
  115. Initialize(
  116. IN PCWSTRING NtDriveName,
  117. IN OUT PMESSAGE Message DEFAULT NULL
  118. );
  119. NONVIRTUAL
  120. PCWSTRING
  121. GetNtDriveName(
  122. ) CONST;
  123. private:
  124. NONVIRTUAL
  125. VOID
  126. Construct(
  127. );
  128. NONVIRTUAL
  129. VOID
  130. Destroy(
  131. );
  132. DSTRING _name;
  133. };
  134. INLINE
  135. PCWSTRING
  136. DRIVE::GetNtDriveName(
  137. ) CONST
  138. /*++
  139. Routine Description:
  140. This routine returns a pointer string containing the NT drive name.
  141. Arguments:
  142. None.
  143. Return Value:
  144. A pointer to a string containing the NT drive name.
  145. --*/
  146. {
  147. return &_name;
  148. }
  149. class DP_DRIVE : public DRIVE {
  150. public:
  151. IFSUTIL_EXPORT
  152. DECLARE_CONSTRUCTOR(DP_DRIVE);
  153. VIRTUAL
  154. IFSUTIL_EXPORT
  155. ~DP_DRIVE(
  156. );
  157. NONVIRTUAL
  158. IFSUTIL_EXPORT
  159. BOOLEAN
  160. Initialize(
  161. IN PCWSTRING NtDriveName,
  162. IN OUT PMESSAGE Message DEFAULT NULL,
  163. IN BOOLEAN IsTransient DEFAULT FALSE,
  164. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  165. );
  166. NONVIRTUAL
  167. IFSUTIL_EXPORT
  168. BOOLEAN
  169. Initialize(
  170. IN PCWSTRING NtDriveName,
  171. IN PCWSTRING HostFileName,
  172. IN OUT PMESSAGE Message DEFAULT NULL,
  173. IN BOOLEAN IsTransient DEFAULT FALSE,
  174. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  175. );
  176. NONVIRTUAL
  177. MEDIA_TYPE
  178. QueryMediaType(
  179. ) CONST;
  180. NONVIRTUAL
  181. IFSUTIL_EXPORT
  182. UCHAR
  183. QueryMediaByte(
  184. ) CONST;
  185. NONVIRTUAL
  186. IFSUTIL_EXPORT
  187. HANDLE
  188. QueryDriveHandle(
  189. ) CONST;
  190. NONVIRTUAL
  191. IFSUTIL_EXPORT
  192. VOID
  193. CloseDriveHandle(
  194. );
  195. VIRTUAL
  196. IFSUTIL_EXPORT
  197. ULONG
  198. QuerySectorSize(
  199. ) CONST;
  200. VIRTUAL
  201. IFSUTIL_EXPORT
  202. BIG_INT
  203. QuerySectors(
  204. ) CONST;
  205. NONVIRTUAL
  206. BIG_INT
  207. QueryHiddenSectors(
  208. ) CONST;
  209. NONVIRTUAL
  210. SECTORCOUNT
  211. QuerySectorsPerTrack(
  212. ) CONST;
  213. #if defined(FE_SB) && defined(_X86_)
  214. // NEC98 supports ATACard. We must judge whether it is ATAcard.
  215. NONVIRTUAL
  216. IFSUTIL_EXPORT
  217. BOOLEAN
  218. IsATformat(
  219. ) CONST;
  220. // NEC98 uses the phsical sectorsize of target disk
  221. NONVIRTUAL
  222. IFSUTIL_EXPORT
  223. ULONG
  224. QueryPhysicalSectorSize(
  225. ) CONST;
  226. // NEC98 uses physical hidden sectors of target disk to support special FAT.
  227. NONVIRTUAL
  228. BIG_INT
  229. QueryPhysicalHiddenSectors(
  230. ) CONST;
  231. #endif
  232. NONVIRTUAL
  233. ULONG
  234. QueryHeads(
  235. ) CONST;
  236. NONVIRTUAL
  237. BIG_INT
  238. QueryTracks(
  239. ) CONST;
  240. NONVIRTUAL
  241. BIG_INT
  242. QueryCylinders(
  243. ) CONST;
  244. NONVIRTUAL
  245. BOOLEAN
  246. IsWriteable(
  247. ) CONST;
  248. NONVIRTUAL
  249. BOOLEAN
  250. IsRemovable(
  251. ) CONST;
  252. NONVIRTUAL
  253. BOOLEAN
  254. IsFloppy(
  255. ) CONST;
  256. NONVIRTUAL
  257. BOOLEAN
  258. IsSuperFloppy(
  259. ) CONST;
  260. NONVIRTUAL
  261. BOOLEAN
  262. IsFixed(
  263. ) CONST;
  264. NONVIRTUAL
  265. BOOLEAN
  266. IsSupported(
  267. IN MEDIA_TYPE MediaType
  268. ) CONST;
  269. NONVIRTUAL
  270. PCDRTYPE
  271. GetSupportedList(
  272. OUT PINT NumSupported
  273. ) CONST;
  274. NONVIRTUAL
  275. IFSUTIL_EXPORT
  276. MEDIA_TYPE
  277. QueryRecommendedMediaType(
  278. ) CONST;
  279. NONVIRTUAL
  280. ULONG
  281. QueryAlignmentMask(
  282. ) CONST;
  283. NONVIRTUAL
  284. NTSTATUS
  285. QueryLastNtStatus(
  286. ) CONST;
  287. NONVIRTUAL
  288. HANDLE
  289. GetVolumeFileHandle(
  290. ) CONST;
  291. #if defined ( DBLSPACE_ENABLED )
  292. NONVIRTUAL
  293. BOOLEAN
  294. QueryMountedFileSystemName(
  295. OUT PWSTRING FileSystemName,
  296. OUT PBOOLEAN IsCompressed
  297. );
  298. NONVIRTUAL
  299. BOOLEAN
  300. MountCvf(
  301. IN PCWSTRING CvfName,
  302. IN PMESSAGE Message
  303. );
  304. NONVIRTUAL
  305. BOOLEAN
  306. SetCvfSize(
  307. IN ULONG Size
  308. );
  309. #endif // DBLSPACE_ENABLED
  310. #if defined(FE_SB) && defined(_X86_)
  311. // NEC98 uses this word in QueryFormatMediaType whether it is AT.
  312. private:
  313. ULONG _next_format_type;
  314. #define FORMAT_MEDIA_98 0
  315. #define FORMAT_MEDIA_AT 1
  316. #define FORMAT_MEDIA_OTHER 2
  317. #endif
  318. protected:
  319. NONVIRTUAL
  320. BOOLEAN
  321. SetMediaType(
  322. IN MEDIA_TYPE MediaType DEFAULT Unknown
  323. );
  324. // On a normal drive, _handle is a handle to the drive
  325. // and _alternate_drive is zero. On a hosted drive,
  326. // however, _handle is a handle to the file which
  327. // contains the volume and _alternate_handle is a handle
  328. // to the volume itself.
  329. //
  330. // When the drive object opens a hosted volume, it must
  331. // first make the host file non-readonly. It caches the
  332. // old attributes of the file so that it can reset them.
  333. //
  334. HANDLE _handle;
  335. HANDLE _alternate_handle;
  336. BOOLEAN _hosted_drive;
  337. ULONG _old_attributes;
  338. NTSTATUS _last_status;
  339. #if defined( _EFICHECK_ )
  340. // store the disk's BLOCK_IO interface pointer here
  341. // from OpenDrive on EFI
  342. EFI_BLOCK_IO *_block_io;
  343. EFI_DISK_IO *_disk_io;
  344. UINT32 _media_id;
  345. EFI_BLOCK_IO *_device_block_io;
  346. EFI_DISK_IO *_device_disk_io;
  347. UINT32 _partition_number;
  348. #endif
  349. private:
  350. NONVIRTUAL
  351. VOID
  352. Construct(
  353. );
  354. NONVIRTUAL
  355. VOID
  356. Destroy(
  357. );
  358. NTSTATUS
  359. OpenDrive(
  360. IN PCWSTRING NtDriveName,
  361. IN ACCESS_MASK DesiredAccess,
  362. IN BOOLEAN ExclusiveWrite,
  363. #if defined(_EFICHECK_)
  364. OUT EFI_BLOCK_IO ** BlockIoPtr,
  365. OUT EFI_DISK_IO ** DiskIoPtr,
  366. #else
  367. OUT PHANDLE Handle,
  368. OUT PHANDLE Handle,
  369. #endif
  370. OUT PULONG Alignment,
  371. IN OUT PMESSAGE Message
  372. );
  373. STATIC
  374. VOID
  375. DiskGeometryToDriveType(
  376. IN PCDISK_GEOMETRY DiskGeometry,
  377. OUT PDRTYPE DriveType
  378. );
  379. STATIC
  380. VOID
  381. DiskGeometryToDriveType(
  382. IN PCDISK_GEOMETRY DiskGeometry,
  383. IN BIG_INT NumSectors,
  384. IN BIG_INT NumHiddenSectors,
  385. OUT PDRTYPE DriveType
  386. );
  387. DRTYPE _actual;
  388. PDRTYPE _supported_list;
  389. INT _num_supported;
  390. ULONG _alignment_mask;
  391. BOOLEAN _super_floppy;
  392. BOOLEAN _is_writeable;
  393. };
  394. INLINE
  395. HANDLE
  396. DP_DRIVE::QueryDriveHandle(
  397. ) CONST
  398. /*++
  399. Routine Description:
  400. This routine returns the drive handle.
  401. Arguments:
  402. None.
  403. Return Value:
  404. Drive handle.
  405. --*/
  406. {
  407. return _handle;
  408. }
  409. INLINE
  410. MEDIA_TYPE
  411. DP_DRIVE::QueryMediaType(
  412. ) CONST
  413. /*++
  414. Routine Description:
  415. This routine computes the media type.
  416. Arguments:
  417. None.
  418. Return Value:
  419. The media type.
  420. --*/
  421. {
  422. return _actual.MediaType;
  423. }
  424. INLINE
  425. BIG_INT
  426. DP_DRIVE::QueryHiddenSectors(
  427. ) CONST
  428. /*++
  429. Routine Description:
  430. This routine computes the number of hidden sectors.
  431. Arguments:
  432. None.
  433. Return Value:
  434. The number of hidden sectors.
  435. --*/
  436. {
  437. return _actual.HiddenSectors;
  438. }
  439. #if defined(FE_SB) && defined(_X86_)
  440. INLINE
  441. BIG_INT
  442. DP_DRIVE::QueryPhysicalHiddenSectors(
  443. ) CONST
  444. /*++
  445. Routine Description:
  446. This routine computes the number of hidden sectors for 98's FAT.
  447. Arguments:
  448. None.
  449. Return Value:
  450. The number of hidden sectors.
  451. --*/
  452. {
  453. return _actual.PhysicalHiddenSectors;
  454. }
  455. #endif
  456. INLINE
  457. SECTORCOUNT
  458. DP_DRIVE::QuerySectorsPerTrack(
  459. ) CONST
  460. /*++
  461. Routine Description:
  462. This routine computes the number of sectors per track.
  463. Arguments:
  464. None.
  465. Return Value:
  466. The number of sectors per track.
  467. --*/
  468. {
  469. return _actual.SectorsPerTrack;
  470. }
  471. INLINE
  472. ULONG
  473. DP_DRIVE::QueryHeads(
  474. ) CONST
  475. /*++
  476. Routine Description:
  477. This routine computes the number of heads.
  478. Arguments:
  479. None.
  480. Return Value:
  481. The number of heads.
  482. --*/
  483. {
  484. return _actual.Heads;
  485. }
  486. INLINE
  487. BIG_INT
  488. DP_DRIVE::QueryTracks(
  489. ) CONST
  490. /*++
  491. Routine Description:
  492. This routine computes the number of tracks on the disk.
  493. Arguments:
  494. None.
  495. Return Value:
  496. The number of tracks on the disk.
  497. --*/
  498. {
  499. return (_actual.Sectors + _actual.HiddenSectors)/_actual.SectorsPerTrack;
  500. }
  501. INLINE
  502. BIG_INT
  503. DP_DRIVE::QueryCylinders(
  504. ) CONST
  505. /*++
  506. Routine Description:
  507. This routine computes the number of cylinders on the disk.
  508. Arguments:
  509. None.
  510. Return Value:
  511. The number of cylinders on the disk.
  512. --*/
  513. {
  514. return QueryTracks()/_actual.Heads;
  515. }
  516. INLINE
  517. BOOLEAN
  518. DP_DRIVE::IsRemovable(
  519. ) CONST
  520. /*++
  521. Routine Description:
  522. This routine computes whether or not the disk is removable.
  523. Arguments:
  524. None.
  525. Return Value:
  526. FALSE - The disk is not removable.
  527. TRUE - The disk is removable.
  528. --*/
  529. {
  530. return _actual.MediaType != FixedMedia;
  531. }
  532. INLINE
  533. BOOLEAN
  534. DP_DRIVE::IsWriteable(
  535. ) CONST
  536. /*++
  537. Routine Description:
  538. This routine checks to see if the drive is writeable.
  539. Arguments:
  540. N/A
  541. Return Value:
  542. TRUE - if the disk is writeable
  543. FALSE - if the disk is write protected
  544. --*/
  545. {
  546. return _is_writeable;
  547. }
  548. INLINE
  549. BOOLEAN
  550. DP_DRIVE::IsFloppy(
  551. ) CONST
  552. /*++
  553. Routine Description:
  554. This routine computes whether or not the disk is a floppy disk.
  555. Arguments:
  556. None.
  557. Return Value:
  558. FALSE - The disk is not a floppy disk.
  559. TRUE - The disk is a floppy disk.
  560. --*/
  561. {
  562. return IsRemovable() && _actual.MediaType != RemovableMedia;
  563. }
  564. INLINE
  565. BOOLEAN
  566. DP_DRIVE::IsSuperFloppy(
  567. ) CONST
  568. /*++
  569. Routine Description:
  570. This routine tells whether the media is non-floppy unpartitioned
  571. removable media.
  572. Arguments:
  573. None.
  574. Return Value:
  575. FALSE - The disk is not a floppy disk.
  576. TRUE - The disk is a floppy disk.
  577. --*/
  578. {
  579. return _super_floppy;
  580. }
  581. INLINE
  582. BOOLEAN
  583. DP_DRIVE::IsFixed(
  584. ) CONST
  585. /*++
  586. Routine Description:
  587. This routine computes whether or not the disk is a fixed disk.
  588. Arguments:
  589. None.
  590. Return Value:
  591. FALSE - The disk is not a fixed disk.
  592. TRUE - The disk is a fixed disk.
  593. --*/
  594. {
  595. return _actual.MediaType == FixedMedia;
  596. }
  597. INLINE
  598. PCDRTYPE
  599. DP_DRIVE::GetSupportedList(
  600. OUT PINT NumSupported
  601. ) CONST
  602. /*++
  603. Routine Description:
  604. This routine returns a list of the supported media types by the device.
  605. Arguments:
  606. NumSupported - Returns the number of elements in the list.
  607. Return Value:
  608. A list of the supported media types by the device.
  609. --*/
  610. {
  611. *NumSupported = _num_supported;
  612. return _supported_list;
  613. }
  614. INLINE
  615. ULONG
  616. DP_DRIVE::QueryAlignmentMask(
  617. ) CONST
  618. /*++
  619. Routine Description:
  620. This routine returns the memory alignment requirement for the drive.
  621. Arguments:
  622. None.
  623. Return Value:
  624. The memory alignment requirement for the drive in the form of a mask.
  625. --*/
  626. {
  627. return _alignment_mask;
  628. }
  629. INLINE
  630. NTSTATUS
  631. DP_DRIVE::QueryLastNtStatus(
  632. ) CONST
  633. /*++
  634. Routine Description:
  635. This routine returns the last NT status value.
  636. Arguments:
  637. None.
  638. Return Value:
  639. The last NT status value.
  640. --*/
  641. {
  642. return _last_status;
  643. }
  644. class IO_DP_DRIVE : public DP_DRIVE {
  645. FRIEND class DRIVE_CACHE;
  646. public:
  647. VIRTUAL
  648. ~IO_DP_DRIVE(
  649. );
  650. NONVIRTUAL
  651. IFSUTIL_EXPORT
  652. BOOLEAN
  653. Read(
  654. IN BIG_INT StartingSector,
  655. IN SECTORCOUNT NumberOfSectors,
  656. OUT PVOID Buffer
  657. );
  658. NONVIRTUAL
  659. IFSUTIL_EXPORT
  660. BOOLEAN
  661. Write(
  662. IN BIG_INT StartingSector,
  663. IN SECTORCOUNT NumberOfSectors,
  664. IN PVOID Buffer
  665. );
  666. NONVIRTUAL
  667. IFSUTIL_EXPORT
  668. BOOLEAN
  669. Verify(
  670. IN BIG_INT StartingSector,
  671. IN BIG_INT NumberOfSectors,
  672. IN PVOID TestBuffer1,
  673. IN PVOID TestBuffer2
  674. );
  675. NONVIRTUAL
  676. IFSUTIL_EXPORT
  677. BOOLEAN
  678. Verify(
  679. IN BIG_INT StartingSector,
  680. IN BIG_INT NumberOfSectors,
  681. IN OUT PNUMBER_SET BadSectors
  682. );
  683. NONVIRTUAL
  684. IFSUTIL_EXPORT
  685. PMESSAGE
  686. GetMessage(
  687. );
  688. NONVIRTUAL
  689. IFSUTIL_EXPORT
  690. BOOLEAN
  691. Lock(
  692. );
  693. NONVIRTUAL
  694. IFSUTIL_EXPORT
  695. BOOLEAN
  696. InvalidateVolume(
  697. );
  698. NONVIRTUAL
  699. BOOLEAN
  700. Unlock(
  701. );
  702. NONVIRTUAL
  703. BOOLEAN
  704. DismountAndUnlock(
  705. );
  706. NONVIRTUAL
  707. BOOLEAN
  708. ForceDirty(
  709. );
  710. NONVIRTUAL
  711. BOOLEAN
  712. FormatVerifyFloppy(
  713. IN MEDIA_TYPE MediaType DEFAULT Unknown,
  714. IN OUT PNUMBER_SET BadSectors DEFAULT NULL,
  715. IN OUT PMESSAGE Message DEFAULT NULL,
  716. IN BOOLEAN IsDmfFormat DEFAULT FALSE
  717. );
  718. NONVIRTUAL
  719. IFSUTIL_EXPORT
  720. VOID
  721. SetCache(
  722. IN OUT PDRIVE_CACHE Cache
  723. );
  724. NONVIRTUAL
  725. IFSUTIL_EXPORT
  726. BOOLEAN
  727. FlushCache(
  728. );
  729. // Note that the following three methods, provided to
  730. // support SimBad, are _not_ in ifsutil.dll.
  731. NONVIRTUAL
  732. BOOLEAN
  733. EnableBadSectorSimulation(
  734. IN BOOLEAN Enable
  735. );
  736. NONVIRTUAL
  737. BOOLEAN
  738. SimulateBadSectors(
  739. IN BOOLEAN Add,
  740. IN ULONG Count,
  741. IN PLBN SectorArray,
  742. IN NTSTATUS Status,
  743. IN ULONG AccessType
  744. );
  745. NONVIRTUAL
  746. BOOLEAN
  747. QuerySimulatedBadSectors(
  748. OUT PULONG Count,
  749. IN ULONG MaximumLbnsInBuffer,
  750. OUT PLBN SectorArray,
  751. OUT PULONG AccessTypeArray
  752. );
  753. protected:
  754. DECLARE_CONSTRUCTOR(IO_DP_DRIVE);
  755. NONVIRTUAL
  756. BOOLEAN
  757. Initialize(
  758. IN PCWSTRING NtDriveName,
  759. IN OUT PMESSAGE Message DEFAULT NULL,
  760. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  761. );
  762. NONVIRTUAL
  763. BOOLEAN
  764. Initialize(
  765. IN PCWSTRING NtDriveName,
  766. IN PCWSTRING HostFileName,
  767. IN OUT PMESSAGE Message DEFAULT NULL,
  768. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  769. );
  770. private:
  771. BOOLEAN _is_locked;
  772. BOOLEAN _is_exclusive_write;
  773. PDRIVE_CACHE _cache;
  774. ULONG _ValidBlockLengthForVerify;
  775. PMESSAGE _message;
  776. NONVIRTUAL
  777. VOID
  778. Construct(
  779. );
  780. NONVIRTUAL
  781. VOID
  782. Destroy(
  783. );
  784. NONVIRTUAL
  785. BOOLEAN
  786. VerifyWithRead(
  787. IN BIG_INT StartingSector,
  788. IN BIG_INT NumberOfSectors
  789. );
  790. NONVIRTUAL
  791. BOOLEAN
  792. HardRead(
  793. IN BIG_INT StartingSector,
  794. IN SECTORCOUNT NumberOfSectors,
  795. OUT PVOID Buffer
  796. );
  797. NONVIRTUAL
  798. BOOLEAN
  799. HardWrite(
  800. IN BIG_INT StartingSector,
  801. IN SECTORCOUNT NumberOfSectors,
  802. IN PVOID Buffer
  803. );
  804. NONVIRTUAL
  805. BOOLEAN
  806. Dismount(
  807. );
  808. };
  809. INLINE
  810. PMESSAGE
  811. IO_DP_DRIVE::GetMessage(
  812. )
  813. /*++
  814. Routine Description:
  815. Retrieve the message object.
  816. Arguments:
  817. N/A
  818. Return Value:
  819. The message object.
  820. --*/
  821. {
  822. return _message;
  823. }
  824. class LOG_IO_DP_DRIVE : public IO_DP_DRIVE {
  825. public:
  826. IFSUTIL_EXPORT
  827. DECLARE_CONSTRUCTOR(LOG_IO_DP_DRIVE);
  828. VIRTUAL
  829. IFSUTIL_EXPORT
  830. ~LOG_IO_DP_DRIVE(
  831. );
  832. NONVIRTUAL
  833. IFSUTIL_EXPORT
  834. BOOLEAN
  835. Initialize(
  836. IN PCWSTRING NtDriveName,
  837. IN OUT PMESSAGE Message DEFAULT NULL,
  838. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  839. );
  840. NONVIRTUAL
  841. IFSUTIL_EXPORT
  842. BOOLEAN
  843. SetSystemId(
  844. IN PARTITION_SYSTEM_ID SystemId
  845. );
  846. #if defined (FE_SB) && defined (_X86_)
  847. // NEC98 June.25.1995
  848. // Add the type definition of function that other DLL is able to
  849. // call IO_DP_DRIVE::Read and IO_DP_DRIVE::Write.
  850. NONVIRTUAL
  851. IFSUTIL_EXPORT
  852. BOOLEAN
  853. Read(
  854. IN BIG_INT StartingSector,
  855. IN SECTORCOUNT NumberOfSectors,
  856. OUT PVOID Buffer
  857. );
  858. NONVIRTUAL
  859. IFSUTIL_EXPORT
  860. BOOLEAN
  861. Write(
  862. IN BIG_INT StartingSector,
  863. IN SECTORCOUNT NumberOfSectors,
  864. IN PVOID Buffer
  865. );
  866. #endif
  867. NONVIRTUAL
  868. IFSUTIL_EXPORT
  869. BOOLEAN
  870. Initialize(
  871. IN PCWSTRING NtDriveName,
  872. IN PCWSTRING HostFileName,
  873. IN OUT PMESSAGE Message DEFAULT NULL,
  874. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  875. );
  876. private:
  877. NONVIRTUAL
  878. VOID
  879. Construct(
  880. );
  881. };
  882. INLINE
  883. VOID
  884. LOG_IO_DP_DRIVE::Construct(
  885. )
  886. /*++
  887. Routine Description:
  888. Constructor for LOG_IO_DP_DRIVE.
  889. Arguments:
  890. None.
  891. Return Value:
  892. None.
  893. --*/
  894. {
  895. }
  896. class PHYS_IO_DP_DRIVE : public IO_DP_DRIVE {
  897. public:
  898. DECLARE_CONSTRUCTOR(PHYS_IO_DP_DRIVE);
  899. VIRTUAL
  900. ~PHYS_IO_DP_DRIVE(
  901. );
  902. NONVIRTUAL
  903. BOOLEAN
  904. Initialize(
  905. IN PCWSTRING NtDriveName,
  906. IN OUT PMESSAGE Message DEFAULT NULL,
  907. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  908. );
  909. private:
  910. NONVIRTUAL
  911. VOID
  912. Construct(
  913. );
  914. };
  915. INLINE
  916. VOID
  917. PHYS_IO_DP_DRIVE::Construct(
  918. )
  919. /*++
  920. Routine Description:
  921. Constructor for PHYS_IO_DP_DRIVE.
  922. Arguments:
  923. None.
  924. Return Value:
  925. None.
  926. --*/
  927. {
  928. }
  929. INLINE
  930. HANDLE
  931. DP_DRIVE::GetVolumeFileHandle(
  932. ) CONST
  933. /*++
  934. Routine Description:
  935. This routine is a hack for NTFS->OFS convert... it returns the
  936. handle open on the ntfs volume-file.
  937. Arguments:
  938. None.
  939. Return Value:
  940. The handle.
  941. --*/
  942. {
  943. return _handle;
  944. }
  945. #endif // DRIVE_DEFN