Ejemplo n.º 1
0
        internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath)
        {
            EmergencyFileEntry Entry = EmergencyRepository.Where(e => ((e.Type == Type) && (string.Compare(e.ProgrammerPath, ProgrammerPath, true) == 0))).FirstOrDefault();

            if ((Entry != null) && (PayloadPath != null) && (string.Compare(Entry.PayloadPath, PayloadPath, true) != 0))
            {
                LogFile.Log("Updating emergency payload path in repository: " + PayloadPath, LogType.FileAndConsole);
                Entry.PayloadPath = PayloadPath;
                WriteConfig();
            }
            else if (Entry == null)
            {
                LogFile.Log("Adding emergency files to repository: " + ProgrammerPath, LogType.FileAndConsole);
                LogFile.Log("Type: " + Type, LogType.FileAndConsole);

                Entry                = new EmergencyFileEntry();
                Entry.Type           = Type;
                Entry.ProgrammerPath = ProgrammerPath;
                Entry.PayloadPath    = PayloadPath;

                QualcommPartition Programmer = new QualcommPartition(ProgrammerPath);
                Entry.RKH = Programmer.RootKeyHash;

                EmergencyRepository.Add(Entry);
                WriteConfig();
            }
            else
            {
                LogFile.Log("Emergency files not added, because they were already present in the repository.", LogType.FileAndConsole);
            }
        }
Ejemplo n.º 2
0
        internal static List <QualcommPartition> GetPossibleLoadersForRootKeyHash(string Path, byte[] RootKeyHash)
        {
            List <QualcommPartition> Result = new List <QualcommPartition>();

            try
            {
                IEnumerable <string> FilePaths = Directory.EnumerateFiles(Path);
                foreach (string FilePath in FilePaths)
                {
                    try
                    {
                        FileInfo Info = new FileInfo(FilePath);
                        if (Info.Length <= 0x80000)
                        {
                            QualcommPartition Loader;

#if DEBUG
                            System.Diagnostics.Debug.Print("Evaluating loader: " + FilePath);
#endif

                            byte[] Binary = ParseAsHexFile(FilePath);
                            if (Binary == null)
                            {
                                Loader = new QualcommPartition(FilePath);
                            }
                            else
                            {
                                Loader = new QualcommPartition(Binary);
                            }

                            // 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]))
                            {
                                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);
                                }
                            }
                        }
                    }
                    catch { }
                }
            }
            catch { }

            return(Result);
        }
        private void SetEDEPath()
        {
            QualcommPartition Programmer;
            string            TempEDEPath;

            try
            {
                if (_EDEPath != null)
                {
                    Programmer = new QualcommPartition(_EDEPath);
                    if (ByteOperations.Compare(Programmer.RootKeyHash, RootKeyHash))
                    {
                        return;
                    }
                }
            }
            catch { }

            try
            {
                TempEDEPath = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\WPInternals", "EDEPath", null);
                if (TempEDEPath != null)
                {
                    Programmer = new QualcommPartition(TempEDEPath);
                    if (ByteOperations.Compare(Programmer.RootKeyHash, RootKeyHash))
                    {
                        EDEPath = TempEDEPath;
                        return;
                    }
                }
            }
            catch { }

            TempEDEPath = LumiaV2UnlockBootViewModel.GetProgrammerPath(RootKeyHash, ProductType);
            if (TempEDEPath != null)
            {
                Programmer = new QualcommPartition(TempEDEPath);
                if (ByteOperations.Compare(Programmer.RootKeyHash, RootKeyHash))
                {
                    EDEPath = TempEDEPath;
                    return;
                }
            }
        }