mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-14 03:16:40 +10:00
Remove Defunct MSR Downloads
This commit is contained in:
+15
-500
@@ -32,7 +32,6 @@ using WPinternals.Models.Lumia.MSR;
|
||||
using WPinternals.Models.Lumia.NCSd;
|
||||
using WPinternals.Models.UEFIApps.BootMgr;
|
||||
using WPinternals.Models.UEFIApps.Flash;
|
||||
using WPinternals.Models.UEFIApps.PhoneInfo;
|
||||
|
||||
namespace WPinternals
|
||||
{
|
||||
@@ -92,20 +91,14 @@ namespace WPinternals
|
||||
PhoneNotifierViewModel Notifier;
|
||||
LumiaFlashAppModel FlashModel;
|
||||
LumiaBootManagerAppModel BootMgrModel;
|
||||
LumiaPhoneInfoAppModel PhoneInfoModel;
|
||||
NokiaCareSuiteModel NormalModel;
|
||||
LumiaFlashAppPhoneInfo FlashInfo;
|
||||
LumiaPhoneInfoAppPhoneInfo PhoneInfo;
|
||||
LumiaBootManagerPhoneInfo BootManagerInfo;
|
||||
string ProductType;
|
||||
string ProductCode;
|
||||
string OperatorCode;
|
||||
string DownloadFolder;
|
||||
string FFUFilePath;
|
||||
string URL;
|
||||
string[] URLs;
|
||||
Uri URI;
|
||||
string FFUFileName;
|
||||
string EmergencyFileName;
|
||||
string EmergencyFilePath;
|
||||
string ProgrammerPath = "";
|
||||
@@ -1274,211 +1267,6 @@ namespace WPinternals
|
||||
|
||||
LogFile.Log("Root access enabled on image", LogType.FileAndConsole);
|
||||
break;
|
||||
case "downloadffu":
|
||||
LogFile.Log("Command: Download FFU", LogType.FileAndConsole);
|
||||
Notifier = new PhoneNotifierViewModel();
|
||||
UIContext.Send(s => Notifier.Start(), null);
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Normal)
|
||||
{
|
||||
NormalModel = (NokiaCareSuiteModel)Notifier.CurrentModel;
|
||||
ProductCode = NormalModel.ExecuteJsonMethodAsString("ReadProductCode", "ProductCode");
|
||||
}
|
||||
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
(Notifier.CurrentModel as LumiaBootManagerAppModel).SwitchToPhoneInfoAppContext();
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
PhoneInfoModel = (LumiaPhoneInfoAppModel)Notifier.CurrentModel;
|
||||
PhoneInfo = PhoneInfoModel.ReadPhoneInfo();
|
||||
ProductCode = PhoneInfo.ProductCode;
|
||||
}
|
||||
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_PhoneInfo)
|
||||
{
|
||||
PhoneInfoModel = (LumiaPhoneInfoAppModel)Notifier.CurrentModel;
|
||||
PhoneInfo = PhoneInfoModel.ReadPhoneInfo();
|
||||
ProductCode = PhoneInfo.ProductCode;
|
||||
}
|
||||
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
bool ModernFlashApp = ((LumiaFlashAppModel)Notifier.CurrentModel).ReadPhoneInfo().FlashAppProtocolVersionMajor >= 2;
|
||||
if (ModernFlashApp)
|
||||
{
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).SwitchToPhoneInfoAppContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).SwitchToPhoneInfoAppContextLegacy();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
PhoneInfoModel = (LumiaPhoneInfoAppModel)Notifier.CurrentModel;
|
||||
PhoneInfo = PhoneInfoModel.ReadPhoneInfo();
|
||||
ProductCode = PhoneInfo.ProductCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalModel = (NokiaCareSuiteModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Normal);
|
||||
ProductCode = NormalModel.ExecuteJsonMethodAsString("ReadProductCode", "ProductCode");
|
||||
}
|
||||
URL = LumiaDownloadModel.SearchFFU(null, ProductCode, null, out ProductType);
|
||||
DownloadFolder = args.Length >= 3
|
||||
? args[4]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
Notifier.Stop();
|
||||
break;
|
||||
case "downloadffubyoperatorcode":
|
||||
LogFile.Log("Command: Download FFU by Operator Code", LogType.FileAndConsole);
|
||||
if (args.Length < 4)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -DownloadFFUbyOperatorCode <Product type> <Operator code> <Optional: Download folder>");
|
||||
}
|
||||
|
||||
ProductType = args[2];
|
||||
LogFile.Log("Product type: " + ProductType, LogType.FileAndConsole);
|
||||
OperatorCode = args[3];
|
||||
LogFile.Log("Operator code: " + OperatorCode, LogType.FileAndConsole);
|
||||
DownloadFolder = args.Length >= 5
|
||||
? args[4]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, OperatorCode);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
break;
|
||||
case "downloadffubyproductcode":
|
||||
LogFile.Log("Command: Download FFU by Product Code", LogType.FileAndConsole);
|
||||
if (args.Length < 3)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -DownloadFFUbyProductCode <Product code> <Optional: Download folder>");
|
||||
}
|
||||
|
||||
ProductCode = args[2];
|
||||
LogFile.Log("Product code: " + ProductCode, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(null, ProductCode, null, out ProductType);
|
||||
DownloadFolder = args.Length >= 4
|
||||
? args[3]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
break;
|
||||
case "downloadffubyproducttype":
|
||||
LogFile.Log("Command: Download FFU by Product Type", LogType.FileAndConsole);
|
||||
if (args.Length < 3)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -DownloadFFUbyProductType <Product type> <Optional: Download folder>");
|
||||
}
|
||||
|
||||
ProductType = args[2];
|
||||
LogFile.Log("Product type: " + ProductType, LogType.FileAndConsole);
|
||||
DownloadFolder = args.Length >= 4
|
||||
? args[3]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
break;
|
||||
case "searchffubyproducttype":
|
||||
LogFile.Log("Command: Search FFU by Product Type", LogType.FileAndConsole);
|
||||
if (args.Length < 3)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -SearchFFUbyProductType <Lumia model>");
|
||||
}
|
||||
|
||||
ProductType = args[2];
|
||||
LogFile.Log("Lumia model: " + ProductType, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
break;
|
||||
case "downloademergency":
|
||||
LogFile.Log("Command: Download Emergency files", LogType.FileAndConsole);
|
||||
Notifier = new PhoneNotifierViewModel();
|
||||
@@ -1609,28 +1397,36 @@ namespace WPinternals
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Normal)
|
||||
{
|
||||
NormalModel = (NokiaCareSuiteModel)Notifier.CurrentModel;
|
||||
ProductCode = NormalModel.ExecuteJsonMethodAsString("ReadProductCode", "ProductCode");
|
||||
ProductType = NormalModel.ExecuteJsonMethodAsString("ReadManufacturerModelName", "ManufacturerModelName");
|
||||
if (ProductType.Contains('_'))
|
||||
{
|
||||
ProductType = ProductType.Substring(0, ProductType.IndexOf('_'));
|
||||
}
|
||||
}
|
||||
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
BootMgrModel = (LumiaBootManagerAppModel)Notifier.CurrentModel;
|
||||
BootManagerInfo = BootMgrModel.ReadPhoneInfo();
|
||||
//ProductCode = BootManagerInfo.ProductCode; // TODO: FIXME
|
||||
ProductCode = "";
|
||||
//ProductType = BootManagerInfo.Type; // TODO: FIXME
|
||||
ProductType = "";
|
||||
}
|
||||
else if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
FlashModel = (LumiaFlashAppModel)Notifier.CurrentModel;
|
||||
FlashInfo = FlashModel.ReadPhoneInfo();
|
||||
//ProductCode = FlashInfo.ProductCode; // TODO: FIXME
|
||||
ProductCode = "";
|
||||
//ProductType = FlashInfo.Type; // TODO: FIXME
|
||||
ProductType = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalModel = (NokiaCareSuiteModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Normal);
|
||||
ProductCode = NormalModel.ExecuteJsonMethodAsString("ReadProductCode", "ProductCode");
|
||||
ProductType = NormalModel.ExecuteJsonMethodAsString("ReadManufacturerModelName", "ManufacturerModelName");
|
||||
if (ProductType.Contains('_'))
|
||||
{
|
||||
ProductType = ProductType.Substring(0, ProductType.IndexOf('_'));
|
||||
}
|
||||
URL = LumiaDownloadModel.SearchFFU(null, ProductCode, null, out ProductType);
|
||||
}
|
||||
|
||||
DownloadFolder = args.Length >= 3
|
||||
? args[2]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
@@ -1640,20 +1436,6 @@ namespace WPinternals
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
URLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
if (URLs != null)
|
||||
{
|
||||
@@ -1683,39 +1465,10 @@ namespace WPinternals
|
||||
App.Config.AddEmergencyToRepository(ProductType, ProgrammerPath, PayloadPath);
|
||||
}
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
ProductType = "RM-1085";
|
||||
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
DownloadFolder = args.Length >= 3
|
||||
? args[2]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
throw new WPinternalsException("Unable to find compatible FFU", "No donor-FFU has been found in the repository with a supported OS version. You can add a donor-FFU within the download section of the tool or by using the command line. A donor-FFU can be for a different device and a different CPU than your device. It is only used to gather Operating System specific binaries to be patched and used as part of the unlock process.");
|
||||
}
|
||||
}
|
||||
Notifier.Stop();
|
||||
break;
|
||||
case "downloadallbyproducttype":
|
||||
@@ -1736,21 +1489,6 @@ namespace WPinternals
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
URLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
if (URLs != null)
|
||||
{
|
||||
@@ -1780,233 +1518,10 @@ namespace WPinternals
|
||||
App.Config.AddEmergencyToRepository(ProductType, ProgrammerPath, PayloadPath);
|
||||
}
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
ProductType = "RM-1085";
|
||||
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
DownloadFolder = args.Length >= 4
|
||||
? args[3]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
throw new WPinternalsException("Unable to find compatible FFU", "No donor-FFU has been found in the repository with a supported OS version. You can add a donor-FFU within the download section of the tool or by using the command line. A donor-FFU can be for a different device and a different CPU than your device. It is only used to gather Operating System specific binaries to be patched and used as part of the unlock process.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "downloadallbyproductcode":
|
||||
LogFile.Log("Command: Download all by Product Code", LogType.FileAndConsole);
|
||||
if (args.Length < 3)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -DownloadAllByProductCode <Product code> <Optional: Download folder>");
|
||||
}
|
||||
|
||||
ProductCode = args[2];
|
||||
LogFile.Log("Product code: " + ProductCode, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(null, ProductCode, null, out ProductType);
|
||||
DownloadFolder = args.Length >= 4
|
||||
? args[3]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
URLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
if (URLs != null)
|
||||
{
|
||||
for (int i = 0; i < URLs.Length; i++)
|
||||
{
|
||||
LogFile.Log("URL: " + URLs[i], LogType.FileAndConsole);
|
||||
URI = new Uri(URLs[i]);
|
||||
EmergencyFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + EmergencyFileName, LogType.FileAndConsole);
|
||||
EmergencyFilePath = Path.Combine(DownloadFolder, EmergencyFileName);
|
||||
if (i == 0)
|
||||
{
|
||||
ProgrammerPath = EmergencyFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
PayloadPath = EmergencyFilePath;
|
||||
}
|
||||
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URLs[i], EmergencyFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
}
|
||||
App.Config.AddEmergencyToRepository(ProductType, ProgrammerPath, PayloadPath);
|
||||
}
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
ProductType = "RM-1085";
|
||||
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
DownloadFolder = args.Length >= 4
|
||||
? args[3]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
throw new WPinternalsException("Unable to find compatible FFU", "No donor-FFU has been found in the repository with a supported OS version. You can add a donor-FFU within the download section of the tool or by using the command line. A donor-FFU can be for a different device and a different CPU than your device. It is only used to gather Operating System specific binaries to be patched and used as part of the unlock process.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "downloadallbyoperatorcode":
|
||||
LogFile.Log("Command: Download FFU by Operator Code", LogType.FileAndConsole);
|
||||
if (args.Length < 4)
|
||||
{
|
||||
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -DownloadFFUbyOperatorCode <Product type> <Operator code> <Optional: Download folder>");
|
||||
}
|
||||
|
||||
ProductType = args[2];
|
||||
LogFile.Log("Product type: " + ProductType, LogType.FileAndConsole);
|
||||
OperatorCode = args[3];
|
||||
LogFile.Log("Operator code: " + OperatorCode, LogType.FileAndConsole);
|
||||
DownloadFolder = args.Length >= 5
|
||||
? args[4]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, OperatorCode);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
URLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
if (URLs != null)
|
||||
{
|
||||
for (int i = 0; i < URLs.Length; i++)
|
||||
{
|
||||
LogFile.Log("URL: " + URLs[i], LogType.FileAndConsole);
|
||||
URI = new Uri(URLs[i]);
|
||||
EmergencyFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + EmergencyFileName, LogType.FileAndConsole);
|
||||
EmergencyFilePath = Path.Combine(DownloadFolder, EmergencyFileName);
|
||||
if (i == 0)
|
||||
{
|
||||
ProgrammerPath = EmergencyFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
PayloadPath = EmergencyFilePath;
|
||||
}
|
||||
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URLs[i], EmergencyFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
}
|
||||
App.Config.AddEmergencyToRepository(ProductType, ProgrammerPath, PayloadPath);
|
||||
}
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
ProductType = "RM-1085";
|
||||
|
||||
URL = LumiaDownloadModel.SearchFFU(ProductType, null, null);
|
||||
DownloadFolder = args.Length >= 5
|
||||
? args[4]
|
||||
: Environment.ExpandEnvironmentVariables("%ALLUSERSPROFILE%\\WPInternals\\Repository\\" + ProductType.ToUpper());
|
||||
|
||||
if (!Directory.Exists(DownloadFolder))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
}
|
||||
|
||||
LogFile.Log("Download folder: " + DownloadFolder, LogType.FileAndConsole);
|
||||
LogFile.Log("URL: " + URL, LogType.FileAndConsole);
|
||||
URI = new Uri(URL);
|
||||
FFUFileName = Path.GetFileName(URI.LocalPath);
|
||||
LogFile.Log("File: " + FFUFileName, LogType.FileAndConsole);
|
||||
FFUFilePath = Path.Combine(DownloadFolder, FFUFileName);
|
||||
LogFile.Log("Downloading...", LogType.FileAndConsole);
|
||||
using (System.Net.WebClient myWebClient = new())
|
||||
{
|
||||
await myWebClient.DownloadFileTaskAsync(URL, FFUFilePath);
|
||||
}
|
||||
LogFile.Log("Download finished", LogType.FileAndConsole);
|
||||
App.Config.AddFfuToRepository(FFUFilePath);
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
throw new WPinternalsException("Unable to find compatible FFU", "No donor-FFU has been found in the repository with a supported OS version. You can add a donor-FFU within the download section of the tool or by using the command line. A donor-FFU can be for a different device and a different CPU than your device. It is only used to gather Operating System specific binaries to be patched and used as part of the unlock process.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "rewritepartitionsfrommassstorage":
|
||||
if (args.Length < 2)
|
||||
|
||||
@@ -18,300 +18,15 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using WPinternals.HelperClasses;
|
||||
|
||||
namespace WPinternals.Models.Lumia.MSR
|
||||
{
|
||||
internal static class LumiaDownloadModel
|
||||
{
|
||||
internal static string SearchFFU(string ProductType, string ProductCode, string OperatorCode)
|
||||
{
|
||||
return SearchFFU(ProductType, ProductCode, OperatorCode, out string FoundProductType);
|
||||
}
|
||||
|
||||
internal static string SearchFFU(string ProductType, string ProductCode, string OperatorCode, out string FoundProductType)
|
||||
{
|
||||
if (ProductType?.Length == 0)
|
||||
{
|
||||
ProductType = null;
|
||||
}
|
||||
|
||||
if (ProductCode?.Length == 0)
|
||||
{
|
||||
ProductCode = null;
|
||||
}
|
||||
|
||||
if (OperatorCode?.Length == 0)
|
||||
{
|
||||
OperatorCode = null;
|
||||
}
|
||||
|
||||
if (ProductCode != null)
|
||||
{
|
||||
ProductCode = ProductCode.ToUpper();
|
||||
ProductType = null;
|
||||
OperatorCode = null;
|
||||
}
|
||||
if (ProductType != null)
|
||||
{
|
||||
ProductType = ProductType.ToUpper();
|
||||
if (ProductType.StartsWith("RM") && !ProductType.StartsWith("RM-"))
|
||||
{
|
||||
ProductType = "RM-" + ProductType[2..];
|
||||
}
|
||||
}
|
||||
if (OperatorCode != null)
|
||||
{
|
||||
OperatorCode = OperatorCode.ToUpper();
|
||||
}
|
||||
|
||||
DiscoveryQueryParameters DiscoveryQueryParams = new()
|
||||
{
|
||||
manufacturerName = "Microsoft",
|
||||
manufacturerProductLine = "Lumia",
|
||||
packageType = "Firmware",
|
||||
packageClass = "Public",
|
||||
manufacturerHardwareModel = ProductType,
|
||||
manufacturerHardwareVariant = ProductCode,
|
||||
operatorName = OperatorCode
|
||||
};
|
||||
DiscoveryParameters DiscoveryParams = new()
|
||||
{
|
||||
query = DiscoveryQueryParams
|
||||
};
|
||||
|
||||
DataContractJsonSerializer Serializer1 = new(typeof(DiscoveryParameters));
|
||||
MemoryStream JsonStream1 = new();
|
||||
Serializer1.WriteObject(JsonStream1, DiscoveryParams);
|
||||
JsonStream1.Seek(0L, SeekOrigin.Begin);
|
||||
string JsonContent = new StreamReader(JsonStream1).ReadToEnd();
|
||||
|
||||
Uri RequestUri = new("https://api.swrepository.com/rest-api/discovery/1/package");
|
||||
|
||||
HttpClient HttpClient = new();
|
||||
HttpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("SoftwareRepository");
|
||||
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
Task<HttpResponseMessage> HttpPostTask = HttpClient.PostAsync(RequestUri, new StringContent(JsonContent, Encoding.UTF8, "application/json"));
|
||||
HttpPostTask.Wait();
|
||||
HttpResponseMessage Response = HttpPostTask.Result;
|
||||
|
||||
string JsonResultString = "";
|
||||
if (Response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Task<string> ReadResponseTask = Response.Content.ReadAsStringAsync();
|
||||
ReadResponseTask.Wait();
|
||||
JsonResultString = ReadResponseTask.Result;
|
||||
}
|
||||
|
||||
SoftwarePackage Package = null;
|
||||
using (MemoryStream JsonStream2 = new(Encoding.UTF8.GetBytes(JsonResultString)))
|
||||
{
|
||||
DataContractJsonSerializer Serializer2 = new(typeof(SoftwarePackages));
|
||||
SoftwarePackages SoftwarePackages = (SoftwarePackages)Serializer2.ReadObject(JsonStream2);
|
||||
if (SoftwarePackages != null)
|
||||
{
|
||||
Package = SoftwarePackages.softwarePackages.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (Package == null)
|
||||
{
|
||||
throw new WPinternalsException("FFU not found", "No FFU has been found in the remote software repository for the requested model.");
|
||||
}
|
||||
|
||||
FoundProductType = Package.manufacturerHardwareModel[0];
|
||||
|
||||
SoftwareFile FileInfo = Package.files.First(f => f.fileName.EndsWith(".ffu", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
Uri FileInfoUri = new("https://api.swrepository.com/rest-api/discovery/fileurl/1/" + Package.id + "/" + FileInfo.fileName);
|
||||
Task<string> GetFileInfoTask = HttpClient.GetStringAsync(FileInfoUri);
|
||||
GetFileInfoTask.Wait();
|
||||
string FileInfoString = GetFileInfoTask.Result;
|
||||
|
||||
string FfuUrl = "";
|
||||
FileUrlResult FileUrl = null;
|
||||
using (MemoryStream JsonStream3 = new(Encoding.UTF8.GetBytes(FileInfoString)))
|
||||
{
|
||||
DataContractJsonSerializer Serializer3 = new(typeof(FileUrlResult));
|
||||
FileUrl = (FileUrlResult)Serializer3.ReadObject(JsonStream3);
|
||||
if (FileUrl != null)
|
||||
{
|
||||
FfuUrl = FileUrl.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
|
||||
}
|
||||
}
|
||||
|
||||
HttpClient.Dispose();
|
||||
|
||||
return FfuUrl;
|
||||
}
|
||||
|
||||
internal static (string SecureWIMUrl, string DPLUrl) SearchENOSW(string ProductType, string PhoneFirmwareRevision)
|
||||
{
|
||||
if (ProductType?.Length == 0)
|
||||
{
|
||||
ProductType = null;
|
||||
}
|
||||
|
||||
if (ProductType != null)
|
||||
{
|
||||
ProductType = ProductType.ToUpper();
|
||||
if (ProductType.StartsWith("RM") && !ProductType.StartsWith("RM-"))
|
||||
{
|
||||
ProductType = $"RM-{ProductType[2..]}";
|
||||
}
|
||||
}
|
||||
|
||||
DiscoveryQueryParameters DiscoveryQueryParams = new()
|
||||
{
|
||||
manufacturerName = "Microsoft",
|
||||
manufacturerProductLine = "Lumia",
|
||||
packageType = "Test Mode",
|
||||
packageClass = "Public",
|
||||
manufacturerHardwareModel = ProductType
|
||||
};
|
||||
|
||||
DiscoveryParameters DiscoveryParams = new()
|
||||
{
|
||||
query = DiscoveryQueryParams
|
||||
};
|
||||
|
||||
DataContractJsonSerializer Serializer1 = new(typeof(DiscoveryParameters));
|
||||
MemoryStream JsonStream1 = new();
|
||||
Serializer1.WriteObject(JsonStream1, DiscoveryParams);
|
||||
JsonStream1.Seek(0L, SeekOrigin.Begin);
|
||||
string JsonContent = new StreamReader(JsonStream1).ReadToEnd();
|
||||
|
||||
Uri RequestUri = new("https://api.swrepository.com/rest-api/discovery/1/package");
|
||||
|
||||
HttpClient HttpClient = new();
|
||||
HttpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("SoftwareRepository");
|
||||
HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
Task<HttpResponseMessage> HttpPostTask = HttpClient.PostAsync(RequestUri, new StringContent(JsonContent, Encoding.UTF8, "application/json"));
|
||||
HttpPostTask.Wait();
|
||||
HttpResponseMessage Response = HttpPostTask.Result;
|
||||
|
||||
string JsonResultString = "";
|
||||
if (Response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Task<string> ReadResponseTask = Response.Content.ReadAsStringAsync();
|
||||
ReadResponseTask.Wait();
|
||||
JsonResultString = ReadResponseTask.Result;
|
||||
}
|
||||
|
||||
SoftwarePackage Package = null;
|
||||
using MemoryStream JsonResultStream = new(Encoding.UTF8.GetBytes(JsonResultString));
|
||||
DataContractJsonSerializer SoftwarePackagesJsonSerializer = new(typeof(SoftwarePackages));
|
||||
SoftwarePackages SoftwarePackages = (SoftwarePackages)SoftwarePackagesJsonSerializer.ReadObject(JsonResultStream);
|
||||
|
||||
if (SoftwarePackages != null)
|
||||
{
|
||||
foreach (SoftwarePackage pkg in SoftwarePackages.softwarePackages)
|
||||
{
|
||||
Package = SoftwarePackages.softwarePackages.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (Package == null)
|
||||
{
|
||||
throw new WPinternalsException("ENOSW package not found", "No ENOSW package has been found in the remote software repository for the requested model.");
|
||||
}
|
||||
|
||||
SoftwareFile SecureWimSoftwareFile = Package.files.First(f => f.fileName.EndsWith(".secwim", StringComparison.OrdinalIgnoreCase));
|
||||
SoftwareFile DPLSoftwareFile = Package.files.First(f => f.fileName.EndsWith(".dpl", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
Uri DPLFileUrlUri = new($"https://api.swrepository.com/rest-api/discovery/fileurl/1/{Package.id}/{DPLSoftwareFile.fileName}");
|
||||
|
||||
Task<string> GetDPLTask = HttpClient.GetStringAsync(DPLFileUrlUri);
|
||||
GetDPLTask.Wait();
|
||||
|
||||
string DPLFileUrlResultContent = GetDPLTask.Result;
|
||||
FileUrlResult DPLFileUrlResult = null;
|
||||
using MemoryStream DPLFileUrlResultStream = new(Encoding.UTF8.GetBytes(DPLFileUrlResultContent));
|
||||
DataContractJsonSerializer DPLFileUrlResultSerializer = new(typeof(FileUrlResult));
|
||||
DPLFileUrlResult = (FileUrlResult)DPLFileUrlResultSerializer.ReadObject(DPLFileUrlResultStream);
|
||||
|
||||
string DPLFileUrl = "";
|
||||
|
||||
if (DPLFileUrlResult != null)
|
||||
{
|
||||
DPLFileUrl = DPLFileUrlResult.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
|
||||
}
|
||||
|
||||
if (DPLFileUrl?.Length == 0)
|
||||
{
|
||||
throw new WPinternalsException("DPL not found", "No DPL has been found in the remote software repository for the requested model.");
|
||||
}
|
||||
|
||||
Task<string> GetDPLStrTask = HttpClient.GetStringAsync(DPLFileUrl);
|
||||
GetDPLStrTask.Wait();
|
||||
string DPLStrString = GetDPLStrTask.Result;
|
||||
|
||||
DPL.Package dpl;
|
||||
XmlSerializer serializer = new(typeof(DPL.Package));
|
||||
using StringReader reader = new(DPLStrString.Replace("ft:", "").Replace("dpl:", "").Replace("typedes:", ""));
|
||||
dpl = (DPL.Package)serializer.Deserialize(reader);
|
||||
|
||||
foreach (DPL.File file in dpl.Content.Files.File)
|
||||
{
|
||||
string name = file.Name;
|
||||
|
||||
DPL.Range range = file.Extensions.MmosWimFile.UseCaseCompatibilities.Compatibility.FirstOrDefault().Range;
|
||||
|
||||
if (IsFirmwareBetween(PhoneFirmwareRevision, range.From, range.To))
|
||||
{
|
||||
SecureWimSoftwareFile = Package.files.First(f => f.fileName.EndsWith(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
Uri FileInfoUri = new("https://api.swrepository.com/rest-api/discovery/fileurl/1/" + Package.id + "/" + SecureWimSoftwareFile.fileName);
|
||||
Task<string> GetFileInfoTask = HttpClient.GetStringAsync(FileInfoUri);
|
||||
GetFileInfoTask.Wait();
|
||||
string FileInfoString = GetFileInfoTask.Result;
|
||||
|
||||
string ENOSWFileUrl = "";
|
||||
|
||||
FileUrlResult FileUrl = null;
|
||||
|
||||
using MemoryStream JsonStream4 = new(Encoding.UTF8.GetBytes(FileInfoString));
|
||||
DataContractJsonSerializer Serializer4 = new(typeof(FileUrlResult));
|
||||
FileUrl = (FileUrlResult)Serializer4.ReadObject(JsonStream4);
|
||||
if (FileUrl != null)
|
||||
{
|
||||
ENOSWFileUrl = FileUrl.url.Replace("sr.azureedge.net", "softwarerepo.blob.core.windows.net");
|
||||
}
|
||||
|
||||
HttpClient.Dispose();
|
||||
|
||||
return (ENOSWFileUrl, DPLFileUrl);
|
||||
}
|
||||
|
||||
private static bool IsFirmwareBetween(string PhoneFirmwareRevision, string Limit1, string Limit2)
|
||||
{
|
||||
Version version = new Version(PhoneFirmwareRevision);
|
||||
Version version1 = new Version(Limit1);
|
||||
Version version2 = new Version(Limit2);
|
||||
|
||||
int result = version.CompareTo(version1);
|
||||
int result2 = version.CompareTo(version2);
|
||||
|
||||
return result >= 0 && result2 <= 0;
|
||||
}
|
||||
|
||||
internal static string[] SearchEmergencyFiles(string ProductType)
|
||||
{
|
||||
ProductType = ProductType.ToUpper();
|
||||
@@ -389,613 +104,4 @@ namespace WPinternals.Models.Lumia.MSR
|
||||
return [.. Result];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable 0649
|
||||
[DataContract]
|
||||
internal class FileUrlResult
|
||||
{
|
||||
[DataMember]
|
||||
internal string url;
|
||||
|
||||
[DataMember]
|
||||
internal List<string> alternateUrl;
|
||||
|
||||
[DataMember]
|
||||
internal long fileSize;
|
||||
|
||||
[DataMember]
|
||||
internal List<SoftwareFileChecksum> checksum;
|
||||
}
|
||||
#pragma warning restore 0649
|
||||
|
||||
[DataContract]
|
||||
public class DiscoveryQueryParameters
|
||||
{
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string customerName;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public ExtendedAttributes extendedAttributes;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerHardwareModel;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerHardwareVariant;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerModelName;
|
||||
|
||||
[DataMember]
|
||||
public string manufacturerName;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerPackageId;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerPlatformId;
|
||||
|
||||
[DataMember]
|
||||
public string manufacturerProductLine;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string manufacturerVariantName;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string operatorName;
|
||||
|
||||
[DataMember]
|
||||
public string packageClass;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string packageRevision;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string packageState;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string packageSubRevision;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string packageSubtitle;
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string packageTitle;
|
||||
|
||||
[DataMember]
|
||||
public string packageType;
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class DiscoveryParameters
|
||||
{
|
||||
[DataMember(Name = "api-version")]
|
||||
public string apiVersion;
|
||||
|
||||
[DataMember]
|
||||
public DiscoveryQueryParameters query;
|
||||
|
||||
[DataMember]
|
||||
public List<string> condition;
|
||||
|
||||
[DataMember]
|
||||
public List<string> response;
|
||||
|
||||
public DiscoveryParameters() : this(DiscoveryCondition.Default)
|
||||
{
|
||||
}
|
||||
|
||||
public DiscoveryParameters(DiscoveryCondition Condition)
|
||||
{
|
||||
apiVersion = "1";
|
||||
query = new DiscoveryQueryParameters();
|
||||
condition = [];
|
||||
if (Condition == DiscoveryCondition.All)
|
||||
{
|
||||
condition.Add("all");
|
||||
return;
|
||||
}
|
||||
if (Condition == DiscoveryCondition.Latest)
|
||||
{
|
||||
condition.Add("latest");
|
||||
return;
|
||||
}
|
||||
condition.Add("default");
|
||||
}
|
||||
}
|
||||
|
||||
public enum DiscoveryCondition
|
||||
{
|
||||
Default,
|
||||
All,
|
||||
Latest
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ExtendedAttributes : ISerializable
|
||||
{
|
||||
public Dictionary<string, string> Dictionary;
|
||||
|
||||
public ExtendedAttributes()
|
||||
{
|
||||
Dictionary = [];
|
||||
}
|
||||
|
||||
protected ExtendedAttributes(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
Dictionary = [];
|
||||
SerializationInfoEnumerator Enumerator = info.GetEnumerator();
|
||||
while (Enumerator.MoveNext())
|
||||
{
|
||||
Dictionary.Add(Enumerator.Current.Name, (string)Enumerator.Current.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
foreach (string Current in Dictionary.Keys)
|
||||
{
|
||||
info.AddValue(Current, Dictionary[Current]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class SoftwareFileChecksum
|
||||
{
|
||||
[DataMember]
|
||||
public string type;
|
||||
|
||||
[DataMember]
|
||||
public string value;
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class SoftwarePackages
|
||||
{
|
||||
[DataMember]
|
||||
public List<SoftwarePackage> softwarePackages;
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class SoftwarePackage
|
||||
{
|
||||
[DataMember]
|
||||
public List<string> customerName;
|
||||
|
||||
[DataMember]
|
||||
public ExtendedAttributes extendedAttributes;
|
||||
|
||||
[DataMember]
|
||||
public List<SoftwareFile> files;
|
||||
|
||||
[DataMember]
|
||||
public string id;
|
||||
|
||||
[DataMember]
|
||||
public List<string> manufacturerHardwareModel;
|
||||
|
||||
[DataMember]
|
||||
public List<string> manufacturerHardwareVariant;
|
||||
|
||||
[DataMember]
|
||||
public List<string> manufacturerModelName;
|
||||
|
||||
[DataMember]
|
||||
public string manufacturerName;
|
||||
|
||||
[DataMember]
|
||||
public string manufacturerPackageId;
|
||||
|
||||
[DataMember]
|
||||
public List<string> manufacturerPlatformId;
|
||||
|
||||
[DataMember]
|
||||
public string manufacturerProductLine;
|
||||
|
||||
[DataMember]
|
||||
public List<string> manufacturerVariantName;
|
||||
|
||||
[DataMember]
|
||||
public List<string> operatorName;
|
||||
|
||||
[DataMember]
|
||||
public List<string> packageClass;
|
||||
|
||||
[DataMember]
|
||||
public string packageDescription;
|
||||
|
||||
[DataMember]
|
||||
public string packageRevision;
|
||||
|
||||
[DataMember]
|
||||
public string packageState;
|
||||
|
||||
[DataMember]
|
||||
public string packageSubRevision;
|
||||
|
||||
[DataMember]
|
||||
public string packageSubtitle;
|
||||
|
||||
[DataMember]
|
||||
public string packageTitle;
|
||||
|
||||
[DataMember]
|
||||
public string packageType;
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class SoftwareFile
|
||||
{
|
||||
[DataMember]
|
||||
public List<SoftwareFileChecksum> checksum;
|
||||
|
||||
[DataMember]
|
||||
public string fileName;
|
||||
|
||||
[DataMember]
|
||||
public long fileSize;
|
||||
|
||||
[DataMember]
|
||||
public string fileType;
|
||||
}
|
||||
|
||||
public static class DPL
|
||||
{
|
||||
[XmlRoot(ElementName = "BasicProductCodes")]
|
||||
public class BasicProductCodes
|
||||
{
|
||||
[XmlElement(ElementName = "BasicProductCode")]
|
||||
public List<string> BasicProductCode
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Identification")]
|
||||
public class Identification
|
||||
{
|
||||
[XmlElement(ElementName = "TypeDesignator")]
|
||||
public string TypeDesignator
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "BasicProductCodes")]
|
||||
public BasicProductCodes BasicProductCodes
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Purpose")]
|
||||
public string Purpose
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Extensions")]
|
||||
public class Extensions
|
||||
{
|
||||
[XmlElement(ElementName = "PackageType")]
|
||||
public string PackageType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Identification")]
|
||||
public Identification Identification
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "FileType")]
|
||||
public string FileType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "MmosWimFile")]
|
||||
public MmosWimFile MmosWimFile
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "PackageDescription")]
|
||||
public class PackageDescription
|
||||
{
|
||||
[XmlElement(ElementName = "Identifier")]
|
||||
public string Identifier
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Revision")]
|
||||
public string Revision
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Extensions")]
|
||||
public Extensions Extensions
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Digest")]
|
||||
public class Digest
|
||||
{
|
||||
[XmlAttribute(AttributeName = "method")]
|
||||
public string Method
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlAttribute(AttributeName = "encoding")]
|
||||
public string Encoding
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlText]
|
||||
public string Text
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Digests")]
|
||||
public class Digests
|
||||
{
|
||||
[XmlElement(ElementName = "Digest")]
|
||||
public List<Digest> Digest
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Range")]
|
||||
public class Range
|
||||
{
|
||||
[XmlAttribute(AttributeName = "from")]
|
||||
public string From
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlAttribute(AttributeName = "to")]
|
||||
public string To
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Compatibility")]
|
||||
public class Compatibility
|
||||
{
|
||||
[XmlElement(ElementName = "Range")]
|
||||
public Range Range
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlAttribute(AttributeName = "useCase")]
|
||||
public string UseCase
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "UseCaseCompatibilities")]
|
||||
public class UseCaseCompatibilities
|
||||
{
|
||||
[XmlElement(ElementName = "Compatibility")]
|
||||
public List<Compatibility> Compatibility
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "MmosWimFile")]
|
||||
public class MmosWimFile
|
||||
{
|
||||
[XmlElement(ElementName = "UseCaseCompatibilities")]
|
||||
public UseCaseCompatibilities UseCaseCompatibilities
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "File")]
|
||||
public class File
|
||||
{
|
||||
[XmlElement(ElementName = "Name")]
|
||||
public string Name
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Digests")]
|
||||
public Digests Digests
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Revision")]
|
||||
public string Revision
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Extensions")]
|
||||
public Extensions Extensions
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Files")]
|
||||
public class Files
|
||||
{
|
||||
[XmlElement(ElementName = "File")]
|
||||
public List<File> File
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Content")]
|
||||
public class Content
|
||||
{
|
||||
[XmlElement(ElementName = "PackageDescription")]
|
||||
public PackageDescription PackageDescription
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Files")]
|
||||
public Files Files
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "CanonicalizationMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class CanonicalizationMethod
|
||||
{
|
||||
[XmlAttribute(AttributeName = "Algorithm")]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "SignatureMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class SignatureMethod
|
||||
{
|
||||
[XmlAttribute(AttributeName = "Algorithm")]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Transform", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class Transform
|
||||
{
|
||||
[XmlAttribute(AttributeName = "Algorithm")]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Transforms", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class Transforms
|
||||
{
|
||||
[XmlElement(ElementName = "Transform", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public Transform Transform
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "DigestMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class DigestMethod
|
||||
{
|
||||
[XmlAttribute(AttributeName = "Algorithm")]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Reference", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class Reference
|
||||
{
|
||||
[XmlElement(ElementName = "Transforms", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public Transforms Transforms
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "DigestMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public DigestMethod DigestMethod
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "DigestValue", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public string DigestValue
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlAttribute(AttributeName = "URI")]
|
||||
public string URI
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "SignedInfo", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class SignedInfo
|
||||
{
|
||||
[XmlElement(ElementName = "CanonicalizationMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public CanonicalizationMethod CanonicalizationMethod
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "SignatureMethod", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public SignatureMethod SignatureMethod
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Reference", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public Reference Reference
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "KeyInfo", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class KeyInfo
|
||||
{
|
||||
[XmlElement(ElementName = "KeyName", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public string KeyName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public class Signature
|
||||
{
|
||||
[XmlElement(ElementName = "SignedInfo", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public SignedInfo SignedInfo
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "SignatureValue", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public string SignatureValue
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "KeyInfo", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public KeyInfo KeyInfo
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlAttribute(AttributeName = "xmlns")]
|
||||
public string Xmlns
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "Package")]
|
||||
public class Package
|
||||
{
|
||||
[XmlElement(ElementName = "Content")]
|
||||
public Content Content
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
[XmlElement(ElementName = "Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
|
||||
public Signature Signature
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using WPinternals.HelperClasses;
|
||||
using WPinternals.Models.Lumia.UEFI;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using WPinternals.HelperClasses;
|
||||
using WPinternals.Models.Lumia.UEFI;
|
||||
|
||||
|
||||
@@ -93,6 +93,42 @@ namespace WPinternals
|
||||
LastStatusText = null;
|
||||
}
|
||||
});
|
||||
|
||||
AddSecWIMCommand = new DelegateCommand(() =>
|
||||
{
|
||||
string SecWIMPath = null;
|
||||
|
||||
OpenFileDialog dlg = new();
|
||||
dlg.DefaultExt = ".secwim"; // Default file extension
|
||||
dlg.Filter = "Secure WIM images (.secwim)|*.secwim"; // Filter files by extension
|
||||
|
||||
bool? result = dlg.ShowDialog();
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
SecWIMPath = dlg.FileName;
|
||||
string SecWIMFile = Path.GetFileName(SecWIMPath);
|
||||
|
||||
try
|
||||
{
|
||||
App.Config.AddSecWimToRepository(SecWIMPath, FirmwareVersion);
|
||||
App.Config.WriteConfig();
|
||||
LastStatusText = $"File \"{SecWIMFile}\" was added to the repository.";
|
||||
}
|
||||
catch (WPinternalsException Ex)
|
||||
{
|
||||
LastStatusText = $"Error: {Ex.Message}. File \"{SecWIMFile}\" was not added.";
|
||||
}
|
||||
catch
|
||||
{
|
||||
LastStatusText = $"Error: File \"{SecWIMFile}\" was not added.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastStatusText = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private string _LastStatusText = null;
|
||||
@@ -192,9 +228,7 @@ namespace WPinternals
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
string FFUURL = null;
|
||||
string[] EmergencyURLs = null;
|
||||
string SecureWIMURL = null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -206,16 +240,6 @@ namespace WPinternals
|
||||
|
||||
ProductType = TempProductType;
|
||||
|
||||
try
|
||||
{
|
||||
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, ProductCode, OperatorCode, out TempProductType);
|
||||
}
|
||||
catch (WPinternalsException ex)
|
||||
{
|
||||
LogFile.LogException(ex, LogType.FileOnly);
|
||||
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, null, OperatorCode, out TempProductType);
|
||||
}
|
||||
|
||||
if (TempProductType != null)
|
||||
{
|
||||
ProductType = TempProductType;
|
||||
@@ -225,11 +249,6 @@ namespace WPinternals
|
||||
{
|
||||
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
}
|
||||
|
||||
if (ProductType != null && FirmwareVersion != null)
|
||||
{
|
||||
(SecureWIMURL, string _) = LumiaDownloadModel.SearchENOSW(ProductType, FirmwareVersion);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -238,20 +257,10 @@ namespace WPinternals
|
||||
|
||||
UIContext.Post(s =>
|
||||
{
|
||||
if (FFUURL != null)
|
||||
{
|
||||
SearchResultList.Add(new SearchResult(FFUURL, ProductType, FFUDownloaded, null));
|
||||
}
|
||||
|
||||
if (EmergencyURLs != null)
|
||||
{
|
||||
SearchResultList.Add(new SearchResult($"{ProductType} emergency-files", EmergencyURLs, ProductType, EmergencyDownloaded, ProductType));
|
||||
}
|
||||
|
||||
if (SecureWIMURL != null)
|
||||
{
|
||||
SearchResultList.Add(new SearchResult($"{ProductType} ENOSW-files", SecureWIMURL, ProductType, ENOSWDownloaded, FirmwareVersion));
|
||||
}
|
||||
}, null);
|
||||
|
||||
IsSearching = false;
|
||||
@@ -279,9 +288,7 @@ namespace WPinternals
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
string FFUURL = null;
|
||||
string[] EmergencyURLs = null;
|
||||
string SecureWIMURL = null;
|
||||
try
|
||||
{
|
||||
string TempProductType = ProductType.ToUpper();
|
||||
@@ -291,7 +298,6 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
ProductType = TempProductType;
|
||||
FFUURL = LumiaDownloadModel.SearchFFU(ProductType, ProductCode, OperatorCode, out TempProductType);
|
||||
if (TempProductType != null)
|
||||
{
|
||||
ProductType = TempProductType;
|
||||
@@ -301,11 +307,6 @@ namespace WPinternals
|
||||
{
|
||||
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
|
||||
}
|
||||
|
||||
if (ProductType != null && FirmwareVersion != null)
|
||||
{
|
||||
(SecureWIMURL, string _) = LumiaDownloadModel.SearchENOSW(ProductType, FirmwareVersion);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -314,20 +315,10 @@ namespace WPinternals
|
||||
|
||||
UIContext.Post(s =>
|
||||
{
|
||||
if (FFUURL != null)
|
||||
{
|
||||
Download(FFUURL, ProductType, FFUDownloadedAndCheckSupported, null);
|
||||
}
|
||||
|
||||
if (EmergencyURLs != null)
|
||||
{
|
||||
Download(EmergencyURLs, ProductType, EmergencyDownloaded, ProductType);
|
||||
}
|
||||
|
||||
if (SecureWIMURL != null)
|
||||
{
|
||||
Download(SecureWIMURL, ProductType, ENOSWDownloaded, FirmwareVersion);
|
||||
}
|
||||
}, null);
|
||||
}).Start();
|
||||
}
|
||||
@@ -340,23 +331,6 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
|
||||
private void FFUDownloaded(string[] Files, object State)
|
||||
{
|
||||
App.Config.AddFfuToRepository(Files[0]);
|
||||
}
|
||||
|
||||
private void FFUDownloadedAndCheckSupported(string[] Files, object State)
|
||||
{
|
||||
App.Config.AddFfuToRepository(Files[0]);
|
||||
|
||||
if (!App.Config.FFURepository.Any(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)))
|
||||
{
|
||||
const string ProductType2 = "RM-1085";
|
||||
string URL = LumiaDownloadModel.SearchFFU(ProductType2, null, null);
|
||||
Download(URL, ProductType2, FFUDownloaded, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void EmergencyDownloaded(string[] Files, object State)
|
||||
{
|
||||
string Type = (string)State;
|
||||
@@ -382,11 +356,6 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
|
||||
private void ENOSWDownloaded(string[] Files, object State)
|
||||
{
|
||||
App.Config.AddSecWimToRepository(Files[0], (string)State);
|
||||
}
|
||||
|
||||
public ObservableCollection<DownloadEntry> DownloadList { get; } = [];
|
||||
public ObservableCollection<SearchResult> SearchResultList { get; } = [];
|
||||
|
||||
@@ -683,6 +652,7 @@ namespace WPinternals
|
||||
}
|
||||
}
|
||||
public DelegateCommand AddFFUCommand { get; } = null;
|
||||
public DelegateCommand AddSecWIMCommand { get; } = null;
|
||||
}
|
||||
|
||||
internal enum DownloadStatus
|
||||
|
||||
@@ -28,7 +28,6 @@ using System.Threading.Tasks;
|
||||
using WPinternals.Config;
|
||||
using WPinternals.HelperClasses;
|
||||
using WPinternals.Models.Lumia.UEFI;
|
||||
using WPinternals.Models.UEFIApps;
|
||||
using WPinternals.Models.UEFIApps.BootMgr;
|
||||
using WPinternals.Models.UEFIApps.Flash;
|
||||
using WPinternals.Models.UEFIApps.PhoneInfo;
|
||||
|
||||
@@ -24,10 +24,8 @@ using System.Diagnostics.Eventing.Reader;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using WPinternals.HelperClasses;
|
||||
using WPinternals.Models.Lumia;
|
||||
using WPinternals.Models.Lumia.NCSd;
|
||||
using WPinternals.Models.Lumia.UEFI;
|
||||
using WPinternals.Models.UEFIApps;
|
||||
using WPinternals.Models.UEFIApps.BootMgr;
|
||||
using WPinternals.Models.UEFIApps.Flash;
|
||||
using WPinternals.Models.UEFIApps.PhoneInfo;
|
||||
|
||||
@@ -25,10 +25,8 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using WPinternals.HelperClasses;
|
||||
using WPinternals.Models.Lumia;
|
||||
using WPinternals.Models.Lumia.MSR;
|
||||
using WPinternals.Models.Lumia.NCSd;
|
||||
using WPinternals.Models.Lumia.UEFI;
|
||||
using WPinternals.Models.UEFIApps;
|
||||
using WPinternals.Models.UEFIApps.BootMgr;
|
||||
using WPinternals.Models.UEFIApps.Flash;
|
||||
using WPinternals.Models.UEFIApps.PhoneInfo;
|
||||
@@ -761,21 +759,7 @@ namespace WPinternals
|
||||
PhoneInfoAppInfo.Type = "RM-1151";
|
||||
}
|
||||
|
||||
(string ENOSWFileUrl, string DPLFileUrl) = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
|
||||
|
||||
UIContext?.Post(d => SetWorkingStatus($"Downloading {PhoneInfoAppInfo.Type} Test Mode package...", MaxProgressValue: 100), null);
|
||||
|
||||
DownloadEntry downloadEntry = new(ENOSWFileUrl, TempFolder, [ENOSWFileUrl], ENOSWDownloadCompleted, Info.Firmware);
|
||||
|
||||
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
||||
{
|
||||
if (e.PropertyName == "Progress")
|
||||
{
|
||||
int progress = (sender as DownloadEntry)?.Progress ?? 0;
|
||||
ulong.TryParse(progress.ToString(), out ulong progressret);
|
||||
UIContext?.Post(d => UpdateWorkingStatus(null, CurrentProgressValue: progressret), null);
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
@@ -875,21 +859,7 @@ namespace WPinternals
|
||||
PhoneInfoAppInfo.Type = "RM-1151";
|
||||
}
|
||||
|
||||
(string ENOSWFileUrl, string DPLFileUrl) = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
|
||||
|
||||
UIContext?.Post(d => SetWorkingStatus($"Downloading {PhoneInfoAppInfo.Type} Test Mode package...", MaxProgressValue: 100), null);
|
||||
|
||||
DownloadEntry downloadEntry = new(ENOSWFileUrl, TempFolder, [ENOSWFileUrl], ENOSWDownloadCompleted, Info.Firmware);
|
||||
|
||||
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
||||
{
|
||||
if (e.PropertyName == "Progress")
|
||||
{
|
||||
int progress = (sender as DownloadEntry)?.Progress ?? 0;
|
||||
ulong.TryParse(progress.ToString(), out ulong progressret);
|
||||
UIContext?.Post(d => UpdateWorkingStatus(null, CurrentProgressValue: progressret), null);
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user