Skip to content

Commit

Permalink
TrueCrypt Source Version 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Truecrypt Foundation authored and FreeApophis committed May 29, 2014
1 parent 021d867 commit df05a91
Show file tree
Hide file tree
Showing 53 changed files with 1,100 additions and 731 deletions.
1 change: 1 addition & 0 deletions Boot/Windows/BootCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct
uint64 HiddenSystemPartitionStart;
uint64 DecoySystemPartitionStart;
uint32 Flags;
uint32 BootDriveSignature;

uint32 BootArgumentsCrc32;

Expand Down
2 changes: 1 addition & 1 deletion Boot/Windows/BootDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#endif

// Modifying this value can introduce incompatibility with previous versions
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000) // Memory reserved in the segment 8000 is always destroyed by Vista with no SP
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000) // Some buggy BIOS routines fail if CS bits 0-10 are not zero

#if TC__BOOT_MEMORY_REQUIRED <= 32
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 32 * 1024 / 16)
Expand Down
90 changes: 54 additions & 36 deletions Boot/Windows/BootDiskIo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Copyright (c) 2008-2011 TrueCrypt Developers Association. All rights reserved.
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
Expand Down Expand Up @@ -114,30 +114,39 @@ BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffs
sector |= byte (chs.Cylinder >> 2) & 0xc0;
byte function = write ? 0x03 : 0x02;

BiosResult result = BiosResultSuccess;
__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
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
mov result, ah
ok:
pop es
}
BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;

if (result == BiosResultEccCorrected)
do
{
result = BiosResultSuccess;

__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
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
mov result, ah
ok:
pop es
}

if (result == BiosResultEccCorrected)
result = BiosResultSuccess;

// Some BIOSes report I/O errors prematurely in some cases
} while (result != BiosResultSuccess && --tryCount != 0);

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

Expand Down Expand Up @@ -189,23 +198,32 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d

byte function = write ? 0x43 : 0x42;

BiosResult result = BiosResultSuccess;
__asm
{
mov bx, 0x55aa
mov dl, drive
mov si, [dapPacket]
mov ah, function
xor al, al
int 0x13
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
mov result, ah
ok:
}
BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;

if (result == BiosResultEccCorrected)
do
{
result = BiosResultSuccess;

__asm
{
mov bx, 0x55aa
mov dl, drive
mov si, [dapPacket]
mov ah, function
xor al, al
int 0x13
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
mov result, ah
ok:
}

if (result == BiosResultEccCorrected)
result = BiosResultSuccess;

// Some BIOSes report I/O errors prematurely in some cases
} while (result != BiosResultSuccess && --tryCount != 0);

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

Expand Down
4 changes: 3 additions & 1 deletion Boot/Windows/BootDiskIo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Copyright (c) 2008-2011 TrueCrypt Developers Association. All rights reserved.
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
Expand All @@ -13,6 +13,8 @@
#include "BootDebug.h"
#include "BootDefs.h"

#define TC_MAX_BIOS_DISK_IO_RETRIES 5

enum
{
BiosResultEccCorrected = 0x11
Expand Down
7 changes: 6 additions & 1 deletion Boot/Windows/BootMain.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Copyright (c) 2008-2011 TrueCrypt Developers Association. All rights reserved.
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
Expand Down Expand Up @@ -435,6 +435,11 @@ static byte BootEncryptedDrive ()
if (ExtraBootPartitionPresent && !GetActivePartition (BootDrive))
goto err;

if (ReadWriteMBR (false, ActivePartition.Drive) != BiosResultSuccess)
goto err;

bootArguments->BootDriveSignature = *(uint32 *) (SectorBuffer + 0x1b8);

if (!InstallInterruptFilters())
goto err;

Expand Down
2 changes: 1 addition & 1 deletion Common/APIDRVR.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define TC_IOCTL_GET_MOUNTED_VOLUMES TC_IOCTL (6)
#define TC_IOCTL_GET_VOLUME_PROPERTIES TC_IOCTL (7)
#define TC_IOCTL_GET_DEVICE_REFCOUNT TC_IOCTL (8)
#define TC_IOCTL_WAS_REFERENCED_DEVICE_DELETED TC_IOCTL (9)
#define TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED TC_IOCTL (9)
#define TC_IOCTL_IS_ANY_VOLUME_MOUNTED TC_IOCTL (10)
#define TC_IOCTL_GET_PASSWORD_CACHE_STATUS TC_IOCTL (11)
#define TC_IOCTL_WIPE_PASSWORD_CACHE TC_IOCTL (12)
Expand Down
26 changes: 26 additions & 0 deletions Common/BootEncryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,32 @@ namespace TrueCrypt
}


