mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-16 20:30:12 +10:00
Implement Qualcomm Sahara VIP and fix a few bugs
* Qualcomm Sahara VIP * Project Cleanup * Allow unlocking an already unlocked phone
This commit is contained in:
@@ -187,7 +187,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackupArchiveCommand ??= new DelegateCommand(() => BackupArchiveCallback(ArchivePath), () => ((ArchivePath != null) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _BackupArchiveCommand ??= new DelegateCommand(() => BackupArchiveCallback(ArchivePath), () => (ArchivePath != null) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackupCommand ??= new DelegateCommand(() => BackupCallback(EFIESPPath, MainOSPath, DataPath), () => (((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _BackupCommand ??= new DelegateCommand(() => BackupCallback(EFIESPPath, MainOSPath, DataPath), () => ((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackupArchiveProvisioningCommand ??= new DelegateCommand(() => BackupArchiveProvisioningCallback(ArchiveProvisioningPath), () => ((ArchiveProvisioningPath != null) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _BackupArchiveProvisioningCommand ??= new DelegateCommand(() => BackupArchiveProvisioningCallback(ArchiveProvisioningPath), () => (ArchiveProvisioningPath != null) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace WPinternals
|
||||
{
|
||||
IsPhoneDisconnected = PhoneNotifier.CurrentInterface == null;
|
||||
IsPhoneInMassStorage = PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_MassStorage;
|
||||
IsPhoneInOtherMode = (!IsPhoneDisconnected && !IsPhoneInMassStorage);
|
||||
IsPhoneInOtherMode = !IsPhoneDisconnected && !IsPhoneInMassStorage;
|
||||
BackupCommand.RaiseCanExecuteChanged();
|
||||
BackupArchiveCommand.RaiseCanExecuteChanged();
|
||||
BackupArchiveProvisioningCommand.RaiseCanExecuteChanged();
|
||||
|
||||
@@ -434,36 +434,33 @@ namespace WPinternals
|
||||
|
||||
foreach (string PartitionName in ProvisioningPartitions)
|
||||
{
|
||||
if (GPT.Partitions.Any(p => p.Name == PartitionName))
|
||||
if (GPT.Partitions.Any(p => p.Name == PartitionName) && Result)
|
||||
{
|
||||
if (Result)
|
||||
try
|
||||
{
|
||||
try
|
||||
Entry = Archive.CreateEntry(PartitionName + ".bin", CompressionLevel.Optimal);
|
||||
EntryStream = Entry.Open();
|
||||
i++;
|
||||
Busy.Message = "Create backup of partition " + PartitionName + " (" + i.ToString() + "/" + PartitionCount.ToString() + ")";
|
||||
if (PartitionName == "UEFI_BS_NV" && GPT.Partitions.Any(p => p.Name == "BACKUP_BS_NV"))
|
||||
{
|
||||
Entry = Archive.CreateEntry(PartitionName + ".bin", CompressionLevel.Optimal);
|
||||
EntryStream = Entry.Open();
|
||||
i++;
|
||||
Busy.Message = "Create backup of partition " + PartitionName + " (" + i.ToString() + "/" + PartitionCount.ToString() + ")";
|
||||
if (PartitionName == "UEFI_BS_NV" && GPT.Partitions.Any(p => p.Name == "BACKUP_BS_NV"))
|
||||
{
|
||||
Phone.BackupPartition("BACKUP_BS_NV", EntryStream, Updater);
|
||||
}
|
||||
else
|
||||
{
|
||||
Phone.BackupPartition(PartitionName, EntryStream, Updater);
|
||||
}
|
||||
Phone.BackupPartition("BACKUP_BS_NV", EntryStream, Updater);
|
||||
}
|
||||
catch (Exception Ex)
|
||||
else
|
||||
{
|
||||
LogFile.LogException(Ex);
|
||||
Result = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
EntryStream?.Close();
|
||||
EntryStream = null;
|
||||
Phone.BackupPartition(PartitionName, EntryStream, Updater);
|
||||
}
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
LogFile.LogException(Ex);
|
||||
Result = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
EntryStream?.Close();
|
||||
EntryStream = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace WPinternals
|
||||
if (result == true)
|
||||
{
|
||||
FFUPath = dlg.FileName;
|
||||
string FFUFile = System.IO.Path.GetFileName(FFUPath);
|
||||
string FFUFile = Path.GetFileName(FFUPath);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -134,7 +134,7 @@ namespace WPinternals
|
||||
internal static long GetFileLengthFromURL(string URL)
|
||||
{
|
||||
long Length = 0;
|
||||
HttpWebRequest req = (HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
|
||||
req.Method = "HEAD";
|
||||
req.ServicePoint.ConnectionLimit = 10;
|
||||
using (WebResponse resp = req.GetResponse())
|
||||
@@ -146,7 +146,7 @@ namespace WPinternals
|
||||
|
||||
internal static string GetFileNameFromURL(string URL)
|
||||
{
|
||||
string FileName = System.IO.Path.GetFileName(URL);
|
||||
string FileName = Path.GetFileName(URL);
|
||||
int End = FileName.IndexOf('?');
|
||||
if (End >= 0)
|
||||
{
|
||||
@@ -541,14 +541,14 @@ namespace WPinternals
|
||||
if (URLCollection == null)
|
||||
{
|
||||
Files = new string[1];
|
||||
Files[0] = System.IO.Path.Combine(Folder, DownloadsViewModel.GetFileNameFromURL(URL));
|
||||
Files[0] = Path.Combine(Folder, DownloadsViewModel.GetFileNameFromURL(URL));
|
||||
}
|
||||
else
|
||||
{
|
||||
Files = new string[URLCollection.Length];
|
||||
for (int i = 0; i < URLCollection.Length; i++)
|
||||
{
|
||||
Files[i] = System.IO.Path.Combine(Folder, DownloadsViewModel.GetFileNameFromURL(URLCollection[i]));
|
||||
Files[i] = Path.Combine(Folder, DownloadsViewModel.GetFileNameFromURL(URLCollection[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@ namespace WPinternals
|
||||
public object Convert(object value, Type targetType,
|
||||
object parameter, CultureInfo culture)
|
||||
{
|
||||
return System.IO.Path.GetFileNameWithoutExtension((string)value);
|
||||
return Path.GetFileNameWithoutExtension((string)value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType,
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _DumpCommand ??= new DelegateCommand(() => DumpCallback(FFUPath, EFIESPPath, CompressEFIESP, MainOSPath, CompressMainOS, DataPath, CompressData), () => ((FFUPath != null) && ((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null))));
|
||||
return _DumpCommand ??= new DelegateCommand(() => DumpCallback(FFUPath, EFIESPPath, CompressEFIESP, MainOSPath, CompressMainOS, DataPath, CompressData), () => (FFUPath != null) && ((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _FlashPartitionsCommand ??= new DelegateCommand(() => FlashPartitionsCallback(EFIESPPath, MainOSPath, DataPath), () => (((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _FlashPartitionsCommand ??= new DelegateCommand(() => FlashPartitionsCallback(EFIESPPath, MainOSPath, DataPath), () => ((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _FlashFFUCommand ??= new DelegateCommand(() => FlashFFUCallback(FFUPath), () => ((FFUPath != null) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _FlashFFUCommand ??= new DelegateCommand(() => FlashFFUCallback(FFUPath), () => (FFUPath != null) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _FlashMMOSCommand ??= new DelegateCommand(() => FlashMMOSCallback(MMOSPath), () => ((MMOSPath != null) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _FlashMMOSCommand ??= new DelegateCommand(() => FlashMMOSCallback(MMOSPath), () => (MMOSPath != null) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _FlashArchiveCommand ??= new DelegateCommand(() => FlashArchiveCallback(ArchivePath), () => ((ArchivePath != null) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _FlashArchiveCommand ??= new DelegateCommand(() => FlashArchiveCallback(ArchivePath), () => (ArchivePath != null) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace WPinternals
|
||||
{
|
||||
IsPhoneDisconnected = PhoneNotifier.CurrentInterface == null;
|
||||
IsPhoneInFlashMode = PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_Flash;
|
||||
IsPhoneInOtherMode = (!IsPhoneDisconnected && !IsPhoneInFlashMode);
|
||||
IsPhoneInOtherMode = !IsPhoneDisconnected && !IsPhoneInFlashMode;
|
||||
FlashPartitionsCommand.RaiseCanExecuteChanged();
|
||||
FlashArchiveCommand.RaiseCanExecuteChanged();
|
||||
FlashFFUCommand.RaiseCanExecuteChanged();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace WPinternals
|
||||
ulong StreamLengthInSectors = (ulong)Stream.Length / 0x200;
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, "EFIESP", true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, "EFIESP", StringComparison.CurrentCultureIgnoreCase));
|
||||
if (StreamLengthInSectors > Partition.SizeInSectors)
|
||||
{
|
||||
LogFile.Log("Flash failed! Size of partition 'EFIESP' is too big.");
|
||||
@@ -131,7 +131,7 @@ namespace WPinternals
|
||||
ulong StreamLengthInSectors = (ulong)Stream.Length / 0x200;
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
MainOSOldSectorCount = Partition.SizeInSectors;
|
||||
MainOSNewSectorCount = StreamLengthInSectors;
|
||||
FirstMainOSSector = Partition.FirstSector;
|
||||
@@ -143,7 +143,7 @@ namespace WPinternals
|
||||
ulong StreamLengthInSectors = (ulong)Stream.Length / 0x200;
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
DataOldSectorCount = Partition.SizeInSectors;
|
||||
DataNewSectorCount = StreamLengthInSectors;
|
||||
}
|
||||
@@ -162,8 +162,8 @@ namespace WPinternals
|
||||
if ((MainOSNewSectorCount + DataNewSectorCount) <= OSSpace)
|
||||
{
|
||||
// MainOS and Data partitions need to be re-aligned!
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
MainOSPartition.LastSector = MainOSPartition.FirstSector + MainOSNewSectorCount - 1;
|
||||
DataPartition.FirstSector = MainOSPartition.LastSector + 1;
|
||||
DataPartition.LastSector = DataPartition.FirstSector + DataNewSectorCount - 1;
|
||||
@@ -327,14 +327,14 @@ namespace WPinternals
|
||||
// First determine if we need a new GPT!
|
||||
if (!Entry.FullName.Contains("/")) // No subfolders
|
||||
{
|
||||
string PartitionName = System.IO.Path.GetFileNameWithoutExtension(Entry.Name);
|
||||
string PartitionName = Path.GetFileNameWithoutExtension(Entry.Name);
|
||||
int P = PartitionName.IndexOf('.');
|
||||
if (P >= 0)
|
||||
{
|
||||
PartitionName = PartitionName.Substring(0, P); // Example: Data.bin.gz -> Data
|
||||
}
|
||||
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, PartitionName, true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, PartitionName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (Partition != null)
|
||||
{
|
||||
DecompressedStream DecompressedStream = new(Entry.Open());
|
||||
@@ -348,13 +348,13 @@ namespace WPinternals
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
|
||||
if (string.Compare(PartitionName, "MainOS", true) == 0)
|
||||
if (string.Equals(PartitionName, "MainOS", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
MainOSOldSectorCount = Partition.SizeInSectors;
|
||||
MainOSNewSectorCount = StreamLengthInSectors;
|
||||
FirstMainOSSector = Partition.FirstSector;
|
||||
}
|
||||
else if (string.Compare(PartitionName, "Data", true) == 0)
|
||||
else if (string.Equals(PartitionName, "Data", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
DataOldSectorCount = Partition.SizeInSectors;
|
||||
DataNewSectorCount = StreamLengthInSectors;
|
||||
@@ -377,8 +377,8 @@ namespace WPinternals
|
||||
if ((MainOSNewSectorCount + DataNewSectorCount) <= OSSpace)
|
||||
{
|
||||
// MainOS and Data partitions need to be re-aligned!
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
MainOSPartition.LastSector = MainOSPartition.FirstSector + MainOSNewSectorCount - 1;
|
||||
DataPartition.FirstSector = MainOSPartition.LastSector + 1;
|
||||
DataPartition.LastSector = DataPartition.FirstSector + DataNewSectorCount - 1;
|
||||
@@ -429,7 +429,7 @@ namespace WPinternals
|
||||
PartitionName = PartitionName.Substring(0, Pos);
|
||||
}
|
||||
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, PartitionName, true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, PartitionName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (Partition != null)
|
||||
{
|
||||
Stream DecompressedStream = new DecompressedStream(Entry.Open());
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace WPinternals
|
||||
UefiSecurityStatusResponse SecurityStatus = ((NokiaFlashModel)PhoneNotifier.CurrentModel).ReadSecurityStatus();
|
||||
if (SecurityStatus != null)
|
||||
{
|
||||
IsBootLoaderUnlocked = (SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus);
|
||||
IsBootLoaderUnlocked = SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus;
|
||||
}
|
||||
|
||||
TestPos = 2;
|
||||
@@ -210,16 +210,16 @@ namespace WPinternals
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool AlreadyUnlocked = false;
|
||||
bool AlreadyUnlocked = false;
|
||||
if (DoUnlock)
|
||||
{
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)PhoneNotifier.CurrentModel;
|
||||
GPT GPT = FlashModel.ReadGPT();
|
||||
if ((GPT.GetPartition("IS_UNLOCKED") != null) || (GPT.GetPartition("BACKUP_EFIESP") != null))
|
||||
{
|
||||
ExitMessage("Phone is already unlocked", null);
|
||||
return;
|
||||
//AlreadyUnlocked = true;
|
||||
//ExitMessage("Phone is already unlocked", null);
|
||||
//return;
|
||||
AlreadyUnlocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace WPinternals
|
||||
{
|
||||
FFU ProfileFFU = null;
|
||||
|
||||
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => (Info.PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists())).ToList();
|
||||
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => Info.PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists()).ToList();
|
||||
ProfileFFU = FFUs.Count > 0
|
||||
? new FFU(FFUs[0].Path)
|
||||
: throw new WPinternalsException("Profile FFU missing", "No profile FFU has been found in the repository for your device. You can add a profile FFU within the download section of the tool or by using the command line.");
|
||||
@@ -608,7 +608,7 @@ namespace WPinternals
|
||||
this.SwitchToDownload = SwitchToDownload;
|
||||
this.IsBootLoaderUnlocked = IsBootLoaderUnlocked;
|
||||
OkCommand = new DelegateCommand(() => Result(FFUPath, LoadersPath, SBL3Path, ProfileFFUPath, EDEPath, IsSupportedFfuNeeded ? SupportedFFUPath : null, false),
|
||||
() => ((!TargetHasNewFlashProtocol && (!IsSupportedFfuNeeded || (IsSupportedFfuValid && (SupportedFFUPath != null)))) || ((ProfileFFUPath != null) && (!IsSupportedFfuNeeded || (IsSupportedFfuValid && (SupportedFFUPath != null))))));
|
||||
() => (!TargetHasNewFlashProtocol && (!IsSupportedFfuNeeded || (IsSupportedFfuValid && (SupportedFFUPath != null)))) || ((ProfileFFUPath != null) && (!IsSupportedFfuNeeded || (IsSupportedFfuValid && (SupportedFFUPath != null)))));
|
||||
FixCommand = new DelegateCommand(() => Result(null, null, null, null, null, null, true));
|
||||
CancelCommand = new DelegateCommand(Abort);
|
||||
this.TargetHasNewFlashProtocol = TargetHasNewFlashProtocol;
|
||||
@@ -660,7 +660,7 @@ namespace WPinternals
|
||||
}
|
||||
catch { }
|
||||
|
||||
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => (PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists())).ToList();
|
||||
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists()).ToList();
|
||||
if (FFUs.Count > 0)
|
||||
{
|
||||
IsProfileFfuValid = true;
|
||||
@@ -859,7 +859,7 @@ namespace WPinternals
|
||||
{
|
||||
if (!TargetHasNewFlashProtocol)
|
||||
{
|
||||
if (App.Config.FFURepository.Any(e => ((e.Path == SupportedFFUPath) && (App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V1.1-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))))
|
||||
if (App.Config.FFURepository.Any(e => (e.Path == SupportedFFUPath) && App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V1.1-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
IsSupportedFfuValid = true;
|
||||
}
|
||||
@@ -871,7 +871,7 @@ namespace WPinternals
|
||||
}
|
||||
else
|
||||
{
|
||||
if (App.Config.FFURepository.Any(e => ((e.Path == SupportedFFUPath) && (App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))))
|
||||
if (App.Config.FFURepository.Any(e => (e.Path == SupportedFFUPath) && App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
IsSupportedFfuValid = true;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//#define DUMPPARTITIONS
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,7 +29,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
internal class LumiaUnlockBootloaderViewModel
|
||||
internal static class LumiaUnlockBootloaderViewModel
|
||||
{
|
||||
// TODO: Add logging
|
||||
private static void PerformSoftBrick(PhoneNotifierViewModel Notifier, FFU FFU)
|
||||
@@ -37,7 +39,7 @@ namespace WPinternals
|
||||
// Send FFU headers
|
||||
UInt64 CombinedFFUHeaderSize = FFU.HeaderSize;
|
||||
byte[] FfuHeader = new byte[CombinedFFUHeaderSize];
|
||||
FileStream FfuFile = new(FFU.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
||||
FileStream FfuFile = new(FFU.Path, FileMode.Open, FileAccess.Read);
|
||||
FfuFile.Read(FfuHeader, 0, (int)CombinedFFUHeaderSize);
|
||||
FfuFile.Close();
|
||||
|
||||
@@ -166,7 +168,7 @@ namespace WPinternals
|
||||
ExitSuccess("Bootloader restored successfully!");
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaRelockUEFI(Notifier, FFUPath, DoResetFirst, SetWorkingStatus, UpdateWorkingStatus, tmpExitSuccess, tmpExitFailure);
|
||||
await LumiaRelockUEFI(Notifier, FFUPath, DoResetFirst, SetWorkingStatus, UpdateWorkingStatus, tmpExitSuccess, tmpExitFailure);
|
||||
}
|
||||
|
||||
internal static async Task LumiaV2UnlockUEFI(PhoneNotifierViewModel Notifier, string ProfileFFUPath, string EDEPath, string SupportedFFUPath, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null, ExitSuccess ExitSuccess = null, ExitFailure ExitFailure = null, bool ReUnlockDevice = false)
|
||||
@@ -232,7 +234,7 @@ namespace WPinternals
|
||||
ExitSuccess("Bootloader unlocked successfully!", null);
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaUnlockUEFI(Notifier, ProfileFFUPath, EDEPath, SupportedFFUPath, SetWorkingStatus, UpdateWorkingStatus, tmpExitSuccess, tmpExitFailure, ReUnlockDevice: ReUnlockDevice);
|
||||
await LumiaUnlockUEFI(Notifier, ProfileFFUPath, EDEPath, SupportedFFUPath, SetWorkingStatus, UpdateWorkingStatus, tmpExitSuccess, tmpExitFailure, ReUnlockDevice: ReUnlockDevice);
|
||||
}
|
||||
|
||||
// Magic!
|
||||
@@ -270,7 +272,7 @@ namespace WPinternals
|
||||
{
|
||||
if (Notifier.CurrentModel is NokiaFlashModel)
|
||||
{
|
||||
await LumiaUnlockBootloaderViewModel.LumiaRelockUEFI(Notifier, FFUPath, true, SetWorkingStatus, UpdateWorkingStatus, null, (string Message, string SubMessage) =>
|
||||
await LumiaRelockUEFI(Notifier, FFUPath, true, SetWorkingStatus, UpdateWorkingStatus, null, (string Message, string SubMessage) =>
|
||||
{
|
||||
ExitFailure(Message, SubMessage);
|
||||
LogFile.EndAction("RelockBootloader");
|
||||
@@ -296,15 +298,11 @@ namespace WPinternals
|
||||
throw new ArgumentNullException("FFU path is missing");
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download && string.IsNullOrEmpty(LoadersPath))
|
||||
{
|
||||
if (string.IsNullOrEmpty(LoadersPath))
|
||||
{
|
||||
throw new Exception("Error: Path for Loaders is mandatory.");
|
||||
}
|
||||
throw new Exception("Error: Path for Loaders is mandatory.");
|
||||
}
|
||||
|
||||
const bool DumpPartitions = false;
|
||||
string DumpFilePrefix = Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\") + DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss") + " - ";
|
||||
bool IsBootLoaderUnlocked = false;
|
||||
|
||||
@@ -333,11 +331,10 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
UefiSecurityStatusResponse SecurityStatus = ((NokiaFlashModel)Notifier.CurrentModel).ReadSecurityStatus();
|
||||
IsBootLoaderUnlocked = (SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus);
|
||||
IsBootLoaderUnlocked = SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus;
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "01.bin", FFU.GetSectors(0, 34)); // Original GPT
|
||||
@@ -347,7 +344,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GPT NewGPT = null;
|
||||
if (Notifier.CurrentModel is NokiaFlashModel)
|
||||
@@ -405,8 +402,7 @@ namespace WPinternals
|
||||
GPT = NewGPT.Rebuild();
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "02.bin", GPT); // Patched GPT
|
||||
@@ -416,7 +412,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SBL1 SBL1 = null;
|
||||
try
|
||||
@@ -429,8 +425,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing SBL1 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "03.bin", SBL1.Binary); // Original SBL1
|
||||
@@ -440,7 +435,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] RootKeyHash = null;
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
|
||||
@@ -489,8 +484,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing SBL2 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "05.bin", SBL2Partition.Binary); // Original SBL2
|
||||
@@ -500,7 +494,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] SBL2 = SBL2Partition.Binary;
|
||||
|
||||
@@ -516,8 +510,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing SBL3 from FFU failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "07.bin", SBL3Partition.Binary); // Original SBL3
|
||||
@@ -527,7 +520,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] SBL3 = SBL3Partition.Binary;
|
||||
|
||||
@@ -542,8 +535,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing UEFI failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "09.bin", UEFIPartition.Binary); // Original UEFI
|
||||
@@ -553,7 +545,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] UEFI = UEFIPartition.Binary;
|
||||
|
||||
@@ -834,7 +826,6 @@ namespace WPinternals
|
||||
throw new ArgumentNullException("FFU path is missing");
|
||||
}
|
||||
|
||||
const bool DumpPartitions = false;
|
||||
string DumpFilePrefix = Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\") + DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss") + " - ";
|
||||
bool IsBootLoaderUnlocked = false;
|
||||
|
||||
@@ -863,15 +854,12 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
UefiSecurityStatusResponse SecurityStatus = ((NokiaFlashModel)Notifier.CurrentModel).ReadSecurityStatus();
|
||||
IsBootLoaderUnlocked = (SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus);
|
||||
IsBootLoaderUnlocked = SecurityStatus.AuthenticationStatus || SecurityStatus.RdcStatus || !SecurityStatus.SecureFfuEfuseStatus;
|
||||
}
|
||||
|
||||
if (!IsBootLoaderUnlocked)
|
||||
if (!IsBootLoaderUnlocked && string.IsNullOrEmpty(LoadersPath))
|
||||
{
|
||||
if (string.IsNullOrEmpty(LoadersPath))
|
||||
{
|
||||
throw new Exception("Error: Path for Loaders is mandatory.");
|
||||
}
|
||||
throw new Exception("Error: Path for Loaders is mandatory.");
|
||||
}
|
||||
|
||||
FFU SupportedFFU = null;
|
||||
@@ -900,8 +888,7 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "01.bin", FFU.GetSectors(0, 34)); // Original GPT
|
||||
@@ -911,7 +898,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GPT NewGPT = null;
|
||||
if (Notifier.CurrentModel is NokiaFlashModel)
|
||||
@@ -980,8 +967,7 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "02.bin", GPT); // Patched GPT
|
||||
@@ -991,7 +977,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SBL1 SBL1 = null;
|
||||
try
|
||||
@@ -1004,8 +990,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing SBL1 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "03.bin", SBL1.Binary); // Original SBL1
|
||||
@@ -1015,7 +1000,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] RootKeyHash = null;
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
|
||||
@@ -1064,8 +1049,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing SBL2 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "05.bin", SBL2Partition.Binary); // Original SBL2
|
||||
@@ -1075,7 +1059,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] SBL2;
|
||||
try
|
||||
@@ -1088,8 +1072,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Patching SBL2 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "06.bin", SBL2Partition.Binary); // Patched SBL2
|
||||
@@ -1099,7 +1082,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] ExtraSector = null;
|
||||
try
|
||||
@@ -1114,8 +1097,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Code generation failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "04.bin", ExtraSector); // Extra sector
|
||||
@@ -1125,7 +1107,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SBL3 SBL3Partition;
|
||||
SBL3 OriginalSBL3;
|
||||
@@ -1165,8 +1147,7 @@ namespace WPinternals
|
||||
LogFile.Log("Taking selected SBL3");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "07.bin", SBL3Partition.Binary); // Original SBL3
|
||||
@@ -1176,7 +1157,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] SBL3;
|
||||
try
|
||||
@@ -1189,8 +1170,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Patching SBL3 failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "08.bin", SBL3Partition.Binary); // Patched SBL3
|
||||
@@ -1200,7 +1180,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UEFI UEFIPartition = null;
|
||||
try
|
||||
@@ -1213,8 +1193,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Parsing UEFI failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "09.bin", UEFIPartition.Binary); // Original UEFI
|
||||
@@ -1224,7 +1203,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] UEFI;
|
||||
try
|
||||
@@ -1237,8 +1216,7 @@ namespace WPinternals
|
||||
throw new Exception("Error: Patching UEFI failed.");
|
||||
}
|
||||
|
||||
if (DumpPartitions)
|
||||
{
|
||||
#if DUMPPARTITIONS
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(DumpFilePrefix + "0A.bin", UEFIPartition.Binary); // Patched UEFI
|
||||
@@ -1248,7 +1226,7 @@ namespace WPinternals
|
||||
LogFile.LogException(Ex);
|
||||
throw new Exception("Error: Writing binary for logging failed.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
List<QualcommPartition> PossibleLoaders = null;
|
||||
if (!IsBootLoaderUnlocked || Notifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
|
||||
@@ -1431,7 +1409,7 @@ namespace WPinternals
|
||||
throw new WPinternalsException("Phone is in an unexpected mode.", "The phone should have been detected in flash, download or emergency flash mode. Instead it has been detected in " + Notifier.CurrentInterface.ToString() + " mode.");
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaUnlockUEFI(Notifier, FFUPath, LoadersPath, SupportedFFUPath, SetWorkingStatus, UpdateWorkingStatus, null, (string Message, string SubMessage) =>
|
||||
await LumiaUnlockUEFI(Notifier, FFUPath, LoadersPath, SupportedFFUPath, SetWorkingStatus, UpdateWorkingStatus, null, (string Message, string SubMessage) =>
|
||||
{
|
||||
ExitFailure(Message, SubMessage);
|
||||
LogFile.EndAction("UnlockBootloader");
|
||||
@@ -1494,7 +1472,7 @@ namespace WPinternals
|
||||
|
||||
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);
|
||||
FlashAppType OriginalAppType = Info.App;
|
||||
bool Switch = ((Info.App != FlashAppType.BootManager) && Info.IsBootloaderSecure);
|
||||
bool Switch = (Info.App != FlashAppType.BootManager) && Info.IsBootloaderSecure;
|
||||
if (Switch)
|
||||
{
|
||||
FlashModel.SwitchToBootManagerContext();
|
||||
@@ -1684,13 +1662,13 @@ namespace WPinternals
|
||||
// The second check should be more than enough in any case, if we find a header named MSDOS5.0 right in the middle of EFIESP,
|
||||
// there's not many cases other than us splitting the partition in half to get this here.
|
||||
//
|
||||
if ((ByteOperations.ReadAsciiString(EFIESP, (UInt32)(EFIESP.Length / 2) + 3, 8)) == "MSDOS5.0")
|
||||
if (ByteOperations.ReadAsciiString(EFIESP, (UInt32)(EFIESP.Length / 2) + 3, 8) == "MSDOS5.0")
|
||||
{
|
||||
EFIESPBackup = new byte[EfiespSizeInSectors * 0x200 / 2];
|
||||
Buffer.BlockCopy(EFIESP, (Int32)EfiespSizeInSectors * 0x200 / 2, EFIESPBackup, 0, (Int32)EfiespSizeInSectors * 0x200 / 2);
|
||||
}
|
||||
|
||||
if (ByteOperations.ReadUInt16(EFIESP, 0xE) == LumiaUnlockBootloaderViewModel.LumiaGetFirstEFIESPSectorCount(GPT, new FFU(FFUPath), IsSpecB))
|
||||
if (ByteOperations.ReadUInt16(EFIESP, 0xE) == LumiaGetFirstEFIESPSectorCount(GPT, new FFU(FFUPath), IsSpecB))
|
||||
{
|
||||
UndoEFIESPPadding = true;
|
||||
}
|
||||
@@ -1744,7 +1722,7 @@ namespace WPinternals
|
||||
|
||||
if (UndoEFIESPPadding)
|
||||
{
|
||||
FlashParts = LumiaUnlockBootloaderViewModel.LumiaGenerateUndoEFIESPFlashPayload(GPT, new FFU(FFUPath), IsSpecB);
|
||||
FlashParts = LumiaGenerateUndoEFIESPFlashPayload(GPT, new FFU(FFUPath), IsSpecB);
|
||||
}
|
||||
|
||||
FlashPart Part;
|
||||
@@ -1821,7 +1799,7 @@ namespace WPinternals
|
||||
|
||||
WPinternalsStatus LastStatus = WPinternalsStatus.Undefined;
|
||||
ulong? MaxProgressValue = null;
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, FFUPath, false, false, FlashParts, DoResetFirst, ClearFlashingStatusAtEnd: !NvCleared,
|
||||
await LumiaFlashParts(Notifier, FFUPath, false, false, FlashParts, DoResetFirst, ClearFlashingStatusAtEnd: !NvCleared,
|
||||
SetWorkingStatus: (m, s, v, a, st) =>
|
||||
{
|
||||
if (SetWorkingStatus != null)
|
||||
@@ -1881,7 +1859,7 @@ namespace WPinternals
|
||||
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, FFUPath, false, false, null, DoResetFirst, ClearFlashingStatusAtEnd: true, ShowProgress: false);
|
||||
await LumiaFlashParts(Notifier, FFUPath, false, false, null, DoResetFirst, ClearFlashingStatusAtEnd: true, ShowProgress: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1939,12 +1917,9 @@ namespace WPinternals
|
||||
|
||||
FFU ProfileFFU = new(ProfileFFUPath);
|
||||
|
||||
if (Info.IsBootloaderSecure)
|
||||
if (Info.IsBootloaderSecure && !Info.PlatformID.StartsWith(ProfileFFU.PlatformID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!Info.PlatformID.StartsWith(ProfileFFU.PlatformID, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Profile FFU has wrong Platform ID for connected phone");
|
||||
}
|
||||
throw new ArgumentNullException("Profile FFU has wrong Platform ID for connected phone");
|
||||
}
|
||||
|
||||
string Patch = "SecureBootHack-V1.1-EFIESP";
|
||||
@@ -1977,7 +1952,7 @@ namespace WPinternals
|
||||
SetWorkingStatus("Assembling data for unlock", null, null);
|
||||
byte[] UnlockedEFIESP = ProfileFFU.GetPartition("EFIESP");
|
||||
|
||||
LumiaUnlockBootloaderViewModel.LumiaPatchEFIESP(SupportedFFU, UnlockedEFIESP, IsSpecB);
|
||||
LumiaPatchEFIESP(SupportedFFU, UnlockedEFIESP, IsSpecB);
|
||||
|
||||
byte[] GPTChunk = GetGptChunk(FlashModel, (UInt32)ProfileFFU.ChunkSize);
|
||||
byte[] GPTChunkBackup = new byte[GPTChunk.Length];
|
||||
@@ -2050,7 +2025,7 @@ namespace WPinternals
|
||||
_part.ProgressText = "Enabling Test Signing...";
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, false, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, false, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
if ((Notifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) && (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash))
|
||||
{
|
||||
@@ -2080,7 +2055,7 @@ namespace WPinternals
|
||||
ShouldApplyOldEFIESPMethod = false;
|
||||
}
|
||||
|
||||
Parts = ShouldApplyOldEFIESPMethod ? new List<FlashPart>() : LumiaUnlockBootloaderViewModel.LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
|
||||
Parts = ShouldApplyOldEFIESPMethod ? new List<FlashPart>() : LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
|
||||
Part = null;
|
||||
|
||||
UInt32 OriginalEfiespSizeInSectors = (UInt32)GPT.GetPartition("EFIESP").SizeInSectors;
|
||||
@@ -2216,7 +2191,7 @@ namespace WPinternals
|
||||
_part.ProgressText = IsSpecB ? "Flashing unlocked bootloader (part 1)..." : "Flashing unlocked bootloader (part 2)...";
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
if ((Notifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) && (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash))
|
||||
{
|
||||
@@ -2284,7 +2259,7 @@ namespace WPinternals
|
||||
};
|
||||
Parts.Add(Part);
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, false, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, false, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
// An old NV backup was restored and it possibly contained the IsFlashing flag.
|
||||
// Can't clear it immeadiately, so we need another flash.
|
||||
@@ -2295,7 +2270,7 @@ namespace WPinternals
|
||||
|
||||
if ((Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader) || (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash))
|
||||
{
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, null, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, null, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
}
|
||||
|
||||
if (IsPhoneInBadMassStorageMode)
|
||||
@@ -2327,7 +2302,7 @@ namespace WPinternals
|
||||
|
||||
try
|
||||
{
|
||||
LumiaUnlockBootloaderViewModel.LumiaPatchEFIESP(SupportedFFU, BackupUnlockedEFIESP, IsSpecB);
|
||||
LumiaPatchEFIESP(SupportedFFU, BackupUnlockedEFIESP, IsSpecB);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -2341,7 +2316,7 @@ namespace WPinternals
|
||||
BackupUnlockedEFIESP = new byte[UnlockedEFIESP.Length];
|
||||
Buffer.BlockCopy(BackupEFIESP, 0, BackupUnlockedEFIESP, 0, UnlockedEFIESP.Length);
|
||||
|
||||
LumiaUnlockBootloaderViewModel.LumiaPatchEFIESP(SupportedFFU, BackupUnlockedEFIESP, IsSpecB);
|
||||
LumiaPatchEFIESP(SupportedFFU, BackupUnlockedEFIESP, IsSpecB);
|
||||
}
|
||||
|
||||
SetWorkingStatus("Boot optimization...", null, null);
|
||||
@@ -2476,12 +2451,12 @@ namespace WPinternals
|
||||
_part.ProgressText = "Flashing unlocked bootloader (part 2)...";
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ulong FirstSector = GPT.GetPartition("EFIESP").FirstSector;
|
||||
ulong SectorCount = LumiaUnlockBootloaderViewModel.LumiaGetFirstEFIESPSectorCount(GPT, ProfileFFU, IsSpecB);
|
||||
ulong SectorCount = LumiaGetFirstEFIESPSectorCount(GPT, ProfileFFU, IsSpecB);
|
||||
byte[] BackupEFIESPAllocation = MassStorage.ReadSectors(FirstSector, SectorCount);
|
||||
|
||||
// The backed up buffer includes our changed header done previously to have two EFIESPs in a single partition
|
||||
@@ -2493,7 +2468,7 @@ namespace WPinternals
|
||||
LogFile.Log("Unlocking backup partition", LogType.FileAndConsole);
|
||||
SetWorkingStatus("Unlocking backup partition", null, null);
|
||||
|
||||
LumiaUnlockBootloaderViewModel.LumiaPatchEFIESP(SupportedFFU, UnlockedEFIESP, IsSpecB);
|
||||
LumiaPatchEFIESP(SupportedFFU, UnlockedEFIESP, IsSpecB);
|
||||
|
||||
SetWorkingStatus("Boot optimization...", null, null);
|
||||
|
||||
@@ -2528,14 +2503,14 @@ namespace WPinternals
|
||||
}
|
||||
((NokiaFlashModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
|
||||
Parts = LumiaUnlockBootloaderViewModel.LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
|
||||
Parts = LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
|
||||
|
||||
foreach (FlashPart _part in Parts)
|
||||
{
|
||||
_part.ProgressText = IsSpecB ? "Flashing unlocked bootloader (part 2)..." : "Flashing unlocked bootloader (part 3)...";
|
||||
}
|
||||
|
||||
await LumiaUnlockBootloaderViewModel.LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
await LumiaFlashParts(Notifier, ProfileFFU.Path, false, false, Parts, true, true, true, true, false, SetWorkingStatus, UpdateWorkingStatus, null, null, EDEPath);
|
||||
|
||||
if (!IsSpecB)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _UnlockImageCommand ??= new DelegateCommand(() => UnlockImageCallback(EFIESPMountPoint, MainOSMountPoint), () => ((EFIESPMountPoint != null) || (MainOSMountPoint != null)));
|
||||
return _UnlockImageCommand ??= new DelegateCommand(() => UnlockImageCallback(EFIESPMountPoint, MainOSMountPoint), () => (EFIESPMountPoint != null) || (MainOSMountPoint != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace WPinternals
|
||||
{
|
||||
IsPhoneDisconnected = PhoneNotifier.CurrentInterface == null;
|
||||
IsPhoneInMassStorage = PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_MassStorage;
|
||||
IsPhoneInOtherMode = (!IsPhoneDisconnected && !IsPhoneInMassStorage);
|
||||
IsPhoneInOtherMode = !IsPhoneDisconnected && !IsPhoneInMassStorage;
|
||||
UnlockPhoneCommand.RaiseCanExecuteChanged();
|
||||
UnlockImageCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
@@ -266,10 +266,10 @@ namespace WPinternals
|
||||
Partition Partition = GPT.GetPartition("UEFI");
|
||||
byte[] UefiBuffer = Phone.ReadSectors(Partition.FirstSector, Partition.LastSector - Partition.FirstSector + 1);
|
||||
UEFI UEFI = new(UefiBuffer);
|
||||
string BootMgrName = UEFI.EFIs.First(efi => ((efi.Name != null) && ((efi.Name.Contains("BootMgrApp")) || (efi.Name.Contains("FlashApp"))))).Name;
|
||||
string BootMgrName = UEFI.EFIs.First(efi => (efi.Name != null) && (efi.Name.Contains("BootMgrApp") || efi.Name.Contains("FlashApp"))).Name;
|
||||
byte[] BootMgr = UEFI.GetFile(BootMgrName);
|
||||
// "Header V2"
|
||||
Result = (ByteOperations.FindAscii(BootMgr, "Header V2") != null);
|
||||
Result = ByteOperations.FindAscii(BootMgr, "Header V2") != null;
|
||||
Phone.CloseVolume();
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace WPinternals
|
||||
{
|
||||
LogFile.Log("Find Flashing Profile", LogType.FileAndConsole);
|
||||
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
PhoneInfo Info;
|
||||
if (DoResetFirst)
|
||||
@@ -125,7 +125,7 @@ namespace WPinternals
|
||||
LogFile.Log("Command: Enable testsigning", LogType.FileAndConsole);
|
||||
PhoneNotifierViewModel Notifier = new();
|
||||
UIContext.Send(s => Notifier.Start(), null);
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
List<FlashPart> Parts = new();
|
||||
FlashPart Part;
|
||||
@@ -197,7 +197,7 @@ namespace WPinternals
|
||||
});
|
||||
Parts.Add(Part);
|
||||
|
||||
await LumiaV2UnlockBootViewModel.LumiaV2CustomFlash(Notifier, FFUPath, false, false, Parts, DoResetFirst, ClearFlashingStatusAtEnd: false);
|
||||
await LumiaV2CustomFlash(Notifier, FFUPath, false, false, Parts, DoResetFirst, ClearFlashingStatusAtEnd: false);
|
||||
|
||||
Notifier.Stop();
|
||||
}
|
||||
@@ -228,7 +228,7 @@ namespace WPinternals
|
||||
return ((MassStorage)Notifier.CurrentModel).Drive;
|
||||
}
|
||||
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
if (DoResetFirst)
|
||||
{
|
||||
// The phone will be reset before flashing, so we have the opportunity to get some more info from the phone
|
||||
@@ -262,7 +262,7 @@ namespace WPinternals
|
||||
LogFile.Log("Command: Clear NV", LogType.FileAndConsole);
|
||||
PhoneNotifierViewModel Notifier = new();
|
||||
UIContext.Send(s => Notifier.Start(), null);
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
List<FlashPart> Parts = new();
|
||||
|
||||
// Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector.
|
||||
@@ -338,7 +338,7 @@ namespace WPinternals
|
||||
PhoneNotifierViewModel Notifier = new();
|
||||
UIContext.Send(s => Notifier.Start(), null);
|
||||
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
PhoneInfo Info = FlashModel.ReadPhoneInfo();
|
||||
|
||||
@@ -359,10 +359,10 @@ namespace WPinternals
|
||||
bool GPTChanged = false;
|
||||
List<FlashPart> Parts = new();
|
||||
FlashPart Part;
|
||||
if (string.Compare(PartitionName, "EFIESP", true) == 0)
|
||||
if (string.Equals(PartitionName, "EFIESP", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
byte[] EfiespBinary = File.ReadAllBytes(PartitionPath);
|
||||
IsUnlocked = ((ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && (ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8)) == "MSDOS5.0");
|
||||
IsUnlocked = (ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8) == "MSDOS5.0";
|
||||
|
||||
if (IsUnlocked)
|
||||
{
|
||||
@@ -417,7 +417,7 @@ namespace WPinternals
|
||||
Stream = Stream
|
||||
};
|
||||
Parts.Add(Part);
|
||||
await LumiaV2CustomFlash(Notifier, FFUPath, false, false, Parts, DoResetFirst, string.Compare(PartitionName, "UEFI_BS_NV", true) != 0);
|
||||
await LumiaV2CustomFlash(Notifier, FFUPath, false, false, Parts, DoResetFirst, !string.Equals(PartitionName, "UEFI_BS_NV", StringComparison.CurrentCultureIgnoreCase));
|
||||
}
|
||||
Notifier.Stop();
|
||||
}
|
||||
@@ -447,11 +447,11 @@ namespace WPinternals
|
||||
PhoneNotifierViewModel Notifier = new();
|
||||
UIContext.Send(s => Notifier.Start(), null);
|
||||
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)(await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash));
|
||||
NokiaFlashModel FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
PhoneInfo Info = FlashModel.ReadPhoneInfo();
|
||||
|
||||
byte[] Data = System.IO.File.ReadAllBytes(DataPath);
|
||||
byte[] Data = File.ReadAllBytes(DataPath);
|
||||
|
||||
await LumiaV2CustomFlash(Notifier, FFUPath, false, false, (UInt32)StartSector, Data, DoResetFirst);
|
||||
Notifier.Stop();
|
||||
@@ -573,7 +573,7 @@ namespace WPinternals
|
||||
if (FFUPath == null)
|
||||
{
|
||||
// Try to find an FFU from the repository for which there is also a known flashing profile
|
||||
FFUs = App.Config.FFURepository.Where(e => (Info.PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists())).ToList();
|
||||
FFUs = App.Config.FFURepository.Where(e => Info.PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists()).ToList();
|
||||
foreach (FFUEntry CurrentEntry in FFUs)
|
||||
{
|
||||
Profile = App.Config.GetProfile(Info.PlatformID, Info.Firmware, CurrentEntry.FirmwareVersion);
|
||||
@@ -620,17 +620,14 @@ namespace WPinternals
|
||||
throw new ArgumentException("Streams must be seekable");
|
||||
}
|
||||
|
||||
if (((Part.StartSector * 0x200) % FFU.ChunkSize) != 0)
|
||||
if ((Part.StartSector * 0x200 % FFU.ChunkSize) != 0)
|
||||
{
|
||||
throw new ArgumentException("Invalid StartSector alignment");
|
||||
}
|
||||
|
||||
if (CheckSectorAlignment)
|
||||
if (CheckSectorAlignment && (Part.Stream.Length % FFU.ChunkSize) != 0)
|
||||
{
|
||||
if ((Part.Stream.Length % FFU.ChunkSize) != 0)
|
||||
{
|
||||
throw new ArgumentException("Invalid Data length");
|
||||
}
|
||||
throw new ArgumentException("Invalid Data length");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -646,7 +643,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
UEFI UEFI = new(FFU.GetPartition("UEFI"));
|
||||
string BootMgrName = UEFI.EFIs.First(efi => (efi.Name?.Contains("BootMgrApp") == true)).Name;
|
||||
string BootMgrName = UEFI.EFIs.First(efi => efi.Name?.Contains("BootMgrApp") == true).Name;
|
||||
UInt32 EstimatedSizeOfMemGap = (UInt32)UEFI.GetFile(BootMgrName).Length;
|
||||
byte Options = 0;
|
||||
if (SkipWrite)
|
||||
@@ -995,7 +992,7 @@ namespace WPinternals
|
||||
Model.SendFfuHeaderV2(CurrentGapFill, 0, PartialHeader, Options); // Fill memory gap -> This will fail on phones with Flash Protocol v1.x !! On Lumia 640 this will hang on receiving the response when EndAsyncFlash was not called.
|
||||
}
|
||||
|
||||
using (FileStream FfuFile = new(FFU.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read))
|
||||
using (FileStream FfuFile = new(FFU.Path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
// On every flashing phase we need to send the full header again to reset all the counters.
|
||||
FfuFile.Read(FfuHeader, 0, (int)CombinedFFUHeaderSize);
|
||||
@@ -1059,7 +1056,7 @@ namespace WPinternals
|
||||
else
|
||||
{
|
||||
// From start of hash-table skip the first hashes for Image- and StoreHeaders.
|
||||
HashTableSize = (UInt32)(((FFU.ImageHeader.Length + FFU.StoreHeader.Length) / FFU.ChunkSize) * 0x20);
|
||||
HashTableSize = (UInt32)((FFU.ImageHeader.Length + FFU.StoreHeader.Length) / FFU.ChunkSize * 0x20);
|
||||
NewHashOffset += HashTableSize;
|
||||
}
|
||||
|
||||
@@ -1615,7 +1612,7 @@ namespace WPinternals
|
||||
PartialHeader = new byte[UefiMemorySim.PageSize];
|
||||
Model.SendFfuHeaderV2(CurrentGapFill, 0, PartialHeader, Options); // Fill memory gap
|
||||
}
|
||||
using (FileStream FfuFile = new(FFU.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read))
|
||||
using (FileStream FfuFile = new(FFU.Path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
// On every flashing phase we need to send the full header again, because this triggers ffu_import_invalidate(), which is necessary to reset all the counters.
|
||||
FfuFile.Read(FfuHeader, 0, (int)CombinedFFUHeaderSize);
|
||||
@@ -1920,7 +1917,7 @@ namespace WPinternals
|
||||
|
||||
internal static string GetProgrammerPath(byte[] RKH, string Type)
|
||||
{
|
||||
IEnumerable<EmergencyFileEntry> RKHEntries = App.Config.EmergencyRepository.Where(e => (StructuralComparisons.StructuralEqualityComparer.Equals(e.RKH, RKH) && e.ProgrammerExists()));
|
||||
IEnumerable<EmergencyFileEntry> RKHEntries = App.Config.EmergencyRepository.Where(e => StructuralComparisons.StructuralEqualityComparer.Equals(e.RKH, RKH) && e.ProgrammerExists());
|
||||
if (RKHEntries.Any())
|
||||
{
|
||||
if (RKHEntries.Count() == 1)
|
||||
@@ -1929,7 +1926,7 @@ namespace WPinternals
|
||||
}
|
||||
else
|
||||
{
|
||||
EmergencyFileEntry RKHEntry = RKHEntries.FirstOrDefault(e => string.Compare(e.Type, Type, false) == 0);
|
||||
EmergencyFileEntry RKHEntry = RKHEntries.FirstOrDefault(e => string.Equals(e.Type, Type, StringComparison.CurrentCulture));
|
||||
if (RKHEntry != null)
|
||||
{
|
||||
return RKHEntry.ProgrammerPath;
|
||||
@@ -1942,7 +1939,7 @@ namespace WPinternals
|
||||
}
|
||||
else
|
||||
{
|
||||
EmergencyFileEntry TypeEntry = App.Config.EmergencyRepository.Find(e => ((string.Compare(e.Type, Type, false) == 0) && e.ProgrammerExists()));
|
||||
EmergencyFileEntry TypeEntry = App.Config.EmergencyRepository.Find(e => string.Equals(e.Type, Type, StringComparison.CurrentCulture) && e.ProgrammerExists());
|
||||
if (TypeEntry != null)
|
||||
{
|
||||
return TypeEntry.ProgrammerPath;
|
||||
@@ -2036,7 +2033,7 @@ namespace WPinternals
|
||||
PartitionName = PartitionName.Substring(0, Pos);
|
||||
}
|
||||
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Compare(p.Name, PartitionName, true) == 0);
|
||||
Partition Partition = GPT.Partitions.Find(p => string.Equals(p.Name, PartitionName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (Partition != null)
|
||||
{
|
||||
using DecompressedStream DecompressedStream = new(Entry.Open());
|
||||
@@ -2050,13 +2047,13 @@ namespace WPinternals
|
||||
TotalSizeSectors += StreamLengthInSectors;
|
||||
PartitionCount++;
|
||||
|
||||
if (string.Compare(PartitionName, "MainOS", true) == 0)
|
||||
if (string.Equals(PartitionName, "MainOS", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
MainOSOldSectorCount = Partition.SizeInSectors;
|
||||
MainOSNewSectorCount = StreamLengthInSectors;
|
||||
FirstMainOSSector = Partition.FirstSector;
|
||||
}
|
||||
else if (string.Compare(PartitionName, "Data", true) == 0)
|
||||
else if (string.Equals(PartitionName, "Data", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
DataOldSectorCount = Partition.SizeInSectors;
|
||||
DataNewSectorCount = StreamLengthInSectors;
|
||||
@@ -2067,12 +2064,12 @@ namespace WPinternals
|
||||
ExitFailure("Flash failed!", "Size of partition '" + PartitionName + "' is too big.");
|
||||
return;
|
||||
}
|
||||
else if (string.Compare(PartitionName, "EFIESP", true) == 0)
|
||||
else if (string.Equals(PartitionName, "EFIESP", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
ulong EfiespLength = StreamLengthInSectors * 0x200;
|
||||
byte[] EfiespBinary = new byte[EfiespLength];
|
||||
DecompressedStream.Read(EfiespBinary, 0, (int)EfiespLength);
|
||||
IsUnlocked = ((ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && (ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8)) == "MSDOS5.0");
|
||||
IsUnlocked = (ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8) == "MSDOS5.0";
|
||||
if (IsUnlocked)
|
||||
{
|
||||
Partition IsUnlockedFlag = GPT.GetPartition("IS_UNLOCKED");
|
||||
@@ -2115,8 +2112,8 @@ namespace WPinternals
|
||||
if ((MainOSNewSectorCount + DataNewSectorCount) <= OSSpace)
|
||||
{
|
||||
// MainOS and Data partitions need to be re-aligned!
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
MainOSPartition.LastSector = MainOSPartition.FirstSector + MainOSNewSectorCount - 1;
|
||||
DataPartition.FirstSector = MainOSPartition.LastSector + 1;
|
||||
if ((DataPartition.FirstSector % 0x100) > 0)
|
||||
@@ -2252,7 +2249,7 @@ namespace WPinternals
|
||||
PartitionName = PartitionName.Substring(0, Pos);
|
||||
}
|
||||
|
||||
Target = GPT.Partitions.Find(p => string.Compare(p.Name, PartitionName, true) == 0);
|
||||
Target = GPT.Partitions.Find(p => string.Equals(p.Name, PartitionName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (Target != null)
|
||||
{
|
||||
Part = new FlashPart
|
||||
@@ -2269,7 +2266,7 @@ namespace WPinternals
|
||||
|
||||
Parts = Parts.OrderBy(p => p.StartSector).ToList();
|
||||
int Count = 1;
|
||||
Parts.Where(p => (p.ProgressText?.StartsWith("Flashing partition ") == true)).ToList().ForEach((p) =>
|
||||
Parts.Where(p => p.ProgressText?.StartsWith("Flashing partition ") == true).ToList().ForEach((p) =>
|
||||
{
|
||||
p.ProgressText += " (" + Count.ToString() + "/" + PartitionCount.ToString() + ")";
|
||||
Count++;
|
||||
@@ -2411,7 +2408,7 @@ namespace WPinternals
|
||||
PartitionCount++;
|
||||
|
||||
byte[] EfiespBinary = File.ReadAllBytes(EFIESPPath);
|
||||
IsUnlocked = ((ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && (ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8)) == "MSDOS5.0");
|
||||
IsUnlocked = (ByteOperations.ReadUInt32(EfiespBinary, 0x20) == (EfiespBinary.Length / 0x200 / 2)) && ByteOperations.ReadAsciiString(EfiespBinary, (UInt32)(EfiespBinary.Length / 2) + 3, 8) == "MSDOS5.0";
|
||||
if (IsUnlocked)
|
||||
{
|
||||
Partition IsUnlockedFlag = GPT.GetPartition("IS_UNLOCKED");
|
||||
@@ -2474,8 +2471,8 @@ namespace WPinternals
|
||||
if ((MainOSNewSectorCount + DataNewSectorCount) <= OSSpace)
|
||||
{
|
||||
// MainOS and Data partitions need to be re-aligned!
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Partition MainOSPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
Partition DataPartition = GPT.Partitions.Single(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
MainOSPartition.LastSector = MainOSPartition.FirstSector + MainOSNewSectorCount - 1;
|
||||
DataPartition.FirstSector = MainOSPartition.LastSector + 1;
|
||||
if ((DataPartition.FirstSector % 0x100) > 0)
|
||||
@@ -2598,7 +2595,7 @@ namespace WPinternals
|
||||
|
||||
int Count = 0;
|
||||
|
||||
Target = GPT.Partitions.Find(p => string.Compare(p.Name, "EFIESP", true) == 0);
|
||||
Target = GPT.Partitions.Find(p => string.Equals(p.Name, "EFIESP", StringComparison.CurrentCultureIgnoreCase));
|
||||
if ((EFIESPPath != null) && (Target != null))
|
||||
{
|
||||
Count++;
|
||||
@@ -2612,7 +2609,7 @@ namespace WPinternals
|
||||
LogFile.Log("Partition name=EFIESP, startsector=0x" + Target.FirstSector.ToString("X8") + ", sectorcount = 0x" + (Part.Stream.Length / 0x200).ToString("X8"), LogType.FileOnly);
|
||||
}
|
||||
|
||||
Target = GPT.Partitions.Find(p => string.Compare(p.Name, "MainOS", true) == 0);
|
||||
Target = GPT.Partitions.Find(p => string.Equals(p.Name, "MainOS", StringComparison.CurrentCultureIgnoreCase));
|
||||
if ((MainOSPath != null) && (Target != null))
|
||||
{
|
||||
Count++;
|
||||
@@ -2626,7 +2623,7 @@ namespace WPinternals
|
||||
LogFile.Log("Partition name=MainOS, startsector=0x" + Target.FirstSector.ToString("X8") + ", sectorcount = 0x" + (Part.Stream.Length / 0x200).ToString("X8"), LogType.FileOnly);
|
||||
}
|
||||
|
||||
Target = GPT.Partitions.Find(p => string.Compare(p.Name, "Data", true) == 0);
|
||||
Target = GPT.Partitions.Find(p => string.Equals(p.Name, "Data", StringComparison.CurrentCultureIgnoreCase));
|
||||
if ((DataPath != null) && (Target != null))
|
||||
{
|
||||
Count++;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace WPinternals
|
||||
public UInt32 HashTableSize;
|
||||
}
|
||||
|
||||
internal class ManifestIni
|
||||
internal static class ManifestIni
|
||||
{
|
||||
internal static string BuildUpManifest(FullFlash fullFlash, Store store)
|
||||
{
|
||||
@@ -178,17 +178,14 @@ namespace WPinternals
|
||||
throw new ArgumentException("Streams must be seekable");
|
||||
}
|
||||
|
||||
if (((Part.StartSector * 0x200) % chunkSize) != 0)
|
||||
if ((Part.StartSector * 0x200 % chunkSize) != 0)
|
||||
{
|
||||
throw new ArgumentException("Invalid StartSector alignment");
|
||||
}
|
||||
|
||||
if (CheckSectorAlignment)
|
||||
if (CheckSectorAlignment && (Part.Stream.Length % chunkSize) != 0)
|
||||
{
|
||||
if ((Part.Stream.Length % chunkSize) != 0)
|
||||
{
|
||||
throw new ArgumentException("Invalid Data length");
|
||||
}
|
||||
throw new ArgumentException("Invalid Data length");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +244,7 @@ namespace WPinternals
|
||||
//Logging.Log("Generating image manifest...");
|
||||
string manifest = ManifestIni.BuildUpManifest(ffimage, simage);//, partitions);
|
||||
|
||||
byte[] TextBytes = System.Text.Encoding.ASCII.GetBytes(manifest);
|
||||
byte[] TextBytes = Encoding.ASCII.GetBytes(manifest);
|
||||
|
||||
image.ManifestLength = (UInt32)TextBytes.Length;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace WPinternals
|
||||
Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("WPInternals");
|
||||
}
|
||||
|
||||
if ((Registration.IsPrerelease) && (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("NdaAccepted") == null))
|
||||
if (Registration.IsPrerelease && (Registry.CurrentUser.OpenSubKey("Software\\WPInternals").GetValue("NdaAccepted") == null))
|
||||
{
|
||||
this.ContextViewModel = new DisclaimerAndNdaViewModel(Disclaimer_Accepted);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace WPinternals
|
||||
{
|
||||
this.ContextViewModel = new DisclaimerViewModel(Disclaimer_Accepted);
|
||||
}
|
||||
else if ((Registration.IsPrerelease) && !Registration.IsRegistered())
|
||||
else if (Registration.IsPrerelease && !Registration.IsRegistered())
|
||||
{
|
||||
ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ namespace WPinternals
|
||||
{
|
||||
ContextViewModel = null;
|
||||
|
||||
if ((Registration.IsPrerelease) && !Registration.IsRegistered())
|
||||
if (Registration.IsPrerelease && !Registration.IsRegistered())
|
||||
{
|
||||
ContextViewModel = new RegistrationViewModel(Registration_Completed, Registration_Failed);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace WPinternals
|
||||
}
|
||||
eMMC = Manufacturer == null ? MemSizeDouble.ToString() + " GB" : Manufacturer + " " + MemSizeDouble.ToString() + " GB";
|
||||
|
||||
SamsungWarningVisible = (MID == 0x0015);
|
||||
SamsungWarningVisible = MID == 0x0015;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace WPinternals
|
||||
bool? ProductionDone = CurrentModel.ExecuteJsonMethodAsBoolean("ReadProductionDoneState", "ProductionDone");
|
||||
IsBootloaderSecurityEnabled = ProductionDone == null
|
||||
? CurrentModel.ExecuteJsonMethodAsString("GetSecurityMode", "SecMode").Contains("Restricted", StringComparison.OrdinalIgnoreCase)
|
||||
: (CurrentModel.ExecuteJsonMethodAsString("GetSecurityMode", "SecMode").Contains("Restricted", StringComparison.OrdinalIgnoreCase)) && (bool)CurrentModel.ExecuteJsonMethodAsBoolean("ReadProductionDoneState", "ProductionDone");
|
||||
: CurrentModel.ExecuteJsonMethodAsString("GetSecurityMode", "SecMode").Contains("Restricted", StringComparison.OrdinalIgnoreCase) && (bool)CurrentModel.ExecuteJsonMethodAsBoolean("ReadProductionDoneState", "ProductionDone");
|
||||
|
||||
LogFile.Log("Bootloader Security: " + ((bool)IsBootloaderSecurityEnabled ? "Enabled" : "Disabled"));
|
||||
IsSimLocked = CurrentModel.ExecuteJsonMethodAsBoolean("ReadSimlockActive", "SimLockActive");
|
||||
|
||||
@@ -162,12 +162,12 @@ namespace WPinternals
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((e.DevicePath.Contains("VID_0421&", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_045E&", StringComparison.OrdinalIgnoreCase)))
|
||||
if (e.DevicePath.Contains("VID_0421&", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_045E&", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if ((e.DevicePath.Contains("&PID_0660&MI_04", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("&PID_0713&MI_04", StringComparison.OrdinalIgnoreCase)) || // for Spec B
|
||||
(e.DevicePath.Contains("&PID_0A01&MI_04", StringComparison.OrdinalIgnoreCase))) // for Spec B (650)
|
||||
if (e.DevicePath.Contains("&PID_0660&MI_04", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("&PID_0713&MI_04", StringComparison.OrdinalIgnoreCase) || // for Spec B
|
||||
e.DevicePath.Contains("&PID_0A01&MI_04", StringComparison.OrdinalIgnoreCase)) // for Spec B (650)
|
||||
{
|
||||
CurrentInterface = PhoneInterfaces.Lumia_Label;
|
||||
CurrentModel = new NokiaPhoneModel(e.DevicePath);
|
||||
@@ -177,9 +177,9 @@ namespace WPinternals
|
||||
LogFile.Log("Mode: Label", LogType.FileAndConsole);
|
||||
NewDeviceArrived(new ArrivalEventArgs((PhoneInterfaces)CurrentInterface, CurrentModel));
|
||||
}
|
||||
else if ((e.DevicePath.Contains("&PID_0661", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("&PID_06FC", StringComparison.OrdinalIgnoreCase)) || // VID_0421&PID_06FC is for Lumia 930
|
||||
(e.DevicePath.Contains("&PID_0A00", StringComparison.OrdinalIgnoreCase))) // vid_045e & pid_0a00 & mi_03 = Lumia 950 XL normal mode
|
||||
else if (e.DevicePath.Contains("&PID_0661", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("&PID_06FC", StringComparison.OrdinalIgnoreCase) || // VID_0421&PID_06FC is for Lumia 930
|
||||
e.DevicePath.Contains("&PID_0A00", StringComparison.OrdinalIgnoreCase)) // vid_045e & pid_0a00 & mi_03 = Lumia 950 XL normal mode
|
||||
{
|
||||
if (((USBNotifier)sender).Guid == OldCombiInterfaceGuid)
|
||||
{
|
||||
@@ -229,10 +229,10 @@ namespace WPinternals
|
||||
NewDeviceArrived(new ArrivalEventArgs((PhoneInterfaces)CurrentInterface, CurrentModel));
|
||||
}
|
||||
}
|
||||
else if ((e.DevicePath.Contains("&PID_066E", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("&PID_0714", StringComparison.OrdinalIgnoreCase)) || // VID_0421&PID_0714 is for Lumia 930
|
||||
(e.DevicePath.Contains("&PID_0A02", StringComparison.OrdinalIgnoreCase)) || // VID_045E&PID_0A02 is for Lumia 950
|
||||
(e.DevicePath.Contains("&PID_05EE", StringComparison.OrdinalIgnoreCase))) // VID_0421&PID_05EE is for early RX100
|
||||
else if (e.DevicePath.Contains("&PID_066E", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("&PID_0714", StringComparison.OrdinalIgnoreCase) || // VID_0421&PID_0714 is for Lumia 930
|
||||
e.DevicePath.Contains("&PID_0A02", StringComparison.OrdinalIgnoreCase) || // VID_045E&PID_0A02 is for Lumia 950
|
||||
e.DevicePath.Contains("&PID_05EE", StringComparison.OrdinalIgnoreCase)) // VID_0421&PID_05EE is for early RX100
|
||||
{
|
||||
CurrentModel = new NokiaFlashModel(e.DevicePath);
|
||||
((NokiaFlashModel)CurrentModel).InterfaceChanged += InterfaceChanged;
|
||||
@@ -284,9 +284,9 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((e.DevicePath.Contains("DISK&VEN_QUALCOMM&PROD_MMC_STORAGE", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("DISK&VEN_MSFT&PROD_PHONE_MMC_STOR", StringComparison.OrdinalIgnoreCase)) ||
|
||||
((e.DevicePath.Length == @"\\.\E:".Length) && (e.DevicePath.StartsWith(@"\\.\")) && (e.DevicePath.EndsWith(":"))))
|
||||
else if (e.DevicePath.Contains("DISK&VEN_QUALCOMM&PROD_MMC_STORAGE", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("DISK&VEN_MSFT&PROD_PHONE_MMC_STOR", StringComparison.OrdinalIgnoreCase) ||
|
||||
((e.DevicePath.Length == @"\\.\E:".Length) && e.DevicePath.StartsWith(@"\\.\") && e.DevicePath.EndsWith(":")))
|
||||
{
|
||||
#if DEBUG
|
||||
LogFile.Log("Mass storage arrived: " + e.DevicePath, LogType.FileOnly);
|
||||
@@ -335,7 +335,7 @@ namespace WPinternals
|
||||
{
|
||||
if (e.DevicePath.Contains("&PID_9008", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
USBDeviceInfo DeviceInfo = Array.Find(USBDevice.GetDevices(((USBNotifier)sender).Guid), (d) => string.Compare(d.DevicePath, e.DevicePath, true) == 0);
|
||||
USBDeviceInfo DeviceInfo = Array.Find(USBDevice.GetDevices(((USBNotifier)sender).Guid), (d) => string.Equals(d.DevicePath, e.DevicePath, StringComparison.CurrentCultureIgnoreCase));
|
||||
|
||||
if ((DeviceInfo.BusName == "QHSUSB_DLOAD") || (DeviceInfo.BusName == "QHSUSB__BULK") || ((DeviceInfo.BusName?.Length == 0) && (LastInterface != PhoneInterfaces.Qualcomm_Download))) // TODO: Separate for Sahara!
|
||||
{
|
||||
@@ -424,19 +424,19 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
if (
|
||||
(e.DevicePath.Contains("VID_0421&PID_0660&MI_04", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_0713&MI_04", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_045E&PID_0A01&MI_04", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_0661", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_06FC", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_066E", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_0714", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_0421&PID_05EE", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_045E&PID_0A00", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_045E&PID_0A02", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("VID_05C6&PID_9008", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("DISK&VEN_QUALCOMM&PROD_MMC_STORAGE", StringComparison.OrdinalIgnoreCase)) ||
|
||||
(e.DevicePath.Contains("DISK&VEN_MSFT&PROD_PHONE_MMC_STOR", StringComparison.OrdinalIgnoreCase))
|
||||
e.DevicePath.Contains("VID_0421&PID_0660&MI_04", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_0713&MI_04", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_045E&PID_0A01&MI_04", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_0661", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_06FC", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_066E", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_0714", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_0421&PID_05EE", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_045E&PID_0A00", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_045E&PID_0A02", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("VID_05C6&PID_9008", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("DISK&VEN_QUALCOMM&PROD_MMC_STORAGE", StringComparison.OrdinalIgnoreCase) ||
|
||||
e.DevicePath.Contains("DISK&VEN_MSFT&PROD_PHONE_MMC_STOR", StringComparison.OrdinalIgnoreCase)
|
||||
)
|
||||
{
|
||||
if (CurrentInterface != null)
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace WPinternals
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RestoreCommand ??= new DelegateCommand(() => RestoreCallback(EFIESPPath, MainOSPath, DataPath), () => (((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null)));
|
||||
return _RestoreCommand ??= new DelegateCommand(() => RestoreCallback(EFIESPPath, MainOSPath, DataPath), () => ((EFIESPPath != null) || (MainOSPath != null) || (DataPath != null)) && (PhoneNotifier.CurrentInterface != null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace WPinternals
|
||||
{
|
||||
IsPhoneDisconnected = PhoneNotifier.CurrentInterface == null;
|
||||
IsPhoneInFlashMode = PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_Flash;
|
||||
IsPhoneInOtherMode = (!IsPhoneDisconnected && !IsPhoneInFlashMode);
|
||||
IsPhoneInOtherMode = !IsPhoneDisconnected && !IsPhoneInFlashMode;
|
||||
RestoreCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -659,15 +659,15 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
|
||||
bool IsOldLumia = (Info.FlashAppProtocolVersionMajor < 2);
|
||||
bool IsNewLumia = (Info.FlashAppProtocolVersionMajor >= 2);
|
||||
bool IsOldLumia = Info.FlashAppProtocolVersionMajor < 2;
|
||||
bool IsNewLumia = Info.FlashAppProtocolVersionMajor >= 2;
|
||||
bool IsUnlockedNew = false;
|
||||
if (IsNewLumia)
|
||||
{
|
||||
GPT GPT = FlashModel.ReadGPT();
|
||||
IsUnlockedNew = ((GPT.GetPartition("IS_UNLOCKED") != null) || (GPT.GetPartition("BACKUP_EFIESP") != null) || (GPT.GetPartition("BACKUP_BS_NV") != null));
|
||||
IsUnlockedNew = (GPT.GetPartition("IS_UNLOCKED") != null) || (GPT.GetPartition("BACKUP_EFIESP") != null) || (GPT.GetPartition("BACKUP_BS_NV") != null);
|
||||
}
|
||||
bool IsOriginalEngineeringLumia = (!Info.IsBootloaderSecure && !IsUnlockedNew);
|
||||
bool IsOriginalEngineeringLumia = !Info.IsBootloaderSecure && !IsUnlockedNew;
|
||||
|
||||
if (IsOldLumia || IsOriginalEngineeringLumia)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user