亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bootdiskio.cpp

?? turecrypt6.0版本的源碼
?? CPP
字號:
/*
 Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.

 Governed by the TrueCrypt License 2.5 the full text of which is contained
 in the file License.txt included in TrueCrypt binary and source code
 distribution packages.
*/

#include "Bios.h"
#include "BootConsoleIo.h"
#include "BootConfig.h"
#include "BootDebug.h"
#include "BootDefs.h"
#include "BootDiskIo.h"


byte SectorBuffer[TC_LB_SIZE];

#ifdef TC_BOOT_DEBUG_ENABLED
static bool SectorBufferInUse = false;

void AcquireSectorBuffer ()
{
	if (SectorBufferInUse)
		TC_THROW_FATAL_EXCEPTION;

	SectorBufferInUse = true;
}


void ReleaseSectorBuffer ()
{
	SectorBufferInUse = false;
}

#endif


bool IsLbaSupported (byte drive)
{
	static byte CachedDrive = TC_INVALID_BIOS_DRIVE;
	static bool CachedStatus;
	uint16 result = 0;

	if (CachedDrive == drive)
		goto ret;

	__asm
	{
		mov bx, 0x55aa
		mov dl, drive
		mov ah, 0x41
		int 0x13
		jc err
		mov result, bx
	err:
	}

	CachedDrive = drive;
	CachedStatus = (result == 0xaa55);
ret:
	return CachedStatus;
}


void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs)
{
	PrintEndl();
	Print (write ? "Write" : "Read"); Print (" error:");
	Print (error);
	Print (" Drive:");
	Print (drive < TC_FIRST_BIOS_DRIVE ? drive : drive - TC_FIRST_BIOS_DRIVE);

	if (sector)
	{
		Print (" Sector:");
		Print (*sector);
	}

	if (chs)
	{
		Print (" CHS:");
		Print (*chs);
	}

	PrintEndl();
	Beep();
}


void Print (const ChsAddress &chs)
{
	Print (chs.Cylinder);
	PrintChar ('/');
	Print (chs.Head);
	PrintChar ('/');
	Print (chs.Sector);
}


void PrintSectorCountInMB (const uint64 &sectorCount)
{
	Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MB ");
}


BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
{
	CheckStack();

	byte cylinderLow = (byte) chs.Cylinder;
	byte sector = chs.Sector;
	sector |= byte (chs.Cylinder >> 2) & 0xc0;
	byte function = write ? 0x03 : 0x02;

	BiosResult result;
	__asm
	{
		push es
		mov ax, bufferSegment
		mov	es, ax
		mov	bx, bufferOffset
		mov dl, drive
		mov ch, cylinderLow
		mov si, chs
		mov dh, [si].Head
		mov cl, sector
		mov	al, sectorCount
		mov	ah, function
		int	0x13
		mov	result, ah
		pop es
	}

	if (result == BiosResultEccCorrected)
		result = BiosResultSuccess;

	if (!silent && result != BiosResultSuccess)
		PrintDiskError (result, write, drive, nullptr, &chs);

	return result;
}


BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
{
	uint16 codeSeg;
	__asm mov codeSeg, cs
	return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent);
}


BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
{
	return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
}


BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
{
	return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
}


static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	CheckStack();

	dapPacket.Size = sizeof (dapPacket);
	dapPacket.Reserved = 0;
	dapPacket.SectorCount = sectorCount;
	dapPacket.Sector = sector;

	byte function = write ? 0x43 : 0x42;
	
	BiosResult result;
	__asm
	{
		mov	bx, 0x55aa
		mov	dl, drive
		mov si, [dapPacket]
		mov	ah, function
		xor al, al
		int	0x13
		mov	result, ah
	}

	if (result == BiosResultEccCorrected)
		result = BiosResultSuccess;

	if (!silent && result != BiosResultSuccess)
		PrintDiskError (result, write, drive, &sector);

	return result;
}


static BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	BiosLbaPacket dapPacket;
	dapPacket.Buffer = (uint32) buffer;
	return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
}


BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	BiosLbaPacket dapPacket;
	dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset;
	return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
}


BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	if (IsLbaSupported (drive))
		return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent);

	DriveGeometry geometry;

	BiosResult result = GetDriveGeometry (drive, geometry, silent);
	if (result != BiosResultSuccess)
		return result;

	ChsAddress chs;
	LbaToChs (geometry, sector, chs);
	return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, chs, sectorCount, silent);
}


BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	uint16 codeSeg;
	__asm mov codeSeg, cs
	return ReadSectors (codeSeg, (uint16) buffer, drive, sector, sectorCount, silent);
}


BiosResult WriteSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent)
{
	return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent);
}


BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent)
{
	CheckStack();

	byte maxCylinderLow, maxHead, maxSector;
	BiosResult result;
	__asm
	{
		push es
		mov dl, drive
		mov ah, 0x08
		int	0x13

		mov	result, ah
		jc err
		mov maxCylinderLow, ch
		mov maxSector, cl
		mov maxHead, dh
err:
		pop es
	}

	if (result == BiosResultSuccess)
	{
		geometry.Cylinders = (maxCylinderLow | (uint16 (maxSector & 0xc0) << 2)) + 1;
		geometry.Heads = maxHead + 1;
		geometry.Sectors = maxSector & ~0xc0;
	}
	else if (!silent)
	{
		PrintError ("Cannot get geometry of drive ", true, false);
		Print (drive);
		PrintEndl();
	}

	return result;
}


void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba)
{
	lba.HighPart = 0;
	lba.LowPart = (uint32 (chs.Cylinder) * geometry.Heads + chs.Head) * geometry.Sectors + chs.Sector - 1;
}


void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs)
{
	chs.Sector = (lba.LowPart % geometry.Sectors) + 1;
	uint32 ch = lba.LowPart / geometry.Sectors;
	chs.Head = ch % geometry.Heads;
	chs.Cylinder = ch / geometry.Heads;
}


void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition &partition)
{
	partition.Active = partEntry.BootIndicator == 0x80;
	partition.EndSector.HighPart = 0;
	partition.EndSector.LowPart = partEntry.StartLBA + partEntry.SectorCountLBA - 1;
	partition.SectorCount.HighPart = 0;
	partition.SectorCount.LowPart = partEntry.SectorCountLBA;
	partition.StartSector.HighPart = 0;
	partition.StartSector.LowPart = partEntry.StartLBA;
	partition.Type = partEntry.Type;
}


BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
{
	ChsAddress chs;
	chs.Cylinder = 0;
	chs.Head = 0;
	chs.Sector = 1;

	return ReadWriteSectors (write, SectorBuffer, drive, chs, 1, silent);
}


BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
{
	Partition *followingPartition;
	Partition tmpPartition;

	if (findPartitionFollowingThis)
	{
		assert (partitionArrayCapacity == 1);
		partitionArrayCapacity = 0xff;
		followingPartition = partitionArray;
		partitionArray = &tmpPartition;

		followingPartition->Drive = TC_INVALID_BIOS_DRIVE;
		followingPartition->StartSector.LowPart = 0xFFFFffffUL;
	}

	AcquireSectorBuffer();
	BiosResult result = ReadWriteMBR (false, drive, silent);
	ReleaseSectorBuffer();

	partitionCount = 0;

	MBR *mbr = (MBR *) SectorBuffer;
	if (result != BiosResultSuccess || mbr->Signature != 0xaa55)
		return result;

	PartitionEntryMBR mbrPartitions[4];
	memcpy (mbrPartitions, mbr->Partitions, sizeof (mbrPartitions));
	size_t partitionArrayPos = 0, partitionNumber;
	
	for (partitionNumber = 0;
		partitionNumber < array_capacity (mbrPartitions) && partitionArrayPos < partitionArrayCapacity;
		++partitionNumber)
	{
		const PartitionEntryMBR &partEntry = mbrPartitions[partitionNumber];
		
		if (partEntry.SectorCountLBA > 0)
		{
			Partition &partition = partitionArray[partitionArrayPos];
			PartitionEntryMBRToPartition (partEntry, partition);

			if (activeOnly && !partition.Active)
				continue;

			partition.Drive = drive;
			partition.Number = partitionNumber;

			if (partEntry.Type == 0x5 || partEntry.Type == 0xf) // Extended partition
			{
				if (IsLbaSupported (drive))
				{
					// Find all extended partitions
					uint64 firstExtStartLBA = partition.StartSector;
					uint64 extStartLBA = partition.StartSector;
					MBR *extMbr = (MBR *) SectorBuffer;

					while (partitionArrayPos < partitionArrayCapacity &&
						(result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
						&& extMbr->Signature == 0xaa55)
					{
						if (extMbr->Partitions[0].SectorCountLBA > 0)
						{
							Partition &logPart = partitionArray[partitionArrayPos];
							PartitionEntryMBRToPartition (extMbr->Partitions[0], logPart);
							logPart.Drive = drive;

							logPart.Number = partitionNumber++;
							logPart.Primary = false;

							logPart.StartSector.LowPart += extStartLBA.LowPart;
							logPart.EndSector.LowPart += extStartLBA.LowPart;

							if (findPartitionFollowingThis)
							{
								if (logPart.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
									&& logPart.StartSector.LowPart < followingPartition->StartSector.LowPart)
								{
									*followingPartition = logPart;
								}
							}
							else
								++partitionArrayPos;
						}

						// Secondary extended
						if (extMbr->Partitions[1].Type != 0x5 && extMbr->Partitions[1].Type == 0xf
							|| extMbr->Partitions[1].SectorCountLBA == 0)
							break;

						extStartLBA.LowPart = extMbr->Partitions[1].StartLBA + firstExtStartLBA.LowPart;
					}
				}
			}
			else
			{
				partition.Primary = true;

				if (findPartitionFollowingThis)
				{
					if (partition.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
						&& partition.StartSector.LowPart < followingPartition->StartSector.LowPart)
					{
						*followingPartition = partition;
					}
				}
				else
					++partitionArrayPos;
			}
		}
	}

	partitionCount = partitionArrayPos;
	return result;
}


bool GetActiveAndFollowingPartition (byte drive)
{
	size_t partCount;

	// Find active partition
	if (GetDrivePartitions (drive, &ActivePartition, 1, partCount, true) != BiosResultSuccess || partCount < 1)
	{
		ActivePartition.Drive = TC_INVALID_BIOS_DRIVE;
		PrintError ("No bootable partition found");
		return false;
	}

	// Find partition following the active one
	GetDrivePartitions (drive, &PartitionFollowingActive, 1, partCount, false, &ActivePartition);

	return true;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区欧美激情| 精品国一区二区三区| 天天色综合成人网| 国产亚洲成aⅴ人片在线观看| 91香蕉视频mp4| 蜜臀精品久久久久久蜜臀| 成人欧美一区二区三区小说| 日韩一级高清毛片| 91麻豆国产精品久久| 国产激情视频一区二区三区欧美 | 日产国产欧美视频一区精品| 国产精品另类一区| 日韩欧美不卡在线观看视频| 一本一本大道香蕉久在线精品| 国产在线国偷精品免费看| 午夜视频一区在线观看| **网站欧美大片在线观看| 欧美tickling挠脚心丨vk| 在线观看日韩一区| hitomi一区二区三区精品| 精品一区二区三区免费视频| 天天影视网天天综合色在线播放| 国产精品三级久久久久三级| 精品国产乱码久久久久久牛牛| 正在播放一区二区| 欧美性猛交xxxxxx富婆| 在线观看网站黄不卡| 99精品一区二区| 成人午夜视频福利| 成人激情免费电影网址| 亚洲成人高清在线| 国产精品综合一区二区| 日本在线播放一区二区三区| 午夜精品久久久久久久久久久| 亚洲精品日韩一| 中文字幕一区二区视频| 亚洲欧美综合网| 中文字幕中文字幕中文字幕亚洲无线| 亚洲精品在线免费观看视频| 91精品国产综合久久精品图片 | 韩国av一区二区三区四区| 三级成人在线视频| 午夜久久久久久久久| 亚洲成人精品影院| 亚洲一区二区三区在线看| 一区二区在线看| 亚洲超丰满肉感bbw| 天堂蜜桃91精品| 美女视频黄免费的久久 | 亚洲香蕉伊在人在线观| 亚洲国产综合视频在线观看| 亚洲国产sm捆绑调教视频| 亚洲chinese男男1069| 亚洲成人777| 日韩电影一区二区三区| 日韩影视精彩在线| 久久99久久99| jizzjizzjizz欧美| 欧美艳星brazzers| 欧美一区二区久久久| 欧美一区国产二区| 国产性天天综合网| 中文字幕视频一区二区三区久| 色噜噜狠狠一区二区三区果冻| 成人久久18免费网站麻豆| 色综合天天综合狠狠| 91官网在线免费观看| 欧美乱熟臀69xxxxxx| 日韩欧美高清在线| 国产日韩欧美a| ...av二区三区久久精品| 午夜精品久久久久久| 黄色精品一二区| 99久久国产综合色|国产精品| 欧美日韩精品高清| 精品成人一区二区三区四区| 国产精品美女久久久久av爽李琼 | 日韩成人免费看| 国产精品影音先锋| 欧美日韩一二区| 国产日韩欧美精品电影三级在线| 亚洲精品中文在线| 精品一区中文字幕| 日本道免费精品一区二区三区| 欧美一区欧美二区| 亚洲三级久久久| 国内精品久久久久影院一蜜桃| 色婷婷av一区二区三区大白胸| 欧美大片拔萝卜| 亚洲影院理伦片| 高清成人免费视频| 在线综合+亚洲+欧美中文字幕| 国产精品久久久久国产精品日日| 日产欧产美韩系列久久99| bt欧美亚洲午夜电影天堂| 欧美日韩精品欧美日韩精品 | 国产亚洲精品aa午夜观看| 亚洲午夜久久久久中文字幕久| 国产成人精品aa毛片| 欧美日韩精品免费| 欧美日韩成人在线| 717成人午夜免费福利电影| 国产午夜精品理论片a级大结局| 亚洲成av人影院在线观看网| 成人av电影免费在线播放| 欧美成人激情免费网| 亚洲高清免费观看| 不卡区在线中文字幕| 精品成a人在线观看| 亚洲夂夂婷婷色拍ww47| 波多野结衣中文字幕一区二区三区 | 麻豆精品久久精品色综合| 欧美专区日韩专区| 亚洲一区二区欧美日韩| 成人aaaa免费全部观看| 精品精品国产高清一毛片一天堂| 亚洲综合激情网| av中文一区二区三区| 久久老女人爱爱| 蜜桃传媒麻豆第一区在线观看| 在线精品观看国产| 亚洲成人资源在线| 在线观看不卡一区| 亚洲激情网站免费观看| 91在线免费播放| 亚洲欧美区自拍先锋| 成人污视频在线观看| 久久久久97国产精华液好用吗| 国产在线精品一区二区三区不卡| 欧美www视频| 成人免费毛片片v| 久久综合九色综合97婷婷女人 | 色噜噜偷拍精品综合在线| 亚洲日本丝袜连裤袜办公室| 亚洲精品视频自拍| 国产欧美日产一区| 久久影院电视剧免费观看| 五月激情综合网| 欧美日韩国产美女| 丝袜诱惑亚洲看片| 911国产精品| 婷婷综合五月天| 欧美日韩第一区日日骚| 亚洲第一狼人社区| 欧美剧情电影在线观看完整版免费励志电影 | 中文字幕一区二区视频| www.日韩在线| 亚洲天堂2014| 日本精品一区二区三区四区的功能| 亚洲精品老司机| 欧美三级资源在线| 亚洲成va人在线观看| 欧美三级视频在线播放| 日韩一区精品字幕| 日韩一区二区三区视频| 亚洲电影视频在线| 亚洲一区二区av在线| 欧美精品亚洲二区| 日韩电影在线免费看| 久久老女人爱爱| av一区二区久久| 亚洲成a人v欧美综合天堂| 欧美成人一区二区| 国产大陆精品国产| 一区二区三区av电影| 91精品中文字幕一区二区三区| 精品一区二区在线播放| 国产精品区一区二区三| 色婷婷久久一区二区三区麻豆| 亚洲电影你懂得| 欧美va亚洲va香蕉在线| 国产a区久久久| 国产精品视频九色porn| 欧美性视频一区二区三区| 激情综合色综合久久综合| 国产精品视频九色porn| 欧美日韩国产a| 国产成人av一区二区三区在线观看| 亚洲欧美一区二区三区极速播放| 欧美日本视频在线| 成人丝袜视频网| 婷婷亚洲久悠悠色悠在线播放| 欧美高清在线一区二区| 91精品婷婷国产综合久久性色| 高清成人在线观看| 免费在线观看日韩欧美| 亚洲欧美成aⅴ人在线观看| 欧美成人一区二区三区在线观看| 99久久99久久精品国产片果冻| 美女视频一区在线观看| 亚洲免费在线看| 国产日韩三级在线| 7777精品伊人久久久大香线蕉超级流畅| 国产成人综合网| 免费av成人在线| 一区二区三区四区不卡在线| 亚洲国产精品黑人久久久| 欧美日韩极品在线观看一区| 成人性生交大合| 老司机精品视频在线|