bool BootEncryption::SystemDriveContainsNonStandardPartitions ()
{
for (int partitionType = 1; partitionType <= 0xff; ++partitionType)
{
switch (partitionType)
{
case PARTITION_FAT_12:
case PARTITION_FAT_16:
case PARTITION_EXTENDED:
case PARTITION_HUGE:
case PARTITION_IFS:
case PARTITION_FAT32:
case PARTITION_FAT32_XINT13:
case PARTITION_XINT13:
case PARTITION_XINT13_EXTENDED:
continue;
}

if (SystemDriveContainsPartitionType ((byte) partitionType))
return true;
}

return false;
}


bool BootEncryption::SystemDriveIsDynamic ()
{
GetSystemDriveConfigurationRequest request;
Expand Down
1 change: 1 addition & 0 deletions Common/BootEncryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ namespace TrueCrypt
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
bool SystemDriveContainsPartitionType (byte type);
bool SystemDriveContainsExtendedPartition ();
bool SystemDriveContainsNonStandardPartitions ();
bool SystemPartitionCoversWholeDrive ();
bool SystemDriveIsDynamic ();
bool VerifyRescueDisk ();
Expand Down
8 changes: 2 additions & 6 deletions Common/CMDLINE.C
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ int GetArgSepPosOffset (char *lpszArgument)
{
if (lpszArgument[0] == '/')
return 1;
else if (lpszArgument[0] == '-' && lpszArgument[1] == '-')
return 2;
else if (lpszArgument[0] == '-')
return 1;
else
return 0;

return 0;
}

int GetArgumentID (argumentspec *as, char *lpszArgument, int *nArgPos)
Expand Down
6 changes: 3 additions & 3 deletions Common/CRYPTO.C
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,15 @@ PCRYPTO_INFO crypto_open ()

/* Do the crt allocation */
PCRYPTO_INFO cryptoInfo = (PCRYPTO_INFO) TCalloc (sizeof (CRYPTO_INFO));
if (cryptoInfo == NULL)
return NULL;

memset (cryptoInfo, 0, sizeof (CRYPTO_INFO));

#ifndef DEVICE_DRIVER
VirtualLock (cryptoInfo, sizeof (CRYPTO_INFO));
#endif

if (cryptoInfo == NULL)
return NULL;

cryptoInfo->ea = -1;
return cryptoInfo;

Expand Down
6 changes: 6 additions & 0 deletions Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

#include "Crypto.h"

#define MIN_MOUNTED_VOLUME_DRIVE_NUMBER ('A' - 'A')
#define MAX_MOUNTED_VOLUME_DRIVE_NUMBER ('Z' - 'A')

#define MAX_HOST_DRIVE_NUMBER 64
#define MAX_HOST_PARTITION_NUMBER 32

typedef enum
{
// IMPORTANT: If you add a new item here, update IsOSVersionAtLeast().
Expand Down
4 changes: 2 additions & 2 deletions Common/Common.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ CLASS "SplashDlg"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
EDITTEXT IDC_ABOUT_CREDITS,7,111,277,45,ES_MULTILINE | WS_VSCROLL | NOT WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,233,178,50,14
DEFPUSHBUTTON "OK",IDOK,230,178,52,14
LTEXT "",IDC_HOMEPAGE,18,87,117,9,SS_NOTIFY
LTEXT "",IDT_ABOUT_RELEASE,18,71,235,8
CONTROL 517,IDC_ABOUT_BKG,"Static",SS_BITMAP,0,0,12,11,WS_EX_STATICEDGE
LTEXT "",IDT_ABOUT_VERSION,18,61,161,8
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,167,291,1,WS_EX_STATICEDGE
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,169,291,1,WS_EX_STATICEDGE
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,107,291,1,WS_EX_STATICEDGE
PUSHBUTTON "Donations...",IDC_DONATIONS,164,178,61,14
CONTROL "",IDC_ABOUT_LOGO_AREA,"Static",SS_GRAYRECT | NOT WS_VISIBLE,0,0,293,50,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
CONTROL 518,IDC_TEXTUAL_LOGO_IMG,"Static",SS_BITMAP,12,26,157,16
END
Expand Down Expand Up @@ -515,6 +514,7 @@ END
// remains consistent on all systems.
IDI_TRUECRYPT_ICON ICON "..\\Common\\TrueCrypt.ico"
IDI_TRUECRYPT_VOL_ICON ICON "..\\Common\\TrueCrypt_volume.ico"
IDI_TRUECRYPT_MOUNTED_ICON ICON "..\\Common\\TrueCrypt_mounted.ico"

/////////////////////////////////////////////////////////////////////////////
//
Expand Down
Loading

0 comments on commit df05a91

Please sign in to comment.