--- truecrypt/boot/windows/bootdiskio.h 2018/04/24 16:49:04 1.1 +++ truecrypt/boot/windows/bootdiskio.h 2018/04/24 17:09:43 1.1.1.9 @@ -1,15 +1,22 @@ /* - Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. + Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved. - Governed by the TrueCrypt License 2.4 the full text of which is contained - in the file License.txt included in TrueCrypt binary and source code - distribution packages. + Governed by the TrueCrypt License 3.0 the full text of which is contained in + the file License.txt included in TrueCrypt binary and source code distribution + packages. */ #ifndef TC_HEADER_Boot_BootDiskIo #define TC_HEADER_Boot_BootDiskIo #include "Bios.h" +#include "BootDebug.h" +#include "BootDefs.h" + +enum +{ + BiosResultEccCorrected = 0x11 +}; #pragma pack(1) @@ -66,7 +73,6 @@ struct Partition bool Primary; uint64 SectorCount; uint64 StartSector; - ChsAddress StartChsAddress; byte Type; }; @@ -78,18 +84,31 @@ struct DriveGeometry }; +#ifdef TC_BOOT_DEBUG_ENABLED +void AcquireSectorBuffer (); +void ReleaseSectorBuffer (); +#else +# define AcquireSectorBuffer() +# define ReleaseSectorBuffer() +#endif + void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba); -BiosResult GetActivePartition (byte drive, Partition &partition, size_t &partitionCount, bool silent); +bool GetActivePartition (byte drive); BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false); -BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, bool silent = false); +BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); +bool IsLbaSupported (byte drive); void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs); void Print (const ChsAddress &chs); void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr); -BiosResult ReadMBR (byte drive, MBR &mbr, bool silent = false); +void PrintSectorCountInMB (const uint64 §orCount); +BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false); +BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent); BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); +extern byte SectorBuffer[TC_LB_SIZE]; + #endif // TC_HEADER_Boot_BootDiskIo