mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-14 03:16:40 +10:00
Various Fixes
This commit is contained in:
@@ -52,8 +52,7 @@ namespace WPinternals
|
||||
byte[] RootKeyHash = null;
|
||||
if (PhoneNotifier.CurrentInterface == PhoneInterfaces.Qualcomm_Download)
|
||||
{
|
||||
QualcommDownload Download2 = new((QualcommSerial)PhoneNotifier.CurrentModel);
|
||||
RootKeyHash = Download2.GetRKH();
|
||||
RootKeyHash = new QualcommDownload((QualcommSerial)PhoneNotifier.CurrentModel).GetRKH();
|
||||
}
|
||||
|
||||
List<QualcommPartition> PossibleLoaders = null;
|
||||
@@ -76,6 +75,7 @@ namespace WPinternals
|
||||
|
||||
QualcommSerial Serial = (QualcommSerial)PhoneNotifier.CurrentModel;
|
||||
QualcommDownload Download = new(Serial);
|
||||
|
||||
if (Download.IsAlive())
|
||||
{
|
||||
int Attempt = 1;
|
||||
|
||||
@@ -413,6 +413,16 @@ namespace WPinternals
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,6 +821,16 @@ namespace WPinternals
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
await SwitchModeViewModel.SwitchToWithStatus(Notifier, PhoneInterfaces.Lumia_Flash, SetWorkingStatus, UpdateWorkingStatus);
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1478,6 +1498,16 @@ namespace WPinternals
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
await SwitchModeViewModel.SwitchToWithStatus(Notifier, PhoneInterfaces.Lumia_Flash, SetWorkingStatus, UpdateWorkingStatus);
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
}
|
||||
|
||||
// phone is in flash mode, we can exit
|
||||
@@ -1725,14 +1755,17 @@ namespace WPinternals
|
||||
await SwitchModeViewModel.SwitchToWithStatus(Notifier, PhoneInterfaces.Lumia_Flash, SetWorkingStatus, UpdateWorkingStatus);
|
||||
}
|
||||
|
||||
if ((Notifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) && (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash))
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
SetWorkingStatus("Flashing...", "The phone may reboot a couple of times. Just wait for it.", null, Status: WPinternalsStatus.Initializing);
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
SetWorkingStatus("Flashing...", "The phone may reboot a couple of times. Just wait for it.", null, Status: WPinternalsStatus.Initializing);
|
||||
|
||||
List<FlashPart> FlashParts = [];
|
||||
|
||||
@@ -1871,12 +1904,19 @@ namespace WPinternals
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Flash)
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await LumiaFlashParts(Notifier, FFUPath, false, false, null, DoResetFirst, ClearFlashingStatusAtEnd: true, ShowProgress: false);
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
await LumiaFlashParts(Notifier, FFUPath, false, false, null, DoResetFirst, ClearFlashingStatusAtEnd: true, ShowProgress: false);
|
||||
}
|
||||
|
||||
LogFile.Log("Phone is relocked", LogType.FileAndConsole);
|
||||
@@ -2265,6 +2305,17 @@ namespace WPinternals
|
||||
|
||||
SetWorkingStatus("Problem detected, rolling back...", ErrorMessage);
|
||||
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
Parts = [];
|
||||
|
||||
// Restore original GPT, which will also reference the original NV.
|
||||
@@ -2495,6 +2546,16 @@ namespace WPinternals
|
||||
{
|
||||
SetWorkingStatus("Rebooting phone...");
|
||||
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1564,8 +1564,22 @@ namespace WPinternals
|
||||
break;
|
||||
}
|
||||
|
||||
// In case we are on an Engineering phone which isn't stuck in flashmode and booted to BootMgrApp
|
||||
((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
if (Notifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader)
|
||||
{
|
||||
// In case we are on an Engineering phone which isn't stuck in flashmode and booted to BootMgrApp
|
||||
((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
await Notifier.WaitForArrival();
|
||||
}
|
||||
}
|
||||
|
||||
if (Notifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||
{
|
||||
throw new WPinternalsException("Unexpected Mode");
|
||||
}
|
||||
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).DisableRebootTimeOut();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,7 @@ namespace WPinternals
|
||||
|
||||
try
|
||||
{
|
||||
LumiaFlashAppModel Model = (LumiaFlashAppModel)Notifier.CurrentModel;
|
||||
LumiaFlashAppPhoneInfo Info = Model.ReadPhoneInfo();
|
||||
LumiaFlashAppPhoneInfo Info = ((LumiaFlashAppModel)Notifier.CurrentModel).ReadPhoneInfo();
|
||||
|
||||
if ((Info.SecureFfuSupportedProtocolMask & ((ushort)FfuProtocol.ProtocolSyncV2)) == 0) // Exploit needs protocol v2 -> This check is not conclusive, because old phones also report support for this protocol, although it is really not supported.
|
||||
{
|
||||
@@ -443,7 +442,7 @@ namespace WPinternals
|
||||
LogFile.Log("Flash in progress...", LogType.ConsoleOnly);
|
||||
SetWorkingStatus("Flashing...", null, (UInt64?)payloads.Length, Status: WPinternalsStatus.Flashing);
|
||||
|
||||
Model.SendFfuHeaderV1(FfuHeader, Options);
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).SendFfuHeaderV1(FfuHeader, Options);
|
||||
|
||||
UInt64 counter = 0;
|
||||
Int32 numberOfPayloadsToSendAtOnce = 1;
|
||||
@@ -485,24 +484,25 @@ namespace WPinternals
|
||||
|
||||
if ((Info.SecureFfuSupportedProtocolMask & (ushort)FfuProtocol.ProtocolSyncV2) != 0)
|
||||
{
|
||||
Model.SendFfuPayloadV2(payloadBuffer, Int32.Parse((counter * 100 / (UInt64)payloads.Length).ToString()));
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).SendFfuPayloadV2(payloadBuffer, Int32.Parse((counter * 100 / (UInt64)payloads.Length).ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.SendFfuPayloadV1(payloadBuffer, Int32.Parse((counter * 100 / (UInt64)payloads.Length).ToString()));
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).SendFfuPayloadV1(payloadBuffer, Int32.Parse((counter * 100 / (UInt64)payloads.Length).ToString()));
|
||||
}
|
||||
|
||||
UpdateWorkingStatus(ProgressText, null, counter, WPinternalsStatus.Flashing);
|
||||
}
|
||||
|
||||
Model.ResetPhone();
|
||||
((LumiaFlashAppModel)Notifier.CurrentModel).ResetPhone();
|
||||
|
||||
await Notifier.WaitForRemoval();
|
||||
|
||||
ExitSuccess("Flash succeeded!", null);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogFile.Log(ex.Message);
|
||||
throw new WPinternalsException("Custom flash failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,34 +87,6 @@ namespace WPinternals
|
||||
internal SwitchModeViewModel(PhoneNotifierViewModel PhoneNotifier, PhoneInterfaces? TargetMode, ModeSwitchProgressHandler ModeSwitchProgress, ModeSwitchErrorHandler ModeSwitchError, ModeSwitchSuccessHandler ModeSwitchSuccess, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null)
|
||||
: base()
|
||||
{
|
||||
if ((PhoneNotifier.CurrentInterface == PhoneInterfaces.Lumia_Bootloader) && (TargetMode == PhoneInterfaces.Lumia_Flash))
|
||||
{
|
||||
LumiaBootManagerPhoneInfo Info = ((LumiaBootManagerAppModel)PhoneNotifier.CurrentModel).ReadPhoneInfo(false);
|
||||
if (Info.BootManagerProtocolVersionMajor >= 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
// The implementation of SwitchToFlashAppContext() is improved
|
||||
// SwitchToFlashAppContext() should only be used with BootMgr v2
|
||||
// For switching from BootMgr to FlashApp, it will use NOKS
|
||||
// That will switch to a charging state, whereas a normal context switch will not start charging
|
||||
// The implementation of NOKS in BootMgr mode has changed in BootMgr v2
|
||||
// It does not disconnect / reconnect anymore and the apptype is changed immediately
|
||||
// NOKS still doesnt return a status
|
||||
// BootMgr v1 uses normal NOKS and waits for arrival of FlashApp
|
||||
((LumiaBootManagerAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext();
|
||||
|
||||
// But this was called as a real switch, so we will raise an arrival event.
|
||||
PhoneNotifier.CurrentInterface = PhoneInterfaces.Lumia_Flash;
|
||||
PhoneNotifier.NotifyArrival();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogFile.LogException(ex, LogType.FileOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PhoneNotifier.CurrentInterface == TargetMode)
|
||||
{
|
||||
ModeSwitchSuccess(PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface);
|
||||
|
||||
Reference in New Issue
Block a user