diff --git a/Models/QualcommLoader.cs b/Models/QualcommLoader.cs index 99c1321..45ff109 100644 --- a/Models/QualcommLoader.cs +++ b/Models/QualcommLoader.cs @@ -53,10 +53,23 @@ namespace WPinternals else Loader = new QualcommPartition(Binary); - if ((StructuralComparisons.StructuralEqualityComparer.Equals(Loader.RootKeyHash, RootKeyHash)) - && (ByteOperations.FindUnicode(Loader.Binary, "QHSUSB_ARMPRG") != null)) // To detect that this is a loader, and not SBL1 or something. V1 loaders are QHSUSB_ARMPRG. V2 loaders are QHSUSB__BULK. Only V1 supported for now, because V2 only accepts signed payload. + // Make sure the RootKeyHash is not blank + // If the RootKeyHash is blank, this is an engineering device, and it will accept any RKH + // We expect the user to know what he is doing in such case and we will ignore checks + if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, new byte[RootKeyHash.Length])) { - Result.Add(Loader); + if ((StructuralComparisons.StructuralEqualityComparer.Equals(Loader.RootKeyHash, RootKeyHash)) + && (ByteOperations.FindUnicode(Loader.Binary, "QHSUSB_ARMPRG") != null)) // To detect that this is a loader, and not SBL1 or something. V1 loaders are QHSUSB_ARMPRG. V2 loaders are QHSUSB__BULK. Only V1 supported for now, because V2 only accepts signed payload. + { + Result.Add(Loader); + } + } + else + { + if ((ByteOperations.FindUnicode(Loader.Binary, "QHSUSB_ARMPRG") != null)) // To detect that this is a loader, and not SBL1 or something. V1 loaders are QHSUSB_ARMPRG. V2 loaders are QHSUSB__BULK. Only V1 supported for now, because V2 only accepts signed payload. + { + Result.Add(Loader); + } } } } diff --git a/ViewModels/LumiaUnlockBootloaderViewModel.cs b/ViewModels/LumiaUnlockBootloaderViewModel.cs index ec787e4..ddd0c9d 100644 --- a/ViewModels/LumiaUnlockBootloaderViewModel.cs +++ b/ViewModels/LumiaUnlockBootloaderViewModel.cs @@ -373,15 +373,22 @@ namespace WPinternals { throw new Exception("Error: Root Key Hash could not be retrieved from the phone."); } - if (SBL1.RootKeyHash == null) + + // Make sure the RootKeyHash is not blank + // If the RootKeyHash is blank, this is an engineering device, and it will accept any RKH + // We expect the user to know what he is doing in such case and we will ignore checks + if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, new byte[RootKeyHash.Length])) { - throw new Exception("Error: Root Key Hash could not be retrieved from FFU file."); - } - if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, SBL1.RootKeyHash)) - { - LogFile.Log("Phone: " + Converter.ConvertHexToString(RootKeyHash, "")); - LogFile.Log("SBL1: " + Converter.ConvertHexToString(SBL1.RootKeyHash, "")); - throw new Exception("Error: Root Key Hash from phone and from FFU file do not match!"); + if (SBL1.RootKeyHash == null) + { + throw new Exception("Error: Root Key Hash could not be retrieved from FFU file."); + } + if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, SBL1.RootKeyHash)) + { + LogFile.Log("Phone: " + Converter.ConvertHexToString(RootKeyHash, "")); + LogFile.Log("SBL1: " + Converter.ConvertHexToString(SBL1.RootKeyHash, "")); + throw new Exception("Error: Root Key Hash from phone and from FFU file do not match!"); + } } } @@ -870,15 +877,22 @@ namespace WPinternals { throw new Exception("Error: Root Key Hash could not be retrieved from the phone."); } - if (SBL1.RootKeyHash == null) + + // Make sure the RootKeyHash is not blank + // If the RootKeyHash is blank, this is an engineering device, and it will accept any RKH + // We expect the user to know what he is doing in such case and we will ignore checks + if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, new byte[RootKeyHash.Length])) { - throw new Exception("Error: Root Key Hash could not be retrieved from FFU file."); - } - if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, SBL1.RootKeyHash)) - { - LogFile.Log("Phone: " + Converter.ConvertHexToString(RootKeyHash, "")); - LogFile.Log("SBL1: " + Converter.ConvertHexToString(SBL1.RootKeyHash, "")); - throw new Exception("Error: Root Key Hash from phone and from FFU file do not match!"); + if (SBL1.RootKeyHash == null) + { + throw new Exception("Error: Root Key Hash could not be retrieved from FFU file."); + } + if (!StructuralComparisons.StructuralEqualityComparer.Equals(RootKeyHash, SBL1.RootKeyHash)) + { + LogFile.Log("Phone: " + Converter.ConvertHexToString(RootKeyHash, "")); + LogFile.Log("SBL1: " + Converter.ConvertHexToString(SBL1.RootKeyHash, "")); + throw new Exception("Error: Root Key Hash from phone and from FFU file do not match!"); + } } }