Skip to content

Commit

Permalink
Windows: Avoid modifying BootArguments structure and use __unaligned …
Browse files Browse the repository at this point in the history
…keyword to inform compiler that pointer is unaligned.

This avoids issues with existing bootloaders
  • Loading branch information
idrassi committed Nov 16, 2024
1 parent c86577f commit 9c9870b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Boot/Windows/BootCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define TC_HEADER_Boot_BootCommon

#include "Common/Password.h"
#include "Crypto/config.h"
#include "BootDefs.h"

// The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version
Expand Down Expand Up @@ -59,7 +58,7 @@ typedef struct
uint16 CryptoInfoOffset;
uint16 CryptoInfoLength;
uint32 HeaderSaltCrc32;
CRYPTOPP_ALIGN_DATA(8) PasswordLegacy BootPassword;
PasswordLegacy BootPassword;
uint64 HiddenSystemPartitionStart;
uint64 DecoySystemPartitionStart;
uint32 Flags;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void AddPasswordToCache (Password *password, int pim, BOOL bCachePim)
burn (&tmpPass, sizeof (Password));
}

void AddLegacyPasswordToCache (PasswordLegacy *password, int pim)
void AddLegacyPasswordToCache (__unaligned PasswordLegacy *password, int pim)
{
Password inputPass = {0};
inputPass.Length = password->Length;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
extern int cacheEmpty;

void AddPasswordToCache (Password *password, int pim, BOOL bCachePim);
void AddLegacyPasswordToCache (PasswordLegacy *password, int pim);
void AddLegacyPasswordToCache (__unaligned PasswordLegacy *password, int pim);
int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, unsigned char *header, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo);
void WipeCache (void);
2 changes: 1 addition & 1 deletion src/Driver/DriveFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8
}


static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, uint32 *headerSaltCrc32)
static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, __unaligned uint32 *headerSaltCrc32)
{
BOOL hiddenVolume = (BootArgs.HiddenSystemPartitionStart != 0);
int64 hiddenHeaderOffset = BootArgs.HiddenSystemPartitionStart + TC_HIDDEN_VOLUME_HEADER_OFFSET;
Expand Down

0 comments on commit 9c9870b

Please sign in to comment.