Skip to content

Commit

Permalink
fix: revert qualcomm partition code changes to account for older ed p…
Browse files Browse the repository at this point in the history
…ayloads
  • Loading branch information
gus33000 committed Aug 27, 2024
1 parent 676a95d commit ab0c35e
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions WPinternals/Models/QualcommPartition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ internal QualcommPartition(byte[] Binary, uint Offset = 0)
HeaderOffset = ImageOffset + (uint)LongHeaderPattern.Length;
}

uint Version = ByteOperations.ReadUInt32(Binary, ImageOffset + 0X04);

if (ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00) != 0)
{
ImageOffset = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00);
Expand All @@ -125,31 +123,10 @@ internal QualcommPartition(byte[] Binary, uint Offset = 0)
CodeSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X0C);
SignatureAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X10);
SignatureSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X14);
SignatureOffset = SignatureAddress - ImageAddress + ImageOffset;
CertificatesAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X18);
CertificatesSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X1C);

if (SignatureAddress == 0xFFFFFFFF)
{
SignatureAddress = ImageAddress + CodeSize;
}

if (CertificatesAddress == 0xFFFFFFFF)
{
CertificatesAddress = SignatureAddress + SignatureSize;
}

// Headers newer than version 5 need more padding here
if (Version > 5)
{
ImageOffset += 0x80;
}

SignatureOffset = ImageOffset + CodeSize;
CertificatesOffset = ImageOffset + CodeSize + SignatureSize;

// Keeping just in case
// SignatureOffset = SignatureAddress - ImageAddress + ImageOffset;
// CertificatesOffset = ImageSize - CertificatesSize + ImageOffset;
CertificatesOffset = CertificatesAddress - ImageAddress + ImageOffset;

uint CurrentCertificateOffset = CertificatesOffset;
uint CertificateSize = 0;
Expand Down

0 comments on commit ab0c35e

Please sign in to comment.